コード例 #1
0
nobBaseWarehouse::nobBaseWarehouse(SerializedGameData& sgd, const unsigned obj_id) : nobBaseMilitary(sgd, obj_id)
{
    sgd.PopObjectContainer(waiting_wares, GOT_WARE);
    fetch_double_protection = sgd.PopBool();
    sgd.PopObjectContainer(dependent_figures, GOT_UNKNOWN);
    sgd.PopObjectContainer(dependent_wares, GOT_WARE);

    producinghelpers_event = sgd.PopObject<EventManager::Event>(GOT_EVENT);
    recruiting_event = sgd.PopObject<EventManager::Event>(GOT_EVENT);
    empty_event = sgd.PopObject<EventManager::Event>(GOT_EVENT);
    store_event = sgd.PopObject<EventManager::Event>(GOT_EVENT);

    for(unsigned i = 0; i < 5; ++i)
    {
        reserve_soldiers_available[i] = sgd.PopUnsignedInt();
        reserve_soldiers_claimed_visual[i] = reserve_soldiers_claimed_real[i] = sgd.PopUnsignedInt();
    }

    for(unsigned i = 0; i < WARE_TYPES_COUNT; ++i)
    {
        inventory.visual.goods[i] = sgd.PopUnsignedInt();
        inventory.real.goods[i] = sgd.PopUnsignedInt();
        inventorySettings.wares[i] = inventorySettingsVisual.wares[i] = static_cast<InventorySetting>(sgd.PopUnsignedChar());
    }
    for(unsigned i = 0; i < JOB_TYPES_COUNT; ++i)
    {
        inventory.visual.people[i] = sgd.PopUnsignedInt();
        inventory.real.people[i] = sgd.PopUnsignedInt();
        inventorySettings.figures[i] = inventorySettingsVisual.figures[i] = static_cast<InventorySetting>(sgd.PopUnsignedChar());
    }
}
コード例 #2
0
void BuildingRegister::Deserialize2(SerializedGameData& sgd)
{
    if(sgd.GetGameDataVersion() < 2)
    {
        for(unsigned i = 0; i < 30; ++i)
            sgd.PopObjectContainer(buildings[i], GOT_NOB_USUAL);
        sgd.PopObjectContainer(building_sites, GOT_BUILDINGSITE);
        sgd.PopObjectContainer(military_buildings, GOT_NOB_MILITARY);
    }
}
コード例 #3
0
void BuildingRegister::Deserialize(SerializedGameData& sgd)
{
    sgd.PopObjectContainer(warehouses, GOT_UNKNOWN);
    sgd.PopObjectContainer(harbors, GOT_NOB_HARBORBUILDING);
    if(sgd.GetGameDataVersion() >= 2)
    {
        for(auto& building : buildings)
            sgd.PopObjectContainer(building, GOT_NOB_USUAL);
        sgd.PopObjectContainer(building_sites, GOT_BUILDINGSITE);
        sgd.PopObjectContainer(military_buildings, GOT_NOB_MILITARY);
    }
}
コード例 #4
0
ファイル: nobUsual.cpp プロジェクト: gattschardo/s25client
/**
 *
 *
 *  @author OLiver
 */
nobUsual::nobUsual(SerializedGameData& sgd, const unsigned int obj_id)
    : noBuilding(sgd, obj_id),
      worker(sgd.PopObject<nofBuildingWorker>(GOT_UNKNOWN)),
      productivity(sgd.PopUnsignedShort()),
      disable_production(sgd.PopBool()),
      disable_production_virtual(sgd.PopBool()),
      last_ordered_ware(sgd.PopUnsignedChar()),
      orderware_ev(sgd.PopObject<EventManager::Event>(GOT_EVENT)),
      productivity_ev(sgd.PopObject<EventManager::Event>(GOT_EVENT)),
      is_working(sgd.PopBool())
{
    for(unsigned i = 0; i < 3; ++i)
        wares[i] = sgd.PopUnsignedChar();

    if(USUAL_BUILDING_CONSTS[type_ - 10].wares_needed_count)
        ordered_wares.resize(USUAL_BUILDING_CONSTS[type_ - 10].wares_needed_count);
    else
        ordered_wares.clear();

    for(unsigned i = 0; i < USUAL_BUILDING_CONSTS[type_ - 10].wares_needed_count; ++i)
        sgd.PopObjectContainer(ordered_wares[i], GOT_WARE);
    for(unsigned i = 0; i < LAST_PRODUCTIVITIES_COUNT; ++i)
        last_productivities[i] = sgd.PopUnsignedShort();

    // Visuellen Produktionszustand dem realen anpassen
    disable_production_virtual = disable_production;
}
コード例 #5
0
ファイル: MapNode.cpp プロジェクト: viksuhor/s25client
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();
}
コード例 #6
0
nobHarborBuilding::nobHarborBuilding(SerializedGameData& sgd, const unsigned obj_id)
    : nobBaseWarehouse(sgd, obj_id),
      expedition(sgd),
      exploration_expedition(sgd),
      orderware_ev(sgd.PopObject<EventManager::Event>(GOT_EVENT))
{
    // ins Militärquadrat einfügen
    gwg->GetMilitarySquares().Add(this);

    for(unsigned i = 0; i < 6; ++i)
        sea_ids[i] = sgd.PopUnsignedShort();

    sgd.PopObjectContainer(wares_for_ships, GOT_WARE);

    unsigned count = sgd.PopUnsignedInt();
    for(unsigned i = 0; i < count; ++i)
    {
        FigureForShip ffs;
        ffs.dest = sgd.PopMapPoint();
        ffs.fig = sgd.PopObject<noFigure>(GOT_UNKNOWN);
        figures_for_ships.push_back(ffs);
    }

    count = sgd.PopUnsignedInt();
    for(unsigned i = 0; i < count; ++i)
    {
        SoldierForShip ffs;
        ffs.dest = sgd.PopMapPoint();
        ffs.attacker = sgd.PopObject<nofAttacker>(GOT_NOF_ATTACKER);
        soldiers_for_ships.push_back(ffs);
    }
}
コード例 #7
0
ファイル: noShip.cpp プロジェクト: Ribosom/s25client
noShip::noShip(SerializedGameData& sgd, const unsigned obj_id) :
    noMovable(sgd, obj_id),
    player(sgd.PopUnsignedChar()),
    state(State(sgd.PopUnsignedChar())),
    seaId_(sgd.PopUnsignedShort()),
    goal_harbor_id(sgd.PopUnsignedInt()),
    goal_dir(sgd.PopUnsignedChar()),
    name(sgd.PopString()),
    curRouteIdx(sgd.PopUnsignedInt()),
    route_(sgd.PopUnsignedInt()),
    lost(sgd.PopBool()),
    remaining_sea_attackers(sgd.PopUnsignedInt()),
    home_harbor(sgd.PopUnsignedInt()),
    covered_distance(sgd.PopUnsignedInt())
{
    for(unsigned i = 0; i < route_.size(); ++i)
        route_[i] = sgd.PopUnsignedChar();
    sgd.PopObjectContainer(figures, GOT_UNKNOWN);
    sgd.PopObjectContainer(wares, GOT_WARE);
}
コード例 #8
0
ファイル: MapNode.cpp プロジェクト: aidevn/s25client
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();
}
コード例 #9
0
noBuildingSite::noBuildingSite(SerializedGameData& sgd, const unsigned obj_id) : noBaseBuilding(sgd, obj_id),
    state(static_cast<State>(sgd.PopUnsignedChar())),
    planer(sgd.PopObject<nofPlaner>(GOT_NOF_PLANER)),
    builder(sgd.PopObject<nofBuilder>(GOT_NOF_BUILDER)),
    boards(sgd.PopUnsignedChar()),
    stones(sgd.PopUnsignedChar()),
    used_boards(sgd.PopUnsignedChar()),
    used_stones(sgd.PopUnsignedChar()),
    build_progress(sgd.PopUnsignedChar())
{
    sgd.PopObjectContainer(ordered_boards, GOT_WARE);
    sgd.PopObjectContainer(ordered_stones, GOT_WARE);
}
コード例 #10
0
ファイル: nobMilitary.cpp プロジェクト: aidevn/s25client
nobMilitary::nobMilitary(SerializedGameData& sgd, const unsigned obj_id) : nobBaseMilitary(sgd, obj_id),
    is_regulating_troops(false)
{
    // use a bitfield instead of 1 unsigned char per boolean
    // mainly for compatibility :-)

    unsigned char bitfield = sgd.PopUnsignedChar();

    new_built = bitfield & (1 << 0);
    captured_not_built = !(bitfield & (1 << 1));

    coins = sgd.PopUnsignedChar();
    coinsDisabled = sgd.PopBool();
    coinsDisabledVirtual = sgd.PopBool();
    frontier_distance = sgd.PopUnsignedChar();
    size = sgd.PopUnsignedChar();
    capturing = sgd.PopBool();
    capturing_soldiers = sgd.PopUnsignedInt();
    goldorder_event = sgd.PopEvent();
    upgrade_event = sgd.PopEvent();


    sgd.PopObjectContainer(ordered_troops, GOT_NOF_PASSIVESOLDIER);
    sgd.PopObjectContainer(ordered_coins, GOT_WARE);
    sgd.PopObjectContainer(troops, GOT_NOF_PASSIVESOLDIER);
    sgd.PopObjectContainer(far_away_capturers, GOT_NOF_ATTACKER);

    mAutoTrain = sgd.PopBool();
    mAutoTrainVirtual = sgd.PopBool();

    // ins Militärquadrat einfügen
    gwg->GetMilitarySquares().Add(this);

    if(capturing && capturing_soldiers == 0 && aggressors.empty())
    {
        LOG.lprintf("Bug in savegame detected: Building at (%d,%d) beeing captured has no capturers. Trying to fix this...\n", pos.x, pos.y);
        capturing = false;
    }
}
コード例 #11
0
nobUsual::nobUsual(SerializedGameData& sgd, const unsigned obj_id)
    : noBuilding(sgd, obj_id), worker(sgd.PopObject<nofBuildingWorker>(GOT_UNKNOWN)), productivity(sgd.PopUnsignedShort()),
      disable_production(sgd.PopBool()), disable_production_virtual(disable_production), last_ordered_ware(sgd.PopUnsignedChar()),
      orderware_ev(sgd.PopEvent()), productivity_ev(sgd.PopEvent()), numGfNotWorking(sgd.PopUnsignedShort()),
      since_not_working(sgd.PopUnsignedInt()), outOfRessourcesMsgSent(sgd.PopBool()), is_working(sgd.PopBool())
{
    for(unsigned i = 0; i < 3; ++i)
        numWares[i] = sgd.PopUnsignedChar();

    ordered_wares.resize(BLD_WORK_DESC[bldType_].waresNeeded.getNum());

    for(std::list<Ware*>& orderedWare : ordered_wares)
        sgd.PopObjectContainer(orderedWare, GOT_WARE);
    for(unsigned short& last_productivitie : last_productivities)
        last_productivitie = sgd.PopUnsignedShort();
}
コード例 #12
0
ファイル: GameWorld.cpp プロジェクト: Ribosom/s25client
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.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 = TerrainType(sgd.PopUnsignedChar());
        nodes[i].t2 = TerrainType(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.GetPlayerCount(); ++z)
        {
            MapNode::FoWData& fow = nodes[i].fow[z];
            fow.visibility = Visibility(sgd.PopUnsignedChar());
            // Nur im FoW können FOW-Objekte stehen
            if(fow.visibility == VIS_FOW)
            {
                fow.last_update_time = sgd.PopUnsignedInt();
                fow.object = sgd.PopFOWObject();
                for(unsigned r = 0; r < 3; ++r)
                    fow.roads[r] = sgd.PopUnsignedChar();
                fow.owner = sgd.PopUnsignedChar();
                for(unsigned b = 0; b < 4; ++b)
                    fow.boundary_stones[b] = sgd.PopUnsignedChar();
            }
            else
            {
                fow.last_update_time = 0;
                fow.object = NULL;
                for(unsigned r = 0; r < 3; ++r)
                    fow.roads[r] = 0;
                fow.owner = 0;
                for(unsigned b = 0; b < 4; ++b)
                    fow.boundary_stones[b] = 0;
            }
        }
        nodes[i].obj = sgd.PopObject<noBase>(GOT_UNKNOWN);
        sgd.PopObjectContainer(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(MapPoint((MapCoord) (i % width_), (MapCoord) (i / width_)));
            harbor_pos.push_back(p);
        }
    }

    // Katapultsteine deserialisieren
    sgd.PopObjectContainer(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].pos = sgd.PopMapPoint();
        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.PopObjectContainer(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(MapPoint(x, y), GAMECLIENT.GetPlayerID());
        }
    }

    tr.GenerateOpenGL(*this);

    // Zum HQ am Anfang springen, falls dieses existiert
    if(GetPlayer(GAMECLIENT.GetPlayerID()).hqPos.x != 0xFFFF)
        this->MoveToMapObject(GetPlayer(GAMECLIENT.GetPlayerID()).hqPos);
}