@@ -237,22 +237,24 @@ void CFrmSet::FreeUpFRM(CFrame *l_pFRM)
237237// ---------------------------------------------------------------------------
238238void CFrmSet::GetCritterFName (String* filename, DWORD frmPID, WORD *frmID)
239239{
240- // Èçâëå÷åíèå íîâîãî èíäåêñà èç ñòðîêè critters.lst
241- int CommaPos = filename->Pos (" ," );
242- String NewIndexAsStr = filename->SubString (filename->Pos (" ," ) + 1 ,
240+ int NewIndex = -1 ;
241+ try {
242+ // extract index B from line A,B,C in critters.lst:
243+ // A: [FRM name (6 chars)],
244+ // B: [index in CRITTERS.LST - used to reference Aimed Shot screen],
245+ // C: [Whether Run animations are included]
246+ int CommaPos = filename->Pos (" ," );
247+
248+ String NewIndexAsStr = filename->SubString (CommaPos + 1 ,
243249 filename->Length () - CommaPos);
244- CommaPos = NewIndexAsStr.Pos (" ," );
245-
246- if (CommaPos)
247- NewIndexAsStr = NewIndexAsStr.SubString (1 , CommaPos - 1 );
250+ CommaPos = NewIndexAsStr.Pos (" ," );
248251
249- int NewIndex;
250- try
251- {
252- NewIndex = NewIndexAsStr.ToInt ();
253- }
254-
255- catch (EConvertError&) {
252+ if (CommaPos)
253+ {
254+ NewIndexAsStr = NewIndexAsStr.SubString (1 , CommaPos - 1 );
255+ NewIndex = NewIndexAsStr.ToInt ();
256+ }
257+ } catch (EConvertError&) {
256258 Application->MessageBox (" Bad string in critters.lst\n "
257259 " Object will be ignored" ,
258260 " Mapper" ,
@@ -272,13 +274,16 @@ void CFrmSet::GetCritterFName(String* filename, DWORD frmPID, WORD *frmID)
272274 ID2 == 0x39 || ID2 == 0x3A ||
273275 ID2 == 0x21 || ID2 == 0x40 )
274276 {
275- Index = NewIndex;
276- *filename = pUtil->GetFRMFileName (critter_ID,
277+ Index = NewIndex;
278+ *filename = pUtil->GetFRMFileName (critter_ID,
277279 pLstFiles->pFRMlst [critter_ID]->Strings [Index]);
278280// *filename = pLstFiles->pFRMlst[critter_ID]->Strings[Index];
279281 }
280282
281- filename->SetLength (filename->Pos (" ," ) - 1 );
283+ int CommaPos = filename->Pos (" ," );
284+
285+ if (CommaPos)
286+ filename->SetLength (CommaPos - 1 );
282287
283288 // Ïîëó÷åíèå ñóôôèêñîâ
284289 char Suffix1;
@@ -306,9 +311,9 @@ void CFrmSet::GetCritterFName(String* filename, DWORD frmPID, WORD *frmID)
306311 }
307312 else
308313 {
309- Application->MessageBox (" Bad suffix\n "
310- " Object will be ignored" ,
311- " Mapper" ,
314+ Application->MessageBox (" Bad suffix\n "
315+ " Object will be ignored" ,
316+ " Mapper" ,
312317 MB_ICONEXCLAMATION | MB_OK);
313318 }
314319 *filename += FileExt;
0 commit comments