Move server terrain code to server folder
This commit is contained in:
parent
fda4a9584b
commit
d8f234503a
@ -287,6 +287,10 @@
|
|||||||
{
|
{
|
||||||
"name" : "randomizerValue44",
|
"name" : "randomizerValue44",
|
||||||
"type" : "FIXED_LONG"
|
"type" : "FIXED_LONG"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name" : "chunkData",
|
||||||
|
"type" : "BYTE_ARRAY"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"messageTypes" : [
|
"messageTypes" : [
|
||||||
@ -405,6 +409,23 @@
|
|||||||
"realLocationY",
|
"realLocationY",
|
||||||
"realLocationZ"
|
"realLocationZ"
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"messageName" : "RequestChunkData",
|
||||||
|
"data" : [
|
||||||
|
"worldX",
|
||||||
|
"worldY",
|
||||||
|
"worldZ"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"messageName" : "sendChunkData",
|
||||||
|
"data" : [
|
||||||
|
"worldX",
|
||||||
|
"worldY",
|
||||||
|
"worldZ",
|
||||||
|
"chunkData"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
@ -34,7 +34,6 @@ import electrosphere.game.collision.CollisionEngine;
|
|||||||
import electrosphere.game.collision.CommonWorldData;
|
import electrosphere.game.collision.CommonWorldData;
|
||||||
import electrosphere.game.config.UserSettings;
|
import electrosphere.game.config.UserSettings;
|
||||||
import electrosphere.game.server.structure.virtual.StructureManager;
|
import electrosphere.game.server.structure.virtual.StructureManager;
|
||||||
import electrosphere.game.server.terrain.manager.ServerTerrainManager;
|
|
||||||
import electrosphere.game.server.world.MacroData;
|
import electrosphere.game.server.world.MacroData;
|
||||||
import electrosphere.game.server.world.ServerWorldData;
|
import electrosphere.game.server.world.ServerWorldData;
|
||||||
import electrosphere.logger.LoggerInterface;
|
import electrosphere.logger.LoggerInterface;
|
||||||
@ -70,6 +69,7 @@ import electrosphere.server.db.DatabaseController;
|
|||||||
import electrosphere.server.pathfinding.NavMeshManager;
|
import electrosphere.server.pathfinding.NavMeshManager;
|
||||||
import electrosphere.server.simulation.MacroSimulation;
|
import electrosphere.server.simulation.MacroSimulation;
|
||||||
import electrosphere.server.simulation.MicroSimulation;
|
import electrosphere.server.simulation.MicroSimulation;
|
||||||
|
import electrosphere.server.terrain.manager.ServerTerrainManager;
|
||||||
import electrosphere.util.FileUtils;
|
import electrosphere.util.FileUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -13,6 +13,9 @@ import electrosphere.engine.loadingthreads.LoadingThread;
|
|||||||
import electrosphere.game.client.ClientFunctions;
|
import electrosphere.game.client.ClientFunctions;
|
||||||
import electrosphere.game.config.UserSettings;
|
import electrosphere.game.config.UserSettings;
|
||||||
import electrosphere.logger.LoggerInterface;
|
import electrosphere.logger.LoggerInterface;
|
||||||
|
import electrosphere.net.parser.net.message.TerrainMessage;
|
||||||
|
import electrosphere.net.parser.net.raw.NetworkParser;
|
||||||
|
import electrosphere.net.parser.util.ByteStreamUtils;
|
||||||
import electrosphere.renderer.Model;
|
import electrosphere.renderer.Model;
|
||||||
import electrosphere.renderer.RenderingEngine;
|
import electrosphere.renderer.RenderingEngine;
|
||||||
import electrosphere.util.worldviewer.TerrainViewer;
|
import electrosphere.util.worldviewer.TerrainViewer;
|
||||||
|
|||||||
@ -11,10 +11,10 @@ import electrosphere.entity.Entity;
|
|||||||
import electrosphere.entity.EntityDataStrings;
|
import electrosphere.entity.EntityDataStrings;
|
||||||
import electrosphere.entity.EntityUtils;
|
import electrosphere.entity.EntityUtils;
|
||||||
import electrosphere.entity.ServerEntityUtils;
|
import electrosphere.entity.ServerEntityUtils;
|
||||||
import electrosphere.game.server.terrain.manager.ServerTerrainManager;
|
|
||||||
import electrosphere.game.server.world.ServerWorldData;
|
import electrosphere.game.server.world.ServerWorldData;
|
||||||
import electrosphere.logger.LoggerInterface;
|
import electrosphere.logger.LoggerInterface;
|
||||||
import electrosphere.server.saves.SaveUtils;
|
import electrosphere.server.saves.SaveUtils;
|
||||||
|
import electrosphere.server.terrain.manager.ServerTerrainManager;
|
||||||
import electrosphere.util.FileUtils;
|
import electrosphere.util.FileUtils;
|
||||||
|
|
||||||
public class ArenaLoading {
|
public class ArenaLoading {
|
||||||
|
|||||||
@ -8,7 +8,6 @@ import electrosphere.auth.AuthenticationManager;
|
|||||||
import electrosphere.engine.Globals;
|
import electrosphere.engine.Globals;
|
||||||
import electrosphere.entity.types.camera.CameraEntityUtils;
|
import electrosphere.entity.types.camera.CameraEntityUtils;
|
||||||
import electrosphere.game.client.targeting.crosshair.Crosshair;
|
import electrosphere.game.client.targeting.crosshair.Crosshair;
|
||||||
import electrosphere.game.server.terrain.manager.ServerTerrainManager;
|
|
||||||
import electrosphere.game.server.world.ServerWorldData;
|
import electrosphere.game.server.world.ServerWorldData;
|
||||||
import electrosphere.logger.LoggerInterface;
|
import electrosphere.logger.LoggerInterface;
|
||||||
import electrosphere.menu.MenuGenerators;
|
import electrosphere.menu.MenuGenerators;
|
||||||
@ -16,6 +15,7 @@ import electrosphere.menu.WindowStrings;
|
|||||||
import electrosphere.menu.WindowUtils;
|
import electrosphere.menu.WindowUtils;
|
||||||
import electrosphere.renderer.ui.Window;
|
import electrosphere.renderer.ui.Window;
|
||||||
import electrosphere.server.saves.SaveUtils;
|
import electrosphere.server.saves.SaveUtils;
|
||||||
|
import electrosphere.server.terrain.manager.ServerTerrainManager;
|
||||||
import electrosphere.util.FileUtils;
|
import electrosphere.util.FileUtils;
|
||||||
import electrosphere.controls.ControlHandler;
|
import electrosphere.controls.ControlHandler;
|
||||||
|
|
||||||
|
|||||||
@ -23,7 +23,6 @@ import electrosphere.game.client.cells.DrawCellManager;
|
|||||||
import electrosphere.game.collision.CommonWorldData;
|
import electrosphere.game.collision.CommonWorldData;
|
||||||
import electrosphere.game.data.creature.type.CreatureType;
|
import electrosphere.game.data.creature.type.CreatureType;
|
||||||
import electrosphere.game.data.creature.type.visualattribute.VisualAttribute;
|
import electrosphere.game.data.creature.type.visualattribute.VisualAttribute;
|
||||||
import electrosphere.game.server.terrain.manager.ServerTerrainManager;
|
|
||||||
import electrosphere.game.server.town.Town;
|
import electrosphere.game.server.town.Town;
|
||||||
import electrosphere.game.server.world.MacroData;
|
import electrosphere.game.server.world.MacroData;
|
||||||
import electrosphere.game.server.world.ServerWorldData;
|
import electrosphere.game.server.world.ServerWorldData;
|
||||||
@ -36,6 +35,7 @@ import electrosphere.server.datacell.Realm;
|
|||||||
import electrosphere.server.saves.SaveUtils;
|
import electrosphere.server.saves.SaveUtils;
|
||||||
import electrosphere.server.simulation.MacroSimulation;
|
import electrosphere.server.simulation.MacroSimulation;
|
||||||
import electrosphere.server.simulation.MicroSimulation;
|
import electrosphere.server.simulation.MicroSimulation;
|
||||||
|
import electrosphere.server.terrain.manager.ServerTerrainManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utilities for all loading thread types
|
* Utilities for all loading thread types
|
||||||
|
|||||||
@ -1,9 +1,9 @@
|
|||||||
package electrosphere.engine.loadingthreads;
|
package electrosphere.engine.loadingthreads;
|
||||||
|
|
||||||
import electrosphere.engine.Globals;
|
import electrosphere.engine.Globals;
|
||||||
import electrosphere.game.server.terrain.manager.ServerTerrainManager;
|
|
||||||
import electrosphere.logger.LoggerInterface;
|
import electrosphere.logger.LoggerInterface;
|
||||||
import electrosphere.server.saves.SaveUtils;
|
import electrosphere.server.saves.SaveUtils;
|
||||||
|
import electrosphere.server.terrain.manager.ServerTerrainManager;
|
||||||
|
|
||||||
public class ServerLoading {
|
public class ServerLoading {
|
||||||
|
|
||||||
|
|||||||
@ -2,12 +2,13 @@ package electrosphere.game.client.cells;
|
|||||||
|
|
||||||
import electrosphere.engine.Globals;
|
import electrosphere.engine.Globals;
|
||||||
import electrosphere.game.client.terrain.manager.ClientTerrainManager;
|
import electrosphere.game.client.terrain.manager.ClientTerrainManager;
|
||||||
import electrosphere.game.server.terrain.manager.ServerTerrainManager;
|
|
||||||
import electrosphere.game.terrain.processing.TerrainInterpolator;
|
import electrosphere.game.terrain.processing.TerrainInterpolator;
|
||||||
import electrosphere.game.client.world.ClientWorldData;
|
import electrosphere.game.client.world.ClientWorldData;
|
||||||
import electrosphere.game.collision.CommonWorldData;
|
import electrosphere.game.collision.CommonWorldData;
|
||||||
import electrosphere.net.parser.net.message.TerrainMessage;
|
import electrosphere.net.parser.net.message.TerrainMessage;
|
||||||
import electrosphere.renderer.ShaderProgram;
|
import electrosphere.renderer.ShaderProgram;
|
||||||
|
import electrosphere.server.terrain.manager.ServerTerrainManager;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
|||||||
@ -1,8 +1,9 @@
|
|||||||
package electrosphere.game.client.terrain.cache;
|
package electrosphere.game.client.terrain.cache;
|
||||||
|
|
||||||
import electrosphere.game.client.world.ClientWorldData;
|
import electrosphere.game.client.world.ClientWorldData;
|
||||||
import electrosphere.game.server.terrain.models.TerrainModel;
|
|
||||||
import electrosphere.game.terrain.processing.TerrainInterpolator;
|
import electrosphere.game.terrain.processing.TerrainInterpolator;
|
||||||
|
import electrosphere.server.terrain.models.TerrainModel;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|||||||
@ -2,7 +2,7 @@ package electrosphere.game.client.world;
|
|||||||
|
|
||||||
import electrosphere.game.server.world.*;
|
import electrosphere.game.server.world.*;
|
||||||
import electrosphere.server.datacell.ServerDataCell;
|
import electrosphere.server.datacell.ServerDataCell;
|
||||||
import electrosphere.game.server.terrain.manager.ServerTerrainManager;
|
import electrosphere.server.terrain.manager.ServerTerrainManager;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.joml.Vector2f;
|
import org.joml.Vector2f;
|
||||||
|
|||||||
@ -2,8 +2,9 @@ package electrosphere.game.collision;
|
|||||||
|
|
||||||
import electrosphere.game.client.terrain.manager.ClientTerrainManager;
|
import electrosphere.game.client.terrain.manager.ClientTerrainManager;
|
||||||
import electrosphere.game.client.world.ClientWorldData;
|
import electrosphere.game.client.world.ClientWorldData;
|
||||||
import electrosphere.game.server.terrain.manager.ServerTerrainManager;
|
|
||||||
import electrosphere.game.server.world.ServerWorldData;
|
import electrosphere.game.server.world.ServerWorldData;
|
||||||
|
import electrosphere.server.terrain.manager.ServerTerrainManager;
|
||||||
|
|
||||||
import org.joml.Vector3d;
|
import org.joml.Vector3d;
|
||||||
import org.joml.Vector3f;
|
import org.joml.Vector3f;
|
||||||
|
|
||||||
|
|||||||
@ -2,11 +2,11 @@ package electrosphere.game.server.town;
|
|||||||
|
|
||||||
import electrosphere.game.server.structure.virtual.Structure;
|
import electrosphere.game.server.structure.virtual.Structure;
|
||||||
import electrosphere.game.server.structure.virtual.VirtualStructureUtils;
|
import electrosphere.game.server.structure.virtual.VirtualStructureUtils;
|
||||||
import electrosphere.game.server.terrain.manager.ServerTerrainChunk;
|
|
||||||
import electrosphere.engine.Globals;
|
import electrosphere.engine.Globals;
|
||||||
import electrosphere.game.server.character.Character;
|
import electrosphere.game.server.character.Character;
|
||||||
import electrosphere.logger.LoggerInterface;
|
import electrosphere.logger.LoggerInterface;
|
||||||
import electrosphere.server.db.DatabaseResult;
|
import electrosphere.server.db.DatabaseResult;
|
||||||
|
import electrosphere.server.terrain.manager.ServerTerrainChunk;
|
||||||
|
|
||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
package electrosphere.game.server.world;
|
package electrosphere.game.server.world;
|
||||||
|
|
||||||
import electrosphere.game.server.terrain.manager.ServerTerrainManager;
|
|
||||||
import electrosphere.server.datacell.ServerDataCell;
|
import electrosphere.server.datacell.ServerDataCell;
|
||||||
|
import electrosphere.server.terrain.manager.ServerTerrainManager;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import org.joml.Vector3f;
|
import org.joml.Vector3f;
|
||||||
|
|||||||
@ -16,7 +16,6 @@ import electrosphere.entity.types.camera.CameraEntityUtils;
|
|||||||
import electrosphere.entity.types.creature.CreatureUtils;
|
import electrosphere.entity.types.creature.CreatureUtils;
|
||||||
import electrosphere.game.data.creature.type.CreatureType;
|
import electrosphere.game.data.creature.type.CreatureType;
|
||||||
import electrosphere.game.data.creature.type.visualattribute.VisualAttribute;
|
import electrosphere.game.data.creature.type.visualattribute.VisualAttribute;
|
||||||
import electrosphere.game.server.terrain.manager.ServerTerrainManager;
|
|
||||||
import electrosphere.net.NetUtils;
|
import electrosphere.net.NetUtils;
|
||||||
import electrosphere.renderer.Model;
|
import electrosphere.renderer.Model;
|
||||||
import electrosphere.renderer.RenderingEngine;
|
import electrosphere.renderer.RenderingEngine;
|
||||||
@ -41,6 +40,7 @@ import electrosphere.renderer.ui.events.NavigationEvent;
|
|||||||
import electrosphere.renderer.ui.events.ValueChangeEvent;
|
import electrosphere.renderer.ui.events.ValueChangeEvent;
|
||||||
import electrosphere.renderer.ui.form.FormElement;
|
import electrosphere.renderer.ui.form.FormElement;
|
||||||
import electrosphere.server.saves.SaveUtils;
|
import electrosphere.server.saves.SaveUtils;
|
||||||
|
import electrosphere.server.terrain.manager.ServerTerrainManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|||||||
@ -223,6 +223,16 @@ INVENTORY_MESSAGE,
|
|||||||
rVal = TerrainMessage.parseSpawnPositionMessage(byteStream);
|
rVal = TerrainMessage.parseSpawnPositionMessage(byteStream);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case TypeBytes.TERRAIN_MESSAGE_TYPE_REQUESTCHUNKDATA:
|
||||||
|
if(TerrainMessage.canParseMessage(byteStream,secondByte)){
|
||||||
|
rVal = TerrainMessage.parseRequestChunkDataMessage(byteStream);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case TypeBytes.TERRAIN_MESSAGE_TYPE_SENDCHUNKDATA:
|
||||||
|
if(TerrainMessage.canParseMessage(byteStream,secondByte)){
|
||||||
|
rVal = TerrainMessage.parsesendChunkDataMessage(byteStream);
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case TypeBytes.MESSAGE_TYPE_SERVER:
|
case TypeBytes.MESSAGE_TYPE_SERVER:
|
||||||
|
|||||||
@ -15,6 +15,8 @@ public class TerrainMessage extends NetworkMessage {
|
|||||||
MACROVALUE,
|
MACROVALUE,
|
||||||
HEIGHTMAPMODIFICATION,
|
HEIGHTMAPMODIFICATION,
|
||||||
SPAWNPOSITION,
|
SPAWNPOSITION,
|
||||||
|
REQUESTCHUNKDATA,
|
||||||
|
SENDCHUNKDATA,
|
||||||
}
|
}
|
||||||
|
|
||||||
TerrainMessageType messageType;
|
TerrainMessageType messageType;
|
||||||
@ -85,6 +87,7 @@ public class TerrainMessage extends NetworkMessage {
|
|||||||
long randomizerValue42;
|
long randomizerValue42;
|
||||||
long randomizerValue43;
|
long randomizerValue43;
|
||||||
long randomizerValue44;
|
long randomizerValue44;
|
||||||
|
byte[] chunkData;
|
||||||
|
|
||||||
TerrainMessage(TerrainMessageType messageType){
|
TerrainMessage(TerrainMessageType messageType){
|
||||||
this.type = MessageType.TERRAIN_MESSAGE;
|
this.type = MessageType.TERRAIN_MESSAGE;
|
||||||
@ -631,6 +634,14 @@ public class TerrainMessage extends NetworkMessage {
|
|||||||
this.randomizerValue44 = randomizerValue44;
|
this.randomizerValue44 = randomizerValue44;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public byte[] getchunkData() {
|
||||||
|
return chunkData;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setchunkData(byte[] chunkData) {
|
||||||
|
this.chunkData = chunkData;
|
||||||
|
}
|
||||||
|
|
||||||
static void stripPacketHeader(List<Byte> byteStream){
|
static void stripPacketHeader(List<Byte> byteStream){
|
||||||
byteStream.remove(0);
|
byteStream.remove(0);
|
||||||
byteStream.remove(0);
|
byteStream.remove(0);
|
||||||
@ -686,6 +697,14 @@ public class TerrainMessage extends NetworkMessage {
|
|||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
case TypeBytes.TERRAIN_MESSAGE_TYPE_REQUESTCHUNKDATA:
|
||||||
|
if(byteStream.size() >= TypeBytes.TERRAIN_MESSAGE_TYPE_REQUESTCHUNKDATA_SIZE){
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
case TypeBytes.TERRAIN_MESSAGE_TYPE_SENDCHUNKDATA:
|
||||||
|
return TerrainMessage.canParsesendChunkDataMessage(byteStream);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -940,6 +959,72 @@ public class TerrainMessage extends NetworkMessage {
|
|||||||
return rVal;
|
return rVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static TerrainMessage parseRequestChunkDataMessage(List<Byte> byteStream){
|
||||||
|
TerrainMessage rVal = new TerrainMessage(TerrainMessageType.REQUESTCHUNKDATA);
|
||||||
|
stripPacketHeader(byteStream);
|
||||||
|
rVal.setworldX(ByteStreamUtils.popIntFromByteQueue(byteStream));
|
||||||
|
rVal.setworldY(ByteStreamUtils.popIntFromByteQueue(byteStream));
|
||||||
|
rVal.setworldZ(ByteStreamUtils.popIntFromByteQueue(byteStream));
|
||||||
|
return rVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static TerrainMessage constructRequestChunkDataMessage(int worldX,int worldY,int worldZ){
|
||||||
|
TerrainMessage rVal = new TerrainMessage(TerrainMessageType.REQUESTCHUNKDATA);
|
||||||
|
rVal.setworldX(worldX);
|
||||||
|
rVal.setworldY(worldY);
|
||||||
|
rVal.setworldZ(worldZ);
|
||||||
|
rVal.serialize();
|
||||||
|
return rVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean canParsesendChunkDataMessage(List<Byte> byteStream){
|
||||||
|
int currentStreamLength = byteStream.size();
|
||||||
|
List<Byte> temporaryByteQueue = new LinkedList();
|
||||||
|
if(currentStreamLength < 6){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if(currentStreamLength < 10){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if(currentStreamLength < 14){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
int chunkDataSize = 0;
|
||||||
|
if(currentStreamLength < 18){
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
temporaryByteQueue.add(byteStream.get(14 + 0));
|
||||||
|
temporaryByteQueue.add(byteStream.get(14 + 1));
|
||||||
|
temporaryByteQueue.add(byteStream.get(14 + 2));
|
||||||
|
temporaryByteQueue.add(byteStream.get(14 + 3));
|
||||||
|
chunkDataSize = ByteStreamUtils.popIntFromByteQueue(temporaryByteQueue);
|
||||||
|
}
|
||||||
|
if(currentStreamLength < 18 + chunkDataSize){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static TerrainMessage parsesendChunkDataMessage(List<Byte> byteStream){
|
||||||
|
TerrainMessage rVal = new TerrainMessage(TerrainMessageType.SENDCHUNKDATA);
|
||||||
|
stripPacketHeader(byteStream);
|
||||||
|
rVal.setworldX(ByteStreamUtils.popIntFromByteQueue(byteStream));
|
||||||
|
rVal.setworldY(ByteStreamUtils.popIntFromByteQueue(byteStream));
|
||||||
|
rVal.setworldZ(ByteStreamUtils.popIntFromByteQueue(byteStream));
|
||||||
|
rVal.setchunkData(ByteStreamUtils.popByteArrayFromByteQueue(byteStream));
|
||||||
|
return rVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static TerrainMessage constructsendChunkDataMessage(int worldX,int worldY,int worldZ,byte[] chunkData){
|
||||||
|
TerrainMessage rVal = new TerrainMessage(TerrainMessageType.SENDCHUNKDATA);
|
||||||
|
rVal.setworldX(worldX);
|
||||||
|
rVal.setworldY(worldY);
|
||||||
|
rVal.setworldZ(worldZ);
|
||||||
|
rVal.setchunkData(chunkData);
|
||||||
|
rVal.serialize();
|
||||||
|
return rVal;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void serialize(){
|
void serialize(){
|
||||||
byte[] intValues = new byte[8];
|
byte[] intValues = new byte[8];
|
||||||
@ -1281,6 +1366,51 @@ public class TerrainMessage extends NetworkMessage {
|
|||||||
rawBytes[18+i] = intValues[i];
|
rawBytes[18+i] = intValues[i];
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case REQUESTCHUNKDATA:
|
||||||
|
rawBytes = new byte[2+4+4+4];
|
||||||
|
//message header
|
||||||
|
rawBytes[0] = TypeBytes.MESSAGE_TYPE_TERRAIN;
|
||||||
|
//entity messaage header
|
||||||
|
rawBytes[1] = TypeBytes.TERRAIN_MESSAGE_TYPE_REQUESTCHUNKDATA;
|
||||||
|
intValues = ByteStreamUtils.serializeIntToBytes(worldX);
|
||||||
|
for(int i = 0; i < 4; i++){
|
||||||
|
rawBytes[2+i] = intValues[i];
|
||||||
|
}
|
||||||
|
intValues = ByteStreamUtils.serializeIntToBytes(worldY);
|
||||||
|
for(int i = 0; i < 4; i++){
|
||||||
|
rawBytes[6+i] = intValues[i];
|
||||||
|
}
|
||||||
|
intValues = ByteStreamUtils.serializeIntToBytes(worldZ);
|
||||||
|
for(int i = 0; i < 4; i++){
|
||||||
|
rawBytes[10+i] = intValues[i];
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case SENDCHUNKDATA:
|
||||||
|
rawBytes = new byte[2+4+4+4+4+chunkData.length];
|
||||||
|
//message header
|
||||||
|
rawBytes[0] = TypeBytes.MESSAGE_TYPE_TERRAIN;
|
||||||
|
//entity messaage header
|
||||||
|
rawBytes[1] = TypeBytes.TERRAIN_MESSAGE_TYPE_SENDCHUNKDATA;
|
||||||
|
intValues = ByteStreamUtils.serializeIntToBytes(worldX);
|
||||||
|
for(int i = 0; i < 4; i++){
|
||||||
|
rawBytes[2+i] = intValues[i];
|
||||||
|
}
|
||||||
|
intValues = ByteStreamUtils.serializeIntToBytes(worldY);
|
||||||
|
for(int i = 0; i < 4; i++){
|
||||||
|
rawBytes[6+i] = intValues[i];
|
||||||
|
}
|
||||||
|
intValues = ByteStreamUtils.serializeIntToBytes(worldZ);
|
||||||
|
for(int i = 0; i < 4; i++){
|
||||||
|
rawBytes[10+i] = intValues[i];
|
||||||
|
}
|
||||||
|
intValues = ByteStreamUtils.serializeIntToBytes(chunkData.length);
|
||||||
|
for(int i = 0; i < 4; i++){
|
||||||
|
rawBytes[14+i] = intValues[i];
|
||||||
|
}
|
||||||
|
for(int i = 0; i < chunkData.length; i++){
|
||||||
|
rawBytes[18+i] = chunkData[i];
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
serialized = true;
|
serialized = true;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -85,6 +85,8 @@ Message categories
|
|||||||
public static final byte TERRAIN_MESSAGE_TYPE_MACROVALUE = 5;
|
public static final byte TERRAIN_MESSAGE_TYPE_MACROVALUE = 5;
|
||||||
public static final byte TERRAIN_MESSAGE_TYPE_HEIGHTMAPMODIFICATION = 6;
|
public static final byte TERRAIN_MESSAGE_TYPE_HEIGHTMAPMODIFICATION = 6;
|
||||||
public static final byte TERRAIN_MESSAGE_TYPE_SPAWNPOSITION = 7;
|
public static final byte TERRAIN_MESSAGE_TYPE_SPAWNPOSITION = 7;
|
||||||
|
public static final byte TERRAIN_MESSAGE_TYPE_REQUESTCHUNKDATA = 8;
|
||||||
|
public static final byte TERRAIN_MESSAGE_TYPE_SENDCHUNKDATA = 9;
|
||||||
/*
|
/*
|
||||||
Terrain packet sizes
|
Terrain packet sizes
|
||||||
*/
|
*/
|
||||||
@ -96,6 +98,7 @@ Message categories
|
|||||||
public static final short TERRAIN_MESSAGE_TYPE_MACROVALUE_SIZE = 310;
|
public static final short TERRAIN_MESSAGE_TYPE_MACROVALUE_SIZE = 310;
|
||||||
public static final byte TERRAIN_MESSAGE_TYPE_HEIGHTMAPMODIFICATION_SIZE = 30;
|
public static final byte TERRAIN_MESSAGE_TYPE_HEIGHTMAPMODIFICATION_SIZE = 30;
|
||||||
public static final byte TERRAIN_MESSAGE_TYPE_SPAWNPOSITION_SIZE = 26;
|
public static final byte TERRAIN_MESSAGE_TYPE_SPAWNPOSITION_SIZE = 26;
|
||||||
|
public static final byte TERRAIN_MESSAGE_TYPE_REQUESTCHUNKDATA_SIZE = 14;
|
||||||
/*
|
/*
|
||||||
Server subcategories
|
Server subcategories
|
||||||
*/
|
*/
|
||||||
|
|||||||
@ -78,6 +78,15 @@ public class ByteStreamUtils {
|
|||||||
return rVal;
|
return rVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static byte[] popByteArrayFromByteQueue(List<Byte> queue){
|
||||||
|
int length = popIntFromByteQueue(queue);
|
||||||
|
byte[] bytes = new byte[length];
|
||||||
|
for(int i = 0; i < length; i++){
|
||||||
|
bytes[i] = queue.remove(0);
|
||||||
|
}
|
||||||
|
return bytes;
|
||||||
|
}
|
||||||
|
|
||||||
public static double popDoubleFromByteQueue(List<Byte> queue){
|
public static double popDoubleFromByteQueue(List<Byte> queue){
|
||||||
double rVal = -1;
|
double rVal = -1;
|
||||||
bufferLock.acquireUninterruptibly();
|
bufferLock.acquireUninterruptibly();
|
||||||
|
|||||||
@ -11,8 +11,6 @@ import electrosphere.entity.types.attach.AttachUtils;
|
|||||||
import electrosphere.entity.types.collision.CollisionObjUtils;
|
import electrosphere.entity.types.collision.CollisionObjUtils;
|
||||||
import electrosphere.entity.types.creature.CreatureUtils;
|
import electrosphere.entity.types.creature.CreatureUtils;
|
||||||
import electrosphere.entity.types.item.ItemUtils;
|
import electrosphere.entity.types.item.ItemUtils;
|
||||||
import electrosphere.game.server.terrain.manager.ServerTerrainChunk;
|
|
||||||
import electrosphere.game.server.terrain.models.TerrainModification;
|
|
||||||
import electrosphere.logger.LoggerInterface;
|
import electrosphere.logger.LoggerInterface;
|
||||||
import electrosphere.net.NetUtils;
|
import electrosphere.net.NetUtils;
|
||||||
import electrosphere.net.parser.net.message.AuthMessage;
|
import electrosphere.net.parser.net.message.AuthMessage;
|
||||||
@ -28,6 +26,8 @@ import electrosphere.net.parser.net.message.NetworkMessage.MessageType;
|
|||||||
import electrosphere.net.parser.net.message.ServerMessage.ServerMessageType;
|
import electrosphere.net.parser.net.message.ServerMessage.ServerMessageType;
|
||||||
import electrosphere.net.server.ServerConnectionHandler;
|
import electrosphere.net.server.ServerConnectionHandler;
|
||||||
import electrosphere.net.server.player.Player;
|
import electrosphere.net.server.player.Player;
|
||||||
|
import electrosphere.server.terrain.manager.ServerTerrainChunk;
|
||||||
|
import electrosphere.server.terrain.models.TerrainModification;
|
||||||
|
|
||||||
public class ServerProtocol {
|
public class ServerProtocol {
|
||||||
|
|
||||||
|
|||||||
@ -1,11 +1,11 @@
|
|||||||
package electrosphere.net.server.protocol;
|
package electrosphere.net.server.protocol;
|
||||||
|
|
||||||
import electrosphere.engine.Globals;
|
import electrosphere.engine.Globals;
|
||||||
import electrosphere.game.server.terrain.manager.ServerTerrainChunk;
|
|
||||||
import electrosphere.game.server.terrain.models.TerrainModification;
|
|
||||||
import electrosphere.net.parser.net.message.TerrainMessage;
|
import electrosphere.net.parser.net.message.TerrainMessage;
|
||||||
import electrosphere.net.server.Server;
|
import electrosphere.net.server.Server;
|
||||||
import electrosphere.net.server.ServerConnectionHandler;
|
import electrosphere.net.server.ServerConnectionHandler;
|
||||||
|
import electrosphere.server.terrain.manager.ServerTerrainChunk;
|
||||||
|
import electrosphere.server.terrain.models.TerrainModification;
|
||||||
|
|
||||||
public class TerrainProtocol {
|
public class TerrainProtocol {
|
||||||
|
|
||||||
|
|||||||
@ -2,12 +2,13 @@ package electrosphere.server.datacell.physics;
|
|||||||
|
|
||||||
import electrosphere.engine.Globals;
|
import electrosphere.engine.Globals;
|
||||||
import electrosphere.game.client.terrain.manager.ClientTerrainManager;
|
import electrosphere.game.client.terrain.manager.ClientTerrainManager;
|
||||||
import electrosphere.game.server.terrain.manager.ServerTerrainManager;
|
|
||||||
import electrosphere.game.terrain.processing.TerrainInterpolator;
|
import electrosphere.game.terrain.processing.TerrainInterpolator;
|
||||||
import electrosphere.game.client.world.ClientWorldData;
|
import electrosphere.game.client.world.ClientWorldData;
|
||||||
import electrosphere.game.collision.CommonWorldData;
|
import electrosphere.game.collision.CommonWorldData;
|
||||||
import electrosphere.net.parser.net.message.TerrainMessage;
|
import electrosphere.net.parser.net.message.TerrainMessage;
|
||||||
import electrosphere.renderer.ShaderProgram;
|
import electrosphere.renderer.ShaderProgram;
|
||||||
|
import electrosphere.server.terrain.manager.ServerTerrainManager;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
package electrosphere.server.pathfinding;
|
package electrosphere.server.pathfinding;
|
||||||
|
|
||||||
import electrosphere.game.server.terrain.manager.ServerTerrainChunk;
|
|
||||||
import electrosphere.server.pathfinding.navmesh.NavMesh;
|
import electrosphere.server.pathfinding.navmesh.NavMesh;
|
||||||
|
import electrosphere.server.terrain.manager.ServerTerrainChunk;
|
||||||
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|||||||
@ -1,11 +1,11 @@
|
|||||||
package electrosphere.server.pathfinding;
|
package electrosphere.server.pathfinding;
|
||||||
|
|
||||||
import electrosphere.game.server.terrain.manager.ServerTerrainChunk;
|
|
||||||
import electrosphere.server.pathfinding.blocker.NavBlocker;
|
import electrosphere.server.pathfinding.blocker.NavBlocker;
|
||||||
import electrosphere.server.pathfinding.blocker.NavTerrainBlockerCache;
|
import electrosphere.server.pathfinding.blocker.NavTerrainBlockerCache;
|
||||||
import electrosphere.server.pathfinding.navmesh.NavMesh;
|
import electrosphere.server.pathfinding.navmesh.NavMesh;
|
||||||
import electrosphere.server.pathfinding.navmesh.NavShape;
|
import electrosphere.server.pathfinding.navmesh.NavShape;
|
||||||
import electrosphere.server.pathfinding.path.Waypoint;
|
import electrosphere.server.pathfinding.path.Waypoint;
|
||||||
|
import electrosphere.server.terrain.manager.ServerTerrainChunk;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
|
|||||||
@ -1,12 +1,12 @@
|
|||||||
package electrosphere.server.pathfinding;
|
package electrosphere.server.pathfinding;
|
||||||
|
|
||||||
import electrosphere.engine.Globals;
|
import electrosphere.engine.Globals;
|
||||||
import electrosphere.game.server.terrain.manager.ServerTerrainChunk;
|
|
||||||
import electrosphere.logger.LoggerInterface;
|
import electrosphere.logger.LoggerInterface;
|
||||||
import electrosphere.server.pathfinding.blocker.NavBlocker;
|
import electrosphere.server.pathfinding.blocker.NavBlocker;
|
||||||
import electrosphere.server.pathfinding.navmesh.NavCube;
|
import electrosphere.server.pathfinding.navmesh.NavCube;
|
||||||
import electrosphere.server.pathfinding.navmesh.NavMesh;
|
import electrosphere.server.pathfinding.navmesh.NavMesh;
|
||||||
import electrosphere.server.pathfinding.navmesh.NavShape;
|
import electrosphere.server.pathfinding.navmesh.NavShape;
|
||||||
|
import electrosphere.server.terrain.manager.ServerTerrainChunk;
|
||||||
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|||||||
@ -3,10 +3,10 @@ package electrosphere.server.saves;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import electrosphere.engine.Globals;
|
import electrosphere.engine.Globals;
|
||||||
import electrosphere.game.server.terrain.manager.ServerTerrainManager;
|
|
||||||
import electrosphere.game.server.world.ServerWorldData;
|
import electrosphere.game.server.world.ServerWorldData;
|
||||||
import electrosphere.logger.LoggerInterface;
|
import electrosphere.logger.LoggerInterface;
|
||||||
import electrosphere.server.db.DatabaseUtils;
|
import electrosphere.server.db.DatabaseUtils;
|
||||||
|
import electrosphere.server.terrain.manager.ServerTerrainManager;
|
||||||
import electrosphere.util.FileUtils;
|
import electrosphere.util.FileUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
package electrosphere.game.server.terrain.generation;
|
package electrosphere.server.terrain.generation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Contains information about a continent
|
* Contains information about a continent
|
||||||
@ -1,4 +1,4 @@
|
|||||||
package electrosphere.game.server.terrain.generation;
|
package electrosphere.server.terrain.generation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -1,4 +1,4 @@
|
|||||||
package electrosphere.game.server.terrain.generation;
|
package electrosphere.server.terrain.generation;
|
||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Graphics;
|
import java.awt.Graphics;
|
||||||
@ -1,4 +1,4 @@
|
|||||||
package electrosphere.game.server.terrain.generation;
|
package electrosphere.server.terrain.generation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -1,4 +1,4 @@
|
|||||||
package electrosphere.game.server.terrain.generation;
|
package electrosphere.server.terrain.generation;
|
||||||
|
|
||||||
import java.awt.event.KeyEvent;
|
import java.awt.event.KeyEvent;
|
||||||
import java.awt.event.KeyListener;
|
import java.awt.event.KeyListener;
|
||||||
@ -13,7 +13,7 @@ import java.util.Random;
|
|||||||
|
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
|
|
||||||
import electrosphere.game.server.terrain.models.TerrainModel;
|
import electrosphere.server.terrain.models.TerrainModel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -1,4 +1,4 @@
|
|||||||
package electrosphere.game.server.terrain.generation;
|
package electrosphere.server.terrain.generation;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
@ -154,7 +154,7 @@ class TerrainGenerator {
|
|||||||
for(int x = 0; x < DIMENSION; x++){
|
for(int x = 0; x < DIMENSION; x++){
|
||||||
for(int y = 0; y < DIMENSION; y++){
|
for(int y = 0; y < DIMENSION; y++){
|
||||||
if(asthenosphereHeat[x][y] > 25){
|
if(asthenosphereHeat[x][y] > 25){
|
||||||
if(electrosphere.game.server.terrain.generation.Utilities.random_Integer(1, 10, rand) == 10){
|
if(electrosphere.server.terrain.generation.Utilities.random_Integer(1, 10, rand) == 10){
|
||||||
elevation[x][y] = elevation[x][y] + 1;
|
elevation[x][y] = elevation[x][y] + 1;
|
||||||
if(elevation[x][y] > 100){
|
if(elevation[x][y] > 100){
|
||||||
elevation[x][y] = 100;
|
elevation[x][y] = 100;
|
||||||
@ -1,4 +1,4 @@
|
|||||||
package electrosphere.game.server.terrain.generation;
|
package electrosphere.server.terrain.generation;
|
||||||
|
|
||||||
import java.awt.Point;
|
import java.awt.Point;
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
@ -1,4 +1,4 @@
|
|||||||
package electrosphere.game.server.terrain.generation;
|
package electrosphere.server.terrain.generation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Int based 2 dimension vector
|
* Int based 2 dimension vector
|
||||||
@ -1,10 +1,10 @@
|
|||||||
package electrosphere.game.server.terrain.manager;
|
package electrosphere.server.terrain.manager;
|
||||||
|
|
||||||
import electrosphere.game.server.terrain.models.TerrainModification;
|
|
||||||
import electrosphere.game.server.terrain.models.TerrainModification;
|
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import electrosphere.server.terrain.models.TerrainModification;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author amaterasu
|
* @author amaterasu
|
||||||
@ -1,12 +1,12 @@
|
|||||||
package electrosphere.game.server.terrain.manager;
|
package electrosphere.server.terrain.manager;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import electrosphere.game.terrain.processing.TerrainInterpolator;
|
import electrosphere.game.terrain.processing.TerrainInterpolator;
|
||||||
|
import electrosphere.server.terrain.generation.TerrainGen;
|
||||||
|
import electrosphere.server.terrain.models.ModificationList;
|
||||||
|
import electrosphere.server.terrain.models.TerrainModel;
|
||||||
|
import electrosphere.server.terrain.models.TerrainModification;
|
||||||
import electrosphere.engine.Globals;
|
import electrosphere.engine.Globals;
|
||||||
import electrosphere.game.server.terrain.generation.TerrainGen;
|
|
||||||
import electrosphere.game.server.terrain.models.ModificationList;
|
|
||||||
import electrosphere.game.server.terrain.models.TerrainModel;
|
|
||||||
import electrosphere.game.server.terrain.models.TerrainModification;
|
|
||||||
import electrosphere.util.FileUtils;
|
import electrosphere.util.FileUtils;
|
||||||
import electrosphere.util.Utilities;
|
import electrosphere.util.Utilities;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@ -1,4 +1,4 @@
|
|||||||
package electrosphere.game.server.terrain.models;
|
package electrosphere.server.terrain.models;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -1,4 +1,4 @@
|
|||||||
package electrosphere.game.server.terrain.models;
|
package electrosphere.server.terrain.models;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -1,4 +1,4 @@
|
|||||||
package electrosphere.game.server.terrain.models;
|
package electrosphere.server.terrain.models;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@ -1,8 +1,9 @@
|
|||||||
package electrosphere.util.worldviewer;
|
package electrosphere.util.worldviewer;
|
||||||
|
|
||||||
import electrosphere.game.server.terrain.manager.ServerTerrainManager;
|
|
||||||
import electrosphere.game.server.terrain.models.TerrainModel;
|
|
||||||
import electrosphere.server.simulation.MacroSimulation;
|
import electrosphere.server.simulation.MacroSimulation;
|
||||||
|
import electrosphere.server.terrain.manager.ServerTerrainManager;
|
||||||
|
import electrosphere.server.terrain.models.TerrainModel;
|
||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
|
|||||||
@ -1,10 +1,11 @@
|
|||||||
package electrosphere.util.worldviewer;
|
package electrosphere.util.worldviewer;
|
||||||
|
|
||||||
import electrosphere.game.server.terrain.models.TerrainModel;
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.awt.Graphics;
|
import java.awt.Graphics;
|
||||||
import javax.swing.JComponent;
|
import javax.swing.JComponent;
|
||||||
|
|
||||||
|
import electrosphere.server.terrain.models.TerrainModel;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author amaterasu
|
* @author amaterasu
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user