Fashion Pouch

FASHION POUCH - HOW TO ADD IT (with mounts and flying mounts)
==============================================================

What it does
------------
Adds a second pouch, the Fashion Pouch (inventory 8). It holds:
  - fashion items
  - mounts
  - flying mounts
Everything else is refused. The Mystery Pouch is not changed.
The pouch starts at 24 slots and can grow to 252.

IMPORTANT: The addresses below only work on a gs that is exactly the
same as gs_3 (MD5 0151930354a5fb728325582fc36fcc0b). On another build
the steps are the same, but the addresses will be different.
Always keep a backup of the original gs.


STEP 1 - elements.data (server AND client)
------------------------------------------
Open SPECIAL_ID_CONFIG and set:
  id_special_pack_item_1 = 11712   (Mystery Pouch, leave it)
  id_special_pack_item_3 = your pouch item ID   (ours: 51863)

- The pouch item must be the same item type as the Mystery Pouch.
- Use slot 3. Slot 2 would just make a second Mystery Pouch.
- The server and client copies must match.


STEP 2 - Client
---------------
Nothing to change. The client already opens slot 3 as inventory 8
in the stash window. (The window title says "Mystery Pouch".)


STEP 3 - GS: what to change and where
-------------------------------------
The GS already saves inventory 8. It is just missing the code to
use it. These are the spots to edit:

  Where                                   Address       Change
  --------------------------------------  ------------  ------------------------------
  MakeItem                                0x816C979     Treat slots 3-4 as pouch items
  item_spectrashbox::OnUse                0x81E2708     Slot 3-4 opens inventory 8,
                                                        gives 24 slots, sends it to client
  ActivateSpecTrashBox                    0x8094C77     Turn on pouch flag (0x7CFD)
  DeactivateSpecTrashBox                  0x8094C8D     Turn off pouch flag
  IsSpecTrashBoxActive                    0x8094D12     Pouch is active if flag is on
                                                        or pouch item is carried
  PlayerMoveItemBetween...SpecTrashBox    0x807BF52     Allow moving bag <-> pouch
                                          0x807BFBC
                                          0x807C008
                                          0x807C086     ITEM FILTER (see Step 4)
  PlayerExchangeInventorySpecTrashBox     0x807C1E9     Allow swapping bag <-> pouch
                                          0x807C23F
                                          0x807C27C/3BB/3F5
                                          0x807C2D1     ITEM FILTER (see Step 4)
  PlayerExchangeInvItem                   0x807B660/6E9/72B   Swap inside pouch
  PlayerMoveInvItem                       0x807B792/81C/85F   Move inside pouch
  PlayerGetInventoryDetail                table 0x8488970     Send pouch contents
  PlayerGetInventory                      table 0x8488AFC     Send pouch summary
  PlayerGetItemInfo                       table 0x8488924     Send one pouch item
  Login (gplayer_controller)              0x80E2BF2     Send pouch at login
  ChangeSpecTrashBoxSize                  0x808C447     Index 1 resizes pouch (24-252)

Pouch item list is at offset 0x7CE0. Pouch flag is at offset 0x7CFD.


STEP 4 - Let mounts and flying mounts in
----------------------------------------
At the two ITEM FILTER spots, allow the item if ANY of these is true:
  - it is fashion          (equip_mask & 0x6F80)
  - it is a mount          (item type 66, DT_VEHICLE_ESSENCE)
  - it is a flying mount   (item type 81, DT_AIRCRAFT_ESSENCE)
Otherwise refuse it. Taking items out is always allowed.

If you have source code, it looks roughly like this:

  bool CanEnterFashionPouch(const item& it) {
      if (it.equip_mask & 0x6F80) return true;      // fashion
      DATA_TYPE dt;
      if (!GetDataMan().get_data_ptr(it.type, ID_SPACE_ESSENCE, dt))
          return false;
      return dt == DT_VEHICLE_ESSENCE || dt == DT_AIRCRAFT_ESSENCE;
  }


IF YOU ONLY HAVE THE BINARY (no source)
---------------------------------------
- New code goes into free space at 0x085AB7B0 (2,134 bytes free).
- At each address above, replace the first bytes with a jump to the
  new code, then jump back.
- For the three "table" spots, point inventory 8's entry to the new code.
- Make the code segment length bigger: 0x5637AA -> 0x563C6D.
- Write the result to a NEW file. Never edit the original.


INSTALL
-------
1. Stop the server. Back up the original gs.
2. Put the patched gs in its place and run: chmod +x gs
3. Start the server and log in fresh.

To undo: put the original gs back.


TEST
----
[ ] Use the pouch: a window with 24 slots opens
[ ] Fashion item, mount and flying mount all go in
[ ] Potion or weapon is refused
[ ] Log out and back in: items are still there
[ ] Mystery Pouch still works normally
[ ] No ASSERT lines in the GS log


IF SOMETHING IS WRONG
---------------------
"Unable to use"              -> MakeItem / OnUse not changed
Window opens but no grid     -> pouch not sent at login / on use
ASSERT when opening          -> missing inventory 8 in the table spots
Mount or fashion refused     -> item filter (Step 4) too narrow


Revision #1
Created 2026-11-24 23:05:38 UTC by Akane
Updated 2026-11-24 23:09:37 UTC by Akane