mirror of
https://github.com/michaelrausch/Party-Parrots-At-Sea.git
synced 2026-05-09 14:28:43 +00:00
Merge request fixes
#story[1246]
This commit is contained in:
@@ -211,10 +211,10 @@ public class ServerToClientThread implements Runnable, Observer {
|
||||
completeRegistration(requestedType);
|
||||
break;
|
||||
case CHATTER_TEXT:
|
||||
// GameState.broadcastChatter(
|
||||
// ServerPacketParser.extractChatterText(payload)
|
||||
// );
|
||||
parseChatter(payload);
|
||||
ChatterMessage chatterMessage = ServerPacketParser
|
||||
.extractChatterText(
|
||||
new StreamPacket(type, payloadLength, timeStamp, payload));
|
||||
GameState.processChatter(chatterMessage, isHost);
|
||||
break;
|
||||
case RACE_CUSTOMIZATION_REQUEST:
|
||||
Long sourceID = Message
|
||||
@@ -381,35 +381,36 @@ public class ServerToClientThread implements Runnable, Observer {
|
||||
isHost = true;
|
||||
}
|
||||
|
||||
private void parseChatter(byte[] chatterPayload) {
|
||||
String chatterText = new String(
|
||||
Arrays.copyOfRange(chatterPayload, 3, 3 + chatterPayload.length)
|
||||
);
|
||||
String[] words = chatterText.split("\\s+");
|
||||
if (words.length > 2 && isHost) {
|
||||
switch (words[2].trim()) {
|
||||
case ">speed":
|
||||
try {
|
||||
GameState.setSpeedMultiplier(Double.valueOf(words[3]));
|
||||
GameState.broadcastChatter(new ChatterMessage(
|
||||
Byte.toUnsignedInt(chatterPayload[1]),
|
||||
"SERVER: Speed modifier set to x" + words[3]
|
||||
));
|
||||
} catch (Exception e) {
|
||||
logger.error("cannot parse >speed value");
|
||||
}
|
||||
return;
|
||||
case ">finish":
|
||||
GameState.broadcastChatter(new ChatterMessage(
|
||||
chatterPayload[1],
|
||||
"SERVER: Game will now finish"
|
||||
));
|
||||
GameState.endRace();
|
||||
return;
|
||||
}
|
||||
}
|
||||
GameState.broadcastChatter(
|
||||
ServerPacketParser.extractChatterText(chatterPayload)
|
||||
);
|
||||
private void checkChatterForCommands(ChatterMessage chatterMessage) {
|
||||
|
||||
// String chatterText = new String(
|
||||
// Arrays.copyOfRange(chatterPayload, 3, 3 + chatterPayload.length)
|
||||
// );
|
||||
// String[] words = chatterText.split("\\s+");
|
||||
// if (words.length > 2 && isHost) {
|
||||
// switch (words[2].trim()) {
|
||||
// case ">speed":
|
||||
// try {
|
||||
// GameState.setSpeedMultiplier(Double.valueOf(words[3]));
|
||||
// GameState.broadcastChatter(new ChatterMessage(
|
||||
// Byte.toUnsignedInt(chatterPayload[1]),
|
||||
// "SERVER: Speed modifier set to x" + words[3]
|
||||
// ));
|
||||
// } catch (Exception e) {
|
||||
// logger.error("cannot parse >speed value");
|
||||
// }
|
||||
// return;
|
||||
// case ">finish":
|
||||
// GameState.broadcastChatter(new ChatterMessage(
|
||||
// chatterPayload[1],
|
||||
// "SERVER: Game will now finish"
|
||||
// ));
|
||||
// GameState.endRace();
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
// GameState.broadcastChatter(
|
||||
// ServerPacketParser.extractChatterText(chatterPayload)
|
||||
// );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user