diff --git a/src/Spawner/Spawner.cpp b/src/Spawner/Spawner.cpp index fc15e522..37bb0dd5 100644 --- a/src/Spawner/Spawner.cpp +++ b/src/Spawner/Spawner.cpp @@ -274,13 +274,16 @@ bool Spawner::StartScenario(const char* pScenarioName) if (playerIndex > 0) { + const auto playerPort = static_cast(pPlayer->Port); + const auto listenPort = static_cast(Spawner::Config->ListenPort); + pNode->Address.sin_addr.s_addr = playerIndex; + ListAddress::Array[playerIndex - 1].Ip = inet_addr(pPlayer->Ip); + ListAddress::Array[playerIndex - 1].Port = htons(playerPort); - const auto Ip = inet_addr(pPlayer->Ip); - const auto Port = htons((u_short)pPlayer->Port); - ListAddress::Array[playerIndex - 1].Ip = Ip; - ListAddress::Array[playerIndex - 1].Port = Port; - if (Port != (u_short)Spawner::Config->ListenPort) + // Accumulate this flag across all players in the loop. + // Do not overwrite it on each iteration. + if (playerPort != listenPort) NetHack::RequirePortMatch = true; } }