Skip to content

Commit

Permalink
Change GetStringFromTable() signature
Browse files Browse the repository at this point in the history
Assuming that index will never be negative, change it to unsigned int.
  • Loading branch information
winterheart committed Sep 12, 2024
1 parent 197e111 commit 153a09c
Show file tree
Hide file tree
Showing 21 changed files with 40 additions and 40 deletions.
4 changes: 2 additions & 2 deletions Descent3/localization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,8 @@ void FreeStringTables() {
String_table.clear();
}

const char *GetStringFromTable(int index) {
if ((index < 0) || (index >= String_table.size()))
const char *GetStringFromTable(uint32_t index) {
if (index >= String_table.size())
return Error_string;

if (String_table[index].empty())
Expand Down
2 changes: 1 addition & 1 deletion Descent3/localization.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ void FreeStringTables();

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

/**
* Creates table of strings from given filename
Expand Down
2 changes: 1 addition & 1 deletion Descent3/stringtable.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
// Returns a pointer to the string at the index location from the string table
// if it is a bad index given, then the pointer to the error string "ERROR MISSING STRING" is given

const char *GetStringFromTable(int index);
const char *GetStringFromTable(uint32_t index);

#define TXT_NEW TXT(0) //"New"
#define TXT_DELETE TXT(1) //"Delete"
Expand Down
6 changes: 3 additions & 3 deletions netgames/coop/coop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,11 @@ int unpack_pstat(tPlayerStat *user_info, uint8_t *data) {
// localization info
static std::vector<std::string> StringTable;
static const char *_ErrorString = "Missing String";
const char *GetStringFromTable(int d) {
if ((d < 0) || (d >= StringTable.size()))
const char *GetStringFromTable(uint32_t index) {
if (index >= StringTable.size())
return _ErrorString;
else
return StringTable[d].c_str();
return StringTable[index].c_str();
}
///////////////////////////////////////////////
static int SortedPlayers[MAX_PLAYER_RECORDS];
Expand Down
2 changes: 1 addition & 1 deletion netgames/coop/coopstr.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
// Returns a pointer to the string at the index location from the string table
// if it is a bad index given, then the pointer to the error string "ERROR MISSING STRING" is given

const char *GetStringFromTable(int index);
const char *GetStringFromTable(uint32_t index);

#define TXT_COOP TXT(0) //"Coop"
#define TXT_STATGAMENAME TXT(1) //"Co-op Descent 3"
Expand Down
6 changes: 3 additions & 3 deletions netgames/entropy/EntropyBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,11 +214,11 @@ static void OnPrintScores(int level);
// localization info
static std::vector<std::string> StringTable;
static const char *_ErrorString = "Missing String";
const char *GetStringFromTable(int d) {
if ((d < 0) || (d >= StringTable.size()))
const char *GetStringFromTable(uint32_t index) {
if (index >= StringTable.size())
return _ErrorString;
else
return StringTable[d].c_str();
return StringTable[index].c_str();
}
///////////////////////////////////////////////

Expand Down
2 changes: 1 addition & 1 deletion netgames/entropy/Entropystr.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
// Returns a pointer to the string at the index location from the string table
// if it is a bad index given, then the pointer to the error string "ERROR MISSING STRING" is given

const char *GetStringFromTable(int index);
const char *GetStringFromTable(uint32_t index);

#define TXT_GAMENAME TXT(0) //"Entropy"
#define TXT_KILLA TXT(1) //"%s was killed by %s"
Expand Down
6 changes: 3 additions & 3 deletions netgames/hoard/hoard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,11 @@ static bool Config_displayed = false;
// localization info
static std::vector<std::string> StringTable;
static const char *_ErrorString = "Missing String";
const char *GetStringFromTable(int d) {
if ((d < 0) || (d >= StringTable.size()))
const char *GetStringFromTable(uint32_t index) {
if (index >= StringTable.size())
return _ErrorString;
else
return StringTable[d].c_str();
return StringTable[index].c_str();
}
///////////////////////////////////////////////

Expand Down
2 changes: 1 addition & 1 deletion netgames/hoard/hoardstr.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
// Returns a pointer to the string at the index location from the string table
// if it is a bad index given, then the pointer to the error string "ERROR MISSING STRING" is given

const char *GetStringFromTable(int index);
const char *GetStringFromTable(uint32_t index);

#define TXT_DEATH1 TXT(0) //"%s got blasted by %s"
#define TXT_DEATH2 TXT(1) //"%s knows %s is his god"
Expand Down
6 changes: 3 additions & 3 deletions netgames/hyperanarchy/hyperanarchy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,11 @@ static void OnClientPlayerEntersGame(int player_num);
// localization info
static std::vector<std::string> StringTable;
static const char *_ErrorString = "Missing String";
const char *GetStringFromTable(int d) {
if ((d < 0) || (d >= StringTable.size()))
const char *GetStringFromTable(uint32_t index) {
if (index >= StringTable.size())
return _ErrorString;
else
return StringTable[d].c_str();
return StringTable[index].c_str();
}
///////////////////////////////////////////////

Expand Down
2 changes: 1 addition & 1 deletion netgames/hyperanarchy/hyperstr.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
// Returns a pointer to the string at the index location from the string table
// if it is a bad index given, then the pointer to the error string "ERROR MISSING STRING" is given

const char *GetStringFromTable(int index);
const char *GetStringFromTable(uint32_t index);

#define TXT_DEATH1 TXT(0) //"%s got butchered by %s"
#define TXT_SUICIDE1 TXT(1) //"%s shags himself"
Expand Down
6 changes: 3 additions & 3 deletions netgames/monsterball/monsterball.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,11 +274,11 @@ static bool monsterball_info_set = false;
// localization info
static std::vector<std::string> StringTable;
static const char *_ErrorString = "Missing String";
const char *GetStringFromTable(int d) {
if ((d < 0) || (d >= StringTable.size()))
const char *GetStringFromTable(uint32_t index) {
if (index >= StringTable.size())
return _ErrorString;
else
return StringTable[d].c_str();
return StringTable[index].c_str();
}
///////////////////////////////////////////////

Expand Down
2 changes: 1 addition & 1 deletion netgames/monsterball/monsterstr.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
// Returns a pointer to the string at the index location from the string table
// if it is a bad index given, then the pointer to the error string "ERROR MISSING STRING" is given

const char *GetStringFromTable(int index);
const char *GetStringFromTable(uint32_t index);

#define TXT_GAMENAME TXT(0) //"Monsterball"
#define TXT_KILLEDA TXT(1) //"%s was killed by %s"
Expand Down
6 changes: 3 additions & 3 deletions netgames/tanarchy/tanarchy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,11 @@ static int Highlight_bmp = -1;
// localization info
static std::vector<std::string> StringTable;
static const char *_ErrorString = "Missing String";
const char *GetStringFromTable(int d) {
if ((d < 0) || (d >= StringTable.size()))
const char *GetStringFromTable(uint32_t index) {
if (index >= StringTable.size())
return _ErrorString;
else
return StringTable[d].c_str();
return StringTable[index].c_str();
}
///////////////////////////////////////////////

Expand Down
2 changes: 1 addition & 1 deletion netgames/tanarchy/tanarchystr.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
// Returns a pointer to the string at the index location from the string table
// if it is a bad index given, then the pointer to the error string "ERROR MISSING STRING" is given

const char *GetStringFromTable(int index);
const char *GetStringFromTable(uint32_t index);

#define TXT_DEATH1 TXT(0) //"%s got blasted by %s"
#define TXT_DEATH2 TXT(1) //"%s knows %s is his god"
Expand Down
4 changes: 2 additions & 2 deletions scripts/AIGame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ DLLEXPORT int STDCALL SaveRestoreState(void *file_ptr, uint8_t saving_state);
static std::vector<std::string> String_table;
static const char *_Error_string = "!!ERROR MISSING STRING!!";
static const char *_Empty_string = "";
const char *GetStringFromTable(int index) {
if ((index < 0) || (index >= String_table.size()))
const char *GetStringFromTable(uint32_t index) {
if (index >= String_table.size())
return _Error_string;
if (String_table[index].empty())
return _Empty_string;
Expand Down
4 changes: 2 additions & 2 deletions scripts/AIGame3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ DLLEXPORT int STDCALL SaveRestoreState(void *file_ptr, uint8_t saving_state);
static std::vector<std::string> String_table;
static const char *_Error_string = "!!ERROR MISSING STRING!!";
static const char *_Empty_string = "";
const char *GetStringFromTable(int index) {
if ((index < 0) || (index >= String_table.size()))
const char *GetStringFromTable(uint32_t index) {
if (index >= String_table.size())
return _Error_string;
if (String_table[index].empty())
return _Empty_string;
Expand Down
4 changes: 2 additions & 2 deletions scripts/aigame2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ DLLEXPORT int STDCALL SaveRestoreState(void *file_ptr, uint8_t saving_state);
static std::vector<std::string> String_table;
static const char *_Error_string = "!!ERROR MISSING STRING!!";
static const char *_Empty_string = "";
const char *GetStringFromTable(int index) {
if ((index < 0) || (index >= String_table.size()))
const char *GetStringFromTable(uint32_t index) {
if (index >= String_table.size())
return _Error_string;
if (String_table[index].empty())
return _Empty_string;
Expand Down
4 changes: 2 additions & 2 deletions scripts/aigame4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ DLLEXPORT int STDCALL SaveRestoreState(void *file_ptr, uint8_t saving_state);
std::vector<std::string> String_table;
static const char *_Error_string = "!!ERROR MISSING STRING!!";
static const char *_Empty_string = "";
const char *GetStringFromTable(int index) {
if ((index < 0) || (index >= String_table.size()))
const char *GetStringFromTable(uint32_t index) {
if (index >= String_table.size())
return _Error_string;
if (String_table[index].empty())
return _Empty_string;
Expand Down
4 changes: 2 additions & 2 deletions scripts/clutter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ DLLEXPORT int STDCALL SaveRestoreState(void *file_ptr, uint8_t saving_state);
static std::vector<std::string> String_table;
static const char *_Error_string = "!!ERROR MISSING STRING!!";
static const char *_Empty_string = "";
static const char *GetStringFromTable(int index) {
if ((index < 0) || (index >= String_table.size()))
static const char *GetStringFromTable(uint32_t index) {
if (index >= String_table.size())
return _Error_string;
if (String_table[index].empty())
return _Empty_string;
Expand Down
4 changes: 2 additions & 2 deletions scripts/generic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ DLLEXPORT int STDCALL SaveRestoreState(void *file_ptr, uint8_t saving_state);
std::vector<std::string> String_table;
static const char *_Error_string = "!!ERROR MISSING STRING!!";
static const char *_Empty_string = "";
const char *GetStringFromTable(int index) {
if ((index < 0) || (index >= String_table.size()))
const char *GetStringFromTable(uint32_t index) {
if (index >= String_table.size())
return _Error_string;
if (String_table[index].empty())
return _Empty_string;
Expand Down

0 comments on commit 153a09c

Please sign in to comment.