IRC logs for #openttd.dev on OFTC at 2013-03-16
⏴ go to previous day
03:43:19 *** Dewin has joined #openttd.dev
08:18:45 *** Meechmunchie has joined #openttd.dev
08:27:09 *** Alberth has joined #openttd.dev
08:27:09 *** ChanServ sets mode: +v Alberth
08:57:00 *** fonsinchen has joined #openttd.dev
08:57:00 *** ChanServ sets mode: +v fonsinchen
10:59:53 *** frosch123 has joined #openttd.dev
10:59:53 *** ChanServ sets mode: +v frosch123
11:49:49 *** Ristovski has joined #openttd.dev
11:59:04 <fonsinchen> I've changed the link graph internals again, providing more intuitive (and different) APIs for component handlers and the main game.
11:59:40 <fonsinchen> However, due to certain architectural decisions I cannot return references from operator* of Edge and Node iterators.
12:00:18 <fonsinchen> Instead a wrapper object which allows some operations on the real edge or node (provided as pointer) is returned as value.
12:00:55 <fonsinchen> That is somewhat against the spirit of operator* and it prevents an implementation of operator->.
12:01:25 <fonsinchen> So you cannot do i->DoSomething(), but only (*i).DoSomething()
12:01:50 <fonsinchen> Is such a thing acceptable by our coding standard?
12:02:52 <frosch123> i doubt there are many operator* in ottd :üp
12:03:10 <frosch123> anyway, personally i have implementend operator* without refercenes multiple times
12:03:23 <frosch123> with some wrapper class you can also implement -> btw.
12:03:52 <fonsinchen> Only works if I can actually return a pointer. However, as the object is a temporary, I can't.
12:04:17 <frosch123> yes, thus the returned wrapper class has to contain a temporary copy
12:04:54 <fonsinchen> Of what? How would I do that?
12:05:01 <frosch123> class Foobar : public T { public: T* operator->() { return this; } };
12:05:07 <frosch123> instead of returning T*, return Foobar
12:05:31 <frosch123> which holds a temporary object of T
12:06:04 <frosch123> since -> is chained, using -> on your original class will chain into Foobar::->
12:07:37 <fonsinchen> So, FooBar is some iterator. FooBar::operator* would return a T, right?
12:08:05 <frosch123> no, Foobar is only wrapper returned by your original operator->
12:08:23 <frosch123> you will never have access to it directly
12:08:43 <frosch123> since you only get it via ooperator-> which immediately chains to T*
12:09:06 <fonsinchen> Thanks for the hint.
12:09:31 <frosch123> anyway, it's not too bad to just skip operator-> to force people to store the result of operator* locally to access members multiple times
12:09:46 <frosch123> instead of using -> and doing a temporary copy on every access
12:11:14 <fonsinchen> The compiler would optimize that out due to common subexpression most of the time.
12:11:51 <fonsinchen> At least I hope so. Otherwise the whole thing I'm doing there is a big hit on performance anyway ...
12:12:33 <frosch123> i would consider the decision that construction of a temporary object has no side effects very hard
12:12:40 <frosch123> so, i doubt it will optimise it
12:12:58 <frosch123> maybe if the object is POD
12:14:16 <fonsinchen> It doesn't do anything in its constructor.
12:15:52 <fonsinchen> The object consists only of pointers to the actual data, providing some methods for manipulating it.
12:16:35 <frosch123> well, check the disassembly in the debugger to be sure :)
12:17:11 <frosch123> damn... where is the code to scroll the main viewport with cursor keys :o
12:17:59 <fonsinchen> Maybe I'll just profile the two versions against each other to see if there's a significant difference.
12:18:53 <frosch123> wow... there is a special _dirkeys
12:27:46 <Alberth> amazing what you find when look at random code :)
12:30:15 <frosch123> hmm, so i think i fixed fs#5504 :) except it's only for sdl and does not work for the keypad comma/delete key :)
12:30:22 <frosch123> is that good enough? :p
12:33:42 <frosch123> so, how to distinguish whether stuff wants to test for the delete key, or for the numpad-delete hotkey? :s
12:34:32 <frosch123> in the former case i want to map the key to ","/delete, in the latter case to something third
12:40:30 <fonsinchen> The delete key should be equivalent to numpad-delete if numlock is off.
12:40:49 <fonsinchen> otherwise it should be equivalent to comma.
12:43:23 <fonsinchen> You shouldn't be able to configure numpad-delete and "normal" delete or numpad-comma and "normal" comma separately, I think.
12:43:32 <fonsinchen> It will just confuse people.
12:52:27 <frosch123> i think sdl already solved the issue
12:52:41 <frosch123> it's just ottd which messes up the difference between characters and scancodes again
12:53:35 <frosch123> hotkeys go by scancode
12:53:41 <frosch123> textediting goes by character
12:54:03 <frosch123> while characters include stuff like enter and cursors
14:54:11 <fonsinchen> The branch with the new version of the link graph API is "linkgraph8", btw. It needs some polish, but the functionality is there.
18:47:29 *** Meechmunchie has joined #openttd.dev
19:24:19 *** Dewin has joined #openttd.dev
19:47:03 *** Supercheese has joined #openttd.dev
22:28:26 *** FLHerne has joined #openttd.dev
22:37:21 *** Alberth has left #openttd.dev
continue to next day ⏵