The International Simutrans Forum

Development => Patches & Projects => Incorporated Patches and Solved Bug Reports => Topic started by: eipi on October 19, 2013, 08:40:15 PM

Title: Code cleanup: Use obj_besch_timelined::is_available()
Post by: eipi on October 19, 2013, 08:40:15 PM
Hi,

here's a small patch adding an is_available() method to obj_besch_timelined_t, and crossing_besch_t is now derived from obj_besch_timelined_t.
This should reduce code duplication in a lot of places.
Title: Re: Code cleanup: Use obj_besch_timelined::is_available()
Post by: kierongreen on October 19, 2013, 08:51:08 PM
Looks good :)
Title: Re: Code cleanup: Use obj_besch_timelined::is_available()
Post by: prissi on October 19, 2013, 08:53:43 PM
Indeed, looks fine. Please use double space for && || etc. in if/while/for ...
Title: Re: Code cleanup: Use obj_besch_timelined::is_available()
Post by: kierongreen on October 19, 2013, 09:52:08 PM
Committing with minor changes to formatting (actually lines in this patch mainly had double spaces it was several around that I noticed).

Edit: Or would have if I could get trunk to compile to test...

Edit2: Attached patch which may (or may not) work as I can't test currently.
Title: Re: Code cleanup: Use obj_besch_timelined::is_available()
Post by: Ters on October 19, 2013, 10:47:15 PM
Quote from: kierongreen on October 19, 2013, 09:52:08 PM
Committing with minor changes to formatting (actually lines in this patch mainly had double spaces it was several around that I noticed).

Edit: Or would have if I could get trunk to compile to test...

Edit2: Attached patch which may (or may not) work as I can't test currently.

My eyes for details report that there is still inconsistent use of spaces in your patch (by that I mean in modified lines, not old code). Not that I care much about that.
Title: Re: Code cleanup: Use obj_besch_timelined::is_available()
Post by: kierongreen on October 19, 2013, 11:05:38 PM
Quote from: Ters on October 19, 2013, 10:47:15 PM
My eyes for details report that there is still inconsistent use of spaces in your patch (by that I mean in modified lines, not old code). Not that I care much about that.

Well one problem is this:
Do not forget brackets along comparisons and use double spaces around
logical operators. Avoid spaces before the comparison operator:
Quoteif((i&3)==1   &&  ptr==NULL) {

You may also use double spaces after/before the brackets:
if(  (i&3)==1   &&  ptr==NULL  ) {

No space between if/while/for and bracket is allowed.
Which is not consistent with the frequent use of padding comparison operators with single spaces. I tried correcting some but really it would need a far bigger tidy to get them all.
Title: Re: Code cleanup: Use obj_besch_timelined::is_available()
Post by: eipi on October 20, 2013, 09:06:21 AM
Patch updated to r6833. I think I have found and fixed all the wrong whitespace in the last patch.  :)
Title: Re: Code cleanup: Use obj_besch_timelined::is_available()
Post by: kierongreen on October 20, 2013, 09:55:59 AM
Committed in 6834 many thanks.