Skip to content

Commit

Permalink
Reset intels and team scores after receiving winning IntelCapture
Browse files Browse the repository at this point in the history
This problem was originally reported in:
<piqueserver/piqueserver#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 yvt#890.
  • Loading branch information
yvt committed Apr 20, 2020
1 parent a455307 commit 4fbe5ee
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
7 changes: 7 additions & 0 deletions Sources/Client/CTFGameMode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
}
}
8 changes: 8 additions & 0 deletions Sources/Client/CTFGameMode.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
};
}
}
4 changes: 3 additions & 1 deletion Sources/Client/NetClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down

0 comments on commit 4fbe5ee

Please sign in to comment.