push full world to new players, push player resets properly
git-svn-id: svn://anubis/gvsu@105 45c1a28c-8058-47b2-ae61-ca45b979098e
This commit is contained in:
parent
eff1c65fd9
commit
723c3cc876
@ -153,6 +153,13 @@ public class BlobWars extends JFrame
|
|||||||
}
|
}
|
||||||
else if (e.getSource() == m_timer)
|
else if (e.getSource() == m_timer)
|
||||||
{
|
{
|
||||||
|
/* m_world.step(); /* step the world like the server would
|
||||||
|
* on its end. this provides motion
|
||||||
|
* prediction by carrying out the same
|
||||||
|
* actions the server would assuming that
|
||||||
|
* player directions have not changed
|
||||||
|
* since the last time step if we have
|
||||||
|
* not heard anything */
|
||||||
processUpdates();
|
processUpdates();
|
||||||
m_panel.repaint();
|
m_panel.repaint();
|
||||||
}
|
}
|
||||||
|
@ -84,6 +84,8 @@ public class BlobWarsServer
|
|||||||
System.out.println("Player '" + arr[1] + "' signed on.");
|
System.out.println("Player '" + arr[1] + "' signed on.");
|
||||||
m_world.addPlayer(arr[1]);
|
m_world.addPlayer(arr[1]);
|
||||||
m_socketToPlayerName.put(cu.socket, arr[1]);
|
m_socketToPlayerName.put(cu.socket, arr[1]);
|
||||||
|
m_lastPlayers.clear(); // clearing the last information will
|
||||||
|
m_lastShots.clear(); // push everything to the new player
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
/* the rest of the commands all require a player to be registered */
|
/* the rest of the commands all require a player to be registered */
|
||||||
@ -200,7 +202,7 @@ public class BlobWarsServer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* check number of players alive, possibly declare winner */
|
/* check number of players alive */
|
||||||
Player alivePlayer = null;
|
Player alivePlayer = null;
|
||||||
int alivePlayers = 0;
|
int alivePlayers = 0;
|
||||||
for (Player p : players.values())
|
for (Player p : players.values())
|
||||||
@ -211,6 +213,12 @@ public class BlobWarsServer
|
|||||||
alivePlayer = p;
|
alivePlayer = p;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* save the player / shot data into the "last" variables */
|
||||||
|
m_lastPlayers = PlayerClone(players);
|
||||||
|
m_lastShots = ShotClone(shots);
|
||||||
|
|
||||||
|
/* declare a winner if there is one and reset the players */
|
||||||
if (alivePlayers == 1 && alivePlayers < m_lastNumPlayersAlive)
|
if (alivePlayers == 1 && alivePlayers < m_lastNumPlayersAlive)
|
||||||
{
|
{
|
||||||
/* game is over, alivePlayer won */
|
/* game is over, alivePlayer won */
|
||||||
@ -236,9 +244,6 @@ public class BlobWarsServer
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* save the player / shot data into the "last" variables */
|
|
||||||
m_lastPlayers = PlayerClone(players);
|
|
||||||
m_lastShots = ShotClone(shots);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user