bugfixes
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit
This commit is contained in:
parent
80924671de
commit
4e7cfe05e7
@ -1529,6 +1529,9 @@ Macro data unloading/loading
|
|||||||
Macro Character data serialization/deserialization
|
Macro Character data serialization/deserialization
|
||||||
Macro character compression/decompression on chunk load/unload
|
Macro character compression/decompression on chunk load/unload
|
||||||
ServerWorldData conversion methods are static now
|
ServerWorldData conversion methods are static now
|
||||||
|
Fix character data serialization only serializing dataType
|
||||||
|
Potential fix for realm undefined for server terrain physics entity
|
||||||
|
Fix macro character entities not being assigned ServerCharacterData
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -29,10 +29,10 @@ public class ServerCharacterData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attaches a ServerPlayerViewDirTree to a given entity
|
* Attaches a ServerCharacterData to a given entity
|
||||||
* @param entity The entity to add to
|
* @param entity The entity to add to
|
||||||
*/
|
*/
|
||||||
public static void attachServerPlayerViewDirTree(Entity entity, int characterId){
|
public static void attachServerCharacterData(Entity entity, int characterId){
|
||||||
ServerCharacterData tree = new ServerCharacterData(entity, characterId);
|
ServerCharacterData tree = new ServerCharacterData(entity, characterId);
|
||||||
entity.putData(EntityDataStrings.TREE_SERVERCHARACTERDATA, tree);
|
entity.putData(EntityDataStrings.TREE_SERVERCHARACTERDATA, tree);
|
||||||
}
|
}
|
||||||
@ -42,7 +42,7 @@ public class ServerCharacterData {
|
|||||||
* @param entity The entity
|
* @param entity The entity
|
||||||
* @return true if the entity contains character data, false otherwise
|
* @return true if the entity contains character data, false otherwise
|
||||||
*/
|
*/
|
||||||
public static boolean hasServerPlayerCharacterDataTree(Entity entity){
|
public static boolean hasServerCharacterDataTree(Entity entity){
|
||||||
return entity.containsKey(EntityDataStrings.TREE_SERVERCHARACTERDATA);
|
return entity.containsKey(EntityDataStrings.TREE_SERVERCHARACTERDATA);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -125,13 +125,15 @@ public class TerrainChunk {
|
|||||||
*/
|
*/
|
||||||
public static void serverCreateTerrainChunkEntity(Entity entity, TerrainChunkData data){
|
public static void serverCreateTerrainChunkEntity(Entity entity, TerrainChunkData data){
|
||||||
if(data.getVertices().length > 0){
|
if(data.getVertices().length > 0){
|
||||||
PhysicsEntityUtils.serverAttachTriGeomRigidBody(entity, data);
|
|
||||||
Realm realm = Globals.realmManager.getEntityRealm(entity);
|
Realm realm = Globals.realmManager.getEntityRealm(entity);
|
||||||
DBody terrainBody = PhysicsEntityUtils.getDBody(entity);
|
if(realm != null){
|
||||||
Vector3d entityPos = EntityUtils.getPosition(entity);
|
PhysicsEntityUtils.serverAttachTriGeomRigidBody(entity, data);
|
||||||
Quaterniond entityRot = EntityUtils.getRotation(entity);
|
DBody terrainBody = PhysicsEntityUtils.getDBody(entity);
|
||||||
PhysicsUtils.setRigidBodyTransform(realm.getCollisionEngine(), entityPos, entityRot, terrainBody);
|
Vector3d entityPos = EntityUtils.getPosition(entity);
|
||||||
entity.putData(EntityDataStrings.TERRAIN_IS_TERRAIN, true);
|
Quaterniond entityRot = EntityUtils.getRotation(entity);
|
||||||
|
PhysicsUtils.setRigidBodyTransform(realm.getCollisionEngine(), entityPos, entityRot, terrainBody);
|
||||||
|
entity.putData(EntityDataStrings.TERRAIN_IS_TERRAIN, true);
|
||||||
|
}
|
||||||
// ServerEntityUtils.initiallyPositionEntity(realm, rVal, position);
|
// ServerEntityUtils.initiallyPositionEntity(realm, rVal, position);
|
||||||
// physicsObject = PhysicsUtils.attachTerrainRigidBody(physicsEntity,heightmap,true);
|
// physicsObject = PhysicsUtils.attachTerrainRigidBody(physicsEntity,heightmap,true);
|
||||||
// Realm realm = Globals.realmManager.getEntityRealm(physicsEntity);
|
// Realm realm = Globals.realmManager.getEntityRealm(physicsEntity);
|
||||||
|
|||||||
@ -102,7 +102,7 @@ public class CharacterService {
|
|||||||
* @param characterEntity The entity
|
* @param characterEntity The entity
|
||||||
*/
|
*/
|
||||||
public static void saveCharacter(Entity characterEntity){
|
public static void saveCharacter(Entity characterEntity){
|
||||||
if(!ServerCharacterData.hasServerPlayerCharacterDataTree(characterEntity)){
|
if(!ServerCharacterData.hasServerCharacterDataTree(characterEntity)){
|
||||||
throw new Error("Trying to save entity hat does not contain character data!");
|
throw new Error("Trying to save entity hat does not contain character data!");
|
||||||
}
|
}
|
||||||
ServerCharacterData characterData = ServerCharacterData.getServerCharacterData(characterEntity);
|
ServerCharacterData characterData = ServerCharacterData.getServerCharacterData(characterEntity);
|
||||||
|
|||||||
@ -14,6 +14,7 @@ import electrosphere.net.server.ServerConnectionHandler;
|
|||||||
import electrosphere.net.server.player.Player;
|
import electrosphere.net.server.player.Player;
|
||||||
import electrosphere.net.server.protocol.CharacterProtocol;
|
import electrosphere.net.server.protocol.CharacterProtocol;
|
||||||
import electrosphere.server.datacell.Realm;
|
import electrosphere.server.datacell.Realm;
|
||||||
|
import electrosphere.server.datacell.ServerWorldData;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Deals with spawning player characters
|
* Deals with spawning player characters
|
||||||
@ -46,9 +47,9 @@ public class PlayerCharacterCreation {
|
|||||||
LoggerInterface.loggerEngine.INFO("Spawned entity for player. Entity id: " + newPlayerEntity.getId() + " Player id: " + playerObject.getId());
|
LoggerInterface.loggerEngine.INFO("Spawned entity for player. Entity id: " + newPlayerEntity.getId() + " Player id: " + playerObject.getId());
|
||||||
PlayerCharacterCreation.attachEntityToPlayerObject(newPlayerEntity,playerObject,connectionHandler);
|
PlayerCharacterCreation.attachEntityToPlayerObject(newPlayerEntity,playerObject,connectionHandler);
|
||||||
playerObject.setWorldPos(new Vector3i(
|
playerObject.setWorldPos(new Vector3i(
|
||||||
realm.getServerWorldData().convertRealToChunkSpace(spawnPoint.x),
|
ServerWorldData.convertRealToChunkSpace(spawnPoint.x),
|
||||||
realm.getServerWorldData().convertRealToChunkSpace(spawnPoint.y),
|
ServerWorldData.convertRealToChunkSpace(spawnPoint.y),
|
||||||
realm.getServerWorldData().convertRealToChunkSpace(spawnPoint.z)
|
ServerWorldData.convertRealToChunkSpace(spawnPoint.z)
|
||||||
));
|
));
|
||||||
realm.getDataCellManager().addPlayerToRealm(playerObject);
|
realm.getDataCellManager().addPlayerToRealm(playerObject);
|
||||||
|
|
||||||
@ -88,7 +89,7 @@ public class PlayerCharacterCreation {
|
|||||||
*/
|
*/
|
||||||
static void addPlayerServerBTrees(Entity entity, ServerConnectionHandler serverConnectionHandler){
|
static void addPlayerServerBTrees(Entity entity, ServerConnectionHandler serverConnectionHandler){
|
||||||
ServerPlayerViewDirTree.attachServerPlayerViewDirTree(entity);
|
ServerPlayerViewDirTree.attachServerPlayerViewDirTree(entity);
|
||||||
ServerCharacterData.attachServerPlayerViewDirTree(entity, serverConnectionHandler.getCharacterId());
|
ServerCharacterData.attachServerCharacterData(entity, serverConnectionHandler.getCharacterId());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -984,20 +984,20 @@ public class GriddedDataCellManager implements DataCellManager, VoxelCellManager
|
|||||||
if(positionToTest.x < 0){
|
if(positionToTest.x < 0){
|
||||||
returnPos.x = 0;
|
returnPos.x = 0;
|
||||||
}
|
}
|
||||||
if(positionToTest.x >= parent.getServerWorldData().convertChunkToRealSpace(parent.getServerWorldData().getWorldSizeDiscrete())){
|
if(positionToTest.x >= ServerWorldData.convertChunkToRealSpace(parent.getServerWorldData().getWorldSizeDiscrete())){
|
||||||
returnPos.x = parent.getServerWorldData().convertChunkToRealSpace(parent.getServerWorldData().getWorldSizeDiscrete()) - 1;
|
returnPos.x = ServerWorldData.convertChunkToRealSpace(parent.getServerWorldData().getWorldSizeDiscrete()) - 1;
|
||||||
}
|
}
|
||||||
if(positionToTest.y < 0){
|
if(positionToTest.y < 0){
|
||||||
returnPos.y = 0;
|
returnPos.y = 0;
|
||||||
}
|
}
|
||||||
if(positionToTest.y >= parent.getServerWorldData().convertChunkToRealSpace(parent.getServerWorldData().getWorldSizeDiscrete())){
|
if(positionToTest.y >= ServerWorldData.convertChunkToRealSpace(parent.getServerWorldData().getWorldSizeDiscrete())){
|
||||||
returnPos.y = parent.getServerWorldData().convertChunkToRealSpace(parent.getServerWorldData().getWorldSizeDiscrete()) - 1;
|
returnPos.y = ServerWorldData.convertChunkToRealSpace(parent.getServerWorldData().getWorldSizeDiscrete()) - 1;
|
||||||
}
|
}
|
||||||
if(positionToTest.z < 0){
|
if(positionToTest.z < 0){
|
||||||
returnPos.z = 0;
|
returnPos.z = 0;
|
||||||
}
|
}
|
||||||
if(positionToTest.z >= parent.getServerWorldData().convertChunkToRealSpace(parent.getServerWorldData().getWorldSizeDiscrete())){
|
if(positionToTest.z >= ServerWorldData.convertChunkToRealSpace(parent.getServerWorldData().getWorldSizeDiscrete())){
|
||||||
returnPos.z = parent.getServerWorldData().convertChunkToRealSpace(parent.getServerWorldData().getWorldSizeDiscrete()) - 1;
|
returnPos.z = ServerWorldData.convertChunkToRealSpace(parent.getServerWorldData().getWorldSizeDiscrete()) - 1;
|
||||||
}
|
}
|
||||||
return returnPos;
|
return returnPos;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -82,8 +82,12 @@ public class ServerContentManager {
|
|||||||
if(Race.hasRace(character)){
|
if(Race.hasRace(character)){
|
||||||
Race race = Race.getRace(character);
|
Race race = Race.getRace(character);
|
||||||
String creatureName = race.getAssociatedCreature();
|
String creatureName = race.getAssociatedCreature();
|
||||||
|
if(creatureName == null){
|
||||||
|
throw new Error("Creature name not defined! " + character.getId());
|
||||||
|
}
|
||||||
//place macro object
|
//place macro object
|
||||||
CreatureUtils.serverSpawnBasicCreature(realm, character.getPos(), creatureName, null);
|
Entity characterEntity = CreatureUtils.serverSpawnBasicCreature(realm, character.getPos(), creatureName, null);
|
||||||
|
ServerCharacterData.attachServerCharacterData(characterEntity, character.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -104,7 +108,7 @@ public class ServerContentManager {
|
|||||||
|
|
||||||
//store all character entities in database
|
//store all character entities in database
|
||||||
for(Entity entity : entities){
|
for(Entity entity : entities){
|
||||||
if(ServerCharacterData.hasServerPlayerCharacterDataTree(entity)){
|
if(ServerCharacterData.hasServerCharacterDataTree(entity)){
|
||||||
CharacterService.saveCharacter(entity);
|
CharacterService.saveCharacter(entity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,6 +7,7 @@ import java.util.List;
|
|||||||
import electrosphere.entity.Entity;
|
import electrosphere.entity.Entity;
|
||||||
import electrosphere.entity.EntityUtils;
|
import electrosphere.entity.EntityUtils;
|
||||||
import electrosphere.entity.state.attach.AttachUtils;
|
import electrosphere.entity.state.attach.AttachUtils;
|
||||||
|
import electrosphere.entity.state.server.ServerCharacterData;
|
||||||
import electrosphere.entity.types.EntityTypes;
|
import electrosphere.entity.types.EntityTypes;
|
||||||
import electrosphere.entity.types.EntityTypes.EntityType;
|
import electrosphere.entity.types.EntityTypes.EntityType;
|
||||||
import electrosphere.entity.types.common.CommonEntityUtils;
|
import electrosphere.entity.types.common.CommonEntityUtils;
|
||||||
@ -37,7 +38,7 @@ public class ContentSerialization {
|
|||||||
public static ContentSerialization constructContentSerialization(Collection<Entity> entities){
|
public static ContentSerialization constructContentSerialization(Collection<Entity> entities){
|
||||||
ContentSerialization rVal = new ContentSerialization();
|
ContentSerialization rVal = new ContentSerialization();
|
||||||
for(Entity entity : entities){
|
for(Entity entity : entities){
|
||||||
if(!CreatureUtils.hasControllerPlayerId(entity)){
|
if(!CreatureUtils.hasControllerPlayerId(entity) && !ServerCharacterData.hasServerCharacterDataTree(entity)){
|
||||||
EntityType type = CommonEntityUtils.getEntityType(entity);
|
EntityType type = CommonEntityUtils.getEntityType(entity);
|
||||||
if(type != null){
|
if(type != null){
|
||||||
EntitySerialization serializedEntity = constructEntitySerialization(entity);
|
EntitySerialization serializedEntity = constructEntitySerialization(entity);
|
||||||
|
|||||||
@ -42,7 +42,8 @@ public class Character implements MacroObject {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Character(){
|
public Character(){
|
||||||
|
this.id = character_id_iterator;
|
||||||
|
character_id_iterator++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -6,6 +6,8 @@ import com.google.gson.JsonDeserializationContext;
|
|||||||
import com.google.gson.JsonDeserializer;
|
import com.google.gson.JsonDeserializer;
|
||||||
import com.google.gson.JsonElement;
|
import com.google.gson.JsonElement;
|
||||||
import com.google.gson.JsonParseException;
|
import com.google.gson.JsonParseException;
|
||||||
|
import com.google.gson.JsonSerializationContext;
|
||||||
|
import com.google.gson.JsonSerializer;
|
||||||
|
|
||||||
import electrosphere.server.macro.character.diety.Diety;
|
import electrosphere.server.macro.character.diety.Diety;
|
||||||
import electrosphere.server.macro.race.Race;
|
import electrosphere.server.macro.race.Race;
|
||||||
@ -15,11 +17,12 @@ import electrosphere.server.macro.town.Town;
|
|||||||
/**
|
/**
|
||||||
* Deserializes noise modules
|
* Deserializes noise modules
|
||||||
*/
|
*/
|
||||||
public class CharacterDataSerializer implements JsonDeserializer<CharacterData> {
|
public class CharacterDataSerializer implements JsonDeserializer<CharacterData>, JsonSerializer<CharacterData> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CharacterData deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
|
public CharacterData deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
|
||||||
switch(json.getAsJsonObject().get("dataType").getAsString()){
|
String type = json.getAsJsonObject().get("dataType").getAsString();
|
||||||
|
switch(type){
|
||||||
|
|
||||||
//race
|
//race
|
||||||
case CharacterDataStrings.RACE: {
|
case CharacterDataStrings.RACE: {
|
||||||
@ -40,8 +43,41 @@ public class CharacterDataSerializer implements JsonDeserializer<CharacterData>
|
|||||||
case CharacterDataStrings.TOWN: {
|
case CharacterDataStrings.TOWN: {
|
||||||
return context.deserialize(json, Town.class);
|
return context.deserialize(json, Town.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default: {
|
||||||
|
throw new Error("Failed to deserialize datatype: " + type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public JsonElement serialize(CharacterData src, Type typeOfSrc, JsonSerializationContext context) {
|
||||||
|
switch(src.getDataType()){
|
||||||
|
|
||||||
|
//race
|
||||||
|
case CharacterDataStrings.RACE: {
|
||||||
|
return context.serialize((Race)src);
|
||||||
|
}
|
||||||
|
|
||||||
|
//diety data
|
||||||
|
case CharacterDataStrings.DIETY: {
|
||||||
|
return context.serialize((Diety)src);
|
||||||
|
}
|
||||||
|
|
||||||
|
//a structure
|
||||||
|
case CharacterDataStrings.STRUCTURE: {
|
||||||
|
return context.serialize((Structure)src);
|
||||||
|
}
|
||||||
|
|
||||||
|
//a town
|
||||||
|
case CharacterDataStrings.TOWN: {
|
||||||
|
return context.serialize((Town)src);
|
||||||
|
}
|
||||||
|
|
||||||
|
default: {
|
||||||
|
throw new Error("Failed to serialize datatype: " + src.getDataType());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user