Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Index: settings.ini
- ===================================================================
- --- settings.ini (revision 97)
- +++ settings.ini (working copy)
- @@ -1,6 +1,8 @@
- [Server]
- Port=25565
- ServerID=-
- +MaxPlayers=100000
- +Description=MCServer - Slightly more custom!
- [Worlds]
- DefaultWorld=world
- Index: source/cClientHandle.cpp
- ===================================================================
- --- source/cClientHandle.cpp (revision 97)
- +++ source/cClientHandle.cpp (working copy)
- @@ -395,9 +395,10 @@
- case E_PING: // Somebody tries to retreive information about the server
- {
- LOGINFO("Got ping");
- - char NumPlayers[8];
- - sprintf_s(NumPlayers, 8, "%i", cRoot::Get()->GetWorld()->GetNumPlayers() );
- - std::string response = std::string("MCServer! - It's OVER 9000!" + cChatColor::Delimiter + NumPlayers + cChatColor::Delimiter + "9001" );
- + char NumPlayers[8], cMaxPlayers[8];
- + sprintf_s(NumPlayers, 8, "%i", cRoot::Get()->GetWorld()->GetNumPlayers());
- + sprintf_s(cMaxPlayers, 8, "%i", cRoot::Get()->GetWorld()->GetMaxPlayers());
- + std::string response = std::string(cRoot::Get()->GetWorld()->GetDescription() + cChatColor::Delimiter + NumPlayers + cChatColor::Delimiter + cMaxPlayers );
- Kick( response.c_str() );
- }
- break;
- @@ -407,6 +408,11 @@
- m_pState->Username = PacketData->m_Username;
- LOG("HANDSHAKE %s", GetUsername() );
- cPacket_Chat Connecting(m_pState->Username + " is connecting.");
- +
- + if (cRoot::Get()->GetWorld()->GetNumPlayers() == cRoot::Get()->GetWorld()->GetMaxPlayers()) {
- + Kick("The server is currently full :( -- Try again later");
- + break;
- + }
- cRoot::Get()->GetServer()->Broadcast( Connecting, this );
- // Give a server handshake thingy back
- Index: source/cWorld.cpp
- ===================================================================
- --- source/cWorld.cpp (revision 97)
- +++ source/cWorld.cpp (working copy)
- @@ -183,6 +183,8 @@
- {
- m_bAnimals = IniFile2.GetValueB("Monsters", "AnimalsOn", true );
- m_SpawnMonsterRate = (float)IniFile2.GetValueF("Monsters", "AnimalSpawnInterval", 10 );
- + SetMaxPlayers(IniFile2.GetValueI("Server", "MaxPlayers", 9001));
- + m_Description = IniFile2.GetValue("Server", "Description", "MCServer! - It's OVER 9000!").c_str();
- }
- m_ChunkMap = new cChunkMap( 32, 32, this );
- @@ -766,6 +768,24 @@
- }
- }
- +std::string cWorld::GetDescription()
- +{
- + return this->m_Description;
- +}
- +
- +unsigned int cWorld::GetMaxPlayers()
- +{
- + return this->m_MaxPlayers;
- +}
- +
- +void cWorld::SetMaxPlayers(int iMax)
- +{
- + this->m_MaxPlayers = 9001;
- + if (iMax > 0 && iMax < MAX_PLAYERS) {
- + this->m_MaxPlayers = iMax;
- + }
- +}
- +
- void cWorld::AddPlayer( cPlayer* a_Player )
- {
- m_pState->m_Players.remove( a_Player );
- Index: source/cWorld.h
- ===================================================================
- --- source/cWorld.h (revision 97)
- +++ source/cWorld.h (working copy)
- @@ -6,6 +6,8 @@
- enum ENUM_ITEM_ID;
- #endif
- +#define MAX_PLAYERS 65535
- +
- #include <list>
- #include <vector>
- @@ -54,7 +56,14 @@
- //ClientList & GetClients();
- void Broadcast( const cPacket & a_Packet, cClientHandle* a_Exclude = 0 );
- +
- + // MOTD
- + std::string GetDescription();
- + // Max Players
- + unsigned int GetMaxPlayers();
- + void SetMaxPlayers(int iMax);
- +
- void AddPlayer( cPlayer* a_Player );
- void RemovePlayer( cPlayer* a_Player );
- PlayerList & GetAllPlayers();
- @@ -168,9 +177,10 @@
- cCriticalSection* m_ClientHandleCriticalSection;
- cCriticalSection* m_EntitiesCriticalSection;
- cCriticalSection* m_ChunksCriticalSection;
- +
- + std::string m_Description;
- + unsigned int m_MaxPlayers;
- -
- -
- cChunkMap* m_ChunkMap;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement