Files
metin2-server/docs/FEATURE-PICKUP.md
T
2026-10-15 21:58:53 +09:00

68 lines
5.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# PORT batch pickup, v1
AVA2-style batch pickup (reference: AVA2 `do_pickup_all`). One command picks up every ground item the character owns within the normal pickup distance, filtered by category. Source: `src/server/game/src/port_pickup.h`, command `mt_pickup` (cmd.cpp), throttle field `m_portPickupLastCommand` in char.h. It reuses the quiet-INFO hook (`m_portQuietInfo`) added for the switchbot. No packet header, no DB schema, no affect. AVA2's `HEADER_CG_ITEMS_PICKUP` packet and its premium automatic pickup (`AFFECT_AUTO_PICK_UP`, item 70002) are not ported.
## Rules
- Collection walks `ForEachAround` on the character's sectree. An item is taken only when it:
- is on the ground (has a sectree);
- passes `DistanceValid` (the original 300-unit pickup distance);
- passes `IsOwnership(ch)` (own or ownerless);
- matches the category mask.
- Party loot owned by someone else is excluded. `PickupItem`'s party branch would hand it to the requester, which is what AVA2 also avoids.
- Items are sorted nearest-first and capped at 48 per command. Each one is looked up again by VID and goes through the original `CHARACTER::PickupItem`. Distance, stacking, inventory space, `ItemLog GET` and quest triggers are therefore the original path's.
- Each successful pickup still sends its own INFO line. Of the failures (usually a full inventory), only the first INFO line is sent, once.
- Busy: dead, stunned, observer mode, warping, or no sectree.
- Throttle: one command per 500 ms per character.
## Protocol (CHAT_TYPE_COMMAND, version 1)
```
/mt_pickup 1 MASK MASK = 1..255, at most 3 digits
MTPU1 done FOUND PICKED FAILED
MTPU1 error rate|invalid|busy
```
A request with a version other than `1`, a token longer than 10 characters or more than 3 tokens is ignored silently.
| Bit | Category | Item type |
| --- | --- | --- |
| 1 | yang | `ITEM_ELK` |
| 2 | weapon | `ITEM_WEAPON` |
| 4 | armor / jewellery | `ITEM_ARMOR` |
| 8 | skill book | `ITEM_SKILLBOOK` |
| 16 | stone | `ITEM_METIN` |
| 32 | material | `ITEM_MATERIAL` |
| 64 | costume | `ITEM_COSTUME` |
| 128 | other | every other type |
Capability: the MTF1 cap mask advertises bit 128 (127 -> 255). The client also falls back to single pickup when it gets no reply within 3 s.
## Verification
- `tests/features/test_pickup.py` compiles the production header against stubs of the PickupItem/ChatPacket contract. It covers:
- nearest-first order;
- foreign and far items left on the ground;
- per-category masks;
- the yang/INFO pass-through;
- a full inventory (`done 8 3 5`, one failure line);
- the 48 cap;
- rate, invalid, busy and silently ignored input.
- `tests/features/test_queries.py` was updated for cap mask 255. `test_switchbot.py` still passes.
- FreeBSD build of the whole game target on 203 in `/root/metin2-features-dev`, log `/root/metin2-features-dev/pickup-build.log`. The live `/usr/metin2` binary was not replaced and no live service was restarted.
- Live test on 2026-10-15 against the channel-5 test core (`/usr/metin2/server/channel5/first`, port 13040, isolated binary) with the macOS native client as [SA]Admin. The test created weapon 19, armor 11209, material 30003, stone 28030 and skill book 50300 with `/item`, then dropped each one and 1000 yang:
- mask 2 → `done 1 1 0` (weapon only);
- mask 48 → `done 2 2 0` (stone + material);
- mask 255 → `done 3 3 0` (armor, book, yang; the yang balance was restored);
- nothing left → `done 0 0 0`, and an immediate second command → `error rate`.
- `log.log` has one `GET` row per item, matching the `DROP` rows. The original path logs no GET for yang.
- The core's syserr shows no new errors. The LOCALE_ERROR there comes from the original yang-drop message.
- Live acceptance on CH1 (13000) after the deploy, with the same scenario as the channel-5 test: mask 2 → `done 1 1 0`, mask 48 → `done 2 2 0`, mask 255 → `done 3 3 0` (yang restored), then `done 0 0 0` and `error rate`.
- Not done yet: a live full-inventory run and Android device validation.
## Production deployment
- 2026-10-15 14:51, approved by the user. The 203 live cores now run main `3b7e158` (`game` sha256 `0d798ec0…`, the binary the channel-5 core was tested with). The db binary is unchanged. Live `/usr/metin2/src` was at `4577d86`, so the deploy also shipped `1a36719` (query protocol and calendar drop gates; the gates stay inert without `port_events.tsv`).
- Package `/root/deploy-features/20261015-features` (`deploy.sh check|go|rollback`, `SHA256SUMS`). The previous `game`/`db` are in `/root/backup-bin/20261015-145122` (recorded in `LAST_BACKUP`), and the replaced `/usr/metin2/src` files are in `src-before/`. `sh deploy.sh rollback` restores both.
- The first `go` stopped at `rebuild.sh stop_server` ("server still running" after about 38 s, cores still exiting) before any backup or copy; the second `go` succeeded. `start.sh` was answered with `1`, which starts only CH1 and game99, so CH2–CH4 were started afterwards with each `run.sh` in the `start.sh` order. The channel-5 test core was restarted too, giving the pre-deploy layout of 14 cores plus db and auth. The new syserr entries contain only the existing `new_quest_lv52` LUA_ERROR (present since 2026-09-21).