mirror of
https://github.com/1dot13/source.git
synced 2026-08-12 14:10:23 +02:00
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:
@@ -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;
|
||||
|
||||
@@ -457,7 +457,7 @@ void HourlyStealUpdate()
|
||||
// we loop over this sector's inventory and look for something shiny. We will pick it up if we hae enough space in our inventory
|
||||
// open sector inv
|
||||
UINT32 uiTotalNumberOfRealItems = 0;
|
||||
WORLDITEM* pWorldItem = NULL;
|
||||
std::vector<WORLDITEM> pWorldItem;//dnl ch75 271013
|
||||
BOOLEAN fReturn = FALSE;
|
||||
|
||||
if( ( gWorldSectorX == pSoldier->sSectorX ) && ( gWorldSectorY == pSoldier->sSectorY ) && (gbWorldSectorZ == pSoldier->bSectorZ ) )
|
||||
@@ -479,7 +479,7 @@ void HourlyStealUpdate()
|
||||
if( uiTotalNumberOfRealItems > 0 )
|
||||
{
|
||||
// allocate space for the list
|
||||
pWorldItem = new WORLDITEM[ uiTotalNumberOfRealItems ];
|
||||
pWorldItem.resize(uiTotalNumberOfRealItems);//dnl ch75 271013
|
||||
|
||||
if ( !uiTotalNumberOfRealItems )
|
||||
continue;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -84,5 +84,5 @@ BOOLEAN SwitchToInventoryPoolQ(UINT8 newidx);
|
||||
// Flugente: handle various cooldown functions over an array of items in a specific sector.
|
||||
// if fWithMinutes = true, adjust cooldown for time since sector was last entered
|
||||
// otherwise its used for a turn-precise cooldown
|
||||
void HandleSectorCooldownFunctions( INT16 sMapX, INT16 sMapY, INT8 sMapZ, WORLDITEM* pWorldItem, UINT32 size, BOOLEAN fWithMinutes, BOOLEAN fUndo = FALSE);
|
||||
void HandleItemCooldownFunctions( OBJECTTYPE* itemStack, INT32 deltaSeconds, UINT16 naturalDirt = 100, BOOLEAN isUnderground = FALSE);
|
||||
void HandleSectorCooldownFunctions( INT16 sMapX, INT16 sMapY, INT8 sMapZ, std::vector<WORLDITEM>& pWorldItem, UINT32 size, BOOLEAN fWithMinutes, BOOLEAN fUndo = FALSE);//dnl ch75 271013
|
||||
void HandleItemCooldownFunctions( OBJECTTYPE* itemStack, INT32 deltaSeconds, UINT16 naturalDirt = 100, BOOLEAN isUnderground = FALSE);
|
||||
|
||||
@@ -2162,6 +2162,7 @@ void EnemyCapturesPlayerSoldier( SOLDIERTYPE *pSoldier )
|
||||
RemoveCharacterFromSquads( pSoldier );
|
||||
|
||||
WORLDITEM WorldItem;
|
||||
std::vector<WORLDITEM> pWorldItem(1);//dnl ch75 271013
|
||||
|
||||
// Is this the first one..?
|
||||
if ( gubQuest[ QUEST_HELD_IN_ALMA ] == QUESTNOTSTARTED )
|
||||
@@ -2186,9 +2187,9 @@ void EnemyCapturesPlayerSoldier( SOLDIERTYPE *pSoldier )
|
||||
WorldItem.bVisible = FALSE;
|
||||
WorldItem.bRenderZHeightAboveLevel = 0;
|
||||
pSoldier->inv[ i ].MoveThisObjectTo(WorldItem.object);
|
||||
|
||||
AddWorldItemsToUnLoadedSector( gModSettings.ubInitialPOWSectorX, gModSettings.ubInitialPOWSectorY, 0,
|
||||
gModSettings.iInitialPOWItemGridNo[ gStrategicStatus.ubNumCapturedForRescue ], 1, &WorldItem, FALSE );
|
||||
//dnl ch75 271013
|
||||
pWorldItem[0] = WorldItem;
|
||||
AddWorldItemsToUnLoadedSector( gModSettings.ubInitialPOWSectorX, gModSettings.ubInitialPOWSectorY, 0, gModSettings.iInitialPOWItemGridNo[ gStrategicStatus.ubNumCapturedForRescue ], 1, pWorldItem, FALSE );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2219,9 +2220,9 @@ void EnemyCapturesPlayerSoldier( SOLDIERTYPE *pSoldier )
|
||||
WorldItem.bVisible = FALSE;
|
||||
WorldItem.bRenderZHeightAboveLevel = 0;
|
||||
pSoldier->inv[ i ].MoveThisObjectTo(WorldItem.object);
|
||||
|
||||
AddWorldItemsToUnLoadedSector( gModSettings.ubMeanwhileInterrogatePOWSectorX, gModSettings.ubMeanwhileInterrogatePOWSectorY, 0,
|
||||
gModSettings.iMeanwhileInterrogatePOWItemGridNo[ gStrategicStatus.ubNumCapturedForRescue ], 1, &WorldItem, FALSE );
|
||||
//dnl ch75 271013
|
||||
pWorldItem[0] = WorldItem;
|
||||
AddWorldItemsToUnLoadedSector( gModSettings.ubMeanwhileInterrogatePOWSectorX, gModSettings.ubMeanwhileInterrogatePOWSectorY, 0, gModSettings.iMeanwhileInterrogatePOWItemGridNo[ gStrategicStatus.ubNumCapturedForRescue ], 1, pWorldItem, FALSE );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -423,12 +423,9 @@ void HandleDelayedItemsArrival( UINT32 uiReason )
|
||||
INT32 sStartGridNo;
|
||||
UINT32 uiNumWorldItems, uiLoop;
|
||||
BOOLEAN fOk;
|
||||
WORLDITEM * pTemp = 0;
|
||||
std::vector<WORLDITEM> pTemp;//dnl ch75 271013
|
||||
UINT8 ubLoop;
|
||||
|
||||
|
||||
|
||||
//#if 0
|
||||
if (uiReason == NPC_SYSTEM_EVENT_ACTION_PARAM_BONUS + NPC_ACTION_RETURN_STOLEN_SHIPMENT_ITEMS )
|
||||
{
|
||||
if ( gMercProfiles[ PABLO ].bMercStatus == MERC_IS_DEAD )
|
||||
@@ -504,11 +501,7 @@ void HandleDelayedItemsArrival( UINT32 uiReason )
|
||||
{
|
||||
return;
|
||||
}
|
||||
pTemp = new WORLDITEM[ uiNumWorldItems];
|
||||
if (!pTemp)
|
||||
{
|
||||
return;
|
||||
}
|
||||
pTemp.resize(uiNumWorldItems);//dnl ch75 271013
|
||||
fOk = LoadWorldItemsFromTempItemFile( BOBBYR_SHIPPING_DEST_SECTOR_X, BOBBYR_SHIPPING_DEST_SECTOR_Y, BOBBYR_SHIPPING_DEST_SECTOR_Z, pTemp );
|
||||
if (fOk)
|
||||
{
|
||||
@@ -522,13 +515,6 @@ void HandleDelayedItemsArrival( UINT32 uiReason )
|
||||
AddWorldItemsToUnLoadedSector( BOBBYR_SHIPPING_DEST_SECTOR_X, BOBBYR_SHIPPING_DEST_SECTOR_Y, BOBBYR_SHIPPING_DEST_SECTOR_Z, 0, uiNumWorldItems, pTemp, TRUE );
|
||||
}
|
||||
}
|
||||
|
||||
if (pTemp) {
|
||||
delete [] pTemp;
|
||||
}
|
||||
|
||||
//#endif
|
||||
|
||||
}
|
||||
|
||||
void AddSecondAirportAttendant( void )
|
||||
|
||||
@@ -1111,7 +1111,7 @@ void RemoveRandomItemsInSector( INT16 sSectorX, INT16 sSectorY, INT16 sSectorZ,
|
||||
{
|
||||
// remove random items in sector
|
||||
UINT32 uiNumberOfItems = 0, iCounter = 0;
|
||||
WORLDITEM *pItemList;
|
||||
std::vector<WORLDITEM> pItemList;//dnl ch75 271013
|
||||
UINT32 uiNewTotal = 0;
|
||||
CHAR16 wSectorName[ 128 ];
|
||||
|
||||
@@ -1138,7 +1138,7 @@ void RemoveRandomItemsInSector( INT16 sSectorX, INT16 sSectorY, INT16 sSectorZ,
|
||||
return;
|
||||
}
|
||||
|
||||
pItemList = new WORLDITEM[ uiNumberOfItems ];
|
||||
pItemList.resize(uiNumberOfItems);//dnl ch75 271013
|
||||
|
||||
// now load items
|
||||
LoadWorldItemsFromTempItemFile( sSectorX, sSectorY, ( UINT8 )sSectorZ, pItemList );
|
||||
@@ -1167,9 +1167,6 @@ void RemoveRandomItemsInSector( INT16 sSectorX, INT16 sSectorY, INT16 sSectorZ,
|
||||
{
|
||||
AddWorldItemsToUnLoadedSector( sSectorX, sSectorY, ( UINT8 )sSectorZ, 0, uiNumberOfItems, pItemList, TRUE );
|
||||
}
|
||||
|
||||
// mem free
|
||||
delete[]( pItemList );
|
||||
}
|
||||
else // handle a loaded sector
|
||||
{
|
||||
|
||||
@@ -209,6 +209,8 @@ void AddExtraItems(UINT8 x, UINT8 y, UINT8 z, bool sectorIsLoaded)
|
||||
}
|
||||
|
||||
strcat(fileName, ".xml");
|
||||
if(!FileExists(fileName))//dnl ch75 261013 just to avoid sdd::exception under debug from VFS when file not exist
|
||||
return;
|
||||
|
||||
// Open extra items file
|
||||
HWFILE hFile;
|
||||
|
||||
+41
-2
@@ -7394,8 +7394,29 @@ void GetMapKeyboardInput( UINT32 *puiNewEvent )
|
||||
case ')':
|
||||
SelectAllCharactersInSquad( 19 ); // internal squad #s start at 0
|
||||
break;
|
||||
|
||||
|
||||
case '\''://dnl ch75 021113
|
||||
#ifdef _DEBUG
|
||||
// temporary add soldiers to your list for equipment inspection and general testing
|
||||
for(UINT32 ubLoop=0; ubLoop<guiNumMercSlots&&gGameExternalOptions.fEnableInventoryPoolQ; ubLoop++)
|
||||
{
|
||||
if(MercSlots[ubLoop] != NULL && MercSlots[ubLoop]->bTeam == ENEMY_TEAM && MercSlots[ubLoop]->bActive)
|
||||
{
|
||||
for(int i=0; i<CODE_MAXIMUM_NUMBER_OF_PLAYER_SLOTS; i++)
|
||||
{
|
||||
if(gCharactersList[i].usSolID == MercSlots[ubLoop]->ubID)
|
||||
break;
|
||||
if(gCharactersList[i].usSolID == 0 && gCharactersList[i].fValid == FALSE)
|
||||
{
|
||||
gCharactersList[i].usSolID = MercSlots[ubLoop]->ubID;
|
||||
gCharactersList[i].fValid = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
fTeamPanelDirty = TRUE;
|
||||
#endif
|
||||
break;
|
||||
case 'a':
|
||||
if( fAlt )
|
||||
{
|
||||
@@ -7881,6 +7902,24 @@ void GetMapKeyboardInput( UINT32 *puiNewEvent )
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
case 'Q'://dnl ch75 021113
|
||||
#ifdef _DEBUG
|
||||
extern UINT8 gInventoryPoolIndex;
|
||||
if(fShowMapInventoryPool == TRUE && gInventoryPoolIndex == '0')
|
||||
{
|
||||
if(gGameExternalOptions.fEnableInventoryPoolQ)
|
||||
{
|
||||
gGameExternalOptions.fEnableInventoryPoolQ = FALSE;
|
||||
ScreenMsg(FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"InventoryPoolQ disabled.");
|
||||
}
|
||||
else
|
||||
{
|
||||
gGameExternalOptions.fEnableInventoryPoolQ = TRUE;
|
||||
ScreenMsg(FONT_MCOLOR_LTYELLOW, MSG_INTERFACE, L"InventoryPoolQ enabled.");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
case 'r':
|
||||
if( gfPreBattleInterfaceActive )
|
||||
{ //activate autoresolve in prebattle interface.
|
||||
|
||||
Reference in New Issue
Block a user