2013-05-09 10:44:08 -04:00
/* EQEMu: Everquest Server Emulator
2017-04-02 20:03:51 -07:00
Copyright ( C ) 2001 - 2016 EQEMu Development Team ( http : //eqemu.org)
2013-02-16 16:14:39 -08:00
2017-04-02 20:03:51 -07:00
This program is free software ; you can redistribute it and / or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation ; version 2 of the License .
2013-05-06 13:07:41 -04:00
2017-04-02 20:03:51 -07:00
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY except by those people which sell it , which
are required to give you total support for your newly bought product ;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR
A PARTICULAR PURPOSE . See the GNU General Public License for more details .
2013-05-06 13:07:41 -04:00
2017-04-02 20:03:51 -07:00
You should have received a copy of the GNU General Public License
along with this program ; if not , write to the Free Software
Foundation , Inc . , 59 Temple Place , Suite 330 , Boston , MA 02111 - 1307 USA
2013-02-16 16:14:39 -08:00
*/
2014-12-15 19:12:04 -06:00
2015-01-19 04:12:09 -06:00
# include "../common/global_define.h"
2013-02-16 16:14:39 -08:00
# include <iostream>
# include <string.h>
# include <stdio.h>
# include <iomanip>
# include <stdarg.h>
2018-02-26 23:04:28 -05:00
# include <limits.h>
2013-02-16 16:14:39 -08:00
# ifdef _WINDOWS
2017-04-02 20:03:51 -07:00
# include <process.h>
2013-02-16 16:14:39 -08:00
2017-04-02 20:03:51 -07:00
# define snprintf _snprintf
# define strncasecmp _strnicmp
# define strcasecmp _stricmp
2013-02-16 16:14:39 -08:00
# endif
# include "../common/eq_packet_structs.h"
2014-08-21 19:33:02 -07:00
# include "../common/misc_functions.h"
2014-12-15 19:12:04 -06:00
# include "../common/rulesys.h"
# include "../common/servertalk.h"
2019-02-04 07:02:27 -05:00
# include "../common/profanity_manager.h"
2014-12-15 19:12:04 -06:00
# include "client.h"
# include "corpse.h"
2013-02-16 16:14:39 -08:00
# include "entity.h"
2015-11-01 15:59:24 -06:00
# include "quest_parser_collection.h"
2014-12-15 19:12:04 -06:00
# include "guild_mgr.h"
# include "mob.h"
2013-02-16 16:14:39 -08:00
# include "petitions.h"
2014-12-15 19:12:04 -06:00
# include "raids.h"
2014-08-21 23:46:01 -07:00
# include "string_ids.h"
2013-02-16 16:14:39 -08:00
# include "titles.h"
2014-12-15 19:12:04 -06:00
# include "worldserver.h"
# include "zone.h"
# include "zone_config.h"
2020-01-31 20:25:06 -06:00
# include "zone_reload.h"
2013-02-16 16:14:39 -08:00
2013-05-09 10:44:08 -04:00
extern EntityList entity_list ;
2013-02-16 16:14:39 -08:00
extern Zone * zone ;
2015-10-31 20:19:57 -05:00
extern volatile bool is_zone_loaded ;
2020-03-21 17:05:28 -07:00
extern void Shutdown ( ) ;
2013-02-16 16:14:39 -08:00
extern WorldServer worldserver ;
extern PetitionList petition_list ;
extern uint32 numclients ;
extern volatile bool RunLoops ;
2015-11-01 15:59:24 -06:00
extern QuestParserCollection * parse ;
// QuestParserCollection *parse = 0;
2013-02-16 16:14:39 -08:00
WorldServer : : WorldServer ( )
{
cur_groupid = 0 ;
last_groupid = 0 ;
oocmuted = false ;
}
WorldServer : : ~ WorldServer ( ) {
}
2017-01-02 22:38:47 -08:00
void WorldServer : : Connect ( )
{
m_connection . reset ( new EQ : : Net : : ServertalkClient ( Config - > WorldIP , Config - > WorldTCPPort , false , " Zone " , Config - > SharedKey ) ) ;
m_connection - > OnConnect ( [ this ] ( EQ : : Net : : ServertalkClient * client ) {
OnConnected ( ) ;
} ) ;
2017-01-03 22:23:03 -08:00
m_connection - > OnMessage ( std : : bind ( & WorldServer : : HandleMessage , this , std : : placeholders : : _1 , std : : placeholders : : _2 ) ) ;
2019-09-07 20:20:10 -05:00
m_keepalive . reset ( new EQ : : Timer ( 2500 , true , std : : bind ( & WorldServer : : OnKeepAlive , this , std : : placeholders : : _1 ) ) ) ;
2017-01-02 22:38:47 -08:00
}
bool WorldServer : : SendPacket ( ServerPacket * pack )
{
m_connection - > SendPacket ( pack ) ;
return true ;
}
std : : string WorldServer : : GetIP ( ) const
{
return m_connection - > Handle ( ) - > RemoteIP ( ) ;
}
uint16 WorldServer : : GetPort ( ) const
{
return m_connection - > Handle ( ) - > RemotePort ( ) ;
}
bool WorldServer : : Connected ( ) const
{
return m_connection - > Connected ( ) ;
}
2013-02-16 16:14:39 -08:00
2015-10-31 20:19:57 -05:00
void WorldServer : : SetZoneData ( uint32 iZoneID , uint32 iInstanceID ) {
2016-05-25 16:10:28 -04:00
auto pack = new ServerPacket ( ServerOP_SetZone , sizeof ( SetZone_Struct ) ) ;
2017-04-02 20:03:51 -07:00
SetZone_Struct * szs = ( SetZone_Struct * ) pack - > pBuffer ;
2013-02-16 16:14:39 -08:00
szs - > zoneid = iZoneID ;
szs - > instanceid = iInstanceID ;
if ( zone ) {
szs - > staticzone = zone - > IsStaticZone ( ) ;
}
SendPacket ( pack ) ;
safe_delete ( pack ) ;
}
void WorldServer : : OnConnected ( ) {
ServerPacket * pack ;
2013-05-06 13:07:41 -04:00
2015-10-31 20:19:57 -05:00
/* Tell the launcher what our information is */
2017-04-02 20:03:51 -07:00
pack = new ServerPacket ( ServerOP_SetLaunchName , sizeof ( LaunchName_Struct ) ) ;
2013-02-16 16:14:39 -08:00
LaunchName_Struct * ln = ( LaunchName_Struct * ) pack - > pBuffer ;
strn0cpy ( ln - > launcher_name , m_launcherName . c_str ( ) , 32 ) ;
strn0cpy ( ln - > zone_name , m_launchedName . c_str ( ) , 16 ) ;
SendPacket ( pack ) ;
safe_delete ( pack ) ;
2015-10-31 20:19:57 -05:00
/* Tell the Worldserver basic information about this zone process */
2013-02-16 16:14:39 -08:00
pack = new ServerPacket ( ServerOP_SetConnectInfo , sizeof ( ServerConnectInfo ) ) ;
2017-04-02 20:03:51 -07:00
ServerConnectInfo * sci = ( ServerConnectInfo * ) pack - > pBuffer ;
2015-10-31 20:19:57 -05:00
2015-07-16 01:51:10 -07:00
auto config = ZoneConfig : : get ( ) ;
2013-02-16 16:14:39 -08:00
sci - > port = ZoneConfig : : get ( ) - > ZonePort ;
2017-04-02 20:03:51 -07:00
if ( config - > WorldAddress . length ( ) > 0 ) {
2015-07-16 01:51:10 -07:00
strn0cpy ( sci - > address , config - > WorldAddress . c_str ( ) , 250 ) ;
}
2017-04-02 20:03:51 -07:00
if ( config - > LocalAddress . length ( ) > 0 ) {
2015-07-22 17:42:57 -07:00
strn0cpy ( sci - > local_address , config - > LocalAddress . c_str ( ) , 250 ) ;
2015-07-16 01:51:10 -07:00
}
2015-10-31 20:19:57 -05:00
/* Fetch process ID */
2017-04-02 20:03:51 -07:00
if ( getpid ( ) ) {
2015-10-31 20:19:57 -05:00
sci - > process_id = getpid ( ) ;
}
else {
sci - > process_id = 0 ;
}
2013-02-16 16:14:39 -08:00
SendPacket ( pack ) ;
safe_delete ( pack ) ;
2013-05-06 13:07:41 -04:00
2015-10-31 20:19:57 -05:00
if ( is_zone_loaded ) {
this - > SetZoneData ( zone - > GetZoneID ( ) , zone - > GetInstanceID ( ) ) ;
2013-02-16 16:14:39 -08:00
entity_list . UpdateWho ( true ) ;
this - > SendEmoteMessage ( 0 , 0 , 15 , " Zone connect: %s " , zone - > GetLongName ( ) ) ;
2015-10-31 20:19:57 -05:00
zone - > GetTimeSync ( ) ;
}
else {
this - > SetZoneData ( 0 ) ;
2013-02-16 16:14:39 -08:00
}
2013-05-06 13:07:41 -04:00
2017-04-02 20:03:51 -07:00
pack = new ServerPacket ( ServerOP_LSZoneBoot , sizeof ( ZoneBoot_Struct ) ) ;
2013-02-16 16:14:39 -08:00
ZoneBoot_Struct * zbs = ( ZoneBoot_Struct * ) pack - > pBuffer ;
2017-04-02 20:03:51 -07:00
strcpy ( zbs - > compile_time , LAST_MODIFIED ) ;
2013-02-16 16:14:39 -08:00
SendPacket ( pack ) ;
safe_delete ( pack ) ;
}
2013-05-06 13:07:41 -04:00
2017-01-02 22:38:47 -08:00
/* Zone Process Packets from World */
void WorldServer : : HandleMessage ( uint16 opcode , const EQ : : Net : : Packet & p )
{
ServerPacket tpack ( opcode , p ) ;
ServerPacket * pack = & tpack ;
2017-01-03 22:23:03 -08:00
2017-04-02 20:03:51 -07:00
switch ( opcode ) {
2017-01-02 22:38:47 -08:00
case 0 : {
break ;
}
case ServerOP_KeepAlive : {
// ignore this
break ;
}
2017-04-02 20:03:51 -07:00
// World is tellins us what port to use.
2017-01-02 22:38:47 -08:00
case ServerOP_SetConnectInfo : {
if ( pack - > size ! = sizeof ( ServerConnectInfo ) )
break ;
2017-04-02 20:03:51 -07:00
ServerConnectInfo * sci = ( ServerConnectInfo * ) pack - > pBuffer ;
2020-03-21 17:05:28 -07:00
if ( sci - > port = = 0 ) {
LogCritical ( " World did not have a port to assign from this server, the port range was not large enough. " ) ;
Shutdown ( ) ;
}
else {
LogInfo ( " World assigned Port: [{}] for this zone " , sci - > port ) ;
ZoneConfig : : SetZonePort ( sci - > port ) ;
}
2017-01-02 22:38:47 -08:00
break ;
}
case ServerOP_ChannelMessage : {
if ( ! is_zone_loaded )
break ;
2017-04-02 20:03:51 -07:00
ServerChannelMessage_Struct * scm = ( ServerChannelMessage_Struct * ) pack - > pBuffer ;
2017-01-02 22:38:47 -08:00
if ( scm - > deliverto [ 0 ] = = 0 ) {
2019-07-14 20:03:30 -07:00
entity_list . ChannelMessageFromWorld ( scm - > from , scm - > to , scm - > chan_num , scm - > guilddbid , scm - > language , scm - > lang_skill , scm - > message ) ;
2013-02-16 16:14:39 -08:00
}
2017-04-02 20:03:51 -07:00
else {
2017-01-02 22:38:47 -08:00
Client * client = entity_list . GetClientByName ( scm - > deliverto ) ;
2019-07-14 20:03:30 -07:00
if ( client & & client - > Connected ( ) ) {
if ( scm - > chan_num = = ChatChannel_TellEcho ) {
2017-01-02 22:38:47 -08:00
if ( scm - > queued = = 1 ) // tell was queued
client - > Tell_StringID ( QUEUED_TELL , scm - > to , scm - > message ) ;
else if ( scm - > queued = = 2 ) // tell queue was full
client - > Tell_StringID ( QUEUE_TELL_FULL , scm - > to , scm - > message ) ;
else if ( scm - > queued = = 3 ) // person was offline
2019-08-11 00:14:02 -05:00
client - > MessageString ( Chat : : EchoTell , TOLD_NOT_ONLINE , scm - > to ) ;
2019-07-14 20:03:30 -07:00
else // normal tell echo "You told Soanso, 'something'"
// tell echo doesn't use language, so it looks normal to you even if nobody can understand your tells
client - > ChannelMessageSend ( scm - > from , scm - > to , scm - > chan_num , 0 , 100 , scm - > message ) ;
}
else if ( scm - > chan_num = = ChatChannel_Tell ) {
client - > ChannelMessageSend ( scm - > from , scm - > to , scm - > chan_num , scm - > language , scm - > lang_skill , scm - > message ) ;
if ( scm - > queued = = 0 ) { // this is not a queued tell
// if it's a tell, echo back to acknowledge it and make it show on the sender's client
scm - > chan_num = ChatChannel_TellEcho ;
2017-01-02 22:38:47 -08:00
memset ( scm - > deliverto , 0 , sizeof ( scm - > deliverto ) ) ;
strcpy ( scm - > deliverto , scm - > from ) ;
SendPacket ( pack ) ;
2013-02-16 16:14:39 -08:00
}
}
2019-07-14 20:03:30 -07:00
else {
client - > ChannelMessageSend ( scm - > from , scm - > to , scm - > chan_num , scm - > language , scm - > lang_skill , scm - > message ) ;
}
2013-02-16 16:14:39 -08:00
}
}
2017-01-02 22:38:47 -08:00
break ;
}
case ServerOP_VoiceMacro : {
2013-02-16 16:14:39 -08:00
2017-01-02 22:38:47 -08:00
if ( ! is_zone_loaded )
break ;
2013-02-16 16:14:39 -08:00
2017-04-02 20:03:51 -07:00
ServerVoiceMacro_Struct * svm = ( ServerVoiceMacro_Struct * ) pack - > pBuffer ;
2013-02-16 16:14:39 -08:00
2017-01-02 22:38:47 -08:00
auto outapp = new EQApplicationPacket ( OP_VoiceMacroOut , sizeof ( VoiceMacroOut_Struct ) ) ;
VoiceMacroOut_Struct * vmo = ( VoiceMacroOut_Struct * ) outapp - > pBuffer ;
2013-02-16 16:14:39 -08:00
2017-01-02 22:38:47 -08:00
strcpy ( vmo - > From , svm - > From ) ;
vmo - > Type = svm - > Type ;
2017-04-02 20:03:51 -07:00
vmo - > Voice = svm - > Voice ;
2017-01-02 22:38:47 -08:00
vmo - > MacroNumber = svm - > MacroNumber ;
2013-02-16 16:14:39 -08:00
2017-04-02 20:03:51 -07:00
switch ( svm - > Type ) {
case VoiceMacroTell : {
Client * c = entity_list . GetClientByName ( svm - > To ) ;
if ( ! c )
2017-01-02 22:38:47 -08:00
break ;
2013-02-16 16:14:39 -08:00
2017-04-02 20:03:51 -07:00
c - > QueuePacket ( outapp ) ;
break ;
}
2013-02-16 16:14:39 -08:00
2017-04-02 20:03:51 -07:00
case VoiceMacroGroup : {
Group * g = entity_list . GetGroupByID ( svm - > GroupID ) ;
2013-02-16 16:14:39 -08:00
2017-04-02 20:03:51 -07:00
if ( ! g )
2017-01-02 22:38:47 -08:00
break ;
2013-02-16 16:14:39 -08:00
2017-04-02 20:03:51 -07:00
for ( unsigned int i = 0 ; i < MAX_GROUP_MEMBERS ; i + + ) {
if ( g - > members [ i ] & & g - > members [ i ] - > IsClient ( ) )
g - > members [ i ] - > CastToClient ( ) - > QueuePacket ( outapp ) ;
2013-02-16 16:14:39 -08:00
}
break ;
}
2017-01-02 22:38:47 -08:00
2017-04-02 20:03:51 -07:00
case VoiceMacroRaid : {
Raid * r = entity_list . GetRaidByID ( svm - > RaidID ) ;
2017-01-02 22:38:47 -08:00
2017-04-02 20:03:51 -07:00
if ( ! r )
2017-01-02 22:38:47 -08:00
break ;
2013-05-06 13:07:41 -04:00
2017-04-02 20:03:51 -07:00
for ( int i = 0 ; i < MAX_RAID_MEMBERS ; i + + )
if ( r - > members [ i ] . member )
r - > members [ i ] . member - > QueuePacket ( outapp ) ;
2013-05-06 13:07:41 -04:00
break ;
2013-02-16 16:14:39 -08:00
}
}
2017-01-02 22:38:47 -08:00
safe_delete ( outapp ) ;
break ;
}
2013-02-16 16:14:39 -08:00
2017-01-02 22:38:47 -08:00
case ServerOP_SpawnCondition : {
2017-04-02 20:03:51 -07:00
if ( pack - > size ! = sizeof ( ServerSpawnCondition_Struct ) )
2017-01-02 22:38:47 -08:00
break ;
if ( ! is_zone_loaded )
break ;
2017-04-02 20:03:51 -07:00
ServerSpawnCondition_Struct * ssc = ( ServerSpawnCondition_Struct * ) pack - > pBuffer ;
2013-05-06 13:07:41 -04:00
2017-01-02 22:38:47 -08:00
zone - > spawn_conditions . SetCondition ( zone - > GetShortName ( ) , zone - > GetInstanceID ( ) , ssc - > condition_id , ssc - > value , true ) ;
break ;
}
case ServerOP_SpawnEvent : {
2017-04-02 20:03:51 -07:00
if ( pack - > size ! = sizeof ( ServerSpawnEvent_Struct ) )
2013-05-06 13:07:41 -04:00
break ;
2017-01-02 22:38:47 -08:00
if ( ! is_zone_loaded )
break ;
2017-04-02 20:03:51 -07:00
ServerSpawnEvent_Struct * sse = ( ServerSpawnEvent_Struct * ) pack - > pBuffer ;
2013-05-06 13:07:41 -04:00
2017-01-02 22:38:47 -08:00
zone - > spawn_conditions . ReloadEvent ( sse - > event_id ) ;
2013-05-06 13:07:41 -04:00
2017-01-02 22:38:47 -08:00
break ;
}
case ServerOP_AcceptWorldEntrance : {
2017-04-02 20:03:51 -07:00
if ( pack - > size ! = sizeof ( WorldToZone_Struct ) )
2013-05-06 13:07:41 -04:00
break ;
2017-01-02 22:38:47 -08:00
if ( ! is_zone_loaded )
break ;
2017-04-02 20:03:51 -07:00
WorldToZone_Struct * wtz = ( WorldToZone_Struct * ) pack - > pBuffer ;
2013-02-16 16:14:39 -08:00
2017-04-02 20:03:51 -07:00
if ( zone - > GetMaxClients ( ) ! = 0 & & numclients > = zone - > GetMaxClients ( ) )
2017-01-02 22:38:47 -08:00
wtz - > response = - 1 ;
else
wtz - > response = 1 ;
2013-02-16 16:14:39 -08:00
2017-01-02 22:38:47 -08:00
SendPacket ( pack ) ;
break ;
}
case ServerOP_ZoneToZoneRequest : {
2017-04-02 20:03:51 -07:00
if ( pack - > size ! = sizeof ( ZoneToZone_Struct ) )
2013-05-06 13:07:41 -04:00
break ;
2017-01-02 22:38:47 -08:00
if ( ! is_zone_loaded )
break ;
2017-04-02 20:03:51 -07:00
ZoneToZone_Struct * ztz = ( ZoneToZone_Struct * ) pack - > pBuffer ;
2013-05-06 13:07:41 -04:00
2017-04-02 20:03:51 -07:00
if ( ztz - > current_zone_id = = zone - > GetZoneID ( )
2017-01-02 22:38:47 -08:00
& & ztz - > current_instance_id = = zone - > GetInstanceID ( ) ) {
// it's a response
Entity * entity = entity_list . GetClientByName ( ztz - > name ) ;
2017-04-02 20:03:51 -07:00
if ( entity = = 0 )
2017-01-02 22:38:47 -08:00
break ;
2013-02-16 16:14:39 -08:00
2017-01-02 22:38:47 -08:00
EQApplicationPacket * outapp ;
2017-04-02 20:03:51 -07:00
outapp = new EQApplicationPacket ( OP_ZoneChange , sizeof ( ZoneChange_Struct ) ) ;
ZoneChange_Struct * zc2 = ( ZoneChange_Struct * ) outapp - > pBuffer ;
2013-02-16 16:14:39 -08:00
2017-04-02 20:03:51 -07:00
if ( ztz - > response < = 0 ) {
2017-01-02 22:38:47 -08:00
zc2 - > success = ZONE_ERROR_NOTREADY ;
entity - > CastToMob ( ) - > SetZone ( ztz - > current_zone_id , ztz - > current_instance_id ) ;
2018-01-17 21:37:06 -05:00
entity - > CastToClient ( ) - > SetZoning ( false ) ;
2017-01-02 22:38:47 -08:00
}
else {
entity - > CastToClient ( ) - > UpdateWho ( 1 ) ;
2017-04-02 20:03:51 -07:00
strn0cpy ( zc2 - > char_name , entity - > CastToMob ( ) - > GetName ( ) , 64 ) ;
zc2 - > zoneID = ztz - > requested_zone_id ;
zc2 - > instanceID = ztz - > requested_instance_id ;
2017-01-02 22:38:47 -08:00
zc2 - > success = 1 ;
// This block is necessary to clean up any merc objects owned by a Client. Maybe we should do this for bots, too?
2017-04-02 20:03:51 -07:00
if ( entity - > CastToClient ( ) - > GetMerc ( ) ! = nullptr )
2017-01-02 22:38:47 -08:00
{
2017-04-02 20:03:51 -07:00
entity - > CastToClient ( ) - > GetMerc ( ) - > ProcessClientZoneChange ( entity - > CastToClient ( ) ) ;
2013-02-16 16:14:39 -08:00
}
2017-01-02 22:38:47 -08:00
entity - > CastToMob ( ) - > SetZone ( ztz - > requested_zone_id , ztz - > requested_instance_id ) ;
2013-02-16 16:14:39 -08:00
2017-04-02 20:03:51 -07:00
if ( ztz - > ignorerestrictions = = 3 )
2017-01-02 22:38:47 -08:00
entity - > CastToClient ( ) - > GoToSafeCoords ( ztz - > requested_zone_id , ztz - > requested_instance_id ) ;
}
2013-02-16 16:14:39 -08:00
2017-01-02 22:38:47 -08:00
outapp - > priority = 6 ;
entity - > CastToClient ( ) - > QueuePacket ( outapp ) ;
safe_delete ( outapp ) ;
2013-02-16 16:14:39 -08:00
2017-04-02 20:03:51 -07:00
switch ( ztz - > response )
2017-01-02 22:38:47 -08:00
{
case - 2 : {
2019-08-11 00:00:55 -05:00
entity - > CastToClient ( ) - > Message ( Chat : : Red , " You do not own the required locations to enter this zone. " ) ;
2017-01-02 22:38:47 -08:00
break ;
2013-02-16 16:14:39 -08:00
}
2017-01-02 22:38:47 -08:00
case - 1 : {
2019-08-11 00:00:55 -05:00
entity - > CastToClient ( ) - > Message ( Chat : : Red , " The zone is currently full, please try again later. " ) ;
2013-02-16 16:14:39 -08:00
break ;
}
2017-04-02 20:03:51 -07:00
case 0 : {
2019-08-11 00:00:55 -05:00
entity - > CastToClient ( ) - > Message ( Chat : : Red , " All zone servers are taken at this time, please try again later. " ) ;
2017-01-02 22:38:47 -08:00
break ;
}
}
}
else {
// it's a request
ztz - > response = 0 ;
2017-04-02 20:03:51 -07:00
if ( zone - > GetMaxClients ( ) ! = 0 & & numclients > = zone - > GetMaxClients ( ) )
2017-01-02 22:38:47 -08:00
ztz - > response = - 1 ;
else {
ztz - > response = 1 ;
// since they asked about comming, lets assume they are on their way and not shut down.
zone - > StartShutdownTimer ( AUTHENTICATION_TIMEOUT * 1000 ) ;
}
SendPacket ( pack ) ;
2013-02-16 16:14:39 -08:00
break ;
}
2017-01-02 22:38:47 -08:00
break ;
}
2017-04-02 20:03:51 -07:00
case ServerOP_WhoAllReply : {
if ( ! is_zone_loaded )
2017-01-02 22:38:47 -08:00
break ;
2013-05-06 13:07:41 -04:00
2017-04-02 20:03:51 -07:00
WhoAllReturnStruct * wars = ( WhoAllReturnStruct * ) pack - > pBuffer ;
if ( wars & & wars - > id ! = 0 & & wars - > id < 0xFFFFFFFF ) {
2017-01-02 22:38:47 -08:00
Client * client = entity_list . GetClientByID ( wars - > id ) ;
if ( client ) {
2017-04-02 20:03:51 -07:00
if ( pack - > size = = 64 ) //no results
2019-08-11 00:14:02 -05:00
client - > MessageString ( Chat : : White , WHOALL_NO_RESULTS ) ;
2013-02-16 16:14:39 -08:00
else {
2017-01-02 22:38:47 -08:00
auto outapp = new EQApplicationPacket ( OP_WhoAllResponse , pack - > size ) ;
memcpy ( outapp - > pBuffer , pack - > pBuffer , pack - > size ) ;
client - > QueuePacket ( outapp ) ;
safe_delete ( outapp ) ;
2013-02-16 16:14:39 -08:00
}
}
2017-01-02 22:38:47 -08:00
else {
2019-09-02 03:18:12 -05:00
LogDebug ( " [CLIENT] id=[{}], playerineqstring=[{}], playersinzonestring=[{}]. Dumping WhoAllReturnStruct: " ,
2017-01-02 22:38:47 -08:00
wars - > id , wars - > playerineqstring , wars - > playersinzonestring ) ;
}
2013-02-16 16:14:39 -08:00
}
2017-01-02 22:38:47 -08:00
else
2019-09-01 22:05:44 -05:00
LogError ( " WhoAllReturnStruct: Could not get return struct! " ) ;
2017-01-02 22:38:47 -08:00
break ;
}
case ServerOP_EmoteMessage : {
if ( ! is_zone_loaded )
break ;
2017-04-02 20:03:51 -07:00
ServerEmoteMessage_Struct * sem = ( ServerEmoteMessage_Struct * ) pack - > pBuffer ;
2017-01-02 22:38:47 -08:00
if ( sem - > to [ 0 ] ! = 0 ) {
if ( strcasecmp ( sem - > to , zone - > GetShortName ( ) ) = = 0 )
entity_list . MessageStatus ( sem - > guilddbid , sem - > minstatus , sem - > type , ( char * ) sem - > message ) ;
else {
Client * client = entity_list . GetClientByName ( sem - > to ) ;
2017-04-02 20:03:51 -07:00
if ( client ! = 0 ) {
char * newmessage = 0 ;
if ( strstr ( sem - > message , " ^ " ) = = 0 )
2017-01-02 22:38:47 -08:00
client - > Message ( sem - > type , ( char * ) sem - > message ) ;
2017-04-02 20:03:51 -07:00
else {
for ( newmessage = strtok ( ( char * ) sem - > message , " ^ " ) ; newmessage ! = nullptr ; newmessage = strtok ( nullptr , " ^ " ) )
2017-01-02 22:38:47 -08:00
client - > Message ( sem - > type , newmessage ) ;
2013-02-16 16:14:39 -08:00
}
}
}
2017-01-02 22:38:47 -08:00
}
2017-04-02 20:03:51 -07:00
else {
char * newmessage = 0 ;
if ( strstr ( sem - > message , " ^ " ) = = 0 )
2017-01-02 22:38:47 -08:00
entity_list . MessageStatus ( sem - > guilddbid , sem - > minstatus , sem - > type , sem - > message ) ;
2017-04-02 20:03:51 -07:00
else {
for ( newmessage = strtok ( ( char * ) sem - > message , " ^ " ) ; newmessage ! = nullptr ; newmessage = strtok ( nullptr , " ^ " ) )
2017-01-02 22:38:47 -08:00
entity_list . MessageStatus ( sem - > guilddbid , sem - > minstatus , sem - > type , newmessage ) ;
2013-02-16 16:14:39 -08:00
}
2017-01-02 22:38:47 -08:00
}
break ;
}
case ServerOP_Motd : {
2017-04-02 20:03:51 -07:00
ServerMotd_Struct * smotd = ( ServerMotd_Struct * ) pack - > pBuffer ;
2017-01-02 22:38:47 -08:00
EQApplicationPacket * outapp ;
outapp = new EQApplicationPacket ( OP_MOTD ) ;
2017-04-02 20:03:51 -07:00
char tmp [ 500 ] = { 0 } ;
2017-01-02 22:38:47 -08:00
sprintf ( tmp , " %s " , smotd - > motd ) ;
2017-04-02 20:03:51 -07:00
outapp - > size = strlen ( tmp ) + 1 ;
2017-01-02 22:38:47 -08:00
outapp - > pBuffer = new uchar [ outapp - > size ] ;
2017-04-02 20:03:51 -07:00
memset ( outapp - > pBuffer , 0 , outapp - > size ) ;
2017-01-02 22:38:47 -08:00
strcpy ( ( char * ) outapp - > pBuffer , tmp ) ;
entity_list . QueueClients ( 0 , outapp ) ;
safe_delete ( outapp ) ;
break ;
}
case ServerOP_ShutdownAll : {
entity_list . Save ( ) ;
2020-03-21 17:05:28 -07:00
Shutdown ( ) ;
2017-01-02 22:38:47 -08:00
break ;
}
case ServerOP_ZoneShutdown : {
if ( pack - > size ! = sizeof ( ServerZoneStateChange_struct ) ) {
std : : cout < < " Wrong size on ServerOP_ZoneShutdown. Got: " < < pack - > size < < " , Expected: " < < sizeof ( ServerZoneStateChange_struct ) < < std : : endl ;
2013-02-16 16:14:39 -08:00
break ;
}
2017-01-02 22:38:47 -08:00
// Annouce the change to the world
if ( ! is_zone_loaded ) {
SetZoneData ( 0 ) ;
}
else {
SendEmoteMessage ( 0 , 0 , 15 , " Zone shutdown: %s " , zone - > GetLongName ( ) ) ;
2013-02-16 16:14:39 -08:00
2017-04-02 20:03:51 -07:00
ServerZoneStateChange_struct * zst = ( ServerZoneStateChange_struct * ) pack - > pBuffer ;
2017-01-02 22:38:47 -08:00
std : : cout < < " Zone shutdown by " < < zst - > adminname < < std : : endl ;
Zone : : Shutdown ( ) ;
2013-02-16 16:14:39 -08:00
}
2017-01-02 22:38:47 -08:00
break ;
}
case ServerOP_ZoneBootup : {
if ( pack - > size ! = sizeof ( ServerZoneStateChange_struct ) ) {
std : : cout < < " Wrong size on ServerOP_ZoneBootup. Got: " < < pack - > size < < " , Expected: " < < sizeof ( ServerZoneStateChange_struct ) < < std : : endl ;
2013-02-16 16:14:39 -08:00
break ;
}
2017-04-02 20:03:51 -07:00
ServerZoneStateChange_struct * zst = ( ServerZoneStateChange_struct * ) pack - > pBuffer ;
2017-01-02 22:38:47 -08:00
if ( is_zone_loaded ) {
SetZoneData ( zone - > GetZoneID ( ) , zone - > GetInstanceID ( ) ) ;
if ( zst - > zoneid = = zone - > GetZoneID ( ) ) {
// This packet also doubles as "incoming client" notification, lets not shut down before they get here
zone - > StartShutdownTimer ( AUTHENTICATION_TIMEOUT * 1000 ) ;
2013-02-16 16:14:39 -08:00
}
else {
2017-01-02 22:38:47 -08:00
SendEmoteMessage ( zst - > adminname , 0 , 0 , " Zone bootup failed: Already running '%s' " , zone - > GetShortName ( ) ) ;
2013-02-16 16:14:39 -08:00
}
break ;
}
2013-05-06 13:07:41 -04:00
2017-01-02 22:38:47 -08:00
if ( zst - > adminname [ 0 ] ! = 0 )
std : : cout < < " Zone bootup by " < < zst - > adminname < < std : : endl ;
2013-05-06 13:07:41 -04:00
2017-01-02 22:38:47 -08:00
Zone : : Bootup ( zst - > zoneid , zst - > instanceid , zst - > makestatic ) ;
break ;
}
case ServerOP_ZoneIncClient : {
if ( pack - > size ! = sizeof ( ServerZoneIncomingClient_Struct ) ) {
std : : cout < < " Wrong size on ServerOP_ZoneIncClient. Got: " < < pack - > size < < " , Expected: " < < sizeof ( ServerZoneIncomingClient_Struct ) < < std : : endl ;
2013-02-16 16:14:39 -08:00
break ;
}
2017-04-02 20:03:51 -07:00
ServerZoneIncomingClient_Struct * szic = ( ServerZoneIncomingClient_Struct * ) pack - > pBuffer ;
2017-01-02 22:38:47 -08:00
if ( is_zone_loaded ) {
SetZoneData ( zone - > GetZoneID ( ) , zone - > GetInstanceID ( ) ) ;
2019-07-24 19:20:09 -07:00
2017-01-02 22:38:47 -08:00
if ( szic - > zoneid = = zone - > GetZoneID ( ) ) {
2019-07-27 20:13:04 -07:00
auto client = entity_list . GetClientByLSID ( szic - > lsid ) ;
if ( client ) {
client - > Kick ( " Dropped by world CLE subsystem " ) ;
client - > Save ( ) ;
}
zone - > RemoveAuth ( szic - > lsid ) ;
2017-01-02 22:38:47 -08:00
zone - > AddAuth ( szic ) ;
// This packet also doubles as "incoming client" notification, lets not shut down before they get here
zone - > StartShutdownTimer ( AUTHENTICATION_TIMEOUT * 1000 ) ;
2013-02-16 16:14:39 -08:00
}
2017-01-02 22:38:47 -08:00
}
else {
if ( ( Zone : : Bootup ( szic - > zoneid , szic - > instanceid ) ) ) {
zone - > AddAuth ( szic ) ;
2013-02-16 16:14:39 -08:00
}
2017-01-02 22:38:47 -08:00
}
break ;
}
2019-07-23 21:59:22 -07:00
case ServerOP_DropClient : {
if ( pack - > size ! = sizeof ( ServerZoneDropClient_Struct ) ) {
break ;
}
ServerZoneDropClient_Struct * drop = ( ServerZoneDropClient_Struct * ) pack - > pBuffer ;
if ( zone ) {
zone - > RemoveAuth ( drop - > lsid ) ;
2019-09-07 20:20:10 -05:00
2019-07-23 21:59:22 -07:00
auto client = entity_list . GetClientByLSID ( drop - > lsid ) ;
if ( client ) {
2019-07-26 19:22:29 -07:00
client - > Kick ( " Dropped by world CLE subsystem " ) ;
2019-07-23 21:59:22 -07:00
client - > Save ( ) ;
}
}
break ;
}
2017-01-02 22:38:47 -08:00
case ServerOP_ZonePlayer : {
2017-04-02 20:03:51 -07:00
ServerZonePlayer_Struct * szp = ( ServerZonePlayer_Struct * ) pack - > pBuffer ;
2017-01-02 22:38:47 -08:00
Client * client = entity_list . GetClientByName ( szp - > name ) ;
printf ( " Zoning %s to %s(%u) - %u \n " , client ! = nullptr ? client - > GetCleanName ( ) : " Unknown " , szp - > zone , database . GetZoneID ( szp - > zone ) , szp - > instance_id ) ;
if ( client ! = 0 ) {
if ( strcasecmp ( szp - > adminname , szp - > name ) = = 0 )
2019-08-11 00:27:04 -05:00
client - > Message ( Chat : : White , " Zoning to: %s " , szp - > zone ) ;
2017-01-02 22:38:47 -08:00
else if ( client - > GetAnon ( ) = = 1 & & client - > Admin ( ) > szp - > adminrank )
break ;
2013-02-16 16:14:39 -08:00
else {
2017-01-02 22:38:47 -08:00
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 ) ;
2013-02-16 16:14:39 -08:00
}
2017-01-02 22:38:47 -08:00
if ( ! szp - > instance_id ) {
client - > MovePC ( database . GetZoneID ( szp - > zone ) , szp - > instance_id , szp - > x_pos , szp - > y_pos , szp - > z_pos , client - > GetHeading ( ) , szp - > ignorerestrictions , GMSummon ) ;
2013-02-16 16:14:39 -08:00
}
else {
2017-01-02 22:38:47 -08:00
if ( database . GetInstanceID ( client - > CharacterID ( ) , database . GetZoneID ( szp - > zone ) ) = = 0 ) {
client - > AssignToInstance ( szp - > instance_id ) ;
2016-09-11 19:19:09 -04:00
client - > MovePC ( database . GetZoneID ( szp - > zone ) , szp - > instance_id , szp - > x_pos , szp - > y_pos , szp - > z_pos , client - > GetHeading ( ) , szp - > ignorerestrictions , GMSummon ) ;
2013-02-16 16:14:39 -08:00
}
else {
2017-01-02 22:38:47 -08:00
client - > RemoveFromInstance ( database . GetInstanceID ( client - > CharacterID ( ) , database . GetZoneID ( szp - > zone ) ) ) ;
client - > AssignToInstance ( szp - > instance_id ) ;
client - > MovePC ( database . GetZoneID ( szp - > zone ) , szp - > instance_id , szp - > x_pos , szp - > y_pos , szp - > z_pos , client - > GetHeading ( ) , szp - > ignorerestrictions , GMSummon ) ;
2016-09-11 19:19:09 -04:00
}
2013-02-16 16:14:39 -08:00
}
}
2017-01-02 22:38:47 -08:00
break ;
}
case ServerOP_KickPlayer : {
2017-04-02 20:03:51 -07:00
ServerKickPlayer_Struct * skp = ( ServerKickPlayer_Struct * ) pack - > pBuffer ;
2017-01-02 22:38:47 -08:00
Client * client = entity_list . GetClientByName ( skp - > name ) ;
if ( client ! = 0 ) {
if ( skp - > adminrank > = client - > Admin ( ) ) {
client - > WorldKick ( ) ;
if ( is_zone_loaded )
SendEmoteMessage ( skp - > adminname , 0 , 0 , " Remote Kick: %s booted in zone %s. " , skp - > name , zone - > GetShortName ( ) ) ;
else
SendEmoteMessage ( skp - > adminname , 0 , 0 , " Remote Kick: %s booted. " , skp - > name ) ;
2013-02-16 16:14:39 -08:00
}
2017-01-02 22:38:47 -08:00
else if ( client - > GetAnon ( ) ! = 1 )
SendEmoteMessage ( skp - > adminname , 0 , 0 , " Remote Kick: Your avatar level is not high enough to kick %s " , skp - > name ) ;
2013-02-16 16:14:39 -08:00
}
2017-01-02 22:38:47 -08:00
break ;
}
case ServerOP_KillPlayer : {
2017-04-02 20:03:51 -07:00
ServerKillPlayer_Struct * skp = ( ServerKillPlayer_Struct * ) pack - > pBuffer ;
2017-01-02 22:38:47 -08:00
Client * client = entity_list . GetClientByName ( skp - > target ) ;
if ( client ! = 0 ) {
if ( skp - > admin > = client - > Admin ( ) ) {
client - > GMKill ( ) ;
if ( is_zone_loaded )
SendEmoteMessage ( skp - > gmname , 0 , 0 , " Remote Kill: %s killed in zone %s. " , skp - > target , zone - > GetShortName ( ) ) ;
else
SendEmoteMessage ( skp - > gmname , 0 , 0 , " Remote Kill: %s killed. " , skp - > target ) ;
2013-02-16 16:14:39 -08:00
}
2017-01-02 22:38:47 -08:00
else if ( client - > GetAnon ( ) ! = 1 )
SendEmoteMessage ( skp - > gmname , 0 , 0 , " Remote Kill: Your avatar level is not high enough to kill %s " , skp - > target ) ;
2013-02-16 16:14:39 -08:00
}
2017-01-02 22:38:47 -08:00
break ;
}
2013-05-06 13:07:41 -04:00
2017-04-02 20:03:51 -07:00
//hand all the guild related packets to the guild manager for processing.
2017-01-02 22:38:47 -08:00
case ServerOP_OnlineGuildMembersResponse :
case ServerOP_RefreshGuild :
2017-04-02 20:03:51 -07:00
// case ServerOP_GuildInvite:
2017-01-02 22:38:47 -08:00
case ServerOP_DeleteGuild :
case ServerOP_GuildCharRefresh :
case ServerOP_GuildMemberUpdate :
case ServerOP_GuildRankUpdate :
case ServerOP_LFGuildUpdate :
2017-04-02 20:03:51 -07:00
// case ServerOP_GuildGMSet:
// case ServerOP_GuildGMSetRank:
// case ServerOP_GuildJoin:
2017-01-02 22:38:47 -08:00
guild_mgr . ProcessWorldPacket ( pack ) ;
break ;
case ServerOP_FlagUpdate : {
2017-04-02 20:03:51 -07:00
Client * client = entity_list . GetClientByAccID ( * ( ( uint32 * ) pack - > pBuffer ) ) ;
2017-01-02 22:38:47 -08:00
if ( client ! = 0 ) {
client - > UpdateAdmin ( ) ;
}
break ;
}
case ServerOP_GMGoto : {
if ( pack - > size ! = sizeof ( ServerGMGoto_Struct ) ) {
std : : cout < < " Wrong size on ServerOP_GMGoto. Got: " < < pack - > size < < " , Expected: " < < sizeof ( ServerGMGoto_Struct ) < < std : : endl ;
break ;
}
if ( ! is_zone_loaded )
break ;
2017-04-02 20:03:51 -07:00
ServerGMGoto_Struct * gmg = ( ServerGMGoto_Struct * ) pack - > pBuffer ;
2017-01-02 22:38:47 -08:00
Client * client = entity_list . GetClientByName ( gmg - > gotoname ) ;
if ( client ! = 0 ) {
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 ( ) ) ;
auto outpack = new ServerPacket ( ServerOP_ZonePlayer , sizeof ( ServerZonePlayer_Struct ) ) ;
2017-04-02 20:03:51 -07:00
ServerZonePlayer_Struct * szp = ( ServerZonePlayer_Struct * ) outpack - > pBuffer ;
2017-01-02 22:38:47 -08:00
strcpy ( szp - > adminname , gmg - > myname ) ;
strcpy ( szp - > name , gmg - > myname ) ;
strcpy ( szp - > zone , zone - > GetShortName ( ) ) ;
szp - > instance_id = zone - > GetInstanceID ( ) ;
szp - > x_pos = client - > GetX ( ) ;
szp - > y_pos = client - > GetY ( ) ;
szp - > z_pos = client - > GetZ ( ) ;
SendPacket ( outpack ) ;
safe_delete ( outpack ) ;
}
else {
SendEmoteMessage ( gmg - > myname , 0 , 13 , " Error: %s not found " , gmg - > gotoname ) ;
}
break ;
}
case ServerOP_MultiLineMsg : {
2017-04-02 20:03:51 -07:00
ServerMultiLineMsg_Struct * mlm = ( ServerMultiLineMsg_Struct * ) pack - > pBuffer ;
2017-01-02 22:38:47 -08:00
Client * client = entity_list . GetClientByName ( mlm - > to ) ;
if ( client ) {
auto outapp = new EQApplicationPacket ( OP_MultiLineMsg , strlen ( mlm - > message ) ) ;
2017-04-02 20:03:51 -07:00
strcpy ( ( char * ) outapp - > pBuffer , mlm - > message ) ;
2017-01-02 22:38:47 -08:00
client - > QueuePacket ( outapp ) ;
safe_delete ( outapp ) ;
2013-02-16 16:14:39 -08:00
}
2017-01-02 22:38:47 -08:00
break ;
}
case ServerOP_Uptime : {
if ( pack - > size ! = sizeof ( ServerUptime_Struct ) ) {
std : : cout < < " Wrong size on ServerOP_Uptime. Got: " < < pack - > size < < " , Expected: " < < sizeof ( ServerUptime_Struct ) < < std : : endl ;
break ;
}
2017-04-02 20:03:51 -07:00
ServerUptime_Struct * sus = ( ServerUptime_Struct * ) pack - > pBuffer ;
2017-01-02 22:38:47 -08:00
uint32 ms = Timer : : GetCurrentTime ( ) ;
uint32 d = ms / 86400000 ;
ms - = d * 86400000 ;
uint32 h = ms / 3600000 ;
ms - = h * 3600000 ;
uint32 m = ms / 60000 ;
ms - = m * 60000 ;
uint32 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 ) ;
}
case ServerOP_Petition : {
std : : cout < < " Got Server Requested Petition List Refresh " < < std : : endl ;
2017-04-02 20:03:51 -07:00
ServerPetitionUpdate_Struct * sus = ( ServerPetitionUpdate_Struct * ) pack - > pBuffer ;
2017-01-02 22:38:47 -08:00
// this was typoed to = instead of ==, not that it acts any different now though..
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_RezzPlayer : {
2017-04-02 20:03:51 -07:00
RezzPlayer_Struct * srs = ( RezzPlayer_Struct * ) pack - > pBuffer ;
2017-01-02 22:38:47 -08:00
if ( srs - > rezzopcode = = OP_RezzRequest )
{
// The Rezz request has arrived in the zone the player to be rezzed is currently in,
// so we send the request to their client which will bring up the confirmation box.
Client * client = entity_list . GetClientByName ( srs - > rez . your_name ) ;
if ( client )
2013-02-16 16:14:39 -08:00
{
2017-04-02 20:03:51 -07:00
if ( client - > IsRezzPending ( ) )
2013-02-16 16:14:39 -08:00
{
2017-01-02 22:38:47 -08:00
auto Response = new ServerPacket ( ServerOP_RezzPlayerReject ,
2017-04-02 20:03:51 -07:00
strlen ( srs - > rez . rezzer_name ) + 1 ) ;
2013-02-16 16:14:39 -08:00
2017-01-02 22:38:47 -08:00
char * Buffer = ( char * ) Response - > pBuffer ;
sprintf ( Buffer , " %s " , srs - > rez . rezzer_name ) ;
worldserver . SendPacket ( Response ) ;
safe_delete ( Response ) ;
break ;
2013-02-16 16:14:39 -08:00
}
2017-01-02 22:38:47 -08:00
//pendingrezexp is the amount of XP on the corpse. Setting it to a value >= 0
//also serves to inform Client::OPRezzAnswer to expect a packet.
client - > SetPendingRezzData ( srs - > exp , srs - > dbid , srs - > rez . spellid , srs - > rez . corpse_name ) ;
2019-09-02 03:26:44 -05:00
LogSpells ( " OP_RezzRequest in zone [{}] for [{}], spellid:[{}] " ,
2017-04-02 20:03:51 -07:00
zone - > GetShortName ( ) , client - > GetName ( ) , srs - > rez . spellid ) ;
auto outapp = new EQApplicationPacket ( OP_RezzRequest ,
sizeof ( Resurrect_Struct ) ) ;
memcpy ( outapp - > pBuffer , & srs - > rez , sizeof ( Resurrect_Struct ) ) ;
2013-02-16 16:14:39 -08:00
client - > QueuePacket ( outapp ) ;
safe_delete ( outapp ) ;
break ;
}
2017-01-02 22:38:47 -08:00
}
2017-04-02 20:03:51 -07:00
if ( srs - > rezzopcode = = OP_RezzComplete ) {
2017-01-02 22:38:47 -08:00
// We get here when the Rezz complete packet has come back via the world server
// to the zone that the corpse is in.
Corpse * corpse = entity_list . GetCorpseByName ( srs - > rez . corpse_name ) ;
if ( corpse & & corpse - > IsCorpse ( ) ) {
2019-09-02 03:26:44 -05:00
LogSpells ( " OP_RezzComplete received in zone [{}] for corpse [{}] " ,
2017-04-02 20:03:51 -07:00
zone - > GetShortName ( ) , srs - > rez . corpse_name ) ;
2017-01-02 22:38:47 -08:00
2019-09-02 03:26:44 -05:00
LogSpells ( " Found corpse. Marking corpse as rezzed if needed " ) ;
2017-01-02 22:38:47 -08:00
// I don't know why Rezzed is not set to true in CompleteRezz().
if ( ! IsEffectInSpell ( srs - > rez . spellid , SE_SummonToCorpse ) ) {
corpse - > IsRezzed ( true ) ;
corpse - > CompleteResurrection ( ) ;
2013-02-16 16:14:39 -08:00
}
}
}
2017-01-02 22:38:47 -08:00
break ;
}
case ServerOP_RezzPlayerReject :
{
char * Rezzer = ( char * ) pack - > pBuffer ;
2013-02-16 16:14:39 -08:00
2017-01-02 22:38:47 -08:00
Client * c = entity_list . GetClientByName ( Rezzer ) ;
2013-02-16 16:14:39 -08:00
2017-01-02 22:38:47 -08:00
if ( c )
2019-08-11 00:14:02 -05:00
c - > MessageString ( Chat : : SpellWornOff , REZZ_ALREADY_PENDING ) ;
2015-05-25 23:48:11 -05:00
2017-01-02 22:38:47 -08:00
break ;
}
case ServerOP_ZoneReboot : {
std : : cout < < " Got Server Requested Zone reboot " < < std : : endl ;
2017-04-02 20:03:51 -07:00
ServerZoneReboot_Struct * zb = ( ServerZoneReboot_Struct * ) pack - > pBuffer ;
2017-01-02 22:38:47 -08:00
break ;
}
case ServerOP_SyncWorldTime : {
if ( zone ! = 0 & & ! zone - > is_zone_time_localized ) {
2019-09-02 03:30:03 -05:00
LogInfo ( " [{}] Received Message SyncWorldTime " , __FUNCTION__ ) ;
2017-01-02 22:38:47 -08:00
eqTimeOfDay * newtime = ( eqTimeOfDay * ) pack - > pBuffer ;
zone - > zone_time . SetCurrentEQTimeOfDay ( newtime - > start_eqtime , newtime - > start_realtime ) ;
auto outapp = new EQApplicationPacket ( OP_TimeOfDay , sizeof ( TimeOfDay_Struct ) ) ;
TimeOfDay_Struct * time_of_day = ( TimeOfDay_Struct * ) outapp - > pBuffer ;
zone - > zone_time . GetCurrentEQTimeOfDay ( time ( 0 ) , time_of_day ) ;
entity_list . QueueClients ( 0 , outapp , false ) ;
safe_delete ( outapp ) ;
2015-05-25 23:48:11 -05:00
2017-01-02 22:38:47 -08:00
char time_message [ 255 ] ;
time_t current_time = time ( nullptr ) ;
TimeOfDay_Struct eq_time ;
zone - > zone_time . GetCurrentEQTimeOfDay ( current_time , & eq_time ) ;
2015-05-25 23:48:11 -05:00
2017-01-02 22:38:47 -08:00
sprintf ( time_message , " EQTime [%02d:%s%d %s] " ,
( ( eq_time . hour - 1 ) % 12 ) = = 0 ? 12 : ( ( eq_time . hour - 1 ) % 12 ) ,
( eq_time . minute < 10 ) ? " 0 " : " " ,
eq_time . minute ,
( eq_time . hour > = 13 ) ? " pm " : " am "
2015-05-25 23:48:11 -05:00
) ;
2019-09-01 21:04:58 -05:00
LogInfo ( " Time Broadcast Packet: {} " , time_message ) ;
2017-01-02 22:38:47 -08:00
zone - > SetZoneHasCurrentTime ( true ) ;
2015-05-25 23:48:11 -05:00
2013-02-16 16:14:39 -08:00
}
2017-04-02 20:03:51 -07:00
if ( zone & & zone - > is_zone_time_localized ) {
2019-09-01 21:04:58 -05:00
LogInfo ( " Received request to sync time from world, but our time is localized currently " ) ;
2013-02-16 16:14:39 -08:00
}
2017-01-02 22:38:47 -08:00
break ;
}
2019-02-04 07:02:27 -05:00
case ServerOP_RefreshCensorship : {
2020-05-17 18:36:06 -07:00
if ( ! EQ : : ProfanityManager : : LoadProfanityList ( & database ) )
2019-09-01 22:05:44 -05:00
LogError ( " Received request to refresh the profanity list..but, the action failed " ) ;
2019-02-04 07:02:27 -05:00
break ;
}
2017-01-02 22:38:47 -08:00
case ServerOP_ChangeWID : {
if ( pack - > size ! = sizeof ( ServerChangeWID_Struct ) ) {
std : : cout < < " Wrong size on ServerChangeWID_Struct. Got: " < < pack - > size < < " , Expected: " < < sizeof ( ServerChangeWID_Struct ) < < std : : endl ;
2013-02-16 16:14:39 -08:00
break ;
}
2017-04-02 20:03:51 -07:00
ServerChangeWID_Struct * scw = ( ServerChangeWID_Struct * ) pack - > pBuffer ;
2017-01-02 22:38:47 -08:00
Client * client = entity_list . GetClientByCharID ( scw - > charid ) ;
if ( client )
client - > SetWID ( scw - > newwid ) ;
break ;
}
case ServerOP_OOCMute : {
oocmuted = * ( pack - > pBuffer ) ;
break ;
}
case ServerOP_Revoke : {
2017-04-02 20:03:51 -07:00
RevokeStruct * rev = ( RevokeStruct * ) pack - > pBuffer ;
2017-01-02 22:38:47 -08:00
Client * client = entity_list . GetClientByName ( rev - > name ) ;
if ( client )
{
2017-04-02 20:03:51 -07:00
SendEmoteMessage ( rev - > adminname , 0 , 0 , " %s: %srevoking %s " , zone - > GetShortName ( ) , rev - > toggle ? " " : " un " , client - > GetName ( ) ) ;
2017-01-02 22:38:47 -08:00
client - > SetRevoked ( rev - > toggle ) ;
2013-02-16 16:14:39 -08:00
}
2017-01-02 22:38:47 -08:00
break ;
}
case ServerOP_GroupIDReply : {
2017-04-02 20:03:51 -07:00
ServerGroupIDReply_Struct * ids = ( ServerGroupIDReply_Struct * ) pack - > pBuffer ;
2017-01-02 22:38:47 -08:00
cur_groupid = ids - > start ;
last_groupid = ids - > end ;
break ;
}
case ServerOP_GroupLeave : {
ServerGroupLeave_Struct * gl = ( ServerGroupLeave_Struct * ) pack - > pBuffer ;
2017-04-02 20:03:51 -07:00
if ( zone ) {
if ( gl - > zoneid = = zone - > GetZoneID ( ) & & gl - > instance_id = = zone - > GetInstanceID ( ) )
2017-01-02 22:38:47 -08:00
break ;
2013-02-16 16:14:39 -08:00
2017-01-02 22:38:47 -08:00
entity_list . SendGroupLeave ( gl - > gid , gl - > member_name ) ;
2013-02-16 16:14:39 -08:00
}
2017-01-02 22:38:47 -08:00
break ;
}
case ServerOP_GroupInvite : {
// A player in another zone invited a player in this zone to join their group.
GroupInvite_Struct * gis = ( GroupInvite_Struct * ) pack - > pBuffer ;
2013-02-16 16:14:39 -08:00
2017-01-02 22:38:47 -08:00
Mob * Invitee = entity_list . GetMob ( gis - > invitee_name ) ;
2013-02-16 16:14:39 -08:00
2017-04-02 20:03:51 -07:00
if ( Invitee & & Invitee - > IsClient ( ) & & Invitee - > CastToClient ( ) - > MercOnlyOrNoGroup ( ) & & ! Invitee - > IsRaidGrouped ( ) )
2017-01-02 22:38:47 -08:00
{
auto outapp = new EQApplicationPacket ( OP_GroupInvite , sizeof ( GroupInvite_Struct ) ) ;
memcpy ( outapp - > pBuffer , gis , sizeof ( GroupInvite_Struct ) ) ;
Invitee - > CastToClient ( ) - > QueuePacket ( outapp ) ;
safe_delete ( outapp ) ;
2013-02-16 16:14:39 -08:00
}
2017-01-02 22:38:47 -08:00
break ;
}
case ServerOP_GroupFollow : {
// Player in another zone accepted a group invitation from a player in this zone.
2017-04-02 20:03:51 -07:00
ServerGroupFollow_Struct * sgfs = ( ServerGroupFollow_Struct * ) pack - > pBuffer ;
2017-01-02 22:38:47 -08:00
Mob * Inviter = entity_list . GetClientByName ( sgfs - > gf . name1 ) ;
2013-02-16 16:14:39 -08:00
2017-04-02 20:03:51 -07:00
if ( Inviter & & Inviter - > IsClient ( ) )
2017-01-02 22:38:47 -08:00
{
Group * group = entity_list . GetGroupByClient ( Inviter - > CastToClient ( ) ) ;
2017-04-02 20:03:51 -07:00
if ( ! group )
2013-02-16 16:14:39 -08:00
{
2017-01-02 22:38:47 -08:00
//Make new group
group = new Group ( Inviter ) ;
2013-02-16 16:14:39 -08:00
2017-01-02 22:38:47 -08:00
if ( ! group )
2014-11-22 00:22:12 -06:00
{
2017-01-02 22:38:47 -08:00
break ;
}
2013-02-16 16:14:39 -08:00
2017-01-02 22:38:47 -08:00
entity_list . AddGroup ( group ) ;
2013-02-16 16:14:39 -08:00
2017-04-02 20:03:51 -07:00
if ( group - > GetID ( ) = = 0 ) {
2019-08-11 00:00:55 -05:00
Inviter - > Message ( Chat : : Red , " Unable to get new group id. Cannot create group. " ) ;
2017-01-02 22:38:47 -08:00
break ;
}
2013-02-16 16:14:39 -08:00
2017-01-02 22:38:47 -08:00
database . SetGroupID ( Inviter - > GetName ( ) , group - > GetID ( ) , Inviter - > CastToClient ( ) - > CharacterID ( ) , false ) ;
database . SetGroupLeaderName ( group - > GetID ( ) , Inviter - > GetName ( ) ) ;
group - > UpdateGroupAAs ( ) ;
2013-02-16 16:14:39 -08:00
2020-05-17 18:36:06 -07:00
if ( Inviter - > CastToClient ( ) - > ClientVersion ( ) < EQ : : versions : : ClientVersion : : SoD )
2017-01-02 22:38:47 -08:00
{
auto outapp =
2017-04-02 20:03:51 -07:00
new EQApplicationPacket ( OP_GroupUpdate , sizeof ( GroupJoin_Struct ) ) ;
GroupJoin_Struct * outgj = ( GroupJoin_Struct * ) outapp - > pBuffer ;
2017-01-02 22:38:47 -08:00
strcpy ( outgj - > membername , Inviter - > GetName ( ) ) ;
strcpy ( outgj - > yourname , Inviter - > GetName ( ) ) ;
outgj - > action = groupActInviteInitial ; // 'You have formed the group'.
group - > GetGroupAAs ( & outgj - > leader_aas ) ;
Inviter - > CastToClient ( ) - > QueuePacket ( outapp ) ;
safe_delete ( outapp ) ;
2013-02-16 16:14:39 -08:00
}
2017-01-02 22:38:47 -08:00
else
2014-11-22 00:22:12 -06:00
{
2017-01-02 22:38:47 -08:00
// SoD and later
Inviter - > CastToClient ( ) - > SendGroupCreatePacket ( ) ;
Inviter - > CastToClient ( ) - > SendGroupLeaderChangePacket ( Inviter - > GetName ( ) ) ;
Inviter - > CastToClient ( ) - > SendGroupJoinAcknowledge ( ) ;
2014-11-22 00:22:12 -06:00
}
2013-02-16 16:14:39 -08:00
2017-02-21 21:20:33 -08:00
group - > GetXTargetAutoMgr ( ) - > merge ( * Inviter - > CastToClient ( ) - > GetXTargetAutoMgr ( ) ) ;
Inviter - > CastToClient ( ) - > GetXTargetAutoMgr ( ) - > clear ( ) ;
Inviter - > CastToClient ( ) - > SetXTargetAutoMgr ( group - > GetXTargetAutoMgr ( ) ) ;
2017-01-02 22:38:47 -08:00
}
2013-02-16 16:14:39 -08:00
2017-04-02 20:03:51 -07:00
if ( ! group )
2017-01-02 22:38:47 -08:00
{
break ;
2013-02-16 16:14:39 -08:00
}
2017-01-02 22:38:47 -08:00
auto outapp = new EQApplicationPacket ( OP_GroupFollow , sizeof ( GroupGeneric_Struct ) ) ;
GroupGeneric_Struct * gg = ( GroupGeneric_Struct * ) outapp - > pBuffer ;
strn0cpy ( gg - > name1 , sgfs - > gf . name1 , sizeof ( gg - > name1 ) ) ;
strn0cpy ( gg - > name2 , sgfs - > gf . name2 , sizeof ( gg - > name2 ) ) ;
Inviter - > CastToClient ( ) - > QueuePacket ( outapp ) ;
safe_delete ( outapp ) ;
2013-02-16 16:14:39 -08:00
2017-04-02 20:03:51 -07:00
if ( ! group - > AddMember ( nullptr , sgfs - > gf . name2 , sgfs - > CharacterID ) )
2013-02-16 16:14:39 -08:00
break ;
2013-05-06 13:07:41 -04:00
2017-04-02 20:03:51 -07:00
if ( Inviter - > CastToClient ( ) - > IsLFP ( ) )
2017-01-02 22:38:47 -08:00
Inviter - > CastToClient ( ) - > UpdateLFP ( ) ;
auto pack2 = new ServerPacket ( ServerOP_GroupJoin , sizeof ( ServerGroupJoin_Struct ) ) ;
ServerGroupJoin_Struct * gj = ( ServerGroupJoin_Struct * ) pack2 - > pBuffer ;
gj - > gid = group - > GetID ( ) ;
gj - > zoneid = zone - > GetZoneID ( ) ;
gj - > instance_id = zone - > GetInstanceID ( ) ;
strn0cpy ( gj - > member_name , sgfs - > gf . name2 , sizeof ( gj - > member_name ) ) ;
worldserver . SendPacket ( pack2 ) ;
safe_delete ( pack2 ) ;
2013-02-16 16:14:39 -08:00
2017-01-02 22:38:47 -08:00
// Send acknowledgement back to the Invitee to let them know we have added them to the group.
auto pack3 =
2017-04-02 20:03:51 -07:00
new ServerPacket ( ServerOP_GroupFollowAck , sizeof ( ServerGroupFollowAck_Struct ) ) ;
2017-01-02 22:38:47 -08:00
ServerGroupFollowAck_Struct * sgfas = ( ServerGroupFollowAck_Struct * ) pack3 - > pBuffer ;
strn0cpy ( sgfas - > Name , sgfs - > gf . name2 , sizeof ( sgfas - > Name ) ) ;
worldserver . SendPacket ( pack3 ) ;
safe_delete ( pack3 ) ;
}
break ;
}
case ServerOP_GroupFollowAck : {
// The Inviter (in another zone) has successfully added the Invitee (in this zone) to the group.
ServerGroupFollowAck_Struct * sgfas = ( ServerGroupFollowAck_Struct * ) pack - > pBuffer ;
2013-02-16 16:14:39 -08:00
2017-01-02 22:38:47 -08:00
Client * client = entity_list . GetClientByName ( sgfas - > Name ) ;
2013-02-16 16:14:39 -08:00
2017-04-02 20:03:51 -07:00
if ( ! client )
2017-01-02 22:38:47 -08:00
break ;
2013-02-16 16:14:39 -08:00
2017-01-02 22:38:47 -08:00
uint32 groupid = database . GetGroupID ( client - > GetName ( ) ) ;
2013-02-16 16:14:39 -08:00
2017-01-02 22:38:47 -08:00
Group * group = nullptr ;
2013-02-16 16:14:39 -08:00
2017-04-02 20:03:51 -07:00
if ( groupid > 0 )
2017-01-02 22:38:47 -08:00
{
group = entity_list . GetGroupByID ( groupid ) ;
2017-04-02 20:03:51 -07:00
if ( ! group )
2017-01-02 22:38:47 -08:00
{ //nobody from our group is here... start a new group
group = new Group ( groupid ) ;
2013-02-16 16:14:39 -08:00
2017-04-02 20:03:51 -07:00
if ( group - > GetID ( ) ! = 0 )
2017-01-02 22:38:47 -08:00
entity_list . AddGroup ( group , groupid ) ;
else
group = nullptr ;
2013-02-16 16:14:39 -08:00
}
2017-04-02 20:03:51 -07:00
if ( group )
2017-01-02 22:38:47 -08:00
group - > UpdatePlayer ( client ) ;
else
2013-02-16 16:14:39 -08:00
{
2017-04-02 20:03:51 -07:00
if ( client - > GetMerc ( ) )
2017-01-02 22:38:47 -08:00
database . SetGroupID ( client - > GetMerc ( ) - > GetCleanName ( ) , 0 , client - > CharacterID ( ) , true ) ;
database . SetGroupID ( client - > GetName ( ) , 0 , client - > CharacterID ( ) , false ) ; //cannot re-establish group, kill it
}
2013-02-16 16:14:39 -08:00
2017-01-02 22:38:47 -08:00
}
2013-02-16 16:14:39 -08:00
2017-04-02 20:03:51 -07:00
if ( group )
2017-01-02 22:38:47 -08:00
{
if ( client - > GetMerc ( ) )
2014-11-22 00:22:12 -06:00
{
client - > GetMerc ( ) - > MercJoinClientGroup ( ) ;
}
2017-01-02 22:38:47 -08:00
database . RefreshGroupFromDB ( client ) ;
2017-07-11 17:54:46 -05:00
group - > SendHPManaEndPacketsTo ( client ) ;
2013-02-16 16:14:39 -08:00
2017-01-02 22:38:47 -08:00
// If the group leader is not set, pull the group leader information from the database.
2017-04-02 20:03:51 -07:00
if ( ! group - > GetLeader ( ) )
2017-01-02 22:38:47 -08:00
{
char ln [ 64 ] ;
char MainTankName [ 64 ] ;
char AssistName [ 64 ] ;
char PullerName [ 64 ] ;
char NPCMarkerName [ 64 ] ;
char mentoree_name [ 64 ] ;
int mentor_percent ;
GroupLeadershipAA_Struct GLAA ;
memset ( ln , 0 , 64 ) ;
strcpy ( ln , database . GetGroupLeadershipInfo ( group - > GetID ( ) , ln , MainTankName , AssistName , PullerName , NPCMarkerName , mentoree_name , & mentor_percent , & GLAA ) ) ;
Client * lc = entity_list . GetClientByName ( ln ) ;
2017-04-02 20:03:51 -07:00
if ( lc )
2017-01-02 22:38:47 -08:00
group - > SetLeader ( lc ) ;
group - > SetMainTank ( MainTankName ) ;
group - > SetMainAssist ( AssistName ) ;
group - > SetPuller ( PullerName ) ;
group - > SetNPCMarker ( NPCMarkerName ) ;
group - > SetGroupAAs ( & GLAA ) ;
group - > SetGroupMentor ( mentor_percent , mentoree_name ) ;
2017-02-21 21:20:33 -08:00
client - > JoinGroupXTargets ( group ) ;
2017-01-02 22:38:47 -08:00
}
}
else if ( client - > GetMerc ( ) )
{
client - > GetMerc ( ) - > MercJoinClientGroup ( ) ;
2013-02-16 16:14:39 -08:00
}
2017-01-02 22:38:47 -08:00
break ;
2013-02-16 16:14:39 -08:00
2017-01-02 22:38:47 -08:00
}
case ServerOP_GroupCancelInvite : {
2013-02-16 16:14:39 -08:00
2017-04-02 20:03:51 -07:00
GroupCancel_Struct * sgcs = ( GroupCancel_Struct * ) pack - > pBuffer ;
2013-02-16 16:14:39 -08:00
2017-01-02 22:38:47 -08:00
Mob * Inviter = entity_list . GetClientByName ( sgcs - > name1 ) ;
2017-04-02 20:03:51 -07:00
if ( Inviter & & Inviter - > IsClient ( ) )
2017-01-02 22:38:47 -08:00
{
auto outapp = new EQApplicationPacket ( OP_GroupCancelInvite , sizeof ( GroupCancel_Struct ) ) ;
memcpy ( outapp - > pBuffer , sgcs , sizeof ( GroupCancel_Struct ) ) ;
Inviter - > CastToClient ( ) - > QueuePacket ( outapp ) ;
safe_delete ( outapp ) ;
2013-02-16 16:14:39 -08:00
}
2017-01-02 22:38:47 -08:00
break ;
}
case ServerOP_GroupJoin : {
ServerGroupJoin_Struct * gj = ( ServerGroupJoin_Struct * ) pack - > pBuffer ;
2017-04-02 20:03:51 -07:00
if ( zone ) {
if ( gj - > zoneid = = zone - > GetZoneID ( ) & & gj - > instance_id = = zone - > GetInstanceID ( ) )
2017-01-02 22:38:47 -08:00
break ;
2013-02-16 16:14:39 -08:00
2017-01-02 22:38:47 -08:00
Group * g = entity_list . GetGroupByID ( gj - > gid ) ;
2017-04-02 20:03:51 -07:00
if ( g )
2017-01-02 22:38:47 -08:00
g - > AddMember ( gj - > member_name ) ;
2013-02-16 16:14:39 -08:00
2017-01-02 22:38:47 -08:00
entity_list . SendGroupJoin ( gj - > gid , gj - > member_name ) ;
2013-02-16 16:14:39 -08:00
}
2017-01-02 22:38:47 -08:00
break ;
}
2013-02-16 16:14:39 -08:00
2017-01-02 22:38:47 -08:00
case ServerOP_ForceGroupUpdate : {
ServerForceGroupUpdate_Struct * fgu = ( ServerForceGroupUpdate_Struct * ) pack - > pBuffer ;
2017-04-02 20:03:51 -07:00
if ( zone ) {
if ( fgu - > origZoneID = = zone - > GetZoneID ( ) & & fgu - > instance_id = = zone - > GetInstanceID ( ) )
2017-01-02 22:38:47 -08:00
break ;
2013-02-16 16:14:39 -08:00
2017-01-02 22:38:47 -08:00
entity_list . ForceGroupUpdate ( fgu - > gid ) ;
2013-02-16 16:14:39 -08:00
}
2017-01-02 22:38:47 -08:00
break ;
}
2013-02-16 16:14:39 -08:00
2017-01-02 22:38:47 -08:00
case ServerOP_OOZGroupMessage : {
ServerGroupChannelMessage_Struct * gcm = ( ServerGroupChannelMessage_Struct * ) pack - > pBuffer ;
2017-04-02 20:03:51 -07:00
if ( zone ) {
if ( gcm - > zoneid = = zone - > GetZoneID ( ) & & gcm - > instanceid = = zone - > GetInstanceID ( ) )
2017-01-02 22:38:47 -08:00
break ;
2013-02-16 16:14:39 -08:00
2017-01-02 22:38:47 -08:00
entity_list . GroupMessage ( gcm - > groupid , gcm - > from , gcm - > message ) ;
2013-02-16 16:14:39 -08:00
}
2017-01-02 22:38:47 -08:00
break ;
}
case ServerOP_DisbandGroup : {
ServerDisbandGroup_Struct * sd = ( ServerDisbandGroup_Struct * ) pack - > pBuffer ;
2017-04-02 20:03:51 -07:00
if ( zone ) {
if ( sd - > zoneid = = zone - > GetZoneID ( ) & & sd - > instance_id = = zone - > GetInstanceID ( ) )
2017-01-02 22:38:47 -08:00
break ;
2013-02-16 16:14:39 -08:00
2017-01-02 22:38:47 -08:00
Group * g = entity_list . GetGroupByID ( sd - > groupid ) ;
2017-04-02 20:03:51 -07:00
if ( g )
2017-01-02 22:38:47 -08:00
g - > DisbandGroup ( ) ;
2013-02-16 16:14:39 -08:00
}
2017-01-02 22:38:47 -08:00
break ;
}
2017-04-02 20:03:51 -07:00
case ServerOP_RaidAdd : {
2017-01-02 22:38:47 -08:00
ServerRaidGeneralAction_Struct * rga = ( ServerRaidGeneralAction_Struct * ) pack - > pBuffer ;
2017-04-02 20:03:51 -07:00
if ( zone ) {
if ( rga - > zoneid = = zone - > GetZoneID ( ) & & rga - > instance_id = = zone - > GetInstanceID ( ) )
2017-01-02 22:38:47 -08:00
break ;
2013-05-06 13:07:41 -04:00
2017-01-02 22:38:47 -08:00
Raid * r = entity_list . GetRaidByID ( rga - > rid ) ;
2017-04-02 20:03:51 -07:00
if ( r ) {
2017-01-02 22:38:47 -08:00
r - > LearnMembers ( ) ;
r - > VerifyRaid ( ) ;
r - > SendRaidAddAll ( rga - > playername ) ;
2013-02-16 16:14:39 -08:00
}
}
2017-01-02 22:38:47 -08:00
break ;
}
2013-02-16 16:14:39 -08:00
2017-04-02 20:03:51 -07:00
case ServerOP_RaidRemove : {
2017-01-02 22:38:47 -08:00
ServerRaidGeneralAction_Struct * rga = ( ServerRaidGeneralAction_Struct * ) pack - > pBuffer ;
2017-04-02 20:03:51 -07:00
if ( zone ) {
if ( rga - > zoneid = = zone - > GetZoneID ( ) & & rga - > instance_id = = zone - > GetInstanceID ( ) )
2017-01-02 22:38:47 -08:00
break ;
2013-05-06 13:07:41 -04:00
2017-01-02 22:38:47 -08:00
Raid * r = entity_list . GetRaidByID ( rga - > rid ) ;
2017-04-02 20:03:51 -07:00
if ( r ) {
2017-01-02 22:38:47 -08:00
r - > SendRaidRemoveAll ( rga - > playername ) ;
Client * rem = entity_list . GetClientByName ( rga - > playername ) ;
2017-04-02 20:03:51 -07:00
if ( rem ) {
2017-02-21 21:20:33 -08:00
rem - > LeaveRaidXTargets ( r ) ;
2017-01-02 22:38:47 -08:00
r - > SendRaidDisband ( rem ) ;
2013-02-16 16:14:39 -08:00
}
2017-01-02 22:38:47 -08:00
r - > LearnMembers ( ) ;
r - > VerifyRaid ( ) ;
2013-02-16 16:14:39 -08:00
}
}
2017-01-02 22:38:47 -08:00
break ;
}
2013-02-16 16:14:39 -08:00
2017-04-02 20:03:51 -07:00
case ServerOP_RaidDisband : {
2017-01-02 22:38:47 -08:00
ServerRaidGeneralAction_Struct * rga = ( ServerRaidGeneralAction_Struct * ) pack - > pBuffer ;
2017-04-02 20:03:51 -07:00
if ( zone ) {
if ( rga - > zoneid = = zone - > GetZoneID ( ) & & rga - > instance_id = = zone - > GetInstanceID ( ) )
2017-01-02 22:38:47 -08:00
break ;
2013-05-06 13:07:41 -04:00
2017-01-02 22:38:47 -08:00
Raid * r = entity_list . GetRaidByID ( rga - > rid ) ;
2017-04-02 20:03:51 -07:00
if ( r ) {
2017-01-02 22:38:47 -08:00
r - > SendRaidDisbandAll ( ) ;
r - > LearnMembers ( ) ;
r - > VerifyRaid ( ) ;
2013-02-16 16:14:39 -08:00
}
}
2017-01-02 22:38:47 -08:00
break ;
}
2013-02-16 16:14:39 -08:00
2017-04-02 20:03:51 -07:00
case ServerOP_RaidLockFlag : {
2017-01-02 22:38:47 -08:00
ServerRaidGeneralAction_Struct * rga = ( ServerRaidGeneralAction_Struct * ) pack - > pBuffer ;
2017-04-02 20:03:51 -07:00
if ( zone ) {
if ( rga - > zoneid = = zone - > GetZoneID ( ) & & rga - > instance_id = = zone - > GetInstanceID ( ) )
2017-01-02 22:38:47 -08:00
break ;
2013-05-06 13:07:41 -04:00
2017-01-02 22:38:47 -08:00
Raid * r = entity_list . GetRaidByID ( rga - > rid ) ;
2017-04-02 20:03:51 -07:00
if ( r ) {
2017-01-02 22:38:47 -08:00
r - > GetRaidDetails ( ) ; //update our details
2017-04-02 20:03:51 -07:00
if ( rga - > gid )
2017-01-02 22:38:47 -08:00
r - > SendRaidLock ( ) ;
else
r - > SendRaidUnlock ( ) ;
2013-02-16 16:14:39 -08:00
}
}
2017-01-02 22:38:47 -08:00
break ;
}
2013-02-16 16:14:39 -08:00
2017-04-02 20:03:51 -07:00
case ServerOP_RaidChangeGroup : {
2017-01-02 22:38:47 -08:00
ServerRaidGeneralAction_Struct * rga = ( ServerRaidGeneralAction_Struct * ) pack - > pBuffer ;
2017-04-02 20:03:51 -07:00
if ( zone ) {
if ( rga - > zoneid = = zone - > GetZoneID ( ) & & rga - > instance_id = = zone - > GetInstanceID ( ) )
2017-01-02 22:38:47 -08:00
break ;
2013-05-06 13:07:41 -04:00
2017-01-02 22:38:47 -08:00
Raid * r = entity_list . GetRaidByID ( rga - > rid ) ;
2017-04-02 20:03:51 -07:00
if ( r ) {
2017-01-02 22:38:47 -08:00
r - > LearnMembers ( ) ;
r - > VerifyRaid ( ) ;
Client * c = entity_list . GetClientByName ( rga - > playername ) ;
2017-04-02 20:03:51 -07:00
if ( c ) {
2017-01-02 22:38:47 -08:00
r - > SendRaidDisband ( c ) ;
r - > SendRaidRemoveAll ( rga - > playername ) ;
r - > SendRaidCreate ( c ) ;
r - > SendMakeLeaderPacketTo ( r - > leadername , c ) ;
r - > SendBulkRaid ( c ) ;
r - > SendRaidAddAll ( rga - > playername ) ;
2017-04-02 20:03:51 -07:00
if ( r - > IsLocked ( ) ) { r - > SendRaidLockTo ( c ) ; }
2017-01-02 22:38:47 -08:00
}
2017-04-02 20:03:51 -07:00
else {
2017-01-02 22:38:47 -08:00
r - > SendRaidRemoveAll ( rga - > playername ) ;
r - > SendRaidAddAll ( rga - > playername ) ;
2013-02-16 16:14:39 -08:00
}
}
}
2017-01-02 22:38:47 -08:00
break ;
}
2013-02-16 16:14:39 -08:00
2017-04-02 20:03:51 -07:00
case ServerOP_UpdateGroup : {
2017-01-02 22:38:47 -08:00
ServerRaidGeneralAction_Struct * rga = ( ServerRaidGeneralAction_Struct * ) pack - > pBuffer ;
2017-04-02 20:03:51 -07:00
if ( zone ) {
if ( rga - > zoneid = = zone - > GetZoneID ( ) & & rga - > instance_id = = zone - > GetInstanceID ( ) )
2017-01-02 22:38:47 -08:00
break ;
2013-05-06 13:07:41 -04:00
2017-01-02 22:38:47 -08:00
Raid * r = entity_list . GetRaidByID ( rga - > rid ) ;
2017-04-02 20:03:51 -07:00
if ( r ) {
2017-01-02 22:38:47 -08:00
r - > GroupUpdate ( rga - > gid , false ) ;
2013-02-16 16:14:39 -08:00
}
}
2017-01-02 22:38:47 -08:00
break ;
}
2013-02-16 16:14:39 -08:00
2017-04-02 20:03:51 -07:00
case ServerOP_RaidGroupLeader : {
2017-01-02 22:38:47 -08:00
ServerRaidGeneralAction_Struct * rga = ( ServerRaidGeneralAction_Struct * ) pack - > pBuffer ;
2017-04-02 20:03:51 -07:00
if ( zone ) {
if ( rga - > zoneid = = zone - > GetZoneID ( ) & & rga - > instance_id = = zone - > GetInstanceID ( ) )
2017-01-02 22:38:47 -08:00
break ;
2013-02-16 16:14:39 -08:00
}
2017-01-02 22:38:47 -08:00
break ;
}
2013-02-16 16:14:39 -08:00
2017-04-02 20:03:51 -07:00
case ServerOP_RaidLeader : {
2017-01-02 22:38:47 -08:00
ServerRaidGeneralAction_Struct * rga = ( ServerRaidGeneralAction_Struct * ) pack - > pBuffer ;
2017-04-02 20:03:51 -07:00
if ( zone ) {
if ( rga - > zoneid = = zone - > GetZoneID ( ) & & rga - > instance_id = = zone - > GetInstanceID ( ) )
2017-01-02 22:38:47 -08:00
break ;
2013-05-06 13:07:41 -04:00
2017-01-02 22:38:47 -08:00
Raid * r = entity_list . GetRaidByID ( rga - > rid ) ;
2017-04-02 20:03:51 -07:00
if ( r ) {
2017-01-02 22:38:47 -08:00
Client * c = entity_list . GetClientByName ( rga - > playername ) ;
strn0cpy ( r - > leadername , rga - > playername , 64 ) ;
2017-04-02 20:03:51 -07:00
if ( c ) {
2017-01-02 22:38:47 -08:00
r - > SetLeader ( c ) ;
2013-02-16 16:14:39 -08:00
}
2017-01-02 22:38:47 -08:00
r - > LearnMembers ( ) ;
r - > VerifyRaid ( ) ;
r - > SendMakeLeaderPacket ( rga - > playername ) ;
2013-02-16 16:14:39 -08:00
}
}
2017-01-02 22:38:47 -08:00
break ;
}
2013-02-16 16:14:39 -08:00
2017-04-02 20:03:51 -07:00
case ServerOP_DetailsChange : {
2017-01-02 22:38:47 -08:00
ServerRaidGeneralAction_Struct * rga = ( ServerRaidGeneralAction_Struct * ) pack - > pBuffer ;
2017-04-02 20:03:51 -07:00
if ( zone ) {
if ( rga - > zoneid = = zone - > GetZoneID ( ) & & rga - > instance_id = = zone - > GetInstanceID ( ) )
2017-01-02 22:38:47 -08:00
break ;
2013-05-06 13:07:41 -04:00
2017-01-02 22:38:47 -08:00
Raid * r = entity_list . GetRaidByID ( rga - > rid ) ;
2017-04-02 20:03:51 -07:00
if ( r ) {
2017-01-02 22:38:47 -08:00
r - > GetRaidDetails ( ) ;
r - > LearnMembers ( ) ;
r - > VerifyRaid ( ) ;
2013-02-16 16:14:39 -08:00
}
}
2017-01-02 22:38:47 -08:00
break ;
}
2013-02-16 16:14:39 -08:00
2017-04-02 20:03:51 -07:00
case ServerOP_RaidGroupDisband : {
2017-01-02 22:38:47 -08:00
ServerRaidGeneralAction_Struct * rga = ( ServerRaidGeneralAction_Struct * ) pack - > pBuffer ;
2017-04-02 20:03:51 -07:00
if ( zone ) {
if ( rga - > zoneid = = zone - > GetZoneID ( ) & & rga - > instance_id = = zone - > GetInstanceID ( ) )
2017-01-02 22:38:47 -08:00
break ;
2013-05-06 13:07:41 -04:00
2017-01-02 22:38:47 -08:00
Client * c = entity_list . GetClientByName ( rga - > playername ) ;
2017-04-02 20:03:51 -07:00
if ( c )
2017-01-02 22:38:47 -08:00
{
auto outapp =
2017-04-02 20:03:51 -07:00
new EQApplicationPacket ( OP_GroupUpdate , sizeof ( GroupUpdate_Struct ) ) ;
GroupUpdate_Struct * gu = ( GroupUpdate_Struct * ) outapp - > pBuffer ;
2017-01-02 22:38:47 -08:00
gu - > action = groupActDisband ;
strn0cpy ( gu - > leadersname , c - > GetName ( ) , 64 ) ;
strn0cpy ( gu - > yourname , c - > GetName ( ) , 64 ) ;
c - > FastQueuePacket ( & outapp ) ;
2013-02-16 16:14:39 -08:00
}
}
2017-01-02 22:38:47 -08:00
break ;
}
2013-02-16 16:14:39 -08:00
2017-04-02 20:03:51 -07:00
case ServerOP_RaidGroupAdd : {
2017-01-02 22:38:47 -08:00
ServerRaidGroupAction_Struct * rga = ( ServerRaidGroupAction_Struct * ) pack - > pBuffer ;
2017-04-02 20:03:51 -07:00
if ( zone ) {
2017-01-02 22:38:47 -08:00
Raid * r = entity_list . GetRaidByID ( rga - > rid ) ;
2017-04-02 20:03:51 -07:00
if ( r ) {
2017-01-02 22:38:47 -08:00
r - > LearnMembers ( ) ;
r - > VerifyRaid ( ) ;
auto outapp = new EQApplicationPacket ( OP_GroupUpdate , sizeof ( GroupJoin_Struct ) ) ;
2017-04-02 20:03:51 -07:00
GroupJoin_Struct * gj = ( GroupJoin_Struct * ) outapp - > pBuffer ;
2017-01-02 22:38:47 -08:00
strn0cpy ( gj - > membername , rga - > membername , 64 ) ;
gj - > action = groupActJoin ;
2017-04-02 20:03:51 -07:00
for ( int x = 0 ; x < MAX_RAID_MEMBERS ; x + + )
2017-01-02 22:38:47 -08:00
{
2017-04-02 20:03:51 -07:00
if ( r - > members [ x ] . member )
2013-02-16 16:14:39 -08:00
{
2017-04-02 20:03:51 -07:00
if ( strcmp ( r - > members [ x ] . member - > GetName ( ) , rga - > membername ) ! = 0 ) {
if ( ( rga - > gid < 12 ) & & rga - > gid = = r - > members [ x ] . GroupNumber )
2017-01-02 22:38:47 -08:00
{
strn0cpy ( gj - > yourname , r - > members [ x ] . member - > GetName ( ) , 64 ) ;
r - > members [ x ] . member - > QueuePacket ( outapp ) ;
2013-02-16 16:14:39 -08:00
}
}
}
}
2017-01-02 22:38:47 -08:00
safe_delete ( outapp ) ;
2013-02-16 16:14:39 -08:00
}
}
2017-01-02 22:38:47 -08:00
break ;
}
2013-02-16 16:14:39 -08:00
2017-04-02 20:03:51 -07:00
case ServerOP_RaidGroupRemove : {
2017-01-02 22:38:47 -08:00
ServerRaidGroupAction_Struct * rga = ( ServerRaidGroupAction_Struct * ) pack - > pBuffer ;
2017-04-02 20:03:51 -07:00
if ( zone ) {
2017-01-02 22:38:47 -08:00
Raid * r = entity_list . GetRaidByID ( rga - > rid ) ;
2017-04-02 20:03:51 -07:00
if ( r ) {
2017-01-02 22:38:47 -08:00
r - > LearnMembers ( ) ;
r - > VerifyRaid ( ) ;
auto outapp = new EQApplicationPacket ( OP_GroupUpdate , sizeof ( GroupJoin_Struct ) ) ;
2017-04-02 20:03:51 -07:00
GroupJoin_Struct * gj = ( GroupJoin_Struct * ) outapp - > pBuffer ;
2017-01-02 22:38:47 -08:00
strn0cpy ( gj - > membername , rga - > membername , 64 ) ;
gj - > action = groupActLeave ;
2017-04-02 20:03:51 -07:00
for ( int x = 0 ; x < MAX_RAID_MEMBERS ; x + + )
2017-01-02 22:38:47 -08:00
{
2017-04-02 20:03:51 -07:00
if ( r - > members [ x ] . member )
2013-02-16 16:14:39 -08:00
{
2017-04-02 20:03:51 -07:00
if ( strcmp ( r - > members [ x ] . member - > GetName ( ) , rga - > membername ) ! = 0 ) {
if ( ( rga - > gid < 12 ) & & rga - > gid = = r - > members [ x ] . GroupNumber )
2017-01-02 22:38:47 -08:00
{
strn0cpy ( gj - > yourname , r - > members [ x ] . member - > GetName ( ) , 64 ) ;
r - > members [ x ] . member - > QueuePacket ( outapp ) ;
2013-02-16 16:14:39 -08:00
}
}
}
}
2017-01-02 22:38:47 -08:00
safe_delete ( outapp ) ;
2013-02-16 16:14:39 -08:00
}
}
2017-01-02 22:38:47 -08:00
break ;
}
2013-02-16 16:14:39 -08:00
2017-04-02 20:03:51 -07:00
case ServerOP_RaidGroupSay : {
2017-01-02 22:38:47 -08:00
ServerRaidMessage_Struct * rmsg = ( ServerRaidMessage_Struct * ) pack - > pBuffer ;
2017-04-02 20:03:51 -07:00
if ( zone ) {
2017-01-02 22:38:47 -08:00
Raid * r = entity_list . GetRaidByID ( rmsg - > rid ) ;
2017-04-02 20:03:51 -07:00
if ( r )
2017-01-02 22:38:47 -08:00
{
2017-04-02 20:03:51 -07:00
for ( int x = 0 ; x < MAX_RAID_MEMBERS ; x + + )
2013-02-16 16:14:39 -08:00
{
2017-04-02 20:03:51 -07:00
if ( r - > members [ x ] . member ) {
if ( strcmp ( rmsg - > from , r - > members [ x ] . member - > GetName ( ) ) ! = 0 )
2017-01-02 22:38:47 -08:00
{
2017-04-02 20:03:51 -07:00
if ( r - > members [ x ] . GroupNumber = = rmsg - > gid ) {
if ( r - > members [ x ] . member - > GetFilter ( FilterGroupChat ) ! = 0 )
2017-01-02 22:38:47 -08:00
{
2019-07-14 20:03:30 -07:00
r - > members [ x ] . member - > ChannelMessageSend ( rmsg - > from , r - > members [ x ] . member - > GetName ( ) , ChatChannel_Group , rmsg - > language , rmsg - > lang_skill , rmsg - > message ) ;
2013-02-16 16:14:39 -08:00
}
}
}
}
}
}
}
2017-01-02 22:38:47 -08:00
break ;
}
2013-02-16 16:14:39 -08:00
2017-04-02 20:03:51 -07:00
case ServerOP_RaidSay : {
2017-01-02 22:38:47 -08:00
ServerRaidMessage_Struct * rmsg = ( ServerRaidMessage_Struct * ) pack - > pBuffer ;
2017-04-02 20:03:51 -07:00
if ( zone )
2017-01-02 22:38:47 -08:00
{
Raid * r = entity_list . GetRaidByID ( rmsg - > rid ) ;
2017-04-02 20:03:51 -07:00
if ( r )
2013-02-16 16:14:39 -08:00
{
2017-04-02 20:03:51 -07:00
for ( int x = 0 ; x < MAX_RAID_MEMBERS ; x + + )
2013-02-16 16:14:39 -08:00
{
2017-04-02 20:03:51 -07:00
if ( r - > members [ x ] . member ) {
if ( strcmp ( rmsg - > from , r - > members [ x ] . member - > GetName ( ) ) ! = 0 )
2017-01-02 22:38:47 -08:00
{
2017-04-02 20:03:51 -07:00
if ( r - > members [ x ] . member - > GetFilter ( FilterGroupChat ) ! = 0 )
2013-02-16 16:14:39 -08:00
{
2019-07-14 20:03:30 -07:00
r - > members [ x ] . member - > ChannelMessageSend ( rmsg - > from , r - > members [ x ] . member - > GetName ( ) , ChatChannel_Raid , rmsg - > language , rmsg - > lang_skill , rmsg - > message ) ;
2013-02-16 16:14:39 -08:00
}
}
}
}
}
}
2017-01-02 22:38:47 -08:00
break ;
}
2013-02-16 16:14:39 -08:00
2017-01-02 22:38:47 -08:00
case ServerOP_RaidMOTD : {
ServerRaidMOTD_Struct * rmotd = ( ServerRaidMOTD_Struct * ) pack - > pBuffer ;
if ( ! zone )
2014-10-11 01:14:11 -04:00
break ;
2017-01-02 22:38:47 -08:00
Raid * r = entity_list . GetRaidByID ( rmotd - > rid ) ;
if ( ! r )
2013-02-16 16:14:39 -08:00
break ;
2017-01-02 22:38:47 -08:00
r - > SetRaidMOTD ( std : : string ( rmotd - > motd ) ) ;
r - > SendRaidMOTD ( ) ;
break ;
}
2013-02-16 16:14:39 -08:00
2017-01-02 22:38:47 -08:00
case ServerOP_SpawnPlayerCorpse : {
SpawnPlayerCorpse_Struct * s = ( SpawnPlayerCorpse_Struct * ) pack - > pBuffer ;
Corpse * NewCorpse = database . LoadCharacterCorpse ( s - > player_corpse_id ) ;
2017-04-02 20:03:51 -07:00
if ( NewCorpse )
2017-01-02 22:38:47 -08:00
NewCorpse - > Spawn ( ) ;
else
2019-09-01 22:05:44 -05:00
LogError ( " Unable to load player corpse id [{}] for zone [{}] " , s - > player_corpse_id , zone - > GetShortName ( ) ) ;
2017-01-02 22:38:47 -08:00
break ;
}
case ServerOP_Consent : {
ServerOP_Consent_Struct * s = ( ServerOP_Consent_Struct * ) pack - > pBuffer ;
2020-01-26 20:53:59 -05:00
bool found_corpse = false ;
for ( auto const & it : entity_list . GetCorpseList ( ) ) {
if ( it . second - > IsPlayerCorpse ( ) & & strcmp ( it . second - > GetOwnerName ( ) , s - > ownername ) = = 0 ) {
2020-05-17 18:36:06 -07:00
if ( s - > consent_type = = EQ : : consent : : Normal ) {
2020-01-26 20:53:59 -05:00
if ( s - > permission = = 1 ) {
it . second - > AddConsentName ( s - > grantname ) ;
}
else {
it . second - > RemoveConsentName ( s - > grantname ) ;
}
}
2020-05-17 18:36:06 -07:00
else if ( s - > consent_type = = EQ : : consent : : Group ) {
2020-01-26 20:53:59 -05:00
it . second - > SetConsentGroupID ( s - > consent_id ) ;
}
2020-05-17 18:36:06 -07:00
else if ( s - > consent_type = = EQ : : consent : : Raid ) {
2020-01-26 20:53:59 -05:00
it . second - > SetConsentRaidID ( s - > consent_id ) ;
}
2020-05-17 18:36:06 -07:00
else if ( s - > consent_type = = EQ : : consent : : Guild ) {
2020-01-26 20:53:59 -05:00
it . second - > SetConsentGuildID ( s - > consent_id ) ;
}
found_corpse = true ;
}
2013-02-16 16:14:39 -08:00
}
2020-01-26 20:53:59 -05:00
2020-01-29 18:34:33 -05:00
if ( found_corpse ) {
2020-01-26 20:53:59 -05:00
// forward the grant/deny message for this zone to both owner and granted
auto outapp = new ServerPacket ( ServerOP_Consent_Response , sizeof ( ServerOP_Consent_Struct ) ) ;
ServerOP_Consent_Struct * scs = ( ServerOP_Consent_Struct * ) outapp - > pBuffer ;
memcpy ( outapp - > pBuffer , s , sizeof ( ServerOP_Consent_Struct ) ) ;
if ( zone ) {
strn0cpy ( scs - > zonename , zone - > GetLongName ( ) , sizeof ( scs - > zonename ) ) ;
}
worldserver . SendPacket ( outapp ) ;
safe_delete ( outapp ) ;
2017-01-02 22:38:47 -08:00
}
break ;
}
case ServerOP_Consent_Response : {
ServerOP_Consent_Struct * s = ( ServerOP_Consent_Struct * ) pack - > pBuffer ;
2020-02-02 14:12:13 -05:00
Client * owner_client = entity_list . GetClientByName ( s - > ownername ) ;
Client * grant_client = nullptr ;
2020-05-17 18:36:06 -07:00
if ( s - > consent_type = = EQ : : consent : : Normal ) {
2020-02-02 14:12:13 -05:00
grant_client = entity_list . GetClientByName ( s - > grantname ) ;
}
if ( owner_client | | grant_client ) {
auto outapp = new EQApplicationPacket ( OP_ConsentResponse , sizeof ( ConsentResponse_Struct ) ) ;
ConsentResponse_Struct * crs = ( ConsentResponse_Struct * ) outapp - > pBuffer ;
strn0cpy ( crs - > grantname , s - > grantname , sizeof ( crs - > grantname ) ) ;
strn0cpy ( crs - > ownername , s - > ownername , sizeof ( crs - > ownername ) ) ;
crs - > permission = s - > permission ;
strn0cpy ( crs - > zonename , s - > zonename , sizeof ( crs - > zonename ) ) ;
if ( owner_client ) {
owner_client - > QueuePacket ( outapp ) ; // confirmation message to the owner
}
2020-01-29 18:34:33 -05:00
if ( grant_client ) {
2020-02-02 14:12:13 -05:00
grant_client - > QueuePacket ( outapp ) ; // message to the client being granted/denied
2020-01-26 20:53:59 -05:00
}
2020-02-02 14:12:13 -05:00
safe_delete ( outapp ) ;
2013-02-16 16:14:39 -08:00
}
2017-01-02 22:38:47 -08:00
break ;
}
case ServerOP_ReloadTasks : {
2017-04-02 20:03:51 -07:00
if ( RuleB ( Tasks , EnableTaskSystem ) ) {
2017-01-02 22:38:47 -08:00
HandleReloadTasks ( pack ) ;
2013-02-16 16:14:39 -08:00
}
2017-01-02 22:38:47 -08:00
break ;
}
case ServerOP_LFGMatches : {
HandleLFGMatches ( pack ) ;
break ;
}
case ServerOP_LFPMatches : {
HandleLFPMatches ( pack ) ;
break ;
}
2013-02-16 16:14:39 -08:00
2017-01-02 22:38:47 -08:00
case ServerOP_UpdateSpawn : {
2017-04-02 20:03:51 -07:00
if ( zone )
2017-01-02 22:38:47 -08:00
{
UpdateSpawnTimer_Struct * ust = ( UpdateSpawnTimer_Struct * ) pack - > pBuffer ;
LinkedListIterator < Spawn2 * > iterator ( zone - > spawn2_list ) ;
iterator . Reset ( ) ;
while ( iterator . MoreElements ( ) )
2013-02-16 16:14:39 -08:00
{
2017-04-02 20:03:51 -07:00
if ( iterator . GetData ( ) - > GetID ( ) = = ust - > id )
2013-02-16 16:14:39 -08:00
{
2017-04-02 20:03:51 -07:00
if ( ! iterator . GetData ( ) - > NPCPointerValid ( ) )
2013-02-16 16:14:39 -08:00
{
2017-01-02 22:38:47 -08:00
iterator . GetData ( ) - > SetTimer ( ust - > duration ) ;
2013-02-16 16:14:39 -08:00
}
2017-01-02 22:38:47 -08:00
break ;
2013-02-16 16:14:39 -08:00
}
2017-01-02 22:38:47 -08:00
iterator . Advance ( ) ;
2013-02-16 16:14:39 -08:00
}
}
2017-01-02 22:38:47 -08:00
break ;
}
2013-02-16 16:14:39 -08:00
2017-01-02 22:38:47 -08:00
case ServerOP_InstanceUpdateTime :
{
ServerInstanceUpdateTime_Struct * iut = ( ServerInstanceUpdateTime_Struct * ) pack - > pBuffer ;
2017-04-02 20:03:51 -07:00
if ( zone )
2013-02-16 16:14:39 -08:00
{
2017-04-02 20:03:51 -07:00
if ( zone - > GetInstanceID ( ) = = iut - > instance_id )
2013-02-16 16:14:39 -08:00
{
2017-01-02 22:38:47 -08:00
zone - > SetInstanceTimer ( iut - > new_duration ) ;
2013-02-16 16:14:39 -08:00
}
}
2017-01-02 22:38:47 -08:00
break ;
}
2013-02-16 16:14:39 -08:00
2017-01-02 22:38:47 -08:00
case ServerOP_DepopAllPlayersCorpses :
{
ServerDepopAllPlayersCorpses_Struct * sdapcs = ( ServerDepopAllPlayersCorpses_Struct * ) pack - > pBuffer ;
2013-02-16 16:14:39 -08:00
2017-04-02 20:03:51 -07:00
if ( zone & & ! ( ( zone - > GetZoneID ( ) = = sdapcs - > ZoneID ) & & ( zone - > GetInstanceID ( ) = = sdapcs - > InstanceID ) ) )
2017-01-02 22:38:47 -08:00
entity_list . RemoveAllCorpsesByCharID ( sdapcs - > CharacterID ) ;
2013-02-16 16:14:39 -08:00
2017-01-02 22:38:47 -08:00
break ;
2013-02-16 16:14:39 -08:00
2017-01-02 22:38:47 -08:00
}
2013-02-16 16:14:39 -08:00
2017-01-02 22:38:47 -08:00
case ServerOP_DepopPlayerCorpse :
{
ServerDepopPlayerCorpse_Struct * sdpcs = ( ServerDepopPlayerCorpse_Struct * ) pack - > pBuffer ;
2013-02-16 16:14:39 -08:00
2017-04-02 20:03:51 -07:00
if ( zone & & ! ( ( zone - > GetZoneID ( ) = = sdpcs - > ZoneID ) & & ( zone - > GetInstanceID ( ) = = sdpcs - > InstanceID ) ) )
2017-01-02 22:38:47 -08:00
entity_list . RemoveCorpseByDBID ( sdpcs - > DBID ) ;
2013-02-16 16:14:39 -08:00
2017-01-02 22:38:47 -08:00
break ;
2013-02-16 16:14:39 -08:00
2017-01-02 22:38:47 -08:00
}
2013-02-16 16:14:39 -08:00
2017-01-02 22:38:47 -08:00
case ServerOP_ReloadTitles :
{
title_manager . LoadTitles ( ) ;
break ;
}
2013-02-16 16:14:39 -08:00
2017-01-02 22:38:47 -08:00
case ServerOP_SpawnStatusChange :
{
2017-04-02 20:03:51 -07:00
if ( zone )
2013-02-16 16:14:39 -08:00
{
2017-01-02 22:38:47 -08:00
ServerSpawnStatusChange_Struct * ssc = ( ServerSpawnStatusChange_Struct * ) pack - > pBuffer ;
LinkedListIterator < Spawn2 * > iterator ( zone - > spawn2_list ) ;
iterator . Reset ( ) ;
Spawn2 * found_spawn = nullptr ;
2017-04-02 20:03:51 -07:00
while ( iterator . MoreElements ( ) )
2013-02-16 16:14:39 -08:00
{
2017-01-02 22:38:47 -08:00
Spawn2 * cur = iterator . GetData ( ) ;
2017-04-02 20:03:51 -07:00
if ( cur - > GetID ( ) = = ssc - > id )
2013-02-16 16:14:39 -08:00
{
2017-01-02 22:38:47 -08:00
found_spawn = cur ;
break ;
2013-02-16 16:14:39 -08:00
}
2017-01-02 22:38:47 -08:00
iterator . Advance ( ) ;
}
2013-02-16 16:14:39 -08:00
2017-04-02 20:03:51 -07:00
if ( found_spawn )
2017-01-02 22:38:47 -08:00
{
2017-04-02 20:03:51 -07:00
if ( ssc - > new_status = = 0 )
2013-02-16 16:14:39 -08:00
{
2017-01-02 22:38:47 -08:00
found_spawn - > Disable ( ) ;
}
else
{
found_spawn - > Enable ( ) ;
2013-02-16 16:14:39 -08:00
}
}
}
2017-01-02 22:38:47 -08:00
break ;
}
2013-02-16 16:14:39 -08:00
2017-01-02 22:38:47 -08:00
case ServerOP_QGlobalUpdate :
{
2017-04-02 20:03:51 -07:00
if ( pack - > size ! = sizeof ( ServerQGlobalUpdate_Struct ) )
2013-02-16 16:14:39 -08:00
{
break ;
}
2017-04-02 20:03:51 -07:00
if ( zone )
2013-02-16 16:14:39 -08:00
{
2017-01-02 22:38:47 -08:00
ServerQGlobalUpdate_Struct * qgu = ( ServerQGlobalUpdate_Struct * ) pack - > pBuffer ;
2017-04-02 20:03:51 -07:00
if ( qgu - > from_zone_id ! = zone - > GetZoneID ( ) | | qgu - > from_instance_id ! = zone - > GetInstanceID ( ) )
2013-02-16 16:14:39 -08:00
{
2017-01-02 22:38:47 -08:00
QGlobal temp ;
temp . npc_id = qgu - > npc_id ;
temp . char_id = qgu - > char_id ;
temp . zone_id = qgu - > zone_id ;
temp . expdate = qgu - > expdate ;
temp . name . assign ( qgu - > name ) ;
temp . value . assign ( qgu - > value ) ;
entity_list . UpdateQGlobal ( qgu - > id , temp ) ;
zone - > UpdateQGlobal ( qgu - > id , temp ) ;
}
}
break ;
}
2013-05-06 13:07:41 -04:00
2017-01-02 22:38:47 -08:00
case ServerOP_QGlobalDelete :
{
2017-04-02 20:03:51 -07:00
if ( pack - > size ! = sizeof ( ServerQGlobalDelete_Struct ) )
2017-01-02 22:38:47 -08:00
{
2013-02-16 16:14:39 -08:00
break ;
}
2017-04-02 20:03:51 -07:00
if ( zone )
2013-02-16 16:14:39 -08:00
{
2017-01-02 22:38:47 -08:00
ServerQGlobalDelete_Struct * qgd = ( ServerQGlobalDelete_Struct * ) pack - > pBuffer ;
2017-04-02 20:03:51 -07:00
if ( qgd - > from_zone_id ! = zone - > GetZoneID ( ) | | qgd - > from_instance_id ! = zone - > GetInstanceID ( ) )
2013-02-16 16:14:39 -08:00
{
2017-01-02 22:38:47 -08:00
entity_list . DeleteQGlobal ( std : : string ( ( char * ) qgd - > name ) , qgd - > npc_id , qgd - > char_id , qgd - > zone_id ) ;
zone - > DeleteQGlobal ( std : : string ( ( char * ) qgd - > name ) , qgd - > npc_id , qgd - > char_id , qgd - > zone_id ) ;
2013-02-16 16:14:39 -08:00
}
}
2017-01-02 22:38:47 -08:00
break ;
}
2013-02-16 16:14:39 -08:00
2017-01-02 22:38:47 -08:00
case ServerOP_AdventureRequestAccept :
{
ServerAdventureRequestAccept_Struct * ars = ( ServerAdventureRequestAccept_Struct * ) pack - > pBuffer ;
Client * c = entity_list . GetClientByName ( ars - > leader ) ;
2017-04-02 20:03:51 -07:00
if ( c )
2013-02-16 16:14:39 -08:00
{
2017-01-02 22:38:47 -08:00
c - > NewAdventure ( ars - > id , ars - > theme , ars - > text , ars - > member_count , ( const char * ) ( pack - > pBuffer + sizeof ( ServerAdventureRequestAccept_Struct ) ) ) ;
c - > ClearPendingAdventureRequest ( ) ;
2013-02-16 16:14:39 -08:00
}
2017-01-02 22:38:47 -08:00
break ;
}
2013-02-16 16:14:39 -08:00
2017-01-02 22:38:47 -08:00
case ServerOP_AdventureRequestDeny :
{
ServerAdventureRequestDeny_Struct * ars = ( ServerAdventureRequestDeny_Struct * ) pack - > pBuffer ;
Client * c = entity_list . GetClientByName ( ars - > leader ) ;
2017-04-02 20:03:51 -07:00
if ( c )
2013-02-16 16:14:39 -08:00
{
2017-01-02 22:38:47 -08:00
c - > SendAdventureError ( ars - > reason ) ;
c - > ClearPendingAdventureRequest ( ) ;
2013-02-16 16:14:39 -08:00
}
2017-01-02 22:38:47 -08:00
break ;
}
2013-02-16 16:14:39 -08:00
2017-01-02 22:38:47 -08:00
case ServerOP_AdventureCreateDeny :
{
Client * c = entity_list . GetClientByName ( ( const char * ) pack - > pBuffer ) ;
2017-04-02 20:03:51 -07:00
if ( c )
2013-02-16 16:14:39 -08:00
{
2017-01-02 22:38:47 -08:00
c - > ClearPendingAdventureData ( ) ;
c - > ClearPendingAdventureCreate ( ) ;
2013-02-16 16:14:39 -08:00
}
2017-01-02 22:38:47 -08:00
break ;
}
2013-02-16 16:14:39 -08:00
2017-01-02 22:38:47 -08:00
case ServerOP_AdventureData :
{
Client * c = entity_list . GetClientByName ( ( const char * ) pack - > pBuffer ) ;
2017-04-02 20:03:51 -07:00
if ( c )
2013-02-16 16:14:39 -08:00
{
2017-01-02 22:38:47 -08:00
c - > ClearAdventureData ( ) ;
auto adv_data = new char [ pack - > size ] ;
memcpy ( adv_data , pack - > pBuffer , pack - > size ) ;
c - > SetAdventureData ( adv_data ) ;
c - > ClearPendingAdventureData ( ) ;
c - > ClearPendingAdventureCreate ( ) ;
c - > SendAdventureDetails ( ) ;
}
break ;
}
2013-02-16 16:14:39 -08:00
2017-01-02 22:38:47 -08:00
case ServerOP_AdventureDataClear :
{
Client * c = entity_list . GetClientByName ( ( const char * ) pack - > pBuffer ) ;
2017-04-02 20:03:51 -07:00
if ( c )
2013-02-16 16:14:39 -08:00
{
2017-04-02 20:03:51 -07:00
if ( c - > HasAdventureData ( ) )
2013-02-16 16:14:39 -08:00
{
2017-01-02 22:38:47 -08:00
c - > ClearAdventureData ( ) ;
c - > SendAdventureError ( " You are not currently assigned to an adventure. " ) ;
2013-02-16 16:14:39 -08:00
}
}
2017-01-02 22:38:47 -08:00
break ;
}
2013-02-16 16:14:39 -08:00
2017-01-02 22:38:47 -08:00
case ServerOP_AdventureClickDoorReply :
{
ServerPlayerClickedAdventureDoorReply_Struct * adr = ( ServerPlayerClickedAdventureDoorReply_Struct * ) pack - > pBuffer ;
Client * c = entity_list . GetClientByName ( adr - > player ) ;
2017-04-02 20:03:51 -07:00
if ( c )
2013-02-16 16:14:39 -08:00
{
2017-01-02 22:38:47 -08:00
c - > ClearPendingAdventureDoorClick ( ) ;
c - > MovePC ( adr - > zone_id , adr - > instance_id , adr - > x , adr - > y , adr - > z , adr - > h , 0 ) ;
2013-02-16 16:14:39 -08:00
}
2017-01-02 22:38:47 -08:00
break ;
}
2013-05-06 13:07:41 -04:00
2017-01-02 22:38:47 -08:00
case ServerOP_AdventureClickDoorError :
{
Client * c = entity_list . GetClientByName ( ( const char * ) pack - > pBuffer ) ;
2017-04-02 20:03:51 -07:00
if ( c )
2013-02-16 16:14:39 -08:00
{
2017-01-02 22:38:47 -08:00
c - > ClearPendingAdventureDoorClick ( ) ;
2019-08-11 00:14:02 -05:00
c - > MessageString ( Chat : : Red , 5141 ) ;
2013-02-16 16:14:39 -08:00
}
2017-01-02 22:38:47 -08:00
break ;
}
2013-02-16 16:14:39 -08:00
2017-01-02 22:38:47 -08:00
case ServerOP_AdventureLeaveReply :
{
Client * c = entity_list . GetClientByName ( ( const char * ) pack - > pBuffer ) ;
2017-04-02 20:03:51 -07:00
if ( c )
2013-02-16 16:14:39 -08:00
{
2017-01-02 22:38:47 -08:00
c - > ClearPendingAdventureLeave ( ) ;
c - > ClearCurrentAdventure ( ) ;
2013-02-16 16:14:39 -08:00
}
2017-01-02 22:38:47 -08:00
break ;
}
2013-02-16 16:14:39 -08:00
2017-01-02 22:38:47 -08:00
case ServerOP_AdventureLeaveDeny :
{
Client * c = entity_list . GetClientByName ( ( const char * ) pack - > pBuffer ) ;
2017-04-02 20:03:51 -07:00
if ( c )
2013-02-16 16:14:39 -08:00
{
2017-01-02 22:38:47 -08:00
c - > ClearPendingAdventureLeave ( ) ;
2019-08-11 00:00:55 -05:00
c - > Message ( Chat : : Red , " You cannot leave this adventure at this time. " ) ;
2013-02-16 16:14:39 -08:00
}
2017-01-02 22:38:47 -08:00
break ;
}
2013-02-16 16:14:39 -08:00
2017-01-02 22:38:47 -08:00
case ServerOP_AdventureCountUpdate :
{
ServerAdventureCountUpdate_Struct * ac = ( ServerAdventureCountUpdate_Struct * ) pack - > pBuffer ;
Client * c = entity_list . GetClientByName ( ac - > player ) ;
2017-04-02 20:03:51 -07:00
if ( c )
2013-02-16 16:14:39 -08:00
{
2017-01-02 22:38:47 -08:00
c - > SendAdventureCount ( ac - > count , ac - > total ) ;
2013-02-16 16:14:39 -08:00
}
2017-01-02 22:38:47 -08:00
break ;
}
2013-02-16 16:14:39 -08:00
2017-01-02 22:38:47 -08:00
case ServerOP_AdventureZoneData :
{
2017-04-02 20:03:51 -07:00
if ( zone )
2013-02-16 16:14:39 -08:00
{
2017-01-02 22:38:47 -08:00
safe_delete ( zone - > adv_data ) ;
zone - > adv_data = new char [ pack - > size ] ;
memcpy ( zone - > adv_data , pack - > pBuffer , pack - > size ) ;
ServerZoneAdventureDataReply_Struct * ds = ( ServerZoneAdventureDataReply_Struct * ) zone - > adv_data ;
2013-02-16 16:14:39 -08:00
}
2017-01-02 22:38:47 -08:00
break ;
}
2013-02-16 16:14:39 -08:00
2017-01-02 22:38:47 -08:00
case ServerOP_AdventureFinish :
{
ServerAdventureFinish_Struct * af = ( ServerAdventureFinish_Struct * ) pack - > pBuffer ;
Client * c = entity_list . GetClientByName ( af - > player ) ;
2017-04-02 20:03:51 -07:00
if ( c )
2013-02-16 16:14:39 -08:00
{
2017-01-02 22:38:47 -08:00
c - > AdventureFinish ( af - > win , af - > theme , af - > points ) ;
2013-02-16 16:14:39 -08:00
}
2017-01-02 22:38:47 -08:00
break ;
}
case ServerOP_AdventureLeaderboard :
{
Client * c = entity_list . GetClientByName ( ( const char * ) pack - > pBuffer ) ;
2017-04-02 20:03:51 -07:00
if ( c )
2013-02-16 16:14:39 -08:00
{
2017-01-02 22:38:47 -08:00
auto outapp = new EQApplicationPacket ( OP_AdventureLeaderboardReply ,
2017-04-02 20:03:51 -07:00
sizeof ( AdventureLeaderboard_Struct ) ) ;
memcpy ( outapp - > pBuffer , pack - > pBuffer + 64 , sizeof ( AdventureLeaderboard_Struct ) ) ;
2017-01-02 22:38:47 -08:00
c - > FastQueuePacket ( & outapp ) ;
2013-02-16 16:14:39 -08:00
}
2017-01-02 22:38:47 -08:00
break ;
}
2018-05-27 23:44:09 -05:00
case ServerOP_ReloadRules : {
worldserver . SendEmoteMessage (
2019-07-01 15:37:12 -05:00
0 , 0 , 100 , 15 ,
" Rules reloaded for Zone: '%s' Instance ID: %u " ,
2019-12-01 17:59:38 -05:00
( zone ? zone - > GetLongName ( ) : StringFormat ( " Null zone pointer [pid]:[%i] " , getpid ( ) ) . c_str ( ) ) ,
( zone ? zone - > GetInstanceID ( ) : 0xFFFFFFFFF )
2018-05-27 23:44:09 -05:00
) ;
2019-01-11 05:01:44 -05:00
RuleManager : : Instance ( ) - > LoadRules ( & database , RuleManager : : Instance ( ) - > GetActiveRuleset ( ) , true ) ;
2017-01-02 22:38:47 -08:00
break ;
}
case ServerOP_ReloadLogs : {
2017-04-02 20:03:51 -07:00
database . LoadLogSettings ( LogSys . log_settings ) ;
2017-01-02 22:38:47 -08:00
break ;
}
case ServerOP_ReloadPerlExportSettings : {
parse - > LoadPerlEventExportSettings ( parse - > perl_event_export_settings ) ;
break ;
}
case ServerOP_CameraShake :
{
2017-04-02 20:03:51 -07:00
if ( zone )
2013-02-16 16:14:39 -08:00
{
2017-04-02 20:03:51 -07:00
ServerCameraShake_Struct * scss = ( ServerCameraShake_Struct * ) pack - > pBuffer ;
entity_list . CameraEffect ( scss - > duration , scss - > intensity ) ;
2013-02-16 16:14:39 -08:00
}
2017-01-02 22:38:47 -08:00
break ;
}
case ServerOP_QueryServGeneric :
{
pack - > SetReadPosition ( 8 ) ;
char From [ 64 ] ;
pack - > ReadString ( From ) ;
2013-02-16 16:14:39 -08:00
2017-01-02 22:38:47 -08:00
Client * c = entity_list . GetClientByName ( From ) ;
2013-02-16 16:14:39 -08:00
2017-04-02 20:03:51 -07:00
if ( ! c )
2017-01-02 22:38:47 -08:00
return ;
2013-02-16 16:14:39 -08:00
2017-01-02 22:38:47 -08:00
uint32 Type = pack - > ReadUInt32 ( ) ; ;
2013-02-16 16:14:39 -08:00
2017-04-02 20:03:51 -07:00
switch ( Type )
2017-01-02 22:38:47 -08:00
{
2017-04-02 20:03:51 -07:00
case QSG_LFGuild :
2013-02-16 16:14:39 -08:00
{
2017-04-02 20:03:51 -07:00
c - > HandleLFGuildResponse ( pack ) ;
2013-02-16 16:14:39 -08:00
break ;
}
2013-05-06 13:07:41 -04:00
2017-04-02 20:03:51 -07:00
default :
2013-02-16 16:14:39 -08:00
break ;
}
2017-01-02 22:38:47 -08:00
break ;
}
2018-03-04 21:38:17 -05:00
case ServerOP_UCSServerStatusReply :
2018-02-26 20:02:27 -05:00
{
2020-04-14 23:28:43 -05:00
auto ucsss = ( UCSServerStatus_Struct * ) pack - > pBuffer ;
if ( zone ) {
2018-03-09 23:41:27 -05:00
zone - > SetUCSServerAvailable ( ( ucsss - > available ! = 0 ) , ucsss - > timestamp ) ;
2020-04-14 23:28:43 -05:00
LogInfo ( " UCS Server is now [{}] " , ( ucsss - > available = = 1 ? " online " : " offline " ) ) ;
}
2018-02-25 21:40:45 -05:00
break ;
}
2017-01-02 22:38:47 -08:00
case ServerOP_CZSetEntityVariableByNPCTypeID :
{
CZSetEntVarByNPCTypeID_Struct * CZM = ( CZSetEntVarByNPCTypeID_Struct * ) pack - > pBuffer ;
NPC * n = entity_list . GetNPCByNPCTypeID ( CZM - > npctype_id ) ;
if ( n ! = 0 ) {
n - > SetEntityVariable ( CZM - > id , CZM - > m_var ) ;
}
break ;
}
case ServerOP_CZSignalNPC :
{
CZNPCSignal_Struct * CZCN = ( CZNPCSignal_Struct * ) pack - > pBuffer ;
2017-04-02 20:03:51 -07:00
NPC * n = entity_list . GetNPCByNPCTypeID ( CZCN - > npctype_id ) ;
2017-01-02 22:38:47 -08:00
if ( n ! = 0 ) {
n - > SignalNPC ( CZCN - > data ) ;
}
break ;
}
case ServerOP_CZSignalClient :
{
2017-04-02 20:03:51 -07:00
CZClientSignal_Struct * CZCS = ( CZClientSignal_Struct * ) pack - > pBuffer ;
2017-01-02 22:38:47 -08:00
Client * client = entity_list . GetClientByCharID ( CZCS - > charid ) ;
if ( client ! = 0 ) {
client - > Signal ( CZCS - > data ) ;
}
break ;
}
2020-05-09 21:15:34 -04:00
case ServerOP_CZSignalGroup :
{
CZGroupSignal_Struct * CZGS = ( CZGroupSignal_Struct * ) pack - > pBuffer ;
auto client_list = entity_list . GetClientList ( ) ;
for ( auto client : client_list ) {
if ( client . second - > GetGroup ( ) & & client . second - > GetGroup ( ) - > GetID ( ) = = CZGS - > group_id ) {
client . second - > Signal ( CZGS - > data ) ;
}
}
break ;
}
2020-05-11 20:10:52 -04:00
case ServerOP_CZSignalRaid :
{
CZRaidSignal_Struct * CZRS = ( CZRaidSignal_Struct * ) pack - > pBuffer ;
auto client_list = entity_list . GetClientList ( ) ;
for ( auto client : client_list ) {
if ( client . second - > GetRaid ( ) & & client . second - > GetRaid ( ) - > GetID ( ) = = CZRS - > raid_id ) {
client . second - > Signal ( CZRS - > data ) ;
}
}
break ;
}
case ServerOP_CZSignalGuild :
{
CZGuildSignal_Struct * CZGS = ( CZGuildSignal_Struct * ) pack - > pBuffer ;
auto client_list = entity_list . GetClientList ( ) ;
for ( auto client : client_list ) {
if ( client . second - > GuildID ( ) > 0 & & client . second - > GuildID ( ) = = CZGS - > guild_id ) {
client . second - > Signal ( CZGS - > data ) ;
}
}
break ;
}
2017-01-02 22:38:47 -08:00
case ServerOP_CZSignalClientByName :
{
2017-04-02 20:03:51 -07:00
CZClientSignalByName_Struct * CZCS = ( CZClientSignalByName_Struct * ) pack - > pBuffer ;
2017-01-02 22:38:47 -08:00
Client * client = entity_list . GetClientByName ( CZCS - > Name ) ;
if ( client ! = 0 ) {
client - > Signal ( CZCS - > data ) ;
}
break ;
}
case ServerOP_CZMessagePlayer :
{
2017-04-02 20:03:51 -07:00
CZMessagePlayer_Struct * CZCS = ( CZMessagePlayer_Struct * ) pack - > pBuffer ;
2017-01-02 22:38:47 -08:00
Client * client = entity_list . GetClientByName ( CZCS - > CharName ) ;
if ( client ! = 0 ) {
client - > Message ( CZCS - > Type , CZCS - > Message ) ;
}
break ;
2020-05-10 16:52:33 -04:00
}
2020-05-11 20:10:52 -04:00
case ServerOP_CZMessageGroup :
{
CZMessageGroup_Struct * CZGM = ( CZMessageGroup_Struct * ) pack - > pBuffer ;
auto client_list = entity_list . GetClientList ( ) ;
for ( auto client : client_list ) {
if ( client . second - > GetGroup ( ) & & client . second - > GetGroup ( ) - > GetID ( ) = = CZGM - > GroupID ) {
client . second - > Message ( CZGM - > Type , CZGM - > Message ) ;
}
}
break ;
}
case ServerOP_CZMessageRaid :
{
CZMessageRaid_Struct * CZRM = ( CZMessageRaid_Struct * ) pack - > pBuffer ;
auto client_list = entity_list . GetClientList ( ) ;
for ( auto client : client_list ) {
if ( client . second - > GetRaid ( ) & & client . second - > GetRaid ( ) - > GetID ( ) = = CZRM - > RaidID ) {
client . second - > Message ( CZRM - > Type , CZRM - > Message ) ;
}
}
break ;
}
2020-05-10 16:52:33 -04:00
case ServerOP_CZMessageGuild :
{
CZMessageGuild_Struct * CZGM = ( CZMessageGuild_Struct * ) pack - > pBuffer ;
auto client_list = entity_list . GetClientList ( ) ;
for ( auto client : client_list ) {
if ( client . second - > GuildID ( ) > 0 & & client . second - > GuildID ( ) = = CZGM - > GuildID ) {
client . second - > Message ( CZGM - > Type , CZGM - > Message ) ;
}
}
break ;
2017-01-02 22:38:47 -08:00
}
2017-06-12 08:41:37 -07:00
case ServerOP_CZSetEntityVariableByClientName :
{
CZSetEntVarByClientName_Struct * CZCS = ( CZSetEntVarByClientName_Struct * ) pack - > pBuffer ;
Client * client = entity_list . GetClientByName ( CZCS - > CharName ) ;
if ( client ! = 0 ) {
client - > SetEntityVariable ( CZCS - > id , CZCS - > m_var ) ;
}
break ;
}
2020-05-11 20:10:52 -04:00
case ServerOP_CZSetEntityVariableByGroupID :
{
CZSetEntVarByGroupID_Struct * CZCS = ( CZSetEntVarByGroupID_Struct * ) pack - > pBuffer ;
auto client_list = entity_list . GetClientList ( ) ;
for ( auto client : client_list ) {
if ( client . second - > GetGroup ( ) & & client . second - > GetGroup ( ) - > GetID ( ) = = CZCS - > group_id ) {
client . second - > SetEntityVariable ( CZCS - > id , CZCS - > m_var ) ;
}
}
break ;
}
case ServerOP_CZSetEntityVariableByRaidID :
{
CZSetEntVarByRaidID_Struct * CZCS = ( CZSetEntVarByRaidID_Struct * ) pack - > pBuffer ;
auto client_list = entity_list . GetClientList ( ) ;
for ( auto client : client_list ) {
if ( client . second - > GetRaid ( ) & & client . second - > GetRaid ( ) - > GetID ( ) = = CZCS - > raid_id ) {
client . second - > SetEntityVariable ( CZCS - > id , CZCS - > m_var ) ;
}
}
break ;
}
case ServerOP_CZSetEntityVariableByGuildID :
{
CZSetEntVarByGuildID_Struct * CZCS = ( CZSetEntVarByGuildID_Struct * ) pack - > pBuffer ;
auto client_list = entity_list . GetClientList ( ) ;
for ( auto client : client_list ) {
if ( client . second - > GuildID ( ) > 0 & & client . second - > GuildID ( ) = = CZCS - > guild_id ) {
client . second - > SetEntityVariable ( CZCS - > id , CZCS - > m_var ) ;
}
}
break ;
}
2017-01-02 22:38:47 -08:00
case ServerOP_WWMarquee :
{
2017-04-02 20:03:51 -07:00
WWMarquee_Struct * WWMS = ( WWMarquee_Struct * ) pack - > pBuffer ;
2017-01-02 22:38:47 -08:00
std : : list < Client * > client_list ;
entity_list . GetClientList ( client_list ) ;
auto iter = client_list . begin ( ) ;
std : : string Message = WWMS - > Message ;
while ( iter ! = client_list . end ( ) ) {
Client * client = ( * iter ) ;
client - > SendMarqueeMessage ( WWMS - > Type , WWMS - > Priority , WWMS - > FadeIn , WWMS - > FadeOut , WWMS - > Duration , Message ) ;
iter + + ;
2016-09-09 23:59:23 -04:00
}
2017-01-02 22:38:47 -08:00
}
2020-01-31 20:25:06 -06:00
2017-01-02 22:38:47 -08:00
case ServerOP_ReloadWorld :
{
2020-01-31 20:25:06 -06:00
auto * reload_world = ( ReloadWorld_Struct * ) pack - > pBuffer ;
2017-04-02 20:03:51 -07:00
if ( zone ) {
2020-01-31 20:25:06 -06:00
zone - > ReloadWorld ( reload_world - > Option ) ;
}
break ;
}
case ServerOP_HotReloadQuests :
{
if ( ! zone ) {
break ;
2013-02-16 16:14:39 -08:00
}
2020-01-31 20:25:06 -06:00
auto * hot_reload_quests = ( HotReloadQuestsStruct * ) pack - > pBuffer ;
LogHotReloadDetail (
" Receiving request [HotReloadQuests] | request_zone [{}] current_zone [{}] " ,
hot_reload_quests - > zone_short_name ,
zone - > GetShortName ( )
) ;
std : : string request_zone_short_name = hot_reload_quests - > zone_short_name ;
std : : string local_zone_short_name = zone - > GetShortName ( ) ;
if ( request_zone_short_name = = local_zone_short_name | | request_zone_short_name = = " all " ) {
zone - > SetQuestHotReloadQueued ( true ) ;
}
2017-01-02 22:38:47 -08:00
break ;
}
2015-06-23 17:39:06 -07:00
2017-01-02 22:38:47 -08:00
case ServerOP_ChangeSharedMem :
{
std : : string hotfix_name = std : : string ( ( char * ) pack - > pBuffer ) ;
2019-09-01 21:04:58 -05:00
LogInfo ( " Loading items " ) ;
2017-04-02 20:03:51 -07:00
if ( ! database . LoadItems ( hotfix_name ) ) {
2019-09-01 22:05:44 -05:00
LogError ( " Loading items failed! " ) ;
2017-01-02 22:38:47 -08:00
}
2015-06-23 17:39:06 -07:00
2019-09-01 21:04:58 -05:00
LogInfo ( " Loading npc faction lists " ) ;
2017-04-02 20:03:51 -07:00
if ( ! database . LoadNPCFactionLists ( hotfix_name ) ) {
2019-09-01 22:05:44 -05:00
LogError ( " Loading npcs faction lists failed! " ) ;
2017-01-02 22:38:47 -08:00
}
2015-06-23 17:39:06 -07:00
2019-09-01 21:04:58 -05:00
LogInfo ( " Loading loot tables " ) ;
2017-04-02 20:03:51 -07:00
if ( ! database . LoadLoot ( hotfix_name ) ) {
2019-09-01 22:05:44 -05:00
LogError ( " Loading loot failed! " ) ;
2017-01-02 22:38:47 -08:00
}
2015-06-23 17:39:06 -07:00
2019-09-01 21:04:58 -05:00
LogInfo ( " Loading skill caps " ) ;
2017-04-02 20:03:51 -07:00
if ( ! database . LoadSkillCaps ( std : : string ( hotfix_name ) ) ) {
2019-09-01 22:05:44 -05:00
LogError ( " Loading skill caps failed! " ) ;
2015-06-23 17:39:06 -07:00
}
2017-01-02 22:38:47 -08:00
2019-09-01 21:04:58 -05:00
LogInfo ( " Loading spells " ) ;
2017-04-02 20:03:51 -07:00
if ( ! database . LoadSpells ( hotfix_name , & SPDAT_RECORDS , & spells ) ) {
2019-09-01 22:05:44 -05:00
LogError ( " Loading spells failed! " ) ;
2013-02-16 16:14:39 -08:00
}
2017-01-02 22:38:47 -08:00
2019-09-01 21:04:58 -05:00
LogInfo ( " Loading base data " ) ;
2017-04-02 20:03:51 -07:00
if ( ! database . LoadBaseData ( hotfix_name ) ) {
2019-09-01 22:05:44 -05:00
LogError ( " Loading base data failed! " ) ;
2013-02-16 16:14:39 -08:00
}
2017-01-02 22:38:47 -08:00
break ;
}
default : {
std : : cout < < " Unknown ZSopcode: " < < ( int ) pack - > opcode ;
std : : cout < < " size: " < < pack - > size < < std : : endl ;
break ;
}
2013-02-16 16:14:39 -08:00
}
}
2019-07-14 20:03:30 -07:00
bool WorldServer : : SendChannelMessage ( Client * from , const char * to , uint8 chan_num , uint32 guilddbid , uint8 language , uint8 lang_skill , const char * message , . . . ) {
2017-04-02 20:03:51 -07:00
if ( ! worldserver . Connected ( ) )
2013-02-16 16:14:39 -08:00
return false ;
va_list argptr ;
char buffer [ 512 ] ;
2013-05-06 13:07:41 -04:00
2013-02-16 16:14:39 -08:00
va_start ( argptr , message ) ;
vsnprintf ( buffer , 512 , message , argptr ) ;
va_end ( argptr ) ;
buffer [ 511 ] = ' \0 ' ;
2013-05-06 13:07:41 -04:00
2016-05-25 16:10:28 -04:00
auto pack = new ServerPacket ( ServerOP_ChannelMessage , sizeof ( ServerChannelMessage_Struct ) + strlen ( buffer ) + 1 ) ;
2017-04-02 20:03:51 -07:00
ServerChannelMessage_Struct * scm = ( ServerChannelMessage_Struct * ) pack - > pBuffer ;
2013-05-06 13:07:41 -04:00
2013-02-16 16:14:39 -08:00
if ( from = = 0 ) {
strcpy ( scm - > from , " ZServer " ) ;
scm - > fromadmin = 0 ;
2017-04-02 20:03:51 -07:00
}
else {
2013-02-16 16:14:39 -08:00
strcpy ( scm - > from , from - > GetName ( ) ) ;
scm - > fromadmin = from - > Admin ( ) ;
}
if ( to = = 0 ) {
scm - > to [ 0 ] = 0 ;
scm - > deliverto [ 0 ] = ' \0 ' ;
2017-04-02 20:03:51 -07:00
}
else {
2013-02-16 16:14:39 -08:00
strn0cpy ( scm - > to , to , sizeof ( scm - > to ) ) ;
strn0cpy ( scm - > deliverto , to , sizeof ( scm - > deliverto ) ) ;
}
scm - > noreply = false ;
scm - > chan_num = chan_num ;
scm - > guilddbid = guilddbid ;
scm - > language = language ;
2019-07-14 20:03:30 -07:00
scm - > lang_skill = lang_skill ;
2014-09-19 18:17:42 -04:00
scm - > queued = 0 ;
2013-02-16 16:14:39 -08:00
strcpy ( scm - > message , buffer ) ;
2013-05-06 13:07:41 -04:00
2013-02-16 16:14:39 -08:00
bool ret = SendPacket ( pack ) ;
safe_delete ( pack ) ;
return ret ;
}
bool WorldServer : : SendEmoteMessage ( const char * to , uint32 to_guilddbid , uint32 type , const char * message , . . . ) {
va_list argptr ;
2015-07-01 00:19:44 -05:00
char buffer [ 4096 ] = { 0 } ;
2013-05-06 13:07:41 -04:00
2013-02-16 16:14:39 -08:00
va_start ( argptr , message ) ;
2015-07-01 00:19:44 -05:00
vsnprintf ( buffer , sizeof ( buffer ) - 1 , message , argptr ) ;
2013-02-16 16:14:39 -08:00
va_end ( argptr ) ;
2013-05-06 13:07:41 -04:00
2013-02-16 16:14:39 -08:00
return SendEmoteMessage ( to , to_guilddbid , 0 , type , buffer ) ;
}
bool WorldServer : : SendEmoteMessage ( const char * to , uint32 to_guilddbid , int16 to_minstatus , uint32 type , const char * message , . . . ) {
va_list argptr ;
2015-07-01 00:19:44 -05:00
char buffer [ 4096 ] = { 0 } ;
2013-05-06 13:07:41 -04:00
2013-02-16 16:14:39 -08:00
va_start ( argptr , message ) ;
2015-06-30 23:42:21 -05:00
vsnprintf ( buffer , sizeof ( buffer ) - 1 , message , argptr ) ;
2013-02-16 16:14:39 -08:00
va_end ( argptr ) ;
if ( ! Connected ( ) & & to = = 0 ) {
entity_list . MessageStatus ( to_guilddbid , to_minstatus , type , buffer ) ;
return false ;
}
2013-05-06 13:07:41 -04:00
2016-05-25 16:10:28 -04:00
auto pack = new ServerPacket ( ServerOP_EmoteMessage , sizeof ( ServerEmoteMessage_Struct ) + strlen ( buffer ) + 1 ) ;
2017-04-02 20:03:51 -07:00
ServerEmoteMessage_Struct * sem = ( ServerEmoteMessage_Struct * ) pack - > pBuffer ;
2013-02-16 16:14:39 -08:00
sem - > type = type ;
if ( to ! = 0 )
strcpy ( sem - > to , to ) ;
sem - > guilddbid = to_guilddbid ;
sem - > minstatus = to_minstatus ;
strcpy ( sem - > message , buffer ) ;
bool ret = SendPacket ( pack ) ;
safe_delete ( pack ) ;
return ret ;
}
bool WorldServer : : SendVoiceMacro ( Client * From , uint32 Type , char * Target , uint32 MacroNumber , uint32 GroupOrRaidID ) {
2017-04-02 20:03:51 -07:00
if ( ! worldserver . Connected ( ) | | ! From )
2013-02-16 16:14:39 -08:00
return false ;
2013-05-06 13:07:41 -04:00
2016-05-25 16:10:28 -04:00
auto pack = new ServerPacket ( ServerOP_VoiceMacro , sizeof ( ServerVoiceMacro_Struct ) ) ;
2013-02-16 16:14:39 -08:00
2017-04-02 20:03:51 -07:00
ServerVoiceMacro_Struct * svm = ( ServerVoiceMacro_Struct * ) pack - > pBuffer ;
2013-05-06 13:07:41 -04:00
2013-02-16 16:14:39 -08:00
strcpy ( svm - > From , From - > GetName ( ) ) ;
2017-04-02 20:03:51 -07:00
switch ( Type ) {
2013-02-16 16:14:39 -08:00
2017-04-02 20:03:51 -07:00
case VoiceMacroTell :
strcpy ( svm - > To , Target ) ;
break ;
2013-02-16 16:14:39 -08:00
2017-04-02 20:03:51 -07:00
case VoiceMacroGroup :
svm - > GroupID = GroupOrRaidID ;
break ;
2013-02-16 16:14:39 -08:00
2017-04-02 20:03:51 -07:00
case VoiceMacroRaid :
svm - > RaidID = GroupOrRaidID ;
break ;
2013-02-16 16:14:39 -08:00
}
svm - > Type = Type ;
2016-03-24 18:50:31 -04:00
svm - > Voice = ( GetPlayerRaceValue ( From - > GetRace ( ) ) * 2 ) + From - > GetGender ( ) ;
2013-02-16 16:14:39 -08:00
svm - > MacroNumber = MacroNumber ;
bool Ret = SendPacket ( pack ) ;
safe_delete ( pack ) ;
return Ret ;
}
bool WorldServer : : RezzPlayer ( EQApplicationPacket * rpack , uint32 rezzexp , uint32 dbid , uint16 opcode )
{
2019-09-02 03:26:44 -05:00
LogSpells ( " WorldServer::RezzPlayer rezzexp is [{}] (0 is normal for RezzComplete " , rezzexp ) ;
2016-05-25 16:10:28 -04:00
auto pack = new ServerPacket ( ServerOP_RezzPlayer , sizeof ( RezzPlayer_Struct ) ) ;
2017-04-02 20:03:51 -07:00
RezzPlayer_Struct * sem = ( RezzPlayer_Struct * ) pack - > pBuffer ;
2013-02-16 16:14:39 -08:00
sem - > rezzopcode = opcode ;
2017-04-02 20:03:51 -07:00
sem - > rez = * ( Resurrect_Struct * ) rpack - > pBuffer ;
2013-02-16 16:14:39 -08:00
sem - > exp = rezzexp ;
sem - > dbid = dbid ;
bool ret = SendPacket ( pack ) ;
if ( ret )
2019-09-02 03:26:44 -05:00
LogSpells ( " Sending player rezz packet to world spellid:[{}] " , sem - > rez . spellid ) ;
2013-02-16 16:14:39 -08:00
else
2019-09-02 03:26:44 -05:00
LogSpells ( " NOT Sending player rezz packet to world " ) ;
2013-02-16 16:14:39 -08:00
safe_delete ( pack ) ;
return ret ;
}
void WorldServer : : SendReloadTasks ( int Command , int TaskID ) {
2016-05-25 16:10:28 -04:00
auto pack = new ServerPacket ( ServerOP_ReloadTasks , sizeof ( ReloadTasks_Struct ) ) ;
2017-04-02 20:03:51 -07:00
ReloadTasks_Struct * rts = ( ReloadTasks_Struct * ) pack - > pBuffer ;
2013-02-16 16:14:39 -08:00
rts - > Command = Command ;
rts - > Parameter = TaskID ;
SendPacket ( pack ) ;
}
2013-05-06 13:07:41 -04:00
void WorldServer : : HandleReloadTasks ( ServerPacket * pack )
{
2017-04-02 20:03:51 -07:00
ReloadTasks_Struct * rts = ( ReloadTasks_Struct * ) pack - > pBuffer ;
2013-02-16 16:14:39 -08:00
2017-04-01 03:51:46 -05:00
Log ( Logs : : General , Logs : : Tasks , " [GLOBALLOAD] Zone received ServerOP_ReloadTasks from World, Command %i " , rts - > Command ) ;
2013-02-16 16:14:39 -08:00
2017-04-02 20:03:51 -07:00
switch ( rts - > Command ) {
case RELOADTASKS :
entity_list . SaveAllClientsTaskState ( ) ;
2013-02-16 16:14:39 -08:00
2017-04-02 20:03:51 -07:00
if ( rts - > Parameter = = 0 ) {
Log ( Logs : : General , Logs : : Tasks , " [GLOBALLOAD] Reload ALL tasks " ) ;
safe_delete ( taskmanager ) ;
taskmanager = new TaskManager ;
taskmanager - > LoadTasks ( ) ;
if ( zone )
2013-02-16 16:14:39 -08:00
taskmanager - > LoadProximities ( zone - > GetZoneID ( ) ) ;
2017-04-02 20:03:51 -07:00
entity_list . ReloadAllClientsTaskState ( ) ;
}
else {
Log ( Logs : : General , Logs : : Tasks , " [GLOBALLOAD] Reload only task %i " , rts - > Parameter ) ;
taskmanager - > LoadTasks ( rts - > Parameter ) ;
entity_list . ReloadAllClientsTaskState ( rts - > Parameter ) ;
}
2013-02-16 16:14:39 -08:00
2017-04-02 20:03:51 -07:00
break ;
2013-02-16 16:14:39 -08:00
2017-04-02 20:03:51 -07:00
case RELOADTASKPROXIMITIES :
if ( zone ) {
Log ( Logs : : General , Logs : : Tasks , " [GLOBALLOAD] Reload task proximities " ) ;
taskmanager - > LoadProximities ( zone - > GetZoneID ( ) ) ;
}
break ;
2013-02-16 16:14:39 -08:00
2017-04-02 20:03:51 -07:00
case RELOADTASKGOALLISTS :
Log ( Logs : : General , Logs : : Tasks , " [GLOBALLOAD] Reload task goal lists " ) ;
taskmanager - > ReloadGoalLists ( ) ;
break ;
case RELOADTASKSETS :
Log ( Logs : : General , Logs : : Tasks , " [GLOBALLOAD] Reload task sets " ) ;
taskmanager - > LoadTaskSets ( ) ;
break ;
default :
Log ( Logs : : General , Logs : : Tasks , " [GLOBALLOAD] Unhandled ServerOP_ReloadTasks command %i " , rts - > Command ) ;
2013-02-16 16:14:39 -08:00
}
}
uint32 WorldServer : : NextGroupID ( ) {
//this system wastes a lot of potential group IDs (~5%), but
//if you are creating 2 billion groups in 1 run of the emu,
//something else is wrong...
2017-04-02 20:03:51 -07:00
if ( cur_groupid > = last_groupid ) {
2013-02-16 16:14:39 -08:00
//this is an error... This means that 50 groups were created before
//1 packet could make the zone->world->zone trip... so let it error.
2019-09-01 22:05:44 -05:00
LogError ( " Ran out of group IDs before the server sent us more " ) ;
2013-02-16 16:14:39 -08:00
return ( 0 ) ;
}
2017-04-02 20:03:51 -07:00
if ( cur_groupid > ( last_groupid - /*50*/ 995 ) ) {
2013-02-16 16:14:39 -08:00
//running low, request more
2016-05-25 16:10:28 -04:00
auto pack = new ServerPacket ( ServerOP_GroupIDReq ) ;
2013-02-16 16:14:39 -08:00
SendPacket ( pack ) ;
safe_delete ( pack ) ;
}
printf ( " Handing out new group id %d \n " , cur_groupid ) ;
return ( cur_groupid + + ) ;
}
2013-05-06 13:07:41 -04:00
void WorldServer : : UpdateLFP ( uint32 LeaderID , uint8 Action , uint8 MatchFilter , uint32 FromLevel , uint32 ToLevel , uint32 Classes ,
2017-04-02 20:03:51 -07:00
const char * Comments , GroupLFPMemberEntry * LFPMembers ) {
2013-02-16 16:14:39 -08:00
2016-05-25 16:10:28 -04:00
auto pack = new ServerPacket ( ServerOP_LFPUpdate , sizeof ( ServerLFPUpdate_Struct ) ) ;
2017-04-02 20:03:51 -07:00
ServerLFPUpdate_Struct * sus = ( ServerLFPUpdate_Struct * ) pack - > pBuffer ;
2013-02-16 16:14:39 -08:00
sus - > LeaderID = LeaderID ;
sus - > Action = Action ;
sus - > MatchFilter = MatchFilter ;
sus - > FromLevel = FromLevel ;
sus - > ToLevel = ToLevel ;
sus - > Classes = Classes ;
strcpy ( sus - > Comments , Comments ) ;
memcpy ( sus - > Members , LFPMembers , sizeof ( sus - > Members ) ) ;
SendPacket ( pack ) ;
safe_delete ( pack ) ;
}
void WorldServer : : UpdateLFP ( uint32 LeaderID , GroupLFPMemberEntry * LFPMembers ) {
UpdateLFP ( LeaderID , LFPMemberUpdate , 0 , 0 , 0 , 0 , " " , LFPMembers ) ;
}
void WorldServer : : StopLFP ( uint32 LeaderID ) {
GroupLFPMemberEntry LFPMembers ;
UpdateLFP ( LeaderID , LFPOff , 0 , 0 , 0 , 0 , " " , & LFPMembers ) ;
}
void WorldServer : : HandleLFGMatches ( ServerPacket * pack ) {
char * Buffer = ( char * ) pack - > pBuffer ;
int PacketLength = 4 ;
int Entries = ( pack - > size - 4 ) / sizeof ( ServerLFGMatchesResponse_Struct ) ;
uint32 EntityID = VARSTRUCT_DECODE_TYPE ( uint32 , Buffer ) ;
Client * client = entity_list . GetClientByID ( EntityID ) ;
2017-04-02 20:03:51 -07:00
if ( client ) {
2013-02-16 16:14:39 -08:00
ServerLFGMatchesResponse_Struct * smrs = ( ServerLFGMatchesResponse_Struct * ) Buffer ;
2017-04-02 20:03:51 -07:00
for ( int i = 0 ; i < Entries ; i + + ) {
2013-02-16 16:14:39 -08:00
PacketLength = PacketLength + 12 + strlen ( smrs - > Name ) + strlen ( smrs - > Comments ) ;
smrs + + ;
}
2016-05-25 16:10:28 -04:00
auto outapp = new EQApplicationPacket ( OP_LFGGetMatchesResponse , PacketLength ) ;
2013-02-16 16:14:39 -08:00
smrs = ( ServerLFGMatchesResponse_Struct * ) Buffer ;
char * OutBuffer = ( char * ) outapp - > pBuffer ;
VARSTRUCT_ENCODE_TYPE ( uint32 , OutBuffer , 0x00074af ) ; // Unknown
2017-04-02 20:03:51 -07:00
for ( int i = 0 ; i < Entries ; i + + ) {
2013-02-16 16:14:39 -08:00
VARSTRUCT_ENCODE_STRING ( OutBuffer , smrs - > Comments ) ;
VARSTRUCT_ENCODE_STRING ( OutBuffer , smrs - > Name ) ;
VARSTRUCT_ENCODE_TYPE ( uint16 , OutBuffer , smrs - > Class_ ) ;
VARSTRUCT_ENCODE_TYPE ( uint16 , OutBuffer , smrs - > Level ) ;
VARSTRUCT_ENCODE_TYPE ( uint16 , OutBuffer , smrs - > Zone ) ;
VARSTRUCT_ENCODE_TYPE ( uint16 , OutBuffer , smrs - > GuildID ) ;
VARSTRUCT_ENCODE_TYPE ( uint16 , OutBuffer , smrs - > Anon ) ;
smrs + + ;
}
client - > QueuePacket ( outapp ) ;
safe_delete ( outapp ) ;
}
2013-05-06 13:07:41 -04:00
}
2013-02-16 16:14:39 -08:00
void WorldServer : : HandleLFPMatches ( ServerPacket * pack ) {
char * Buffer = ( char * ) pack - > pBuffer ;
int PacketLength = 4 ;
int Entries = ( pack - > size - 4 ) / sizeof ( ServerLFPMatchesResponse_Struct ) ;
uint32 EntityID = VARSTRUCT_DECODE_TYPE ( uint32 , Buffer ) ;
2013-05-06 13:07:41 -04:00
2013-02-16 16:14:39 -08:00
ServerLFPMatchesResponse_Struct * smrs = ( ServerLFPMatchesResponse_Struct * ) Buffer ;
Client * client = entity_list . GetClientByID ( EntityID ) ;
2017-04-02 20:03:51 -07:00
if ( client ) {
for ( int i = 0 ; i < Entries ; i + + ) {
2013-02-16 16:14:39 -08:00
PacketLength + = strlen ( smrs - > Comments ) + 11 ;
2017-04-02 20:03:51 -07:00
for ( unsigned int j = 0 ; j < MAX_GROUP_MEMBERS ; j + + ) {
2013-02-16 16:14:39 -08:00
2017-04-02 20:03:51 -07:00
if ( smrs - > Members [ j ] . Name [ 0 ] ! = ' \0 ' )
2013-02-16 16:14:39 -08:00
PacketLength + = strlen ( smrs - > Members [ j ] . Name ) + 9 ;
}
smrs + + ;
}
2016-05-25 16:10:28 -04:00
auto outapp = new EQApplicationPacket ( OP_LFPGetMatchesResponse , PacketLength ) ;
2013-02-16 16:14:39 -08:00
smrs = ( ServerLFPMatchesResponse_Struct * ) Buffer ;
char * OutBuffer = ( char * ) outapp - > pBuffer ;
VARSTRUCT_ENCODE_TYPE ( uint32 , OutBuffer , 0x00074af ) ; // Unknown
2017-04-02 20:03:51 -07:00
for ( int i = 0 ; i < Entries ; i + + ) {
2013-02-16 16:14:39 -08:00
int MemberCount = 0 ;
2017-04-02 20:03:51 -07:00
for ( unsigned int j = 0 ; j < MAX_GROUP_MEMBERS ; j + + )
if ( smrs - > Members [ j ] . Name [ 0 ] ! = ' \0 ' )
2013-02-16 16:14:39 -08:00
MemberCount + + ;
VARSTRUCT_ENCODE_STRING ( OutBuffer , smrs - > Comments ) ;
VARSTRUCT_ENCODE_TYPE ( uint16 , OutBuffer , smrs - > FromLevel ) ;
VARSTRUCT_ENCODE_TYPE ( uint16 , OutBuffer , smrs - > ToLevel ) ;
VARSTRUCT_ENCODE_TYPE ( uint32 , OutBuffer , smrs - > Classes ) ;
VARSTRUCT_ENCODE_TYPE ( uint16 , OutBuffer , MemberCount ) ;
2017-04-02 20:03:51 -07:00
for ( unsigned int j = 0 ; j < MAX_GROUP_MEMBERS ; j + + ) {
if ( smrs - > Members [ j ] . Name [ 0 ] ! = ' \0 ' ) {
2013-02-16 16:14:39 -08:00
VARSTRUCT_ENCODE_STRING ( OutBuffer , smrs - > Members [ j ] . Name ) ;
VARSTRUCT_ENCODE_TYPE ( uint16 , OutBuffer , smrs - > Members [ j ] . Class ) ;
VARSTRUCT_ENCODE_TYPE ( uint16 , OutBuffer , smrs - > Members [ j ] . Level ) ;
VARSTRUCT_ENCODE_TYPE ( uint16 , OutBuffer , smrs - > Members [ j ] . Zone ) ;
VARSTRUCT_ENCODE_TYPE ( uint16 , OutBuffer , smrs - > Members [ j ] . GuildID ) ;
}
}
smrs + + ;
}
client - > QueuePacket ( outapp ) ;
safe_delete ( outapp ) ;
}
}
2014-09-18 22:55:06 -04:00
void WorldServer : : RequestTellQueue ( const char * who )
{
if ( ! who )
return ;
2016-05-25 16:10:28 -04:00
auto pack = new ServerPacket ( ServerOP_RequestTellQueue , sizeof ( ServerRequestTellQueue_Struct ) ) ;
2017-04-02 20:03:51 -07:00
ServerRequestTellQueue_Struct * rtq = ( ServerRequestTellQueue_Struct * ) pack - > pBuffer ;
2014-09-18 22:55:06 -04:00
strn0cpy ( rtq - > name , who , sizeof ( rtq - > name ) ) ;
SendPacket ( pack ) ;
safe_delete ( pack ) ;
return ;
}
2019-09-07 20:20:10 -05:00
void WorldServer : : OnKeepAlive ( EQ : : Timer * t )
{
ServerPacket pack ( ServerOP_KeepAlive , 0 ) ;
SendPacket ( & pack ) ;
}