Fixed crashes with team IDs above 127

This commit is contained in:
Anuken
2020-07-03 12:36:12 -04:00
parent 3772b04c6b
commit 843a8c3e56
18 changed files with 48 additions and 68 deletions
+1 -1
View File
@@ -157,7 +157,7 @@ public class DefaultWaves{
spacing = 3;
}},
new SpawnGroup(UnitTypes.chaosArray){{
new SpawnGroup(UnitTypes.siegeArray){{
begin = 41;
unitAmount = 1;
unitScaling = 1;
+4 -4
View File
@@ -134,16 +134,16 @@ public class Rules{
final TeamRule[] values = new TeamRule[Team.all.length];
public TeamRule get(Team team){
TeamRule out = values[team.uid];
if(out == null) values[team.uid] = (out = new TeamRule());
TeamRule out = values[team.id];
if(out == null) values[team.id] = (out = new TeamRule());
return out;
}
@Override
public void write(Json json){
for(Team team : Team.all){
if(values[team.uid] != null){
json.writeValue(team.uid + "", values[team.uid], TeamRule.class);
if(values[team.id] != null){
json.writeValue(team.id + "", values[team.id], TeamRule.class);
}
}
}
+4 -8
View File
@@ -4,7 +4,6 @@ import arc.*;
import arc.graphics.*;
import arc.math.*;
import arc.struct.*;
import arc.util.*;
import arc.util.ArcAnnotate.*;
import mindustry.game.Rules.*;
import mindustry.game.Teams.*;
@@ -14,8 +13,7 @@ import mindustry.world.blocks.storage.CoreBlock.*;
import static mindustry.Vars.*;
public class Team implements Comparable<Team>{
public final byte id;
public final int uid;
public final int id;
public final Color color;
public final Color[] palette;
public boolean hasPalette;
@@ -52,12 +50,10 @@ public class Team implements Comparable<Team>{
protected Team(int id, String name, Color color){
this.name = name;
this.color = color;
this.id = (byte)id;
this.id = id;
int us = Pack.u(this.id);
uid = us;
if(us < 6) baseTeams[us] = this;
all[us] = this;
if(id < 6) baseTeams[id] = this;
all[id] = this;
palette = new Color[3];
palette[0] = color;
+3 -3
View File
@@ -62,10 +62,10 @@ public class Teams{
/** Returns team data by type. */
public TeamData get(Team team){
if(map[team.uid] == null){
map[team.uid] = new TeamData(team);
if(map[team.id] == null){
map[team.id] = new TeamData(team);
}
return map[team.uid];
return map[team.id];
}
public Seq<CoreEntity> playerCores(){