Reset intels and team scores after receiving winning IntelCapture

This problem was originally reported in:
<https://github.com/piqueserver/piqueserver/issues/586>

Upon receiving `IntelCapture` with `winning = 1`, the voxlap client
resets both team scores and the holding status of both teams' intels,
but OpenSpades didn't do that, resulting in a weird behavior described
in piqueserver/piqueserver#586. This commit changes OpenSpades' behavior
to be congruent with the voxlap client's behavior.

Fixes #890.
This commit is contained in:
yvt 2020-04-20 13:26:11 +09:00
parent a455307017
commit 4fbe5ee5ce
No known key found for this signature in database
GPG Key ID: 48F2768FA8D07C92
3 changed files with 18 additions and 1 deletions

View File

@ -44,5 +44,12 @@ namespace spades {
auto &team = teams[player.GetTeamId()];
return team.hasIntel && team.carrier == player.GetId();
}
void CTFGameMode::ResetTeamScoreAndIntelHoldingStatus() {
for (Team &team : teams) {
team.score = 0;
team.hasIntel = false;
}
}
}
}

View File

@ -50,6 +50,14 @@ namespace spades {
void SetCaptureLimit(int v) { captureLimit = v; }
bool PlayerHasIntel(World &world, Player &player);
/**
* Resets both team score and the holding status of both flags.
*
* This is what the vanila client does upon receiving a winning
* `IntelCapture`.
*/
void ResetTeamScoreAndIntelHoldingStatus();
};
}
}

View File

@ -1399,8 +1399,10 @@ namespace spades {
ctf->GetTeam(p->GetTeamId()).score++;
bool winning = reader.ReadByte() != 0;
if (winning)
if (winning) {
ctf->ResetTeamScoreAndIntelHoldingStatus();
client->TeamWon(p->GetTeamId());
}
} break;
case PacketTypeIntelPickup: {
Player *p = GetPlayer(reader.ReadByte());