Up | Previous | Next |
Explain it, fix it. First:
The interface needs to be consistent:
int size = -1; public void broadcast(int id, int x, int y, String action) throws RemoteException { for (int i = 0; i <= size; i++) { clients[i].update(id, x, y, action); } }
And so needs to be the implementation:
import java.rmi.*; public interface ClientInterface extends Remote{ public void update(int player, int x, int y, String action) throws RemoteException; }
With this we see the exact nature of the bug:
public void update(int player, int x, int y, String action) { System.out.println("Player " + this.id + " updated by player " + player + " with action: " + action); if (players[player] == null) { players[player] = new Penguin(x, y, 30, 30, "(" + this.id + ", " + player + ")"); players[player].placeIn(this); this.repaint(); } else { players[player].perform(action); } }
New clients don't receive existing information about the world from server, earlier clients.
So last picture, with most penguins, is the oldest (first to be created).
Up | Previous | Next |