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

[MUICHAOS] Swords of Chaos - crashes MBBSEmu system #483

Closed Ohmz1290 closed 3 years ago

Ohmz1290 commented 3 years ago

Module Information

Describe the bug Several different things seem to crash the system. The easiest to reproduce is editing a player's stats from the GameOp menu. Also casting certain area of effect spells seems to do it randomly, spells like sleep and shockwave.

To Reproduce Steps to reproduce the behavior:

  1. Login to the game as a SysOp.
  2. Type "gameop" to enter the special access menu.
  3. Type "d" to edit a player, and enter in a valid player name.
  4. Type "a" to edit player stats.
  5. The game will crash at this point. See error below under Screenshots.

Expected behavior Should be able to edit the player info and stats.

Screenshots

Unhandled exception. System.NullReferenceException: Object reference not set to an instance of an object.
   at MBBSEmu.HostProcess.HostRoutines.FsdRoutines.ClearErrorMessage(SessionBase session, FsdFieldSpec errorField)
   at MBBSEmu.HostProcess.HostRoutines.FsdRoutines.EnteringFullScreenDisplay(SessionBase session)
   at MBBSEmu.HostProcess.HostRoutines.FsdRoutines.ProcessSessionState(SessionBase session, Dictionary`2 modules)
   at MBBSEmu.HostProcess.MbbsHost.WorkerThread()
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()

Screen shots of expected vs. actual between MBBSEmu and MajorBBS/Worldgroup help with understanding the expected difference between the two.

gameop

GameOp Menu:

A: Edit Item B: Edit Room C: Edit Monster D: Edit Player E: Edit Permanant Monster Location F: Edit Mercantile Catalog G: Edit Office H: Reload CNF Options I: Start Invasion J: Locate Item K: Locate Monster L: Create Item M: Generate Report N: Delete Player O: Suspend/Reinstate Player P: List Players With Special Permissions Q: Remove Monsters From This Room R: Set Bounty S: Toggle Your GameOp Permissions T: Edit Hall of Fame

Selection (A-T, X): d Player to edit: omegaop

A: Edit Stats B: Edit Spells C: Edit Permissions D: Edit Options

Selection (A-D, X): a Name: OmegaOp Title: Sorcerer Userid: OmegaOp

Str : 100 Dex : 100 Con : 100 Int : 100 Psy: 500
Thief: 0 Shield: 0 Two-Wep: 0 Defense: 1
Edged: 0 Blunt : 0 Pole : 0 Unarmed: 0

Class: S Race : E Outlaw : N Evil: 0
Guild: 0 Master: N Balance: 0

Bank : 1938368941 Cash: 0
Location: 1448

Editing Limitations (Leave the 0's for no limits) Low Room # : 0 High Room # : 0
Low Monster #: 0 High Monster #: 0
Low Item # : 0 High Item # : 0

SAVE/QUIT: (Press to select)

As soon as the above is printed, MBBSEmu crashes with the error message above. Normally, at this point you'd be able to use the arrow keys or tab to move between the fields and input information.

Software Information:

paladine commented 3 years ago

I'm unable to reproduce this on master - when I enter gameop I'm unable to go any further.I press d to go to the player editor but it has no effect and I just get the menu prompt again.

paladine commented 3 years ago

After I exit MUICHAOS and return to the main menu, when I press x to logoff, it doesn't do anything either.

paladine commented 3 years ago

Likely related to #169

enusbaum commented 3 years ago

Also re-entering the module after exiting seems to not work properly. There might be some lingering memory (VDA, etc.) that is not being cleared out on exit.

enusbaum commented 3 years ago

@paladine Fixed the input issue after exit with #484

enusbaum commented 3 years ago

OK! Was able to reproduce this issue! 😄

If this is the first time you're entering Swords of Chaos as sysop, you need to Toggle your GameOp permissions before being able to reproduce this issue.

  1. Enter the Game
  2. Type gameop
  3. Option S
  4. Toggle Player editor to *ON*

image

The error in this thread was being caused by the FSD template not having an error definition field. This was causing the call to ClearErrorMessage() to fail as the errorField value in fieldSpec was null.

https://github.com/mbbsemu/MBBSEmu/blob/1414c8466a44407aaecbb1ea58d9fc27613cb341/MBBSEmu/HostProcess/HostRoutines/FsdRoutines.cs#L292

Adding a null check on errorField resolves the crash, but the FSD still doesn't function properly. I'll have to work through what's causing the issue there.

PR coming shortly for this.