summaryrefslogtreecommitdiff
path: root/src/map
AgeCommit message (Collapse)AuthorFilesLines
2025-02-15Fixed monster name check in npc_load_monsterThorbjørn Lindeijer1-1/+1
Small regression in 2ff2618f8c9a970d1822d5e376fdb67249f63c16.
2025-01-24Fix mobinfo command for scriptsFedja Beader1-130/+74
Note: untested, but it now looks prettier and more correct >:) Note2: it's not used anywhere in serverdata. Approved-by: Thorbjørn Lindeijer <bjorn@lindeijer.nl>
2025-01-24Access mob_db array only once (same for dropitem)Fedja Beader4-95/+103
Note: there were some checks before mob.cpp:3743 that I think applied on empty memory? Plus I moved the std::move right at the end of that loop. I'm not too familiar with move mechanics but it seems to work. YMMV. Approved-by: Thorbjørn Lindeijer <bjorn@lindeijer.nl>
2025-01-21Remove redundant nullptr checks on mdFedja Beader1-4/+4
(see nullpo_retz(md) at start of function, plus md is used all over) grep -r 'if.*[ (]md ' src
2024-11-25Rename server-set variables as suggested by ThorbjornHello=)1-2/+2
2024-11-16Expose X and Y of killed mob to OnMobKillEvent script event (for slime ↵Hello=)1-1/+3
split, etc) Rationale: OnMobKillEvent invoked under PLAYER's RID - so using e.g. POS_X and POS_Y returns PLAYER's coordinates when kill occured. The only extra data available been @mobID - giving killed mob's type (class). However, to "split" slimes I need to spawn few new mobs right on location where kill occured - or some area around this spot, not player's X/Y. This commit exposes 2 new variables set by server, @mob_X and @mob_Y containing mob's X and Y coordinates when kill happened. This is server-code change needed by relevant scripts. Scripts itself would be landed a bit later to serverdata.
2024-10-16Merge branch 'blaming-the-tools'Thorbjørn Lindeijer1-1/+1
Build system overhaul: attoconf from python 2->3, add CMake Merge request !280
2024-10-15Allow item ID as parameter to builtin getitemlinkThorbjørn Lindeijer1-2/+7
In addition to item name. Alternative to https://git.themanaworld.org/legacy/serverdata/-/merge_requests/808
2024-08-30sc_phys_shield_itemHoraK-FDF4-6/+9
2024-08-30sc_cooldown_sg, sc_slowmove, sc_cantmoveHoraK-FDF4-4/+23
2024-08-30GM restricted item handlingHoraK-FDF3-4/+8
2024-08-30Max Weight OverrideHoraK-FDF2-1/+13
2024-08-30Max Weight Add BonusHoraK-FDF1-0/+4
2024-08-30Max Weight BonusHoraK-FDF1-0/+4
2024-08-30map hashHoraK-FDF3-0/+53
as it was not possible to store a string variable with the current format of the athena.txt I though a hash could help to identify the maps since this one can be stored as a permanent char bound variable in athena.txt
2024-06-07activity add sd checkingHoraK-FDF1-5/+10
2024-06-06KeepAfterUse + DontUseAmmoHoraK-FDF5-24/+59
**** Approved-by: Free Yorp <thefreeyorp+git@gmail.com> Approved-by: Thorbjørn Lindeijer <bjorn@lindeijer.nl> Reviewed-by: Thorbjørn Lindeijer <bjorn@lindeijer.nl>
2024-06-05python3: Add explicit list()s for python3.6Freeyorp1-1/+1
This should be reverted once we drop support for Ubuntu 18.04, and therefore python3.6, as it does clutter up the code a bit. Sourced from specing's work on the porting process. See https://git.themanaworld.org/legacy/tmwa/-/merge_requests/256
2024-05-17Mages Quality Of Life, part 2:Hello=)1-2/+2
This commit lands fix for infamous AFK-kill summons exploit. Its what essentially caused summoner spells in cities to be disabled. This is not free lunch: it comes at expense of little fun where mob would bite bad master hitting it. But its been minor fun or cosmetics while spells restriction in cities and so on is annoying setback for mages. So if choosing between evil and even more evil, guess... Technically, server's bug is: it too eager to reattach some things to wrong RID or something like this. Its what causes aggroed mob to lock on really wrong random targets and AFK-kill them.
2024-05-15bugfix for previous commit. Need to wrap MobMode in bool()asuratva1-1/+1
2024-05-15fix issummon function signature. Thanks @HoraK-FDF for catching the typo.asuratva1-1/+1
2024-05-15updated itenplz fix to use mob flag instead of string comparison. More ↵asuratva1-2/+2
efficient. Credit to @Hello for figuring this out :)
2024-05-15Add function to check for summoned creature in scriptsasuratva1-0/+18
2024-04-29npc: formattingFreeyorp1-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 timerFreeyorp4-12/+36
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-29mob: Avoid dangling elseFreeyorp1-0/+2
2024-04-22script-fun: Convert string literals to LStringFreeyorp1-83/+83
This is some rather impressive type safety, albeit safety that has evidently desensitized people to warnings for rather serious problems.
2024-04-22script_nullpo_end: Change error printf fmt -> argFreeyorp1-4/+4
PR !270 is an ongoing investigation into outstanding compiler warnings. One such warning is `warning: format '%s' expects a matching 'char*' argument` from `script_nullpo_end(nd, STRPRINTF("no such npc: '%s'"_fmt, name));` in `src/map/script-fun.cpp`. No such warning is emitted from a similar line in `src/map/atcommand.cpp`: `AString output = STRPRINTF("Jump to %s"_fmt, npc);`. `script_nullpo_end` is a macro, rather than a function. `error` is passed in verbatim by the preprocessor. The macro definition of `script_nullpo_end` includes lines such as the following: ```cpp PRINTF("script:%s: " #error " @ %s\n"_fmt, BUILTIN_NAME(), nullpo_nd->name); ``` `#<variable>` instructs the preprocessor to transform `<variable>` into a literal string. In this case, the string literal: ```cpp "STRPRINTF(\"no such npc: '%s'\"_fmt, name)" ``` So the entire line partly resolves to something like: ```cpp printf("script:%s: STRPRINTF(\"no such npc: '%s'\"_fmt, name) @ %s\n"_fmt, BUILTIN_NAME(), nullpo_nd->name); ``` Once the compiler sees this, it throws out the warning seen here, because printf is seeing three placeholders in the formatter, but is only given two value arguments. Checking with `gcc -E`, the full expansion is as follows: ```cpp if (nullpo_chk("script-fun.cpp", 4885, __PRETTY_FUNCTION__, nd)) { if (st->oid) { dumb_ptr<npc_data> nullpo_nd = map_id_is_npc(st->oid); if (nullpo_nd && nullpo_nd->name) { ({ struct format_impl { constexpr static FormatString print_format() __asm__("_print_format") { return "script:%s: " "STRPRINTF(\"no such npc: '%s'\"_fmt, npc)" " @ %s\n"_fmt; } }; cxxstdio::PrintFormatter<format_impl>::print(( # 4885 "script-fun.cpp" 3 4 stdout # 4885 "script-fun.cpp" ), (builtin_functions[st->stack->stack_datav[st->start].get_if<ScriptDataFuncRef>()->numi].name), nullpo_nd->name); }); } else if (nullpo_nd) { ({ struct format_impl { constexpr static FormatString print_format() __asm__("_print_format") { return "script:%s: " "STRPRINTF(\"no such npc: '%s'\"_fmt, npc)" " (unnamed npc)\n"_fmt; } }; cxxstdio::PrintFormatter<format_impl>::print(( # 4885 "script-fun.cpp" 3 4 stdout # 4885 "script-fun.cpp" ), (builtin_functions[st->stack->stack_datav[st->start].get_if<ScriptDataFuncRef>()->numi].name)); }); } else { ({ struct format_impl { constexpr static FormatString print_format() __asm__("_print_format") { return "script:%s: " "STRPRINTF(\"no such npc: '%s'\"_fmt, npc)" " (no npc)\n"_fmt; } }; cxxstdio::PrintFormatter<format_impl>::print(( # 4885 "script-fun.cpp" 3 4 stdout # 4885 "script-fun.cpp" ), (builtin_functions[st->stack->stack_datav[st->start].get_if<ScriptDataFuncRef>()->numi].name)); }); } } else { ({ struct format_impl { constexpr static FormatString print_format() __asm__("_print_format") { return "script:%s: " "STRPRINTF(\"no such npc: '%s'\"_fmt, npc)" " (no npc)\n"_fmt; } }; cxxstdio::PrintFormatter<format_impl>::print(( # 4885 "script-fun.cpp" 3 4 stdout # 4885 "script-fun.cpp" ), (builtin_functions[st->stack->stack_datav[st->start].get_if<ScriptDataFuncRef>()->numi].name)); }); } st->state = ScriptEndState::END; return; }; ``` Note the string literal: `"STRPRINTF(\"no such npc: '%s'\"_fmt, npc)"`. `script_nullpo_end` currently can't take as its argument for `error` any expression which, when stringified, contains something which `printf` will interpret as its formatter expecting another argument. This appears to have been broken since it was first introduced in https://git.themanaworld.org/legacy/tmwa/-/commit/594eafd4f231a897cbefd since the first revision implicitly had these requirements, and also introduced usage which didn't meet them. This rewrites each PRINTF line in `script_nullpo_end` from the template ```cpp PRINTF("script:%s: " #error " @ %s\n"_fmt, BUILTIN_NAME(), nullpo_nd->name); ``` to something like ```cpp PRINTF("script:%s: %s @ %s\n"_fmt, BUILTIN_NAME(), error, nullpo_nd->name); ``` This means that instead of an expression being stringified, error is interpreted as an expression that resolves (or decays) to a string. This seems consistent with all current usage of `script_nullpo_end`.
2024-04-22Fix warning: 'T& tmwa::Slice<T>::operator[](size_t) is deprecatedFedja Beader1-4/+4
2024-04-22O(48logN) -> O(1logN) + reformat very long linesFedja Beader1-23/+50
2024-04-22Fix -Wformat warningsFedja Beader1-4/+4
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-20getmapmaxx getmapmaxyHoraK-FDF1-0/+26
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.
2024-04-12Add battle_config.max_rate limit (500). GMs cannot go above thisFedja Beader1-28/+35
Blame Ledmitz (:
2024-04-10Add server-wide drop rates modifierFedja Beader2-3/+28
2024-04-10Split @exprate into @bexprate and @jexprateFedja Beader1-0/+44
Preserve @exprate as a shortcut for both & because scripts in serverdata call it
2024-04-10Report (hardcoded) drop rates on same line as base/job exp, reword messages.Fedja Beader1-6/+6
2024-02-01Fix bug whereby stat updates were not sent to client after equipping +1 stat ↵Fedja Beader1-1/+1
pt item when base stat is 1. What is funnier is that it sent updates for all other 5 (unchanged stats). Example, amethyst ring +1 dex: Sending update for stat 0: saved: 0+1, new: 0+0 (str?) Sending update for stat 1: saved: 0+1, new: 0+0 (agi?) Sending update for stat 2: saved: 0+1, new: 0+0 (vit?) Sending update for stat 3: saved: 0+1, new: 0+0 (int?) Sending update for stat 5: saved: 0+1, new: 0+0 (luk?)
2024-01-31Transfer something from local/ to live repository so there are less conflictsJesusaves1-2/+2
2023-11-27activity checks and status cleanupHoraK-FDF11-126/+312
2023-11-08SC_MATKPOTHoraK-FDF1-5/+7
2023-08-28Revert magic attack delay to original behaviourv23.10.22Led Mitz1-9/+9
2023-08-03weapon base attack delay standardizationHoraK-FDF5-36/+52
2023-06-10Backport MaxlvlHoraK-FDF1-16/+27
2023-04-04SC_COOLDOWN_UPMARMUHoraK-FDF2-0/+3
2023-04-03Merge branch 'item_mode' into 'master'Led Mitz5-1/+26
Item mode See merge request legacy/tmwa!246
2023-04-03Item modeHoraK-FDF5-1/+26