void ZServer::stop_building_event(ZServer *p, char *data, int size, int player) { int ref_id; ZObject *obj; //good packet? if (size != sizeof(int)) return; ref_id = *(int*) data; obj = p->GetObjectFromID(ref_id, p->object_list); if (!obj) return; //is this a building that can build? unsigned char ot, oid; obj->GetObjectID(ot, oid); if (ot != BUILDING_OBJECT) return; if (!(oid == FORT_FRONT || oid == FORT_BACK || oid == ROBOT_FACTORY || oid == VEHICLE_FACTORY)) return; //is the team business kosher? if (obj->GetOwner() == NULL_TEAM) return; if (p->player_info[player].team != obj->GetOwner()) return; //logged in? //if(p->psettings.require_login && !p->player_info[player].logged_in) if (p->LoginCheckDenied(player)) { p->SendNews(player, "stop production error: login required, please type /help", 0, 0, 0); return; } //ignored? if (p->player_info[player].ignored) { p->SendNews(player, "stop production error: player currently ignored", 0, 0, 0); return; } //stop it!!! if (obj->StopBuildingProduction()) { //now let us tell everyone the building's new state p->RelayBuildingState(obj); //tell the person who did it computer_msg_packet send_data; send_data.ref_id = obj->GetRefID(); send_data.sound = COMP_MANUFACTURING_CANCELED_SND; p->server_socket.SendMessage(player, COMP_MSG, (char*) &send_data, sizeof(computer_msg_packet)); } }
void ZBot::CollectOurUnits_3(vector<ZObject*> &units_list, vector<ZObject*> &targeted_list) { for (vector<ZObject*>::iterator o = ols.mobile_olist.begin(); o != ols.mobile_olist.end(); o++) if ((*o)->GetOwner() == our_team) { unsigned char ot, oid; (*o)->GetObjectID(ot, oid); //minions can't be given waypoints if (ot == ROBOT_OBJECT && (*o)->IsMinion()) continue; //already got a target? if ((*o)->GetWayPointList().size()) { int ref_id; ZObject *tobj; ref_id = (*o)->GetWayPointList().begin()->ref_id; tobj = this->GetObjectFromID(ref_id); //if we have a target skip this unit //unless it is going to a flag we own if (tobj) { unsigned char tot, toid; tobj->GetObjectID(tot, toid); if (tot == MAP_ITEM_OBJECT && toid == FLAG_ITEM) { if (tobj->GetOwner() != our_team) { targeted_list.push_back(tobj); continue; } } else { //do not flag a repair station as "targeted" //(and therefor to be possibly ignored) if (!(tot == BUILDING_OBJECT && toid == REPAIR)) targeted_list.push_back(tobj); continue; } } //if this is a dodge wp then let the unit be if ((*o)->GetWayPointList().begin()->mode == DODGE_WP) continue; } units_list.push_back(*o); } }
void ZBot::add_new_object_event(char *data, int size, int dummy) { ZObject *obj = ProcessNewObject(data, size); if (!obj) return; //add to short flag list? unsigned char ot, oid; obj->GetObjectID(ot, oid); if (ot == MAP_ITEM_OBJECT) { if (oid == FLAG_ITEM || oid == GRENADES_ITEM) flag_object_list.push_back(obj); else { //we don't care about the rest of the map object garbage ols.DeleteObject(obj); } } }
bool ZCore::CheckWaypoint(ZObject *obj, waypoint *wp) { unsigned char ot, oid; unsigned char aot, aoid; ZObject *aobj; obj->GetObjectID(ot, oid); //just set this to false if //the unit can not attack if(!obj->CanAttack()) wp->attack_to = false; switch(wp->mode) { case MOVE_WP: //can move? if(!obj->CanMove()) return false; break; case FORCE_MOVE_WP: //can move? if(!obj->CanMove()) return false; //clients are not allowed to set forcemove waypoints wp->mode = MOVE_WP; break; case DODGE_WP: //can move? if(!obj->CanMove()) return false; //clients are not allowed to set dodge waypoints wp->mode = MOVE_WP; case AGRO_WP: //clients are not allowed to set agro waypoints wp->mode = ATTACK_WP; break; case ATTACK_WP: //attacking an object that can only be attacked by explosions? aobj = GetObjectFromID(wp->ref_id, object_list); if(!aobj) return false; if(!obj->CanAttackObject(aobj)) return false; //if(!obj->HasExplosives() && aobj->AttackedOnlyByExplosives()) return false; //if(!obj->CanAttack()) return false; break; case ENTER_WP: //can move? if(!obj->CanMove()) return false; //entering ok? if(ot != ROBOT_OBJECT) return false; //target exist? aobj = GetObjectFromID(wp->ref_id, object_list); if(!aobj) return false; //can the target be entered? if(!aobj->CanBeEntered()) return false; break; case CRANE_REPAIR_WP: //can move? if(!obj->CanMove()) return false; //it a crane? if(!(ot == VEHICLE_OBJECT && oid == CRANE)) return false; //target exist? aobj = GetObjectFromID(wp->ref_id, object_list); if(!aobj) return false; //can it repair that target? if(!aobj->CanBeRepairedByCrane(obj->GetOwner())) return false; break; case UNIT_REPAIR_WP: //can move? if(!obj->CanMove()) return false; //can it be repaired? if(!obj->CanBeRepaired()) return false; //target exist? aobj = GetObjectFromID(wp->ref_id, object_list); if(!aobj) return false; //can the target repair it? if(!aobj->CanRepairUnit(obj->GetOwner())) return false; break; case ENTER_FORT_WP: //can move? if(!obj->CanMove()) return false; //target exist? aobj = GetObjectFromID(wp->ref_id, object_list); if(!aobj) return false; //can we enter it? if(!aobj->CanEnterFort(obj->GetOwner())) return false; break; case PICKUP_GRENADES_WP: //can move? if(!obj->CanMove()) return false; //can pickup grenades? if(!obj->CanPickupGrenades()) return false; //target exist? aobj = GetObjectFromID(wp->ref_id, object_list); if(!aobj) return false; //is it grenades? aobj->GetObjectID(aot, aoid); if(!(aot == MAP_ITEM_OBJECT && aoid == GRENADES_ITEM)) return false; break; } //bad mode? if(wp->mode < 0 || wp->mode >= MAX_WAYPOINT_MODES) return false; //should be good return true; }