コード例 #1
0
ファイル: questmgr.cpp プロジェクト: aceoyame/OpenEQC
int16 QuestManager::unique_spawn(int npc_type, int grid, int unused, float x, float y, float z, float heading) {
	Mob *other = entity_list.GetMobByNpcTypeID(npc_type);
	if(other != NULL) {
		return(other->GetID());
	}


	NPCType* tmp = 0;
	if ((tmp = Database::Instance()->GetNPCType(npc_type)))
	{

		NPC* npc = new NPC(tmp, 0, x, y, z, heading);


		npc->AddLootTable();
		entity_list.AddNPC(npc,true);
		// Quag: Sleep in main thread? ICK!
		// Sleep(200);
		// Quag: check is irrelevent, it's impossible for npc to be 0 here
		// (we're in main thread, nothing else can possibly modify it)
//		if(npc != 0) {
			if(grid > 0)
			{
				// HarakiriFIXME npc->AssignWaypoints(grid);
			}
			npc->SendPosUpdate();
//		}
		return(npc->GetID());
	}
	return(0);
}
コード例 #2
0
ファイル: WesQuests.cpp プロジェクト: aceoyame/OpenEQC
void Client::CheckQuests(const char* zonename, const char * message, int32 npc_id, uint16 item_id, Mob* other)
{
	bool ps = false;
	bool tt = false;
	bool ti = false;
	bool tt2 = false;
	bool ti2 = false;
	bool stt = false;
	bool std = false;
	bool td = false;
	bool sta = false;
	bool ta = false;
	bool sti = false;
	bool stf = false;
	bool tf = false;
	bool tk = false;
	bool stk = false;
	bool levelcheck = false;
	int8 fac = GetFactionLevel(GetID(),other->GetNPCTypeID(), GetRace(), GetClass(), DEITY_AGNOSTIC, other->CastToNPC()->GetPrimaryFaction(), other);
	FILE * pFile;
  long lSize;
  char * buffer;
  char filename[255];
  #ifdef WIN32
  snprintf(filename, 254, "quests\\%i.qst", npc_id);
  #else
  snprintf(filename, 254, "quests/%i.qst", npc_id);
  #endif
  adverrorinfo = 940;
  if ((pFile=fopen(filename,"rb")))
  {
		#ifdef DEBUG
		printf("Reading quests from %s\n", filename);
		#endif
  }
  else {
		#ifdef DEBUG
		printf("Error: No quests file found for %s\n", filename);
		#endif
		return;
  }
  if (pFile==NULL) exit (1);

  // obtain file size.
  fseek (pFile , 0 , SEEK_END);
  lSize = ftell (pFile);
  rewind (pFile);

  adverrorinfo = 941;
  // allocate memory to contain the whole file.
  buffer = (char*) malloc (lSize);
  if (buffer == NULL) exit (2);

  // copy the file into the buffer.
  fread (buffer,1,lSize,pFile);
  fclose(pFile);
  Seperator3 sep3(buffer);
  for(int i=0; i < 2048; ++i)
  {
//  printf("Temp: %s\n", sep3.arghz[i]);
	char * command;
	char * temp;
	temp = sep3.arghz[i];
	if (temp == NULL) return;
	Seperator sep(temp);
	Seperator4 sep4(temp);
	command = sep4.arghza[0];
	command = strupr(command);
#ifdef DEBUG
	cout<<sep.argplus[0]<<endl;
#endif
	if (!IsCommented(temp))
	{
	if (strstr(command,"END_FILE") != NULL || command == NULL)
	{
		break;
	}
	if (ti2 || tt2 || tf || td || ta) {
		char lvl[5];
		sprintf(lvl, "%i", this->GetLevel());
		strcpy(sep4.arghza[1], strreplace(sep4.arghza[1],"%CHARRACE%", GetRaceName(this->GetRace())));
		strcpy(sep4.arghza[1], strreplace(sep4.arghza[1],"%CHARLEVEL%", lvl));
		strcpy(sep4.arghza[1], strreplace(sep4.arghza[1],"%CHARCLASS%", GetEQClassName(this->GetClass(), 50)));
		char * nmessage = strreplace(sep4.arghza[1],"%CHARNAME%", this->GetName());
		nmessage[strlen(nmessage) - 1] = '\0';
		if (ti2 || tt2 || ta)
		{
			other->CastToNPC()->FaceTarget(this, true);
		}
		if ((fac == 7 || fac == 6) && (ti2 || tt2))
		{
			entity_list.NPCMessage(other,true,200,0,"%s says, 'I will have nothing to do with such as you. Begone.'",other->GetName());
			break;
		}
		else if (strstr(command,"FACTION_CHECK") != NULL) {
			int8 fac2 = atoi(sep.arg[1]);
			if ((fac2 <= 5 && fac > fac2) || (fac2 == 6 && fac == 8))
			{
				entity_list.NPCMessage(other,true,200,0,"%s says, 'I will have nothing to do with such as you. Begone.'",other->GetName());
				break;
			}
			ps = true;
		}
		else if (strstr(command,"SAY") != NULL) {
			entity_list.NPCMessage(this, false, 400, 0, "%s says, '%s'", other->GetName(), nmessage);
			ps = true;
		}
		else if (strstr(command,"EMOTE") != NULL) {
			cout<<"Emoting!"<<endl;
			entity_list.NPCMessage(this, false, 400, 0, "%s %s", other->GetName(), nmessage);
			ps = true;
		}
		else if (strstr(command,"TEXT") != NULL) {
			entity_list.NPCMessage(this, false, 400, 0, "%s", nmessage);
			ps = true;
		}
		else if (strstr(command,"SHOUT") != NULL) {
			entity_list.NPCMessage(this, false, 0, 13, "%s shouts, '%s'", other->GetName(), nmessage);
			ps = true;
		}
		else if (strstr(command,"SPAWN_ITEM") != NULL) {
			this->SummonItem(atoi(sep.arg[1]));
			ps = true;
		}
		else if (strstr(command,"ADD_HATELIST") != NULL) {
			other->CastToNPC()->AddToHateList(this, 100);
			ps = true;
		}
		else if (strstr(command,"DEPOP") != NULL) {
			other->CastToNPC()->Depop();
			ps = true;
		}
#ifdef GUILDWARS
		else if (strstr(command,"CITYTAKE") != NULL) {
			if(IsClient() && GuildDBID() != 0)
			{
				if(target->CastToNPC()->GetGuildOwner() == GuildDBID())
				{
			entity_list.NPCMessage(this, false, 400, 0, "%s says, 'You are a member of the guild that owns this city, why would you want to conquere it?'", other->GetName(), nmessage);				
				}
				else if(!IsAttackAllowed(other))
				{
			entity_list.NPCMessage(this, false, 400, 0, "%s says, 'You cannot conquere an allied city.'", other->GetName(), nmessage);				
				}
				else if(database.CityDefense(zone->GetZoneID(),0))
				{
			entity_list.NPCMessage(this, false, 400, 0, "%s says, 'This city still has men standing, I will not surrender!'", other->GetName(), nmessage);				
				}
				else if(database.SetCityGuildOwned(GuildDBID(),other->GetNPCTypeID()))
				{
			entity_list.NPCMessage(this, false, 400, 0, "%s says, 'You have won, I surrender to you.'", other->GetName(), nmessage);	
			zone->SetGuildOwned(GuildDBID());
			zone->Repop();			
				}
			}
			ps = true;
		}
#endif
		else if (strstr(command,"SPAWN_NPC") != NULL) {
				adverrorinfo = 751;
				const NPCType* tmp = 0;
				adverrorinfo = 752;
				int16 grid = atoi(sep.arg[2]);
				int8 guildwarset = atoi(sep.arg[3]);
				if ((tmp = database.GetNPCType(atoi(sep.arg[1]))))
				{
					adverrorinfo = 753;
					NPC* npc = new NPC(tmp, 0, other->GetX(), other->GetY(), other->GetZ(), heading);
					adverrorinfo = 754;
					npc->AddLootTable();
					adverrorinfo = 755;
					entity_list.AddNPC(npc,true,true);
					adverrorinfo = 756;
					Sleep(200);
					if(npc != 0)
					{
					if(grid > 0)
						npc->AssignWaypoints(grid);
					adverrorinfo = 757;
#ifdef GUILDWARS
					if(guildwarset > 0 && guildwarset == 1 && GuildDBID() > 0)
						npc->SetGuildOwner(GuildDBID());
#endif
					adverrorinfo = 758;
					npc->SendPosUpdate();
					}
			}
			ps = true;
		}
		else if (strstr(command,"LEVEL_CHECK") != NULL) 
      { 
         int8 Level1 = atoi(sep.arg[1]); 
         int8 Level2 = atoi(sep.arg[2]); 
         int8 Levelp = this->GetLevel(); 
          
         if(Level2 == 0 || Level2 == NULL){ 
            //Min Level 
            if(Level1 > Levelp) 
            { 
               //not high enough to talk too 
               break; 
            } 
         } 
         else{ 
            //Level Range 
            if(Level1 < Levelp && Level2 < Levelp) 
            { 
               //not in the req level range 
               break; 
            } 
         } 
         levelcheck = true; 
      }
		else if (strstr(command,"CUMULATIVE_FLAG") != NULL) {
			other->flag[50] = other->flag[50] + 1;
			ps = true;
		}
		else if (strstr(command,"NPC_FLAG") != NULL) {
			other->flag[atoi(sep.arg[1])] = atoi(sep.arg[2]);
			ps = true;
		}
		else if (strstr(command,"PLAYER_FLAG") != NULL) {
			this->flag[atoi(sep.arg[1])] = atoi(sep.arg[2]);
			ps = true;
		}
		else if (strstr(command,"EXP") != NULL) {
			this->AddEXP (atoi(sep.arg[1]));
			ps = true;
		}
		else if (strstr(command,"LEVEL") != NULL) {
			this->SetLevel(atoi(sep.arg[1]), true);
			ps = true;
		}
		else if (strstr(command,"SAFEMOVE") != NULL) {
			this->MovePC(zone->GetShortName(),database.GetSafePoint(zone->GetShortName(),"x"),database.GetSafePoint(zone->GetShortName(),"y"),database.GetSafePoint(zone->GetShortName(),"z"),false,false);
			ps = true;
		}
		else if (strstr(command,"RAIN") != NULL) {
			zone->zone_weather = atoi(sep.arg[1]);
			APPLAYER* outapp = new APPLAYER;
			outapp = new APPLAYER;
			outapp->opcode = OP_Weather;
			outapp->pBuffer = new uchar[8];
			memset(outapp->pBuffer, 0, 8);
			outapp->size = 8;
			outapp->pBuffer[4] = atoi(sep.arg[1]); // Why not just use 0x01/2/3?
			entity_list.QueueClients(this, outapp);
			delete outapp;
			ps = true;
		}
		else if (strstr(command,"SNOW") != NULL) {
			zone->zone_weather = atoi(sep.arg[1]) + 1;
			APPLAYER* outapp = new APPLAYER;
			outapp = new APPLAYER;
			outapp->opcode = OP_Weather;
			outapp->pBuffer = new uchar[8];
			memset(outapp->pBuffer, 0, 8);
			outapp->size = 8;
			outapp->pBuffer[0] = 0x01;
			outapp->pBuffer[4] = atoi(sep.arg[1]);
			entity_list.QueueClients(this, outapp);
			delete outapp;
			ps = true;
		}
		else if (strstr(command,"GIVE_CASH") != NULL) {
			this->AddMoneyToPP(atoi(sep.arg[1]),true);
			ps = true;
		} 
		else if (strstr(command,"GIVE_ITEM") != NULL) { 
			int16 ItemID = atoi(sep.arg[1]); 
			sint8 ItemCharges = atoi(sep.arg[2]); 
			this->SummonItem(ItemID, ItemCharges); 
			ps = true; 
		} 
		else if (strstr(command,"CAST_SPELL") != NULL) {
			other->CastSpell(atoi(sep.arg[1]),this->GetID());
			ps = true;
		}
		else if (strstr(command,"PVP") != NULL) {
			if (strstr(strupr(sep.arg[1]),"ON") != NULL)
				this->CastToClient()->SetPVP(true);
			else
				this->CastToClient()->SetPVP(false);
			ps = true;
		}
		/*else if (strstr(command,"CHANGEFACTION") != NULL) {
			if ((sep.IsNumber(1)) && (sep.IsNumber(2))) {
				this->CastToClient()->SetFactionLevel2(this->CastToClient()->CharacterID(),atoi(sep.arg[1]), this->CastToClient()->GetClass(), this->CastToClient()->GetRace(), this->CastToClient()->GetDeity(), atoi(sep.arg[2]));
				this->CastToClient()->Message(0,BuildFactionMessage(GetCharacterFactionLevel(atoi(sep.arg[1])),atoi(sep.arg[1])));
			}
			else
			{
				cout << "Error in script!!!!!  Bad CHANGEFACTION Line! " << endl;
			}
			ps = true;
		}*/
		else if (strstr(command,"DO_ANIMATION") != NULL) {
			other->DoAnim(atoi(sep.arg[1]));
			ps = true;
		}
		else if (strstr(command,"ADDSKILL") != NULL) {
			if (sep.IsNumber(1) && sep.IsNumber(2) && (atoi(sep.arg[2]) >= 0 || atoi(sep.arg[2]) <= 252) && (atoi(sep.arg[1]) >= 0 && atoi(sep.arg[1]) < 74)) {
				this->AddSkill(atoi(sep.arg[1]), atoi(sep.arg[2]));
			}
			else
				cout << "Error in script!!!! Bad ADDSKILL line!" << endl;
			ps = true;
		}
		else if (strstr(command,"FLAG_CHECK") != NULL)
		{
			if (this->flag[atoi(sep.arg[1])] == 0)
				break;
			else
				this->flag[atoi(sep.arg[1])] = 0;
			ps = true;
		}
		else if (strstr(command,"CHANCE") != NULL)
		{
			if (rand()%100 > atoi(sep.arg[1]))
				break;
			ps = true;
		}
	}
	if (IsEnd(temp)) 
	{
		tt = false; tt2 = false; stt = false; ti = false; ti2 = false; sti = false; tk = false;	td = false; std = false; ta = false; sta = false; tf = false; stf = false; stk = false; 
	}
		if (strstr(command,"TRIGGER_ATTACK") != NULL)
		{
			if (strstr(message,"%%ATTACK%%") != NULL) {
				adverrorinfo = 943;
				ta = true;
			}
			else { sta = true; }
		}
		else if (strstr(command,"TRIGGER_DEATH") != NULL)
		{
			if (strstr(message,"%%DEATH%%") != NULL)
			{
				td = true;
			}
			else { std = true; }
		}
		else if (strstr(command,"TRIGGER_KILLED") != NULL)
		{
			if (strstr(message,"%%KILLED%%") != NULL)
			{
				tk = true;
			}
			else { stk = true; }
		}
		else if (strstr(command,"TRIGGER_FLAGS") != NULL)
		{
			int8 flag1 = atoi(sep.arg[1]);
			int8 flag2 = atoi(sep.arg[2]);
			int8 flag3 = atoi(sep.arg[3]);
			int8 flag4 = atoi(sep.arg[4]);
			if (flag1 == 50)
			{
				if (other->flag[50] >= atoi(sep.arg[2]))
				{
					tf = true;
					other->flag[50] = 0;
				}
				else
					stf = true;
			}
			else
			{
				if (ta || tt || ti)
					stf = true;
				else if (flag1 > 0 && other->flag[flag1] == 0)
					stf = true;
				else if (flag2 > 0 && other->flag[flag2] == 0)
					stf = true;
				else if (flag3 > 0 && other->flag[flag3] == 0)
					stf = true;
				else if (flag4 > 0 && other->flag[flag4] == 0)
					stf = true;
				else
				{
					tf = true;
					if (flag1 > 0)
						other->flag[flag1] = 0;
					if (flag2 > 0)
						other->flag[flag2] = 0;
					if (flag3 > 0)
						other->flag[flag3] = 0;
				if (flag4 > 0)
							other->flag[flag4] = 0;
				}
			}
		}
		else if (strstr(command,"TRIGGER_ITEM") != NULL) {
			if (!ta && !tt && !ti)
			{
				if ((uint16)item_id == atoi(sep4.arghza[1]))
				{
					ti = true; ti2 = true;
				}
				else { sti = true; }
			}
			else
			{
				printf("TRIGGER_ITEM Error at line %d: missing left curly bracket\n", i);
				return;
			}
		}
		else if (strstr(command,"TRIGGER_TEXT") != NULL)
		{
			if (strstr(message,"%%DEATH%%") == NULL && strstr(message,"%%ITEM%%") == NULL && strstr(message,"%%ATTACK%%") == NULL && strstr(message,"%%KILLED%%") == NULL && Dist(other) <= 50) {
				char* tmp = new char[strlen(message)+1];
				strcpy(tmp, message);
				strupr(tmp);
				if (strstr(tmp,strupr(sep4.arghza[1])) != NULL)
				{
					tt2 = true; tt = true;
				}
				else
				{
					stt = true;
				}
				delete tmp;
			}
			else if (strstr(message,"%%DEATH%%") != NULL || strstr(message,"%%item%%") != NULL || strstr(message,"%%attack%%")) { stt = true; }
			else if (!ps) { printf("TRIGGER_TEXT Error at line %d: Not in NPC_Script\n", i); return; }
			else
			{
				printf("TRIGGER_TEXT Error at line %d: missing left curly bracket\n", i);
				return;
			}
		}
	/*#ifdef WIN32
		delete command;
		delete temp;
	#endif*/
}
}
	if (!ps && item_id != 0)
	{
		entity_list.NPCMessage(this,true,200,0,"%s has no use for this item.",other->GetName());
		SummonItem(item_id);
	}
	delete buffer;
}
コード例 #3
0
void WorldServer::Process()
{
	if(this == 0)
	{
		return;
	}
	if(!Connected())
	{
		return;
	}

	SOCKADDR_IN to;
	memset((char *) &to, 0, sizeof(to));
	to.sin_family = AF_INET;
	to.sin_port = port;
	to.sin_addr.s_addr = ip;

	/************ Get all packets from packet manager out queue and process them ************/
	ServerPacket *pack = 0;
	while(pack = ServerRecvQueuePop())
	{
		switch(pack->opcode) 
		{
		case 0: 
			{
				break;
			}
		case ServerOP_KeepAlive: 
			{
				// ignore this
				break;
			}
		case ServerOP_ChannelMessage:
			{
				if (!ZoneLoaded) break;
				ServerChannelMessage_Struct* scm = (ServerChannelMessage_Struct*) pack->pBuffer;
				if (scm->deliverto[0] == 0) 
				{
					entity_list.ChannelMessageFromWorld(scm->from, scm->to, scm->chan_num, scm->guilddbid, scm->language, scm->message);
				}
				else 
				{
					Client* client;
					client = entity_list.GetClientByName(scm->deliverto);
					if (client != 0)
					{
						if (client->Connected()) 
						{
							client->ChannelMessageSend(scm->from, scm->to, scm->chan_num, scm->language, scm->message);
							if (!scm->noreply) 
							{
								// if it's a tell, echo back so it shows up
								scm->noreply = true;
								scm->chan_num = 14;
								memset(scm->deliverto, 0, sizeof(scm->deliverto));
								strcpy(scm->deliverto, scm->from);
								SendPacket(pack);
							}
						}
					}
				}
				break;
			}
		case ServerOP_EmoteMessage: 
			{
				if (!ZoneLoaded)
				{
					break;
				}

				ServerEmoteMessage_Struct* sem = (ServerEmoteMessage_Struct*) pack->pBuffer;

				if (sem->to[0] != 0)
				{
					if (strcasecmp(sem->to, zone->GetShortName()) == 0)
					{
						entity_list.Message(sem->guilddbid, (MessageFormat)sem->type, sem->message);
					}
					else
					{
						Client* client = entity_list.GetClientByName(sem->to);
						if (client != 0)
						{
							client->Message((MessageFormat)sem->type, sem->message);
						}
					}
				}
				else
				{
					entity_list.Message(sem->guilddbid, (MessageFormat)sem->type, sem->message);
				}
				break;
			}
/*		case ServerOP_GroupRefresh: //Kibanu - 4/22/2009
			{
				cout << "WorldServer_Process: In Group Refresh" << endl;
				if (!ZoneLoaded)
				{
					break;
				}

				ServerGroupRefresh_Struct* gr = (ServerGroupRefresh_Struct*) pack->pBuffer;

				if (gr->member[0] != 0)
				{
					cout << "WorldServer_Process: Refreshing group for " << gr->member << endl;
					Client* client = entity_list.GetClientByName(gr->member);
					if (client != 0)
					{
						client->RefreshGroup(gr->gid, gr->action);
					}
				}
				break;
			}*/
		case ServerOP_ShutdownAll: 
			{
				entity_list.Save();
				CatchSignal(2);
				break;
			}
		case ServerOP_ZoneShutdown: 
			{
				// Annouce the change to the world
				if (!ZoneLoaded)
				{
					SetZone("");
				}
				else
				{
					worldserver.SendEmoteMessage(0, 0, 15, "Zone shutdown: %s", zone->GetLongName());

					ServerZoneStateChange_struct* zst = (ServerZoneStateChange_struct *) pack->pBuffer;
					cout << "Zone shutdown by " << zst->adminname << endl;
					Zone::Shutdown();
				}
				break;
			}
		case ServerOP_ZoneBootup:
			{
				ServerZoneStateChange_struct* zst = (ServerZoneStateChange_struct *) pack->pBuffer;
				if (ZoneLoaded)
				{
					SetZone(zone->GetShortName());
					if (strcasecmp(Database::Instance()->GetZoneName(zst->zoneid), zone->GetShortName()) == 0) 
					{
						// This packet also doubles as "incomming client" notification, lets not shut down before they get here
						zone->StartShutdownTimer(AUTHENTICATION_TIMEOUT * 1000);
					}
					else 
					{
						worldserver.SendEmoteMessage(zst->adminname, 0, 0, "Zone bootup failed: Already running '%s'", zone->GetShortName());
					}
					break;
				}

				if (zst->adminname[0] != 0)
				{
					cout << "Zone bootup by " << zst->adminname << endl;
				}

				if (!(Zone::Bootup(Database::Instance()->GetZoneName(zst->zoneid)))) 
				{
					worldserver.SendChannelMessage(0, 0, 10, 0, 0, "%s:%i Zone::Bootup failed: %s", net.GetZoneAddress(), net.GetZonePort(), Database::Instance()->GetZoneName(zst->zoneid));
				}
				break;
			}
		case ServerOP_ZonePlayer: 
			{
				ServerZonePlayer_Struct* szp = (ServerZonePlayer_Struct*) pack->pBuffer;
				Client* client = entity_list.GetClientByName(szp->name);
				if (client != 0) 
				{
					if (strcasecmp(szp->adminname, szp->name) == 0)
					{
						client->Message(BLACK, "Zoning to: %s", szp->zone);
					}
					else if (client->GetAnon() == 1 && client->Admin() > szp->adminrank)
					{
						break;
					}
					else 
					{
						worldserver.SendEmoteMessage(szp->adminname, 0, 0, "Summoning %s to %s %1.1f, %1.1f, %1.1f", szp->name, szp->zone, szp->x_pos, szp->y_pos, szp->z_pos);
					}
					client->SetIsZoning(true);
					client->SetUsingSoftCodedZoneLine(true);
					client->SetZoningHeading(client->GetHeading());
					client->SetZoningX(szp->x_pos);
					client->SetZoningY(szp->y_pos);
					client->SetZoningZ(szp->z_pos);
					client->ZonePC(szp->zone, szp->x_pos, szp->y_pos, szp->z_pos);
				}
				break;
			}
			// Cofruben: used to send a packet directly to a client.
/*		case ServerOP_SendPacket: 
			{
				ServerSendPacket_Struct* sss = (ServerSendPacket_Struct*)pack->pBuffer;
				int32 PacketSize = pack->size - sizeof(sss->charname) - sizeof(sss->opcode);
				Client* PacketTo = entity_list.GetClientByName(sss->charname);
				if(!PacketTo)
				{
					break;
				}
				APPLAYER* outapp = new APPLAYER(sss->opcode, PacketSize);
				memcpy(outapp->pBuffer, sss->packet, PacketSize);
				PacketTo->QueuePacket(outapp);
				safe_delete(outapp);//delete outapp;
				break;
			}*/
		case ServerOP_KickPlayer:
			{
				ServerKickPlayer_Struct* skp = (ServerKickPlayer_Struct*) pack->pBuffer;
				Client* client = entity_list.GetClientByName(skp->name);
				if (client != 0) 
				{
					if (skp->adminrank >= client->Admin()) 
					{
						client->Kick();
						if (ZoneLoaded)
						{
							worldserver.SendEmoteMessage(skp->adminname, 0, 0, "Remote Kick: %s booted in zone %s.", skp->name, zone->GetShortName());
						}
						else
						{
							worldserver.SendEmoteMessage(skp->adminname, 0, 0, "Remote Kick: %s booted.", skp->name);
						}
					}
					else if (client->GetAnon() != 1)
					{
						worldserver.SendEmoteMessage(skp->adminname, 0, 0, "Remote Kick: Your avatar level is not high enough to kick %s", skp->name);
					}
				}
				break;
			}
		case ServerOP_KillPlayer:
			{
				ServerKillPlayer_Struct* skp = (ServerKillPlayer_Struct*) pack->pBuffer;
				Client* client = entity_list.GetClientByName(skp->target);
				if (client != 0) 
				{
					if (skp->admin >= client->Admin()) 
					{
						client->Kill();
						if (ZoneLoaded)
						{
							worldserver.SendEmoteMessage(skp->gmname, 0, 0, "Remote Kill: %s killed in zone %s.", skp->target, zone->GetShortName());
						}
						else
						{
							worldserver.SendEmoteMessage(skp->gmname, 0, 0, "Remote Kill: %s killed.", skp->target);
						}
					}
					else if (client->GetAnon() != 1)
					{
						worldserver.SendEmoteMessage(skp->gmname, 0, 0, "Remote Kill: Your avatar level is not high enough to kill %s", skp->target);
					}
				}
				break;
			}
		case ServerOP_RefreshGuild:
			{
				if (pack->size == 5)
				{
					int32 guildeqid = 0;
					memcpy(&guildeqid, pack->pBuffer, 4);

					zgm.LoadGuilds();
					Guild_Struct* guilds = zgm.GetGuildList();


					if (pack->pBuffer[4] == 1)
					{
						APPLAYER* outapp = new APPLAYER(OP_GuildUpdate, 64);
						memset(outapp->pBuffer, 0, outapp->size);
						GuildUpdate_Struct* gu = (GuildUpdate_Struct*) outapp->pBuffer;
						gu->guildID = guildeqid;
						gu->entry.guildID = guildeqid;

						if (guilds[guildeqid].databaseID == 0) 
						{
							gu->entry.exists = 0; // = 0x01 if exists, 0x00 on empty
						}
						else
						{
							strcpy(gu->entry.name, guilds[guildeqid].name);
							gu->entry.exists = 1; // = 0x01 if exists, 0x00 on empty
						}
						gu->entry.unknown1[0] = 0xFF;
						gu->entry.unknown1[1] = 0xFF;
						gu->entry.unknown1[2] = 0xFF;
						gu->entry.unknown1[3] = 0xFF;
						gu->entry.unknown3[0] = 0xFF;
						gu->entry.unknown3[1] = 0xFF;
						gu->entry.unknown3[2] = 0xFF;
						gu->entry.unknown3[3] = 0xFF;

						entity_list.QueueClients(0, outapp, false);
						safe_delete(outapp);//delete outapp;
					}
				}
				else
					cout << "Wrong size: ServerOP_RefreshGuild. size=" << pack->size << endl;
				break;
			}
		case ServerOP_GuildLeader:
			{
				ServerGuildCommand_Struct* sgc = (ServerGuildCommand_Struct*) pack->pBuffer;
				Client* client = entity_list.GetClientByName(sgc->target);

				if (client == 0)
				{
					// do nothing
				}
				else if (client->GuildDBID() != sgc->guilddbid)
				{
					worldserver.SendEmoteMessage(sgc->from, 0, 0, "%s is not in your guild.", client->GetName());
				}
				else if ((client->GuildRank() != 0) || (client->GuildRank() != 1))
				{
					worldserver.SendEmoteMessage(sgc->from, 0, 0, "%s is not rank 0.", client->GetName());
				}
				else 
				{
					if (Database::Instance()->SetGuildLeader(sgc->guilddbid, client->AccountID())) 
					{
						worldserver.SendEmoteMessage(0, sgc->guilddbid, MESSAGETYPE_Guild, "%s is now the leader of your guild.", client->GetName());
						ServerPacket* pack2 = new ServerPacket(ServerOP_RefreshGuild, 4);

						pack2->pBuffer = new uchar[pack->size];
						memcpy(pack2->pBuffer, &sgc->guildeqid, 4);
						worldserver.SendPacket(pack2);
						safe_delete(pack2);//delete pack2;
					}
					else
					{
						worldserver.SendEmoteMessage(sgc->from, 0, 0, "Guild leadership transfer failed.");
					}
				}
				break;
			}
		case ServerOP_GuildInvite: 
			{
				ServerGuildCommand_Struct* sgc = (ServerGuildCommand_Struct*) pack->pBuffer;
				Client* client = entity_list.GetClientByName(sgc->target);
				zgm.LoadGuilds();
				Guild_Struct* guilds = zgm.GetGuildList();

				if (client == 0)
				{
					// do nothing
				}
				else if (!guilds[sgc->guildeqid].rank[sgc->fromrank].invite)
				{
					worldserver.SendEmoteMessage(sgc->from, 0, 0, "You dont have permission to invite.");
				}
				else if (client->GuildDBID() != 0)
				{
					worldserver.SendEmoteMessage(sgc->from, 0, 0, "%s is already in another guild.", client->GetName());
				}
				else if (client->PendingGuildInvite != 0 && !(client->PendingGuildInvite == sgc->guilddbid))
				{
					worldserver.SendEmoteMessage(sgc->from, 0, 0, "%s has another pending guild invite.", client->GetName());
				}
				else
				{
					client->PendingGuildInvite = sgc->guilddbid;
					APPLAYER* outapp = new APPLAYER(OP_GuildInvite, sizeof(GuildCommand_Struct));
					memset(outapp->pBuffer, 0, outapp->size);
					GuildCommand_Struct* gc = (GuildCommand_Struct*) outapp->pBuffer;
					gc->guildeqid = sgc->guildeqid;
					strcpy(gc->Inviter, sgc->target);
					strcpy(gc->Invitee, sgc->from);
					client->QueuePacket(outapp);
					/*				
					if (client->SetGuild(sgc->guilddbid, GUILD_MAX_RANK))
					worldserver.SendEmoteMessage(0, sgc->guilddbid, MT_Guild, "%s has joined the guild. Rank: %s.", client->GetName(), guilds[sgc->guildeqid].rank[GUILD_MAX_RANK].rankname);
					else
					worldserver.SendEmoteMessage(sgc->from, 0, 0, "Guild invite failed.");
					*/
				}
				break;
			}
		case ServerOP_GuildRemove:
			{
				ServerGuildCommand_Struct* sgc = (ServerGuildCommand_Struct*) pack->pBuffer;
				Client* client = entity_list.GetClientByName(sgc->target);
				zgm.LoadGuilds();
				Guild_Struct* guilds = zgm.GetGuildList();

				if (client == 0)
				{
					// do nothing
				}
				else if ((!guilds[sgc->guildeqid].rank[sgc->fromrank].remove) && !(strcasecmp(sgc->from, sgc->target) == 0))
				{
					worldserver.SendEmoteMessage(sgc->from, 0, 0, "You dont have permission to remove.");
				}
				else if (client->GuildDBID() != sgc->guilddbid)
				{
					worldserver.SendEmoteMessage(sgc->from, 0, 0, "%s is not in your guild.", client->GetName());
				}
				else if (client->GuildRank() <= sgc->fromrank && !(sgc->fromaccountid == guilds[sgc->guildeqid].leader) && !(strcasecmp(sgc->from, sgc->target) == 0))
				{
					worldserver.SendEmoteMessage(sgc->from, 0, 0, "%s's rank is too high for you to remove them.", client->GetName());
				}
				else
				{
					if (client->SetGuild(0, GUILD_MAX_RANK))
					{
						if (strcasecmp(sgc->from, sgc->target) == 0)
						{
							worldserver.SendEmoteMessage(0, sgc->guilddbid, GUILD, "%s has left the guild.", client->GetName());
						}
						else
						{
							worldserver.SendEmoteMessage(0, sgc->guilddbid, GUILD, "%s has been removed from the guild by %s.", client->GetName(), sgc->from);
							client->Message(GUILD, "You have been removed from the guild by %s.", sgc->from);
						}
					}
					else
					{
						worldserver.SendEmoteMessage(sgc->from, 0, 0, "Guild remove failed.");
					}
				}
				break;
			}
		case ServerOP_GuildPromote:
			{
				ServerGuildCommand_Struct* sgc = (ServerGuildCommand_Struct*) pack->pBuffer;
				Client* client = entity_list.GetClientByName(sgc->target);
				zgm.LoadGuilds();
				Guild_Struct* guilds = zgm.GetGuildList();

				if (client == 0)
				{
					// do nothing
				}

				else if (client->GuildDBID() != sgc->guilddbid)
				{
					worldserver.SendEmoteMessage(sgc->from, 0, 0, "%s is not in your guild.", client->GetName());
				}
				else if ((!guilds[sgc->guildeqid].rank[sgc->fromrank].promote) && !(strcasecmp(sgc->from, sgc->target) == 0))
				{
					worldserver.SendEmoteMessage(sgc->from, 0, 0, "You dont have permission to promote.");
				}
				else if (client->GuildDBID() != sgc->guilddbid)
				{
					worldserver.SendEmoteMessage(sgc->from, 0, 0, "%s isnt in your guild.", client->GetName());
				}
				else if (client->GuildRank() <= sgc->newrank)
				{
					worldserver.SendEmoteMessage(sgc->from, 0, 0, "%s is already rank %i.", client->GetName(), client->GuildRank());
				}
				else if (sgc->newrank <= sgc->fromrank && sgc->fromaccountid != guilds[sgc->guildeqid].leader)
				{
					worldserver.SendEmoteMessage(sgc->from, 0, 0, "You cannot promote people to a greater or equal rank than yourself.");
				}
				else 
				{
					if (client->SetGuild(sgc->guilddbid, sgc->newrank)) 
					{
						worldserver.SendEmoteMessage(0, sgc->guilddbid, MESSAGETYPE_Guild, "%s has been promoted to %s by %s.", client->GetName(), guilds[sgc->guildeqid].rank[sgc->newrank].rankname, sgc->from);
					}
					else
					{
						worldserver.SendEmoteMessage(sgc->from, 0, 0, "Guild promote failed");
					}
				}
				break;
			}
		case ServerOP_GuildDemote:
			{
				ServerGuildCommand_Struct* sgc = (ServerGuildCommand_Struct*) pack->pBuffer;
				Client* client = entity_list.GetClientByName(sgc->target);

				zgm.LoadGuilds();
				Guild_Struct* guilds = zgm.GetGuildList();

				if (client == 0)
				{
					// do nothing
				}
				else if (client->GuildDBID() != sgc->guilddbid)
				{
					worldserver.SendEmoteMessage(sgc->from, 0, 0, "%s is not in your guild.", client->GetName());
				}
				else if (!guilds[sgc->guildeqid].rank[sgc->fromrank].demote)
				{
					worldserver.SendEmoteMessage(sgc->from, 0, 0, "You dont have permission to demote.");
				}
				else if (client->GuildRank() >= sgc->newrank)
				{
					worldserver.SendEmoteMessage(sgc->from, 0, 0, "%s is already rank %i.", client->GetName(), client->GuildRank());
				}
				else if (sgc->newrank <= sgc->fromrank && sgc->fromaccountid != guilds[sgc->guildeqid].leader && !(strcasecmp(sgc->from, sgc->target) == 0))
				{
					worldserver.SendEmoteMessage(sgc->from, 0, 0, "You cannot demote people with a greater or equal rank than yourself.");
				}
				else
				{
					if (client->SetGuild(sgc->guilddbid, sgc->newrank)) 
					{
						worldserver.SendEmoteMessage(0, sgc->guilddbid, MESSAGETYPE_Guild, "%s has been demoted to %s by %s.", client->GetName(), guilds[sgc->guildeqid].rank[sgc->newrank].rankname, sgc->from);
					}
					else
					{
						worldserver.SendEmoteMessage(sgc->from, 0, 0, "Guild demote failed");
					}
				}
				break;
			}
		case ServerOP_GuildGMSet:
			{
				ServerGuildCommand_Struct* sgc = (ServerGuildCommand_Struct*) pack->pBuffer;
				Client* client = entity_list.GetClientByName(sgc->target);
				if (client != 0) 
				{
					if (client->GuildDBID() == 0 || sgc->guilddbid == 0) 
					{
						if (!client->SetGuild(sgc->guilddbid, GUILD_MAX_RANK))
						{
							worldserver.SendEmoteMessage(sgc->from, 0, 0, "Error: Guild #%i not found", sgc->guilddbid);
						}
					}
					else
					{
						worldserver.SendEmoteMessage(sgc->from, 0, 0, "Error: %s is already in a guild", sgc->target);
					}
				}
				break;
			}
		case ServerOP_GuildGMSetRank:
			{
				ServerGuildCommand_Struct* sgc = (ServerGuildCommand_Struct*) pack->pBuffer;
				Client* client = entity_list.GetClientByName(sgc->target);
				if (client != 0)
				{
					if (client->GuildDBID() != 0)
					{
						if (!client->SetGuild(client->GuildDBID(), sgc->newrank))
						{
							worldserver.SendEmoteMessage(sgc->from, 0, 0, "Error: SetRank failed.", sgc->guilddbid);
						}
					}
					else
					{
						worldserver.SendEmoteMessage(sgc->from, 0, 0, "Error: %s is not in a guild", sgc->target);
					}
				}
				break;
			}
/*		case ServerOP_GuildCreateResponse:
			{
				GuildCreateResponse_Struct* gcrs = (GuildCreateResponse_Struct*) pack->pBuffer;

				if(gcrs->Created)
				{
					cout << "Guild " << gcrs->GuildName << " created." << endl;
					Client* client = entity_list.GetClientByName(gcrs->LeaderCharName);
					// invite the client to guild
					zgm.InviteToGuild(0, gcrs->eqid, client, client, GuildLeader);
				}
				
				break;
			}*/
		case ServerOP_FlagUpdate:
			{
				Client* client = entity_list.GetClientByAccID(Database::Instance()->GetAccountIDByName((char*) pack->pBuffer));
				if (client != 0) 
				{
					client->UpdateAdmin();
				}
				break;
			}
		case ServerOP_GMGoto: 
			{
				if (pack->size != sizeof(ServerGMGoto_Struct)) 
				{
					cout << "Wrong size on ServerOP_GMGoto. Got: " << pack->size << ", Expected: " << sizeof(ServerGMGoto_Struct) << endl;
					break;
				}
				if (!ZoneLoaded) 
				{
					break;
				}
				ServerGMGoto_Struct* gmg = (ServerGMGoto_Struct*) pack->pBuffer;
				Client* client = entity_list.GetClientByName(gmg->gotoname);
				if (client != 0) 
				{
					worldserver.SendEmoteMessage(gmg->myname, 0, 13, "Summoning you to: %s @ %s, %1.1f, %1.1f, %1.1f", client->GetName(), zone->GetShortName(), client->GetX(), client->GetY(), client->GetZ());

					ServerPacket* outpack = new ServerPacket(ServerOP_ZonePlayer, sizeof(ServerZonePlayer_Struct));


					outpack->pBuffer = new uchar[outpack->size];
					memset(outpack->pBuffer, 0, outpack->size);
					ServerZonePlayer_Struct* szp = (ServerZonePlayer_Struct*) outpack->pBuffer;
					strcpy(szp->adminname, gmg->myname);
					strcpy(szp->name, gmg->myname);
					strcpy(szp->zone, zone->GetShortName());
					szp->x_pos = client->GetX();
					szp->y_pos = client->GetY();
					szp->z_pos = client->GetZ();
					worldserver.SendPacket(outpack);
					safe_delete(outpack);//delete outpack;
				}
				else
				{
					worldserver.SendEmoteMessage(gmg->myname, 0, 13, "Error: %s not found", gmg->gotoname);
				}
				break;
			}
		case ServerOP_MultiLineMsg:
			{
				ServerMultiLineMsg_Struct* mlm = (ServerMultiLineMsg_Struct*) pack->pBuffer;
				Client* client = entity_list.GetClientByName(mlm->to);
				if (client) 
				{
					APPLAYER* outapp = new APPLAYER(OP_MultiLineMsg, strlen(mlm->message));
					strcpy((char*) outapp->pBuffer, mlm->message);
					client->QueuePacket(outapp);
					safe_delete(outapp);//delete outapp;
				}
				break;
			}
		case ServerOP_RezzPlayer:
			{
				RezzPlayer_Struct* srs = (RezzPlayer_Struct*)pack->pBuffer;
				//Yeahlight: A resurrection request has been made
				if(srs->rezzopcode == OP_RezzRequest)
				{
					Client* client = entity_list.GetClientByName(srs->owner);
					//Yeahlight: Owner of the corpse is online
					if(client)
					{
						Spell* spell = spells_handler.GetSpellPtr(srs->rez.spellID);
						//Yeahlight: Spell passed through the packet is a legit spell
						if(spell)
						{
							//Yeahlight: Record the pending resurrection information
							client->SetPendingRez(true);
							client->SetPendingRezExp(srs->exp);
							client->SetPendingCorpseID(srs->corpseDBID);
							client->SetPendingRezX(srs->rez.x);
							client->SetPendingRezY(srs->rez.y);
							client->SetPendingRezZ(srs->rez.z);
							client->SetPendingRezZone(srs->rez.zoneName);
							client->SetPendingSpellID(spell->GetSpellID());
							client->StartPendingRezTimer();
							if(client->GetDebugMe())
								client->Message(YELLOW, "Debug: Forwarding the resurrection request to your client (%s)", srs->rez.targetName);
							//Yeahlight: Forward the resurrection packet to the corpse's owner
							APPLAYER* outapp = new APPLAYER(OP_RezzRequest, sizeof(Resurrect_Struct));
							Resurrect_Struct* rez = (Resurrect_Struct*)outapp->pBuffer;
							memset(rez, 0, sizeof(Resurrect_Struct));
							memcpy(rez, &srs->rez, sizeof(Resurrect_Struct));
							client->QueuePacket(outapp);
							safe_delete(outapp);
						}
					}
				}
				//Yeahlight: A resurrection confirmation has been made
				else if(srs->rezzopcode == OP_RezzAnswer)
				{
					Client* client = entity_list.GetClientByName(srs->owner);
					//Yeahlight: Owner of the corpse is online
					if(client)
					{
						bool fullGMRez = false;
						//Yeahlight: The corpse owner answers 'yes' to the request
						if(srs->action == 1)
						{
							Database::Instance()->SetCorpseRezzed(client->GetPendingCorpseID());
							//Yeahlight: Player casted resurrection
							if(client->GetPendingSpellID() != 994)
							{
								float expRefund = 0.00;
								//Yeahlight: PC has exp on the corpse
								if(client->GetPendingRezExp())
								{
									//Yeahlight: Switch based on spell ID
									switch(client->GetPendingSpellID())
									{
										//Yeahlight: Revive
										case 391:
										{
											expRefund = 0.00;
											break;
										}
										//Yeahlight: Resuscitate
										case 388:
										{
											expRefund = 0.50;
											break;
										}
										//Yeahlight: Resurrection
										case 392:
										{
											expRefund = 0.90;
											break;
										}
										//Yeahlight: Reviviscence
										case 1524:
										{
											expRefund = 0.96;
											break;
										}
										//Yeahlight: Convergence
										case 1733:
										{
											expRefund = 0.93;
											break;
										}
										default:
										{
											client->Message(RED, "ERROR: Unknown resurrection spell ID: %i", client->GetPendingSpellID());
											expRefund = 0.00;
										}
									}
									if(client->GetDebugMe())
										client->Message(LIGHTEN_BLUE, "Debug: Your resurrection return on exp: %1.2f", expRefund);
									client->AddEXP(client->GetPendingRezExp() * expRefund, true);
								}
							}
							//Yeahlight: GM casted resurrection
							else
							{
								fullGMRez = true;
								if(client->GetDebugMe())
									client->Message(LIGHTEN_BLUE, "Debug: Your resurrection return on exp: 1.00");
								client->AddEXP(client->GetPendingRezExp(), true);
							}
							//Yeahlight: Client is being resurrected in another zone; prepare them for transit
							if(strcmp(zone->GetShortName(), srs->rez.zoneName) != 0)
							{
								client->SetTempHeading(0);
								client->SetUsingSoftCodedZoneLine(true);
								client->SetIsZoning(true);
								client->SetZoningX(client->GetPendingRezX());
								client->SetZoningY(client->GetPendingRezY());
								client->SetZoningZ(client->GetPendingRezZ());
							}
							//Yeahlight: Send the packet back to the owner of the corpse
							APPLAYER* outapp = new APPLAYER(OP_RezzComplete, sizeof(Resurrect_Struct));
							memcpy(outapp->pBuffer, &srs->rez, sizeof(Resurrect_Struct));
							srs->rez.fullGMRez = fullGMRez;
							client->QueuePacket(outapp);
							safe_delete(outapp);
						}
						//Yeahlight: The corpse owner answers 'no' to the request
						else if(srs->action == 0)
						{
							client->Message(BLACK, "You decline the request to be resurrected.");
							client->SetPendingRez(false);
							client->SetPendingRezExp(0);
						}
					}
				}
				break;
			}
		case ServerOP_Uptime: 
			{
				if (pack->size != sizeof(ServerUptime_Struct))
				{
					cout << "Wrong size on ServerOP_Uptime. Got: " << pack->size << ", Expected: " << sizeof(ServerUptime_Struct) << endl;
					break;
				}
				ServerUptime_Struct* sus = (ServerUptime_Struct*) pack->pBuffer;
				int32 ms = Timer::GetCurrentTime();
				int32 d = ms / 86400000;
				ms -= d * 86400000;
				int32 h = ms / 3600000;
				ms -= h * 3600000;
				int32 m = ms / 60000;
				ms -= m * 60000;
				int32 s = ms / 1000;
				if (d)
				{
					this->SendEmoteMessage(sus->adminname, 0, 0, "Zone #%i Uptime: %02id %02ih %02im %02is", sus->zoneserverid, d, h, m, s);
				}
				else if (h)
				{
					this->SendEmoteMessage(sus->adminname, 0, 0, "Zone #%i Uptime: %02ih %02im %02is", sus->zoneserverid, h, m, s);
				}
				else
				{
					this->SendEmoteMessage(sus->adminname, 0, 0, "Zone #%i Uptime: %02im %02is", sus->zoneserverid, m, s);
				}
				break;
			}
		case ServerOP_Petition:
			{
				cout << "Got Server Requested Petition List Refresh" << endl;
				ServerPetitionUpdate_Struct* sus = (ServerPetitionUpdate_Struct*) pack->pBuffer;
				if (sus->status = 0) 
				{
					petition_list.ReadDatabase();
				}

				else if (sus->status = 1)
				{
					petition_list.ReadDatabase(); // Until I fix this to be better....
				}
				break;
			}
		case ServerOP_RemoveBoat: // Tazadar (06/12/09) : We remove the boat from the zone 
			{
				BoatName_Struct* bs = (BoatName_Struct*) pack->pBuffer;
				
				cout << "Trying to remove the boat : " << bs->boatname << endl;
	
				Mob * tmp = entity_list.GetMob(bs->boatname);
				
				if(tmp){
					tmp->CastToNPC()->Depop(false);
					entity_list.RemoveNPC(tmp->CastToNPC());
				}

				break;
			}
		case ServerOP_ZoneBoat	: // Tazadar (06/16/09) : We teleport player to the other zone !
			{
				cout << "A boat is zoning ! Teleporting clients !" << endl;
				ZoneBoat_Struct * zb = (ZoneBoat_Struct *) pack->pBuffer;
				Entity * tmp = 0;
				Mob * boat = entity_list.GetMob(zb->boatname);
				float xboat,yboat,zboat,headingboat;
				if(boat){
					xboat = boat->GetX();
					yboat = boat->GetY();
					zboat = boat->GetZ();;
					headingboat = boat->GetHeading();
				}
				else{
					cerr << "Error in ServerOP_ZoneBoat boat : "<< zb->boatname << " does not exist."<<endl;
					break;
				}
				char  * clients = (char *) pack->pBuffer;
				char zone[16] = "";
				strcpy(zone, zb->zonename);
				char name[30];
				float x,y,z,heading;
				for(int i=0 ; i < zb->numberOfPlayers ; i++){
					memcpy(name,clients+sizeof(ZoneBoat_Struct)+30*i,30*sizeof(char));
					cout << "Trying to teleport : "<< name << endl;
					tmp = entity_list.GetClientByName(name);
					if(tmp != 0 && tmp->IsClient()){
						//cout << "ZonePC to " << zone << endl;

						Client * client = tmp->CastToClient();

						heading = client->GetHeading()-headingboat; // Tazadar : Relative heading from the boat
						z = client->GetZ()-zboat; // Tazadar : Relative z from the boat
						
						
						client->GetRelativeCoordToBoat(client->GetY()-yboat,client->GetX()-xboat,(zb->heading-headingboat)*1.4,y,x);
						client->SetZoningHeading(zb->heading+heading);
						client->SetUsingSoftCodedZoneLine(true);
						client->SetIsZoning(true);
						client->SetZoningX(zb->x+x);
						client->SetZoningY(zb->y+y);
						client->SetZoningZ(zb->z+z);
						client->ZonePC(zone,0,0,10);
					}
					else{ // Tazadar : Player has crashed ? We remove it from boat infos

						// Tazadar : Make the packet for the World Serv
						ServerPacket* pack = new ServerPacket(ServerOP_BoatPL, sizeof(ServerBoat_Struct));

						ServerBoat_Struct* servBoatInfos = (ServerBoat_Struct*) pack->pBuffer;

						// Tazadar : Fill the packet
						memcpy(servBoatInfos->player_name,name,sizeof(servBoatInfos->player_name));

						// Tazadar : Send the packet
						worldserver.SendPacket(pack);

					}
				}

				break;
			}
		case ServerOP_SpawnBoat: // Tazadar (06/13/09) : We make the boat spawn before the zone in at the correct location.
			{

				SpawnBoat_Struct * bs = (SpawnBoat_Struct *) pack->pBuffer; 
				
				Mob * tmp = 0;
				
				cout << "Spawning the boat :" << bs->boatname << "at loc " << bs->x <<","<< bs->y << "," << bs->z <<" heading " << bs->heading<<endl;
				//cout << "Loading boat from DB " << endl;
				string name = bs->boatname;
				name.resize(name.length()-2);
				NPCType boat;
				bool lineroute = false;
				Database::Instance()->LoadBoatData(name.c_str(),boat,lineroute);
				NPC* npc = new NPC(&boat, 0, bs->x, bs->y, bs->z, bs->heading);
				npc->SetLineRoute(lineroute);
				entity_list.AddNPC(npc);
				npc->SendPosUpdate(false);
				
				break;
			}

		case ServerOP_BoatGoTo :  // Tazadar (06/14/09) : We make the boat move
			{
				BoatGoTo_Struct * gt = (BoatGoTo_Struct *) pack->pBuffer;
				cout << "World orders " << gt->boatname << " to go to node number " << gt->toNode << endl;
				
				Mob * tmp = entity_list.GetMob(gt->boatname);
				if(tmp && tmp->IsNPC()){
					if(tmp->CastToNPC()->IsBoat()){
						tmp->CastToNPC()->setBoatDestinationNode(gt->fromNode,gt->toNode);
					}
					else{
						cerr << "Tried to give an order to the npc "<< gt->boatname <<" which is not a boat " << endl;
					}
				}
				else{
					cerr << "Error in ServerOP_BoatGoTo boat " << gt->boatname << " does not exist"<<endl;
				}

				break;
			}
		case ServerOP_DayTime : // Kibanu - 7/30/2009 : Switch to day time for spawn data
			{
				if (ZoneLoaded)
					zone->SetTimeOfDay(true);
				break;
			}
		case ServerOP_NightTime : // Kibanu - 7/30/2009 : Switch to day time for spawn data
			{
				if (ZoneLoaded)
					zone->SetTimeOfDay(false);
				break;
			}
		case ServerOP_ZoneToZoneRequest: 
			{
				if(pack->size != sizeof(ZoneToZone_Struct)) 
					break;
				if (!ZoneLoaded)
					break;
				ZoneToZone_Struct* ztz = (ZoneToZone_Struct*) pack->pBuffer;
			
				if(ztz->current_zone_id == zone->GetZoneID()) 
				{
					// it's a response
					Entity* entity = entity_list.GetClientByName(ztz->name);
					if(entity == 0)
						break;

					APPLAYER *outapp;
					outapp = new APPLAYER(OP_ZoneChange,sizeof(ZoneChange_Struct));
					ZoneChange_Struct* zc2=(ZoneChange_Struct*)outapp->pBuffer;

					if(ztz->response == 0 || ztz->response == -1) 
					{
						zc2->success = ZONE_ERROR_NOTREADY;
						entity->CastToMob()->SetZone(ztz->current_zone_id);
					}
					else 
					{
						strncpy(zc2->char_name,entity->CastToMob()->GetName(),64);
						zc2->zoneID=ztz->requested_zone_id;
						zc2->success = 1;
					}
					entity->CastToClient()->QueuePacket(outapp);
					delete outapp;

					switch(ztz->response)
					{
						case -1: 
						{
							entity->CastToMob()->Message(RED,"The zone is currently full, please try again later.");
							break;
						}
						case 0:	
						{
							entity->CastToMob()->Message(RED,"All zone servers are taken at this time, please try again later.");
							break;
						}
					}
				}
				else 
				{
					// it's a request
					if(zone->GetMaxClients() != 0 && numclients >= zone->GetMaxClients())
						ztz->response = -1;
					else 
					{
						ztz->response = 1;
						// since they asked about coming, lets assume they are on their way and not shut down.
						zone->StartShutdownTimer(AUTHENTICATION_TIMEOUT * 1000);
					}
					SendPacket(pack);
					break;
				}
			break;
		}
			default:
			{
				cout << "Unknown ZSopcode:" << (int)pack->opcode;
				cout << "size:" << pack->size << endl;
				//DumpPacket(pack->pBuffer, pack->size);
				break;
			}
		}

		safe_delete(pack);//delete pack;
		//Yeahlight: Zone freeze debug
		if(ZONE_FREEZE_DEBUG && rand()%ZONE_FREEZE_DEBUG == 1)
			EQC_FREEZE_DEBUG(__LINE__, __FILE__);
	}
	return;
}