void MapNode::Deserialize(SerializedGameData& sgd, const unsigned numPlayers) { for(unsigned z = 0; z < roads.size(); ++z) { roads[z] = sgd.PopUnsignedChar(); RTTR_Assert(roads[z] < 4); roads_real[z] = roads[z] != 0; } altitude = sgd.PopUnsignedChar(); shadow = sgd.PopUnsignedChar(); t1 = TerrainType(sgd.PopUnsignedChar()); RTTR_Assert(t1 < TT_COUNT); t2 = TerrainType(sgd.PopUnsignedChar()); RTTR_Assert(t2 < TT_COUNT); resources = sgd.PopUnsignedChar(); reserved = sgd.PopBool(); owner = sgd.PopUnsignedChar(); for(unsigned b = 0; b < boundary_stones.size(); ++b) boundary_stones[b] = sgd.PopUnsignedChar(); bq = BuildingQuality(sgd.PopUnsignedChar()); bqVisual = BuildingQuality(sgd.PopUnsignedChar()); RTTR_Assert(numPlayers < fow.size()); for(unsigned z = 0; z < numPlayers; ++z) { MapNode::FoWData& curFoW = fow[z]; curFoW.visibility = Visibility(sgd.PopUnsignedChar()); // Only in FoW can be FoW objects if(curFoW.visibility == VIS_FOW) { curFoW.last_update_time = sgd.PopUnsignedInt(); curFoW.object = sgd.PopFOWObject(); for(unsigned r = 0; r < curFoW.roads.size(); ++r) curFoW.roads[r] = sgd.PopUnsignedChar(); curFoW.owner = sgd.PopUnsignedChar(); for(unsigned b = 0; b < curFoW.boundary_stones.size(); ++b) curFoW.boundary_stones[b] = sgd.PopUnsignedChar(); } else { curFoW.last_update_time = 0; curFoW.object = NULL; for(unsigned r = 0; r < curFoW.roads.size(); ++r) curFoW.roads[r] = 0; curFoW.owner = 0; for(unsigned b = 0; b < curFoW.boundary_stones.size(); ++b) curFoW.boundary_stones[b] = 0; } } obj = sgd.PopObject<noBase>(GOT_UNKNOWN); sgd.PopObjectContainer(figures, GOT_UNKNOWN); sea_id = sgd.PopUnsignedShort(); harbor_id = sgd.PopUnsignedInt(); }
void MapNode::Deserialize(SerializedGameData& sgd, const unsigned numPlayers) { for(unsigned z = 0; z < roads.size(); ++z) { roads[z] = sgd.PopUnsignedChar(); RTTR_Assert(roads[z] < 4); } altitude = sgd.PopUnsignedChar(); shadow = sgd.PopUnsignedChar(); t1 = TerrainType(sgd.PopUnsignedChar()); RTTR_Assert(t1 < TT_COUNT); t2 = TerrainType(sgd.PopUnsignedChar()); RTTR_Assert(t2 < TT_COUNT); resources = sgd.PopUnsignedChar(); reserved = sgd.PopBool(); owner = sgd.PopUnsignedChar(); for(unsigned b = 0; b < boundary_stones.size(); ++b) boundary_stones[b] = sgd.PopUnsignedChar(); bq = BuildingQuality(sgd.PopUnsignedChar()); RTTR_Assert(numPlayers < fow.size()); for(unsigned z = 0; z < numPlayers; ++z) fow[z].Deserialize(sgd); obj = sgd.PopObject<noBase>(GOT_UNKNOWN); sgd.PopObjectContainer(figures, GOT_UNKNOWN); seaId = sgd.PopUnsignedShort(); harborId = sgd.PopUnsignedInt(); }
void GameWorld::Deserialize(SerializedGameData *sgd) { // Headinformationen width = sgd->PopUnsignedShort(); height = sgd->PopUnsignedShort(); lt = LandscapeType(sgd->PopUnsignedChar()); // Initialisierungen Init(); // Obj-ID-Counter setzen GameObject::SetObjIDCounter(sgd->PopUnsignedInt()); // Trade graphs // Only if trade is enabled if(GameClient::inst().GetGGS().isEnabled(ADDON_TRADE)) { tgs.resize(sgd->PopUnsignedChar()); for(unsigned i = 0;i<tgs.size();++i) tgs[i] = new TradeGraph(sgd,this); } // Alle Weltpunkte serialisieren for(unsigned i = 0;i<map_size;++i) { for(unsigned z = 0;z<3;++z) { nodes[i].roads[z] = sgd->PopUnsignedChar(); nodes[i].roads_real[z] = nodes[i].roads[z] ? true : false; } nodes[i].altitude = sgd->PopUnsignedChar(); nodes[i].shadow = sgd->PopUnsignedChar(); nodes[i].t1 = sgd->PopUnsignedChar(); nodes[i].t2 = sgd->PopUnsignedChar(); nodes[i].resources = sgd->PopUnsignedChar(); nodes[i].reserved = sgd->PopBool(); nodes[i].owner = sgd->PopUnsignedChar(); for(unsigned b = 0;b<4;++b) nodes[i].boundary_stones[b] = sgd->PopUnsignedChar(); nodes[i].bq = BuildingQuality(sgd->PopUnsignedChar()); for(unsigned z = 0;z<GameClient::inst().GetPlayerCount();++z) { nodes[i].fow[z].visibility = Visibility(sgd->PopUnsignedChar()); // Nur im FoW können FOW-Objekte stehen if(nodes[i].fow[z].visibility == VIS_FOW) { nodes[i].fow[z].last_update_time = sgd->PopUnsignedInt(); nodes[i].fow[z].object = sgd->PopFOWObject(); for(unsigned r = 0;r<3;++r) nodes[i].fow[z].roads[r] = sgd->PopUnsignedChar(); nodes[i].fow[z].owner = sgd->PopUnsignedChar(); for(unsigned b = 0;b<4;++b) nodes[i].fow[z].boundary_stones[b] = sgd->PopUnsignedChar(); } else { nodes[i].fow[z].last_update_time = 0; nodes[i].fow[z].object = NULL; for(unsigned r = 0;r<3;++r) nodes[i].fow[z].roads[r] = 0; nodes[i].fow[z].owner = 0; for(unsigned b = 0;b<4;++b) nodes[i].fow[z].boundary_stones[b] = 0; } } nodes[i].obj = sgd->PopObject<noBase>(GOT_UNKNOWN); sgd->PopObjectList<noBase>(nodes[i].figures,GOT_UNKNOWN); nodes[i].sea_id = sgd->PopUnsignedShort(); nodes[i].harbor_id = sgd->PopUnsignedInt(); if(nodes[i].harbor_id) { GameWorldBase::HarborPos p = {i%width,i/width}; harbor_pos.push_back(p); } } // Katapultsteine deserialisieren sgd->PopObjectList(catapult_stones,GOT_CATAPULTSTONE); // Meeresinformationen deserialisieren seas.resize(sgd->PopUnsignedInt()); for(unsigned i = 0;i<seas.size();++i) { seas[i].nodes_count = sgd->PopUnsignedInt(); } // Hafenpositionen serialisieren harbor_pos.resize(sgd->PopUnsignedInt()); for(unsigned i = 0;i<harbor_pos.size();++i) { harbor_pos[i].x = sgd->PopUnsignedShort(); harbor_pos[i].y = sgd->PopUnsignedShort(); for(unsigned z = 0;z<6;++z) harbor_pos[i].cps[z].sea_id = sgd->PopUnsignedShort(); for(unsigned z = 0;z<6;++z) { harbor_pos[i].neighbors[z].resize(sgd->PopUnsignedInt()); for(unsigned c = 0;c<harbor_pos[i].neighbors[z].size();++c) { harbor_pos[i].neighbors[z][c].id = sgd->PopUnsignedInt(); harbor_pos[i].neighbors[z][c].distance = sgd->PopUnsignedInt(); } } } sgd->PopObjectList<noBuildingSite>(harbor_building_sites_from_sea,GOT_BUILDINGSITE); // BQ neu berechnen for(unsigned y = 0;y<height;++y) { for(unsigned x = 0;x<width;++x) { SetBQ(x,y,GAMECLIENT.GetPlayerID()); } } tr.GenerateOpenGL(this); // Zum HQ am Anfang springen, falls dieses existiert if(GetPlayer(GameClient::inst().GetPlayerID())->hqx != 0xFFFF) this->MoveToMapObject(GetPlayer(GameClient::inst().GetPlayerID())->hqx, GetPlayer(GameClient::inst().GetPlayerID())->hqy); }