Исправлен Server::GetVersion (getServerVersion в Lua). Добавлен класс Game

This commit is contained in:
Kernell 2015-12-03 16:49:05 +03:00
parent 669f475d79
commit 43014102fc
3 changed files with 43 additions and 29 deletions

View File

@ -28,14 +28,14 @@ void CMonoFunctions::AddInternals( void )
MONO_DECLARE( Server, SetPassword ); MONO_DECLARE( Server, SetPassword );
MONO_DECLARE( Server, GetVersion ); MONO_DECLARE( Server, GetVersion );
MONO_DECLARE( Server, GetGameType ); MONO_DECLARE( Game, GetType );
MONO_DECLARE( Server, GetMapName ); MONO_DECLARE( Game, GetMapName );
MONO_DECLARE( Server, SetGameType ); MONO_DECLARE( Game, SetType );
MONO_DECLARE( Server, SetMapName ); MONO_DECLARE( Game, SetMapName );
MONO_DECLARE( Server, GetRuleValue ); MONO_DECLARE( Game, GetRuleValue );
MONO_DECLARE( Server, SetRuleValue ); MONO_DECLARE( Game, SetRuleValue );
MONO_DECLARE( Server, RemoveRuleValue ); MONO_DECLARE( Game, RemoveRuleValue );
MONO_DECLARE( Event, AddHandler ); MONO_DECLARE( Event, AddHandler );
@ -738,17 +738,27 @@ MonoObject* CMonoFunctions::Server::GetVersion( void )
const char* szBuildTag = pLuaTable[ "tag" ]->GetString(); const char* szBuildTag = pLuaTable[ "tag" ]->GetString();
const char* szSortable = pLuaTable[ "sortable" ]->GetString(); const char* szSortable = pLuaTable[ "sortable" ]->GetString();
void *args[] = CMonoCorlib* pLib = RESOURCE->GetDomain()->GetCorlib();
{
&ulNumber, void** args = new gpointer[ 8 ];
&szString,
&szName, MonoObject* pNumber = pLib->Class[ "uint64" ]->Box( &ulNumber );
&szBuildType, MonoString* pString = RESOURCE->GetDomain()->NewString( szString );
&ulNetcode, MonoString* pName = RESOURCE->GetDomain()->NewString( szName );
&szOS, MonoString* pBuildType = RESOURCE->GetDomain()->NewString( szBuildType );
&szBuildTag, MonoObject* pNetcode = pLib->Class[ "uint64" ]->Box( &ulNetcode );
&szSortable MonoString* pOS = RESOURCE->GetDomain()->NewString( szOS );
}; MonoString* pBuildTag = RESOURCE->GetDomain()->NewString( szBuildTag );
MonoString* pSortable = RESOURCE->GetDomain()->NewString( szSortable );
args[ 0 ] = pNumber;
args[ 1 ] = pString;
args[ 2 ] = pName;
args[ 3 ] = pBuildType;
args[ 4 ] = pNetcode;
args[ 5 ] = pOS;
args[ 6 ] = pBuildTag;
args[ 7 ] = pSortable;
return RESOURCE->GetDomain()->GetMTALib()->GetClass( "ServerVersion" )->New( args, 8 ); return RESOURCE->GetDomain()->GetMTALib()->GetClass( "ServerVersion" )->New( args, 8 );
} }
@ -757,7 +767,7 @@ MonoObject* CMonoFunctions::Server::GetVersion( void )
return NULL; return NULL;
} }
MonoString* CMonoFunctions::Server::GetGameType( void ) MonoString* CMonoFunctions::Game::GetType( void )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
@ -767,7 +777,7 @@ MonoString* CMonoFunctions::Server::GetGameType( void )
return NULL; return NULL;
} }
MonoString* CMonoFunctions::Server::GetMapName( void ) MonoString* CMonoFunctions::Game::GetMapName( void )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
@ -777,7 +787,7 @@ MonoString* CMonoFunctions::Server::GetMapName( void )
return NULL; return NULL;
} }
bool CMonoFunctions::Server::SetGameType( MonoString* msGameType ) bool CMonoFunctions::Game::SetType( MonoString* msGameType )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
@ -789,7 +799,7 @@ bool CMonoFunctions::Server::SetGameType( MonoString* msGameType )
return false; return false;
} }
bool CMonoFunctions::Server::SetMapName( MonoString* msMapName ) bool CMonoFunctions::Game::SetMapName( MonoString* msMapName )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
@ -801,7 +811,7 @@ bool CMonoFunctions::Server::SetMapName( MonoString* msMapName )
return false; return false;
} }
MonoString* CMonoFunctions::Server::GetRuleValue( MonoString* msKey ) MonoString* CMonoFunctions::Game::GetRuleValue( MonoString* msKey )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
@ -813,7 +823,7 @@ MonoString* CMonoFunctions::Server::GetRuleValue( MonoString* msKey )
return false; return false;
} }
bool CMonoFunctions::Server::SetRuleValue( MonoString* msKey, MonoString* msValue ) bool CMonoFunctions::Game::SetRuleValue( MonoString* msKey, MonoString* msValue )
{ {
if( RESOURCE ) if( RESOURCE )
{ {
@ -826,7 +836,7 @@ bool CMonoFunctions::Server::SetRuleValue( MonoString* msKey, MonoString* msValu
return false; return false;
} }
bool CMonoFunctions::Server::RemoveRuleValue( MonoString* msKey ) bool CMonoFunctions::Game::RemoveRuleValue( MonoString* msKey )
{ {
if( RESOURCE ) if( RESOURCE )
{ {

View File

@ -62,11 +62,15 @@ public:
static bool OutputConsole ( MonoString* szText, DWORD pElement ); static bool OutputConsole ( MonoString* szText, DWORD pElement );
static bool SetPassword ( MonoString* msPassword, bool bSave ); static bool SetPassword ( MonoString* msPassword, bool bSave );
static MonoObject* GetVersion ( void ); static MonoObject* GetVersion ( void );
};
static MonoString* GetGameType ( void ); class Game
{
public:
static MonoString* GetType ( void );
static MonoString* GetMapName ( void ); static MonoString* GetMapName ( void );
static bool SetGameType ( MonoString* msGameType ); static bool SetType ( MonoString* msGameType );
static bool SetMapName ( MonoString* msMapName ); static bool SetMapName ( MonoString* msMapName );
static MonoString* GetRuleValue ( MonoString* msKey ); static MonoString* GetRuleValue ( MonoString* msKey );
static bool SetRuleValue ( MonoString* msKey, MonoString* msValue ); static bool SetRuleValue ( MonoString* msKey, MonoString* msValue );

View File

@ -279,11 +279,11 @@ void CLuaArgument::Read ( lua_State* luaVM, signed int uiArgument )
while( lua_next( luaVM, uiArgument ) != 0 ) while( lua_next( luaVM, uiArgument ) != 0 )
{ {
CLuaArgument pKey( luaVM, -2 ); CLuaArgument pKey( luaVM, -2 );
CLuaArgument pValue( luaVM, -1 ); CLuaArgument* pValue = new CLuaArgument( luaVM, -1 );
if( pKey.GetType() == LUA_TSTRING ) if( pKey.GetType() == LUA_TSTRING )
{ {
m_pTable[ string( pKey.GetString() ) ] = &pValue; m_pTable[ string( pKey.GetString() ) ] = pValue;
} }
m_pArray->PushArgument( pValue ); m_pArray->PushArgument( pValue );