The International Simutrans Forum

Development => Patches & Projects => Incorporated Patches and Solved Bug Reports => Topic started by: neroden on June 18, 2010, 07:48:07 PM

Title: [cleanup patch]: get_nummer -> get_number & conversion warning squelch
Post by: neroden on June 18, 2010, 07:48:07 PM
I know it's bad form to do two things at once.  However, I translated all instances of "get_nummer" to "get_number" while trying to find the source of one of the integer narrowing warnings (in besch/bildliste_besch.h).  The source turned out to be something else -- the constant IMG_LEER in simimg.h needs to be typed.  I did this with parentheses and a typecast; one could also do it with a C++ constant, but I figured that might have odd results in a header file outside anything.
Title: Re: [cleanup patch]: get_nummer -> get_number & conversion warning squelch
Post by: neroden on June 29, 2010, 04:58:35 AM
OK, maintainers, any thoughts?  I'm not sure what the views are on translation patches.  I can separate out the conversion warning fix, or I can convert it to a C++ constant instead of a macro with a typecast.
Title: Re: [cleanup patch]: get_nummer -> get_number & conversion warning squelch
Post by: prissi on June 29, 2010, 11:37:19 AM
many of those get_number would be anyway better get_bild_nr() ...
Title: Re: [cleanup patch]: get_nummer -> get_number & conversion warning squelch
Post by: neroden on July 02, 2010, 05:52:44 PM
Quote from: prissi on June 29, 2010, 11:37:19 AM
many of those get_number would be anyway better get_bild_nr() ...

OK!  I'll try to work out exactly how to convert that.  Most of them look like

bild = (something);
return bild ? bild->get_number() : IMG_LEER;

I guess these could be replaced with get_bild_nr() ?

Thoughts on the conversion warning fix?  This is the patch for that:

diff --git a/simimg.h b/simimg.h
index 2b323c7..0572590 100644
--- a/simimg.h
+++ b/simimg.h
@@ -15,10 +15,10 @@

#include "simtypes.h"

-#define IMG_LEER         0xFFFF
-
typedef uint16 image_id;

+#define IMG_LEER        ( (image_id) 0xFFFF )
+
// spezielle gebaeude

#endif


It looks a little ugly; I could do it like this:

static const image_id IMG_LEER = 0xFFFF;

This is prettier.  I think this will work, but I'm not 100% sure *all* our C++ compilers will treat that as a constant.

And I just realized that "IMG_LEER" needs to be translated too.  But I'm not sure how to translate it; I can see several possible translations:

IMG_FREE
IMG_BLANK
IMG_EMPTY
NO_IMG

Thanks for the feedback.  I'll try to come up with a new patch after getting more feedback.  :-)
Title: Re: [cleanup patch]: get_nummer -> get_number & conversion warning squelch
Post by: neroden on July 10, 2010, 03:53:25 PM
Quote from: neroden on July 02, 2010, 05:52:44 PM
And I just realized that "IMG_LEER" needs to be translated too.  But I'm not sure how to translate it; I can see several possible translations:

IMG_FREE
IMG_BLANK
IMG_EMPTY
NO_IMG

OK, asking again, what do people think?  What is the best translation of IMG_LEER?
Title: Re: [cleanup patch]: get_nummer -> get_number & conversion warning squelch
Post by: jamespetts on July 10, 2010, 04:22:21 PM
I like "NO_IMG", and think that "IMAGE_BLANK" is a close second.