2016-02-29 09:59:09 +01:00
|
|
|
/**
|
2016-03-01 02:19:19 +01:00
|
|
|
* vim: set ts=4 :
|
|
|
|
* =============================================================================
|
|
|
|
* SourceMod SourceTV Manager Extension
|
|
|
|
* Copyright (C) 2004-2016 AlliedModders LLC. All rights reserved.
|
|
|
|
* =============================================================================
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it under
|
|
|
|
* the terms of the GNU General Public License, version 3.0, as published by the
|
|
|
|
* Free Software Foundation.
|
|
|
|
*
|
|
|
|
* 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, see <http://www.gnu.org/licenses/>.
|
|
|
|
*
|
|
|
|
* As a special exception, AlliedModders LLC gives you permission to link the
|
|
|
|
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
|
|
|
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
|
|
|
* by the Valve Corporation. You must obey the GNU General Public License in
|
|
|
|
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
|
|
|
* this exception to all derivative works. AlliedModders LLC defines further
|
|
|
|
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
|
|
|
* or <http://www.sourcemod.net/license.php>.
|
|
|
|
*
|
|
|
|
* Version: $Id$
|
|
|
|
*/
|
2016-02-29 09:59:09 +01:00
|
|
|
|
|
|
|
#ifndef _INCLUDE_SOURCEMOD_EXTENSION_FORWARDS_H_
|
|
|
|
#define _INCLUDE_SOURCEMOD_EXTENSION_FORWARDS_H_
|
|
|
|
|
|
|
|
#include "extension.h"
|
|
|
|
|
2016-03-03 01:12:16 +01:00
|
|
|
#if SOURCE_ENGINE == SE_CSGO
|
|
|
|
#include "netmessages.pb.h"
|
|
|
|
|
|
|
|
template <int Type, class NetMessage, int Group, bool reliable>
|
|
|
|
class CNetMessagePB : public INetMessage, public NetMessage {
|
|
|
|
public:
|
|
|
|
~CNetMessagePB() {}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef CNetMessagePB<16, CCLCMsg_SplitPlayerConnect, 0, true> NetMsg_SplitPlayerConnect;
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2016-03-03 07:17:40 +01:00
|
|
|
typedef enum EAuthProtocol
|
|
|
|
{
|
|
|
|
k_EAuthProtocolWONCertificate = 1,
|
|
|
|
k_EAuthProtocolHashedCDKey = 2,
|
|
|
|
k_EAuthProtocolSteam = 3
|
|
|
|
} EAuthProtocol;
|
|
|
|
|
2016-02-29 09:59:09 +01:00
|
|
|
class CGameInfo;
|
|
|
|
|
|
|
|
class CForwardManager
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
void Init();
|
|
|
|
void Shutdown();
|
|
|
|
|
|
|
|
void HookRecorder(IDemoRecorder *recorder);
|
|
|
|
void UnhookRecorder(IDemoRecorder *recorder);
|
|
|
|
|
2016-03-08 16:57:07 +01:00
|
|
|
void HookServer(HLTVServerWrapper *server);
|
|
|
|
void UnhookServer(HLTVServerWrapper *server);
|
2016-03-02 23:23:53 +01:00
|
|
|
|
2016-03-09 23:04:28 +01:00
|
|
|
#ifndef WIN32
|
2016-11-14 08:16:39 +01:00
|
|
|
void CreateStartRecordingDetour();
|
2016-03-09 23:04:28 +01:00
|
|
|
void RemoveStartRecordingDetour();
|
2016-11-14 08:16:39 +01:00
|
|
|
void CreateStopRecordingDetour();
|
2016-03-09 23:04:28 +01:00
|
|
|
void RemoveStopRecordingDetour();
|
|
|
|
#endif
|
|
|
|
|
2016-03-06 12:16:38 +01:00
|
|
|
void CallOnServerStart(IHLTVServer *server);
|
|
|
|
void CallOnServerShutdown(IHLTVServer *server);
|
|
|
|
|
2016-03-09 23:04:28 +01:00
|
|
|
void CallOnStartRecording(IDemoRecorder *recorder, const char *filename, bool bContinuously);
|
|
|
|
void CallOnStopRecording(IDemoRecorder *recorder);
|
|
|
|
|
2016-11-14 08:16:39 +01:00
|
|
|
bool CallOnSpectatorChatMessage(HLTVServerWrapper *server, char *msg, int msglen, char *chatgroup, int grouplen);
|
|
|
|
void CallOnSpectatorChatMessage_Post(HLTVServerWrapper *server, const char *msg, const char *chatgroup);
|
|
|
|
|
|
|
|
bool OnSpectatorExecuteStringCommand(const char *s);
|
2016-11-16 05:02:03 +01:00
|
|
|
bool OnSpectatorExecuteStringCommand_Post(const char *s);
|
2016-11-14 08:16:39 +01:00
|
|
|
void CreateBroadcastLocalChatDetour();
|
|
|
|
void RemoveBroadcastLocalChatDetour();
|
|
|
|
|
2016-03-02 23:23:53 +01:00
|
|
|
private:
|
|
|
|
void HookClient(IClient *client);
|
|
|
|
void UnhookClient(IClient *client);
|
|
|
|
|
2016-02-29 09:59:09 +01:00
|
|
|
private:
|
|
|
|
void OnStartRecording_Post(const char *filename, bool bContinuously);
|
2016-02-29 14:55:23 +01:00
|
|
|
#if SOURCE_ENGINE == SE_CSGO
|
2016-03-10 15:20:33 +01:00
|
|
|
void OnStopRecording(CGameInfo const *info);
|
2016-03-03 07:17:40 +01:00
|
|
|
IClient *OnSpectatorConnect(const netadr_t & address, int nProtocol, int iChallenge, int nAuthProtocol, const char *pchName, const char *pchPassword, const char *pCookie, int cbCookie, CUtlVector<NetMsg_SplitPlayerConnect *> &pSplitPlayerConnectVector, bool bUnknown, CrossPlayPlatform_t platform, const unsigned char *pUnknown, int iUnknown);
|
2016-12-05 05:41:07 +01:00
|
|
|
#elif SOURCE_ENGINE == SE_LEFT4DEAD || SOURCE_ENGINE == SE_LEFT4DEAD2
|
2016-12-05 05:05:06 +01:00
|
|
|
void OnStopRecording();
|
|
|
|
IClient *OnSpectatorConnect(const netadr_t & address, int nProtocol, int iChallenge, int iClientChallenge, const char * pchName, const char * pchPassword, const char * pCookie, int, CUtlVector<CLC_SplitPlayerConnect *> &pSplitPlayerConnectVector, bool bUnknown);
|
2016-02-29 14:55:23 +01:00
|
|
|
#else
|
2016-03-10 15:20:33 +01:00
|
|
|
void OnStopRecording();
|
2016-03-02 23:23:53 +01:00
|
|
|
IClient *OnSpectatorConnect(netadr_t &address, int nProtocol, int iChallenge, int iClientChallenge, int nAuthProtocol, const char *pchName, const char *pchPassword, const char *pCookie, int cbCookie);
|
2016-02-29 14:55:23 +01:00
|
|
|
#endif
|
2016-03-17 13:39:52 +01:00
|
|
|
void BaseClient_OnSpectatorDisconnect(const char *reason);
|
|
|
|
void IClient_OnSpectatorDisconnect(const char *reason);
|
2016-03-03 07:23:49 +01:00
|
|
|
void OnSpectatorPutInServer();
|
2016-02-29 09:59:09 +01:00
|
|
|
|
2016-03-03 07:17:40 +01:00
|
|
|
int OnGetChallengeType(const netadr_t &address);
|
|
|
|
|
2016-03-17 13:39:52 +01:00
|
|
|
private:
|
|
|
|
void HandleSpectatorDisconnect(IClient *client, const char *reason);
|
|
|
|
|
2016-02-29 09:59:09 +01:00
|
|
|
private:
|
|
|
|
IForward *m_StartRecordingFwd;
|
|
|
|
IForward *m_StopRecordingFwd;
|
2016-03-02 23:23:53 +01:00
|
|
|
IForward *m_SpectatorPreConnectFwd;
|
|
|
|
IForward *m_SpectatorConnectedFwd;
|
|
|
|
IForward *m_SpectatorDisconnectFwd;
|
|
|
|
IForward *m_SpectatorDisconnectedFwd;
|
2016-03-03 07:23:49 +01:00
|
|
|
IForward *m_SpectatorPutInServerFwd;
|
2016-11-14 08:16:39 +01:00
|
|
|
IForward *m_SpectatorChatMessageFwd;
|
|
|
|
IForward *m_SpectatorChatMessagePostFwd;
|
2016-03-02 23:23:53 +01:00
|
|
|
|
2016-03-06 12:16:38 +01:00
|
|
|
IForward *m_ServerStartFwd;
|
|
|
|
IForward *m_ServerShutdownFwd;
|
|
|
|
|
2016-03-02 23:23:53 +01:00
|
|
|
bool m_bHasClientConnectOffset = false;
|
2016-03-03 09:13:59 +01:00
|
|
|
bool m_bHasRejectConnectionOffset = false;
|
2016-03-03 07:17:40 +01:00
|
|
|
bool m_bHasGetChallengeTypeOffset = false;
|
2016-03-03 07:23:49 +01:00
|
|
|
bool m_bHasActivatePlayerOffset = false;
|
2016-03-17 13:39:52 +01:00
|
|
|
bool m_bHasDisconnectOffset = false;
|
2016-03-09 23:04:28 +01:00
|
|
|
|
2016-11-14 08:16:39 +01:00
|
|
|
bool m_bBroadcastLocalChatDetoured = false;
|
|
|
|
CDetour *m_DBroadcastLocalChat = nullptr;
|
|
|
|
|
2016-03-09 23:04:28 +01:00
|
|
|
// Only need the detours on linux. Windows always uses its vtables..
|
|
|
|
#ifndef WIN32
|
|
|
|
bool m_bStartRecordingDetoured = false;
|
|
|
|
CDetour *m_DStartRecording = nullptr;
|
|
|
|
bool m_bStopRecordingDetoured = false;
|
|
|
|
CDetour *m_DStopRecording = nullptr;
|
|
|
|
#endif
|
2016-02-29 09:59:09 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
extern CForwardManager g_pSTVForwards;
|
|
|
|
|
2016-03-08 16:57:07 +01:00
|
|
|
#endif // _INCLUDE_SOURCEMOD_EXTENSION_FORWARDS_H_
|