Skip to content

Commit

Permalink
Allow the orders checker to check faction password.
Browse files Browse the repository at this point in the history
  • Loading branch information
jt-traub committed May 5, 2024
1 parent 6188999 commit 74111b8
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions parseorders.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,12 @@ void Game::ParseOrders(int faction, istream& f, OrdersCheck *pCheck)
fac = 0;
break;
}
Faction *passFac = nullptr;
if (pCheck) {
fac = &(pCheck->dummyFaction);
pCheck->numshows = 0;
// Even though we don't use the real faction for other things, we do want it for the password check.
passFac = GetFaction(&factions, token->value());
} else {
fac = GetFaction(&factions, token->value());
}
Expand All @@ -243,6 +246,18 @@ void Game::ParseOrders(int faction, istream& f, OrdersCheck *pCheck)
if (!token) {
parse_error(pCheck, 0, fac, "Warning: No password on #atlantis line.");
parse_error(pCheck, 0, fac, "If this is your first turn, ignore this error.");
} else {
// If we found their real faction above (we should have but let's not assume), then we
// can check if they gave us the correct password.
if (passFac) {
bool has_password = !(*(passFac->password) == "none");
bool wrong_password = !(*(passFac->password) == *token);
if (has_password && wrong_password) {
parse_error(pCheck, 0, fac, "Incorrect password on #atlantis line.");
fac = 0;
break;
}
}
}
} else {
if (!(*(fac->password) == "none")) {
Expand Down

0 comments on commit 74111b8

Please sign in to comment.