Skip to content

Commit

Permalink
Updated for the latest Garry's Mod update.
Browse files Browse the repository at this point in the history
  • Loading branch information
danielga committed Apr 18, 2017
1 parent 64f6f06 commit 80ad68e
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 28 deletions.
6 changes: 3 additions & 3 deletions source/filecheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ LUA_FUNCTION_STATIC( EnableFileValidation )
return 1;
}

void Initialize( lua_State *state )
void Initialize( GarrysMod::Lua::ILuaBase *LUA )
{
lua_interface = static_cast<GarrysMod::Lua::ILuaInterface *>( LUA );

Expand All @@ -235,15 +235,15 @@ void Initialize( lua_State *state )
LUA->ThrowError( "unable to sigscan for CNetChan::IsValidFileForTransfer" );
}

int32_t PostInitialize( lua_State *state )
int32_t PostInitialize( GarrysMod::Lua::ILuaBase *LUA )
{
LUA->PushCFunction( EnableFileValidation );
LUA->SetField( -2, "EnableFileValidation" );

return 0;
}

void Deinitialize( lua_State * )
void Deinitialize( GarrysMod::Lua::ILuaBase * )
{
if( IsValidFileForTransfer != nullptr )
{
Expand Down
14 changes: 10 additions & 4 deletions source/filecheck.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,19 @@

#include <stdint.h>

struct lua_State;
namespace GarrysMod
{
namespace Lua
{
class ILuaBase;
}
}

namespace filecheck
{

void Initialize( lua_State *state );
int32_t PostInitialize( lua_State *state );
void Deinitialize( lua_State *state );
void Initialize( GarrysMod::Lua::ILuaBase *LUA );
int32_t PostInitialize( GarrysMod::Lua::ILuaBase *LUA );
void Deinitialize( GarrysMod::Lua::ILuaBase *LUA );

}
28 changes: 14 additions & 14 deletions source/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ LUA_FUNCTION_STATIC( PostInitialize )
if( !LUA->IsType( -1, GarrysMod::Lua::Type::TABLE ) )
LUA->ThrowError( "EVEN NOW, THE EVIL SEED OF WHAT YOU'VE DONE GERMINATES WITHIN YOU" );

int32_t nrets = netfilter::PostInitialize( state );
int32_t nrets = netfilter::PostInitialize( LUA );
if( nrets != 0 )
return nrets;

nrets = filecheck::PostInitialize( state );
nrets = filecheck::PostInitialize( LUA );
if( nrets != 0 )
return nrets;

Expand All @@ -53,18 +53,18 @@ LUA_FUNCTION_STATIC( PostInitialize )
return 1;
}

static void PreInitialize( lua_State *state )
static void PreInitialize( GarrysMod::Lua::ILuaBase *LUA )
{
if( !engine_loader.IsValid( ) )
LUA->ThrowError( "unable to get engine factory" );

LUA->CreateTable( );

LUA->PushString( "serversecure 1.5.6" );
LUA->PushString( "serversecure 1.5.7" );
LUA->SetField( -2, "Version" );

// version num follows LuaJIT style, xxyyzz
LUA->PushNumber( 10506 );
LUA->PushNumber( 10507 );
LUA->SetField( -2, "VersionNum" );

LUA->PushCFunction( PostInitialize );
Expand All @@ -73,12 +73,12 @@ static void PreInitialize( lua_State *state )
post_initialized = false;
}

static void Initialize( lua_State *state )
static void Initialize( GarrysMod::Lua::ILuaBase *LUA )
{
LUA->SetField( GarrysMod::Lua::INDEX_GLOBAL, "serversecure" );
}

static void Deinitialize( lua_State *state )
static void Deinitialize( GarrysMod::Lua::ILuaBase *LUA )
{
LUA->PushNil( );
LUA->SetField( GarrysMod::Lua::INDEX_GLOBAL, "serversecure" );
Expand All @@ -88,17 +88,17 @@ static void Deinitialize( lua_State *state )

GMOD_MODULE_OPEN( )
{
global::PreInitialize( state );
netfilter::Initialize( state );
filecheck::Initialize( state );
global::Initialize( state );
global::PreInitialize( LUA );
netfilter::Initialize( LUA );
filecheck::Initialize( LUA );
global::Initialize( LUA );
return 1;
}

GMOD_MODULE_CLOSE( )
{
filecheck::Deinitialize( state );
netfilter::Deinitialize( state );
global::Deinitialize( state );
filecheck::Deinitialize( LUA );
netfilter::Deinitialize( LUA );
global::Deinitialize( LUA );
return 0;
}
6 changes: 3 additions & 3 deletions source/netfilter/core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -762,7 +762,7 @@ LUA_FUNCTION_STATIC( GetSamplePacket )
return 3;
}

void Initialize( lua_State *state )
void Initialize( GarrysMod::Lua::ILuaBase *LUA )
{
lua = static_cast<GarrysMod::Lua::ILuaInterface *>( LUA );

Expand Down Expand Up @@ -865,7 +865,7 @@ void Initialize( lua_State *state )
BuildStaticReplyInfo( );
}

int32_t PostInitialize( lua_State *state )
int32_t PostInitialize( GarrysMod::Lua::ILuaBase *LUA )
{
if( gameserver_context == nullptr )
{
Expand Down Expand Up @@ -963,7 +963,7 @@ int32_t PostInitialize( lua_State *state )
return 0;
}

void Deinitialize( lua_State * )
void Deinitialize( GarrysMod::Lua::ILuaBase * )
{
if( threaded_socket_handle != nullptr )
{
Expand Down
14 changes: 10 additions & 4 deletions source/netfilter/core.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,19 @@

#include <stdint.h>

struct lua_State;
namespace GarrysMod
{
namespace Lua
{
class ILuaBase;
}
}

namespace netfilter
{

void Initialize( lua_State *state );
int32_t PostInitialize( lua_State *state );
void Deinitialize( lua_State *state );
void Initialize( GarrysMod::Lua::ILuaBase *LUA );
int32_t PostInitialize( GarrysMod::Lua::ILuaBase *LUA );
void Deinitialize( GarrysMod::Lua::ILuaBase *LUA );

}

0 comments on commit 80ad68e

Please sign in to comment.