mirror of
https://github.com/simon987/Much-Assembly-Required.git
synced 2025-04-10 14:26:45 +00:00
Logs cleanup
This commit is contained in:
parent
41b981f3ab
commit
626c55bcce
@ -54,14 +54,14 @@ public class CubotLaser extends CpuHardware {
|
||||
} else {
|
||||
//The inventory holder can't provide this item
|
||||
//todo Add emote here
|
||||
System.out.println("FAILED: take (The inventory holder can't provide this item)");
|
||||
System.out.println("DEBUG: FAILED: take (The inventory holder can't provide this item)");
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
//Nothing in front
|
||||
//todo Add emote here
|
||||
System.out.println("FAILED: take (Nothing in front)");
|
||||
System.out.println("DEBUG: FAILED: take (Nothing in front)");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,9 +3,9 @@ package net.simon987.cubotplugin;
|
||||
import net.simon987.cubotplugin.event.CpuInitialisationListener;
|
||||
import net.simon987.cubotplugin.event.UserCreationListener;
|
||||
import net.simon987.server.assembly.CpuHardware;
|
||||
import net.simon987.server.game.CpuHardwareDeserializer;
|
||||
import net.simon987.server.game.GameObject;
|
||||
import net.simon987.server.game.GameObjectDeserializer;
|
||||
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;
|
||||
|
@ -98,7 +98,7 @@ public class CubotRadar extends CpuHardware implements JSONSerialisable {
|
||||
mem[counter] = -1;
|
||||
}
|
||||
|
||||
System.out.println("path to" + destX + "," + destY);
|
||||
System.out.println("DEBUG: path to" + destX + "," + destY);
|
||||
break;
|
||||
|
||||
case GET_MAP:
|
||||
|
@ -5,6 +5,7 @@ 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 {
|
||||
@ -15,7 +16,7 @@ public class CpuInitialisationListener implements GameEventListener {
|
||||
|
||||
@Override
|
||||
public void handle(GameEvent event) {
|
||||
System.out.println("CPU Init");
|
||||
LogManager.LOGGER.fine("(Plugin) Handled CPU Initialisation event (Cubot Plugin)");
|
||||
|
||||
CPU cpu = (CPU)event.getSource();
|
||||
User user = ((CpuInitialisationEvent)event).getUser();
|
||||
|
@ -5,6 +5,7 @@ import net.simon987.server.GameServer;
|
||||
import net.simon987.server.event.GameEvent;
|
||||
import net.simon987.server.event.GameEventListener;
|
||||
import net.simon987.server.event.UserCreationEvent;
|
||||
import net.simon987.server.logging.LogManager;
|
||||
import net.simon987.server.user.User;
|
||||
|
||||
import java.awt.*;
|
||||
@ -20,6 +21,7 @@ public class UserCreationListener implements GameEventListener {
|
||||
|
||||
User user = (User)event.getSource();
|
||||
|
||||
LogManager.LOGGER.fine("(Plugin) Handled User creation event (Cubot Plugin)");
|
||||
|
||||
Cubot cubot = new Cubot();
|
||||
|
||||
@ -28,6 +30,8 @@ public class UserCreationListener implements GameEventListener {
|
||||
|
||||
cubot.setObjectId(GameServer.INSTANCE.getGameUniverse().getNextObjectId());
|
||||
|
||||
cubot.setHeldItem(GameServer.INSTANCE.getConfig().getInt("new_user_item"));
|
||||
|
||||
cubot.setParent(user);
|
||||
|
||||
Point point = cubot.getWorld().getRandomPassableTile();
|
||||
|
@ -1,7 +1,7 @@
|
||||
package net.simon987.kilnplugin;
|
||||
|
||||
import net.simon987.server.game.GameObject;
|
||||
import net.simon987.server.game.GameObjectDeserializer;
|
||||
import net.simon987.server.io.GameObjectDeserializer;
|
||||
import net.simon987.server.plugin.ServerPlugin;
|
||||
import org.json.simple.JSONObject;
|
||||
|
||||
|
@ -2,7 +2,7 @@ package net.simon987.plantplugin;
|
||||
|
||||
import net.simon987.plantplugin.event.WorldCreationListener;
|
||||
import net.simon987.server.game.GameObject;
|
||||
import net.simon987.server.game.GameObjectDeserializer;
|
||||
import net.simon987.server.io.GameObjectDeserializer;
|
||||
import net.simon987.server.logging.LogManager;
|
||||
import net.simon987.server.plugin.ServerPlugin;
|
||||
import org.json.simple.JSONObject;
|
||||
|
@ -10,9 +10,50 @@ import java.net.InetSocketAddress;
|
||||
public class Main {
|
||||
public static void main(String[] args){
|
||||
|
||||
//TODO: Copper/Iron/Biomass: on hover only
|
||||
//TODO: Docs
|
||||
//TODO:
|
||||
/*
|
||||
* - Intel 8086 p.14 design
|
||||
* - Memory: Storage organisation: From a storage pov, 8086 memory spaces are
|
||||
* organised as identical arrays of 16-bit words
|
||||
*/
|
||||
//TODO: Object information Window (Hover, click ?)
|
||||
//TODO: Website front page
|
||||
//TODO: Account page
|
||||
//TODO: Chat (Slack?)
|
||||
//TODO: Inventory indicator
|
||||
//TODO: Dig animations
|
||||
//TODO: Withdraw animation / action
|
||||
//TODO: HWN, HWQ Instruction
|
||||
//TODO: Prevent Biomass from blocking Worlds
|
||||
//TODO: Change code documentation (Check for "Database" etc..)
|
||||
//TODO: Load and save: handle no save / invalid save
|
||||
// - Make sure the Hardware is saved and can be loaded
|
||||
//TODO: Add more logs
|
||||
//TODO: Clean sprites
|
||||
|
||||
//---------------------------------
|
||||
|
||||
//TODO: Software Interrupts (PIC): Interupt flag?
|
||||
/*
|
||||
* - INT/INTO instruction
|
||||
* - IRET instruction
|
||||
*/
|
||||
//TODO: Clock hardware
|
||||
//TODO: Floppy drive hardware (and item?)
|
||||
//TODO: LEA instruction
|
||||
//TODO: XCHG instruction
|
||||
//TODO: SAL/SAR instruction
|
||||
//TODO: ROL/ROR/RCL/RCR instruction
|
||||
//TODO: LOOP/LOOPE/LOOPX/LOOPNE/LOOPNZ ?
|
||||
//TODO: World goto (form)
|
||||
//TODO: Save backup (keep X saves, Zip em)
|
||||
//TODO: Log backup (keep X backups, Zip em)
|
||||
//TODO: More tests
|
||||
//TODO: Handle client disconnects
|
||||
//TODO: Cache objects requests?
|
||||
//TODO: Ability to toggle debug stuff
|
||||
//TODO: Data segment, DB, DW, DD, DQ
|
||||
|
||||
|
||||
LogManager.initialize();
|
||||
ServerConfiguration config = new ServerConfiguration(new File("config.properties"));
|
||||
|
@ -98,7 +98,7 @@ public class Assembler {
|
||||
line = line.substring(0, line.indexOf(':'));
|
||||
String label = line.trim();
|
||||
|
||||
System.out.println("Label " + label + " @ " + (result.origin + currentOffset));
|
||||
System.out.println("DEBUG: Label " + label + " @ " + (result.origin + currentOffset));
|
||||
result.labels.put(label, (char) (result.origin + currentOffset));
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ package net.simon987.server.assembly;
|
||||
|
||||
|
||||
import net.simon987.server.GameServer;
|
||||
import net.simon987.server.game.CpuHardwareDeserializer;
|
||||
import net.simon987.server.io.CpuHardwareDeserializer;
|
||||
import net.simon987.server.io.JSONSerialisable;
|
||||
import net.simon987.server.plugin.ServerPlugin;
|
||||
import org.json.simple.JSONObject;
|
||||
|
@ -1,6 +1,8 @@
|
||||
package net.simon987.server.assembly;
|
||||
|
||||
|
||||
import net.simon987.server.assembly.exception.IllegalOperandException;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
|
||||
/**
|
||||
|
@ -1,6 +1,5 @@
|
||||
package net.simon987.server.assembly;
|
||||
package net.simon987.server.assembly.exception;
|
||||
|
||||
import net.simon987.server.assembly.exception.AssemblyException;
|
||||
|
||||
public class IllegalOperandException extends AssemblyException {
|
||||
public IllegalOperandException(String msg, int line) {
|
@ -34,8 +34,6 @@ public class CmpInstruction extends Instruction {
|
||||
status.setOverflowFlag(Util.checkOverFlowAdd16(a, b));
|
||||
status.setCarryFlag(Util.checkCarry16(result));
|
||||
|
||||
|
||||
// System.out.println(a + " ?= " + b);
|
||||
return status;
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
package net.simon987.server.game;
|
||||
|
||||
import net.simon987.server.GameServer;
|
||||
import net.simon987.server.io.GameObjectDeserializer;
|
||||
import net.simon987.server.io.JSONSerialisable;
|
||||
import net.simon987.server.plugin.ServerPlugin;
|
||||
import org.json.simple.JSONObject;
|
||||
|
@ -231,4 +231,9 @@ public class GameUniverse implements JSONSerialisable{
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
public void removeUser(User user) {
|
||||
users.remove(user);
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,21 +0,0 @@
|
||||
package net.simon987.server.game;
|
||||
|
||||
import net.simon987.server.GameServer;
|
||||
|
||||
public class TmpObject extends GameObject{
|
||||
|
||||
public TmpObject(){
|
||||
|
||||
GameServer.INSTANCE.getGameUniverse();
|
||||
|
||||
setWorld(GameServer.INSTANCE.getGameUniverse().getWorld(0,0));
|
||||
setX(6);
|
||||
setY(6);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public char getMapInfo() {
|
||||
return 0;
|
||||
}
|
||||
}
|
@ -116,7 +116,7 @@ public class Pathfinder {
|
||||
}
|
||||
|
||||
//Incomplete path
|
||||
LogManager.LOGGER.info("Incomplete path! " + counter);
|
||||
LogManager.LOGGER.fine("Incomplete path! " + counter);
|
||||
return null;
|
||||
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
package net.simon987.server.game;
|
||||
package net.simon987.server.io;
|
||||
|
||||
import net.simon987.server.assembly.CpuHardware;
|
||||
import org.json.simple.JSONObject;
|
@ -1,5 +1,6 @@
|
||||
package net.simon987.server.game;
|
||||
package net.simon987.server.io;
|
||||
|
||||
import net.simon987.server.game.GameObject;
|
||||
import org.json.simple.JSONObject;
|
||||
|
||||
public interface GameObjectDeserializer {
|
@ -12,52 +12,40 @@ import java.util.ArrayList;
|
||||
public class ObjectsRequestHandler implements MessageHandler {
|
||||
|
||||
|
||||
private String cachedResponse;
|
||||
private long timeCached;
|
||||
|
||||
@Override
|
||||
public void handle(OnlineUser user, JSONObject json) {
|
||||
if (json.get("t").equals("object")) {
|
||||
LogManager.LOGGER.info("(WS) Objects request from " + user.getUser().getUsername());
|
||||
|
||||
if (timeCached == GameServer.INSTANCE.getGameUniverse().getTime()) {
|
||||
|
||||
if (json.containsKey("x") && json.containsKey("y")) {
|
||||
int x = Long.valueOf((long) json.get("x")).intValue();
|
||||
int y = Long.valueOf((long) json.get("y")).intValue();
|
||||
|
||||
ArrayList<GameObject> gameObjects = GameServer.INSTANCE.getGameUniverse().getWorld(x, y).getGameObjects();
|
||||
|
||||
JSONObject response = new JSONObject();
|
||||
JSONArray objects = new JSONArray();
|
||||
|
||||
|
||||
for (GameObject object : gameObjects) {
|
||||
|
||||
if (object instanceof JSONSerialisable) {
|
||||
objects.add(object.serialise());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
response.put("t", "object");
|
||||
response.put("objects", objects);
|
||||
|
||||
|
||||
if (user.getWebSocket().isOpen()) {
|
||||
user.getWebSocket().send(cachedResponse);
|
||||
user.getWebSocket().send(response.toJSONString());
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
if (json.containsKey("x") && json.containsKey("y")) {
|
||||
int x = Long.valueOf((long) json.get("x")).intValue();
|
||||
int y = Long.valueOf((long) json.get("y")).intValue();
|
||||
|
||||
ArrayList<GameObject> gameObjects = GameServer.INSTANCE.getGameUniverse().getWorld(x, y).getGameObjects();
|
||||
|
||||
JSONObject response = new JSONObject();
|
||||
JSONArray objects = new JSONArray();
|
||||
|
||||
|
||||
for (GameObject object : gameObjects) {
|
||||
|
||||
if (object instanceof JSONSerialisable) {
|
||||
objects.add(object.serialise());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
response.put("t", "object");
|
||||
response.put("objects", objects);
|
||||
|
||||
cachedResponse = response.toJSONString();
|
||||
timeCached = GameServer.INSTANCE.getGameUniverse().getTime();
|
||||
|
||||
if (user.getWebSocket().isOpen()) {
|
||||
user.getWebSocket().send(cachedResponse);
|
||||
}
|
||||
} else {
|
||||
LogManager.LOGGER.info("(WS) Malformed Objects request from " + user.getUser().getUsername());
|
||||
}
|
||||
LogManager.LOGGER.info("(WS) Malformed Objects request from " + user.getUser().getUsername());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package net.simon987.server.webserver;
|
||||
|
||||
import net.simon987.server.GameServer;
|
||||
import org.java_websocket.WebSocket;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -41,6 +42,7 @@ public class OnlineUserManager {
|
||||
*/
|
||||
public void remove(OnlineUser user) {
|
||||
onlineUsers.remove(user);
|
||||
GameServer.INSTANCE.getGameUniverse().removeUser(user.getUser());
|
||||
}
|
||||
|
||||
public ArrayList<OnlineUser> getOnlineUsers() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user