Skip to content
This repository has been archived by the owner on May 2, 2022. It is now read-only.

Commit

Permalink
Fix parsing lines without indexes from critters.lst
Browse files Browse the repository at this point in the history
  • Loading branch information
JanSimek committed Jan 3, 2022
1 parent 195596e commit 4106c81
Showing 1 changed file with 25 additions and 20 deletions.
45 changes: 25 additions & 20 deletions Mapper/frmset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,22 +237,24 @@ void CFrmSet::FreeUpFRM(CFrame *l_pFRM)
//---------------------------------------------------------------------------
void CFrmSet::GetCritterFName(String* filename, DWORD frmPID, WORD *frmID)
{
// Èçâëå÷åíèå íîâîãî èíäåêñà èç ñòðîêè critters.lst
int CommaPos = filename->Pos(",");
String NewIndexAsStr = filename->SubString(filename->Pos(",") + 1,
int NewIndex = -1;
try {
// extract index B from line A,B,C in critters.lst:
// A: [FRM name (6 chars)],
// B: [index in CRITTERS.LST - used to reference Aimed Shot screen],
// C: [Whether Run animations are included]
int CommaPos = filename->Pos(",");

String NewIndexAsStr = filename->SubString(CommaPos + 1,
filename->Length() - CommaPos);
CommaPos = NewIndexAsStr.Pos(",");

if (CommaPos)
NewIndexAsStr = NewIndexAsStr.SubString(1, CommaPos - 1);
CommaPos = NewIndexAsStr.Pos(",");

int NewIndex;
try
{
NewIndex = NewIndexAsStr.ToInt();
}

catch(EConvertError&) {
if (CommaPos)
{
NewIndexAsStr = NewIndexAsStr.SubString(1, CommaPos - 1);
NewIndex = NewIndexAsStr.ToInt();
}
} catch(EConvertError&) {
Application->MessageBox("Bad string in critters.lst\n"
"Object will be ignored",
"Mapper",
Expand All @@ -272,13 +274,16 @@ void CFrmSet::GetCritterFName(String* filename, DWORD frmPID, WORD *frmID)
ID2 == 0x39 || ID2 == 0x3A ||
ID2 == 0x21 || ID2 == 0x40)
{
Index = NewIndex;
*filename = pUtil->GetFRMFileName(critter_ID,
Index = NewIndex;
*filename = pUtil->GetFRMFileName(critter_ID,
pLstFiles->pFRMlst[critter_ID]->Strings[Index]);
// *filename = pLstFiles->pFRMlst[critter_ID]->Strings[Index];
}

filename->SetLength(filename->Pos(",") - 1);
int CommaPos = filename->Pos(",");

if (CommaPos)
filename->SetLength(CommaPos - 1);

// Ïîëó÷åíèå ñóôôèêñîâ
char Suffix1;
Expand Down Expand Up @@ -306,9 +311,9 @@ void CFrmSet::GetCritterFName(String* filename, DWORD frmPID, WORD *frmID)
}
else
{
Application->MessageBox("Bad suffix\n"
"Object will be ignored",
"Mapper",
Application->MessageBox("Bad suffix\n"
"Object will be ignored",
"Mapper",
MB_ICONEXCLAMATION | MB_OK);
}
*filename += FileExt;
Expand Down

0 comments on commit 4106c81

Please sign in to comment.