mirror of
https://github.com/simon987/Much-Assembly-Required.git
synced 2025-04-19 18:46:43 +00:00
Merge branch 'master' of https://github.com/simon987/Much-Assembly-Required into Interupts
This commit is contained in:
commit
9e14467ccd
3
.gitignore
vendored
3
.gitignore
vendored
@ -12,3 +12,6 @@ mar.log.lck
|
||||
plugins/*.jar
|
||||
save.json
|
||||
Server/Server.iml
|
||||
target/*
|
||||
Server/Server.iml
|
||||
Server/src/main/java/META-INF/MANIFEST.MF
|
||||
|
@ -8,16 +8,16 @@ import org.json.simple.JSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class Cubot extends GameObject implements Updatable, ControllableUnit {
|
||||
public class Cubot extends GameObject implements Updatable, ControllableUnit, Programmable {
|
||||
|
||||
private static final char MAP_INFO = 0x0080;
|
||||
public static final int ID = 1;
|
||||
|
||||
private char hologram = 0;
|
||||
private int hologram = 0;
|
||||
private String hologramString = "";
|
||||
private HologramMode hologramMode = HologramMode.CLEARED;
|
||||
|
||||
private char lastHologram = 0;
|
||||
private HologramMode lastHologramMode = HologramMode.CLEARED;
|
||||
private int hologramColor = 0;
|
||||
|
||||
/**
|
||||
* Hit points
|
||||
@ -30,7 +30,10 @@ public class Cubot extends GameObject implements Updatable, ControllableUnit {
|
||||
|
||||
private ArrayList<Integer> keyboardBuffer = new ArrayList<>();
|
||||
|
||||
private FloppyDisk floppyDisk;
|
||||
private ArrayList<char[]> consoleMessagesBuffer = new ArrayList<>(CONSOLE_BUFFER_MAX_SIZE);
|
||||
private ArrayList<char[]> lastConsoleMessagesBuffer = new ArrayList<>(CONSOLE_BUFFER_MAX_SIZE);
|
||||
private ConsoleMode consoleMode = ConsoleMode.NORMAL;
|
||||
private ConsoleMode lastConsoleMode = ConsoleMode.NORMAL;
|
||||
|
||||
private User parent;
|
||||
|
||||
@ -38,6 +41,7 @@ public class Cubot extends GameObject implements Updatable, ControllableUnit {
|
||||
private int maxEnergy;
|
||||
|
||||
private static final float SOLAR_PANEL_MULTIPLIER = 1;
|
||||
private static final int CONSOLE_BUFFER_MAX_SIZE = 40;
|
||||
|
||||
public Cubot() {
|
||||
|
||||
@ -73,8 +77,15 @@ public class Cubot extends GameObject implements Updatable, ControllableUnit {
|
||||
currentAction = Action.IDLE;
|
||||
|
||||
//Same principle for hologram
|
||||
lastHologram = hologram;
|
||||
hologram = 0;
|
||||
lastHologramMode = hologramMode;
|
||||
hologramMode = HologramMode.CLEARED;
|
||||
|
||||
//And the console
|
||||
lastConsoleMode = consoleMode;
|
||||
consoleMode = ConsoleMode.NORMAL;
|
||||
|
||||
lastConsoleMessagesBuffer = new ArrayList<>(consoleMessagesBuffer);
|
||||
consoleMessagesBuffer.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -88,9 +99,10 @@ public class Cubot extends GameObject implements Updatable, ControllableUnit {
|
||||
json.put("heldItem", heldItem);
|
||||
json.put("hp", hp);
|
||||
json.put("action", lastAction.ordinal());
|
||||
json.put("holo", (int) lastHologram);
|
||||
json.put("holo", hologram);
|
||||
json.put("holoStr", hologramString);
|
||||
json.put("holoMode", hologramMode.ordinal());
|
||||
json.put("holoMode", lastHologramMode.ordinal());
|
||||
json.put("holoC", hologramColor);
|
||||
json.put("energy", energy);
|
||||
|
||||
if (parent != null) {
|
||||
@ -158,13 +170,10 @@ public class Cubot extends GameObject implements Updatable, ControllableUnit {
|
||||
return currentAction;
|
||||
}
|
||||
|
||||
public void setHologram(char hologram) {
|
||||
public void setHologram(int hologram) {
|
||||
this.hologram = hologram;
|
||||
}
|
||||
|
||||
public char getHologram() {
|
||||
return lastHologram;
|
||||
}
|
||||
|
||||
public void setHologramString(String hologramString) {
|
||||
this.hologramString = hologramString;
|
||||
@ -226,6 +235,42 @@ public class Cubot extends GameObject implements Updatable, ControllableUnit {
|
||||
public enum HologramMode {
|
||||
CLEARED,
|
||||
HEX,
|
||||
STRING
|
||||
STRING,
|
||||
DEC
|
||||
}
|
||||
|
||||
public enum ConsoleMode {
|
||||
CLEAR,
|
||||
NORMAL
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAction(Action action) {
|
||||
currentAction = action;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(char[] message) {
|
||||
|
||||
if (consoleMessagesBuffer.size() < CONSOLE_BUFFER_MAX_SIZE) {
|
||||
consoleMessagesBuffer.add(message);
|
||||
}
|
||||
}
|
||||
|
||||
public ArrayList<char[]> getConsoleMessagesBuffer() {
|
||||
return lastConsoleMessagesBuffer;
|
||||
}
|
||||
|
||||
|
||||
public int getConsoleMode() {
|
||||
return lastConsoleMode.ordinal();
|
||||
}
|
||||
|
||||
public void setConsoleMode(ConsoleMode consoleMode) {
|
||||
this.consoleMode = consoleMode;
|
||||
}
|
||||
|
||||
public void setHologramColor(int hologramColor) {
|
||||
this.hologramColor = hologramColor;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,132 @@
|
||||
package net.simon987.cubotplugin;
|
||||
|
||||
import net.simon987.server.GameServer;
|
||||
import net.simon987.server.assembly.CpuHardware;
|
||||
import net.simon987.server.assembly.Status;
|
||||
import net.simon987.server.game.GameObject;
|
||||
import net.simon987.server.game.Programmable;
|
||||
import org.json.simple.JSONObject;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class CubotComPort extends CpuHardware {
|
||||
|
||||
public static final char HWID = 0xD;
|
||||
public static final int DEFAULT_ADDRESS = 0xD;
|
||||
|
||||
private Cubot cubot;
|
||||
|
||||
private static final int SELF_CLEAR = 0;
|
||||
private static final int POLL = 1;
|
||||
private static final int FRONT_PORT_OUT = 2;
|
||||
private static final int SELF_OUT = 3;
|
||||
|
||||
public CubotComPort(Cubot cubot) {
|
||||
this.cubot = cubot;
|
||||
}
|
||||
|
||||
private static final int MESSAGE_LENGTH = 8;
|
||||
|
||||
@Override
|
||||
public void handleInterrupt(Status status) {
|
||||
|
||||
int a = getCpu().getRegisterSet().getRegister("A").getValue();
|
||||
|
||||
if (a == SELF_CLEAR) {
|
||||
|
||||
cubot.getConsoleMessagesBuffer().clear();
|
||||
cubot.setConsoleMode(Cubot.ConsoleMode.CLEAR);
|
||||
|
||||
} else if (a == POLL) {
|
||||
|
||||
if (cubot.spendEnergy(4)) {
|
||||
|
||||
int x = getCpu().getRegisterSet().getRegister("X").getValue();
|
||||
|
||||
//Read all messages in the console buffer to memory at X
|
||||
|
||||
for (char[] message : cubot.getConsoleMessagesBuffer()) {
|
||||
if (x + MESSAGE_LENGTH >= getCpu().getMemory().getWords().length) {
|
||||
//todo set interrupt ?
|
||||
getCpu().getStatus().setErrorFlag(true);
|
||||
} else {
|
||||
System.arraycopy(message, 0, getCpu().getMemory().getWords(), x, MESSAGE_LENGTH);
|
||||
}
|
||||
}
|
||||
|
||||
//Set B = number of messages
|
||||
getCpu().getRegisterSet().getRegister("B").setValue(cubot.getConsoleMessagesBuffer().size());
|
||||
|
||||
}
|
||||
|
||||
} else if (a == FRONT_PORT_OUT) {
|
||||
|
||||
if (cubot.spendEnergy(20)) {
|
||||
//Get object directly in front of the Cubot
|
||||
Point frontTile = cubot.getFrontTile();
|
||||
//Todo will have to add getGameObjectsBlockingAt to enable Factory
|
||||
ArrayList<GameObject> objects = cubot.getWorld().getGameObjectsAt(frontTile.x, frontTile.y);
|
||||
|
||||
if (objects.size() > 0 && objects.get(0) instanceof Programmable) {
|
||||
|
||||
int x = getCpu().getRegisterSet().getRegister("X").getValue();
|
||||
|
||||
if (x + MESSAGE_LENGTH >= getCpu().getMemory().getWords().length) {
|
||||
//todo set interrupt ?
|
||||
getCpu().getStatus().setErrorFlag(true);
|
||||
} else {
|
||||
|
||||
//Get MESSAGE_LENGTH-word message pointed by X
|
||||
char[] message = new char[MESSAGE_LENGTH];
|
||||
System.arraycopy(getCpu().getMemory().getWords(), x, message, 0, MESSAGE_LENGTH);
|
||||
|
||||
//Send it to the Programmable object
|
||||
((Programmable) objects.get(0)).sendMessage(message);
|
||||
|
||||
System.out.println("Sent message to " + ((Cubot) objects.get(0)).getParent().getUsername());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else if (a == SELF_OUT) {
|
||||
|
||||
if (cubot.spendEnergy(1)) {
|
||||
|
||||
int x = getCpu().getRegisterSet().getRegister("X").getValue();
|
||||
|
||||
//Write a single message to console buffer
|
||||
if (x + MESSAGE_LENGTH >= getCpu().getMemory().getWords().length) {
|
||||
//todo set interrupt ?
|
||||
getCpu().getStatus().setErrorFlag(true);
|
||||
} else {
|
||||
|
||||
//Get MESSAGE_LENGTH-word message pointed by X
|
||||
char[] message = new char[MESSAGE_LENGTH];
|
||||
System.arraycopy(getCpu().getMemory().getWords(), x, message, 0, MESSAGE_LENGTH);
|
||||
cubot.sendMessage(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public char getId() {
|
||||
return HWID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject serialise() {
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("hwid", (int) HWID);
|
||||
json.put("cubot", cubot.getObjectId());
|
||||
|
||||
return json;
|
||||
}
|
||||
|
||||
public static CubotComPort deserialize(JSONObject json) {
|
||||
return new CubotComPort((Cubot) GameServer.INSTANCE.getGameUniverse().getObject((int) (long) json.get("cubot")));
|
||||
}
|
||||
}
|
@ -20,6 +20,8 @@ public class CubotHologram extends CpuHardware {
|
||||
private static final int CLEAR = 0;
|
||||
private static final int DISPLAY_HEX = 1;
|
||||
private static final int DISPLAY_STRING = 2;
|
||||
private static final int DISPLAY_DEC = 3;
|
||||
private static final int DISPLAY_COLOR = 4;
|
||||
|
||||
private static final int STR_MAX_LEN = 8;
|
||||
|
||||
@ -57,6 +59,20 @@ public class CubotHologram extends CpuHardware {
|
||||
|
||||
cubot.setHologramString(holoString.toString());
|
||||
cubot.setHologramMode(Cubot.HologramMode.STRING);
|
||||
} else if (a == DISPLAY_DEC) {
|
||||
//Display decimal number
|
||||
char b = getCpu().getRegisterSet().getRegister("B").getValue();
|
||||
cubot.setHologram(b);
|
||||
cubot.setHologramMode(Cubot.HologramMode.DEC);
|
||||
|
||||
} else if (a == DISPLAY_COLOR) {
|
||||
|
||||
if (cubot.spendEnergy(4)) {
|
||||
int b = getCpu().getRegisterSet().getRegister("B").getValue();
|
||||
int c = getCpu().getRegisterSet().getRegister("C").getValue();
|
||||
|
||||
cubot.setHologramColor((c | (b << 16))); //B:C
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -16,8 +16,8 @@ public class CubotInventory extends CpuHardware {
|
||||
|
||||
private Cubot cubot;
|
||||
|
||||
private static final int CLEAR = 0;
|
||||
private static final int POLL = 1;
|
||||
private static final int CLEAR = 2;
|
||||
|
||||
public CubotInventory(Cubot cubot) {
|
||||
this.cubot = cubot;
|
||||
|
@ -5,7 +5,7 @@ import net.simon987.server.assembly.CpuHardware;
|
||||
import net.simon987.server.assembly.Status;
|
||||
import org.json.simple.JSONObject;
|
||||
|
||||
public class Keyboard extends CpuHardware {
|
||||
public class CubotKeyboard extends CpuHardware {
|
||||
|
||||
public static final int DEFAULT_ADDRESS = 4;
|
||||
|
||||
@ -19,7 +19,7 @@ public class Keyboard extends CpuHardware {
|
||||
|
||||
private Cubot cubot;
|
||||
|
||||
public Keyboard(Cubot cubot) {
|
||||
public CubotKeyboard(Cubot cubot) {
|
||||
this.cubot = cubot;
|
||||
}
|
||||
|
||||
@ -61,7 +61,7 @@ public class Keyboard extends CpuHardware {
|
||||
return json;
|
||||
}
|
||||
|
||||
public static Keyboard deserialize(JSONObject hwJSON) {
|
||||
return new Keyboard((Cubot) GameServer.INSTANCE.getGameUniverse().getObject((int) (long) hwJSON.get("cubot")));
|
||||
public static CubotKeyboard deserialize(JSONObject hwJSON) {
|
||||
return new CubotKeyboard((Cubot) GameServer.INSTANCE.getGameUniverse().getObject((int) (long) hwJSON.get("cubot")));
|
||||
}
|
||||
}
|
@ -46,7 +46,7 @@ public class CubotLaser extends CpuHardware {
|
||||
|
||||
|
||||
Point frontTile = cubot.getFrontTile();
|
||||
ArrayList<GameObject> objects = cubot.getWorld().getGameObjectsAt(frontTile.x, frontTile.y);
|
||||
ArrayList<GameObject> objects = cubot.getWorld().getGameObjectsBlockingAt(frontTile.x, frontTile.y);
|
||||
|
||||
|
||||
if (cubot.getCurrentAction() == Action.IDLE && objects.size() > 0) {
|
||||
@ -62,8 +62,6 @@ public class CubotLaser extends CpuHardware {
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
System.out.println("\n\n\n\n\n It did it");
|
||||
}
|
||||
|
||||
|
||||
|
@ -55,16 +55,18 @@ public class CubotLeg extends CpuHardware implements JSONSerialisable {
|
||||
|
||||
} else if (a == SET_DIR_AND_WALK) {
|
||||
|
||||
Direction dir = Direction.getDirection(b);
|
||||
if (cubot.getMaxEnergy() >= 100) {
|
||||
Direction dir = Direction.getDirection(b);
|
||||
|
||||
if (dir != null) {
|
||||
cubot.setDirection(Direction.getDirection(b));
|
||||
status.setErrorFlag(false);
|
||||
} else {
|
||||
status.setErrorFlag(true);
|
||||
if (dir != null) {
|
||||
cubot.setDirection(Direction.getDirection(b));
|
||||
status.setErrorFlag(false);
|
||||
} else {
|
||||
status.setErrorFlag(true);
|
||||
}
|
||||
|
||||
cubot.setCurrentAction(Action.WALKING);
|
||||
}
|
||||
|
||||
cubot.setCurrentAction(Action.WALKING);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -50,14 +50,16 @@ public class CubotPlugin extends ServerPlugin implements GameObjectDeserializer,
|
||||
return CubotDrill.deserialize(hwJson);
|
||||
case CubotInventory.HWID:
|
||||
return CubotInventory.deserialize(hwJson);
|
||||
case Keyboard.HWID:
|
||||
return Keyboard.deserialize(hwJson);
|
||||
case CubotKeyboard.HWID:
|
||||
return CubotKeyboard.deserialize(hwJson);
|
||||
case CubotHologram.HWID:
|
||||
return CubotHologram.deserialize(hwJson);
|
||||
case CubotBattery.HWID:
|
||||
return CubotBattery.deserialize(hwJson);
|
||||
case CubotFloppyDrive.HWID:
|
||||
return CubotFloppyDrive.deserialize(hwJson);
|
||||
case CubotComPort.HWID:
|
||||
return CubotComPort.deserialize(hwJson);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
@ -5,7 +5,6 @@ import net.simon987.server.assembly.CPU;
|
||||
import net.simon987.server.event.CpuInitialisationEvent;
|
||||
import net.simon987.server.event.GameEvent;
|
||||
import net.simon987.server.event.GameEventListener;
|
||||
import net.simon987.server.logging.LogManager;
|
||||
import net.simon987.server.user.User;
|
||||
|
||||
public class CpuInitialisationListener implements GameEventListener {
|
||||
@ -16,7 +15,7 @@ public class CpuInitialisationListener implements GameEventListener {
|
||||
|
||||
@Override
|
||||
public void handle(GameEvent event) {
|
||||
LogManager.LOGGER.fine("(Plugin) Handled CPU Initialisation event (Cubot Plugin)");
|
||||
//LogManager.LOGGER.fine("(Plugin) Handled CPU Initialisation event (Cubot Plugin)");
|
||||
|
||||
CPU cpu = (CPU) event.getSource();
|
||||
User user = ((CpuInitialisationEvent) event).getUser();
|
||||
@ -27,7 +26,7 @@ public class CpuInitialisationListener implements GameEventListener {
|
||||
laserHw.setCpu(cpu);
|
||||
CubotLidar radarHw = new CubotLidar((Cubot) user.getControlledUnit());
|
||||
radarHw.setCpu(cpu);
|
||||
Keyboard keyboard = new Keyboard((Cubot) user.getControlledUnit());
|
||||
CubotKeyboard keyboard = new CubotKeyboard((Cubot) user.getControlledUnit());
|
||||
keyboard.setCpu(cpu);
|
||||
CubotDrill drillHw = new CubotDrill((Cubot) user.getControlledUnit());
|
||||
drillHw.setCpu(cpu);
|
||||
@ -39,16 +38,19 @@ public class CpuInitialisationListener implements GameEventListener {
|
||||
batteryHw.setCpu(cpu);
|
||||
CubotFloppyDrive floppyHw = new CubotFloppyDrive((Cubot) user.getControlledUnit());
|
||||
floppyHw.setCpu(cpu);
|
||||
CubotComPort comPortHw = new CubotComPort((Cubot) user.getControlledUnit());
|
||||
comPortHw.setCpu(cpu);
|
||||
|
||||
cpu.attachHardware(legHw, CubotLeg.DEFAULT_ADDRESS);
|
||||
cpu.attachHardware(laserHw, CubotLaser.DEFAULT_ADDRESS);
|
||||
cpu.attachHardware(radarHw, CubotLidar.DEFAULT_ADDRESS);
|
||||
cpu.attachHardware(keyboard, Keyboard.DEFAULT_ADDRESS);
|
||||
cpu.attachHardware(keyboard, CubotKeyboard.DEFAULT_ADDRESS);
|
||||
cpu.attachHardware(drillHw, CubotDrill.DEFAULT_ADDRESS);
|
||||
cpu.attachHardware(invHw, CubotInventory.DEFAULT_ADDRESS);
|
||||
cpu.attachHardware(invHw, CubotInventory.DEFAULT_ADDRESS);
|
||||
cpu.attachHardware(emoteHw, CubotHologram.DEFAULT_ADDRESS);
|
||||
cpu.attachHardware(batteryHw, CubotBattery.DEFAULT_ADDRESS);
|
||||
cpu.attachHardware(floppyHw, CubotFloppyDrive.DEFAULT_ADDRESS);
|
||||
cpu.attachHardware(comPortHw, CubotComPort.DEFAULT_ADDRESS);
|
||||
}
|
||||
}
|
||||
|
@ -124,7 +124,7 @@ public class Factory extends GameObject implements Updatable {
|
||||
factory.setX((int) (long) json.get("x"));
|
||||
factory.setY((int) (long) json.get("y"));
|
||||
|
||||
factory.tmpNpcArray = (Object[]) ((JSONArray) json.get("n")).toArray();
|
||||
factory.tmpNpcArray = ((JSONArray) json.get("n")).toArray();
|
||||
|
||||
return factory;
|
||||
}
|
||||
|
@ -1,35 +1,65 @@
|
||||
package net.simon987.npcplugin;
|
||||
|
||||
import net.simon987.npcplugin.event.CpuInitialisationListener;
|
||||
import net.simon987.npcplugin.event.WorldCreationListener;
|
||||
import net.simon987.server.ServerConfiguration;
|
||||
import net.simon987.server.assembly.CpuHardware;
|
||||
import net.simon987.server.game.GameObject;
|
||||
import net.simon987.server.io.CpuHardwareDeserializer;
|
||||
import net.simon987.server.io.GameObjectDeserializer;
|
||||
import net.simon987.server.logging.LogManager;
|
||||
import net.simon987.server.plugin.ServerPlugin;
|
||||
import org.json.simple.JSONObject;
|
||||
|
||||
public class NpcPlugin extends ServerPlugin implements GameObjectDeserializer {
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class NpcPlugin extends ServerPlugin implements GameObjectDeserializer, CpuHardwareDeserializer {
|
||||
|
||||
/**
|
||||
* Radio tower cache
|
||||
*/
|
||||
private static ArrayList<RadioTower> radioTowers;
|
||||
|
||||
@Override
|
||||
public void init(ServerConfiguration configuration) {
|
||||
|
||||
listeners.add(new WorldCreationListener());
|
||||
listeners.add(new CpuInitialisationListener());
|
||||
|
||||
radioTowers = new ArrayList<>(32);
|
||||
|
||||
LogManager.LOGGER.info("Initialised NPC plugin");
|
||||
}
|
||||
|
||||
@Override
|
||||
public GameObject deserializeObject(JSONObject object) {
|
||||
public GameObject deserializeObject(JSONObject json) {
|
||||
|
||||
int objType = (int) (long) object.get("t");
|
||||
int objType = (int) (long) json.get("t");
|
||||
|
||||
if (objType == HarvesterNPC.ID) {
|
||||
return HarvesterNPC.deserialize(object);
|
||||
return HarvesterNPC.deserialize(json);
|
||||
} else if (objType == Factory.ID) {
|
||||
return Factory.deserialise(object);
|
||||
return Factory.deserialise(json);
|
||||
} else if (objType == RadioTower.ID) {
|
||||
return RadioTower.deserialize(json);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CpuHardware deserializeHardware(JSONObject hwJson) {
|
||||
int hwid = (int) (long) hwJson.get("hwid");
|
||||
|
||||
switch (hwid) {
|
||||
case RadioReceiverHardware.HWID:
|
||||
return RadioReceiverHardware.deserialize(hwJson);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static ArrayList<RadioTower> getRadioTowers() {
|
||||
return radioTowers;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,79 @@
|
||||
package net.simon987.npcplugin;
|
||||
|
||||
import net.simon987.server.GameServer;
|
||||
import net.simon987.server.assembly.CpuHardware;
|
||||
import net.simon987.server.assembly.Status;
|
||||
import net.simon987.server.assembly.Util;
|
||||
import net.simon987.server.game.Action;
|
||||
import net.simon987.server.game.ControllableUnit;
|
||||
import org.json.simple.JSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class RadioReceiverHardware extends CpuHardware {
|
||||
|
||||
public static final char HWID = 0xC; //12
|
||||
|
||||
private static final int LISTEN = 1;
|
||||
|
||||
public static final int DEFAULT_ADDRESS = 0xC;
|
||||
|
||||
private ControllableUnit cubot;
|
||||
|
||||
public RadioReceiverHardware(ControllableUnit cubot) {
|
||||
this.cubot = cubot;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleInterrupt(Status status) {
|
||||
int x = getCpu().getRegisterSet().getRegister("X").getValue();
|
||||
int a = getCpu().getRegisterSet().getRegister("A").getValue();
|
||||
|
||||
if (a == LISTEN) {
|
||||
|
||||
//Find the nearest Radio Tower and query it
|
||||
cubot.setAction(Action.LISTENING);
|
||||
|
||||
ArrayList<char[]> messages = new ArrayList<>(6);
|
||||
|
||||
ArrayList<RadioTower> towers = new ArrayList<>(NpcPlugin.getRadioTowers()); //Avoid ConcurrentModificationException
|
||||
for (RadioTower tower : towers) {
|
||||
if (Util.manhattanDist(tower.getWorld().getX(), tower.getWorld().getY(), cubot.getWorld().getX(),
|
||||
cubot.getWorld().getY()) <= RadioTower.MAX_RANGE) {
|
||||
//Tower is in range
|
||||
messages.addAll(tower.getMessages());
|
||||
}
|
||||
}
|
||||
|
||||
//Write messages to memory
|
||||
int offset = 0;
|
||||
|
||||
for (char[] message : messages) {
|
||||
|
||||
getCpu().getMemory().write(x + offset, message, 0, message.length);
|
||||
offset += message.length;
|
||||
}
|
||||
|
||||
//Write the amount of messages received to B
|
||||
getCpu().getRegisterSet().getRegister("B").setValue(messages.size());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public char getId() {
|
||||
return HWID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject serialise() {
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("hwid", (int) HWID);
|
||||
json.put("cubot", cubot.getObjectId());
|
||||
|
||||
return json;
|
||||
}
|
||||
|
||||
public static RadioReceiverHardware deserialize(JSONObject json) {
|
||||
return new RadioReceiverHardware((ControllableUnit) GameServer.INSTANCE.getGameUniverse().getObject((int) (long) json.get("cubot")));
|
||||
}
|
||||
}
|
@ -1,4 +1,103 @@
|
||||
package net.simon987.npcplugin;
|
||||
|
||||
public class RadioTower {
|
||||
import net.simon987.server.game.GameObject;
|
||||
import net.simon987.server.game.Programmable;
|
||||
import net.simon987.server.game.Updatable;
|
||||
import org.json.simple.JSONObject;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class RadioTower extends GameObject implements Programmable, Updatable {
|
||||
|
||||
private static final int MAP_INFO = 0x1000;
|
||||
|
||||
public static final int ID = 4;
|
||||
|
||||
public static final int MAX_RANGE = 3; //todo load from config
|
||||
|
||||
private static final int MAX_MESSAGES = 16;
|
||||
|
||||
@Override
|
||||
public char getMapInfo() {
|
||||
return MAP_INFO;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Messages from the current tick
|
||||
*/
|
||||
private ArrayList<char[]> messages = new ArrayList<>(4);
|
||||
|
||||
/**
|
||||
* Messages from the last tick
|
||||
*/
|
||||
private ArrayList<char[]> lastMessages = new ArrayList<>(4);
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
lastMessages = new ArrayList<>(messages);
|
||||
messages.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(char[] message) {
|
||||
|
||||
if (message.length < MAX_MESSAGES) {
|
||||
messages.add(message);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject serialise() {
|
||||
|
||||
JSONObject json = new JSONObject();
|
||||
|
||||
json.put("i", getObjectId());
|
||||
json.put("x", getX());
|
||||
json.put("y", getY());
|
||||
json.put("t", ID);
|
||||
|
||||
return json;
|
||||
|
||||
}
|
||||
|
||||
public static RadioTower deserialize(JSONObject json) {
|
||||
|
||||
RadioTower tower = new RadioTower();
|
||||
tower.setObjectId((long) json.get("i"));
|
||||
tower.setX((int) (long) json.get("x"));
|
||||
tower.setY((int) (long) json.get("y"));
|
||||
|
||||
NpcPlugin.getRadioTowers().add(tower);
|
||||
|
||||
return tower;
|
||||
}
|
||||
|
||||
|
||||
public ArrayList<char[]> getMessages() {
|
||||
return lastMessages;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the first directly adjacent tile (starting east, going clockwise)
|
||||
*/
|
||||
public Point getAdjacentTile() {
|
||||
|
||||
if (!getWorld().isTileBlocked(getX() + 1, getY())) {
|
||||
return new Point(getX() + 1, getY());
|
||||
|
||||
} else if (!getWorld().isTileBlocked(getX(), getY() + 1)) {
|
||||
return new Point(getX(), getY() + 1);
|
||||
|
||||
} else if (!getWorld().isTileBlocked(getX() - 1, getY())) {
|
||||
return new Point(getX() - 1, getY());
|
||||
|
||||
} else if (!getWorld().isTileBlocked(getX(), getY() - 1)) {
|
||||
return new Point(getX(), getY() - 1);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,27 @@
|
||||
package net.simon987.npcplugin.event;
|
||||
|
||||
import net.simon987.npcplugin.RadioReceiverHardware;
|
||||
import net.simon987.server.assembly.CPU;
|
||||
import net.simon987.server.event.CpuInitialisationEvent;
|
||||
import net.simon987.server.event.GameEvent;
|
||||
import net.simon987.server.event.GameEventListener;
|
||||
import net.simon987.server.user.User;
|
||||
|
||||
public class CpuInitialisationListener implements GameEventListener {
|
||||
@Override
|
||||
public Class getListenedEventType() {
|
||||
return CpuInitialisationEvent.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void handle(GameEvent event) {
|
||||
CPU cpu = (CPU) event.getSource();
|
||||
User user = ((CpuInitialisationEvent) event).getUser();
|
||||
|
||||
RadioReceiverHardware radioHw = new RadioReceiverHardware(user.getControlledUnit());
|
||||
radioHw.setCpu(cpu);
|
||||
|
||||
cpu.attachHardware(radioHw, RadioReceiverHardware.DEFAULT_ADDRESS);
|
||||
}
|
||||
}
|
@ -1,6 +1,8 @@
|
||||
package net.simon987.npcplugin.event;
|
||||
|
||||
import net.simon987.npcplugin.Factory;
|
||||
import net.simon987.npcplugin.NpcPlugin;
|
||||
import net.simon987.npcplugin.RadioTower;
|
||||
import net.simon987.server.GameServer;
|
||||
import net.simon987.server.event.GameEvent;
|
||||
import net.simon987.server.event.GameEventListener;
|
||||
@ -8,6 +10,7 @@ import net.simon987.server.event.WorldGenerationEvent;
|
||||
import net.simon987.server.game.World;
|
||||
import net.simon987.server.logging.LogManager;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.Random;
|
||||
|
||||
public class WorldCreationListener implements GameEventListener {
|
||||
@ -31,6 +34,7 @@ public class WorldCreationListener implements GameEventListener {
|
||||
|
||||
World world = ((WorldGenerationEvent) event).getWorld();
|
||||
|
||||
outerLoopFactory:
|
||||
for (int x = 2; x < 12; x++) {
|
||||
for (int y = 2; y < 12; y++) {
|
||||
|
||||
@ -54,10 +58,40 @@ public class WorldCreationListener implements GameEventListener {
|
||||
|
||||
LogManager.LOGGER.info("Spawned Factory at (" + world.getX() + ", " + world.getY() +
|
||||
") (" + x + ", " + y + ")");
|
||||
break outerLoopFactory;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Also spawn a radio tower in the same World
|
||||
Point p = world.getRandomPassableTile();
|
||||
if (p != null) {
|
||||
while (p.x == 0 || p.x == World.WORLD_SIZE - 1 || p.y == World.WORLD_SIZE - 1 || p.y == 0) {
|
||||
p = world.getRandomPassableTile();
|
||||
|
||||
if (p == null) {
|
||||
//World is full
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
RadioTower radioTower = new RadioTower();
|
||||
|
||||
radioTower.setWorld(world);
|
||||
radioTower.setObjectId(GameServer.INSTANCE.getGameUniverse().getNextObjectId());
|
||||
radioTower.setX(p.x);
|
||||
radioTower.setY(p.y);
|
||||
|
||||
if (radioTower.getAdjacentTile() != null) {
|
||||
//Radio Tower has adjacent tiles
|
||||
world.getGameObjects().add(radioTower);
|
||||
world.incUpdatable(); //In case the Factory couldn't be spawned.
|
||||
|
||||
NpcPlugin.getRadioTowers().add(radioTower);
|
||||
|
||||
LogManager.LOGGER.info("Spawned RadioTower at (" + world.getX() + ", " + world.getY() +
|
||||
") (" + p.x + ", " + p.y + ")");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,7 +17,7 @@ public class WorldUtils {
|
||||
|
||||
Random random = new Random();
|
||||
int blobCount = random.nextInt(maxCount - minCount) + minCount;
|
||||
ArrayList<BiomassBlob> biomassBlobs = new ArrayList<>(maxCount);
|
||||
ArrayList<BiomassBlob> biomassBlobs = new ArrayList<>(blobCount);
|
||||
|
||||
//Count number of plain tiles. If there is less plain tiles than desired amount of blobs,
|
||||
//set the desired amount of blobs to the plain tile count
|
||||
@ -45,7 +45,7 @@ public class WorldUtils {
|
||||
//Don't block worlds
|
||||
int counter = 0;
|
||||
while (p.x == 0 || p.y == 0 || p.x == World.WORLD_SIZE - 1 || p.y == World.WORLD_SIZE - 1 ||
|
||||
world.isTileBlocked(p.x, p.y)) {
|
||||
world.getGameObjectsAt(p.x, p.y).size() != 0) {
|
||||
p = world.getTileMap().getRandomPlainTile();
|
||||
counter++;
|
||||
|
||||
|
@ -7,8 +7,6 @@
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
|
||||
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/${parent.project.basedir}/ServerTarget" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/ServerTarget" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/target" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
@ -18,5 +16,7 @@
|
||||
<orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: mysql:mysql-connector-java:5.1.42" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.googlecode.json-simple:json-simple:1.1.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.commons:commons-text:1.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.7" level="project" />
|
||||
</component>
|
||||
</module>
|
@ -4,14 +4,36 @@
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>net.simon987.server</groupId>
|
||||
<artifactId>server_root</artifactId>
|
||||
<version>1.2a</version>
|
||||
</parent>
|
||||
|
||||
<build>
|
||||
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<version>3.0.2</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>default-resources</id>
|
||||
<!-- here the phase you need -->
|
||||
<phase>prepare-package</phase>
|
||||
<goals>
|
||||
<goal>resources</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>../target/</outputDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>../Server/src/main/resources</directory>
|
||||
<filtering>true</filtering>
|
||||
<includes>
|
||||
<include>config.properties</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<version>3.6.2</version>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
@ -21,11 +43,36 @@
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-dependency-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>copy-dependencies</id>
|
||||
<phase>prepare-package</phase>
|
||||
<goals>
|
||||
<goal>copy-dependencies</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>../target/libs</outputDirectory>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>3.0.2</version>
|
||||
<configuration>
|
||||
<outputDirectory>../target</outputDirectory>
|
||||
<archive>
|
||||
<manifest>
|
||||
<mainClass>net.simon987.server.Main</mainClass>
|
||||
<addClasspath>true</addClasspath>
|
||||
<classpathPrefix>libs/</classpathPrefix>
|
||||
</manifest>
|
||||
</archive>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
@ -57,7 +104,17 @@
|
||||
<artifactId>json-simple</artifactId>
|
||||
<version>1.1.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-text</artifactId>
|
||||
<version>1.2</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<properties>
|
||||
<!-- explicitly set build encoding so not altered by build platform defaults -->
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
</project>
|
@ -40,7 +40,7 @@ public class GameServer implements Runnable {
|
||||
|
||||
public GameServer() {
|
||||
|
||||
this.config = new ServerConfiguration(new File("config.properties"));
|
||||
this.config = new ServerConfiguration("config.properties");
|
||||
|
||||
gameUniverse = new GameUniverse(config);
|
||||
pluginManager = new PluginManager();
|
||||
|
@ -12,8 +12,7 @@ public class Main {
|
||||
|
||||
|
||||
LogManager.initialize();
|
||||
ServerConfiguration config = new ServerConfiguration(new File("config.properties"));
|
||||
|
||||
ServerConfiguration config = new ServerConfiguration("config.properties");
|
||||
//Load
|
||||
GameServer.INSTANCE.getGameUniverse().load(new File("save.json"));
|
||||
|
||||
@ -23,6 +22,7 @@ public class Main {
|
||||
|
||||
GameServer.INSTANCE.setSocketServer(socketServer);
|
||||
|
||||
System.out.println(GameServer.INSTANCE.getGameUniverse().getWorld(0x7fff, 0x7fff));
|
||||
|
||||
(new Thread(socketServer)).start();
|
||||
(new Thread(GameServer.INSTANCE)).start();
|
||||
|
@ -6,6 +6,7 @@ import net.simon987.server.logging.LogManager;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Properties;
|
||||
|
||||
/**
|
||||
@ -18,11 +19,11 @@ public class ServerConfiguration {
|
||||
*/
|
||||
private Properties properties;
|
||||
|
||||
public ServerConfiguration(File file) {
|
||||
public ServerConfiguration(String file) {
|
||||
try {
|
||||
properties = new Properties();
|
||||
|
||||
properties.load(new FileInputStream(file));
|
||||
InputStream is = new FileInputStream("config.properties");
|
||||
properties.load(is);
|
||||
|
||||
} catch (IOException e) {
|
||||
LogManager.LOGGER.severe("Problem loading server configuration: " + e.getMessage());
|
||||
|
@ -3,12 +3,15 @@ package net.simon987.server.assembly;
|
||||
import net.simon987.server.ServerConfiguration;
|
||||
import net.simon987.server.assembly.exception.*;
|
||||
import net.simon987.server.logging.LogManager;
|
||||
import org.apache.commons.text.StringEscapeUtils;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.HashMap;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* Top-level class for assembly operations.
|
||||
@ -48,11 +51,9 @@ public class Assembler {
|
||||
* @return The line without its label part
|
||||
*/
|
||||
private static String removeLabel(String line) {
|
||||
if (line.indexOf(':') != -1) {
|
||||
return line.substring(line.indexOf(':') + 1);
|
||||
} else {
|
||||
return line;
|
||||
}
|
||||
|
||||
return line.replaceAll("\\b\\w*\\b:", "");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -94,10 +95,11 @@ public class Assembler {
|
||||
line = removeComment(line);
|
||||
|
||||
//Check for labels
|
||||
if (line.indexOf(':') != -1) {
|
||||
Pattern pattern = Pattern.compile("\\b\\w*\\b:");
|
||||
Matcher matcher = pattern.matcher(line);
|
||||
|
||||
line = line.substring(0, line.indexOf(':'));
|
||||
String label = line.trim();
|
||||
if (matcher.find()) {
|
||||
String label = matcher.group(0).substring(0, matcher.group(0).length() - 1);
|
||||
|
||||
LogManager.LOGGER.fine("DEBUG: Label " + label + " @ " + (result.origin + currentOffset));
|
||||
result.labels.put(label, (char) (result.origin + currentOffset));
|
||||
@ -134,7 +136,8 @@ public class Assembler {
|
||||
|
||||
try {
|
||||
|
||||
String[] values = line.substring(2, line.length()).split(",");
|
||||
//Special thanks to https://stackoverflow.com/questions/1757065/
|
||||
String[] values = line.substring(2, line.length()).split(",(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)", -1);
|
||||
|
||||
for (String value : values) {
|
||||
|
||||
@ -147,7 +150,12 @@ public class Assembler {
|
||||
out.write(parseDUPOperator16(valueTokens, labels, currentLine));
|
||||
} else if (value.startsWith("\"") && value.endsWith("\"")) {
|
||||
//Handle string
|
||||
out.write(value.substring(1, value.length() - 1).getBytes(StandardCharsets.UTF_16));
|
||||
|
||||
//Unescape the string
|
||||
String string = value.substring(1, value.length() - 1);
|
||||
string = StringEscapeUtils.unescapeJava(string);
|
||||
|
||||
out.write(string.getBytes(StandardCharsets.UTF_16BE));
|
||||
} else if (labels != null && labels.containsKey(value)) {
|
||||
//Handle label
|
||||
out.writeChar(labels.get(value));
|
||||
|
@ -245,7 +245,7 @@ public class CPU implements JSONSerialisable {
|
||||
} else if (destination <= registerSetSize * 2) {
|
||||
//Destination is [reg]
|
||||
ip++;
|
||||
instruction.execute(memory, registerSet.get(destination - registerSetSize), memory, sourceValue, status);
|
||||
instruction.execute(memory, registerSet.get(destination - registerSetSize), sourceValue, status);
|
||||
} else {
|
||||
//Assuming that destination is [reg + x]
|
||||
ip += 2;
|
||||
|
@ -120,8 +120,8 @@ public abstract class Instruction {
|
||||
* Whether or not the instruction is valid without any
|
||||
* operands
|
||||
*/
|
||||
private static boolean noOperandsValid() {
|
||||
return true;
|
||||
public boolean noOperandsValid() {
|
||||
return false;
|
||||
}
|
||||
|
||||
String getMnemonic() {
|
||||
|
@ -42,7 +42,7 @@ public class Util {
|
||||
}
|
||||
|
||||
public static String toHex(int a) {
|
||||
return String.format("%04X ", uShort(a));
|
||||
return String.format("%04X ", a);
|
||||
}
|
||||
|
||||
public static String toHex(byte[] byteArray) {
|
||||
|
@ -20,4 +20,8 @@ public class BrkInstruction extends Instruction {
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
public boolean noOperandsValid() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -28,8 +28,8 @@ public class DivInstruction extends Instruction {
|
||||
public Status execute(Target src, int srcIndex, Status status) {
|
||||
|
||||
//Source = Y:A
|
||||
int source = ((((char) cpu.getRegisterSet().getRegister("Y").getValue() & 0xFFFF) << 16)) |
|
||||
((char) cpu.getRegisterSet().getRegister("A").getValue() & 0xFFFF);
|
||||
int source = (((cpu.getRegisterSet().getRegister("Y").getValue() & 0xFFFF) << 16)) |
|
||||
(cpu.getRegisterSet().getRegister("A").getValue() & 0xFFFF);
|
||||
|
||||
if (src.get(srcIndex) == 0) {
|
||||
//Division by 0
|
||||
@ -48,8 +48,8 @@ public class DivInstruction extends Instruction {
|
||||
|
||||
|
||||
//Source = Y:A
|
||||
int source = ((((char) cpu.getRegisterSet().getRegister("Y").getValue() & 0xFFFF) << 16)) |
|
||||
((char) cpu.getRegisterSet().getRegister("A").getValue() & 0xFFFF);
|
||||
int source = (((cpu.getRegisterSet().getRegister("Y").getValue() & 0xFFFF) << 16)) |
|
||||
(cpu.getRegisterSet().getRegister("A").getValue() & 0xFFFF);
|
||||
|
||||
if (src == 0) {
|
||||
//Division by 0
|
||||
|
@ -25,9 +25,11 @@ public class MulInstruction extends Instruction {
|
||||
status.setOverflowFlag(true);
|
||||
status.setCarryFlag(true);
|
||||
cpu.getRegisterSet().getRegister("Y").setValue(hWord);//Don't overwrite Y register if it's blank
|
||||
} else {
|
||||
status.setOverflowFlag(false);
|
||||
status.setCarryFlag(false);
|
||||
}
|
||||
status.setOverflowFlag(false);
|
||||
status.setCarryFlag(false);
|
||||
|
||||
cpu.getRegisterSet().set(1, Util.getLowerWord(result));
|
||||
|
||||
return status;
|
||||
@ -44,9 +46,11 @@ public class MulInstruction extends Instruction {
|
||||
status.setOverflowFlag(true);
|
||||
status.setCarryFlag(true);
|
||||
cpu.getRegisterSet().getRegister("Y").setValue(hWord);//Don't overwrite Y register if it's blank
|
||||
} else {
|
||||
status.setOverflowFlag(false);
|
||||
status.setCarryFlag(false);
|
||||
}
|
||||
status.setOverflowFlag(false);
|
||||
status.setCarryFlag(false);
|
||||
|
||||
cpu.getRegisterSet().getRegister("A").setValue(Util.getLowerWord(result));
|
||||
|
||||
return status;
|
||||
|
@ -14,7 +14,23 @@ public class NegInstruction extends Instruction {
|
||||
|
||||
@Override
|
||||
public Status execute(Target dst, int dstIndex, Status status) {
|
||||
dst.set(dstIndex, -dst.get(dstIndex));
|
||||
//If the operand is zero, the carry flag is cleared; in all other cases, the carry flag is set.
|
||||
|
||||
char destination = (char) dst.get(dstIndex);
|
||||
|
||||
if (destination == 0) {
|
||||
status.setCarryFlag(false);
|
||||
status.setZeroFlag(true);
|
||||
} else {
|
||||
status.setCarryFlag(true);
|
||||
}
|
||||
|
||||
//Attempting to negate a word containing -32,768 causes no change to the operand and sets the Overflow Flag.
|
||||
if (destination == 0x8000) {
|
||||
status.setOverflowFlag(true);
|
||||
} else {
|
||||
dst.set(dstIndex, -destination);
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
@ -37,4 +37,9 @@ public class RetInstruction extends Instruction {
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean noOperandsValid() {
|
||||
return true;
|
||||
}
|
||||
}
|
@ -5,6 +5,7 @@ public enum Action {
|
||||
DIGGING,
|
||||
WALKING,
|
||||
WITHDRAWING,
|
||||
DEPOSITING
|
||||
DEPOSITING,
|
||||
LISTENING
|
||||
|
||||
}
|
||||
|
@ -21,4 +21,15 @@ public interface ControllableUnit {
|
||||
|
||||
int getEnergy();
|
||||
|
||||
int getX();
|
||||
|
||||
int getY();
|
||||
|
||||
void setAction(Action listening);
|
||||
|
||||
World getWorld();
|
||||
|
||||
ArrayList<char[]> getConsoleMessagesBuffer();
|
||||
|
||||
int getConsoleMode();
|
||||
}
|
||||
|
@ -0,0 +1,7 @@
|
||||
package net.simon987.server.game;
|
||||
|
||||
public interface Programmable {
|
||||
|
||||
void sendMessage(char[] message);
|
||||
|
||||
}
|
@ -54,7 +54,7 @@ public class World implements JSONSerialisable {
|
||||
*/
|
||||
public boolean isTileBlocked(int x, int y) {
|
||||
|
||||
return getGameObjectsAt(x, y).size() > 0 || tileMap.getTileAt(x, y) == TileMap.WALL_TILE;
|
||||
return getGameObjectsBlockingAt(x, y).size() > 0 || tileMap.getTileAt(x, y) == TileMap.WALL_TILE;
|
||||
|
||||
}
|
||||
|
||||
@ -245,13 +245,13 @@ public class World implements JSONSerialisable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of game objects at a location
|
||||
* Get the list of game objects that are blocking a tile at a set of coordinates
|
||||
*
|
||||
* @param x X coordinate on the World
|
||||
* @param y Y coordinate on the World
|
||||
* @return the list of game objects at a location
|
||||
* @return the list of game objects blocking a location
|
||||
*/
|
||||
public ArrayList<GameObject> getGameObjectsAt(int x, int y) {
|
||||
public ArrayList<GameObject> getGameObjectsBlockingAt(int x, int y) {
|
||||
|
||||
ArrayList<GameObject> gameObjects = new ArrayList<>(2);
|
||||
|
||||
@ -266,6 +266,30 @@ public class World implements JSONSerialisable {
|
||||
return gameObjects;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of game objects that are exactly at a given location
|
||||
* <br>
|
||||
* Note: Objects like the Factory that are more than 1x1 tiles wide will only be returned
|
||||
* when their exact coordinates are specified
|
||||
*
|
||||
* @param x X coordinate on the World
|
||||
* @param y Y coordinate on the World
|
||||
* @return the list of game objects at a location
|
||||
*/
|
||||
public ArrayList<GameObject> getGameObjectsAt(int x, int y) {
|
||||
ArrayList<GameObject> gameObjects = new ArrayList<>(2);
|
||||
|
||||
for (GameObject obj : this.gameObjects) {
|
||||
|
||||
if (obj.getX() == x && obj.getY() == y) {
|
||||
gameObjects.add(obj);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return gameObjects;
|
||||
}
|
||||
|
||||
public void incUpdatable() {
|
||||
updatable++;
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
package net.simon987.server.io;
|
||||
|
||||
import net.simon987.server.logging.LogManager;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
@ -11,176 +13,172 @@ import java.util.zip.ZipOutputStream;
|
||||
|
||||
public class FileUtils {
|
||||
|
||||
private static final int BUFFER_SIZE = 1024;
|
||||
private static final String STR_ENCODING = "UTF-8";
|
||||
private static final String DATE_FORMAT = "yyyyMMddHHmmss";
|
||||
private static final String FILE_TYPE = ".zip";
|
||||
private static final Path ROOT_DIR;
|
||||
private static final String DIR_NAME = "history";
|
||||
public static final Path DIR_PATH;
|
||||
private static final int BUFFER_SIZE = 1024;
|
||||
private static final String STR_ENCODING = "UTF-8";
|
||||
private static final String DATE_FORMAT = "yyyyMMddHHmmss";
|
||||
private static final String FILE_TYPE = ".zip";
|
||||
private static final Path ROOT_DIR;
|
||||
private static final String DIR_NAME = "history";
|
||||
public static final Path DIR_PATH;
|
||||
|
||||
static {
|
||||
ROOT_DIR = Paths.get(".").normalize();
|
||||
DIR_PATH = ROOT_DIR.resolve(DIR_NAME);
|
||||
}
|
||||
static {
|
||||
ROOT_DIR = Paths.get(".").normalize();
|
||||
DIR_PATH = ROOT_DIR.resolve(DIR_NAME);
|
||||
}
|
||||
|
||||
//Private constructor
|
||||
private FileUtils() {
|
||||
//Private constructor
|
||||
private FileUtils() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new stamp containing the current date and time
|
||||
*
|
||||
* @return date and time stamp
|
||||
*/
|
||||
private static String getDateTimeStamp() {
|
||||
Date millisToDate = new Date(System.currentTimeMillis());
|
||||
SimpleDateFormat f = new SimpleDateFormat(DATE_FORMAT);
|
||||
return f.format(millisToDate);
|
||||
}
|
||||
/**
|
||||
* Creates a new stamp containing the current date and time
|
||||
*
|
||||
* @return date and time stamp
|
||||
*/
|
||||
private static String getDateTimeStamp() {
|
||||
Date millisToDate = new Date(System.currentTimeMillis());
|
||||
SimpleDateFormat f = new SimpleDateFormat(DATE_FORMAT);
|
||||
return f.format(millisToDate);
|
||||
}
|
||||
|
||||
/**
|
||||
* Created a directory if none exists with the specified name
|
||||
*
|
||||
/**
|
||||
* Created a directory if none exists with the specified name
|
||||
*
|
||||
* @param directory folder to create
|
||||
* @return true is the file exists or create operation is successful
|
||||
*/
|
||||
public static boolean prepDirectory(Path directory) {
|
||||
File file = directory.toFile();
|
||||
*/
|
||||
public static boolean prepDirectory(Path directory) {
|
||||
File file = directory.toFile();
|
||||
|
||||
//If the directory exists or the directory created successfully return true
|
||||
if(file.exists() || file.mkdir()) {
|
||||
return true;
|
||||
//If the directory exists or the directory created successfully return true
|
||||
if (file.exists() || file.mkdir()) {
|
||||
return true;
|
||||
|
||||
} else {
|
||||
System.out.println("Error creating directory: " + file.toString());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
System.out.println("Error creating directory: " + file.toString());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a file into an array of bytes
|
||||
*
|
||||
/**
|
||||
* Converts a file into an array of bytes
|
||||
*
|
||||
* @param path the file to be converted into bytes
|
||||
* @return the byte array of the given file
|
||||
*/
|
||||
public static byte[] bytifyFile(Path path) {
|
||||
byte[] bytes = null;
|
||||
*/
|
||||
public static byte[] bytifyFile(Path path) {
|
||||
byte[] bytes = null;
|
||||
|
||||
try {
|
||||
bytes = Files.readAllBytes(path);
|
||||
try {
|
||||
bytes = Files.readAllBytes(path);
|
||||
|
||||
} catch (IOException e) {
|
||||
System.out.println("Failed to extract bytes from: " + path);
|
||||
e.printStackTrace();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
System.out.println("Failed to extract bytes from: " + path);
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return bytes;
|
||||
}
|
||||
return bytes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Takes in a file that had been converted to a byte[] to be written to a new
|
||||
* zip file
|
||||
*
|
||||
/**
|
||||
* Takes in a file that had been converted to a byte[] to be written to a new
|
||||
* zip file
|
||||
*
|
||||
* @param data
|
||||
* contains data in byte array form to be written, typically a file
|
||||
* that has been converted with bytifyFile()
|
||||
* @throws IOException
|
||||
* if an error occurs during the write process
|
||||
*/
|
||||
public static void writeSaveToZip(String name, byte[] data) throws IOException {
|
||||
* that has been converted with bytifyFile()
|
||||
* @throws IOException
|
||||
* if an error occurs during the write process
|
||||
*/
|
||||
public static void writeSaveToZip(String name, byte[] data) throws IOException {
|
||||
|
||||
String newFile = DIR_PATH.resolve(getDateTimeStamp() + FILE_TYPE).toString();
|
||||
FileOutputStream output = new FileOutputStream(newFile);
|
||||
ZipOutputStream stream = new ZipOutputStream(output);
|
||||
byte[] buffer = new byte[BUFFER_SIZE];
|
||||
ByteArrayInputStream bais = new ByteArrayInputStream(buffer);
|
||||
String newFile = DIR_PATH.resolve(getDateTimeStamp() + FILE_TYPE).toString();
|
||||
FileOutputStream output = new FileOutputStream(newFile);
|
||||
ZipOutputStream stream = new ZipOutputStream(output);
|
||||
byte[] buffer = new byte[BUFFER_SIZE];
|
||||
ByteArrayInputStream bais = new ByteArrayInputStream(buffer);
|
||||
|
||||
while ((bais.read(buffer)) > -1) {
|
||||
// File name
|
||||
ZipEntry entry = new ZipEntry(name);
|
||||
// Set to start of next entry in the stream.
|
||||
stream.putNextEntry(entry);
|
||||
// Data to write.
|
||||
stream.write(data);
|
||||
// Close the current entry.
|
||||
stream.closeEntry();
|
||||
}
|
||||
while ((bais.read(buffer)) > -1) {
|
||||
// File name
|
||||
ZipEntry entry = new ZipEntry(name);
|
||||
// Set to start of next entry in the stream.
|
||||
stream.putNextEntry(entry);
|
||||
// Data to write.
|
||||
stream.write(data);
|
||||
// Close the current entry.
|
||||
stream.closeEntry();
|
||||
}
|
||||
|
||||
stream.close();
|
||||
output.close();
|
||||
}
|
||||
stream.close();
|
||||
output.close();
|
||||
}
|
||||
|
||||
public static void cleanHistory(int size) {
|
||||
public static void cleanHistory(int size) {
|
||||
|
||||
|
||||
File[] files = new File(DIR_PATH.toString()).listFiles();
|
||||
File[] sorted = new File[size];
|
||||
File[] files = new File(DIR_PATH.toString()).listFiles();
|
||||
File[] sorted = new File[size];
|
||||
|
||||
File nextSortedFile = null;
|
||||
File currentFile = null;
|
||||
boolean changed = false;
|
||||
File currentFile;
|
||||
boolean changed;
|
||||
|
||||
for(int i = 0; i < files.length / 2; i++) {
|
||||
currentFile = files[i];
|
||||
files[i] = files[files.length - i - 1];
|
||||
files[files.length - i - 1] = currentFile;
|
||||
}
|
||||
if (files != null) {
|
||||
for (int i = 0; i < files.length / 2; i++) {
|
||||
currentFile = files[i];
|
||||
files[i] = files[files.length - i - 1];
|
||||
files[files.length - i - 1] = currentFile;
|
||||
}
|
||||
|
||||
currentFile = null;
|
||||
for (int f = 0; f < files.length; f++) {
|
||||
changed = false;
|
||||
|
||||
for(int f = 0; f < files.length; f++) {
|
||||
changed = false;
|
||||
long dirFile = Long.parseLong(files[f].getName().substring(0, (files[f].getName().length() -4)));
|
||||
try {
|
||||
long dirFile = Long.parseLong(files[f].getName().substring(0, (files[f].getName().length() - 4)));
|
||||
|
||||
if(f < size && sorted[f] == null) {
|
||||
sorted[f] = files[f];
|
||||
if (f < size && sorted[f] == null) {
|
||||
sorted[f] = files[f];
|
||||
|
||||
} else {
|
||||
} else {
|
||||
|
||||
for(int s = 0; s < sorted.length; s++) {
|
||||
for (int s = 0; s < sorted.length; s++) {
|
||||
|
||||
long sortedFile = Long.parseLong(sorted[s].getName().substring(0, (sorted[s].getName().length() -4)));
|
||||
long sortedFile = Long.parseLong(sorted[s].getName().substring(0, (sorted[s].getName().length() - 4)));
|
||||
|
||||
if(dirFile > sortedFile) {
|
||||
if (dirFile > sortedFile) {
|
||||
|
||||
if(s == sorted.length - 1) {
|
||||
sorted[s] = files[f];
|
||||
if (s == sorted.length - 1) {
|
||||
sorted[s] = files[f];
|
||||
|
||||
} else if(nextSortedFile == null) {
|
||||
nextSortedFile = sorted[s];
|
||||
sorted[s] = files[f];
|
||||
} else {
|
||||
sorted[s] = files[f];
|
||||
}
|
||||
|
||||
} else {
|
||||
currentFile = sorted[s];
|
||||
sorted[s] = nextSortedFile;
|
||||
nextSortedFile = currentFile;
|
||||
}
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
|
||||
nextSortedFile = null;
|
||||
currentFile = null;
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
if (!changed) {
|
||||
files[f].delete();
|
||||
}
|
||||
|
||||
if(changed == false) {
|
||||
files[f].delete();
|
||||
}
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
LogManager.LOGGER.info("Non-save file in history directory: " + files[f].getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a byte array into human readable format using the provided encoding
|
||||
*
|
||||
* @param bytes
|
||||
* data to be encoded to String
|
||||
* @return a String containing the encoded bytes
|
||||
*/
|
||||
public static String byteArrAsString(byte[] bytes) throws UnsupportedEncodingException {
|
||||
return new String(bytes, STR_ENCODING);
|
||||
}
|
||||
/**
|
||||
* Converts a byte array into human readable format using the provided encoding
|
||||
*
|
||||
* @param bytes data to be encoded to String
|
||||
* @return a String containing the encoded bytes
|
||||
*/
|
||||
public static String byteArrAsString(byte[] bytes) throws UnsupportedEncodingException {
|
||||
return new String(bytes, STR_ENCODING);
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ public class CodeRequestHandler implements MessageHandler {
|
||||
|
||||
if (json.get("t").equals("codeRequest")) {
|
||||
|
||||
LogManager.LOGGER.info("(WS) Code request from " + user.getUser().getUsername());
|
||||
LogManager.LOGGER.fine("(WS) Code request from " + user.getUser().getUsername());
|
||||
|
||||
if (user.isGuest()) {
|
||||
|
||||
|
@ -12,7 +12,7 @@ public class CodeUploadHandler implements MessageHandler {
|
||||
public void handle(OnlineUser user, JSONObject json) {
|
||||
if (json.get("t").equals("uploadCode")) {
|
||||
|
||||
LogManager.LOGGER.info("(WS) Code upload from " + user.getUser().getUsername());
|
||||
LogManager.LOGGER.fine("(WS) Code upload from " + user.getUser().getUsername());
|
||||
|
||||
if (user.isGuest()) {
|
||||
//Ignore
|
||||
@ -33,6 +33,13 @@ public class CodeUploadHandler implements MessageHandler {
|
||||
user.getUser().getCpu().getMemory().write((char) ar.origin, assembledCode, 0, assembledCode.length);
|
||||
user.getUser().getCpu().setCodeSegmentOffset(ar.getCodeSegmentOffset());
|
||||
|
||||
//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);
|
||||
|
@ -13,7 +13,7 @@ public class FloppyHandler implements MessageHandler {
|
||||
|
||||
if (json.get("t").equals("floppyDown")) {
|
||||
|
||||
LogManager.LOGGER.info("(WS) Floppy download request from " + user.getUser().getUsername());
|
||||
LogManager.LOGGER.fine("(WS) Floppy download request from " + user.getUser().getUsername());
|
||||
|
||||
if (user.isGuest()) {
|
||||
return;
|
||||
@ -27,7 +27,7 @@ public class FloppyHandler implements MessageHandler {
|
||||
|
||||
} else if (json.get("t").equals("floppyUp")) {
|
||||
|
||||
LogManager.LOGGER.info("(WS) Floppy upload request from " + user.getUser().getUsername());
|
||||
LogManager.LOGGER.fine("(WS) Floppy upload request from " + user.getUser().getUsername());
|
||||
|
||||
//Check newly uploaded file on the database
|
||||
byte[] bytes = db.getFloppy(user.getUser().getUsername());
|
||||
|
@ -1,6 +1,5 @@
|
||||
package net.simon987.server.webserver;
|
||||
|
||||
import net.simon987.server.logging.LogManager;
|
||||
import org.json.simple.JSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -14,7 +13,7 @@ public class KeypressHandler implements MessageHandler {
|
||||
if (!user.isGuest()) {
|
||||
if (json.get("t").equals("k")) {
|
||||
|
||||
LogManager.LOGGER.info("(WS) Received keypress");
|
||||
//LogManager.LOGGER.fine("(WS) Received keypress");
|
||||
|
||||
int key = (int) (long) json.get("k");
|
||||
|
||||
|
@ -33,11 +33,11 @@ public class MessageEventDispatcher {
|
||||
handler.handle(user, json);
|
||||
}
|
||||
} else {
|
||||
LogManager.LOGGER.info("Malformed JSON sent by " + user.getUser().getUsername());
|
||||
LogManager.LOGGER.severe("Malformed JSON sent by " + user.getUser().getUsername());
|
||||
}
|
||||
|
||||
} catch (ParseException e) {
|
||||
LogManager.LOGGER.info("Malformed JSON sent by " + user.getUser().getUsername());
|
||||
LogManager.LOGGER.severe("Malformed JSON sent by " + user.getUser().getUsername());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -15,14 +15,14 @@ public class ObjectsRequestHandler implements MessageHandler {
|
||||
@Override
|
||||
public void handle(OnlineUser user, JSONObject json) {
|
||||
if (json.get("t").equals("object")) {
|
||||
LogManager.LOGGER.info("(WS) Objects request from " + user.getUser().getUsername());
|
||||
LogManager.LOGGER.fine("(WS) Objects request from " + user.getUser().getUsername());
|
||||
|
||||
int x, y;
|
||||
try {
|
||||
x = Long.valueOf((long) json.get("x")).intValue();
|
||||
y = Long.valueOf((long) json.get("y")).intValue();
|
||||
} catch (Exception e) {
|
||||
LogManager.LOGGER.info("(WS) Malformed Objects request from " + user.getUser().getUsername());
|
||||
LogManager.LOGGER.severe("(WS) Malformed Objects request from " + user.getUser().getUsername());
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2,6 +2,7 @@ package net.simon987.server.webserver;
|
||||
|
||||
import net.simon987.server.GameServer;
|
||||
import net.simon987.server.ServerConfiguration;
|
||||
import net.simon987.server.game.ControllableUnit;
|
||||
import net.simon987.server.logging.LogManager;
|
||||
import net.simon987.server.user.User;
|
||||
import org.java_websocket.WebSocket;
|
||||
@ -172,20 +173,42 @@ public class SocketServer extends WebSocketServer {
|
||||
|
||||
if (user.isGuest()) {
|
||||
|
||||
json.remove("c");
|
||||
user.getWebSocket().send(json.toJSONString());
|
||||
|
||||
} else {
|
||||
//Send keyboard updated buffer
|
||||
try {
|
||||
ArrayList<Integer> kbBuffer = user.getUser().getControlledUnit().getKeyboardBuffer();
|
||||
ControllableUnit unit = user.getUser().getControlledUnit();
|
||||
|
||||
//Send keyboard updated buffer
|
||||
ArrayList<Integer> kbBuffer = unit.getKeyboardBuffer();
|
||||
JSONArray keys = new JSONArray();
|
||||
keys.addAll(kbBuffer);
|
||||
json.put("keys", keys);
|
||||
|
||||
//Send console buffer
|
||||
if (unit.getConsoleMessagesBuffer().size() > 0) {
|
||||
|
||||
JSONArray buff = new JSONArray();
|
||||
|
||||
for (char[] message : unit.getConsoleMessagesBuffer()) {
|
||||
buff.add(new String(message));
|
||||
}
|
||||
|
||||
json.put("c", buff);
|
||||
} else {
|
||||
json.remove("c");
|
||||
}
|
||||
|
||||
json.put("cm", unit.getConsoleMode());
|
||||
|
||||
|
||||
//Send tick message
|
||||
user.getWebSocket().send(json.toJSONString());
|
||||
} catch (NullPointerException e) {
|
||||
//User is online but not completely initialised
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -12,7 +12,7 @@ public class TerrainRequestHandler implements MessageHandler {
|
||||
public void handle(OnlineUser user, JSONObject json) {
|
||||
if (json.get("t").equals("terrain") && json.containsKey("x") && json.containsKey("y")) {
|
||||
|
||||
LogManager.LOGGER.info("Terrain request from " + user.getUser().getUsername());
|
||||
LogManager.LOGGER.fine("Terrain request from " + user.getUser().getUsername());
|
||||
World world;
|
||||
try {
|
||||
world = GameServer.INSTANCE.getGameUniverse().getWorld(
|
||||
|
@ -13,7 +13,7 @@ public class UserInfoRequestHandler implements MessageHandler {
|
||||
|
||||
if (message.get("t").equals("userInfo")) {
|
||||
|
||||
LogManager.LOGGER.info("(WS) User info request from " + user.getUser().getUsername());
|
||||
LogManager.LOGGER.fine("(WS) User info request from " + user.getUser().getUsername());
|
||||
JSONObject json = new JSONObject();
|
||||
|
||||
if (user.isGuest()) {
|
||||
|
@ -65,9 +65,9 @@ wg_centerPointCountMin=5
|
||||
wg_centerPointCountMax=15
|
||||
# Wall/Plain tile ratio for the WorldGenerator
|
||||
wg_wallPlainRatio=4
|
||||
# Minimum iron tiles count for the WorldGenerator
|
||||
wg_minIronCount=0
|
||||
# Minimum iron tile count for the WorldGenerator
|
||||
wg_minIronCount=0
|
||||
# Maximum iron tile count for the WorldGenerator
|
||||
wg_maxIronCount=2
|
||||
# Minimum copper tile count for the WorldGenerator
|
||||
wg_minCopperCount=0
|
20
pom.xml
20
pom.xml
@ -13,28 +13,26 @@
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<version>3.6.2</version>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<version>3.6.2</version>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<version>3.6.2</version>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>3.0.2</version>
|
||||
<configuration>
|
||||
<outputDirectory>../target/plugins</outputDirectory>
|
||||
<archive>
|
||||
<manifest>
|
||||
<addClasspath>false</addClasspath>
|
||||
<mainClass>net.simon987.server.Main</mainClass>
|
||||
</manifest>
|
||||
</archive>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user