Fixed "waiting for players" being shown after PvP end

This commit is contained in:
Anuken
2020-08-21 10:03:40 -04:00
parent 28d2243abc
commit 3b85dc27d7
6 changed files with 20 additions and 6 deletions

View File

@ -302,6 +302,11 @@ public class Logic implements ApplicationListener{
}); });
} }
@Remote(called = Loc.both)
public static void updateGameOver(Team winner){
state.gameOver = true;
}
@Remote(called = Loc.both) @Remote(called = Loc.both)
public static void gameOver(Team winner){ public static void gameOver(Team winner){
state.stats.wavesLasted = state.wave; state.stats.wavesLasted = state.wave;

View File

@ -437,13 +437,14 @@ public class NetClient implements ApplicationListener{
} }
@Remote(variants = Variant.one, priority = PacketPriority.low, unreliable = true) @Remote(variants = Variant.one, priority = PacketPriority.low, unreliable = true)
public static void stateSnapshot(float waveTime, int wave, int enemies, boolean paused, short coreDataLen, byte[] coreData){ public static void stateSnapshot(float waveTime, int wave, int enemies, boolean paused, boolean gameOver, short coreDataLen, byte[] coreData){
try{ try{
if(wave > state.wave){ if(wave > state.wave){
state.wave = wave; state.wave = wave;
Events.fire(new WaveEvent()); Events.fire(new WaveEvent());
} }
state.gameOver = gameOver;
state.wavetime = waveTime; state.wavetime = waveTime;
state.wave = wave; state.wave = wave;
state.enemies = enemies; state.enemies = enemies;

View File

@ -735,7 +735,7 @@ public class NetServer implements ApplicationListener{
} }
public boolean isWaitingForPlayers(){ public boolean isWaitingForPlayers(){
if(state.rules.pvp){ if(state.rules.pvp && !state.gameOver){
int used = 0; int used = 0;
for(TeamData t : state.teams.getActive()){ for(TeamData t : state.teams.getActive()){
if(Groups.player.count(p -> p.team() == t.team) > 0){ if(Groups.player.count(p -> p.team() == t.team) > 0){
@ -794,7 +794,7 @@ public class NetServer implements ApplicationListener{
if(!entity.block().sync) continue; if(!entity.block().sync) continue;
sent ++; sent ++;
dataStream.writeInt(entity.tile().pos()); dataStream.writeInt(entity.pos());
entity.writeAll(Writes.get(dataStream)); entity.writeAll(Writes.get(dataStream));
if(syncStream.size() > maxSnapshotSize){ if(syncStream.size() > maxSnapshotSize){
@ -828,7 +828,7 @@ public class NetServer implements ApplicationListener{
byte[] stateBytes = syncStream.toByteArray(); byte[] stateBytes = syncStream.toByteArray();
//write basic state data. //write basic state data.
Call.stateSnapshot(player.con, state.wavetime, state.wave, state.enemies, state.serverPaused, (short)stateBytes.length, net.compressSnapshot(stateBytes)); Call.stateSnapshot(player.con, state.wavetime, state.wave, state.enemies, state.serverPaused, state.gameOver, (short)stateBytes.length, net.compressSnapshot(stateBytes));
viewport.setSize(player.con.viewWidth, player.con.viewHeight).setCenter(player.con.viewX, player.con.viewY); viewport.setSize(player.con.viewWidth, player.con.viewHeight).setCenter(player.con.viewX, player.con.viewY);

View File

@ -41,6 +41,8 @@ public class MassDriver extends Block{
hasItems = true; hasItems = true;
hasPower = true; hasPower = true;
outlineIcon = true; outlineIcon = true;
sync = true;
//point2 is relative //point2 is relative
config(Point2.class, (MassDriverBuild tile, Point2 point) -> tile.link = Point2.pack(point.x + tile.tileX(), point.y + tile.tileY())); config(Point2.class, (MassDriverBuild tile, Point2 point) -> tile.link = Point2.pack(point.x + tile.tileX(), point.y + tile.tileY()));
config(Integer.class, (MassDriverBuild tile, Integer point) -> tile.link = point); config(Integer.class, (MassDriverBuild tile, Integer point) -> tile.link = point);
@ -318,7 +320,7 @@ public class MassDriver extends Block{
super.read(read, revision); super.read(read, revision);
link = read.i(); link = read.i();
rotation = read.f(); rotation = read.f();
state = DriverState.values()[read.b()]; state = DriverState.all[read.b()];
} }
} }
@ -326,6 +328,8 @@ public class MassDriver extends Block{
idle, //nothing is shooting at this mass driver and it does not have any target idle, //nothing is shooting at this mass driver and it does not have any target
accepting, //currently getting shot at, unload items accepting, //currently getting shot at, unload items
shooting, shooting,
unloading unloading;
public static final DriverState[] all = values();
} }
} }

View File

@ -24,6 +24,7 @@ public class PayloadAcceptor extends Block{
super(name); super(name);
update = true; update = true;
sync = true;
} }
public static boolean blends(Building tile, int direction){ public static boolean blends(Building tile, int direction){

View File

@ -159,6 +159,9 @@ public class ServerControl implements ApplicationListener{
+ (map.tags.containsKey("author") && !map.tags.get("author").trim().isEmpty() ? " by[accent] " + map.author() + "[white]" : "") + "." + + (map.tags.containsKey("author") && !map.tags.get("author").trim().isEmpty() ? " by[accent] " + map.author() + "[white]" : "") + "." +
"\nNew game begins in " + roundExtraTime + " seconds."); "\nNew game begins in " + roundExtraTime + " seconds.");
state.gameOver = true;
Call.updateGameOver(event.winner);
info("Selected next map to be @.", map.name()); info("Selected next map to be @.", map.name());
play(true, () -> world.loadMap(map, map.applyRules(lastMode))); play(true, () -> world.loadMap(map, map.applyRules(lastMode)));