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
129 stars 14 forks source link

[ELWIC] Infinity Complex - Module crashes during game message #86

Closed dlightman311 closed 4 years ago

dlightman311 commented 4 years ago

Module Information

Describe the bug During the game Infinity Complex alerts players to parts shipments and provides information as to where they can be collected. These messages are displayed but some of the relative locations show negative numbers and MBBSEmu crashes with a System.FormatException: Input string was not in a correct format message.

To Reproduce Steps to reproduce the behavior:

  1. Enter the module
  2. Wait for a few minutes in any room for the shipment announcement to be made.

Expected behavior Location of the parts shipment displayed relative to the players location.

Screenshots

Unhandled exception. System.FormatException: Input string was not in a correct format.
   at System.Number.ThrowOverflowOrFormatException(ParsingStatus status, TypeCode type)
   at System.Int16.Parse(ReadOnlySpan`1 s, NumberStyles style, IFormatProvider provider)
   at MBBSEmu.Module.McvFile.GetNumeric(Int32 ordinal)
   at MBBSEmu.HostProcess.ExportedModules.Majorbbs.numopt()
   at MBBSEmu.HostProcess.ExportedModules.Majorbbs.Invoke(UInt16 ordinal, Boolean offsetsOnly)
   at MBBSEmu.HostProcess.ExecutionUnits.ExecutionUnit.ExternalFunctionDelegate(UInt16 ordinal, UInt16 functionOrdinal)
   at MBBSEmu.CPU.CpuCore.Tick()
   at MBBSEmu.HostProcess.ExecutionUnits.ExecutionUnit.Execute(IntPtr16 entryPoint, UInt16 channelNumber, Boolean simulateCallFar, Boolean bypassState, Queue`1 initialStackValues, UInt16 initialStackPointer)
   at MBBSEmu.Module.MbbsModule.Execute(IntPtr16 entryPoint, UInt16 channelNumber, Boolean simulateCallFar, Boolean bypassSetState, Queue`1 initialStackValues, UInt16 initialStackPointer)
   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()

image

image

Software Information:

enusbaum commented 4 years ago

It appears that the issue is cause by MBBSEmu not properly parsing numopt fields in an MCV file.

The current logic assumes that the number will be by itself the MCV field, but it appears you can have leading text before the number and the leading text is not parsed. An example here is the MCV value { ... 1 } should be parsed as 1 by numopt().

I've added a new GetNumericMessageValue() to McvFile.cs which implements this logic for the numeric retrieval options. Testing this now but I believe it'll work.