mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-12 05:21: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>
1532 lines
44 KiB
C++
1532 lines
44 KiB
C++
/* EQEMu: Everquest Server Emulator
|
|
Copyright (C) 2001-2005 EQEMu Development Team (http://eqemulator.net)
|
|
|
|
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 "zoneserver.h"
|
|
#include "clientlist.h"
|
|
#include "login_server.h"
|
|
#include "login_server_list.h"
|
|
#include "zonelist.h"
|
|
#include "worlddb.h"
|
|
#include "client.h"
|
|
#include "../common/md5.h"
|
|
#include "world_config.h"
|
|
#include "../common/guilds.h"
|
|
#include "../common/packet_dump.h"
|
|
#include "../common/misc.h"
|
|
#include "../common/string_util.h"
|
|
#include "cliententry.h"
|
|
#include "wguild_mgr.h"
|
|
#include "lfplist.h"
|
|
#include "adventure_manager.h"
|
|
#include "ucs.h"
|
|
#include "queryserv.h"
|
|
#include "world_store.h"
|
|
#include "dynamic_zone.h"
|
|
#include "expedition_message.h"
|
|
#include "shared_task_world_messaging.h"
|
|
#include "../common/shared_tasks.h"
|
|
|
|
extern ClientList client_list;
|
|
extern GroupLFPList LFPGroupList;
|
|
extern ZSList zoneserver_list;
|
|
extern LoginServerList loginserverlist;
|
|
extern volatile bool RunLoops;
|
|
extern volatile bool UCSServerAvailable_;
|
|
extern AdventureManager adventure_manager;
|
|
extern UCSConnection UCSLink;
|
|
extern QueryServConnection QSLink;
|
|
void CatchSignal(int sig_num);
|
|
|
|
ZoneServer::ZoneServer(std::shared_ptr<EQ::Net::ServertalkServerConnection> connection, EQ::Net::ConsoleServer *console)
|
|
: tcpc(connection), zone_boot_timer(5000) {
|
|
|
|
/* Set Process tracking variable defaults */
|
|
memset(zone_name, 0, sizeof(zone_name));
|
|
memset(compiled, 0, sizeof(compiled));
|
|
memset(client_address, 0, sizeof(client_address));
|
|
memset(client_local_address, 0, sizeof(client_local_address));
|
|
|
|
zone_server_id = zoneserver_list.GetNextID();
|
|
zone_server_zone_id = 0;
|
|
instance_id = 0;
|
|
zone_os_process_id = 0;
|
|
client_port = 0;
|
|
is_booting_up = false;
|
|
is_authenticated = false;
|
|
is_static_zone = false;
|
|
zone_player_count = 0;
|
|
|
|
tcpc->OnMessage(std::bind(&ZoneServer::HandleMessage, this, std::placeholders::_1, std::placeholders::_2));
|
|
|
|
boot_timer_obj = std::make_unique<EQ::Timer>(100, true, [this](EQ::Timer *obj) {
|
|
if (zone_boot_timer.Check()) {
|
|
LSBootUpdate(GetZoneID(), true);
|
|
zone_boot_timer.Disable();
|
|
}
|
|
});
|
|
|
|
this->console = console;
|
|
}
|
|
|
|
ZoneServer::~ZoneServer() {
|
|
if (RunLoops)
|
|
client_list.CLERemoveZSRef(this);
|
|
}
|
|
|
|
bool ZoneServer::SetZone(uint32 iZoneID, uint32 iInstanceID, bool iStaticZone) {
|
|
is_booting_up = false;
|
|
|
|
const char* zn = MakeLowerString(ZoneName(iZoneID));
|
|
char* longname;
|
|
|
|
if (iZoneID)
|
|
Log(Logs::Detail, Logs::WorldServer, "Setting to '%s' (%d:%d)%s", (zn) ? zn : "", iZoneID, iInstanceID,
|
|
iStaticZone ? " (Static)" : "");
|
|
|
|
zone_server_zone_id = iZoneID;
|
|
instance_id = iInstanceID;
|
|
if (iZoneID != 0)
|
|
zone_server_previous_zone_id = iZoneID;
|
|
if (zone_server_zone_id == 0) {
|
|
client_list.CLERemoveZSRef(this);
|
|
zone_player_count = 0;
|
|
LSSleepUpdate(GetPrevZoneID());
|
|
}
|
|
|
|
is_static_zone = iStaticZone;
|
|
|
|
if (zn)
|
|
{
|
|
strn0cpy(zone_name, zn, sizeof(zone_name));
|
|
if (content_db.GetZoneLongName((char*)zone_name, &longname, nullptr, nullptr, nullptr, nullptr, nullptr, nullptr))
|
|
{
|
|
strn0cpy(long_name, longname, sizeof(long_name));
|
|
safe_delete_array(longname);
|
|
}
|
|
else
|
|
strcpy(long_name, "");
|
|
}
|
|
else
|
|
{
|
|
strcpy(zone_name, "");
|
|
strcpy(long_name, "");
|
|
}
|
|
|
|
client_list.ZoneBootup(this);
|
|
zone_boot_timer.Start();
|
|
|
|
return true;
|
|
}
|
|
|
|
void ZoneServer::LSShutDownUpdate(uint32 zoneid) {
|
|
if (WorldConfig::get()->UpdateStats) {
|
|
auto pack = new ServerPacket;
|
|
pack->opcode = ServerOP_LSZoneShutdown;
|
|
pack->size = sizeof(ZoneShutdown_Struct);
|
|
pack->pBuffer = new uchar[pack->size];
|
|
memset(pack->pBuffer, 0, pack->size);
|
|
ZoneShutdown_Struct* zsd = (ZoneShutdown_Struct*)pack->pBuffer;
|
|
if (zoneid == 0)
|
|
zsd->zone = GetPrevZoneID();
|
|
else
|
|
zsd->zone = zoneid;
|
|
zsd->zone_wid = GetID();
|
|
loginserverlist.SendPacket(pack);
|
|
safe_delete(pack);
|
|
}
|
|
}
|
|
void ZoneServer::LSBootUpdate(uint32 zoneid, uint32 instanceid, bool startup) {
|
|
if (WorldConfig::get()->UpdateStats) {
|
|
auto pack = new ServerPacket;
|
|
if (startup)
|
|
pack->opcode = ServerOP_LSZoneStart;
|
|
else
|
|
pack->opcode = ServerOP_LSZoneBoot;
|
|
pack->size = sizeof(ZoneBoot_Struct);
|
|
pack->pBuffer = new uchar[pack->size];
|
|
memset(pack->pBuffer, 0, pack->size);
|
|
ZoneBoot_Struct* bootup = (ZoneBoot_Struct*)pack->pBuffer;
|
|
if (startup)
|
|
strcpy(bootup->compile_time, GetCompileTime());
|
|
bootup->zone = zoneid;
|
|
bootup->zone_wid = GetID();
|
|
bootup->instance = instanceid;
|
|
loginserverlist.SendPacket(pack);
|
|
safe_delete(pack);
|
|
}
|
|
}
|
|
|
|
void ZoneServer::LSSleepUpdate(uint32 zoneid) {
|
|
if (WorldConfig::get()->UpdateStats) {
|
|
auto pack = new ServerPacket;
|
|
pack->opcode = ServerOP_LSZoneSleep;
|
|
pack->size = sizeof(ServerLSZoneSleep_Struct);
|
|
pack->pBuffer = new uchar[pack->size];
|
|
memset(pack->pBuffer, 0, pack->size);
|
|
ServerLSZoneSleep_Struct* sleep = (ServerLSZoneSleep_Struct*)pack->pBuffer;
|
|
sleep->zone = zoneid;
|
|
sleep->zone_wid = GetID();
|
|
loginserverlist.SendPacket(pack);
|
|
safe_delete(pack);
|
|
}
|
|
}
|
|
|
|
void ZoneServer::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;
|
|
}
|
|
case ServerOP_ZAAuth: {
|
|
break;
|
|
}
|
|
case ServerOP_LSZoneBoot: {
|
|
if (pack->size == sizeof(ZoneBoot_Struct)) {
|
|
ZoneBoot_Struct* zbs = (ZoneBoot_Struct*)pack->pBuffer;
|
|
SetCompile(zbs->compile_time);
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_GroupInvite: {
|
|
if (pack->size != sizeof(GroupInvite_Struct))
|
|
break;
|
|
|
|
GroupInvite_Struct* gis = (GroupInvite_Struct*)pack->pBuffer;
|
|
|
|
client_list.SendPacket(gis->invitee_name, pack);
|
|
break;
|
|
}
|
|
case ServerOP_GroupFollow: {
|
|
if (pack->size != sizeof(ServerGroupFollow_Struct))
|
|
break;
|
|
|
|
ServerGroupFollow_Struct *sgfs = (ServerGroupFollow_Struct *)pack->pBuffer;
|
|
|
|
client_list.SendPacket(sgfs->gf.name1, pack);
|
|
break;
|
|
}
|
|
case ServerOP_GroupFollowAck: {
|
|
if (pack->size != sizeof(ServerGroupFollowAck_Struct))
|
|
break;
|
|
|
|
ServerGroupFollowAck_Struct *sgfas = (ServerGroupFollowAck_Struct *)pack->pBuffer;
|
|
|
|
client_list.SendPacket(sgfas->Name, pack);
|
|
break;
|
|
}
|
|
case ServerOP_GroupCancelInvite: {
|
|
if (pack->size != sizeof(GroupCancel_Struct))
|
|
break;
|
|
|
|
GroupCancel_Struct *gcs = (GroupCancel_Struct *)pack->pBuffer;
|
|
|
|
client_list.SendPacket(gcs->name1, pack);
|
|
break;
|
|
}
|
|
case ServerOP_GroupIDReq: {
|
|
SendGroupIDs();
|
|
break;
|
|
}
|
|
case ServerOP_GroupLeave: {
|
|
if (pack->size != sizeof(ServerGroupLeave_Struct))
|
|
break;
|
|
zoneserver_list.SendPacket(pack); //bounce it to all zones
|
|
break;
|
|
}
|
|
|
|
case ServerOP_GroupJoin: {
|
|
if (pack->size != sizeof(ServerGroupJoin_Struct))
|
|
break;
|
|
zoneserver_list.SendPacket(pack); //bounce it to all zones
|
|
break;
|
|
}
|
|
|
|
case ServerOP_ForceGroupUpdate: {
|
|
if (pack->size != sizeof(ServerForceGroupUpdate_Struct))
|
|
break;
|
|
zoneserver_list.SendPacket(pack); //bounce it to all zones
|
|
break;
|
|
}
|
|
|
|
case ServerOP_OOZGroupMessage: {
|
|
zoneserver_list.SendPacket(pack); //bounce it to all zones
|
|
break;
|
|
}
|
|
|
|
case ServerOP_DisbandGroup: {
|
|
if (pack->size != sizeof(ServerDisbandGroup_Struct))
|
|
break;
|
|
zoneserver_list.SendPacket(pack); //bounce it to all zones
|
|
break;
|
|
}
|
|
|
|
case ServerOP_RaidAdd: {
|
|
if (pack->size != sizeof(ServerRaidGeneralAction_Struct))
|
|
break;
|
|
|
|
zoneserver_list.SendPacket(pack);
|
|
break;
|
|
}
|
|
|
|
case ServerOP_RaidRemove: {
|
|
if (pack->size != sizeof(ServerRaidGeneralAction_Struct))
|
|
break;
|
|
|
|
zoneserver_list.SendPacket(pack);
|
|
break;
|
|
}
|
|
|
|
case ServerOP_RaidDisband: {
|
|
if (pack->size != sizeof(ServerRaidGeneralAction_Struct))
|
|
break;
|
|
|
|
zoneserver_list.SendPacket(pack);
|
|
break;
|
|
}
|
|
|
|
case ServerOP_RaidLockFlag: {
|
|
if (pack->size != sizeof(ServerRaidGeneralAction_Struct))
|
|
break;
|
|
|
|
zoneserver_list.SendPacket(pack);
|
|
break;
|
|
}
|
|
|
|
case ServerOP_RaidChangeGroup: {
|
|
if (pack->size != sizeof(ServerRaidGeneralAction_Struct))
|
|
break;
|
|
|
|
zoneserver_list.SendPacket(pack);
|
|
break;
|
|
}
|
|
|
|
case ServerOP_UpdateGroup: {
|
|
if (pack->size != sizeof(ServerRaidGeneralAction_Struct))
|
|
break;
|
|
|
|
zoneserver_list.SendPacket(pack);
|
|
break;
|
|
}
|
|
|
|
case ServerOP_RaidGroupDisband: {
|
|
if (pack->size != sizeof(ServerRaidGeneralAction_Struct))
|
|
break;
|
|
|
|
zoneserver_list.SendPacket(pack);
|
|
break;
|
|
}
|
|
|
|
case ServerOP_RaidGroupAdd: {
|
|
if (pack->size != sizeof(ServerRaidGroupAction_Struct))
|
|
break;
|
|
|
|
zoneserver_list.SendPacket(pack);
|
|
break;
|
|
}
|
|
|
|
case ServerOP_RaidGroupRemove: {
|
|
if (pack->size != sizeof(ServerRaidGroupAction_Struct))
|
|
break;
|
|
|
|
zoneserver_list.SendPacket(pack);
|
|
break;
|
|
}
|
|
|
|
case ServerOP_RaidGroupSay: {
|
|
zoneserver_list.SendPacket(pack);
|
|
break;
|
|
}
|
|
|
|
case ServerOP_RaidSay: {
|
|
zoneserver_list.SendPacket(pack);
|
|
break;
|
|
}
|
|
|
|
case ServerOP_RaidGroupLeader: {
|
|
if (pack->size != sizeof(ServerRaidGeneralAction_Struct))
|
|
break;
|
|
|
|
zoneserver_list.SendPacket(pack);
|
|
break;
|
|
}
|
|
|
|
case ServerOP_RaidLeader: {
|
|
if (pack->size != sizeof(ServerRaidGeneralAction_Struct))
|
|
break;
|
|
|
|
zoneserver_list.SendPacket(pack);
|
|
break;
|
|
}
|
|
|
|
case ServerOP_DetailsChange: {
|
|
if (pack->size != sizeof(ServerRaidGeneralAction_Struct))
|
|
break;
|
|
|
|
zoneserver_list.SendPacket(pack);
|
|
break;
|
|
}
|
|
|
|
case ServerOP_RaidMOTD: {
|
|
if (pack->size < sizeof(ServerRaidMOTD_Struct))
|
|
break;
|
|
|
|
zoneserver_list.SendPacket(pack);
|
|
break;
|
|
}
|
|
|
|
case ServerOP_SpawnCondition: {
|
|
if (pack->size != sizeof(ServerSpawnCondition_Struct))
|
|
break;
|
|
//bounce the packet to the correct zone server, if its up
|
|
ServerSpawnCondition_Struct* ssc = (ServerSpawnCondition_Struct*)pack->pBuffer;
|
|
zoneserver_list.SendPacket(ssc->zoneID, ssc->instanceID, pack);
|
|
break;
|
|
}
|
|
case ServerOP_SpawnEvent: {
|
|
if (pack->size != sizeof(ServerSpawnEvent_Struct))
|
|
break;
|
|
//bounce the packet to the correct zone server, if its up
|
|
ServerSpawnEvent_Struct* sse = (ServerSpawnEvent_Struct*)pack->pBuffer;
|
|
zoneserver_list.SendPacket(sse->zoneID, 0, pack);
|
|
break;
|
|
}
|
|
case ServerOP_ChannelMessage: {
|
|
if (pack->size < sizeof(ServerChannelMessage_Struct))
|
|
break;
|
|
ServerChannelMessage_Struct* scm = (ServerChannelMessage_Struct*)pack->pBuffer;
|
|
if (scm->chan_num == ChatChannel_UCSRelay)
|
|
{
|
|
UCSLink.SendMessage(scm->from, scm->message);
|
|
break;
|
|
}
|
|
if (scm->chan_num == ChatChannel_Tell || scm->chan_num == ChatChannel_TellEcho) {
|
|
if (scm->deliverto[0] == '*') {
|
|
|
|
if (console) {
|
|
auto con = console->FindByAccountName(&scm->deliverto[1]);
|
|
if (((!con) || (!con->SendChannelMessage(scm, [&scm]() {
|
|
auto pack = new ServerPacket(ServerOP_ChannelMessage,
|
|
sizeof(ServerChannelMessage_Struct) + strlen(scm->message) + 1);
|
|
memcpy(pack->pBuffer, scm, pack->size);
|
|
ServerChannelMessage_Struct* scm2 = (ServerChannelMessage_Struct*)pack->pBuffer;
|
|
strcpy(scm2->deliverto, scm2->from);
|
|
scm2->noreply = true;
|
|
client_list.SendPacket(scm->from, pack);
|
|
safe_delete(pack);
|
|
}))) && (!scm->noreply))
|
|
{
|
|
zoneserver_list.SendEmoteMessage(scm->from, 0, 0, 0, "%s is not online at this time.", scm->to);
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
|
|
ClientListEntry* cle = client_list.FindCharacter(scm->deliverto);
|
|
if (cle == 0 || cle->Online() < CLE_Status::Zoning ||
|
|
(cle->TellsOff() && ((cle->Anon() == 1 && scm->fromadmin < cle->Admin()) || scm->fromadmin < 80))) {
|
|
if (!scm->noreply) {
|
|
ClientListEntry* sender = client_list.FindCharacter(scm->from);
|
|
if (!sender || !sender->Server())
|
|
break;
|
|
scm->noreply = true;
|
|
scm->queued = 3; // offline
|
|
strcpy(scm->deliverto, scm->from);
|
|
// ideally this would be trimming off the message too, oh well
|
|
sender->Server()->SendPacket(pack);
|
|
}
|
|
}
|
|
else if (cle->Online() == CLE_Status::Zoning) {
|
|
if (!scm->noreply) {
|
|
ClientListEntry* sender = client_list.FindCharacter(scm->from);
|
|
if (cle->TellQueueFull()) {
|
|
if (!sender || !sender->Server())
|
|
break;
|
|
scm->noreply = true;
|
|
scm->queued = 2; // queue full
|
|
strcpy(scm->deliverto, scm->from);
|
|
sender->Server()->SendPacket(pack);
|
|
}
|
|
else {
|
|
size_t struct_size = sizeof(ServerChannelMessage_Struct) + strlen(scm->message) + 1;
|
|
ServerChannelMessage_Struct *temp = (ServerChannelMessage_Struct *) new uchar[struct_size];
|
|
memset(temp, 0, struct_size); // just in case, was seeing some corrupt messages, but it shouldn't happen
|
|
memcpy(temp, scm, struct_size);
|
|
temp->noreply = true;
|
|
cle->PushToTellQueue(temp); // deallocation is handled in processing or deconstructor
|
|
|
|
if (!sender || !sender->Server())
|
|
break;
|
|
scm->noreply = true;
|
|
scm->queued = 1; // queued
|
|
strcpy(scm->deliverto, scm->from);
|
|
sender->Server()->SendPacket(pack);
|
|
}
|
|
}
|
|
}
|
|
else if (cle->Server() == 0) {
|
|
if (!scm->noreply)
|
|
zoneserver_list.SendEmoteMessage(scm->from, 0, 0, 0, "You told %s, '%s is not contactable at this time'", scm->to, scm->to);
|
|
}
|
|
else
|
|
cle->Server()->SendPacket(pack);
|
|
}
|
|
else {
|
|
if (scm->chan_num == ChatChannel_OOC || scm->chan_num == ChatChannel_Broadcast
|
|
|| scm->chan_num == ChatChannel_GMSAY) {
|
|
if (console) {
|
|
console->SendChannelMessage(scm, [&scm]() {
|
|
auto pack = new ServerPacket(ServerOP_ChannelMessage,
|
|
sizeof(ServerChannelMessage_Struct) + strlen(scm->message) + 1);
|
|
memcpy(pack->pBuffer, scm, pack->size);
|
|
ServerChannelMessage_Struct* scm2 = (ServerChannelMessage_Struct*)pack->pBuffer;
|
|
strcpy(scm2->deliverto, scm2->from);
|
|
scm2->noreply = true;
|
|
client_list.SendPacket(scm->from, pack);
|
|
safe_delete(pack);
|
|
});
|
|
}
|
|
}
|
|
zoneserver_list.SendPacket(pack);
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_EmoteMessage: {
|
|
ServerEmoteMessage_Struct* sem = (ServerEmoteMessage_Struct*)pack->pBuffer;
|
|
zoneserver_list.SendEmoteMessageRaw(sem->to, sem->guilddbid, sem->minstatus, sem->type, sem->message);
|
|
break;
|
|
}
|
|
case ServerOP_VoiceMacro: {
|
|
|
|
ServerVoiceMacro_Struct* svm = (ServerVoiceMacro_Struct*)pack->pBuffer;
|
|
|
|
if (svm->Type == VoiceMacroTell) {
|
|
|
|
ClientListEntry* cle = client_list.FindCharacter(svm->To);
|
|
|
|
if (!cle || (cle->Online() < CLE_Status::Zoning) || !cle->Server()) {
|
|
|
|
zoneserver_list.SendEmoteMessage(svm->From, 0, 0, 0, "'%s is not online at this time'", svm->To);
|
|
|
|
break;
|
|
}
|
|
|
|
cle->Server()->SendPacket(pack);
|
|
}
|
|
else
|
|
zoneserver_list.SendPacket(pack);
|
|
|
|
break;
|
|
}
|
|
|
|
case ServerOP_RezzPlayerAccept: {
|
|
zoneserver_list.SendPacket(pack);
|
|
break;
|
|
}
|
|
case ServerOP_RezzPlayer: {
|
|
|
|
RezzPlayer_Struct* sRezz = (RezzPlayer_Struct*)pack->pBuffer;
|
|
if (zoneserver_list.SendPacket(pack)) {
|
|
LogInfo("Sent Rez packet for [{}]", sRezz->rez.your_name);
|
|
}
|
|
else {
|
|
LogInfo("Could not send Rez packet for [{}]", sRezz->rez.your_name);
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_RezzPlayerReject:
|
|
{
|
|
char *Recipient = (char *)pack->pBuffer;
|
|
client_list.SendPacket(Recipient, pack);
|
|
break;
|
|
}
|
|
|
|
case ServerOP_MultiLineMsg: {
|
|
ServerMultiLineMsg_Struct* mlm = (ServerMultiLineMsg_Struct*)pack->pBuffer;
|
|
client_list.SendPacket(mlm->to, pack);
|
|
break;
|
|
}
|
|
case ServerOP_SetZone: {
|
|
if (pack->size != sizeof(SetZone_Struct))
|
|
break;
|
|
|
|
SetZone_Struct* szs = (SetZone_Struct*)pack->pBuffer;
|
|
if (szs->zoneid != 0) {
|
|
if (ZoneName(szs->zoneid))
|
|
SetZone(szs->zoneid, szs->instanceid, szs->staticzone);
|
|
else
|
|
SetZone(0);
|
|
}
|
|
else
|
|
SetZone(0);
|
|
|
|
break;
|
|
}
|
|
case ServerOP_SetConnectInfo: {
|
|
if (pack->size != sizeof(ServerConnectInfo))
|
|
break;
|
|
ServerConnectInfo* sci = (ServerConnectInfo*)pack->pBuffer;
|
|
|
|
if (!sci->port) {
|
|
client_port = zoneserver_list.GetAvailableZonePort();
|
|
|
|
ServerPacket p(ServerOP_SetConnectInfo, sizeof(ServerConnectInfo));
|
|
memset(p.pBuffer, 0, sizeof(ServerConnectInfo));
|
|
ServerConnectInfo* sci = (ServerConnectInfo*)p.pBuffer;
|
|
sci->port = client_port;
|
|
SendPacket(&p);
|
|
LogInfo("Auto zone port configuration. Telling zone to use port [{}]", client_port);
|
|
}
|
|
else {
|
|
client_port = sci->port;
|
|
LogInfo("Zone specified port [{}]", client_port);
|
|
}
|
|
|
|
if (sci->address[0]) {
|
|
strn0cpy(client_address, sci->address, 250);
|
|
LogInfo("Zone specified address [{}]", sci->address);
|
|
}
|
|
|
|
if (sci->local_address[0]) {
|
|
strn0cpy(client_local_address, sci->local_address, 250);
|
|
LogInfo("Zone specified local address [{}]", sci->address);
|
|
}
|
|
|
|
if (sci->process_id) {
|
|
zone_os_process_id = sci->process_id;
|
|
}
|
|
|
|
}
|
|
case ServerOP_SetLaunchName: {
|
|
if (pack->size != sizeof(LaunchName_Struct))
|
|
break;
|
|
const LaunchName_Struct* ln = (const LaunchName_Struct*)pack->pBuffer;
|
|
launcher_name = ln->launcher_name;
|
|
launched_name = ln->zone_name;
|
|
LogInfo("Zone started with name [{}] by launcher [{}]", launched_name.c_str(), launcher_name.c_str());
|
|
break;
|
|
}
|
|
case ServerOP_ShutdownAll: {
|
|
if (pack->size == 0) {
|
|
zoneserver_list.SendPacket(pack);
|
|
zoneserver_list.Process();
|
|
CatchSignal(2);
|
|
}
|
|
else {
|
|
WorldShutDown_Struct* wsd = (WorldShutDown_Struct*)pack->pBuffer;
|
|
if (wsd->time == 0 && wsd->interval == 0 && zoneserver_list.shutdowntimer->Enabled()) {
|
|
zoneserver_list.shutdowntimer->Disable();
|
|
zoneserver_list.reminder->Disable();
|
|
}
|
|
else {
|
|
zoneserver_list.shutdowntimer->SetTimer(wsd->time);
|
|
zoneserver_list.reminder->SetTimer(wsd->interval - 1000);
|
|
zoneserver_list.reminder->SetAtTrigger(wsd->interval);
|
|
zoneserver_list.shutdowntimer->Start();
|
|
zoneserver_list.reminder->Start();
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_ZoneShutdown: {
|
|
ServerZoneStateChange_struct* s = (ServerZoneStateChange_struct *)pack->pBuffer;
|
|
ZoneServer* zs = 0;
|
|
if (s->ZoneServerID != 0)
|
|
zs = zoneserver_list.FindByID(s->ZoneServerID);
|
|
else if (s->zoneid != 0)
|
|
zs = zoneserver_list.FindByName(ZoneName(s->zoneid));
|
|
else
|
|
zoneserver_list.SendEmoteMessage(s->adminname, 0, 0, 0, "Error: SOP_ZoneShutdown: neither ID nor name specified");
|
|
|
|
if (zs == 0)
|
|
zoneserver_list.SendEmoteMessage(s->adminname, 0, 0, 0, "Error: SOP_ZoneShutdown: zoneserver not found");
|
|
else
|
|
zs->SendPacket(pack);
|
|
break;
|
|
}
|
|
case ServerOP_ZoneBootup: {
|
|
ServerZoneStateChange_struct* s = (ServerZoneStateChange_struct *)pack->pBuffer;
|
|
zoneserver_list.SOPZoneBootup(s->adminname, s->ZoneServerID, ZoneName(s->zoneid), s->makestatic);
|
|
break;
|
|
}
|
|
case ServerOP_ZoneStatus: {
|
|
if (pack->size >= 1)
|
|
zoneserver_list.SendZoneStatus((char *)&pack->pBuffer[1], (uint8)pack->pBuffer[0], this);
|
|
break;
|
|
|
|
}
|
|
case ServerOP_AcceptWorldEntrance: {
|
|
if (pack->size != sizeof(WorldToZone_Struct))
|
|
break;
|
|
|
|
WorldToZone_Struct* wtz = (WorldToZone_Struct*)pack->pBuffer;
|
|
Client* client = 0;
|
|
client = client_list.FindByAccountID(wtz->account_id);
|
|
if (client != 0)
|
|
client->Clearance(wtz->response);
|
|
}
|
|
case ServerOP_ZoneToZoneRequest: {
|
|
//
|
|
// ZoneChange is received by the zone the player is in, then the
|
|
// zone sends a ZTZ which ends up here. This code then find the target
|
|
// (ingress point) and boots it if needed, then sends the ZTZ to it.
|
|
// The ingress server will decide wether the player can enter, then will
|
|
// send back the ZTZ to here. This packet is passed back to the egress
|
|
// server, which will send a ZoneChange response back to the client
|
|
// which can be an error, or a success, in which case the client will
|
|
// disconnect, and their zone location will be saved when ~Client is
|
|
// called, so it will be available when they ask to zone.
|
|
//
|
|
|
|
|
|
if (pack->size != sizeof(ZoneToZone_Struct))
|
|
break;
|
|
ZoneToZone_Struct* ztz = (ZoneToZone_Struct*)pack->pBuffer;
|
|
ClientListEntry* client = nullptr;
|
|
if (WorldConfig::get()->UpdateStats)
|
|
client = client_list.FindCharacter(ztz->name);
|
|
|
|
LogInfo("ZoneToZone request for [{}] current zone [{}] req zone [{}]", ztz->name, ztz->current_zone_id, ztz->requested_zone_id);
|
|
|
|
/* This is a request from the egress zone */
|
|
if (GetZoneID() == ztz->current_zone_id && GetInstanceID() == ztz->current_instance_id) {
|
|
LogInfo("Processing ZTZ for egress from zone for client [{}]", ztz->name);
|
|
|
|
if (ztz->admin < 80 && ztz->ignorerestrictions < 2 && zoneserver_list.IsZoneLocked(ztz->requested_zone_id)) {
|
|
ztz->response = 0;
|
|
SendPacket(pack);
|
|
break;
|
|
}
|
|
|
|
ZoneServer *ingress_server = nullptr;
|
|
if (ztz->requested_instance_id > 0) {
|
|
ingress_server = zoneserver_list.FindByInstanceID(ztz->requested_instance_id);
|
|
}
|
|
else {
|
|
ingress_server = zoneserver_list.FindByZoneID(ztz->requested_zone_id);
|
|
}
|
|
|
|
/* Zone was already running*/
|
|
if (ingress_server) {
|
|
LogInfo("Found a zone already booted for [{}]", ztz->name);
|
|
ztz->response = 1;
|
|
}
|
|
/* Boot the Zone*/
|
|
else {
|
|
int server_id;
|
|
if ((server_id = zoneserver_list.TriggerBootup(ztz->requested_zone_id, ztz->requested_instance_id))) {
|
|
LogInfo("Successfully booted a zone for [{}]", ztz->name);
|
|
// bootup successful, ready to rock
|
|
ztz->response = 1;
|
|
ingress_server = zoneserver_list.FindByID(server_id);
|
|
}
|
|
else {
|
|
LogError("failed to boot a zone for [{}]", ztz->name);
|
|
// bootup failed, send back error code 0
|
|
ztz->response = 0;
|
|
}
|
|
}
|
|
if (ztz->response != 0 && client)
|
|
client->LSZoneChange(ztz);
|
|
SendPacket(pack); // send back to egress server
|
|
if (ingress_server) {
|
|
ingress_server->SendPacket(pack); // inform target server
|
|
}
|
|
}
|
|
/* Response from Ingress server, route back to egress */
|
|
else {
|
|
|
|
LogInfo("Processing ZTZ for ingress to zone for client [{}]", ztz->name);
|
|
ZoneServer *egress_server = nullptr;
|
|
if (ztz->current_instance_id > 0) {
|
|
egress_server = zoneserver_list.FindByInstanceID(ztz->current_instance_id);
|
|
}
|
|
else {
|
|
egress_server = zoneserver_list.FindByZoneID(ztz->current_zone_id);
|
|
}
|
|
|
|
if (egress_server) {
|
|
egress_server->SendPacket(pack);
|
|
}
|
|
}
|
|
|
|
break;
|
|
}
|
|
case ServerOP_ClientList: {
|
|
if (pack->size != sizeof(ServerClientList_Struct)) {
|
|
LogInfo("Wrong size on ServerOP_ClientList. Got: [{}], Expected: [{}]", pack->size, sizeof(ServerClientList_Struct));
|
|
break;
|
|
}
|
|
client_list.ClientUpdate(this, (ServerClientList_Struct*)pack->pBuffer);
|
|
break;
|
|
}
|
|
case ServerOP_ClientListKA: {
|
|
ServerClientListKeepAlive_Struct* sclka = (ServerClientListKeepAlive_Struct*)pack->pBuffer;
|
|
if (pack->size < 4 || pack->size != 4 + (4 * sclka->numupdates)) {
|
|
LogInfo("Wrong size on ServerOP_ClientListKA. Got: [{}], Expected: [{}]", pack->size, (4 + (4 * sclka->numupdates)));
|
|
break;
|
|
}
|
|
client_list.CLEKeepAlive(sclka->numupdates, sclka->wid);
|
|
break;
|
|
}
|
|
case ServerOP_Who: {
|
|
ServerWhoAll_Struct* whoall = (ServerWhoAll_Struct*)pack->pBuffer;
|
|
auto whom = new Who_All_Struct;
|
|
memset(whom, 0, sizeof(Who_All_Struct));
|
|
whom->gmlookup = whoall->gmlookup;
|
|
whom->lvllow = whoall->lvllow;
|
|
whom->lvlhigh = whoall->lvlhigh;
|
|
whom->wclass = whoall->wclass;
|
|
whom->wrace = whoall->wrace;
|
|
strcpy(whom->whom, whoall->whom);
|
|
client_list.SendWhoAll(whoall->fromid, whoall->from, whoall->admin, whom, this);
|
|
safe_delete(whom);
|
|
break;
|
|
}
|
|
case ServerOP_RequestOnlineGuildMembers: {
|
|
ServerRequestOnlineGuildMembers_Struct *srogms = (ServerRequestOnlineGuildMembers_Struct*)pack->pBuffer;
|
|
client_list.SendOnlineGuildMembers(srogms->FromID, srogms->GuildID);
|
|
break;
|
|
}
|
|
case ServerOP_ClientVersionSummary: {
|
|
ServerRequestClientVersionSummary_Struct *srcvss = (ServerRequestClientVersionSummary_Struct*)pack->pBuffer;
|
|
client_list.SendClientVersionSummary(srcvss->Name);
|
|
break;
|
|
}
|
|
case ServerOP_ReloadLogs: {
|
|
zoneserver_list.SendPacket(pack);
|
|
LogSys.LoadLogDatabaseSettings();
|
|
break;
|
|
}
|
|
case ServerOP_ReloadRules: {
|
|
zoneserver_list.SendPacket(pack);
|
|
RuleManager::Instance()->LoadRules(&database, "default", true);
|
|
break;
|
|
}
|
|
case ServerOP_ReloadRulesWorld:
|
|
{
|
|
RuleManager::Instance()->LoadRules(&database, "default", true);
|
|
break;
|
|
}
|
|
case ServerOP_ReloadPerlExportSettings:
|
|
{
|
|
zoneserver_list.SendPacket(pack);
|
|
break;
|
|
}
|
|
case ServerOP_CameraShake:
|
|
{
|
|
zoneserver_list.SendPacket(pack);
|
|
break;
|
|
}
|
|
case ServerOP_FriendsWho: {
|
|
ServerFriendsWho_Struct* FriendsWho = (ServerFriendsWho_Struct*)pack->pBuffer;
|
|
client_list.SendFriendsWho(FriendsWho, this);
|
|
break;
|
|
}
|
|
case ServerOP_LFGMatches: {
|
|
ServerLFGMatchesRequest_Struct* smrs = (ServerLFGMatchesRequest_Struct*)pack->pBuffer;
|
|
client_list.SendLFGMatches(smrs);
|
|
break;
|
|
}
|
|
case ServerOP_LFPMatches: {
|
|
ServerLFPMatchesRequest_Struct* smrs = (ServerLFPMatchesRequest_Struct*)pack->pBuffer;
|
|
LFPGroupList.SendLFPMatches(smrs);
|
|
break;
|
|
}
|
|
case ServerOP_LFPUpdate: {
|
|
ServerLFPUpdate_Struct* sus = (ServerLFPUpdate_Struct*)pack->pBuffer;
|
|
if (sus->Action)
|
|
LFPGroupList.UpdateGroup(sus);
|
|
else
|
|
LFPGroupList.RemoveGroup(sus);
|
|
break;
|
|
}
|
|
case ServerOP_ZonePlayer: {
|
|
//ServerZonePlayer_Struct* szp = (ServerZonePlayer_Struct*) pack->pBuffer;
|
|
zoneserver_list.SendPacket(pack);
|
|
break;
|
|
}
|
|
case ServerOP_KickPlayer: {
|
|
zoneserver_list.SendPacket(pack);
|
|
break;
|
|
}
|
|
case ServerOP_KillPlayer: {
|
|
zoneserver_list.SendPacket(pack);
|
|
break;
|
|
}
|
|
|
|
case ServerOP_GuildRankUpdate:
|
|
{
|
|
zoneserver_list.SendPacket(pack);
|
|
break;
|
|
}
|
|
//these opcodes get processed by the guild manager.
|
|
case ServerOP_RefreshGuild:
|
|
case ServerOP_DeleteGuild:
|
|
case ServerOP_GuildCharRefresh:
|
|
case ServerOP_GuildMemberUpdate: {
|
|
guild_mgr.ProcessZonePacket(pack);
|
|
break;
|
|
}
|
|
|
|
case ServerOP_FlagUpdate: {
|
|
ClientListEntry* cle = client_list.FindCLEByAccountID(*((uint32*)pack->pBuffer));
|
|
if (cle)
|
|
cle->SetAdmin(*((int16*)&pack->pBuffer[4]));
|
|
zoneserver_list.SendPacket(pack);
|
|
break;
|
|
}
|
|
case ServerOP_GMGoto: {
|
|
if (pack->size != sizeof(ServerGMGoto_Struct)) {
|
|
LogInfo("Wrong size on ServerOP_GMGoto. Got: [{}], Expected: [{}]", pack->size, sizeof(ServerGMGoto_Struct));
|
|
break;
|
|
}
|
|
ServerGMGoto_Struct* gmg = (ServerGMGoto_Struct*)pack->pBuffer;
|
|
ClientListEntry* cle = client_list.FindCharacter(gmg->gotoname);
|
|
if (cle != 0) {
|
|
if (cle->Server() == 0)
|
|
this->SendEmoteMessage(gmg->myname, 0, 0, 13, "Error: Cannot identify %s's zoneserver.", gmg->gotoname);
|
|
else if (cle->Anon() == 1 && cle->Admin() > gmg->admin) // no snooping for anon GMs
|
|
this->SendEmoteMessage(gmg->myname, 0, 0, 13, "Error: %s not found", gmg->gotoname);
|
|
else
|
|
cle->Server()->SendPacket(pack);
|
|
}
|
|
else {
|
|
this->SendEmoteMessage(gmg->myname, 0, 0, 13, "Error: %s not found", gmg->gotoname);
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_Lock: {
|
|
if (pack->size != sizeof(ServerLock_Struct)) {
|
|
LogInfo("Wrong size on ServerOP_Lock. Got: [{}], Expected: [{}]", pack->size, sizeof(ServerLock_Struct));
|
|
break;
|
|
}
|
|
ServerLock_Struct* slock = (ServerLock_Struct*)pack->pBuffer;
|
|
if (slock->mode >= 1)
|
|
WorldConfig::LockWorld();
|
|
else
|
|
WorldConfig::UnlockWorld();
|
|
if (loginserverlist.Connected()) {
|
|
loginserverlist.SendStatus();
|
|
if (slock->mode >= 1)
|
|
this->SendEmoteMessage(slock->myname, 0, 0, 13, "World locked");
|
|
else
|
|
this->SendEmoteMessage(slock->myname, 0, 0, 13, "World unlocked");
|
|
}
|
|
else {
|
|
if (slock->mode >= 1)
|
|
this->SendEmoteMessage(slock->myname, 0, 0, 13, "World locked, but login server not connected.");
|
|
else
|
|
this->SendEmoteMessage(slock->myname, 0, 0, 13, "World unlocked, but login server not conencted.");
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_Motd: {
|
|
if (pack->size != sizeof(ServerMotd_Struct)) {
|
|
LogInfo("Wrong size on ServerOP_Motd. Got: [{}], Expected: [{}]", pack->size, sizeof(ServerMotd_Struct));
|
|
break;
|
|
}
|
|
ServerMotd_Struct* smotd = (ServerMotd_Struct*)pack->pBuffer;
|
|
database.SetVariable("MOTD", smotd->motd);
|
|
//this->SendEmoteMessage(smotd->myname, 0, 0, 13, "Updated Motd.");
|
|
zoneserver_list.SendPacket(pack);
|
|
break;
|
|
}
|
|
case ServerOP_Uptime: {
|
|
if (pack->size != sizeof(ServerUptime_Struct)) {
|
|
LogInfo("Wrong size on ServerOP_Uptime. Got: [{}], Expected: [{}]", pack->size, sizeof(ServerUptime_Struct));
|
|
break;
|
|
}
|
|
ServerUptime_Struct* sus = (ServerUptime_Struct*)pack->pBuffer;
|
|
if (sus->zoneserverid == 0) {
|
|
ZSList::ShowUpTime(this, sus->adminname);
|
|
}
|
|
else {
|
|
ZoneServer* zs = zoneserver_list.FindByID(sus->zoneserverid);
|
|
if (zs)
|
|
zs->SendPacket(pack);
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_Petition: {
|
|
zoneserver_list.SendPacket(pack);
|
|
break;
|
|
}
|
|
case ServerOP_GetWorldTime: {
|
|
LogInfo("Broadcasting a world time update");
|
|
auto pack = new ServerPacket;
|
|
|
|
pack->opcode = ServerOP_SyncWorldTime;
|
|
pack->size = sizeof(eqTimeOfDay);
|
|
pack->pBuffer = new uchar[pack->size];
|
|
memset(pack->pBuffer, 0, pack->size);
|
|
eqTimeOfDay* tod = (eqTimeOfDay*)pack->pBuffer;
|
|
tod->start_eqtime = zoneserver_list.worldclock.getStartEQTime();
|
|
tod->start_realtime = zoneserver_list.worldclock.getStartRealTime();
|
|
SendPacket(pack);
|
|
safe_delete(pack);
|
|
break;
|
|
}
|
|
case ServerOP_RefreshCensorship: {
|
|
zoneserver_list.SendPacket(pack);
|
|
break;
|
|
}
|
|
case ServerOP_SetWorldTime: {
|
|
LogNetcode("Received SetWorldTime");
|
|
eqTimeOfDay* newtime = (eqTimeOfDay*)pack->pBuffer;
|
|
zoneserver_list.worldclock.SetCurrentEQTimeOfDay(newtime->start_eqtime, newtime->start_realtime);
|
|
LogInfo("New time = [{}]-[{}]-[{}] [{}]:[{}] ([{}])\n", newtime->start_eqtime.year, newtime->start_eqtime.month, (int)newtime->start_eqtime.day, (int)newtime->start_eqtime.hour, (int)newtime->start_eqtime.minute, (int)newtime->start_realtime);
|
|
database.SaveTime((int)newtime->start_eqtime.minute, (int)newtime->start_eqtime.hour, (int)newtime->start_eqtime.day, newtime->start_eqtime.month, newtime->start_eqtime.year);
|
|
zoneserver_list.SendTimeSync();
|
|
break;
|
|
}
|
|
case ServerOP_IPLookup: {
|
|
if (pack->size < sizeof(ServerGenericWorldQuery_Struct)) {
|
|
LogInfo("Wrong size on ServerOP_IPLookup. Got: [{}], Expected (at least): [{}]", pack->size, sizeof(ServerGenericWorldQuery_Struct));
|
|
break;
|
|
}
|
|
ServerGenericWorldQuery_Struct* sgwq = (ServerGenericWorldQuery_Struct*)pack->pBuffer;
|
|
if (pack->size == sizeof(ServerGenericWorldQuery_Struct))
|
|
client_list.SendCLEList(sgwq->admin, sgwq->from, this);
|
|
else
|
|
client_list.SendCLEList(sgwq->admin, sgwq->from, this, sgwq->query);
|
|
break;
|
|
}
|
|
case ServerOP_LockZone: {
|
|
if (pack->size < sizeof(ServerLockZone_Struct)) {
|
|
LogInfo("Wrong size on ServerOP_LockZone. Got: [{}], Expected: [{}]", pack->size, sizeof(ServerLockZone_Struct));
|
|
break;
|
|
}
|
|
ServerLockZone_Struct* s = (ServerLockZone_Struct*)pack->pBuffer;
|
|
switch (s->op) {
|
|
case 0:
|
|
zoneserver_list.ListLockedZones(s->adminname, this);
|
|
break;
|
|
case 1:
|
|
if (zoneserver_list.SetLockedZone(s->zoneID, true))
|
|
zoneserver_list.SendEmoteMessage(0, 0, 80, 15, "Zone locked: %s", ZoneName(s->zoneID));
|
|
else
|
|
this->SendEmoteMessageRaw(s->adminname, 0, 0, 0, "Failed to change lock");
|
|
break;
|
|
case 2:
|
|
if (zoneserver_list.SetLockedZone(s->zoneID, false))
|
|
zoneserver_list.SendEmoteMessage(0, 0, 80, 15, "Zone unlocked: %s", ZoneName(s->zoneID));
|
|
else
|
|
this->SendEmoteMessageRaw(s->adminname, 0, 0, 0, "Failed to change lock");
|
|
break;
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_ItemStatus: {
|
|
zoneserver_list.SendPacket(pack);
|
|
break;
|
|
}
|
|
case ServerOP_OOCMute: {
|
|
zoneserver_list.SendPacket(pack);
|
|
break;
|
|
}
|
|
case ServerOP_Revoke: {
|
|
RevokeStruct* rev = (RevokeStruct*)pack->pBuffer;
|
|
ClientListEntry* cle = client_list.FindCharacter(rev->name);
|
|
if (cle != 0 && cle->Server() != 0)
|
|
{
|
|
cle->Server()->SendPacket(pack);
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_SpawnPlayerCorpse: {
|
|
SpawnPlayerCorpse_Struct* s = (SpawnPlayerCorpse_Struct*)pack->pBuffer;
|
|
ZoneServer* zs = zoneserver_list.FindByZoneID(s->zone_id);
|
|
if (zs) {
|
|
zs->SendPacket(pack);
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_Consent: {
|
|
zoneserver_list.SendPacket(pack); // update corpses in all zones
|
|
break;
|
|
}
|
|
case ServerOP_Consent_Response: {
|
|
ServerOP_Consent_Struct* s = (ServerOP_Consent_Struct*)pack->pBuffer;
|
|
|
|
ZoneServer* owner_zs = nullptr;
|
|
if (s->instance_id == 0) {
|
|
owner_zs = zoneserver_list.FindByZoneID(s->zone_id);
|
|
}
|
|
else {
|
|
owner_zs = zoneserver_list.FindByInstanceID(s->instance_id);
|
|
}
|
|
|
|
if (owner_zs) {
|
|
owner_zs->SendPacket(pack);
|
|
}
|
|
else {
|
|
LogInfo("Unable to locate zone record for zone id [{}] or instance id [{}] in zoneserver list for ServerOP_Consent_Response operation", s->zone_id, s->instance_id);
|
|
}
|
|
|
|
if (s->consent_type == EQ::consent::Normal) {
|
|
// send the message to the client being granted or denied permission
|
|
ClientListEntry* cle = client_list.FindCharacter(s->grantname);
|
|
if (cle) {
|
|
ZoneServer* granted_zs = nullptr;
|
|
if (cle->instance() == 0) {
|
|
granted_zs = zoneserver_list.FindByZoneID(cle->zone());
|
|
}
|
|
else {
|
|
granted_zs = zoneserver_list.FindByInstanceID(cle->instance());
|
|
}
|
|
// avoid sending twice if owner and granted are in same zone
|
|
if (granted_zs && granted_zs != owner_zs) {
|
|
granted_zs->SendPacket(pack);
|
|
}
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
|
|
case ServerOP_InstanceUpdateTime:
|
|
{
|
|
ServerInstanceUpdateTime_Struct *iut = (ServerInstanceUpdateTime_Struct*)pack->pBuffer;
|
|
ZoneServer *zm = zoneserver_list.FindByInstanceID(iut->instance_id);
|
|
if (zm)
|
|
{
|
|
zm->SendPacket(pack);
|
|
}
|
|
break;
|
|
}
|
|
case ServerOP_QGlobalUpdate:
|
|
{
|
|
if (pack->size != sizeof(ServerQGlobalUpdate_Struct))
|
|
{
|
|
break;
|
|
}
|
|
|
|
zoneserver_list.SendPacket(pack);
|
|
break;
|
|
}
|
|
|
|
case ServerOP_QGlobalDelete:
|
|
{
|
|
if (pack->size != sizeof(ServerQGlobalDelete_Struct))
|
|
{
|
|
break;
|
|
}
|
|
|
|
zoneserver_list.SendPacket(pack);
|
|
break;
|
|
}
|
|
|
|
case ServerOP_AdventureRequest:
|
|
{
|
|
adventure_manager.CalculateAdventureRequestReply((const char*)pack->pBuffer);
|
|
break;
|
|
}
|
|
|
|
case ServerOP_AdventureRequestCreate:
|
|
{
|
|
adventure_manager.TryAdventureCreate((const char*)pack->pBuffer);
|
|
break;
|
|
}
|
|
|
|
case ServerOP_AdventureDataRequest:
|
|
{
|
|
AdventureFinishEvent fe;
|
|
while (adventure_manager.PopFinishedEvent((const char*)pack->pBuffer, fe))
|
|
{
|
|
adventure_manager.SendAdventureFinish(fe);
|
|
}
|
|
adventure_manager.GetAdventureData((const char*)pack->pBuffer);
|
|
break;
|
|
}
|
|
|
|
case ServerOP_AdventureClickDoor:
|
|
{
|
|
ServerPlayerClickedAdventureDoor_Struct *pcad = (ServerPlayerClickedAdventureDoor_Struct*)pack->pBuffer;
|
|
adventure_manager.PlayerClickedDoor(pcad->player, pcad->zone_id, pcad->id);
|
|
break;
|
|
}
|
|
|
|
case ServerOP_AdventureLeave:
|
|
{
|
|
adventure_manager.LeaveAdventure((const char*)pack->pBuffer);
|
|
break;
|
|
}
|
|
|
|
case ServerOP_AdventureCountUpdate:
|
|
{
|
|
ServerAdventureCount_Struct *sc = (ServerAdventureCount_Struct*)pack->pBuffer;
|
|
adventure_manager.IncrementCount(sc->instance_id);
|
|
break;
|
|
}
|
|
|
|
case ServerOP_AdventureAssaCountUpdate:
|
|
{
|
|
adventure_manager.IncrementAssassinationCount(*((uint16*)pack->pBuffer));
|
|
break;
|
|
}
|
|
case ServerOP_AdventureZoneData:
|
|
{
|
|
adventure_manager.GetZoneData(*((uint16*)pack->pBuffer));
|
|
break;
|
|
}
|
|
|
|
case ServerOP_AdventureLeaderboard:
|
|
{
|
|
ServerLeaderboardRequest_Struct *lr = (ServerLeaderboardRequest_Struct*)pack->pBuffer;
|
|
adventure_manager.DoLeaderboardRequest(lr->player, lr->type);
|
|
break;
|
|
}
|
|
|
|
case ServerOP_LSAccountUpdate:
|
|
{
|
|
LogNetcode("Received ServerOP_LSAccountUpdate packet from zone");
|
|
loginserverlist.SendAccountUpdate(pack);
|
|
break;
|
|
}
|
|
|
|
case ServerOP_UCSMailMessage:
|
|
{
|
|
UCSLink.SendPacket(pack);
|
|
break;
|
|
}
|
|
|
|
case ServerOP_UCSServerStatusRequest:
|
|
{
|
|
auto ucsss = (UCSServerStatus_Struct*)pack->pBuffer;
|
|
auto zs = zoneserver_list.FindByPort(ucsss->port);
|
|
if (!zs)
|
|
break;
|
|
|
|
auto outapp = new ServerPacket(ServerOP_UCSServerStatusReply, sizeof(UCSServerStatus_Struct));
|
|
ucsss = (UCSServerStatus_Struct*)outapp->pBuffer;
|
|
ucsss->available = (UCSServerAvailable_ ? 1 : 0);
|
|
ucsss->timestamp = Timer::GetCurrentTime();
|
|
zs->SendPacket(outapp);
|
|
safe_delete(outapp);
|
|
|
|
break;
|
|
}
|
|
|
|
case ServerOP_QSSendQuery:
|
|
case ServerOP_QueryServGeneric:
|
|
case ServerOP_Speech:
|
|
case ServerOP_QSPlayerLogTrades:
|
|
case ServerOP_QSPlayerLogHandins:
|
|
case ServerOP_QSPlayerLogNPCKills:
|
|
case ServerOP_QSPlayerLogDeletes:
|
|
case ServerOP_QSPlayerLogMoves:
|
|
case ServerOP_QSPlayerLogMerchantTransactions:
|
|
case ServerOP_QSPlayerDropItem:
|
|
{
|
|
QSLink.SendPacket(pack);
|
|
break;
|
|
}
|
|
case ServerOP_CZCastSpellPlayer:
|
|
case ServerOP_CZCastSpellGroup:
|
|
case ServerOP_CZCastSpellRaid:
|
|
case ServerOP_CZCastSpellGuild:
|
|
case ServerOP_CZMarqueePlayer:
|
|
case ServerOP_CZMarqueeGroup:
|
|
case ServerOP_CZMarqueeRaid:
|
|
case ServerOP_CZMarqueeGuild:
|
|
case ServerOP_CZMessagePlayer:
|
|
case ServerOP_CZMessageGroup:
|
|
case ServerOP_CZMessageRaid:
|
|
case ServerOP_CZMessageGuild:
|
|
case ServerOP_CZMovePlayer:
|
|
case ServerOP_CZMoveGroup:
|
|
case ServerOP_CZMoveRaid:
|
|
case ServerOP_CZMoveGuild:
|
|
case ServerOP_CZMoveInstancePlayer:
|
|
case ServerOP_CZMoveInstanceGroup:
|
|
case ServerOP_CZMoveInstanceRaid:
|
|
case ServerOP_CZMoveInstanceGuild:
|
|
case ServerOP_CZRemoveSpellPlayer:
|
|
case ServerOP_CZRemoveSpellGroup:
|
|
case ServerOP_CZRemoveSpellRaid:
|
|
case ServerOP_CZRemoveSpellGuild:
|
|
case ServerOP_CZSetEntityVariableByClientName:
|
|
case ServerOP_CZSetEntityVariableByNPCTypeID:
|
|
case ServerOP_CZSetEntityVariableByGroupID:
|
|
case ServerOP_CZSetEntityVariableByRaidID:
|
|
case ServerOP_CZSetEntityVariableByGuildID:
|
|
case ServerOP_CZSignalNPC:
|
|
case ServerOP_CZSignalClient:
|
|
case ServerOP_CZSignalClientByName:
|
|
case ServerOP_CZSignalGroup:
|
|
case ServerOP_CZSignalRaid:
|
|
case ServerOP_CZSignalGuild:
|
|
case ServerOP_CZTaskActivityResetPlayer:
|
|
case ServerOP_CZTaskActivityResetGroup:
|
|
case ServerOP_CZTaskActivityResetRaid:
|
|
case ServerOP_CZTaskActivityResetGuild:
|
|
case ServerOP_CZTaskActivityUpdatePlayer:
|
|
case ServerOP_CZTaskActivityUpdateGroup:
|
|
case ServerOP_CZTaskActivityUpdateRaid:
|
|
case ServerOP_CZTaskActivityUpdateGuild:
|
|
case ServerOP_CZTaskAssignPlayer:
|
|
case ServerOP_CZTaskAssignGroup:
|
|
case ServerOP_CZTaskAssignRaid:
|
|
case ServerOP_CZTaskAssignGuild:
|
|
case ServerOP_CZTaskDisablePlayer:
|
|
case ServerOP_CZTaskDisableGroup:
|
|
case ServerOP_CZTaskDisableRaid:
|
|
case ServerOP_CZTaskDisableGuild:
|
|
case ServerOP_CZTaskEnablePlayer:
|
|
case ServerOP_CZTaskEnableGroup:
|
|
case ServerOP_CZTaskEnableRaid:
|
|
case ServerOP_CZTaskEnableGuild:
|
|
case ServerOP_CZTaskFailPlayer:
|
|
case ServerOP_CZTaskFailGroup:
|
|
case ServerOP_CZTaskFailRaid:
|
|
case ServerOP_CZTaskFailGuild:
|
|
case ServerOP_CZTaskRemovePlayer:
|
|
case ServerOP_CZTaskRemoveGroup:
|
|
case ServerOP_CZTaskRemoveRaid:
|
|
case ServerOP_CZTaskRemoveGuild:
|
|
case ServerOP_CZLDoNUpdate:
|
|
case ServerOP_WWAssignTask:
|
|
case ServerOP_WWCastSpell:
|
|
case ServerOP_WWDisableTask:
|
|
case ServerOP_WWEnableTask:
|
|
case ServerOP_WWFailTask:
|
|
case ServerOP_WWMarquee:
|
|
case ServerOP_WWMessage:
|
|
case ServerOP_WWMove:
|
|
case ServerOP_WWMoveInstance:
|
|
case ServerOP_WWRemoveSpell:
|
|
case ServerOP_WWRemoveTask:
|
|
case ServerOP_WWResetActivity:
|
|
case ServerOP_WWSetEntityVariableClient:
|
|
case ServerOP_WWSetEntityVariableNPC:
|
|
case ServerOP_WWSignalClient:
|
|
case ServerOP_WWSignalNPC:
|
|
case ServerOP_WWUpdateActivity:
|
|
case ServerOP_DepopAllPlayersCorpses:
|
|
case ServerOP_DepopPlayerCorpse:
|
|
case ServerOP_ReloadTitles:
|
|
case ServerOP_SpawnStatusChange:
|
|
case ServerOP_ReloadTasks:
|
|
case ServerOP_ReloadWorld:
|
|
case ServerOP_UpdateSpawn:
|
|
{
|
|
zoneserver_list.SendPacket(pack);
|
|
break;
|
|
}
|
|
case ServerOP_ChangeSharedMem: {
|
|
std::string hotfix_name = std::string((char*)pack->pBuffer);
|
|
|
|
LogInfo("Loading items");
|
|
if (!database.LoadItems(hotfix_name)) {
|
|
LogInfo("Error: Could not load item data. But ignoring");
|
|
}
|
|
|
|
LogInfo("Loading skill caps");
|
|
if (!content_db.LoadSkillCaps(hotfix_name)) {
|
|
LogInfo("Error: Could not load skill cap data. But ignoring");
|
|
}
|
|
|
|
zoneserver_list.SendPacket(pack);
|
|
break;
|
|
}
|
|
|
|
case ServerOP_RequestTellQueue:
|
|
{
|
|
ServerRequestTellQueue_Struct* rtq = (ServerRequestTellQueue_Struct*)pack->pBuffer;
|
|
ClientListEntry *cle = client_list.FindCharacter(rtq->name);
|
|
if (!cle || cle->TellQueueEmpty())
|
|
break;
|
|
|
|
cle->ProcessTellQueue();
|
|
break;
|
|
}
|
|
case ServerOP_CZClientMessageString:
|
|
{
|
|
auto buf = reinterpret_cast<CZClientMessageString_Struct*>(pack->pBuffer);
|
|
client_list.SendPacket(buf->character_name, pack);
|
|
break;
|
|
}
|
|
case ServerOP_ExpeditionLockout:
|
|
case ServerOP_ExpeditionLockoutDuration:
|
|
case ServerOP_ExpeditionLockState:
|
|
case ServerOP_ExpeditionReplayOnJoin:
|
|
{
|
|
zoneserver_list.SendPacket(pack);
|
|
break;
|
|
}
|
|
case ServerOP_SharedTaskRequest:
|
|
case ServerOP_SharedTaskAddPlayer:
|
|
case ServerOP_SharedTaskAttemptRemove:
|
|
case ServerOP_SharedTaskUpdate:
|
|
case ServerOP_SharedTaskRequestMemberlist:
|
|
case ServerOP_SharedTaskRemovePlayer:
|
|
case ServerOP_SharedTaskInviteAcceptedPlayer:
|
|
case ServerOP_SharedTaskMakeLeader:
|
|
case ServerOP_SharedTaskCreateDynamicZone:
|
|
case ServerOP_SharedTaskPurgeAllCommand:
|
|
case ServerOP_SharedTaskPlayerList:
|
|
case ServerOP_SharedTaskKickPlayers:
|
|
{
|
|
SharedTaskWorldMessaging::HandleZoneMessage(pack);
|
|
break;
|
|
}
|
|
|
|
case ServerOP_ExpeditionCreate:
|
|
case ServerOP_ExpeditionDzAddPlayer:
|
|
case ServerOP_ExpeditionDzMakeLeader:
|
|
case ServerOP_ExpeditionCharacterLockout:
|
|
case ServerOP_ExpeditionSaveInvite:
|
|
case ServerOP_ExpeditionRequestInvite:
|
|
{
|
|
ExpeditionMessage::HandleZoneMessage(pack);
|
|
break;
|
|
}
|
|
case ServerOP_DzCreated:
|
|
case ServerOP_DzAddRemoveMember:
|
|
case ServerOP_DzSwapMembers:
|
|
case ServerOP_DzRemoveAllMembers:
|
|
case ServerOP_DzGetMemberStatuses:
|
|
case ServerOP_DzSetSecondsRemaining:
|
|
case ServerOP_DzSetCompass:
|
|
case ServerOP_DzSetSafeReturn:
|
|
case ServerOP_DzSetZoneIn:
|
|
case ServerOP_DzUpdateMemberStatus:
|
|
{
|
|
DynamicZone::HandleZoneMessage(pack);
|
|
break;
|
|
}
|
|
default:
|
|
{
|
|
LogInfo("Unknown ServerOPcode from zone {:#04x}, size [{}]", pack->opcode, pack->size);
|
|
DumpPacket(pack->pBuffer, pack->size);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
void ZoneServer::SendEmoteMessage(const char* to, uint32 to_guilddbid, int16 to_minstatus, uint32 type, const char* message, ...) {
|
|
if (!message)
|
|
return;
|
|
va_list argptr;
|
|
char buffer[1024];
|
|
|
|
va_start(argptr, message);
|
|
vsnprintf(buffer, sizeof(buffer), message, argptr);
|
|
va_end(argptr);
|
|
SendEmoteMessageRaw(to, to_guilddbid, to_minstatus, type, buffer);
|
|
}
|
|
|
|
void ZoneServer::SendEmoteMessageRaw(const char* to, uint32 to_guilddbid, int16 to_minstatus, uint32 type, const char* message) {
|
|
if (!message)
|
|
return;
|
|
auto pack = new ServerPacket;
|
|
|
|
pack->opcode = ServerOP_EmoteMessage;
|
|
pack->size = sizeof(ServerEmoteMessage_Struct) + strlen(message) + 1;
|
|
pack->pBuffer = new uchar[pack->size];
|
|
memset(pack->pBuffer, 0, pack->size);
|
|
ServerEmoteMessage_Struct* sem = (ServerEmoteMessage_Struct*)pack->pBuffer;
|
|
|
|
if (to != 0) {
|
|
strcpy((char *)sem->to, to);
|
|
}
|
|
else {
|
|
sem->to[0] = 0;
|
|
}
|
|
|
|
sem->guilddbid = to_guilddbid;
|
|
sem->minstatus = to_minstatus;
|
|
sem->type = type;
|
|
strcpy(&sem->message[0], message);
|
|
|
|
SendPacket(pack);
|
|
delete pack;
|
|
}
|
|
|
|
void ZoneServer::SendGroupIDs() {
|
|
auto pack = new ServerPacket(ServerOP_GroupIDReply, sizeof(ServerGroupIDReply_Struct));
|
|
ServerGroupIDReply_Struct* sgi = (ServerGroupIDReply_Struct*)pack->pBuffer;
|
|
zoneserver_list.NextGroupIDs(sgi->start, sgi->end);
|
|
SendPacket(pack);
|
|
delete pack;
|
|
}
|
|
|
|
|
|
void ZoneServer::SendKeepAlive()
|
|
{
|
|
ServerPacket pack(ServerOP_KeepAlive, 0);
|
|
SendPacket(&pack);
|
|
}
|
|
|
|
void ZoneServer::ChangeWID(uint32 iCharID, uint32 iWID) {
|
|
auto pack = new ServerPacket(ServerOP_ChangeWID, sizeof(ServerChangeWID_Struct));
|
|
ServerChangeWID_Struct* scw = (ServerChangeWID_Struct*)pack->pBuffer;
|
|
scw->charid = iCharID;
|
|
scw->newwid = iWID;
|
|
zoneserver_list.SendPacket(pack);
|
|
delete pack;
|
|
}
|
|
|
|
|
|
void ZoneServer::TriggerBootup(uint32 iZoneID, uint32 iInstanceID, const char* adminname, bool iMakeStatic) {
|
|
is_booting_up = true;
|
|
zone_server_zone_id = iZoneID;
|
|
instance_id = iInstanceID;
|
|
|
|
auto pack = new ServerPacket(ServerOP_ZoneBootup, sizeof(ServerZoneStateChange_struct));
|
|
ServerZoneStateChange_struct* s = (ServerZoneStateChange_struct *)pack->pBuffer;
|
|
s->ZoneServerID = zone_server_id;
|
|
if (adminname != 0)
|
|
strcpy(s->adminname, adminname);
|
|
|
|
if (iZoneID == 0)
|
|
s->zoneid = this->GetZoneID();
|
|
else
|
|
s->zoneid = iZoneID;
|
|
|
|
s->instanceid = iInstanceID;
|
|
s->makestatic = iMakeStatic;
|
|
SendPacket(pack);
|
|
delete pack;
|
|
LSBootUpdate(iZoneID, iInstanceID);
|
|
}
|
|
|
|
void ZoneServer::IncomingClient(Client* client) {
|
|
is_booting_up = true;
|
|
auto pack = new ServerPacket(ServerOP_ZoneIncClient, sizeof(ServerZoneIncomingClient_Struct));
|
|
ServerZoneIncomingClient_Struct* s = (ServerZoneIncomingClient_Struct*)pack->pBuffer;
|
|
s->zoneid = GetZoneID();
|
|
s->instanceid = GetInstanceID();
|
|
s->wid = client->GetWID();
|
|
s->ip = client->GetIP();
|
|
s->accid = client->GetAccountID();
|
|
s->admin = client->GetAdmin();
|
|
s->charid = client->GetCharID();
|
|
s->lsid = client->GetLSID();
|
|
if (client->GetCLE())
|
|
s->tellsoff = client->GetCLE()->TellsOff();
|
|
strn0cpy(s->charname, client->GetCharName(), sizeof(s->charname));
|
|
strn0cpy(s->lskey, client->GetLSKey(), sizeof(s->lskey));
|
|
SendPacket(pack);
|
|
delete pack;
|
|
}
|