本文整理汇总了C++中ZObject::GetOwner方法的典型用法代码示例。如果您正苦于以下问题:C++ ZObject::GetOwner方法的具体用法?C++ ZObject::GetOwner怎么用?C++ ZObject::GetOwner使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ZObject
的用法示例。
在下文中一共展示了ZObject::GetOwner方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: stop_building_event
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));
}
}
示例2: add_building_queue_event
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);
}
}
示例3: cancel_building_queue_event
void ZServer::cancel_building_queue_event(ZServer *p, char *data, int size, int player) {
cancel_building_queue_packet *pi = (cancel_building_queue_packet*) data;
ZObject *obj;
//good packet?
if (size != sizeof(cancel_building_queue_packet))
return;
obj = p->GetObjectFromID(pi->ref_id, p->object_list);
if (!obj)
return;
//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, "cancel queue error: login required, please type /help", 0, 0, 0);
return;
}
//ignored?
if (p->player_info[player].ignored) {
p->SendNews(player, "cancel queue error: player currently ignored", 0, 0, 0);
return;
}
if (obj->CancelBuildingQueue(pi->list_i, pi->ot, pi->oid))
p->RelayObjectBuildingQueue(obj);
}
示例4:
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);
}
}