void ZServer::replace_building_event(ZServer *p, char *data, int size, int player) { start_building_packet *pi = (start_building_packet*) data; ZObject *obj; //good packet? if (size != sizeof(start_building_packet)) return; obj = p->GetObjectFromID(pi->ref_id, p->object_list); if (!obj) return; //is this a building that can build? if (!obj->ProducesUnits()) return; //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, "start production error: login required, please type /help", 0, 0, 0); return; } //ignored? if (p->player_info[player].ignored) { p->SendNews(player, "start production error: player currently ignored", 0, 0, 0); return; } // Cancel current production: obj->StopBuildingProduction(); //ok it is a building that can build so lets set its new production if (obj->SetBuildingProduction(pi->ot, pi->oid)) { //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_STARTING_MANUFACTURE_SND; p->server_socket.SendMessage(player, COMP_MSG, (char*) &send_data, sizeof(computer_msg_packet)); } }
void ZServer::add_building_queue_event(ZServer *p, char *data, int size, int player) { add_building_queue_packet *pi = (add_building_queue_packet*) data; ZObject *obj; //good packet? if (size != sizeof(add_building_queue_packet)) return; obj = p->GetObjectFromID(pi->ref_id, p->object_list); if (!obj) return; //printf("add queue %d %d\n", pi->ot, pi->oid); //is the team business kosher? if (obj->GetOwner() == NULL_TEAM) return; if (p->player_info[player].team != obj->GetOwner()) return; //produces units? if (!obj->ProducesUnits()) return; //logged in? if (p->LoginCheckDenied(player)) { p->SendNews(player, "add queue error: login required, please type /help", 0, 0, 0); return; } //ignored? if (p->player_info[player].ignored) { p->SendNews(player, "add queue error: player currently ignored", 0, 0, 0); return; } //are we starting production or adding to the queue? unsigned char bot, boid; if (obj->GetBuildUnit(bot, boid) && bot == (unsigned char) -1 && boid == (unsigned char) -1) { if (obj->SetBuildingProduction(pi->ot, pi->oid)) p->RelayBuildingState(obj); } else { if (obj->AddBuildingQueue(pi->ot, pi->oid)) p->RelayObjectBuildingQueue(obj); } }