Commit Graph

42 Commits

Author SHA1 Message Date
hg 70ab08fc54 Cleanup some expedition logging and formatting
Remove logging unsanitized input

Make unsigned comparison not compare < 0

Cleanup some FormatName and string usage. Some of these strings could
probably be moved instead

Remove unnecessary expedition lookup in a world message handler
2020-10-07 21:55:28 -04:00
hg 0d8df60358 Add character id based expedition apis
Add static expedition methods to add or remove character lockouts

Add CreateLockout static helper to ExpeditionLockoutTimer

Refactor existing character lockout removal to allow removal of lockouts
for offline characters (was only used by #dz lockouts remove command)

Fix #dz list member count
2020-10-07 21:55:27 -04:00
hg 09d7731ccf Remove dz check in expedition invite reply
Characters can no longer be re-invited while inside a dz, these checks
aren't necessary
2020-10-07 21:55:27 -04:00
hg 940c8fcb36 Cleanup expedition headers and unused variables
Modify some expedition and dz logging

Remove unnecessary includes in expedition sources
2020-10-07 21:55:27 -04:00
hg 57eaa74280 Refactor client cross zone message helpers
Remove extra cross zone message server opcode and struct. Existing
function already exists for normal messages

Group CZClientMessageString struct with other CZ structs
2020-10-07 21:55:27 -04:00
hg dc874851d9 Change lockout packet variable to signed 2020-10-07 21:55:26 -04:00
hg 834418ec03 Add api to update lockout duration
Some live expeditions update a lockout's duration during progression

The current AddLockout method replaces lockout timers. This updates the
expiration of an existing lockout by modifying the original duration

Only members are updated and not the internal expedition timer by
default. This is so new members receive the original duration like live
2020-10-07 21:55:26 -04:00
hg f40e0786e4 Add expedition event loot api
Add SetLootEventByNPCTypeID and SetLootEventBySpawnID quest apis

These associate events with npcs or entities inside the dz to prevent
them from being looted by characters that didn't receive the event
lockout from the current expedition.

This fixes an exploit that allowed a player that already had a lockout
from another expedition being added to loot after the event is complete
2020-10-07 21:55:26 -04:00
hg 32c69d235d Remove member history from expeditions
Expedition uuids are now used to check if characters may re-join
2020-10-07 21:55:25 -04:00
hg deedc392bf Use replay timer uuid to allow re-invite
Instead of allowing all previous members to bypass a replay timer
conflict, only allow if expedition uuid of the lockout matches

This fixes an exploit for expeditions that add delayed replay timers.
Members could be part of an expedition on creation and then quit to form
another expedition. They could then always be re-invited to the original
expedition even with a conflicting replay timer lockout.
2020-10-07 21:55:25 -04:00
hg c7e8182cd2 Store lockouts with source expedition uuid
Add Client::GetLockoutExpeditionUUID quest api

Refactor lockout update methods to take ExpeditionLockoutTimer parameter

Fix updating expedition lockout cache for multiple AddLockout calls

Fix updating lockout duration when replacing a lockout in database

Replace lockout timer inherited flags with expedition uuid comparisons

Remove is_inherited column from expedition_lockouts table
2020-10-07 21:55:25 -04:00
hg 8c12909deb Assign expeditions a uuid 2020-10-07 21:55:25 -04:00
hg a8af2a0216 Remove replay timer argument to CreateExpedition
Breaking change to the current API

has_replay_timer column removed from expedition_details table

This argument is unnecessary and just creates confusion. Expedition
replay timers use a hardcoded name precisely for this purpose and
those lockouts are already being checked on creation requests.
2020-10-07 21:55:25 -04:00
hg 10b544c814 Fix replay timer assignment to new members
Ignore expired state of replay timers when assigning to new members

This fixes a regression from a previous change that stopped assigning
expired lockouts to new members. Only expired event timers should be
ignored for new members. Replay Timers should always be added with a
a fresh lockout
2020-10-07 21:55:24 -04:00
hg 7f669e104b Don't allow expedition re-invite inside dz
Live requires characters that quit an expedition to zone out before
being re-added. This is probably to avoid exploiting max player
requirements by constantly swapping players in and out
2020-10-07 21:55:24 -04:00
hg 0d662759a6 Don't remove expedition lockouts from non-members
Clients still inside a dz after being removed from an expedition
should only ever have lockouts added
2020-10-07 21:55:24 -04:00
hg 7e532869a0 Clear stale pending expedition lockouts
Delete pending lockouts of members on expedition creation

Delete pending lockouts when all members removed from expedition

This fixes an edge case where members could incorrectly be assigned
pending lockouts that were never cleared from the database (from a
server crash or other situation) after entering another dz.
2020-10-07 21:55:23 -04:00
hg 3f3cb9114b Copy instead of moving expedition request data 2020-10-07 21:55:23 -04:00
hg 4c9b3ea1df Refactor expedition member online status requests
This optimizes character status requests by only sending a single
bulk request to world for characters in all expeditions instead of
sending a separate request for each expedition on zone startup
2020-10-07 21:55:23 -04:00
hg 158d934df7 Refactor zone expedition caching
This optimizes caching all expeditions by loading dynamic zone data and
expedition members in bulk instead of for each expedition separately.
This reduces the number of queries from 1+2n to 3 total.

Expedition members are now joined in the initial query since empty
expeditions aren't cached anyway. Optional internal lockouts for all
cached expeditions are loaded in a single bulk query afterwards.

Dynamic Zone data is also loaded as a single bulk query afterwards to
simplify processing and keep dz database logic separated. It might be
worth investigating if joining dz data in the initial expeditions load
query is worth refactoring for.
2020-10-07 21:55:23 -04:00
hg 8ae063f953 Ignore expired lockouts on expedition invite
This fixes an edge case with client invites sometimes failing because
an expired lockout hasn't been removed from client yet

Clients no longer receive expired lockouts from expeditions when joining
2020-10-07 21:55:22 -04:00
hg d5f476926d Add #dz lockouts remove by event name 2020-10-07 21:55:22 -04:00
hg ca2c1171a1 Let world shutdown dz early for empty expeditions
Since world now tracks empty expeditions it can determine when to
shutdown dynamic zone instances when the rule is enabled rather than
letting zones do it.
2020-10-07 21:55:22 -04:00
hg 4699a303c0 Only delete empty expeditions when the dz is empty
Zones are no longer able to delete expeditions. World now tracks empty
expeditions in cache and only deletes them when it detects an
expedition's dynamic zone instance has no more clients inside.

This fixes an exploit where lockouts couldn't be applied to expeditions
after all members were removed because zones were deleting the expedition
immediately. Clients still inside the dz were able to complete events
before being kicked from the instance while not having an expedition.

Expeditions are no longer purged from database in the world purge
instance timer to avoid a possible race with this new system
2020-10-07 21:55:21 -04:00
hg 2a0ae8160e Implement world cache to monitor expeditions
This implements a small cache in world to track expedition states.

This fixes expired expeditions being left in zone caches unless the
expedition's dz instance was running to detect it (or unless an
expedition was deleted via a client using /kickplayers). This was also
leaving clients in a ghost expedition that no longer actually existed
2020-10-07 21:55:21 -04:00
hg c5f473e589 Implement expedition locking
Disables the ability to add new members

Adds Expedition::SetLocked(bool) to quest api

Adds is_locked column to expedition_details db table
2020-10-07 21:55:21 -04:00
hg 11eacf25f0 Make adding replay timers to new members optional
Not all expeditions with a replay timer lockout add it to newly
added members automatically

This adds the Expedition::SetReplayLockoutOnMemberJoin(bool) method
to the quest api so it can be disabled
2020-10-07 21:55:21 -04:00
hg 9692aad123 Fix missing invite failure messages 2020-10-07 21:55:20 -04:00
hg 2f1c3b8037 Use stl algorithms for expedition member searches 2020-10-07 21:55:20 -04:00
hg f716c06ca3 Use built-in benchmarking for expedition caching 2020-10-07 21:55:20 -04:00
hg e79d03261a Send expedition re-invite to clients that zone
Moves expedition message handling in world to Expedition method
for messages that need special handling
2020-10-07 21:55:19 -04:00
hg 20bfdac7e0 Check for empty expedition via database not cache
Checking the cache on member removal here isn't reliable due to race
with cross zone message

If a zone removes a member at the same time as another zone, neither zone
can know if the expedition will be empty via cache unless it processes the
world message from the other zone's member removal first.
2020-10-07 21:55:19 -04:00
hg a9a3e46aa2 Send client lockout update in lockout methods
Add optional client update argument to client lockout methods

This is better than requiring callers to manually send the update
2020-10-07 21:55:18 -04:00
hg 26176f44fe Validate expedition invite response server side
Stores expedition invite data on client
2020-10-07 21:55:18 -04:00
hg d9ee19f0ea Move LoadAllClientLockouts back to a client method 2020-10-07 21:55:17 -04:00
hg 0de11ab56b Clear client expedition info if removed inside dz
Clears client expedition info immediately if removed inside dynamic zone

Live clears expedition info from clients removed inside a dz on the same
timer used for removals, even if the client zones before it triggers.
This is problematic to mimic and not worth the effort
2020-10-07 21:55:17 -04:00
hg 7e25e7b3a3 Add #dz lockouts remove command
This allows clearing a character's lockouts

Adds client RemoveAllExpeditionLockouts methods and exposes to lua api
2020-10-07 21:55:17 -04:00
hg a47546fc14 Cache new expedition before sending client updates
Compass updates get data from the expedition cache so it needs to be
cached first.

Currently this doesn't affect anything because compass isn't sent to
CreateExpedition and has to be set post-creation. In the future this
will make the order of client messages more live accurate though
2020-10-07 21:55:16 -04:00
hg 098176a7ed Let dz handle client removal timers
Remove all clients inside a dz, not just those assigned to instance
2020-10-07 21:55:16 -04:00
hg 3ca57dc0eb Assign lockouts to all clients inside dz
This is live like and prevents possible exploiting by dropping
expedition before a lockout. Clients will continue receiving lockouts
until they leave the zone or are kicked via timer
2020-10-07 21:55:16 -04:00
hg b8b4c5a280 Add DynamicZone class for expedition instancing
Add DynamicZone sql table schema

Add DynamicZones logging category

Modify CreateExpedition to take DynamicZone and ExpeditionRequest objects

Implement DynamicZone compass, safereturn, and zone-in coordinates.

Implement live-like DynamicZone instance kick timer for removed members

Implement updating multiple client compasses (supports existing quest compass)

fix: Send client compass update after entering zones to clear existing compass

Implement Client::MovePCDynamicZone to invoke DynamicZoneSwitchListWnd
when entering a zone where client has multiple dynamic zones assigned

Implement OP_DzChooseZoneReply handling

Add Lua api methods for expedition's associated dynamic zone

Add #dz list gm command to list current DynamicZone instances from database
2020-10-07 21:55:16 -04:00
hg 0a4151b7c5 Implement initial expedition system
Add Expeditions logging category

Add handlers for all Dynamic Zone/Expedition related opcodes

Add FormatName string_util function to format character names

Add Zone::IsZone helper method

Add cross zone MessageString support with variable parameters

Add static Client method helpers for cross zone messaging

Add #dz gm command to debug expedition cache for current zone
2020-10-07 21:55:15 -04:00