Skip to content
This repository has been archived by the owner on Apr 29, 2024. It is now read-only.

Commit

Permalink
Merge pull request #320 from storm-devs/feature/replace-strnicmp
Browse files Browse the repository at this point in the history
replace _strnicmp with storm::iEquals
  • Loading branch information
espkk authored Jan 16, 2022
2 parents c1a3975 + 0ffa912 commit 6bf5eb9
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 21 deletions.
2 changes: 1 addition & 1 deletion src/apps/engine/src/internal_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1158,7 +1158,7 @@ DATA *COMPILER::BC_CallIntFunction(uint32_t func_code, DATA *&pVResult, uint32_t
n = TempLong1;
while (n + static_cast<uint32_t>(slen2) <= static_cast<uint32_t>(slen))
{
if (_strnicmp(pChar + n, pChar2, slen2) == 0)
if (storm::iEquals(pChar + n, pChar2, slen2))
{
pV = SStack.Push();
pV->Set(static_cast<int32_t>(n));
Expand Down
4 changes: 2 additions & 2 deletions src/libs/location/src/character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2789,13 +2789,13 @@ if(storm::iEquals(eventName, "Blade to belt"))
{
const char *pcActionName = nullptr;
int32_t nIdx = -1;
if (_strnicmp(alliace, "set", 3) == 0)
if (storm::iEquals(alliace, "set", 3))
{
pcActionName = "set";
if (alliace[3] >= '0' && alliace[3] <= '9')
nIdx = atoi(&alliace[3]);
}
else if (_strnicmp(alliace, "reset", 5) == 0)
else if (storm::iEquals(alliace, "reset", 5))
{
pcActionName = "reset";
if (alliace[5] >= '0' && alliace[5] <= '9')
Expand Down
6 changes: 3 additions & 3 deletions src/libs/sea_ai/src/ai_fort.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -351,19 +351,19 @@ bool AIFort::ScanFortForCannons(AI_FORT *pFort, char *pModelsDir, char *pLocator
pNode->geo->GetLabel(i, label);
AICannon *pCannon = nullptr;

if (_strnicmp(label.name, "cannon", 6) == 0 && pFort->dwCannonType != -1)
if (storm::iEquals(label.name, "cannon", 6) && pFort->dwCannonType != -1)
{
pFort->aCannons.push_back(AICannon{});
pCannon = &pFort->aCannons.back();
// pCannon = &pFort->aCannons[pFort->aCannons.Add()];
}
if (_strnicmp(label.name, "culverin", 8) == 0 && pFort->dwCulverinType != -1)
if (storm::iEquals(label.name, "culverin", 8) && pFort->dwCulverinType != -1)
{
pFort->aCulverins.push_back(AICannon{});
pCannon = &pFort->aCulverins.back();
// pCannon = &pFort->aCulverins[pFort->aCulverins.Add()];
}
if (_strnicmp(label.name, "mortar", 6) == 0 && pFort->dwMortarType != -1)
if (storm::iEquals(label.name, "mortar", 6) && pFort->dwMortarType != -1)
{
pFort->aMortars.push_back(AICannon{});
pCannon = &pFort->aMortars.back();
Expand Down
4 changes: 2 additions & 2 deletions src/libs/ship/src/ship_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ bool SHIP::BuildMasts()
}
const auto *const cNodeName = pNode->GetName();

if (_strnicmp(cNodeName, MAST_IDENTIFY, std::size(MAST_IDENTIFY) - 1) == 0)
if (storm::iEquals(cNodeName, MAST_IDENTIFY, std::size(MAST_IDENTIFY) - 1))
{
CVECTOR vBSize, vBCenter, vUp, vDown, vTemp;

Expand Down Expand Up @@ -245,7 +245,7 @@ bool SHIP::BuildHulls()
if (!pNode)
break;
const auto *const cNodeName = pNode->GetName();
if (_strnicmp(cNodeName, HULL_IDENTIFY, std::size(HULL_IDENTIFY) - 1) == 0)
if (storm::iEquals(cNodeName, HULL_IDENTIFY, std::size(HULL_IDENTIFY) - 1))
{
CVECTOR vBSize, vBCenter, vUp, vDown, vTemp;

Expand Down
2 changes: 1 addition & 1 deletion src/libs/teleport/src/teleport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ bool FINDDIALOGNODES::Init()
auto nodIdx = 0;
while (GetStringLine(pStr, param, sizeof(param) - 1))
{
if (strlen(param) < 5 || _strnicmp(param, "case", 4))
if (strlen(param) < 5 || !storm::iEquals(param, "case", 4))
continue;
char param2[512];
GetQuotedString(param, param2, sizeof(param2) - 1);
Expand Down
4 changes: 2 additions & 2 deletions src/libs/xinterface/src/inode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ bool CINODE::GetMidStr(const char *inStr, char *buf, size_t bufSize, const char
int i;
auto fcn = -1, lcn = -1;
for (i = 0; i <= lenIn - lenBeg; i++)
if (_strnicmp(&inStr[i], begStr, lenBeg) == 0)
if (storm::iEquals(&inStr[i], begStr, lenBeg))
{
fcn = i;
break;
Expand All @@ -348,7 +348,7 @@ bool CINODE::GetMidStr(const char *inStr, char *buf, size_t bufSize, const char
fcn += lenBeg;

for (i = fcn; i <= lenIn - lenEnd; i++)
if (_strnicmp(&inStr[i], endStr, lenEnd) == 0)
if (storm::iEquals(&inStr[i], endStr, lenEnd))
{
lcn = i;
break;
Expand Down
2 changes: 1 addition & 1 deletion src/libs/xinterface/src/nodes/xi_check_buttons.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ void CXI_CHECKBUTTONS::SetInternalName(std::string &sName)
else
{
m_nEditableSectionIndex = -1;
if (_strnicmp(sName.c_str(), "btn", 3) == 0)
if (storm::iEquals(sName.c_str(), "btn", 3))
{
m_nEditableSectionIndex = atoi(&sName.c_str()[3]) - 1;
}
Expand Down
12 changes: 6 additions & 6 deletions src/libs/xinterface/src/nodes/xi_formt_text.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -679,13 +679,13 @@ bool CXI_FORMATEDTEXT::GetLineNext(int fontNum, const char *&pInStr, char *buf,
{
if (pStart[i] == '<')
{
if (_strnicmp(&pStart[i], "<color", 6) == 0)
if (storm::iEquals(&pStart[i], "<color", 6))
{
while (i < lineSize && i < bufSize - 1 && pStart[i] != '>')
i++;
continue;
}
if (_strnicmp(&pStart[i], "</color>", 8) == 0)
if (storm::iEquals(&pStart[i], "</color>", 8))
{
i += 7;
continue;
Expand All @@ -710,13 +710,13 @@ bool CXI_FORMATEDTEXT::GetLineNext(int fontNum, const char *&pInStr, char *buf,
{
if (pStart[i] == '<')
{
if (_strnicmp(&pStart[i], "<color", 6) == 0)
if (storm::iEquals(&pStart[i], "<color", 6))
{
while (i < lineSize && i < bufSize - 1 && pStart[i] != '>')
i++;
continue;
}
if (_strnicmp(&pStart[i], "</color>", 8) == 0)
if (storm::iEquals(&pStart[i], "</color>", 8))
{
i += 7;
continue;
Expand Down Expand Up @@ -962,7 +962,7 @@ void CXI_FORMATEDTEXT::MakeTagChecking(bool &tagState, uint32_t &tagColor, uint3
{
if (tagState)
{
if (_strnicmp(str, "</color>", 8) == 0)
if (storm::iEquals(str, "</color>", 8))
{
tagState = false;
q = str - tagBegin;
Expand All @@ -971,7 +971,7 @@ void CXI_FORMATEDTEXT::MakeTagChecking(bool &tagState, uint32_t &tagColor, uint3
}
else
{
if (_strnicmp(str, "<color=", 7) == 0)
if (storm::iEquals(str, "<color=", 7))
{
tagState = true;
int32_t a = 255, r = 255, g = 255, b = 255;
Expand Down
4 changes: 2 additions & 2 deletions src/libs/xinterface/src/nodes/xi_img_collection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ void CXI_IMGCOLLECTION::LoadIni(INIFILE *ini1, const char *name1, INIFILE *ini2,
if (ini1->ReadString(name1, "picture", param, sizeof(param) - 1, ""))
do
{
if (_strnicmp(param, "editsection:", 12) != 0)
if (!storm::iEquals(param, "editsection:", 12))
imgQuantity++;
} while (ini1->ReadStringNext(name1, "picture", param, sizeof(param) - 1));

Expand Down Expand Up @@ -136,7 +136,7 @@ void CXI_IMGCOLLECTION::LoadIni(INIFILE *ini1, const char *name1, INIFILE *ini2,
ini1->ReadString(name1, "picture", param, sizeof(param) - 1, "");
for (auto i = 0; i < imgQuantity; i++)
{
if (_strnicmp(param, "editsection:", 12) != 0)
if (!storm::iEquals(param, "editsection:", 12))
{
auto dwColor = ARGB(255, 128, 128, 128);
char param2[256];
Expand Down
2 changes: 1 addition & 1 deletion src/libs/xinterface/src/nodes/xi_table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,7 @@ void CXI_TABLE::SetInternalName(std::string &sName)
else
{
m_EditData.bAllEditable = false;
m_EditData.bColsEditable = (_strnicmp(sName.c_str(), "col", 3) == 0);
m_EditData.bColsEditable = (storm::iEquals(sName.c_str(), "col", 3));
m_EditData.nEditableIndex = atoi(&sName.c_str()[3]) - 1;
}
}
Expand Down

0 comments on commit 6bf5eb9

Please sign in to comment.