mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-17 03:08:26 +00:00
[Shared Tasks] Shared Tasks System Implementation (#1451)
* 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>
This commit is contained in:
@@ -129,6 +129,7 @@ SET(zone_sources
|
||||
quest_parser_collection.cpp
|
||||
raids.cpp
|
||||
raycast_mesh.cpp
|
||||
shared_task_zone_messaging.cpp
|
||||
spawn2.cpp
|
||||
spawn2.h
|
||||
spawngroup.cpp
|
||||
@@ -255,6 +256,7 @@ SET(zone_headers
|
||||
raids.h
|
||||
raycast_mesh.h
|
||||
skills.h
|
||||
shared_task_zone_messaging.h
|
||||
spawn2.cpp
|
||||
spawn2.h
|
||||
spawngroup.h
|
||||
|
||||
+12
-8
@@ -2350,6 +2350,18 @@ bool NPC::Death(Mob* killer_mob, int32 damage, uint16 spell, EQ::skills::SkillTy
|
||||
int32 finalxp = give_exp_client->GetExperienceForKill(this);
|
||||
finalxp = give_exp_client->mod_client_xp(finalxp, this);
|
||||
|
||||
// handle task credit on behalf of the killer
|
||||
if (RuleB(TaskSystem, EnableTaskSystem)) {
|
||||
LogTasksDetail(
|
||||
"[NPC::Death] Triggering HandleUpdateTasksOnKill for [{}] npc [{}]",
|
||||
give_exp_client->GetCleanName(),
|
||||
GetNPCTypeID()
|
||||
);
|
||||
give_exp_client
|
||||
->GetTaskState()
|
||||
->HandleUpdateTasksOnKill(give_exp_client, GetNPCTypeID());
|
||||
}
|
||||
|
||||
if (kr) {
|
||||
if (!IsLdonTreasure && MerchantType == 0) {
|
||||
kr->SplitExp((finalxp), this);
|
||||
@@ -2368,8 +2380,6 @@ bool NPC::Death(Mob* killer_mob, int32 damage, uint16 spell, EQ::skills::SkillTy
|
||||
|
||||
mod_npc_killed_merit(kr->members[i].member);
|
||||
|
||||
if (RuleB(TaskSystem, EnableTaskSystem))
|
||||
kr->members[i].member->UpdateTasksOnKill(GetNPCTypeID());
|
||||
PlayerCount++;
|
||||
}
|
||||
}
|
||||
@@ -2417,9 +2427,6 @@ bool NPC::Death(Mob* killer_mob, int32 damage, uint16 spell, EQ::skills::SkillTy
|
||||
|
||||
mod_npc_killed_merit(c);
|
||||
|
||||
if (RuleB(TaskSystem, EnableTaskSystem))
|
||||
c->UpdateTasksOnKill(GetNPCTypeID());
|
||||
|
||||
PlayerCount++;
|
||||
}
|
||||
}
|
||||
@@ -2468,9 +2475,6 @@ bool NPC::Death(Mob* killer_mob, int32 damage, uint16 spell, EQ::skills::SkillTy
|
||||
|
||||
mod_npc_killed_merit(give_exp_client);
|
||||
|
||||
if (RuleB(TaskSystem, EnableTaskSystem))
|
||||
give_exp_client->UpdateTasksOnKill(GetNPCTypeID());
|
||||
|
||||
// QueryServ Logging - Solo
|
||||
if (RuleB(QueryServ, PlayerLogNPCKills)) {
|
||||
auto pack = new ServerPacket(ServerOP_QSPlayerLogNPCKills,
|
||||
|
||||
+131
-70
@@ -348,9 +348,10 @@ Client::Client(EQStreamInterface* ieqs)
|
||||
temp_pvp = false;
|
||||
is_client_moving = false;
|
||||
|
||||
/**
|
||||
* GM
|
||||
*/
|
||||
// rate limiter
|
||||
m_list_task_timers_rate_limit.Start(1000);
|
||||
|
||||
// gm
|
||||
SetDisplayMobInfoWindow(true);
|
||||
SetDevToolsEnabled(true);
|
||||
|
||||
@@ -1550,46 +1551,56 @@ void Client::SendSound(){//Makes a sound.
|
||||
safe_delete(outapp);
|
||||
|
||||
}
|
||||
void Client::UpdateWho(uint8 remove) {
|
||||
if (account_id == 0)
|
||||
void Client::UpdateWho(uint8 remove)
|
||||
{
|
||||
if (account_id == 0) {
|
||||
return;
|
||||
if (!worldserver.Connected())
|
||||
}
|
||||
if (!worldserver.Connected()) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto pack = new ServerPacket(ServerOP_ClientList, sizeof(ServerClientList_Struct));
|
||||
ServerClientList_Struct* scl = (ServerClientList_Struct*) pack->pBuffer;
|
||||
scl->remove = remove;
|
||||
scl->wid = this->GetWID();
|
||||
scl->IP = this->GetIP();
|
||||
scl->charid = this->CharacterID();
|
||||
strcpy(scl->name, this->GetName());
|
||||
auto *s = (ServerClientList_Struct *) pack->pBuffer;
|
||||
s->remove = remove;
|
||||
s->wid = this->GetWID();
|
||||
s->IP = this->GetIP();
|
||||
s->charid = this->CharacterID();
|
||||
strcpy(s->name, this->GetName());
|
||||
|
||||
scl->gm = GetGM();
|
||||
scl->Admin = this->Admin();
|
||||
scl->AccountID = this->AccountID();
|
||||
strcpy(scl->AccountName, this->AccountName());
|
||||
scl->LSAccountID = this->LSAccountID();
|
||||
strn0cpy(scl->lskey, lskey, sizeof(scl->lskey));
|
||||
scl->zone = zone->GetZoneID();
|
||||
scl->instance_id = zone->GetInstanceID();
|
||||
scl->race = this->GetRace();
|
||||
scl->class_ = GetClass();
|
||||
scl->level = GetLevel();
|
||||
if (m_pp.anon == 0)
|
||||
scl->anon = 0;
|
||||
else if (m_pp.anon == 1)
|
||||
scl->anon = 1;
|
||||
else if (m_pp.anon >= 2)
|
||||
scl->anon = 2;
|
||||
s->gm = GetGM();
|
||||
s->Admin = this->Admin();
|
||||
s->AccountID = this->AccountID();
|
||||
strcpy(s->AccountName, this->AccountName());
|
||||
|
||||
scl->ClientVersion = static_cast<unsigned int>(ClientVersion());
|
||||
scl->tellsoff = tellsoff;
|
||||
scl->guild_id = guild_id;
|
||||
scl->LFG = LFG;
|
||||
if(LFG) {
|
||||
scl->LFGFromLevel = LFGFromLevel;
|
||||
scl->LFGToLevel = LFGToLevel;
|
||||
scl->LFGMatchFilter = LFGMatchFilter;
|
||||
memcpy(scl->LFGComments, LFGComments, sizeof(scl->LFGComments));
|
||||
s->LSAccountID = this->LSAccountID();
|
||||
strn0cpy(s->lskey, lskey, sizeof(s->lskey));
|
||||
|
||||
s->zone = zone->GetZoneID();
|
||||
s->instance_id = zone->GetInstanceID();
|
||||
s->race = this->GetRace();
|
||||
s->class_ = GetClass();
|
||||
s->level = GetLevel();
|
||||
|
||||
if (m_pp.anon == 0) {
|
||||
s->anon = 0;
|
||||
}
|
||||
else if (m_pp.anon == 1) {
|
||||
s->anon = 1;
|
||||
}
|
||||
else if (m_pp.anon >= 2) {
|
||||
s->anon = 2;
|
||||
}
|
||||
|
||||
s->ClientVersion = static_cast<unsigned int>(ClientVersion());
|
||||
s->tellsoff = tellsoff;
|
||||
s->guild_id = guild_id;
|
||||
s->LFG = LFG;
|
||||
if (LFG) {
|
||||
s->LFGFromLevel = LFGFromLevel;
|
||||
s->LFGToLevel = LFGToLevel;
|
||||
s->LFGMatchFilter = LFGMatchFilter;
|
||||
memcpy(s->LFGComments, LFGComments, sizeof(s->LFGComments));
|
||||
}
|
||||
|
||||
worldserver.SendPacket(pack);
|
||||
@@ -3368,11 +3379,7 @@ void Client::LinkDead()
|
||||
raid->MemberZoned(this);
|
||||
}
|
||||
|
||||
Expedition* expedition = GetExpedition();
|
||||
if (expedition)
|
||||
{
|
||||
expedition->SetMemberStatus(this, DynamicZoneMemberStatus::LinkDead);
|
||||
}
|
||||
SetDynamicZoneMemberStatus(DynamicZoneMemberStatus::LinkDead);
|
||||
|
||||
// save_timer.Start(2500);
|
||||
linkdead_timer.Start(RuleI(Zone,ClientLinkdeadMS));
|
||||
@@ -5730,16 +5737,27 @@ void Client::AddPVPPoints(uint32 Points)
|
||||
SendPVPStats();
|
||||
}
|
||||
|
||||
void Client::AddCrystals(uint32 Radiant, uint32 Ebon)
|
||||
void Client::AddCrystals(uint32 radiant, uint32 ebon)
|
||||
{
|
||||
m_pp.currentRadCrystals += Radiant;
|
||||
m_pp.careerRadCrystals += Radiant;
|
||||
m_pp.currentEbonCrystals += Ebon;
|
||||
m_pp.careerEbonCrystals += Ebon;
|
||||
m_pp.currentRadCrystals += radiant;
|
||||
m_pp.careerRadCrystals += radiant;
|
||||
m_pp.currentEbonCrystals += ebon;
|
||||
m_pp.careerEbonCrystals += ebon;
|
||||
|
||||
SaveCurrency();
|
||||
|
||||
SendCrystalCounts();
|
||||
|
||||
// newer clients handle message client side (older clients likely used eqstr 5967 and 5968, this matches live)
|
||||
if (radiant > 0)
|
||||
{
|
||||
MessageString(Chat::Yellow, YOU_RECEIVE, fmt::format("{} Radiant Crystals", radiant).c_str());
|
||||
}
|
||||
|
||||
if (ebon > 0)
|
||||
{
|
||||
MessageString(Chat::Yellow, YOU_RECEIVE, fmt::format("{} Ebon Crystals", ebon).c_str());
|
||||
}
|
||||
}
|
||||
|
||||
void Client::SetEbonCrystals(uint32 value) {
|
||||
@@ -9515,28 +9533,25 @@ void Client::SendCrossZoneMessageString(
|
||||
}
|
||||
}
|
||||
|
||||
void Client::UpdateExpeditionInfoAndLockouts()
|
||||
void Client::SendDynamicZoneUpdates()
|
||||
{
|
||||
// this is processed by client after entering a zone
|
||||
// bit inefficient since each do lookups but it avoids duplicating code here
|
||||
SendDzCompassUpdate();
|
||||
SetDynamicZoneMemberStatus(DynamicZoneMemberStatus::Online);
|
||||
|
||||
m_expedition_lockouts = ExpeditionDatabase::LoadCharacterLockouts(CharacterID());
|
||||
|
||||
// expeditions are the only dz type that keep the window updated
|
||||
auto expedition = GetExpedition();
|
||||
if (expedition)
|
||||
{
|
||||
expedition->SendClientExpeditionInfo(this);
|
||||
expedition->GetDynamicZone()->SendClientWindowUpdate(this);
|
||||
|
||||
// live synchronizes lockouts obtained during the active expedition to
|
||||
// members once they zone into the expedition's dynamic zone instance
|
||||
if (expedition->GetDynamicZone().IsCurrentZoneDzInstance())
|
||||
if (expedition->GetDynamicZone()->IsCurrentZoneDzInstance())
|
||||
{
|
||||
expedition->SyncCharacterLockouts(CharacterID(), m_expedition_lockouts);
|
||||
expedition->SetMemberStatus(this, DynamicZoneMemberStatus::InDynamicZone);
|
||||
}
|
||||
else
|
||||
{
|
||||
expedition->SetMemberStatus(this, DynamicZoneMemberStatus::Online);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9546,18 +9561,29 @@ void Client::UpdateExpeditionInfoAndLockouts()
|
||||
RequestPendingExpeditionInvite();
|
||||
}
|
||||
|
||||
Expedition* Client::CreateExpedition(DynamicZone& dz_instance, ExpeditionRequest& request)
|
||||
Expedition* Client::CreateExpedition(DynamicZone& dz, bool disable_messages)
|
||||
{
|
||||
return Expedition::TryCreate(this, dz_instance, request);
|
||||
return Expedition::TryCreate(this, dz, disable_messages);
|
||||
}
|
||||
|
||||
Expedition* Client::CreateExpedition(
|
||||
const std::string& zone_name, uint32 version, uint32 duration, const std::string& expedition_name,
|
||||
uint32 min_players, uint32 max_players, bool disable_messages)
|
||||
{
|
||||
DynamicZone dz_instance{ ZoneID(zone_name), version, duration, DynamicZoneType::Expedition };
|
||||
ExpeditionRequest request{ expedition_name, min_players, max_players, disable_messages };
|
||||
return Expedition::TryCreate(this, dz_instance, request);
|
||||
DynamicZone dz{ ZoneID(zone_name), version, duration, DynamicZoneType::Expedition };
|
||||
dz.SetName(expedition_name);
|
||||
dz.SetMinPlayers(min_players);
|
||||
dz.SetMaxPlayers(max_players);
|
||||
|
||||
return Expedition::TryCreate(this, dz, disable_messages);
|
||||
}
|
||||
|
||||
void Client::CreateTaskDynamicZone(int task_id, DynamicZone& dz_request)
|
||||
{
|
||||
if (task_state)
|
||||
{
|
||||
task_state->CreateTaskDynamicZone(this, task_id, dz_request);
|
||||
}
|
||||
}
|
||||
|
||||
Expedition* Client::GetExpedition() const
|
||||
@@ -9877,24 +9903,59 @@ void Client::GoToDzSafeReturnOrBind(const DynamicZone* dynamic_zone)
|
||||
GoToBind();
|
||||
}
|
||||
|
||||
void Client::AddDynamicZoneID(uint32_t dz_id)
|
||||
{
|
||||
auto it = std::find_if(m_dynamic_zone_ids.begin(), m_dynamic_zone_ids.end(),
|
||||
[&](uint32_t current_dz_id) { return current_dz_id == dz_id; });
|
||||
|
||||
if (it == m_dynamic_zone_ids.end())
|
||||
{
|
||||
LogDynamicZonesDetail("Adding dz [{}] to client [{}]", dz_id, GetName());
|
||||
m_dynamic_zone_ids.push_back(dz_id);
|
||||
}
|
||||
}
|
||||
|
||||
void Client::RemoveDynamicZoneID(uint32_t dz_id)
|
||||
{
|
||||
LogDynamicZonesDetail("Removing dz [{}] from client [{}]", dz_id, GetName());
|
||||
m_dynamic_zone_ids.erase(std::remove_if(m_dynamic_zone_ids.begin(), m_dynamic_zone_ids.end(),
|
||||
[&](uint32_t current_dz_id) { return current_dz_id == dz_id; }
|
||||
), m_dynamic_zone_ids.end());
|
||||
}
|
||||
|
||||
std::vector<DynamicZone*> Client::GetDynamicZones(uint32_t zone_id, int zone_version)
|
||||
{
|
||||
std::vector<DynamicZone*> client_dzs;
|
||||
|
||||
// check client systems for any associated dynamic zones optionally filtered by zone
|
||||
Expedition* expedition = GetExpedition();
|
||||
if (expedition &&
|
||||
(zone_id == 0 || expedition->GetDynamicZone().GetZoneID() == zone_id) &&
|
||||
(zone_version < 0 || expedition->GetDynamicZone().GetZoneVersion() == zone_version))
|
||||
for (uint32_t dz_id : m_dynamic_zone_ids)
|
||||
{
|
||||
client_dzs.emplace_back(&expedition->GetDynamicZone());
|
||||
auto dz = DynamicZone::FindDynamicZoneByID(dz_id);
|
||||
if (dz &&
|
||||
(zone_id == 0 || dz->GetZoneID() == zone_id) &&
|
||||
(zone_version < 0 || dz->GetZoneVersion() == zone_version))
|
||||
{
|
||||
client_dzs.emplace_back(dz);
|
||||
}
|
||||
}
|
||||
|
||||
// todo: tasks, missions (shared tasks), and quests with an associated dz to zone_id
|
||||
|
||||
return client_dzs;
|
||||
}
|
||||
|
||||
void Client::SetDynamicZoneMemberStatus(DynamicZoneMemberStatus status)
|
||||
{
|
||||
// sets status on all associated dzs client may have. if client is online
|
||||
// inside a dz, only that dz has the "In Dynamic Zone" status set
|
||||
for (auto& dz : GetDynamicZones())
|
||||
{
|
||||
// the rule to disable this status is handled internally by the dz
|
||||
if (status == DynamicZoneMemberStatus::Online && dz->IsCurrentZoneDzInstance())
|
||||
{
|
||||
status = DynamicZoneMemberStatus::InDynamicZone;
|
||||
}
|
||||
dz->SetMemberStatus(CharacterID(), status);
|
||||
}
|
||||
}
|
||||
|
||||
void Client::MovePCDynamicZone(uint32 zone_id, int zone_version, bool msg_if_invalid)
|
||||
{
|
||||
if (zone_id == 0)
|
||||
|
||||
+36
-6
@@ -80,6 +80,7 @@ namespace EQ
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
#include <deque>
|
||||
#include <ctime>
|
||||
|
||||
|
||||
#define CLIENT_TIMEOUT 90000
|
||||
@@ -1030,6 +1031,9 @@ public:
|
||||
void SendTaskActivityComplete(int task_id, int activity_id, int task_index, TaskType task_type, int task_incomplete=1);
|
||||
void SendTaskFailed(int task_id, int task_index, TaskType task_type);
|
||||
void SendTaskComplete(int task_index);
|
||||
bool HasTaskRequestCooldownTimer();
|
||||
void SendTaskRequestCooldownTimerMessage();
|
||||
void StartTaskRequestCooldownTimer();
|
||||
inline ClientTaskState *GetTaskState() const { return task_state; }
|
||||
inline void CancelTask(int task_index, TaskType task_type)
|
||||
{
|
||||
@@ -1095,7 +1099,7 @@ public:
|
||||
}
|
||||
}
|
||||
inline void UpdateTasksForItem(
|
||||
ActivityType activity_type,
|
||||
TaskActivityType activity_type,
|
||||
int item_id,
|
||||
int count = 1
|
||||
)
|
||||
@@ -1202,7 +1206,7 @@ public:
|
||||
bool enforce_level_requirement = false
|
||||
) {
|
||||
if (task_state) {
|
||||
task_state->AcceptNewTask(this, task_id, npc_id, enforce_level_requirement);
|
||||
task_state->AcceptNewTask(this, task_id, npc_id, std::time(nullptr), enforce_level_requirement);
|
||||
}
|
||||
}
|
||||
inline int ActiveSpeakTask(int npc_type_id)
|
||||
@@ -1262,6 +1266,15 @@ public:
|
||||
{
|
||||
return (task_state ? task_state->CompletedTasksInSet(task_set_id) : 0);
|
||||
}
|
||||
void PurgeTaskTimers();
|
||||
|
||||
// shared task shims / middleware
|
||||
// these variables are used as a shim to intercept normal localized task functionality
|
||||
// and pipe it into zone -> world and back to world -> zone
|
||||
// world is authoritative
|
||||
bool m_requesting_shared_task = false;
|
||||
bool m_shared_task_update = false;
|
||||
bool m_requested_shared_task_removal = false;
|
||||
|
||||
inline const EQ::versions::ClientVersion ClientVersion() const { return m_ClientVersion; }
|
||||
inline const uint32 ClientVersionBit() const { return m_ClientVersionBit; }
|
||||
@@ -1330,9 +1343,9 @@ public:
|
||||
const std::string& event_Name, int seconds, const std::string& uuid = {}, bool update_db = false);
|
||||
void AddNewExpeditionLockout(const std::string& expedition_name,
|
||||
const std::string& event_name, uint32_t duration, std::string uuid = {});
|
||||
Expedition* CreateExpedition(DynamicZone& dz_instance, ExpeditionRequest& request);
|
||||
Expedition* CreateExpedition(
|
||||
const std::string& zone_name, uint32 version, uint32 duration, const std::string& expedition_name,
|
||||
Expedition* CreateExpedition(DynamicZone& dz, bool disable_messages = false);
|
||||
Expedition* CreateExpedition(const std::string& zone_name,
|
||||
uint32 version, uint32 duration, const std::string& expedition_name,
|
||||
uint32 min_players, uint32 max_players, bool disable_messages = false);
|
||||
Expedition* GetExpedition() const;
|
||||
uint32 GetExpeditionID() const { return m_expedition_id; }
|
||||
@@ -1350,7 +1363,6 @@ public:
|
||||
void SendExpeditionLockoutTimers();
|
||||
void SetExpeditionID(uint32 expedition_id) { m_expedition_id = expedition_id; };
|
||||
void SetPendingExpeditionInvite(ExpeditionInvite&& invite) { m_pending_expedition_invite = invite; }
|
||||
void UpdateExpeditionInfoAndLockouts();
|
||||
void DzListTimers();
|
||||
void SetDzRemovalTimer(bool enable_timer);
|
||||
void SendDzCompassUpdate();
|
||||
@@ -1360,6 +1372,11 @@ public:
|
||||
std::vector<DynamicZone*> GetDynamicZones(uint32_t zone_id = 0, int zone_version = -1);
|
||||
std::unique_ptr<EQApplicationPacket> CreateDzSwitchListPacket(const std::vector<DynamicZone*>& dzs);
|
||||
std::unique_ptr<EQApplicationPacket> CreateCompassPacket(const std::vector<DynamicZoneCompassEntry_Struct>& entries);
|
||||
void AddDynamicZoneID(uint32_t dz_id);
|
||||
void RemoveDynamicZoneID(uint32_t dz_id);
|
||||
void SendDynamicZoneUpdates();
|
||||
void SetDynamicZoneMemberStatus(DynamicZoneMemberStatus status);
|
||||
void CreateTaskDynamicZone(int task_id, DynamicZone& dz_request);
|
||||
|
||||
void CalcItemScale();
|
||||
bool CalcItemScale(uint32 slot_x, uint32 slot_y); // behavior change: 'slot_y' is now [RANGE]_END and not [RANGE]_END + 1
|
||||
@@ -1590,6 +1607,9 @@ public:
|
||||
void ShowDevToolsMenu();
|
||||
CheatManager cheat_manager;
|
||||
|
||||
// rate limit
|
||||
Timer m_list_task_timers_rate_limit = {};
|
||||
|
||||
protected:
|
||||
friend class Mob;
|
||||
void CalcItemBonuses(StatBonuses* newbon);
|
||||
@@ -1821,6 +1841,7 @@ private:
|
||||
Timer position_update_timer; /* Timer used when client hasn't updated within a 10 second window */
|
||||
Timer consent_throttle_timer;
|
||||
Timer dynamiczone_removal_timer;
|
||||
Timer task_request_timer;
|
||||
|
||||
glm::vec3 m_Proximity;
|
||||
glm::vec4 last_position_before_bulk_update;
|
||||
@@ -1855,6 +1876,14 @@ private:
|
||||
ClientTaskState *task_state;
|
||||
int TotalSecondsPlayed;
|
||||
|
||||
// we use this very sparingly at the zone level
|
||||
// used for keeping clients in donecount sync before world sends absolute confirmations of state
|
||||
int64 m_shared_task_id = 0;
|
||||
public:
|
||||
void SetSharedTaskId(int64 shared_task_id);
|
||||
int64 GetSharedTaskId() const;
|
||||
private:
|
||||
|
||||
//Anti Spam Stuff
|
||||
Timer *KarmaUpdateTimer;
|
||||
uint32 TotalKarma;
|
||||
@@ -1927,6 +1956,7 @@ private:
|
||||
std::vector<ExpeditionLockoutTimer> m_expedition_lockouts;
|
||||
glm::vec3 m_quest_compass;
|
||||
bool m_has_quest_compass = false;
|
||||
std::vector<uint32_t> m_dynamic_zone_ids;
|
||||
|
||||
#ifdef BOTS
|
||||
|
||||
|
||||
+327
-19
@@ -63,7 +63,9 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#include "worldserver.h"
|
||||
#include "zone.h"
|
||||
#include "mob_movement_manager.h"
|
||||
#include "../common/repositories/character_instance_safereturns_repository.h"
|
||||
#include "../common/repositories/criteria/content_filter_criteria.h"
|
||||
#include "../common/shared_tasks.h"
|
||||
|
||||
#ifdef BOTS
|
||||
#include "bot.h"
|
||||
@@ -381,6 +383,7 @@ void MapOpcodes()
|
||||
ConnectedOpcodes[OP_TargetCommand] = &Client::Handle_OP_TargetCommand;
|
||||
ConnectedOpcodes[OP_TargetMouse] = &Client::Handle_OP_TargetMouse;
|
||||
ConnectedOpcodes[OP_TaskHistoryRequest] = &Client::Handle_OP_TaskHistoryRequest;
|
||||
ConnectedOpcodes[OP_TaskTimers] = &Client::Handle_OP_TaskTimers;
|
||||
ConnectedOpcodes[OP_Taunt] = &Client::Handle_OP_Taunt;
|
||||
ConnectedOpcodes[OP_TestBuff] = &Client::Handle_OP_TestBuff;
|
||||
ConnectedOpcodes[OP_TGB] = &Client::Handle_OP_TGB;
|
||||
@@ -414,6 +417,15 @@ void MapOpcodes()
|
||||
ConnectedOpcodes[OP_ZoneChange] = &Client::Handle_OP_ZoneChange;
|
||||
ConnectedOpcodes[OP_ResetAA] = &Client::Handle_OP_ResetAA;
|
||||
ConnectedOpcodes[OP_UnderWorld] = &Client::Handle_OP_UnderWorld;
|
||||
|
||||
// shared tasks
|
||||
ConnectedOpcodes[OP_SharedTaskRemovePlayer] = &Client::Handle_OP_SharedTaskRemovePlayer;
|
||||
ConnectedOpcodes[OP_SharedTaskAddPlayer] = &Client::Handle_OP_SharedTaskAddPlayer;
|
||||
ConnectedOpcodes[OP_SharedTaskMakeLeader] = &Client::Handle_OP_SharedTaskMakeLeader;
|
||||
ConnectedOpcodes[OP_SharedTaskInviteResponse] = &Client::Handle_OP_SharedTaskInviteResponse;
|
||||
ConnectedOpcodes[OP_SharedTaskAcceptNew] = &Client::Handle_OP_SharedTaskAccept;
|
||||
ConnectedOpcodes[OP_SharedTaskQuit] = &Client::Handle_OP_SharedTaskQuit;
|
||||
ConnectedOpcodes[OP_SharedTaskPlayerList] = &Client::Handle_OP_SharedTaskPlayerList;
|
||||
}
|
||||
|
||||
void ClearMappedOpcode(EmuOpcode op)
|
||||
@@ -526,6 +538,9 @@ void Client::CompleteConnect()
|
||||
/* Sets GM Flag if needed & Sends Petition Queue */
|
||||
UpdateAdmin(false);
|
||||
|
||||
// Task Packets
|
||||
LoadClientTaskState();
|
||||
|
||||
if (IsInAGuild()) {
|
||||
uint8 rank = GuildRank();
|
||||
if (ClientVersion() >= EQ::versions::ClientVersion::RoF)
|
||||
@@ -899,7 +914,7 @@ void Client::CompleteConnect()
|
||||
guild_mgr.RequestOnlineGuildMembers(this->CharacterID(), this->GuildID());
|
||||
}
|
||||
|
||||
UpdateExpeditionInfoAndLockouts();
|
||||
SendDynamicZoneUpdates();
|
||||
|
||||
/** Request adventure info **/
|
||||
auto pack = new ServerPacket(ServerOP_AdventureDataRequest, 64);
|
||||
@@ -940,6 +955,25 @@ void Client::CompleteConnect()
|
||||
ShowDevToolsMenu();
|
||||
}
|
||||
|
||||
// shared tasks memberlist
|
||||
if (GetTaskState()->HasActiveSharedTask()) {
|
||||
|
||||
// struct
|
||||
auto p = new ServerPacket(
|
||||
ServerOP_SharedTaskRequestMemberlist,
|
||||
sizeof(ServerSharedTaskRequestMemberlist_Struct)
|
||||
);
|
||||
|
||||
auto *r = (ServerSharedTaskRequestMemberlist_Struct *) p->pBuffer;
|
||||
|
||||
// fill
|
||||
r->source_character_id = CharacterID();
|
||||
r->task_id = GetTaskState()->GetActiveSharedTask().task_id;
|
||||
|
||||
// send
|
||||
worldserver.SendPacket(p);
|
||||
safe_delete(p);
|
||||
}
|
||||
}
|
||||
|
||||
// connecting opcode handlers
|
||||
@@ -1716,13 +1750,41 @@ void Client::Handle_Connect_OP_ZoneEntry(const EQApplicationPacket *app)
|
||||
m_inv.SetGMInventory((bool)m_pp.gm); // reset back to current gm state
|
||||
}
|
||||
|
||||
/* Task Packets */
|
||||
LoadClientTaskState();
|
||||
|
||||
ApplyWeaponsStance();
|
||||
|
||||
auto dynamic_zone_member_entries = DynamicZoneMembersRepository::GetWhere(database,
|
||||
fmt::format("character_id = {}", CharacterID()));
|
||||
|
||||
for (const auto& entry : dynamic_zone_member_entries)
|
||||
{
|
||||
m_dynamic_zone_ids.emplace_back(entry.dynamic_zone_id);
|
||||
}
|
||||
|
||||
m_expedition_id = ExpeditionsRepository::GetIDByMemberID(database, CharacterID());
|
||||
|
||||
auto dz = zone->GetDynamicZone();
|
||||
if (dz && dz->GetSafeReturnLocation().zone_id != 0)
|
||||
{
|
||||
auto safereturn = dz->GetSafeReturnLocation();
|
||||
|
||||
auto safereturn_entry = CharacterInstanceSafereturnsRepository::NewEntity();
|
||||
safereturn_entry.character_id = CharacterID();
|
||||
safereturn_entry.instance_zone_id = zone->GetZoneID();
|
||||
safereturn_entry.instance_id = zone->GetInstanceID();
|
||||
safereturn_entry.safe_zone_id = safereturn.zone_id;
|
||||
safereturn_entry.safe_x = safereturn.x;
|
||||
safereturn_entry.safe_y = safereturn.y;
|
||||
safereturn_entry.safe_z = safereturn.z;
|
||||
safereturn_entry.safe_heading = safereturn.heading;
|
||||
|
||||
CharacterInstanceSafereturnsRepository::InsertOneOrUpdate(database, safereturn_entry);
|
||||
}
|
||||
else
|
||||
{
|
||||
CharacterInstanceSafereturnsRepository::DeleteWhere(database,
|
||||
fmt::format("character_id = {}", character_id));
|
||||
}
|
||||
|
||||
/**
|
||||
* DevTools Load Settings
|
||||
*/
|
||||
@@ -1828,7 +1890,7 @@ void Client::Handle_OP_AcceptNewTask(const EQApplicationPacket *app)
|
||||
AcceptNewTask_Struct *ant = (AcceptNewTask_Struct*)app->pBuffer;
|
||||
|
||||
if (ant->task_id > 0 && RuleB(TaskSystem, EnableTaskSystem) && task_state)
|
||||
task_state->AcceptNewTask(this, ant->task_id, ant->task_master_id);
|
||||
task_state->AcceptNewTask(this, ant->task_id, ant->task_master_id, std::time(nullptr));
|
||||
}
|
||||
|
||||
void Client::Handle_OP_AdventureInfoRequest(const EQApplicationPacket *app)
|
||||
@@ -9041,9 +9103,9 @@ void Client::Handle_OP_KickPlayers(const EQApplicationPacket *app)
|
||||
expedition->DzKickPlayers(this);
|
||||
}
|
||||
}
|
||||
else if (buf->kick_task)
|
||||
else if (buf->kick_task && GetTaskState() && GetTaskState()->HasActiveSharedTask())
|
||||
{
|
||||
// todo: shared tasks
|
||||
GetTaskState()->KickPlayersSharedTask(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12820,16 +12882,16 @@ void Client::Handle_OP_Shielding(const EQApplicationPacket *app)
|
||||
While active for the duration of 12 seconds baseline. The 'shield target' will take 50 pct less damage and
|
||||
the 'shielder' will be hit with the damage taken by the 'shield target' after all applicable mitigiont is calculated,
|
||||
the damage on the 'shielder' will be reduced by 25 percent, this reduction can be increased to 50 pct if equiping a shield.
|
||||
You receive a 1% increase in mitigation for every 2 AC on the shield.
|
||||
You receive a 1% increase in mitigation for every 2 AC on the shield.
|
||||
Shielder must stay with in a close distance (15 units) to your 'shield target'. If either move out of range, shield ends, no message given.
|
||||
Both duration and shield range can be modified by AA.
|
||||
Recast is 3 minutes.
|
||||
|
||||
For custom use cases, Mob::ShieldAbility can be used in quests with all parameters being altered. This functional
|
||||
is also used for SPA 201 SE_PetShield, which functions in a simalar manner with pet shielding owner.
|
||||
|
||||
|
||||
Note: If either the shielder or the shield target die all variables are reset on both.
|
||||
|
||||
|
||||
*/
|
||||
|
||||
if (app->size != sizeof(Shielding_Struct)) {
|
||||
@@ -12838,7 +12900,7 @@ void Client::Handle_OP_Shielding(const EQApplicationPacket *app)
|
||||
}
|
||||
|
||||
if (GetLevel() < 30) { //Client gives message
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
if (GetClass() != WARRIOR){
|
||||
@@ -12854,7 +12916,7 @@ void Client::Handle_OP_Shielding(const EQApplicationPacket *app)
|
||||
}
|
||||
|
||||
Shielding_Struct* shield = (Shielding_Struct*)app->pBuffer;
|
||||
|
||||
|
||||
if (ShieldAbility(shield->target_id, 15, 12000, 50, 25, true, false)) {
|
||||
p_timers.Start(timer, SHIELD_ABILITY_RECAST_TIME);
|
||||
}
|
||||
@@ -15196,20 +15258,266 @@ void Client::Handle_OP_ResetAA(const EQApplicationPacket *app)
|
||||
return;
|
||||
}
|
||||
|
||||
void Client::Handle_OP_MovementHistoryList(const EQApplicationPacket* app) {
|
||||
void Client::Handle_OP_MovementHistoryList(const EQApplicationPacket *app)
|
||||
{
|
||||
cheat_manager.ProcessMovementHistory(app);
|
||||
}
|
||||
|
||||
void Client::Handle_OP_UnderWorld(const EQApplicationPacket* app) {
|
||||
UnderWorld* m_UnderWorld = (UnderWorld*)app->pBuffer;
|
||||
if (app->size != sizeof(UnderWorld))
|
||||
{
|
||||
void Client::Handle_OP_UnderWorld(const EQApplicationPacket *app)
|
||||
{
|
||||
UnderWorld *m_UnderWorld = (UnderWorld *) app->pBuffer;
|
||||
if (app->size != sizeof(UnderWorld)) {
|
||||
LogDebug("Size mismatch in OP_UnderWorld, expected {}, got [{}]", sizeof(UnderWorld), app->size);
|
||||
DumpPacket(app);
|
||||
return;
|
||||
}
|
||||
auto dist = Distance(glm::vec3(m_UnderWorld->x, m_UnderWorld->y, zone->newzone_data.underworld), glm::vec3(m_UnderWorld->x, m_UnderWorld->y, m_UnderWorld->z));
|
||||
auto dist = Distance(
|
||||
glm::vec3(m_UnderWorld->x, m_UnderWorld->y, zone->newzone_data.underworld),
|
||||
glm::vec3(m_UnderWorld->x, m_UnderWorld->y, m_UnderWorld->z));
|
||||
cheat_manager.MovementCheck(glm::vec3(m_UnderWorld->x, m_UnderWorld->y, m_UnderWorld->z));
|
||||
if (m_UnderWorld->spawn_id == GetID() && dist <= 5.0f && zone->newzone_data.underworld_teleport_index != 0)
|
||||
if (m_UnderWorld->spawn_id == GetID() && dist <= 5.0f && zone->newzone_data.underworld_teleport_index != 0) {
|
||||
cheat_manager.SetExemptStatus(Port, true);
|
||||
}
|
||||
}
|
||||
|
||||
void Client::Handle_OP_SharedTaskRemovePlayer(const EQApplicationPacket *app)
|
||||
{
|
||||
if (app->size != sizeof(SharedTaskRemovePlayer_Struct)) {
|
||||
LogPacketClientServer(
|
||||
"Wrong size on Handle_OP_SharedTaskRemovePlayer | got [{}] expected [{}]",
|
||||
app->size,
|
||||
sizeof(SharedTaskRemovePlayer_Struct)
|
||||
);
|
||||
return;
|
||||
}
|
||||
auto *r = (SharedTaskRemovePlayer_Struct *) app->pBuffer;
|
||||
|
||||
LogTasks(
|
||||
"[Handle_OP_SharedTaskRemovePlayer] field1 [{}] field2 [{}] player_name [{}]",
|
||||
r->field1,
|
||||
r->field2,
|
||||
r->player_name
|
||||
);
|
||||
|
||||
// live no-ops this command if not in a shared task
|
||||
if (GetTaskState()->HasActiveSharedTask()) {
|
||||
// struct
|
||||
auto p = new ServerPacket(
|
||||
ServerOP_SharedTaskRemovePlayer,
|
||||
sizeof(ServerSharedTaskRemovePlayer_Struct)
|
||||
);
|
||||
|
||||
auto *rp = (ServerSharedTaskRemovePlayer_Struct *) p->pBuffer;
|
||||
|
||||
// fill
|
||||
rp->source_character_id = CharacterID();
|
||||
rp->task_id = GetTaskState()->GetActiveSharedTask().task_id;
|
||||
strn0cpy(rp->player_name, r->player_name, sizeof(r->player_name));
|
||||
|
||||
LogTasks(
|
||||
"[Handle_OP_SharedTaskRemovePlayer] source_character_id [{}] task_id [{}] player_name [{}]",
|
||||
rp->source_character_id,
|
||||
rp->task_id,
|
||||
rp->player_name
|
||||
);
|
||||
|
||||
// send
|
||||
worldserver.SendPacket(p);
|
||||
safe_delete(p);
|
||||
}
|
||||
}
|
||||
|
||||
void Client::Handle_OP_SharedTaskAddPlayer(const EQApplicationPacket *app)
|
||||
{
|
||||
if (app->size != sizeof(SharedTaskAddPlayer_Struct)) {
|
||||
LogPacketClientServer(
|
||||
"Wrong size on Handle_OP_SharedTaskAddPlayer | got [{}] expected [{}]",
|
||||
app->size,
|
||||
sizeof(SharedTaskAddPlayer_Struct)
|
||||
);
|
||||
return;
|
||||
}
|
||||
auto *r = (SharedTaskAddPlayer_Struct *) app->pBuffer;
|
||||
|
||||
LogTasks(
|
||||
"[SharedTaskAddPlayer_Struct] field1 [{}] field2 [{}] player_name [{}]",
|
||||
r->field1,
|
||||
r->field2,
|
||||
r->player_name
|
||||
);
|
||||
|
||||
if (!GetTaskState()->HasActiveSharedTask()) {
|
||||
// this message is generated client-side in newer clients
|
||||
Message(Chat::System, SharedTaskMessage::GetEQStr(SharedTaskMessage::COULD_NOT_USE_COMMAND));
|
||||
}
|
||||
else {
|
||||
// struct
|
||||
auto p = new ServerPacket(
|
||||
ServerOP_SharedTaskAddPlayer,
|
||||
sizeof(ServerSharedTaskAddPlayer_Struct)
|
||||
);
|
||||
|
||||
auto *rp = (ServerSharedTaskAddPlayer_Struct *) p->pBuffer;
|
||||
|
||||
// fill
|
||||
rp->source_character_id = CharacterID();
|
||||
rp->task_id = GetTaskState()->GetActiveSharedTask().task_id;
|
||||
strn0cpy(rp->player_name, r->player_name, sizeof(r->player_name));
|
||||
|
||||
LogTasks(
|
||||
"[Handle_OP_SharedTaskRemovePlayer] source_character_id [{}] task_id [{}] player_name [{}]",
|
||||
rp->source_character_id,
|
||||
rp->task_id,
|
||||
rp->player_name
|
||||
);
|
||||
|
||||
// send
|
||||
worldserver.SendPacket(p);
|
||||
safe_delete(p);
|
||||
}
|
||||
}
|
||||
|
||||
void Client::Handle_OP_SharedTaskMakeLeader(const EQApplicationPacket *app)
|
||||
{
|
||||
if (app->size != sizeof(SharedTaskMakeLeader_Struct)) {
|
||||
LogPacketClientServer(
|
||||
"Wrong size on Handle_OP_SharedTaskMakeLeader | got [{}] expected [{}]",
|
||||
app->size,
|
||||
sizeof(SharedTaskMakeLeader_Struct)
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
auto *r = (SharedTaskMakeLeader_Struct *) app->pBuffer;
|
||||
LogTasks(
|
||||
"[SharedTaskMakeLeader_Struct] field1 [{}] field2 [{}] player_name [{}]",
|
||||
r->field1,
|
||||
r->field2,
|
||||
r->player_name
|
||||
);
|
||||
|
||||
// live no-ops this command if not in a shared task
|
||||
if (GetTaskState()->HasActiveSharedTask()) {
|
||||
// struct
|
||||
auto p = new ServerPacket(
|
||||
ServerOP_SharedTaskMakeLeader,
|
||||
sizeof(ServerSharedTaskMakeLeader_Struct)
|
||||
);
|
||||
|
||||
auto *rp = (ServerSharedTaskMakeLeader_Struct *) p->pBuffer;
|
||||
|
||||
// fill
|
||||
rp->source_character_id = CharacterID();
|
||||
rp->task_id = GetTaskState()->GetActiveSharedTask().task_id;
|
||||
strn0cpy(rp->player_name, r->player_name, sizeof(r->player_name));
|
||||
|
||||
LogTasks(
|
||||
"[Handle_OP_SharedTaskRemovePlayer] source_character_id [{}] task_id [{}] player_name [{}]",
|
||||
rp->source_character_id,
|
||||
rp->task_id,
|
||||
rp->player_name
|
||||
);
|
||||
|
||||
// send
|
||||
worldserver.SendPacket(p);
|
||||
safe_delete(p);
|
||||
}
|
||||
}
|
||||
|
||||
void Client::Handle_OP_SharedTaskInviteResponse(const EQApplicationPacket *app)
|
||||
{
|
||||
if (app->size != sizeof(SharedTaskInviteResponse_Struct)) {
|
||||
LogPacketClientServer(
|
||||
"Wrong size on SharedTaskInviteResponse | got [{}] expected [{}]",
|
||||
app->size,
|
||||
sizeof(SharedTaskInviteResponse_Struct)
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
auto *r = (SharedTaskInviteResponse_Struct *) app->pBuffer;
|
||||
LogTasks(
|
||||
"[SharedTaskInviteResponse] unknown00 [{}] invite_id [{}] accepted [{}]",
|
||||
r->unknown00,
|
||||
r->invite_id,
|
||||
r->accepted
|
||||
);
|
||||
|
||||
// struct
|
||||
auto p = new ServerPacket(
|
||||
ServerOP_SharedTaskInviteAcceptedPlayer,
|
||||
sizeof(ServerSharedTaskInviteAccepted_Struct)
|
||||
);
|
||||
|
||||
auto *c = (ServerSharedTaskInviteAccepted_Struct *) p->pBuffer;
|
||||
|
||||
// fill
|
||||
c->source_character_id = CharacterID();
|
||||
c->shared_task_id = r->invite_id;
|
||||
c->accepted = r->accepted;
|
||||
strn0cpy(c->player_name, GetName(), sizeof(c->player_name));
|
||||
|
||||
LogTasks(
|
||||
"[ServerOP_SharedTaskInviteAcceptedPlayer] source_character_id [{}] shared_task_id [{}]",
|
||||
c->source_character_id,
|
||||
c->shared_task_id
|
||||
);
|
||||
|
||||
// send
|
||||
worldserver.SendPacket(p);
|
||||
safe_delete(p);
|
||||
}
|
||||
|
||||
void Client::Handle_OP_SharedTaskAccept(const EQApplicationPacket* app)
|
||||
{
|
||||
auto buf = reinterpret_cast<SharedTaskAccept_Struct*>(app->pBuffer);
|
||||
|
||||
LogTasksDetail(
|
||||
"[OP_SharedTaskAccept] unknown00 [{}] unknown04 [{}] npc_entity_id [{}] task_id [{}]",
|
||||
buf->unknown00,
|
||||
buf->unknown04,
|
||||
buf->npc_entity_id,
|
||||
buf->task_id
|
||||
);
|
||||
|
||||
if (buf->task_id > 0 && RuleB(TaskSystem, EnableTaskSystem) && task_state) {
|
||||
task_state->AcceptNewTask(this, buf->task_id, buf->npc_entity_id, std::time(nullptr));
|
||||
}
|
||||
}
|
||||
|
||||
void Client::Handle_OP_SharedTaskQuit(const EQApplicationPacket* app)
|
||||
{
|
||||
if (GetTaskState()->HasActiveSharedTask())
|
||||
{
|
||||
CancelTask(TASKSLOTSHAREDTASK, TaskType::Shared);
|
||||
}
|
||||
}
|
||||
|
||||
void Client::Handle_OP_TaskTimers(const EQApplicationPacket* app)
|
||||
{
|
||||
GetTaskState()->ListTaskTimers(this);
|
||||
}
|
||||
|
||||
void Client::Handle_OP_SharedTaskPlayerList(const EQApplicationPacket* app)
|
||||
{
|
||||
if (GetTaskState()->HasActiveSharedTask())
|
||||
{
|
||||
uint32_t size = sizeof(ServerSharedTaskPlayerList_Struct);
|
||||
auto pack = std::make_unique<ServerPacket>(ServerOP_SharedTaskPlayerList, size);
|
||||
auto buf = reinterpret_cast<ServerSharedTaskPlayerList_Struct*>(pack->pBuffer);
|
||||
buf->source_character_id = CharacterID();
|
||||
buf->task_id = GetTaskState()->GetActiveSharedTask().task_id;
|
||||
|
||||
worldserver.SendPacket(pack.get());
|
||||
}
|
||||
}
|
||||
|
||||
int64 Client::GetSharedTaskId() const
|
||||
{
|
||||
return m_shared_task_id;
|
||||
}
|
||||
|
||||
void Client::SetSharedTaskId(int64 shared_task_id)
|
||||
{
|
||||
Client::m_shared_task_id = shared_task_id;
|
||||
}
|
||||
|
||||
@@ -282,6 +282,7 @@
|
||||
void Handle_OP_TargetCommand(const EQApplicationPacket *app);
|
||||
void Handle_OP_TargetMouse(const EQApplicationPacket *app);
|
||||
void Handle_OP_TaskHistoryRequest(const EQApplicationPacket *app);
|
||||
void Handle_OP_TaskTimers(const EQApplicationPacket *app);
|
||||
void Handle_OP_Taunt(const EQApplicationPacket *app);
|
||||
void Handle_OP_TestBuff(const EQApplicationPacket *app);
|
||||
void Handle_OP_TGB(const EQApplicationPacket *app);
|
||||
@@ -315,3 +316,12 @@
|
||||
void Handle_OP_ResetAA(const EQApplicationPacket *app);
|
||||
void Handle_OP_MovementHistoryList(const EQApplicationPacket* app);
|
||||
void Handle_OP_UnderWorld(const EQApplicationPacket* app);
|
||||
|
||||
// shared tasks
|
||||
void Handle_OP_SharedTaskRemovePlayer(const EQApplicationPacket *app);
|
||||
void Handle_OP_SharedTaskAddPlayer(const EQApplicationPacket *app);
|
||||
void Handle_OP_SharedTaskMakeLeader(const EQApplicationPacket *app);
|
||||
void Handle_OP_SharedTaskInviteResponse(const EQApplicationPacket *app);
|
||||
void Handle_OP_SharedTaskAccept(const EQApplicationPacket *app);
|
||||
void Handle_OP_SharedTaskQuit(const EQApplicationPacket *app);
|
||||
void Handle_OP_SharedTaskPlayerList(const EQApplicationPacket *app);
|
||||
|
||||
+4
-13
@@ -181,11 +181,7 @@ bool Client::Process() {
|
||||
myraid->MemberZoned(this);
|
||||
}
|
||||
|
||||
Expedition* expedition = GetExpedition();
|
||||
if (expedition)
|
||||
{
|
||||
expedition->SetMemberStatus(this, DynamicZoneMemberStatus::Offline);
|
||||
}
|
||||
SetDynamicZoneMemberStatus(DynamicZoneMemberStatus::Offline);
|
||||
|
||||
return false; //delete client
|
||||
}
|
||||
@@ -562,11 +558,7 @@ bool Client::Process() {
|
||||
AI_Start(CLIENT_LD_TIMEOUT);
|
||||
SendAppearancePacket(AT_Linkdead, 1);
|
||||
|
||||
Expedition* expedition = GetExpedition();
|
||||
if (expedition)
|
||||
{
|
||||
expedition->SetMemberStatus(this, DynamicZoneMemberStatus::LinkDead);
|
||||
}
|
||||
SetDynamicZoneMemberStatus(DynamicZoneMemberStatus::LinkDead);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -698,10 +690,9 @@ void Client::OnDisconnect(bool hard_disconnect) {
|
||||
}
|
||||
}
|
||||
|
||||
Expedition* expedition = GetExpedition();
|
||||
if (expedition && !bZoning)
|
||||
if (!bZoning)
|
||||
{
|
||||
expedition->SetMemberStatus(this, DynamicZoneMemberStatus::Offline);
|
||||
SetDynamicZoneMemberStatus(DynamicZoneMemberStatus::Offline);
|
||||
}
|
||||
|
||||
RemoveAllAuras();
|
||||
|
||||
+122
-13
@@ -61,6 +61,7 @@
|
||||
|
||||
#include "data_bucket.h"
|
||||
#include "command.h"
|
||||
#include "dynamic_zone.h"
|
||||
#include "expedition.h"
|
||||
#include "guild_mgr.h"
|
||||
#include "map.h"
|
||||
@@ -76,6 +77,7 @@
|
||||
#include "npc_scale_manager.h"
|
||||
#include "../common/content/world_content_service.h"
|
||||
#include "../common/http/httplib.h"
|
||||
#include "../common/shared_tasks.h"
|
||||
|
||||
extern QueryServ* QServ;
|
||||
extern WorldServer worldserver;
|
||||
@@ -7143,7 +7145,19 @@ void command_dz(Client* c, const Seperator* sep)
|
||||
return;
|
||||
}
|
||||
|
||||
if (strcasecmp(sep->arg[1], "expedition") == 0)
|
||||
if (strcasecmp(sep->arg[1], "cache") == 0)
|
||||
{
|
||||
if (strcasecmp(sep->arg[2], "reload") == 0)
|
||||
{
|
||||
DynamicZone::CacheAllFromDatabase();
|
||||
Expedition::CacheAllFromDatabase();
|
||||
c->Message(Chat::White, fmt::format(
|
||||
"Reloaded [{}] dynamic zone(s) and [{}] expedition(s) from database",
|
||||
zone->dynamic_zone_cache.size(), zone->expedition_cache.size()
|
||||
).c_str());
|
||||
}
|
||||
}
|
||||
else if (strcasecmp(sep->arg[1], "expedition") == 0)
|
||||
{
|
||||
if (strcasecmp(sep->arg[2], "list") == 0)
|
||||
{
|
||||
@@ -7161,25 +7175,32 @@ void command_dz(Client* c, const Seperator* sep)
|
||||
c->Message(Chat::White, fmt::format("Total Active Expeditions: [{}]", expeditions.size()).c_str());
|
||||
for (const auto& expedition : expeditions)
|
||||
{
|
||||
auto dz = expedition->GetDynamicZone();
|
||||
if (!dz)
|
||||
{
|
||||
LogExpeditions("Expedition [{}] has an invalid dz [{}] in cache", expedition->GetID(), expedition->GetDynamicZoneID());
|
||||
continue;
|
||||
}
|
||||
|
||||
auto leader_saylink = EQ::SayLinkEngine::GenerateQuestSaylink(fmt::format(
|
||||
"#goto {}", expedition->GetLeaderName()), false, expedition->GetLeaderName());
|
||||
auto zone_saylink = EQ::SayLinkEngine::GenerateQuestSaylink(fmt::format(
|
||||
"#zoneinstance {}", expedition->GetDynamicZone().GetInstanceID()), false, "zone");
|
||||
"#zoneinstance {}", dz->GetInstanceID()), false, "zone");
|
||||
|
||||
auto seconds = expedition->GetDynamicZone().GetSecondsRemaining();
|
||||
auto seconds = dz->GetSecondsRemaining();
|
||||
|
||||
c->Message(Chat::White, fmt::format(
|
||||
"expedition id: [{}] dz id: [{}] name: [{}] leader: [{}] {}: [{}]:[{}]:[{}]:[{}] members: [{}] remaining: [{:02}:{:02}:{:02}]",
|
||||
expedition->GetID(),
|
||||
expedition->GetDynamicZone().GetID(),
|
||||
expedition->GetDynamicZoneID(),
|
||||
expedition->GetName(),
|
||||
leader_saylink,
|
||||
zone_saylink,
|
||||
ZoneName(expedition->GetDynamicZone().GetZoneID()),
|
||||
expedition->GetDynamicZone().GetZoneID(),
|
||||
expedition->GetDynamicZone().GetInstanceID(),
|
||||
expedition->GetDynamicZone().GetZoneVersion(),
|
||||
expedition->GetDynamicZone().GetMemberCount(),
|
||||
ZoneName(dz->GetZoneID()),
|
||||
dz->GetZoneID(),
|
||||
dz->GetInstanceID(),
|
||||
dz->GetZoneVersion(),
|
||||
dz->GetMemberCount(),
|
||||
seconds / 3600, // hours
|
||||
(seconds / 60) % 60, // minutes
|
||||
seconds % 60 // seconds
|
||||
@@ -7201,7 +7222,7 @@ void command_dz(Client* c, const Seperator* sep)
|
||||
{
|
||||
c->Message(Chat::White, fmt::format("Destroying expedition [{}] ({})",
|
||||
expedition_id, expedition->GetName()).c_str());
|
||||
expedition->RemoveAllMembers();
|
||||
expedition->GetDynamicZone()->RemoveAllMembers();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -7224,9 +7245,46 @@ void command_dz(Client* c, const Seperator* sep)
|
||||
}
|
||||
}
|
||||
else if (strcasecmp(sep->arg[1], "list") == 0)
|
||||
{
|
||||
c->Message(Chat::White, fmt::format("Total Dynamic Zones (cache): [{}]", zone->dynamic_zone_cache.size()).c_str());
|
||||
|
||||
std::vector<DynamicZone*> dynamic_zones;
|
||||
for (const auto& dz : zone->dynamic_zone_cache)
|
||||
{
|
||||
dynamic_zones.emplace_back(dz.second.get());
|
||||
}
|
||||
|
||||
std::sort(dynamic_zones.begin(), dynamic_zones.end(),
|
||||
[](const DynamicZone* lhs, const DynamicZone* rhs) {
|
||||
return lhs->GetID() < rhs->GetID();
|
||||
});
|
||||
|
||||
for (const auto& dz : dynamic_zones)
|
||||
{
|
||||
auto seconds = dz->GetSecondsRemaining();
|
||||
auto zone_saylink = EQ::SayLinkEngine::GenerateQuestSaylink(
|
||||
fmt::format("#zoneinstance {}", dz->GetInstanceID()), false, "zone");
|
||||
|
||||
std::string aligned_type = fmt::format("[{}]", DynamicZone::GetDynamicZoneTypeName(static_cast<DynamicZoneType>(dz->GetType())));
|
||||
c->Message(Chat::White, fmt::format(
|
||||
"id: [{}] type: {:>10} {}: [{}]:[{}]:[{}] members: [{}] remaining: [{:02}:{:02}:{:02}]",
|
||||
dz->GetID(),
|
||||
aligned_type,
|
||||
zone_saylink,
|
||||
dz->GetZoneID(),
|
||||
dz->GetInstanceID(),
|
||||
dz->GetZoneVersion(),
|
||||
dz->GetMemberCount(),
|
||||
seconds / 3600, // hours
|
||||
(seconds / 60) % 60, // minutes
|
||||
seconds % 60 // seconds
|
||||
).c_str());
|
||||
}
|
||||
}
|
||||
else if (strcasecmp(sep->arg[1], "listdb") == 0)
|
||||
{
|
||||
auto dz_list = DynamicZonesRepository::AllDzInstancePlayerCounts(database);
|
||||
c->Message(Chat::White, fmt::format("Total Dynamic Zones: [{}]", dz_list.size()).c_str());
|
||||
c->Message(Chat::White, fmt::format("Total Dynamic Zones (database): [{}]", dz_list.size()).c_str());
|
||||
|
||||
auto now = std::chrono::system_clock::now();
|
||||
|
||||
@@ -7243,7 +7301,7 @@ void command_dz(Client* c, const Seperator* sep)
|
||||
fmt::format("#zoneinstance {}", dz.instance), false, "zone");
|
||||
|
||||
c->Message(Chat::White, fmt::format(
|
||||
"dz id: [{}] type: [{}] {}: [{}]:[{}]:[{}] members: [{}] remaining: [{:02}:{:02}:{:02}]",
|
||||
"id: [{}] type: [{}] {}: [{}]:[{}]:[{}] members: [{}] remaining: [{:02}:{:02}:{:02}]",
|
||||
dz.id,
|
||||
DynamicZone::GetDynamicZoneTypeName(static_cast<DynamicZoneType>(dz.type)),
|
||||
zone_saylink,
|
||||
@@ -7295,11 +7353,13 @@ void command_dz(Client* c, const Seperator* sep)
|
||||
else
|
||||
{
|
||||
c->Message(Chat::White, "#dz usage:");
|
||||
c->Message(Chat::White, "#dz cache reload - reload the current zone cache from db (also reloads expedition cache dependency)");
|
||||
c->Message(Chat::White, "#dz expedition list - list expeditions in current zone cache");
|
||||
c->Message(Chat::White, "#dz expedition reload - reload expedition zone cache from database");
|
||||
c->Message(Chat::White, "#dz expedition destroy <expedition_id> - destroy expedition globally (must be in cache)");
|
||||
c->Message(Chat::White, "#dz expedition unlock <expedition_id> - unlock expedition");
|
||||
c->Message(Chat::White, "#dz list [all] - list dynamic zone instances from database -- 'all' includes expired");
|
||||
c->Message(Chat::White, "#dz list - list all dynamic zone instances from current zone cache");
|
||||
c->Message(Chat::White, "#dz listdb [all] - list dynamic zone instances from database -- 'all' includes expired");
|
||||
c->Message(Chat::White, "#dz lockouts remove <char_name> - delete all of character's expedition lockouts");
|
||||
c->Message(Chat::White, "#dz lockouts remove <char_name> \"<expedition_name>\" - delete lockouts by expedition");
|
||||
c->Message(Chat::White, "#dz lockouts remove <char_name> \"<expedition_name>\" \"<event_name>\" - delete lockout by expedition event");
|
||||
@@ -10526,6 +10586,25 @@ void command_task(Client *c, const Seperator *sep) {
|
||||
EQ::SayLinkEngine::GenerateQuestSaylink("#task reload sets", false, "reload sets")
|
||||
).c_str()
|
||||
);
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"--- [{}] Purges targeted characters task timers",
|
||||
EQ::SayLinkEngine::GenerateQuestSaylink("#task purgetimers", false, "purgetimers")
|
||||
).c_str()
|
||||
);
|
||||
|
||||
c->Message(Chat::White, "------------------------------------------------");
|
||||
c->Message(Chat::White, "# Shared Task System Commands");
|
||||
c->Message(Chat::White, "------------------------------------------------");
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"--- [{}] Purges all active Shared Tasks in memory and database ",
|
||||
EQ::SayLinkEngine::GenerateQuestSaylink("#task sharedpurge", false, "sharedpurge")
|
||||
).c_str()
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -10539,6 +10618,15 @@ void command_task(Client *c, const Seperator *sep) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!strcasecmp(sep->arg[1], "purgetimers")) {
|
||||
c->Message(15, fmt::format("{}'s task timers have been purged", client_target->GetCleanName()).c_str());
|
||||
if (client_target != c) {
|
||||
client_target->Message(15, "[GM] Your task timers have been purged by a GM");
|
||||
}
|
||||
client_target->PurgeTaskTimers();
|
||||
return;
|
||||
}
|
||||
|
||||
if (!strcasecmp(sep->arg[1], "update")) {
|
||||
if (sep->argnum >= 3) {
|
||||
int task_id = atoi(sep->arg[2]);
|
||||
@@ -10565,6 +10653,27 @@ void command_task(Client *c, const Seperator *sep) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!strcasecmp(sep->arg[1], "sharedpurge")) {
|
||||
if (!strcasecmp(sep->arg[2], "confirm")) {
|
||||
LogTasksDetail("Sending purge request");
|
||||
auto pack = new ServerPacket(ServerOP_SharedTaskPurgeAllCommand, 0);
|
||||
worldserver.SendPacket(pack);
|
||||
safe_delete(pack);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"[WARNING] This will purge all active Shared Tasks [{}]?",
|
||||
EQ::SayLinkEngine::GenerateQuestSaylink("#task sharedpurge confirm", false, "confirm")
|
||||
).c_str()
|
||||
);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (!strcasecmp(sep->arg[1], "assign")) {
|
||||
int task_id = atoi(sep->arg[2]);
|
||||
if ((task_id > 0) && (task_id < MAXTASKS)) {
|
||||
|
||||
+8
-8
@@ -1261,16 +1261,16 @@ void Corpse::LootItem(Client *client, const EQApplicationPacket *app)
|
||||
return;
|
||||
}
|
||||
|
||||
if (zone && zone->GetInstanceID() != 0)
|
||||
if (!IsPlayerCorpse())
|
||||
{
|
||||
// expeditions may prevent looting based on client's lockouts
|
||||
auto expedition = Expedition::FindCachedExpeditionByZoneInstance(zone->GetZoneID(), zone->GetInstanceID());
|
||||
if (expedition && !expedition->CanClientLootCorpse(client, GetNPCTypeID(), GetID()))
|
||||
// dynamic zones may prevent looting by non-members or based on lockouts
|
||||
auto dz = zone->GetDynamicZone();
|
||||
if (dz && !dz->CanClientLootCorpse(client, GetNPCTypeID(), GetID()))
|
||||
{
|
||||
client->MessageString(Chat::Red, LOOT_NOT_ALLOWED, inst->GetItem()->Name);
|
||||
// note on live this message is only sent once on the first loot attempt of an open corpse
|
||||
client->MessageString(Chat::Loot, LOOT_NOT_ALLOWED, inst->GetItem()->Name);
|
||||
lootitem->auto_loot = -1; // generates client eqstr 1370 "You may not loot that item from this corpse."
|
||||
client->QueuePacket(app);
|
||||
SendEndLootErrorPacket(client);
|
||||
ResetLooter();
|
||||
delete inst;
|
||||
return;
|
||||
}
|
||||
@@ -1307,7 +1307,7 @@ void Corpse::LootItem(Client *client, const EQApplicationPacket *app)
|
||||
|
||||
/* Update any tasks that have an activity to loot this item */
|
||||
if (RuleB(TaskSystem, EnableTaskSystem))
|
||||
client->UpdateTasksForItem(ActivityLoot, item->ID);
|
||||
client->UpdateTasksForItem(TaskActivityType::Loot, item->ID);
|
||||
|
||||
/* Remove it from Corpse */
|
||||
if (item_data) {
|
||||
|
||||
+606
-52
@@ -21,6 +21,7 @@
|
||||
#include "dynamic_zone.h"
|
||||
#include "client.h"
|
||||
#include "expedition.h"
|
||||
#include "string_ids.h"
|
||||
#include "worldserver.h"
|
||||
#include "../common/eqemu_logsys.h"
|
||||
|
||||
@@ -43,6 +44,11 @@ Database& DynamicZone::GetDatabase()
|
||||
return database;
|
||||
}
|
||||
|
||||
bool DynamicZone::SendServerPacket(ServerPacket* packet)
|
||||
{
|
||||
return worldserver.SendPacket(packet);
|
||||
}
|
||||
|
||||
uint16_t DynamicZone::GetCurrentInstanceID()
|
||||
{
|
||||
return zone ? static_cast<uint16_t>(zone->GetInstanceID()) : 0;
|
||||
@@ -53,17 +59,119 @@ uint16_t DynamicZone::GetCurrentZoneID()
|
||||
return zone ? static_cast<uint16_t>(zone->GetZoneID()) : 0;
|
||||
}
|
||||
|
||||
DynamicZone* DynamicZone::CreateNew(DynamicZone& dz_request, const std::vector<DynamicZoneMember>& members)
|
||||
{
|
||||
if (!zone || dz_request.GetID() != 0)
|
||||
{
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// this creates a new dz instance and saves it to both db and cache
|
||||
uint32_t dz_id = dz_request.Create();
|
||||
if (dz_id == 0)
|
||||
{
|
||||
LogDynamicZones("Failed to create dynamic zone for zone [{}]", dz_request.GetZoneID());
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto dz = std::make_unique<DynamicZone>(dz_request);
|
||||
if (!members.empty())
|
||||
{
|
||||
dz->SaveMembers(members);
|
||||
}
|
||||
|
||||
LogDynamicZones("Created new dz [{}] for zone [{}]", dz_id, dz_request.GetZoneID());
|
||||
|
||||
// world must be notified before we request async member updates
|
||||
auto pack = dz->CreateServerDzCreatePacket(zone->GetZoneID(), zone->GetInstanceID());
|
||||
worldserver.SendPacket(pack.get());
|
||||
|
||||
auto inserted = zone->dynamic_zone_cache.emplace(dz_id, std::move(dz));
|
||||
|
||||
// expeditions invoke their own updates after installing client update callbacks
|
||||
if (inserted.first->second->GetType() != DynamicZoneType::Expedition)
|
||||
{
|
||||
inserted.first->second->DoAsyncZoneMemberUpdates();
|
||||
}
|
||||
|
||||
return inserted.first->second.get();
|
||||
}
|
||||
|
||||
void DynamicZone::CacheNewDynamicZone(ServerPacket* pack)
|
||||
{
|
||||
auto buf = reinterpret_cast<ServerDzCreateSerialized_Struct*>(pack->pBuffer);
|
||||
|
||||
// caching new dz created in world or another zone (has member statuses set by world)
|
||||
auto dz = std::make_unique<DynamicZone>();
|
||||
dz->LoadSerializedDzPacket(buf->cereal_data, buf->cereal_size);
|
||||
|
||||
uint32_t dz_id = dz->GetID();
|
||||
auto inserted = zone->dynamic_zone_cache.emplace(dz_id, std::move(dz));
|
||||
|
||||
// expeditions invoke their own updates after installing client update callbacks
|
||||
if (inserted.first->second->GetType() != DynamicZoneType::Expedition)
|
||||
{
|
||||
inserted.first->second->DoAsyncZoneMemberUpdates();
|
||||
}
|
||||
|
||||
LogDynamicZones("Cached new dynamic zone [{}]", dz_id);
|
||||
}
|
||||
|
||||
void DynamicZone::CacheAllFromDatabase()
|
||||
{
|
||||
if (!zone)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
BenchTimer bench;
|
||||
|
||||
auto dynamic_zones = DynamicZonesRepository::AllWithInstanceNotExpired(database);
|
||||
auto dynamic_zone_members = DynamicZoneMembersRepository::GetAllWithNames(database);
|
||||
|
||||
zone->dynamic_zone_cache.clear();
|
||||
zone->dynamic_zone_cache.reserve(dynamic_zones.size());
|
||||
|
||||
for (auto& entry : dynamic_zones)
|
||||
{
|
||||
uint32_t dz_id = entry.id;
|
||||
auto dz = std::make_unique<DynamicZone>(std::move(entry));
|
||||
|
||||
for (auto& member : dynamic_zone_members)
|
||||
{
|
||||
if (member.dynamic_zone_id == dz_id)
|
||||
{
|
||||
dz->AddMemberFromRepositoryResult(std::move(member));
|
||||
}
|
||||
}
|
||||
|
||||
zone->dynamic_zone_cache.emplace(dz_id, std::move(dz));
|
||||
}
|
||||
|
||||
LogDynamicZones("Caching [{}] dynamic zone(s) took [{}s]", zone->dynamic_zone_cache.size(), bench.elapsed());
|
||||
}
|
||||
|
||||
DynamicZone* DynamicZone::FindDynamicZoneByID(uint32_t dz_id)
|
||||
{
|
||||
auto expedition = Expedition::FindCachedExpeditionByDynamicZoneID(dz_id);
|
||||
if (expedition)
|
||||
if (!zone)
|
||||
{
|
||||
return &expedition->GetDynamicZone();
|
||||
return nullptr;
|
||||
}
|
||||
// todo: other system caches
|
||||
|
||||
auto dz = zone->dynamic_zone_cache.find(dz_id);
|
||||
if (dz != zone->dynamic_zone_cache.end())
|
||||
{
|
||||
return dz->second.get();
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void DynamicZone::RegisterOnClientAddRemove(std::function<void(Client*, bool, bool)> on_client_addremove)
|
||||
{
|
||||
m_on_client_addremove = std::move(on_client_addremove);
|
||||
}
|
||||
|
||||
void DynamicZone::StartAllClientRemovalTimers()
|
||||
{
|
||||
for (const auto& client_iter : entity_list.GetClientList())
|
||||
@@ -75,38 +183,6 @@ void DynamicZone::StartAllClientRemovalTimers()
|
||||
}
|
||||
}
|
||||
|
||||
void DynamicZone::SendInstanceRemoveAllCharacters()
|
||||
{
|
||||
// just remove all clients in bulk instead of only characters assigned to the instance
|
||||
if (IsCurrentZoneDzInstance())
|
||||
{
|
||||
DynamicZone::StartAllClientRemovalTimers();
|
||||
}
|
||||
else if (GetInstanceID() != 0)
|
||||
{
|
||||
auto pack = CreateServerRemoveAllCharactersPacket();
|
||||
worldserver.SendPacket(pack.get());
|
||||
}
|
||||
}
|
||||
|
||||
void DynamicZone::SendInstanceAddRemoveCharacter(uint32_t character_id, bool removed)
|
||||
{
|
||||
// if removing, sets removal timer on client inside the instance
|
||||
if (IsCurrentZoneDzInstance())
|
||||
{
|
||||
Client* client = entity_list.GetClientByCharID(character_id);
|
||||
if (client)
|
||||
{
|
||||
client->SetDzRemovalTimer(removed);
|
||||
}
|
||||
}
|
||||
else if (GetInstanceID() != 0)
|
||||
{
|
||||
auto pack = CreateServerAddRemoveCharacterPacket(character_id, removed);
|
||||
worldserver.SendPacket(pack.get());
|
||||
}
|
||||
}
|
||||
|
||||
bool DynamicZone::IsCurrentZoneDzInstance() const
|
||||
{
|
||||
return (zone && zone->GetInstanceID() != 0 && zone->GetInstanceID() == GetInstanceID());
|
||||
@@ -129,8 +205,8 @@ void DynamicZone::SetUpdatedDuration(uint32_t new_duration)
|
||||
m_duration = std::chrono::seconds(new_duration);
|
||||
m_expire_time = m_start_time + m_duration;
|
||||
|
||||
LogDynamicZones("Updated zone [{}]:[{}] seconds remaining: [{}]",
|
||||
m_zone_id, m_instance_id, GetSecondsRemaining());
|
||||
LogDynamicZones("Updated dz [{}] zone [{}]:[{}] seconds remaining: [{}]",
|
||||
m_id, m_zone_id, m_instance_id, GetSecondsRemaining());
|
||||
|
||||
if (zone && IsCurrentZoneDzInstance())
|
||||
{
|
||||
@@ -138,31 +214,115 @@ void DynamicZone::SetUpdatedDuration(uint32_t new_duration)
|
||||
}
|
||||
}
|
||||
|
||||
void DynamicZone::SendGlobalLocationChange(uint16_t server_opcode, const DynamicZoneLocation& location)
|
||||
{
|
||||
auto pack = CreateServerDzLocationPacket(server_opcode, location);
|
||||
worldserver.SendPacket(pack.get());
|
||||
}
|
||||
|
||||
void DynamicZone::HandleWorldMessage(ServerPacket* pack)
|
||||
{
|
||||
switch (pack->opcode)
|
||||
{
|
||||
case ServerOP_DzAddRemoveCharacter:
|
||||
case ServerOP_DzCreated:
|
||||
{
|
||||
auto buf = reinterpret_cast<ServerDzCharacter_Struct*>(pack->pBuffer);
|
||||
Client* client = entity_list.GetClientByCharID(buf->character_id);
|
||||
if (client)
|
||||
auto buf = reinterpret_cast<ServerDzCreateSerialized_Struct*>(pack->pBuffer);
|
||||
if (zone && !zone->IsZone(buf->origin_zone_id, buf->origin_instance_id))
|
||||
{
|
||||
client->SetDzRemovalTimer(buf->remove); // instance kick timer
|
||||
DynamicZone::CacheNewDynamicZone(pack);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ServerOP_DzRemoveAllCharacters:
|
||||
case ServerOP_DzDeleted:
|
||||
{
|
||||
auto buf = reinterpret_cast<ServerDzCharacter_Struct*>(pack->pBuffer);
|
||||
if (buf->remove)
|
||||
// sent by world when it deletes an expired or empty dz
|
||||
// any system that held a reference to the dz should have already been notified
|
||||
auto buf = reinterpret_cast<ServerDzID_Struct*>(pack->pBuffer);
|
||||
auto dz = DynamicZone::FindDynamicZoneByID(buf->dz_id);
|
||||
if (zone && dz)
|
||||
{
|
||||
dz->SendUpdatesToZoneMembers(true, true); // members silently removed
|
||||
|
||||
// manually handle expeditions to remove any references before the dz is deleted
|
||||
if (dz->GetType() == DynamicZoneType::Expedition)
|
||||
{
|
||||
auto expedition = Expedition::FindCachedExpeditionByDynamicZoneID(dz->GetID());
|
||||
if (expedition)
|
||||
{
|
||||
LogExpeditionsModerate("Deleting expedition [{}] from zone cache", expedition->GetID());
|
||||
zone->expedition_cache.erase(expedition->GetID());
|
||||
}
|
||||
}
|
||||
|
||||
LogDynamicZonesDetail("Deleting dynamic zone [{}] from zone cache", buf->dz_id);
|
||||
zone->dynamic_zone_cache.erase(buf->dz_id);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ServerOP_DzAddRemoveMember:
|
||||
{
|
||||
auto buf = reinterpret_cast<ServerDzMember_Struct*>(pack->pBuffer);
|
||||
if (zone && !zone->IsZone(buf->sender_zone_id, buf->sender_instance_id))
|
||||
{
|
||||
auto dz = DynamicZone::FindDynamicZoneByID(buf->dz_id);
|
||||
if (dz)
|
||||
{
|
||||
auto status = static_cast<DynamicZoneMemberStatus>(buf->character_status);
|
||||
dz->ProcessMemberAddRemove({ buf->character_id, buf->character_name, status }, buf->removed);
|
||||
}
|
||||
}
|
||||
|
||||
if (zone && zone->IsZone(buf->dz_zone_id, buf->dz_instance_id))
|
||||
{
|
||||
// cache independent redundancy to kick removed members from dz's instance
|
||||
Client* client = entity_list.GetClientByCharID(buf->character_id);
|
||||
if (client)
|
||||
{
|
||||
client->SetDzRemovalTimer(buf->removed);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ServerOP_DzSwapMembers:
|
||||
{
|
||||
auto buf = reinterpret_cast<ServerDzMemberSwap_Struct*>(pack->pBuffer);
|
||||
if (zone && !zone->IsZone(buf->sender_zone_id, buf->sender_instance_id))
|
||||
{
|
||||
auto dz = DynamicZone::FindDynamicZoneByID(buf->dz_id);
|
||||
if (dz)
|
||||
{
|
||||
auto status = static_cast<DynamicZoneMemberStatus>(buf->add_character_status);
|
||||
dz->ProcessMemberAddRemove({ buf->remove_character_id, buf->remove_character_name }, true);
|
||||
dz->ProcessMemberAddRemove({ buf->add_character_id, buf->add_character_name, status }, false);
|
||||
}
|
||||
}
|
||||
|
||||
if (zone && zone->IsZone(buf->dz_zone_id, buf->dz_instance_id))
|
||||
{
|
||||
// cache independent redundancy to kick removed members from dz's instance
|
||||
Client* removed_client = entity_list.GetClientByCharID(buf->remove_character_id);
|
||||
if (removed_client)
|
||||
{
|
||||
removed_client->SetDzRemovalTimer(true);
|
||||
}
|
||||
|
||||
Client* added_client = entity_list.GetClientByCharID(buf->add_character_id);
|
||||
if (added_client)
|
||||
{
|
||||
added_client->SetDzRemovalTimer(false);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ServerOP_DzRemoveAllMembers:
|
||||
{
|
||||
auto buf = reinterpret_cast<ServerDzID_Struct*>(pack->pBuffer);
|
||||
if (zone && !zone->IsZone(buf->sender_zone_id, buf->sender_instance_id))
|
||||
{
|
||||
auto dz = DynamicZone::FindDynamicZoneByID(buf->dz_id);
|
||||
if (dz)
|
||||
{
|
||||
dz->ProcessRemoveAllMembers();
|
||||
}
|
||||
}
|
||||
|
||||
if (zone && zone->IsZone(buf->dz_zone_id, buf->dz_instance_id))
|
||||
{
|
||||
// cache independent redundancy to kick removed members from dz's instance
|
||||
DynamicZone::StartAllClientRemovalTimers();
|
||||
}
|
||||
break;
|
||||
@@ -203,7 +363,140 @@ void DynamicZone::HandleWorldMessage(ServerPacket* pack)
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ServerOP_DzGetMemberStatuses:
|
||||
{
|
||||
// reply from world for online member statuses request for async zone member updates
|
||||
auto buf = reinterpret_cast<ServerDzMemberStatuses_Struct*>(pack->pBuffer);
|
||||
auto dz = DynamicZone::FindDynamicZoneByID(buf->dz_id);
|
||||
if (dz)
|
||||
{
|
||||
for (uint32_t i = 0; i < buf->count; ++i)
|
||||
{
|
||||
auto status = static_cast<DynamicZoneMemberStatus>(buf->entries[i].online_status);
|
||||
dz->SetInternalMemberStatus(buf->entries[i].character_id, status);
|
||||
}
|
||||
dz->m_has_member_statuses = true;
|
||||
dz->SendUpdatesToZoneMembers(false, true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ServerOP_DzUpdateMemberStatus:
|
||||
{
|
||||
auto buf = reinterpret_cast<ServerDzMemberStatus_Struct*>(pack->pBuffer);
|
||||
if (zone && !zone->IsZone(buf->sender_zone_id, buf->sender_instance_id))
|
||||
{
|
||||
auto dz = DynamicZone::FindDynamicZoneByID(buf->dz_id);
|
||||
if (dz)
|
||||
{
|
||||
auto status = static_cast<DynamicZoneMemberStatus>(buf->status);
|
||||
dz->ProcessMemberStatusChange(buf->character_id, status);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ServerOP_DzLeaderChanged:
|
||||
{
|
||||
auto buf = reinterpret_cast<ServerDzLeaderID_Struct*>(pack->pBuffer);
|
||||
auto dz = DynamicZone::FindDynamicZoneByID(buf->dz_id);
|
||||
if (dz)
|
||||
{
|
||||
dz->ProcessLeaderChanged(buf->leader_id);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ServerOP_DzExpireWarning:
|
||||
{
|
||||
auto buf = reinterpret_cast<ServerDzExpireWarning_Struct*>(pack->pBuffer);
|
||||
auto dz = DynamicZone::FindDynamicZoneByID(buf->dz_id);
|
||||
if (dz)
|
||||
{
|
||||
dz->SendMembersExpireWarning(buf->minutes_remaining);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::unique_ptr<EQApplicationPacket> DynamicZone::CreateExpireWarningPacket(uint32_t minutes_remaining)
|
||||
{
|
||||
uint32_t outsize = sizeof(ExpeditionExpireWarning);
|
||||
auto outapp = std::make_unique<EQApplicationPacket>(OP_DzExpeditionEndsWarning, outsize);
|
||||
auto buf = reinterpret_cast<ExpeditionExpireWarning*>(outapp->pBuffer);
|
||||
buf->minutes_remaining = minutes_remaining;
|
||||
return outapp;
|
||||
}
|
||||
|
||||
std::unique_ptr<EQApplicationPacket> DynamicZone::CreateInfoPacket(bool clear)
|
||||
{
|
||||
constexpr uint32_t outsize = sizeof(DynamicZoneInfo_Struct);
|
||||
auto outapp = std::make_unique<EQApplicationPacket>(OP_DzExpeditionInfo, outsize);
|
||||
if (!clear)
|
||||
{
|
||||
auto info = reinterpret_cast<DynamicZoneInfo_Struct*>(outapp->pBuffer);
|
||||
info->assigned = true;
|
||||
strn0cpy(info->dz_name, m_name.c_str(), sizeof(info->dz_name));
|
||||
strn0cpy(info->leader_name, m_leader.name.c_str(), sizeof(info->leader_name));
|
||||
info->max_players = m_max_players;
|
||||
}
|
||||
return outapp;
|
||||
}
|
||||
|
||||
std::unique_ptr<EQApplicationPacket> DynamicZone::CreateMemberListPacket(bool clear)
|
||||
{
|
||||
uint32_t member_count = clear ? 0 : static_cast<uint32_t>(m_members.size());
|
||||
uint32_t member_entries_size = sizeof(DynamicZoneMemberEntry_Struct) * member_count;
|
||||
uint32_t outsize = sizeof(DynamicZoneMemberList_Struct) + member_entries_size;
|
||||
auto outapp = std::make_unique<EQApplicationPacket>(OP_DzMemberList, outsize);
|
||||
auto buf = reinterpret_cast<DynamicZoneMemberList_Struct*>(outapp->pBuffer);
|
||||
|
||||
buf->member_count = member_count;
|
||||
|
||||
if (!clear)
|
||||
{
|
||||
for (auto i = 0; i < m_members.size(); ++i)
|
||||
{
|
||||
strn0cpy(buf->members[i].name, m_members[i].name.c_str(), sizeof(buf->members[i].name));
|
||||
buf->members[i].online_status = static_cast<uint8_t>(m_members[i].status);
|
||||
}
|
||||
}
|
||||
|
||||
return outapp;
|
||||
}
|
||||
|
||||
std::unique_ptr<EQApplicationPacket> DynamicZone::CreateMemberListNamePacket(
|
||||
const std::string& name, bool remove_name)
|
||||
{
|
||||
constexpr uint32_t outsize = sizeof(DynamicZoneMemberListName_Struct);
|
||||
auto outapp = std::make_unique<EQApplicationPacket>(OP_DzMemberListName, outsize);
|
||||
auto buf = reinterpret_cast<DynamicZoneMemberListName_Struct*>(outapp->pBuffer);
|
||||
buf->add_name = !remove_name;
|
||||
strn0cpy(buf->name, name.c_str(), sizeof(buf->name));
|
||||
return outapp;
|
||||
}
|
||||
|
||||
std::unique_ptr<EQApplicationPacket> DynamicZone::CreateMemberListStatusPacket(
|
||||
const std::string& name, DynamicZoneMemberStatus status)
|
||||
{
|
||||
// member list status uses member list struct with a single entry
|
||||
constexpr uint32_t outsize = sizeof(DynamicZoneMemberList_Struct) + sizeof(DynamicZoneMemberEntry_Struct);
|
||||
auto outapp = std::make_unique<EQApplicationPacket>(OP_DzMemberListStatus, outsize);
|
||||
auto buf = reinterpret_cast<DynamicZoneMemberList_Struct*>(outapp->pBuffer);
|
||||
buf->member_count = 1;
|
||||
|
||||
auto entry = static_cast<DynamicZoneMemberEntry_Struct*>(buf->members);
|
||||
strn0cpy(entry->name, name.c_str(), sizeof(entry->name));
|
||||
entry->online_status = static_cast<uint8_t>(status);
|
||||
|
||||
return outapp;
|
||||
}
|
||||
|
||||
std::unique_ptr<EQApplicationPacket> DynamicZone::CreateLeaderNamePacket()
|
||||
{
|
||||
constexpr uint32_t outsize = sizeof(DynamicZoneLeaderName_Struct);
|
||||
auto outapp = std::make_unique<EQApplicationPacket>(OP_DzSetLeaderName, outsize);
|
||||
auto buf = reinterpret_cast<DynamicZoneLeaderName_Struct*>(outapp->pBuffer);
|
||||
strn0cpy(buf->leader_name, m_leader.name.c_str(), sizeof(buf->leader_name));
|
||||
return outapp;
|
||||
}
|
||||
|
||||
void DynamicZone::ProcessCompassChange(const DynamicZoneLocation& location)
|
||||
@@ -223,3 +516,264 @@ void DynamicZone::SendCompassUpdateToZoneMembers()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DynamicZone::SendLeaderNameToZoneMembers()
|
||||
{
|
||||
auto outapp_leader = CreateLeaderNamePacket();
|
||||
|
||||
for (const auto& member : m_members)
|
||||
{
|
||||
Client* member_client = entity_list.GetClientByCharID(member.id);
|
||||
if (member_client)
|
||||
{
|
||||
member_client->QueuePacket(outapp_leader.get());
|
||||
|
||||
if (member.id == m_leader.id && RuleB(Expedition, AlwaysNotifyNewLeaderOnChange))
|
||||
{
|
||||
member_client->MessageString(Chat::Yellow, DZMAKELEADER_YOU);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DynamicZone::SendMembersExpireWarning(uint32_t minutes_remaining)
|
||||
{
|
||||
// expeditions warn members in all zones not just the dz
|
||||
auto outapp = CreateExpireWarningPacket(minutes_remaining);
|
||||
for (const auto& member : GetMembers())
|
||||
{
|
||||
Client* member_client = entity_list.GetClientByCharID(member.id);
|
||||
if (member_client)
|
||||
{
|
||||
member_client->QueuePacket(outapp.get());
|
||||
|
||||
// live doesn't actually send the chat message with it
|
||||
member_client->MessageString(Chat::Yellow, EXPEDITION_MIN_REMAIN,
|
||||
fmt::format_int(minutes_remaining).c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DynamicZone::SendMemberListToZoneMembers()
|
||||
{
|
||||
auto outapp_members = CreateMemberListPacket(false);
|
||||
|
||||
for (const auto& member : m_members)
|
||||
{
|
||||
Client* member_client = entity_list.GetClientByCharID(member.id);
|
||||
if (member_client)
|
||||
{
|
||||
member_client->QueuePacket(outapp_members.get());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DynamicZone::SendMemberListNameToZoneMembers(const std::string& char_name, bool remove)
|
||||
{
|
||||
auto outapp_member_name = CreateMemberListNamePacket(char_name, remove);
|
||||
|
||||
for (const auto& member : m_members)
|
||||
{
|
||||
Client* member_client = entity_list.GetClientByCharID(member.id);
|
||||
if (member_client)
|
||||
{
|
||||
member_client->QueuePacket(outapp_member_name.get());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DynamicZone::SendMemberListStatusToZoneMembers(const DynamicZoneMember& update_member)
|
||||
{
|
||||
auto outapp_member_status = CreateMemberListStatusPacket(update_member.name, update_member.status);
|
||||
|
||||
for (const auto& member : m_members)
|
||||
{
|
||||
Client* member_client = entity_list.GetClientByCharID(member.id);
|
||||
if (member_client)
|
||||
{
|
||||
member_client->QueuePacket(outapp_member_status.get());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DynamicZone::SendClientWindowUpdate(Client* client)
|
||||
{
|
||||
if (client)
|
||||
{
|
||||
client->QueuePacket(CreateInfoPacket().get());
|
||||
client->QueuePacket(CreateMemberListPacket().get());
|
||||
}
|
||||
}
|
||||
|
||||
void DynamicZone::SendUpdatesToZoneMembers(bool removing_all, bool silent)
|
||||
{
|
||||
// performs a full update on all members (usually for dz creation or removing all)
|
||||
if (!HasMembers())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
std::unique_ptr<EQApplicationPacket> outapp_info = nullptr;
|
||||
std::unique_ptr<EQApplicationPacket> outapp_members = nullptr;
|
||||
|
||||
// only expeditions use the dz window. on live the window is filled by non
|
||||
// expeditions when first created but never kept updated. that behavior could
|
||||
// be replicated in the future by flagging this as a creation update
|
||||
if (m_type == DynamicZoneType::Expedition)
|
||||
{
|
||||
// clearing info also clears member list, no need to send both when removing
|
||||
outapp_info = CreateInfoPacket(removing_all);
|
||||
outapp_members = removing_all ? nullptr : CreateMemberListPacket();
|
||||
}
|
||||
|
||||
for (const auto& member : GetMembers())
|
||||
{
|
||||
Client* client = entity_list.GetClientByCharID(member.id);
|
||||
if (client)
|
||||
{
|
||||
if (removing_all) {
|
||||
client->RemoveDynamicZoneID(GetID());
|
||||
} else {
|
||||
client->AddDynamicZoneID(GetID());
|
||||
}
|
||||
|
||||
client->SendDzCompassUpdate();
|
||||
|
||||
if (outapp_info)
|
||||
{
|
||||
client->QueuePacket(outapp_info.get());
|
||||
}
|
||||
|
||||
if (outapp_members)
|
||||
{
|
||||
client->QueuePacket(outapp_members.get());
|
||||
}
|
||||
|
||||
// callback to the dz system so it can perform any messages or set client data
|
||||
if (m_on_client_addremove)
|
||||
{
|
||||
m_on_client_addremove(client, removing_all, silent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DynamicZone::ProcessMemberAddRemove(const DynamicZoneMember& member, bool removed)
|
||||
{
|
||||
DynamicZoneBase::ProcessMemberAddRemove(member, removed);
|
||||
|
||||
// the affected client always gets a full compass update. for expeditions
|
||||
// client also gets window info update and all members get a member list update
|
||||
Client* client = entity_list.GetClientByCharID(member.id);
|
||||
if (client)
|
||||
{
|
||||
if (!removed) {
|
||||
client->AddDynamicZoneID(GetID());
|
||||
} else {
|
||||
client->RemoveDynamicZoneID(GetID());
|
||||
}
|
||||
|
||||
client->SendDzCompassUpdate();
|
||||
|
||||
if (m_type == DynamicZoneType::Expedition)
|
||||
{
|
||||
// sending clear info also clears member list for removed members
|
||||
client->QueuePacket(CreateInfoPacket(removed).get());
|
||||
}
|
||||
|
||||
if (m_on_client_addremove)
|
||||
{
|
||||
m_on_client_addremove(client, removed, false);
|
||||
}
|
||||
}
|
||||
|
||||
if (m_type == DynamicZoneType::Expedition)
|
||||
{
|
||||
// send full list when adding (MemberListName adds with "unknown" status)
|
||||
if (!removed) {
|
||||
SendMemberListToZoneMembers();
|
||||
} else {
|
||||
SendMemberListNameToZoneMembers(member.name, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DynamicZone::ProcessRemoveAllMembers(bool silent)
|
||||
{
|
||||
SendUpdatesToZoneMembers(true, silent);
|
||||
DynamicZoneBase::ProcessRemoveAllMembers(silent);
|
||||
}
|
||||
|
||||
void DynamicZone::DoAsyncZoneMemberUpdates()
|
||||
{
|
||||
// gets member statuses from world and performs zone member updates on reply
|
||||
// if we've already received member statuses we can just update immediately
|
||||
if (m_has_member_statuses)
|
||||
{
|
||||
SendUpdatesToZoneMembers();
|
||||
return;
|
||||
}
|
||||
|
||||
constexpr uint32_t pack_size = sizeof(ServerDzID_Struct);
|
||||
auto pack = std::make_unique<ServerPacket>(ServerOP_DzGetMemberStatuses, pack_size);
|
||||
auto buf = reinterpret_cast<ServerDzID_Struct*>(pack->pBuffer);
|
||||
buf->dz_id = GetID();
|
||||
buf->sender_zone_id = zone ? zone->GetZoneID() : 0;
|
||||
buf->sender_instance_id = zone ? zone->GetInstanceID() : 0;
|
||||
worldserver.SendPacket(pack.get());
|
||||
}
|
||||
|
||||
bool DynamicZone::ProcessMemberStatusChange(uint32_t member_id, DynamicZoneMemberStatus status)
|
||||
{
|
||||
bool changed = DynamicZoneBase::ProcessMemberStatusChange(member_id, status);
|
||||
|
||||
if (changed && m_type == DynamicZoneType::Expedition)
|
||||
{
|
||||
auto member = GetMemberData(member_id);
|
||||
if (member.IsValid())
|
||||
{
|
||||
SendMemberListStatusToZoneMembers(member);
|
||||
}
|
||||
}
|
||||
|
||||
return changed;
|
||||
}
|
||||
|
||||
void DynamicZone::ProcessLeaderChanged(uint32_t new_leader_id)
|
||||
{
|
||||
auto new_leader = GetMemberData(new_leader_id);
|
||||
if (!new_leader.IsValid())
|
||||
{
|
||||
LogDynamicZones("Processed invalid new leader id [{}] for dz [{}]", new_leader_id, m_id);
|
||||
return;
|
||||
}
|
||||
|
||||
LogDynamicZones("Replaced [{}] leader [{}] with [{}]", m_id, GetLeaderName(), new_leader.name);
|
||||
|
||||
SetLeader(new_leader);
|
||||
if (GetType() == DynamicZoneType::Expedition)
|
||||
{
|
||||
SendLeaderNameToZoneMembers();
|
||||
}
|
||||
}
|
||||
|
||||
bool DynamicZone::CanClientLootCorpse(Client* client, uint32_t npc_type_id, uint32_t entity_id)
|
||||
{
|
||||
// non-members of a dz cannot loot corpses inside the dz
|
||||
if (!HasMember(client->CharacterID()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// expeditions may prevent looting based on client's lockouts
|
||||
if (GetType() == DynamicZoneType::Expedition)
|
||||
{
|
||||
auto expedition = Expedition::FindCachedExpeditionByZoneInstance(zone->GetZoneID(), zone->GetInstanceID());
|
||||
if (expedition && !expedition->CanClientLootCorpse(client, npc_type_id, entity_id))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
+31
-4
@@ -27,7 +27,9 @@
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
class Client;
|
||||
class Database;
|
||||
class EQApplicationPacket;
|
||||
class ServerPacket;
|
||||
|
||||
extern const char* const CREATE_NOT_ALL_ADDED;
|
||||
@@ -40,26 +42,51 @@ public:
|
||||
DynamicZone() = default;
|
||||
DynamicZone(uint32_t zone_id, uint32_t version, uint32_t duration, DynamicZoneType type);
|
||||
|
||||
static void CacheAllFromDatabase();
|
||||
static void CacheNewDynamicZone(ServerPacket* pack);
|
||||
static DynamicZone* CreateNew(DynamicZone& dz_details, const std::vector<DynamicZoneMember>& members);
|
||||
static DynamicZone* FindDynamicZoneByID(uint32_t dz_id);
|
||||
static void HandleWorldMessage(ServerPacket* pack);
|
||||
|
||||
void SetSecondsRemaining(uint32_t seconds_remaining) override;
|
||||
|
||||
void DoAsyncZoneMemberUpdates();
|
||||
bool CanClientLootCorpse(Client* client, uint32_t npc_type_id, uint32_t entity_id);
|
||||
bool IsCurrentZoneDzInstance() const;
|
||||
void SetUpdatedDuration(uint32_t seconds);
|
||||
void RegisterOnClientAddRemove(std::function<void(Client* client, bool removed, bool silent)> on_client_addremove);
|
||||
void SendClientWindowUpdate(Client* client);
|
||||
void SendLeaderNameToZoneMembers();
|
||||
void SendMemberListToZoneMembers();
|
||||
void SendMemberListNameToZoneMembers(const std::string& char_name, bool remove);
|
||||
void SendMemberListStatusToZoneMembers(const DynamicZoneMember& member);
|
||||
void SendRemoveAllMembersToZoneMembers(bool silent) { ProcessRemoveAllMembers(silent); }
|
||||
|
||||
std::unique_ptr<EQApplicationPacket> CreateExpireWarningPacket(uint32_t minutes_remaining);
|
||||
std::unique_ptr<EQApplicationPacket> CreateInfoPacket(bool clear = false);
|
||||
std::unique_ptr<EQApplicationPacket> CreateLeaderNamePacket();
|
||||
std::unique_ptr<EQApplicationPacket> CreateMemberListPacket(bool clear = false);
|
||||
std::unique_ptr<EQApplicationPacket> CreateMemberListNamePacket(const std::string& name, bool remove_name);
|
||||
std::unique_ptr<EQApplicationPacket> CreateMemberListStatusPacket(const std::string& name, DynamicZoneMemberStatus status);
|
||||
|
||||
protected:
|
||||
uint16_t GetCurrentInstanceID() override;
|
||||
uint16_t GetCurrentZoneID() override;
|
||||
Database& GetDatabase() override;
|
||||
void ProcessCompassChange(const DynamicZoneLocation& location) override;
|
||||
void SendInstanceAddRemoveCharacter(uint32_t character_id, bool remove) override;
|
||||
void SendInstanceRemoveAllCharacters() override;
|
||||
void SendGlobalLocationChange(uint16_t server_opcode, const DynamicZoneLocation& location) override;
|
||||
void ProcessMemberAddRemove(const DynamicZoneMember& member, bool removed) override;
|
||||
bool ProcessMemberStatusChange(uint32_t member_id, DynamicZoneMemberStatus status) override;
|
||||
void ProcessRemoveAllMembers(bool silent = false) override;
|
||||
bool SendServerPacket(ServerPacket* packet) override;
|
||||
|
||||
private:
|
||||
static void StartAllClientRemovalTimers();
|
||||
void ProcessLeaderChanged(uint32_t new_leader_id);
|
||||
void SendCompassUpdateToZoneMembers();
|
||||
void SendMembersExpireWarning(uint32_t minutes);
|
||||
void SendUpdatesToZoneMembers(bool removing_all = false, bool silent = true);
|
||||
void SetUpdatedDuration(uint32_t seconds);
|
||||
|
||||
std::function<void(Client*, bool, bool)> m_on_client_addremove;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
+162
-663
File diff suppressed because it is too large
Load Diff
+21
-35
@@ -22,7 +22,6 @@
|
||||
#define EXPEDITION_H
|
||||
|
||||
#include "dynamic_zone.h"
|
||||
#include "../common/expedition_base.h"
|
||||
#include "../common/expedition_lockout_timer.h"
|
||||
#include "../common/repositories/expeditions_repository.h"
|
||||
#include <cstdint>
|
||||
@@ -47,14 +46,14 @@ enum class ExpeditionLockMessage : uint8_t
|
||||
Begin
|
||||
};
|
||||
|
||||
class Expedition : public ExpeditionBase
|
||||
class Expedition
|
||||
{
|
||||
public:
|
||||
Expedition() = default;
|
||||
Expedition(uint32_t id, const std::string& uuid, DynamicZone&& dz, const std::string& expedition_name,
|
||||
const DynamicZoneMember& leader);
|
||||
Expedition() = delete;
|
||||
Expedition(DynamicZone* dz) : m_dynamic_zone(dz) { assert(m_dynamic_zone != nullptr); }
|
||||
Expedition(DynamicZone* dz, uint32_t id, uint32_t dz_id);
|
||||
|
||||
static Expedition* TryCreate(Client* requester, DynamicZone& dynamiczone, ExpeditionRequest& request);
|
||||
static Expedition* TryCreate(Client* requester, DynamicZone& dynamiczone, bool disable_messages);
|
||||
|
||||
static void CacheFromDatabase(uint32_t expedition_id);
|
||||
static bool CacheAllFromDatabase();
|
||||
@@ -79,14 +78,15 @@ public:
|
||||
const std::string& expedition_name = {}, const std::string& event_name = {});
|
||||
static void AddLockoutClients(const ExpeditionLockoutTimer& lockout, uint32_t exclude_id = 0);
|
||||
|
||||
DynamicZone& GetDynamicZone() { return m_dynamiczone; }
|
||||
uint32_t GetID() const { return m_id; }
|
||||
uint32_t GetDynamicZoneID() const { return m_dynamic_zone_id; }
|
||||
DynamicZone* GetDynamicZone() const { return m_dynamic_zone; }
|
||||
const DynamicZoneMember& GetLeader() { return GetDynamicZone()->GetLeader(); }
|
||||
uint32_t GetLeaderID() { return GetDynamicZone()->GetLeaderID(); }
|
||||
const std::string& GetLeaderName() { return GetDynamicZone()->GetLeaderName(); }
|
||||
const std::unordered_map<std::string, ExpeditionLockoutTimer>& GetLockouts() const { return m_lockouts; }
|
||||
|
||||
bool AddMember(const std::string& add_char_name, uint32_t add_char_id);
|
||||
void RemoveAllMembers(bool enable_removal_timers = true);
|
||||
bool RemoveMember(const std::string& remove_char_name);
|
||||
void SetMemberStatus(Client* client, DynamicZoneMemberStatus status);
|
||||
void SwapMember(Client* add_client, const std::string& remove_char_name);
|
||||
const std::string& GetName() { return GetDynamicZone()->GetName(); }
|
||||
void RegisterDynamicZoneCallbacks();
|
||||
|
||||
bool IsLocked() const { return m_is_locked; }
|
||||
void SetLocked(bool lock_expedition, ExpeditionLockMessage lock_msg,
|
||||
@@ -109,7 +109,6 @@ public:
|
||||
void SetLootEventByNPCTypeID(uint32_t npc_type_id, const std::string& event_name);
|
||||
void SetLootEventBySpawnID(uint32_t spawn_id, const std::string& event_name);
|
||||
|
||||
void SendClientExpeditionInfo(Client* client);
|
||||
void SendWorldMakeLeaderRequest(uint32_t requester_id, const std::string& new_leader_name);
|
||||
void SendWorldPendingInvite(const ExpeditionInvite& invite, const std::string& add_name);
|
||||
|
||||
@@ -127,29 +126,22 @@ public:
|
||||
static const int32_t EVENT_TIMER_ID;
|
||||
|
||||
private:
|
||||
static void CacheExpeditions(std::vector<ExpeditionsRepository::ExpeditionWithLeader>&& expeditions);
|
||||
static void CacheExpeditions(std::vector<ExpeditionsRepository::Expeditions>&& expeditions);
|
||||
static void SendWorldCharacterLockout(uint32_t character_id, const ExpeditionLockoutTimer& lockout, bool remove);
|
||||
|
||||
void AddLockout(const ExpeditionLockoutTimer& lockout, bool members_only = false);
|
||||
void AddLockoutDurationClients(const ExpeditionLockoutTimer& lockout, int seconds, uint32_t exclude_id = 0);
|
||||
bool ConfirmLeaderCommand(Client* requester);
|
||||
void OnClientAddRemove(Client* client, bool removed, bool silent);
|
||||
void LoadRepositoryResult(const ExpeditionsRepository::Expeditions& entry);
|
||||
bool ProcessAddConflicts(Client* leader_client, Client* add_client, bool swapping);
|
||||
void ProcessLeaderChanged(uint32_t new_leader_id);
|
||||
void ProcessLockoutDuration(const ExpeditionLockoutTimer& lockout, int seconds, bool members_only = false);
|
||||
void ProcessLockoutUpdate(const ExpeditionLockoutTimer& lockout, bool remove, bool members_only = false);
|
||||
void ProcessMakeLeader(Client* old_leader, Client* new_leader,
|
||||
const std::string& new_leader_name, bool is_success, bool is_online);
|
||||
void ProcessMemberAdded(const std::string& added_char_name, uint32_t added_char_id);
|
||||
void ProcessMemberRemoved(const std::string& removed_char_name, uint32_t removed_char_id);
|
||||
void SaveLockouts(ExpeditionRequest& request);
|
||||
void SendClientExpeditionInvite(
|
||||
Client* client, const std::string& inviter_name, const std::string& swap_remove_name);
|
||||
void SendLeaderMessage(Client* leader_client, uint16_t chat_type, uint32_t string_id,
|
||||
const std::initializer_list<std::string>& args = {});
|
||||
void SendMemberListToZoneMembers();
|
||||
void SendMemberStatusToZoneMembers(uint32_t update_character_id, DynamicZoneMemberStatus status);
|
||||
void SendMembersExpireWarning(uint32_t minutes);
|
||||
void SendUpdatesToZoneMembers(bool clear = false, bool message_on_clear = true);
|
||||
void SendWorldExpeditionUpdate(uint16_t server_opcode);
|
||||
void SendWorldAddPlayerInvite(const std::string& inviter_name, const std::string& swap_remove_name,
|
||||
const std::string& add_name, bool pending = false);
|
||||
@@ -157,24 +149,18 @@ private:
|
||||
const ExpeditionLockoutTimer& lockout, int seconds, bool members_only = false);
|
||||
void SendWorldLockoutUpdate(
|
||||
const ExpeditionLockoutTimer& lockout, bool remove, bool members_only = false);
|
||||
void SendWorldMemberChanged(const std::string& char_name, uint32_t char_id, bool remove);
|
||||
void SendWorldMemberStatus(uint32_t character_id, DynamicZoneMemberStatus status);
|
||||
void SendWorldMemberSwapped(const std::string& remove_char_name, uint32_t remove_char_id,
|
||||
const std::string& add_char_name, uint32_t add_char_id);
|
||||
void SendWorldSettingChanged(uint16_t server_opcode, bool setting_value);
|
||||
void SetDynamicZone(DynamicZone&& dz);
|
||||
void TryAddClient(Client* add_client, const std::string& inviter_name,
|
||||
const std::string& swap_remove_name, Client* leader_client = nullptr);
|
||||
|
||||
std::unique_ptr<EQApplicationPacket> CreateExpireWarningPacket(uint32_t minutes_remaining);
|
||||
std::unique_ptr<EQApplicationPacket> CreateInfoPacket(bool clear = false);
|
||||
std::unique_ptr<EQApplicationPacket> CreateInvitePacket(const std::string& inviter_name, const std::string& swap_remove_name);
|
||||
std::unique_ptr<EQApplicationPacket> CreateMemberListPacket(bool clear = false);
|
||||
std::unique_ptr<EQApplicationPacket> CreateMemberListNamePacket(const std::string& name, bool remove_name);
|
||||
std::unique_ptr<EQApplicationPacket> CreateMemberListStatusPacket(const std::string& name, DynamicZoneMemberStatus status);
|
||||
std::unique_ptr<EQApplicationPacket> CreateLeaderNamePacket();
|
||||
|
||||
DynamicZone m_dynamiczone { DynamicZoneType::Expedition };
|
||||
uint32_t m_id = 0;
|
||||
uint32_t m_dynamic_zone_id = 0;
|
||||
bool m_is_locked = false;
|
||||
bool m_add_replay_on_join = true;
|
||||
DynamicZone* m_dynamic_zone = nullptr; // should never be null, will exist for lifetime of expedition
|
||||
std::unordered_map<std::string, ExpeditionLockoutTimer> m_lockouts;
|
||||
std::unordered_map<uint32_t, std::string> m_npc_loot_events; // only valid inside dz zone
|
||||
std::unordered_map<uint32_t, std::string> m_spawn_loot_events; // only valid inside dz zone
|
||||
|
||||
@@ -26,25 +26,21 @@
|
||||
#include "../common/string_util.h"
|
||||
#include <fmt/core.h>
|
||||
|
||||
uint32_t ExpeditionDatabase::InsertExpedition(
|
||||
const std::string& uuid, uint32_t dz_id, const std::string& expedition_name,
|
||||
uint32_t leader_id, uint32_t min_players, uint32_t max_players)
|
||||
uint32_t ExpeditionDatabase::InsertExpedition(uint32_t dz_id)
|
||||
{
|
||||
LogExpeditionsDetail(
|
||||
"Inserting new expedition [{}] leader [{}] uuid [{}]", expedition_name, leader_id, uuid
|
||||
);
|
||||
LogExpeditionsDetail("Inserting new expedition dz [{}]", dz_id);
|
||||
|
||||
std::string query = fmt::format(SQL(
|
||||
INSERT INTO expeditions
|
||||
(uuid, dynamic_zone_id, expedition_name, leader_id, min_players, max_players)
|
||||
(dynamic_zone_id)
|
||||
VALUES
|
||||
('{}', {}, '{}', {}, {}, {});
|
||||
), uuid, dz_id, EscapeString(expedition_name), leader_id, min_players, max_players);
|
||||
({});
|
||||
), dz_id);
|
||||
|
||||
auto results = database.QueryDatabase(query);
|
||||
if (!results.Success())
|
||||
{
|
||||
LogExpeditions("Failed to obtain an expedition id for [{}]", expedition_name);
|
||||
LogExpeditions("Failed to obtain an expedition id for dz [{}]", dz_id);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -35,9 +35,7 @@ class MySQLRequestResult;
|
||||
|
||||
namespace ExpeditionDatabase
|
||||
{
|
||||
uint32_t InsertExpedition(
|
||||
const std::string& uuid, uint32_t instance_id, const std::string& expedition_name,
|
||||
uint32_t leader_id, uint32_t min_players, uint32_t max_players);
|
||||
uint32_t InsertExpedition(uint32_t dz_id);
|
||||
std::vector<ExpeditionLockoutTimer> LoadCharacterLockouts(uint32_t character_id);
|
||||
std::vector<ExpeditionLockoutTimer> LoadCharacterLockouts(uint32_t character_id,
|
||||
const std::string& expedition_name);
|
||||
|
||||
@@ -30,12 +30,10 @@
|
||||
|
||||
constexpr char SystemName[] = "expedition";
|
||||
|
||||
ExpeditionRequest::ExpeditionRequest(std::string expedition_name,
|
||||
uint32_t min_players, uint32_t max_players, bool disable_messages
|
||||
) :
|
||||
m_expedition_name(std::move(expedition_name)),
|
||||
m_min_players(min_players),
|
||||
m_max_players(max_players),
|
||||
ExpeditionRequest::ExpeditionRequest(const DynamicZone& dz, bool disable_messages) :
|
||||
m_expedition_name(dz.GetName()),
|
||||
m_min_players(dz.GetMinPlayers()),
|
||||
m_max_players(dz.GetMaxPlayers()),
|
||||
m_disable_messages(disable_messages)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -35,8 +35,7 @@ class Raid;
|
||||
class ExpeditionRequest
|
||||
{
|
||||
public:
|
||||
ExpeditionRequest(std::string expedition_name, uint32_t min_players,
|
||||
uint32_t max_players, bool disable_messages = false);
|
||||
ExpeditionRequest(const DynamicZone& dz, bool disable_messages = false);
|
||||
|
||||
bool Validate(Client* requester);
|
||||
|
||||
|
||||
+2
-2
@@ -367,7 +367,7 @@ void Client::GoFish()
|
||||
PushItemOnCursor(*inst);
|
||||
SendItemPacket(EQ::invslot::slotCursor, inst, ItemPacketLimbo);
|
||||
if (RuleB(TaskSystem, EnableTaskSystem))
|
||||
UpdateTasksForItem(ActivityFish, food_id);
|
||||
UpdateTasksForItem(TaskActivityType::Fish, food_id);
|
||||
|
||||
safe_delete(inst);
|
||||
inst = m_inv.GetItem(EQ::invslot::slotCursor);
|
||||
@@ -487,7 +487,7 @@ void Client::ForageItem(bool guarantee) {
|
||||
PushItemOnCursor(*inst);
|
||||
SendItemPacket(EQ::invslot::slotCursor, inst, ItemPacketLimbo);
|
||||
if(RuleB(TaskSystem, EnableTaskSystem))
|
||||
UpdateTasksForItem(ActivityForage, foragedfood);
|
||||
UpdateTasksForItem(TaskActivityType::Forage, foragedfood);
|
||||
|
||||
safe_delete(inst);
|
||||
inst = m_inv.GetItem(EQ::invslot::slotCursor);
|
||||
|
||||
+56
-10
@@ -1864,6 +1864,7 @@ Lua_Expedition Lua_Client::CreateExpedition(luabind::object expedition_table) {
|
||||
|
||||
// luabind will catch thrown cast_failed exceptions for invalid/missing args
|
||||
luabind::object instance_info = expedition_table["instance"];
|
||||
luabind::object expedition_info = expedition_table["expedition"];
|
||||
luabind::object zone = instance_info["zone"];
|
||||
|
||||
uint32_t zone_id = 0;
|
||||
@@ -1880,6 +1881,9 @@ Lua_Expedition Lua_Client::CreateExpedition(luabind::object expedition_table) {
|
||||
uint32_t zone_duration = luabind::object_cast<uint32_t>(instance_info["duration"]);
|
||||
|
||||
DynamicZone dz{ zone_id, zone_version, zone_duration, DynamicZoneType::Expedition };
|
||||
dz.SetName(luabind::object_cast<std::string>(expedition_info["name"]));
|
||||
dz.SetMinPlayers(luabind::object_cast<uint32_t>(expedition_info["min_players"]));
|
||||
dz.SetMaxPlayers(luabind::object_cast<uint32_t>(expedition_info["max_players"]));
|
||||
|
||||
// the dz_info table supports optional hash entries for 'compass', 'safereturn', and 'zonein' data
|
||||
if (luabind::type(expedition_table["compass"]) == LUA_TTABLE)
|
||||
@@ -1900,21 +1904,13 @@ Lua_Expedition Lua_Client::CreateExpedition(luabind::object expedition_table) {
|
||||
dz.SetZoneInLocation(zonein_loc);
|
||||
}
|
||||
|
||||
luabind::object expedition_info = expedition_table["expedition"];
|
||||
|
||||
std::string expedition_name = luabind::object_cast<std::string>(expedition_info["name"]);
|
||||
uint32_t min_players = luabind::object_cast<uint32_t>(expedition_info["min_players"]);
|
||||
uint32_t max_players = luabind::object_cast<uint32_t>(expedition_info["max_players"]);
|
||||
bool disable_messages = false;
|
||||
|
||||
bool disable_messages = false;
|
||||
if (luabind::type(expedition_info["disable_messages"]) == LUA_TBOOLEAN)
|
||||
{
|
||||
disable_messages = luabind::object_cast<bool>(expedition_info["disable_messages"]);
|
||||
}
|
||||
|
||||
ExpeditionRequest request{ expedition_name, min_players, max_players, disable_messages };
|
||||
|
||||
return self->CreateExpedition(dz, request);
|
||||
return self->CreateExpedition(dz, disable_messages);
|
||||
}
|
||||
|
||||
Lua_Expedition Lua_Client::CreateExpedition(std::string zone_name, uint32 version, uint32 duration, std::string expedition_name, uint32 min_players, uint32 max_players) {
|
||||
@@ -2053,6 +2049,55 @@ void Lua_Client::MovePCDynamicZone(std::string zone_name, int zone_version, bool
|
||||
return self->MovePCDynamicZone(zone_name, zone_version, msg_if_invalid);
|
||||
}
|
||||
|
||||
void Lua_Client::CreateTaskDynamicZone(int task_id, luabind::object dz_table) {
|
||||
Lua_Safe_Call_Void();
|
||||
|
||||
if (luabind::type(dz_table) != LUA_TTABLE)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// luabind will catch thrown cast_failed exceptions for invalid/missing args
|
||||
luabind::object instance_info = dz_table["instance"];
|
||||
luabind::object zone = instance_info["zone"];
|
||||
|
||||
uint32_t zone_id = 0;
|
||||
if (luabind::type(zone) == LUA_TSTRING)
|
||||
{
|
||||
zone_id = ZoneID(luabind::object_cast<std::string>(zone));
|
||||
}
|
||||
else if (luabind::type(zone) == LUA_TNUMBER)
|
||||
{
|
||||
zone_id = luabind::object_cast<uint32_t>(zone);
|
||||
}
|
||||
|
||||
uint32_t zone_version = luabind::object_cast<uint32_t>(instance_info["version"]);
|
||||
|
||||
// tasks override dz duration so duration is ignored here
|
||||
DynamicZone dz{ zone_id, zone_version, 0, DynamicZoneType::None };
|
||||
|
||||
// the dz_info table supports optional hash entries for 'compass', 'safereturn', and 'zonein' data
|
||||
if (luabind::type(dz_table["compass"]) == LUA_TTABLE)
|
||||
{
|
||||
auto compass_loc = GetDynamicZoneLocationFromTable(dz_table["compass"]);
|
||||
dz.SetCompass(compass_loc);
|
||||
}
|
||||
|
||||
if (luabind::type(dz_table["safereturn"]) == LUA_TTABLE)
|
||||
{
|
||||
auto safereturn_loc = GetDynamicZoneLocationFromTable(dz_table["safereturn"]);
|
||||
dz.SetSafeReturn(safereturn_loc);
|
||||
}
|
||||
|
||||
if (luabind::type(dz_table["zonein"]) == LUA_TTABLE)
|
||||
{
|
||||
auto zonein_loc = GetDynamicZoneLocationFromTable(dz_table["zonein"]);
|
||||
dz.SetZoneInLocation(zonein_loc);
|
||||
}
|
||||
|
||||
self->CreateTaskDynamicZone(task_id, dz);
|
||||
}
|
||||
|
||||
void Lua_Client::Fling(float value, float target_x, float target_y, float target_z) {
|
||||
Lua_Safe_Call_Void();
|
||||
self->Fling(value, target_x, target_y, target_z);
|
||||
@@ -2515,6 +2560,7 @@ luabind::scope lua_register_client() {
|
||||
.def("MovePCDynamicZone", (void(Lua_Client::*)(std::string))&Lua_Client::MovePCDynamicZone)
|
||||
.def("MovePCDynamicZone", (void(Lua_Client::*)(std::string, int))&Lua_Client::MovePCDynamicZone)
|
||||
.def("MovePCDynamicZone", (void(Lua_Client::*)(std::string, int, bool))&Lua_Client::MovePCDynamicZone)
|
||||
.def("CreateTaskDynamicZone", &Lua_Client::CreateTaskDynamicZone)
|
||||
.def("Fling", (void(Lua_Client::*)(float,float,float,float))&Lua_Client::Fling)
|
||||
.def("Fling", (void(Lua_Client::*)(float,float,float,float,bool))&Lua_Client::Fling)
|
||||
.def("Fling", (void(Lua_Client::*)(float,float,float,float,bool,bool))&Lua_Client::Fling)
|
||||
|
||||
@@ -400,6 +400,7 @@ public:
|
||||
void MovePCDynamicZone(std::string zone_name);
|
||||
void MovePCDynamicZone(std::string zone_name, int zone_version);
|
||||
void MovePCDynamicZone(std::string zone_name, int zone_version, bool msg_if_invalid);
|
||||
void CreateTaskDynamicZone(int task_id, luabind::object dz_table);
|
||||
void Fling(float value, float target_x, float target_y, float target_z);
|
||||
void Fling(float value, float target_x, float target_y, float target_z, bool ignore_los);
|
||||
void Fling(float value, float target_x, float target_y, float target_z, bool ignore_los, bool clipping);
|
||||
|
||||
+16
-16
@@ -59,7 +59,7 @@ void Lua_Expedition::AddReplayLockoutDuration(int seconds, bool members_only) {
|
||||
|
||||
uint32_t Lua_Expedition::GetDynamicZoneID() {
|
||||
Lua_Safe_Call_Int();
|
||||
return self->GetDynamicZone().GetID();
|
||||
return self->GetDynamicZoneID();
|
||||
}
|
||||
|
||||
uint32_t Lua_Expedition::GetID() {
|
||||
@@ -69,7 +69,7 @@ uint32_t Lua_Expedition::GetID() {
|
||||
|
||||
int Lua_Expedition::GetInstanceID() {
|
||||
Lua_Safe_Call_Int();
|
||||
return self->GetDynamicZone().GetInstanceID();
|
||||
return self->GetDynamicZone()->GetInstanceID();
|
||||
}
|
||||
|
||||
std::string Lua_Expedition::GetLeaderName() {
|
||||
@@ -104,7 +104,7 @@ std::string Lua_Expedition::GetLootEventBySpawnID(uint32_t spawn_id) {
|
||||
|
||||
uint32_t Lua_Expedition::GetMemberCount() {
|
||||
Lua_Safe_Call_Int();
|
||||
return self->GetDynamicZone().GetMemberCount();
|
||||
return self->GetDynamicZone()->GetMemberCount();
|
||||
}
|
||||
|
||||
luabind::object Lua_Expedition::GetMembers(lua_State* L) {
|
||||
@@ -113,7 +113,7 @@ luabind::object Lua_Expedition::GetMembers(lua_State* L) {
|
||||
if (d_)
|
||||
{
|
||||
auto self = reinterpret_cast<NativeType*>(d_);
|
||||
for (const auto& member : self->GetDynamicZone().GetMembers())
|
||||
for (const auto& member : self->GetDynamicZone()->GetMembers())
|
||||
{
|
||||
lua_table[member.name] = member.id;
|
||||
}
|
||||
@@ -128,27 +128,27 @@ std::string Lua_Expedition::GetName() {
|
||||
|
||||
int Lua_Expedition::GetSecondsRemaining() {
|
||||
Lua_Safe_Call_Int();
|
||||
return self->GetDynamicZone().GetSecondsRemaining();
|
||||
return self->GetDynamicZone()->GetSecondsRemaining();
|
||||
}
|
||||
|
||||
std::string Lua_Expedition::GetUUID() {
|
||||
Lua_Safe_Call_String();
|
||||
return self->GetUUID();
|
||||
return self->GetDynamicZone()->GetUUID();
|
||||
}
|
||||
|
||||
int Lua_Expedition::GetZoneID() {
|
||||
Lua_Safe_Call_Int();
|
||||
return self->GetDynamicZone().GetZoneID();
|
||||
return self->GetDynamicZone()->GetZoneID();
|
||||
}
|
||||
|
||||
std::string Lua_Expedition::GetZoneName() {
|
||||
Lua_Safe_Call_String();
|
||||
return ZoneName(self->GetDynamicZone().GetZoneID());
|
||||
return ZoneName(self->GetDynamicZone()->GetZoneID());
|
||||
}
|
||||
|
||||
int Lua_Expedition::GetZoneVersion() {
|
||||
Lua_Safe_Call_Int();
|
||||
return self->GetDynamicZone().GetZoneVersion();
|
||||
return self->GetDynamicZone()->GetZoneVersion();
|
||||
}
|
||||
|
||||
bool Lua_Expedition::HasLockout(std::string event_name) {
|
||||
@@ -168,7 +168,7 @@ bool Lua_Expedition::IsLocked() {
|
||||
|
||||
void Lua_Expedition::RemoveCompass() {
|
||||
Lua_Safe_Call_Void();
|
||||
self->GetDynamicZone().SetCompass(0, 0, 0, 0, true);
|
||||
self->GetDynamicZone()->SetCompass(0, 0, 0, 0, true);
|
||||
}
|
||||
|
||||
void Lua_Expedition::RemoveLockout(std::string event_name) {
|
||||
@@ -178,12 +178,12 @@ void Lua_Expedition::RemoveLockout(std::string event_name) {
|
||||
|
||||
void Lua_Expedition::SetCompass(uint32_t zone_id, float x, float y, float z) {
|
||||
Lua_Safe_Call_Void();
|
||||
self->GetDynamicZone().SetCompass(zone_id, x, y, z, true);
|
||||
self->GetDynamicZone()->SetCompass(zone_id, x, y, z, true);
|
||||
}
|
||||
|
||||
void Lua_Expedition::SetCompass(std::string zone_name, float x, float y, float z) {
|
||||
Lua_Safe_Call_Void();
|
||||
self->GetDynamicZone().SetCompass(ZoneID(zone_name), x, y, z, true);
|
||||
self->GetDynamicZone()->SetCompass(ZoneID(zone_name), x, y, z, true);
|
||||
}
|
||||
|
||||
void Lua_Expedition::SetLocked(bool lock_expedition) {
|
||||
@@ -218,23 +218,23 @@ void Lua_Expedition::SetReplayLockoutOnMemberJoin(bool enable) {
|
||||
|
||||
void Lua_Expedition::SetSafeReturn(uint32_t zone_id, float x, float y, float z, float heading) {
|
||||
Lua_Safe_Call_Void();
|
||||
self->GetDynamicZone().SetSafeReturn(zone_id, x, y, z, heading, true);
|
||||
self->GetDynamicZone()->SetSafeReturn(zone_id, x, y, z, heading, true);
|
||||
}
|
||||
|
||||
void Lua_Expedition::SetSafeReturn(std::string zone_name, float x, float y, float z, float heading) {
|
||||
Lua_Safe_Call_Void();
|
||||
self->GetDynamicZone().SetSafeReturn(ZoneID(zone_name), x, y, z, heading, true);
|
||||
self->GetDynamicZone()->SetSafeReturn(ZoneID(zone_name), x, y, z, heading, true);
|
||||
}
|
||||
|
||||
void Lua_Expedition::SetSecondsRemaining(uint32_t seconds_remaining)
|
||||
{
|
||||
Lua_Safe_Call_Void();
|
||||
self->GetDynamicZone().SetSecondsRemaining(seconds_remaining);
|
||||
self->GetDynamicZone()->SetSecondsRemaining(seconds_remaining);
|
||||
}
|
||||
|
||||
void Lua_Expedition::SetZoneInLocation(float x, float y, float z, float heading) {
|
||||
Lua_Safe_Call_Void();
|
||||
self->GetDynamicZone().SetZoneInLocation(x, y, z, heading, true);
|
||||
self->GetDynamicZone()->SetZoneInLocation(x, y, z, heading, true);
|
||||
}
|
||||
|
||||
void Lua_Expedition::UpdateLockoutDuration(std::string event_name, uint32_t duration) {
|
||||
|
||||
+2
-2
@@ -675,7 +675,7 @@ luabind::scope lua_register_packet_opcodes() {
|
||||
luabind::value("MobRename", static_cast<int>(OP_MobRename)),
|
||||
luabind::value("TaskDescription", static_cast<int>(OP_TaskDescription)),
|
||||
luabind::value("TaskActivity", static_cast<int>(OP_TaskActivity)),
|
||||
luabind::value("TaskMemberList", static_cast<int>(OP_TaskMemberList)),
|
||||
luabind::value("SharedTaskPlayerList", static_cast<int>(OP_SharedTaskPlayerList)),
|
||||
luabind::value("AnnoyingZoneUnknown", static_cast<int>(OP_AnnoyingZoneUnknown)),
|
||||
luabind::value("Some3ByteHPUpdate", static_cast<int>(OP_Some3ByteHPUpdate)),
|
||||
luabind::value("FloatListThing", static_cast<int>(OP_FloatListThing)),
|
||||
@@ -770,7 +770,7 @@ luabind::scope lua_register_packet_opcodes() {
|
||||
luabind::value("ZonePlayerToBind", static_cast<int>(OP_ZonePlayerToBind)),
|
||||
luabind::value("AutoFire", static_cast<int>(OP_AutoFire)),
|
||||
luabind::value("Rewind", static_cast<int>(OP_Rewind)),
|
||||
luabind::value("OpenNewTasksWindow", static_cast<int>(OP_OpenNewTasksWindow)),
|
||||
luabind::value("TaskSelectWindow", static_cast<int>(OP_TaskSelectWindow)),
|
||||
luabind::value("TaskActivityComplete", static_cast<int>(OP_TaskActivityComplete)),
|
||||
luabind::value("AcceptNewTask", static_cast<int>(OP_AcceptNewTask)),
|
||||
luabind::value("CancelTask", static_cast<int>(OP_CancelTask)),
|
||||
|
||||
@@ -198,6 +198,7 @@ LuaParser::LuaParser() {
|
||||
PlayerArgumentDispatch[EVENT_PLAYER_PICKUP] = handle_player_pick_up;
|
||||
PlayerArgumentDispatch[EVENT_CAST] = handle_player_cast;
|
||||
PlayerArgumentDispatch[EVENT_CAST_BEGIN] = handle_player_cast;
|
||||
PlayerArgumentDispatch[EVENT_CAST_ON] = handle_player_cast;
|
||||
PlayerArgumentDispatch[EVENT_TASK_FAIL] = handle_player_task_fail;
|
||||
PlayerArgumentDispatch[EVENT_ZONE] = handle_player_zone;
|
||||
PlayerArgumentDispatch[EVENT_DUEL_WIN] = handle_player_duel_win;
|
||||
|
||||
+16
-16
@@ -142,7 +142,7 @@ XS(XS_Expedition_GetDynamicZoneID) {
|
||||
Expedition* THIS = nullptr;
|
||||
VALIDATE_THIS_IS_EXPEDITION;
|
||||
|
||||
XSRETURN_UV(THIS->GetDynamicZone().GetID());
|
||||
XSRETURN_UV(THIS->GetDynamicZone()->GetID());
|
||||
}
|
||||
|
||||
XS(XS_Expedition_GetID);
|
||||
@@ -168,7 +168,7 @@ XS(XS_Expedition_GetInstanceID) {
|
||||
Expedition* THIS = nullptr;
|
||||
VALIDATE_THIS_IS_EXPEDITION;
|
||||
|
||||
XSRETURN_UV(THIS->GetDynamicZone().GetInstanceID());
|
||||
XSRETURN_UV(THIS->GetDynamicZone()->GetInstanceID());
|
||||
}
|
||||
|
||||
XS(XS_Expedition_GetLeaderName);
|
||||
@@ -247,7 +247,7 @@ XS(XS_Expedition_GetMemberCount) {
|
||||
Expedition* THIS = nullptr;
|
||||
VALIDATE_THIS_IS_EXPEDITION;
|
||||
|
||||
XSRETURN_UV(THIS->GetDynamicZone().GetMemberCount());
|
||||
XSRETURN_UV(THIS->GetDynamicZone()->GetMemberCount());
|
||||
}
|
||||
|
||||
XS(XS_Expedition_GetMembers);
|
||||
@@ -262,7 +262,7 @@ XS(XS_Expedition_GetMembers) {
|
||||
|
||||
HV* hash = newHV();
|
||||
|
||||
for (const auto& member : THIS->GetDynamicZone().GetMembers())
|
||||
for (const auto& member : THIS->GetDynamicZone()->GetMembers())
|
||||
{
|
||||
hv_store(hash, member.name.c_str(), static_cast<uint32_t>(member.name.size()),
|
||||
newSVuv(member.id), 0);
|
||||
@@ -295,7 +295,7 @@ XS(XS_Expedition_GetSecondsRemaining) {
|
||||
Expedition* THIS = nullptr;
|
||||
VALIDATE_THIS_IS_EXPEDITION;
|
||||
|
||||
XSRETURN_UV(THIS->GetDynamicZone().GetSecondsRemaining());
|
||||
XSRETURN_UV(THIS->GetDynamicZone()->GetSecondsRemaining());
|
||||
}
|
||||
|
||||
XS(XS_Expedition_GetUUID);
|
||||
@@ -308,7 +308,7 @@ XS(XS_Expedition_GetUUID) {
|
||||
Expedition* THIS = nullptr;
|
||||
VALIDATE_THIS_IS_EXPEDITION;
|
||||
|
||||
XSRETURN_PV(THIS->GetUUID().c_str());
|
||||
XSRETURN_PV(THIS->GetDynamicZone()->GetUUID().c_str());
|
||||
}
|
||||
|
||||
XS(XS_Expedition_GetZoneID);
|
||||
@@ -321,7 +321,7 @@ XS(XS_Expedition_GetZoneID) {
|
||||
Expedition* THIS = nullptr;
|
||||
VALIDATE_THIS_IS_EXPEDITION;
|
||||
|
||||
XSRETURN_UV(THIS->GetDynamicZone().GetZoneID());
|
||||
XSRETURN_UV(THIS->GetDynamicZone()->GetZoneID());
|
||||
}
|
||||
|
||||
XS(XS_Expedition_GetZoneName);
|
||||
@@ -334,7 +334,7 @@ XS(XS_Expedition_GetZoneName) {
|
||||
Expedition* THIS = nullptr;
|
||||
VALIDATE_THIS_IS_EXPEDITION;
|
||||
|
||||
XSRETURN_PV(ZoneName(THIS->GetDynamicZone().GetZoneID()));
|
||||
XSRETURN_PV(ZoneName(THIS->GetDynamicZone()->GetZoneID()));
|
||||
}
|
||||
|
||||
XS(XS_Expedition_GetZoneVersion);
|
||||
@@ -347,7 +347,7 @@ XS(XS_Expedition_GetZoneVersion) {
|
||||
Expedition* THIS = nullptr;
|
||||
VALIDATE_THIS_IS_EXPEDITION;
|
||||
|
||||
XSRETURN_UV(THIS->GetDynamicZone().GetZoneVersion());
|
||||
XSRETURN_UV(THIS->GetDynamicZone()->GetZoneVersion());
|
||||
}
|
||||
|
||||
XS(XS_Expedition_HasLockout);
|
||||
@@ -406,7 +406,7 @@ XS(XS_Expedition_RemoveCompass) {
|
||||
Expedition* THIS = nullptr;
|
||||
VALIDATE_THIS_IS_EXPEDITION;
|
||||
|
||||
THIS->GetDynamicZone().SetCompass(0, 0, 0, 0, true);
|
||||
THIS->GetDynamicZone()->SetCompass(0, 0, 0, 0, true);
|
||||
|
||||
XSRETURN_EMPTY;
|
||||
}
|
||||
@@ -445,12 +445,12 @@ XS(XS_Expedition_SetCompass) {
|
||||
if (SvTYPE(ST(1)) == SVt_PV)
|
||||
{
|
||||
std::string zone_name(SvPV_nolen(ST(1)));
|
||||
THIS->GetDynamicZone().SetCompass(ZoneID(zone_name), x, y, z, true);
|
||||
THIS->GetDynamicZone()->SetCompass(ZoneID(zone_name), x, y, z, true);
|
||||
}
|
||||
else if (SvTYPE(ST(1)) == SVt_IV)
|
||||
{
|
||||
uint32_t zone_id = static_cast<uint32_t>(SvUV(ST(1)));
|
||||
THIS->GetDynamicZone().SetCompass(zone_id, x, y, z, true);
|
||||
THIS->GetDynamicZone()->SetCompass(zone_id, x, y, z, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -555,12 +555,12 @@ XS(XS_Expedition_SetSafeReturn) {
|
||||
if (SvTYPE(ST(1)) == SVt_PV)
|
||||
{
|
||||
std::string zone_name(SvPV_nolen(ST(1)));
|
||||
THIS->GetDynamicZone().SetSafeReturn(ZoneID(zone_name), x, y, z, heading, true);
|
||||
THIS->GetDynamicZone()->SetSafeReturn(ZoneID(zone_name), x, y, z, heading, true);
|
||||
}
|
||||
else if (SvTYPE(ST(1)) == SVt_IV)
|
||||
{
|
||||
uint32_t zone_id = static_cast<uint32_t>(SvUV(ST(1)));
|
||||
THIS->GetDynamicZone().SetSafeReturn(zone_id, x, y, z, heading, true);
|
||||
THIS->GetDynamicZone()->SetSafeReturn(zone_id, x, y, z, heading, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -581,7 +581,7 @@ XS(XS_Expedition_SetSecondsRemaining) {
|
||||
VALIDATE_THIS_IS_EXPEDITION;
|
||||
|
||||
uint32_t seconds_remaining = static_cast<uint32_t>(SvUV(ST(1)));
|
||||
THIS->GetDynamicZone().SetSecondsRemaining(seconds_remaining);
|
||||
THIS->GetDynamicZone()->SetSecondsRemaining(seconds_remaining);
|
||||
|
||||
XSRETURN_EMPTY;
|
||||
}
|
||||
@@ -601,7 +601,7 @@ XS(XS_Expedition_SetZoneInLocation) {
|
||||
float z = static_cast<float>(SvNV(ST(3)));
|
||||
float heading = static_cast<float>(SvNV(ST(4)));
|
||||
|
||||
THIS->GetDynamicZone().SetZoneInLocation(x, y, z, heading, true);
|
||||
THIS->GetDynamicZone()->SetZoneInLocation(x, y, z, heading, true);
|
||||
|
||||
XSRETURN_EMPTY;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,176 @@
|
||||
#include "shared_task_zone_messaging.h"
|
||||
#include "../common/shared_tasks.h"
|
||||
#include "../common/servertalk.h"
|
||||
#include "client.h"
|
||||
#include "../common/repositories/character_data_repository.h"
|
||||
#include "../common/repositories/shared_task_members_repository.h"
|
||||
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
void SharedTaskZoneMessaging::HandleWorldMessage(ServerPacket *pack)
|
||||
{
|
||||
switch (pack->opcode) {
|
||||
case ServerOP_SharedTaskAcceptNewTask: {
|
||||
auto p = reinterpret_cast<ServerSharedTaskRequest_Struct *>(pack->pBuffer);
|
||||
auto c = entity_list.GetClientByCharID(p->requested_character_id);
|
||||
if (c) {
|
||||
LogTasks("[ServerOP_SharedTaskAcceptNewTask] We're back in zone and I found [{}]", c->GetCleanName());
|
||||
|
||||
c->m_requesting_shared_task = true;
|
||||
c->GetTaskState()
|
||||
->AcceptNewTask(
|
||||
c,
|
||||
(int) p->requested_task_id,
|
||||
(int) p->requested_npc_type_id,
|
||||
p->accept_time
|
||||
);
|
||||
c->LoadClientTaskState();
|
||||
c->m_requesting_shared_task = false;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case ServerOP_SharedTaskUpdate: {
|
||||
auto p = reinterpret_cast<ServerSharedTaskActivityUpdate_Struct *>(pack->pBuffer);
|
||||
auto c = entity_list.GetClientByCharID(p->source_character_id);
|
||||
if (c) {
|
||||
LogTasks("[ServerOP_SharedTaskUpdate] We're back in zone and I found [{}]", c->GetCleanName());
|
||||
|
||||
c->m_shared_task_update = true;
|
||||
c->GetTaskState()->SharedTaskIncrementDoneCount(
|
||||
c,
|
||||
(int) p->task_id,
|
||||
(int) p->activity_id,
|
||||
(int) p->done_count,
|
||||
p->ignore_quest_update
|
||||
);
|
||||
c->m_shared_task_update = false;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case ServerOP_SharedTaskAttemptRemove: {
|
||||
auto p = reinterpret_cast<ServerSharedTaskAttemptRemove_Struct *>(pack->pBuffer);
|
||||
auto c = entity_list.GetClientByCharID(p->requested_character_id);
|
||||
if (c) {
|
||||
LogTasks("[ServerOP_SharedTaskAttemptRemove] We're back in zone and I found [{}]", c->GetCleanName());
|
||||
|
||||
c->m_requested_shared_task_removal = true;
|
||||
c->GetTaskState()->CancelTask(
|
||||
c,
|
||||
TASKSLOTSHAREDTASK,
|
||||
static_cast<TaskType>((int) TASK_TYPE_SHARED),
|
||||
p->remove_from_db
|
||||
);
|
||||
c->m_requested_shared_task_removal = false;
|
||||
|
||||
c->SetSharedTaskId(0);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case ServerOP_SharedTaskMemberlist: {
|
||||
auto p = reinterpret_cast<ServerSharedTaskMemberListPacket_Struct *>(pack->pBuffer);
|
||||
|
||||
LogTasks(
|
||||
"[ServerOP_SharedTaskMemberlist] We're back in zone and I'm searching for [{}]",
|
||||
p->destination_character_id
|
||||
);
|
||||
|
||||
// find character and route packet
|
||||
auto c = entity_list.GetClientByCharID(p->destination_character_id);
|
||||
if (c) {
|
||||
LogTasks("[ServerOP_SharedTaskMemberlist] We're back in zone and I found [{}]", c->GetCleanName());
|
||||
|
||||
std::vector<SharedTaskMember> members;
|
||||
|
||||
// deserialize members from world
|
||||
EQ::Util::MemoryStreamReader ss(p->cereal_serialized_members, p->cereal_size);
|
||||
cereal::BinaryInputArchive archive(ss);
|
||||
archive(members);
|
||||
|
||||
SerializeBuffer buf(sizeof(SharedTaskMemberList_Struct) + 15 * members.size());
|
||||
buf.WriteInt32(0); // unknown ids
|
||||
buf.WriteInt32(0);
|
||||
buf.WriteInt32((int32) members.size());
|
||||
|
||||
for (auto &m : members) {
|
||||
buf.WriteString(m.character_name);
|
||||
buf.WriteInt32(0); // monster mission
|
||||
buf.WriteInt8(m.is_leader ? 1 : 0);
|
||||
}
|
||||
|
||||
auto outapp = std::make_unique<EQApplicationPacket>(OP_SharedTaskMemberList, buf);
|
||||
c->QueuePacket(outapp.get());
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case ServerOP_SharedTaskMemberChange: {
|
||||
auto p = reinterpret_cast<ServerSharedTaskMemberChangePacket_Struct *>(pack->pBuffer);
|
||||
|
||||
LogTasksDetail("[ServerOP_SharedTaskMemberChange] Searching for [{}]", p->destination_character_id);
|
||||
|
||||
auto c = entity_list.GetClientByCharID(p->destination_character_id);
|
||||
if (c) {
|
||||
LogTasksDetail("[ServerOP_SharedTaskMemberChange] Found [{}]", c->GetCleanName());
|
||||
|
||||
SerializeBuffer buf;
|
||||
buf.WriteInt32(0); // unique character id of receiver, leave 0 for emu
|
||||
buf.WriteInt32(0); // unknown, seen 50, 4, 0
|
||||
buf.WriteInt8(p->removed ? 0 : 1); // 0: removed 1: added
|
||||
buf.WriteString(p->player_name);
|
||||
|
||||
// live sends more after the name but it might just be garbage from
|
||||
// a re-used buffer (possibly a former name[64] buffer?)
|
||||
|
||||
auto outapp = std::make_unique<EQApplicationPacket>(OP_SharedTaskMemberChange, buf);
|
||||
c->QueuePacket(outapp.get());
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case ServerOP_SharedTaskInvitePlayer: {
|
||||
auto p = reinterpret_cast<ServerSharedTaskInvitePlayer_Struct *>(pack->pBuffer);
|
||||
auto c = entity_list.GetClientByCharID(p->requested_character_id);
|
||||
if (c) {
|
||||
LogTasks("[ServerOP_SharedTaskInvitePlayer] We're back in zone and I found [{}]", c->GetCleanName());
|
||||
|
||||
// init packet
|
||||
auto outapp = new EQApplicationPacket(OP_SharedTaskInvite, sizeof(SharedTaskInvite_Struct));
|
||||
auto *i = (SharedTaskInvite_Struct *) outapp->pBuffer;
|
||||
|
||||
// fill
|
||||
i->unknown00 = 0;
|
||||
i->invite_id = (int) p->invite_shared_task_id;
|
||||
strn0cpy(i->inviter_name, p->inviter_name, 64);
|
||||
strn0cpy(i->task_name, p->task_name, 64);
|
||||
|
||||
// sends
|
||||
c->QueuePacket(outapp);
|
||||
safe_delete(outapp);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case ServerOP_SharedTaskPurgeAllCommand: {
|
||||
LogTasksDetail("[ServerOP_SharedTaskPurgeAllCommand] Syncing clients");
|
||||
|
||||
for (auto &client: entity_list.GetClientList()) {
|
||||
Client *c = client.second;
|
||||
task_manager->SyncClientSharedTaskState(c, c->GetTaskState());
|
||||
c->RemoveClientTaskState();
|
||||
c->LoadClientTaskState();
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
#ifndef EQEMU_SHARED_TASK_ZONE_MESSAGING_H
|
||||
#define EQEMU_SHARED_TASK_ZONE_MESSAGING_H
|
||||
|
||||
class ServerPacket;
|
||||
|
||||
class SharedTaskZoneMessaging {
|
||||
public:
|
||||
static void HandleWorldMessage(ServerPacket *pack);
|
||||
};
|
||||
|
||||
|
||||
#endif //EQEMU_SHARED_TASK_ZONE_MESSAGING_H
|
||||
@@ -173,6 +173,7 @@
|
||||
#define GENERIC_STRINGID_SAY 554 //%1 says '%T2'
|
||||
#define CANNOT_WAKE 555 //%1 tells you, 'I am unable to wake %2, master.'
|
||||
#define SUMMONING_CORPSE_ZONE 596 //Summoning %1's corpse(s).
|
||||
#define TASK_NOT_RIGHT_LEVEL 615 //You are not at the right level for this task.
|
||||
#define PET_HOLD_SET_ON 698 //The pet hold mode has been set to on.
|
||||
#define PET_HOLD_SET_OFF 699 //The pet hold mode has been set to off.
|
||||
#define PET_FOCUS_SET_ON 700 //The pet focus mode has been set to on.
|
||||
@@ -295,6 +296,8 @@
|
||||
#define TRADESKILL_MISSING_ITEM 3455 //You are missing a %1.
|
||||
#define TRADESKILL_MISSING_COMPONENTS 3456 //Sorry, but you don't have everything you need for this recipe in your general inventory.
|
||||
#define TRADESKILL_LEARN_RECIPE 3457 //You have learned the recipe %1!
|
||||
#define TASK_UPDATED 3471 //Your task '%1' has been updated.
|
||||
#define YOU_ASSIGNED_TASK 3472 //You have been assigned the task '%1'.
|
||||
#define EXPEDITION_YOU_BELONG 3500 //You cannot create this expedition since you already belong to another.
|
||||
#define EXPEDITION_YOU_PLAYED_HERE 3501 //You cannot create this expedition for another %1d:%2h:%3m since you have recently played here.
|
||||
#define REQUIRED_PLAYER_COUNT 3503 //You do not meet the player count requirement. You have %1 players. You must have at least %2 and no more than %3.
|
||||
@@ -369,7 +372,10 @@
|
||||
#define FAILED_TAUNT 5811 //You have failed to taunt your target.
|
||||
#define PHYSICAL_RESIST_FAIL 5817 //Your target avoided your %1 ability.
|
||||
#define AA_NO_TARGET 5825 //You must first select a target for this ability!
|
||||
#define YOU_RECEIVE 5941 //You receive %1.
|
||||
#define NO_TASK_OFFERS 6009 //Sorry %3, I don't have anything for someone with your abilities.
|
||||
#define MAX_ACTIVE_TASKS 6010 //Sorry %3, you already have the maximum number of active tasks.
|
||||
#define TASK_REQUEST_COOLDOWN_TIMER 6011 //Sorry, %3, but you can't request another task for %4 minutes and %5 seconds.
|
||||
#define FORAGE_MASTERY 6012 //Your forage mastery has enabled you to find something else!
|
||||
#define GUILD_BANK_CANNOT_DEPOSIT 6097 // Cannot deposit this item. Containers must be empty, and only one of each LORE and no NO TRADE or TEMPORARY items may be deposited.
|
||||
#define GUILD_BANK_FULL 6098 // There is no more room in the Guild Bank.
|
||||
@@ -418,6 +424,7 @@
|
||||
#define GAIN_GROUP_LEADERSHIP_EXP 8788 //
|
||||
#define GAIN_RAID_LEADERSHIP_EXP 8789 //
|
||||
#define BUFF_MINUTES_REMAINING 8799 //%1 (%2 minutes remaining)
|
||||
#define YOU_HAVE_BEEN_GIVEN 8994 //You have been given: %1
|
||||
#define NO_MORE_TRAPS 9002 //You have already placed your maximum number of traps.
|
||||
#define FEAR_TOO_HIGH 9035 //Your target is too high of a level for your fear spell.
|
||||
#define SLOW_MOSTLY_SUCCESSFUL 9029 //Your spell was mostly successful.
|
||||
|
||||
+905
-212
File diff suppressed because it is too large
Load Diff
@@ -20,7 +20,7 @@ public:
|
||||
int GetTaskActivityDoneCount(TaskType task_type, int index, int activity_id);
|
||||
int GetTaskActivityDoneCountFromTaskID(int task_id, int activity_id);
|
||||
int GetTaskStartTime(TaskType task_type, int index);
|
||||
void AcceptNewTask(Client *client, int task_id, int npc_type_id, bool enforce_level_requirement = false);
|
||||
void AcceptNewTask(Client *client, int task_id, int npc_type_id, time_t accept_time, bool enforce_level_requirement = false);
|
||||
void FailTask(Client *client, int task_id);
|
||||
int TaskTimeLeft(int task_id);
|
||||
int IsTaskCompleted(int task_id);
|
||||
@@ -29,13 +29,13 @@ public:
|
||||
ActivityState GetTaskActivityState(TaskType task_type, int index, int activity_id);
|
||||
void UpdateTaskActivity(Client *client, int task_id, int activity_id, int count, bool ignore_quest_update = false);
|
||||
void ResetTaskActivity(Client *client, int task_id, int activity_id);
|
||||
void CancelTask(Client *client, int sequence_number, TaskType task_type, bool remove_from_db = true);
|
||||
void CancelTask(Client *c, int sequence_number, TaskType task_type, bool remove_from_db = true);
|
||||
void CancelAllTasks(Client *client);
|
||||
void RemoveTask(Client *client, int sequence_number, TaskType task_type);
|
||||
void RemoveTaskByTaskID(Client *client, uint32 task_id);
|
||||
bool UpdateTasksByNPC(Client *client, int activity_type, int npc_type_id);
|
||||
bool UpdateTasksByNPC(Client *client, TaskActivityType activity_type, int npc_type_id);
|
||||
void UpdateTasksOnKill(Client *client, int npc_type_id);
|
||||
void UpdateTasksForItem(Client *client, ActivityType activity_type, int item_id, int count = 1);
|
||||
void UpdateTasksForItem(Client *client, TaskActivityType activity_type, int item_id, int count = 1);
|
||||
void UpdateTasksOnExplore(Client *client, int explore_id);
|
||||
bool UpdateTasksOnSpeakWith(Client *client, int npc_type_id);
|
||||
bool UpdateTasksOnDeliver(Client *client, std::list<EQ::ItemInstance *> &items, int cash, int npc_type_id);
|
||||
@@ -54,13 +54,31 @@ public:
|
||||
int ActiveTasksInSet(int task_set_id);
|
||||
int CompletedTasksInSet(int task_set_id);
|
||||
bool HasSlotForTask(TaskInformation *task);
|
||||
void CreateTaskDynamicZone(Client* client, int task_id, DynamicZone& dz);
|
||||
void ListTaskTimers(Client* client);
|
||||
void KickPlayersSharedTask(Client* client);
|
||||
|
||||
inline bool HasFreeTaskSlot() { return m_active_task.task_id == TASKSLOTEMPTY; }
|
||||
|
||||
friend class TaskManager;
|
||||
|
||||
// wrapper to call internal IncrementDoneCount
|
||||
void SharedTaskIncrementDoneCount(
|
||||
Client *client,
|
||||
int task_id,
|
||||
int activity_id,
|
||||
int done_count,
|
||||
bool ignore_quest_update = false
|
||||
);
|
||||
|
||||
const ClientTaskInformation &GetActiveSharedTask() const;
|
||||
bool HasActiveSharedTask();
|
||||
|
||||
|
||||
void HandleUpdateTasksOnKill(Client *client, uint32 npc_type_id);
|
||||
private:
|
||||
bool UnlockActivities(int character_id, ClientTaskInformation &task_info);
|
||||
void AddReplayTimer(Client *client, ClientTaskInformation& client_task, TaskInformation& task);
|
||||
|
||||
void IncrementDoneCount(
|
||||
Client *client,
|
||||
TaskInformation *task_information,
|
||||
@@ -70,16 +88,21 @@ private:
|
||||
bool ignore_quest_update = false
|
||||
);
|
||||
|
||||
bool UnlockActivities(int character_id, ClientTaskInformation &task_info);
|
||||
|
||||
inline ClientTaskInformation *GetClientTaskInfo(TaskType task_type, int index)
|
||||
{
|
||||
ClientTaskInformation *info = nullptr;
|
||||
switch (task_type) {
|
||||
case TaskType::Task:
|
||||
if (index == 0) {
|
||||
if (index == TASKSLOTTASK) {
|
||||
info = &m_active_task;
|
||||
}
|
||||
break;
|
||||
case TaskType::Shared:
|
||||
if (index == TASKSLOTSHAREDTASK) {
|
||||
info = &m_active_shared_task;
|
||||
}
|
||||
break;
|
||||
case TaskType::Quest:
|
||||
if (index < MAXACTIVEQUESTS) {
|
||||
@@ -95,9 +118,13 @@ private:
|
||||
union { // easier to loop over
|
||||
struct {
|
||||
ClientTaskInformation m_active_task; // only one
|
||||
|
||||
// acts as a read-only "view" of data that is managed by world and the internal task
|
||||
// system largely behaves like other tasks but shims logic to world where necessary
|
||||
ClientTaskInformation m_active_shared_task; // only one
|
||||
ClientTaskInformation m_active_quests[MAXACTIVEQUESTS];
|
||||
};
|
||||
ClientTaskInformation m_active_tasks[MAXACTIVEQUESTS + 1];
|
||||
ClientTaskInformation m_active_tasks[MAXACTIVEQUESTS + 2] = {};
|
||||
};
|
||||
// Shared tasks should be limited to 1 as well
|
||||
int m_active_task_count;
|
||||
@@ -105,6 +132,17 @@ private:
|
||||
std::vector<CompletedTaskInformation> m_completed_tasks;
|
||||
int m_last_completed_task_loaded;
|
||||
bool m_checked_touch_activities;
|
||||
|
||||
static void ShowClientTaskInfoMessage(ClientTaskInformation *task, Client *c);
|
||||
|
||||
void SyncSharedTaskZoneClientDoneCountState(
|
||||
Client *p_client,
|
||||
TaskInformation *p_information,
|
||||
int task_index,
|
||||
int activity_id,
|
||||
uint32 done_count
|
||||
);
|
||||
bool HasActiveTasks();
|
||||
};
|
||||
|
||||
|
||||
|
||||
+580
-420
File diff suppressed because it is too large
Load Diff
+11
-10
@@ -6,6 +6,7 @@
|
||||
#include "task_proximity_manager.h"
|
||||
#include "task_goal_list_manager.h"
|
||||
#include "../common/types.h"
|
||||
#include "../common/repositories/character_tasks_repository.h"
|
||||
#include <list>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
@@ -31,7 +32,6 @@ public:
|
||||
bool LoadClientState(Client *client, ClientTaskState *client_task_state);
|
||||
bool SaveClientState(Client *client, ClientTaskState *client_task_state);
|
||||
void SendTaskSelector(Client *client, Mob *mob, int task_count, int *task_list);
|
||||
void SendTaskSelectorNew(Client *client, Mob *mob, int task_count, int *task_list);
|
||||
bool ValidateLevel(int task_id, int player_level);
|
||||
std::string GetTaskName(uint32 task_id);
|
||||
TaskType GetTaskType(uint32 task_id);
|
||||
@@ -44,6 +44,7 @@ public:
|
||||
int count,
|
||||
int *tasks
|
||||
);
|
||||
void SharedTaskSelector(Client* client, Mob* mob, int count, const int* tasks);
|
||||
void SendActiveTasksToClient(Client *client, bool task_complete = false);
|
||||
void SendSingleActiveTaskToClient(
|
||||
Client *client,
|
||||
@@ -57,15 +58,6 @@ public:
|
||||
int task_id,
|
||||
int activity_id,
|
||||
int client_task_index,
|
||||
bool optional,
|
||||
bool task_complete = false
|
||||
);
|
||||
void SendTaskActivityNew(
|
||||
Client *client,
|
||||
int task_id,
|
||||
int activity_id,
|
||||
int client_task_index,
|
||||
bool optional,
|
||||
bool task_complete = false
|
||||
);
|
||||
void SendCompletedTasksToClient(Client *c, ClientTaskState *client_task_state);
|
||||
@@ -77,6 +69,8 @@ public:
|
||||
|
||||
friend class ClientTaskState;
|
||||
|
||||
// shared tasks
|
||||
void SyncClientSharedTaskState(Client *c, ClientTaskState *cts);
|
||||
|
||||
private:
|
||||
TaskGoalListManager m_goal_list_manager;
|
||||
@@ -92,6 +86,13 @@ private:
|
||||
bool bring_up_task_journal = false
|
||||
);
|
||||
|
||||
void SendActiveTaskToClient(ClientTaskInformation *task, Client *client, int task_index, bool task_complete);
|
||||
|
||||
// shared tasks
|
||||
void SyncClientSharedTaskWithPersistedState(Client *c, ClientTaskState *cts);
|
||||
void SyncClientSharedTaskRemoveLocalIfNotExists(Client *c, ClientTaskState *cts);
|
||||
void SendSharedTaskSelector(Client* client, Mob* mob, int task_count, int* task_list);
|
||||
void SyncClientSharedTaskStateToLocal(Client *c);
|
||||
};
|
||||
|
||||
|
||||
|
||||
+39
-1
@@ -5,8 +5,10 @@
|
||||
#include "client.h"
|
||||
#include "queryserv.h"
|
||||
#include "quest_parser_collection.h"
|
||||
#include "string_ids.h"
|
||||
#include "tasks.h"
|
||||
#include "zonedb.h"
|
||||
#include "../common/repositories/character_task_timers_repository.h"
|
||||
|
||||
extern QueryServ *QServ;
|
||||
|
||||
@@ -17,7 +19,7 @@ void Client::LoadClientTaskState()
|
||||
safe_delete(task_state);
|
||||
}
|
||||
|
||||
task_state = new ClientTaskState;
|
||||
task_state = new ClientTaskState();
|
||||
if (!task_manager->LoadClientState(this, task_state)) {
|
||||
safe_delete(task_state);
|
||||
}
|
||||
@@ -118,6 +120,42 @@ void Client::SendTaskFailed(int task_id, int task_index, TaskType task_type)
|
||||
safe_delete(outapp);
|
||||
}
|
||||
|
||||
bool Client::HasTaskRequestCooldownTimer()
|
||||
{
|
||||
if (task_request_timer.Check(false))
|
||||
{
|
||||
task_request_timer.Disable();
|
||||
}
|
||||
|
||||
return (!GetGM() && task_request_timer.Enabled());
|
||||
}
|
||||
|
||||
void Client::SendTaskRequestCooldownTimerMessage()
|
||||
{
|
||||
if (HasTaskRequestCooldownTimer())
|
||||
{
|
||||
uint32_t seconds = task_request_timer.GetRemainingTime() / 1000;
|
||||
MessageString(Chat::Yellow, TASK_REQUEST_COOLDOWN_TIMER,
|
||||
".", ".", // args start at %3 for this eqstr
|
||||
GetName(),
|
||||
fmt::format_int(seconds / 60).c_str(), // minutes
|
||||
fmt::format_int(seconds % 60).c_str() // seconds
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
void Client::StartTaskRequestCooldownTimer()
|
||||
{
|
||||
uint32_t milliseconds = RuleI(TaskSystem, RequestCooldownTimerSeconds) * 1000;
|
||||
task_request_timer.Start(milliseconds);
|
||||
|
||||
uint32_t size = sizeof(uint32_t);
|
||||
auto outapp = std::make_unique<EQApplicationPacket>(OP_TaskRequestTimer, size);
|
||||
outapp->WriteUInt32(milliseconds);
|
||||
QueuePacket(outapp.get());
|
||||
}
|
||||
|
||||
void Client::PurgeTaskTimers()
|
||||
{
|
||||
CharacterTaskTimersRepository::DeleteWhere(database, fmt::format("character_id = {}", CharacterID()));
|
||||
}
|
||||
|
||||
+1
-132
@@ -2,24 +2,12 @@
|
||||
#define TASKS_H
|
||||
|
||||
#include "../common/types.h"
|
||||
#include "../common/tasks.h"
|
||||
#include <list>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <algorithm>
|
||||
|
||||
#define MAXTASKS 10000
|
||||
#define MAXTASKSETS 1000
|
||||
#define MAXACTIVEQUESTS 19 // The Client has a hard cap of 19 active quests, 29 in SoD+
|
||||
#define MAXCHOOSERENTRIES 40 // The Max Chooser (Task Selector entries) is capped at 40 in the Titanium Client.
|
||||
#define MAXACTIVITIESPERTASK 20 // The Client has a hard cap of 20 activities per task.
|
||||
#define TASKSLOTEMPTY 0 // This is used to determine if a client's active task slot is empty.
|
||||
|
||||
// Command Codes for worldserver ServerOP_ReloadTasks
|
||||
#define RELOADTASKS 0
|
||||
#define RELOADTASKGOALLISTS 1
|
||||
#define RELOADTASKPROXIMITIES 2
|
||||
#define RELOADTASKSETS 3
|
||||
|
||||
class Client;
|
||||
class Mob;
|
||||
|
||||
@@ -27,123 +15,4 @@ namespace EQ {
|
||||
class ItemInstance;
|
||||
}
|
||||
|
||||
typedef enum {
|
||||
METHODSINGLEID = 0,
|
||||
METHODLIST = 1,
|
||||
METHODQUEST = 2
|
||||
} TaskMethodType;
|
||||
|
||||
struct ActivityInformation {
|
||||
int step_number;
|
||||
int activity_type;
|
||||
std::string target_name; // name mob, location -- default empty
|
||||
std::string item_list; // likely defaults to empty
|
||||
std::string skill_list; // IDs ; separated -- default -1
|
||||
std::string spell_list; // IDs ; separated -- default 0
|
||||
std::string description_override; // overrides auto generated description -- default empty
|
||||
int skill_id; // older clients, first id from above
|
||||
int spell_id; // older clients, first id from above
|
||||
int goal_id;
|
||||
TaskMethodType goal_method;
|
||||
int goal_count;
|
||||
int deliver_to_npc;
|
||||
std::vector<int> zone_ids;
|
||||
std::string zones; // IDs ; searated, ZoneID is the first in this list for older clients -- default empty string
|
||||
bool optional;
|
||||
|
||||
inline bool CheckZone(int zone_id)
|
||||
{
|
||||
if (zone_ids.empty()) {
|
||||
return true;
|
||||
}
|
||||
return std::find(zone_ids.begin(), zone_ids.end(), zone_id) != zone_ids.end();
|
||||
}
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
ActivitiesSequential = 0,
|
||||
ActivitiesStepped = 1
|
||||
} SequenceType;
|
||||
|
||||
enum class TaskType {
|
||||
Task = 0, // can have at max 1
|
||||
Shared = 1, // can have at max 1
|
||||
Quest = 2, // can have at max 19 or 29 depending on client
|
||||
E = 3 // can have at max 19 or 29 depending on client, not present in live anymore
|
||||
};
|
||||
|
||||
enum class DurationCode {
|
||||
None = 0,
|
||||
Short = 1,
|
||||
Medium = 2,
|
||||
Long = 3
|
||||
};
|
||||
|
||||
struct TaskInformation {
|
||||
TaskType type;
|
||||
int duration;
|
||||
DurationCode duration_code; // description for time investment for when duration == 0
|
||||
std::string title; // max length 64
|
||||
std::string description; // max length 4000, 2048 on Tit
|
||||
std::string reward;
|
||||
std::string item_link; // max length 128 older clients, item link gets own string
|
||||
std::string completion_emote; // emote after completing task, yellow. Maybe should make more generic ... but yellow for now!
|
||||
int reward_id;
|
||||
int cash_reward; // Expressed in copper
|
||||
int experience_reward;
|
||||
int faction_reward; // just a npc_faction_id
|
||||
TaskMethodType reward_method;
|
||||
int activity_count;
|
||||
SequenceType sequence_mode;
|
||||
int last_step;
|
||||
short min_level;
|
||||
short max_level;
|
||||
bool repeatable;
|
||||
ActivityInformation activity_information[MAXACTIVITIESPERTASK];
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
ActivityHidden = 0,
|
||||
ActivityActive = 1,
|
||||
ActivityCompleted = 2
|
||||
} ActivityState;
|
||||
|
||||
typedef enum {
|
||||
ActivityDeliver = 1,
|
||||
ActivityKill = 2,
|
||||
ActivityLoot = 3,
|
||||
ActivitySpeakWith = 4,
|
||||
ActivityExplore = 5,
|
||||
ActivityTradeSkill = 6,
|
||||
ActivityFish = 7,
|
||||
ActivityForage = 8,
|
||||
ActivityCastOn = 9,
|
||||
ActivitySkillOn = 10,
|
||||
ActivityTouch = 11,
|
||||
ActivityCollect = 13,
|
||||
ActivityGiveCash = 100
|
||||
} ActivityType;
|
||||
|
||||
struct ClientActivityInformation {
|
||||
int activity_id;
|
||||
int done_count;
|
||||
ActivityState activity_state;
|
||||
bool updated; // Flag so we know if we need to updated the database
|
||||
};
|
||||
|
||||
struct ClientTaskInformation {
|
||||
int slot; // intrusive, but makes things easier :P
|
||||
int task_id;
|
||||
int current_step;
|
||||
int accepted_time;
|
||||
bool updated;
|
||||
ClientActivityInformation activity[MAXACTIVITIESPERTASK];
|
||||
};
|
||||
|
||||
struct CompletedTaskInformation {
|
||||
int task_id;
|
||||
int completed_time;
|
||||
bool activity_done[MAXACTIVITIESPERTASK];
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1093,7 +1093,7 @@ bool Client::TradeskillExecute(DBTradeskillRecipe_Struct *spec) {
|
||||
}
|
||||
|
||||
if (RuleB(TaskSystem, EnableTaskSystem)) {
|
||||
UpdateTasksForItem(ActivityTradeSkill, itr->first, itr->second);
|
||||
UpdateTasksForItem(TaskActivityType::TradeSkill, itr->first, itr->second);
|
||||
}
|
||||
|
||||
++itr;
|
||||
|
||||
+31
-13
@@ -54,6 +54,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
#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;
|
||||
@@ -3004,38 +3006,50 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p)
|
||||
break;
|
||||
}
|
||||
case ServerOP_ExpeditionCreate:
|
||||
case ServerOP_ExpeditionDeleted:
|
||||
case ServerOP_ExpeditionLeaderChanged:
|
||||
case ServerOP_ExpeditionLockout:
|
||||
case ServerOP_ExpeditionLockoutDuration:
|
||||
case ServerOP_ExpeditionLockState:
|
||||
case ServerOP_ExpeditionMemberChange:
|
||||
case ServerOP_ExpeditionMemberSwap:
|
||||
case ServerOP_ExpeditionMemberStatus:
|
||||
case ServerOP_ExpeditionMembersRemoved:
|
||||
case ServerOP_ExpeditionReplayOnJoin:
|
||||
case ServerOP_ExpeditionGetMemberStatuses:
|
||||
case ServerOP_ExpeditionDzAddPlayer:
|
||||
case ServerOP_ExpeditionDzMakeLeader:
|
||||
case ServerOP_ExpeditionCharacterLockout:
|
||||
case ServerOP_ExpeditionExpireWarning:
|
||||
{
|
||||
Expedition::HandleWorldMessage(pack);
|
||||
break;
|
||||
}
|
||||
case ServerOP_DzAddRemoveCharacter:
|
||||
case ServerOP_DzRemoveAllCharacters:
|
||||
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: {
|
||||
std::cout << " Unknown ZSopcode:" << (int)pack->opcode;
|
||||
std::cout << " size:" << pack->size << std::endl;
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -3200,13 +3214,16 @@ void WorldServer::HandleReloadTasks(ServerPacket *pack)
|
||||
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)
|
||||
if (zone) {
|
||||
task_manager->LoadProximities(zone->GetZoneID());
|
||||
}
|
||||
entity_list.ReloadAllClientsTaskState();
|
||||
}
|
||||
else {
|
||||
@@ -3428,3 +3445,4 @@ void WorldServer::SetScheduler(ZoneEventScheduler *scheduler)
|
||||
{
|
||||
WorldServer::m_zone_scheduler = scheduler;
|
||||
}
|
||||
|
||||
|
||||
+12
-10
@@ -1184,6 +1184,9 @@ bool Zone::Init(bool iStaticZone) {
|
||||
petition_list.ClearPetitions();
|
||||
petition_list.ReadDatabase();
|
||||
|
||||
LogInfo("Loading dynamic zones");
|
||||
DynamicZone::CacheAllFromDatabase();
|
||||
|
||||
LogInfo("Loading active Expeditions");
|
||||
Expedition::CacheAllFromDatabase();
|
||||
|
||||
@@ -1491,16 +1494,14 @@ bool Zone::Process() {
|
||||
{
|
||||
if(Instance_Timer->Check())
|
||||
{
|
||||
// if this is a dynamic zone instance notify system associated with it
|
||||
auto expedition = Expedition::FindCachedExpeditionByZoneInstance(GetZoneID(), GetInstanceID());
|
||||
if (expedition)
|
||||
auto dz = GetDynamicZone();
|
||||
if (dz)
|
||||
{
|
||||
expedition->RemoveAllMembers(false); // entity list will teleport clients out immediately
|
||||
dz->RemoveAllMembers(); // entity list will teleport clients out immediately
|
||||
}
|
||||
|
||||
// instance shutting down, move corpses to graveyard or non-instanced zone at same coords
|
||||
entity_list.MovePlayerCorpsesToGraveyard(true);
|
||||
|
||||
entity_list.GateAllClientsToSafeReturn();
|
||||
database.DeleteInstance(GetInstanceID());
|
||||
Instance_Shutdown_Timer = new Timer(20000); //20 seconds
|
||||
@@ -2726,13 +2727,14 @@ DynamicZone* Zone::GetDynamicZone()
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto expedition = Expedition::FindCachedExpeditionByZoneInstance(GetZoneID(), GetInstanceID());
|
||||
if (expedition)
|
||||
// todo: cache dynamic zone id on zone later for faster lookup
|
||||
for (const auto& dz_iter : zone->dynamic_zone_cache)
|
||||
{
|
||||
return &expedition->GetDynamicZone();
|
||||
if (dz_iter.second->IsSameDz(GetZoneID(), GetInstanceID()))
|
||||
{
|
||||
return dz_iter.second.get();
|
||||
}
|
||||
}
|
||||
|
||||
// todo: tasks, missions, and quests with an associated dz for this instance id
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -222,6 +222,7 @@ public:
|
||||
std::vector<GridRepository::Grid> zone_grids;
|
||||
std::vector<GridEntriesRepository::GridEntry> zone_grid_entries;
|
||||
|
||||
std::unordered_map<uint32, std::unique_ptr<DynamicZone>> dynamic_zone_cache;
|
||||
std::unordered_map<uint32, std::unique_ptr<Expedition>> expedition_cache;
|
||||
|
||||
time_t weather_timer;
|
||||
|
||||
Reference in New Issue
Block a user