im bad at video games, the test build™️

This commit is contained in:
george 2019-05-21 02:22:26 +01:00
parent 7bd2b07064
commit 58bb670958
3 changed files with 24 additions and 16 deletions

View File

@ -32,9 +32,10 @@
#include "extension.h"
#include "string.h"
#include "sys/socket.h"
#include "iplayerinfo.h"
#include <inetchannel.h>
#include "CDetour/detours.h"
#include <bitbuf.h>
#include <inetchannel.h>
#define DETOUR_CREATE_MEMBER_ADDRESS(name, address) CDetourManager::CreateDetour(GET_MEMBER_CALLBACK(name), GET_MEMBER_TRAMPOLINE(name), address);
#define DETOUR_CREATE_STATIC_ADDRESS(name, address) CDetourManager::CreateDetour(GET_STATIC_CALLBACK(name), GET_STATIC_TRAMPOLINE(name), address);
@ -57,7 +58,7 @@ CDetour *g_pDetour_SendTo = NULL;
CDetour *g_pDetour_RecvFrom = NULL;
char g_PlayerReply[1024];
bf_write g_PlayerReplyPacket(PlayerReply, 1024);
bf_write g_PlayerReplyPacket(g_PlayerReply, 1024);
char *NewBuf;
char *OldBuf;
@ -132,12 +133,12 @@ DETOUR_DECL_STATIC6(Detour_SendTo, int, int, s, char *, buf, int, len, int, flag
{
g_pSM->LogMessage(myself, "A2S_PLAYER_REPLY: %s", buf);
g_PlayerReply.Reset(); //build up the packet as a bitbuffer so we can use the nice helper functions to do the work for us
g_PlayerReplyPacket.Reset(); //build up the packet as a bitbuffer so we can use the nice helper functions to do the work for us
g_PlayerReply.WriteLong(-1);//FF FF FF FF
g_PlayerReply.WriteByte(68);//44
g_PlayerReplyPacket.WriteLong(-1);//FF FF FF FF
g_PlayerReplyPacket.WriteByte(68);//44
g_PlayerReply.WriteByte(playerhelpers->GetNumPlayers()); //number of players
g_PlayerReplyPacket.WriteByte(playerhelpers->GetNumPlayers()); //number of players
int iPlayers = 0;
@ -148,26 +149,26 @@ DETOUR_DECL_STATIC6(Detour_SendTo, int, int, s, char *, buf, int, len, int, flag
if (pPlayer != NULL && pPlayer->IsConnected() && pPlayer->IsInGame() && !pPlayer->IsSourceTV())
{
IPlayerInfo *pInfo = pPlayer->GetPlayerInfo();
INetChannelInfo *pNetInfo = engine->GetPlayerNetInfo(client);
INetChannelInfo *pNetInfo = engine->GetPlayerNetInfo(index);
g_PlayerReply.WriteByte(iPlayers);
g_PlayerReply.WriteString(pPlayer->GetName());
g_PlayerReplyPacket.WriteByte(iPlayers);
g_PlayerReplyPacket.WriteString(pPlayer->GetName());
if(pInfo != NULL)
g_PlayerReply.WriteLong(pInfo->GetFragCount());
g_PlayerReplyPacket.WriteLong(pInfo->GetFragCount());
else
g_PlayerReply.WriteLong(0);
g_PlayerReplyPacket.WriteLong(0);
if(pNetInfo != NULL)
g_PlayerReply.WriteFloat(pNetInfo->GetTimeConnected());
g_PlayerReplyPacket.WriteFloat(pNetInfo->GetTimeConnected());
else
g_PlayerReply.WriteFloat(0.0);
g_PlayerReplyPacket.WriteFloat(0.0);
iPlayers++;
}
}
return DETOUR_STATIC_CALL(Detour_SendTo)(s, (const char *)g_PlayerReply.GetData(), g_PlayerReply.GetNumBytesWritten(), flags, to, tolen);
return DETOUR_STATIC_CALL(Detour_SendTo)(s, (char *)g_PlayerReplyPacket.GetData(), g_PlayerReplyPacket.GetNumBytesWritten(), flags, to, tolen);
}
return DETOUR_STATIC_CALL(Detour_SendTo)(s, buf, len, flags, to, tolen);
@ -191,6 +192,13 @@ DETOUR_DECL_STATIC6(Detour_RecvFrom, int, int, s, char *, buf, int, len, int, fl
return DETOUR_STATIC_CALL(Detour_RecvFrom)(s, buf, len, flags, from, fromlen);
}
bool A2SFixes::SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlen, bool late)
{
GET_V_IFACE_CURRENT(GetEngineFactory, engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER);
return true;
}
/**
* @brief This is called after the initial loading sequence has been processed.
*

View File

@ -91,7 +91,7 @@ public:
* @param late Whether or not Metamod considers this a late load.
* @return True to succeed, false to fail.
*/
//virtual bool SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlength, bool late);
virtual bool SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlength, bool late);
/**
* @brief Called when Metamod is detaching, after the extension version is called.

View File

@ -56,7 +56,7 @@
* @brief Sets whether or not this plugin required Metamod.
* NOTE: Uncomment to enable, comment to disable.
*/
//#define SMEXT_CONF_METAMOD
#define SMEXT_CONF_METAMOD
/** Enable interfaces you want to use here by uncommenting lines */
//#define SMEXT_ENABLE_FORWARDSYS