Issue information

Issue ID
#1425
Status
Fixed
Severity
Critical
Started
Hercules Elf Bot
Apr 26, 2008 0:10
Last Post
Hercules Elf Bot
Apr 26, 2008 0:10
Confirmation
N/A

Hercules Elf Bot - Apr 26, 2008 0:10

Originally posted by [b]theultramage[/b]
http://www.eathena.ws/board/index.php?autocom=bugtracker&showbug=1425

I have received a report that the code that handles storage behaves incorrectly on multimapserver setups, making an item duplication scenario possible.
After tracing the behavior of the code, I can generalize this to single-server too, although the circumstances are a bit different.

To make it short:

The mapserver has a storage_db (int account_id -> struct storage*). This thing is populated the first time a char requests storage, and stays around, like a cache. The issue is that it stays around even after the char logs out! And when he logs back in, the same cache will be there, unchanged.

Scenario 1 (single-server):
Player puts item X into storage, then logs out. Something externally modifies the storage db (control panel, gm maintenance, 'gift' system, etc etc). Player logs back in. Player still sees the old storage, and if he does anything, the db will be most likely re-set to match the current mapserver cache.

Scenario 2 (multi-mapserver):
Player opens storage on mapserver A, leaves it like that, goes to mapserver B, opens storage, loots everything, then goes back to mapserver A and loots everything again. Result is that he'll have every item twice.

This scenario has existed for who knows how long. There _is_ a place where the storage data would get deleted, but its execution depends on various flags, and from what I've gathered, the deciding flag is always '0' when it finally gets there...

This glaring defect is the result of the mess that is the save-on-exit mechanism, which consists of various magic numbers and variables to track the data saving pingpong between the charserver and mapserver, recursive and repetitive calls that make no sense, and a spaghetti of poorly structured functions. In other words, it fails.