Logs cleanup

This commit is contained in:
simon 2017-11-05 10:20:38 -05:00
parent 41b981f3ab
commit 626c55bcce
21 changed files with 97 additions and 76 deletions

View File

@ -54,14 +54,14 @@ public class CubotLaser extends CpuHardware {
} else { } else {
//The inventory holder can't provide this item //The inventory holder can't provide this item
//todo Add emote here //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 { } else {
//Nothing in front //Nothing in front
//todo Add emote here //todo Add emote here
System.out.println("FAILED: take (Nothing in front)"); System.out.println("DEBUG: FAILED: take (Nothing in front)");
} }
} }

View File

@ -3,9 +3,9 @@ package net.simon987.cubotplugin;
import net.simon987.cubotplugin.event.CpuInitialisationListener; import net.simon987.cubotplugin.event.CpuInitialisationListener;
import net.simon987.cubotplugin.event.UserCreationListener; import net.simon987.cubotplugin.event.UserCreationListener;
import net.simon987.server.assembly.CpuHardware; import net.simon987.server.assembly.CpuHardware;
import net.simon987.server.game.CpuHardwareDeserializer;
import net.simon987.server.game.GameObject; 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.logging.LogManager;
import net.simon987.server.plugin.ServerPlugin; import net.simon987.server.plugin.ServerPlugin;
import org.json.simple.JSONObject; import org.json.simple.JSONObject;

View File

@ -98,7 +98,7 @@ public class CubotRadar extends CpuHardware implements JSONSerialisable {
mem[counter] = -1; mem[counter] = -1;
} }
System.out.println("path to" + destX + "," + destY); System.out.println("DEBUG: path to" + destX + "," + destY);
break; break;
case GET_MAP: case GET_MAP:

View File

@ -5,6 +5,7 @@ import net.simon987.server.assembly.CPU;
import net.simon987.server.event.CpuInitialisationEvent; import net.simon987.server.event.CpuInitialisationEvent;
import net.simon987.server.event.GameEvent; import net.simon987.server.event.GameEvent;
import net.simon987.server.event.GameEventListener; import net.simon987.server.event.GameEventListener;
import net.simon987.server.logging.LogManager;
import net.simon987.server.user.User; import net.simon987.server.user.User;
public class CpuInitialisationListener implements GameEventListener { public class CpuInitialisationListener implements GameEventListener {
@ -15,7 +16,7 @@ public class CpuInitialisationListener implements GameEventListener {
@Override @Override
public void handle(GameEvent event) { 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(); CPU cpu = (CPU)event.getSource();
User user = ((CpuInitialisationEvent)event).getUser(); User user = ((CpuInitialisationEvent)event).getUser();

View File

@ -5,6 +5,7 @@ import net.simon987.server.GameServer;
import net.simon987.server.event.GameEvent; import net.simon987.server.event.GameEvent;
import net.simon987.server.event.GameEventListener; import net.simon987.server.event.GameEventListener;
import net.simon987.server.event.UserCreationEvent; import net.simon987.server.event.UserCreationEvent;
import net.simon987.server.logging.LogManager;
import net.simon987.server.user.User; import net.simon987.server.user.User;
import java.awt.*; import java.awt.*;
@ -20,6 +21,7 @@ public class UserCreationListener implements GameEventListener {
User user = (User)event.getSource(); User user = (User)event.getSource();
LogManager.LOGGER.fine("(Plugin) Handled User creation event (Cubot Plugin)");
Cubot cubot = new Cubot(); Cubot cubot = new Cubot();
@ -28,6 +30,8 @@ public class UserCreationListener implements GameEventListener {
cubot.setObjectId(GameServer.INSTANCE.getGameUniverse().getNextObjectId()); cubot.setObjectId(GameServer.INSTANCE.getGameUniverse().getNextObjectId());
cubot.setHeldItem(GameServer.INSTANCE.getConfig().getInt("new_user_item"));
cubot.setParent(user); cubot.setParent(user);
Point point = cubot.getWorld().getRandomPassableTile(); Point point = cubot.getWorld().getRandomPassableTile();

View File

@ -1,7 +1,7 @@
package net.simon987.kilnplugin; package net.simon987.kilnplugin;
import net.simon987.server.game.GameObject; 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 net.simon987.server.plugin.ServerPlugin;
import org.json.simple.JSONObject; import org.json.simple.JSONObject;

View File

@ -2,7 +2,7 @@ package net.simon987.plantplugin;
import net.simon987.plantplugin.event.WorldCreationListener; import net.simon987.plantplugin.event.WorldCreationListener;
import net.simon987.server.game.GameObject; 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.logging.LogManager;
import net.simon987.server.plugin.ServerPlugin; import net.simon987.server.plugin.ServerPlugin;
import org.json.simple.JSONObject; import org.json.simple.JSONObject;

View File

@ -10,9 +10,50 @@ import java.net.InetSocketAddress;
public class Main { public class Main {
public static void main(String[] args){ public static void main(String[] args){
//TODO: Copper/Iron/Biomass: on hover only
//TODO: Docs //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(); LogManager.initialize();
ServerConfiguration config = new ServerConfiguration(new File("config.properties")); ServerConfiguration config = new ServerConfiguration(new File("config.properties"));

View File

@ -98,7 +98,7 @@ public class Assembler {
line = line.substring(0, line.indexOf(':')); line = line.substring(0, line.indexOf(':'));
String label = line.trim(); 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)); result.labels.put(label, (char) (result.origin + currentOffset));
} }
} }

View File

@ -2,7 +2,7 @@ package net.simon987.server.assembly;
import net.simon987.server.GameServer; 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.io.JSONSerialisable;
import net.simon987.server.plugin.ServerPlugin; import net.simon987.server.plugin.ServerPlugin;
import org.json.simple.JSONObject; import org.json.simple.JSONObject;

View File

@ -1,6 +1,8 @@
package net.simon987.server.assembly; package net.simon987.server.assembly;
import net.simon987.server.assembly.exception.IllegalOperandException;
import java.io.ByteArrayOutputStream; import java.io.ByteArrayOutputStream;
/** /**

View File

@ -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 class IllegalOperandException extends AssemblyException {
public IllegalOperandException(String msg, int line) { public IllegalOperandException(String msg, int line) {

View File

@ -34,8 +34,6 @@ public class CmpInstruction extends Instruction {
status.setOverflowFlag(Util.checkOverFlowAdd16(a, b)); status.setOverflowFlag(Util.checkOverFlowAdd16(a, b));
status.setCarryFlag(Util.checkCarry16(result)); status.setCarryFlag(Util.checkCarry16(result));
// System.out.println(a + " ?= " + b);
return status; return status;
} }

View File

@ -1,6 +1,7 @@
package net.simon987.server.game; package net.simon987.server.game;
import net.simon987.server.GameServer; import net.simon987.server.GameServer;
import net.simon987.server.io.GameObjectDeserializer;
import net.simon987.server.io.JSONSerialisable; import net.simon987.server.io.JSONSerialisable;
import net.simon987.server.plugin.ServerPlugin; import net.simon987.server.plugin.ServerPlugin;
import org.json.simple.JSONObject; import org.json.simple.JSONObject;

View File

@ -231,4 +231,9 @@ public class GameUniverse implements JSONSerialisable{
return null; return null;
} }
public void removeUser(User user) {
users.remove(user);
}
} }

View File

@ -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;
}
}

View File

@ -116,7 +116,7 @@ public class Pathfinder {
} }
//Incomplete path //Incomplete path
LogManager.LOGGER.info("Incomplete path! " + counter); LogManager.LOGGER.fine("Incomplete path! " + counter);
return null; return null;
} }

View File

@ -1,4 +1,4 @@
package net.simon987.server.game; package net.simon987.server.io;
import net.simon987.server.assembly.CpuHardware; import net.simon987.server.assembly.CpuHardware;
import org.json.simple.JSONObject; import org.json.simple.JSONObject;

View File

@ -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; import org.json.simple.JSONObject;
public interface GameObjectDeserializer { public interface GameObjectDeserializer {

View File

@ -12,21 +12,12 @@ import java.util.ArrayList;
public class ObjectsRequestHandler implements MessageHandler { public class ObjectsRequestHandler implements MessageHandler {
private String cachedResponse;
private long timeCached;
@Override @Override
public void handle(OnlineUser user, JSONObject json) { public void handle(OnlineUser user, JSONObject json) {
if (json.get("t").equals("object")) { if (json.get("t").equals("object")) {
LogManager.LOGGER.info("(WS) Objects request from " + user.getUser().getUsername()); LogManager.LOGGER.info("(WS) Objects request from " + user.getUser().getUsername());
if (timeCached == GameServer.INSTANCE.getGameUniverse().getTime()) {
if (user.getWebSocket().isOpen()) {
user.getWebSocket().send(cachedResponse);
}
} else {
if (json.containsKey("x") && json.containsKey("y")) { if (json.containsKey("x") && json.containsKey("y")) {
int x = Long.valueOf((long) json.get("x")).intValue(); int x = Long.valueOf((long) json.get("x")).intValue();
@ -49,16 +40,13 @@ public class ObjectsRequestHandler implements MessageHandler {
response.put("t", "object"); response.put("t", "object");
response.put("objects", objects); response.put("objects", objects);
cachedResponse = response.toJSONString();
timeCached = GameServer.INSTANCE.getGameUniverse().getTime();
if (user.getWebSocket().isOpen()) { if (user.getWebSocket().isOpen()) {
user.getWebSocket().send(cachedResponse); user.getWebSocket().send(response.toJSONString());
} }
} else { } else {
LogManager.LOGGER.info("(WS) Malformed Objects request from " + user.getUser().getUsername()); LogManager.LOGGER.info("(WS) Malformed Objects request from " + user.getUser().getUsername());
} }
} }
} }
}
} }

View File

@ -1,5 +1,6 @@
package net.simon987.server.webserver; package net.simon987.server.webserver;
import net.simon987.server.GameServer;
import org.java_websocket.WebSocket; import org.java_websocket.WebSocket;
import java.util.ArrayList; import java.util.ArrayList;
@ -41,6 +42,7 @@ public class OnlineUserManager {
*/ */
public void remove(OnlineUser user) { public void remove(OnlineUser user) {
onlineUsers.remove(user); onlineUsers.remove(user);
GameServer.INSTANCE.getGameUniverse().removeUser(user.getUser());
} }
public ArrayList<OnlineUser> getOnlineUsers() { public ArrayList<OnlineUser> getOnlineUsers() {