New LUA functions: via GetModderLUAFact and SetModderLUAFact, a modder can set up to 1000 INT32 values exclusively in LUA scripts. This can be used to store mod-specific data in save games without additional code required

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@8276 3b4a5df2-a311-0410-b5c6-a8a6f20db521
This commit is contained in:
Flugente
2016-07-26 20:44:42 +00:00
parent ab554b937c
commit 7b6f3d8441
7 changed files with 308 additions and 118 deletions
+40 -1
View File
@@ -60,6 +60,9 @@ extern SOLDIERTYPE * gpDestSoldier;
UINT8 gubQuest[MAX_QUESTS];
UINT8 gubFact[ NUM_FACTS ]; // this has to be updated when we figure out how many facts we have
// Flugente: we save and load this array. It is to be used exclusively by modders, who can set this in lua scripts
INT32 gubModderLuaData[MODDER_LUA_DATA_MAX]; // this has to be updated when we figure out how many facts we have
INT16 gsFoodQuestSectorX;
INT16 gsFoodQuestSectorY;
@@ -1578,6 +1581,8 @@ void InitQuestEngine()
gubBoxingMatchesWon = 0;
gubBoxersRests = 0;
gfBoxersResting = FALSE;
InitLUAModderData( );
}
@@ -1643,7 +1648,6 @@ BOOLEAN SaveQuestInfoToSavedGameFile( HWFILE hFile )
return(FALSE);
}
return( TRUE );
}
@@ -1671,6 +1675,41 @@ BOOLEAN LoadQuestInfoFromSavedGameFile( HWFILE hFile, UINT8 MaxQuest )
return( TRUE );
}
// Flugente: a huge array that can be used exclusively by modders
BOOLEAN SaveLUAModderDataToSavedGameFile( HWFILE hFile )
{
UINT32 uiNumBytesWritten;
//Save all the states for the facts
FileWrite( hFile, gubModderLuaData, sizeof(INT32)* MODDER_LUA_DATA_MAX, &uiNumBytesWritten );
if ( uiNumBytesWritten != sizeof(INT32)* MODDER_LUA_DATA_MAX )
{
return(FALSE);
}
return(TRUE);
}
BOOLEAN LoadLUAModderDataFromSavedGameFile( HWFILE hFile )
{
UINT32 uiNumBytesRead;
//Save all the states for the facts
FileRead( hFile, gubModderLuaData, sizeof(INT32)* MODDER_LUA_DATA_MAX, &uiNumBytesRead );
if ( uiNumBytesRead != sizeof(INT32)* MODDER_LUA_DATA_MAX )
{
return(FALSE);
}
return(TRUE);
}
void InitLUAModderData( )
{
memset( gubModderLuaData, 0, sizeof(gubModderLuaData) );
}
// SANDRO - a function to add quest-done point to merc records, and award some exp possibly
void GiveQuestRewardPoint( INT16 sQuestSectorX, INT16 sQuestsSectorY, INT8 bExpReward, UINT8 bException )
{