equal
deleted
inserted
replaced
20 #include "table/landscape_const.h" |
20 #include "table/landscape_const.h" |
21 #include "table/control_codes.h" |
21 #include "table/control_codes.h" |
22 #include "music.h" |
22 #include "music.h" |
23 #include "date.h" |
23 #include "date.h" |
24 #include "industry.h" |
24 #include "industry.h" |
|
25 #include "helpers.hpp" |
25 |
26 |
26 #ifdef WIN32 |
27 #ifdef WIN32 |
27 /* for opendir/readdir/closedir */ |
28 /* for opendir/readdir/closedir */ |
28 # include "fios.h" |
29 # include "fios.h" |
29 #else |
30 #else |
749 case SCC_CARGO: { // {CARGO} |
750 case SCC_CARGO: { // {CARGO} |
750 // Layout now is: |
751 // Layout now is: |
751 // 8bit - cargo type |
752 // 8bit - cargo type |
752 // 16-bit - cargo count |
753 // 16-bit - cargo count |
753 CargoID cargo = GetInt32(&argv); |
754 CargoID cargo = GetInt32(&argv); |
754 StringID cargo_str = (cargo == CT_INVALID) ? STR_8838_N_A : _cargoc.names_long[cargo]; |
755 StringID cargo_str = (cargo == CT_INVALID) ? (StringID)STR_8838_N_A : _cargoc.names_long[cargo]; |
755 buff = GetStringWithArgs(buff, cargo_str, argv++, last); |
756 buff = GetStringWithArgs(buff, cargo_str, argv++, last); |
756 break; |
757 break; |
757 } |
758 } |
758 |
759 |
759 case SCC_POWER: { // {POWER} |
760 case SCC_POWER: { // {POWER} |
1137 char **langpack_offs; |
1138 char **langpack_offs; |
1138 char *s; |
1139 char *s; |
1139 |
1140 |
1140 { |
1141 { |
1141 char *lang = str_fmt("%s%s", _paths.lang_dir, _dynlang.ent[lang_index].file); |
1142 char *lang = str_fmt("%s%s", _paths.lang_dir, _dynlang.ent[lang_index].file); |
1142 lang_pack = ReadFileToMem(lang, &len, 200000); |
1143 lang_pack = (LanguagePack*)ReadFileToMem(lang, &len, 200000); |
1143 free(lang); |
1144 free(lang); |
1144 } |
1145 } |
1145 if (lang_pack == NULL) return false; |
1146 if (lang_pack == NULL) return false; |
1146 if (len < sizeof(LanguagePack) || |
1147 if (len < sizeof(LanguagePack) || |
1147 lang_pack->ident != TO_LE32(LANGUAGE_PACK_IDENT) || |
1148 lang_pack->ident != TO_LE32(LANGUAGE_PACK_IDENT) || |
1163 _langtab_num[i] = num; |
1164 _langtab_num[i] = num; |
1164 tot_count += num; |
1165 tot_count += num; |
1165 } |
1166 } |
1166 |
1167 |
1167 // Allocate offsets |
1168 // Allocate offsets |
1168 langpack_offs = malloc(tot_count * sizeof(*langpack_offs)); |
1169 MallocT(&langpack_offs, tot_count); |
1169 |
1170 |
1170 // Fill offsets |
1171 // Fill offsets |
1171 s = lang_pack->data; |
1172 s = lang_pack->data; |
1172 for (i = 0; i != tot_count; i++) { |
1173 for (i = 0; i != tot_count; i++) { |
1173 len = (byte)*s; |
1174 len = (byte)*s; |
1227 |
1228 |
1228 dir = opendir(_paths.lang_dir); |
1229 dir = opendir(_paths.lang_dir); |
1229 if (dir != NULL) { |
1230 if (dir != NULL) { |
1230 while ((dirent = readdir(dir)) != NULL) { |
1231 while ((dirent = readdir(dir)) != NULL) { |
1231 const char *d_name = FS2OTTD(dirent->d_name); |
1232 const char *d_name = FS2OTTD(dirent->d_name); |
1232 char *t = strrchr(d_name, '.'); |
1233 const char *t = strrchr(d_name, '.'); |
1233 |
1234 |
1234 if (t != NULL && strcmp(t, ".lng") == 0) { |
1235 if (t != NULL && strcmp(t, ".lng") == 0) { |
1235 languages[num++] = strdup(d_name); |
1236 languages[num++] = strdup(d_name); |
1236 if (num == max) break; |
1237 if (num == max) break; |
1237 } |
1238 } |