option to load whole scene on init
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit

This commit is contained in:
austin 2024-07-29 14:53:39 -04:00
parent e0b94b334c
commit be5c24a7fc
26 changed files with 169 additions and 61 deletions

View File

@ -6,5 +6,6 @@
"type" : "gridded", "type" : "gridded",
"griddedRealmSize" : 2 "griddedRealmSize" : 2
}, },
"createSaveInstance" : true "createSaveInstance" : true,
"loadAllCells": true
} }

View File

@ -7,7 +7,10 @@
review effects review effects
review combat code (lifestate, damage calculation, etc) review combat code (lifestate, damage calculation, etc)
audio fx for everything audio fx for everything
fix rendering pipelines (black when looking at character from angle with item, shadows are not darker color, etc)
option to load all data cells in scene on initializing a scene (thereby loading spawn points into memory)
+ bug fixes + bug fixes
fix bug where synchronization packet for non-existant entity crashes engine
fix rendering pipelines (black when looking at character from angle with item, shadows are not darker color, etc)
fix items falling through floor
fix jump tree not applying force while movement tree is active

View File

@ -475,6 +475,12 @@ Unify animation format data on disk
Leverage animation masks to block while moving Leverage animation masks to block while moving
Remove Airplane movement system Remove Airplane movement system
Fix client-attached models to viewmodel drawing on previous frame Fix client-attached models to viewmodel drawing on previous frame
Alignment work for human right hand
(07/29/2024)
Option to load all cells on init scene file
Insidious Entity protocol bugfix on server
# TODO # TODO

View File

@ -52,7 +52,7 @@ public class ClientSceneWrapper {
* @param serverId The server's provided ID * @param serverId The server's provided ID
*/ */
public void mapIdToId(int clientId, int serverId){ public void mapIdToId(int clientId, int serverId){
LoggerInterface.loggerEngine.DEBUG("MapID: " + clientId + " <===> " + serverId); LoggerInterface.loggerNetworking.DEBUG("MapID: " + clientId + " <===> " + serverId);
clientToServerIdMap.put(clientId, serverId); clientToServerIdMap.put(clientId, serverId);
serverToClientIdMap.put(serverId, clientId); serverToClientIdMap.put(serverId, clientId);
} }

View File

@ -87,11 +87,11 @@ import electrosphere.entity.state.attack.ShooterTree;
import electrosphere.entity.state.equip.ClientEquipState; import electrosphere.entity.state.equip.ClientEquipState;
import electrosphere.entity.state.inventory.InventoryUtils; import electrosphere.entity.state.inventory.InventoryUtils;
import electrosphere.entity.state.inventory.UnrelationalInventoryState; import electrosphere.entity.state.inventory.UnrelationalInventoryState;
import electrosphere.entity.state.movement.JumpTree;
import electrosphere.entity.state.movement.SprintTree; import electrosphere.entity.state.movement.SprintTree;
import electrosphere.entity.state.movement.groundmove.ClientGroundMovementTree; import electrosphere.entity.state.movement.groundmove.ClientGroundMovementTree;
import electrosphere.entity.state.movement.groundmove.ClientGroundMovementTree.MovementRelativeFacing; import electrosphere.entity.state.movement.groundmove.ClientGroundMovementTree.MovementRelativeFacing;
import electrosphere.entity.state.movement.groundmove.ClientGroundMovementTree.MovementTreeState; import electrosphere.entity.state.movement.groundmove.ClientGroundMovementTree.MovementTreeState;
import electrosphere.entity.state.movement.jump.JumpTree;
import electrosphere.entity.types.camera.CameraEntityUtils; import electrosphere.entity.types.camera.CameraEntityUtils;
import electrosphere.entity.types.creature.CreatureUtils; import electrosphere.entity.types.creature.CreatureUtils;
import electrosphere.logger.LoggerInterface; import electrosphere.logger.LoggerInterface;

View File

@ -33,6 +33,11 @@ public class SceneFile {
*/ */
boolean createSaveInstance; boolean createSaveInstance;
/**
* Loads all cells on initialization
*/
boolean loadAllCells;
/** /**
* Private constructor * Private constructor
@ -52,6 +57,7 @@ public class SceneFile {
rVal.initScriptPath = null; rVal.initScriptPath = null;
rVal.realmDescriptor = new RealmDescriptor(); rVal.realmDescriptor = new RealmDescriptor();
rVal.createSaveInstance = false; rVal.createSaveInstance = false;
rVal.loadAllCells = false;
return rVal; return rVal;
} }
@ -103,4 +109,12 @@ public class SceneFile {
this.createSaveInstance = createSaveInstance; this.createSaveInstance = createSaveInstance;
} }
/**
* Gets whether the scene should load all cells on initialization or not
* @return true if should load all cells on init, false otherwise
*/
public boolean loadAllCells(){
return loadAllCells;
}
} }

View File

@ -25,6 +25,7 @@ public class SceneGenerator {
file.realmDescriptor.type = RealmDescriptor.REALM_DESCRIPTOR_PROCEDURAL; file.realmDescriptor.type = RealmDescriptor.REALM_DESCRIPTOR_PROCEDURAL;
file.realmDescriptor.griddedRealmSize = GriddedDataCellManager.MAX_GRID_SIZE; file.realmDescriptor.griddedRealmSize = GriddedDataCellManager.MAX_GRID_SIZE;
file.createSaveInstance = true; //won't have a predefined scene to load, so must create one in the save file.createSaveInstance = true; //won't have a predefined scene to load, so must create one in the save
file.loadAllCells = false; // do not load all cells on init
//create terrain //create terrain
ServerWorldData serverWorldData = ServerWorldData.createGriddedRealmWorldData(2000); ServerWorldData serverWorldData = ServerWorldData.createGriddedRealmWorldData(2000);

View File

@ -10,6 +10,7 @@ import electrosphere.entity.types.item.ItemUtils;
import electrosphere.entity.types.object.ObjectUtils; import electrosphere.entity.types.object.ObjectUtils;
import electrosphere.game.server.world.ServerWorldData; import electrosphere.game.server.world.ServerWorldData;
import electrosphere.server.content.ServerContentManager; import electrosphere.server.content.ServerContentManager;
import electrosphere.server.datacell.GriddedDataCellManager;
import electrosphere.server.datacell.Realm; import electrosphere.server.datacell.Realm;
import electrosphere.server.datacell.ServerDataCell; import electrosphere.server.datacell.ServerDataCell;
import electrosphere.util.FileUtils; import electrosphere.util.FileUtils;
@ -66,6 +67,9 @@ public class SceneLoader {
switch(file.realmDescriptor.getType()){ switch(file.realmDescriptor.getType()){
case RealmDescriptor.REALM_DESCRIPTOR_GRIDDED: { case RealmDescriptor.REALM_DESCRIPTOR_GRIDDED: {
realm = Globals.realmManager.createGriddedRealm(serverWorldData,serverContentManager); realm = Globals.realmManager.createGriddedRealm(serverWorldData,serverContentManager);
if(file.loadAllCells()){
((GriddedDataCellManager)realm.getDataCellManager()).loadAllCells();
}
} break; } break;
case RealmDescriptor.REALM_DESCRIPTOR_PROCEDURAL: { case RealmDescriptor.REALM_DESCRIPTOR_PROCEDURAL: {
realm = Globals.realmManager.createRealm(); realm = Globals.realmManager.createRealm();

View File

@ -20,7 +20,7 @@ import electrosphere.entity.btree.BehaviorTree;
import electrosphere.entity.state.collidable.ClientCollidableTree; import electrosphere.entity.state.collidable.ClientCollidableTree;
import electrosphere.entity.state.collidable.Impulse; import electrosphere.entity.state.collidable.Impulse;
import electrosphere.entity.state.movement.FallTree; import electrosphere.entity.state.movement.FallTree;
import electrosphere.entity.state.movement.JumpTree; import electrosphere.entity.state.movement.jump.JumpTree;
import electrosphere.net.parser.net.message.EntityMessage; import electrosphere.net.parser.net.message.EntityMessage;
import electrosphere.net.synchronization.annotation.SyncedField; import electrosphere.net.synchronization.annotation.SyncedField;
import electrosphere.net.synchronization.annotation.SynchronizableEnum; import electrosphere.net.synchronization.annotation.SynchronizableEnum;

View File

@ -26,7 +26,7 @@ import electrosphere.entity.state.collidable.Impulse;
import electrosphere.entity.state.collidable.ServerCollidableTree; import electrosphere.entity.state.collidable.ServerCollidableTree;
import electrosphere.entity.state.gravity.ClientGravityTree.GravityTreeState; import electrosphere.entity.state.gravity.ClientGravityTree.GravityTreeState;
import electrosphere.entity.state.movement.ServerFallTree; import electrosphere.entity.state.movement.ServerFallTree;
import electrosphere.entity.state.movement.ServerJumpTree; import electrosphere.entity.state.movement.jump.ServerJumpTree;
import electrosphere.net.parser.net.message.EntityMessage; import electrosphere.net.parser.net.message.EntityMessage;
import electrosphere.net.synchronization.annotation.SyncedField; import electrosphere.net.synchronization.annotation.SyncedField;
import electrosphere.net.synchronization.annotation.SynchronizedBehaviorTree; import electrosphere.net.synchronization.annotation.SynchronizedBehaviorTree;

View File

@ -9,6 +9,7 @@ import electrosphere.entity.btree.StateTransitionUtil;
import electrosphere.entity.btree.StateTransitionUtil.StateTransitionUtilItem; import electrosphere.entity.btree.StateTransitionUtil.StateTransitionUtilItem;
import electrosphere.entity.state.AnimationPriorities; import electrosphere.entity.state.AnimationPriorities;
import electrosphere.entity.state.client.firstPerson.FirstPersonTree; import electrosphere.entity.state.client.firstPerson.FirstPersonTree;
import electrosphere.entity.state.movement.jump.JumpTree;
import electrosphere.game.data.creature.type.movement.FallMovementSystem; import electrosphere.game.data.creature.type.movement.FallMovementSystem;
import electrosphere.renderer.actor.Actor; import electrosphere.renderer.actor.Actor;

View File

@ -5,6 +5,7 @@ import electrosphere.entity.EntityDataStrings;
import electrosphere.entity.EntityUtils; import electrosphere.entity.EntityUtils;
import electrosphere.entity.btree.BehaviorTree; import electrosphere.entity.btree.BehaviorTree;
import electrosphere.entity.state.AnimationPriorities; import electrosphere.entity.state.AnimationPriorities;
import electrosphere.entity.state.movement.jump.ServerJumpTree;
import electrosphere.game.data.creature.type.movement.FallMovementSystem; import electrosphere.game.data.creature.type.movement.FallMovementSystem;
import electrosphere.server.poseactor.PoseActor; import electrosphere.server.poseactor.PoseActor;

View File

@ -19,9 +19,9 @@ import electrosphere.entity.state.attack.ClientAttackTree;
import electrosphere.entity.state.attack.ClientAttackTree.AttackTreeState; import electrosphere.entity.state.attack.ClientAttackTree.AttackTreeState;
import electrosphere.entity.state.client.firstPerson.FirstPersonTree; import electrosphere.entity.state.client.firstPerson.FirstPersonTree;
import electrosphere.entity.state.movement.FallTree; import electrosphere.entity.state.movement.FallTree;
import electrosphere.entity.state.movement.JumpTree;
import electrosphere.entity.state.movement.SprintTree; import electrosphere.entity.state.movement.SprintTree;
import electrosphere.entity.state.movement.SprintTree.SprintTreeState; import electrosphere.entity.state.movement.SprintTree.SprintTreeState;
import electrosphere.entity.state.movement.jump.JumpTree;
import electrosphere.net.parser.net.message.EntityMessage; import electrosphere.net.parser.net.message.EntityMessage;
import electrosphere.net.synchronization.annotation.SyncedField; import electrosphere.net.synchronization.annotation.SyncedField;
import electrosphere.net.synchronization.annotation.SynchronizableEnum; import electrosphere.net.synchronization.annotation.SynchronizableEnum;

View File

@ -20,11 +20,11 @@ import electrosphere.entity.state.AnimationPriorities;
import electrosphere.entity.state.attack.ClientAttackTree.AttackTreeState; import electrosphere.entity.state.attack.ClientAttackTree.AttackTreeState;
import electrosphere.entity.state.attack.ServerAttackTree; import electrosphere.entity.state.attack.ServerAttackTree;
import electrosphere.entity.state.movement.ServerFallTree; import electrosphere.entity.state.movement.ServerFallTree;
import electrosphere.entity.state.movement.ServerJumpTree;
import electrosphere.entity.state.movement.ServerSprintTree; import electrosphere.entity.state.movement.ServerSprintTree;
import electrosphere.entity.state.movement.ServerSprintTree.SprintTreeState; import electrosphere.entity.state.movement.ServerSprintTree.SprintTreeState;
import electrosphere.entity.state.movement.groundmove.ClientGroundMovementTree.MovementRelativeFacing; import electrosphere.entity.state.movement.groundmove.ClientGroundMovementTree.MovementRelativeFacing;
import electrosphere.entity.state.movement.groundmove.ClientGroundMovementTree.MovementTreeState; import electrosphere.entity.state.movement.groundmove.ClientGroundMovementTree.MovementTreeState;
import electrosphere.entity.state.movement.jump.ServerJumpTree;
import electrosphere.net.parser.net.message.EntityMessage; import electrosphere.net.parser.net.message.EntityMessage;
import electrosphere.net.synchronization.annotation.SyncedField; import electrosphere.net.synchronization.annotation.SyncedField;
import electrosphere.net.synchronization.annotation.SynchronizedBehaviorTree; import electrosphere.net.synchronization.annotation.SynchronizedBehaviorTree;

View File

@ -1,4 +1,4 @@
package electrosphere.entity.state.movement; package electrosphere.entity.state.movement.jump;
import org.ode4j.math.DVector3C; import org.ode4j.math.DVector3C;
import org.ode4j.ode.DBody; import org.ode4j.ode.DBody;

View File

@ -1,4 +1,4 @@
package electrosphere.entity.state.movement; package electrosphere.entity.state.movement.jump;
import org.ode4j.math.DVector3C; import org.ode4j.math.DVector3C;
import org.ode4j.ode.DBody; import org.ode4j.ode.DBody;

View File

@ -34,13 +34,13 @@ import electrosphere.entity.state.inventory.UnrelationalInventoryState;
import electrosphere.entity.state.life.ClientLifeTree; import electrosphere.entity.state.life.ClientLifeTree;
import electrosphere.entity.state.life.ServerLifeTree; import electrosphere.entity.state.life.ServerLifeTree;
import electrosphere.entity.state.movement.FallTree; import electrosphere.entity.state.movement.FallTree;
import electrosphere.entity.state.movement.JumpTree;
import electrosphere.entity.state.movement.ServerFallTree; import electrosphere.entity.state.movement.ServerFallTree;
import electrosphere.entity.state.movement.ServerJumpTree;
import electrosphere.entity.state.movement.ServerSprintTree; import electrosphere.entity.state.movement.ServerSprintTree;
import electrosphere.entity.state.movement.SprintTree; import electrosphere.entity.state.movement.SprintTree;
import electrosphere.entity.state.movement.groundmove.ClientGroundMovementTree; import electrosphere.entity.state.movement.groundmove.ClientGroundMovementTree;
import electrosphere.entity.state.movement.groundmove.ServerGroundMovementTree; import electrosphere.entity.state.movement.groundmove.ServerGroundMovementTree;
import electrosphere.entity.state.movement.jump.JumpTree;
import electrosphere.entity.state.movement.jump.ServerJumpTree;
import electrosphere.entity.state.rotator.RotatorHierarchyNode; import electrosphere.entity.state.rotator.RotatorHierarchyNode;
import electrosphere.entity.state.rotator.RotatorTree; import electrosphere.entity.state.rotator.RotatorTree;
import electrosphere.entity.state.rotator.ServerRotatorTree; import electrosphere.entity.state.rotator.ServerRotatorTree;

View File

@ -193,7 +193,6 @@ public class MenuGeneratorsLevelEditor {
griddedRealmControls.addChild(InputMacros.createToggle("Create Scene File", false, (ValueChangeEvent event) -> { griddedRealmControls.addChild(InputMacros.createToggle("Create Scene File", false, (ValueChangeEvent event) -> {
sceneFile.setCreateSaveInstance(event.getAsBoolean()); sceneFile.setCreateSaveInstance(event.getAsBoolean());
System.out.println(sceneFile.getCreateSaveInstance());
})); }));
} }
rVal.addChild(griddedRealmControls); rVal.addChild(griddedRealmControls);

View File

@ -190,13 +190,13 @@ public class ClientNetworking implements Runnable{
(((ServerMessage)message).getMessageSubtype()) == ServerMessageType.PONG (((ServerMessage)message).getMessageSubtype()) == ServerMessageType.PONG
){ ){
if(this.echoPings == true){ if(this.echoPings == true){
LoggerInterface.loggerNetworking.DEBUG("[CLIENT] New message " + message.getType()); LoggerInterface.loggerNetworking.DEBUG_LOOP("[CLIENT] New message " + message.getType());
} }
} else { } else {
LoggerInterface.loggerNetworking.DEBUG("[CLIENT] New message " + message.getType()); LoggerInterface.loggerNetworking.DEBUG_LOOP("[CLIENT] New message " + message.getType());
} }
} else { } else {
LoggerInterface.loggerNetworking.DEBUG("[CLIENT] New message " + message.getType()); LoggerInterface.loggerNetworking.DEBUG_LOOP("[CLIENT] New message " + message.getType());
} }
} }

View File

@ -1,15 +1,16 @@
package electrosphere.net.client.protocol; package electrosphere.net.client.protocol;
import java.util.Arrays;
import java.util.List;
import org.joml.Quaterniond; import org.joml.Quaterniond;
import org.joml.Vector3d; import org.joml.Vector3d;
import electrosphere.engine.Globals; import electrosphere.engine.Globals;
import electrosphere.entity.ClientEntityUtils; import electrosphere.entity.ClientEntityUtils;
import electrosphere.entity.Entity; import electrosphere.entity.Entity;
import electrosphere.entity.EntityCreationUtils;
import electrosphere.entity.EntityUtils; import electrosphere.entity.EntityUtils;
import electrosphere.entity.state.attack.ClientAttackTree; import electrosphere.entity.state.attack.ClientAttackTree;
import electrosphere.entity.state.client.firstPerson.FirstPersonTree;
import electrosphere.entity.types.attach.AttachUtils; import electrosphere.entity.types.attach.AttachUtils;
import electrosphere.entity.types.creature.CreatureTemplate; import electrosphere.entity.types.creature.CreatureTemplate;
import electrosphere.entity.types.creature.CreatureUtils; import electrosphere.entity.types.creature.CreatureUtils;
@ -20,6 +21,7 @@ import electrosphere.game.data.creature.type.CreatureData;
import electrosphere.game.data.creature.type.ViewModelData; import electrosphere.game.data.creature.type.ViewModelData;
import electrosphere.logger.LoggerInterface; import electrosphere.logger.LoggerInterface;
import electrosphere.net.parser.net.message.EntityMessage; import electrosphere.net.parser.net.message.EntityMessage;
import electrosphere.net.parser.net.message.EntityMessage.EntityMessageType;
import electrosphere.util.Utilities; import electrosphere.util.Utilities;
/** /**
@ -27,13 +29,30 @@ import electrosphere.util.Utilities;
*/ */
public class EntityProtocol { public class EntityProtocol {
//Messages to ignore when complaining about messages that have nonexistant entity associated
static List<EntityMessageType> spawnMessageTypes = Arrays.asList(new EntityMessageType[]{
EntityMessageType.CREATE,
EntityMessageType.SPAWNCREATURE,
EntityMessageType.SPAWNFOLIAGESEED,
EntityMessageType.SPAWNITEM,
EntityMessageType.SPAWNOBJECT,
});
/** /**
* Handles a single clientbound entity message * Handles a single clientbound entity message
* @param message The message to handle * @param message The message to handle
*/ */
protected static void handleEntityMessage(EntityMessage message){ protected static void handleEntityMessage(EntityMessage message){
Globals.profiler.beginCpuSample("EntityProtocol.handleEntityMessage"); Globals.profiler.beginCpuSample("EntityProtocol.handleEntityMessage");
LoggerInterface.loggerNetworking.DEBUG("Parse entity message of type " + message.getMessageSubtype()); LoggerInterface.loggerNetworking.DEBUG_LOOP("Parse entity message of type " + message.getMessageSubtype());
//error check
if(Globals.clientScene != null && Globals.clientSceneWrapper.getEntityFromServerId(message.getentityID()) == null && !spawnMessageTypes.contains(message.getMessageSubtype())){
LoggerInterface.loggerNetworking.WARNING("Client received packet for entity that is not in the client scene!");
Globals.clientSceneWrapper.dumpTranslationLayerStatus();
Globals.clientSceneWrapper.dumpIdData(message.getentityID());
}
Entity newlySpawnedEntity; Entity newlySpawnedEntity;
switch(message.getMessageSubtype()){ switch(message.getMessageSubtype()){
@ -110,6 +129,7 @@ public class EntityProtocol {
} }
} else { } else {
//TODO: bounce message //TODO: bounce message
LoggerInterface.loggerNetworking.WARNING("Received property packet for entity that does not exist on client!");
} }
} break; } break;
case ATTACHENTITYTOENTITY: { case ATTACHENTITYTOENTITY: {
@ -167,11 +187,13 @@ public class EntityProtocol {
static void setPlayerEntity(EntityMessage message){ static void setPlayerEntity(EntityMessage message){
Entity target = Globals.clientSceneWrapper.getEntityFromServerId(message.getentityID()); Entity target = Globals.clientSceneWrapper.getEntityFromServerId(message.getentityID());
if(target != null){ if(target != null){
LoggerInterface.loggerNetworking.DEBUG("Set player entity id for entity: " + target.getId() + " to player: " + message.getpropertyValue());
CreatureUtils.setControllerPlayerId(target, message.getpropertyValue()); CreatureUtils.setControllerPlayerId(target, message.getpropertyValue());
String creatureTypeRaw = CreatureUtils.getType(target); String creatureTypeRaw = CreatureUtils.getType(target);
CreatureData creatureType = Globals.gameConfigCurrent.getCreatureTypeLoader().getCreature(creatureTypeRaw); CreatureData creatureType = Globals.gameConfigCurrent.getCreatureTypeLoader().getCreature(creatureTypeRaw);
ViewModelData viewModelData = creatureType.getViewModelData(); ViewModelData viewModelData = creatureType.getViewModelData();
if(Globals.clientPlayer != null && message.getpropertyValue() == Globals.clientPlayer.getId()){ if(Globals.clientPlayer != null && message.getpropertyValue() == Globals.clientPlayer.getId()){
LoggerInterface.loggerNetworking.DEBUG("Set this player's entity id!");
Globals.clientCharacterID = message.getentityID(); Globals.clientCharacterID = message.getentityID();
Globals.playerEntity = target; Globals.playerEntity = target;
if(viewModelData != null && viewModelData.getFirstPersonModelPath() != null){ if(viewModelData != null && viewModelData.getFirstPersonModelPath() != null){
@ -180,7 +202,12 @@ public class EntityProtocol {
null null
); );
} }
} else {
//setting player id on entity that is not this player's
} }
} else {
LoggerInterface.loggerNetworking.WARNING("Tried to set player entity property on an entity that doesn't exist!");
Globals.clientSceneWrapper.dumpTranslationLayerStatus();
} }
} }

View File

@ -274,6 +274,7 @@ public class ServerConnectionHandler implements Runnable {
} }
public void setPlayerEntityId(int id){ public void setPlayerEntityId(int id){
LoggerInterface.loggerNetworking.DEBUG("Set player(" + this.playerID + ")'s entity ID to be " + id);
playerEntityID = id; playerEntityID = id;
} }

View File

@ -2,10 +2,12 @@ package electrosphere.net.server.protocol;
import org.joml.Vector3d; import org.joml.Vector3d;
import electrosphere.engine.Globals;
import electrosphere.entity.Entity; import electrosphere.entity.Entity;
import electrosphere.entity.state.attack.ServerAttackTree; import electrosphere.entity.state.attack.ServerAttackTree;
import electrosphere.entity.state.server.ServerPlayerViewDirTree; import electrosphere.entity.state.server.ServerPlayerViewDirTree;
import electrosphere.entity.types.creature.CreatureUtils; import electrosphere.entity.types.creature.CreatureUtils;
import electrosphere.logger.LoggerInterface;
import electrosphere.net.parser.net.message.EntityMessage; import electrosphere.net.parser.net.message.EntityMessage;
import electrosphere.net.server.ServerConnectionHandler; import electrosphere.net.server.ServerConnectionHandler;
import electrosphere.server.datacell.utils.EntityLookupUtils; import electrosphere.server.datacell.utils.EntityLookupUtils;
@ -13,28 +15,34 @@ import electrosphere.server.datacell.utils.EntityLookupUtils;
public class EntityProtocol { public class EntityProtocol {
protected static void handleEntityMessage(ServerConnectionHandler connectionHandler, EntityMessage message){ protected static void handleEntityMessage(ServerConnectionHandler connectionHandler, EntityMessage message){
//error check
if(Globals.clientScene != null && Globals.clientScene.getEntityFromId(message.getentityID()) != null){
LoggerInterface.loggerNetworking.WARNING("Server received packet for entity that is in client scene wrapper!");
}
//parse message
Entity targetEntity; Entity targetEntity;
switch(message.getMessageSubtype()){ switch(message.getMessageSubtype()){
case MOVEUPDATE: case MOVEUPDATE:
targetEntity = EntityLookupUtils.getEntityById(message.getentityID()); targetEntity = EntityLookupUtils.getEntityById(connectionHandler.getPlayerEntityId());
if(targetEntity != null){ if(targetEntity != null){
CreatureUtils.serverAttachEntityMessageToMovementTree(targetEntity,message); CreatureUtils.serverAttachEntityMessageToMovementTree(targetEntity,message);
} }
break; break;
case ATTACKUPDATE: case ATTACKUPDATE:
targetEntity = EntityLookupUtils.getEntityById(message.getentityID()); targetEntity = EntityLookupUtils.getEntityById(connectionHandler.getPlayerEntityId());
if(targetEntity != null){ if(targetEntity != null){
ServerAttackTree.getServerAttackTree(targetEntity).addNetworkMessage(message); ServerAttackTree.getServerAttackTree(targetEntity).addNetworkMessage(message);
} }
break; break;
case STARTATTACK: { case STARTATTACK: {
targetEntity = EntityLookupUtils.getEntityById(message.getentityID()); targetEntity = EntityLookupUtils.getEntityById(connectionHandler.getPlayerEntityId());
if(targetEntity != null){ if(targetEntity != null){
ServerAttackTree.getServerAttackTree(targetEntity).addNetworkMessage(message); ServerAttackTree.getServerAttackTree(targetEntity).addNetworkMessage(message);
} }
} break; } break;
case UPDATEENTITYVIEWDIR: { case UPDATEENTITYVIEWDIR: {
targetEntity = EntityLookupUtils.getEntityById(message.getentityID()); targetEntity = EntityLookupUtils.getEntityById(connectionHandler.getPlayerEntityId());
if(targetEntity != null && ServerPlayerViewDirTree.hasTree(targetEntity)){ if(targetEntity != null && ServerPlayerViewDirTree.hasTree(targetEntity)){
ServerPlayerViewDirTree.getTree(targetEntity).setPlayerViewDir(new Vector3d(message.getpositionX(),message.getpositionY(),message.getpositionZ()),message.gettime()); ServerPlayerViewDirTree.getTree(targetEntity).setPlayerViewDir(new Vector3d(message.getpositionX(),message.getpositionY(),message.getpositionZ()),message.gettime());
} }

View File

@ -152,13 +152,13 @@ public class ServerProtocol {
(((ServerMessage)message).getMessageSubtype()) == ServerMessageType.PONG (((ServerMessage)message).getMessageSubtype()) == ServerMessageType.PONG
){ ){
if(this.echoPings == true){ if(this.echoPings == true){
LoggerInterface.loggerNetworking.DEBUG("[Server] New message " + message.getType()); LoggerInterface.loggerNetworking.DEBUG_LOOP("[Server] New message " + message.getType());
} }
} else { } else {
LoggerInterface.loggerNetworking.DEBUG("[Server] New message " + message.getType()); LoggerInterface.loggerNetworking.DEBUG_LOOP("[Server] New message " + message.getType());
} }
} else { } else {
LoggerInterface.loggerNetworking.DEBUG("[Server] New message " + message.getType()); LoggerInterface.loggerNetworking.DEBUG_LOOP("[Server] New message " + message.getType());
} }
} }

View File

@ -2,11 +2,9 @@ package electrosphere.net.synchronization;
import electrosphere.entity.state.life.ClientLifeTree; import electrosphere.entity.state.life.ClientLifeTree;
import electrosphere.net.synchronization.FieldIdEnums;
import electrosphere.entity.state.block.ClientBlockTree; import electrosphere.entity.state.block.ClientBlockTree;
import electrosphere.entity.state.movement.groundmove.ClientGroundMovementTree; import electrosphere.entity.state.movement.groundmove.ClientGroundMovementTree;
import electrosphere.logger.LoggerInterface; import electrosphere.logger.LoggerInterface;
import electrosphere.entity.state.equip.ClientEquipState;
import electrosphere.entity.state.attack.ClientAttackTree; import electrosphere.entity.state.attack.ClientAttackTree;
import electrosphere.entity.state.gravity.ClientGravityTree; import electrosphere.entity.state.gravity.ClientGravityTree;
import electrosphere.entity.state.idle.ClientIdleTree; import electrosphere.entity.state.idle.ClientIdleTree;
@ -83,6 +81,8 @@ public class ClientSynchronizationManager {
int bTreeId = message.getbTreeId(); int bTreeId = message.getbTreeId();
int entityId = message.getentityId(); int entityId = message.getentityId();
} break; } break;
case LOADSCENE: {
} break;
} }
} else if(Globals.clientSceneWrapper.containsServerId(message.getentityId()) && Globals.clientSceneWrapper.getEntityFromServerId(message.getentityId()) == null){ } else if(Globals.clientSceneWrapper.containsServerId(message.getentityId()) && Globals.clientSceneWrapper.getEntityFromServerId(message.getentityId()) == null){
String errorMessage = String errorMessage =
@ -93,6 +93,14 @@ public class ClientSynchronizationManager {
Globals.clientSceneWrapper.dumpTranslationLayerStatus(); Globals.clientSceneWrapper.dumpTranslationLayerStatus();
Globals.clientSceneWrapper.dumpIdData(message.getentityId()); Globals.clientSceneWrapper.dumpIdData(message.getentityId());
throw new IllegalStateException(errorMessage); throw new IllegalStateException(errorMessage);
} else if(!Globals.clientSceneWrapper.containsServerId(message.getentityId())){
String errorMessage =
"Client received synchronization packet for entity that does not exists on client!\n" +
"Entity id in network message: " + message.getentityId()
;
Globals.clientSceneWrapper.dumpTranslationLayerStatus();
Globals.clientSceneWrapper.dumpIdData(message.getentityId());
throw new IllegalStateException(errorMessage);
} }
//warn if a message has bounced a certain number of times //warn if a message has bounced a certain number of times

View File

@ -8,6 +8,7 @@ import electrosphere.entity.Entity;
import electrosphere.entity.state.server.ServerPlayerViewDirTree; import electrosphere.entity.state.server.ServerPlayerViewDirTree;
import electrosphere.entity.types.creature.CreatureTemplate; import electrosphere.entity.types.creature.CreatureTemplate;
import electrosphere.entity.types.creature.CreatureUtils; import electrosphere.entity.types.creature.CreatureUtils;
import electrosphere.logger.LoggerInterface;
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.datacell.Realm; import electrosphere.server.datacell.Realm;
@ -30,6 +31,7 @@ public class PlayerCharacterCreation {
Realm realm = Globals.realmManager.getRealms().iterator().next(); Realm realm = Globals.realmManager.getRealms().iterator().next();
Vector3d spawnPoint = realm.getSpawnPoint(); Vector3d spawnPoint = realm.getSpawnPoint();
Entity newPlayerEntity = CreatureUtils.serverSpawnBasicCreature(realm,new Vector3d(spawnPoint.x,spawnPoint.y,spawnPoint.z),raceName,template); Entity newPlayerEntity = CreatureUtils.serverSpawnBasicCreature(realm,new Vector3d(spawnPoint.x,spawnPoint.y,spawnPoint.z),raceName,template);
LoggerInterface.loggerEngine.INFO("Spawned entity for player. Entity id: " + newPlayerEntity.getId() + " Player id: " + playerObject.getId());
int playerCharacterId = newPlayerEntity.getId(); int playerCharacterId = newPlayerEntity.getId();
connectionHandler.setPlayerEntityId(playerCharacterId); connectionHandler.setPlayerEntityId(playerCharacterId);
CreatureUtils.setControllerPlayerId(newPlayerEntity, connectionHandler.getPlayerId()); CreatureUtils.setControllerPlayerId(newPlayerEntity, connectionHandler.getPlayerId());

View File

@ -42,6 +42,11 @@ public class GriddedDataCellManager implements DataCellManager, VoxelCellManager
*/ */
public static final int MAX_GRID_SIZE = 10; public static final int MAX_GRID_SIZE = 10;
/**
* Tracks whether this manager has been flagged to unload cells or not
*/
boolean unloadCells = true;
//these are going to be the natural ground grid of data cells, but we're going to have more than this //these are going to be the natural ground grid of data cells, but we're going to have more than this
Map<String,ServerDataCell> groundDataCells = new HashMap<String,ServerDataCell>(); Map<String,ServerDataCell> groundDataCells = new HashMap<String,ServerDataCell>();
Map<ServerDataCell,Vector3i> cellPositionMap = new HashMap<ServerDataCell,Vector3i>(); Map<ServerDataCell,Vector3i> cellPositionMap = new HashMap<ServerDataCell,Vector3i>();
@ -257,6 +262,7 @@ public class GriddedDataCellManager implements DataCellManager, VoxelCellManager
* Unloads all chunks that haven't had players in them for a set amount of time * Unloads all chunks that haven't had players in them for a set amount of time
*/ */
public void unloadPlayerlessChunks(){ public void unloadPlayerlessChunks(){
if(this.unloadCells){
//TODO: improve to make have less performance impact //TODO: improve to make have less performance impact
for(ServerDataCell cell : loadedCells){ for(ServerDataCell cell : loadedCells){
loadedCellsLock.acquireUninterruptibly(); loadedCellsLock.acquireUninterruptibly();
@ -290,6 +296,7 @@ public class GriddedDataCellManager implements DataCellManager, VoxelCellManager
} }
toCleanQueue.clear(); toCleanQueue.clear();
} }
}
/** /**
* Get data cell at a given real point in this realm * Get data cell at a given real point in this realm
@ -328,11 +335,20 @@ public class GriddedDataCellManager implements DataCellManager, VoxelCellManager
int worldY = parent.getServerWorldData().convertRealToChunkSpace(point.y); int worldY = parent.getServerWorldData().convertRealToChunkSpace(point.y);
int worldZ = parent.getServerWorldData().convertRealToChunkSpace(point.z); int worldZ = parent.getServerWorldData().convertRealToChunkSpace(point.z);
Vector3i worldPos = new Vector3i(worldX,worldY,worldZ); Vector3i worldPos = new Vector3i(worldX,worldY,worldZ);
return tryCreateCellAtPoint(worldPos);
}
/**
* Tries to create a data cell at a given discrete point
* @param point The discrete point
* @return The data cell if created, null otherwise
*/
public ServerDataCell tryCreateCellAtPoint(Vector3i worldPos){
if( if(
//in bounds of array //in bounds of array
worldX >= 0 && worldX < this.serverWorldData.getWorldSizeDiscrete() && worldPos.x >= 0 && worldPos.x < this.serverWorldData.getWorldSizeDiscrete() &&
worldY >= 0 && worldY < this.serverWorldData.getWorldSizeDiscrete() && worldPos.y >= 0 && worldPos.y < this.serverWorldData.getWorldSizeDiscrete() &&
worldZ >= 0 && worldZ < this.serverWorldData.getWorldSizeDiscrete() && worldPos.z >= 0 && worldPos.z < this.serverWorldData.getWorldSizeDiscrete() &&
//isn't null //isn't null
groundDataCells.get(getServerDataCellKey(worldPos)) == null groundDataCells.get(getServerDataCellKey(worldPos)) == null
){ ){
@ -375,7 +391,9 @@ public class GriddedDataCellManager implements DataCellManager, VoxelCellManager
public void simulate(){ public void simulate(){
loadedCellsLock.acquireUninterruptibly(); loadedCellsLock.acquireUninterruptibly();
for(ServerDataCell cell : loadedCells){ for(ServerDataCell cell : loadedCells){
if(Globals.microSimulation != null && Globals.microSimulation.isReady()){
Globals.microSimulation.simulate(cell); Globals.microSimulation.simulate(cell);
}
//simulate fluid //simulate fluid
Vector3i cellPos = this.getCellWorldPosition(cell); Vector3i cellPos = this.getCellWorldPosition(cell);
@ -521,6 +539,20 @@ public class GriddedDataCellManager implements DataCellManager, VoxelCellManager
return serverFluidManager.getChunk(worldPosition.x, worldPosition.y, worldPosition.z); return serverFluidManager.getChunk(worldPosition.x, worldPosition.y, worldPosition.z);
} }
/**
* Loads all cells
*/
public void loadAllCells(){
this.unloadCells = false;
for(int x = 0; x < this.serverWorldData.getWorldSizeDiscrete(); x++){
for(int y = 0; y < this.serverWorldData.getWorldSizeDiscrete(); y++){
for(int z = 0; z < this.serverWorldData.getWorldSizeDiscrete(); z++){
this.tryCreateCellAtPoint(new Vector3i(x,y,z));
}
}
}
}
/** /**
* Rebroadcasts the fluid cell at a given position * Rebroadcasts the fluid cell at a given position
* @param worldPosition the world position * @param worldPosition the world position