TCGameMode: Force bounds check

This commit is contained in:
yvt 2019-08-08 01:11:59 +09:00
parent 99489cab66
commit eece4c3251
No known key found for this signature in database
GPG Key ID: 48F2768FA8D07C92
2 changed files with 4 additions and 7 deletions

View File

@ -30,9 +30,7 @@ namespace spades {
TCGameMode::Team &TCGameMode::GetTeam(int t) {
SPADES_MARK_FUNCTION();
SPAssert(t >= 0);
SPAssert(t < 2);
return teams[t];
return teams.at(t);
}
void TCGameMode::AddTerritory(const spades::client::TCGameMode::Territory &t) {

View File

@ -20,6 +20,7 @@
#pragma once
#include <array>
#include <vector>
#include "IGameMode.h"
@ -56,7 +57,7 @@ namespace spades {
private:
World &world;
Team teams[2];
std::array<Team, 2> teams;
std::vector<Territory> territories;
public:
@ -71,9 +72,7 @@ namespace spades {
int GetNumTerritories() const { return (int)territories.size(); }
Territory &GetTerritory(int index) {
SPADES_MARK_FUNCTION();
SPAssert(index >= 0);
SPAssert(index < GetNumTerritories());
return territories[index];
return territories.at(index);
}
void AddTerritory(const Territory &);