summaryrefslogtreecommitdiff
path: root/src/map/npc.cpp
AgeCommit message (Collapse)AuthorFilesLines
2024-04-29npc: formattingv23.10.22Freeyorp1-1/+2
Nice consistency there, past!Freeyorp.
2024-04-29npc_scripcont: consistent return valueFreeyorp1-2/+2
`npc_scriptcont` now consistently returns 1 on failure, though in practice, this return value was always ignored.
2024-04-29npc_destroy: Defer NPC destruction via timerFreeyorp1-5/+14
055-1 _nodes.txt will call `destroy;` from within OnInit, that is during an iteration of the global `ev_db`. Previously, concurrent modification invalidated this iteration, resulting in a crash. This still nullifes `oid`, dequeues all timers, and effectively calls `builtin_end`. `npc_data::deletion_pending` is extended to include a third state. In addition to no deletion happening, and indicating when `npc_free` is currently on the stack, it now also tracks whether the NPC is about to be deleted by a timer. This means that an NPC which is about to be deleted is still blocked from triggering new events, much like an NPC actively being deleted would. Starting or continuing an NPC dialog with an NPC that does not, or is about to no longer exist, is now also blocked.
2024-04-21DB/npc_free_internal: Use ancient approachFreeyorp1-3/+12
C++11 was a really long time ago, huh?
2024-04-21DB: Maybe fix concurrent modificationFreeyorp1-7/+3
2024-04-20npc: Deregister events with `ev_db` on freeFreeyorp1-0/+12
In serverdata@c3b7fe59a, `magic-knuckles` made use of temporary copies of the spell NPC via `puppet`/`destroy` to provide additional functionality. This implementation was correct with respect to tmwa behaviour as documented. However, `puppet` and `destroy` doesn't quite return the server to a clean prior state. In `builtin_puppet`, events with the fresh new copy of NPC are registered into the global `ev_db` map to track named events, such as `OnDischarge`, which might be triggered later. However, these registrations are not reversed with `destroy`, leaving `ev_db` to retain references to now invalid and destroyed NPCs. serverdata@c3b7fe59a revealed this oversight through an intersection of rare conditions: - An NPC that is routinely cloned and destroyed - Having a variety of events - Including one that can be triggered during a search for the event over ALL NPCs when `#discharge` is cast. To reproduce, compile with `-fsanitize=address -fsanitize=undefined` to more reliably catch use of invalid memory, cast `magic-knuckles`, log out the character which cast `magic-knuckles` to destroy the NPC, log back in, then cast `#discharge`. The server will then crash. Special thanks to SystemError for testing out this theory. Currently lacking a test environment of my own, this would not have been possible without his patience and diligence.
2023-04-03Item modeHoraK-FDF1-1/+6
2018-03-23fix a bug introduced by wushin, which freeyorp highlighted with his previous ↵Tezer1-17/+2
patch
2018-03-23automatically de-attach freed NPCsgumi1-3/+12
2018-03-04ignore phony npc event calls (~)gumi1-0/+3
2018-03-03don't blindly trust event npc namegumi1-1/+8
2018-01-03release v18.1.3gumi1-1/+1
2018-01-03mark NPCs as disabled while cleaninggumi1-0/+1
2018-01-03remove mob timers, make areatimer only work on PCgumi1-15/+0
2018-01-03remove npc event queue, always clear npc event timergumi1-3/+5
2018-01-01release v18.1.1gumi1-2/+6
2017-11-12re-fix the puppet despawn buggumi1-0/+8
2016-05-12add undefined_gat check to npc_propagate_update()mekolat1-0/+3
2016-04-23dispose orphan puppet if the parent is gonemekolat1-1/+33
2016-04-15do not send BEING_REMOVE when the npc is already removedmekolat1-16/+15
2016-04-15improvements, cleanup, bug fixesmekolat1-21/+26
2016-04-15remove MESSAGE npc subtypemekolat1-21/+1
2016-04-15do not bind trigger detection to map cellsmekolat1-2/+2
2016-04-15fix compilation errorsmekolat1-2/+2
2016-04-15do non-timer events synchronouslymekolat1-1/+1
2016-04-15merge npc_event_do_l into npc_eventmekolat1-84/+56
2016-04-15remove ugly workaroundmekolat1-19/+22
2016-04-15implement puppet npcsmekolat1-13/+24
2016-04-15shrink magic_messagemekolat1-20/+8
2016-04-15Remove old Magicwushin1-15/+43
2016-04-15Magic -> Map Npcswushin1-0/+69
2016-04-15new/modified builtinswushin1-0/+88
areatimer foreach aggravate Override attack animation injure summon
2015-05-02npc -1 => 32767mekolat1-1/+1
2015-04-05remove deprecated cmdothernpcmekolat1-21/+0
2015-01-23Use generated config for mapBen Longbons1-21/+5
2015-01-03Document every network packet's pre, post, and descBen Longbons1-21/+0
With pretty pictures (not a submodule because large images). Part of this commit was originally made by Rawng.
2014-11-09Add explicit check for mapless eventsBen Longbons1-4/+3
2014-10-26Fix header rankingBen Longbons1-3/+1
2014-10-13Convert container lookups to use Option<Borrowed<T>>Ben Longbons1-30/+32
2014-10-08Split npc parse functions in to their own fileBen Longbons1-843/+13
2014-10-08Split script.cppBen Longbons1-1/+2
2014-09-30Rename enum Option to Opt0Ben Longbons1-3/+3
2014-06-30It's about time I did thisBen Longbons1-7/+7
2014-06-26Stick everything in a namespaceBen Longbons1-0/+4
2014-06-26Low hanging fruitBen Longbons1-21/+21
2014-06-26specialize inventory/storage indicesBen Longbons1-4/+4
2014-06-24No one is .neutral() here (except IPv4 addresses)Ben Longbons1-1/+1
2014-06-23SwatBen Longbons1-1/+4
2014-06-23Generate the map server protocolBen Longbons1-29/+31
Sigh, map server will have no smart filters yet
2014-05-12Split net/ from mmo/Ben Longbons1-1/+2