diff options
author | peter1138 <peter1138@openttd.org> | 2007-08-03 09:08:49 +0000 |
---|---|---|
committer | peter1138 <peter1138@openttd.org> | 2007-08-03 09:08:49 +0000 |
commit | 23a46a301e1d5c8d661bf0f823fbf5d29516a692 (patch) | |
tree | b6337974657d183b3d4648de552643ab63470cc7 /src/strgen | |
parent | f95df6bb61f8e04bf146a8ebcd051b7e19820a82 (diff) | |
download | openttd-23a46a301e1d5c8d661bf0f823fbf5d29516a692.tar.xz |
(svn r10762) -Codechange: Change enum StringIDEnum { to static const StringID = for
each STR_ entry. This avoids the need for a cast to StringID in some
places and thus better type-safety.
Diffstat (limited to 'src/strgen')
-rw-r--r-- | src/strgen/strgen.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/strgen/strgen.cpp b/src/strgen/strgen.cpp index c6eaa4466..cfae3814d 100644 --- a/src/strgen/strgen.cpp +++ b/src/strgen/strgen.cpp @@ -1019,19 +1019,20 @@ static void WriteStringsH(const char *filename) out = fopen("tmp.xxx", "w"); if (out == NULL) fatal("can't open tmp.xxx"); - fprintf(out, "enum StringIdEnum {"); + fprintf(out, "/* This file is automatically generated. Do not modify */\n\n"); + fprintf(out, "#ifndef TABLE_STRINGS_H\n"); + fprintf(out, "#define TABLE_STRINGS_H\n"); lastgrp = 0; for (i = 0; i != lengthof(_strings); i++) { if (_strings[i] != NULL) { - fprintf(out, next == i ? "\t%s,\n" : "\n\t%s = 0x%X,\n", _strings[i]->name, i); + if (next != i) fprintf(out, "\n"); + fprintf(out, "static const StringID %s = 0x%X;\n", _strings[i]->name, i); next = i + 1; } } - fprintf(out, "};\n"); - fprintf(out, "\nenum {\n" "\tLANGUAGE_PACK_IDENT = 0x474E414C, // Big Endian value for 'LANG' (LE is 0x 4C 41 4E 47)\n" @@ -1039,6 +1040,8 @@ static void WriteStringsH(const char *filename) "};\n", (uint)_hash ); + fprintf(out, "\n#endif /* TABLE_STRINGS_H */\n"); + fclose(out); if (CompareFiles("tmp.xxx", filename)) { |