- 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
This commit is contained in:
Wanne
2012-04-15 23:45:41 +00:00
parent 6a24e04bbc
commit b150bd172c
6 changed files with 98 additions and 38 deletions
+4
View File
@@ -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);
+2 -1
View File
@@ -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; p<NUM_PROFILES; p++)
+43 -6
View File
@@ -19,6 +19,7 @@
#include "Encyclopedia_Data.h"
#include "Encyclopedia.h"
// Link Images
#define ENCYCLOPEDIA_BUTTON_SIZE_X 205
#define ENCYCLOPEDIA_BUTTON_SIZE_Y 19
@@ -70,6 +71,8 @@ BOOLEAN fFirstTimeInEncyclopedia = TRUE;
BOOLEAN DrawEncyclopediaLogoAim();
#ifdef ENABLE_ENCYCLOPEDIA
ENCYCLOPEDIA_LOCATION gEncyclopediaLocationData[ NUM_SECTOR ];
ENCYCLOPEDIA_LOCATION gEncyclopediaDataTemp[ NUM_MAX_TEMP ];
ENCYCLOPEDIA_LOCATION gEncyclopediaProfilesData[ NUM_PROFILES ];
@@ -89,6 +92,13 @@ MISSION_SAVE saveBriefingRoomSpecialMissionData[ NUM_SECTOR ];
MISSION_SAVE saveMissionData[ NUM_SECTOR ];
#else // ENABLE_ENCYCLOPEDIA
ENCYCLOPEDIA_LOCATION gEncyclopediaProfilesData[ 1 ];
ENCYCLOPEDIA_LOCATION gBriefingRoomData[ 1 ];
#endif // ENABLE_ENCYCLOPEDIA
void GameInitEncyclopedia()
{
LaptopInitEncyclopedia();
@@ -96,6 +106,7 @@ void GameInitEncyclopedia()
BOOLEAN EnterEncyclopedia()
{
#ifdef ENABLE_ENCYCLOPEDIA
VOBJECT_DESC VObjectDesc;
UINT16 i, usPosY;
@@ -140,7 +151,7 @@ BOOLEAN EnterEncyclopedia()
fFirstTimeInEncyclopedia = FALSE;
RenderEncyclopedia();
#endif // ENABLE_ENCYCLOPEDIA
return( TRUE );
}
@@ -161,6 +172,7 @@ void InitEncyklopediaBool()
void ExitEncyclopedia()
{
#ifdef ENABLE_ENCYCLOPEDIA
UINT16 i;
//InitEncyklopediaBool();
@@ -175,6 +187,7 @@ void ExitEncyclopedia()
MSYS_RemoveRegion( &gSelectedEncyclopediaTocMenuRegion[i]);
//guiCurrentLaptopMode = LAPTOP_MODE_NONE;
#endif // ENABLE_ENCYCLOPEDIA
}
void HandleEncyclopedia()
@@ -184,6 +197,7 @@ void HandleEncyclopedia()
void RenderEncyclopedia()
{
#ifdef ENABLE_ENCYCLOPEDIA
UINT16 i, usPosY;
UINT16 usHeight;
HVOBJECT hContentButtonHandle;
@@ -216,10 +230,12 @@ void RenderEncyclopedia()
//InitEncyklopediaBool();
InvalidateRegion(LAPTOP_SCREEN_UL_X,LAPTOP_SCREEN_WEB_UL_Y,LAPTOP_SCREEN_LR_X,LAPTOP_SCREEN_WEB_LR_Y);
#endif // ENABLE_ENCYCLOPEDIA
}
void SelectEncyclopediaLocationButton(MOUSE_REGION * pRegion, INT32 iReason )
{
{
#ifdef ENABLE_ENCYCLOPEDIA
if (iReason & MSYS_CALLBACK_REASON_INIT)
{
@@ -242,10 +258,12 @@ void SelectEncyclopediaLocationButton(MOUSE_REGION * pRegion, INT32 iReason )
else if (iReason & MSYS_CALLBACK_REASON_RBUTTON_UP)
{
}
#endif // ENABLE_ENCYCLOPEDIA
}
void SelectEncyclopediaCharacterButton(MOUSE_REGION * pRegion, INT32 iReason )
{
{
#ifdef ENABLE_ENCYCLOPEDIA
if (iReason & MSYS_CALLBACK_REASON_INIT)
{
@@ -268,10 +286,12 @@ void SelectEncyclopediaCharacterButton(MOUSE_REGION * pRegion, INT32 iReason )
else if (iReason & MSYS_CALLBACK_REASON_RBUTTON_UP)
{
}
#endif // ENABLE_ENCYCLOPEDIA
}
void SelectEncyclopediaQuestsButton(MOUSE_REGION * pRegion, INT32 iReason )
{
{
#ifdef ENABLE_ENCYCLOPEDIA
if (iReason & MSYS_CALLBACK_REASON_INIT)
{
}
@@ -293,10 +313,12 @@ void SelectEncyclopediaQuestsButton(MOUSE_REGION * pRegion, INT32 iReason )
else if (iReason & MSYS_CALLBACK_REASON_RBUTTON_UP)
{
}
#endif // ENABLE_ENCYCLOPEDIA
}
void SelectEncyclopediaInentoryButton(MOUSE_REGION * pRegion, INT32 iReason )
{
{
#ifdef ENABLE_ENCYCLOPEDIA
if (iReason & MSYS_CALLBACK_REASON_INIT)
{
}
@@ -318,10 +340,12 @@ void SelectEncyclopediaInentoryButton(MOUSE_REGION * pRegion, INT32 iReason )
else if (iReason & MSYS_CALLBACK_REASON_RBUTTON_UP)
{
}
#endif // ENABLE_ENCYCLOPEDIA
}
BOOLEAN InitEncyclopediaDefaults()
{
#ifdef ENABLE_ENCYCLOPEDIA
VOBJECT_DESC VObjectDesc;
// load the Rust bacground graphic and add it
@@ -330,30 +354,35 @@ BOOLEAN InitEncyclopediaDefaults()
FilenameForBPP("ENCYCLOPEDIA\\encyclopediabackground.sti", VObjectDesc.ImageFile);
CHECKF(AddVideoObject(&VObjectDesc, &guiRustEncyclopediaBackGround));
#endif // ENABLE_ENCYCLOPEDIA
return(TRUE);
}
BOOLEAN RemoveEncyclopediaDefaults()
{
#ifdef ENABLE_ENCYCLOPEDIA
DeleteVideoObjectFromIndex(guiRustEncyclopediaBackGround);
#endif // ENABLE_ENCYCLOPEDIA
return(TRUE);
}
BOOLEAN DrawEncyclopediaLogoAim()
{
#ifdef ENABLE_ENCYCLOPEDIA
HVOBJECT hLogoEncyklopedia;
// UINT16 x,y, uiPosX, uiPosY;
GetVideoObject(&hLogoEncyklopedia, guiRustEncyclopediaLogoAim);
BltVideoObject(FRAME_BUFFER, hLogoEncyklopedia, 0,ENCYCLOPEDIA_TOC_X, RUSTBACKGROUND_1_Y + 40, VO_BLT_SRCTRANSPARENCY,NULL);
#endif // ENABLE_ENCYCLOPEDIA
return(TRUE);
}
BOOLEAN DrawEncyclopediaDefaults()
{
#ifdef ENABLE_ENCYCLOPEDIA
HVOBJECT hRustBackGroundHandle;
// UINT16 x,y, uiPosX, uiPosY;
@@ -373,6 +402,7 @@ BOOLEAN DrawEncyclopediaDefaults()
uiPosY += RUSTBACKGROUND_SIZE_Y;
}
*/
#endif // ENABLE_ENCYCLOPEDIA
return(TRUE);
}
@@ -388,3 +418,10 @@ BOOLEAN DisplayEncyclopediaCopyright()
return(TRUE);
}
void ShowNPCEncyclopediaEntry(UINT8 ubNPC, BOOLEAN hidden)
{
#ifdef ENABLE_ENCYCLOPEDIA
gEncyclopediaProfilesData[ubNPC].Hidden = TRUE; //encyclopedia
#endif
}
+5 -21
View File
@@ -185,17 +185,6 @@ typedef struct
#define MISSIONSTART 1
#define MISSIONEND 2
extern ENCYCLOPEDIA_LOCATION gEncyclopediaLocationData[ NUM_SECTOR ];
extern ENCYCLOPEDIA_LOCATION gEncyclopediaProfilesData[ NUM_PROFILES ];
extern ENCYCLOPEDIA_LOCATION gEncyclopediaDataTemp[ NUM_MAX_TEMP ];
extern ENCYCLOPEDIA_LOCATION gEncyclopediaInventoryData[ MAXITEMS ];
extern ENCYCLOPEDIA_LOCATION gEncyclopediaOldProfilesData[ NUM_PROFILES ];
extern ENCYCLOPEDIA_LOCATION gEncyclopediaQuestsData[ MAX_QUESTS ];
extern ENCYCLOPEDIA_LOCATION gBriefingRoomData[ NUM_SECTOR ];
extern ENCYCLOPEDIA_LOCATION gBriefingRoomSpecialMissionData[ NUM_SECTOR ];
typedef struct
{
UINT32 uiIndex;
@@ -210,16 +199,11 @@ typedef struct
INT32 CheckMission;
} MISSION_SAVE;
//extern MISSION_SAVE saveMissionData[ NUM_SECTOR ];
extern BOOLEAN saveEncyclopediaLocationData[ NUM_SECTOR ];
extern ENCYCLOPEDIA_PROF_SAVE saveEncyclopediaProfilesData[ NUM_PROFILES ];
extern BOOLEAN saveEncyclopediaInventoryData[ MAXITEMS ];
extern BOOLEAN saveEncyclopediaOldProfilesData[ NUM_PROFILES ];
extern BOOLEAN saveEncyclopediaQuestsData[ MAX_QUESTS ];
extern MISSION_SAVE saveBriefingRoomData[ NUM_SECTOR ];
extern MISSION_SAVE saveBriefingRoomSpecialMissionData[ NUM_SECTOR ];
extern void InitEncyklopediaBool();
extern void ShowNPCEncyclopediaEntry(UINT8 ubNPC, BOOLEAN hidden);
extern ENCYCLOPEDIA_LOCATION gEncyclopediaProfilesData[];
extern ENCYCLOPEDIA_LOCATION gBriefingRoomData[];
#endif
+43 -9
View File
@@ -133,6 +133,8 @@ void GameInitEncyclopediaLocation()
void ResetTemp()
{
#ifdef ENABLE_ENCYCLOPEDIA
UINT32 i,NUM_TEMP;
if ( bEncyclopediaLocation == TRUE )
@@ -239,10 +241,12 @@ UINT32 i,NUM_TEMP;
}
#endif // ENABLE_ENCYCLOPEDIA
}
void CopyToTemp ( ENCYCLOPEDIA_LOCATION *Ency, BOOLEAN bFiltr, INT32 sort, INT32 TypFiltr, BOOLEAN ShowBox )
{
#ifdef ENABLE_ENCYCLOPEDIA
UINT32 i, NUM_TEMP;
INT32 IDClass;
BOOLEAN bBoxShow;
@@ -661,6 +665,7 @@ void CopyToTemp ( ENCYCLOPEDIA_LOCATION *Ency, BOOLEAN bFiltr, INT32 sort, INT32
ResetVal = TRUE;
//DoLapTopMessageBox( MSG_BOX_LAPTOP_DEFAULT, pSectorPageText[ 4 ], LAPTOP_SCREEN, MSG_BOX_FLAG_OK, NULL);
}
#endif // ENABLE_ENCYCLOPEDIA
}
/*
void InitLocationFiltrButtons()
@@ -856,6 +861,7 @@ BOOLEAN RenderFiltrBox()
void InitData ( BOOLEAN bInit)
{
#ifdef ENABLE_ENCYCLOPEDIA
IDimage = 1;
MaxImages = 1;
@@ -903,11 +909,12 @@ void InitData ( BOOLEAN bInit)
InitSoundButtons();
ResetVal = bInit;
#endif // ENABLE_ENCYCLOPEDIA
}
BOOLEAN EnterEncyclopediaLocation()
{
#ifdef ENABLE_ENCYCLOPEDIA
UINT16 usPosX, usPosY, i;
/*
IDimage = 1;
@@ -1020,7 +1027,9 @@ BOOLEAN EnterEncyclopediaLocation()
DisableButton( guiEncyclopediaLocationPageButton[2] );
RenderMap();
#endif // ENABLE_ENCYCLOPEDIA
return(TRUE);
}
@@ -1214,6 +1223,7 @@ void HandleEncyclopediaLocation()
void RenderButtonDisabled()
{
#ifdef ENABLE_ENCYCLOPEDIA
if ( gEncyclopediaDataTemp[LocationID].sDesc2 == '\0' && gEncyclopediaDataTemp[LocationID].sDesc3 == '\0' )
{
DisableButton( guiEncyclopediaPageButton[0] );
@@ -1223,32 +1233,40 @@ void RenderButtonDisabled()
{
EnableButton( guiEncyclopediaPageButton[2] );
}
#endif // ENABLE_ENCYCLOPEDIA
}
void RenderButtonDisabled2()
{
#ifdef ENABLE_ENCYCLOPEDIA
DisableButton( guiEncyclopediaPageButton[0] );
EnableButton( guiEncyclopediaPageButton[2] );
#endif // ENABLE_ENCYCLOPEDIA
}
void RenderButtonDisabled3()
{
#ifdef ENABLE_ENCYCLOPEDIA
DisableButton( guiEncyclopediaLocationPageButton[0] );
if ( MaxLocation == -1 || MaxLocation == 0 || MaxLocation == 1 )
DisableButton( guiEncyclopediaLocationPageButton[2] );
else
EnableButton( guiEncyclopediaLocationPageButton[2] );
#endif // ENABLE_ENCYCLOPEDIA
}
void RenderButtonDisabled4()
{
#ifdef ENABLE_ENCYCLOPEDIA
DisableButton( guiEncyclopediaPageButton[0] );
DisableButton( guiEncyclopediaPageButton[2] );
#endif // ENABLE_ENCYCLOPEDIA
}
void RenderBoxDisabledButton()
{
#ifdef ENABLE_ENCYCLOPEDIA
MaxImages = 1;
MaxLocation = 0;
IDimage = 1;
@@ -1260,10 +1278,12 @@ void RenderBoxDisabledButton()
DisableButton( guiEncyclopediaPageButton[0] );
DisableButton( guiEncyclopediaPageButton[1] );
DisableButton( guiEncyclopediaPageButton[2] );
#endif // ENABLE_ENCYCLOPEDIA
}
BOOLEAN RenderMap()
{
#ifdef ENABLE_ENCYCLOPEDIA
VOBJECT_DESC VObjectDesc;
char fileName[500];
@@ -1327,11 +1347,13 @@ BOOLEAN RenderMap()
// BltVideoObjectFromIndex( FRAME_BUFFER, gEncyclopediaDataTemp[LocationID].uiIndex, 0 , ENCYCLOPEDIA_LOCATION_BOX_X + 150 , ENCYCLOPEDIA_LOCATION_BOX_Y - 190, VO_BLT_SRCTRANSPARENCY, NULL );
}
*/
#endif // ENABLE_ENCYCLOPEDIA
return(TRUE);
}
void RenderEncyclopediaLocation( BOOLEAN bHidden )
{
#ifdef ENABLE_ENCYCLOPEDIA
UINT16 i;
UINT8 ubNumLines=11;
UINT16 usPosY;
@@ -1603,11 +1625,12 @@ void RenderEncyclopediaLocation( BOOLEAN bHidden )
//DoLapTopMessageBox( MSG_BOX_LAPTOP_DEFAULT, pSectorPageText[ 4 ], LAPTOP_SCREEN, MSG_BOX_FLAG_OK, NULL);
InvalidateRegion(LAPTOP_SCREEN_UL_X,LAPTOP_SCREEN_WEB_UL_Y,LAPTOP_SCREEN_LR_X,LAPTOP_SCREEN_WEB_LR_Y);
#endif // ENABLE_ENCYCLOPEDIA
}
void SelectEncyclopediaLocationPageRegionCallBack(GUI_BUTTON * btn, INT32 reason )
{
#ifdef ENABLE_ENCYCLOPEDIA
UINT8 ubRetValue = (UINT8)MSYS_GetBtnUserData( btn, 0 );
if(reason & MSYS_CALLBACK_REASON_LBUTTON_DWN )
@@ -1654,10 +1677,12 @@ void SelectEncyclopediaLocationPageRegionCallBack(GUI_BUTTON * btn, INT32 reason
{
btn->uiFlags &= (~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 );
}
+1 -1
View File
@@ -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);
}