Skip to content

Commit 72fbff9

Browse files
committed
Change GetStringFromTable() signature
Assuming that index will never be negative, change it to unsigned int.
1 parent 963aedc commit 72fbff9

21 files changed

+40
-40
lines changed

Descent3/localization.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,8 +207,8 @@ void FreeStringTables() {
207207
String_table.clear();
208208
}
209209

210-
const char *GetStringFromTable(int index) {
211-
if ((index < 0) || (index >= String_table.size()))
210+
const char *GetStringFromTable(uint32_t index) {
211+
if (index >= String_table.size())
212212
return Error_string;
213213

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

Descent3/localization.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ void FreeStringTables();
5959

6060
// Returns a pointer to the string at the index location from the string table
6161
// if it is a bad index given, then the pointer to the error string "ERROR MISSING STRING" is given
62-
const char *GetStringFromTable(int index);
62+
const char *GetStringFromTable(uint32_t index);
6363

6464
/**
6565
* Creates table of strings from given filename

Descent3/stringtable.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
// Returns a pointer to the string at the index location from the string table
2727
// if it is a bad index given, then the pointer to the error string "ERROR MISSING STRING" is given
2828

29-
const char *GetStringFromTable(int index);
29+
const char *GetStringFromTable(uint32_t index);
3030

3131
#define TXT_NEW TXT(0) //"New"
3232
#define TXT_DELETE TXT(1) //"Delete"

netgames/coop/coop.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,11 @@ int unpack_pstat(tPlayerStat *user_info, uint8_t *data) {
137137
// localization info
138138
static std::vector<std::string> StringTable;
139139
static const char *_ErrorString = "Missing String";
140-
const char *GetStringFromTable(int d) {
141-
if ((d < 0) || (d >= StringTable.size()))
140+
const char *GetStringFromTable(uint32_t index) {
141+
if (index >= StringTable.size())
142142
return _ErrorString;
143143
else
144-
return StringTable[d].c_str();
144+
return StringTable[index].c_str();
145145
}
146146
///////////////////////////////////////////////
147147
static int SortedPlayers[MAX_PLAYER_RECORDS];

netgames/coop/coopstr.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
// Returns a pointer to the string at the index location from the string table
2727
// if it is a bad index given, then the pointer to the error string "ERROR MISSING STRING" is given
2828

29-
const char *GetStringFromTable(int index);
29+
const char *GetStringFromTable(uint32_t index);
3030

3131
#define TXT_COOP TXT(0) //"Coop"
3232
#define TXT_STATGAMENAME TXT(1) //"Co-op Descent 3"

netgames/entropy/EntropyBase.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,11 +214,11 @@ static void OnPrintScores(int level);
214214
// localization info
215215
static std::vector<std::string> StringTable;
216216
static const char *_ErrorString = "Missing String";
217-
const char *GetStringFromTable(int d) {
218-
if ((d < 0) || (d >= StringTable.size()))
217+
const char *GetStringFromTable(uint32_t index) {
218+
if (index >= StringTable.size())
219219
return _ErrorString;
220220
else
221-
return StringTable[d].c_str();
221+
return StringTable[index].c_str();
222222
}
223223
///////////////////////////////////////////////
224224

netgames/entropy/Entropystr.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
// Returns a pointer to the string at the index location from the string table
2727
// if it is a bad index given, then the pointer to the error string "ERROR MISSING STRING" is given
2828

29-
const char *GetStringFromTable(int index);
29+
const char *GetStringFromTable(uint32_t index);
3030

3131
#define TXT_GAMENAME TXT(0) //"Entropy"
3232
#define TXT_KILLA TXT(1) //"%s was killed by %s"

netgames/hoard/hoard.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -144,11 +144,11 @@ static bool Config_displayed = false;
144144
// localization info
145145
static std::vector<std::string> StringTable;
146146
static const char *_ErrorString = "Missing String";
147-
const char *GetStringFromTable(int d) {
148-
if ((d < 0) || (d >= StringTable.size()))
147+
const char *GetStringFromTable(uint32_t index) {
148+
if (index >= StringTable.size())
149149
return _ErrorString;
150150
else
151-
return StringTable[d].c_str();
151+
return StringTable[index].c_str();
152152
}
153153
///////////////////////////////////////////////
154154

netgames/hoard/hoardstr.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
// Returns a pointer to the string at the index location from the string table
2727
// if it is a bad index given, then the pointer to the error string "ERROR MISSING STRING" is given
2828

29-
const char *GetStringFromTable(int index);
29+
const char *GetStringFromTable(uint32_t index);
3030

3131
#define TXT_DEATH1 TXT(0) //"%s got blasted by %s"
3232
#define TXT_DEATH2 TXT(1) //"%s knows %s is his god"

netgames/hyperanarchy/hyperanarchy.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,11 @@ static void OnClientPlayerEntersGame(int player_num);
113113
// localization info
114114
static std::vector<std::string> StringTable;
115115
static const char *_ErrorString = "Missing String";
116-
const char *GetStringFromTable(int d) {
117-
if ((d < 0) || (d >= StringTable.size()))
116+
const char *GetStringFromTable(uint32_t index) {
117+
if (index >= StringTable.size())
118118
return _ErrorString;
119119
else
120-
return StringTable[d].c_str();
120+
return StringTable[index].c_str();
121121
}
122122
///////////////////////////////////////////////
123123

netgames/hyperanarchy/hyperstr.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
// Returns a pointer to the string at the index location from the string table
2727
// if it is a bad index given, then the pointer to the error string "ERROR MISSING STRING" is given
2828

29-
const char *GetStringFromTable(int index);
29+
const char *GetStringFromTable(uint32_t index);
3030

3131
#define TXT_DEATH1 TXT(0) //"%s got butchered by %s"
3232
#define TXT_SUICIDE1 TXT(1) //"%s shags himself"

netgames/monsterball/monsterball.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -274,11 +274,11 @@ static bool monsterball_info_set = false;
274274
// localization info
275275
static std::vector<std::string> StringTable;
276276
static const char *_ErrorString = "Missing String";
277-
const char *GetStringFromTable(int d) {
278-
if ((d < 0) || (d >= StringTable.size()))
277+
const char *GetStringFromTable(uint32_t index) {
278+
if (index >= StringTable.size())
279279
return _ErrorString;
280280
else
281-
return StringTable[d].c_str();
281+
return StringTable[index].c_str();
282282
}
283283
///////////////////////////////////////////////
284284

netgames/monsterball/monsterstr.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
// Returns a pointer to the string at the index location from the string table
2727
// if it is a bad index given, then the pointer to the error string "ERROR MISSING STRING" is given
2828

29-
const char *GetStringFromTable(int index);
29+
const char *GetStringFromTable(uint32_t index);
3030

3131
#define TXT_GAMENAME TXT(0) //"Monsterball"
3232
#define TXT_KILLEDA TXT(1) //"%s was killed by %s"

netgames/tanarchy/tanarchy.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,11 @@ static int Highlight_bmp = -1;
119119
// localization info
120120
static std::vector<std::string> StringTable;
121121
static const char *_ErrorString = "Missing String";
122-
const char *GetStringFromTable(int d) {
123-
if ((d < 0) || (d >= StringTable.size()))
122+
const char *GetStringFromTable(uint32_t index) {
123+
if (index >= StringTable.size())
124124
return _ErrorString;
125125
else
126-
return StringTable[d].c_str();
126+
return StringTable[index].c_str();
127127
}
128128
///////////////////////////////////////////////
129129

netgames/tanarchy/tanarchystr.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
// Returns a pointer to the string at the index location from the string table
2727
// if it is a bad index given, then the pointer to the error string "ERROR MISSING STRING" is given
2828

29-
const char *GetStringFromTable(int index);
29+
const char *GetStringFromTable(uint32_t index);
3030

3131
#define TXT_DEATH1 TXT(0) //"%s got blasted by %s"
3232
#define TXT_DEATH2 TXT(1) //"%s knows %s is his god"

scripts/AIGame.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ DLLEXPORT int STDCALL SaveRestoreState(void *file_ptr, uint8_t saving_state);
4848
static std::vector<std::string> String_table;
4949
static const char *_Error_string = "!!ERROR MISSING STRING!!";
5050
static const char *_Empty_string = "";
51-
const char *GetStringFromTable(int index) {
52-
if ((index < 0) || (index >= String_table.size()))
51+
const char *GetStringFromTable(uint32_t index) {
52+
if (index >= String_table.size())
5353
return _Error_string;
5454
if (String_table[index].empty())
5555
return _Empty_string;

scripts/AIGame3.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ DLLEXPORT int STDCALL SaveRestoreState(void *file_ptr, uint8_t saving_state);
4949
static std::vector<std::string> String_table;
5050
static const char *_Error_string = "!!ERROR MISSING STRING!!";
5151
static const char *_Empty_string = "";
52-
const char *GetStringFromTable(int index) {
53-
if ((index < 0) || (index >= String_table.size()))
52+
const char *GetStringFromTable(uint32_t index) {
53+
if (index >= String_table.size())
5454
return _Error_string;
5555
if (String_table[index].empty())
5656
return _Empty_string;

scripts/aigame2.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ DLLEXPORT int STDCALL SaveRestoreState(void *file_ptr, uint8_t saving_state);
4848
static std::vector<std::string> String_table;
4949
static const char *_Error_string = "!!ERROR MISSING STRING!!";
5050
static const char *_Empty_string = "";
51-
const char *GetStringFromTable(int index) {
52-
if ((index < 0) || (index >= String_table.size()))
51+
const char *GetStringFromTable(uint32_t index) {
52+
if (index >= String_table.size())
5353
return _Error_string;
5454
if (String_table[index].empty())
5555
return _Empty_string;

scripts/aigame4.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ DLLEXPORT int STDCALL SaveRestoreState(void *file_ptr, uint8_t saving_state);
4747
std::vector<std::string> String_table;
4848
static const char *_Error_string = "!!ERROR MISSING STRING!!";
4949
static const char *_Empty_string = "";
50-
const char *GetStringFromTable(int index) {
51-
if ((index < 0) || (index >= String_table.size()))
50+
const char *GetStringFromTable(uint32_t index) {
51+
if (index >= String_table.size())
5252
return _Error_string;
5353
if (String_table[index].empty())
5454
return _Empty_string;

scripts/clutter.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ DLLEXPORT int STDCALL SaveRestoreState(void *file_ptr, uint8_t saving_state);
4646
static std::vector<std::string> String_table;
4747
static const char *_Error_string = "!!ERROR MISSING STRING!!";
4848
static const char *_Empty_string = "";
49-
static const char *GetStringFromTable(int index) {
50-
if ((index < 0) || (index >= String_table.size()))
49+
static const char *GetStringFromTable(uint32_t index) {
50+
if (index >= String_table.size())
5151
return _Error_string;
5252
if (String_table[index].empty())
5353
return _Empty_string;

scripts/generic.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ DLLEXPORT int STDCALL SaveRestoreState(void *file_ptr, uint8_t saving_state);
4646
std::vector<std::string> String_table;
4747
static const char *_Error_string = "!!ERROR MISSING STRING!!";
4848
static const char *_Empty_string = "";
49-
const char *GetStringFromTable(int index) {
50-
if ((index < 0) || (index >= String_table.size()))
49+
const char *GetStringFromTable(uint32_t index) {
50+
if (index >= String_table.size())
5151
return _Error_string;
5252
if (String_table[index].empty())
5353
return _Empty_string;

0 commit comments

Comments
 (0)