Define a new string
Moderator: OpenTTD Developers
Define a new string
with ShowErrorMessage() I want to display a new error message.
But.. how can I create english.lng??
The program says:
2034: WARNING: String name 'STR_5808_ERROR' is invalid (or already used)
2035: WARNING: String STR_5808_ERROR has no definition. Using NULL value
Thanks!
Very good project!
But.. how can I create english.lng??
The program says:
2034: WARNING: String name 'STR_5808_ERROR' is invalid (or already used)
2035: WARNING: String STR_5808_ERROR has no definition. Using NULL value
Thanks!
Very good project!
Stefano
TTDX Configurator Translator
TTDX Configurator Translator
-
- Engineer
- Posts: 26
- Joined: 08 Mar 2004 17:55
- Location: Chomutov (Komotau), Czech Republic
- Contact:
How to define new string.
First, add the string into strings.h and make sure that number value (enums are number values) is not used anywhere else
Second, look into strings.c, where is this table:
You'll have to modify the number which corresponds to the postion of enum you have modified in strings.h. Every number in this array corresponds to number of entries for each enum in strings.h. And don't forget, it is a hex. number!
Third, use the defined string where you want it, then compile program.
Forth, add new strings into english.txt (to the right position, you mustn't have it mixed) and compile with strgen.
First, add the string into strings.h and make sure that number value (enums are number values) is not used anywhere else
Second, look into strings.c, where is this table:
Code: Select all
static const uint16 _lang_pack_num[32] = {
0x33B, 0x11, 0x25, 0x19, 0x5D, 0x11, 0x6D, 0x08,
0x11, 0x3C, 0x2A, 0x08, 0x19, 0x39, 0x80, 0x0,
0x108, 0x6C, 0x38, 0x43, 0x44, 0, 0x6, 0x0,
0,0,0,0,0,0,0,0
};
Third, use the defined string where you want it, then compile program.
Forth, add new strings into english.txt (to the right position, you mustn't have it mixed) and compile with strgen.
May the blessed Czech hands will be with you...
(A nejlepsi je stejne cesky pivo a cesky holky)
(A nejlepsi je stejne cesky pivo a cesky holky)
-
- Engineer
- Posts: 26
- Joined: 08 Mar 2004 17:55
- Location: Chomutov (Komotau), Czech Republic
- Contact:
At the end of file there is:peste1 wrote:But... I can't find _lang_pack_num[32] in strings.c
Code: Select all
bool read_language_pack(const char *filename)
May the blessed Czech hands will be with you...
(A nejlepsi je stejne cesky pivo a cesky holky)
(A nejlepsi je stejne cesky pivo a cesky holky)
I'm sorry... but I'm new using C++
Code: Select all
bool read_language_pack(const char *filename) {
FILE *in;
int tot_count, i;
byte *lang_pack;
size_t len;
byte **langpack_offs;
byte *s;
uint offs;
in = fopen(filename, "rb");
if (in == NULL)
return false;
fseek(in, 0, SEEK_END);
len = ftell(in);
fseek(in, 0, SEEK_SET);
lang_pack = (byte*)malloc(len + 1); // want a traling NUL
if (lang_pack == NULL) {
fclose(in);
return false;
}
lang_pack[len] = 0;
fread(lang_pack, len, 1, in);
fclose(in);
#if defined(TTD_BIG_ENDIAN)
for(i=0; i!=32; i++) {
((uint16*)lang_pack)[i] = READ_LE_UINT16((uint16*)lang_pack + i);
}
#endif
tot_count = 0;
for(i=0; i!=32; i++) {
uint num = ((uint16*)lang_pack)[i];
_langtab_start[i] = tot_count;
_langtab_num[i] = num;
tot_count += num;
}
// Allocate offsets
_langpack_offs = langpack_offs = (byte**)malloc(tot_count * sizeof(byte*));
// Fill offsets
s = lang_pack + 32 * sizeof(uint16);
for(i=0; i!=tot_count; i++) {
langpack_offs[i] = s + sizeof(uint16);
offs = READ_LE_UINT16(s);
s[0] = 0;// This has the effect of zero terminating the string
s += sizeof(uint16) + offs;
}
return true;
}
Stefano
TTDX Configurator Translator
TTDX Configurator Translator
-
- Engineer
- Posts: 26
- Joined: 08 Mar 2004 17:55
- Location: Chomutov (Komotau), Czech Republic
- Contact:
Who is online
Users browsing this forum: No registered users and 33 guests