Initialize local project and fix ranch growth synchronization
This commit is contained in:
@@ -0,0 +1,115 @@
|
||||
# Local battle diagnostic builds V3
|
||||
|
||||
Superseded for testing by the damage-only [V4 cache fix](BATTLE_V4.md).
|
||||
V3 preserved the original AIR extraction-cache ID, allowing already extracted
|
||||
program files to survive an in-place installation. APK asset identity alone
|
||||
does not establish what AIR executed.
|
||||
|
||||
Date: 2026-11-07. User reported both previous modifications had no effect.
|
||||
The private-server prototype is outside this work.
|
||||
|
||||
## Confirmed defects in the previous builds
|
||||
|
||||
`tools/AuditBattleBytecode.java` traverses reachable instructions, checks operand
|
||||
and scope stack heights, stack merges, declared limits and branch destinations.
|
||||
The original methods pass. The previous builds fail as follows:
|
||||
|
||||
- `MYRMain_player_stats_x2.app`, `TeamCenter.getBattleTeamVo`, method 12,
|
||||
body 11: stack underflow at method byte offset 268 (`0x10c`), `pop` on an
|
||||
empty stack after the inserted HP assignments.
|
||||
- `MYRDyd_packaged_main.swf`, `MYRLoaderStarter.fixComplete`, method 44,
|
||||
body 43: reachable stack height 5 exceeds `max_stack=4` at method offsets
|
||||
`0x2b` and `0x32`. The old patch overwrote `setlocal1` and left the
|
||||
`updateFiles` value on the stack. The branch destination remains valid.
|
||||
|
||||
These are bytecode defects, independently of APK signatures or readable
|
||||
decompiler output. They have not been established as the sole cause of the
|
||||
reported behavior through an Android execution trace.
|
||||
|
||||
Read-only ADB checks established that the installed APK matched the previous
|
||||
stats build and that the game process was not running during inspection.
|
||||
No installation, uninstallation or application-data clearing was performed.
|
||||
|
||||
## New builds
|
||||
|
||||
- Damage variant: player team 1 attacking enemy team 2, after hurt controllers
|
||||
and before HP deduction: `int(Math.min(damage * 10, 50000))`.
|
||||
Environmental damage without an attacking unit and enemy attacks retain
|
||||
their original behavior. Zero damage remains zero.
|
||||
- Stats variant: double the player battle copy's attack, defense, dexterity,
|
||||
current/max HP, crit, self heal, lifesteal, attack/defense stun, poison chance
|
||||
and damage, cooldown modifier, sun fire, moon heal, death explosion and
|
||||
thorns. The separate damage multiplier is absent. Speed, range, level,
|
||||
skill IDs/levels, AP costs and persistent character records are unchanged.
|
||||
- Both variants use a loader created from the original loader. Its 20-byte
|
||||
assignment block now obtains
|
||||
`File.applicationDirectory.resolvePath("MYRMain.app").url` directly.
|
||||
Only 18 bytes change; file length, all branch/exception offsets and method
|
||||
signatures remain unchanged. No storage or update files are deleted by
|
||||
this patch; existing resource-update behavior elsewhere is retained.
|
||||
|
||||
`SurgicalBattlePatch.java` adds actual instructions to original methods,
|
||||
rebuilds branch offsets from instruction identities, retains signatures,
|
||||
and copies all other SWF tags byte for byte. It does not import a complete
|
||||
decompiler P-code listing. The loader patch is separately guarded by the
|
||||
original SWF SHA-256 and an exact original-byte assertion.
|
||||
|
||||
## Visible runtime checks
|
||||
|
||||
A small green status overlay is attached to the stage. It ignores touches.
|
||||
The status has these stages:
|
||||
|
||||
1. `LOCAL D10 V3` or `LOCAL S2 V3`, then `WAITING FOR LOCAL BATTLE`:
|
||||
the instrumented main startup method has executed.
|
||||
2. `ENTRY ATK=... DEF=... DEX=... HP=.../...`:
|
||||
the player battle-copy creation path has executed. With several party
|
||||
members, the last processed member is displayed. Character menus show
|
||||
persistent records and are not a reliable check of this battle-copy patch.
|
||||
3. In the damage variant, `HIT 123 -> 1230 (PLAYER > ENEMY)` is an example
|
||||
of the pre/post values printed by the actual patched hurt path. Values
|
||||
reaching the cap instead display a final value of 50000. This is computed
|
||||
damage; HP actually lost may be smaller if the enemy has less HP left.
|
||||
|
||||
Test one variant at a time in an ordinary adventure battle. Fully exit and
|
||||
relaunch the app after installing an update. Resource updates are not needed
|
||||
to activate these packaged-code changes. If the overlay is absent, or stays
|
||||
at a particular stage, report that stage or capture the screen so the next
|
||||
probe can focus on the loading/startup/battle path concerned.
|
||||
|
||||
These builds use the same local test signing certificate as the previous
|
||||
modified builds. Installing on the device remains a separate user action.
|
||||
Do not uninstall or clear application data to resolve a signature error.
|
||||
|
||||
## Validation and limits
|
||||
|
||||
- Original methods pass the structural bytecode audit; the two old defects
|
||||
fail it; all V3 target methods pass it after serialization and re-reading.
|
||||
- `TestBattleFragment` executes instructions read from each final SWF using
|
||||
FFDec's arithmetic/branch implementation with property and display stubs.
|
||||
Twenty damage cases cover both teams, null attacker, zero, the cap, integer
|
||||
overflow, and an available/absent overlay. Thirty-four stat assertions
|
||||
cover all modified fields including fractional modifiers and HP/max HP.
|
||||
- These are fragment tests and structural checks, not the full Android AIR
|
||||
verifier or a gameplay test. Actual loading, displayed numbers and battle
|
||||
outcomes still need an on-device test of V3.
|
||||
- `compare_swf_v3.py` verifies tag count/order and exact preservation of every
|
||||
unmodified SWF tag. Only startup, team and (damage variant) hurt ABC tags
|
||||
may change. The loader changes only its original merged ABC tag.
|
||||
- `build_battle_v3.py` checks original APK identity, repacks both SWFs, aligns,
|
||||
signs, verifies signatures and all ZIP CRCs, and asserts that only the two
|
||||
intended non-signature APK members changed. The resulting hashes and
|
||||
paths are recorded in `analysis/battle_v3_manifest.json` when it completes.
|
||||
|
||||
## Reproduce
|
||||
|
||||
```powershell
|
||||
javac -encoding UTF-8 -cp 'tools\ffdec\lib\*' -d analysis\build tools\AuditBattleBytecode.java tools\SurgicalBattlePatch.java tools\TestBattleFragment.java
|
||||
java -Xmx2g -cp 'analysis\build;tools\ffdec\lib\*' SurgicalBattlePatch analysis\MYRMain.app analysis\MYRMain_damage_v3.app damage
|
||||
java -Xmx2g -cp 'analysis\build;tools\ffdec\lib\*' SurgicalBattlePatch analysis\MYRMain.app analysis\MYRMain_stats_v3.app stats
|
||||
python tools\patch_loader_v3.py analysis\MYRDyd.swf analysis\MYRDyd_v3.swf
|
||||
java -Xmx2g -cp 'analysis\build;tools\ffdec\lib\*' AuditBattleBytecode analysis\MYRDyd_v3.swf analysis\MYRMain_damage_v3.app analysis\MYRMain_stats_v3.app
|
||||
java -Xmx2g -cp 'analysis\build;tools\ffdec\lib\*' TestBattleFragment analysis\MYRMain_damage_v3.app damage
|
||||
java -Xmx2g -cp 'analysis\build;tools\ffdec\lib\*' TestBattleFragment analysis\MYRMain_stats_v3.app stats
|
||||
python tools\compare_swf_v3.py
|
||||
python tools\build_battle_v3.py
|
||||
```
|
||||
Reference in New Issue
Block a user