A2S: Zuff's allmighty OCD fixing.
This commit is contained in:
parent
f166ca9f6c
commit
8c808be870
@ -8,7 +8,7 @@ builder.SetBuildFolder('package')
|
||||
# Add any folders you need to this list
|
||||
folder_list = [
|
||||
'addons/sourcemod/extensions',
|
||||
#'addons/sourcemod/scripting/include',
|
||||
'addons/sourcemod/scripting/include',
|
||||
#'addons/sourcemod/gamedata',
|
||||
#'addons/sourcemod/configs',
|
||||
]
|
||||
@ -29,9 +29,9 @@ def CopyFiles(src, dest, files):
|
||||
builder.AddCopy(source_path, dest_entry)
|
||||
|
||||
# Include files
|
||||
#CopyFiles('include', 'addons/sourcemod/scripting/include',
|
||||
# [ 'sample.inc', ]
|
||||
#)
|
||||
CopyFiles('include', 'addons/sourcemod/scripting/include',
|
||||
[ 'A2SFixes.inc', ]
|
||||
)
|
||||
|
||||
# GameData files
|
||||
#CopyFiles('gamedata', 'addons/sourcemod/gamedata',
|
||||
|
@ -62,14 +62,15 @@ ConVar g_A2SIncludeSourceTV("a2s_includesourcetv", "0", FCVAR_NONE, "Include Sou
|
||||
char *NewBuf;
|
||||
char *OldBuf;
|
||||
|
||||
struct PlayerInfo {
|
||||
int g_iFakePlayers = 0;
|
||||
|
||||
struct PlayerInfo
|
||||
{
|
||||
char Name[32];
|
||||
long Score;
|
||||
float Time;
|
||||
};
|
||||
|
||||
int g_FakePlayers = 0;
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*/
|
||||
@ -122,11 +123,14 @@ DETOUR_DECL_STATIC6(Detour_SendTo, int, int, s, char *, buf, int, len, int, flag
|
||||
for (int index = 0; index <= SM_MAXPLAYERS; index++)
|
||||
{
|
||||
IGamePlayer *pPlayer = playerhelpers->GetGamePlayer(index);
|
||||
|
||||
if (pPlayer != NULL && pPlayer->IsConnected() && (!pPlayer->IsSourceTV() || g_A2SIncludeSourceTV.GetInt()))
|
||||
{
|
||||
iPlayers++;
|
||||
}
|
||||
}
|
||||
|
||||
iPlayers += g_FakePlayers;
|
||||
iPlayers += g_iFakePlayers;
|
||||
|
||||
// Correct playercount
|
||||
memset(NewBuf, iPlayers, 1);
|
||||
@ -147,14 +151,6 @@ DETOUR_DECL_STATIC6(Detour_SendTo, int, int, s, char *, buf, int, len, int, flag
|
||||
|
||||
if (memcmp(buf, A2S_PLAYER_REPLY, 5) == 0)
|
||||
{
|
||||
char PlayerReply[1024 * 6];
|
||||
bf_write PlayerReplyPacket(PlayerReply, sizeof(PlayerReply));
|
||||
|
||||
PlayerReplyPacket.Reset(); // Build up the packet as a bitbuffer so we can use the nice helper functions to do the work for us
|
||||
|
||||
PlayerReplyPacket.WriteLong(-1); // FF FF FF FF
|
||||
PlayerReplyPacket.WriteByte(68); // 44
|
||||
|
||||
int iPlayers = 0;
|
||||
|
||||
PlayerInfo PlayerList[SM_MAXPLAYERS];
|
||||
@ -185,6 +181,14 @@ DETOUR_DECL_STATIC6(Detour_SendTo, int, int, s, char *, buf, int, len, int, flag
|
||||
}
|
||||
}
|
||||
|
||||
char PlayerReply[1024 * 6];
|
||||
bf_write PlayerReplyPacket(PlayerReply, sizeof(PlayerReply));
|
||||
|
||||
PlayerReplyPacket.Reset(); // Build up the packet as a bitbuffer so we can use the nice helper functions to do the work for us
|
||||
|
||||
PlayerReplyPacket.WriteLong(-1); // FF FF FF FF
|
||||
PlayerReplyPacket.WriteByte(68); // 44
|
||||
|
||||
PlayerReplyPacket.WriteByte(iPlayers); // Number of players
|
||||
|
||||
for (int index = 0; index < iPlayers; index++)
|
||||
@ -204,26 +208,21 @@ DETOUR_DECL_STATIC6(Detour_SendTo, int, int, s, char *, buf, int, len, int, flag
|
||||
/**
|
||||
* @brief
|
||||
*/
|
||||
cell_t FakePlayers(IPluginContext *pContext, const cell_t *params)
|
||||
cell_t SetFakePlayerCount(IPluginContext *pContext, const cell_t *params)
|
||||
{
|
||||
g_FakePlayers = params[1];
|
||||
g_iFakePlayers = params[1];
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*/
|
||||
const sp_nativeinfo_t MyNatives[] =
|
||||
const sp_nativeinfo_t g_ExtensionNatives[] =
|
||||
{
|
||||
{"FakePlayers", FakePlayers},
|
||||
{NULL, NULL},
|
||||
{"A2S_SetFakePlayerCount", SetFakePlayerCount},
|
||||
{NULL, NULL},
|
||||
};
|
||||
|
||||
void A2SFixes::SDK_OnAllLoaded()
|
||||
{
|
||||
sharesys->AddNatives(myself, MyNatives);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This is called after the initial loading sequence has been processed.
|
||||
*
|
||||
@ -261,10 +260,14 @@ void A2SFixes::SDK_OnUnload()
|
||||
}
|
||||
}
|
||||
|
||||
bool A2SFixes::RegisterConCommandBase(ConCommandBase *pVar)
|
||||
/**
|
||||
* @brief This is called once all known extensions have been loaded.
|
||||
* Note: It is is a good idea to add natives here, if any are provided.
|
||||
*/
|
||||
void A2SFixes::SDK_OnAllLoaded()
|
||||
{
|
||||
/* Always call META_REGCVAR instead of going through the engine. */
|
||||
return META_REGCVAR(pVar);
|
||||
sharesys->AddNatives(myself, g_ExtensionNatives);
|
||||
sharesys->RegisterLibrary(myself, "A2SFixes");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -282,4 +285,13 @@ bool A2SFixes::SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlen, bool
|
||||
ConVar_Register(0, this);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*/
|
||||
bool A2SFixes::RegisterConCommandBase(ConCommandBase *pVar)
|
||||
{
|
||||
/* Always call META_REGCVAR instead of going through the engine. */
|
||||
return META_REGCVAR(pVar);
|
||||
}
|
37
include/A2SFixes.inc
Normal file
37
include/A2SFixes.inc
Normal file
@ -0,0 +1,37 @@
|
||||
#if defined _A2SFixes_included
|
||||
#endinput
|
||||
#endif
|
||||
#define _A2SFixes_included
|
||||
|
||||
/**
|
||||
* Check if clients usertype is legit.
|
||||
*
|
||||
* @param count The amount of fakes to set.
|
||||
*
|
||||
* @return Always true.
|
||||
*/
|
||||
native bool A2S_SetFakePlayerCount(int count);
|
||||
|
||||
|
||||
public Extension __ext_A2SFixes =
|
||||
{
|
||||
name = "A2SFixes",
|
||||
file = "A2SFixes.ext",
|
||||
#if defined AUTOLOAD_EXTENSIONS
|
||||
autoload = 1,
|
||||
#else
|
||||
autoload = 0,
|
||||
#endif
|
||||
#if defined REQUIRE_EXTENSIONS
|
||||
required = 1,
|
||||
#else
|
||||
required = 0,
|
||||
#endif
|
||||
};
|
||||
|
||||
#if !defined REQUIRE_EXTENSIONS
|
||||
public __ext_A2SFixes_SetNTVOptional()
|
||||
{
|
||||
MarkNativeAsOptional("A2S_SetFakePlayerCount");
|
||||
}
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user