Ejemplo n.º 1
0
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));
	}
}
Ejemplo n.º 2
0
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);
	}
}
Ejemplo n.º 3
0
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);
}
Ejemplo n.º 4
0
Archivo: zbot.cpp Proyecto: sebhd/zod
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);
		}
}