aboutsummaryrefslogtreecommitdiff
path: root/src/parsec_server/MasterServerItem.cpp
diff options
context:
space:
mode:
authorFelix Morgner <felix.morgner@gmail.com>2026-08-24 11:16:07 +0200
committerFelix Morgner <felix.morgner@gmail.com>2026-08-24 11:16:07 +0200
commitc068f22329d5cc722622a2183bbb22eef2093df7 (patch)
tree12d56c1aede67988a55e241364606bfbb4dba933 /src/parsec_server/MasterServerItem.cpp
downloadopenparsec-main.tar.xz
openparsec-main.zip
initial importHEADmain
Diffstat (limited to 'src/parsec_server/MasterServerItem.cpp')
-rw-r--r--src/parsec_server/MasterServerItem.cpp214
1 files changed, 214 insertions, 0 deletions
diff --git a/src/parsec_server/MasterServerItem.cpp b/src/parsec_server/MasterServerItem.cpp
new file mode 100644
index 0000000..445e590
--- /dev/null
+++ b/src/parsec_server/MasterServerItem.cpp
@@ -0,0 +1,214 @@
+/*
+ * MasterServerList.cpp
+ *
+ * Created on: Jan 2, 2013
+ * Author: jasonw
+ */
+// C library
+#include <ctype.h>
+#include <stdio.h>
+#include <string.h>
+#include <time.h>
+#include <sys/types.h>
+#include <sys/timeb.h>
+
+// compilation flags/debug support
+#include "config.h"
+#include "debug.h"
+
+// general definitions
+#include "general.h"
+#include "objstruc.h"
+
+// global externals
+#include "globals.h"
+
+// subsystem headers
+#include "net_defs.h"
+//FIXME: ????
+#include "sys_refframe_sv.h"
+
+// UNP header
+#include "net_wrap.h"
+
+// server defs
+#include "e_defs.h"
+
+// net game header
+#include "net_game_sv.h"
+
+// mathematics header
+#include "utl_math.h"
+
+// local module header
+#include "e_gameserver.h"
+
+// proprietary module headers
+#include "con_arg.h"
+#include "con_aux_sv.h"
+#include "con_com_sv.h"
+#include "con_main_sv.h"
+#include "e_colldet.h"
+#include "g_extra.h"
+#include "inp_main_sv.h"
+#include "net_csdf.h"
+#include "net_limits.h"
+#include "net_udpdriver.h"
+#include "net_util.h"
+#include "net_packetdriver.h"
+#include "obj_clas.h"
+//#include "e_stats.h"
+#include "g_main_sv.h"
+#include "e_connmanager.h"
+#include "e_packethandler.h"
+#include "e_simulator.h"
+#include "e_simnetinput.h"
+#include "e_simnetoutput.h"
+#include "sys_refframe_sv.h"
+#include "sys_util_sv.h"
+
+#include "gd_help.h"
+
+
+#include "MasterServerItem.h"
+
+MasterServerItem::MasterServerItem() {
+ // TODO Auto-generated constructor stub
+
+}
+MasterServerItem::MasterServerItem(int SrvID, int CurrPlayers, int MaxPlayers,
+ int PMajor, int PMinor, char ServerName[MAX_SERVER_NAME + 1],
+ char OS[MAX_OSNAME_LEN + 1], node_t *node) {
+
+ _SrvID = SrvID;
+ _CurrPlayers = CurrPlayers;
+ _MaxPlayers = MaxPlayers;
+ _PMajor = PMajor;
+ _PMinor = PMinor;
+ strncpy(_ServerName, ServerName, MAX_SERVER_NAME);
+ _ServerName[MAX_SERVER_NAME] = '\0';
+ strncpy(_OS, OS, MAX_OSNAME_LEN);
+ _OS[MAX_OSNAME_LEN] = '\0';
+ NODE_Copy(&_Node, node);
+
+}
+MasterServerItem::~MasterServerItem() {
+ // TODO Auto-generated destructor stub
+}
+
+bool MasterServerItem::update(int SrvID, int CurrPlayers, int MaxPlayers,
+ int PMajor, int PMinor, char ServerName[MAX_SERVER_NAME + 1],
+ char OS[MAX_OSNAME_LEN + 1], node_t *node) {
+
+ _SrvID = SrvID;
+ _CurrPlayers = CurrPlayers;
+ _MaxPlayers = MaxPlayers;
+ _PMajor = PMajor;
+ _PMinor = PMinor;
+ SAFE_STR_DUPLICATE(_ServerName, ServerName, MAX_SERVER_NAME-1);
+ _ServerName[MAX_SERVER_NAME] = '\0';
+ SAFE_STR_DUPLICATE(_OS, OS, MAX_OSNAME_LEN-1);
+ _OS[MAX_OSNAME_LEN] = '\0';
+ NODE_Copy(&_Node, node);
+
+
+ return true;
+}
+
+bool MasterServerItem::remove() {
+
+ // set the SrvID to -1 to indicate it should be removed.
+ _SrvID = -1;
+
+ return false;
+}
+
+bool MasterServerItem::operator <(const MasterServerItem& msl) const {
+
+ return false;
+}
+
+bool MasterServerItem::operator ==(const MasterServerItem& msl) const {
+
+ return false;
+}
+
+bool MasterServerItem::operator !=(const MasterServerItem& msl) const {
+
+ return false;
+}
+
+
+
+bool MasterServerItem::isValid() const {
+ if(_SrvID > -1) {
+ return true;
+ }
+ return false;
+}
+
+int MasterServerItem::GetSrvID() {
+ return _SrvID;
+}
+
+int MasterServerItem::GetCurrPlayers() {
+ return _CurrPlayers;
+}
+
+int MasterServerItem::GetMaxPlayers() {
+ return _MaxPlayers;
+}
+
+int MasterServerItem::GetPMajor() {
+ return _PMajor;
+}
+
+int MasterServerItem::GetPMinor() {
+ return _PMinor;
+}
+
+int MasterServerItem::GetServerName(char *buffer, int buffer_sz) {
+
+ int str_sz = strlen(_ServerName);
+ if(buffer_sz < str_sz + 1){
+ return -1;
+ }
+
+ strncpy(buffer, _ServerName, str_sz);
+ buffer[str_sz + 1] = '\0';
+
+ return 0;
+}
+
+int MasterServerItem::GetOS(char *buffer, int buffer_sz) {
+ int str_sz = strlen(_OS);
+ if(buffer_sz < str_sz + 1){
+ return -1;
+ }
+
+ strncpy(buffer, _OS, str_sz);
+ buffer[str_sz + 1] = '\0';
+
+ return 0;
+}
+
+MasterServerItem::MasterServerItem(const MasterServerItem& msi_copy) :
+ _SrvID (msi_copy._SrvID),
+ _CurrPlayers (msi_copy._CurrPlayers),
+ _MaxPlayers (msi_copy._MaxPlayers),
+ _PMajor (msi_copy._PMajor),
+ _PMinor (msi_copy._PMinor)
+{
+ strncpy(_ServerName, msi_copy._OS, MAX_SERVER_NAME);
+ _ServerName[MAX_SERVER_NAME]='\0';
+ strncpy( _OS, msi_copy._OS, MAX_OSNAME_LEN);
+ _OS[MAX_OSNAME_LEN]='\0';
+ memcpy(&_Node, &msi_copy._Node, sizeof( node_t ));
+
+}
+
+int MasterServerItem::GetNode(node_t* node) {
+ NODE_Copy(node, &_Node);
+
+ return true;
+}