Skip to content

Commit

Permalink
Prevent the player from showing up in the player list; handle incoming
Browse files Browse the repository at this point in the history
invisible connections.
  • Loading branch information
njs11009 committed Dec 9, 2015
1 parent 723e1de commit 9d62f37
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 32 deletions.
22 changes: 0 additions & 22 deletions MegaMek/src/megamek/client/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ public class Client implements IClientCommandHandler {

// we need these to communicate with the server
private String name;
private boolean conAsInvis;

private IConnection connection;

Expand Down Expand Up @@ -250,27 +249,6 @@ public Client(String name, String host, int port) {

rsg = new RandomSkillsGenerator();
}

public Client(String name, String host, int port, boolean invisible) {
// construct new client
this.name = name;
this.host = host;
this.port = port;
this.conAsInvis = invisible;

registerCommand(new HelpCommand(this));
registerCommand(new MoveCommand(this));
registerCommand(new RulerCommand(this));
registerCommand(new ShowEntityCommand(this));
registerCommand(new FireCommand(this));
registerCommand(new DeployCommand(this));
registerCommand(new ShowTileCommand(this));
registerCommand(new AddBotCommand(this));
registerCommand(new AssignNovaNetworkCommand(this));

rsg = new RandomSkillsGenerator();
}


public int getLocalPlayerNumber() {
return localPlayerNumber;
Expand Down
11 changes: 1 addition & 10 deletions MegaMek/src/megamek/client/ui/swing/MegaMekGUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -735,17 +735,8 @@ void connect() {
Messages.getString("MegaMek.ConnectAlert.message"), Messages.getString("MegaMek.ConnectAlert.title"), JOptionPane.ERROR_MESSAGE); //$NON-NLS-1$ //$NON-NLS-2$
return;
}
boolean conAsInvis = false;
if (cd.spectateValue.equalsIgnoreCase("Yes")) {
conAsInvis = true;
}
// initialize game
if(!conAsInvis){
client = new Client(cd.playerName, cd.serverAddr, cd.port);
}
else {
client = new Client(cd.playerName, cd.serverAddr, cd.port, true);
}
client = new Client(cd.playerName, cd.serverAddr, cd.port);
ClientGUI gui = new ClientGUI(client,controller);
controller.clientgui = gui;
frame.setCursor(new Cursor(Cursor.WAIT_CURSOR));
Expand Down
4 changes: 4 additions & 0 deletions MegaMek/src/megamek/client/ui/swing/PlayerListDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,10 @@ public static void refreshPlayerList(JList<String> playerList,
}
((DefaultListModel<String>) playerList.getModel())
.addElement(playerDisplay.toString());

if(player.isInvisible()) {
playerDisplay.delete(0, playerDisplay.length()-1);
}
}
}

Expand Down
3 changes: 3 additions & 0 deletions MegaMek/src/megamek/server/Server.java
Original file line number Diff line number Diff line change
Expand Up @@ -879,9 +879,12 @@ private void receivePlayerVersion(Packet packet, int connId) {
if (needs) {
IPlayer player = getPlayer(connId);
if (null != player) {
if(!player.isInvisible())
{
sendServerChat("For " + player.getName() + " Server reports:"
+ System.lineSeparator()
+ buf.toString());
}
}
} else {
System.out.println("SUCCESS: Client/Server Version ("+version+") and Checksum ("+clientChecksum+") matched");
Expand Down

0 comments on commit 9d62f37

Please sign in to comment.