Skip to content

Commit

Permalink
Fixed some bugs.
Browse files Browse the repository at this point in the history
Add "rev status" to print detailed info
Update rehlsdk
  • Loading branch information
s1lentq committed Oct 26, 2017
1 parent d271a42 commit 2f2b7fe
Show file tree
Hide file tree
Showing 59 changed files with 4,251 additions and 124 deletions.
164 changes: 164 additions & 0 deletions dep/rehlsdk/common/BaseSystemModule.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
/*
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*
*/

#include "precompiled.h"

BaseSystemModule::BaseSystemModule()
{
m_System = nullptr;
m_Serial = 0;
m_SystemTime = 0;
m_State = MODULE_UNDEFINED;

Q_memset(m_Name, 0, sizeof(m_Name));
}

char *BaseSystemModule::GetName()
{
return m_Name;
}

char *BaseSystemModule::GetType()
{
return "GenericModule";
}

char *BaseSystemModule::GetStatusLine()
{
return "No status available.\n";
}

void BaseSystemModule::ExecuteCommand(int commandID, char *commandLine)
{
m_System->DPrintf("WARNING! Undeclared ExecuteCommand().\n");
}

extern int COM_BuildNumber();

int BaseSystemModule::GetVersion()
{
return COM_BuildNumber();
}

int BaseSystemModule::GetSerial()
{
return m_Serial;
}

IBaseSystem *BaseSystemModule::GetSystem()
{
return m_System;
}

bool BaseSystemModule::Init(IBaseSystem *system, int serial, char *name)
{
if (!system)
return false;

m_State = MODULE_INITIALIZING;
m_System = system;
m_Serial = serial;
m_SystemTime = 0;

if (name) {
Q_strlcpy(m_Name, name);
}

return true;
}

void BaseSystemModule::RunFrame(double time)
{
m_SystemTime = time;
}

void BaseSystemModule::ShutDown()
{
if (m_State == MODULE_DISCONNECTED)
return;

m_Listener.Clear();
m_State = MODULE_DISCONNECTED;

if (!m_System->RemoveModule(this))
{
m_System->DPrintf("ERROR! BaseSystemModule::ShutDown: faild to remove module %s.\n", m_Name);
}
}

void BaseSystemModule::RegisterListener(ISystemModule *module)
{
ISystemModule *listener = (ISystemModule *)m_Listener.GetFirst();
while (listener)
{
if (listener->GetSerial() == module->GetSerial())
{
m_System->DPrintf("WARNING! BaseSystemModule::RegisterListener: module %s already added.\n", module->GetName());
return;
}

listener = (ISystemModule *)m_Listener.GetNext();
}

m_Listener.Add(module);
}

void BaseSystemModule::RemoveListener(ISystemModule *module)
{
ISystemModule *listener = (ISystemModule *)m_Listener.GetFirst();
while (listener)
{
if (listener->GetSerial() == module->GetSerial())
{
m_Listener.Remove(module);
return;
}

listener = (ISystemModule *)m_Listener.GetNext();
}
}

void BaseSystemModule::FireSignal(unsigned int signal, void *data)
{
ISystemModule *listener = (ISystemModule *)m_Listener.GetFirst();
while (listener)
{
listener->ReceiveSignal(this, signal, data);
listener = (ISystemModule *)m_Listener.GetNext();
}
}

void BaseSystemModule::ReceiveSignal(ISystemModule *module, unsigned int signal, void *data)
{
m_System->DPrintf("WARNING! Unhandled signal (%i) from module %s.\n", signal, module->GetName());
}

int BaseSystemModule::GetState()
{
return m_State;
}
75 changes: 75 additions & 0 deletions dep/rehlsdk/common/BaseSystemModule.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
/*
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*
*/

#pragma once

#include "ObjectList.h"
#include "IBaseSystem.h"

// C4250 - 'class1' : inherits 'BaseSystemModule::member' via dominance
#pragma warning(disable:4250)

class BaseSystemModule: virtual public ISystemModule {
public:
BaseSystemModule();
virtual ~BaseSystemModule() {}

EXT_FUNC virtual bool Init(IBaseSystem *system, int serial, char *name);
EXT_FUNC virtual void RunFrame(double time);
EXT_FUNC virtual void ReceiveSignal(ISystemModule *module, unsigned int signal, void *data);
EXT_FUNC virtual void ExecuteCommand(int commandID, char *commandLine);
EXT_FUNC virtual void RegisterListener(ISystemModule *module);
EXT_FUNC virtual void RemoveListener(ISystemModule *module);
EXT_FUNC virtual IBaseSystem *GetSystem();
EXT_FUNC virtual int GetSerial();
EXT_FUNC virtual char *GetStatusLine();
EXT_FUNC virtual char *GetType();
EXT_FUNC virtual char *GetName();

enum ModuleState {
MODULE_UNDEFINED = 0,
MODULE_INITIALIZING,
MODULE_CONNECTING,
MODULE_RUNNING,
MODULE_DISCONNECTED
};

EXT_FUNC virtual int GetState();
EXT_FUNC virtual int GetVersion();
EXT_FUNC virtual void ShutDown();
EXT_FUNC virtual char *GetBaseDir() { return ""; }
void FireSignal(unsigned int signal, void *data = nullptr);

protected:
IBaseSystem *m_System;
ObjectList m_Listener;
char m_Name[255];
unsigned int m_State;
unsigned int m_Serial;
double m_SystemTime;
};
54 changes: 54 additions & 0 deletions dep/rehlsdk/common/IAdminServer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*
*/

#pragma once

#include "interface.h"

// handle to a game window
typedef unsigned int ManageServerUIHandle_t;
class IManageServer;

// Purpose: Interface to server administration functions
class IAdminServer: public IBaseInterface
{
public:
// opens a manage server dialog for a local server
virtual ManageServerUIHandle_t OpenManageServerDialog(const char *serverName, const char *gameDir) = 0;

// opens a manage server dialog to a remote server
virtual ManageServerUIHandle_t OpenManageServerDialog(unsigned int gameIP, unsigned int gamePort, const char *password) = 0;

// forces the game info dialog closed
virtual void CloseManageServerDialog(ManageServerUIHandle_t gameDialog) = 0;

// Gets a handle to the interface
virtual IManageServer *GetManageServerInterface(ManageServerUIHandle_t handle) = 0;
};

#define ADMINSERVER_INTERFACE_VERSION "AdminServer002"
91 changes: 91 additions & 0 deletions dep/rehlsdk/common/IBaseSystem.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/*
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*
*/

#pragma once

#if defined(_WIN32)
#define LIBRARY_PREFIX "dll"
#elif defined(OSX)
#define LIBRARY_PREFIX "dylib"
#else
#define LIBRARY_PREFIX "so"
#endif

#include "ISystemModule.h"
#include "IVGuiModule.h"

class Panel;
class ObjectList;
class IFileSystem;

class IBaseSystem: virtual public ISystemModule {
public:
virtual ~IBaseSystem() {}

virtual double GetTime() = 0;
virtual unsigned int GetTick() = 0;
virtual void SetFPS(float fps) = 0;

virtual void Printf(char *fmt, ...) = 0;
virtual void DPrintf(char *fmt, ...) = 0;

virtual void RedirectOutput(char *buffer = nullptr, int maxSize = 0) = 0;

virtual IFileSystem *GetFileSystem() = 0;
virtual unsigned char *LoadFile(const char *name, int *length = nullptr) = 0;
virtual void FreeFile(unsigned char *fileHandle) = 0;

virtual void SetTitle(char *text) = 0;
virtual void SetStatusLine(char *text) = 0;

virtual void ShowConsole(bool visible) = 0;
virtual void LogConsole(char *filename) = 0;

virtual bool InitVGUI(IVGuiModule *module) = 0;

#ifdef _WIN32
virtual Panel *GetPanel() = 0;
#endif // _WIN32

virtual bool RegisterCommand(char *name, ISystemModule *module, int commandID) = 0;
virtual void GetCommandMatches(char *string, ObjectList *pMatchList) = 0;
virtual void ExecuteString(char *commands) = 0;
virtual void ExecuteFile(char *filename) = 0;
virtual void Errorf(char *fmt, ...) = 0;

virtual char *CheckParam(char *param) = 0;

virtual bool AddModule(ISystemModule *module, char *name) = 0;
virtual ISystemModule *GetModule(char *interfacename, char *library, char *instancename = nullptr) = 0;
virtual bool RemoveModule(ISystemModule *module) = 0;

virtual void Stop() = 0;
virtual char *GetBaseDir() = 0;
};

#define BASESYSTEM_INTERFACE_VERSION "basesystem002"
Loading

0 comments on commit 2f2b7fe

Please sign in to comment.