Work on data storage system. We need some form of caching.
parent
af772a0215
commit
c21ac7882d
34
.classpath
34
.classpath
|
@ -1,9 +1,25 @@
|
|||
<?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="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>
|
||||
<?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"/>
|
||||
</classpath>
|
||||
|
|
|
@ -2,11 +2,17 @@ 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,
|
||||
String heavy) {
|
||||
// TODO Auto-generated constructor stub
|
||||
this.x=x;
|
||||
this.y=y;
|
||||
this.z=z;
|
||||
for(int i=0; i<4096; i++){
|
||||
int thisNode=chunkLightStorage.charAt(4*i)<<24+chunkLightStorage.charAt(4*i+1)<<16+chunkLightStorage.charAt(4*i+2)<<8+chunkLightStorage.charAt(4*i+3);
|
||||
nodes[(i/256)][(i/16)%16][i%16]=thisNode;
|
||||
}
|
||||
}
|
||||
|
||||
public MapChunkPacked pack(){
|
||||
|
|
|
@ -20,15 +20,19 @@ import com.db4o.query.Query;
|
|||
import java.util.UUID;
|
||||
|
||||
public class MapDatabase {
|
||||
ObjectContainer mapDb;
|
||||
static ObjectContainer mapDb;
|
||||
static ObjectContainer nodeDb;
|
||||
static ObjectContainer entityDb;
|
||||
static ObjectContainer banDb;
|
||||
public MapDatabase(String name, boolean create) throws MapDatabaseException, MossWorldLoadException {
|
||||
if(!name.matches("^[A-Z[a-z[0-9[ ]]]]+$")){
|
||||
throw new MossWorldLoadException("World name contains invalid characters");
|
||||
}
|
||||
|
||||
try {
|
||||
//mapDb=Db4oEmbedded.openFile("worlds/"+name+"mapdb.db4o");
|
||||
mapDb=Db4oEmbedded.openFile("testDb6.db");
|
||||
mapDb=Db4oEmbedded.openFile("worlds/"+name+"mapdb");
|
||||
entityDb=Db4oEmbedded.openFile("worlds/"+name+"entities");
|
||||
banDb=Db4oEmbedded.openFile("worlds/"+name+"nodes");
|
||||
} catch (Db4oIOException | DatabaseFileLockedException
|
||||
| IncompatibleFileFormatException | OldFormatException
|
||||
| DatabaseReadOnlyException e) {
|
||||
|
@ -71,6 +75,7 @@ ObjectContainer mapDb;
|
|||
* @throws MapDatabaseException
|
||||
*/
|
||||
public static void main(String[] args) throws MapDatabaseException, MossWorldLoadException {
|
||||
//TESTING ONLY
|
||||
MapDatabase ourDb=new MapDatabase("test2", true);
|
||||
for(int i=1; i<=320; i++){
|
||||
//ourDb.add(new MapChunkPacked(i, i, i, UUID.randomUUID().toString(), UUID.randomUUID().toString()));
|
||||
|
@ -98,9 +103,14 @@ ed++;
|
|||
|
||||
}
|
||||
|
||||
private void add(MapChunkPacked mapChunkPacked) {
|
||||
private void addMapChunk(MapChunkPacked mapChunkPacked) {
|
||||
mapDb.store(mapChunkPacked);
|
||||
|
||||
}
|
||||
private void addMapChunk(MapChunk mapChunk) {
|
||||
mapDb.store(mapChunk.pack());
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -2,13 +2,17 @@ package org.nodetest.servercore;
|
|||
|
||||
|
||||
public class MapNode {
|
||||
protected long nodeId;
|
||||
protected int nodeId=0;
|
||||
public MapNode(NodeParams nodeparams, GenericTexture textureSpace,
|
||||
String nodeName, String userFacingName, boolean isLiquid,
|
||||
int lightEmission) {
|
||||
this.nodeparams = nodeparams;
|
||||
this.textureSpace = textureSpace;
|
||||
this.nodeName = nodeName;
|
||||
for (int i = 0; i < nodeName.length(); i++)
|
||||
{
|
||||
nodeId = 31*nodeId + nodeName.charAt(i);
|
||||
}
|
||||
this.userFacingName = userFacingName;
|
||||
this.isLiquid = isLiquid;
|
||||
this.lightEmission = lightEmission;
|
||||
|
|
Loading…
Reference in New Issue