Skip to content

Commit fca5318

Browse files
committed
Remove static variable String_table_size
1 parent 77bb924 commit fca5318

File tree

7 files changed

+5
-23
lines changed

7 files changed

+5
-23
lines changed

Descent3/localization.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ namespace {
118118
// Assume that we on English locale
119119
int Localization_language = LANGUAGE_ENGLISH;
120120

121-
int String_table_size = 0;
122121
std::vector<std::string> String_table;
123122

124123
// list of the string table files, they will be loaded in the order they are listed
@@ -175,8 +174,6 @@ int LoadStringTables() {
175174
}
176175
}
177176

178-
String_table_size = 0;
179-
180177
String_table = std::vector<std::string>(string_count);
181178

182179
int runcount = 0;
@@ -199,11 +196,10 @@ int LoadStringTables() {
199196
return 0;
200197
}
201198

202-
String_table_size = runcount;
203199
Localization_language = old_language;
204200

205201
atexit(FreeStringTables);
206-
return String_table_size;
202+
return runcount;
207203
}
208204

209205
// Deallocates all the memory used for the string tables
@@ -212,7 +208,7 @@ void FreeStringTables() {
212208
}
213209

214210
const char *GetStringFromTable(int index) {
215-
if ((index < 0) || (index >= String_table_size))
211+
if ((index < 0) || (index >= String_table.size()))
216212
return Error_string;
217213

218214
if (String_table[index].empty())

scripts/AIGame.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ DLLEXPORT int STDCALL SaveRestoreState(void *file_ptr, uint8_t saving_state);
4545
}
4646
#endif
4747

48-
static int String_table_size = 0;
4948
static std::vector<std::string> String_table;
5049
static const char *_Error_string = "!!ERROR MISSING STRING!!";
5150
static const char *_Empty_string = "";
@@ -2471,7 +2470,6 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) {
24712470
return 0;
24722471
}
24732472
aigame_mod_id = func_list->module_identifier;
2474-
String_table_size = func_list->string_count;
24752473
String_table = func_list->string_table;
24762474

24772475
return 1;

scripts/AIGame3.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ DLLEXPORT int STDCALL SaveRestoreState(void *file_ptr, uint8_t saving_state);
4646
}
4747
#endif
4848

49-
static int String_table_size = 0;
5049
static std::vector<std::string> String_table;
5150
static const char *_Error_string = "!!ERROR MISSING STRING!!";
5251
static const char *_Empty_string = "";
@@ -1493,7 +1492,6 @@ void DoNameLookups(void) {
14931492
// Returns 1 if initialization went ok, 0 if there was an error and the DLL should not be loaded.
14941493
char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) {
14951494
osicommon_Initialize((tOSIRISModuleInit *)func_list);
1496-
String_table_size = func_list->string_count;
14971495
String_table = func_list->string_table;
14981496

14991497
// Do name lookups

scripts/aigame2.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ DLLEXPORT int STDCALL SaveRestoreState(void *file_ptr, uint8_t saving_state);
4545
}
4646
#endif
4747

48-
static int String_table_size = 0;
4948
static std::vector<std::string> String_table;
5049
static const char *_Error_string = "!!ERROR MISSING STRING!!";
5150
static const char *_Empty_string = "";
@@ -262,7 +261,6 @@ class aiSTBlackBarrel : public aiObjScript {
262261
// Returns 1 if initialization went ok, 0 if there was an error and the DLL should not be loaded.
263262
char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) {
264263
osicommon_Initialize((tOSIRISModuleInit *)func_list);
265-
String_table_size = func_list->string_count;
266264
String_table = func_list->string_table;
267265
if (func_list->game_checksum != CHECKSUM) {
268266
mprintf(0, "Game-Checksum FAIL!!! (%ul!=%ul)\n", func_list->game_checksum, CHECKSUM);

scripts/aigame4.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,11 @@ DLLEXPORT int STDCALL SaveRestoreState(void *file_ptr, uint8_t saving_state);
4444
}
4545
#endif
4646

47-
int String_table_size = 0;
4847
std::vector<std::string> String_table;
4948
static const char *_Error_string = "!!ERROR MISSING STRING!!";
5049
static const char *_Empty_string = "";
5150
const char *GetStringFromTable(int index) {
52-
if ((index < 0) || (index >= String_table_size))
51+
if ((index < 0) || (index >= String_table.size()))
5352
return _Error_string;
5453
if (String_table[index].empty())
5554
return _Empty_string;
@@ -303,7 +302,6 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) {
303302
return 0;
304303
}
305304
aigame_mod_id = func_list->module_identifier;
306-
String_table_size = func_list->string_count;
307305
String_table = func_list->string_table;
308306

309307
return 1;

scripts/clutter.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ DLLEXPORT int STDCALL SaveRestoreState(void *file_ptr, uint8_t saving_state);
4343
}
4444
#endif
4545

46-
static int String_table_size = 0;
4746
static std::vector<std::string> String_table;
4847
static const char *_Error_string = "!!ERROR MISSING STRING!!";
4948
static const char *_Empty_string = "";
@@ -143,7 +142,6 @@ class LavaRock : public ClutterScript {
143142
// Returns 1 if initialization went ok, 0 if there was an error and the DLL should not be loaded.
144143
char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) {
145144
osicommon_Initialize((tOSIRISModuleInit *)func_list);
146-
String_table_size = func_list->string_count;
147145
String_table = func_list->string_table;
148146
if (func_list->game_checksum != CHECKSUM) {
149147
mprintf(0, "Game-Checksum FAIL!!! (%ul!=%ul)\n", func_list->game_checksum, CHECKSUM);

scripts/generic.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ DLLEXPORT int STDCALL SaveRestoreState(void *file_ptr, uint8_t saving_state);
4343
}
4444
#endif
4545

46-
int String_table_size = 0;
4746
std::vector<std::string> String_table;
4847
static const char *_Error_string = "!!ERROR MISSING STRING!!";
4948
static const char *_Empty_string = "";
@@ -152,14 +151,11 @@ char STDCALL InitializeDLL(tOSIRISModuleInit *func_list) {
152151
return 0;
153152
}
154153

155-
String_table_size = func_list->string_count;
156154
String_table = func_list->string_table;
157155

158-
int i;
159-
160156
// initialize rapid fire script data
161-
for (i = 0; i < MAX_PLAYERS; i++) {
162-
RapidFirePlayerTimers[i].timer_handle = -1;
157+
for (auto & RapidFirePlayerTimer : RapidFirePlayerTimers) {
158+
RapidFirePlayerTimer.timer_handle = -1;
163159
}
164160

165161
return 1;

0 commit comments

Comments
 (0)