Verified Commit 95d22651 authored by JohnMH's avatar JohnMH

Fix deserialization

parent 32cba599
Pipeline #2500 passed with stages
in 18 minutes and 44 seconds
......@@ -44,7 +44,7 @@ namespace OB{
char* GetAsset(std::string url);
#if HAVE_PUGIXML
virtual std::string serializedID();
virtual std::string fixedSerializedID();
#endif
DECLARE_LUA_METHOD(Preload);
......
......@@ -69,7 +69,7 @@ namespace OB{
#endif
#if HAVE_PUGIXML
virtual std::string serializedID();
virtual std::string fixedSerializedID();
#endif
virtual std::map<std::string, _PropertyInfo> getProperties();
......
......@@ -189,7 +189,7 @@ namespace OB{
#if HAVE_PUGIXML
virtual void deserialize(pugi::xml_node thisNode);
virtual std::string serializedID();
virtual std::string fixedSerializedID();
#endif
virtual std::map<std::string, _PropertyInfo> getProperties();
......
......@@ -437,6 +437,8 @@ namespace OB{
virtual void deserializeCreate(pugi::xml_node thisNode);
virtual void deserialize(pugi::xml_node thisNode);
virtual void deserializeProperties(pugi::xml_node thisNode);
virtual std::string fixedSerializedID();
virtual std::string serializedID();
#endif
......
......@@ -38,7 +38,7 @@ namespace OB{
virtual ~Lighting();
#if HAVE_PUGIXML
virtual std::string serializedID();
virtual std::string fixedSerializedID();
#endif
virtual void preRender();
......
......@@ -38,7 +38,7 @@ namespace OB{
virtual ~LogService();
#if HAVE_PUGIXML
virtual std::string serializedID();
virtual std::string fixedSerializedID();
#endif
void postLog(std::string message, Enum::MessageType messageType);
......
......@@ -45,7 +45,7 @@ namespace OB{
void send(enet_uint8 channel, BitStream &bs);
#if HAVE_PUGIXML
virtual std::string serializedID();
virtual std::string fixedSerializedID();
#endif
DECLARE_LUA_METHOD(Connect);
......
......@@ -45,7 +45,7 @@ namespace OB{
void broadcast(enet_uint8 channel, BitStream &bs);
#if HAVE_PUGIXML
virtual std::string serializedID();
virtual std::string fixedSerializedID();
#endif
DECLARE_LUA_METHOD(Start);
......
......@@ -45,7 +45,7 @@ namespace OB{
virtual ~Players();
#if HAVE_PUGIXML
virtual std::string serializedID();
virtual std::string fixedSerializedID();
#endif
virtual void removeChild(shared_ptr<Instance> kid);
......
......@@ -36,7 +36,7 @@ namespace OB{
virtual ~ReplicatedFirst();
#if HAVE_PUGIXML
virtual std::string serializedID();
virtual std::string fixedSerializedID();
#endif
DECLARE_CLASS(ReplicatedFirst);
......
......@@ -36,7 +36,7 @@ namespace OB{
virtual ~ReplicatedStorage();
#if HAVE_PUGIXML
virtual std::string serializedID();
virtual std::string fixedSerializedID();
#endif
DECLARE_CLASS(ReplicatedStorage);
......
......@@ -50,7 +50,7 @@ namespace OB{
virtual void tick();
#if HAVE_PUGIXML
virtual std::string serializedID();
virtual std::string fixedSerializedID();
#endif
static void register_lua_events(lua_State* L);
......
......@@ -36,7 +36,7 @@ namespace OB{
virtual ~StarterGui();
#if HAVE_PUGIXML
virtual std::string serializedID();
virtual std::string fixedSerializedID();
#endif
DECLARE_CLASS(StarterGui);
......
......@@ -39,7 +39,7 @@ namespace OB{
int getNumWaitingJobs();
#if HAVE_PUGIXML
virtual std::string serializedID();
virtual std::string fixedSerializedID();
#endif
virtual std::map<std::string, _PropertyInfo> getProperties();
......
......@@ -38,7 +38,7 @@ namespace OB{
virtual ~UserInputService();
#if HAVE_PUGIXML
virtual std::string serializedID();
virtual std::string fixedSerializedID();
#endif
virtual void render();
......
......@@ -68,7 +68,7 @@ namespace OB{
#endif
#if HAVE_PUGIXML
virtual std::string serializedID();
virtual std::string fixedSerializedID();
#endif
virtual std::map<std::string, _PropertyInfo> getProperties();
......
......@@ -230,7 +230,15 @@ namespace OB{
bool OBSerializer::HasID(shared_ptr<Instance::Instance> inst){
auto it = instanceMap.find(inst);
return it == instanceMap.end();
bool hasInMap = (it != instanceMap.end());
if(!hasInMap){
std::string fixedStr = inst->fixedSerializedID();
if(!fixedStr.empty()){
SetID(inst, fixedStr);
return true;
}
}
return hasInMap;
}
shared_ptr<Instance::Instance> OBSerializer::GetByID(std::string id){
......
......@@ -77,11 +77,8 @@ namespace OB{
}
#if HAVE_PUGIXML
std::string ContentProvider::serializedID(){
shared_ptr<OBSerializer> serializer = eng->getSerializer();
serializer->SetID(shared_from_this(), getClassName());
return Instance::serializedID();
std::string ContentProvider::fixedSerializedID(){
return "ContentProvider";
}
#endif
......
......@@ -121,11 +121,8 @@ namespace OB{
}
#if HAVE_PUGIXML
std::string CoreGui::serializedID(){
shared_ptr<OBSerializer> serializer = eng->getSerializer();
serializer->SetID(shared_from_this(), getClassName());
return Instance::serializedID();
std::string CoreGui::fixedSerializedID(){
return "CoreGui";
}
#endif
......
......@@ -287,11 +287,8 @@ namespace OB{
Instance::deserialize(thisNode);
}
std::string DataModel::serializedID(){
shared_ptr<OBSerializer> serializer = eng->getSerializer();
serializer->SetID(shared_from_this(), "game");
return Instance::serializedID();
std::string DataModel::fixedSerializedID(){
return "game";
}
#endif
......
......@@ -456,7 +456,6 @@ namespace OB{
if(serializer){
shared_ptr<Instance> tInst = serializer->GetByID(sid);
if(!tInst){
printf("Created %s with id %s\n", stype.c_str(), sid.c_str());
tInst = ClassFactory::createReplicate(stype, eng);
serializer->SetID(tInst, sid);
}
......@@ -539,18 +538,26 @@ namespace OB{
shared_ptr<Instance> kid = kids[i];
if(kid){
if(serializer->HasID(kid)){
printf("%s has id\n", kid->getName().c_str());
pugi::xml_node cinst = thisNode.find_child_by_attribute("instance", "id", kid->serializedID().c_str());
kid->deserializeProperties(cinst);
}else{
printf("%s does not have an id\n", kid->getName().c_str());
}
}
}
}
std::string Instance::fixedSerializedID(){
return "";
}
std::string Instance::serializedID(){
shared_ptr<OBSerializer> serializer = eng->getSerializer();
std::string fixedStr = fixedSerializedID();
if(!fixedStr.empty()){
serializer->SetID(shared_from_this(), fixedStr);
return fixedStr;
}
return serializer->GetID(shared_from_this());
}
#endif
......
......@@ -63,11 +63,8 @@ namespace OB{
Lighting::~Lighting(){}
#if HAVE_PUGIXML
std::string Lighting::serializedID(){
shared_ptr<OBSerializer> serializer = eng->getSerializer();
serializer->SetID(shared_from_this(), getClassName());
return Instance::serializedID();
std::string Lighting::fixedSerializedID(){
return "Lighting";
}
#endif
......
......@@ -47,11 +47,8 @@ namespace OB{
LogService::~LogService(){}
#if HAVE_PUGIXML
std::string LogService::serializedID(){
shared_ptr<OBSerializer> serializer = eng->getSerializer();
serializer->SetID(shared_from_this(), getClassName());
return Instance::serializedID();
std::string LogService::fixedSerializedID(){
return "LogService";
}
#endif
......
......@@ -302,11 +302,8 @@ namespace OB{
}
#if HAVE_PUGIXML
std::string NetworkClient::serializedID(){
shared_ptr<OBSerializer> serializer = eng->getSerializer();
serializer->SetID(shared_from_this(), "NetworkClient");
return Instance::serializedID();
std::string NetworkClient::fixedSerializedID(){
return "NetworkClient";
}
#endif
......
......@@ -122,11 +122,8 @@ namespace OB{
}
#if HAVE_PUGIXML
std::string NetworkServer::serializedID(){
shared_ptr<OBSerializer> serializer = eng->getSerializer();
serializer->SetID(shared_from_this(), getClassName());
return Instance::serializedID();
std::string NetworkServer::fixedSerializedID(){
return "NetworkServer";
}
#endif
......
......@@ -41,11 +41,8 @@ namespace OB{
Players::~Players(){}
#if HAVE_PUGIXML
std::string Players::serializedID(){
shared_ptr<OBSerializer> serializer = eng->getSerializer();
serializer->SetID(shared_from_this(), getClassName());
return Instance::serializedID();
std::string Players::fixedSerializedID(){
return "Players";
}
#endif
......
......@@ -34,11 +34,8 @@ namespace OB{
ReplicatedFirst::~ReplicatedFirst(){}
#if HAVE_PUGIXML
std::string ReplicatedFirst::serializedID(){
shared_ptr<OBSerializer> serializer = eng->getSerializer();
serializer->SetID(shared_from_this(), getClassName());
return Instance::serializedID();
std::string ReplicatedFirst::fixedSerializedID(){
return "ReplicatedFirst";
}
#endif
......
......@@ -33,11 +33,8 @@ namespace OB{
ReplicatedStorage::~ReplicatedStorage(){}
#if HAVE_PUGIXML
std::string ReplicatedStorage::serializedID(){
shared_ptr<OBSerializer> serializer = eng->getSerializer();
serializer->SetID(shared_from_this(), getClassName());
return Instance::serializedID();
std::string ReplicatedStorage::fixedSerializedID(){
return "ReplicatedStorage";
}
#endif
......
......@@ -100,11 +100,8 @@ namespace OB{
}
#if HAVE_PUGIXML
std::string RunService::serializedID(){
shared_ptr<OBSerializer> serializer = eng->getSerializer();
serializer->SetID(shared_from_this(), getClassName());
return Instance::serializedID();
std::string RunService::fixedSerializedID(){
return "RunService";
}
#endif
......
......@@ -38,11 +38,8 @@ namespace OB{
StarterGui::~StarterGui(){}
#if HAVE_PUGIXML
std::string StarterGui::serializedID(){
shared_ptr<OBSerializer> serializer = eng->getSerializer();
serializer->SetID(shared_from_this(), getClassName());
return Instance::serializedID();
std::string StarterGui::fixedSerializedID(){
return "StarterGui";
}
#endif
......
......@@ -57,11 +57,8 @@ namespace OB{
}
#if HAVE_PUGIXML
std::string TaskScheduler::serializedID(){
shared_ptr<OBSerializer> serializer = eng->getSerializer();
serializer->SetID(shared_from_this(), getClassName());
return Instance::serializedID();
std::string TaskScheduler::fixedSerializedID(){
return "TaskScheduler";
}
#endif
......
......@@ -54,11 +54,8 @@ namespace OB{
UserInputService::~UserInputService(){}
#if HAVE_PUGIXML
std::string UserInputService::serializedID(){
shared_ptr<OBSerializer> serializer = eng->getSerializer();
serializer->SetID(shared_from_this(), getClassName());
return Instance::serializedID();
std::string UserInputService::fixedSerializedID(){
return "UserInputService";
}
#endif
......
......@@ -164,11 +164,8 @@ namespace OB{
#endif
#if HAVE_PUGIXML
std::string Workspace::serializedID(){
shared_ptr<OBSerializer> serializer = eng->getSerializer();
serializer->SetID(shared_from_this(), getClassName());
return Instance::serializedID();
std::string Workspace::fixedSerializedID(){
return "Workspace";
}
#endif
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment