当前位置: 首页>>代码示例>>C++>>正文


C++ ZObject::GetOwner方法代码示例

本文整理汇总了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));
	}
}
开发者ID:sebhd,项目名称:zod,代码行数:56,代码来源:zserver_events.cpp

示例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);
	}
}
开发者ID:sebhd,项目名称:zod,代码行数:47,代码来源:zserver_events.cpp

示例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);
}
开发者ID:sebhd,项目名称:zod,代码行数:38,代码来源:zserver_events.cpp

示例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);
		}
}
开发者ID:sebhd,项目名称:zod,代码行数:49,代码来源:zbot.cpp


注:本文中的ZObject::GetOwner方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。