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

File tree

21 files changed

+40
-40
lines changed

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

0 commit comments

Comments
 (0)