193 lines
12 KiB
Markdown
193 lines
12 KiB
Markdown
# Native class trainers and learned-spell state
|
|
|
|
Verified against actual Forever70334 and local Tortoise1.18.1, external gateway
|
|
stopped. Originals, server rules and account permissions are unchanged.
|
|
|
|
## Protocol boundary
|
|
|
|
Tortoise `src/game/Handlers/NPCHandler.cpp::SendTrainerSpellHelper` serializes
|
|
38 bytes per offer: the real teaching/service spell, state, cost, profession
|
|
availability/confirmation, level, skill/rank and three prerequisite spells.
|
|
`HandleTrainerBuySpellOpcode` independently validates interaction, requirements
|
|
and money, then casts the teaching spell. Teaching IDs and learned IDs differ;
|
|
for the tested source row, service1423 teaches772 (Rend). Neither is remapped to
|
|
an unrelated Forever ability.
|
|
|
|
The pinned Forever reference `Server/Packets/NPCPackets.cpp::TrainerList::Write`
|
|
uses 33 bytes per service and an11bit greeting length. Its build-specific opcode
|
|
is47018A, derived from original `ClassicOpcodes::TranslateServerOpcode`, not a
|
|
uniform group/index shift. The native adapter keeps genuine offers in its
|
|
trainer context; original CMSG3F0046 must echo that actor and offered service.
|
|
For class trainers, TrainerID1 is a destination context token: Turtle supplies
|
|
no corresponding field. Source request1B2 contains the genuine NPC and service.
|
|
For Source tradeskill lists (type 2), the reference creature-to-trainer mapping
|
|
supplies the native TrainerID. The gateway presents the learned recipe spell
|
|
with a native SkillLineAbility and category in the venue's profession. Source
|
|
and native spell effects must agree on the teaching wrapper's target. Native
|
|
buys resolve to the unique service in the current Source offer. A failed
|
|
purchase identifies the displayed spell, and a successful service refreshes
|
|
the same Source trainer. Prices, ranks and requirements come from Source.
|
|
The generator and input hashes are in `ops/tradeskill_trainer_offers.py` and
|
|
`include/gateway/tradeskill_trainer_offers.hpp`.
|
|
|
|
For a Source profession list, the native presentation depends on the current
|
|
player's Source skill lines. The generic trainer (native type 0) shows the
|
|
offers when the player has yet to learn that skill or a current skill
|
|
snapshot is unavailable. The rank panel (native type 2) requires the
|
|
matching skill ID and a positive base rank on the selected character. A
|
|
known service in the trainer list alone cannot establish that state. The
|
|
native backend uses the full SELF create and applies sparse field updates
|
|
to the same character. Replacing or removing SELF, changing characters,
|
|
transferring or logging out invalidates earlier ownership. Standalone codec
|
|
mode 30 receives a GUID and a Source trainer list. Its established request
|
|
contains no player skill state, so its output uses the generic presentation.
|
|
|
|
In both presentations, the first native service is the selected
|
|
profession's teaching spell. The gateway chooses the lowest genuinely
|
|
available tier, or the highest tier the trainer offers that Source says the
|
|
player knows. If neither exists it can present a restricted step whose
|
|
profession slot, level, skill or ability requirement the stock window can
|
|
evaluate. Source reports a blocked first-profession slot using green with
|
|
unequal profession flags. The gateway always refuses a purchase with those
|
|
flags. Remaining rows are the genuine recipes in their original Source
|
|
order, including recipes the player cannot yet buy. Each keeps its own price,
|
|
requirements and Source eligibility. A list with an unresolved or ambiguous
|
|
rank invalidates the prior purchase context and records `GWTrainerStepHeld`
|
|
with the creature entry.
|
|
|
|
Both presentations retain the venue's native trainer ID and the underlying
|
|
Source profession offer, including the exact service, purchase checks and
|
|
success/failure refresh. The per-NPC venue and the observed profession
|
|
catalog serve different roles.
|
|
The Forever server's imported venue for Alchemist Mallory (1215) is 1001215.
|
|
Build 70124's recorded Alchemy trainer 353 records type 2 and offers teaching spell 2275 for
|
|
Apprentice Alchemy and learned spell 2331 for Minor Mana Potion. That catalog
|
|
contains no player skill snapshot or presentation example for a specific
|
|
player. In native
|
|
70334 data, 2275 teaches 2259 (effect 36) and advances skill 171 by one tier
|
|
(effect 44). Spell 2259 establishes the same tier and skill (effect 118).
|
|
Source also defines 2275 as the teacher of 2259. The generator applies the
|
|
same checks to higher tiers and requires each venue to offer that specific
|
|
learned rank. The evidence hashes and observed trainer IDs are in
|
|
`include/gateway/tradeskill_trainer_steps.hpp`.
|
|
|
|
Mallory teaches a single rank and 15 recipes. The host emits service
|
|
2275 first for a new player. On gaining the profession, the next Source list can carry that
|
|
same service as known alongside independently purchasable recipes. A buy
|
|
for native 2331 requests Source service 2339. Smith trainer 1383 teaches
|
|
both 2020 (Apprentice Blacksmith, learned 2018) and 2021 (Journeyman,
|
|
learned 3100). The second offer requires skill 164 at 50 and level 10.
|
|
Recorded trainer 376 offers both wrappers. When Journeyman becomes
|
|
available it replaces Apprentice at the head of the list. With both ranks
|
|
known, Journeyman stays first and cannot be bought.
|
|
|
|
Tortoise identifies available, unavailable and known services with states
|
|
0, 1 and 2 respectively. The Forever reference `Trainer::SpellState` values
|
|
for those states are 1, 2 and 0. Both reference adapters convert between the
|
|
two. The pinned original 33-byte writer emits zero in its reserved field and
|
|
documents that the client derives used status from known spells. The gateway
|
|
retains Source state for purchase validation. Known and unavailable services
|
|
cannot issue Source buy requests. On the stock tradeskill path, the 70334 UI opens
|
|
`CONFIRM_PROFESSION` when `IsTradeskillTrainer()` and the selected service's
|
|
`showDialog` flag are both true. The generic path can call
|
|
`BuyTrainerService` directly when the player clicks Train. A separate
|
|
confirmation dialog on this path remains unverified. Neither presentation
|
|
initiates a purchase automatically. The buy requires the current trainer GUID, context,
|
|
displayed service and eligible Source offer. The server checks prerequisites
|
|
and money again.
|
|
|
|
The trainer observations are from build 70124. The 70334 spell records,
|
|
UI source and host writer comparisons establish the offline representation.
|
|
Actual stock rank recognition, used-state rendering, confirmation, acquisition
|
|
and recipe purchase remain live acceptance items.
|
|
|
|
Repeated lists do not reopen the interaction.
|
|
|
|
Source event12B contains a uint32 learned spell;203 has a uint16 removed spell;
|
|
12C has two uint16 rank-replacement IDs. Allocation capacity in source comments
|
|
must not be confused with actual payload size. Native690040/690041/69003F
|
|
use the pinned `SpellPackets.cpp::{LearnedSpells,UnlearnedSpells,SupercededSpells}::Write`
|
|
layouts. Known-spell cache changes follow these genuine events only. Original
|
|
writer parity, malformed payloads, context/offer checks and refresh handling
|
|
are covered by the native C++ and source serializer tests. No new Lua-C callback
|
|
registration or experimental executable-call route is enabled.
|
|
|
|
## Real client result and controlled visibility comparison
|
|
|
|
Actual668451 displayed Llane Beshere's five genuine services. The original Train
|
|
button bought Rend for100c; source12B/4bytes became690040/18bytes, the normal UI
|
|
printed its learned-ability message, and both IsPlayerSpell772 and IsSpellKnown772
|
|
became true. Saved character_spell contains772 active1/disabled0; money became9701
|
|
and inventory was unchanged. Screenshots/public metadata are in
|
|
`evidence/gameplay/native-class-trainer/`. Four other teaching services display
|
|
Unknown. Their client-data definitions are unresolved; this is bounded training,
|
|
not complete class/profession or spell-effect compatibility.
|
|
|
|
The preceding invisible attempt really charged100c but taught nothing. The
|
|
source's positive teaching cast uses NPC as caster when spellVisual1!=222.
|
|
`Spells/Spell.cpp::CheckTarget` rejects a different player with VISIBILITY_OFF,
|
|
including positive effects; GM mode itself only blocks negative effects there.
|
|
`SpellEffects.cpp::EffectLearnSpell` requires the resulting player target.
|
|
Thus server1B3 success is insufficient evidence of learning.
|
|
|
|
A controlled comparison kept GM mode ON and changed flags55->39 using the real
|
|
local `.gm visible on` command. Rend then genuinely learned. Finally `.gm visible
|
|
off`, `.whispers on` and `.save` restored EXACT flags55: invisibility-off restore
|
|
otherwise clears the accept-whispers flag in `Player::SetGMVisible(false)`.
|
|
Both real charges remain,9901->9801->9701; no SQL grant/refund manufactured success.
|
|
The trainer teleport was reversed and normal save confirmed the exact original
|
|
position/orientation. HP5859 and original gear/bags are preserved.
|
|
|
|
The32-row metadata ring overwrote56 surrounding rows during the successful
|
|
capture. All critical request/learn/success records are present, with independent
|
|
saved-state and actual UI evidence. This is an observation limitation, not a
|
|
claim of network packet loss. Scripts never retry a purchase to repair telemetry.
|
|
|
|
## Action-bar persistence dependency
|
|
|
|
Actual learning generated original SetActionButton440062/10bytes. The native
|
|
outgoing whitelist previously omitted it, so an auto-created icon alone did not
|
|
prove persistence. The reference `SpellPackets.cpp::SetActionButton::Read` reads
|
|
uint64action plus uint16index; source Tortoise
|
|
`Handlers/MiscHandler.cpp::HandleSetActionButtonOpcode` expects index8 and packed
|
|
action24/type8. The native boundary preserves genuine spells/items/clear in the
|
|
first120 source slots and rejects unrepresentable IDs, modern-only action types
|
|
and indices. It does not truncate or substitute. Source validation still decides
|
|
whether a spell/item action is legitimate. Actual680929 C_Spell.PickupSpell772 and original PlaceAction2 emitted10bytes.
|
|
The source .save command calls Player::SaveToDB, not MasterPlayer::SaveActions;
|
|
the initial harness therefore timed out checking SQL too early. Normal logout
|
|
via WorldSession::LogoutPlayer saved action1/772/type0 and preserved actions72,
|
|
73 and83. Actual688574 then displayed the restored Rend icon and original
|
|
GetActionInfo2 returned spell772; IsPlayerSpell/IsSpellKnown remained true.
|
|
Gateway remained stopped, HP5859/money9701/inventory unchanged. The relog
|
|
report records server login-policy extra_flags19; controlled visibility was
|
|
restored to55 before logout, while source Player login reconstructs GM/social
|
|
flags through configured GM_LOGIN/VISIBLE/CHAT/WHISPER policies. No account
|
|
permissions were modified to preserve a display flag across login.
|
|
|
|
The corrected ops/native_actionbar_test.py requires --logout-and-check for a
|
|
new assignment, keeps the observer outside shutdown, validates an empty source
|
|
slot and exact cursor spell, then checks the actual saved action after normal
|
|
close. --check-saved reuses a relogged world read-only. No repeated assignment
|
|
was needed for the successful persistence result. Item/clear actions and modern
|
|
boundary rejection have fixtures; actual item-action persistence is unverified.
|
|
|
|
## Reproduce without re-purchasing
|
|
|
|
With the private client closed, build and run focused tests before deployment:
|
|
|
|
```sh
|
|
cmake --build build -j2
|
|
python3 ops/build_forever_create.py
|
|
ctest --test-dir build --output-on-failure -R 'native-gameplay-guid-lifecycle|source-transport-opcode-profile|source-native-serializer-abi'
|
|
```
|
|
|
|
Never rebuild mapped native libraries with WowB running. Existing launch wrappers
|
|
restore authenticated native selection/world state without passwords in command
|
|
lines. Inspect saved772 and actual original APIs after relog rather than buying
|
|
it again. `ops/native_trainer_purchase_test.py` requires an explicitly reviewed,
|
|
unlearned real offer and exact wallet; it makes one original Train-button action,
|
|
observes genuine learning and restores controlled visibility in finally. It
|
|
neither grants spells nor writes SQL. Do not reuse it against an already-learned
|
|
service or infer global support from the single bounded case.
|