1
0

Added m_IP to player class and binding to get IP for LUA. (Probably should use m_pState)

git-svn-id: http://mc-server.googlecode.com/svn/trunk@82 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
admin@omencraft.com 2011-11-09 22:17:30 +00:00
parent 9e77db8e3d
commit 18b7563680
6 changed files with 79 additions and 3 deletions

View File

@ -1,6 +1,6 @@
/*
** Lua binding: AllToLua
** Generated automatically by tolua++-1.0.92 on 11/08/11 02:11:35.
** Generated automatically by tolua++-1.0.92 on 11/09/11 15:37:09.
*/
#ifndef __cplusplus
@ -5099,6 +5099,70 @@ tolua_lerror:
}
#endif //#ifndef TOLUA_DISABLE
/* method: GetGameMode of class cPlayer */
#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlayer_GetGameMode00
static int tolua_AllToLua_cPlayer_GetGameMode00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
if (
!tolua_isusertype(tolua_S,1,"cPlayer",0,&tolua_err) ||
!tolua_isnoobj(tolua_S,2,&tolua_err)
)
goto tolua_lerror;
else
#endif
{
cPlayer* self = (cPlayer*) tolua_tousertype(tolua_S,1,0);
#ifndef TOLUA_RELEASE
if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetGameMode'", NULL);
#endif
{
int tolua_ret = (int) self->GetGameMode();
tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
}
}
return 1;
#ifndef TOLUA_RELEASE
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'GetGameMode'.",&tolua_err);
return 0;
#endif
}
#endif //#ifndef TOLUA_DISABLE
/* method: GetIP of class cPlayer */
#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlayer_GetIP00
static int tolua_AllToLua_cPlayer_GetIP00(lua_State* tolua_S)
{
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
if (
!tolua_isusertype(tolua_S,1,"cPlayer",0,&tolua_err) ||
!tolua_isnoobj(tolua_S,2,&tolua_err)
)
goto tolua_lerror;
else
#endif
{
cPlayer* self = (cPlayer*) tolua_tousertype(tolua_S,1,0);
#ifndef TOLUA_RELEASE
if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetIP'", NULL);
#endif
{
std::string tolua_ret = (std::string) self->GetIP();
tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
}
}
return 1;
#ifndef TOLUA_RELEASE
tolua_lerror:
tolua_error(tolua_S,"#ferror in function 'GetIP'.",&tolua_err);
return 0;
#endif
}
#endif //#ifndef TOLUA_DISABLE
/* method: MoveTo of class cPlayer */
#ifndef TOLUA_DISABLE_tolua_AllToLua_cPlayer_MoveTo00
static int tolua_AllToLua_cPlayer_MoveTo00(lua_State* tolua_S)
@ -15631,6 +15695,8 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
tolua_function(tolua_S,"GetInventory",tolua_AllToLua_cPlayer_GetInventory00);
tolua_function(tolua_S,"TeleportTo",tolua_AllToLua_cPlayer_TeleportTo00);
tolua_function(tolua_S,"TeleportTo",tolua_AllToLua_cPlayer_TeleportTo01);
tolua_function(tolua_S,"GetGameMode",tolua_AllToLua_cPlayer_GetGameMode00);
tolua_function(tolua_S,"GetIP",tolua_AllToLua_cPlayer_GetIP00);
tolua_function(tolua_S,"MoveTo",tolua_AllToLua_cPlayer_MoveTo00);
tolua_function(tolua_S,"GetClientHandle",tolua_AllToLua_cPlayer_GetClientHandle00);
tolua_function(tolua_S,"SendMessage",tolua_AllToLua_cPlayer_SendMessage00);

View File

@ -1,6 +1,6 @@
/*
** Lua binding: AllToLua
** Generated automatically by tolua++-1.0.92 on 11/08/11 02:11:36.
** Generated automatically by tolua++-1.0.92 on 11/09/11 15:37:10.
*/
/* Exported function */

View File

@ -1078,6 +1078,8 @@ void cClientHandle::Tick(float a_Dt)
World->LockEntities();
m_Player->SetGameMode ( World->GetGameMode() ); //set player's gamemode to server's gamemode at login.
m_Player->SetIP ( m_pState->Socket.GetIPString() );
cRoot::Get()->GetPluginManager()->CallHook( cPluginManager::E_PLUGIN_PLAYER_SPAWN, 1, m_Player );
// Return a server login packet

View File

@ -61,6 +61,7 @@ struct cPlayer::sPlayerState
cPlayer::cPlayer(cClientHandle* a_Client, const char* a_PlayerName)
: m_bBurnable(true)
, m_GameMode( 0 )
, m_IP("")
, m_LastBlockActionTime( 0 )
, e_EPMetaState(NORMAL)
, m_bVisible( true )
@ -419,6 +420,10 @@ void cPlayer::SetGameMode( int a_GameMode )
m_GameMode = a_GameMode;
}
void cPlayer::SetIP( std::string a_IP )
{
m_IP = a_IP;
}
#ifdef SendMessage // Cause stupid windows.h defines SendMessage as SendMessageA
#undef SendMessage

View File

@ -31,10 +31,12 @@ public:
virtual void TeleportTo( cEntity* a_Entity ); //tolua_export
virtual void TeleportTo( const double & a_PosX, const double & a_PosY, const double & a_PosZ ); //tolua_export
int GetGameMode() { return m_GameMode; } //return GameMode for player.
int GetGameMode() { return m_GameMode; } //tolua_export
std::string GetIP() { return m_IP; } //tolua_export
float GetLastBlockActionTime() { return m_LastBlockActionTime; } //return LastBlockActionTime for player.
void SetLastBlockActionTime();
void SetGameMode( int a_GameMode );
void SetIP( std::string a_IP );
// Tries to move to a new position, with collision checks and stuff
virtual void MoveTo( const Vector3d & a_NewPos ); //tolua_export
@ -104,6 +106,7 @@ protected:
float m_LastBlockActionTime;
int m_GameMode;
std::string m_IP;
cClientHandle* m_ClientHandle;
}; //tolua_export

BIN
source/lua5.1.dll Normal file

Binary file not shown.