summaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
13 daysnpc: formattingHEADmasterFreeyorp1-1/+2
Nice consistency there, past!Freeyorp.
13 daysnpc_scripcont: consistent return valueFreeyorp1-2/+2
`npc_scriptcont` now consistently returns 1 on failure, though in practice, this return value was always ignored.
13 daysnpc_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.
13 daysmob: 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 Beader2-9/+13
2024-04-22O(48logN) -> O(1logN) + reformat very long linesFedja Beader1-23/+50
2024-04-22Fix Wformat-zero-length warningsFedja Beader3-5/+0
Squash with: remove empty lines
2024-04-22Fix -Wformat warningsFedja Beader2-5/+5
2024-04-21DB/npc_free_internal: Use ancient approachFreeyorp2-7/+12
C++11 was a really long time ago, huh?
2024-04-21DB: Maybe fix concurrent modificationFreeyorp2-7/+7
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 Beader2-28/+36
Blame Ledmitz (:
2024-04-10Add server-wide drop rates modifierFedja Beader3-3/+29
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-03-18Add CI test stageFedja Beader1-1/+40
+Pass artifacts (well, the whole repo) to test stage +YAML syntax error. Since I saw a glimpse of the repo being reinitialised two tries ago, perhaps it saves everything tracked and just adding untracked files should be enough.
2024-03-18Workaround "Function... not defined in.." (breakpoints not found) (GDB bug)Fedja Beader1-1/+14
Function "_Z13do_breakpointIN4tmwa3map11script_dataEEvRKT_PKc" not defined in "/builds/specing/tmwa/src/debug-debug/map-script-persist.cpp". Breakpoint 1 (/builds/specing/tmwa/src/debug-debug/map-script-persist.cpp:'_Z13do_breakpointIN4tmwa3map11script_dataEEvRKT_PKc') pending. void do_breakpoint<tmwa::map::script_data>(tmwa::map::script_data const&, char const*); Thanks to ssbssa@#gdb for pointing this out.
2024-03-13Several updates to the README.mdThorbjørn Lindeijer1-50/+18
It's no longer maintained by o11c since many years now, so an update was long due. Also updated some outdated links. Finally, who can say for sure that The Mana World will never run on Manaserv?
2024-03-08Add googletest-1.8.1 as a submodule - gtest-1.14 shipped by my distro ↵Fedja Beader3-1/+10
requires C++14.
2024-03-08Correct issue with GTEST_DIR not being passed properly.Fedja Beader1-2/+9
Note how gcc uses /usr/include/gtest (default search path) as the -I for GTEST_DIR is not on the gcc command line: System-wide gtest is 1.14 and requires C++14 while provided one is 1.8.1. GTEST_DIR="$PWD/deps/googletest/googletest" ./configure --user make[1]: Leaving directory '/data/users/tmwa/proj/tmw/classic/tmwa' find: ‘doc-gen/’: No such file or directory g++ -std=c++0x -I . -I ./include -DGENERATING_DEPENDENCIES -O2 -g -fstack-protector -fno-strict-aliasing -fvisibility=hidden -fvisibility=hidden -MG -MM \ -MT 'ast/item_test := ' \ -MF obj/ast/item_test.d src/ast/item_test.cpp In file included from /usr/include/gtest/gtest-message.h:57, from /usr/include/gtest/gtest-assertion-result.h:46, from /usr/include/gtest/gtest.h:64, from src/ast/item_test.cpp:21: /usr/include/gtest/internal/gtest-port.h:270:2: error: #error C++ versions less than C++14 are not supported. 270 | #error C++ versions less than C++14 are not supported. | ^~~~~ Makefile:331: obj/ast/item_test.d: No such file or directory
2024-03-06Restored README.md visibilityThorbjørn Lindeijer1-28/+2
* Removed the <details> tag used to hide the main contents. * Removed deprecation notice, since we're still running this server and will need to maintain it until it has been replaced. * Deleted the section about tmwa-monitor, since the tool is not just deprecated but actually was deleted in 53a91a3fbf0929a99abcdfea23126f978c3ce71a. This partly reverts da50c517000391c83305ff704e3059c900f28d5b.
2024-02-22Update test cases for addition of Item Mode fieldFedja Beader1-8/+10
See "Item Mode" commit from Apr 3 2023
2024-02-20Merge branch 'py2CI' into 'master'Led Mitz1-0/+52
Enable GitLab CI See merge request legacy/tmwa!259
2024-02-20Merge branch 'generate-client-code' into 'master'Led Mitz1-5/+62
tools/protocol.py: Added generation of client code See merge request legacy/tmwa!258
2024-02-20tools/protocol.py: Added generation of client codeThorbjørn Lindeijer1-5/+62
This helps with keeping the protocol in the Mana client up to date. ****
2024-02-13Enable GitLab CIFedja Beader1-0/+52
+Add meway's Ubuntu +Add python -> python2 symlink +Separate python/python2 into INSTALL_PACKAGES
2024-02-13Merge branch 'extra_stat_update_fix' into 'master'Jesusalva Jesusalva1-1/+1
Fix bug whereby stat updates were not sent to client after equipping +1 stat... See merge request legacy/tmwa!257
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-27Merge branch 'activity_checks' into 'master'Led Mitz12-126/+318
activity checks and status cleanup See merge request legacy/tmwa!252
2023-11-27activity checks and status cleanupHoraK-FDF12-126/+318
2023-11-12Merge branch 'submodule_update' into 'master'Led Mitz1-1/+1
Update ProprietaryHub link. git:// was likely waiting indefinetely for user to login. See merge request legacy/tmwa!253
2023-11-12Update ProprietaryHub link. git:// was likely waiting indefinetely for user ↵Fedja Beader1-1/+1
to login.
2023-11-08Merge branch 'matkpot' into 'master'Led Mitz1-5/+7
SC_MATKPOT See merge request legacy/tmwa!251
2023-11-08SC_MATKPOTHoraK-FDF1-5/+7
2023-08-28Merge branch 'magic_delay' into 'master'Led Mitz1-9/+9
Revert magic attack delay to original behaviour See merge request legacy/tmwa!250
2023-08-28Revert magic attack delay to original behaviourv23.10.22Led Mitz1-9/+9
2023-08-03Merge branch 'atk_delays' into 'master'Led Mitz9-44/+81
weapon base attack delay standardization See merge request legacy/tmwa!249
2023-08-03weapon base attack delay standardizationHoraK-FDF9-44/+81
2023-06-10Merge branch 'maxlvl' into 'master'v23.6.10Led Mitz1-16/+27
Backport Maxlvl See merge request legacy/tmwa!248
2023-06-10Backport MaxlvlHoraK-FDF1-16/+27
2023-04-17Merge branch 'sc_cooldown_upmarmu' into 'master'Led Mitz3-0/+4
SC_COOLDOWN_UPMARMU See merge request legacy/tmwa!247
2023-04-04SC_COOLDOWN_UPMARMUHoraK-FDF3-0/+4
2023-04-03Merge branch 'item_mode' into 'master'Led Mitz9-1/+47
Item mode See merge request legacy/tmwa!246
2023-04-03Item modeHoraK-FDF9-1/+47
2023-02-09Merge branch 'bonus' into 'master'Jesusalva Jesusalva5-126/+190
bAllStats, bAgiVit, bAgiDexStr, bDeadlyStrikeRate, bDeadlyStrikeAddRate See merge request legacy/tmwa!245
2023-02-09bAllStats, bAgiVit, bAgiDexStr, bDeadlyStrikeRate, bDeadlyStrikeAddRateHoraK-FDF5-126/+190