Yup, it's me again. And this one's not too obvious for my eyes.
The current code checks the first byte of the file for a specific file. This value has two variations, which dictates the location of the NPC data pointer. Navigate to the pointer, chuck the next 2000 bytes into an AnsiString, then output it back to the main program function
MainProcedure().
For some reason, using the buffer as a result throws the following exception:
raised eception class
'External: SIGSEGV'.
At address 10000939D
Here's the code, with the problem line indicated.
Repo here.
function GetWholeNPCData(msMAPFile: TMemoryStream; strPointer: string): AnsiString;
var
bufferNPCData: AnsiString;
begin
{$IFDEF DEBUG} ShowMessage('Putting entire block of NPC data into buffer!'); {$ENDIF}
msMAPFile.Seek(Hex2Dec(strPointer), 0);
{$IFDEF DEBUG} ShowMessage('Used pointer to get to NPC data!'); {$ENDIF}
msMAPFile.ReadBuffer(bufferNPCData, Hex2Dec('5DC'));
{$IFDEF DEBUG} ShowMessage('Put NPC data into buffer!'); {$ENDIF}
Result := bufferNPCData; <-- Problem code
{$IFDEF DEBUG} ShowMessage('Sent the buffer!'); {$ENDIF}
end;Considering this error is similar to the previous one I had, where I called
.Create; directly on a TStringList variable, I thought it might be to do with something, like, using string instead of AnsiString somewhere along the line, but nada.