Various bug fixes

This commit is contained in:
simon
2017-11-05 14:13:53 -05:00
parent 626c55bcce
commit 98b0c480b9
19 changed files with 145 additions and 68 deletions

View File

@@ -10,21 +10,17 @@ import java.net.InetSocketAddress;
public class Main {
public static void main(String[] args){
//TODO: Object information Window (Hover, click ?)
//TODO: Docs
/*
* - 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
@@ -33,6 +29,7 @@ public class Main {
//---------------------------------
//TODO: Inventory indicator (Multiple items)
//TODO: Software Interrupts (PIC): Interupt flag?
/*
* - INT/INTO instruction
@@ -53,6 +50,11 @@ public class Main {
//TODO: Cache objects requests?
//TODO: Ability to toggle debug stuff
//TODO: Data segment, DB, DW, DD, DQ
//TODO: Set client animation speed relative to TICK_LENGTH
//TODO: Withdraw animation / action
//TODO: Prevent World creation out of bounds, warp around universe
//TODO: Multiple Biomass style (and yield, rarity)
LogManager.initialize();
@@ -69,5 +71,4 @@ public class Main {
(new Thread(socketServer)).start();
(new Thread(GameServer.INSTANCE)).start();
}
}

View File

@@ -92,6 +92,7 @@ public class CPU implements JSONSerialisable{
instructionSet.add(new JnsInstruction(this));
instructionSet.add(new JsInstruction(this));
instructionSet.add(new HwiInstruction(this));
instructionSet.add(new HwqInstruction(this));
status = new Status();
memory = new Memory(config.getInt("memory_size"));
@@ -423,6 +424,17 @@ public class CPU implements JSONSerialisable{
}
}
public void hardwareQuery(int address) {
CpuHardware hardware = attachedHardware.get(address);
if (hardware != null) {
registerSet.getRegister("B").setValue(hardware.getId());
} else {
registerSet.getRegister("B").setValue(0);
}
}
@Override
public String toString() {
@@ -433,4 +445,6 @@ public class CPU implements JSONSerialisable{
return str;
}
}

View File

@@ -24,6 +24,8 @@ public abstract class CpuHardware implements JSONSerialisable {
this.cpu = cpu;
}
public abstract char getId();
public static CpuHardware deserialize(JSONObject hwJson){
for(ServerPlugin plugin : GameServer.INSTANCE.getPluginManager().getPlugins()){

View File

@@ -3,6 +3,7 @@ package net.simon987.server.assembly.instruction;
import net.simon987.server.assembly.CPU;
import net.simon987.server.assembly.Instruction;
import net.simon987.server.assembly.Status;
import net.simon987.server.assembly.Target;
/**
* Send hardware interupt
@@ -20,6 +21,13 @@ public class HwiInstruction extends Instruction {
this.cpu = cpu;
}
@Override
public Status execute(Target src, int srcIndex, Status status) {
status.setErrorFlag(cpu.hardwareInterrupt(src.get(srcIndex)));
return status;
}
@Override
public Status execute(int src, Status status) {

View File

@@ -0,0 +1,32 @@
package net.simon987.server.assembly.instruction;
import net.simon987.server.assembly.CPU;
import net.simon987.server.assembly.Instruction;
import net.simon987.server.assembly.Status;
import net.simon987.server.assembly.Target;
public class HwqInstruction extends Instruction {
private static final int OPCODE = 28;
private CPU cpu;
public HwqInstruction(CPU cpu) {
super("hwq", OPCODE);
this.cpu = cpu;
}
@Override
public Status execute(Target src, int srcIndex, Status status) {
cpu.hardwareQuery(src.get(srcIndex));
return status;
}
@Override
public Status execute(int src, Status status) {
cpu.hardwareQuery(src);
return status;
}
}

View File

@@ -67,13 +67,13 @@ public class World implements JSONSerialisable{
ArrayList<GameObject> gameObjects_ = new ArrayList<>(gameObjects);
for(GameObject object : gameObjects_){
if(object instanceof Updatable){
((Updatable) object).update();
}
if(object.isDead()){
System.out.println("Removed" + object.getObjectId());
gameObjects.remove(object);
}
if (object instanceof Updatable) {
((Updatable) object).update();
}
}
}
@@ -145,17 +145,17 @@ public class World implements JSONSerialisable{
for (int y = 0; y < World.WORLD_SIZE; y++) {
for (int x = 0; x < World.WORLD_SIZE; x++) {
if (tiles[y][x] == TileMap.PLAIN_TILE) {
if (tiles[x][y] == TileMap.PLAIN_TILE) {
mapInfo[x][y] = 0;
} else if (tiles[y][x] == TileMap.WALL_TILE) {
} else if (tiles[x][y] == TileMap.WALL_TILE) {
mapInfo[x][y] = INFO_BLOCKED;
} else if (tiles[y][x] == TileMap.COPPER_TILE) {
} else if (tiles[x][y] == TileMap.COPPER_TILE) {
mapInfo[x][y] = INFO_COPPER;
} else if (tiles[y][x] == TileMap.IRON_TILE) {
} else if (tiles[x][y] == TileMap.IRON_TILE) {
mapInfo[x][y] = INFO_IRON;
}
}

View File

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

View File

@@ -110,6 +110,7 @@ public class SocketServer extends WebSocketServer {
public void onError(WebSocket conn, Exception ex) {
System.err.println("an error occured on connection " + conn.getRemoteSocketAddress() + ':' + ex);
userManager.remove(userManager.getUser(conn));
conn.close();
ex.printStackTrace();
}

View File

@@ -20,8 +20,6 @@ public class UserInfoRequestHandler implements MessageHandler {
json.put("t", "userInfo");
json.put("worldX", GameServer.INSTANCE.getConfig().getInt("new_user_worldX"));
json.put("worldY", GameServer.INSTANCE.getConfig().getInt("new_user_worldY"));
json.put("x", 1);
json.put("y", 1);
user.getWebSocket().send(json.toJSONString());
} else {
@@ -31,8 +29,6 @@ public class UserInfoRequestHandler implements MessageHandler {
json.put("t", "userInfo");
json.put("worldX", object.getWorld().getX());
json.put("worldY", object.getWorld().getY());
json.put("x", object.getX());
json.put("y", object.getY());
user.getWebSocket().send(json.toJSONString());
}