Skip to content

Commit 2f2b7fe

Browse files
committed
Fixed some bugs.
Add "rev status" to print detailed info Update rehlsdk
1 parent d271a42 commit 2f2b7fe

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+4251
-124
lines changed
Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
/*
2+
*
3+
* This program is free software; you can redistribute it and/or modify it
4+
* under the terms of the GNU General Public License as published by the
5+
* Free Software Foundation; either version 2 of the License, or (at
6+
* your option) any later version.
7+
*
8+
* This program is distributed in the hope that it will be useful, but
9+
* WITHOUT ANY WARRANTY; without even the implied warranty of
10+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11+
* General Public License for more details.
12+
*
13+
* You should have received a copy of the GNU General Public License
14+
* along with this program; if not, write to the Free Software Foundation,
15+
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16+
*
17+
* In addition, as a special exception, the author gives permission to
18+
* link the code of this program with the Half-Life Game Engine ("HL
19+
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
20+
* L.L.C ("Valve"). You must obey the GNU General Public License in all
21+
* respects for all of the code used other than the HL Engine and MODs
22+
* from Valve. If you modify this file, you may extend this exception
23+
* to your version of the file, but you are not obligated to do so. If
24+
* you do not wish to do so, delete this exception statement from your
25+
* version.
26+
*
27+
*/
28+
29+
#include "precompiled.h"
30+
31+
BaseSystemModule::BaseSystemModule()
32+
{
33+
m_System = nullptr;
34+
m_Serial = 0;
35+
m_SystemTime = 0;
36+
m_State = MODULE_UNDEFINED;
37+
38+
Q_memset(m_Name, 0, sizeof(m_Name));
39+
}
40+
41+
char *BaseSystemModule::GetName()
42+
{
43+
return m_Name;
44+
}
45+
46+
char *BaseSystemModule::GetType()
47+
{
48+
return "GenericModule";
49+
}
50+
51+
char *BaseSystemModule::GetStatusLine()
52+
{
53+
return "No status available.\n";
54+
}
55+
56+
void BaseSystemModule::ExecuteCommand(int commandID, char *commandLine)
57+
{
58+
m_System->DPrintf("WARNING! Undeclared ExecuteCommand().\n");
59+
}
60+
61+
extern int COM_BuildNumber();
62+
63+
int BaseSystemModule::GetVersion()
64+
{
65+
return COM_BuildNumber();
66+
}
67+
68+
int BaseSystemModule::GetSerial()
69+
{
70+
return m_Serial;
71+
}
72+
73+
IBaseSystem *BaseSystemModule::GetSystem()
74+
{
75+
return m_System;
76+
}
77+
78+
bool BaseSystemModule::Init(IBaseSystem *system, int serial, char *name)
79+
{
80+
if (!system)
81+
return false;
82+
83+
m_State = MODULE_INITIALIZING;
84+
m_System = system;
85+
m_Serial = serial;
86+
m_SystemTime = 0;
87+
88+
if (name) {
89+
Q_strlcpy(m_Name, name);
90+
}
91+
92+
return true;
93+
}
94+
95+
void BaseSystemModule::RunFrame(double time)
96+
{
97+
m_SystemTime = time;
98+
}
99+
100+
void BaseSystemModule::ShutDown()
101+
{
102+
if (m_State == MODULE_DISCONNECTED)
103+
return;
104+
105+
m_Listener.Clear();
106+
m_State = MODULE_DISCONNECTED;
107+
108+
if (!m_System->RemoveModule(this))
109+
{
110+
m_System->DPrintf("ERROR! BaseSystemModule::ShutDown: faild to remove module %s.\n", m_Name);
111+
}
112+
}
113+
114+
void BaseSystemModule::RegisterListener(ISystemModule *module)
115+
{
116+
ISystemModule *listener = (ISystemModule *)m_Listener.GetFirst();
117+
while (listener)
118+
{
119+
if (listener->GetSerial() == module->GetSerial())
120+
{
121+
m_System->DPrintf("WARNING! BaseSystemModule::RegisterListener: module %s already added.\n", module->GetName());
122+
return;
123+
}
124+
125+
listener = (ISystemModule *)m_Listener.GetNext();
126+
}
127+
128+
m_Listener.Add(module);
129+
}
130+
131+
void BaseSystemModule::RemoveListener(ISystemModule *module)
132+
{
133+
ISystemModule *listener = (ISystemModule *)m_Listener.GetFirst();
134+
while (listener)
135+
{
136+
if (listener->GetSerial() == module->GetSerial())
137+
{
138+
m_Listener.Remove(module);
139+
return;
140+
}
141+
142+
listener = (ISystemModule *)m_Listener.GetNext();
143+
}
144+
}
145+
146+
void BaseSystemModule::FireSignal(unsigned int signal, void *data)
147+
{
148+
ISystemModule *listener = (ISystemModule *)m_Listener.GetFirst();
149+
while (listener)
150+
{
151+
listener->ReceiveSignal(this, signal, data);
152+
listener = (ISystemModule *)m_Listener.GetNext();
153+
}
154+
}
155+
156+
void BaseSystemModule::ReceiveSignal(ISystemModule *module, unsigned int signal, void *data)
157+
{
158+
m_System->DPrintf("WARNING! Unhandled signal (%i) from module %s.\n", signal, module->GetName());
159+
}
160+
161+
int BaseSystemModule::GetState()
162+
{
163+
return m_State;
164+
}
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
/*
2+
*
3+
* This program is free software; you can redistribute it and/or modify it
4+
* under the terms of the GNU General Public License as published by the
5+
* Free Software Foundation; either version 2 of the License, or (at
6+
* your option) any later version.
7+
*
8+
* This program is distributed in the hope that it will be useful, but
9+
* WITHOUT ANY WARRANTY; without even the implied warranty of
10+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11+
* General Public License for more details.
12+
*
13+
* You should have received a copy of the GNU General Public License
14+
* along with this program; if not, write to the Free Software Foundation,
15+
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16+
*
17+
* In addition, as a special exception, the author gives permission to
18+
* link the code of this program with the Half-Life Game Engine ("HL
19+
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
20+
* L.L.C ("Valve"). You must obey the GNU General Public License in all
21+
* respects for all of the code used other than the HL Engine and MODs
22+
* from Valve. If you modify this file, you may extend this exception
23+
* to your version of the file, but you are not obligated to do so. If
24+
* you do not wish to do so, delete this exception statement from your
25+
* version.
26+
*
27+
*/
28+
29+
#pragma once
30+
31+
#include "ObjectList.h"
32+
#include "IBaseSystem.h"
33+
34+
// C4250 - 'class1' : inherits 'BaseSystemModule::member' via dominance
35+
#pragma warning(disable:4250)
36+
37+
class BaseSystemModule: virtual public ISystemModule {
38+
public:
39+
BaseSystemModule();
40+
virtual ~BaseSystemModule() {}
41+
42+
EXT_FUNC virtual bool Init(IBaseSystem *system, int serial, char *name);
43+
EXT_FUNC virtual void RunFrame(double time);
44+
EXT_FUNC virtual void ReceiveSignal(ISystemModule *module, unsigned int signal, void *data);
45+
EXT_FUNC virtual void ExecuteCommand(int commandID, char *commandLine);
46+
EXT_FUNC virtual void RegisterListener(ISystemModule *module);
47+
EXT_FUNC virtual void RemoveListener(ISystemModule *module);
48+
EXT_FUNC virtual IBaseSystem *GetSystem();
49+
EXT_FUNC virtual int GetSerial();
50+
EXT_FUNC virtual char *GetStatusLine();
51+
EXT_FUNC virtual char *GetType();
52+
EXT_FUNC virtual char *GetName();
53+
54+
enum ModuleState {
55+
MODULE_UNDEFINED = 0,
56+
MODULE_INITIALIZING,
57+
MODULE_CONNECTING,
58+
MODULE_RUNNING,
59+
MODULE_DISCONNECTED
60+
};
61+
62+
EXT_FUNC virtual int GetState();
63+
EXT_FUNC virtual int GetVersion();
64+
EXT_FUNC virtual void ShutDown();
65+
EXT_FUNC virtual char *GetBaseDir() { return ""; }
66+
void FireSignal(unsigned int signal, void *data = nullptr);
67+
68+
protected:
69+
IBaseSystem *m_System;
70+
ObjectList m_Listener;
71+
char m_Name[255];
72+
unsigned int m_State;
73+
unsigned int m_Serial;
74+
double m_SystemTime;
75+
};

dep/rehlsdk/common/IAdminServer.h

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/*
2+
*
3+
* This program is free software; you can redistribute it and/or modify it
4+
* under the terms of the GNU General Public License as published by the
5+
* Free Software Foundation; either version 2 of the License, or (at
6+
* your option) any later version.
7+
*
8+
* This program is distributed in the hope that it will be useful, but
9+
* WITHOUT ANY WARRANTY; without even the implied warranty of
10+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11+
* General Public License for more details.
12+
*
13+
* You should have received a copy of the GNU General Public License
14+
* along with this program; if not, write to the Free Software Foundation,
15+
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16+
*
17+
* In addition, as a special exception, the author gives permission to
18+
* link the code of this program with the Half-Life Game Engine ("HL
19+
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
20+
* L.L.C ("Valve"). You must obey the GNU General Public License in all
21+
* respects for all of the code used other than the HL Engine and MODs
22+
* from Valve. If you modify this file, you may extend this exception
23+
* to your version of the file, but you are not obligated to do so. If
24+
* you do not wish to do so, delete this exception statement from your
25+
* version.
26+
*
27+
*/
28+
29+
#pragma once
30+
31+
#include "interface.h"
32+
33+
// handle to a game window
34+
typedef unsigned int ManageServerUIHandle_t;
35+
class IManageServer;
36+
37+
// Purpose: Interface to server administration functions
38+
class IAdminServer: public IBaseInterface
39+
{
40+
public:
41+
// opens a manage server dialog for a local server
42+
virtual ManageServerUIHandle_t OpenManageServerDialog(const char *serverName, const char *gameDir) = 0;
43+
44+
// opens a manage server dialog to a remote server
45+
virtual ManageServerUIHandle_t OpenManageServerDialog(unsigned int gameIP, unsigned int gamePort, const char *password) = 0;
46+
47+
// forces the game info dialog closed
48+
virtual void CloseManageServerDialog(ManageServerUIHandle_t gameDialog) = 0;
49+
50+
// Gets a handle to the interface
51+
virtual IManageServer *GetManageServerInterface(ManageServerUIHandle_t handle) = 0;
52+
};
53+
54+
#define ADMINSERVER_INTERFACE_VERSION "AdminServer002"

dep/rehlsdk/common/IBaseSystem.h

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
/*
2+
*
3+
* This program is free software; you can redistribute it and/or modify it
4+
* under the terms of the GNU General Public License as published by the
5+
* Free Software Foundation; either version 2 of the License, or (at
6+
* your option) any later version.
7+
*
8+
* This program is distributed in the hope that it will be useful, but
9+
* WITHOUT ANY WARRANTY; without even the implied warranty of
10+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11+
* General Public License for more details.
12+
*
13+
* You should have received a copy of the GNU General Public License
14+
* along with this program; if not, write to the Free Software Foundation,
15+
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16+
*
17+
* In addition, as a special exception, the author gives permission to
18+
* link the code of this program with the Half-Life Game Engine ("HL
19+
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
20+
* L.L.C ("Valve"). You must obey the GNU General Public License in all
21+
* respects for all of the code used other than the HL Engine and MODs
22+
* from Valve. If you modify this file, you may extend this exception
23+
* to your version of the file, but you are not obligated to do so. If
24+
* you do not wish to do so, delete this exception statement from your
25+
* version.
26+
*
27+
*/
28+
29+
#pragma once
30+
31+
#if defined(_WIN32)
32+
#define LIBRARY_PREFIX "dll"
33+
#elif defined(OSX)
34+
#define LIBRARY_PREFIX "dylib"
35+
#else
36+
#define LIBRARY_PREFIX "so"
37+
#endif
38+
39+
#include "ISystemModule.h"
40+
#include "IVGuiModule.h"
41+
42+
class Panel;
43+
class ObjectList;
44+
class IFileSystem;
45+
46+
class IBaseSystem: virtual public ISystemModule {
47+
public:
48+
virtual ~IBaseSystem() {}
49+
50+
virtual double GetTime() = 0;
51+
virtual unsigned int GetTick() = 0;
52+
virtual void SetFPS(float fps) = 0;
53+
54+
virtual void Printf(char *fmt, ...) = 0;
55+
virtual void DPrintf(char *fmt, ...) = 0;
56+
57+
virtual void RedirectOutput(char *buffer = nullptr, int maxSize = 0) = 0;
58+
59+
virtual IFileSystem *GetFileSystem() = 0;
60+
virtual unsigned char *LoadFile(const char *name, int *length = nullptr) = 0;
61+
virtual void FreeFile(unsigned char *fileHandle) = 0;
62+
63+
virtual void SetTitle(char *text) = 0;
64+
virtual void SetStatusLine(char *text) = 0;
65+
66+
virtual void ShowConsole(bool visible) = 0;
67+
virtual void LogConsole(char *filename) = 0;
68+
69+
virtual bool InitVGUI(IVGuiModule *module) = 0;
70+
71+
#ifdef _WIN32
72+
virtual Panel *GetPanel() = 0;
73+
#endif // _WIN32
74+
75+
virtual bool RegisterCommand(char *name, ISystemModule *module, int commandID) = 0;
76+
virtual void GetCommandMatches(char *string, ObjectList *pMatchList) = 0;
77+
virtual void ExecuteString(char *commands) = 0;
78+
virtual void ExecuteFile(char *filename) = 0;
79+
virtual void Errorf(char *fmt, ...) = 0;
80+
81+
virtual char *CheckParam(char *param) = 0;
82+
83+
virtual bool AddModule(ISystemModule *module, char *name) = 0;
84+
virtual ISystemModule *GetModule(char *interfacename, char *library, char *instancename = nullptr) = 0;
85+
virtual bool RemoveModule(ISystemModule *module) = 0;
86+
87+
virtual void Stop() = 0;
88+
virtual char *GetBaseDir() = 0;
89+
};
90+
91+
#define BASESYSTEM_INTERFACE_VERSION "basesystem002"

0 commit comments

Comments
 (0)