int Workwidget::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QWidget::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: SwitchToCompleteWorkSignal(); break; case 1: SwitchToChooseCraftSignal(); break; case 2: SwitchToTimeSecretSignal(); break; case 3: SwitchToSensorSecretSignal(); break; case 4: SwitchToParaSecretSignal(); break; case 5: SwitchToSysEleSecretSignal(); break; case 6: ShutDownSignal(); break; case 7: SwitchToGThSignal(); break; case 8: UpdateShowSig(); break; case 9: UpdateNetWorkInfoSig(); break; case 10: ShowRecordStateSig(); break; case 11: SwitchToCompleteWorkSlot(); break; case 12: SwitchToChooseCraftSlot(); break; case 13: SwitchToTimeSecretSlot(); break; case 14: SwitchToSensorSecretSlot(); break; case 15: SwitchToParaSecretSlot(); break; case 16: SwitchToSysEleSecretSlot(); break; case 17: ShutDown(); break; case 18: SwitchToGThSecretSlot(); break; case 19: updatetime(); break; case 20: showMenu(); break; case 21: UpdateShowSlot(); break; case 22: TCPState((*reinterpret_cast< bool(*)>(_a[1]))); break; case 23: WorkFinished(); break; case 24: ToWorkWidget(); break; case 25: UpdateNetWorkInfoSlot(); break; case 26: ComIndexChange((*reinterpret_cast< int(*)>(_a[1]))); break; case 27: ShowRecordState(); break; case 28: on_StartWorkBtn_clicked(); break; case 29: on_ManInputBtn_clicked(); break; case 30: on_QuPi_clicked(); break; default: ; } _id -= 31; } return _id; }
void nofFarmhand::HandleDerivedEvent(const unsigned int id) { switch(state) { case STATE_WORK: { // fertig mit Arbeiten --> dann müssen die "Folgen des Arbeitens" ausgeführt werden WorkFinished(); // Objekt wieder freigeben gwg->GetNode(pos).reserved = false; // Wieder nach Hause gehen StartWalkingHome(); // Evtl. Sounds löschen if(was_sounding) { SOUNDMANAGER.WorkingFinished(this); was_sounding = false; } } break; case STATE_WAITING1: { // Fertig mit warten --> anfangen zu arbeiten // Die Arbeitsradien der Berufe wie in JobConst.h (ab JOB_WOODCUTTER!) const unsigned char RADIUS[7] = { 6, 7, 6, 0, 8, 2, 2 }; // Additional radius delta r which is used when a point in radius r was found // I.e. looks till radius r + delta r const unsigned ADD_RADIUS_WHEN_FOUND[7] = { 1, 1, 1, 1, 0, 1, 1}; // Anzahl der Radien, wo wir gültige Punkte gefunden haben unsigned radius_count = 0; // Available points: 1st class and 2st class std::vector< MapPoint > available_points[3]; unsigned max_radius = (job_ == JOB_CHARBURNER) ? 3 : RADIUS[job_ - JOB_WOODCUTTER]; unsigned add_radius_when_found = (job_ == JOB_CHARBURNER) ? 1 : ADD_RADIUS_WHEN_FOUND[job_ - JOB_WOODCUTTER]; bool points_found = false; bool wait = false; for(MapCoord tx = gwg->GetXA(pos, 0), r = 1; r <= max_radius; tx = gwg->GetXA(tx, pos.y, 0), ++r) { // Wurde ein Punkt in diesem Radius gefunden? bool found_in_radius = false; MapPoint t2(tx, pos.y); for(unsigned i = 2; i < 8; ++i) { for(MapCoord r2 = 0; r2 < r; t2 = gwg->GetNeighbour(t2, i % 6), ++r2) { if(IsPointAvailable(t2)) { if (!gwg->GetNode(t2).reserved) { available_points[GetPointQuality(t2) - PQ_CLASS1].push_back(MapPoint(t2)); found_in_radius = true; points_found = true; } else if (job_ == JOB_STONEMASON) { // just wait a little bit longer wait = true; } } } } // Nur die zwei ADD_RADIUS_WHEN_FOUND Radien erst einmal nehmen if(found_in_radius) { if( radius_count++ == add_radius_when_found) break; } } // Are there any objects at all? if(points_found) { // Prefer 1st class objects and use only 2nd class objects if there are no more other objects anymore MapPoint p(0, 0); for(unsigned i = 0; i < 3; ++i) { if(!available_points[i].empty()) { p = available_points[i][RANDOM.Rand(__FILE__, __LINE__, GetObjId(), available_points[i].size())]; break; } } // Als neues Ziel nehmen dest = p; state = STATE_WALKTOWORKPOINT; // Wir arbeiten jetzt workplace->is_working = true; // Punkt für uns reservieren gwg->GetNode(dest).reserved = true;; // Anfangen zu laufen (erstmal aus dem Haus raus!) StartWalking(4); StopNotWorking(); WalkingStarted(); } else if (wait) { // We have to wait, since we do not know whether there are any unreachable or reserved points where there's more to get current_ev = em->AddEvent(this, JOB_CONSTS[job_].wait1_length, 1); StartNotWorking(); } else { if(GAMECLIENT.GetPlayerID() == this->player) { if (!OutOfRessourcesMsgSent) { switch(job_) { case JOB_STONEMASON: GAMECLIENT.SendPostMessage( new ImagePostMsgWithLocation(_("No more stones in range"), PMC_GENERAL, pos, workplace->GetBuildingType(), workplace->GetNation())); OutOfRessourcesMsgSent = true; // Produktivitätsanzeige auf 0 setzen workplace->SetProductivityToZero(); break; case JOB_FISHER: GAMECLIENT.SendPostMessage( new ImagePostMsgWithLocation(_("No more fishes in range"), PMC_GENERAL, pos, workplace->GetBuildingType(), workplace->GetNation())); OutOfRessourcesMsgSent = true; // Produktivitätsanzeige auf 0 setzen workplace->SetProductivityToZero(); break; default: break; } } } // KI-Event erzeugen switch(workplace->GetBuildingType()) { case BLD_WOODCUTTER: case BLD_QUARRY: case BLD_FISHERY: GAMECLIENT.SendAIEvent(new AIEvent::Building(AIEvent::NoMoreResourcesReachable, workplace->GetPos(), workplace->GetBuildingType()), player); break; default: break; } // Weiter warten, vielleicht gibts ja später wieder mal was current_ev = em->AddEvent(this, JOB_CONSTS[job_].wait1_length, 1); StartNotWorking(); } } break; default: break; } }
void nofShipWright::HandleDerivedEvent(const unsigned int id) { switch(state) { case STATE_WAITING1: { // Herausfinden, was der Schiffsbauer als nächstes bauen soll if(dynamic_cast<nobShipYard*>(workplace)->GetMode() == nobShipYard::BOATS) // in Handwerksmanier Boote herstellen nofWorkman::HandleStateWaiting1(); else { // Verfügbare Punkte, die geeignete Plätze darstellen würden std::vector<ShipPoint> available_points; // Wege müssen immer von der Flagge aus berechnet werden MapPoint flagPos = gwg->GetNeighbour(pos, 4); for(MapCoord tx = gwg->GetXA(pos, 0), r = 1; r <= SHIPWRIGHT_RADIUS; tx = gwg->GetXA(tx, pos.y, 0), ++r) { MapPoint t2(tx, pos.y); for(unsigned i = 2; i < 8; ++i) { for(MapCoord r2 = 0; r2 < r; t2 = gwg->GetNeighbour(t2, i % 6), ++r2) { // Besitze ich noch ein Schiff, was gebaut werden muss? noBase* obj = gwg->GetNode(t2).obj; if(!obj) continue; // Schiff? if(obj->GetGOT() == GOT_SHIPBUILDINGSITE) { // Platz noch nicht reserviert und gehört das Schiff auch mir? unsigned char first_dir = 0xFF; if(!gwg->GetNode(pos).reserved && static_cast<noShipBuildingSite*>(obj)->GetPlayer() == player && (first_dir = gwg->FindHumanPath(flagPos, t2, SHIPWRIGHT_WALKING_DISTANCE)) != 0xFF) { available_points.push_back(ShipPoint(t2, first_dir)); } } } } } // Kein Schiff im Bau gefunden? Dann Plätzchen für ein neues Schiff suchen if(available_points.empty()) { for(MapCoord tx = gwg->GetXA(pos, 0), r = 1; r <= SHIPWRIGHT_RADIUS; tx = gwg->GetXA(tx, pos.y, 0), ++r) { MapPoint t2(tx, pos.y); for(unsigned i = 2; i < 8; ++i) { for(MapCoord r2 = 0; r2 < r; t2 = gwg->GetNeighbour(t2, i % 6), ++r2) { // Dieser Punkt geeignet? if(IsPointGood(t2)) { // Weg dorthin finden unsigned char first_dir = gwg->FindHumanPath(flagPos, t2, SHIPWRIGHT_WALKING_DISTANCE); if(first_dir != 0xFF) { available_points.push_back(ShipPoint(t2, first_dir)); } } } } } } // Punkte gefunden? if(!available_points.empty()) { // Einen Punkt zufällig auswählen und dorthin laufen ShipPoint p = available_points[RANDOM.Rand(__FILE__, __LINE__, obj_id, available_points.size())]; dest = p.pos; StartWalkingToShip(p.first_dir); } else { // Nichts zu arbeiten gefunden StartNotWorking(); // Weiter warten, vielleicht gibts ja später wieder mal was current_ev = em->AddEvent(this, JOB_CONSTS[job].wait1_length, 1); } } } break; case STATE_WORK: { // Sind wir an unserem Arbeitsplatz (dem Gebäude), wenn wir die Arbeit beendet haben, bauen wir nur Boote, // ansonsten sind wir an unserem Schiff und bauen große Schiffe if(workplace->GetPos() == pos) // Boote bauen nofWorkman::HandleStateWork(); else { // fertig mit Arbeiten --> dann müssen die "Folgen des Arbeitens" ausgeführt werden WorkFinished(); // Objekt wieder freigeben gwg->GetNode(pos).reserved = false; // Wieder nach Hause gehen StartWalkingHome(); // Evtl. Sounds löschen if(was_sounding) { SOUNDMANAGER.WorkingFinished(this); was_sounding = false; } } } break; case STATE_WAITING2: { // Hier ist die Sache klar, dieser State kann nur bei Handwerkern vorkommen nofWorkman::HandleStateWaiting2(); } break; default: break; } }