Skip to content

Commit

Permalink
Replace s.compare("..") == 0 by s == "..".
Browse files Browse the repository at this point in the history
  • Loading branch information
Jarod42 committed Apr 30, 2024
1 parent fee78c1 commit 497539b
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 16 deletions.
6 changes: 3 additions & 3 deletions gameheaders/stratagus-game-launcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -384,9 +384,9 @@ static void ExtractData(char *extractor_tool,
}
} else {
// we cannot test if this is an innoextract installer, assume not but maybe warn
if (datafile.compare("INSTALL.EXE") == 0 || datafile.compare("install.exe") == 0
|| datafile.compare("INSTALL.exe") == 0 || datafile.compare("SETUP.EXE") == 0
|| datafile.compare("setup.exe") == 0 || datafile.compare("SETUP.exe") == 0) {
if (datafile == "INSTALL.EXE" || datafile == "install.exe"
|| datafile == "INSTALL.exe" || datafile == "SETUP.EXE"
|| datafile == "setup.exe" || datafile == "SETUP.exe") {
// probably not a packaged installer
} else {
// warn
Expand Down
4 changes: 2 additions & 2 deletions src/network/online_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1981,7 +1981,7 @@ class C2S_SID_AUTH_INFO : public OnlineState
// Connect

std::string localHost = CNetworkParameter::Instance.localHost;
if (!localHost.compare("127.0.0.1")) {
if (localHost == "127.0.0.1") {
localHost = "0.0.0.0";
}
if (!ctx.getTCPSocket().IsValid()) {
Expand Down Expand Up @@ -2022,7 +2022,7 @@ class C2S_SID_AUTH_INFO : public OnlineState
// (UINT32) Language code
buffer.serialize32(0x00);
// (UINT32) Local IP
if (CNetworkParameter::Instance.localHost.compare("127.0.0.1")) {
if (CNetworkParameter::Instance.localHost != "127.0.0.1") {
// user set a custom local ip, use that
#ifdef USE_WIN32
uint32_t addr = inet_addr(CNetworkParameter::Instance.localHost.c_str());
Expand Down
2 changes: 1 addition & 1 deletion src/ui/button_checks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ bool ButtonCheckSingleResearch(const CUnit &unit, const ButtonAction &button)
*/
bool ButtonCheckDebug(const CUnit &, const ButtonAction &button)
{
if(!button.AllowStr.compare("single-player-walls")) { /// Check if enabled walls for singleplayer games
if (button.AllowStr == "single-player-walls") { /// Check if enabled walls for singleplayer games
return !IsNetworkGame() && EnableWallsInSinglePlayer;
}
return false;
Expand Down
20 changes: 10 additions & 10 deletions src/unit/build.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,9 @@ bool CBuildRestrictionDistance::Check(const CUnit *builder, const CUnitType &typ
(this->RestrictType == unit->Type || (!this->RestrictType && this->RestrictTypeOwner.size() > 0)) &&
// RestrictTypeOwner is not set or unit belongs to a suitable player
(this->RestrictTypeOwner.empty() ||
(!this->RestrictTypeOwner.compare("self") && player == unit->Player) ||
(!this->RestrictTypeOwner.compare("allied") && (player == unit->Player || player->IsAllied(*unit->Player))) ||
(!this->RestrictTypeOwner.compare("enemy") && player->IsEnemy(*unit->Player)))) {
(this->RestrictTypeOwner == "self" && player == unit->Player) ||
(this->RestrictTypeOwner == "allied" && (player == unit->Player || player->IsAllied(*unit->Player))) ||
(this->RestrictTypeOwner == "enemy" && player->IsEnemy(*unit->Player)))) {

switch (this->DistanceType) {
case EComparison::GreaterThan:
Expand Down Expand Up @@ -202,22 +202,22 @@ bool CBuildRestrictionHasUnit::Check(const CUnit *builder, const CUnitType &type
Vec2i pos2(0, 0);
CPlayer* player = builder != nullptr ? builder->Player : ThisPlayer;
int count = 0;
if (this->RestrictTypeOwner.empty() || !this->RestrictTypeOwner.compare("self")) {
if (this->RestrictTypeOwner.empty() || this->RestrictTypeOwner == "self") {
count = player->GetUnitTotalCount(*this->RestrictType);
} else if (!this->RestrictTypeOwner.compare("allied")) {
} else if (this->RestrictTypeOwner == "allied") {
count = player->GetUnitTotalCount(*this->RestrictType);
for (int i = 0; i < NumPlayers; i++) {
if (player->IsAllied(Players[i])) {
count += Players[i].GetUnitTotalCount(*this->RestrictType);
}
}
} else if (!this->RestrictTypeOwner.compare("enemy")) {
} else if (this->RestrictTypeOwner == "enemy") {
for (int i = 0; i < NumPlayers; i++) {
if (player->IsEnemy(Players[i])) {
count += Players[i].GetUnitTotalCount(*this->RestrictType);
}
}
} else if (!this->RestrictTypeOwner.compare("any")) {
} else if (this->RestrictTypeOwner == "any") {
for (int i = 0; i < NumPlayers; i++) {
count += Players[i].GetUnitTotalCount(*this->RestrictType);
}
Expand Down Expand Up @@ -278,9 +278,9 @@ bool CBuildRestrictionSurroundedBy::Check(const CUnit *builder, const CUnitType
(this->RestrictType == unit->Type || (!this->RestrictType && this->RestrictTypeOwner.size() > 0)) &&
// RestrictTypeOwner is not set or unit belongs to a suitable player
(this->RestrictTypeOwner.empty() ||
(!this->RestrictTypeOwner.compare("self") && builder->Player == unit->Player) ||
(!this->RestrictTypeOwner.compare("allied") && (builder->Player == unit->Player || builder->Player->IsAllied(*unit->Player))) ||
(!this->RestrictTypeOwner.compare("enemy") && builder->Player->IsEnemy(*unit->Player)))) {
(this->RestrictTypeOwner == "self" && builder->Player == unit->Player) ||
(this->RestrictTypeOwner == "allied" && (builder->Player == unit->Player || builder->Player->IsAllied(*unit->Player))) ||
(this->RestrictTypeOwner == "enemy" && builder->Player->IsEnemy(*unit->Player)))) {

switch (this->DistanceType) {
case EComparison::GreaterThan:
Expand Down

0 comments on commit 497539b

Please sign in to comment.