@@ -305,28 +305,36 @@ int CLuaEngineDefs::EngineLoadIFP ( lua_State* luaVM )
305
305
{
306
306
// Grab the resource root entity
307
307
CClientEntity* pRoot = pResource->GetResourceTXDRoot ();
308
-
309
- // Create a IFP element
310
- CClientIFP* pIFP = new CClientIFP ( m_pManager, INVALID_ELEMENT_ID );
311
-
312
- // Try to load the IFP file
313
- if ( pIFP->LoadIFP ( strPath, strBlockName ) )
314
- {
315
- // We can use the map to retrieve correct IFP by block name later
316
- g_pClientGame->InsertIFPPointerToMap ( strBlockName, pIFP );
317
-
318
- // Success loading the file. Set parent to IFP root
319
- pIFP->SetParent ( pRoot );
320
-
321
- // Return the IFP element
322
- lua_pushelement ( luaVM, pIFP );
323
- return 1 ;
324
- }
308
+
309
+ // Check whether the IFP blockname exists or not
310
+ if ( g_pClientGame->GetIFPPointerFromMap ( strBlockName ) == nullptr )
311
+ {
312
+ // Create a IFP element
313
+ CClientIFP* pIFP = new CClientIFP ( m_pManager, INVALID_ELEMENT_ID );
314
+
315
+ // Try to load the IFP file
316
+ if ( pIFP->LoadIFP ( strPath, strBlockName ) )
317
+ {
318
+ // We can use the map to retrieve correct IFP by block name later
319
+ g_pClientGame->InsertIFPPointerToMap ( strBlockName, pIFP );
320
+
321
+ // Success loading the file. Set parent to IFP root
322
+ pIFP->SetParent ( pRoot );
323
+
324
+ // Return the IFP element
325
+ lua_pushelement ( luaVM, pIFP );
326
+ return 1 ;
327
+ }
328
+ else
329
+ {
330
+ // Delete it again
331
+ delete pIFP;
332
+ argStream.SetCustomError ( strFile, " Error loading IFP" );
333
+ }
334
+ }
325
335
else
326
336
{
327
- // Delete it again
328
- delete pIFP;
329
- argStream.SetCustomError ( strFile, " Error loading IFP" );
337
+ argStream.SetCustomError ( strFile, " Block name already exists" );
330
338
}
331
339
}
332
340
else
0 commit comments