mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-11 21:01:29 +00:00
* Shared tasks WIP; lots of logging; shared tasks and tasks work internally the same for now; lots to cleanup yet * Update task_manager.cpp * Add tables * World message handler * Zone message handler * More messaging * More rearranging * Task creation work (wip) * Tweaks * Decoupled things, added a shared task manager, moved logic to the manager, created the shared task object, now creating a sense of state on creation and members, zero validation, happy path * Cleanup unnecessary getter * More work on shared task persistence and state loading * Add int64 support into repositories * More state handling, creation loads all tables * Wrap up shared task state creation and removal * Move more lookup operations to preloading (memory). Restore shared task state during world bootup * Implement shared task updates * Add members other than just leader in task confirmations * Update shared_task_manager.cpp * Hook task cancellation for shared task removal (middleware) * Remove dynamic_zone_id from SharedTasks model in repositories (for now) since we will likely be one to many with DZ objects * Get members to show up in the window on creation * Add opcodes, cleanup * Add opcode handlers * Split some methods out, self removal of shared task and updating members * Implement offline shared task sync * Style changes * Send memberlist on initial login; implement remove player from shared task window * Refactorings, cleanup * Implement make leader in shared tasks window * Implement add player, sync shared task state after add * Add opcodes for remaining clients * Shared task invite dialogue window implementation and response handling (including validation) * Logging * Remove comment * Some cleanup * Pass NPC context through shared task request logic * Remove extra SharedTaskMember fields * Add message constants * Remove static * Only use dz for expedition request This passes expedition creation parameters through DynamicZone instead of injecting ExpeditionRequest since it can hold creation data now * Store expedition leader on dz This shifts to using the leader object that exists in the core dynamic zone object. It will be moved to the dynamic zone table later with other columns that should just be on the dz to make loading easier. Expeditions are probably the only dz type that will use this for window updates and command auth. Other systems on live do fill the window but don't keep it updated * Store expedition name on dz This uses the name stored on dz (for window packets) instead of duplicating it. This will be moved completely to dz table later * Store uuid on dynamic zone This lets dynamic zones generate the uuid instead of expeditions. Other dz type systems may want to make use of this. Lockouts should also be moved to dynamic zones at some point in the future so this will be necessary for that * Move expedition db columns to dz These columns should just belong to the core dynamic zone. This will simplify loading from the database and in the future a separate expedition table may no longer be necessary. * Move window packet methods to dz It makes more sense for these methods to be in the core This will also allow support for other systems to use the window, though live behavior that updates the window for shared task missions when not in an expedition is likely unintended since it's not updated on changes. * Store dynamic zone ids on clients These will now be used for client dynamic zone lookups to remove dependency on any dz type system caches * Move member management to dz This moves server messaging for adding and removing members to internal dynamic zone methods Set default dz member status to Unknown * Move member status caching to dz This moves world member status caching into internal dz methods Zone member updates for created expeditions are now async and sent after world replies with member statuses. Prior to this two memberlist packets were sent to members in other zones on creation to update statuses. This also fixes a bug with member statuses being wrong for offline raid members in the zone that created an expedition. Note that live kicks offline players out of raids so this is only to support emu behavior. * Move member status updates to dz * Set dz member status on all client dzs This also renames the zone entry dz update method and moves window update to a dynamic zone method. Eventually expedition components should just be merged with dz and handled as another dz type * Save instance safe return on characters Add character_instance_safereturns table and repository Previously dz safe return only worked for online characters via the dz kicktimer or offline characters with a workaround that moved them when an expedition was deleted. There were various edge cases that would cause characters to be moved to bind instead (succoring after removal, camping before kick timer, removed while offline, bulk kickplayers removal with some offline) This updates a character's instance safereturn every time they enter a zone. If a character enters world in an instance that expired or are no longer part of they'll be moved to their instance safereturn (if the safereturn data is for the same zone-instance). Bind is still a fallback This may also be used for non-dz instancing so it's named generically This removes the expedition MoveMembersToSafeReturn workaround which deprecates the is_current_member column of dynamic_zone_members and will be removed in a followup patch. * Remove is_current_member from dz members This was only being used in the workaround to move past members to dz safereturns if they were still inside the dz but not online * Let dz check leader in world This moves expedition leader processing in world to the dynamic zone. This is a step in phasing out the separate expedition class for things that can run off the dynamic zone core with simple dz type checks This greatly simplifies checking leader on member and status changes without needing callbacks. Other dz types that may use the dz leader object can just handle it directly on the dz the same as expeditions * Let dz handle member expire warnings This moves expire warning checks to dz. This will make it easier for other dz types to issue expire warnings if needed * Use separate dynamic zone cache Dynamic zones are no longer member objects of expeditions and have been placed into their own cache. This was done so other dz types can be cached without relying on their systems. Client and zone dz Lookups are now independent of any system This continues the process of phasing out a separate expedition cache. Eventually expeditions can just be run directly as dynamic zones internally with a few dz type checks. Add dz serialization methods (cereal) for passing server dz creation Modify #dz list to show cache and database separately. Also adds #dz cache reload. This command will reload expeditions too since they currently hold references to the dz in their own zone cache. Add a dynamic zone processing class to world to process all types and move expedition processing to it * Move expedition makeleader processing to dz * Let dz handle expedition deletions This removes the need for separate expedition cache in world This will greatly simplify world dynamic zone caching and processing. Dynamic zones that are expeditions can just handle this directly. Once lockouts and other components are completely moved to dynamic zones the separate expedition cache in zone will also no longer be necessary * Remove ExpeditionBase class Since world no longer caches expeditions this will not be necessary * Fix windows compile * Implement task dz creation Prototype dz creation for shared tasks * Add and remove shared task members from dz Also keep leader updated (used in choose zone window) * Fix client crash on failed shared task * Fix linux compile and warning * Check client nullptr for dz message This was accidently removed when expedition makeleader was moved * Disable dz creation for solo tasks * Add shared task repository headers to CMakeLists * Add shared task dynamic zones table * Add shared task dz database persistence * Get members from db on shared task dz creation This fixes a case where removing a member from a shared task dz would fail if the member's name was empty. This could happen if the shared task dz was created while a member was offline. This also changes the dz member removal method to only check id. It might be possible to change all dz member validations to only check ids since names are primarily for window updates, but shared task dz member names need to be non-empty anyway to support possible live-like dz window usage in the future. * Add character message methods to world Add simple and eqstr message methods to ClientList Add shared task manager methods to message all members or leader * Add SyncClientSharedTaskState and nested sync strategies to cover M3 work * Fix whitespace * Implement task request cooldown timer This implements the task request cooldown (15 seconds) that live uses when a task is accepted. This will also need to be set when shared tasks are offered (likely due to additional group/raid validations) * Implement shared task selector validation This implements the validation and filtering that occurs before the task selection window is sent to a client for shared tasks To keep things live-like, task selectors that contain a shared task will be run through shared task validation and drop non-shared tasks. Live doesn't mix types in task selections and this makes validation simpler. Also note that live sends shared task selectors via a different opcode than solo tasks but that has not been implemented yet * Add separate shared task select opcodes Live uses separate opcodes for solo and shared task selection windows * Convert ActivityType to enum class * Refactor task selector serialization This adds serializer methods to task and task objective structs for the task selection windows. This combines the duplicate task selector methods to reduce code duplication and simplify serialization * Add shared task selector This sends shared task selection window using the shared task specific opcode and adds an opcode handler for shared task accepts which are sent by client in response to setting selection window to shared task type. * Refactor task objective serialization This adds a serialization method to the task objective struct for serializing objectives in the window list and combines the separate client-based methods to reduce duplicated code. * Add task level spread and player count columns * Implement shared task accept validation This adds a common method for shared task character request queries * Add task replay and request timer columns * Add character task timers table * Use shared task accept time on clients This overrides client task accept time with shared task's creation time. This is needed for accurate window task timers and lockout messages especially for characters added to shared tasks post creation * Implement task timer lockouts This implements replay and request task timers for solo and shared tasks * Add solo and shared task timer validation * Remove logging of padding array This gets interpreted as a c string which may not be null terminated * Implement /kickplayers task This also fixes current CancelTask behavior for leader which was performing kickplayers functionality through the remove task button * Implement /taskquit command * Implement shared task invite validation Remove active invitation before invite accept validation * Remove local client db persistence during SyncClientSharedTaskRemoveLocalIfNotExists * Add missing accept time arg to assign task * Only validate non-zero task invite requirements * Fix task error log crash * Separate task cooldown timer messaging * Use method to check for client shared task * Avoid unneeded task invite validation query Only need to query character data for levels for non-zero level spread * Implement /tasktimers command May want to add some type of throttled caching mechanism for this in the future * Add /tasktimers rate limiter * Intercept shared task completion; more work to come * Change SharedTaskActivityState and SharedTasks time objects to datetime * Add updated_time updates to SharedTaskActivities * Mark shared tasks as complete when all activities are completed * Save a database query on shared task completion and use the active record in memory * Don't record shared task completions to the quest log * Implement RecordSharedTaskCompletion, add tables, repositories * Update shared_task_manager.cpp * Update shared_task_manager.cpp * Add shared task replay timers This is still not feature complete. On live any past members that ever joined the shared task will receive a replay timer when it's completed * Create FindCharactersInSharedTasks that searches through memory * Remove namespace shorthand and formatting * More minor cleanup * Implement PurgeAllSharedTasks via #task command * Add #task purgetimers * Decrease m_keepalive time between processes * Remove type ordering in /tasktimer query * Add comment for task packet reward multiplier This is likely a reward multiplier that changes text color based on value to represent any scaled bonus or penalty * Add replay timers to past members This implements the live behavior that adds replay timers to any previous member of a shared task. This likely exists to avoid possible exploits. Shared task member history is stored in memory and is used to assign replay timers. This history will be lost on world crashes or restarts but is simpler than saving past member state in database. This also makes world send shared task replay timer messages since past members need to be messaged now * Move PurgeTaskTimers client method to tasks.cpp * Remove dz members when purging shared tasks Server dz states need to be updated before shared tasks are deleted * Use exact name in shared task invites This removes the wildcards from shared task invite character queries which was sometimes selecting the wrong character Taskadd validation is called even for invalid characters to allow for proper messages to occur * Clear declined active shared task invitations This also notifies leader for declined shared task invites * Store shared task member names This adds back the character name field to SharedTaskMember. This should make serialization easier in the future and reduce database lookups when names are needed for /task commands * Implement /taskplayerlist command * Replace queries with member name lookups Now that shared task members store names these queries are unnecessary This also adds not-a-member messages for /taskremove and /taskmakeleader * Implement shared task member change packet This avoids sending the full member list to members when a single member is added or removed and lets the client generate chat messages for it. * Serialize shared task member list from world This uses cereal to serialize the full member list from world and removes the zone query workarounds * Initialize client task state array This was causing sql query errors on client state reloads The client task information array was uninitialized resulting in being filled with 0xcdcdcdcd values in msvc debug builds. Under release builds this may have resulted in indeterminate values A better fix would be to refactor some of this legacy code * Add shared task command messages Add messages for non-leader task commands This adds taskadd, taskremove, taskmakeleader, and taskquit messages The leader receives double messages for taskremove like live due to the client generated message as well as the explicit one. It also receives double server messages if the leader /taskremoves self. * Replace some task messages with eqstrs This also updates to use live colors * Avoid shared task invite leader lookup query Since member names are stored now this query is also unnecessary * Avoid reloading client state on shared task accept This was unnecessarily reloading client task state when added to a shared task. This also resulted in all active tasks being resent to shared task members on creation. The shared task itself is the only task that needs to be sent which is handled by AcceptNewTask. * Remove active shared task invite on zone Live doesn't re-send shared task invites after zoning like it does for expeditions so there's no need to keep these around. This fixes active invitations never getting reset on characters that zone or go offline. * Choose new shared task leader if leader removed * Add separate shared task kickplayers method * Enable EVENT_CAST_ON for clients This will be required for a shared task objective (The Creator) in DoN * Revert "Avoid reloading client state on shared task accept" This reverts commit 3af14fee2de8b109ffb6c2b2fc67731e1531a665. Without this clients added to a task after some objectives have been completed don't get updated state. Will need to investigate this later * Disallow looting inside a dz by non-members Non-members of a dynamic zone should not be allowed to loot npcs inside it. This should have been disabled for expeditions already but was still allowed due to an oversight (or live behavior changed). This is less critical for shared tasks since members can be added and removed at will without leaving a dz but still an important feature. * Change load where criteria * Increase task completion emote column size * Use eqstr for task item reward message * Implement radiant and ebon crystal rewards This adds reward columns for radiant and ebon crystals to the tasks table and updates task description serialization * Send task completion emote before rewards This matches live and makes it a little easier to see item rewards when tasks have a long completion emote. This also changes it to send via the same normal message opcode that live uses. * Do not send a shared task in completed task history * Allow EVENT_TASK_STAGE_COMPLETE for quest goals This invokes event_task_stage_complete for task elements flagged with a quest controlled goal method. It should be expected behavior that a completed task stage always fires this event even if a quest controls it * Add SyncSharedTaskZoneClientDoneCountState * Swap return for continue in this case * Formatting * Simplify * Formatting * Formatting * Formatting * Remove errant check * Formatting, add setter for shared tasks * Remove debugging * Comments in PR * More PR follow up * Formatting * Cleanup * Update packet comments * Comments * More cleanup * Send command error message if not in shared task /taskadd is the only command with this feedback on live. Newer live clients also generate this instead of the server sending the message * Implement expire_time on SharedTask object and add a purge on world bootup * Comment * Add SyncClientSharedTaskStateToLocal where clients fall out of sync and no longer have a task locally * Clamp shared task activity updates to max done count and discard updates out of bounds * Fix packet send * Revert packet send * Adjust clamping OOO for completed time check. Add completed tables to purge truncation * Refactor kill update logic so that shared task kill updates only update one client instead of all clients * Cleanup how we're checking for active tasks * Forward task sets that contain shared tasks This forwards task sets that contain a shared task to shared task selector validation like normal task selectors * Change eqstr for empty solo task offers This is the message live appears to use if all task offers are filtered out by solo task validation * Fix max active tasks client message This message starts at the third argument. It was maybe intended to be an npc say message but live just sends it as a normal eqstr with the first two arguments nulled. * Load client task state after zoning complete This fixes a possible race where a character removed from a shared task while zoning would be stuck with an incorrect character activities state after zoning was completed. This was caused by the character loading task state to early on zone entry but never receiving the remove player message from world since they are missing from the world cle until zoning is completed. Loading client state after zone connection is completed makes sure the client has the latest state and available to the world cle * Send message to clients removed while zoning This message should usually only be sent to characters that were removed from a shared task while zoning but will occur for any sync state removals where a message wouldn't have already occured. * Post rebase fix * HG comment for checking active task * Addressing HG comments around zeroing out a shared task id * Remove errant comment * Post rebase database manifest updates * Update eqemu_logsys_log_aliases.h * More rebase catches * Bump database version for last commit Co-authored-by: hg <4683435+hgtw@users.noreply.github.com>
3449 lines
106 KiB
C++
3449 lines
106 KiB
C++
/* EQEMu: Everquest Server Emulator
|
|
Copyright (C) 2001-2016 EQEMu Development Team (http://eqemu.org)
|
|
|
|
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.
|
|
|
|
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.
|
|
|
|
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
|
|
*/
|
|
|
|
#include "../common/global_define.h"
|
|
#include <iostream>
|
|
#include <string.h>
|
|
#include <stdio.h>
|
|
#include <iomanip>
|
|
#include <stdarg.h>
|
|
#include <limits.h>
|
|
|
|
#ifdef _WINDOWS
|
|
#include <process.h>
|
|
|
|
#define snprintf _snprintf
|
|
#define strncasecmp _strnicmp
|
|
#define strcasecmp _stricmp
|
|
#endif
|
|
|
|
#include "../common/eq_packet_structs.h"
|
|
#include "../common/misc_functions.h"
|
|
#include "../common/rulesys.h"
|
|
#include "../common/say_link.h"
|
|
#include "../common/servertalk.h"
|
|
#include "../common/profanity_manager.h"
|
|
|
|
#include "client.h"
|
|
#include "corpse.h"
|
|
#include "entity.h"
|
|
#include "expedition.h"
|
|
#include "quest_parser_collection.h"
|
|
#include "guild_mgr.h"
|
|
#include "mob.h"
|
|
#include "petitions.h"
|
|
#include "raids.h"
|
|
#include "string_ids.h"
|
|
#include "titles.h"
|
|
#include "worldserver.h"
|
|
#include "zone.h"
|
|
#include "zone_config.h"
|
|
#include "zone_reload.h"
|
|
#include "../common/shared_tasks.h"
|
|
#include "shared_task_zone_messaging.h"
|
|
|
|
extern EntityList entity_list;
|
|
extern Zone* zone;
|
|
extern volatile bool is_zone_loaded;
|
|
extern void Shutdown();
|
|
extern WorldServer worldserver;
|
|
extern PetitionList petition_list;
|
|
extern uint32 numclients;
|
|
extern volatile bool RunLoops;
|
|
extern QuestParserCollection *parse;
|
|
|
|
// QuestParserCollection *parse = 0;
|
|
|
|
WorldServer::WorldServer()
|
|
{
|
|
cur_groupid = 0;
|
|
last_groupid = 0;
|
|
oocmuted = false;
|
|
}
|
|
|
|
WorldServer::~WorldServer() {
|
|
}
|
|
|
|
void WorldServer::Connect()
|
|
{
|
|
m_connection = std::make_unique<EQ::Net::ServertalkClient>(Config->WorldIP, Config->WorldTCPPort, false, "Zone", Config->SharedKey);
|
|
m_connection->OnConnect([this](EQ::Net::ServertalkClient *client) {
|
|
OnConnected();
|
|
});
|
|
|
|
m_connection->OnMessage(std::bind(&WorldServer::HandleMessage, this, std::placeholders::_1, std::placeholders::_2));
|
|
|
|
m_keepalive = std::make_unique<EQ::Timer>(1000, true, std::bind(&WorldServer::OnKeepAlive, this, std::placeholders::_1));
|
|
}
|
|
|
|
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();
|
|
}
|
|
|
|
void WorldServer::SetZoneData(uint32 iZoneID, uint32 iInstanceID) {
|
|
auto pack = new ServerPacket(ServerOP_SetZone, sizeof(SetZone_Struct));
|
|
SetZone_Struct* szs = (SetZone_Struct*)pack->pBuffer;
|
|
szs->zoneid = iZoneID;
|
|
szs->instanceid = iInstanceID;
|
|
if (zone) {
|
|
szs->staticzone = zone->IsStaticZone();
|
|
}
|
|
SendPacket(pack);
|
|
safe_delete(pack);
|
|
}
|
|
|
|
void WorldServer::OnConnected() {
|
|
ServerPacket* pack;
|
|
|
|
/* Tell the launcher what our information is */
|
|
pack = new ServerPacket(ServerOP_SetLaunchName, sizeof(LaunchName_Struct));
|
|
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);
|
|
|
|
/* Tell the Worldserver basic information about this zone process */
|
|
pack = new ServerPacket(ServerOP_SetConnectInfo, sizeof(ServerConnectInfo));
|
|
ServerConnectInfo* sci = (ServerConnectInfo*)pack->pBuffer;
|
|
|
|
auto config = ZoneConfig::get();
|
|
sci->port = ZoneConfig::get()->ZonePort;
|
|
if (config->WorldAddress.length() > 0) {
|
|
strn0cpy(sci->address, config->WorldAddress.c_str(), 250);
|
|
}
|
|
if (config->LocalAddress.length() > 0) {
|
|
strn0cpy(sci->local_address, config->LocalAddress.c_str(), 250);
|
|
}
|
|
|
|
/* Fetch process ID */
|
|
if (getpid()) {
|
|
sci->process_id = getpid();
|
|
}
|
|
else {
|
|
sci->process_id = 0;
|
|
}
|
|
|
|
SendPacket(pack);
|
|
safe_delete(pack);
|
|
|
|
if (is_zone_loaded) {
|
|
this->SetZoneData(zone->GetZoneID(), zone->GetInstanceID());
|
|
entity_list.UpdateWho(true);
|
|
this->SendEmoteMessage(0, 0, 15, "Zone connect: %s", zone->GetLongName());
|
|
zone->GetTimeSync();
|
|
}
|
|
else {
|
|
this->SetZoneData(0);
|
|
}
|
|
|
|
pack = new ServerPacket(ServerOP_LSZoneBoot, sizeof(ZoneBoot_Struct));
|
|
ZoneBoot_Struct* zbs = (ZoneBoot_Struct*)pack->pBuffer;
|
|
strcpy(zbs->compile_time, LAST_MODIFIED);
|
|
SendPacket(pack);
|
|
safe_delete(pack);
|
|
}
|
|
|
|
/* Zone Process Packets from World */
|
|
void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p)
|
|
{
|
|
ServerPacket tpack(opcode, p);
|
|
ServerPacket *pack = &tpack;
|
|
|
|
switch (opcode) {
|
|
case 0: {
|
|
break;
|
|
}
|
|
case ServerOP_KeepAlive: {
|
|
// ignore this
|
|
break;
|
|
}
|
|
// World is tellins us what port to use.
|
|
case ServerOP_SetConnectInfo: {
|
|
if (pack->size != sizeof(ServerConnectInfo))
|
|
break;
|
|
ServerConnectInfo* sci = (ServerConnectInfo*)pack->pBuffer;
|
|
|
|
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);
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_ChannelMessage: {
|
|
if (!is_zone_loaded)
|
|
break;
|
|
ServerChannelMessage_Struct* scm = (ServerChannelMessage_Struct*)pack->pBuffer;
|
|
if (scm->deliverto[0] == 0) {
|
|
entity_list.ChannelMessageFromWorld(scm->from, scm->to, scm->chan_num, scm->guilddbid, scm->language, scm->lang_skill, scm->message);
|
|
}
|
|
else {
|
|
Client* client = entity_list.GetClientByName(scm->deliverto);
|
|
if (client && client->Connected()) {
|
|
if (scm->chan_num == ChatChannel_TellEcho) {
|
|
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
|
|
client->MessageString(Chat::EchoTell, TOLD_NOT_ONLINE, scm->to);
|
|
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;
|
|
memset(scm->deliverto, 0, sizeof(scm->deliverto));
|
|
strcpy(scm->deliverto, scm->from);
|
|
SendPacket(pack);
|
|
}
|
|
}
|
|
else {
|
|
client->ChannelMessageSend(scm->from, scm->to, scm->chan_num, scm->language, scm->lang_skill, scm->message);
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_VoiceMacro: {
|
|
|
|
if (!is_zone_loaded)
|
|
break;
|
|
|
|
ServerVoiceMacro_Struct* svm = (ServerVoiceMacro_Struct*)pack->pBuffer;
|
|
|
|
auto outapp = new EQApplicationPacket(OP_VoiceMacroOut, sizeof(VoiceMacroOut_Struct));
|
|
VoiceMacroOut_Struct* vmo = (VoiceMacroOut_Struct*)outapp->pBuffer;
|
|
|
|
strcpy(vmo->From, svm->From);
|
|
vmo->Type = svm->Type;
|
|
vmo->Voice = svm->Voice;
|
|
vmo->MacroNumber = svm->MacroNumber;
|
|
|
|
switch (svm->Type) {
|
|
case VoiceMacroTell: {
|
|
Client* c = entity_list.GetClientByName(svm->To);
|
|
if (!c)
|
|
break;
|
|
|
|
c->QueuePacket(outapp);
|
|
break;
|
|
}
|
|
|
|
case VoiceMacroGroup: {
|
|
Group* g = entity_list.GetGroupByID(svm->GroupID);
|
|
|
|
if (!g)
|
|
break;
|
|
|
|
for (unsigned int i = 0; i < MAX_GROUP_MEMBERS; i++) {
|
|
if (g->members[i] && g->members[i]->IsClient())
|
|
g->members[i]->CastToClient()->QueuePacket(outapp);
|
|
|
|
}
|
|
break;
|
|
}
|
|
|
|
case VoiceMacroRaid: {
|
|
Raid *r = entity_list.GetRaidByID(svm->RaidID);
|
|
|
|
if (!r)
|
|
break;
|
|
|
|
for (int i = 0; i < MAX_RAID_MEMBERS; i++)
|
|
if (r->members[i].member)
|
|
r->members[i].member->QueuePacket(outapp);
|
|
|
|
break;
|
|
}
|
|
}
|
|
safe_delete(outapp);
|
|
break;
|
|
}
|
|
|
|
case ServerOP_SpawnCondition: {
|
|
if (pack->size != sizeof(ServerSpawnCondition_Struct))
|
|
break;
|
|
if (!is_zone_loaded)
|
|
break;
|
|
ServerSpawnCondition_Struct* ssc = (ServerSpawnCondition_Struct*)pack->pBuffer;
|
|
|
|
zone->spawn_conditions.SetCondition(zone->GetShortName(), zone->GetInstanceID(), ssc->condition_id, ssc->value, true);
|
|
break;
|
|
}
|
|
case ServerOP_SpawnEvent: {
|
|
if (pack->size != sizeof(ServerSpawnEvent_Struct))
|
|
break;
|
|
if (!is_zone_loaded)
|
|
break;
|
|
ServerSpawnEvent_Struct* sse = (ServerSpawnEvent_Struct*)pack->pBuffer;
|
|
|
|
zone->spawn_conditions.ReloadEvent(sse->event_id);
|
|
|
|
break;
|
|
}
|
|
case ServerOP_AcceptWorldEntrance: {
|
|
if (pack->size != sizeof(WorldToZone_Struct))
|
|
break;
|
|
if (!is_zone_loaded)
|
|
break;
|
|
WorldToZone_Struct* wtz = (WorldToZone_Struct*)pack->pBuffer;
|
|
|
|
if (zone->GetMaxClients() != 0 && numclients >= zone->GetMaxClients())
|
|
wtz->response = -1;
|
|
else
|
|
wtz->response = 1;
|
|
|
|
SendPacket(pack);
|
|
break;
|
|
}
|
|
case ServerOP_ZoneToZoneRequest: {
|
|
if (pack->size != sizeof(ZoneToZone_Struct))
|
|
break;
|
|
if (!is_zone_loaded)
|
|
break;
|
|
ZoneToZone_Struct* ztz = (ZoneToZone_Struct*)pack->pBuffer;
|
|
|
|
if (ztz->current_zone_id == zone->GetZoneID()
|
|
&& ztz->current_instance_id == zone->GetInstanceID()) {
|
|
// it's a response
|
|
Entity* entity = entity_list.GetClientByName(ztz->name);
|
|
if (entity == 0)
|
|
break;
|
|
|
|
EQApplicationPacket *outapp;
|
|
outapp = new EQApplicationPacket(OP_ZoneChange, sizeof(ZoneChange_Struct));
|
|
ZoneChange_Struct* zc2 = (ZoneChange_Struct*)outapp->pBuffer;
|
|
|
|
if (ztz->response <= 0) {
|
|
zc2->success = ZONE_ERROR_NOTREADY;
|
|
entity->CastToMob()->SetZone(ztz->current_zone_id, ztz->current_instance_id);
|
|
entity->CastToClient()->SetZoning(false);
|
|
}
|
|
else {
|
|
entity->CastToClient()->UpdateWho(1);
|
|
strn0cpy(zc2->char_name, entity->CastToMob()->GetName(), 64);
|
|
zc2->zoneID = ztz->requested_zone_id;
|
|
zc2->instanceID = ztz->requested_instance_id;
|
|
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?
|
|
if (entity->CastToClient()->GetMerc() != nullptr)
|
|
{
|
|
entity->CastToClient()->GetMerc()->ProcessClientZoneChange(entity->CastToClient());
|
|
}
|
|
|
|
entity->CastToMob()->SetZone(ztz->requested_zone_id, ztz->requested_instance_id);
|
|
|
|
if (ztz->ignorerestrictions == 3)
|
|
entity->CastToClient()->GoToSafeCoords(ztz->requested_zone_id, ztz->requested_instance_id);
|
|
}
|
|
|
|
outapp->priority = 6;
|
|
entity->CastToClient()->QueuePacket(outapp);
|
|
safe_delete(outapp);
|
|
|
|
switch (ztz->response)
|
|
{
|
|
case -2: {
|
|
entity->CastToClient()->Message(Chat::Red, "You do not own the required locations to enter this zone.");
|
|
break;
|
|
}
|
|
case -1: {
|
|
entity->CastToClient()->Message(Chat::Red, "The zone is currently full, please try again later.");
|
|
break;
|
|
}
|
|
case 0: {
|
|
entity->CastToClient()->Message(Chat::Red, "All zone servers are taken at this time, please try again later.");
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
else {
|
|
// it's a request
|
|
ztz->response = 0;
|
|
|
|
if (zone->GetMaxClients() != 0 && numclients >= zone->GetMaxClients())
|
|
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);
|
|
break;
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_WhoAllReply: {
|
|
if (!is_zone_loaded)
|
|
break;
|
|
|
|
|
|
WhoAllReturnStruct* wars = (WhoAllReturnStruct*)pack->pBuffer;
|
|
if (wars && wars->id != 0 && wars->id<0xFFFFFFFF) {
|
|
Client* client = entity_list.GetClientByID(wars->id);
|
|
if (client) {
|
|
if (pack->size == 64)//no results
|
|
client->MessageString(Chat::White, WHOALL_NO_RESULTS);
|
|
else {
|
|
auto outapp = new EQApplicationPacket(OP_WhoAllResponse, pack->size);
|
|
memcpy(outapp->pBuffer, pack->pBuffer, pack->size);
|
|
client->QueuePacket(outapp);
|
|
safe_delete(outapp);
|
|
}
|
|
}
|
|
else {
|
|
LogDebug("[CLIENT] id=[{}], playerineqstring=[{}], playersinzonestring=[{}]. Dumping WhoAllReturnStruct:",
|
|
wars->id, wars->playerineqstring, wars->playersinzonestring);
|
|
}
|
|
}
|
|
else
|
|
LogError("WhoAllReturnStruct: Could not get return struct!");
|
|
break;
|
|
}
|
|
case ServerOP_EmoteMessage: {
|
|
if (!is_zone_loaded)
|
|
break;
|
|
ServerEmoteMessage_Struct* sem = (ServerEmoteMessage_Struct*)pack->pBuffer;
|
|
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);
|
|
if (client) {
|
|
char* newmessage = 0;
|
|
if (strstr(sem->message, "^") == 0)
|
|
client->Message(sem->type, (char*)sem->message);
|
|
else {
|
|
for (newmessage = strtok((char*)sem->message, "^"); newmessage != nullptr; newmessage = strtok(nullptr, "^"))
|
|
client->Message(sem->type, newmessage);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else {
|
|
char* newmessage = 0;
|
|
if (strstr(sem->message, "^") == 0)
|
|
entity_list.MessageStatus(sem->guilddbid, sem->minstatus, sem->type, sem->message);
|
|
else {
|
|
for (newmessage = strtok((char*)sem->message, "^"); newmessage != nullptr; newmessage = strtok(nullptr, "^"))
|
|
entity_list.MessageStatus(sem->guilddbid, sem->minstatus, sem->type, newmessage);
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_Motd: {
|
|
if (pack->size != sizeof(ServerMotd_Struct))
|
|
break;
|
|
|
|
ServerMotd_Struct *smotd = (ServerMotd_Struct *)pack->pBuffer;
|
|
SerializeBuffer buf(100);
|
|
buf.WriteString(smotd->motd);
|
|
|
|
auto outapp = std::make_unique<EQApplicationPacket>(OP_MOTD, buf);
|
|
|
|
entity_list.QueueClients(0, outapp.get());
|
|
break;
|
|
}
|
|
case ServerOP_ShutdownAll: {
|
|
entity_list.Save();
|
|
Shutdown();
|
|
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;
|
|
break;
|
|
}
|
|
// Annouce the change to the world
|
|
if (!is_zone_loaded) {
|
|
SetZoneData(0);
|
|
}
|
|
else {
|
|
SendEmoteMessage(0, 0, 15, "Zone shutdown: %s", zone->GetLongName());
|
|
|
|
ServerZoneStateChange_struct* zst = (ServerZoneStateChange_struct *)pack->pBuffer;
|
|
std::cout << "Zone shutdown by " << zst->adminname << std::endl;
|
|
Zone::Shutdown();
|
|
}
|
|
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;
|
|
break;
|
|
}
|
|
ServerZoneStateChange_struct* zst = (ServerZoneStateChange_struct *)pack->pBuffer;
|
|
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);
|
|
}
|
|
else {
|
|
SendEmoteMessage(zst->adminname, 0, 0, "Zone bootup failed: Already running '%s'", zone->GetShortName());
|
|
}
|
|
break;
|
|
}
|
|
|
|
if (zst->adminname[0] != 0)
|
|
std::cout << "Zone bootup by " << zst->adminname << std::endl;
|
|
|
|
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;
|
|
break;
|
|
}
|
|
ServerZoneIncomingClient_Struct* szic = (ServerZoneIncomingClient_Struct*)pack->pBuffer;
|
|
if (is_zone_loaded) {
|
|
SetZoneData(zone->GetZoneID(), zone->GetInstanceID());
|
|
|
|
if (szic->zoneid == zone->GetZoneID()) {
|
|
auto client = entity_list.GetClientByLSID(szic->lsid);
|
|
if (client) {
|
|
client->Kick("Dropped by world CLE subsystem");
|
|
client->Save();
|
|
}
|
|
|
|
zone->RemoveAuth(szic->lsid);
|
|
zone->AddAuth(szic);
|
|
// This packet also doubles as "incoming client" notification, lets not shut down before they get here
|
|
zone->StartShutdownTimer(AUTHENTICATION_TIMEOUT * 1000);
|
|
}
|
|
}
|
|
else {
|
|
if ((Zone::Bootup(szic->zoneid, szic->instanceid))) {
|
|
zone->AddAuth(szic);
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_DropClient: {
|
|
if (pack->size != sizeof(ServerZoneDropClient_Struct)) {
|
|
break;
|
|
}
|
|
|
|
ServerZoneDropClient_Struct* drop = (ServerZoneDropClient_Struct*)pack->pBuffer;
|
|
if (zone) {
|
|
zone->RemoveAuth(drop->lsid);
|
|
|
|
auto client = entity_list.GetClientByLSID(drop->lsid);
|
|
if (client) {
|
|
client->Kick("Dropped by world CLE subsystem");
|
|
client->Save();
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_ZonePlayer: {
|
|
ServerZonePlayer_Struct* szp = (ServerZonePlayer_Struct*)pack->pBuffer;
|
|
Client* client = entity_list.GetClientByName(szp->name);
|
|
// printf("Zoning %s to %s(%u) - %u\n", client != nullptr ? client->GetCleanName() : "Unknown", szp->zone, ZoneID(szp->zone), szp->instance_id);
|
|
if (client) {
|
|
if (strcasecmp(szp->adminname, szp->name) == 0)
|
|
client->Message(Chat::White, "Zoning to: %s", szp->zone);
|
|
else if (client->GetAnon() == 1 && client->Admin() > szp->adminrank)
|
|
break;
|
|
else {
|
|
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);
|
|
}
|
|
if (!szp->instance_id) {
|
|
client->MovePC(ZoneID(szp->zone), szp->instance_id, szp->x_pos, szp->y_pos, szp->z_pos, client->GetHeading(), szp->ignorerestrictions, GMSummon);
|
|
}
|
|
else {
|
|
if (database.GetInstanceID(client->CharacterID(), ZoneID(szp->zone)) == 0) {
|
|
client->AssignToInstance(szp->instance_id);
|
|
client->MovePC(ZoneID(szp->zone), szp->instance_id, szp->x_pos, szp->y_pos, szp->z_pos, client->GetHeading(), szp->ignorerestrictions, GMSummon);
|
|
}
|
|
else {
|
|
client->RemoveFromInstance(database.GetInstanceID(client->CharacterID(), ZoneID(szp->zone)));
|
|
client->AssignToInstance(szp->instance_id);
|
|
client->MovePC(ZoneID(szp->zone), szp->instance_id, szp->x_pos, szp->y_pos, szp->z_pos, client->GetHeading(), szp->ignorerestrictions, GMSummon);
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_KickPlayer: {
|
|
ServerKickPlayer_Struct* skp = (ServerKickPlayer_Struct*)pack->pBuffer;
|
|
Client* client = entity_list.GetClientByName(skp->name);
|
|
if (client) {
|
|
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);
|
|
}
|
|
else if (client->GetAnon() != 1)
|
|
SendEmoteMessage(skp->adminname, 0, 0, "Remote Kick: Your avatar level is not high enough to kick %s", skp->name);
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_KillPlayer: {
|
|
ServerKillPlayer_Struct* skp = (ServerKillPlayer_Struct*)pack->pBuffer;
|
|
Client* client = entity_list.GetClientByName(skp->target);
|
|
if (client) {
|
|
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);
|
|
}
|
|
else if (client->GetAnon() != 1)
|
|
SendEmoteMessage(skp->gmname, 0, 0, "Remote Kill: Your avatar level is not high enough to kill %s", skp->target);
|
|
}
|
|
break;
|
|
}
|
|
|
|
//hand all the guild related packets to the guild manager for processing.
|
|
case ServerOP_OnlineGuildMembersResponse:
|
|
case ServerOP_RefreshGuild:
|
|
// case ServerOP_GuildInvite:
|
|
case ServerOP_DeleteGuild:
|
|
case ServerOP_GuildCharRefresh:
|
|
case ServerOP_GuildMemberUpdate:
|
|
case ServerOP_GuildRankUpdate:
|
|
case ServerOP_LFGuildUpdate:
|
|
// case ServerOP_GuildGMSet:
|
|
// case ServerOP_GuildGMSetRank:
|
|
// case ServerOP_GuildJoin:
|
|
guild_mgr.ProcessWorldPacket(pack);
|
|
break;
|
|
|
|
case ServerOP_FlagUpdate: {
|
|
Client* client = entity_list.GetClientByAccID(*((uint32*)pack->pBuffer));
|
|
if (client) {
|
|
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;
|
|
ServerGMGoto_Struct* gmg = (ServerGMGoto_Struct*)pack->pBuffer;
|
|
Client* client = entity_list.GetClientByName(gmg->gotoname);
|
|
if (client) {
|
|
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));
|
|
ServerZonePlayer_Struct* szp = (ServerZonePlayer_Struct*)outpack->pBuffer;
|
|
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: {
|
|
ServerMultiLineMsg_Struct* mlm = (ServerMultiLineMsg_Struct*)pack->pBuffer;
|
|
Client* client = entity_list.GetClientByName(mlm->to);
|
|
if (client) {
|
|
auto outapp = new EQApplicationPacket(OP_MultiLineMsg, strlen(mlm->message));
|
|
strcpy((char*)outapp->pBuffer, mlm->message);
|
|
client->QueuePacket(outapp);
|
|
safe_delete(outapp);
|
|
}
|
|
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;
|
|
}
|
|
ServerUptime_Struct* sus = (ServerUptime_Struct*)pack->pBuffer;
|
|
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;
|
|
ServerPetitionUpdate_Struct* sus = (ServerPetitionUpdate_Struct*)pack->pBuffer;
|
|
// 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: {
|
|
RezzPlayer_Struct* srs = (RezzPlayer_Struct*)pack->pBuffer;
|
|
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)
|
|
{
|
|
if (client->IsRezzPending())
|
|
{
|
|
auto Response = new ServerPacket(ServerOP_RezzPlayerReject,
|
|
strlen(srs->rez.rezzer_name) + 1);
|
|
|
|
char *Buffer = (char *)Response->pBuffer;
|
|
sprintf(Buffer, "%s", srs->rez.rezzer_name);
|
|
worldserver.SendPacket(Response);
|
|
safe_delete(Response);
|
|
break;
|
|
}
|
|
//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);
|
|
LogSpells("OP_RezzRequest in zone [{}] for [{}], spellid:[{}]",
|
|
zone->GetShortName(), client->GetName(), srs->rez.spellid);
|
|
auto outapp = new EQApplicationPacket(OP_RezzRequest,
|
|
sizeof(Resurrect_Struct));
|
|
memcpy(outapp->pBuffer, &srs->rez, sizeof(Resurrect_Struct));
|
|
client->QueuePacket(outapp);
|
|
safe_delete(outapp);
|
|
break;
|
|
}
|
|
}
|
|
if (srs->rezzopcode == OP_RezzComplete) {
|
|
// 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()) {
|
|
LogSpells("OP_RezzComplete received in zone [{}] for corpse [{}]",
|
|
zone->GetShortName(), srs->rez.corpse_name);
|
|
|
|
LogSpells("Found corpse. Marking corpse as rezzed if needed");
|
|
// 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();
|
|
}
|
|
}
|
|
}
|
|
|
|
break;
|
|
}
|
|
case ServerOP_RezzPlayerReject:
|
|
{
|
|
char *Rezzer = (char *)pack->pBuffer;
|
|
|
|
Client* c = entity_list.GetClientByName(Rezzer);
|
|
|
|
if (c)
|
|
c->MessageString(Chat::SpellWornOff, REZZ_ALREADY_PENDING);
|
|
|
|
break;
|
|
}
|
|
case ServerOP_ZoneReboot: {
|
|
std::cout << "Got Server Requested Zone reboot" << std::endl;
|
|
ServerZoneReboot_Struct* zb = (ServerZoneReboot_Struct*)pack->pBuffer;
|
|
break;
|
|
}
|
|
case ServerOP_SyncWorldTime: {
|
|
if (zone != 0 && !zone->is_zone_time_localized) {
|
|
LogInfo("[{}] Received Message SyncWorldTime", __FUNCTION__);
|
|
|
|
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);
|
|
|
|
char time_message[255];
|
|
time_t current_time = time(nullptr);
|
|
TimeOfDay_Struct eq_time;
|
|
zone->zone_time.GetCurrentEQTimeOfDay(current_time, &eq_time);
|
|
|
|
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"
|
|
);
|
|
|
|
LogInfo("Time Broadcast Packet: {}", time_message);
|
|
zone->SetZoneHasCurrentTime(true);
|
|
|
|
}
|
|
if (zone && zone->is_zone_time_localized) {
|
|
LogInfo("Received request to sync time from world, but our time is localized currently");
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_RefreshCensorship: {
|
|
if (!EQ::ProfanityManager::LoadProfanityList(&database))
|
|
LogError("Received request to refresh the profanity list..but, the action failed");
|
|
break;
|
|
}
|
|
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;
|
|
break;
|
|
}
|
|
ServerChangeWID_Struct* scw = (ServerChangeWID_Struct*)pack->pBuffer;
|
|
Client* client = entity_list.GetClientByCharID(scw->charid);
|
|
if (client)
|
|
client->SetWID(scw->newwid);
|
|
break;
|
|
}
|
|
case ServerOP_OOCMute: {
|
|
oocmuted = *(pack->pBuffer);
|
|
break;
|
|
}
|
|
case ServerOP_Revoke: {
|
|
RevokeStruct* rev = (RevokeStruct*)pack->pBuffer;
|
|
Client* client = entity_list.GetClientByName(rev->name);
|
|
if (client)
|
|
{
|
|
SendEmoteMessage(rev->adminname, 0, 0, "%s: %srevoking %s", zone->GetShortName(), rev->toggle ? "" : "un", client->GetName());
|
|
client->SetRevoked(rev->toggle);
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_GroupIDReply: {
|
|
ServerGroupIDReply_Struct* ids = (ServerGroupIDReply_Struct*)pack->pBuffer;
|
|
cur_groupid = ids->start;
|
|
last_groupid = ids->end;
|
|
break;
|
|
}
|
|
case ServerOP_GroupLeave: {
|
|
ServerGroupLeave_Struct* gl = (ServerGroupLeave_Struct*)pack->pBuffer;
|
|
if (zone) {
|
|
if (gl->zoneid == zone->GetZoneID() && gl->instance_id == zone->GetInstanceID())
|
|
break;
|
|
|
|
entity_list.SendGroupLeave(gl->gid, gl->member_name);
|
|
}
|
|
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;
|
|
|
|
Mob *Invitee = entity_list.GetMob(gis->invitee_name);
|
|
|
|
if (Invitee && Invitee->IsClient() && Invitee->CastToClient()->MercOnlyOrNoGroup() && !Invitee->IsRaidGrouped())
|
|
{
|
|
auto outapp = new EQApplicationPacket(OP_GroupInvite, sizeof(GroupInvite_Struct));
|
|
memcpy(outapp->pBuffer, gis, sizeof(GroupInvite_Struct));
|
|
Invitee->CastToClient()->QueuePacket(outapp);
|
|
safe_delete(outapp);
|
|
}
|
|
|
|
break;
|
|
}
|
|
case ServerOP_GroupFollow: {
|
|
// Player in another zone accepted a group invitation from a player in this zone.
|
|
ServerGroupFollow_Struct* sgfs = (ServerGroupFollow_Struct*)pack->pBuffer;
|
|
|
|
Mob* Inviter = entity_list.GetClientByName(sgfs->gf.name1);
|
|
|
|
if (Inviter && Inviter->IsClient())
|
|
{
|
|
Group* group = entity_list.GetGroupByClient(Inviter->CastToClient());
|
|
|
|
if (!group)
|
|
{
|
|
//Make new group
|
|
group = new Group(Inviter);
|
|
|
|
if (!group)
|
|
{
|
|
break;
|
|
}
|
|
|
|
entity_list.AddGroup(group);
|
|
|
|
if (group->GetID() == 0) {
|
|
Inviter->Message(Chat::Red, "Unable to get new group id. Cannot create group.");
|
|
break;
|
|
}
|
|
|
|
database.SetGroupID(Inviter->GetName(), group->GetID(), Inviter->CastToClient()->CharacterID(), false);
|
|
database.SetGroupLeaderName(group->GetID(), Inviter->GetName());
|
|
group->UpdateGroupAAs();
|
|
|
|
if (Inviter->CastToClient()->ClientVersion() < EQ::versions::ClientVersion::SoD)
|
|
{
|
|
auto outapp =
|
|
new EQApplicationPacket(OP_GroupUpdate, sizeof(GroupJoin_Struct));
|
|
GroupJoin_Struct* outgj = (GroupJoin_Struct*)outapp->pBuffer;
|
|
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);
|
|
}
|
|
else
|
|
{
|
|
// SoD and later
|
|
Inviter->CastToClient()->SendGroupCreatePacket();
|
|
Inviter->CastToClient()->SendGroupLeaderChangePacket(Inviter->GetName());
|
|
Inviter->CastToClient()->SendGroupJoinAcknowledge();
|
|
}
|
|
|
|
group->GetXTargetAutoMgr()->merge(*Inviter->CastToClient()->GetXTargetAutoMgr());
|
|
Inviter->CastToClient()->GetXTargetAutoMgr()->clear();
|
|
Inviter->CastToClient()->SetXTargetAutoMgr(group->GetXTargetAutoMgr());
|
|
}
|
|
|
|
if (!group)
|
|
{
|
|
break;
|
|
}
|
|
|
|
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);
|
|
|
|
if (!group->AddMember(nullptr, sgfs->gf.name2, sgfs->CharacterID))
|
|
break;
|
|
|
|
if (Inviter->CastToClient()->IsLFP())
|
|
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);
|
|
|
|
|
|
|
|
// Send acknowledgement back to the Invitee to let them know we have added them to the group.
|
|
auto pack3 =
|
|
new ServerPacket(ServerOP_GroupFollowAck, sizeof(ServerGroupFollowAck_Struct));
|
|
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;
|
|
|
|
Client *client = entity_list.GetClientByName(sgfas->Name);
|
|
|
|
if (!client)
|
|
break;
|
|
|
|
uint32 groupid = database.GetGroupID(client->GetName());
|
|
|
|
Group* group = nullptr;
|
|
|
|
if (groupid > 0)
|
|
{
|
|
group = entity_list.GetGroupByID(groupid);
|
|
|
|
if (!group)
|
|
{ //nobody from our group is here... start a new group
|
|
group = new Group(groupid);
|
|
|
|
if (group->GetID() != 0)
|
|
entity_list.AddGroup(group, groupid);
|
|
else
|
|
safe_delete(group);
|
|
}
|
|
|
|
if (group)
|
|
group->UpdatePlayer(client);
|
|
else
|
|
{
|
|
if (client->GetMerc())
|
|
database.SetGroupID(client->GetMerc()->GetCleanName(), 0, client->CharacterID(), true);
|
|
database.SetGroupID(client->GetName(), 0, client->CharacterID(), false); //cannot re-establish group, kill it
|
|
}
|
|
|
|
}
|
|
|
|
if (group)
|
|
{
|
|
if (client->GetMerc())
|
|
{
|
|
client->GetMerc()->MercJoinClientGroup();
|
|
}
|
|
database.RefreshGroupFromDB(client);
|
|
|
|
group->SendHPManaEndPacketsTo(client);
|
|
|
|
// If the group leader is not set, pull the group leader information from the database.
|
|
if (!group->GetLeader())
|
|
{
|
|
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);
|
|
database.GetGroupLeadershipInfo(group->GetID(), ln, MainTankName, AssistName, PullerName, NPCMarkerName, mentoree_name, &mentor_percent, &GLAA);
|
|
Client *lc = entity_list.GetClientByName(ln);
|
|
if (lc)
|
|
group->SetLeader(lc);
|
|
|
|
group->SetMainTank(MainTankName);
|
|
group->SetMainAssist(AssistName);
|
|
group->SetPuller(PullerName);
|
|
group->SetNPCMarker(NPCMarkerName);
|
|
group->SetGroupAAs(&GLAA);
|
|
group->SetGroupMentor(mentor_percent, mentoree_name);
|
|
client->JoinGroupXTargets(group);
|
|
}
|
|
}
|
|
else if (client->GetMerc())
|
|
{
|
|
client->GetMerc()->MercJoinClientGroup();
|
|
}
|
|
break;
|
|
|
|
}
|
|
case ServerOP_GroupCancelInvite: {
|
|
|
|
GroupCancel_Struct* sgcs = (GroupCancel_Struct*)pack->pBuffer;
|
|
|
|
Mob* Inviter = entity_list.GetClientByName(sgcs->name1);
|
|
|
|
if (Inviter && Inviter->IsClient())
|
|
{
|
|
auto outapp = new EQApplicationPacket(OP_GroupCancelInvite, sizeof(GroupCancel_Struct));
|
|
memcpy(outapp->pBuffer, sgcs, sizeof(GroupCancel_Struct));
|
|
Inviter->CastToClient()->QueuePacket(outapp);
|
|
safe_delete(outapp);
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_GroupJoin: {
|
|
ServerGroupJoin_Struct* gj = (ServerGroupJoin_Struct*)pack->pBuffer;
|
|
if (zone) {
|
|
if (gj->zoneid == zone->GetZoneID() && gj->instance_id == zone->GetInstanceID())
|
|
break;
|
|
|
|
Group* g = entity_list.GetGroupByID(gj->gid);
|
|
if (g)
|
|
g->AddMember(gj->member_name);
|
|
|
|
entity_list.SendGroupJoin(gj->gid, gj->member_name);
|
|
}
|
|
break;
|
|
}
|
|
|
|
case ServerOP_ForceGroupUpdate: {
|
|
ServerForceGroupUpdate_Struct* fgu = (ServerForceGroupUpdate_Struct*)pack->pBuffer;
|
|
if (zone) {
|
|
if (fgu->origZoneID == zone->GetZoneID() && fgu->instance_id == zone->GetInstanceID())
|
|
break;
|
|
|
|
entity_list.ForceGroupUpdate(fgu->gid);
|
|
}
|
|
break;
|
|
}
|
|
|
|
case ServerOP_OOZGroupMessage: {
|
|
ServerGroupChannelMessage_Struct* gcm = (ServerGroupChannelMessage_Struct*)pack->pBuffer;
|
|
if (zone) {
|
|
if (gcm->zoneid == zone->GetZoneID() && gcm->instanceid == zone->GetInstanceID())
|
|
break;
|
|
|
|
entity_list.GroupMessage(gcm->groupid, gcm->from, gcm->message);
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_DisbandGroup: {
|
|
ServerDisbandGroup_Struct* sd = (ServerDisbandGroup_Struct*)pack->pBuffer;
|
|
if (zone) {
|
|
if (sd->zoneid == zone->GetZoneID() && sd->instance_id == zone->GetInstanceID())
|
|
break;
|
|
|
|
Group *g = entity_list.GetGroupByID(sd->groupid);
|
|
if (g)
|
|
g->DisbandGroup();
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_RaidAdd: {
|
|
ServerRaidGeneralAction_Struct* rga = (ServerRaidGeneralAction_Struct*)pack->pBuffer;
|
|
if (zone) {
|
|
if (rga->zoneid == zone->GetZoneID() && rga->instance_id == zone->GetInstanceID())
|
|
break;
|
|
|
|
Raid *r = entity_list.GetRaidByID(rga->rid);
|
|
if (r) {
|
|
r->LearnMembers();
|
|
r->VerifyRaid();
|
|
r->SendRaidAddAll(rga->playername);
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
|
|
case ServerOP_RaidRemove: {
|
|
ServerRaidGeneralAction_Struct* rga = (ServerRaidGeneralAction_Struct*)pack->pBuffer;
|
|
if (zone) {
|
|
if (rga->zoneid == zone->GetZoneID() && rga->instance_id == zone->GetInstanceID())
|
|
break;
|
|
|
|
Raid *r = entity_list.GetRaidByID(rga->rid);
|
|
if (r) {
|
|
r->SendRaidRemoveAll(rga->playername);
|
|
Client *rem = entity_list.GetClientByName(rga->playername);
|
|
if (rem) {
|
|
rem->LeaveRaidXTargets(r);
|
|
r->SendRaidDisband(rem);
|
|
}
|
|
r->LearnMembers();
|
|
r->VerifyRaid();
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
|
|
case ServerOP_RaidDisband: {
|
|
ServerRaidGeneralAction_Struct* rga = (ServerRaidGeneralAction_Struct*)pack->pBuffer;
|
|
if (zone) {
|
|
if (rga->zoneid == zone->GetZoneID() && rga->instance_id == zone->GetInstanceID())
|
|
break;
|
|
|
|
Raid *r = entity_list.GetRaidByID(rga->rid);
|
|
if (r) {
|
|
r->SendRaidDisbandAll();
|
|
r->LearnMembers();
|
|
r->VerifyRaid();
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
|
|
case ServerOP_RaidLockFlag: {
|
|
ServerRaidGeneralAction_Struct* rga = (ServerRaidGeneralAction_Struct*)pack->pBuffer;
|
|
if (zone) {
|
|
if (rga->zoneid == zone->GetZoneID() && rga->instance_id == zone->GetInstanceID())
|
|
break;
|
|
|
|
Raid *r = entity_list.GetRaidByID(rga->rid);
|
|
if (r) {
|
|
r->GetRaidDetails(); //update our details
|
|
if (rga->gid)
|
|
r->SendRaidLock();
|
|
else
|
|
r->SendRaidUnlock();
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
|
|
case ServerOP_RaidChangeGroup: {
|
|
ServerRaidGeneralAction_Struct* rga = (ServerRaidGeneralAction_Struct*)pack->pBuffer;
|
|
if (zone) {
|
|
if (rga->zoneid == zone->GetZoneID() && rga->instance_id == zone->GetInstanceID())
|
|
break;
|
|
|
|
Raid *r = entity_list.GetRaidByID(rga->rid);
|
|
if (r) {
|
|
r->LearnMembers();
|
|
r->VerifyRaid();
|
|
Client *c = entity_list.GetClientByName(rga->playername);
|
|
if (c) {
|
|
r->SendRaidDisband(c);
|
|
r->SendRaidRemoveAll(rga->playername);
|
|
r->SendRaidCreate(c);
|
|
r->SendMakeLeaderPacketTo(r->leadername, c);
|
|
r->SendBulkRaid(c);
|
|
r->SendRaidAddAll(rga->playername);
|
|
if (r->IsLocked()) { r->SendRaidLockTo(c); }
|
|
}
|
|
else {
|
|
r->SendRaidRemoveAll(rga->playername);
|
|
r->SendRaidAddAll(rga->playername);
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
|
|
case ServerOP_UpdateGroup: {
|
|
ServerRaidGeneralAction_Struct* rga = (ServerRaidGeneralAction_Struct*)pack->pBuffer;
|
|
if (zone) {
|
|
if (rga->zoneid == zone->GetZoneID() && rga->instance_id == zone->GetInstanceID())
|
|
break;
|
|
|
|
Raid *r = entity_list.GetRaidByID(rga->rid);
|
|
if (r) {
|
|
r->GroupUpdate(rga->gid, false);
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
|
|
case ServerOP_RaidGroupLeader: {
|
|
ServerRaidGeneralAction_Struct* rga = (ServerRaidGeneralAction_Struct*)pack->pBuffer;
|
|
if (zone) {
|
|
if (rga->zoneid == zone->GetZoneID() && rga->instance_id == zone->GetInstanceID())
|
|
break;
|
|
}
|
|
break;
|
|
}
|
|
|
|
case ServerOP_RaidLeader: {
|
|
ServerRaidGeneralAction_Struct* rga = (ServerRaidGeneralAction_Struct*)pack->pBuffer;
|
|
if (zone) {
|
|
if (rga->zoneid == zone->GetZoneID() && rga->instance_id == zone->GetInstanceID())
|
|
break;
|
|
|
|
Raid *r = entity_list.GetRaidByID(rga->rid);
|
|
if (r) {
|
|
Client *c = entity_list.GetClientByName(rga->playername);
|
|
strn0cpy(r->leadername, rga->playername, 64);
|
|
if (c) {
|
|
r->SetLeader(c);
|
|
}
|
|
r->LearnMembers();
|
|
r->VerifyRaid();
|
|
r->SendMakeLeaderPacket(rga->playername);
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
|
|
case ServerOP_DetailsChange: {
|
|
ServerRaidGeneralAction_Struct* rga = (ServerRaidGeneralAction_Struct*)pack->pBuffer;
|
|
if (zone) {
|
|
if (rga->zoneid == zone->GetZoneID() && rga->instance_id == zone->GetInstanceID())
|
|
break;
|
|
|
|
Raid *r = entity_list.GetRaidByID(rga->rid);
|
|
if (r) {
|
|
r->GetRaidDetails();
|
|
r->LearnMembers();
|
|
r->VerifyRaid();
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
|
|
case ServerOP_RaidGroupDisband: {
|
|
ServerRaidGeneralAction_Struct* rga = (ServerRaidGeneralAction_Struct*)pack->pBuffer;
|
|
if (zone) {
|
|
if (rga->zoneid == zone->GetZoneID() && rga->instance_id == zone->GetInstanceID())
|
|
break;
|
|
|
|
Client *c = entity_list.GetClientByName(rga->playername);
|
|
if (c)
|
|
{
|
|
auto outapp =
|
|
new EQApplicationPacket(OP_GroupUpdate, sizeof(GroupUpdate_Struct));
|
|
GroupUpdate_Struct* gu = (GroupUpdate_Struct*)outapp->pBuffer;
|
|
gu->action = groupActDisband;
|
|
strn0cpy(gu->leadersname, c->GetName(), 64);
|
|
strn0cpy(gu->yourname, c->GetName(), 64);
|
|
c->FastQueuePacket(&outapp);
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
|
|
case ServerOP_RaidGroupAdd: {
|
|
ServerRaidGroupAction_Struct* rga = (ServerRaidGroupAction_Struct*)pack->pBuffer;
|
|
if (zone) {
|
|
Raid *r = entity_list.GetRaidByID(rga->rid);
|
|
if (r) {
|
|
r->LearnMembers();
|
|
r->VerifyRaid();
|
|
auto outapp = new EQApplicationPacket(OP_GroupUpdate, sizeof(GroupJoin_Struct));
|
|
GroupJoin_Struct* gj = (GroupJoin_Struct*)outapp->pBuffer;
|
|
strn0cpy(gj->membername, rga->membername, 64);
|
|
gj->action = groupActJoin;
|
|
|
|
for (int x = 0; x < MAX_RAID_MEMBERS; x++)
|
|
{
|
|
if (r->members[x].member)
|
|
{
|
|
if (strcmp(r->members[x].member->GetName(), rga->membername) != 0) {
|
|
if ((rga->gid < 12) && rga->gid == r->members[x].GroupNumber)
|
|
{
|
|
strn0cpy(gj->yourname, r->members[x].member->GetName(), 64);
|
|
r->members[x].member->QueuePacket(outapp);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
safe_delete(outapp);
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
|
|
case ServerOP_RaidGroupRemove: {
|
|
ServerRaidGroupAction_Struct* rga = (ServerRaidGroupAction_Struct*)pack->pBuffer;
|
|
if (zone) {
|
|
Raid *r = entity_list.GetRaidByID(rga->rid);
|
|
if (r) {
|
|
r->LearnMembers();
|
|
r->VerifyRaid();
|
|
auto outapp = new EQApplicationPacket(OP_GroupUpdate, sizeof(GroupJoin_Struct));
|
|
GroupJoin_Struct* gj = (GroupJoin_Struct*)outapp->pBuffer;
|
|
strn0cpy(gj->membername, rga->membername, 64);
|
|
gj->action = groupActLeave;
|
|
|
|
for (int x = 0; x < MAX_RAID_MEMBERS; x++)
|
|
{
|
|
if (r->members[x].member)
|
|
{
|
|
if (strcmp(r->members[x].member->GetName(), rga->membername) != 0) {
|
|
if ((rga->gid < 12) && rga->gid == r->members[x].GroupNumber)
|
|
{
|
|
strn0cpy(gj->yourname, r->members[x].member->GetName(), 64);
|
|
r->members[x].member->QueuePacket(outapp);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
safe_delete(outapp);
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
|
|
case ServerOP_RaidGroupSay: {
|
|
ServerRaidMessage_Struct* rmsg = (ServerRaidMessage_Struct*)pack->pBuffer;
|
|
if (zone) {
|
|
Raid *r = entity_list.GetRaidByID(rmsg->rid);
|
|
if (r)
|
|
{
|
|
for (int x = 0; x < MAX_RAID_MEMBERS; x++)
|
|
{
|
|
if (r->members[x].member) {
|
|
if (strcmp(rmsg->from, r->members[x].member->GetName()) != 0)
|
|
{
|
|
if (r->members[x].GroupNumber == rmsg->gid) {
|
|
if (r->members[x].member->GetFilter(FilterGroupChat) != 0)
|
|
{
|
|
r->members[x].member->ChannelMessageSend(rmsg->from, r->members[x].member->GetName(), ChatChannel_Group, rmsg->language, rmsg->lang_skill, rmsg->message);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
|
|
case ServerOP_RaidSay: {
|
|
ServerRaidMessage_Struct* rmsg = (ServerRaidMessage_Struct*)pack->pBuffer;
|
|
if (zone)
|
|
{
|
|
Raid *r = entity_list.GetRaidByID(rmsg->rid);
|
|
if (r)
|
|
{
|
|
for (int x = 0; x < MAX_RAID_MEMBERS; x++)
|
|
{
|
|
if (r->members[x].member) {
|
|
if (strcmp(rmsg->from, r->members[x].member->GetName()) != 0)
|
|
{
|
|
if (r->members[x].member->GetFilter(FilterGroupChat) != 0)
|
|
{
|
|
r->members[x].member->ChannelMessageSend(rmsg->from, r->members[x].member->GetName(), ChatChannel_Raid, rmsg->language, rmsg->lang_skill, rmsg->message);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
|
|
case ServerOP_RaidMOTD: {
|
|
ServerRaidMOTD_Struct *rmotd = (ServerRaidMOTD_Struct *)pack->pBuffer;
|
|
if (!zone)
|
|
break;
|
|
Raid *r = entity_list.GetRaidByID(rmotd->rid);
|
|
if (!r)
|
|
break;
|
|
r->SetRaidMOTD(std::string(rmotd->motd));
|
|
r->SendRaidMOTD();
|
|
break;
|
|
}
|
|
|
|
case ServerOP_SpawnPlayerCorpse: {
|
|
SpawnPlayerCorpse_Struct* s = (SpawnPlayerCorpse_Struct*)pack->pBuffer;
|
|
Corpse* NewCorpse = database.LoadCharacterCorpse(s->player_corpse_id);
|
|
if (NewCorpse)
|
|
NewCorpse->Spawn();
|
|
else
|
|
LogError("Unable to load player corpse id [{}] for zone [{}]", s->player_corpse_id, zone->GetShortName());
|
|
|
|
break;
|
|
}
|
|
case ServerOP_Consent: {
|
|
ServerOP_Consent_Struct* s = (ServerOP_Consent_Struct*)pack->pBuffer;
|
|
|
|
bool found_corpse = false;
|
|
for (auto const& it : entity_list.GetCorpseList()) {
|
|
if (it.second->IsPlayerCorpse() && strcmp(it.second->GetOwnerName(), s->ownername) == 0) {
|
|
if (s->consent_type == EQ::consent::Normal) {
|
|
if (s->permission == 1) {
|
|
it.second->AddConsentName(s->grantname);
|
|
}
|
|
else {
|
|
it.second->RemoveConsentName(s->grantname);
|
|
}
|
|
}
|
|
else if (s->consent_type == EQ::consent::Group) {
|
|
it.second->SetConsentGroupID(s->consent_id);
|
|
}
|
|
else if (s->consent_type == EQ::consent::Raid) {
|
|
it.second->SetConsentRaidID(s->consent_id);
|
|
}
|
|
else if (s->consent_type == EQ::consent::Guild) {
|
|
it.second->SetConsentGuildID(s->consent_id);
|
|
}
|
|
found_corpse = true;
|
|
}
|
|
}
|
|
|
|
if (found_corpse) {
|
|
// 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);
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_Consent_Response: {
|
|
ServerOP_Consent_Struct* s = (ServerOP_Consent_Struct*)pack->pBuffer;
|
|
Client* owner_client = entity_list.GetClientByName(s->ownername);
|
|
Client* grant_client = nullptr;
|
|
if (s->consent_type == EQ::consent::Normal) {
|
|
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
|
|
}
|
|
if (grant_client) {
|
|
grant_client->QueuePacket(outapp); // message to the client being granted/denied
|
|
}
|
|
safe_delete(outapp);
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_ReloadTasks: {
|
|
if (RuleB(Tasks, EnableTaskSystem)) {
|
|
HandleReloadTasks(pack);
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_LFGMatches: {
|
|
HandleLFGMatches(pack);
|
|
break;
|
|
}
|
|
case ServerOP_LFPMatches: {
|
|
HandleLFPMatches(pack);
|
|
break;
|
|
}
|
|
|
|
case ServerOP_UpdateSpawn: {
|
|
if (zone)
|
|
{
|
|
UpdateSpawnTimer_Struct *ust = (UpdateSpawnTimer_Struct*)pack->pBuffer;
|
|
LinkedListIterator<Spawn2*> iterator(zone->spawn2_list);
|
|
iterator.Reset();
|
|
while (iterator.MoreElements())
|
|
{
|
|
if (iterator.GetData()->GetID() == ust->id)
|
|
{
|
|
if (!iterator.GetData()->NPCPointerValid())
|
|
{
|
|
iterator.GetData()->SetTimer(ust->duration);
|
|
}
|
|
break;
|
|
}
|
|
iterator.Advance();
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
|
|
case ServerOP_InstanceUpdateTime:
|
|
{
|
|
ServerInstanceUpdateTime_Struct *iut = (ServerInstanceUpdateTime_Struct*)pack->pBuffer;
|
|
if (zone)
|
|
{
|
|
if (zone->GetInstanceID() == iut->instance_id)
|
|
{
|
|
zone->SetInstanceTimer(iut->new_duration);
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
|
|
case ServerOP_DepopAllPlayersCorpses:
|
|
{
|
|
ServerDepopAllPlayersCorpses_Struct *sdapcs = (ServerDepopAllPlayersCorpses_Struct *)pack->pBuffer;
|
|
|
|
if (zone && !((zone->GetZoneID() == sdapcs->ZoneID) && (zone->GetInstanceID() == sdapcs->InstanceID)))
|
|
entity_list.RemoveAllCorpsesByCharID(sdapcs->CharacterID);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case ServerOP_DepopPlayerCorpse:
|
|
{
|
|
ServerDepopPlayerCorpse_Struct *sdpcs = (ServerDepopPlayerCorpse_Struct *)pack->pBuffer;
|
|
|
|
if (zone && !((zone->GetZoneID() == sdpcs->ZoneID) && (zone->GetInstanceID() == sdpcs->InstanceID)))
|
|
entity_list.RemoveCorpseByDBID(sdpcs->DBID);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case ServerOP_ReloadTitles:
|
|
{
|
|
title_manager.LoadTitles();
|
|
break;
|
|
}
|
|
|
|
case ServerOP_SpawnStatusChange:
|
|
{
|
|
if (zone)
|
|
{
|
|
ServerSpawnStatusChange_Struct *ssc = (ServerSpawnStatusChange_Struct*)pack->pBuffer;
|
|
LinkedListIterator<Spawn2*> iterator(zone->spawn2_list);
|
|
iterator.Reset();
|
|
Spawn2 *found_spawn = nullptr;
|
|
while (iterator.MoreElements())
|
|
{
|
|
Spawn2* cur = iterator.GetData();
|
|
if (cur->GetID() == ssc->id)
|
|
{
|
|
found_spawn = cur;
|
|
break;
|
|
}
|
|
iterator.Advance();
|
|
}
|
|
|
|
if (found_spawn)
|
|
{
|
|
if (ssc->new_status == 0)
|
|
{
|
|
found_spawn->Disable();
|
|
}
|
|
else
|
|
{
|
|
found_spawn->Enable();
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
|
|
case ServerOP_QGlobalUpdate:
|
|
{
|
|
if (pack->size != sizeof(ServerQGlobalUpdate_Struct))
|
|
{
|
|
break;
|
|
}
|
|
|
|
if (zone)
|
|
{
|
|
ServerQGlobalUpdate_Struct *qgu = (ServerQGlobalUpdate_Struct*)pack->pBuffer;
|
|
if (qgu->from_zone_id != zone->GetZoneID() || qgu->from_instance_id != zone->GetInstanceID())
|
|
{
|
|
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;
|
|
}
|
|
|
|
case ServerOP_QGlobalDelete:
|
|
{
|
|
if (pack->size != sizeof(ServerQGlobalDelete_Struct))
|
|
{
|
|
break;
|
|
}
|
|
|
|
if (zone)
|
|
{
|
|
ServerQGlobalDelete_Struct *qgd = (ServerQGlobalDelete_Struct*)pack->pBuffer;
|
|
if (qgd->from_zone_id != zone->GetZoneID() || qgd->from_instance_id != zone->GetInstanceID())
|
|
{
|
|
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);
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
|
|
case ServerOP_AdventureRequestAccept:
|
|
{
|
|
ServerAdventureRequestAccept_Struct *ars = (ServerAdventureRequestAccept_Struct*)pack->pBuffer;
|
|
Client *c = entity_list.GetClientByName(ars->leader);
|
|
if (c)
|
|
{
|
|
c->NewAdventure(ars->id, ars->theme, ars->text, ars->member_count, (const char*)(pack->pBuffer + sizeof(ServerAdventureRequestAccept_Struct)));
|
|
c->ClearPendingAdventureRequest();
|
|
}
|
|
break;
|
|
}
|
|
|
|
case ServerOP_AdventureRequestDeny:
|
|
{
|
|
ServerAdventureRequestDeny_Struct *ars = (ServerAdventureRequestDeny_Struct*)pack->pBuffer;
|
|
Client *c = entity_list.GetClientByName(ars->leader);
|
|
if (c)
|
|
{
|
|
c->SendAdventureError(ars->reason);
|
|
c->ClearPendingAdventureRequest();
|
|
}
|
|
break;
|
|
}
|
|
|
|
case ServerOP_AdventureCreateDeny:
|
|
{
|
|
Client *c = entity_list.GetClientByName((const char*)pack->pBuffer);
|
|
if (c)
|
|
{
|
|
c->ClearPendingAdventureData();
|
|
c->ClearPendingAdventureCreate();
|
|
}
|
|
break;
|
|
}
|
|
|
|
case ServerOP_AdventureData:
|
|
{
|
|
Client *c = entity_list.GetClientByName((const char*)pack->pBuffer);
|
|
if (c)
|
|
{
|
|
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;
|
|
}
|
|
|
|
case ServerOP_AdventureDataClear:
|
|
{
|
|
Client *c = entity_list.GetClientByName((const char*)pack->pBuffer);
|
|
if (c)
|
|
{
|
|
if (c->HasAdventureData())
|
|
{
|
|
c->ClearAdventureData();
|
|
c->SendAdventureError("You are not currently assigned to an adventure.");
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
|
|
case ServerOP_AdventureClickDoorReply:
|
|
{
|
|
ServerPlayerClickedAdventureDoorReply_Struct *adr = (ServerPlayerClickedAdventureDoorReply_Struct*)pack->pBuffer;
|
|
Client *c = entity_list.GetClientByName(adr->player);
|
|
if (c)
|
|
{
|
|
c->ClearPendingAdventureDoorClick();
|
|
c->MovePC(adr->zone_id, adr->instance_id, adr->x, adr->y, adr->z, adr->h, 0);
|
|
}
|
|
break;
|
|
}
|
|
|
|
case ServerOP_AdventureClickDoorError:
|
|
{
|
|
Client *c = entity_list.GetClientByName((const char*)pack->pBuffer);
|
|
if (c)
|
|
{
|
|
c->ClearPendingAdventureDoorClick();
|
|
c->MessageString(Chat::Red, 5141);
|
|
}
|
|
break;
|
|
}
|
|
|
|
case ServerOP_AdventureLeaveReply:
|
|
{
|
|
Client *c = entity_list.GetClientByName((const char*)pack->pBuffer);
|
|
if (c)
|
|
{
|
|
c->ClearPendingAdventureLeave();
|
|
c->ClearCurrentAdventure();
|
|
}
|
|
break;
|
|
}
|
|
|
|
case ServerOP_AdventureLeaveDeny:
|
|
{
|
|
Client *c = entity_list.GetClientByName((const char*)pack->pBuffer);
|
|
if (c)
|
|
{
|
|
c->ClearPendingAdventureLeave();
|
|
c->Message(Chat::Red, "You cannot leave this adventure at this time.");
|
|
}
|
|
break;
|
|
}
|
|
|
|
case ServerOP_AdventureCountUpdate:
|
|
{
|
|
ServerAdventureCountUpdate_Struct *ac = (ServerAdventureCountUpdate_Struct*)pack->pBuffer;
|
|
Client *c = entity_list.GetClientByName(ac->player);
|
|
if (c)
|
|
{
|
|
c->SendAdventureCount(ac->count, ac->total);
|
|
}
|
|
break;
|
|
}
|
|
|
|
case ServerOP_AdventureZoneData:
|
|
{
|
|
if (zone)
|
|
{
|
|
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;
|
|
}
|
|
break;
|
|
}
|
|
|
|
case ServerOP_AdventureFinish:
|
|
{
|
|
ServerAdventureFinish_Struct *af = (ServerAdventureFinish_Struct*)pack->pBuffer;
|
|
Client *c = entity_list.GetClientByName(af->player);
|
|
if (c)
|
|
{
|
|
c->AdventureFinish(af->win, af->theme, af->points);
|
|
}
|
|
break;
|
|
}
|
|
|
|
case ServerOP_AdventureLeaderboard:
|
|
{
|
|
Client *c = entity_list.GetClientByName((const char*)pack->pBuffer);
|
|
if (c)
|
|
{
|
|
auto outapp = new EQApplicationPacket(OP_AdventureLeaderboardReply,
|
|
sizeof(AdventureLeaderboard_Struct));
|
|
memcpy(outapp->pBuffer, pack->pBuffer + 64, sizeof(AdventureLeaderboard_Struct));
|
|
c->FastQueuePacket(&outapp);
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_ReloadRules: {
|
|
worldserver.SendEmoteMessage(
|
|
0, 0, 100, 15,
|
|
"Rules reloaded for Zone: '%s' Instance ID: %u",
|
|
(zone ? zone->GetLongName() : StringFormat("Null zone pointer [pid]:[%i]", getpid()).c_str()),
|
|
(zone ? zone->GetInstanceID() : 0xFFFFFFFFF)
|
|
);
|
|
RuleManager::Instance()->LoadRules(&database, RuleManager::Instance()->GetActiveRuleset(), true);
|
|
break;
|
|
}
|
|
case ServerOP_ReloadLogs: {
|
|
LogSys.LoadLogDatabaseSettings();
|
|
break;
|
|
}
|
|
case ServerOP_ReloadPerlExportSettings: {
|
|
parse->LoadPerlEventExportSettings(parse->perl_event_export_settings);
|
|
break;
|
|
}
|
|
case ServerOP_CameraShake:
|
|
{
|
|
if (zone)
|
|
{
|
|
ServerCameraShake_Struct *scss = (ServerCameraShake_Struct*)pack->pBuffer;
|
|
entity_list.CameraEffect(scss->duration, scss->intensity);
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_QueryServGeneric:
|
|
{
|
|
pack->SetReadPosition(8);
|
|
char From[64];
|
|
pack->ReadString(From);
|
|
|
|
Client *c = entity_list.GetClientByName(From);
|
|
|
|
if (!c)
|
|
return;
|
|
|
|
uint32 Type = pack->ReadUInt32();;
|
|
|
|
switch (Type)
|
|
{
|
|
case QSG_LFGuild:
|
|
{
|
|
c->HandleLFGuildResponse(pack);
|
|
break;
|
|
}
|
|
|
|
default:
|
|
break;
|
|
}
|
|
|
|
break;
|
|
}
|
|
case ServerOP_UCSServerStatusReply:
|
|
{
|
|
auto ucsss = (UCSServerStatus_Struct *) pack->pBuffer;
|
|
if (zone) {
|
|
zone->SetUCSServerAvailable((ucsss->available != 0), ucsss->timestamp);
|
|
LogInfo("UCS Server is now [{}]", (ucsss->available == 1 ? "online" : "offline"));
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_CZCastSpellPlayer:
|
|
{
|
|
CZCastSpellPlayer_Struct* CZSC = (CZCastSpellPlayer_Struct*) pack->pBuffer;
|
|
Client* client = entity_list.GetClientByCharID(CZSC->character_id);
|
|
if (client) {
|
|
client->SpellFinished(CZSC->spell_id, client);
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_CZCastSpellGroup:
|
|
{
|
|
CZCastSpellGroup_Struct* CZSC = (CZCastSpellGroup_Struct*) pack->pBuffer;
|
|
auto client_group = entity_list.GetGroupByID(CZSC->group_id);
|
|
if (client_group) {
|
|
for (int member_index = 0; member_index < MAX_GROUP_MEMBERS; member_index++) {
|
|
if (client_group->members[member_index] && client_group->members[member_index]->IsClient()) {
|
|
auto group_member = client_group->members[member_index]->CastToClient();
|
|
group_member->SpellFinished(CZSC->spell_id, group_member);
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_CZCastSpellRaid:
|
|
{
|
|
CZCastSpellRaid_Struct* CZSC = (CZCastSpellRaid_Struct*) pack->pBuffer;
|
|
auto client_raid = entity_list.GetRaidByID(CZSC->raid_id);
|
|
if (client_raid) {
|
|
for (int member_index = 0; member_index < MAX_RAID_MEMBERS; member_index++) {
|
|
if (client_raid->members[member_index].member && client_raid->members[member_index].member->IsClient()) {
|
|
auto raid_member = client_raid->members[member_index].member->CastToClient();
|
|
raid_member->SpellFinished(CZSC->spell_id, raid_member);
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_CZCastSpellGuild:
|
|
{
|
|
CZCastSpellGuild_Struct* CZSC = (CZCastSpellGuild_Struct*) pack->pBuffer;
|
|
for (auto &client : entity_list.GetClientList()) {
|
|
if (client.second->GuildID() > 0 && client.second->GuildID() == CZSC->guild_id) {
|
|
client.second->SpellFinished(CZSC->spell_id, client.second);
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_CZLDoNUpdate:
|
|
{
|
|
CZLDoNUpdate_Struct* CZLU = (CZLDoNUpdate_Struct*) pack->pBuffer;
|
|
uint8 update_type = CZLU->update_type;
|
|
uint8 update_subtype = CZLU->update_subtype;
|
|
int update_identifier = CZLU->update_identifier;
|
|
uint32 theme_id = CZLU->theme_id;
|
|
int points = CZLU->points;
|
|
if (update_type == CZLDoNUpdateType_Character) {
|
|
auto client = entity_list.GetClientByCharID(update_identifier);
|
|
if (client) {
|
|
switch (update_subtype) {
|
|
case CZLDoNUpdateSubtype_Loss:
|
|
client->AddLDoNLoss(theme_id);
|
|
break;
|
|
case CZLDoNUpdateSubtype_Points:
|
|
client->UpdateLDoNPoints(theme_id, points);
|
|
break;
|
|
case CZLDoNUpdateSubtype_Win:
|
|
client->AddLDoNWin(theme_id);
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
break;
|
|
} else if (update_type == CZLDoNUpdateType_Group) {
|
|
auto client_group = entity_list.GetGroupByID(update_identifier);
|
|
if (client_group) {
|
|
for (int member_index = 0; member_index < MAX_GROUP_MEMBERS; member_index++) {
|
|
if (client_group->members[member_index] && client_group->members[member_index]->IsClient()) {
|
|
auto client_group_member = client_group->members[member_index]->CastToClient();
|
|
switch (update_subtype) {
|
|
case CZLDoNUpdateSubtype_Loss:
|
|
client_group_member->AddLDoNLoss(theme_id);
|
|
break;
|
|
case CZLDoNUpdateSubtype_Points:
|
|
client_group_member->UpdateLDoNPoints(theme_id, points);
|
|
break;
|
|
case CZLDoNUpdateSubtype_Win:
|
|
client_group_member->AddLDoNWin(theme_id);
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} else if (update_type == CZLDoNUpdateType_Raid) {
|
|
auto client_raid = entity_list.GetRaidByID(update_identifier);
|
|
if (client_raid) {
|
|
for (int member_index = 0; member_index < MAX_RAID_MEMBERS; member_index++) {
|
|
auto client_raid_member = client_raid->members[member_index].member;
|
|
if (client_raid_member && client_raid_member->IsClient()) {
|
|
switch (update_subtype) {
|
|
case CZLDoNUpdateSubtype_Loss:
|
|
client_raid_member->AddLDoNLoss(theme_id);
|
|
break;
|
|
case CZLDoNUpdateSubtype_Points:
|
|
client_raid_member->UpdateLDoNPoints(theme_id, points);
|
|
break;
|
|
case CZLDoNUpdateSubtype_Win:
|
|
client_raid_member->AddLDoNWin(theme_id);
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} else if (update_type == CZLDoNUpdateType_Guild) {
|
|
for (auto &client : entity_list.GetClientList()) {
|
|
if (client.second->GuildID() > 0 && client.second->GuildID() == update_identifier) {
|
|
switch (update_subtype) {
|
|
case CZLDoNUpdateSubtype_Loss:
|
|
client.second->AddLDoNLoss(theme_id);
|
|
break;
|
|
case CZLDoNUpdateSubtype_Points:
|
|
client.second->UpdateLDoNPoints(theme_id, points);
|
|
break;
|
|
case CZLDoNUpdateSubtype_Win:
|
|
client.second->AddLDoNWin(theme_id);
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
} else if (update_type == CZLDoNUpdateType_Expedition) {
|
|
for (auto &client : entity_list.GetClientList()) {
|
|
if (client.second->GetExpedition() && client.second->GetExpedition()->GetID() == update_identifier) {
|
|
switch (update_subtype) {
|
|
case CZLDoNUpdateSubtype_Loss:
|
|
client.second->AddLDoNLoss(theme_id);
|
|
break;
|
|
case CZLDoNUpdateSubtype_Points:
|
|
client.second->UpdateLDoNPoints(theme_id, points);
|
|
break;
|
|
case CZLDoNUpdateSubtype_Win:
|
|
client.second->AddLDoNWin(theme_id);
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_CZMarqueePlayer:
|
|
{
|
|
CZMarqueePlayer_Struct* CZMS = (CZMarqueePlayer_Struct*) pack->pBuffer;
|
|
auto client = entity_list.GetClientByCharID(CZMS->character_id);
|
|
std::string message = CZMS->message;
|
|
if (client) {
|
|
client->SendMarqueeMessage(CZMS->type, CZMS->priority, CZMS->fade_in, CZMS->fade_out, CZMS->duration, message);
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_CZMarqueeGroup:
|
|
{
|
|
CZMarqueeGroup_Struct* CZMS = (CZMarqueeGroup_Struct*) pack->pBuffer;
|
|
auto client_group = entity_list.GetGroupByID(CZMS->group_id);
|
|
std::string message = CZMS->message;
|
|
if (client_group) {
|
|
for (int member_index = 0; member_index < MAX_GROUP_MEMBERS; member_index++) {
|
|
if (client_group->members[member_index] && client_group->members[member_index]->IsClient()) {
|
|
auto group_member = client_group->members[member_index]->CastToClient();
|
|
group_member->SendMarqueeMessage(CZMS->type, CZMS->priority, CZMS->fade_in, CZMS->fade_out, CZMS->duration, message);
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_CZMarqueeRaid:
|
|
{
|
|
CZMarqueeRaid_Struct* CZMS = (CZMarqueeRaid_Struct*) pack->pBuffer;
|
|
auto client_raid = entity_list.GetRaidByID(CZMS->raid_id);
|
|
std::string message = CZMS->message;
|
|
if (client_raid) {
|
|
for (int member_index = 0; member_index < MAX_RAID_MEMBERS; member_index++) {
|
|
if (client_raid->members[member_index].member && client_raid->members[member_index].member->IsClient()) {
|
|
auto raid_member = client_raid->members[member_index].member->CastToClient();
|
|
raid_member->SendMarqueeMessage(CZMS->type, CZMS->priority, CZMS->fade_in, CZMS->fade_out, CZMS->duration, message);
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_CZMarqueeGuild:
|
|
{
|
|
CZMarqueeGuild_Struct* CZMS = (CZMarqueeGuild_Struct*) pack->pBuffer;
|
|
std::string message = CZMS->message;
|
|
for (auto &client : entity_list.GetClientList()) {
|
|
if (client.second->GuildID() > 0 && client.second->GuildID() == CZMS->guild_id) {
|
|
client.second->SendMarqueeMessage(CZMS->type, CZMS->priority, CZMS->fade_in, CZMS->fade_out, CZMS->duration, message);
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_CZMessagePlayer:
|
|
{
|
|
CZMessagePlayer_Struct* CZCS = (CZMessagePlayer_Struct*) pack->pBuffer;
|
|
auto client = entity_list.GetClientByName(CZCS->character_name);
|
|
if (client) {
|
|
client->Message(CZCS->type, CZCS->message);
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_CZMessageGroup:
|
|
{
|
|
CZMessageGroup_Struct* CZGM = (CZMessageGroup_Struct*) pack->pBuffer;
|
|
auto client_group = entity_list.GetGroupByID(CZGM->group_id);
|
|
if (client_group) {
|
|
for (int member_index = 0; member_index < MAX_GROUP_MEMBERS; member_index++) {
|
|
if (client_group->members[member_index] && client_group->members[member_index]->IsClient()) {
|
|
auto group_member = client_group->members[member_index]->CastToClient();
|
|
group_member->Message(CZGM->type, CZGM->message);
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_CZMessageRaid:
|
|
{
|
|
CZMessageRaid_Struct* CZRM = (CZMessageRaid_Struct*) pack->pBuffer;
|
|
auto client_raid = entity_list.GetRaidByID(CZRM->raid_id);
|
|
if (client_raid) {
|
|
for (int member_index = 0; member_index < MAX_RAID_MEMBERS; member_index++) {
|
|
if (client_raid->members[member_index].member && client_raid->members[member_index].member->IsClient()) {
|
|
auto raid_member = client_raid->members[member_index].member->CastToClient();
|
|
raid_member->Message(CZRM->type, CZRM->message);
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_CZMessageGuild:
|
|
{
|
|
CZMessageGuild_Struct* CZGM = (CZMessageGuild_Struct*) pack->pBuffer;
|
|
for (auto &client : entity_list.GetClientList()) {
|
|
if (client.second->GuildID() > 0 && client.second->GuildID() == CZGM->guild_id) {
|
|
client.second->Message(CZGM->type, CZGM->message);
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_CZMovePlayer:
|
|
{
|
|
CZMovePlayer_Struct* CZMP = (CZMovePlayer_Struct*) pack->pBuffer;
|
|
auto client = entity_list.GetClientByCharID(CZMP->character_id);
|
|
if (client) {
|
|
client->MoveZone(CZMP->zone_short_name);
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_CZMoveGroup:
|
|
{
|
|
CZMoveGroup_Struct* CZMG = (CZMoveGroup_Struct*) pack->pBuffer;
|
|
auto client_group = entity_list.GetGroupByID(CZMG->group_id);
|
|
if (client_group) {
|
|
for (int member_index = 0; member_index < MAX_GROUP_MEMBERS; member_index++) {
|
|
if (client_group->members[member_index] && client_group->members[member_index]->IsClient()) {
|
|
auto group_member = client_group->members[member_index]->CastToClient();
|
|
group_member->MoveZone(CZMG->zone_short_name);
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_CZMoveRaid:
|
|
{
|
|
CZMoveRaid_Struct* CZMR = (CZMoveRaid_Struct*) pack->pBuffer;
|
|
auto client_raid = entity_list.GetRaidByID(CZMR->raid_id);
|
|
if (client_raid) {
|
|
for (int member_index = 0; member_index < MAX_RAID_MEMBERS; member_index++) {
|
|
if (client_raid->members[member_index].member && client_raid->members[member_index].member->IsClient()) {
|
|
auto raid_member = client_raid->members[member_index].member->CastToClient();
|
|
raid_member->MoveZone(CZMR->zone_short_name);
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_CZMoveGuild:
|
|
{
|
|
CZMoveGuild_Struct* CZMG = (CZMoveGuild_Struct*) pack->pBuffer;
|
|
for (auto &client : entity_list.GetClientList()) {
|
|
if (client.second->GuildID() > 0 && client.second->GuildID() == CZMG->guild_id) {
|
|
client.second->MoveZone(CZMG->zone_short_name);
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
|
|
case ServerOP_CZMoveInstancePlayer:
|
|
{
|
|
CZMoveInstancePlayer_Struct* CZMP = (CZMoveInstancePlayer_Struct*) pack->pBuffer;
|
|
auto client = entity_list.GetClientByCharID(CZMP->character_id);
|
|
if (client) {
|
|
client->MoveZoneInstance(CZMP->instance_id);
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_CZMoveInstanceGroup:
|
|
{
|
|
CZMoveInstanceGroup_Struct* CZMG = (CZMoveInstanceGroup_Struct*) pack->pBuffer;
|
|
auto client_group = entity_list.GetGroupByID(CZMG->group_id);
|
|
if (client_group) {
|
|
for (int member_index = 0; member_index < MAX_GROUP_MEMBERS; member_index++) {
|
|
if (client_group->members[member_index] && client_group->members[member_index]->IsClient()) {
|
|
auto group_member = client_group->members[member_index]->CastToClient();
|
|
group_member->MoveZoneInstance(CZMG->instance_id);
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_CZMoveInstanceRaid:
|
|
{
|
|
CZMoveInstanceRaid_Struct* CZMR = (CZMoveInstanceRaid_Struct*) pack->pBuffer;
|
|
auto client_raid = entity_list.GetRaidByID(CZMR->raid_id);
|
|
if (client_raid) {
|
|
for (int member_index = 0; member_index < MAX_RAID_MEMBERS; member_index++) {
|
|
if (client_raid->members[member_index].member && client_raid->members[member_index].member->IsClient()) {
|
|
auto raid_member = client_raid->members[member_index].member->CastToClient();
|
|
raid_member->MoveZoneInstance(CZMR->instance_id);
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_CZMoveInstanceGuild:
|
|
{
|
|
CZMoveInstanceGuild_Struct* CZMG = (CZMoveInstanceGuild_Struct*) pack->pBuffer;
|
|
for (auto &client : entity_list.GetClientList()) {
|
|
if (client.second->GuildID() > 0 && client.second->GuildID() == CZMG->guild_id) {
|
|
client.second->MoveZoneInstance(CZMG->instance_id);
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_CZRemoveSpellPlayer:
|
|
{
|
|
CZRemoveSpellPlayer_Struct* CZRS = (CZRemoveSpellPlayer_Struct*) pack->pBuffer;
|
|
auto client = entity_list.GetClientByCharID(CZRS->character_id);
|
|
if (client) {
|
|
client->BuffFadeBySpellID(CZRS->spell_id);
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_CZRemoveSpellGroup:
|
|
{
|
|
CZRemoveSpellGroup_Struct* CZRS = (CZRemoveSpellGroup_Struct*) pack->pBuffer;
|
|
auto client_group = entity_list.GetGroupByID(CZRS->group_id);
|
|
if (client_group) {
|
|
for (int member_index = 0; member_index < MAX_GROUP_MEMBERS; member_index++) {
|
|
if (client_group->members[member_index] && client_group->members[member_index]->IsClient()) {
|
|
auto group_member = client_group->members[member_index]->CastToClient();
|
|
group_member->BuffFadeBySpellID(CZRS->spell_id);
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_CZRemoveSpellRaid:
|
|
{
|
|
CZRemoveSpellRaid_Struct* CZRS = (CZRemoveSpellRaid_Struct*) pack->pBuffer;
|
|
auto client_raid = entity_list.GetRaidByID(CZRS->raid_id);
|
|
if (client_raid) {
|
|
for (int member_index = 0; member_index < MAX_RAID_MEMBERS; member_index++) {
|
|
if (client_raid->members[member_index].member && client_raid->members[member_index].member->IsClient()) {
|
|
auto raid_member = client_raid->members[member_index].member->CastToClient();
|
|
raid_member->BuffFadeBySpellID(CZRS->spell_id);
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_CZRemoveSpellGuild:
|
|
{
|
|
CZRemoveSpellGuild_Struct* CZRS = (CZRemoveSpellGuild_Struct*) pack->pBuffer;
|
|
for (auto &client : entity_list.GetClientList()) {
|
|
if (client.second->GuildID() > 0 && client.second->GuildID() == CZRS->guild_id) {
|
|
client.second->BuffFadeBySpellID(CZRS->spell_id);
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_CZSetEntityVariableByClientName:
|
|
{
|
|
CZSetEntVarByClientName_Struct* CZCS = (CZSetEntVarByClientName_Struct*) pack->pBuffer;
|
|
auto client = entity_list.GetClientByName(CZCS->character_name);
|
|
if (client) {
|
|
client->SetEntityVariable(CZCS->variable_name, CZCS->variable_value);
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_CZSetEntityVariableByGroupID:
|
|
{
|
|
CZSetEntVarByGroupID_Struct* CZCS = (CZSetEntVarByGroupID_Struct*) pack->pBuffer;
|
|
auto client_group = entity_list.GetGroupByID(CZCS->group_id);
|
|
if (client_group) {
|
|
for (int member_index = 0; member_index < MAX_GROUP_MEMBERS; member_index++) {
|
|
if (client_group->members[member_index] && client_group->members[member_index]->IsClient()) {
|
|
auto group_member = client_group->members[member_index]->CastToClient();
|
|
group_member->SetEntityVariable(CZCS->variable_name, CZCS->variable_value);
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_CZSetEntityVariableByRaidID:
|
|
{
|
|
CZSetEntVarByRaidID_Struct* CZCS = (CZSetEntVarByRaidID_Struct*) pack->pBuffer;
|
|
auto client_raid = entity_list.GetRaidByID(CZCS->raid_id);
|
|
if (client_raid) {
|
|
for (int member_index = 0; member_index < MAX_RAID_MEMBERS; member_index++) {
|
|
if (client_raid->members[member_index].member && client_raid->members[member_index].member->IsClient()) {
|
|
auto raid_member = client_raid->members[member_index].member->CastToClient();
|
|
raid_member->SetEntityVariable(CZCS->variable_name, CZCS->variable_value);
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_CZSetEntityVariableByGuildID:
|
|
{
|
|
CZSetEntVarByGuildID_Struct* CZCS = (CZSetEntVarByGuildID_Struct*) pack->pBuffer;
|
|
for (auto &client : entity_list.GetClientList()) {
|
|
if (client.second->GuildID() > 0 && client.second->GuildID() == CZCS->guild_id) {
|
|
client.second->SetEntityVariable(CZCS->variable_name, CZCS->variable_value);
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_CZSetEntityVariableByNPCTypeID:
|
|
{
|
|
CZSetEntVarByNPCTypeID_Struct* CZM = (CZSetEntVarByNPCTypeID_Struct*) pack->pBuffer;
|
|
auto npc = entity_list.GetNPCByNPCTypeID(CZM->npctype_id);
|
|
if (npc != 0) {
|
|
npc->SetEntityVariable(CZM->variable_name, CZM->variable_value);
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_CZSignalNPC:
|
|
{
|
|
CZNPCSignal_Struct* CZCN = (CZNPCSignal_Struct*) pack->pBuffer;
|
|
auto npc = entity_list.GetNPCByNPCTypeID(CZCN->npctype_id);
|
|
if (npc != 0) {
|
|
npc->SignalNPC(CZCN->signal);
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_CZSignalClient:
|
|
{
|
|
CZClientSignal_Struct* CZCS = (CZClientSignal_Struct*) pack->pBuffer;
|
|
auto client = entity_list.GetClientByCharID(CZCS->character_id);
|
|
if (client) {
|
|
client->Signal(CZCS->signal);
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_CZSignalGroup:
|
|
{
|
|
CZGroupSignal_Struct* CZGS = (CZGroupSignal_Struct*) pack->pBuffer;
|
|
auto client_group = entity_list.GetGroupByID(CZGS->group_id);
|
|
if (client_group) {
|
|
for (int member_index = 0; member_index < MAX_GROUP_MEMBERS; member_index++) {
|
|
if (client_group->members[member_index] && client_group->members[member_index]->IsClient()) {
|
|
auto group_member = client_group->members[member_index]->CastToClient();
|
|
group_member->Signal(CZGS->signal);
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_CZSignalRaid:
|
|
{
|
|
CZRaidSignal_Struct* CZRS = (CZRaidSignal_Struct*) pack->pBuffer;
|
|
auto client_raid = entity_list.GetRaidByID(CZRS->raid_id);
|
|
if (client_raid) {
|
|
for (int member_index = 0; member_index < MAX_RAID_MEMBERS; member_index++) {
|
|
if (client_raid->members[member_index].member && client_raid->members[member_index].member->IsClient()) {
|
|
auto raid_member = client_raid->members[member_index].member->CastToClient();
|
|
raid_member->Signal(CZRS->signal);
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_CZSignalGuild:
|
|
{
|
|
CZGuildSignal_Struct* CZGS = (CZGuildSignal_Struct*) pack->pBuffer;
|
|
for (auto &client : entity_list.GetClientList()) {
|
|
if (client.second->GuildID() > 0 && client.second->GuildID() == CZGS->guild_id) {
|
|
client.second->Signal(CZGS->signal);
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_CZSignalClientByName:
|
|
{
|
|
CZClientSignalByName_Struct* CZCS = (CZClientSignalByName_Struct*) pack->pBuffer;
|
|
auto client = entity_list.GetClientByName(CZCS->character_name);
|
|
if (client) {
|
|
client->Signal(CZCS->signal);
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_CZTaskAssignPlayer:
|
|
{
|
|
CZTaskAssignPlayer_Struct* CZTA = (CZTaskAssignPlayer_Struct*) pack->pBuffer;
|
|
auto client = entity_list.GetClientByCharID(CZTA->character_id);
|
|
if (client) {
|
|
client->AssignTask(CZTA->task_id, CZTA->npc_entity_id, CZTA->enforce_level_requirement);
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_CZTaskAssignGroup:
|
|
{
|
|
CZTaskAssignGroup_Struct* CZTA = (CZTaskAssignGroup_Struct*) pack->pBuffer;
|
|
auto client_group = entity_list.GetGroupByID(CZTA->group_id);
|
|
if (client_group) {
|
|
for (int member_index = 0; member_index < MAX_GROUP_MEMBERS; member_index++) {
|
|
if (client_group->members[member_index] && client_group->members[member_index]->IsClient()) {
|
|
auto group_member = client_group->members[member_index]->CastToClient();
|
|
group_member->AssignTask(CZTA->task_id, CZTA->npc_entity_id, CZTA->enforce_level_requirement);
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_CZTaskAssignRaid:
|
|
{
|
|
CZTaskAssignRaid_Struct* CZTA = (CZTaskAssignRaid_Struct*) pack->pBuffer;
|
|
auto client_raid = entity_list.GetRaidByID(CZTA->raid_id);
|
|
if (client_raid) {
|
|
for (int member_index = 0; member_index < MAX_RAID_MEMBERS; member_index++) {
|
|
if (client_raid->members[member_index].member && client_raid->members[member_index].member->IsClient()) {
|
|
auto raid_member = client_raid->members[member_index].member->CastToClient();
|
|
raid_member->AssignTask(CZTA->task_id, CZTA->npc_entity_id, CZTA->enforce_level_requirement);
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_CZTaskAssignGuild:
|
|
{
|
|
CZTaskAssignGuild_Struct* CZTA = (CZTaskAssignGuild_Struct*) pack->pBuffer;
|
|
for (auto &client : entity_list.GetClientList()) {
|
|
if (client.second->GuildID() > 0 && client.second->GuildID() == CZTA->guild_id) {
|
|
client.second->AssignTask(CZTA->task_id, CZTA->npc_entity_id, CZTA->enforce_level_requirement);
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_CZTaskActivityResetPlayer:
|
|
{
|
|
CZTaskActivityResetPlayer_Struct* CZRA = (CZTaskActivityResetPlayer_Struct*) pack->pBuffer;
|
|
auto client = entity_list.GetClientByCharID(CZRA->character_id);
|
|
if (client) {
|
|
client->ResetTaskActivity(CZRA->task_id, CZRA->activity_id);
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_CZTaskActivityResetGroup:
|
|
{
|
|
CZTaskActivityResetGroup_Struct* CZRA = (CZTaskActivityResetGroup_Struct*) pack->pBuffer;
|
|
auto client_group = entity_list.GetGroupByID(CZRA->group_id);
|
|
if (client_group) {
|
|
for (int member_index = 0; member_index < MAX_GROUP_MEMBERS; member_index++) {
|
|
if (client_group->members[member_index] && client_group->members[member_index]->IsClient()) {
|
|
auto group_member = client_group->members[member_index]->CastToClient();
|
|
group_member->ResetTaskActivity(CZRA->task_id, CZRA->activity_id);
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_CZTaskActivityResetRaid:
|
|
{
|
|
CZTaskActivityResetRaid_Struct* CZRA = (CZTaskActivityResetRaid_Struct*) pack->pBuffer;
|
|
auto client_raid = entity_list.GetRaidByID(CZRA->raid_id);
|
|
if (client_raid) {
|
|
for (int member_index = 0; member_index < MAX_RAID_MEMBERS; member_index++) {
|
|
if (client_raid->members[member_index].member && client_raid->members[member_index].member->IsClient()) {
|
|
auto raid_member = client_raid->members[member_index].member->CastToClient();
|
|
raid_member->ResetTaskActivity(CZRA->task_id, CZRA->activity_id);
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_CZTaskActivityResetGuild:
|
|
{
|
|
CZTaskActivityResetGuild_Struct* CZRA = (CZTaskActivityResetGuild_Struct*) pack->pBuffer;
|
|
for (auto &client : entity_list.GetClientList()) {
|
|
if (client.second->GuildID() > 0 && client.second->GuildID() == CZRA->guild_id) {
|
|
client.second->ResetTaskActivity(CZRA->task_id, CZRA->activity_id);
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_CZTaskActivityUpdatePlayer:
|
|
{
|
|
CZTaskActivityUpdatePlayer_Struct* CZUA = (CZTaskActivityUpdatePlayer_Struct*) pack->pBuffer;
|
|
auto client = entity_list.GetClientByCharID(CZUA->character_id);
|
|
if (client) {
|
|
client->UpdateTaskActivity(CZUA->task_id, CZUA->activity_id, CZUA->activity_count);
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_CZTaskActivityUpdateGroup:
|
|
{
|
|
CZTaskActivityUpdateGroup_Struct* CZUA = (CZTaskActivityUpdateGroup_Struct*) pack->pBuffer;
|
|
auto client_group = entity_list.GetGroupByID(CZUA->group_id);
|
|
if (client_group) {
|
|
for (int member_index = 0; member_index < MAX_GROUP_MEMBERS; member_index++) {
|
|
if (client_group->members[member_index] && client_group->members[member_index]->IsClient()) {
|
|
auto group_member = client_group->members[member_index]->CastToClient();
|
|
group_member->UpdateTaskActivity(CZUA->task_id, CZUA->activity_id, CZUA->activity_count);
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_CZTaskActivityUpdateRaid:
|
|
{
|
|
CZTaskActivityUpdateRaid_Struct* CZUA = (CZTaskActivityUpdateRaid_Struct*) pack->pBuffer;
|
|
auto client_raid = entity_list.GetRaidByID(CZUA->raid_id);
|
|
if (client_raid) {
|
|
for (int member_index = 0; member_index < MAX_RAID_MEMBERS; member_index++) {
|
|
if (client_raid->members[member_index].member && client_raid->members[member_index].member->IsClient()) {
|
|
auto raid_member = client_raid->members[member_index].member->CastToClient();
|
|
raid_member->UpdateTaskActivity(CZUA->task_id, CZUA->activity_id, CZUA->activity_count);
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_CZTaskActivityUpdateGuild:
|
|
{
|
|
CZTaskActivityUpdateGuild_Struct* CZUA = (CZTaskActivityUpdateGuild_Struct*) pack->pBuffer;
|
|
for (auto &client : entity_list.GetClientList()) {
|
|
if (client.second->GuildID() > 0 && client.second->GuildID() == CZUA->guild_id) {
|
|
client.second->UpdateTaskActivity(CZUA->task_id, CZUA->activity_id, CZUA->activity_count);
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_CZTaskDisablePlayer:
|
|
{
|
|
CZTaskDisablePlayer_Struct* CZUA = (CZTaskDisablePlayer_Struct*) pack->pBuffer;
|
|
auto client = entity_list.GetClientByCharID(CZUA->character_id);
|
|
if (client) {
|
|
client->DisableTask(1, reinterpret_cast<int *>(CZUA->task_id));
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_CZTaskDisableGroup:
|
|
{
|
|
CZTaskDisableGroup_Struct* CZUA = (CZTaskDisableGroup_Struct*) pack->pBuffer;
|
|
auto client_group = entity_list.GetGroupByID(CZUA->group_id);
|
|
if (client_group) {
|
|
for (int member_index = 0; member_index < MAX_GROUP_MEMBERS; member_index++) {
|
|
if (client_group->members[member_index] && client_group->members[member_index]->IsClient()) {
|
|
auto group_member = client_group->members[member_index]->CastToClient();
|
|
group_member->DisableTask(1, reinterpret_cast<int *>(CZUA->task_id));
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_CZTaskDisableRaid:
|
|
{
|
|
CZTaskDisableRaid_Struct* CZUA = (CZTaskDisableRaid_Struct*) pack->pBuffer;
|
|
auto client_raid = entity_list.GetRaidByID(CZUA->raid_id);
|
|
if (client_raid) {
|
|
for (int member_index = 0; member_index < MAX_RAID_MEMBERS; member_index++) {
|
|
if (client_raid->members[member_index].member && client_raid->members[member_index].member->IsClient()) {
|
|
auto raid_member = client_raid->members[member_index].member->CastToClient();
|
|
raid_member->DisableTask(1, reinterpret_cast<int *>(CZUA->task_id));
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_CZTaskDisableGuild:
|
|
{
|
|
CZTaskDisableGuild_Struct* CZUA = (CZTaskDisableGuild_Struct*) pack->pBuffer;
|
|
for (auto &client : entity_list.GetClientList()) {
|
|
if (client.second->GuildID() > 0 && client.second->GuildID() == CZUA->guild_id) {
|
|
client.second->DisableTask(1, reinterpret_cast<int *>(CZUA->task_id));
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_CZTaskEnablePlayer:
|
|
{
|
|
CZTaskEnablePlayer_Struct* CZUA = (CZTaskEnablePlayer_Struct*) pack->pBuffer;
|
|
auto client = entity_list.GetClientByCharID(CZUA->character_id);
|
|
if (client) {
|
|
client->EnableTask(1, reinterpret_cast<int *>(CZUA->task_id));
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_CZTaskEnableGroup:
|
|
{
|
|
CZTaskEnableGroup_Struct* CZUA = (CZTaskEnableGroup_Struct*) pack->pBuffer;
|
|
auto client_group = entity_list.GetGroupByID(CZUA->group_id);
|
|
if (client_group) {
|
|
for (int member_index = 0; member_index < MAX_GROUP_MEMBERS; member_index++) {
|
|
if (client_group->members[member_index] && client_group->members[member_index]->IsClient()) {
|
|
auto group_member = client_group->members[member_index]->CastToClient();
|
|
group_member->EnableTask(1, reinterpret_cast<int *>(CZUA->task_id));
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_CZTaskEnableRaid:
|
|
{
|
|
CZTaskEnableRaid_Struct* CZUA = (CZTaskEnableRaid_Struct*) pack->pBuffer;
|
|
auto client_raid = entity_list.GetRaidByID(CZUA->raid_id);
|
|
if (client_raid) {
|
|
for (int member_index = 0; member_index < MAX_RAID_MEMBERS; member_index++) {
|
|
if (client_raid->members[member_index].member && client_raid->members[member_index].member->IsClient()) {
|
|
auto raid_member = client_raid->members[member_index].member->CastToClient();
|
|
raid_member->EnableTask(1, reinterpret_cast<int *>(CZUA->task_id));
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_CZTaskEnableGuild:
|
|
{
|
|
CZTaskEnableGuild_Struct* CZUA = (CZTaskEnableGuild_Struct*) pack->pBuffer;
|
|
for (auto &client : entity_list.GetClientList()) {
|
|
if (client.second->GuildID() > 0 && client.second->GuildID() == CZUA->guild_id) {
|
|
client.second->EnableTask(1, reinterpret_cast<int *>(CZUA->task_id));
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_CZTaskFailPlayer:
|
|
{
|
|
CZTaskFailPlayer_Struct* CZUA = (CZTaskFailPlayer_Struct*) pack->pBuffer;
|
|
auto client = entity_list.GetClientByCharID(CZUA->character_id);
|
|
if (client) {
|
|
client->FailTask(CZUA->task_id);
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_CZTaskFailGroup:
|
|
{
|
|
CZTaskFailGroup_Struct* CZUA = (CZTaskFailGroup_Struct*) pack->pBuffer;
|
|
auto client_group = entity_list.GetGroupByID(CZUA->group_id);
|
|
if (client_group) {
|
|
for (int member_index = 0; member_index < MAX_GROUP_MEMBERS; member_index++) {
|
|
if (client_group->members[member_index] && client_group->members[member_index]->IsClient()) {
|
|
auto group_member = client_group->members[member_index]->CastToClient();
|
|
group_member->FailTask(CZUA->task_id);
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_CZTaskFailRaid:
|
|
{
|
|
CZTaskFailRaid_Struct* CZUA = (CZTaskFailRaid_Struct*) pack->pBuffer;
|
|
auto client_raid = entity_list.GetRaidByID(CZUA->raid_id);
|
|
if (client_raid) {
|
|
for (int member_index = 0; member_index < MAX_RAID_MEMBERS; member_index++) {
|
|
if (client_raid->members[member_index].member && client_raid->members[member_index].member->IsClient()) {
|
|
auto raid_member = client_raid->members[member_index].member->CastToClient();
|
|
raid_member->FailTask(CZUA->task_id);
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_CZTaskFailGuild:
|
|
{
|
|
CZTaskFailGuild_Struct* CZUA = (CZTaskFailGuild_Struct*) pack->pBuffer;
|
|
for (auto &client : entity_list.GetClientList()) {
|
|
if (client.second->GuildID() > 0 && client.second->GuildID() == CZUA->guild_id) {
|
|
client.second->FailTask(CZUA->task_id);
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_CZTaskRemovePlayer:
|
|
{
|
|
CZTaskRemovePlayer_Struct* CZTR = (CZTaskRemovePlayer_Struct*) pack->pBuffer;
|
|
auto client = entity_list.GetClientByCharID(CZTR->character_id);
|
|
if (client) {
|
|
client->RemoveTaskByTaskID(CZTR->task_id);
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_CZTaskRemoveGroup:
|
|
{
|
|
CZTaskRemoveGroup_Struct* CZTR = (CZTaskRemoveGroup_Struct*) pack->pBuffer;
|
|
auto client_group = entity_list.GetGroupByID(CZTR->group_id);
|
|
if (client_group) {
|
|
for (int member_index = 0; member_index < MAX_GROUP_MEMBERS; member_index++) {
|
|
if (client_group->members[member_index] && client_group->members[member_index]->IsClient()) {
|
|
auto group_member = client_group->members[member_index]->CastToClient();
|
|
group_member->RemoveTaskByTaskID(CZTR->task_id);
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_CZTaskRemoveRaid:
|
|
{
|
|
CZTaskRemoveRaid_Struct* CZTR = (CZTaskRemoveRaid_Struct*) pack->pBuffer;
|
|
auto client_raid = entity_list.GetRaidByID(CZTR->raid_id);
|
|
if (client_raid) {
|
|
for (int member_index = 0; member_index < MAX_RAID_MEMBERS; member_index++) {
|
|
if (client_raid->members[member_index].member && client_raid->members[member_index].member->IsClient()) {
|
|
auto raid_member = client_raid->members[member_index].member->CastToClient();
|
|
raid_member->RemoveTaskByTaskID(CZTR->task_id);
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_CZTaskRemoveGuild:
|
|
{
|
|
CZTaskRemoveGuild_Struct* CZTR = (CZTaskRemoveGuild_Struct*) pack->pBuffer;
|
|
for (auto &client : entity_list.GetClientList()) {
|
|
if (client.second->GuildID() > 0 && client.second->GuildID() == CZTR->guild_id) {
|
|
client.second->RemoveTaskByTaskID(CZTR->task_id);
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_WWAssignTask:
|
|
{
|
|
WWAssignTask_Struct* WWAT = (WWAssignTask_Struct*) pack->pBuffer;
|
|
for (auto &client : entity_list.GetClientList()) {
|
|
auto client_status = client.second->Admin();
|
|
if (client_status >= WWAT->min_status && (client_status <= WWAT->max_status || WWAT->max_status == 0)) {
|
|
client.second->AssignTask(WWAT->task_id, WWAT->npc_entity_id, WWAT->enforce_level_requirement);
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_WWCastSpell:
|
|
{
|
|
WWCastSpell_Struct* WWCS = (WWCastSpell_Struct*) pack->pBuffer;
|
|
for (auto &client : entity_list.GetClientList()) {
|
|
auto client_status = client.second->Admin();
|
|
if (client_status >= WWCS->min_status && (client_status <= WWCS->max_status || WWCS->max_status == 0)) {
|
|
client.second->SpellFinished(WWCS->spell_id, client.second);
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_WWDisableTask:
|
|
{
|
|
WWDisableTask_Struct* WWDT = (WWDisableTask_Struct*) pack->pBuffer;
|
|
for (auto &client : entity_list.GetClientList()) {
|
|
auto client_status = client.second->Admin();
|
|
if (client_status >= WWDT->min_status && (client_status <= WWDT->max_status || WWDT->max_status == 0)) {
|
|
client.second->DisableTask(1, reinterpret_cast<int *>(WWDT->task_id));
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_WWEnableTask:
|
|
{
|
|
WWEnableTask_Struct* WWET = (WWEnableTask_Struct*) pack->pBuffer;
|
|
for (auto &client : entity_list.GetClientList()) {
|
|
auto client_status = client.second->Admin();
|
|
if (client_status >= WWET->min_status && (client_status <= WWET->max_status || WWET->max_status == 0)) {
|
|
client.second->EnableTask(1, reinterpret_cast<int *>(WWET->task_id));
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_WWFailTask:
|
|
{
|
|
WWFailTask_Struct* WWFT = (WWFailTask_Struct*) pack->pBuffer;
|
|
for (auto &client : entity_list.GetClientList()) {
|
|
auto client_status = client.second->Admin();
|
|
if (client_status >= WWFT->min_status && (client_status <= WWFT->max_status || WWFT->max_status == 0)) {
|
|
client.second->FailTask(WWFT->task_id);
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_WWMarquee:
|
|
{
|
|
WWMarquee_Struct* WWMS = (WWMarquee_Struct*) pack->pBuffer;
|
|
std::string message = WWMS->message;
|
|
for (auto &client : entity_list.GetClientList()) {
|
|
auto client_status = client.second->Admin();
|
|
if (client_status >= WWMS->min_status && (client_status <= WWMS->max_status || WWMS->max_status == 0)) {
|
|
client.second->SendMarqueeMessage(WWMS->type, WWMS->priority, WWMS->fade_in, WWMS->fade_out, WWMS->duration, message);
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_WWMessage:
|
|
{
|
|
WWMessage_Struct* WWMS = (WWMessage_Struct*) pack->pBuffer;
|
|
for (auto &client : entity_list.GetClientList()) {
|
|
auto client_status = client.second->Admin();
|
|
if (client_status >= WWMS->min_status && (client_status <= WWMS->max_status || WWMS->max_status == 0)) {
|
|
client.second->Message(WWMS->type, WWMS->message);
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_WWMove:
|
|
{
|
|
WWMove_Struct* WWMS = (WWMove_Struct*) pack->pBuffer;
|
|
for (auto &client : entity_list.GetClientList()) {
|
|
auto client_status = client.second->Admin();
|
|
if (client_status >= WWMS->min_status && (client_status <= WWMS->max_status || WWMS->max_status == 0)) {
|
|
client.second->MoveZone(WWMS->zone_short_name);
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_WWMoveInstance:
|
|
{
|
|
WWMoveInstance_Struct* WWMS = (WWMoveInstance_Struct*) pack->pBuffer;
|
|
for (auto &client : entity_list.GetClientList()) {
|
|
auto client_status = client.second->Admin();
|
|
if (client_status >= WWMS->min_status && (client_status <= WWMS->max_status || WWMS->max_status == 0)) {
|
|
client.second->MoveZoneInstance(WWMS->instance_id);
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_WWRemoveSpell:
|
|
{
|
|
WWRemoveSpell_Struct* WWRS = (WWRemoveSpell_Struct*) pack->pBuffer;
|
|
for (auto &client : entity_list.GetClientList()) {
|
|
auto client_status = client.second->Admin();
|
|
if (client_status >= WWRS->min_status && (client_status <= WWRS->max_status || WWRS->max_status == 0)) {
|
|
client.second->BuffFadeBySpellID(WWRS->spell_id);
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_WWRemoveTask:
|
|
{
|
|
WWRemoveTask_Struct* WWRT = (WWRemoveTask_Struct*) pack->pBuffer;
|
|
for (auto &client : entity_list.GetClientList()) {
|
|
auto client_status = client.second->Admin();
|
|
if (client_status >= WWRT->min_status && (client_status <= WWRT->max_status || WWRT->max_status == 0)) {
|
|
client.second->RemoveTaskByTaskID(WWRT->task_id);
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_WWResetActivity:
|
|
{
|
|
WWResetActivity_Struct* WWRA = (WWResetActivity_Struct*) pack->pBuffer;
|
|
for (auto &client : entity_list.GetClientList()) {
|
|
auto client_status = client.second->Admin();
|
|
if (client_status >= WWRA->min_status && (client_status <= WWRA->max_status || WWRA->max_status == 0)) {
|
|
client.second->ResetTaskActivity(WWRA->task_id, WWRA->activity_id);
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_WWSetEntityVariableClient:
|
|
{
|
|
WWSetEntVarClient_Struct* WWSC = (WWSetEntVarClient_Struct*) pack->pBuffer;
|
|
for (auto &client : entity_list.GetClientList()) {
|
|
auto client_status = client.second->Admin();
|
|
if (client_status >= WWSC->min_status && (client_status <= WWSC->max_status || WWSC->max_status == 0)) {
|
|
client.second->SetEntityVariable(WWSC->variable_name, WWSC->variable_value);
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_WWSetEntityVariableNPC:
|
|
{
|
|
WWSetEntVarNPC_Struct* WWSN = (WWSetEntVarNPC_Struct*) pack->pBuffer;
|
|
for (auto &npc : entity_list.GetNPCList()) {
|
|
npc.second->SetEntityVariable(WWSN->variable_name, WWSN->variable_value);
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_WWSignalClient:
|
|
{
|
|
WWSignalClient_Struct* WWSC = (WWSignalClient_Struct*) pack->pBuffer;
|
|
for (auto &client : entity_list.GetClientList()) {
|
|
auto client_status = client.second->Admin();
|
|
if (client_status >= WWSC->min_status && (client_status <= WWSC->max_status || WWSC->max_status == 0)) {
|
|
client.second->Signal(WWSC->signal);
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_WWSignalNPC:
|
|
{
|
|
WWSignalNPC_Struct* WWSN = (WWSignalNPC_Struct*) pack->pBuffer;
|
|
for (auto &npc : entity_list.GetNPCList()) {
|
|
npc.second->SignalNPC(WWSN->signal);
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_WWUpdateActivity:
|
|
{
|
|
WWUpdateActivity_Struct* WWUA = (WWUpdateActivity_Struct*) pack->pBuffer;
|
|
for (auto &client : entity_list.GetClientList()) {
|
|
auto client_status = client.second->Admin();
|
|
if (client_status >= WWUA->min_status && (client_status <= WWUA->max_status || WWUA->max_status == 0)) {
|
|
client.second->UpdateTaskActivity(WWUA->task_id, WWUA->activity_id, WWUA->activity_count);
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
|
|
case ServerOP_ReloadWorld:
|
|
{
|
|
auto* reload_world = (ReloadWorld_Struct*)pack->pBuffer;
|
|
if (zone) {
|
|
zone->ReloadWorld(reload_world->Option);
|
|
}
|
|
break;
|
|
}
|
|
|
|
case ServerOP_UpdateSchedulerEvents: {
|
|
LogScheduler("Received signal from world to update");
|
|
if (m_zone_scheduler) {
|
|
m_zone_scheduler->LoadScheduledEvents();
|
|
}
|
|
|
|
break;
|
|
}
|
|
|
|
case ServerOP_HotReloadQuests:
|
|
{
|
|
if (!zone) {
|
|
break;
|
|
}
|
|
|
|
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();
|
|
bool can_reload_global_script = (request_zone_short_name == "all" && RuleB(HotReload, QuestsAutoReloadGlobalScripts));
|
|
|
|
if (request_zone_short_name == local_zone_short_name || can_reload_global_script) {
|
|
zone->SetQuestHotReloadQueued(true);
|
|
} else if (request_zone_short_name == "all") {
|
|
std::string reload_quest_saylink = EQ::SayLinkEngine::GenerateQuestSaylink("#reloadquest", false, "Locally");
|
|
std::string reload_world_saylink = EQ::SayLinkEngine::GenerateQuestSaylink("#reloadworld", false, "Globally");
|
|
worldserver.SendEmoteMessage(0, 0, 20, 15, "A quest, plugin, or global script has changed reload quests [%s] [%s].", reload_quest_saylink.c_str(), reload_world_saylink.c_str());
|
|
}
|
|
|
|
break;
|
|
}
|
|
case ServerOP_ChangeSharedMem:
|
|
{
|
|
std::string hotfix_name = std::string((char*)pack->pBuffer);
|
|
LogInfo("Loading items");
|
|
if (!content_db.LoadItems(hotfix_name)) {
|
|
LogError("Loading items failed!");
|
|
}
|
|
|
|
LogInfo("Loading npc faction lists");
|
|
if (!content_db.LoadNPCFactionLists(hotfix_name)) {
|
|
LogError("Loading npcs faction lists failed!");
|
|
}
|
|
|
|
LogInfo("Loading loot tables");
|
|
if (!content_db.LoadLoot(hotfix_name)) {
|
|
LogError("Loading loot failed!");
|
|
}
|
|
|
|
LogInfo("Loading skill caps");
|
|
if (!content_db.LoadSkillCaps(std::string(hotfix_name))) {
|
|
LogError("Loading skill caps failed!");
|
|
}
|
|
|
|
LogInfo("Loading spells");
|
|
if (!content_db.LoadSpells(hotfix_name, &SPDAT_RECORDS, &spells)) {
|
|
LogError("Loading spells failed!");
|
|
}
|
|
|
|
LogInfo("Loading base data");
|
|
if (!content_db.LoadBaseData(hotfix_name)) {
|
|
LogError("Loading base data failed!");
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_CZClientMessageString:
|
|
{
|
|
auto buf = reinterpret_cast<CZClientMessageString_Struct*>(pack->pBuffer);
|
|
Client* client = entity_list.GetClientByName(buf->character_name);
|
|
if (client) {
|
|
client->MessageString(buf);
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_ExpeditionCreate:
|
|
case ServerOP_ExpeditionLockout:
|
|
case ServerOP_ExpeditionLockoutDuration:
|
|
case ServerOP_ExpeditionLockState:
|
|
case ServerOP_ExpeditionReplayOnJoin:
|
|
case ServerOP_ExpeditionDzAddPlayer:
|
|
case ServerOP_ExpeditionDzMakeLeader:
|
|
case ServerOP_ExpeditionCharacterLockout:
|
|
{
|
|
Expedition::HandleWorldMessage(pack);
|
|
break;
|
|
}
|
|
case ServerOP_DzCreated:
|
|
case ServerOP_DzDeleted:
|
|
case ServerOP_DzAddRemoveMember:
|
|
case ServerOP_DzSwapMembers:
|
|
case ServerOP_DzRemoveAllMembers:
|
|
case ServerOP_DzDurationUpdate:
|
|
case ServerOP_DzGetMemberStatuses:
|
|
case ServerOP_DzSetCompass:
|
|
case ServerOP_DzSetSafeReturn:
|
|
case ServerOP_DzSetZoneIn:
|
|
case ServerOP_DzUpdateMemberStatus:
|
|
case ServerOP_DzLeaderChanged:
|
|
case ServerOP_DzExpireWarning:
|
|
{
|
|
DynamicZone::HandleWorldMessage(pack);
|
|
break;
|
|
}
|
|
case ServerOP_SharedTaskAcceptNewTask:
|
|
case ServerOP_SharedTaskUpdate:
|
|
case ServerOP_SharedTaskAttemptRemove:
|
|
case ServerOP_SharedTaskMemberlist:
|
|
case ServerOP_SharedTaskMemberChange:
|
|
case ServerOP_SharedTaskInvitePlayer:
|
|
case ServerOP_SharedTaskPurgeAllCommand:
|
|
{
|
|
SharedTaskZoneMessaging::HandleWorldMessage(pack);
|
|
break;
|
|
}
|
|
default: {
|
|
LogInfo("[HandleMessage] Unknown ZS Opcode [{}] size [{}]", (int)pack->opcode, pack->size);
|
|
|
|
// std::cout << " Unknown ZSopcode:" << (int)pack->opcode;
|
|
// std::cout << " size:" << pack->size << std::endl;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
bool WorldServer::SendChannelMessage(Client* from, const char* to, uint8 chan_num, uint32 guilddbid, uint8 language, uint8 lang_skill, const char* message, ...) {
|
|
if (!worldserver.Connected())
|
|
return false;
|
|
va_list argptr;
|
|
char buffer[512];
|
|
|
|
va_start(argptr, message);
|
|
vsnprintf(buffer, 512, message, argptr);
|
|
va_end(argptr);
|
|
buffer[511] = '\0';
|
|
|
|
auto pack = new ServerPacket(ServerOP_ChannelMessage, sizeof(ServerChannelMessage_Struct) + strlen(buffer) + 1);
|
|
ServerChannelMessage_Struct* scm = (ServerChannelMessage_Struct*)pack->pBuffer;
|
|
|
|
if (from == 0) {
|
|
strcpy(scm->from, "ZServer");
|
|
scm->fromadmin = 0;
|
|
}
|
|
else {
|
|
strcpy(scm->from, from->GetName());
|
|
scm->fromadmin = from->Admin();
|
|
}
|
|
if (to == 0) {
|
|
scm->to[0] = 0;
|
|
scm->deliverto[0] = '\0';
|
|
}
|
|
else {
|
|
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;
|
|
scm->lang_skill = lang_skill;
|
|
scm->queued = 0;
|
|
strcpy(scm->message, buffer);
|
|
|
|
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;
|
|
char buffer[4096] = { 0 };
|
|
|
|
va_start(argptr, message);
|
|
vsnprintf(buffer, sizeof(buffer) - 1, message, argptr);
|
|
va_end(argptr);
|
|
|
|
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;
|
|
char buffer[4096] = { 0 };
|
|
|
|
va_start(argptr, message);
|
|
vsnprintf(buffer, sizeof(buffer) - 1, message, argptr);
|
|
va_end(argptr);
|
|
|
|
if (!Connected() && to == 0) {
|
|
entity_list.MessageStatus(to_guilddbid, to_minstatus, type, buffer);
|
|
return false;
|
|
}
|
|
|
|
auto pack = new ServerPacket(ServerOP_EmoteMessage, sizeof(ServerEmoteMessage_Struct) + strlen(buffer) + 1);
|
|
ServerEmoteMessage_Struct* sem = (ServerEmoteMessage_Struct*)pack->pBuffer;
|
|
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) {
|
|
|
|
if (!worldserver.Connected() || !From)
|
|
return false;
|
|
|
|
auto pack = new ServerPacket(ServerOP_VoiceMacro, sizeof(ServerVoiceMacro_Struct));
|
|
|
|
ServerVoiceMacro_Struct* svm = (ServerVoiceMacro_Struct*)pack->pBuffer;
|
|
|
|
strcpy(svm->From, From->GetName());
|
|
|
|
switch (Type) {
|
|
|
|
case VoiceMacroTell:
|
|
strcpy(svm->To, Target);
|
|
break;
|
|
|
|
case VoiceMacroGroup:
|
|
svm->GroupID = GroupOrRaidID;
|
|
break;
|
|
|
|
case VoiceMacroRaid:
|
|
svm->RaidID = GroupOrRaidID;
|
|
break;
|
|
}
|
|
|
|
svm->Type = Type;
|
|
|
|
svm->Voice = (GetPlayerRaceValue(From->GetRace()) * 2) + From->GetGender();
|
|
|
|
svm->MacroNumber = MacroNumber;
|
|
|
|
bool Ret = SendPacket(pack);
|
|
|
|
safe_delete(pack);
|
|
|
|
return Ret;
|
|
}
|
|
|
|
bool WorldServer::RezzPlayer(EQApplicationPacket* rpack, uint32 rezzexp, uint32 dbid, uint16 opcode)
|
|
{
|
|
LogSpells("WorldServer::RezzPlayer rezzexp is [{}] (0 is normal for RezzComplete", rezzexp);
|
|
auto pack = new ServerPacket(ServerOP_RezzPlayer, sizeof(RezzPlayer_Struct));
|
|
RezzPlayer_Struct* sem = (RezzPlayer_Struct*)pack->pBuffer;
|
|
sem->rezzopcode = opcode;
|
|
sem->rez = *(Resurrect_Struct*)rpack->pBuffer;
|
|
sem->exp = rezzexp;
|
|
sem->dbid = dbid;
|
|
bool ret = SendPacket(pack);
|
|
if (ret)
|
|
LogSpells("Sending player rezz packet to world spellid:[{}]", sem->rez.spellid);
|
|
else
|
|
LogSpells("NOT Sending player rezz packet to world");
|
|
|
|
safe_delete(pack);
|
|
return ret;
|
|
}
|
|
|
|
void WorldServer::SendReloadTasks(int Command, int TaskID) {
|
|
auto pack = new ServerPacket(ServerOP_ReloadTasks, sizeof(ReloadTasks_Struct));
|
|
ReloadTasks_Struct* rts = (ReloadTasks_Struct*)pack->pBuffer;
|
|
|
|
rts->Command = Command;
|
|
rts->Parameter = TaskID;
|
|
|
|
SendPacket(pack);
|
|
}
|
|
|
|
void WorldServer::HandleReloadTasks(ServerPacket *pack)
|
|
{
|
|
ReloadTasks_Struct* rts = (ReloadTasks_Struct*)pack->pBuffer;
|
|
|
|
Log(Logs::General, Logs::Tasks, "[GLOBALLOAD] Zone received ServerOP_ReloadTasks from World, Command %i", rts->Command);
|
|
|
|
switch (rts->Command) {
|
|
case RELOADTASKS:
|
|
entity_list.SaveAllClientsTaskState();
|
|
|
|
// TODO: Reload at the world level for shared tasks
|
|
|
|
if (rts->Parameter == 0) {
|
|
Log(Logs::General, Logs::Tasks, "[GLOBALLOAD] Reload ALL tasks");
|
|
safe_delete(task_manager);
|
|
task_manager = new TaskManager;
|
|
task_manager->LoadTasks();
|
|
if (zone) {
|
|
task_manager->LoadProximities(zone->GetZoneID());
|
|
}
|
|
entity_list.ReloadAllClientsTaskState();
|
|
}
|
|
else {
|
|
Log(Logs::General, Logs::Tasks, "[GLOBALLOAD] Reload only task %i", rts->Parameter);
|
|
task_manager->LoadTasks(rts->Parameter);
|
|
entity_list.ReloadAllClientsTaskState(rts->Parameter);
|
|
}
|
|
|
|
break;
|
|
|
|
case RELOADTASKPROXIMITIES:
|
|
if (zone) {
|
|
Log(Logs::General, Logs::Tasks, "[GLOBALLOAD] Reload task proximities");
|
|
task_manager->LoadProximities(zone->GetZoneID());
|
|
}
|
|
break;
|
|
|
|
case RELOADTASKGOALLISTS:
|
|
Log(Logs::General, Logs::Tasks, "[GLOBALLOAD] Reload task goal lists");
|
|
task_manager->ReloadGoalLists();
|
|
break;
|
|
|
|
case RELOADTASKSETS:
|
|
Log(Logs::General, Logs::Tasks, "[GLOBALLOAD] Reload task sets");
|
|
task_manager->LoadTaskSets();
|
|
break;
|
|
|
|
default:
|
|
Log(Logs::General, Logs::Tasks, "[GLOBALLOAD] Unhandled ServerOP_ReloadTasks command %i", rts->Command);
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
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...
|
|
if (cur_groupid >= last_groupid) {
|
|
//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.
|
|
LogError("Ran out of group IDs before the server sent us more");
|
|
return(0);
|
|
}
|
|
if (cur_groupid > (last_groupid - /*50*/995)) {
|
|
//running low, request more
|
|
auto pack = new ServerPacket(ServerOP_GroupIDReq);
|
|
SendPacket(pack);
|
|
safe_delete(pack);
|
|
}
|
|
printf("Handing out new group id %d\n", cur_groupid);
|
|
return(cur_groupid++);
|
|
}
|
|
|
|
void WorldServer::UpdateLFP(uint32 LeaderID, uint8 Action, uint8 MatchFilter, uint32 FromLevel, uint32 ToLevel, uint32 Classes,
|
|
const char *Comments, GroupLFPMemberEntry *LFPMembers) {
|
|
|
|
auto pack = new ServerPacket(ServerOP_LFPUpdate, sizeof(ServerLFPUpdate_Struct));
|
|
ServerLFPUpdate_Struct* sus = (ServerLFPUpdate_Struct*)pack->pBuffer;
|
|
|
|
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[MAX_GROUP_MEMBERS];
|
|
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);
|
|
|
|
if (client) {
|
|
ServerLFGMatchesResponse_Struct* smrs = (ServerLFGMatchesResponse_Struct*)Buffer;
|
|
|
|
for (int i = 0; i<Entries; i++) {
|
|
PacketLength = PacketLength + 12 + strlen(smrs->Name) + strlen(smrs->Comments);
|
|
smrs++;
|
|
}
|
|
|
|
auto outapp = new EQApplicationPacket(OP_LFGGetMatchesResponse, PacketLength);
|
|
|
|
smrs = (ServerLFGMatchesResponse_Struct*)Buffer;
|
|
|
|
char *OutBuffer = (char *)outapp->pBuffer;
|
|
|
|
VARSTRUCT_ENCODE_TYPE(uint32, OutBuffer, 0x00074af); // Unknown
|
|
|
|
for (int i = 0; i<Entries; i++) {
|
|
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);
|
|
}
|
|
}
|
|
|
|
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);
|
|
|
|
ServerLFPMatchesResponse_Struct* smrs = (ServerLFPMatchesResponse_Struct*)Buffer;
|
|
|
|
Client* client = entity_list.GetClientByID(EntityID);
|
|
|
|
if (client) {
|
|
for (int i = 0; i<Entries; i++) {
|
|
PacketLength += strlen(smrs->Comments) + 11;
|
|
for (unsigned int j = 0; j<MAX_GROUP_MEMBERS; j++) {
|
|
|
|
if (smrs->Members[j].Name[0] != '\0')
|
|
PacketLength += strlen(smrs->Members[j].Name) + 9;
|
|
}
|
|
smrs++;
|
|
}
|
|
auto outapp = new EQApplicationPacket(OP_LFPGetMatchesResponse, PacketLength);
|
|
|
|
smrs = (ServerLFPMatchesResponse_Struct*)Buffer;
|
|
|
|
char *OutBuffer = (char *)outapp->pBuffer;
|
|
|
|
VARSTRUCT_ENCODE_TYPE(uint32, OutBuffer, 0x00074af); // Unknown
|
|
|
|
for (int i = 0; i<Entries; i++) {
|
|
|
|
int MemberCount = 0;
|
|
|
|
for (unsigned int j = 0; j<MAX_GROUP_MEMBERS; j++)
|
|
if (smrs->Members[j].Name[0] != '\0')
|
|
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);
|
|
|
|
for (unsigned int j = 0; j<MAX_GROUP_MEMBERS; j++) {
|
|
if (smrs->Members[j].Name[0] != '\0') {
|
|
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);
|
|
}
|
|
}
|
|
|
|
void WorldServer::RequestTellQueue(const char *who)
|
|
{
|
|
if (!who)
|
|
return;
|
|
|
|
auto pack = new ServerPacket(ServerOP_RequestTellQueue, sizeof(ServerRequestTellQueue_Struct));
|
|
ServerRequestTellQueue_Struct* rtq = (ServerRequestTellQueue_Struct*)pack->pBuffer;
|
|
|
|
strn0cpy(rtq->name, who, sizeof(rtq->name));
|
|
|
|
SendPacket(pack);
|
|
safe_delete(pack);
|
|
return;
|
|
}
|
|
|
|
void WorldServer::OnKeepAlive(EQ::Timer *t)
|
|
{
|
|
ServerPacket pack(ServerOP_KeepAlive, 0);
|
|
SendPacket(&pack);
|
|
}
|
|
|
|
ZoneEventScheduler *WorldServer::GetScheduler() const
|
|
{
|
|
return m_zone_scheduler;
|
|
}
|
|
|
|
void WorldServer::SetScheduler(ZoneEventScheduler *scheduler)
|
|
{
|
|
WorldServer::m_zone_scheduler = scheduler;
|
|
}
|
|
|