Ejemplo n.º 1
0
void InitRound(void)
{
  std::cerr<<"DEBUG- InitRound\n";
  Pac.zy=Pac.sy*BITMAP_Y; Pac.zx=Pac.sx*BITMAP_X; Pac.mcnt=0;
  Pac.nextdir=DIR_STOP; Pac.cur=SPR_PACLEFT; Pac.speed=1*SPEED*CPU_SPEED;
  Pac.mc=0; Pac.old=SPR_PACLEFT; Pac.dir=DIR_STOP;
  Pac.bx=Pac.sx;  Pac.by=Pac.sy;
  Ghost0.zy=Ghost0.sy*BITMAP_Y; Ghost0.zx=Ghost0.sx*BITMAP_X;
  Ghost0.old=SPR_GHOST; Ghost0.speed=1*SPEED*CPU_SPEED;
  Ghost0.lastint=G_SMART;  Ghost0.mc=0; Ghost0.cur=SPR_GHOST;
  Ghost0.ly=Ghost0.sy; Ghost0.lx=Ghost0.sx;
  Ghost0.bx=Ghost0.sx;  Ghost0.by=Ghost0.sy;
  Ghost0.dir=DIR_LEFT; Ghost0.nextdir=DIR_LEFT; Ghost0.mcnt=CountMax;
  Ghost1.zy=Ghost1.sy*BITMAP_Y; Ghost1.zx=Ghost1.sx*BITMAP_X;
  Ghost1.old=SPR_GHOST; Ghost1.speed=1*SPEED*CPU_SPEED;
  Ghost1.lastint=G_SMART;  Ghost1.mc=0; Ghost1.cur=SPR_GHOST;
  Ghost1.ly=Ghost1.sy; Ghost1.lx=Ghost1.sx;
  Ghost1.bx=Ghost1.sx;  Ghost1.by=Ghost1.sy;
  Ghost1.dir=DIR_RIGHT; Ghost1.nextdir=DIR_RIGHT; Ghost1.mcnt=CountMax;
  Ghost2.zy=Ghost2.sy*BITMAP_Y; Ghost2.zx=Ghost2.sx*BITMAP_X;
  Ghost2.old=SPR_GHOST; Ghost2.speed=1*SPEED*CPU_SPEED;
  Ghost2.lastint=G_SMART;  Ghost2.mc=0; Ghost2.cur=SPR_GHOST;
  Ghost2.ly=Ghost2.sy; Ghost2.lx=Ghost2.sx;
  Ghost2.bx=Ghost2.sx;  Ghost2.by=Ghost2.sy;
  Ghost2.dir=DIR_LEFT; Ghost2.nextdir=DIR_LEFT; Ghost2.mcnt=CountMax;
  Ghost3.zy=Ghost3.sy*BITMAP_Y; Ghost3.zx=Ghost3.sx*BITMAP_X;
  Ghost3.old=SPR_GHOST; Ghost3.speed=1*SPEED*CPU_SPEED;
  Ghost3.lastint=G_SMART;  Ghost3.mc=0; Ghost3.cur=SPR_GHOST;
  Ghost3.ly=Ghost3.sy; Ghost3.lx=Ghost3.sx;
  Ghost3.bx=Ghost3.sx;  Ghost3.by=Ghost3.sy;
  Ghost3.dir=DIR_RIGHT; Ghost3.nextdir=DIR_RIGHT; Ghost3.mcnt=CountMax;
  GoHome(&Ghost0);  GoHome(&Ghost1);
  GoHome(&Ghost2);  GoHome(&Ghost3);
  BlueCount=0;  GhostEatCount=100;
}
Ejemplo n.º 2
0
void nofGeologist::LostWork()
{
    flag = 0;

    switch(state)
    {
        default: break;
            // Wenn wir noch hingehen, dann zurückgehen
        case STATE_FIGUREWORK:
        {
            GoHome();
        } break;
        case STATE_GOTOFLAG:
        {
            // dann sofort rumirren, wenn wir zur Flagge gehen
            StartWandering();
            state = STATE_FIGUREWORK;
        } break;
        case STATE_GEOLOGIST_GOTONEXTNODE:
        case STATE_GEOLOGIST_DIG:
        case STATE_GEOLOGIST_CHEER:
        {
            gwg->GetNode(node_goal).reserved = false;;
        } break;
    }
}
Ejemplo n.º 3
0
void nofPlaner::Walked()
{
    /// Zur Baustelle zurückgelaufen? (=fertig)
    if(pos == building_site->GetPos())
    {
        // Baustelle Bescheid sagen
        building_site->PlaningFinished();

        state = STATE_FIGUREWORK;

        // Nach Hause laufen bzw. auch rumirren
        rs_pos = 0;
        rs_dir = true;
        cur_rs = gwg->GetSpecObj<noRoadNode>(pos)->routes[4];
        building_site = 0;

        GoHome();
        StartWalking(4);
    }
    else
    {
        /// Anfangen zu arbeiten
        current_ev = em->AddEvent(this, JOB_CONSTS[JOB_PLANER].work_length, 1);
        state = STATE_PLANING;
    }
}
Ejemplo n.º 4
0
void Hormiga::move()
{
	switch (state)
   {
   case kNoBorn:
	   break;
   case kForage:
//	   printf("antes kForage\n");
	   Forage();
//	   printf("despues kForage\n");
	   break;
   case kGoHome:
//	   printf("antes kGoHome\n");
	   GoHome();
//	   printf("despues kGoHome\n");
	   break;
   case kThirsty:
//	   printf("antes kThirsty\n");
	   Thirsty();
//	   printf("despues kThirsty\n");
	   break;
   default:
	   break;

   }
}
Ejemplo n.º 5
0
TQErrCode CMotorsBase::MoveHome(TMotorAxis Axis)
{
   if(Axis==AXIS_ALL)
      return HomeAll();

   return GoHome(Axis);
}
Ejemplo n.º 6
0
void nofPassiveSoldier::LeaveBuilding()
{
    // Nach Hause in ein Lagerhaus gehen
    rs_dir = true;
    rs_pos = 1;
    cur_rs = building->routes[4];
    GoHome();

    building = 0;
}
Ejemplo n.º 7
0
/// Geht wieder zurück zur Flagge und dann nach Hause
void nofFlagWorker::GoToFlag()
{
    // Zur Flagge zurücklaufen

    // Bin ich an der Fahne?
    if(pos == flag->GetPos())
    {
        // nach Hause gehen
        nobBaseWarehouse* wh = gwg->GetPlayer(player).FindWarehouse(*flag, FW::AcceptsFigure(job_), true, false);
        if(wh)
        {
            GoHome(wh);
            // Vorgaukeln, dass wir ein Stück Straße bereits geschafft haben
            // damit wir mit WalkToGoal weiter bis zum Ziel laufen können
            cur_rs = &emulated_wanderroad;
            rs_pos = 0;
            WalkToGoal();
        }
        else
        {
            // Weg führt nicht mehr zum Lagerhaus, dann rumirren
            StartWandering();
            Wander();
        }


        // Da wir quasi "freiwillig" nach Hause gegangen sind ohne das Abreißen der Flagge, auch manuell wieder
        // "abmelden"
        gwg->GetPlayer(player).RemoveFlagWorker(this);
        state = STATE_FIGUREWORK;
        flag = NULL;
    }
    else
    {
        // Weg suchen
        unsigned char dir = gwg->FindHumanPath(pos, flag->GetPos(), 40);

        // Wenns keinen gibt, rumirren, ansonsten hinlaufen
        if(dir == 0xFF)
        {
            Abrogate();
            StartWandering();
            Wander();
            state = STATE_FIGUREWORK;

            flag = NULL;
        }
        else
        {
            StartWalking(dir);
        }
    }
}
Ejemplo n.º 8
0
void CBCGPIE7DemoView::OnInitialUpdate() 
{
	CHtmlView::OnInitialUpdate ();

	m_nFontSize = 2l;

	SetOffline (m_bWorkOffline);

	if (m_bGoAddress)
	{
		GoHome();
	}
}
Ejemplo n.º 9
0
void CMfcieView::OnInitialUpdate()
{
	// Go to the home page initially
	CHtmlView::OnInitialUpdate();
	CString strCmdLine(AfxGetApp()->m_lpCmdLine);
	if(strCmdLine == _T(""))
	{
		GoHome();
	}
	else
	{
		Navigate(strCmdLine);
	}
}
Ejemplo n.º 10
0
void nofBuilder::LostWork()
{
    building_site = NULL;

    if(state == STATE_FIGUREWORK)
        GoHome();
    else
    {
        // Event abmelden
        em->RemoveEvent(current_ev);

        StartWandering();
        Wander();
        state = STATE_FIGUREWORK;
    }
}
Ejemplo n.º 11
0
void nofScout_Free::LostWork()
{
    flag = 0;

    switch(state)
    {
        default: break;
            // Wenn wir noch hingehen, dann zurückgehen
        case STATE_FIGUREWORK:
        {
            GoHome();
        } break;
        case STATE_GOTOFLAG:
        case STATE_SCOUT_SCOUTING:
        {
            // dann sofort rumirren, wenn wir zur Flagge gehen
            StartWandering();
            state = STATE_FIGUREWORK;
        } break;
    }
}
Ejemplo n.º 12
0
void nofGeologist::LostWork()
{
    flag = nullptr;

    switch(state)
    {
        default:
            break;
        // Wenn wir noch hingehen, dann zurückgehen
        case STATE_FIGUREWORK: { GoHome();
        }
        break;
        case STATE_GOTOFLAG:
        {
            // dann sofort rumirren, wenn wir zur Flagge gehen
            StartWandering();
            state = STATE_FIGUREWORK;
        }
        break;
    }
}
Ejemplo n.º 13
0
// Goes to home position (without interrupt), then lowers the build platform to
// the PDMS in order to calibrate and/or start a print
bool Motor::GoToStartPosition()
{
    EnableMotors();
    
    GoHome(false);
    
    std::vector<MotorCommand> commands;
    
    // set rotation parameters
    commands.push_back(MotorCommand(MC_ROT_SETTINGS_REG, MC_JERK, 
                                    _settings.GetInt(R_START_PRINT_JERK)));
    commands.push_back(MotorCommand(MC_ROT_SETTINGS_REG, MC_SPEED, 
                   R_SPEED_FACTOR * _settings.GetInt(R_START_PRINT_SPEED)));
      
    int startAngle = _settings.GetInt(R_START_PRINT_ANGLE) / R_SCALE_FACTOR;
    if (startAngle != 0)
    {
        // rotate to the start position
        commands.push_back(MotorCommand(MC_ROT_ACTION_REG, MC_MOVE, 
                                                                startAngle));
    }
    
    // set Z motion parameters
    commands.push_back(MotorCommand(MC_Z_SETTINGS_REG, MC_JERK,
                                    _settings.GetInt(Z_START_PRINT_JERK)));
    commands.push_back(MotorCommand(MC_Z_SETTINGS_REG, MC_SPEED,
                   Z_SPEED_FACTOR * _settings.GetInt(Z_START_PRINT_SPEED)));

    // move down to the PDMS
    commands.push_back(MotorCommand(MC_Z_ACTION_REG, MC_MOVE, 
                                    _settings.GetInt(Z_START_PRINT_POSITION)));
    
    // request an interrupt when these commands are completed
    commands.push_back(MotorCommand(MC_GENERAL_REG, MC_INTERRUPT));
    
    return SendCommands(commands);
}
Ejemplo n.º 14
0
TQErrCode CMotorsDummy::GoHome (TMotorAxis Axis,bool IgnoreBumperImpact)
{
   long EndPosition =0;
   CQLog::Write(LOG_TAG_MOTORS,"Home: %s",PrintAxis(Axis).c_str());

   if(m_ParamsMgr->AllowEmulationDelay)
      QSleepSec(1);

   if(Axis==AXIS_ALL)
   {
      for(int i=AXIS_X;i<MAX_AXIS;i++)
         GoHome(static_cast<TMotorAxis>(i),IgnoreBumperImpact);
   }
   else
   {
      AxisUnderMovement[Axis] = true;
      UpdateAxisLocation(Axis,0L);
      UpdateAxisHomePerformed(Axis,true);
      m_LastSolicitedPositions[Axis] = GetAxisSolicitedLocation(Axis);
      KeepAxisSolicitedLocation(Axis,EndPosition);
      FrontEndInterface->UpdateStatus(FE_CURRENT_X_AXIS_POSITION+Axis,(int)EndPosition);
   }
   return Q_NO_ERROR;
}
Ejemplo n.º 15
0
void nofPlaner::LostWork()
{
    building_site = 0;

    if(state == STATE_FIGUREWORK)
        GoHome();
    else
    {
        // Event ggf. abmelden
        if(state == STATE_PLANING)
        {
            em->RemoveEvent(current_ev);
            /// Sounds abmelden
            SOUNDMANAGER.WorkingFinished(this);
        }

        StartWandering();
        // wenn wir schon laufen, nicht nochmal laufen!
        if(state != STATE_WALKING)
            Wander();

        state = STATE_FIGUREWORK;
    }
}
//------------------------------------------------------------------------------
void main(void)
{
 
  WDTCTL = WDTPW+WDTHOLD;                   // Stop watchdog timer
  FCTL2 = FWKEY + FSSEL0 + FN0;             // MCLK/2 for Flash Timing Generator

  read_flash_segA();

  Rs232_Init();                             //  RS232 初始化      115200   P3  
  TDCM3_Init();                             //  電子羅盤 初始化
  
  P4DIR = 0xff;                             // Set P4. to output direction 
  P4OUT = 0;

  WDT_flag = true;
  TBCTL = TBSSEL_2 + MC_1;                  // SCLK, up-down mode  PWM timeClock
  
  AD_Init();
 
  WDTCTL = WDT_ARST_1000;                   //--開狗
  
  CloseMotorPower();                        //----開電測試系統  
  
     // TimerA 啟動讀秒
      TACCTL0 = CCIE;                             // CCR0 interrupt enabled
      TACCR0 = 16384-1;                           // for 0.5 Hz
      TACTL = TASSEL_1 + MC_1;                    // ACLK, contmode  

    //     _BIS_SR(GIE);    

     Setting_mode = true;
     long int cou_delay;     
     
     while(Setting_mode){                      //---- setting mode
     
               if(Set_OriginX_flag){
                Set_OriginX_flag = 0;
                OpenMotorPower();
                cou_delay = (long int)motor_T_AD * 1150; //       delay
                while(cou_delay > 0){ cou_delay--;}       
                DoTheAd(AD_AVGtime,1);  
                CloseMotorPower();
                Set_OriginX =  (int)(Angle_X*100);
                write_flash_segA();
              }
              if(Set_OriginY_flag){
                Set_OriginY_flag = 0;
                OpenMotorPower();
                cou_delay = (long int)motor_T_AD * 1150; //       delay
                while(cou_delay > 0){ cou_delay--;}       
                DoTheAd(AD_AVGtime,1);  
                CloseMotorPower();
                Set_OriginY =  (int)(Angle_Y*100);
                write_flash_segA();
              }

           _BIS_SR(LPM0_bits + GIE);    
     
     }
      
  IE2 &= ~URXIE1 ;                           // Disable USART1 RX interrupt
          ReStart_Sec +=  ((unsigned long int)ReStart_Day * 3600);  //--
 //         ReStart_Sec +=  ((unsigned long int)ReStart_Day * 60);  //--  每隔分鐘數
  PwmSet();
  
int testRun = 0;
   Leveling = true;
while(1)          //-------------- working mode
  {
                           
    if(Leveling){  
      
      
       WDTCTL = WDTPW+WDTHOLD;                       // Stop watchdog timer
       TACCTL0 &= ~CCIE;                             // close timer
       
       
       Leveling = false;
       outPutcount = false;
       
       //TDCM3_Enable();

         testRun++;
           sprintf(string,"this is %02d time   \r\n",testRun); UART1_SendStr(string);
        
      OpenMotorPower();       //----開電  
      WDTCTL = WDTPW+WDTHOLD;                       // Stop watchdog timer
      
                long int cou = (long int)motor_T_AD * 1150; //    100Hz   delay
                while(cou > 0){       cou--;   }       
                
      GoToRange_V2();
      GoHome();
     
      CloseMotorPower();      //----關電  
        outPutcount = true;
        
        TACCTL0 |= CCIE;                             // open timer
        
    }


    _BIS_SR(LPM0_bits + GIE);                 // Enter LPM0, Enable interrupts
 
    
    
      
  }
  
    
    
  
}
Ejemplo n.º 17
0
void nofPassiveSoldier::NotNeeded()
{
    building = 0;
    GoHome();
}
Ejemplo n.º 18
0
static void     FileMenuItem( a_window *wnd, gui_ctl_id id, int row, int piece )
{
    address     addr;
    mod_handle  mod;
    bool        has_addr;
    bool        has_popitem;
    file_window *file = WndFile( wnd );

    piece=piece;
    addr = GetRowAddr( file, row, id != MENU_FILE_ASSEMBLY );
    has_addr = !IS_NIL_ADDR( addr );
    switch( id ) {
    case MENU_INITIALIZE:
        has_popitem = ( *WndPopItem( wnd ) != NULLCHAR );
        if( has_popitem && !ScanSelectedExpr( WndPopItem( wnd ) ) ) {
            has_popitem = false;
        }
        WndMenuEnable( wnd, MENU_FILE_SHOW, true );
        WndMenuEnable( wnd, MENU_FILE_SHOW_ADDRESS, true );
        WndMenuEnable( wnd, MENU_FILE_SHOW_MODULE, true );
        WndMenuEnable( wnd, MENU_FILE_FUNCTIONS, file->mod != NO_MOD );
        WndMenuEnable( wnd, MENU_FILE_HOME, true );
        addr = GetRowAddr( file, row, false );
        WndMenuEnable( wnd, MENU_FILE_ASSEMBLY, !IS_NIL_ADDR( addr ) );
        WndMenuEnable( wnd, MENU_FILE_WATCH, has_popitem );
        WndMenuEnable( wnd, MENU_FILE_INSPECT, has_popitem );
        WndMenuEnable( wnd, MENU_FILE_STEP_INTO, file->mod != NO_MOD && has_popitem );
        WndMenuEnable( wnd, MENU_FILE_BREAK, has_popitem );
        WndMenuEnable( wnd, MENU_FILE_RUN, has_addr );
        WndMenuEnable( wnd, MENU_FILE_SKIP_TO_CURSOR, has_addr );
        break;
    case MENU_FILE_RUN:
        GoToAddr( addr );
        break;
    case MENU_FILE_SKIP_TO_CURSOR:
        SkipToAddr( addr );
        break;
    case MENU_FILE_BREAK:
        BreakOnSelected( WndPopItem( wnd ) );
        break;
    case MENU_FILE_HOME:
        GoHome();
        break;
    case MENU_FILE_SHOW_MODULE:
        mod = file->mod;
        if( DlgModName( LIT_DUI( New_Module ), &mod ) ) {
            WndModInspect( mod );
        }
        break;
    case MENU_FILE_SHOW_ADDRESS:
        if( DlgCodeAddr( LIT_DUI( New_Addr ), &addr ) ) {
            WndSrcInspect( addr );
        }
        break;
    case MENU_FILE_STEP_INTO:
        StepIntoFunction( WndPopItem( wnd ) );
        break;
    case MENU_FILE_INSPECT:
        WndInspect( WndPopItem( wnd ) );
        break;
    case MENU_FILE_WATCH:
        WndVarInspect( WndPopItem( wnd ) );
        break;
    case MENU_FILE_SEARCH:
        WndSaveToHistory( SrchHistory, WndPopItem( wnd ) );
        DbgWndSearch( wnd, false, DlgSearch( wnd, SrchHistory ) );
        break;
    case MENU_FILE_ASSEMBLY:
        AsmWndFind( file->asw, addr, file->track );
        break;
    case MENU_FILE_LINE:
        GotoLine( wnd );
        break;
    case MENU_FILE_FUNCTIONS:
        WndFuncInspect( file->mod );
        break;
    }
}
Ejemplo n.º 19
0
void CBCGPIE7DemoView::OnGoHomePage()
{
	GoHome();
}
Ejemplo n.º 20
0
void nofBuildingWorker::LostWork()
{
    switch(state)
    {
        default:
            break;
        case STATE_FIGUREWORK:
        {
            // Auf Wegen nach Hause gehen
            GoHome();
        } break;
        case STATE_WAITING1:
        case STATE_WAITING2:
        case STATE_WORK:
        case STATE_WAITINGFORWARES_OR_PRODUCTIONSTOPPED:
        case STATE_WAITFORWARESPACE:
        case STATE_HUNTER_SHOOTING:
        case STATE_HUNTER_EVISCERATING:
        case STATE_CATAPULT_TARGETBUILDING:
        case STATE_CATAPULT_BACKOFF:
        {
            // Bisheriges Event abmelden, da die Arbeit unterbrochen wird
            if(state != STATE_WAITINGFORWARES_OR_PRODUCTIONSTOPPED && state != STATE_WAITFORWARESPACE)
            {
                em->RemoveEvent(current_ev);
                current_ev = 0;
            }

            // Bescheid sagen, dass Arbeit abgebrochen wurde
            WorkAborted();

            // Rumirren
            StartWandering();
            Wander();


            // Evtl. Sounds löschen
            SOUNDMANAGER.WorkingFinished(this);

            state = STATE_FIGUREWORK;

        } break;
        case STATE_ENTERBUILDING:
        case STATE_CARRYOUTWARE:
        case STATE_WALKTOWORKPOINT:
        case STATE_WALKINGHOME:
        case STATE_HUNTER_CHASING:
        case STATE_HUNTER_FINDINGSHOOTINGPOINT:
        case STATE_HUNTER_WALKINGTOCADAVER:
        {
            // Bescheid sagen, dass Arbeit abgebrochen wurde
            WorkAborted();

            // Rumirren
            // Bei diesen States läuft man schon, darf also nicht noch zusätzlich Wander aufrufen, da man dann ja im Laufen nochmal losläuft!
            StartWandering();

            // Evtl. Sounds löschen
            SOUNDMANAGER.WorkingFinished(this);

            state = STATE_FIGUREWORK;
        } break;

    }

    workplace = 0;
}
Ejemplo n.º 21
0
void CIEDemoView::OnInitialUpdate() 
{
	GoHome();
}
Ejemplo n.º 22
0
void CIEDemoView::OnGoStartPage()
{
	GoHome();
}
Ejemplo n.º 23
0
void CMfcieView::OnGoStartPage()
{
	GoHome();
}
Ejemplo n.º 24
0
/**
 *
 *
 *  @author OLiver
 */
void nofCarrier::LostWork()
{
    workplace = 0;
    em->RemoveEvent(productivity_ev);
    productivity_ev = 0;

    if(state == CARRS_FIGUREWORK)
        GoHome();
    else
    {
        // Wenn ich noch ne Ware in der Hand habe, muss die gelöscht werden
        if(carried_ware)
        {
            carried_ware->WareLost(player);
            delete carried_ware;
            carried_ware = 0;
        }

        // Is this a boat carrier (i.e. he is on the water)
        if(ct == CT_BOAT)
        {
            MapPoint tmpPos(pos);
            if(state != CARRS_WAITFORWARE && state != CARRS_WAITFORWARESPACE)
            {
                // If we are walking choose the destination point as start point
                // for the pathfinding!
                tmpPos = gwg->GetNeighbour(tmpPos, GetCurMoveDir());
            }

            // Look for the shore
            for(MapCoord tx = gwg->GetXA(tmpPos, 0), r = 1; r <= 5; tx = gwg->GetXA(tx, tmpPos.y, 0), ++r)
            {

                MapPoint t2(tx, tmpPos.y);
                for(unsigned i = 2; i < 8; ++i)
                {
                    for(MapCoord r2 = 0; r2 < r; t2 = gwg->GetNeighbour(t2,  i % 6), ++r2)
                    {
                        if(gwg->IsCoastalPoint(t2) && gwg->IsNodeForFigures(t2))
                        {
                            shore_path = new std::vector<unsigned char>;
                            if(gwg->FindShipPath(tmpPos, t2, shore_path, NULL))
                            {
                                // Ok let's paddle to the coast
                                rs_pos = 0;
                                cur_rs = NULL;
                                if(state == CARRS_WAITFORWARE || state == CARRS_WAITFORWARESPACE)
                                    WanderOnWater();
                                state = CARRS_BOATCARRIER_WANDERONWATER;
                                return;
                            }
                        }
                    }
                }
            }
        }

        StartWandering();
        if(state == CARRS_WAITFORWARE || state == CARRS_WAITFORWARESPACE)
            Wander();
    }
    state = CARRS_FIGUREWORK;
}
Ejemplo n.º 25
0
void nofBuilder::HandleDerivedEvent(const unsigned int id)
{
    switch(state)
    {
        case STATE_WAITINGFREEWALK:
        {
            // Platz einnehmen
            rel_x = next_rel_x;
            rel_y = next_rel_y;

            // Ware aufnehmen, falls es eine gibt
            if(ChooseWare())
                state = STATE_BUILDFREEWALK;

            // Weiter drumrumlaufen
            StartFreewalk();
        } break;
        case STATE_BUILDFREEWALK:
        {
            // Platz einnehmen
            rel_x = next_rel_x;
            rel_y = next_rel_y;

            // Gibts noch was zu bauen?
            if(building_steps_available)
            {
                // dann mal schön bauen
                current_ev = em->AddEvent(this, 40, 1);
                state = STATE_BUILD;
            }
            else if(building_site->IsBuildingComplete())
            {
                // fertig mit Bauen!

                // Baustelle abreißen und Gebäude hinsetzen

                // Gebäudetyp merken und das Volk des Gebäudes
                BuildingType building_type = building_site->GetBuildingType();
                Nation building_nation = building_site->GetNation();

                state = STATE_FIGUREWORK;

                // Baustelle abmelden
                GameClientPlayer& owner = gwg->GetPlayer(player);
                owner.RemoveBuildingSite(building_site);

                // ggf. Baustellenfenster schließen
                gwg->ImportantObjectDestroyed(building_site->GetPos());

                // Baustelle kommt in den Bytehimmel
                gwg->SetNO(NULL, building_site->GetPos());
                delete building_site;

                // KI-Event schicken
                GAMECLIENT.SendAIEvent(new AIEvent::Building(AIEvent::BuildingFinished, pos, building_type), player);

                noBuilding* bld = BuildingFactory::CreateBuilding(gwg, building_type, pos, player, building_nation);

                // Special handling for storehouses and harbours
                if(building_type == BLD_STOREHOUSE || building_type == BLD_HARBORBUILDING){
                    nobBaseWarehouse* wh = static_cast<nobBaseWarehouse*>(bld);
                    // Mich dort gleich einquartieren und nicht erst zurücklaufen
                    wh->AddFigure(this);
                    gwg->RemoveFigure(this, pos);

                    // Evtl Träger aus dem HQ wieder verwenden
                    owner.FindWarehouseForAllRoads();
                    owner.FindWarehouseForAllJobs(JOB_HELPER);

                    // Evtl gabs verlorene Waren, die jetzt in das HQ wieder reinkönnen
                    owner.FindClientForLostWares();

                    return;
                }

                // Nach Hause laufen bzw. auch rumirren
                rs_pos = 0;
                rs_dir = true;
                cur_rs = gwg->GetSpecObj<noRoadNode>(pos)->routes[4];
                building_site = 0;

                GoHome();
                StartWalking(4);

            }
            else
            {
                // Brauchen neues Material

                // Ware aufnehmen, falls es eine gibt
                if(!ChooseWare())
                    state = STATE_WAITINGFREEWALK;

                // Weiter drumrumlaufen
                StartFreewalk();
            }

        } break;
        case STATE_BUILD:
        {
            // Sounds abmelden
            SOUNDMANAGER.WorkingFinished(this);

            // ein Bauschritt weniger, Haus um eins höher
            --building_steps_available;
            ++building_site->build_progress;
            // Fertig mit dem Bauschritt, dann an nächste Position gehen
            state = STATE_BUILDFREEWALK;
            StartFreewalk();
        } break;
        default: break;
    }
}
Ejemplo n.º 26
0
void noFigure::WalkToGoal()
{
    // Kein Ziel mehr --> Rumirren
    if(!goal_)
    {
        StartWandering();
        Wander();
        return;
    }

    // Straße abgelaufen oder noch gar keine Straße vorhanden?
    if(((cur_rs) ? (rs_pos == cur_rs->GetLength()) : true))
    {
        // Ziel erreicht?
        // Bei dem Träger können das beide Flaggen sein!
        MapPoint goal1, goal2;
        if(GetGOT() == GOT_NOF_CARRIER && fs == FS_GOTOGOAL)
        {
            goal1 = static_cast<nofCarrier*>(this)->GetFirstFlag() ?
                static_cast<nofCarrier*>(this)->GetFirstFlag()->GetPos() : MapPoint(0xFFFF, 0xFFFF);
            goal2 = static_cast<nofCarrier*>(this)->GetSecondFlag() ?
                static_cast<nofCarrier*>(this)->GetSecondFlag()->GetPos() : MapPoint(0xFFFF, 0xFFFF);
        }
        else
        {
            goal1 = goal_->GetPos();
            goal2 = MapPoint(0xFFFF, 0xFFFF);
        }

        if(goal1 == pos || goal2 == pos)
        {
            if(fs == FS_GOHOME)
            {
                // Mann im Lagerhaus angekommen
                gwg->RemoveFigure(this, pos);
                static_cast<nobBaseWarehouse*>(goal_)->AddFigure(this);
            }
            else
            {
                // Zeug nullen
                cur_rs = NULL;
                rs_dir = 0;
                rs_pos = 0;
                goal_ = NULL;


                // abgeleiteter Klasse sagen, dass das Ziel erreicht wurde
                fs = FS_JOB;
                GoalReached();
            }

        }
        else
        {
            MapPoint next_harbor;
            // Neuen Weg berechnen
            unsigned char route = gwg->FindHumanPathOnRoads(gwg->GetSpecObj<noRoadNode>(pos), goal_, NULL, &next_harbor);
            // Kein Weg zum Ziel... nächstes Lagerhaus suchen
            if(route == 0xFF)
            {
                // Arbeisplatz oder Laghaus Bescheid sagen
                Abrogate();
                // Wir gehen jetzt nach Hause
                GoHome();
                // Evtl wurde kein Lagerhaus gefunden und wir sollen rumirren, dann tun wir das gleich
                if(fs == FS_WANDER)
                {
                    Wander();
                    return;
                }

                // Nach Hause laufen...
                WalkToGoal();
                return;
            }
            // Oder müssen wir das Schiff nehmen?
            else if(route == SHIP_DIR)
            {
                // Uns in den Hafen einquartieren
                noBase* nob;
                if((nob = gwg->GetNO(pos))->GetGOT() != GOT_NOB_HARBORBUILDING)
                {
                    // Es gibt keinen Hafen mehr -> nach Hause gehen

                    // Arbeisplatz oder Laghaus Bescheid sagen
                    Abrogate();
                    // Wir gehen jetzt nach Hause
                    GoHome();
                    // Evtl wurde kein Lagerhaus gefunden und wir sollen rumirren, dann tun wir das gleich
                    if(fs == FS_WANDER)
                    {
                        Wander();
                        return;
                    }

                    // Nach Hause laufen...
                    WalkToGoal();
                    return;
                }

                // Uns in den Hafen einquartieren
                cur_rs = NULL; // wir laufen nicht mehr auf einer Straße
                gwg->RemoveFigure(this, pos);
                static_cast<nobHarborBuilding*>(nob)->AddFigureForShip(this, next_harbor);

                return;
            }


            // Nächste Straße wollen, auf der man geht
            cur_rs = gwg->GetSpecObj<noRoadNode>(pos)->routes[route];
            StartWalking(route);
            rs_pos = 0;
            rs_dir = (gwg->GetSpecObj<noRoadNode>(pos) == cur_rs->GetF1()) ? false : true;
        }

    }
    else
    {
        StartWalking(cur_rs->GetDir(rs_dir, rs_pos));
    }
}
Ejemplo n.º 27
0
void CWebView::OnGoHome() 
{
	GoHome();	
}
Ejemplo n.º 28
0
TQErrCode CMotorsBase::HomeAll(void)
{
   return GoHome(AXIS_ALL);
}