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

[ELWBAK] Pro Backgammon - Unable to run and shows blank menu option #103

Closed tuday2 closed 3 years ago

tuday2 commented 3 years ago

Module Information

Describe the bug Crashes on selection from menu, also shows up as "BLANK" (See screenshot)

To Reproduce Steps to reproduce the behavior:

  1. Add Pro Backgammon module to config
  2. Start MBBSemu
  3. Select menu item for Pro Backgammon (blank, see screenshot)

Expected behavior Module runs without crashing

Screenshots Screenshot 2020-09-10 070553

Unhandled exception. System.Collections.Generic.KeyNotFoundException: The given key 'sttrou' was not present in the dictionary.
   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 where exception was thrown ---
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()

Software Information:

API REPORT {"UniqueIdentifier":"ELWbak","File":"ELWBAK.DLL","Imports":{"DOSCALLS":[89],"PHAPI":[16],"MAJORBBS":[629,534,543,783,785,628,786,484,520,624,999,53,485,880,162,330,561,599,566,455,492,589,331,550,559,601,357,757,574,997,456,350,401,403,571,578,568,521,762,761,463,474,77,467,625,107,650,441,879,437,475,510,85,476,411,119,117,351,428,787,458,713,654,659,486,604,587,377,621,661,657,134,157,580,640,639,582,779,827,788,712,505,511,335,726,459,409,560,665,522,974,941,942,938,927,1170,68,930,996,968,943,1144,944,973,960,958,572,967,940,1172,1171,326,348,460,449,167],"GALGSBL":[40,30,53,36,72]}}

enusbaum commented 3 years ago

This is usually caused by the module's _INIT_ routine failing before calling register_module(), which results in MBBSEmu knowing that there is a module loaded... but not much else.

The research item here is to better understand what's causing the _INIT_ routine to exit prematurely, but also perhaps have MBBSEmu not include, and report modules that fail to register.

enusbaum commented 3 years ago

It appears that Backgammon is storing your demo start in GENBB.DAT, using the first segmented key to basically do a two dimensional lookup by username and module identifier to get the record for demo.

MBBSEmu's Btrieve engine doesn't handle Segmented Keys very well. Conversely, MajorBBS/WG is not aware of Key Segments either and only limited to query on one key at a time. To accommodate this, the engine appears to be pulling in the sum total of all segments lengths as a byte array for a Key query on a Segmented Key.

image

As you can see, the BBSGEN.DAT definition defines key 0 as:

0:1 - Length 30 (Username)
0:2 - Length 25 (Module Identifier)

TODO: The Btrieve File Processor needs to be enhance to when reading a key that is segmented, if the byte order is sequential, to just increase the size of the "parent" key. So in the case of BBSGEN.DAT, Key #0 will have a length of 55 bytes starting at byte 1. This is most likely how MajorBBS/WG handle querying segmented keys when only one key value can be specified.

If the Segments are not sequential, we'll need to display an error as that'll require some additional logic to handle.

enusbaum commented 3 years ago

Sold myself short on this one, MBBSEmu actually handles Segmented Keys just fine 😆

The issue is qrybtv was updated to support the sum bytes of a given key (https://github.com/enusbaum/MBBSEmu/blob/master/MBBSEmu/HostProcess/ExportedModules/Majorbbs.cs#L4764), but obtbtv was not (https://github.com/enusbaum/MBBSEmu/blob/master/MBBSEmu/HostProcess/ExportedModules/Majorbbs.cs#L2695).

In this case, only obtbtv needs to fixed 👍