Core now detects and handles a changed maxplayers value (bug 2537 and bug 2758)
This commit is contained in:
@@ -93,7 +93,7 @@ unsigned int TopMenu::CalcMemUsage()
|
||||
|
||||
size += m_Config.strings.GetMemTable()->MemUsage();
|
||||
size += (m_Config.cats.size() * sizeof(int));
|
||||
size += (sizeof(topmenu_player_t) * m_max_clients);
|
||||
size += (sizeof(topmenu_player_t) * (ABSOLUTE_PLAYER_LIMIT + 1));
|
||||
size += (m_SortedCats.size() * sizeof(unsigned int));
|
||||
size += (m_UnsortedCats.size() * sizeof(unsigned int));
|
||||
size += (m_Categories.size() * (sizeof(topmenu_category_t *) + sizeof(topmenu_category_t)));
|
||||
@@ -904,8 +904,8 @@ void TopMenu::SortCategoriesIfNeeded()
|
||||
void TopMenu::CreatePlayers(int max_clients)
|
||||
{
|
||||
m_max_clients = max_clients;
|
||||
m_clients = (topmenu_player_t *)malloc(sizeof(topmenu_player_t) * (max_clients + 1));
|
||||
memset(m_clients, 0, sizeof(topmenu_player_t) * (max_clients + 1));
|
||||
m_clients = (topmenu_player_t *)malloc(sizeof(topmenu_player_t) * (ABSOLUTE_PLAYER_LIMIT + 1));
|
||||
memset(m_clients, 0, sizeof(topmenu_player_t) * (ABSOLUTE_PLAYER_LIMIT + 1));
|
||||
}
|
||||
|
||||
void TopMenu::TearDownClient(topmenu_player_t *player)
|
||||
@@ -1100,6 +1100,11 @@ unsigned int TopMenu::FindCategory(const char *name)
|
||||
return obj->object_id;
|
||||
}
|
||||
|
||||
void TopMenu::OnMaxPlayersChanged( int newvalue )
|
||||
{
|
||||
m_max_clients = newvalue;
|
||||
}
|
||||
|
||||
int _SortObjectNamesDescending(const void *ptr1, const void *ptr2)
|
||||
{
|
||||
obj_by_name_t *obj1 = (obj_by_name_t *)ptr1;
|
||||
|
||||
@@ -42,6 +42,8 @@
|
||||
using namespace SourceHook;
|
||||
using namespace SourceMod;
|
||||
|
||||
#define ABSOLUTE_PLAYER_LIMIT 255 // not 256, so we can send the limit as a byte
|
||||
|
||||
struct config_category_t
|
||||
{
|
||||
int name;
|
||||
@@ -162,6 +164,7 @@ private:
|
||||
void OnClientDisconnected(int client);
|
||||
void OnServerActivated(int max_clients);
|
||||
bool OnIdentityRemoval(IdentityToken_t *owner);
|
||||
void OnMaxPlayersChanged(int newvalue);
|
||||
private:
|
||||
config_root_t m_Config; /* Configuration from file */
|
||||
topmenu_player_t *m_clients; /* Client array */
|
||||
|
||||
@@ -117,3 +117,13 @@ void TopMenuManager::DestroyTopMenu(ITopMenu *topmenu)
|
||||
|
||||
delete pMenu;
|
||||
}
|
||||
|
||||
void TopMenuManager::OnMaxPlayersChanged( int newvalue )
|
||||
{
|
||||
List<TopMenu *>::iterator iter;
|
||||
|
||||
for (iter = m_TopMenus.begin(); iter != m_TopMenus.end(); iter++)
|
||||
{
|
||||
(*iter)->OnMaxPlayersChanged(newvalue);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,6 +58,7 @@ public:
|
||||
void OnClientDisconnected(int client);
|
||||
void OnServerActivated(int max_clients);
|
||||
void OnPluginUnloaded(IPlugin *plugin);
|
||||
void OnMaxPlayersChanged(int newvalue);
|
||||
private:
|
||||
List<TopMenu *> m_TopMenus;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user