Fix some crashes

This commit is contained in:
yvt 2017-02-22 08:19:14 +09:00
parent 0ce8d07311
commit 23231dd2a4
2 changed files with 6 additions and 1 deletions

View File

@ -491,6 +491,11 @@ namespace spades {
if (!world->GetLocalPlayer() || world->GetLocalPlayer()->GetTeamId() >= 2) { if (!world->GetLocalPlayer() || world->GetLocalPlayer()->GetTeamId() >= 2) {
// join // join
if (team == 255) {
// weaponId doesn't matter for spectators, but
// NetClient doesn't like invalid weapon ID
weap = WeaponType::RIFLE_WEAPON;
}
net->SendJoin(team, weap, playerName, lastKills); net->SendJoin(team, weap, playerName, lastKills);
} else { } else {
Player *p = world->GetLocalPlayer(); Player *p = world->GetLocalPlayer();

View File

@ -117,7 +117,7 @@ namespace spades {
void SetMode(IGameMode *); void SetMode(IGameMode *);
Team &GetTeam(int t) { Team &GetTeam(int t) {
if (t >= 2) // spectator if (t >= 2 || t < 0) // spectator
return teams[2]; return teams[2];
return teams[t]; return teams[t];
} }