Slowly chipping away at file and event handling...
parent
3030e580a4
commit
845d0c9a2e
34
.classpath
34
.classpath
|
@ -1,25 +1,11 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="lib" path="lib/commons-cli-1.2.jar" sourcepath="lib/commons-cli-1.2-sources.jar"/>
|
||||
<classpathentry kind="lib" path="lib/js-14.jar"/>
|
||||
<classpathentry kind="lib" path="lib/ardor3d-animation-0.8.jar"/>
|
||||
<classpathentry kind="lib" path="lib/ardor3d-archetype-0.8.jar"/>
|
||||
<classpathentry kind="lib" path="lib/ardor3d-awt-0.8.jar"/>
|
||||
<classpathentry kind="lib" path="lib/ardor3d-collada-0.8.jar"/>
|
||||
<classpathentry kind="lib" path="lib/ardor3d-core-0.8.jar"/>
|
||||
<classpathentry kind="lib" path="lib/ardor3d-effects-0.8.jar"/>
|
||||
<classpathentry kind="lib" path="lib/ardor3d-extras-0.8.jar"/>
|
||||
<classpathentry kind="lib" path="lib/ardor3d-jogl-0.8.jar"/>
|
||||
<classpathentry kind="lib" path="lib/ardor3d-lwjgl-0.8.jar"/>
|
||||
<classpathentry kind="lib" path="lib/ardor3d-math-0.8.jar"/>
|
||||
<classpathentry kind="lib" path="lib/ardor3d-savable-0.8.jar"/>
|
||||
<classpathentry kind="lib" path="lib/ardor3d-swt-0.8.jar"/>
|
||||
<classpathentry kind="lib" path="lib/ardor3d-terrain-0.8.jar"/>
|
||||
<classpathentry kind="lib" path="lib/ardor3d-ui-0.8.jar"/>
|
||||
<classpathentry kind="lib" path="lib/commons-cli-1.2-sources.jar"/>
|
||||
<classpathentry kind="lib" path="lib/db4o-8.0.249.16098-all-java5.jar"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="lib" path="lib/commons-cli-1.2.jar" sourcepath="lib/commons-cli-1.2-sources.jar"/>
|
||||
<classpathentry kind="lib" path="lib/js-14.jar"/>
|
||||
<classpathentry kind="lib" path="lib/commons-cli-1.2-sources.jar"/>
|
||||
<classpathentry kind="lib" path="lib/db4o-8.0.249.16098-all-java5.jar"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package org.nodetest.servercore;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.concurrent.ArrayBlockingQueue;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
|
@ -11,7 +10,7 @@ public class EventProcessor {
|
|||
"maxEventThreads", 8);
|
||||
private static final int initialEventThreads = EngineSettings.getInt(
|
||||
"initialEventThreads", 8);
|
||||
static ThreadGroup eventProcessorGroup = new ThreadGroup(
|
||||
static ThreadGroup eventProcessorGroup = new ThreadGroup(
|
||||
"EventProcessor");
|
||||
private static AtomicBoolean runManager = new AtomicBoolean(true);
|
||||
protected static final int sampleInterval = EngineSettings.getInt(
|
||||
|
@ -24,6 +23,7 @@ static ThreadGroup eventProcessorGroup = new ThreadGroup(
|
|||
"eventQueueTuneSamples", 100);
|
||||
private static Thread manager = new Thread(eventProcessorGroup,
|
||||
new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
System.out.println("manager thread started");
|
||||
int ticks = 0;
|
||||
|
@ -38,6 +38,7 @@ static ThreadGroup eventProcessorGroup = new ThreadGroup(
|
|||
System.out.println("foo");
|
||||
threads[currentThreads]=new Thread(EventProcessor.eventProcessorGroup, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
System.out.println("Worker thread starteds");
|
||||
processEvents();
|
||||
|
@ -60,6 +61,7 @@ static ThreadGroup eventProcessorGroup = new ThreadGroup(
|
|||
&& (((float) ticksBusy / (float) ticks) > ((float) upshift / (float) samples))) {
|
||||
new Thread(eventProcessorGroup, new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
System.out.println("Dynamically added thread");
|
||||
processEvents();
|
||||
|
@ -71,7 +73,7 @@ static ThreadGroup eventProcessorGroup = new ThreadGroup(
|
|||
}
|
||||
if (((float) ticksBusy / (float) ticks) < ((float) downshift / (float) samples)) {
|
||||
System.out.println(("Stopping one thread"));
|
||||
eventQueue.add(new MossStopEvent());
|
||||
eventQueue.add(new MossEvent(MossEvent.EvtType.EVT_THREADSTOP));
|
||||
|
||||
}
|
||||
ticks = 0;
|
||||
|
@ -92,9 +94,8 @@ static ThreadGroup eventProcessorGroup = new ThreadGroup(
|
|||
boolean run=true; //Not synchronized as only used internally
|
||||
while(run){try {
|
||||
MossEvent myEvent=eventQueue.take();
|
||||
if(myEvent instanceof MossStopEvent){
|
||||
System.out.println("Thread shutting down");
|
||||
run=false;
|
||||
{//Section for actually handling the events
|
||||
|
||||
|
||||
}
|
||||
//Otherwise do some cool scripting stuff!
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
package org.nodetest.servercore;
|
||||
|
||||
import java.util.concurrent.ArrayBlockingQueue;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
public class FileManager {
|
||||
public class Chunk {
|
||||
byte[] fileSha512;
|
||||
byte[] data;
|
||||
}
|
||||
AtomicBoolean shouldRun=new AtomicBoolean(true);
|
||||
static ArrayBlockingQueue<MossFile> resolutionQueue = new ArrayBlockingQueue<>(
|
||||
256);
|
||||
private static ArrayBlockingQueue<FileManager.Chunk> chunkInQueue = new ArrayBlockingQueue<>(
|
||||
256);
|
||||
private Thread resolutionThread = new Thread(new Runnable() {
|
||||
public void run(){
|
||||
while(shouldRun.get()){
|
||||
MossFile fileIn = resolutionQueue.poll();
|
||||
if (fileIn!=null){
|
||||
// FIXME
|
||||
//NetworkManager.send(NetworkManager.PacketTypes.TOSERVER_INIT, fileIn.sha256);
|
||||
}
|
||||
}
|
||||
}
|
||||
}, "FileResolutionThread");
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
package org.nodetest.servercore;
|
||||
|
||||
public class ItemStack {
|
||||
MossItem item;
|
||||
}
|
|
@ -3,8 +3,8 @@ package org.nodetest.servercore;
|
|||
public class MapChunk {
|
||||
|
||||
private int[][][] nodes=new int[16][16][16];
|
||||
long x,y,z;
|
||||
public MapChunk(long x, long y, long z, String chunkLightStorage,
|
||||
int x,y,z;
|
||||
public MapChunk(int x, int y, int z, String chunkLightStorage,
|
||||
String heavy) {
|
||||
this.x=x;
|
||||
this.y=y;
|
||||
|
|
|
@ -3,13 +3,13 @@ package org.nodetest.servercore;
|
|||
|
||||
public class MapChunkPacked {
|
||||
|
||||
long x;
|
||||
long y;
|
||||
long z;
|
||||
int x;
|
||||
int y;
|
||||
int z;
|
||||
String chunkLightStorage;
|
||||
String heavy;
|
||||
|
||||
public MapChunkPacked(long x, long y, long z, String chunkLightStorage,
|
||||
public MapChunkPacked(int x, int y, int z, String chunkLightStorage,
|
||||
String heavy) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
|
|
|
@ -1,5 +1,19 @@
|
|||
package org.nodetest.servercore;
|
||||
|
||||
public class MossEvent {
|
||||
|
||||
enum EvtType {
|
||||
EVT_DIEPLAYER, EVT_DIGNODE, EVT_PREGENERATE, EVT_POSTGENERATE, EVT_JOINPLAYER, EVT_QUITPLAYER, EVT_NEWPLAYER, EVT_PLACENODE,
|
||||
EVT_FSPEC_OPEN, EVT_FSPEC_SUBMIT, EVT_FSPEC_INVACTION, EVT_THREADSTOP, EVT_ENTITY_PUNCH, EVT_ENTITY_DEATH, EVT_CHATMESSAGE, EVT_SHUTDOWN,
|
||||
EVT_CHATCOMMAND, EVT_NODEMOVE
|
||||
}
|
||||
MossEvent.EvtType type;
|
||||
Entity actor; //Player extends entity
|
||||
long posx;
|
||||
long posy;
|
||||
long posz;
|
||||
MapNode nodeBefore;
|
||||
MapNode nodeAfter;
|
||||
Entity recvEntity;
|
||||
MossFormspec fspec;
|
||||
MossInventoryAction action;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
package org.nodetest.servercore;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
|
||||
public class MossFile {
|
||||
byte[] sha512;
|
||||
byte[] data;
|
||||
String name;
|
||||
AtomicBoolean isReady=new AtomicBoolean(false);
|
||||
public MossFile(byte[] sha512, String name) throws InterruptedException {
|
||||
|
||||
this.sha512 = sha512;
|
||||
this.name = name;
|
||||
FileManager.resolutionQueue.put(this);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
/**
|
||||
* TODO
|
||||
*/
|
||||
package org.nodetest.servercore;
|
||||
|
||||
|
||||
public class MossFormspec {
|
||||
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package org.nodetest.servercore;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class MossInventory {
|
||||
int maxStackSize;
|
||||
int width;
|
||||
int height;
|
||||
ArrayList<ArrayList<ItemStack>> stacks=new ArrayList<>();
|
||||
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
package org.nodetest.servercore;
|
||||
|
||||
public class MossInventoryAction {
|
||||
MossInventory from;
|
||||
MossInventory to;
|
||||
ItemStack moved;
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
package org.nodetest.servercore;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
|
||||
public class MossItem {
|
||||
MossFile invTex;
|
||||
MossFile wieldTex;
|
||||
double invWeight;
|
||||
boolean mayStack;
|
||||
String displayName;
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
package org.nodetest.servercore;
|
||||
|
||||
public class MossStopEvent extends MossEvent {
|
||||
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
package org.nodetest.servercore;
|
||||
|
||||
public class Player {
|
||||
public class Player extends Entity{
|
||||
|
||||
}
|
||||
|
|
|
@ -38,9 +38,8 @@ public class ScriptEnv {
|
|||
|
||||
public boolean visibleToScripts(String className) {
|
||||
if (className.startsWith("adapter")
|
||||
|| className.startsWith("PluginOurname")
|
||||
|| (allowDb && className.startsWith("DbPlugin")))// FIXME
|
||||
// name
|
||||
|| className=="MossScriptEnv")
|
||||
|
||||
return true;
|
||||
|
||||
else
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
package org.nodetest.servercore;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
|
||||
public class TextureManager {
|
||||
static ArrayList<MossFile> texs=new ArrayList<>();
|
||||
static MossFile addTexture(MossFile tex){
|
||||
for(MossFile thisTex : texs){
|
||||
if(tex.sha512==thisTex.sha512) return thisTex;
|
||||
}
|
||||
return tex;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue