From 74111b80458151d4c43e52422c669368ad8c8532 Mon Sep 17 00:00:00 2001 From: JT Traub Date: Sat, 4 May 2024 19:08:04 -0700 Subject: [PATCH] Allow the orders checker to check faction password. --- parseorders.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/parseorders.cpp b/parseorders.cpp index 868411f1..cf2c20ad 100644 --- a/parseorders.cpp +++ b/parseorders.cpp @@ -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()); } @@ -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")) {