Skip to content

Commit

Permalink
Also do the hooks on non-dedicated servers
Browse files Browse the repository at this point in the history
Right now we only hook the SendProxies for the SrcTV client, but really
we might as well hook them for non-dedicated servers as well. This
allows srctv+ to provide its extra data when used on listen servers.

This has no impact on existing deployments.
  • Loading branch information
dalegaard committed Aug 21, 2018
1 parent 72bfc72 commit ea45450
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions srctvplus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
IServerGameDLL* g_pGameDLL;
IFileSystem* g_pFileSystem;
IHLTVDirector* g_pHLTVDirector;
IVEngineServer* engine;

class SrcTVPlus : public IServerPluginCallbacks {
public:
Expand Down Expand Up @@ -88,13 +89,19 @@ typedef void* (*SendTableProxyFn)(
// Calls a sendproxy and adds the HLTV pseudo client to the returned recipients list
void* SendProxy_IncludeHLTV(SendTableProxyFn fn, const SendProp* pProp, const void* pStructBase, const void* pData, CSendProxyRecipients* pRecipients, int objectID) {
const char* ret = (const char*)fn(pProp, pStructBase, pData, pRecipients, objectID);
if(ret) {
auto server = g_pHLTVDirector->GetHLTVServer();
if(server) {
auto slot = server->GetHLTVSlot();
if(slot >= 0) {
pRecipients->m_Bits.Set(slot);
if (ret) {
if (engine->IsDedicatedServer()) {
// Normal dedicated server
auto server = g_pHLTVDirector->GetHLTVServer();
if (server) {
auto slot = server->GetHLTVSlot();
if (slot >= 0) {
pRecipients->m_Bits.Set(slot);
}
}
} else {
// Listen server
pRecipients->m_Bits.Set(0);
}
}
return (void*)ret;
Expand Down Expand Up @@ -213,6 +220,12 @@ bool SrcTVPlus::Load(CreateInterfaceFn interfaceFactory, CreateInterfaceFn gameS
return false;
}

engine = (IVEngineServer*)interfaceFactory(INTERFACEVERSION_VENGINESERVER, nullptr);
if (!engine) {
Error("[srctv+] Could not find engine interface, aborting load\n");
return false;
}

g_pFileSystem = (IFileSystem*)interfaceFactory(FILESYSTEM_INTERFACE_VERSION, nullptr);
if(!g_pFileSystem) {
Error("[srctv+] Could not find filesystem interface, aborting load\n");
Expand Down

0 comments on commit ea45450

Please sign in to comment.