diff options
author | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-02-01 23:38:03 +0100 |
---|---|---|
committer | madmaxoft@gmail.com <madmaxoft@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6> | 2012-02-01 23:38:03 +0100 |
commit | 48d30d6ab4657e00c0c861d67285256daeff1142 (patch) | |
tree | b9dc6b6e59f09224fe3e2b80c5c247b44331e469 /source/cServer.cpp | |
parent | Added all current hooks to the new plugin structure. (diff) | |
download | cuberite-48d30d6ab4657e00c0c861d67285256daeff1142.tar cuberite-48d30d6ab4657e00c0c861d67285256daeff1142.tar.gz cuberite-48d30d6ab4657e00c0c861d67285256daeff1142.tar.bz2 cuberite-48d30d6ab4657e00c0c861d67285256daeff1142.tar.lz cuberite-48d30d6ab4657e00c0c861d67285256daeff1142.tar.xz cuberite-48d30d6ab4657e00c0c861d67285256daeff1142.tar.zst cuberite-48d30d6ab4657e00c0c861d67285256daeff1142.zip |
Diffstat (limited to '')
-rw-r--r-- | source/cServer.cpp | 109 |
1 files changed, 101 insertions, 8 deletions
diff --git a/source/cServer.cpp b/source/cServer.cpp index 826de3bb3..44dd365c2 100644 --- a/source/cServer.cpp +++ b/source/cServer.cpp @@ -48,6 +48,10 @@ bool g_bWaterPhysics = false; typedef std::list< cClientHandle* > ClientList;
+
+
+
+
struct cServer::sServerState
{
sServerState()
@@ -67,12 +71,20 @@ struct cServer::sServerState std::string ServerID;
};
-cServer*cServer::GetServer()
+
+
+
+
+cServer * cServer::GetServer()
{
LOGWARN("WARNING: Using deprecated function cServer::GetServer() use cRoot::Get()->GetServer() instead!");
return cRoot::Get()->GetServer();
}
+
+
+
+
void cServer::ServerListenThread( void *a_Args )
{
LOG("ServerListenThread");
@@ -84,6 +96,10 @@ void cServer::ServerListenThread( void *a_Args ) }
}
+
+
+
+
std::string GetWSAError()
{
#ifdef _WIN32
@@ -126,6 +142,10 @@ std::string GetWSAError() return "No Error";
}
+
+
+
+
bool cServer::InitServer( int a_Port )
{
if( m_bIsConnected )
@@ -135,7 +155,7 @@ bool cServer::InitServer( int a_Port ) }
printf("/============================\\\n");
- printf("| Minecraft Alpha Server |\n");
+ printf("| Custom Minecraft Server |\n");
printf("| Created by Kevin Bansberg |\n");
printf("| A.K.A. |\n");
printf("| FakeTruth |\n");
@@ -222,6 +242,10 @@ bool cServer::InitServer( int a_Port ) return true;
}
+
+
+
+
cServer::cServer()
: m_pState( new sServerState )
, m_Millisecondsf( 0 )
@@ -232,6 +256,10 @@ cServer::cServer() {
}
+
+
+
+
cServer::~cServer()
{
if( m_pState->SListenClient ) m_pState->SListenClient.CloseSocket();
@@ -245,6 +273,10 @@ cServer::~cServer() delete m_pState;
}
+
+
+
+
// TODO - Need to modify this or something, so it broadcasts to all worlds? And move this to cWorld?
void cServer::Broadcast( const cPacket & a_Packet, cClientHandle* a_Exclude /* = 0 */ )
{
@@ -255,6 +287,10 @@ void cServer::Broadcast( const cPacket & a_Packet, cClientHandle* a_Exclude /* = }
}
+
+
+
+
void cServer::StartListenClient()
{
cSocket SClient = m_pState->SListenClient.Accept();
@@ -272,6 +308,10 @@ void cServer::StartListenClient() }
}
+
+
+
+
bool cServer::Tick(float a_Dt)
{
//LOG("1. Tick %0.2f", a_Dt);
@@ -318,6 +358,10 @@ bool cServer::Tick(float a_Dt) }
}
+
+
+
+
void ServerTickThread( void * a_Param )
{
LOG("ServerTickThread");
@@ -394,14 +438,18 @@ bool cServer::Command( cClientHandle & a_Client, const char* a_Cmd ) if (split[0].compare("/coords") == 0)
{
- char c_Str[128];
- sprintf_s( c_Str, 128, "[X:%0.2f] [Y:%0.2f] [Z:%0.2f]", a_Client.GetPlayer()->GetPosX(), a_Client.GetPlayer()->GetPosY(), a_Client.GetPlayer()->GetPosZ() );
- a_Client.Send( cPacket_Chat( cChatColor::Green + c_Str ) );
+ AString Pos;
+ Printf(Pos, "[X:%0.2f] [Y:%0.2f] [Z:%0.2f]", a_Client.GetPlayer()->GetPosX(), a_Client.GetPlayer()->GetPosY(), a_Client.GetPlayer()->GetPosZ() );
+ a_Client.Send( cPacket_Chat(cChatColor::Green + Pos));
return true;
}
return false;
}
+
+
+
+
void cServer::ServerCommand( const char* a_Cmd )
{
AString Command( a_Cmd );
@@ -472,6 +520,10 @@ void cServer::ServerCommand( const char* a_Cmd ) //LOG("You didn't enter anything? (%s)", a_Cmd.c_str() );
}
+
+
+
+
void cServer::SendMessage( const char* a_Message, cPlayer* a_Player /* = 0 */, bool a_bExclude /* = false */ )
{
cPacket_Chat Chat( a_Message );
@@ -485,6 +537,10 @@ void cServer::SendMessage( const char* a_Message, cPlayer* a_Player /* = 0 */, b Broadcast( Chat, (a_Player)?a_Player->GetClientHandle():0 );
}
+
+
+
+
void cServer::Shutdown()
{
m_bRestarting = true;
@@ -503,7 +559,44 @@ void cServer::Shutdown() }
-const char* cServer::GetServerID()
+
+
+
+const AString & cServer::GetServerID(void) const
+{
+ return m_pState->ServerID;
+}
+
+
+
+
+
+void cServer::KickUser(const AString & iUserName, const AString & iReason)
{
- return m_pState->ServerID.c_str();
-}
\ No newline at end of file + for (ClientList::iterator itr = m_pState->Clients.begin(); itr != m_pState->Clients.end(); ++itr)
+ {
+ if ((*itr)->GetUsername() == iUserName)
+ {
+ (*itr)->Kick(iReason);
+ }
+ } // for itr - m_pState->Clients[]
+}
+
+
+
+
+
+void cServer::AuthenticateUser(const AString & iUserName)
+{
+ for (ClientList::iterator itr = m_pState->Clients.begin(); itr != m_pState->Clients.end(); ++itr)
+ {
+ if ((*itr)->GetUsername() == iUserName)
+ {
+ (*itr)->Authenticate();
+ }
+ } // for itr - m_pState->Clients[]
+}
+
+
+
+
|