Home » MODDING HQ 1.13 » v1.13 Coding Talk » [FIX] improve loading speed of stash
[FIX] improve loading speed of stash[message #325332]
|
Wed, 18 September 2013 09:59
|
|
Moa |
|
Messages:58
Registered:September 2013 |
|
|
Loading time to show sector stash especially in debugversion whith active debuging is high. In release version you might as well notice a delay whenever you access a stash with several items.
This is caused by multiple file loads to get again and again some countings of active (visible and existing) items and total number of items. In addition the stash is loaded and saved (again with several reads/writes) to update the decay.
Closing stash, saving and loading temporary files when loading a saved had the same problems.
As of today only the loading of the stash has been improved, closing the stash is different kettle of fish.
fixed that.
EDIT: opening & closing for stash and savegame loading speed improved. >>> LoadingSpeed-saveGameCompatible4.patch <<<
Known issues:
1. Inventory of mercs are repeatedly recalculated under time compression but almost no items decay. This is due to the calling of the recalculation: once in a while the function HandleStrategicTurn() calls indirectly SOLDIER::SoldierInventoryCoolDown(void). It gets called on real time seconds passed and not on game seconds passed.
Therefore I dont think this issue is related to the changes in this patch.
2. Moving items feature assumes that when removing items from one sector to another both sectors have updated items - this is not the case using this patch. But it was also not the case before the changes.
The reason is you could not even check if the sector had been updated correctly.
Toggle Spoiler
To illustrate the following scenario, but do not access stash by doing this you update the timestamps before patch
and you dont update timestamps after patch.
-Have merc in sector B ready to move some items
-enter sector B and note down dirt% of item1 (e.g.: 6.58)
-enter sector A and note down dirt% of item2 (e.g.: 6.58)
-save game (to have some base)
-compress time to some day after (A and B have equal timestamps A, note down time!!)
-Load A and B and write down item1/2 again (e.g.: 6.82/8.65)
-Now reload savegame
-enter some random map
-enter sector A (gets time stamp A item1 has 6.58 as suspected)
-compress time to the same time as before.
-enter sector B and write down item2 (A and B have different timestamps, item2 has 8.65 as suspected)
Order merc in B to collect items in A
compress again until merc have moved item1.
enter sector B and compare status of item1 (has 6.73 after patch and 6.73 before patch).
There is an issue with the timestamps, this is however not related to the patch (tested 6394 with 6401+patch above).
[Updated on: Sat, 21 September 2013 00:02] by Moderator Report message to a moderator
|
Corporal
|
|
|
|
|
|
|
|
|
|
|
Re: [WIP] improve loading speed of stash[message #325932]
|
Sun, 29 September 2013 19:10
|
|
Moa |
|
Messages:58
Registered:September 2013 |
|
|
Glad to hear it works with more then one page of items.
Sorry for the CTD when loading an empty stash in the original commit. Somehow I just tested sectors with lots of items - stuppid me.
Another issue exists when mouse is over an item the game frequently (100us) renders all items again in order to show compatible items highlighted. Those recalculations dont need to be done since the state does not change: mouse is still over an item, no need to recalc and rerender everything over and over again. Also maybe one noticed that highlighting does not work allways correctly when moving the mouse fast enough or just in a 'bad' time over a different item.
For sector stash it was strait forward, as there is only one function and one mousecallback. Soldier inventory is more complicated as it is called in various routines (at least 5) and mouseCB's (3). So I had to cheat here to reduce the calls without messing in all those functions.
/brief: reduces render calls when mouse over compatible item in stash and soldier inventory (highlighting).
http://www.file-upload.net/download-8126058/MouseOver_Item_in_inventory_performance.patch.html
Toggle Spoiler
Index: Strategic/Map Screen Interface Map Inventory.cpp
===================================================================
--- Strategic/Map Screen Interface Map Inventory.cpp (revision 6450)
+++ Strategic/Map Screen Interface Map Inventory.cpp (working copy)
@@ -178,7 +178,7 @@
WORLDITEM *pSaveList = NULL;
INT32 giFlashHighlightedItemBaseTime = 0;
-INT32 giCompatibleItemBaseTime = 0;
+//INT32 giCompatibleItemBaseTime = 0;//Moa: removed (see HandleMouseInCompatableItemForMapSectorInventory)
// the buttons and images
// HEADROCK HAM 5: Increased for new inventory buttons
@@ -1133,11 +1133,13 @@
INT16 sXA = 0, sYA = 0;
INT16 sULX = 0, sULY = 0;
INT16 sBRX = 0, sBRY = 0;
+ extern MOUSE_REGION gMapViewRegion;
+ //Moa: removed MapInventoryPoolMask, instead we disable map mouseregion and enable again when deleting stash regions
+ MSYS_DisableRegion( &gMapViewRegion );
+ //MSYS_DefineRegion( &MapInventoryPoolMask,
+ // MAP_INVENTORY_POOL_SLOT_START_X, 0, SCREEN_WIDTH - MAP_INVENTORY_POOL_SLOT_START_X, SCREEN_HEIGHT - 120,
+ // MSYS_PRIORITY_HIGH, MSYS_NO_CURSOR, MSYS_NO_CALLBACK, MapInvenPoolScreenMaskCallback);
- MSYS_DefineRegion( &MapInventoryPoolMask,
- MAP_INVENTORY_POOL_SLOT_START_X, 0, SCREEN_WIDTH - MAP_INVENTORY_POOL_SLOT_START_X, SCREEN_HEIGHT - 120,
- MSYS_PRIORITY_HIGH, MSYS_NO_CURSOR, MSYS_NO_CALLBACK, MapInvenPoolScreenMaskCallback);
-
for( iCounter = 0; iCounter < MAP_INVENTORY_POOL_SLOT_COUNT; iCounter++ )
{
sX = ( iCounter / MAP_INV_SLOT_COLS );
@@ -1168,6 +1170,7 @@
void DestroyMapInventoryPoolSlots( void )
{
INT32 iCounter = 0;
+ extern MOUSE_REGION gMapViewRegion;
for( iCounter = 0; iCounter < MAP_INVENTORY_POOL_SLOT_COUNT; iCounter++ )
{
@@ -1175,8 +1178,8 @@
}
// remove map inventory mask
- MSYS_RemoveRegion( &MapInventoryPoolMask );
-
+ //MSYS_RemoveRegion( &MapInventoryPoolMask );
+ MSYS_EnableRegion( &gMapViewRegion );
}
void MapInvenPoolSlotsMove( MOUSE_REGION * pRegion, INT32 iReason )
@@ -3459,11 +3462,14 @@
}
}
+
+//Moa 09/26/2013: now only processed if mouse over different slot then before (using fChangedInventorySlots)
+// change preprocessor directive to 1 and uncomment any giCompatibleItemBaseTime in TimerControl.cpp and in this file if original Sirtech code should be used.
void HandleMouseInCompatableItemForMapSectorInventory( INT32 iCurrentSlot )
{
SOLDIERTYPE *pSoldier = NULL;
static BOOLEAN fItemWasHighLighted = FALSE;
-
+#if 0
if( iCurrentSlot == -1 )
{
giCompatibleItemBaseTime = 0;
@@ -3501,10 +3507,38 @@
{
return;
}
+#else
+ //if same slot then before dont recalculate
+ if ( !fChangedInventorySlots ) return;
+
+ //reset highlightings for soldier inventory and stash if it was highlighted before
+ if ( fItemWasHighLighted )
+ {
+ ResetCompatibleItemArray( );
+ ResetMapSectorInventoryPoolHighLights( );
+ }
+
+ //Nothing selected or out of bounds or empty slot selected; highlightings reseted already, return
+ if ( iCurrentSlot == NO_SLOT ||
+ (pInventoryPoolList.size() < (UINT32)(iCurrentSlot + ( iCurrentInventoryPoolPage * MAP_INVENTORY_POOL_SLOT_COUNT ) )) ||
+ pInventoryPoolList[ iCurrentSlot + iCurrentInventoryPoolPage * MAP_INVENTORY_POOL_SLOT_COUNT ].fExists == FALSE )
+ {
+ fChangedInventorySlots = FALSE;
+ if (fItemWasHighLighted)
+ {
+ fTeamPanelDirty = TRUE;
+ fMapPanelDirty = TRUE;
+ fItemWasHighLighted = FALSE;
+ }
+ return;
+ }
+#endif
+
// given this slot value, check if anything in the displayed sector inventory or on the mercs inventory is compatable
if( fShowInventoryFlag )
{
+#if 0
// check if any compatable items in the soldier inventory matches with this item
if( gfCheckForCursorOverMapSectorInventoryItem )
{
@@ -3528,6 +3562,18 @@
{
giCompatibleItemBaseTime = 0;
}
+#else
+ //Soldier inventory is shown, highlight those items
+ pSoldier = &Menptr[ gCharactersList[ bSelectedInfoChar ].usSolID ];
+ if( pSoldier )
+ {
+ if( HandleCompatibleAmmoUIForMapScreen( pSoldier, iCurrentSlot + ( iCurrentInventoryPoolPage * MAP_INVENTORY_POOL_SLOT_COUNT ), TRUE, FALSE ) )
+ {
+ fItemWasHighLighted = TRUE;//remember that something is highlighted
+ }
+ fTeamPanelDirty = TRUE;
+ }
+#endif
}
@@ -3534,6 +3580,7 @@
// now handle for the sector inventory
if( fShowMapInventoryPool )
{
+#if 0
// check if any compatable items in the soldier inventory matches with this item
if( gfCheckForCursorOverMapSectorInventoryItem )
{
@@ -3553,9 +3600,16 @@
{
giCompatibleItemBaseTime = 0;
}
+#else
+ if( HandleCompatibleAmmoUIForMapInventory( pSoldier, iCurrentSlot, ( iCurrentInventoryPoolPage * MAP_INVENTORY_POOL_SLOT_COUNT ) , TRUE, FALSE ) )
+ {
+ fItemWasHighLighted = TRUE;//remember that something is highlighted
+ }
+ fMapPanelDirty = TRUE;
+#endif
}
+ fChangedInventorySlots = FALSE;
-
return;
}
Index: Tactical/Interface Items.cpp
===================================================================
--- Tactical/Interface Items.cpp (revision 6450)
+++ Tactical/Interface Items.cpp (working copy)
@@ -3123,6 +3123,26 @@
OBJECTTYPE *pObject;
BOOLEAN fFoundAttachment = FALSE;
+ //Moa 09/26/2013: this is a hack to avoid frequent recalc and rerender of screen when mouse is over an item, its less work and less error prone then rewriting several functions (various mousecallbacks, >4 renderfunctions and probalby some others too)
+ static OBJECTTYPE* previousObject = NULL;
+ //dont recalc when same item then before
+ if (pTestObject == previousObject && fOn)
+ {
+ return FALSE;//nothing to rerender
+ }
+ else if ( fOn )
+ {
+ previousObject = pTestObject;
+ //make something dirty?
+ fInterfacePanelDirty = DIRTYLEVEL2;
+ fTeamPanelDirty = TRUE;
+ }
+ else
+ {
+ previousObject = NULL;
+ }
+ //end hack
+
// ATE: If pTest object is NULL, test only for existence of syringes, etc...
if ( pTestObject == NULL )
{
Index: Utils/Timer Control.cpp
===================================================================
--- Utils/Timer Control.cpp (revision 6450)
+++ Utils/Timer Control.cpp (working copy)
@@ -121,7 +121,7 @@
extern UINT32 guiCompressionStringBaseTime;
extern INT32 giFlashHighlightedItemBaseTime;
-extern INT32 giCompatibleItemBaseTime;
+//extern INT32 giCompatibleItemBaseTime;//Moa:removed (see HandleMouseInCompatableItemForMapSectorInventory)
extern INT32 giAnimateRouteBaseTime;
extern INT32 giPotHeliPathBaseTime;
extern INT32 giClickHeliIconBaseTime;
@@ -543,7 +543,7 @@
guiCompressionStringBaseTime = uiCurrentTime;
giFlashHighlightedItemBaseTime = uiCurrentTime;
- giCompatibleItemBaseTime = uiCurrentTime;
+ //giCompatibleItemBaseTime = uiCurrentTime;//Moa: removed (see HandleMouseInCompatableItemForMapSectorInventory)
giAnimateRouteBaseTime = uiCurrentTime;
giPotHeliPathBaseTime = uiCurrentTime;
giClickHeliIconBaseTime = uiCurrentTime;
Report message to a moderator
|
Corporal
|
|
|
|
Goto Forum:
Current Time: Sat Nov 30 11:09:46 GMT+2 2024
Total time taken to generate the page: 0.01272 seconds
|