News:

Congratulations!
 You've won the News Item Lottery! Your prize? Reading this news item! :)

[cleanup patch]: get_nummer -> get_number & conversion warning squelch

Started by neroden, June 18, 2010, 07:48:07 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

neroden

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.

neroden

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.

prissi

many of those get_number would be anyway better get_bild_nr() ...

neroden

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.  :-)

neroden

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?

jamespetts

I like "NO_IMG", and think that "IMAGE_BLANK" is a close second.
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.