From b150bd172c8d36ec0bdab3c6114844df321577b4 Mon Sep 17 00:00:00 2001 From: Wanne Date: Sun, 15 Apr 2012 23:45:41 +0000 Subject: [PATCH] - Temporary disabled the Encyclopedia, because it seems it takes up a huge amount of virtual/committed memory (~ 2 GB) (by tazpn) o A define ENABLE_ENCYCLOPEDIA defines, if the encyclopedia code should be compiled o What is happening here is encyclopedia has a lot of really big structures (ENCYCLOPEDIA_LOCATION) and then a lot of arrays of size NUM_SECTOR, NUM_PROFILES, NUMITEMS which are fairly sizable themselves. o What the problem with doing this is when you need to allocate memory it typically needs to go to virtual memory to get large blocks of memory (malloc and related routines all do this) but you only have 2GB worth of virtual space as a pointer is 32 bits and user mode gets half of that 00000000-7FFFFFFF for addressing. This statically allocated space is taking up 7/8ths of the virtual address space. When animations or maps need to be loaded there might not be enough virtual space left due to fragmentation. o To see the amount of committed memory, open TaskManager and add the "Committed Memory" column to the view git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@5212 3b4a5df2-a311-0410-b5c6-a8a6f20db521 --- GameSettings.cpp | 4 +++ Init.cpp | 3 ++- Laptop/Encyclopedia.cpp | 49 ++++++++++++++++++++++++++++----- Laptop/Encyclopedia.h | 26 ++++-------------- Laptop/Encyclopedia_Data.cpp | 52 +++++++++++++++++++++++++++++------- TacticalAI/NPC.cpp | 2 +- 6 files changed, 98 insertions(+), 38 deletions(-) diff --git a/GameSettings.cpp b/GameSettings.cpp index 009bfd2e..4ecbf426 100644 --- a/GameSettings.cpp +++ b/GameSettings.cpp @@ -1451,7 +1451,11 @@ void LoadGameExternalOptions() //################# Laptop Settings ################## gGameExternalOptions.gBriefingRoom = iniReader.ReadBoolean("Laptop Settings", "BRIEFING_ROOM", FALSE); +#ifdef ENABLE_ENCYCLOPEDIA gGameExternalOptions.gEncyclopedia = iniReader.ReadBoolean("Laptop Settings", "ENCYCLOPEDIA", FALSE); +#else + gGameExternalOptions.gEncyclopedia = FALSE; +#endif gGameExternalOptions.fDisableLaptopTransition = iniReader.ReadBoolean("Laptop Settings", "DISABLE_LAPTOP_TRANSITION", FALSE); gGameExternalOptions.fFastWWWSitesLoading = iniReader.ReadBoolean("Laptop Settings", "FAST_WWW_SITES_LOADING", FALSE); diff --git a/Init.cpp b/Init.cpp index f4f35d88..640757ca 100644 --- a/Init.cpp +++ b/Init.cpp @@ -1016,6 +1016,7 @@ if ( ReadXMLEmail == TRUE ) } #endif +#ifdef ENABLE_ENCYCLOPEDIA //encyklopedia strcpy(fileName, directoryName); strcat(fileName, ENCYCLOPEDIALOCATIONFILENAME); @@ -1086,7 +1087,7 @@ if ( ReadXMLEmail == TRUE ) SGP_THROW_IFFALSE(ReadInEncyclopediaLocation(fileName,TRUE,gBriefingRoomData, 4), fileName); } #endif - +#endif //ENABLE_ENCYCLOPEDIA UINT8 p; for(p=0; puiFlags &= (~BUTTON_CLICKED_ON ); } +#endif // ENABLE_ENCYCLOPEDIA } void SelectEncyclopediaLocationRegionCallBack(GUI_BUTTON * btn, INT32 reason ) -{ +{ +#ifdef ENABLE_ENCYCLOPEDIA UINT8 ubRetValue = (UINT8)MSYS_GetBtnUserData( btn, 0 ); if(reason & MSYS_CALLBACK_REASON_LBUTTON_DWN ) @@ -1758,10 +1783,12 @@ void SelectEncyclopediaLocationRegionCallBack(GUI_BUTTON * btn, INT32 reason ) btn->uiFlags &= (~BUTTON_CLICKED_ON ); } +#endif // ENABLE_ENCYCLOPEDIA } void SelectFiltrButtonsRegionCallBack(GUI_BUTTON * btn, INT32 reason ) -{ +{ +#ifdef ENABLE_ENCYCLOPEDIA UINT8 ubRetValue = (UINT8)MSYS_GetBtnUserData( btn, 0 ); if(reason & MSYS_CALLBACK_REASON_LBUTTON_DWN ) @@ -2183,10 +2210,12 @@ void SelectFiltrButtonsRegionCallBack(GUI_BUTTON * btn, INT32 reason ) btn->uiFlags &= (~BUTTON_CLICKED_ON ); } +#endif // ENABLE_ENCYCLOPEDIA } void SelectInventoryFiltrButtonsRegionCallBack(GUI_BUTTON * btn, INT32 reason ) -{ +{ +#ifdef ENABLE_ENCYCLOPEDIA UINT8 ubRetValue = (UINT8)MSYS_GetBtnUserData( btn, 0 ); if(reason & MSYS_CALLBACK_REASON_LBUTTON_DWN ) @@ -2605,11 +2634,13 @@ void SelectInventoryFiltrButtonsRegionCallBack(GUI_BUTTON * btn, INT32 reason ) btn->uiFlags &= (~BUTTON_CLICKED_ON ); } +#endif // ENABLE_ENCYCLOPEDIA } void SelectSoundButtonsRegionCallBack(GUI_BUTTON * btn, INT32 reason ) -{ +{ +#ifdef ENABLE_ENCYCLOPEDIA UINT8 ubRetValue = (UINT8)MSYS_GetBtnUserData( btn, 0 ); CHAR8 str[MAX_ENCYCLOPEDIA_CHARS]; @@ -2710,6 +2741,7 @@ void SelectSoundButtonsRegionCallBack(GUI_BUTTON * btn, INT32 reason ) btn->uiFlags &= (~BUTTON_CLICKED_ON ); } +#endif // ENABLE_ENCYCLOPEDIA } //-------------------------------------------------------------- @@ -2717,6 +2749,7 @@ void SelectSoundButtonsRegionCallBack(GUI_BUTTON * btn, INT32 reason ) BOOLEAN SaveEncyclopediaToSaveGameFile( HWFILE hFile ) { +#ifdef ENABLE_ENCYCLOPEDIA UINT32 uiNumBytesWritten; UINT32 i; @@ -2807,12 +2840,13 @@ BOOLEAN SaveEncyclopediaToSaveGameFile( HWFILE hFile ) { return( FALSE ); } - +#endif // ENABLE_ENCYCLOPEDIA return( TRUE ); } BOOLEAN LoadEncyclopediaFromLoadGameFile( HWFILE hFile ) { +#ifdef ENABLE_ENCYCLOPEDIA UINT32 uiNumBytesRead; UINT32 i; @@ -2902,7 +2936,7 @@ BOOLEAN LoadEncyclopediaFromLoadGameFile( HWFILE hFile ) { gEncyclopediaOldProfilesData[ i ].Hidden = saveEncyclopediaOldProfilesData[i]; } - +#endif // ENABLE_ENCYCLOPEDIA return( TRUE ); } diff --git a/TacticalAI/NPC.cpp b/TacticalAI/NPC.cpp index dad0dc08..6575568c 100644 --- a/TacticalAI/NPC.cpp +++ b/TacticalAI/NPC.cpp @@ -1861,7 +1861,7 @@ void Converse( UINT8 ubNPC, UINT8 ubMerc, INT8 bApproach, UINT32 uiApproachData if (zHiddenNames[ubNPC].Hidden == TRUE) { zHiddenNames[ubNPC].Hidden = FALSE; - gEncyclopediaProfilesData[ubNPC].Hidden = TRUE; //encyclopedia + ShowNPCEncyclopediaEntry(ubNPC, TRUE); }