Advertisement
Guest User

Untitled

a guest
Dec 23rd, 2011
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.68 KB | None | 0 0
  1. Index: settings.ini
  2. ===================================================================
  3. --- settings.ini (revision 97)
  4. +++ settings.ini (working copy)
  5. @@ -1,6 +1,8 @@
  6. [Server]
  7. Port=25565
  8. ServerID=-
  9. +MaxPlayers=100000
  10. +Description=MCServer - Slightly more custom!
  11.  
  12. [Worlds]
  13. DefaultWorld=world
  14. Index: source/cClientHandle.cpp
  15. ===================================================================
  16. --- source/cClientHandle.cpp (revision 97)
  17. +++ source/cClientHandle.cpp (working copy)
  18. @@ -395,9 +395,10 @@
  19. case E_PING: // Somebody tries to retreive information about the server
  20. {
  21. LOGINFO("Got ping");
  22. - char NumPlayers[8];
  23. - sprintf_s(NumPlayers, 8, "%i", cRoot::Get()->GetWorld()->GetNumPlayers() );
  24. - std::string response = std::string("MCServer! - It's OVER 9000!" + cChatColor::Delimiter + NumPlayers + cChatColor::Delimiter + "9001" );
  25. + char NumPlayers[8], cMaxPlayers[8];
  26. + sprintf_s(NumPlayers, 8, "%i", cRoot::Get()->GetWorld()->GetNumPlayers());
  27. + sprintf_s(cMaxPlayers, 8, "%i", cRoot::Get()->GetWorld()->GetMaxPlayers());
  28. + std::string response = std::string(cRoot::Get()->GetWorld()->GetDescription() + cChatColor::Delimiter + NumPlayers + cChatColor::Delimiter + cMaxPlayers );
  29. Kick( response.c_str() );
  30. }
  31. break;
  32. @@ -407,6 +408,11 @@
  33. m_pState->Username = PacketData->m_Username;
  34. LOG("HANDSHAKE %s", GetUsername() );
  35. cPacket_Chat Connecting(m_pState->Username + " is connecting.");
  36. +
  37. + if (cRoot::Get()->GetWorld()->GetNumPlayers() == cRoot::Get()->GetWorld()->GetMaxPlayers()) {
  38. + Kick("The server is currently full :( -- Try again later");
  39. + break;
  40. + }
  41. cRoot::Get()->GetServer()->Broadcast( Connecting, this );
  42.  
  43. // Give a server handshake thingy back
  44. Index: source/cWorld.cpp
  45. ===================================================================
  46. --- source/cWorld.cpp (revision 97)
  47. +++ source/cWorld.cpp (working copy)
  48. @@ -183,6 +183,8 @@
  49. {
  50. m_bAnimals = IniFile2.GetValueB("Monsters", "AnimalsOn", true );
  51. m_SpawnMonsterRate = (float)IniFile2.GetValueF("Monsters", "AnimalSpawnInterval", 10 );
  52. + SetMaxPlayers(IniFile2.GetValueI("Server", "MaxPlayers", 9001));
  53. + m_Description = IniFile2.GetValue("Server", "Description", "MCServer! - It's OVER 9000!").c_str();
  54. }
  55.  
  56. m_ChunkMap = new cChunkMap( 32, 32, this );
  57. @@ -766,6 +768,24 @@
  58. }
  59. }
  60.  
  61. +std::string cWorld::GetDescription()
  62. +{
  63. + return this->m_Description;
  64. +}
  65. +
  66. +unsigned int cWorld::GetMaxPlayers()
  67. +{
  68. + return this->m_MaxPlayers;
  69. +}
  70. +
  71. +void cWorld::SetMaxPlayers(int iMax)
  72. +{
  73. + this->m_MaxPlayers = 9001;
  74. + if (iMax > 0 && iMax < MAX_PLAYERS) {
  75. + this->m_MaxPlayers = iMax;
  76. + }
  77. +}
  78. +
  79. void cWorld::AddPlayer( cPlayer* a_Player )
  80. {
  81. m_pState->m_Players.remove( a_Player );
  82. Index: source/cWorld.h
  83. ===================================================================
  84. --- source/cWorld.h (revision 97)
  85. +++ source/cWorld.h (working copy)
  86. @@ -6,6 +6,8 @@
  87. enum ENUM_ITEM_ID;
  88. #endif
  89.  
  90. +#define MAX_PLAYERS 65535
  91. +
  92. #include <list>
  93. #include <vector>
  94.  
  95. @@ -54,7 +56,14 @@
  96. //ClientList & GetClients();
  97.  
  98. void Broadcast( const cPacket & a_Packet, cClientHandle* a_Exclude = 0 );
  99. +
  100. + // MOTD
  101. + std::string GetDescription();
  102.  
  103. + // Max Players
  104. + unsigned int GetMaxPlayers();
  105. + void SetMaxPlayers(int iMax);
  106. +
  107. void AddPlayer( cPlayer* a_Player );
  108. void RemovePlayer( cPlayer* a_Player );
  109. PlayerList & GetAllPlayers();
  110. @@ -168,9 +177,10 @@
  111. cCriticalSection* m_ClientHandleCriticalSection;
  112. cCriticalSection* m_EntitiesCriticalSection;
  113. cCriticalSection* m_ChunksCriticalSection;
  114. +
  115. + std::string m_Description;
  116. + unsigned int m_MaxPlayers;
  117.  
  118. -
  119. -
  120. cChunkMap* m_ChunkMap;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement