mirror of
https://github.com/simon987/Much-Assembly-Required.git
synced 2025-12-13 22:59:02 +00:00
Merge branch 'master' into vaults
# Conflicts: # Server/src/main/java/net/simon987/server/game/GameObject.java # Server/src/main/java/net/simon987/server/game/World.java # Server/src/main/java/net/simon987/server/webserver/TerrainRequestHandler.java
This commit is contained in:
@@ -9,9 +9,9 @@ import java.net.InetSocketAddress;
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
|
||||
|
||||
LogManager.initialize();
|
||||
ServerConfiguration config = new ServerConfiguration("config.properties");
|
||||
LogManager.initialize(config);
|
||||
|
||||
//Load
|
||||
GameServer.INSTANCE.load();
|
||||
|
||||
|
||||
@@ -99,6 +99,8 @@ public class CPU implements MongoSerialisable {
|
||||
instructionSet.add(new JoInstruction(this));
|
||||
instructionSet.add(new PushfInstruction(this));
|
||||
instructionSet.add(new PopfInstruction(this));
|
||||
instructionSet.add(new JnaInstruction(this));
|
||||
instructionSet.add(new JaInstruction(this));
|
||||
|
||||
status = new Status();
|
||||
memory = new Memory(config.getInt("memory_size"));
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
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;
|
||||
|
||||
/**
|
||||
* Jump if above
|
||||
*/
|
||||
public class JaInstruction extends Instruction {
|
||||
|
||||
public static final int OPCODE = 46;
|
||||
|
||||
private CPU cpu;
|
||||
|
||||
public JaInstruction(CPU cpu) {
|
||||
super("ja", OPCODE);
|
||||
|
||||
this.cpu = cpu;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Status execute(Target src, int srcIndex, Status status) {
|
||||
if (!status.isCarryFlag() && !status.isZeroFlag()) {
|
||||
cpu.setIp((char) src.get(srcIndex));
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Status execute(int src, Status status) {
|
||||
if (!status.isCarryFlag() && !status.isZeroFlag()) {
|
||||
cpu.setIp((char) src);
|
||||
}
|
||||
return status;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
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;
|
||||
|
||||
/**
|
||||
* Jump if not above
|
||||
*/
|
||||
public class JnaInstruction extends Instruction {
|
||||
|
||||
public static final int OPCODE = 47;
|
||||
|
||||
private CPU cpu;
|
||||
|
||||
public JnaInstruction(CPU cpu) {
|
||||
super("jna", OPCODE);
|
||||
|
||||
this.cpu = cpu;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Status execute(Target src, int srcIndex, Status status) {
|
||||
if (status.isCarryFlag() || status.isZeroFlag()) {
|
||||
cpu.setIp((char) src.get(srcIndex));
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Status execute(int src, Status status) {
|
||||
if (status.isCarryFlag() || status.isZeroFlag()) {
|
||||
cpu.setIp((char) src);
|
||||
}
|
||||
return status;
|
||||
}
|
||||
}
|
||||
@@ -254,7 +254,7 @@ public abstract class GameObject implements JSONSerialisable, MongoSerialisable
|
||||
|
||||
/**
|
||||
* Called before this GameObject is removed from the world - defaults to doing nothing
|
||||
* @return cancelled
|
||||
* @return true if cancelled
|
||||
*/
|
||||
public boolean onDeadCallback() {
|
||||
return false;
|
||||
|
||||
@@ -159,6 +159,7 @@ public class World implements MongoSerialisable {
|
||||
if (object.isDead()) {
|
||||
if (!object.onDeadCallback()) {
|
||||
removeObject(object);
|
||||
//LogManager.LOGGER.fine("Removed object " + object + " id: " + object.getObjectId());
|
||||
}
|
||||
|
||||
} else if (object instanceof Updatable) {
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package net.simon987.server.logging;
|
||||
|
||||
import net.simon987.server.ServerConfiguration;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.logging.*;
|
||||
|
||||
@@ -16,7 +18,7 @@ public class LogManager {
|
||||
/**
|
||||
* Initialises the logger
|
||||
*/
|
||||
public static void initialize() {
|
||||
public static void initialize(ServerConfiguration config) {
|
||||
LOGGER.setUseParentHandlers(false);
|
||||
|
||||
/*
|
||||
@@ -45,15 +47,18 @@ public class LogManager {
|
||||
handler.setLevel(Level.ALL);
|
||||
|
||||
try {
|
||||
Handler fileHandler = new FileHandler("mar.log");
|
||||
Handler fileHandler = new FileHandler("mar-%g.log", config.getInt("log_limit"),
|
||||
config.getInt("log_count"));
|
||||
fileHandler.setLevel(Level.ALL);
|
||||
fileHandler.setFormatter(new GenericFormatter());
|
||||
|
||||
|
||||
LOGGER.addHandler(handler);
|
||||
LOGGER.addHandler(errHandler);
|
||||
LOGGER.addHandler(fileHandler);
|
||||
LOGGER.setLevel(Level.ALL);
|
||||
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -6,8 +6,8 @@ mysql_pass=mar
|
||||
mysql_url=jdbc:mysql://localhost:3306/mar?useSSL=false
|
||||
# File management
|
||||
save_interval=5
|
||||
clean_interval=10
|
||||
history_size=10
|
||||
log_limit=2000000
|
||||
log_count=10
|
||||
# Web server port
|
||||
webSocket_port=8887
|
||||
webSocket_host=0.0.0.0
|
||||
@@ -49,6 +49,10 @@ maxBiomassRespawnCount=6
|
||||
biomassEnergyValue=4000
|
||||
# Maximum energy of the battery hardware in kJ
|
||||
battery_max_energy=60000
|
||||
# Maximum shield power
|
||||
max_shield=100
|
||||
# Energy cost per unit to charge shield
|
||||
shield_energy_cost=50
|
||||
# Time for biomass respawn in ticks
|
||||
biomassRespawnTime=64
|
||||
# Respawn timer will start when biomass count is below this number
|
||||
|
||||
Reference in New Issue
Block a user