Exemplo n.º 1
0
void ZoneServer::ProcessServerOP_GMGoto(ServerPacket* pack)
{
	if (pack->size != sizeof(ServerGMGoto_Struct)) 
	{
		cout << "Wrong size on ServerOP_GMGoto. Got: " << pack->size << ", Expected: " << sizeof(ServerGMGoto_Struct) << endl;
		return;
	}
	ServerGMGoto_Struct* gmg = (ServerGMGoto_Struct*) pack->pBuffer;
	ClientListEntry* cle = zoneserver_list.FindCharacter(gmg->gotoname);
	if (cle != 0) 
	{
		if (cle->Server() == 0)
		{
			this->SendEmoteMessage(gmg->myname, 0, 13, "Error: Cannot identify %s's zoneserver.", gmg->gotoname);
		}
		else if (cle->Anon() == 1 && cle->Admin() > gmg->admin) // no snooping for anon GMs
		{
			this->SendEmoteMessage(gmg->myname, 0, 13, "Error: %s not found", gmg->gotoname);
		}
		else
		{
			cle->Server()->SendPacket(pack);
		}
	}
	else 
	{
		this->SendEmoteMessage(gmg->myname, 0, 13, "Error: %s not found", gmg->gotoname);
	}
}
Exemplo n.º 2
0
bool ClientList::SendPacket(const char* to, ServerPacket* pack) {
	if (to == 0 || to[0] == 0) {
		zoneserver_list.SendPacket(pack);
		return true;
	}
	else if (to[0] == '*') {
		// Cant send a packet to a console....
		return false;
	}
	else {
		ClientListEntry* cle = FindCharacter(to);
		if (cle != nullptr) {
			if (cle->Server() != nullptr) {
				cle->Server()->SendPacket(pack);
				return true;
			}
			return false;
		} else {
			ZoneServer* zs = zoneserver_list.FindByName(to);
			if (zs != nullptr) {
				zs->SendPacket(pack);
				return true;
			}
			return false;
		}
	}
	return false;
}
Exemplo n.º 3
0
void ClientList::ClientUpdate(ZoneServer* zoneserver, ServerClientList_Struct* scl) {
	LinkedListIterator<ClientListEntry*> iterator(clientlist);
	ClientListEntry* cle;
	iterator.Reset();
	while(iterator.MoreElements()) {
		if (iterator.GetData()->GetID() == scl->wid) {
			cle = iterator.GetData();
			if (scl->remove == 2){
				cle->LeavingZone(zoneserver, CLE_Status_Offline);
			}
			else if (scl->remove == 1)
				cle->LeavingZone(zoneserver, CLE_Status_Zoning);
			else
				cle->Update(zoneserver, scl);
			return;
		}
		iterator.Advance();
	}
	if (scl->remove == 2)
		cle = new ClientListEntry(GetNextCLEID(), zoneserver, scl, CLE_Status_Online);
	else if (scl->remove == 1)
		cle = new ClientListEntry(GetNextCLEID(), zoneserver, scl, CLE_Status_Zoning);
	else
		cle = new ClientListEntry(GetNextCLEID(), zoneserver, scl, CLE_Status_InZone);
	clientlist.Insert(cle);
	zoneserver->ChangeWID(scl->charid, cle->GetID());
}
Exemplo n.º 4
0
// Cofruben: used to send a packet directly to a client.
void ZoneServer::ProcessServerOP_SendPacket(ServerPacket* pack) {
	ServerSendPacket_Struct* sss = (ServerSendPacket_Struct*)pack->pBuffer;
	sss->charname[sizeof(sss->charname)-1] = '\0'; // Sanity check ;)
	ClientListEntry* cle = zoneserver_list.FindCharacter(sss->charname);
	if (cle == 0 || cle->Server() == 0) return;
	cle->Server()->SendPacket(pack);
	EQC::Common::PrintF(CP_WORLDSERVER, "ProcessServerOP_SendPacket(): Sending a packet to %s.\n", sss->charname);
}
Exemplo n.º 5
0
void ClientList::SendOnlineGuildMembers(uint32 FromID, uint32 GuildID)
{
	int PacketLength = 8;

	uint32 Count = 0;
	ClientListEntry* from = this->FindCLEByCharacterID(FromID);

	if(!from)
	{
		_log(WORLD__CLIENT_ERR,"Invalid client. FromID=%i GuildID=%i", FromID, GuildID);
		return;
	}

	LinkedListIterator<ClientListEntry*> Iterator(clientlist);

	Iterator.Reset();

	while(Iterator.MoreElements())
	{
		ClientListEntry* CLE = Iterator.GetData();

		if(CLE && (CLE->GuildID() == GuildID))
		{
			PacketLength += (strlen(CLE->name()) + 5);
			++Count;
		}

		Iterator.Advance();

	}

	Iterator.Reset();

	ServerPacket* pack = new ServerPacket(ServerOP_OnlineGuildMembersResponse, PacketLength);

	char *Buffer = (char *)pack->pBuffer;

	VARSTRUCT_ENCODE_TYPE(uint32, Buffer, FromID);
	VARSTRUCT_ENCODE_TYPE(uint32, Buffer, Count);

	while(Iterator.MoreElements())
	{
		ClientListEntry* CLE = Iterator.GetData();

		if(CLE && (CLE->GuildID() == GuildID))
		{
			VARSTRUCT_ENCODE_STRING(Buffer, CLE->name());
			VARSTRUCT_ENCODE_TYPE(uint32, Buffer, CLE->zone());
		}

		Iterator.Advance();
	}
	zoneserver_list.SendPacket(from->zone(), from->instance(), pack);
	safe_delete(pack);
}
Exemplo n.º 6
0
void ClientList::UpdateClientGuild(uint32 char_id, uint32 guild_id) {
	LinkedListIterator<ClientListEntry*> iterator(clientlist);

	iterator.Reset();
	while(iterator.MoreElements()) {
		ClientListEntry *cle = iterator.GetData();
		if (cle->CharID() == char_id) {
			cle->SetGuild(guild_id);
		}
		iterator.Advance();
	}
}
Exemplo n.º 7
0
void ClientList::GetCLEIP(int32 iIP) {

	ClientListEntry* countCLEIPs = 0;
	LinkedListIterator<ClientListEntry*> iterator(clientlist);

	int IPInstances = 0;
	iterator.Reset();

	while(iterator.MoreElements()) {

		countCLEIPs = iterator.GetData();

		// If the IP matches, and the connection admin status is below the exempt status,
		// or exempt status is less than 0 (no-one is exempt)
		if ((countCLEIPs->GetIP() == iIP) &&
			((countCLEIPs->Admin() < (RuleI(World, ExemptMaxClientsStatus))) ||
			(RuleI(World, ExemptMaxClientsStatus) < 0))) {

			// Increment the occurences of this IP address
			IPInstances++;

			// If the number of connections exceeds the lower limit
			if (IPInstances > (RuleI(World, MaxClientsPerIP))) {
						
				// If MaxClientsSetByStatus is set to True, override other IP Limit Rules
				if (RuleB(World, MaxClientsSetByStatus)) {

					// The IP Limit is set by the status of the account if status > MaxClientsPerIP
					if (IPInstances > countCLEIPs->Admin()) {
						
						// Remove the connection
						countCLEIPs->SetOnline(CLE_Status_Offline);
						iterator.RemoveCurrent();
						continue;
					}
				}
				// Else if the Admin status of the connection is not eligible for the higher limit,
				// or there is no higher limit (AddMaxClientStatus<0)
				else if ((countCLEIPs->Admin() < (RuleI(World, AddMaxClientsStatus)) ||
						(RuleI(World, AddMaxClientsStatus) < 0))) {

					// Remove the connection
					countCLEIPs->SetOnline(CLE_Status_Offline);
					iterator.RemoveCurrent();
					continue;
				}
				// else they are eligible for the higher limit, but if they exceed that
				else if (IPInstances > RuleI(World, AddMaxClientsPerIP)) {

					// Remove the connection
					countCLEIPs->SetOnline(CLE_Status_Offline);
					iterator.RemoveCurrent();
					continue;
				}
			}
		}
		iterator.Advance();
	}
}
Exemplo n.º 8
0
void Adventure::SendAdventureMessage(uint32 type, const char *msg)
{
	ServerPacket *pack = new ServerPacket(ServerOP_EmoteMessage, sizeof(ServerEmoteMessage_Struct) + strlen(msg) + 1);
	ServerEmoteMessage_Struct *sms = (ServerEmoteMessage_Struct*)pack->pBuffer;
	sms->type = type;
	strcpy(sms->message, msg);
	list<string>::iterator iter = players.begin();
	while(iter != players.end())
	{
		ClientListEntry *current = client_list.FindCharacter((*iter).c_str());
		if(current)
		{
			strcpy(sms->to, (*iter).c_str());
			zoneserver_list.SendPacket(current->zone(), current->instance(), pack);
		}
		iter++;
	}
	delete pack;
}
Exemplo n.º 9
0
void ClientList::GetClients(const char *zone_name, std::vector<ClientListEntry *> &res) {
	LinkedListIterator<ClientListEntry *> iterator(clientlist);
	iterator.Reset();

	if(zone_name[0] == '\0') {
		while(iterator.MoreElements()) {
			ClientListEntry* tmp = iterator.GetData();
			res.push_back(tmp);
			iterator.Advance();
		}
	} else {
		uint32 zoneid = database.GetZoneID(zone_name);
		while(iterator.MoreElements()) {
			ClientListEntry* tmp = iterator.GetData();
			if(tmp->zone() == zoneid)
				res.push_back(tmp);
			iterator.Advance();
		}
	}
}
Exemplo n.º 10
0
void ClientList::DisconnectByIP(uint32 iIP) {
	ClientListEntry* countCLEIPs = 0;
	LinkedListIterator<ClientListEntry*> iterator(clientlist);
	iterator.Reset();

	while(iterator.MoreElements()) {
		countCLEIPs = iterator.GetData();
		if ((countCLEIPs->GetIP() == iIP)) {
			if(strlen(countCLEIPs->name())) {
				ServerPacket* pack = new ServerPacket(ServerOP_KickPlayer, sizeof(ServerKickPlayer_Struct));
				ServerKickPlayer_Struct* skp = (ServerKickPlayer_Struct*) pack->pBuffer;
				strcpy(skp->adminname, "SessionLimit");
				strcpy(skp->name, countCLEIPs->name());
				skp->adminrank = 255;
				zoneserver_list.SendPacket(pack);
				safe_delete(pack);
			}
			countCLEIPs->SetOnline(CLE_Status_Offline);
			iterator.RemoveCurrent();
		}
		iterator.Advance();
	}
}
Exemplo n.º 11
0
// 15/10/2007 - froglok23
//TODO: MAKE SURE EACH METHOD HAS PACKET SIZE CHECKING!!!!
// Will come, but for now im off to bed :P - froglok23
void ZoneServer::ProcessServerOP_ChannelMessage(ServerPacket* pack)
{
	if (pack->size >= sizeof(ServerChannelMessage_Struct))
	{
		ServerChannelMessage_Struct* scm = (ServerChannelMessage_Struct*) pack->pBuffer;

		if (scm->chan_num == 7) // 7 = tell
		{
			ClientListEntry* cle = zoneserver_list.FindCharacter(scm->deliverto);
			if (cle == 0) 
			{
				if (!scm->noreply)
					zoneserver_list.SendEmoteMessage(scm->from, 0, 0, "You told %s, '%s is not online at this time'", scm->to, scm->to);
			}
			else if (cle->TellsOff() && ((cle->Anon() == 1 && scm->fromadmin < cle->Admin()) || scm->fromadmin < 100))
			{
				if (!scm->noreply)
					zoneserver_list.SendEmoteMessage(scm->from, 0, 0, "You told %s, '%s is not online at this time'", scm->to, scm->to);
			}
			else if (cle->Server() == 0)
			{
				if (!scm->noreply)
					zoneserver_list.SendEmoteMessage(scm->from, 0, 0, "You told %s, '%s is not contactable at this time'", scm->to, scm->to);
			}
			else
				cle->Server()->SendPacket(pack);
		}
		else if(scm->chan_num == 2) { //Cofruben: for grouping.
			ClientListEntry* cle = zoneserver_list.FindCharacter(scm->deliverto);
			if(cle && cle->Server())
				cle->Server()->SendPacket(pack);
		}
		else
			zoneserver_list.SendPacket(pack);
	}
	else
		cout << "Wrong size OP_ChannelMessage" << pack->size << ", should be " << sizeof(ServerChannelMessage_Struct) << "+ on 0x" << hex << setfill('0') << setw(4) << pack->opcode << dec << endl;
}
Exemplo n.º 12
0
void ClientList::SendCLEList(const int16& admin, const char* to, WorldTCPConnection* connection, const char* iName) {
	LinkedListIterator<ClientListEntry*> iterator(clientlist);
	char* output = 0;
	uint32 outsize = 0, outlen = 0;
	int x = 0, y = 0;
	int namestrlen = iName == 0 ? 0 : strlen(iName);
	bool addnewline = false;
	char newline[3];
	if (connection->IsConsole())
		strcpy(newline, "\r\n");
	else
		strcpy(newline, "^");

	iterator.Reset();
	while(iterator.MoreElements()) {
		ClientListEntry* cle = iterator.GetData();
		if (admin >= cle->Admin() && (iName == 0 || namestrlen == 0 || strncasecmp(cle->name(), iName, namestrlen) == 0 || strncasecmp(cle->AccountName(), iName, namestrlen) == 0 || strncasecmp(cle->LSName(), iName, namestrlen) == 0)) {
			struct in_addr in;
			in.s_addr = cle->GetIP();
			if (addnewline) {
				AppendAnyLenString(&output, &outsize, &outlen, newline);
			}
			AppendAnyLenString(&output, &outsize, &outlen, "ID: %i  Acc# %i  AccName: %s  IP: %s", cle->GetID(), cle->AccountID(), cle->AccountName(), inet_ntoa(in));
			AppendAnyLenString(&output, &outsize, &outlen, "%s  Stale: %i  Online: %i  Admin: %i", newline, cle->GetStaleCounter(), cle->Online(), cle->Admin());
			if (cle->LSID())
				AppendAnyLenString(&output, &outsize, &outlen, "%s  LSID: %i  LSName: %s  WorldAdmin: %i", newline, cle->LSID(), cle->LSName(), cle->WorldAdmin());
			if (cle->CharID())
				AppendAnyLenString(&output, &outsize, &outlen, "%s  CharID: %i  CharName: %s  Zone: %s (%i)", newline, cle->CharID(), cle->name(), database.GetZoneName(cle->zone()), cle->zone());
			if (outlen >= 3072) {
				connection->SendEmoteMessageRaw(to, 0, 0, 10, output);
				safe_delete(output);
				outsize = 0;
				outlen = 0;
				addnewline = false;
			}
			else
				addnewline = true;
			y++;
		}
		iterator.Advance();
		x++;
	}
	AppendAnyLenString(&output, &outsize, &outlen, "%s%i CLEs in memory. %i CLEs listed. numplayers = %i.", newline, x, y, numplayers);
	connection->SendEmoteMessageRaw(to, 0, 0, 10, output);
	safe_delete(output);
}
Exemplo n.º 13
0
//Account Limiting Code to limit the number of characters allowed on from a single account at once.
void ClientList::EnforceSessionLimit(int32 iLSAccountID) {

	ClientListEntry* ClientEntry = 0;

	LinkedListIterator<ClientListEntry*> iterator(clientlist, BACKWARD);

	int CharacterCount = 0;

	iterator.Reset();

	while(iterator.MoreElements()) {

		ClientEntry = iterator.GetData();

		if ((ClientEntry->LSAccountID() == iLSAccountID) &&
		    ((ClientEntry->Admin() <= (RuleI(World, ExemptAccountLimitStatus))) || (RuleI(World, ExemptAccountLimitStatus) < 0))) {

			CharacterCount++;

			if (CharacterCount >= (RuleI(World, AccountSessionLimit))){
				// If we have a char name, they are in a zone, so send a kick to the zone server
				if(strlen(ClientEntry->name())) 
				
				{				
					
					ServerPacket* pack = new ServerPacket(ServerOP_KickPlayer, sizeof(ServerKickPlayer_Struct));
					ServerKickPlayer_Struct* skp = (ServerKickPlayer_Struct*) pack->pBuffer;
					strcpy(skp->adminname, "SessionLimit");
					strcpy(skp->name, ClientEntry->name());
					skp->adminrank = 255;
					zoneserver_list.SendPacket(pack);
					safe_delete(pack);
					
				}
				
				ClientEntry->SetOnline(CLE_Status_Offline);

				iterator.RemoveCurrent();

				continue;
			}
		}
		iterator.Advance();
	}
}
Exemplo n.º 14
0
void ClientList::SendClientVersionSummary(const char *Name)
{
	uint32 Client62Count = 0;
	uint32 ClientTitaniumCount = 0;
	uint32 ClientSoFCount = 0;
	uint32 ClientSoDCount = 0;
	uint32 ClientUnderfootCount = 0;
	uint32 ClientRoFCount = 0;

	LinkedListIterator<ClientListEntry*> Iterator(clientlist);

	Iterator.Reset();

	while(Iterator.MoreElements())
	{
		ClientListEntry* CLE = Iterator.GetData();

		if(CLE && CLE->zone())
		{
			switch(CLE->GetClientVersion())
			{
				case 1:
				{
					++Client62Count;
					break;
				}
				case 2:
				{
					++ClientTitaniumCount;
					break;
				}
				case 3:
				{
					++ClientSoFCount;
					break;
				}
				case 4:
				{
					++ClientSoDCount;
					break;
				}
				case 5:
				{
					++ClientUnderfootCount;
					break;
				}
				case 6:
				{
					++ClientRoFCount;
					break;
				}
				default:
					break;
			}
		}

		Iterator.Advance();

	}

	zoneserver_list.SendEmoteMessage(Name, 0, 0, 13, "There are %i 6.2, %i Titanium, %i SoF, %i SoD, %i UF, %i RoF clients currently connected.",
					Client62Count, ClientTitaniumCount, ClientSoFCount, ClientSoDCount, ClientUnderfootCount, ClientRoFCount);
}
Exemplo n.º 15
0
void ClientList::SendFriendsWho(ServerFriendsWho_Struct *FriendsWho, WorldTCPConnection* connection) {

	std::vector<ClientListEntry*> FriendsCLEs;
	FriendsCLEs.reserve(100);

	char Friend_[65];

	char *FriendsPointer = FriendsWho->FriendsString;

	// FriendsString is a comma delimited list of names.

	char *Seperator = nullptr;

	Seperator = strchr(FriendsPointer, ',');
	if(!Seperator) Seperator = strchr(FriendsPointer, '\0');

	uint32 TotalLength=0;

	while(Seperator != nullptr) {

		if((Seperator - FriendsPointer) > 64) return;

		strncpy(Friend_, FriendsPointer, Seperator - FriendsPointer);
		Friend_[Seperator - FriendsPointer] = 0;

		ClientListEntry* CLE = FindCharacter(Friend_);
		if(CLE && CLE->name() && (CLE->Online() >= CLE_Status_Zoning) && !(CLE->GetGM() && CLE->Anon())) {
			FriendsCLEs.push_back(CLE);
			TotalLength += strlen(CLE->name());
			int GuildNameLength = strlen(guild_mgr.GetGuildName(CLE->GuildID()));
			if(GuildNameLength>0)
				TotalLength += (GuildNameLength + 2);
		}

		if(Seperator[0] == '\0') break;

		FriendsPointer = Seperator + 1;
		Seperator = strchr(FriendsPointer, ',');
		if(!Seperator) Seperator = strchr(FriendsPointer, '\0');
	}


	try{
		ClientListEntry* cle;
		int FriendsOnline = FriendsCLEs.size();
		int PacketLength = sizeof(WhoAllReturnStruct) + (47 * FriendsOnline) + TotalLength;
		ServerPacket* pack2 = new ServerPacket(ServerOP_WhoAllReply, PacketLength);
		memset(pack2->pBuffer,0,pack2->size);
		uchar *buffer=pack2->pBuffer;
		uchar *bufptr=buffer;

		WhoAllReturnStruct *WARS = (WhoAllReturnStruct *)bufptr;

		WARS->id = FriendsWho->FromID;
		WARS->playerineqstring = 0xffff;
		strcpy(WARS->line, "");
		WARS->unknown35 = 0x0a;
		WARS->unknown36 = 0x00;

		if(FriendsCLEs.size() == 1)
			WARS->playersinzonestring = 5028; // 5028 There is %1 player in EverQuest.
		else
			WARS->playersinzonestring = 5036; // 5036 There are %1 players in EverQuest.

		WARS->unknown44[0] = 0;
		WARS->unknown44[1] = 0;
		WARS->unknown44[2] = 0;
		WARS->unknown44[3] = 0;
		WARS->unknown44[4] = 0;
		WARS->unknown52 = FriendsOnline;
		WARS->unknown56 = 1;
		WARS->playercount = FriendsOnline;

		bufptr+=sizeof(WhoAllReturnStruct);

		for(int CLEEntry = 0; CLEEntry < FriendsOnline; CLEEntry++) {

			cle = FriendsCLEs[CLEEntry];

			char GuildName[67]={0};
			if (cle->GuildID() != GUILD_NONE && cle->GuildID()>0)
				sprintf(GuildName,"<%s>", guild_mgr.GetGuildName(cle->GuildID()));
			uint16 FormatMSGID=5025; // 5025 %T1[%2 %3] %4 (%5) %6 %7 %8 %9
			if(cle->Anon()==1)
				FormatMSGID=5024; // 5024 %T1[ANONYMOUS] %2 %3
			else if(cle->Anon()==2)
				FormatMSGID=5023; // 5023 %T1[ANONYMOUS] %2 %3 %4

			uint16 PlayerClass=0;
			uint16 PlayerLevel=0;
			uint16 PlayerRace=0;
			uint16 ZoneMSGID=0xffff;
			uint16 PlayerZone=0;

			if(cle->Anon()==0) {
				PlayerClass=cle->class_();
				PlayerLevel=cle->level();
				PlayerRace=cle->race();
				ZoneMSGID=5006; // 5006 ZONE: %1
				PlayerZone=cle->zone();
			}

			char PlayerName[64]={0};
			strcpy(PlayerName,cle->name());

			WhoAllPlayerPart1* WAPP1 = (WhoAllPlayerPart1*)bufptr;

			WAPP1->FormatMSGID = FormatMSGID;
			WAPP1->PIDMSGID = 0xffff;
			strcpy(WAPP1->Name, PlayerName);

			bufptr += sizeof(WhoAllPlayerPart1) + strlen(PlayerName);
			WhoAllPlayerPart2* WAPP2 = (WhoAllPlayerPart2*)bufptr;

			WAPP2->RankMSGID = 0xffff;
			strcpy(WAPP2->Guild, GuildName);

			bufptr += sizeof(WhoAllPlayerPart2) + strlen(GuildName);
			WhoAllPlayerPart3* WAPP3 = (WhoAllPlayerPart3*)bufptr;

			WAPP3->Unknown80[0] = 0xffff;
			WAPP3->Unknown80[1] = 0xffff;
			WAPP3->Unknown80[2] = 0xffff;
			WAPP3->ZoneMSGID = ZoneMSGID;
			WAPP3->Zone = PlayerZone;
			WAPP3->Class_ = PlayerClass;
			WAPP3->Level = PlayerLevel;
			WAPP3->Race = PlayerRace;
			WAPP3->Account[0] = 0;

			bufptr += sizeof(WhoAllPlayerPart3);

			WhoAllPlayerPart4* WAPP4 = (WhoAllPlayerPart4*)bufptr;
			WAPP4->Unknown100 = 211;

			bufptr += sizeof(WhoAllPlayerPart4);

		}
		pack2->Deflate();
		SendPacket(FriendsWho->FromName,pack2);
		safe_delete(pack2);
	}
	catch(...){
		_log(WORLD__ZONELIST_ERR,"Unknown error in world's SendFriendsWho (probably mem error), ignoring...");
		return;
	}
}
Exemplo n.º 16
0
void ClientList::SendClientVersionSummary(const char *Name)
{
	uint32 ClientUnusedCount = 0;
	uint32 ClientPCCount = 0;
	uint32 ClientIntelCount = 0;
	uint32 ClientPPCCount = 0;
	uint32 ClientEvolutionCount = 0;

	LinkedListIterator<ClientListEntry*> Iterator(clientlist);

	Iterator.Reset();

	while(Iterator.MoreElements())
	{
		ClientListEntry* CLE = Iterator.GetData();

		if(CLE && CLE->zone())
		{
			switch(CLE->GetClientVersion())
			{
				case 1:
				{
					++ClientUnusedCount;
					break;
				}
				case 2:
				{
					switch(CLE->GetMacClientVersion())
					{
						case 2:
						{
							++ClientPCCount;
							break;
						}
						case 4:
						{
							++ClientIntelCount;
							break;
						}
						case 8:
						{
							++ClientPPCCount;
							break;
						}
					}
					break;
				}
				case 3:
				{
					++ClientEvolutionCount;
					break;
				}
				default:
					break;
			}
		}

		Iterator.Advance();

	}

	zoneserver_list.SendEmoteMessage(Name, 0, 0, 13, "There are %i Unused, %i PC, %i Intel, %i PPC, %i Evolution clients currently connected.",
					ClientUnusedCount, ClientPCCount, ClientIntelCount, ClientPPCCount, ClientEvolutionCount);
}
Exemplo n.º 17
0
void ClientList::GetCLEIP(uint32 iIP) {
	ClientListEntry* countCLEIPs = 0;
	LinkedListIterator<ClientListEntry*> iterator(clientlist);

	int IPInstances = 0;
	iterator.Reset();

	while(iterator.MoreElements()) {
		countCLEIPs = iterator.GetData();		
		if ((countCLEIPs->GetIP() == iIP) && ((countCLEIPs->Admin() < (RuleI(World, ExemptMaxClientsStatus))) || (RuleI(World, ExemptMaxClientsStatus) < 0))) { // If the IP matches, and the connection admin status is below the exempt status, or exempt status is less than 0 (no-one is exempt)
			IPInstances++; // Increment the occurences of this IP address
			Log.Out(Logs::General, Logs::Client_Login, "Account ID: %i Account Name: %s IP: %s.", countCLEIPs->LSID(), countCLEIPs->LSName(), long2ip(countCLEIPs->GetIP()).c_str());
			if (RuleB(World, EnableIPExemptions)) {
				Log.Out(Logs::General, Logs::Client_Login, "Account ID: %i Account Name: %s IP: %s IP Instances: %i Max IP Instances: %i", countCLEIPs->LSID(), countCLEIPs->LSName(), long2ip(countCLEIPs->GetIP()).c_str(), IPInstances, database.GetIPExemption(long2ip(countCLEIPs->GetIP()).c_str()));
				if (IPInstances > database.GetIPExemption(long2ip(countCLEIPs->GetIP()).c_str())) {
					if(RuleB(World, IPLimitDisconnectAll)) {
						Log.Out(Logs::General, Logs::Client_Login, "Disconnect: All accounts on IP %s", long2ip(countCLEIPs->GetIP()).c_str());
						DisconnectByIP(iIP);
						return;
					} else {
						Log.Out(Logs::General, Logs::Client_Login, "Disconnect: Account %s on IP %s.", countCLEIPs->LSName(), long2ip(countCLEIPs->GetIP()).c_str());
						countCLEIPs->SetOnline(CLE_Status_Offline);
						iterator.RemoveCurrent();
						continue;
					}
				}
			} else {
				if (IPInstances > (RuleI(World, MaxClientsPerIP))) { // If the number of connections exceeds the lower limit
					if (RuleB(World, MaxClientsSetByStatus)) { // If MaxClientsSetByStatus is set to True, override other IP Limit Rules
						Log.Out(Logs::General, Logs::Client_Login, "Account ID: %i Account Name: %s IP: %s IP Instances: %i Max IP Instances: %i", countCLEIPs->LSID(), countCLEIPs->LSName(), long2ip(countCLEIPs->GetIP()).c_str(), IPInstances, countCLEIPs->Admin());
						if (IPInstances > countCLEIPs->Admin()) { // The IP Limit is set by the status of the account if status > MaxClientsPerIP	
							if(RuleB(World, IPLimitDisconnectAll)) {
								Log.Out(Logs::General, Logs::Client_Login, "Disconnect: All accounts on IP %s", long2ip(countCLEIPs->GetIP()).c_str());
								DisconnectByIP(iIP);
								return;
							} else {
								Log.Out(Logs::General, Logs::Client_Login, "Disconnect: Account %s on IP %s.", countCLEIPs->LSName(), long2ip(countCLEIPs->GetIP()).c_str());
								countCLEIPs->SetOnline(CLE_Status_Offline); // Remove the connection
								iterator.RemoveCurrent();
								continue;
							}
						}
					} else if ((countCLEIPs->Admin() < RuleI(World, AddMaxClientsStatus)) || (RuleI(World, AddMaxClientsStatus) < 0)) { // Else if the Admin status of the connection is not eligible for the higher limit, or there is no higher limit (AddMaxClientStatus < 0)
						if(RuleB(World, IPLimitDisconnectAll)) {								
							Log.Out(Logs::General, Logs::Client_Login, "Disconnect: All accounts on IP %s", long2ip(countCLEIPs->GetIP()).c_str());
							DisconnectByIP(iIP);
							return;
						} else {
							Log.Out(Logs::General, Logs::Client_Login, "Disconnect: Account %s on IP %s.", countCLEIPs->LSName(), long2ip(countCLEIPs->GetIP()).c_str());
							countCLEIPs->SetOnline(CLE_Status_Offline); // Remove the connection
							iterator.RemoveCurrent();
							continue;
						}
					} else if (IPInstances > RuleI(World, AddMaxClientsPerIP)) { // else they are eligible for the higher limit, but if they exceed that	
						if(RuleB(World, IPLimitDisconnectAll)) {
							Log.Out(Logs::General, Logs::Client_Login, "Disconnect: All accounts on IP %s", long2ip(countCLEIPs->GetIP()).c_str());
							DisconnectByIP(iIP);
							return;
						} else {
							Log.Out(Logs::General, Logs::Client_Login, "Disconnect: Account %s on IP %s.", countCLEIPs->LSName(), long2ip(countCLEIPs->GetIP()).c_str());
							countCLEIPs->SetOnline(CLE_Status_Offline); // Remove the connection
							iterator.RemoveCurrent();
							continue;
						}
					}
				}
			}
		}
		iterator.Advance();
	}
}
Exemplo n.º 18
0
bool ZoneServer::Process() {
	if (!tcpc->Connected())
		return false;
	if(ls_zboot.Check()){
		LSBootUpdate(GetZoneID(), true);
		ls_zboot.Disable();
	}
	ServerPacket *pack = 0;
	while((pack = tcpc->PopPacket())) {
		_hex(WORLD__ZONE_TRACE,pack->pBuffer,pack->size);
		if (!authenticated) {
			if (WorldConfig::get()->SharedKey.length() > 0) {
				if (pack->opcode == ServerOP_ZAAuth && pack->size == 16) {
					uint8 tmppass[16];
					MD5::Generate((const uchar*) WorldConfig::get()->SharedKey.c_str(), WorldConfig::get()->SharedKey.length(), tmppass);
					if (memcmp(pack->pBuffer, tmppass, 16) == 0)
						authenticated = true;
					else {
						struct in_addr  in;
						in.s_addr = GetIP();
						zlog(WORLD__ZONE_ERR,"Zone authorization failed.");
						ServerPacket* pack = new ServerPacket(ServerOP_ZAAuthFailed);
						SendPacket(pack);
						delete pack;
						Disconnect();
						return false;
					}
				}
				else {
					struct in_addr  in;
					in.s_addr = GetIP();
					zlog(WORLD__ZONE_ERR,"Zone authorization failed.");
					ServerPacket* pack = new ServerPacket(ServerOP_ZAAuthFailed);
					SendPacket(pack);
					delete pack;
					Disconnect();
					return false;
				}
			}
			else
			{
				_log(WORLD__ZONE,"**WARNING** You have not configured a world shared key in your config file. You should add a <key>STRING</key> element to your <world> element to prevent unauthroized zone access.");
				authenticated = true;
			}
		}
		switch(pack->opcode) {
		case 0:
			break;
		case ServerOP_KeepAlive: {
			// ignore this
			break;
		}
		case ServerOP_ZAAuth: {
			break;
		}
		case ServerOP_LSZoneBoot:{
			if(pack->size==sizeof(ZoneBoot_Struct)){
				ZoneBoot_Struct* zbs= (ZoneBoot_Struct*)pack->pBuffer;
				SetCompile(zbs->compile_time);
			}
			break;
		}
		case ServerOP_GroupInvite: {
			if(pack->size != sizeof(GroupInvite_Struct))
				break;

			GroupInvite_Struct* gis = (GroupInvite_Struct*) pack->pBuffer;

			client_list.SendPacket(gis->invitee_name, pack);
			break;
		}
		case ServerOP_GroupFollow: {
			if(pack->size != sizeof(ServerGroupFollow_Struct))
				break;

			ServerGroupFollow_Struct *sgfs = (ServerGroupFollow_Struct *) pack->pBuffer;

			client_list.SendPacket(sgfs->gf.name1, pack);
			break;
		}
		case ServerOP_GroupFollowAck: {
			if(pack->size != sizeof(ServerGroupFollowAck_Struct))
				break;

			ServerGroupFollowAck_Struct *sgfas = (ServerGroupFollowAck_Struct *) pack->pBuffer;

			client_list.SendPacket(sgfas->Name, pack);
			break;
		}
		case ServerOP_GroupCancelInvite: {
			if(pack->size != sizeof(GroupCancel_Struct))
				break;

			GroupCancel_Struct *gcs = (GroupCancel_Struct *) pack->pBuffer;

			client_list.SendPacket(gcs->name1, pack);
			break;
		}
		case ServerOP_GroupIDReq: {
			SendGroupIDs();
			break;
		}
		case ServerOP_GroupLeave: {
			if(pack->size != sizeof(ServerGroupLeave_Struct))
				break;
			zoneserver_list.SendPacket(pack); //bounce it to all zones
			break;
		}

		case ServerOP_GroupJoin: {
			if(pack->size != sizeof(ServerGroupJoin_Struct))
				break;
			zoneserver_list.SendPacket(pack); //bounce it to all zones
			break;
		}

		case ServerOP_ForceGroupUpdate: {
			if(pack->size != sizeof(ServerForceGroupUpdate_Struct))
				break;
			zoneserver_list.SendPacket(pack); //bounce it to all zones
			break;
		}

		case ServerOP_OOZGroupMessage: {
			zoneserver_list.SendPacket(pack); //bounce it to all zones
			break;
		}

		case ServerOP_DisbandGroup: {
			if(pack->size != sizeof(ServerDisbandGroup_Struct))
				break;
			zoneserver_list.SendPacket(pack); //bounce it to all zones
			break;
		}

		case ServerOP_RaidAdd:{
			if(pack->size != sizeof(ServerRaidGeneralAction_Struct))
				break;

			zoneserver_list.SendPacket(pack);
			break;
		}

		case ServerOP_RaidRemove: {
			if(pack->size != sizeof(ServerRaidGeneralAction_Struct))
				break;

			zoneserver_list.SendPacket(pack);
			break;
		}

		case ServerOP_RaidDisband: {
			if(pack->size != sizeof(ServerRaidGeneralAction_Struct))
				break;

			zoneserver_list.SendPacket(pack);
			break;
		}

		case ServerOP_RaidLockFlag: {
			if(pack->size != sizeof(ServerRaidGeneralAction_Struct))
				break;

			zoneserver_list.SendPacket(pack);
			break;
		}

		case ServerOP_RaidChangeGroup: {
			if(pack->size != sizeof(ServerRaidGeneralAction_Struct))
				break;

			zoneserver_list.SendPacket(pack);
			break;
		}

		case ServerOP_UpdateGroup: {
			if(pack->size != sizeof(ServerRaidGeneralAction_Struct))
				break;

			zoneserver_list.SendPacket(pack);
			break;
		}

		case ServerOP_RaidGroupDisband: {
			if(pack->size != sizeof(ServerRaidGeneralAction_Struct))
				break;

			zoneserver_list.SendPacket(pack);
			break;
		}

		case ServerOP_RaidGroupAdd: {
			if(pack->size != sizeof(ServerRaidGroupAction_Struct))
				break;

			zoneserver_list.SendPacket(pack);
			break;
		}

		case ServerOP_RaidGroupRemove: {
			if(pack->size != sizeof(ServerRaidGroupAction_Struct))
				break;

			zoneserver_list.SendPacket(pack);
			break;
		}

		case ServerOP_RaidGroupSay: {
			zoneserver_list.SendPacket(pack);
			break;
		}

		case ServerOP_RaidSay: {
			zoneserver_list.SendPacket(pack);
			break;
		}

		case ServerOP_RaidGroupLeader: {
			if(pack->size != sizeof(ServerRaidGeneralAction_Struct))
				break;

			zoneserver_list.SendPacket(pack);
			break;
		}

		case ServerOP_RaidLeader: {
			if(pack->size != sizeof(ServerRaidGeneralAction_Struct))
				break;

			zoneserver_list.SendPacket(pack);
			break;
		}

		case ServerOP_DetailsChange: {
			if(pack->size != sizeof(ServerRaidGeneralAction_Struct))
				break;

			zoneserver_list.SendPacket(pack);
			break;
		}

		case ServerOP_SpawnCondition: {
			if(pack->size != sizeof(ServerSpawnCondition_Struct))
				break;
			//bounce the packet to the correct zone server, if its up
			ServerSpawnCondition_Struct* ssc = (ServerSpawnCondition_Struct*)pack->pBuffer;
			zoneserver_list.SendPacket(ssc->zoneID, ssc->instanceID, pack);
			break;
		}
		case ServerOP_SpawnEvent: {
			if(pack->size != sizeof(ServerSpawnEvent_Struct))
				break;
			//bounce the packet to the correct zone server, if its up
			ServerSpawnEvent_Struct* sse = (ServerSpawnEvent_Struct*)pack->pBuffer;
			zoneserver_list.SendPacket(sse->zoneID, 0, pack);
			break;
		}
		case ServerOP_ChannelMessage: {
			ServerChannelMessage_Struct* scm = (ServerChannelMessage_Struct*) pack->pBuffer;
			if(scm->chan_num == 20)
			{
				UCSLink.SendMessage(scm->from, scm->message);
				break;
			}
			if (scm->chan_num == 7 || scm->chan_num == 14) {
				if (scm->deliverto[0] == '*') {
					Console* con = 0;
					con = console_list.FindByAccountName(&scm->deliverto[1]);
					if (((!con) || (!con->SendChannelMessage(scm))) && (!scm->noreply))
						zoneserver_list.SendEmoteMessage(scm->from, 0, 0, 0, "You told %s, '%s is not online at this time'", scm->to, scm->to);
					break;
				}
				ClientListEntry* cle = client_list.FindCharacter(scm->deliverto);
				if (cle == 0 || cle->Online() < CLE_Status_Zoning || (cle->TellsOff() && ((cle->Anon() == 1 && scm->fromadmin < cle->Admin()) || scm->fromadmin < 80))) {
					if (!scm->noreply)
						zoneserver_list.SendEmoteMessage(scm->from, 0, 0, 0, "You told %s, '%s is not online at this time'", scm->to, scm->to);
				}
				else if (cle->Online() == CLE_Status_Zoning) {
					if (!scm->noreply) {
						char errbuf[MYSQL_ERRMSG_SIZE];
						char *query = 0;
						MYSQL_RES *result;
						//MYSQL_ROW row;   Trumpcard - commenting.  Currently unused.
						time_t rawtime;
						struct tm * timeinfo;
						time ( &rawtime );
						timeinfo = localtime ( &rawtime );
						char *telldate=asctime(timeinfo);
						if (database.RunQuery(query, MakeAnyLenString(&query, "SELECT name from character_ where name='%s'",scm->deliverto), errbuf, &result)) {
							safe_delete(query);
							if (result!=0) {
								if (database.RunQuery(query, MakeAnyLenString(&query, "INSERT INTO tellque (Date,Receiver,Sender,Message) values('%s','%s','%s','%s')",telldate,scm->deliverto,scm->from,scm->message), errbuf, &result))
									zoneserver_list.SendEmoteMessage(scm->from, 0, 0, 0, "Your message has been added to the %s's que.", scm->to);
								else
									zoneserver_list.SendEmoteMessage(scm->from, 0, 0, 0, "You told %s, '%s is not online at this time'", scm->to, scm->to);
								safe_delete(query);
							}
							else
								zoneserver_list.SendEmoteMessage(scm->from, 0, 0, 0, "You told %s, '%s is not online at this time'", scm->to, scm->to);
							mysql_free_result(result);
						}
						else
							safe_delete(query);
					}
				//		zoneserver_list.SendEmoteMessage(scm->from, 0, 0, 0, "You told %s, '%s is not online at this time'", scm->to, scm->to);
				}
				else if (cle->Server() == 0) {
					if (!scm->noreply)
						zoneserver_list.SendEmoteMessage(scm->from, 0, 0, 0, "You told %s, '%s is not contactable at this time'", scm->to, scm->to);
				}
				else
					cle->Server()->SendPacket(pack);
			}
			else {
				if (scm->chan_num == 5 || scm->chan_num == 6 || scm->chan_num == 11) {
					console_list.SendChannelMessage(scm);
				}
				zoneserver_list.SendPacket(pack);
			}
			break;
		}
		case ServerOP_EmoteMessage: {
			ServerEmoteMessage_Struct* sem = (ServerEmoteMessage_Struct*) pack->pBuffer;
			zoneserver_list.SendEmoteMessageRaw(sem->to, sem->guilddbid, sem->minstatus, sem->type, sem->message);
			break;
		}
		case ServerOP_VoiceMacro: {

			ServerVoiceMacro_Struct* svm = (ServerVoiceMacro_Struct*) pack->pBuffer;
			
			if(svm->Type == VoiceMacroTell) {

				ClientListEntry* cle = client_list.FindCharacter(svm->To);

				if (!cle || (cle->Online() < CLE_Status_Zoning) || !cle->Server())  {

					zoneserver_list.SendEmoteMessage(svm->From, 0, 0, 0, "'%s is not online at this time'", svm->To);

					break;
				}

				cle->Server()->SendPacket(pack);
			}
			else
				zoneserver_list.SendPacket(pack);

			break;
		}

		case ServerOP_RezzPlayerAccept: {
			zoneserver_list.SendPacket(pack);
			break;
		}
		case ServerOP_RezzPlayer: {

			RezzPlayer_Struct* sRezz = (RezzPlayer_Struct*) pack->pBuffer;
			if (zoneserver_list.SendPacket(pack)){
				zlog(WORLD__ZONE,"Sent Rez packet for %s",sRezz->rez.your_name);
			}
			else {
				zlog(WORLD__ZONE,"Could not send Rez packet for %s",sRezz->rez.your_name);
			}
			break;
		}
		case ServerOP_RezzPlayerReject:
		{
			char *Recipient = (char *)pack->pBuffer;
			client_list.SendPacket(Recipient, pack);
			break;
		}

		case ServerOP_MultiLineMsg: {
			ServerMultiLineMsg_Struct* mlm = (ServerMultiLineMsg_Struct*) pack->pBuffer;
			client_list.SendPacket(mlm->to, pack);
			break;
		}
		case ServerOP_SetZone: {
			if(pack->size != sizeof(SetZone_Struct))
				break;

			SetZone_Struct* szs = (SetZone_Struct*) pack->pBuffer;	
			if (szs->zoneid != 0) {
				if(database.GetZoneName(szs->zoneid))
					SetZone(szs->zoneid, szs->instanceid, szs->staticzone);
				else
					SetZone(0);
			}
			else
				SetZone(0);

			break;
		}
		case ServerOP_SetConnectInfo: {
			if (pack->size != sizeof(ServerConnectInfo))
					break;
			ServerConnectInfo* sci = (ServerConnectInfo*) pack->pBuffer;

			if (!sci->port) {
				clientport=zoneserver_list.GetAvailableZonePort();

				ServerPacket p(ServerOP_SetConnectInfo, sizeof(ServerConnectInfo));
				memset(p.pBuffer,0,sizeof(ServerConnectInfo));
				ServerConnectInfo* sci = (ServerConnectInfo*) p.pBuffer;
				sci->port = clientport;
				SendPacket(&p);
				zlog(WORLD__ZONE,"Auto zone port configuration.  Telling zone to use port %d",clientport);
			} else {
				clientport=sci->port;
				zlog(WORLD__ZONE,"Zone specified port %d, must be a previously allocated zone reconnecting.",clientport);
			}

		}
		case ServerOP_SetLaunchName: {
			if(pack->size != sizeof(LaunchName_Struct))
				break;
			const LaunchName_Struct* ln = (const LaunchName_Struct*)pack->pBuffer;
			launcher_name = ln->launcher_name;
			launched_name = ln->zone_name;
			zlog(WORLD__ZONE, "Zone started with name %s by launcher %s", launched_name.c_str(), launcher_name.c_str());
			break;
		}
		case ServerOP_ShutdownAll: {
			if(pack->size==0){
				zoneserver_list.SendPacket(pack);
				zoneserver_list.Process();
				CatchSignal(2);
			}
			else{
				WorldShutDown_Struct* wsd=(WorldShutDown_Struct*)pack->pBuffer;
				if(wsd->time==0 && wsd->interval==0 && zoneserver_list.shutdowntimer->Enabled()){
					zoneserver_list.shutdowntimer->Disable();
					zoneserver_list.reminder->Disable();
				}
				else{
					zoneserver_list.shutdowntimer->SetTimer(wsd->time);
					zoneserver_list.reminder->SetTimer(wsd->interval-1000);
					zoneserver_list.reminder->SetAtTrigger(wsd->interval);
					zoneserver_list.shutdowntimer->Start();
					zoneserver_list.reminder->Start();
				}
			}
			break;
		}
		case ServerOP_ZoneShutdown: {
			ServerZoneStateChange_struct* s = (ServerZoneStateChange_struct *) pack->pBuffer;
			ZoneServer* zs = 0;
			if (s->ZoneServerID != 0)
				zs = zoneserver_list.FindByID(s->ZoneServerID);
			else if (s->zoneid != 0)
				zs = zoneserver_list.FindByName(database.GetZoneName(s->zoneid));
			else
				zoneserver_list.SendEmoteMessage(s->adminname, 0, 0, 0, "Error: SOP_ZoneShutdown: neither ID nor name specified");

			if (zs == 0)
				zoneserver_list.SendEmoteMessage(s->adminname, 0, 0, 0, "Error: SOP_ZoneShutdown: zoneserver not found");
			else
				zs->SendPacket(pack);
			break;
		}
		case ServerOP_ZoneBootup: {
			ServerZoneStateChange_struct* s = (ServerZoneStateChange_struct *) pack->pBuffer;
			zoneserver_list.SOPZoneBootup(s->adminname, s->ZoneServerID, database.GetZoneName(s->zoneid), s->makestatic);
			break;
		}
		case ServerOP_ZoneStatus: {
			if (pack->size >= 1)
				zoneserver_list.SendZoneStatus((char *) &pack->pBuffer[1], (uint8) pack->pBuffer[0], this);
			break;

		}
		case ServerOP_AcceptWorldEntrance: {
			if(pack->size != sizeof(WorldToZone_Struct))
				break;

			WorldToZone_Struct* wtz = (WorldToZone_Struct*) pack->pBuffer;
			Client* client = 0;
			client = client_list.FindByAccountID(wtz->account_id);
			if(client != 0)
				client->Clearance(wtz->response);
		}
		case ServerOP_ZoneToZoneRequest: {
		//
		// solar: ZoneChange is received by the zone the player is in, then the
		// zone sends a ZTZ which ends up here.  This code then find the target
		// (ingress point) and boots it if needed, then sends the ZTZ to it.
		// The ingress server will decide wether the player can enter, then will
		// send back the ZTZ to here.  This packet is passed back to the egress
		// server, which will send a ZoneChange response back to the client
		// which can be an error, or a success, in which case the client will
		// disconnect, and their zone location will be saved when ~Client is
		// called, so it will be available when they ask to zone.
		//

			
			if(pack->size != sizeof(ZoneToZone_Struct))
				break;
			ZoneToZone_Struct* ztz = (ZoneToZone_Struct*) pack->pBuffer;
			ClientListEntry* client = NULL;
			if(WorldConfig::get()->UpdateStats)
				client = client_list.FindCharacter(ztz->name);

			zlog(WORLD__ZONE,"ZoneToZone request for %s current zone %d req zone %d\n",
				ztz->name, ztz->current_zone_id, ztz->requested_zone_id);

			if(GetZoneID() == ztz->current_zone_id && GetInstanceID() == ztz->current_instance_id)	// this is a request from the egress zone
			{
				zlog(WORLD__ZONE,"Processing ZTZ for egress from zone for client %s\n", ztz->name);

				if
				(
					ztz->admin < 80 &&
					ztz->ignorerestrictions < 2 &&
					zoneserver_list.IsZoneLocked(ztz->requested_zone_id)
				)
				{
					ztz->response = 0;
					SendPacket(pack);
					break;
				}

				ZoneServer *ingress_server = NULL;
				if(ztz->requested_instance_id > 0)
				{
					ingress_server = zoneserver_list.FindByInstanceID(ztz->requested_instance_id);
				}
				else
				{
					ingress_server = zoneserver_list.FindByZoneID(ztz->requested_zone_id);

				}

				if(ingress_server)	// found a zone already running
				{
					_log(WORLD__ZONE,"Found a zone already booted for %s\n", ztz->name);
					ztz->response = 1;
				}
				else	// need to boot one
				{
					int server_id;
					if ((server_id = zoneserver_list.TriggerBootup(ztz->requested_zone_id, ztz->requested_instance_id))){
						_log(WORLD__ZONE,"Successfully booted a zone for %s\n", ztz->name);
						// bootup successful, ready to rock
						ztz->response = 1;
						ingress_server = zoneserver_list.FindByID(server_id);
					}
					else
					{
						_log(WORLD__ZONE_ERR,"FAILED to boot a zone for %s\n", ztz->name);
						// bootup failed, send back error code 0
						ztz->response = 0;
					}
				}
				if(ztz->response!=0 && client)
					client->LSZoneChange(ztz);
				SendPacket(pack);	// send back to egress server
				if(ingress_server)	// if we couldn't boot one, this is 0
				{
					ingress_server->SendPacket(pack);	// inform target server
				}
			}
			else	// this is response from the ingress server, route it back to the egress server
			{
				zlog(WORLD__ZONE,"Processing ZTZ for ingress to zone for client %s\n", ztz->name);
				ZoneServer *egress_server = NULL;
				if(ztz->current_instance_id > 0)
				{
					egress_server = zoneserver_list.FindByInstanceID(ztz->current_instance_id);
				}
				else
				{
					egress_server = zoneserver_list.FindByZoneID(ztz->current_zone_id);
				}

				if(egress_server)
				{
					egress_server->SendPacket(pack);
				}
			}

			break;
		}
		case ServerOP_ClientList: {
			if (pack->size != sizeof(ServerClientList_Struct)) {
				zlog(WORLD__ZONE_ERR,"Wrong size on ServerOP_ClientList. Got: %d, Expected: %d",pack->size,sizeof(ServerClientList_Struct));
				break;
			}
			client_list.ClientUpdate(this, (ServerClientList_Struct*) pack->pBuffer);
			break;
		}
		case ServerOP_ClientListKA: {
			ServerClientListKeepAlive_Struct* sclka = (ServerClientListKeepAlive_Struct*) pack->pBuffer;
			if (pack->size < 4 || pack->size != 4 + (4 * sclka->numupdates)) {
				zlog(WORLD__ZONE_ERR,"Wrong size on ServerOP_ClientListKA. Got: %d, Expected: %d",pack->size, (4 + (4 * sclka->numupdates)));
				break;
			}
			client_list.CLEKeepAlive(sclka->numupdates, sclka->wid);
			break;
		}
		case ServerOP_Who: {
			ServerWhoAll_Struct* whoall = (ServerWhoAll_Struct*) pack->pBuffer;
			Who_All_Struct* whom = new Who_All_Struct;
			memset(whom,0,sizeof(Who_All_Struct));
			whom->gmlookup = whoall->gmlookup;
			whom->lvllow = whoall->lvllow;
			whom->lvlhigh = whoall->lvlhigh;
			whom->wclass = whoall->wclass;
			whom->wrace = whoall->wrace;
			strcpy(whom->whom,whoall->whom);
			client_list.SendWhoAll(whoall->fromid,whoall->from, whoall->admin, whom, this);
			delete whom;
			break;
		}
		case ServerOP_RequestOnlineGuildMembers:
		{
			ServerRequestOnlineGuildMembers_Struct *srogms = (ServerRequestOnlineGuildMembers_Struct*) pack->pBuffer;
			zlog(GUILDS__IN_PACKETS, "ServerOP_RequestOnlineGuildMembers Recieved. FromID=%i GuildID=%i", srogms->FromID, srogms->GuildID);	
			client_list.SendOnlineGuildMembers(srogms->FromID, srogms->GuildID);
			break;
		}
		case ServerOP_ClientVersionSummary:
		{
			ServerRequestClientVersionSummary_Struct *srcvss = (ServerRequestClientVersionSummary_Struct*) pack->pBuffer;
			client_list.SendClientVersionSummary(srcvss->Name);
			break;
		}
		case ServerOP_ReloadRules:
		{
			zoneserver_list.SendPacket(pack);
			rules->LoadRules(&database, "default");
			break;
		}
		case ServerOP_ReloadRulesWorld:
		{
			rules->LoadRules(&database, "default");
			break;
		}
		case ServerOP_CameraShake:
		{
			zoneserver_list.SendPacket(pack);
			break;
		}
		case ServerOP_FriendsWho: {
			ServerFriendsWho_Struct* FriendsWho = (ServerFriendsWho_Struct*) pack->pBuffer;
			client_list.SendFriendsWho(FriendsWho, this);
			break;
		}
		case ServerOP_LFGMatches: {
			ServerLFGMatchesRequest_Struct* smrs = (ServerLFGMatchesRequest_Struct*) pack->pBuffer;
			client_list.SendLFGMatches(smrs);
			break;
		}
		case ServerOP_LFPMatches: {
			ServerLFPMatchesRequest_Struct* smrs = (ServerLFPMatchesRequest_Struct*) pack->pBuffer;
			LFPGroupList.SendLFPMatches(smrs);
			break;
		}
		case ServerOP_LFPUpdate: {
			ServerLFPUpdate_Struct* sus = (ServerLFPUpdate_Struct*) pack->pBuffer;	
			if(sus->Action) 
				LFPGroupList.UpdateGroup(sus);
			else
				LFPGroupList.RemoveGroup(sus);
			break;
		}
		case ServerOP_ZonePlayer: {
			//ServerZonePlayer_Struct* szp = (ServerZonePlayer_Struct*) pack->pBuffer;
			zoneserver_list.SendPacket(pack);
			break;
		}
		case ServerOP_KickPlayer: {
			zoneserver_list.SendPacket(pack);
			break;
		}
		case ServerOP_KillPlayer: {
			zoneserver_list.SendPacket(pack);
			break;
		}
		
		case ServerOP_GuildRankUpdate:
		{
			zoneserver_list.SendPacket(pack);
			break;
		}
		//these opcodes get processed by the guild manager.
		case ServerOP_RefreshGuild:
		case ServerOP_DeleteGuild:
		case ServerOP_GuildCharRefresh:
		case ServerOP_GuildMemberUpdate: {
			guild_mgr.ProcessZonePacket(pack);
			break;
		}
		
		case ServerOP_FlagUpdate: {
			ClientListEntry* cle = client_list.FindCLEByAccountID(*((uint32*) pack->pBuffer));
			if (cle)
				cle->SetAdmin(*((int16*) &pack->pBuffer[4]));
			zoneserver_list.SendPacket(pack);
			break;
		}
		case ServerOP_GMGoto: {
			if (pack->size != sizeof(ServerGMGoto_Struct)) {
				zlog(WORLD__ZONE_ERR,"Wrong size on ServerOP_GMGoto. Got: %d, Expected: %d",pack->size,sizeof(ServerGMGoto_Struct));
				break;
			}
			ServerGMGoto_Struct* gmg = (ServerGMGoto_Struct*) pack->pBuffer;
			ClientListEntry* cle = client_list.FindCharacter(gmg->gotoname);
			if (cle != 0) {
				if (cle->Server() == 0)
					this->SendEmoteMessage(gmg->myname, 0, 0, 13, "Error: Cannot identify %s's zoneserver.", gmg->gotoname);
				else if (cle->Anon() == 1 && cle->Admin() > gmg->admin) // no snooping for anon GMs
					this->SendEmoteMessage(gmg->myname, 0, 0, 13, "Error: %s not found", gmg->gotoname);
				else
					cle->Server()->SendPacket(pack);
			}
			else {
				this->SendEmoteMessage(gmg->myname, 0, 0, 13, "Error: %s not found", gmg->gotoname);
			}
			break;
		}
		case ServerOP_Lock: {
			if (pack->size != sizeof(ServerLock_Struct)) {
				zlog(WORLD__ZONE_ERR,"Wrong size on ServerOP_Lock. Got: %d, Expected: %d",pack->size,sizeof(ServerLock_Struct));
				break;
			}
			ServerLock_Struct* slock = (ServerLock_Struct*) pack->pBuffer;
  			if (slock->mode >= 1) 
				WorldConfig::LockWorld();
			else
				WorldConfig::UnlockWorld();
			if (loginserverlist.Connected()) {
				loginserverlist.SendStatus();
				if (slock->mode >= 1)
					this->SendEmoteMessage(slock->myname, 0, 0, 13, "World locked");
				else
					this->SendEmoteMessage(slock->myname, 0, 0, 13, "World unlocked");
			}
			else {
				if (slock->mode >= 1)
					this->SendEmoteMessage(slock->myname, 0, 0, 13, "World locked, but login server not connected.");
				else 
					this->SendEmoteMessage(slock->myname, 0, 0, 13, "World unlocked, but login server not conencted.");
			}
			break;
							}
		case ServerOP_Motd: {
			if (pack->size != sizeof(ServerMotd_Struct)) {
				zlog(WORLD__ZONE_ERR,"Wrong size on ServerOP_Motd. Got: %d, Expected: %d",pack->size,sizeof(ServerMotd_Struct));
				break;
			}
			ServerMotd_Struct* smotd = (ServerMotd_Struct*) pack->pBuffer;
			database.SetVariable("MOTD",smotd->motd);
			//this->SendEmoteMessage(smotd->myname, 0, 0, 13, "Updated Motd.");
			zoneserver_list.SendPacket(pack);
			break;
		}
		case ServerOP_Uptime: {
			if (pack->size != sizeof(ServerUptime_Struct)) {
				zlog(WORLD__ZONE_ERR,"Wrong size on ServerOP_Uptime. Got: %d, Expected: %d",pack->size,sizeof(ServerUptime_Struct));
				break;
			}
			ServerUptime_Struct* sus = (ServerUptime_Struct*) pack->pBuffer;
			if (sus->zoneserverid == 0) {
				ZSList::ShowUpTime(this, sus->adminname);
			}
			else {
				ZoneServer* zs = zoneserver_list.FindByID(sus->zoneserverid);
				if (zs)
					zs->SendPacket(pack);
			}
			break;
							  }
		case ServerOP_Petition: {
			zoneserver_list.SendPacket(pack);
			break;
								}
		case ServerOP_GetWorldTime: {
			zlog(WORLD__ZONE,"Broadcasting a world time update");
			ServerPacket* pack = new ServerPacket;
			
			pack->opcode = ServerOP_SyncWorldTime;
			pack->size = sizeof(eqTimeOfDay);
			pack->pBuffer = new uchar[pack->size];
			memset(pack->pBuffer, 0, pack->size);
			eqTimeOfDay* tod = (eqTimeOfDay*) pack->pBuffer;
			tod->start_eqtime=zoneserver_list.worldclock.getStartEQTime();
			tod->start_realtime=zoneserver_list.worldclock.getStartRealTime();
			SendPacket(pack);
			delete pack;
			break;
									}
		case ServerOP_SetWorldTime: {
			zlog(WORLD__ZONE,"Received SetWorldTime");
			eqTimeOfDay* newtime = (eqTimeOfDay*) pack->pBuffer;
			zoneserver_list.worldclock.setEQTimeOfDay(newtime->start_eqtime, newtime->start_realtime);
			zlog(WORLD__ZONE,"New time = %d-%d-%d %d:%d (%d)\n", newtime->start_eqtime.year, newtime->start_eqtime.month, (int)newtime->start_eqtime.day, (int)newtime->start_eqtime.hour, (int)newtime->start_eqtime.minute, (int)newtime->start_realtime);
			zoneserver_list.worldclock.saveFile(WorldConfig::get()->EQTimeFile.c_str());
			zoneserver_list.SendTimeSync();
			break;
		}
		case ServerOP_IPLookup: {
			if (pack->size < sizeof(ServerGenericWorldQuery_Struct)) {
				zlog(WORLD__ZONE_ERR,"Wrong size on ServerOP_IPLookup. Got: %d, Expected (at least): %d",pack->size,sizeof(ServerGenericWorldQuery_Struct));
				break;
			}
			ServerGenericWorldQuery_Struct* sgwq = (ServerGenericWorldQuery_Struct*) pack->pBuffer;
			if (pack->size == sizeof(ServerGenericWorldQuery_Struct))
				client_list.SendCLEList(sgwq->admin, sgwq->from, this);
			else
				client_list.SendCLEList(sgwq->admin, sgwq->from, this, sgwq->query);
			break;
		}
		case ServerOP_LockZone: {
			if (pack->size < sizeof(ServerLockZone_Struct)) {
				zlog(WORLD__ZONE_ERR,"Wrong size on ServerOP_LockZone. Got: %d, Expected: %d",pack->size,sizeof(ServerLockZone_Struct));
				break;
			}
			ServerLockZone_Struct* s = (ServerLockZone_Struct*) pack->pBuffer;
			switch (s->op) {
				case 0:
					zoneserver_list.ListLockedZones(s->adminname, this);
					break;
				case 1:
					if (zoneserver_list.SetLockedZone(s->zoneID, true))
						zoneserver_list.SendEmoteMessage(0, 0, 80, 15, "Zone locked: %s", database.GetZoneName(s->zoneID));
					else
						this->SendEmoteMessageRaw(s->adminname, 0, 0, 0, "Failed to change lock");
					break;
				case 2:
					if (zoneserver_list.SetLockedZone(s->zoneID, false))
						zoneserver_list.SendEmoteMessage(0, 0, 80, 15, "Zone unlocked: %s", database.GetZoneName(s->zoneID));
					else
						this->SendEmoteMessageRaw(s->adminname, 0, 0, 0, "Failed to change lock");
					break;
			}
			break;
		}
		case ServerOP_ItemStatus: {
			zoneserver_list.SendPacket(pack);
			break;
		}
		case ServerOP_OOCMute: {
			zoneserver_list.SendPacket(pack);
			break;
		}
		case ServerOP_Revoke: {
			RevokeStruct* rev = (RevokeStruct*)pack->pBuffer;
			ClientListEntry* cle = client_list.FindCharacter(rev->name);
			if (cle != 0 && cle->Server() != 0)
			{
				cle->Server()->SendPacket(pack);
			}
			break;
		}
		case ServerOP_SpawnPlayerCorpse: {
			SpawnPlayerCorpse_Struct* s = (SpawnPlayerCorpse_Struct*)pack->pBuffer;
			ZoneServer* zs = zoneserver_list.FindByZoneID(s->zone_id);
			if(zs) {
				if (zs->SendPacket(pack)) {
					zlog(WORLD__ZONE,"Sent request to spawn player corpse id %i in zone %u.",s->player_corpse_id, s->zone_id);
				}
				else {
					zlog(WORLD__ZONE_ERR,"Could not send request to spawn player corpse id %i in zone %u.",s->player_corpse_id, s->zone_id);
				}
			}
			break;
		}
	    case ServerOP_Consent: {
			// Message string id's likely to be used here are:
			// CONSENT_YOURSELF = 399
			// CONSENT_INVALID_NAME = 397
			// TARGET_NOT_FOUND = 101
			ZoneServer* zs;
			ServerOP_Consent_Struct* s = (ServerOP_Consent_Struct*)pack->pBuffer;
			ClientListEntry* cle = client_list.FindCharacter(s->grantname);
			if(cle) {
				if(cle->instance() != 0)
				{
					zs = zoneserver_list.FindByInstanceID(cle->instance());
					if(zs) {
						if(zs->SendPacket(pack)) {
							zlog(WORLD__ZONE, "Sent consent packet from player %s to player %s in zone %u.", s->ownername, s->grantname, cle->instance());
						}
						else {
							zlog(WORLD__ZONE_ERR, "Unable to locate zone record for instance id %u in zoneserver list for ServerOP_Consent operation.", s->instance_id);
						}
					}
					else
					{
						delete pack;
						pack = new ServerPacket(ServerOP_Consent_Response, sizeof(ServerOP_Consent_Struct));
						ServerOP_Consent_Struct* scs = (ServerOP_Consent_Struct*)pack->pBuffer;
						strcpy(scs->grantname, s->grantname);
						strcpy(scs->ownername, s->ownername);
						scs->permission = s->permission;
						scs->zone_id = s->zone_id;
						scs->instance_id = s->instance_id;
						scs->message_string_id = 101;
						zs = zoneserver_list.FindByInstanceID(s->instance_id);
						if(zs) {
							if(!zs->SendPacket(pack))
								zlog(WORLD__ZONE_ERR, "Unable to send consent response back to player %s in instance %u.", s->ownername, zs->GetInstanceID());
						}
						else {
							zlog(WORLD__ZONE_ERR, "Unable to locate zone record for instance id %u in zoneserver list for ServerOP_Consent_Response operation.", s->instance_id);
						}
					}
				}
				else
				{
					zs = zoneserver_list.FindByZoneID(cle->zone());
					if(zs) {
						if(zs->SendPacket(pack)) {
							zlog(WORLD__ZONE, "Sent consent packet from player %s to player %s in zone %u.", s->ownername, s->grantname, cle->zone());
						}
						else {
							zlog(WORLD__ZONE_ERR, "Unable to locate zone record for zone id %u in zoneserver list for ServerOP_Consent operation.", s->zone_id);
						}
					}
					else {
						// send target not found back to requester
						delete pack;
						pack = new ServerPacket(ServerOP_Consent_Response, sizeof(ServerOP_Consent_Struct));
						ServerOP_Consent_Struct* scs = (ServerOP_Consent_Struct*)pack->pBuffer;
						strcpy(scs->grantname, s->grantname);
						strcpy(scs->ownername, s->ownername);
						scs->permission = s->permission;
						scs->zone_id = s->zone_id;
						scs->message_string_id = 101;
						zs = zoneserver_list.FindByZoneID(s->zone_id);
						if(zs) {
							if(!zs->SendPacket(pack))
								zlog(WORLD__ZONE_ERR, "Unable to send consent response back to player %s in zone %s.", s->ownername, zs->GetZoneName());
						}
						else {
							zlog(WORLD__ZONE_ERR, "Unable to locate zone record for zone id %u in zoneserver list for ServerOP_Consent_Response operation.", s->zone_id);
						}
					}
				}
			}
			else {
				// send target not found back to requester
				delete pack;
				pack = new ServerPacket(ServerOP_Consent_Response, sizeof(ServerOP_Consent_Struct));
				ServerOP_Consent_Struct* scs = (ServerOP_Consent_Struct*)pack->pBuffer;
				strcpy(scs->grantname, s->grantname);
				strcpy(scs->ownername, s->ownername);
				scs->permission = s->permission;
				scs->zone_id = s->zone_id;
				scs->message_string_id = 397;
				zs = zoneserver_list.FindByZoneID(s->zone_id);
				if(zs) {
					if(!zs->SendPacket(pack))
						zlog(WORLD__ZONE_ERR, "Unable to send consent response back to player %s in zone %s.", s->ownername, zs->GetZoneName());
				}
				else {
					zlog(WORLD__ZONE_ERR, "Unable to locate zone record for zone id %u in zoneserver list for ServerOP_Consent_Response operation.", s->zone_id);
				}
			}
			break;
		}
		case ServerOP_Consent_Response: {
			// Message string id's likely to be used here are:
			// CONSENT_YOURSELF = 399
			// CONSENT_INVALID_NAME = 397
			// TARGET_NOT_FOUND = 101
			ServerOP_Consent_Struct* s = (ServerOP_Consent_Struct*)pack->pBuffer;
			if(s->instance_id != 0)
			{
				ZoneServer* zs = zoneserver_list.FindByInstanceID(s->instance_id);
				if(zs) {
					if(!zs->SendPacket(pack))
						zlog(WORLD__ZONE_ERR, "Unable to send consent response back to player %s in instance %u.", s->ownername, zs->GetInstanceID());
				}
				else {
					zlog(WORLD__ZONE_ERR, "Unable to locate zone record for instance id %u in zoneserver list for ServerOP_Consent_Response operation.", s->instance_id);
				}
			}
			else
			{
				ZoneServer* zs = zoneserver_list.FindByZoneID(s->zone_id);
				if(zs) {
					if(!zs->SendPacket(pack))
						zlog(WORLD__ZONE_ERR, "Unable to send consent response back to player %s in zone %s.", s->ownername, zs->GetZoneName());
				}
				else {
					zlog(WORLD__ZONE_ERR, "Unable to locate zone record for zone id %u in zoneserver list for ServerOP_Consent_Response operation.", s->zone_id);
				}
			}
			break;
		}

		case ServerOP_InstanceUpdateTime :
		{
			ServerInstanceUpdateTime_Struct *iut = (ServerInstanceUpdateTime_Struct*)pack->pBuffer;
			ZoneServer *zm = zoneserver_list.FindByInstanceID(iut->instance_id);
			if(zm)
			{
				zm->SendPacket(pack);
			}
			break;
		}
		case ServerOP_QGlobalUpdate:
		{
			if(pack->size != sizeof(ServerQGlobalUpdate_Struct))
			{
				break;
			}

			zoneserver_list.SendPacket(pack);
			break;		
		}

		case ServerOP_QGlobalDelete:
		{
			if(pack->size != sizeof(ServerQGlobalDelete_Struct))
			{
				break;
			}

			zoneserver_list.SendPacket(pack);
			break;		
		}

		case ServerOP_AdventureRequest:
		{
			adventure_manager.CalculateAdventureRequestReply((const char*)pack->pBuffer);
			break;
		}

		case ServerOP_AdventureRequestCreate:
		{
			adventure_manager.TryAdventureCreate((const char*)pack->pBuffer);
			break;
		}

		case ServerOP_AdventureDataRequest:
		{
			AdventureFinishEvent fe;
			while(adventure_manager.PopFinishedEvent((const char*)pack->pBuffer, fe))
			{
				adventure_manager.SendAdventureFinish(fe);
			}
			adventure_manager.GetAdventureData((const char*)pack->pBuffer);
			break;
		}

		case ServerOP_AdventureClickDoor:
		{
			ServerPlayerClickedAdventureDoor_Struct *pcad = (ServerPlayerClickedAdventureDoor_Struct*)pack->pBuffer;
			adventure_manager.PlayerClickedDoor(pcad->player, pcad->zone_id, pcad->id);
			break;
		}

		case ServerOP_AdventureLeave:
		{
			adventure_manager.LeaveAdventure((const char*)pack->pBuffer);
			break;
		}

		case ServerOP_AdventureCountUpdate:
		{
			ServerAdventureCount_Struct *sc = (ServerAdventureCount_Struct*)pack->pBuffer;
			adventure_manager.IncrementCount(sc->instance_id);
			break;
		}

		case ServerOP_AdventureAssaCountUpdate:
		{
			adventure_manager.IncrementAssassinationCount(*((uint16*)pack->pBuffer));
			break;
		}

		case ServerOP_AdventureZoneData:
		{
			adventure_manager.GetZoneData(*((uint16*)pack->pBuffer));
			break;
		}

		case ServerOP_AdventureLeaderboard:
		{
			ServerLeaderboardRequest_Struct *lr = (ServerLeaderboardRequest_Struct*)pack->pBuffer;
			adventure_manager.DoLeaderboardRequest(lr->player, lr->type);
			break;
		}

		case ServerOP_LSAccountUpdate:
		{
			zlog(WORLD__ZONE, "Received ServerOP_LSAccountUpdate packet from zone");
			loginserverlist.SendAccountUpdate(pack);
			break;
		}

		case ServerOP_UCSMailMessage: 
		{
			UCSLink.SendPacket(pack);
			break;
		}

		case ServerOP_QueryServGeneric:
		case ServerOP_Speech:
		case ServerOP_QSPlayerLogTrades:
		{
			QSLink.SendPacket(pack);
			break;
		}
		case ServerOP_QSPlayerLogHandins:
		{
			QSLink.SendPacket(pack);
			break;
		}
		case ServerOP_QSPlayerLogNPCKills:
		{
			QSLink.SendPacket(pack);
			break;
		}
		case ServerOP_QSPlayerLogDeletes:
		{
			QSLink.SendPacket(pack);
			break;
		}
		case ServerOP_QSPlayerLogMoves:
		{
			QSLink.SendPacket(pack);
			break;
		}
		case ServerOP_QSMerchantLogTransactions:
		{
			QSLink.SendPacket(pack);
			break;
		}
		case ServerOP_CZSignalClientByName:
		case ServerOP_CZMessagePlayer:
		case ServerOP_CZSignalClient:
		{
			zoneserver_list.SendPacket(pack);
			break;
		}
		case ServerOP_DepopAllPlayersCorpses:
		case ServerOP_DepopPlayerCorpse:
		case ServerOP_ReloadTitles:
		case ServerOP_SpawnStatusChange:
		case ServerOP_ReloadTasks:
		case ServerOP_ReloadWorld:
		case ServerOP_UpdateSpawn:
		{
			zoneserver_list.SendPacket(pack);
			break;
		}
		default:
		{
			zlog(WORLD__ZONE_ERR,"Unknown ServerOPcode from zone 0x%04x, size %d",pack->opcode,pack->size);
			DumpPacket(pack->pBuffer, pack->size);
			break;
		}
		}

		delete pack;
	} 
	return true;
}
Exemplo n.º 19
0
void Adventure::Finished(AdventureWinStatus ws)
{
	list<string>::iterator iter = players.begin();
	while(iter != players.end())
	{
		ClientListEntry *current = client_list.FindCharacter((*iter).c_str());
		if(current)
		{
			if(current->Online() == CLE_Status_InZone)
			{
				//We can send our packets only.
				ServerPacket *pack = new ServerPacket(ServerOP_AdventureFinish, sizeof(ServerAdventureFinish_Struct));
				ServerAdventureFinish_Struct *af = (ServerAdventureFinish_Struct*)pack->pBuffer;
				strcpy(af->player, (*iter).c_str());
				af->theme = GetTemplate()->theme;
				if(ws == AWS_Win)
				{
					af->win = true;
					af->points = GetTemplate()->win_points;
				}
				else if(ws == AWS_SecondPlace)
				{
					af->win = true;
					af->points = GetTemplate()->lose_points;
				}
				else
				{
					af->win = false;
					af->points = 0;
				}
				pack->Deflate();
				zoneserver_list.SendPacket(current->zone(), current->instance(), pack);
				database.UpdateAdventureStatsEntry(database.GetCharacterID((*iter).c_str()), GetTemplate()->theme, (ws != AWS_Lose) ? true : false);
				delete pack;
			}
			else
			{
				AdventureFinishEvent afe;
				afe.name = (*iter);
				if(ws == AWS_Win)
				{
					afe.theme = GetTemplate()->theme;
					afe.points = GetTemplate()->win_points;
					afe.win = true;
				}
				else if(ws == AWS_SecondPlace)
				{
					afe.theme = GetTemplate()->theme;
					afe.points = GetTemplate()->lose_points;
					afe.win = true;
				}
				else
				{
					afe.win = false;
					afe.points = 0;
				}
				adventure_manager.AddFinishedEvent(afe);
				database.UpdateAdventureStatsEntry(database.GetCharacterID((*iter).c_str()), GetTemplate()->theme, (ws != AWS_Lose) ? true : false);
			}
		}
		else
		{
			AdventureFinishEvent afe;
			afe.name = (*iter);
			if(ws == AWS_Win)
			{
				afe.theme = GetTemplate()->theme;
				afe.points = GetTemplate()->win_points;
				afe.win = true;
			}
			else if(ws == AWS_SecondPlace)
			{
				afe.theme = GetTemplate()->theme;
				afe.points = GetTemplate()->lose_points;
				afe.win = true;
			}
			else
			{
				afe.win = false;
				afe.points = 0;
			}
			adventure_manager.AddFinishedEvent(afe);
			database.UpdateAdventureStatsEntry(database.GetCharacterID((*iter).c_str()), GetTemplate()->theme, (ws != AWS_Lose) ? true : false);
		}
		iter++;
	}
	adventure_manager.GetAdventureData(this);
}
Exemplo n.º 20
0
void ClientList::SendWhoAll(uint32 fromid,const char* to, int16 admin, Who_All_Struct* whom, WorldTCPConnection* connection) {
	try{
	LinkedListIterator<ClientListEntry*> iterator(clientlist);
	LinkedListIterator<ClientListEntry*> countclients(clientlist);
	ClientListEntry* cle = 0;
	ClientListEntry* countcle = 0;
	//char tmpgm[25] = "";
	//char accinfo[150] = "";
	char line[300] = "";
	//char tmpguild[50] = "";
	//char LFG[10] = "";
	//uint32 x = 0;
	int whomlen = 0;
	if (whom) {
		whomlen = strlen(whom->whom);
		if(whom->wrace == 0x1A) // 0x001A is the old Froglok race number and is sent by the client for /who all froglok
			whom->wrace = FROGLOK; // This is what EQEmu uses for the Froglok Race number.
	}

	char* output = 0;
	uint32 outsize = 0, outlen = 0;
	uint16 totalusers=0;
	uint16 totallength=0;
	AppendAnyLenString(&output, &outsize, &outlen, "Players on server:");
	if (connection->IsConsole())
		AppendAnyLenString(&output, &outsize, &outlen, "\r\n");
	else
		AppendAnyLenString(&output, &outsize, &outlen, "\n");
	countclients.Reset();
	while(countclients.MoreElements()){
		countcle = countclients.GetData();
		const char* tmpZone = database.GetZoneName(countcle->zone());
		if (
	(countcle->Online() >= CLE_Status_Zoning) &&
	(!countcle->GetGM() || countcle->Anon() != 1 || admin >= countcle->Admin()) &&
	(whom == 0 || (
		((countcle->Admin() >= 80 && countcle->GetGM()) || whom->gmlookup == 0xFFFF) &&
		(whom->lvllow == 0xFFFF || (countcle->level() >= whom->lvllow && countcle->level() <= whom->lvlhigh && (countcle->Anon()==0 || admin > countcle->Admin()))) &&
		(whom->wclass == 0xFFFF || (countcle->class_() == whom->wclass && (countcle->Anon()==0 || admin > countcle->Admin()))) &&
		(whom->wrace == 0xFFFF || (countcle->race() == whom->wrace && (countcle->Anon()==0 || admin > countcle->Admin()))) &&
		(whomlen == 0 || (
			(tmpZone != 0 && strncasecmp(tmpZone, whom->whom, whomlen) == 0) ||
			strncasecmp(countcle->name(),whom->whom, whomlen) == 0 ||
			(strncasecmp(guild_mgr.GetGuildName(countcle->GuildID()), whom->whom, whomlen) == 0) ||
			(admin >= 100 && strncasecmp(countcle->AccountName(), whom->whom, whomlen) == 0)
		))
	))
) {
			if((countcle->Anon()>0 && admin>=countcle->Admin() && admin>0) || countcle->Anon()==0 ){
				totalusers++;
				if(totalusers<=20 || admin>=100)
					totallength=totallength+strlen(countcle->name())+strlen(countcle->AccountName())+strlen(guild_mgr.GetGuildName(countcle->GuildID()))+5;
			}
			else if((countcle->Anon()>0 && admin<=countcle->Admin()) || countcle->Anon()==0 && !countcle->GetGM()){
				totalusers++;
				if(totalusers<=20 || admin>=100)
					totallength=totallength+strlen(countcle->name())+strlen(guild_mgr.GetGuildName(countcle->GuildID()))+5;
			}
		}
		countclients.Advance();
	}
	uint16 plid=fromid;
	uint16 playerineqstring=5001;
	const char line2[]="---------------------------";
	uint8 unknown35=0x0A;
	uint16 unknown36=0;
	uint16 playersinzonestring=5028;
	if(totalusers>20 && admin<100){
		totalusers=20;
		playersinzonestring=5033;
	}
	else if(totalusers>1)
		playersinzonestring=5036;
	uint16 unknown44[5];
	unknown44[0]=0;
	unknown44[1]=0;
	unknown44[2]=0;
	unknown44[3]=0;
	unknown44[4]=0;
	uint32 unknown52=totalusers;
	uint32 unknown56=1;
	ServerPacket* pack2 = new ServerPacket(ServerOP_WhoAllReply,58+totallength+(30*totalusers));
	memset(pack2->pBuffer,0,pack2->size);
	uchar *buffer=pack2->pBuffer;
	uchar *bufptr=buffer;
	//memset(buffer,0,pack2->size);
	memcpy(bufptr,&plid, sizeof(uint32));
	bufptr+=sizeof(uint32);
	memcpy(bufptr,&playerineqstring, sizeof(uint16));
	bufptr+=sizeof(uint16);
	memcpy(bufptr,&line2, strlen(line2));
	bufptr+=strlen(line2);
	memcpy(bufptr,&unknown35, sizeof(uint8));
	bufptr+=sizeof(uint8);
	memcpy(bufptr,&unknown36, sizeof(uint16));
	bufptr+=sizeof(uint16);
	memcpy(bufptr,&playersinzonestring, sizeof(uint16));
	bufptr+=sizeof(uint16);
	memcpy(bufptr,&unknown44[0], sizeof(uint16));
	bufptr+=sizeof(uint16);
	memcpy(bufptr,&unknown44[1], sizeof(uint16));
	bufptr+=sizeof(uint16);
	memcpy(bufptr,&unknown44[2], sizeof(uint16));
	bufptr+=sizeof(uint16);
	memcpy(bufptr,&unknown44[3], sizeof(uint16));
	bufptr+=sizeof(uint16);
	memcpy(bufptr,&unknown44[4], sizeof(uint16));
	bufptr+=sizeof(uint16);
	memcpy(bufptr,&unknown52, sizeof(uint32));
	bufptr+=sizeof(uint32);
	memcpy(bufptr,&unknown56, sizeof(uint32));
	bufptr+=sizeof(uint32);
	memcpy(bufptr,&totalusers, sizeof(uint16));
	bufptr+=sizeof(uint16);

	iterator.Reset();
	int idx=-1;
	while(iterator.MoreElements()) {
		cle = iterator.GetData();

		const char* tmpZone = database.GetZoneName(cle->zone());
		if (
	(cle->Online() >= CLE_Status_Zoning) &&
	(!cle->GetGM() || cle->Anon() != 1 || admin >= cle->Admin()) &&
	(whom == 0 || (
		((cle->Admin() >= 80 && cle->GetGM()) || whom->gmlookup == 0xFFFF) &&
		(whom->lvllow == 0xFFFF || (cle->level() >= whom->lvllow && cle->level() <= whom->lvlhigh && (cle->Anon()==0 || admin>cle->Admin()))) &&
		(whom->wclass == 0xFFFF || (cle->class_() == whom->wclass && (cle->Anon()==0 || admin>cle->Admin()))) &&
		(whom->wrace == 0xFFFF || (cle->race() == whom->wrace && (cle->Anon()==0 || admin>cle->Admin()))) &&
		(whomlen == 0 || (
			(tmpZone != 0 && strncasecmp(tmpZone, whom->whom, whomlen) == 0) ||
			strncasecmp(cle->name(),whom->whom, whomlen) == 0 ||
			(strncasecmp(guild_mgr.GetGuildName(cle->GuildID()), whom->whom, whomlen) == 0) ||
			(admin >= 100 && strncasecmp(cle->AccountName(), whom->whom, whomlen) == 0)
		))
	))
) {
			line[0] = 0;
			uint16 rankstring=0xFFFF;
				if((cle->Anon()==1 && cle->GetGM() && cle->Admin()>admin) || (idx>=20 && admin<100)){ //hide gms that are anon from lesser gms and normal players, cut off at 20
					rankstring=0;
					iterator.Advance();
					continue;
				} else if (cle->GetGM()) {
					if (cle->Admin() >=250)
						rankstring=5021;
					else if (cle->Admin() >= 200)
						rankstring=5020;
					else if (cle->Admin() >= 180)
						rankstring=5019;
					else if (cle->Admin() >= 170)
						rankstring=5018;
					else if (cle->Admin() >= 160)
						rankstring=5017;
					else if (cle->Admin() >= 150)
						rankstring=5016;
					else if (cle->Admin() >= 100)
						rankstring=5015;
					else if (cle->Admin() >= 95)
						rankstring=5014;
					else if (cle->Admin() >= 90)
						rankstring=5013;
					else if (cle->Admin() >= 85)
						rankstring=5012;
					else if (cle->Admin() >= 81)
						rankstring=5011;
					else if (cle->Admin() >= 80)
						rankstring=5010;
					else if (cle->Admin() >= 50)
						rankstring=5009;
					else if (cle->Admin() >= 20)
						rankstring=5008;
					else if (cle->Admin() >= 10)
						rankstring=5007;
				}
			idx++;
			char guildbuffer[67]={0};
			if (cle->GuildID() != GUILD_NONE && cle->GuildID()>0)
				sprintf(guildbuffer,"<%s>", guild_mgr.GetGuildName(cle->GuildID()));
			uint16 formatstring=5025;
			if(cle->Anon()==1 && (admin<cle->Admin() || admin==0))
				formatstring=5024;
			else if(cle->Anon()==1 && admin>=cle->Admin() && admin>0)
				formatstring=5022;
			else if(cle->Anon()==2 && (admin<cle->Admin() || admin==0))
				formatstring=5023;//display guild
			else if(cle->Anon()==2 && admin>=cle->Admin() && admin>0)
				formatstring=5022;//display everything

	//war* wars2 = (war*)pack2->pBuffer;

	uint16 plclass_=0;
	uint16 pllevel=0;
	uint16 pidstring=0xFFFF;//5003;
	uint16 plrace=0;
	uint16 zonestring=0xFFFF;
	uint32 plzone=0;
	uint16 unknown80[3];
	if(cle->Anon()==0 || (admin>=cle->Admin() && admin>0)){
		plclass_=cle->class_();
		pllevel=cle->level();
		if(admin>=100)
			pidstring=5003;
		plrace=cle->race();
		zonestring=5006;
		plzone=cle->zone();
	}


	if(admin>=cle->Admin() && admin>0)
		unknown80[0]=cle->Admin();
	else
	unknown80[0]=0xFFFF;
	unknown80[1]=0xFFFF;//1035
	unknown80[2]=0xFFFF;

	//char plstatus[20]={0};
	//sprintf(plstatus, "Status %i",cle->Admin());
	char plname[64]={0};
	strcpy(plname,cle->name());

	char placcount[30]={0};
	if(admin>=cle->Admin() && admin>0)
		strcpy(placcount,cle->AccountName());

	memcpy(bufptr,&formatstring, sizeof(uint16));
	bufptr+=sizeof(uint16);
	memcpy(bufptr,&pidstring, sizeof(uint16));
	bufptr+=sizeof(uint16);
	memcpy(bufptr,&plname, strlen(plname)+1);
	bufptr+=strlen(plname)+1;
	memcpy(bufptr,&rankstring, sizeof(uint16));
	bufptr+=sizeof(uint16);
	memcpy(bufptr,&guildbuffer, strlen(guildbuffer)+1);
	bufptr+=strlen(guildbuffer)+1;
	memcpy(bufptr,&unknown80[0], sizeof(uint16));
	bufptr+=sizeof(uint16);
	memcpy(bufptr,&unknown80[1], sizeof(uint16));
	bufptr+=sizeof(uint16);
	memcpy(bufptr,&unknown80[2], sizeof(uint16));
	bufptr+=sizeof(uint16);
	memcpy(bufptr,&zonestring, sizeof(uint16));
	bufptr+=sizeof(uint16);
	memcpy(bufptr,&plzone, sizeof(uint32));
	bufptr+=sizeof(uint32);
	memcpy(bufptr,&plclass_, sizeof(uint16));
	bufptr+=sizeof(uint16);
	memcpy(bufptr,&pllevel, sizeof(uint16));
	bufptr+=sizeof(uint16);
	memcpy(bufptr,&plrace, sizeof(uint16));
	bufptr+=sizeof(uint16);
	uint16 ending=0;
	memcpy(bufptr,&placcount, strlen(placcount)+1);
	bufptr+=strlen(placcount)+1;
	ending=211;
	memcpy(bufptr,&ending, sizeof(uint16));
	bufptr+=sizeof(uint16);
		}
		iterator.Advance();
	}
	pack2->Deflate();
	//zoneserver_list.SendPacket(pack2); // NO NO NO WHY WOULD YOU SEND IT TO EVERY ZONE SERVER?!?
	SendPacket(to,pack2);
	safe_delete(pack2);
	safe_delete(output);
	}
	catch(...){
		_log(WORLD__ZONELIST_ERR,"Unknown error in world's SendWhoAll (probably mem error), ignoring... Player id is: %i, Name is: %s", fromid, to);
		return;
	}
}
Exemplo n.º 21
0
void ClientList::SendLFGMatches(ServerLFGMatchesRequest_Struct *smrs) {

	// Send back matches when someone searches player's Looking For A Group.

	LinkedListIterator<ClientListEntry*> Iterator(clientlist);
	ClientListEntry* CLE = 0;
	int Matches = 0;

	Iterator.Reset();

	// We run the ClientList twice. The first time is to determine how big the outgoing packet needs to be.
	while(Iterator.MoreElements()) {
		CLE = Iterator.GetData();
		if(CLE->LFG()) {
			unsigned int BitMask = 1 << CLE->class_();
			// First we check that the player meets the level and class criteria of the person
			// doing the search.
			if((CLE->level() >= smrs->FromLevel) && (CLE->level() <= smrs->ToLevel) &&
			   (BitMask & smrs->Classes))
			   	// Then we check if if the player doing the search meets the level criteria specified
				// by the player who is LFG.
				//
				// GetLFGMatchFilter returns the setting of the 'Only players who match my posted filters
				//						 can query me' checkbox.
				//
				// FromLevel and ToLevel are the settings of the 'Want group levels:' boxes.
			   	if(!CLE->GetLFGMatchFilter() || ((smrs->QuerierLevel >= CLE->GetLFGFromLevel()) &&
								 (smrs->QuerierLevel <= CLE->GetLFGToLevel())))
					Matches++;
		}
		Iterator.Advance();
	}
	ServerPacket* Pack = new ServerPacket(ServerOP_LFGMatches, (sizeof(ServerLFGMatchesResponse_Struct) * Matches) + 4);

	char *Buf = (char *)Pack->pBuffer;
	// FromID is the Entity ID of the player doing the search.
	VARSTRUCT_ENCODE_TYPE(int32, Buf, smrs->FromID);

	ServerLFGMatchesResponse_Struct* Buffer = (ServerLFGMatchesResponse_Struct*)Buf;

	Iterator.Reset();

	if(Matches) {
		while(Iterator.MoreElements() && (Matches > 0)) {
			CLE = Iterator.GetData();
			if(CLE->LFG()) {
				unsigned int BitMask = 1 << CLE->class_();
				if((CLE->level() >= smrs->FromLevel) && (CLE->level() <= smrs->ToLevel) &&
				   (BitMask & smrs->Classes)) {
					Matches--;
					strcpy(Buffer->Name, CLE->name());
					Buffer->Class_ = CLE->class_();
					Buffer->Level = CLE->level();
					Buffer->Zone = CLE->zone();
					// If the LFG player is anon, level and class are still displayed, but
					// zone shows as UNAVAILABLE.
					Buffer->Anon = (CLE->Anon() != 0);
					// The client can filter on Guildname
					Buffer->GuildID = CLE->GuildID();
					strcpy(Buffer->Comments, CLE->GetLFGComments());
					Buffer++;
				}
			}
			Iterator.Advance();
		}
		Pack->Deflate();
	}
	SendPacket(smrs->FromName,Pack);
	safe_delete(Pack);
}
Exemplo n.º 22
0
void ClientList::ConsoleSendWhoAll(const char* to, int16 admin, Who_All_Struct* whom, WorldTCPConnection* connection) {
	LinkedListIterator<ClientListEntry*> iterator(clientlist);
	ClientListEntry* cle = 0;
	char tmpgm[25] = "";
	char accinfo[150] = "";
	char line[300] = "";
	char tmpguild[50] = "";
	char LFG[10] = "";
	uint32 x = 0;
	int whomlen = 0;
	if (whom)
		whomlen = strlen(whom->whom);

	char* output = 0;
	uint32 outsize = 0, outlen = 0;
	AppendAnyLenString(&output, &outsize, &outlen, "Players on server:");
	if (connection->IsConsole())
		AppendAnyLenString(&output, &outsize, &outlen, "\r\n");
	else
		AppendAnyLenString(&output, &outsize, &outlen, "\n");
	iterator.Reset();
	while(iterator.MoreElements()) {
		cle = iterator.GetData();
		const char* tmpZone = database.GetZoneName(cle->zone());
		if (
	(cle->Online() >= CLE_Status_Zoning)
	&& (whom == 0 || (
		((cle->Admin() >= 80 && cle->GetGM()) || whom->gmlookup == 0xFFFF) &&
		(whom->lvllow == 0xFFFF || (cle->level() >= whom->lvllow && cle->level() <= whom->lvlhigh)) &&
		(whom->wclass == 0xFFFF || cle->class_() == whom->wclass) &&
		(whom->wrace == 0xFFFF || cle->race() == whom->wrace) &&
		(whomlen == 0 || (
			(tmpZone != 0 && strncasecmp(tmpZone, whom->whom, whomlen) == 0) ||
			strncasecmp(cle->name(),whom->whom, whomlen) == 0 ||
			(strncasecmp(guild_mgr.GetGuildName(cle->GuildID()), whom->whom, whomlen) == 0) ||
			(admin >= 100 && strncasecmp(cle->AccountName(), whom->whom, whomlen) == 0)
		))
	))
) {
			line[0] = 0;
// MYRA - use new (5.x) Status labels in who for telnet connection
			if (cle->Admin() >=250)
				strcpy(tmpgm, "* GM-Impossible * ");
			else if (cle->Admin() >= 200)
				strcpy(tmpgm, "* GM-Mgmt * ");
			else if (cle->Admin() >= 180)
				strcpy(tmpgm, "* GM-Coder * ");
			else if (cle->Admin() >= 170)
				strcpy(tmpgm, "* GM-Areas * ");
			else if (cle->Admin() >= 160)
				strcpy(tmpgm, "* QuestMaster * ");
			else if (cle->Admin() >= 150)
				strcpy(tmpgm, "* GM-Lead Admin * ");
			else if (cle->Admin() >= 100)
				strcpy(tmpgm, "* GM-Admin * ");
			else if (cle->Admin() >= 95)
				strcpy(tmpgm, "* GM-Staff * ");
			else if (cle->Admin() >= 90)
				strcpy(tmpgm, "* EQ Support * ");
			else if (cle->Admin() >= 85)
				strcpy(tmpgm, "* GM-Tester * ");
			else if (cle->Admin() >= 81)
				strcpy(tmpgm, "* Senior Guide * ");
			else if (cle->Admin() >= 80)
				strcpy(tmpgm, "* QuestTroupe * ");
			else if (cle->Admin() >= 50)
				strcpy(tmpgm, "* Guide * ");
			else if (cle->Admin() >= 20)
				strcpy(tmpgm, "* Apprentice Guide * ");
			else if (cle->Admin() >= 10)
				strcpy(tmpgm, "* Steward * ");
			else
				tmpgm[0] = 0;
// end Myra

			if (guild_mgr.GuildExists(cle->GuildID())) {
				snprintf(tmpguild, 36, " <%s>", guild_mgr.GetGuildName(cle->GuildID()));
			} else
				tmpguild[0] = 0;

			if (cle->LFG())
				strcpy(LFG, " LFG");
			else
				LFG[0] = 0;

			if (admin >= 150 && admin >= cle->Admin()) {
				sprintf(accinfo, " AccID: %i AccName: %s LSID: %i Status: %i", cle->AccountID(), cle->AccountName(), cle->LSAccountID(), cle->Admin());
			}
			else
				accinfo[0] = 0;

			if (cle->Anon() == 2) { // Roleplay
				if (admin >= 100 && admin >= cle->Admin())
					sprintf(line, "  %s[RolePlay %i %s] %s (%s)%s zone: %s%s%s", tmpgm, cle->level(), GetEQClassName(cle->class_(),cle->level()), cle->name(), GetRaceName(cle->race()), tmpguild, tmpZone, LFG, accinfo);
				else if (cle->Admin() >= 80 && admin < 80 && cle->GetGM()) {
					iterator.Advance();
					continue;
				}
				else
					sprintf(line, "  %s[ANONYMOUS] %s%s%s%s", tmpgm, cle->name(), tmpguild, LFG, accinfo);
			}
			else if (cle->Anon() == 1) { // Anon
				if (admin >= 100 && admin >= cle->Admin())
					sprintf(line, "  %s[ANON %i %s] %s (%s)%s zone: %s%s%s", tmpgm, cle->level(), GetEQClassName(cle->class_(),cle->level()), cle->name(), GetRaceName(cle->race()), tmpguild, tmpZone, LFG, accinfo);
				else if (cle->Admin() >= 80 && cle->GetGM()) {
					iterator.Advance();
					continue;
				}
				else
					sprintf(line, "  %s[ANONYMOUS] %s%s%s", tmpgm, cle->name(), LFG, accinfo);
			}
			else
				sprintf(line, "  %s[%i %s] %s (%s)%s zone: %s%s%s", tmpgm, cle->level(), GetEQClassName(cle->class_(),cle->level()), cle->name(), GetRaceName(cle->race()), tmpguild, tmpZone, LFG, accinfo);

			AppendAnyLenString(&output, &outsize, &outlen, line);
			if (outlen >= 3584) {
				connection->SendEmoteMessageRaw(to, 0, 0, 10, output);
				safe_delete(output);
				outsize = 0;
				outlen = 0;
			}
			else {
				if (connection->IsConsole())
					AppendAnyLenString(&output, &outsize, &outlen, "\r\n");
				else
					AppendAnyLenString(&output, &outsize, &outlen, "\n");
			}
			x++;
			if (x >= 20 && admin < 80)
				break;
		}
		iterator.Advance();
	}

	if (x >= 20 && admin < 80)
		AppendAnyLenString(&output, &outsize, &outlen, "too many results...20 players shown");
	else
		AppendAnyLenString(&output, &outsize, &outlen, "%i players online", x);
	if (admin >= 150 && (whom == 0 || whom->gmlookup != 0xFFFF)) {
		if (connection->IsConsole())
			AppendAnyLenString(&output, &outsize, &outlen, "\r\n");
		else
			AppendAnyLenString(&output, &outsize, &outlen, "\n");
		console_list.SendConsoleWho(connection, to, admin, &output, &outsize, &outlen);
	}
	if (output)
		connection->SendEmoteMessageRaw(to, 0, 0, 10, output);
	safe_delete(output);
}
Exemplo n.º 23
0
map<string,string> EQW::GetPlayerDetails(Const_char *char_name) {
	map<string,string> res;
	
	ClientListEntry *cle = client_list.FindCharacter(char_name);
	if(cle == NULL) {
		res["error"] = "1";
		return(res);
	}
	
	res["character"] = cle->name();
	res["account"] = cle->AccountName();
	res["account_id"] = itoa(cle->AccountID());
	res["location_short"] = cle->zone()?database.GetZoneName(cle->zone()):"No Zone";
	res["location_long"] = res["location_short"];
	res["location_id"] = itoa(cle->zone());
	res["ip"] = long2ip(cle->GetIP());
	res["level"] = itoa(cle->level());
	res["race"] = GetRaceName(cle->race());
	res["race_id"] = itoa(cle->race());
	res["class"] = GetEQClassName(cle->class_());
	res["class_id"] = itoa(cle->class_());
	res["guild_id"] = itoa(cle->GuildID());
	res["guild"] = guild_mgr.GetGuildName(cle->GuildID());
	res["status"] = itoa(cle->Admin());
//	res["patch"] = cle->DescribePatch();
	
	return(res);
}