Revert "Cache result of evaluating strategicmap.lua (#32)" (#293)

This reverts commit 8f22d13fd9.
This commit is contained in:
Asdow
2024-03-16 13:00:04 +02:00
committed by GitHub
parent 9dfbc7d394
commit bf01f87cb4
+15 -30
View File
@@ -13603,58 +13603,43 @@ static int l_GetNumHostilesInSector( lua_State *L )
void LuaGetIntelAndQuestMapData( INT32 aLevel ) void LuaGetIntelAndQuestMapData( INT32 aLevel )
{ {
static LuaScopeState _LS(true); const char* filename = "scripts\\strategicmap.lua";
static bool isInitialized = false;
LuaScopeState _LS( true );
// Initialize only once during lifetime of program
if (!isInitialized)
{
isInitialized = true;
IniFunction( _LS.L(), TRUE ); IniFunction( _LS.L(), TRUE );
IniGlobalGameSetting( _LS.L() ); IniGlobalGameSetting( _LS.L() );
const char* filename = "scripts\\strategicmap.lua";
SGP_THROW_IFFALSE(_LS.L.EvalFile(filename), _BS("Cannot open file: ") << filename << _BS::cget);
}
IniGlobalGameSetting(_LS.L()); SGP_THROW_IFFALSE( _LS.L.EvalFile( filename ), _BS( "Cannot open file: " ) << filename << _BS::cget );
LuaFunction( _LS.L, "GetIntelAndQuestMapData" ).Param<int>( aLevel ).Call( 1 ); LuaFunction( _LS.L, "GetIntelAndQuestMapData" ).Param<int>( aLevel ).Call( 1 );
} }
void SetFactoryLeftoverProgress( INT16 sSectorX, INT16 sSectorY, INT8 bSectorZ, UINT16 usFacilityType, UINT16 usProductionNumber, INT32 sProgressLeft ) void SetFactoryLeftoverProgress( INT16 sSectorX, INT16 sSectorY, INT8 bSectorZ, UINT16 usFacilityType, UINT16 usProductionNumber, INT32 sProgressLeft )
{ {
static LuaScopeState _LS(true); const char* filename = "scripts\\strategicmap.lua";
static bool isInitialized = false;
LuaScopeState _LS( true );
// Initialize only once during lifetime of program
if (!isInitialized)
{
isInitialized = true;
IniFunction( _LS.L(), TRUE ); IniFunction( _LS.L(), TRUE );
IniGlobalGameSetting( _LS.L() ); IniGlobalGameSetting( _LS.L() );
const char* filename = "scripts\\strategicmap.lua";
SGP_THROW_IFFALSE(_LS.L.EvalFile(filename), _BS("Cannot open file: ") << filename << _BS::cget);
}
IniGlobalGameSetting(_LS.L()); SGP_THROW_IFFALSE( _LS.L.EvalFile( filename ), _BS( "Cannot open file: " ) << filename << _BS::cget );
LuaFunction( _LS.L, "SetFactoryLeftoverProgress" ).Param<int>( sSectorX ).Param<int>( sSectorY ).Param<int>( bSectorZ ).Param<int>( usFacilityType ).Param<int>( usProductionNumber ).Param<int>( sProgressLeft ).Call( 6 ); LuaFunction( _LS.L, "SetFactoryLeftoverProgress" ).Param<int>( sSectorX ).Param<int>( sSectorY ).Param<int>( bSectorZ ).Param<int>( usFacilityType ).Param<int>( usProductionNumber ).Param<int>( sProgressLeft ).Call( 6 );
} }
INT32 GetFactoryLeftoverProgress( INT16 sSectorX, INT16 sSectorY, INT8 bSectorZ, UINT16 usFacilityType, UINT16 usProductionNumber ) INT32 GetFactoryLeftoverProgress( INT16 sSectorX, INT16 sSectorY, INT8 bSectorZ, UINT16 usFacilityType, UINT16 usProductionNumber )
{ {
static LuaScopeState _LS( true ); const char* filename = "scripts\\strategicmap.lua";
static bool isInitialized = false;
LuaScopeState _LS( true );
// Initialize only once during lifetime of program
if (!isInitialized)
{
isInitialized = true;
IniFunction( _LS.L(), TRUE ); IniFunction( _LS.L(), TRUE );
IniGlobalGameSetting( _LS.L() ); IniGlobalGameSetting( _LS.L() );
const char* filename = "scripts\\strategicmap.lua";
SGP_THROW_IFFALSE( _LS.L.EvalFile( filename ), _BS( "Cannot open file: " ) << filename << _BS::cget );
}
IniGlobalGameSetting(_LS.L()); SGP_THROW_IFFALSE( _LS.L.EvalFile( filename ), _BS( "Cannot open file: " ) << filename << _BS::cget );
LuaFunction( _LS.L, "GetFactoryLeftoverProgress" ).Param<int>( sSectorX ).Param<int>( sSectorY ).Param<int>( bSectorZ ).Param<int>( usFacilityType ).Param<int>( usProductionNumber ).Call( 5 ); LuaFunction( _LS.L, "GetFactoryLeftoverProgress" ).Param<int>( sSectorX ).Param<int>( sSectorY ).Param<int>( bSectorZ ).Param<int>( usFacilityType ).Param<int>( usProductionNumber ).Call( 5 );
if ( lua_gettop( _LS.L() ) >= 0 ) if ( lua_gettop( _LS.L() ) >= 0 )