Skip to content

lod114d: fill in the gameevent names the 0x5A packet leaves out - #106

Merged
ResurrectedTrader merged 2 commits into
mainfrom
gameevent-resolve-names
Oct 8, 2026
Merged

ResurrectedTrader merged 2 commits into
mainfrom
gameevent-resolve-names

Conversation

@ResurrectedTrader

Copy link
Copy Markdown
Owner

d2bs behaviour

EventMessagesHandler (reference D2NetHandlers.cpp) rewrites the packet's names before it calls GameActionEvent:

Mode When Name rewrite
0x06 "name1 slain by name2" param2 (slayer unit type) is a monster or an object name2 = the localized name from monstats.NameStr / objects.Name for row param1
0x07 player relation always name1 = the roster (PlayerUnitList) name of player param1
0x0a "name1 has items in his box" name1 is empty name1 = "You"

d2bsng before

The 0x5A case in src/backends/lod114d/hooks/Intercepts.cpp passed the raw packet strings to onGameEvent. For a monster kill the packet carries no killer name, so name2 was empty, and the mode 7 / 0x0a names were blank as well.

Fix

A ResolveGameEventNames helper in the 0x5A intercept applies the same rules as the reference:

  • Monster slayer: GetTxtValue("monstats", param1, "NameStr") gives the locale id, which GetLocaleString turns into the name.
  • Object slayer: the reference passes objects.txt's Name column to FillBaseStat as a 2-byte locale id. That column is a 64-char ASCII string, so FillBaseStat refuses the size and the reference resolves an uninitialised locale id. This PR uses the object's name string from the same column instead.
  • Player relation: the roster name is looked up by walking gpPlayerUnitList under a GameReadLock.
  • Item box: an empty name1 becomes "You".

The gameevent parameter docs mention the filled-in names.

kolbot usage restored

  • threads/Party.js:70-72: case 0x06 formats Config.DeathMessages with $killer = name2. A monster kill printed an empty killer name.
  • libs/scripts/Follower.js:840 matches name1 === Config.Leader on every event, so mode 7 events from the leader now match. threads/ToolsThread.js:228 handles mode 7 too.

Testing

Built (Release, Win32) and ran the test suite. The intercept is not part of the test build, so there is no unit test. Not live-tested in game.

Not in this PR

The reference also exits the game on a mode 7 hostile event when QuitOnHostile is set. d2bsng stores and shows that setting, but nothing acts on it. That is left for a separate change.

@ResurrectedTrader

Copy link
Copy Markdown
Owner Author

Don't we already have similar code elsewhere?

@ResurrectedTrader

Copy link
Copy Markdown
Owner Author

If not, feel free to merge

ResurrectedTrader and others added 2 commits October 8, 2026 11:57
d2bs's EventMessagesHandler fills in names before it fires gameevent:
- a monster or object slayer (mode 6) is named from its txt row;
- a player-relation event (mode 7) gets the roster name for param1;
- an item-box event (mode 0x0a) with no name becomes "You".

d2bsng passed the raw packet strings, so a death message had no killer
name. The 0x5A intercept now resolves the names the same way. The one
exception is an object slayer: the reference reads objects.txt "Name"
as a locale id, but that column holds the name itself, so it is used
directly.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
The roster walk duplicated Party::FindById / Party::Name; use them.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@ResurrectedTrader

Copy link
Copy Markdown
Owner Author

Partly, yes. The player-relation case (mode 7) walked the roster list by hand, which is what Party::FindById + Party::Name already do. It now uses those, and the extra GameLock.h include is gone.

The rest has no equivalent:

  • The slayer name is resolved from a txt row only, because the packet carries no unit. Unit::Name needs a live unit (UNITS_GetName / pObjectTxt->szName), so this path still uses the shared GetTxtValue + GetLocaleString primitives (monstats NameStr, objects Name).
  • Nothing else in the tree produces "You".

Rebased onto main; Release build, tests and format check pass. I'm leaving the merge to you.

@ResurrectedTrader
ResurrectedTrader merged commit 39f24b8 into main Oct 8, 2026
1 check passed
@ResurrectedTrader
ResurrectedTrader deleted the gameevent-resolve-names branch October 8, 2026 19:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant