mbbsemu / MBBSEmu

The MajorBBS Emulation Project is an Open Source, Cross-Platform emulator for easily running The MajorBBS & Worldgroup Modules
https://www.mbbsemu.com
MIT License
128 stars 14 forks source link

[RTSLORD] LORD - PLAYER.DAT blanked #400

Closed synacktic closed 3 years ago

synacktic commented 3 years ago

Module Information

Describe the bug After updating module config, the PLAYER.DAT gets damaged on the next run.

To Reproduce Steps to reproduce the behavior:

  1. Create a module.conf with two games, RTSLORD being the first one
  2. Run MBBSEmu and create character
  3. Shutdown MBBSEmu
  4. Edit module.conf to flip RTSLORD to the second listed and the other game as the first
  5. Run MBBSEmu and find your character missing

Expected behavior Moving RTSLORD to a new position in the menu should not cause it to erase PLAYER.DAT

Software Information:

paladine commented 3 years ago

If I had to guess, this might be caused by how the file is being opened in the first place - are we blanking the file for example with an O_TRUNC argument or similar?

synacktic commented 3 years ago

I'm also seeing this when I have not changed the config, I think... I have recompiled a lot though. I'll see if I can find more ways to make it happen. Also, I'll see if I can find what is going on with that IO, but it might be a little beyond me.

paladine commented 3 years ago

I tried reproducing but was unable to. My player data remaining throughout multiple restarts as well as changing module position order.

synacktic commented 3 years ago

Thanks. Let me spend some more time reviewing and maybe try on Windows, etc. I was using a copy I build from master btw. Just hold until I update.

synacktic commented 3 years ago

Ok, this is weird. I've only been testing with GALKYR and RTSLORD. module.conf: { "Modules": [ { "Identifier": "GALKYR", "Path": "GALKYR", "MenuOptionKey": "K" }, { "Identifier": "RTSLORD", "Path": "RTSLORD", "MenuOptionKey": "L" } ] }

I can reproduce everytime by following the steps above with one change... once you restart with after switching, you first go right back into the port where LORD WAS last time. This will take you to Kyrandia. X out. Then load the correct port for LORD, as soon as it loads, you see the PLAYER.DAT has been blanked.

Running under Linux, built from master...

Now look at this... Screenshot from 2021-02-10 21-15-25

That error sometimes appears when exiting Kyrandia after the rlogin to the old/wrong/kyrandia port... what makes that so interesting, is if you search for where that message came from, it is an RTSLORD message, not a kyrandia message.

I'm still digging around, but it seems there is a memory / ptr issue, but I can't imagine why it only turns up when swapping the modules / ports.

synacktic commented 3 years ago

Oh, and whenever this issue fires RTSLORD has decided to load PLAYER.BAK and overwrite PLAYER.DAT... It does not do that on "normal" runs, so I'm not sure what is firing that bit of code in the module or why it does not check to see if there is a BAK worth using, etc.

paladine commented 3 years ago

That Cannot save account # 0 - there are only -1 people playing!!? looks alarming.

Mind sharing your appsettings.json?

synacktic commented 3 years ago

Not at all.

{ "BBS.Title": "MBBSEmu", "BBS.Channels": "10", "Cleanup.Time": "03:00", "GSBL.BTURNO":"13936829", "GSBL.BTURNO.HVSTW":"97771457", "Module.DoLoginRoutine": "False", "Telnet.Enabled": "True", "Telnet.Port": "2323", "Telnet.Heartbeat": "False", "Rlogin.Enabled": "True", "Rlogin.Port": "1513", "Rlogin.RemoteIP": "127.0.0.1", "Rlogin.PortPerModule": "True", "Database.File": "mbbsemu.db", "Btrieve.CacheSize": 4, "Account.DefaultKeys": [ "DEMO", "NORMAL", "USER" ] }

synacktic commented 3 years ago

So, I think I worked this out. The PR #402 should fix it. Will see if it gets merged and go from there.

synacktic commented 3 years ago

We good. Thanks all.