aorecomp

Anarchy Online classic in the browser

git clone https://aorecomp.ubeagle.com/code/aorecomp.git


docs/combat-client-requirements.md (14463B)


14.9.1 client requirement evaluation

The shipped client has a postfix requirement interpreter. Its result controls local item actions, equipment checks and predicted item/nano effects. It is not sufficient as authoritative server validation: strict skill comparisons deliberately pass when the initial subject is not the local player, a null initial subject passes the entire list, and some shipped database operators are unsupported by this executable.

Evidence and coverage

Target: anarchy-vanilla-14.9.1/kkr.dll, SHA-256 a37bc1c15053fdcc5572772309f7074c4f83baffe2faa164df40b059b7c480c0. Addresses here are original VAs based at 0x10000000; generated C in client/game/kkr.dll/ is relocated by +0x26000000.

The principal evidence is evaluator 0x100056e0, retained as local/reports/combat-client-criteria.txt and instruction-for-instruction local/reports/combat-client-criteria.asm. The assembly evidence ID is ev_766b14bab9ca66a483cc487e7daa79d93f1790c34718cedc6ad768caac1acc3d. Related native queries are retained in local/reports/combat-client-pass2-decompiles-1.json through -15.json. The second-pass bundle is local/reports/combat-client-requirements-evidence.json.

The matched database inventory contains 305917 requirement references and 18 distinct operator values. Counts below are references across action and function lists, including separate item/QL records, rather than distinct game rules. Reproducible counts and full example lists are retained in local/reports/combat-client-requirement-inventory.json.

Coverage question Result
All 18 observed opcode values Every value mapped to an exact native branch or explicit rejection
Basic comparisons, boolean stack and getter modes Recovered, including strict boundaries and local-player bypass
Subject switching and missing subject Recovered for observed selectors 2/3
Item placement and falling checks Recovered integer predicates
Packed pet-count comparison Recovered bit extraction and signed threshold encoding
Tower predicates 80/83 Exact delegation and return test recovered; concrete derived land-control service implementation remains outside this bounded pass
Caller flags and effect execution gate Recovered for normal wear/use/effect callers; unusual comparison rewrite flag documented separately
Original server validation Unavailable from the client

Record layout and call contract

Criterion reader 0x10008150 reads three stream int32 values in order: stat/operand, value, operator. There is no operator translation in this reader. A criterion payload is therefore 12 bytes. A native linked-list node has next/previous links at +0/+4, then those three values at +8/+0xc/+0x10. The containing list has a sentinel at list+4 and count at list+8; 0x100056e0 receives a pointer to the list pointer.

The wrapper 0x10005680 uses a criteria object's list at this+4 and forwards an initial Beholder/stat interface, a diagnostic flag, and a comparison-rewrite flag. Its copied two-word identity context is not an extra boolean operand. 0x100056c0 copies those two identity words without transforming requirement records.

The evaluator creates an empty local byte stack. It initializes current subject to the supplied interface and determines a separate initial_is_local_character byte once: initial subject must cast to SimpleChar, must not cast to SimpleItem, and character +0x128 must be nonzero. Switching the current subject does not recompute this byte.

The stat getter is interface vtable +4; presence test is vtable +0x10. Keep getter modes numeric when implementing or comparing these rules: mode 0 is the effective-skill path in the recovered skill code, mode 2 reads stored/base values in focused paths, and mode 3 includes final stat-specific computations. These labels are not proven universal for every stat. combat-client-stats.md gives the recovered stat-specific formulas.

Observed opcode table

Names for 0..4,18,22,24,26 are first-party strings registered by 0x10039cf0 and returned by fOperatorToString, 0x1003dd90. Other descriptions below name the recovered behavior, rather than importing a later emulator's enum.

Opcode References Exact observed behavior
0 Equal 15973 Push false if current subject lacks stat; otherwise push get(stat,3) == value.
1 Less 355 If initial subject was the local character, push signed get(stat,0) < value; otherwise push true.
2 Larger 170679 If initial subject was the local character, push signed get(stat,0) > value; otherwise push true. A requirement value 7 therefore needs at least 8.
3 Or 139 Pop two boolean bytes, push their logical OR; fewer than two fails the entire evaluation.
4 And 117200 Pop two boolean bytes, push their logical AND; fewer than two fails the entire evaluation.
18 OnTarget 270 Replace current subject with selector 3 of the original initial interface. Missing result fails entire evaluation. No boolean is pushed.
22 BitAnd 347 Push (get(stat,2) & value) != 0, testing any common bit rather than requiring all bits of the mask.
24 Unequal 378 Push false if stat is absent; otherwise push get(stat,2) != value.
26 OnUser 14 Replace current subject with selector 2 of original initial interface. Missing result fails entire evaluation. No boolean is pushed.
42 logical NOT 133 Invert top boolean byte in place; empty stack fails entire evaluation.
66 packed pet count 229 Read stat 251 in mode 2. Let a=abs(value), index=(a/1000)&7, limit=a%1000, count=(stat251>>(4*index))&15. Push count < limit when value is nonnegative; push count >= limit when negative. Stat operand is unused.
80 tower placement eligibility 118 Obtain user via selector 2, cast to character, obtain identity at its ATR helper +0xe4/+0xe8, resolve item, call item placement validation 0x10058520; push true iff returned error mask is zero. Missing item pushes false. See delegation below.
83 defense shield check 3 Resolve the same ATR identity for the current cached character; push whether an item resolves. Separately invoke land-control service vtable +0x10 for a result and +8 to format it. That result does not replace the pushed existence boolean.
85 same target stat 5 Cast current subject to character, obtain target identity from its interaction helper 0x10072000 at +0x70, resolve target Beholder; push whether target.get(stat,2) == character.get(stat,2). Missing character/target pushes false. value is unused.
88 item placement class 20 For cached character, use ATR helper +0x150; 0x100635a0(value,stat) tests identity type at helper +0xe4. True if (value&1 && type in {101,102,103}) || (value&2 && type==104) || (value&4 && signed(type)>250). The second parameter is unused. Missing character pushes false.
89 falling 24 Cast current subject to character; push its vehicle's IsFalling() result, or false if no character. Falling also queues the "can't do this while falling" diagnostic. Lists that forbid falling explicitly follow with opcode 42.
92 1 Unsigned operator exceeds 89: fail entire evaluation immediately. Intended server meaning unknown.
93 29 Same immediate rejection as 92. Intended server meaning unknown.

The exact opcode-to-branch index is a compressed byte table at 0x10007ffc, followed by the jump table at 0x10007f10. The bound check is CMP opcode,0x59; JA failure at 0x10005835. In particular, 42 maps to decompiler case 0x23, 66 to 0x2b, and 80 to 0x33: decompiler case numbers are not database operator IDs. Raw table evidence: ev_7c9145dc05f2a6dd3ea769a7df32d9fcd9f2140b7fc1b87a17d84863fe6e2fd6.

The pet-count index extraction is unsigned after the absolute-value arithmetic. Valid observed data uses ordinary positive/negative small values; this does not establish desirable behavior for malformed INT_MIN.

Subject and context resolution

0x10002e60 resolves selectors relative to the original initial interface, not the current switched subject. First-party names distinguish OnTarget (18 -> selector 3) and OnUser (26 -> selector 2):

Initial object Selector 2 Selector 3
SimpleItem Resolve identity at Beholder +0x24/+0x28 using 0x10002750 Null
SimpleChar Same interface-relative user identity lookup NPC: identity at Beholder +0x2c/+0x30 via 0x100027b0; player: identity at interaction helper +0x70/+0x74

For either selector the candidate must also cast to a dynel, share the initial object's playfield, and have dynel byte +0x94 != 1; otherwise resolution returns null. Initial playfield is item +0x104 or character +0x78. The routine accepts selectors 1..22 as input but only concrete 1..4 branches exist for a character and 1..2 for an item. Selector 1 returns the initial interface; selector 4 resolves an item using stats 82/83 in mode 2. These extra selectors are documented to explain the resolver, not included in the observed-opcode coverage count.

The cached character used by some advanced predicates starts as the initial character, and certain character-casting branches overwrite it. It is not a fresh dynamic cast for every predicate; opcode 88 uses the cached character while opcode 89 explicitly casts current subject again. Do not silently substitute the original player in all advanced branches.

Tower predicates delegate to the service returned by 0x10157b10, global 0x1030db44. Its base constructor 0x10157ad0 installs vtable 0x10178d64; derived service behavior must be established before claiming complete tower validation. 0x10058520 builds an item description from stats 701,702,703 (mode 2), replacing zero high template with low template, then calls service vtable +0xc with the character pointer from interaction helper +0x10 and that item description. The returned error mask is what opcode 80 tests. Formatting paths include land-control, organization, tower spacing and shield error messages; strings alone do not recover those rules. Opcode 83's database examples are the Emergency Defense Shield Neutralizer and its test item.

Evaluation order and final result

For the observed operators with the rewrite flag false, the central algorithm is:

if initial subject is null: return true
current = initial
stack = []
initial_is_local_character = classify(initial)

for criterion in stored order:
    if unsigned(criterion.operator) > 89: return false
    if predicate: append its result as specified above
    if AND/OR: require two entries, reduce them to one
    if NOT: require one entry, invert it
    if OnTarget/OnUser: replace current; fail if missing

if stack is empty: return true
result = pop top
if stack is not empty: discard extras and produce diagnostic list
return result

There is no implicit AND across leftover stack entries. Native helper 0x100080c0 tests count==0, 0x10008110 peeks, 0x10008100 pops, 0x100080d0 clears, and 0x100080e0 pushes. At 0x10007c62..0x10007c94 the function preserves the top byte before discarding extras and printing the criteria list. Malformed postfix lists therefore have observable behavior that differs from an all-requirements conjunction.

There is no boolean short circuit: every list node is visited until an explicit fatal condition. False predicates can therefore still be followed by context switches or diagnostics. An empty list, or a list containing only successful context switches, returns true.

Example: Basic Nano Recharger 25820 requires Treatment >7, TimeSpace >7, then AND; it tests a movement mask and combines that result, switches OnTarget, checks target posture and a zero-valued stat, and combines those results explicitly. Symbio-Graft: Detain Suspect 93655 uses 89,42,4 to require not falling in addition to its skill/profession checks.

Caller flags and local prediction limits

Normal wear/unwear/item action callers 0x10090970, 0x10090b70, 0x10090c70, 0x10090d10, 0x10090fe0 and 0x100ace70 pass rewrite flag zero. Their criteria lists come from item action records (for example action 6 wear,7 unwear,3 use). Passing character +0xe4 supplies its stat-interface subobject. Callers skip evaluation when their action or list is absent; other item flags and wear restrictions are checked outside the interpreter.

Predicted spell executor 0x100be8e0 first checks client-effect allowlist 0x100bfb40, then evaluates the effect's criteria with diagnostic and rewrite flags both zero. A false result decrements remaining ticks and returns without applying that tick. Thus an unsupported operator in a client-admitted Modify effect can suppress local prediction. The original server may understand a broader operator set; client rejection does not prove that an intended original-server effect never happens.

The nonzero rewrite flag has an unusual verified implementation. For operators 0,1,2,24 and stat in {367,4,368,60,33}, it loads local registers with stat54/current level and forces dispatch opcode 0 at 0x100057fa..0x10005833. However, the equality branch at 0x100058d3..0x1000590e reloads the original node's stat and value. It therefore changes dispatch to the original equality predicate rather than reliably bypassing those restrictions. The original list is not mutated. Do not label this flag "ignore profession/side requirements" without accounting for that assembly behavior. 0x1008fc40 forwards an external flag here; the normal callers and predicted-effect path above use zero.

The two unsupported database cases are concrete:

These records must remain explicitly unresolved for server behavior. Do not reinterpret 92/93 as a later enum merely because the data contains them. Full original-server correctness additionally needs authoritative subject ownership, inventory state, skill locks, range/LOS and action permissions; the client supplies only the local paths described here.