mirror of
https://github.com/simon987/Much-Assembly-Required.git
synced 2025-04-19 18:46:43 +00:00
Fixes #115
This commit is contained in:
parent
0bd25df977
commit
a8beb8c3e2
@ -21,30 +21,32 @@ public class CodeUploadHandler implements MessageHandler {
|
||||
//TODO Should we wait at the end of the tick to modify the CPU ?
|
||||
user.getUser().setUserCode((String) json.get("code"));
|
||||
|
||||
AssemblyResult ar = new Assembler(user.getUser().getCpu().getInstructionSet(),
|
||||
user.getUser().getCpu().getRegisterSet(),
|
||||
GameServer.INSTANCE.getConfig()).parse(user.getUser().getUserCode());
|
||||
if (user.getUser().getUserCode() != null) {
|
||||
AssemblyResult ar = new Assembler(user.getUser().getCpu().getInstructionSet(),
|
||||
user.getUser().getCpu().getRegisterSet(),
|
||||
GameServer.INSTANCE.getConfig()).parse(user.getUser().getUserCode());
|
||||
|
||||
user.getUser().getCpu().getMemory().clear();
|
||||
user.getUser().getCpu().getMemory().clear();
|
||||
|
||||
//Write assembled code to mem
|
||||
char[] assembledCode = ar.getWords();
|
||||
//Write assembled code to mem
|
||||
char[] assembledCode = ar.getWords();
|
||||
|
||||
user.getUser().getCpu().getMemory().write((char) ar.origin, assembledCode, 0, assembledCode.length);
|
||||
user.getUser().getCpu().setCodeSectionOffset(ar.getCodeSectionOffset());
|
||||
user.getUser().getCpu().getMemory().write((char) ar.origin, assembledCode, 0, assembledCode.length);
|
||||
user.getUser().getCpu().setCodeSectionOffset(ar.getCodeSectionOffset());
|
||||
|
||||
//Clear keyboard buffer
|
||||
if (user.getUser().getControlledUnit() != null &&
|
||||
user.getUser().getControlledUnit().getKeyboardBuffer() != null) {
|
||||
user.getUser().getControlledUnit().getKeyboardBuffer().clear();
|
||||
//Clear keyboard buffer
|
||||
if (user.getUser().getControlledUnit() != null &&
|
||||
user.getUser().getControlledUnit().getKeyboardBuffer() != null) {
|
||||
user.getUser().getControlledUnit().getKeyboardBuffer().clear();
|
||||
}
|
||||
|
||||
|
||||
JSONObject response = new JSONObject();
|
||||
response.put("t", "codeResponse");
|
||||
response.put("bytes", ar.bytes.length);
|
||||
|
||||
user.getWebSocket().send(response.toJSONString());
|
||||
}
|
||||
|
||||
|
||||
JSONObject response = new JSONObject();
|
||||
response.put("t", "codeResponse");
|
||||
response.put("bytes", ar.bytes.length);
|
||||
|
||||
user.getWebSocket().send(response.toJSONString());
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user