// =================== // Class structures. // =================== #pragma pack(1) typedef struct SS_CPlayerPool { // Data BOOL bPlayerConnected[MAX_PLAYERS]; // Methods bool IsPlayerConnected(int playerid) { if (playerid < 0 || playerid >= MAX_PLAYERS) { return false; } return (bPlayerConnected[playerid] != 0); }; } SS_CPlayerPool; #pragma pack(1) typedef struct SS_CServer { void *pFirst; SS_CPlayerPool *pPlayerPool; } SS_CServer; // ================================ // Our version of the server data // ================================ class CServer { public: // cons CServer(); SS_CServer * GetServer() { return *m_pServer; }; SS_CPlayerPool * GetPlayerPool() { return GetServer()->pPlayerPool; }; private: SS_CServer ** m_pServer; }; // ======================== // Set up the server data // ======================== extern logprintf_t logprintf; // cons CServer:: CServer() { switch ((int)logprintf) { case ADDR_LOGPRINTF_0303: m_pServer = ADDR_NETGAME_0303; break; default: logprintf("Error: Unknown server version\n"); return; } } // ============================================== // Once all that is set up, using it is trivial // ============================================== extern CServer gServer; void MyFunc(int playerid) { if (gServer.GetPlayerPool()->IsPlayerConnected(playerid)) { // Do something. } }