Brief: //dnl ch75

- More map editor fixes and map inventory pool performance improvement for big maps.
Details:
- Fix not showing expected messagebox on exit (ALT+x) which also throw exception and goes to improper mapeditor exit.
- Fix second annoying sticky message which shouldn't popup during map loading and performing RemoveProhibitedAttachments.
- Fix CTD when delete all enemies or civilians or all of them in map.
- Fix some std exception when reporting for missing optional xml file.
- Fix memory and map corruption in old mapeditors if loaded old map has item with invalid attachment and we try to attach something else.
- As years ago pInventoryPoolList had migrated from WORLDITEM* array to std::vector<WORLDITEM> it was time to do that with gWorldItems too, all necessary functions which need to be adopted to gWorldItems std::vector type are also changed.
- Resize code for gWorldItems is changed hoping will lead into less corruption problems as now could occur in mapeditor and game when code automatically doing attachment changes.
- Change code for handling map inventory which now should be fast enough to support AIMNAS project which will probably deal with thousands of items per map.


git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@6554 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Kriplo
2013-11-03 16:26:30 +00:00
parent 0c82c1845f
commit b91bc7b209
24 changed files with 593 additions and 711 deletions
+6 -20
View File
@@ -6105,7 +6105,7 @@ void HandleEquipmentMove( INT16 sMapX, INT16 sMapY, INT8 bZ )
CHAR16 wSectorName[ 64 ];
GetShortSectorString( sMapX, sMapY, wSectorName );
WORLDITEM* pWorldItem_Target = NULL;
std::vector<WORLDITEM> pWorldItem_Target;//dnl ch75 271013
// now loop over all sectors from which we take stuff, and move the equipment
std::map<UINT8, UINT8>::iterator itend = sectormercmap.end();
@@ -6136,11 +6136,7 @@ void HandleEquipmentMove( INT16 sMapX, INT16 sMapY, INT8 bZ )
UINT32 uiTotalNumberOfRealItems_Target = 0;
// use the new map
if ( pWorldItem_Target )
{
delete[] pWorldItem_Target;
pWorldItem_Target = NULL;
}
pWorldItem_Target.clear();//dnl ch75 021113
if( ( gWorldSectorX == targetX )&&( gWorldSectorY == targetY ) && (gbWorldSectorZ == bZ ) )
{
@@ -6157,8 +6153,8 @@ void HandleEquipmentMove( INT16 sMapX, INT16 sMapY, INT8 bZ )
if( uiTotalNumberOfRealItems_Target > 0 )
{
// allocate space for the list
pWorldItem_Target = new WORLDITEM[ uiTotalNumberOfRealItems_Target ];
pWorldItem_Target.resize(uiTotalNumberOfRealItems_Target);//dnl ch75 271013
// now load into mem
LoadWorldItemsFromTempItemFile( targetX, targetY, bZ, pWorldItem_Target );
}
@@ -6236,7 +6232,7 @@ void HandleEquipmentMove( INT16 sMapX, INT16 sMapY, INT8 bZ )
WORLDITEM* pWorldItem_tmp = NULL;
if( ( gWorldSectorX != targetX ) || ( gWorldSectorY != targetY ) || (gbWorldSectorZ != bZ ) )
{
pWorldItem_tmp = new WORLDITEM[ uiTotalNumberOfRealItems_Target ];
std::vector<WORLDITEM> pWorldItem_tmp(uiTotalNumberOfRealItems_Target);//dnl ch75 271013
// copy over old inventory
UINT32 newcount = 0;
@@ -6250,11 +6246,7 @@ void HandleEquipmentMove( INT16 sMapX, INT16 sMapY, INT8 bZ )
}
// use the new map
if ( pWorldItem_Target )
{
delete[] pWorldItem_Target;
pWorldItem_Target = NULL;
}
pWorldItem_Target.clear();//dnl ch75 021113
pWorldItem_Target = pWorldItem_tmp;
}
@@ -6270,12 +6262,6 @@ void HandleEquipmentMove( INT16 sMapX, INT16 sMapY, INT8 bZ )
//Save the Items to the the file
SaveWorldItemsToTempItemFile( targetX, targetY, bZ, uiTotalNumberOfRealItems_Target, pWorldItem_Target );
}
if ( pWorldItem_tmp )
{
delete[] pWorldItem_tmp;
pWorldItem_tmp = NULL;
}
// award a bit of experience to the movers
UINT16 itemsperperson = moveditems / (*it).second;