コード例 #1
0
nofAttacker::nofAttacker(SerializedGameData& sgd, const unsigned obj_id) : nofActiveSoldier(sgd, obj_id)
{
    if(state != STATE_WALKINGHOME && state != STATE_FIGUREWORK)
    {
        attacked_goal = sgd.PopObject<nobBaseMilitary>(GOT_UNKNOWN);
        mayBeHunted = sgd.PopBool();
        sgd.PopContainer(canPlayerSendAggDefender);
        RTTR_Assert(canPlayerSendAggDefender.size() == gwg->GetNumPlayers());
        huntingDefender = sgd.PopObject<nofAggressiveDefender>(GOT_NOF_AGGRESSIVEDEFENDER);

        radius = sgd.PopUnsignedShort();

        if(state == STATE_ATTACKING_WAITINGFORDEFENDER)
            blocking_event = sgd.PopEvent();
        else
            blocking_event = nullptr;

        harborPos = sgd.PopMapPoint();
        shipPos = sgd.PopMapPoint();
        ship_obj_id = sgd.PopUnsignedInt();
    } else
    {
        attacked_goal = nullptr;
        mayBeHunted = false;
        canPlayerSendAggDefender.resize(gwg->GetNumPlayers(), 2);
        huntingDefender = nullptr;
        radius = 0;
        blocking_event = nullptr;
        harborPos = MapPoint::Invalid();
        shipPos = MapPoint::Invalid(); //-V656
        ship_obj_id = 0;
    }
}
コード例 #2
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();
}
コード例 #3
0
ファイル: noMovable.cpp プロジェクト: aidevn/s25client
noMovable::noMovable(SerializedGameData& sgd, const unsigned obj_id) : noCoordBase(sgd, obj_id),
    curMoveDir(sgd.PopUnsignedChar()),
    ascent(sgd.PopUnsignedChar()),
    current_ev(sgd.PopEvent()),
    pause_walked_gf(sgd.PopUnsignedInt()),
    pause_event_length(sgd.PopUnsignedInt())
    , moving(sgd.PopBool())
{
}
コード例 #4
0
ファイル: noFighting.cpp プロジェクト: viksuhor/s25client
noFighting::noFighting(SerializedGameData& sgd, const unsigned obj_id) : noBase(sgd, obj_id),
    turn(sgd.PopUnsignedChar()),
    defending_animation(sgd.PopUnsignedChar()),
    current_ev(sgd.PopEvent()),
    player_won(sgd.PopUnsignedChar())

{
    for(unsigned i = 0; i < 2; ++i)
        soldiers[i] = sgd.PopObject<nofActiveSoldier>(GOT_UNKNOWN);
}
コード例 #5
0
ファイル: CatapultStone.cpp プロジェクト: aidevn/s25client
CatapultStone::CatapultStone(SerializedGameData& sgd, const unsigned obj_id) : GameObject(sgd, obj_id),
    dest_building(sgd.PopMapPoint()),
    dest_map(sgd.PopMapPoint()),
    start_x(sgd.PopSignedInt()),
    start_y(sgd.PopSignedInt()),
    dest_x(sgd.PopSignedInt()),
    dest_y(sgd.PopSignedInt()),
    explode(sgd.PopBool()),
    event(sgd.PopEvent())
{
}
コード例 #6
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;
    }
}
コード例 #7
0
ファイル: nofCarrier.cpp プロジェクト: Flow86/s25client
nofCarrier::nofCarrier(SerializedGameData& sgd, unsigned int obj_id)
    : noFigure(sgd, obj_id),
      ct( CarrierType(sgd.PopUnsignedChar()) ),
      state( CarrierState(sgd.PopUnsignedChar()) ),
      fat( sgd.PopBool() ),
      workplace( sgd.PopObject<RoadSegment>(GOT_ROADSEGMENT) ),
      carried_ware( sgd.PopObject<Ware>(GOT_WARE) ),
      productivity_ev(sgd.PopEvent()),
      productivity(sgd.PopUnsignedInt()),
      worked_gf(sgd.PopUnsignedInt()),
      since_working_gf(sgd.PopUnsignedInt()),
      next_animation(0)
{

    if(state == CARRS_BOATCARRIER_WANDERONWATER)
    {
        shore_path.resize(sgd.PopUnsignedInt());
        for(std::vector<unsigned char>::iterator it = shore_path.begin(); it != shore_path.end(); ++it)
            *it = sgd.PopUnsignedChar();
    }
}
コード例 #8
0
noFire::noFire(SerializedGameData& sgd, const unsigned obj_id)
    : noCoordBase(sgd, obj_id), isBig(sgd.PopBool()), dead_event(sgd.PopEvent()), was_sounding(false), last_sound(0), next_interval(0)
{}