just updating plugins to 64bit support
This commit is contained in:
@@ -8,6 +8,7 @@
|
|||||||
"ForceVPhysicsCollide"
|
"ForceVPhysicsCollide"
|
||||||
{
|
{
|
||||||
"linux" "160"
|
"linux" "160"
|
||||||
|
"linux64" "160"
|
||||||
"windows" "159"
|
"windows" "159"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -15,6 +16,7 @@
|
|||||||
"PlayerUse"
|
"PlayerUse"
|
||||||
{
|
{
|
||||||
"linux" "414"
|
"linux" "414"
|
||||||
|
"linux64" "414"
|
||||||
"windows" "413"
|
"windows" "413"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -28,6 +30,7 @@
|
|||||||
{
|
{
|
||||||
"library" "server"
|
"library" "server"
|
||||||
"linux" "@_ZN15CCollisionEvent13ShouldCollideEP14IPhysicsObjectS1_PvS2_"
|
"linux" "@_ZN15CCollisionEvent13ShouldCollideEP14IPhysicsObjectS1_PvS2_"
|
||||||
|
"linux64" "@_ZN15CCollisionEvent13ShouldCollideEP14IPhysicsObjectS1_PvS2_"
|
||||||
}
|
}
|
||||||
|
|
||||||
// CBaseEntity::CollisionRulesChanged(). Makes vphysics re-ask ShouldCollide for cached pairs.
|
// CBaseEntity::CollisionRulesChanged(). Makes vphysics re-ask ShouldCollide for cached pairs.
|
||||||
@@ -35,6 +38,7 @@
|
|||||||
{
|
{
|
||||||
"library" "server"
|
"library" "server"
|
||||||
"linux" "@_ZN11CBaseEntity21CollisionRulesChangedEv"
|
"linux" "@_ZN11CBaseEntity21CollisionRulesChangedEv"
|
||||||
|
"linux64" "@_ZN11CBaseEntity21CollisionRulesChangedEv"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1182,8 +1182,8 @@ void LoadGameData()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
DHookAddParam(g_hShouldCollideDetour, HookParamType_Int); // IPhysicsObject *pObj0
|
DHookAddParam(g_hShouldCollideDetour, HookParamType_ObjectPtr); // IPhysicsObject *pObj0 (pointer-sized: 4 bytes x86, 8 bytes x64)
|
||||||
DHookAddParam(g_hShouldCollideDetour, HookParamType_Int); // IPhysicsObject *pObj1
|
DHookAddParam(g_hShouldCollideDetour, HookParamType_ObjectPtr); // IPhysicsObject *pObj1
|
||||||
DHookAddParam(g_hShouldCollideDetour, HookParamType_CBaseEntity); // void *pGameData0: entity behind pObj0
|
DHookAddParam(g_hShouldCollideDetour, HookParamType_CBaseEntity); // void *pGameData0: entity behind pObj0
|
||||||
DHookAddParam(g_hShouldCollideDetour, HookParamType_CBaseEntity); // void *pGameData1: entity behind pObj1
|
DHookAddParam(g_hShouldCollideDetour, HookParamType_CBaseEntity); // void *pGameData1: entity behind pObj1
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,10 @@
|
|||||||
{
|
{
|
||||||
"signature" "g_fGameOver"
|
"signature" "g_fGameOver"
|
||||||
}
|
}
|
||||||
|
"linux64"
|
||||||
|
{
|
||||||
|
"signature" "g_fGameOver"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -19,6 +23,7 @@
|
|||||||
{
|
{
|
||||||
"library" "server"
|
"library" "server"
|
||||||
"linux" "@g_fGameOver"
|
"linux" "@g_fGameOver"
|
||||||
|
"linux64" "@g_fGameOver"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+377
-229
@@ -3,26 +3,46 @@
|
|||||||
|
|
||||||
#include <sourcemod>
|
#include <sourcemod>
|
||||||
#include <sdktools>
|
#include <sdktools>
|
||||||
|
#include <multicolors>
|
||||||
|
|
||||||
|
#undef REQUIRE_PLUGIN
|
||||||
|
#tryinclude <mapchooser_extended>
|
||||||
|
#define REQUIRE_PLUGIN
|
||||||
|
|
||||||
#define VOTE_NO "###no###"
|
#define VOTE_NO "###no###"
|
||||||
#define VOTE_YES "###yes###"
|
#define VOTE_YES "###yes###"
|
||||||
|
#define PLUGIN_TAG "{green}[Extend]"
|
||||||
|
|
||||||
ConVar g_cvarExtendVoteTime = null;
|
// Largest mp_timelimit we allow; floats are exact up to 2^24 and the engine also converts it to int
|
||||||
ConVar g_cvarExtendVotePercent = null;
|
#define MAX_TIMELIMIT_MINUTES 16777216.0
|
||||||
ConVar g_cvarMpMaxRounds = null;
|
|
||||||
ConVar g_cvarMpFragLimit = null;
|
|
||||||
ConVar g_cvarMpWinLimit = null;
|
|
||||||
ConVar g_cvarMpTimeLimit = null;
|
|
||||||
|
|
||||||
bool g_bGameOver = false;
|
int g_iNumAttempts = 0;
|
||||||
|
int g_iExtendCount = 0;
|
||||||
|
int g_iExtendTime = 0;
|
||||||
|
float g_fVoteRequired = 0.0;
|
||||||
|
|
||||||
|
ConVar g_cvarExtendVoteTime;
|
||||||
|
ConVar g_cvarExtendVoteMaxDuration;
|
||||||
|
ConVar g_cvarExtendVotePercent;
|
||||||
|
ConVar g_cvarExtendVotePercentIncrement;
|
||||||
|
ConVar g_cvarExtendVotePercentMax;
|
||||||
|
ConVar g_cvarExtendVoteMaxFailedAttempt;
|
||||||
|
ConVar g_cvarExtendVote;
|
||||||
|
ConVar g_cvarMpMaxRounds;
|
||||||
|
ConVar g_cvarMpFragLimit;
|
||||||
|
ConVar g_cvarMpWinLimit;
|
||||||
|
ConVar g_cvarMpTimeLimit;
|
||||||
|
ConVar g_cvarRequireAllExtends;
|
||||||
|
|
||||||
|
bool g_bCanCancelGameOver = false;
|
||||||
Address g_pGameOver;
|
Address g_pGameOver;
|
||||||
|
|
||||||
public Plugin myinfo =
|
public Plugin myinfo =
|
||||||
{
|
{
|
||||||
name = "Map extend tools",
|
name = "Map Extend Tools",
|
||||||
author = "Obus + BotoX",
|
author = "Obus, BotoX, .Rushaway, koen",
|
||||||
description = "Adds map extension commands.",
|
description = "Adds map extension commands.",
|
||||||
version = "1.0",
|
version = "1.4.5",
|
||||||
url = ""
|
url = ""
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -30,16 +50,23 @@ public void OnPluginStart()
|
|||||||
{
|
{
|
||||||
LoadTranslations("common.phrases");
|
LoadTranslations("common.phrases");
|
||||||
LoadTranslations("basevotes.phrases");
|
LoadTranslations("basevotes.phrases");
|
||||||
|
LoadTranslations("extend.phrases");
|
||||||
|
|
||||||
g_cvarMpMaxRounds = FindConVar("mp_maxrounds");
|
g_cvarMpMaxRounds = FindConVar("mp_maxrounds");
|
||||||
g_cvarMpFragLimit = FindConVar("mp_fraglimit");
|
g_cvarMpFragLimit = FindConVar("mp_fraglimit");
|
||||||
g_cvarMpWinLimit = FindConVar("mp_winlimit");
|
g_cvarMpWinLimit = FindConVar("mp_winlimit");
|
||||||
g_cvarMpTimeLimit = FindConVar("mp_timelimit");
|
g_cvarMpTimeLimit = FindConVar("mp_timelimit");
|
||||||
|
|
||||||
|
g_cvarExtendVote = CreateConVar("sm_extendvote_enabled", "1", "Enable Extend Vote? [1 = Enable | 0 = Disable]", FCVAR_NONE, true, 0.0, true, 1.0);
|
||||||
g_cvarExtendVoteTime = CreateConVar("sm_extendvote_time", "15", "Time that will be added to mp_timelimit shall the extend vote succeed", FCVAR_NONE, true, 1.0);
|
g_cvarExtendVoteTime = CreateConVar("sm_extendvote_time", "15", "Time that will be added to mp_timelimit shall the extend vote succeed", FCVAR_NONE, true, 1.0);
|
||||||
|
g_cvarExtendVoteMaxDuration = CreateConVar("sm_extendvote_max_duration", "30", "Maximum minutes an admin can request with \"sm_extend <time>\"", FCVAR_NONE, true, 1.0);
|
||||||
g_cvarExtendVotePercent = CreateConVar("sm_extendvote_percent", "0.6", "Percentage of \"yes\" votes required to consider the vote successful", FCVAR_NONE, true, 0.05, true, 1.0);
|
g_cvarExtendVotePercent = CreateConVar("sm_extendvote_percent", "0.6", "Percentage of \"yes\" votes required to consider the vote successful", FCVAR_NONE, true, 0.05, true, 1.0);
|
||||||
|
g_cvarExtendVotePercentIncrement = CreateConVar("sm_extendvote_percent_increment", "0.1", "Percentage added to the required \"yes\" votes for each successful extend vote on the current map", FCVAR_NONE, true, 0.0, true, 1.0);
|
||||||
|
g_cvarExtendVotePercentMax = CreateConVar("sm_extendvote_percent_max", "0.9", "Maximum percentage of \"yes\" votes that can be required after increments", FCVAR_NONE, true, 0.05, true, 1.0);
|
||||||
|
g_cvarExtendVoteMaxFailedAttempt = CreateConVar("sm_extendvote_maxfailed", "0", "Maximum Extend vote failed before locking the Extend vote command \n0 = Disable this function", FCVAR_NONE, true, 0.0);
|
||||||
|
g_cvarRequireAllExtends = CreateConVar("sm_extendvote_require_all_extends", "1", "Require all mapchooser extends to be used before admins can call for extend? Only works with MapChooser Extended [1 = Yes | 0 = No]", FCVAR_NONE, true, 0.0, true, 1.0);
|
||||||
|
|
||||||
AutoExecConfig(true, "plugin.Extend");
|
AutoExecConfig(true);
|
||||||
|
|
||||||
if (g_cvarMpMaxRounds != null)
|
if (g_cvarMpMaxRounds != null)
|
||||||
RegAdminCmd("sm_extend_rounds", Command_Extend_Rounds, ADMFLAG_GENERIC, "Add more rounds to mp_maxrounds");
|
RegAdminCmd("sm_extend_rounds", Command_Extend_Rounds, ADMFLAG_GENERIC, "Add more rounds to mp_maxrounds");
|
||||||
@@ -58,240 +85,128 @@ public void OnPluginStart()
|
|||||||
|
|
||||||
if (g_cvarMpTimeLimit != null)
|
if (g_cvarMpTimeLimit != null)
|
||||||
{
|
{
|
||||||
RegAdminCmd("sm_extend", Command_Extend, ADMFLAG_GENERIC, "Add more time to mp_timelimit");
|
RegAdminCmd("sm_extendmap", Command_Extend, ADMFLAG_GENERIC, "Add more time to mp_timelimit");
|
||||||
RegAdminCmd("sm_extend_time", Command_Extend, ADMFLAG_GENERIC, "Add more time to mp_timelimit");
|
RegAdminCmd("sm_extend", Command_ExtendVote, ADMFLAG_GENERIC, "sm_extend [time] - Start an extendvote");
|
||||||
RegAdminCmd("sm_extendvote", Command_ExtendVote, ADMFLAG_GENERIC, "sm_extendvote [time] - Start an extendvote");
|
|
||||||
RegAdminCmd("sm_voteextend", Command_ExtendVote, ADMFLAG_GENERIC, "sm_voteextend [time] - Start an extendvote");
|
// Relies on the m_fRoundStartTime gamerules prop, which only Counter-Strike games have
|
||||||
RegAdminCmd("sm_extend_vote", Command_ExtendVote, ADMFLAG_GENERIC, "sm_extend_vote [time] - Start an extendvote");
|
EngineVersion engine = GetEngineVersion();
|
||||||
|
if (engine == Engine_CSS || engine == Engine_CSGO)
|
||||||
|
RegAdminCmd("sm_roundextend", Command_RoundExtend, ADMFLAG_GENERIC, "sm_roundextend - Extend mp_timelimit elapsed time since the start of the round");
|
||||||
|
else
|
||||||
|
LogMessage("\"sm_roundextend\" is only supported on Counter-Strike games and will be disabled.");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
|
||||||
LogMessage("Failed to find \"mp_timelimit\" console variable, related commands will be disabled.");
|
LogMessage("Failed to find \"mp_timelimit\" console variable, related commands will be disabled.");
|
||||||
}
|
|
||||||
|
|
||||||
Handle hGameConf = LoadGameConfigFile("Extend.games");
|
GameData hGameConf = new GameData("Extend.games");
|
||||||
if(hGameConf == INVALID_HANDLE)
|
if (!hGameConf)
|
||||||
{
|
{
|
||||||
g_bGameOver = false;
|
|
||||||
LogError("Couldn't load Extend.games game config! GameOver cancel disabled.");
|
LogError("Couldn't load Extend.games game config! GameOver cancel disabled.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!(g_pGameOver = GameConfGetAddress(hGameConf, "GameOver")))
|
g_pGameOver = hGameConf.GetAddress("GameOver");
|
||||||
{
|
|
||||||
g_bGameOver = false;
|
|
||||||
delete hGameConf;
|
delete hGameConf;
|
||||||
|
|
||||||
|
if (!g_pGameOver)
|
||||||
|
{
|
||||||
LogError("Couldn't get GameOver address from game config! GameOver cancel disabled.");
|
LogError("Couldn't get GameOver address from game config! GameOver cancel disabled.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_bGameOver = true;
|
g_bCanCancelGameOver = true;
|
||||||
delete hGameConf;
|
}
|
||||||
|
|
||||||
|
public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max)
|
||||||
|
{
|
||||||
|
#if defined _mapchooser_extended_included_
|
||||||
|
MarkNativeAsOptional("GetExtendsLeft");
|
||||||
|
#endif
|
||||||
|
return APLRes_Success;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnMapEnd()
|
||||||
|
{
|
||||||
|
g_iNumAttempts = 0;
|
||||||
|
g_iExtendCount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Action Command_Extend_Rounds(int client, int argc)
|
public Action Command_Extend_Rounds(int client, int argc)
|
||||||
{
|
{
|
||||||
if (argc < 1)
|
return HandleLimitCommand(client, argc, g_cvarMpMaxRounds, "sm_extend_rounds", "rounds", "Unit Round", "Unit Rounds");
|
||||||
{
|
|
||||||
ReplyToCommand(client, "[SM] Usage: sm_extend_rounds <rounds>");
|
|
||||||
return Plugin_Handled;
|
|
||||||
}
|
|
||||||
|
|
||||||
char sArgs[16];
|
|
||||||
|
|
||||||
GetCmdArg(1, sArgs, sizeof(sArgs));
|
|
||||||
|
|
||||||
if (sArgs[0] == '-')
|
|
||||||
{
|
|
||||||
int iRoundsToDeduct;
|
|
||||||
|
|
||||||
if (!StringToIntEx(sArgs[1], iRoundsToDeduct))
|
|
||||||
{
|
|
||||||
ReplyToCommand(client, "[SM] Invalid value");
|
|
||||||
return Plugin_Handled;
|
|
||||||
}
|
|
||||||
|
|
||||||
g_cvarMpMaxRounds.IntValue -= iRoundsToDeduct;
|
|
||||||
|
|
||||||
LogAction(client, -1, "\"%L\" deducted \"%d\" rounds from \"mp_maxrounds\"", client, iRoundsToDeduct);
|
|
||||||
|
|
||||||
return Plugin_Handled;
|
|
||||||
}
|
|
||||||
|
|
||||||
int iRoundsToAdd;
|
|
||||||
|
|
||||||
if (!StringToIntEx(sArgs, iRoundsToAdd))
|
|
||||||
{
|
|
||||||
ReplyToCommand(client, "[SM] Invalid value");
|
|
||||||
return Plugin_Handled;
|
|
||||||
}
|
|
||||||
|
|
||||||
g_cvarMpMaxRounds.IntValue += iRoundsToAdd;
|
|
||||||
CancelGameOver();
|
|
||||||
|
|
||||||
LogAction(client, -1, "\"%L\" added \"%d\" rounds to \"mp_maxrounds\"", client, iRoundsToAdd);
|
|
||||||
|
|
||||||
return Plugin_Handled;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Action Command_Extend_Frags(int client, int argc)
|
public Action Command_Extend_Frags(int client, int argc)
|
||||||
{
|
{
|
||||||
if (argc < 1)
|
return HandleLimitCommand(client, argc, g_cvarMpFragLimit, "sm_extend_frags", "frags", "Unit Frag", "Unit Frags");
|
||||||
{
|
|
||||||
ReplyToCommand(client, "[SM] Usage: sm_extend_frags <frags>");
|
|
||||||
return Plugin_Handled;
|
|
||||||
}
|
|
||||||
|
|
||||||
char sArgs[16];
|
|
||||||
|
|
||||||
GetCmdArg(1, sArgs, sizeof(sArgs));
|
|
||||||
|
|
||||||
if (sArgs[0] == '-')
|
|
||||||
{
|
|
||||||
int iFragsToDeduct;
|
|
||||||
|
|
||||||
if (!StringToIntEx(sArgs[1], iFragsToDeduct))
|
|
||||||
{
|
|
||||||
ReplyToCommand(client, "[SM] Invalid value");
|
|
||||||
return Plugin_Handled;
|
|
||||||
}
|
|
||||||
|
|
||||||
g_cvarMpFragLimit.IntValue -= iFragsToDeduct;
|
|
||||||
|
|
||||||
LogAction(client, -1, "\"%L\" deducted \"%d\" frags from \"mp_fraglimit\"", client, iFragsToDeduct);
|
|
||||||
|
|
||||||
return Plugin_Handled;
|
|
||||||
}
|
|
||||||
|
|
||||||
int iFragsToAdd;
|
|
||||||
|
|
||||||
if (!StringToIntEx(sArgs, iFragsToAdd))
|
|
||||||
{
|
|
||||||
ReplyToCommand(client, "[SM] Invalid value");
|
|
||||||
return Plugin_Handled;
|
|
||||||
}
|
|
||||||
|
|
||||||
g_cvarMpFragLimit.IntValue += iFragsToAdd;
|
|
||||||
CancelGameOver();
|
|
||||||
|
|
||||||
LogAction(client, -1, "\"%L\" added \"%d\" frags to \"mp_fraglimit\"", client, iFragsToAdd);
|
|
||||||
|
|
||||||
return Plugin_Handled;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Action Command_Extend_Wins(int client, int argc)
|
public Action Command_Extend_Wins(int client, int argc)
|
||||||
{
|
{
|
||||||
if (argc < 1)
|
return HandleLimitCommand(client, argc, g_cvarMpWinLimit, "sm_extend_wins", "wins", "Unit Win", "Unit Wins");
|
||||||
{
|
|
||||||
ReplyToCommand(client, "[SM] Usage: sm_extend_wins <wins>");
|
|
||||||
return Plugin_Handled;
|
|
||||||
}
|
|
||||||
|
|
||||||
char sArgs[16];
|
|
||||||
|
|
||||||
GetCmdArg(1, sArgs, sizeof(sArgs));
|
|
||||||
|
|
||||||
if (sArgs[0] == '-')
|
|
||||||
{
|
|
||||||
int iWinsToDeduct;
|
|
||||||
|
|
||||||
if (!StringToIntEx(sArgs[1], iWinsToDeduct))
|
|
||||||
{
|
|
||||||
ReplyToCommand(client, "[SM] Invalid value");
|
|
||||||
return Plugin_Handled;
|
|
||||||
}
|
|
||||||
|
|
||||||
g_cvarMpWinLimit.IntValue -= iWinsToDeduct;
|
|
||||||
|
|
||||||
LogAction(client, -1, "\"%L\" deducted \"%d\" wins from \"mp_winlimit\"", client, iWinsToDeduct);
|
|
||||||
|
|
||||||
return Plugin_Handled;
|
|
||||||
}
|
|
||||||
|
|
||||||
int iWinsToAdd;
|
|
||||||
|
|
||||||
if (!StringToIntEx(sArgs, iWinsToAdd))
|
|
||||||
{
|
|
||||||
ReplyToCommand(client, "[SM] Invalid value");
|
|
||||||
return Plugin_Handled;
|
|
||||||
}
|
|
||||||
|
|
||||||
g_cvarMpWinLimit.IntValue += iWinsToAdd;
|
|
||||||
CancelGameOver();
|
|
||||||
|
|
||||||
LogAction(client, -1, "\"%L\" added \"%d\" wins to \"mp_winlimit\"", client, iWinsToAdd);
|
|
||||||
|
|
||||||
return Plugin_Handled;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Action Command_Extend(int client, int argc)
|
public Action Command_Extend(int client, int argc)
|
||||||
{
|
{
|
||||||
if (argc < 1)
|
return HandleLimitCommand(client, argc, g_cvarMpTimeLimit, "sm_extendmap", "minutes", "Unit Minute", "Unit Minutes");
|
||||||
{
|
|
||||||
ReplyToCommand(client, "[SM] Usage: sm_extend <time>");
|
|
||||||
return Plugin_Handled;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
char sArgs[16];
|
|
||||||
|
|
||||||
GetCmdArg(1, sArgs, sizeof(sArgs));
|
|
||||||
|
|
||||||
if (sArgs[0] == '-')
|
|
||||||
{
|
|
||||||
int iMinutesToDeduct;
|
|
||||||
|
|
||||||
if (!StringToIntEx(sArgs[1], iMinutesToDeduct))
|
|
||||||
{
|
|
||||||
ReplyToCommand(client, "[SM] Invalid value");
|
|
||||||
return Plugin_Handled;
|
|
||||||
}
|
|
||||||
|
|
||||||
g_cvarMpTimeLimit.IntValue -= iMinutesToDeduct;
|
|
||||||
|
|
||||||
LogAction(client, -1, "\"%L\" deducted \"%d\" minutes from \"mp_timelimit\"", client, iMinutesToDeduct);
|
|
||||||
PrintToChatAll("[SM] %N deducted %d minutes from the timelimit.", client, iMinutesToDeduct);
|
|
||||||
|
|
||||||
return Plugin_Handled;
|
|
||||||
}
|
|
||||||
|
|
||||||
int iMinutesToAdd;
|
|
||||||
|
|
||||||
if (!StringToIntEx(sArgs, iMinutesToAdd))
|
|
||||||
{
|
|
||||||
ReplyToCommand(client, "[SM] Invalid value");
|
|
||||||
return Plugin_Handled;
|
|
||||||
}
|
|
||||||
|
|
||||||
g_cvarMpTimeLimit.IntValue += iMinutesToAdd;
|
|
||||||
CancelGameOver();
|
|
||||||
|
|
||||||
LogAction(client, -1, "\"%L\" added \"%d\" minutes to \"mp_timelimit\"", client, iMinutesToAdd);
|
|
||||||
PrintToChatAll("[SM] %N added %d minutes to the timelimit.", client, iMinutesToAdd);
|
|
||||||
|
|
||||||
return Plugin_Handled;
|
|
||||||
}
|
|
||||||
|
|
||||||
int g_ExtendTime = 0;
|
|
||||||
public Action Command_ExtendVote(int client, int argc)
|
public Action Command_ExtendVote(int client, int argc)
|
||||||
{
|
{
|
||||||
if (IsVoteInProgress())
|
if (!g_cvarExtendVote.BoolValue)
|
||||||
{
|
{
|
||||||
ReplyToCommand(client, "[SM] %t", "Vote in Progress");
|
CReplyToCommand(client, "%s {default}%t", PLUGIN_TAG, "Feature Disabled");
|
||||||
return Plugin_Handled;
|
return Plugin_Handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_ExtendTime = g_cvarExtendVoteTime.IntValue;
|
if (g_cvarExtendVoteMaxFailedAttempt.IntValue > 0 && g_iNumAttempts >= g_cvarExtendVoteMaxFailedAttempt.IntValue)
|
||||||
if(argc == 1)
|
|
||||||
{
|
{
|
||||||
char sArg[64];
|
CReplyToCommand(client, "%s {default}%t", PLUGIN_TAG, "Max Failed Votes", g_iNumAttempts);
|
||||||
GetCmdArg(1, sArg, sizeof(sArg));
|
LogAction(-1, -1, "%L Attempting to start another extend vote after %d vote failed.. Clamped!", client, g_iNumAttempts);
|
||||||
int Tmp = StringToInt(sArg);
|
return Plugin_Handled;
|
||||||
if(Tmp > 0)
|
|
||||||
g_ExtendTime = Tmp > 30 ? 30 : Tmp;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Menu hVoteMenu = new Menu(Handler_VoteCallback, MenuAction_End|MenuAction_DisplayItem|MenuAction_VoteCancel|MenuAction_VoteEnd);
|
// Check if all extends are required and if the client can bypass this requirement
|
||||||
hVoteMenu.SetTitle("Extend the current map (%d minutes)?", g_ExtendTime);
|
if (g_cvarRequireAllExtends.BoolValue && AreExtendsRemaining() && !CheckCommandAccess(client, "sm_extend_bypass", ADMFLAG_CHANGEMAP, false))
|
||||||
|
{
|
||||||
|
CReplyToCommand(client, "%s {default}%t", PLUGIN_TAG, "Extends Remaining");
|
||||||
|
return Plugin_Handled;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (IsVoteInProgress())
|
||||||
|
{
|
||||||
|
CReplyToCommand(client, "%s {default}%t", PLUGIN_TAG, "Vote in Progress");
|
||||||
|
return Plugin_Handled;
|
||||||
|
}
|
||||||
|
|
||||||
|
g_iExtendTime = g_cvarExtendVoteTime.IntValue;
|
||||||
|
if (argc == 1)
|
||||||
|
{
|
||||||
|
char sArg[16];
|
||||||
|
GetCmdArg(1, sArg, sizeof(sArg));
|
||||||
|
|
||||||
|
int Tmp;
|
||||||
|
if (!ParseValue(sArg, Tmp) || Tmp < 0)
|
||||||
|
{
|
||||||
|
CReplyToCommand(client, "%s {default}%t", PLUGIN_TAG, "Invalid Value");
|
||||||
|
return Plugin_Handled;
|
||||||
|
}
|
||||||
|
|
||||||
|
int maxDuration = g_cvarExtendVoteMaxDuration.IntValue;
|
||||||
|
if (Tmp > 0)
|
||||||
|
g_iExtendTime = Tmp > maxDuration ? maxDuration : Tmp;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!CanChangeLimit(client, g_cvarMpTimeLimit, g_iExtendTime))
|
||||||
|
return Plugin_Handled;
|
||||||
|
|
||||||
|
// Capture the requirement now so changing the convars mid-vote can't move it
|
||||||
|
g_fVoteRequired = GetRequiredVoteRatio();
|
||||||
|
|
||||||
|
Menu hVoteMenu = new Menu(Handler_VoteCallback, MenuAction_End|MenuAction_Display|MenuAction_DisplayItem|MenuAction_VoteCancel|MenuAction_VoteEnd);
|
||||||
|
char sRequired[16];
|
||||||
|
FormatPercent(g_fVoteRequired, sRequired, sizeof(sRequired));
|
||||||
|
hVoteMenu.SetTitle("Extend map by %d minutes? (%s%% required)", g_iExtendTime, sRequired);
|
||||||
|
|
||||||
hVoteMenu.AddItem(VOTE_YES, "Yes");
|
hVoteMenu.AddItem(VOTE_YES, "Yes");
|
||||||
hVoteMenu.AddItem(VOTE_NO, "No");
|
hVoteMenu.AddItem(VOTE_NO, "No");
|
||||||
@@ -300,8 +215,38 @@ public Action Command_ExtendVote(int client, int argc)
|
|||||||
hVoteMenu.ExitButton = false;
|
hVoteMenu.ExitButton = false;
|
||||||
hVoteMenu.DisplayVoteToAll(20);
|
hVoteMenu.DisplayVoteToAll(20);
|
||||||
|
|
||||||
ShowActivity2(client, "[SM] ", "Initiated an extend vote");
|
char sTimeleft[128];
|
||||||
LogAction(client, -1, "\"%L\" initiated an extend vote.", client);
|
int TimeLeft;
|
||||||
|
GetMapTimeLeft(TimeLeft);
|
||||||
|
if (TimeLeft >= 0)
|
||||||
|
GenerateTimeleft(sTimeleft, sizeof(sTimeleft));
|
||||||
|
else
|
||||||
|
strcopy(sTimeleft, sizeof(sTimeleft), "0:00 (This is the last round!)");
|
||||||
|
|
||||||
|
CShowActivity2(client, PLUGIN_TAG ... " ", "{default}%t", "Activity Vote Started");
|
||||||
|
LogAction(client, -1, "\"%L\" Initiated an extend vote. (%d minutes)\nTimeLeft: %s", client, g_iExtendTime, sTimeleft);
|
||||||
|
|
||||||
|
return Plugin_Handled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Action Command_RoundExtend(int client, int argc)
|
||||||
|
{
|
||||||
|
float fElapsedTime = (GetGameTime() - GameRules_GetPropFloat("m_fRoundStartTime")) / 60.0;
|
||||||
|
int elapsedMinutes = RoundToFloor(fElapsedTime);
|
||||||
|
|
||||||
|
// Negative during freeze time, 0 in the first minute of the round
|
||||||
|
if (elapsedMinutes <= 0)
|
||||||
|
{
|
||||||
|
CReplyToCommand(client, "%s {default}%t", PLUGIN_TAG, "Round Too Short");
|
||||||
|
return Plugin_Handled;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!CanChangeLimit(client, g_cvarMpTimeLimit, elapsedMinutes))
|
||||||
|
return Plugin_Handled;
|
||||||
|
|
||||||
|
ChangeLimit(g_cvarMpTimeLimit, elapsedMinutes);
|
||||||
|
CPrintToChatAll("%s {default}%t", PLUGIN_TAG, "Round Extended", client, elapsedMinutes);
|
||||||
|
LogAction(client, -1, "\"%L\" added \"%d\" minutes to \"mp_timelimit\" based on the current round time elapsed.", client, elapsedMinutes);
|
||||||
|
|
||||||
return Plugin_Handled;
|
return Plugin_Handled;
|
||||||
}
|
}
|
||||||
@@ -309,69 +254,260 @@ public Action Command_ExtendVote(int client, int argc)
|
|||||||
public int Handler_VoteCallback(Menu menu, MenuAction action, int param1, int param2)
|
public int Handler_VoteCallback(Menu menu, MenuAction action, int param1, int param2)
|
||||||
{
|
{
|
||||||
if (action == MenuAction_End)
|
if (action == MenuAction_End)
|
||||||
{
|
|
||||||
delete menu;
|
delete menu;
|
||||||
|
else if (action == MenuAction_Display)
|
||||||
|
{
|
||||||
|
// Translate the title for each player; the SetTitle in Command_ExtendVote is the fallback
|
||||||
|
char sRequired[16], sTitle[128];
|
||||||
|
FormatPercent(g_fVoteRequired, sRequired, sizeof(sRequired));
|
||||||
|
Format(sTitle, sizeof(sTitle), "%T", "Vote Menu Title", param1, g_iExtendTime, sRequired);
|
||||||
|
view_as<Panel>(param2).SetTitle(sTitle);
|
||||||
}
|
}
|
||||||
else if (action == MenuAction_DisplayItem)
|
else if (action == MenuAction_DisplayItem)
|
||||||
{
|
{
|
||||||
char display[64];
|
char display[64];
|
||||||
menu.GetItem(param2, "", 0, _, display, sizeof(display));
|
menu.GetItem(param2, "", 0, _, display, sizeof(display));
|
||||||
|
|
||||||
if (strcmp(display, VOTE_NO) == 0 || strcmp(display, VOTE_YES) == 0)
|
if (strcmp(display, "No") == 0 || strcmp(display, "Yes") == 0)
|
||||||
{
|
{
|
||||||
char buffer[255];
|
char buffer[255];
|
||||||
Format(buffer, sizeof(buffer), "%T", display, param1);
|
Format(buffer, sizeof(buffer), "%T", display, param1);
|
||||||
|
|
||||||
return RedrawMenuItem(buffer);
|
return RedrawMenuItem(buffer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (action == MenuAction_VoteCancel && param1 == VoteCancel_NoVotes)
|
else if (action == MenuAction_VoteCancel && param1 == VoteCancel_NoVotes)
|
||||||
{
|
{
|
||||||
PrintToChatAll("[SM] %t", "No Votes Cast");
|
LogAction(-1, -1, "No Votes Cast. Extend Vote failed.");
|
||||||
|
PrintToServer("[SM] %t", "No Votes Cast");
|
||||||
|
CPrintToChatAll("%s {default}%t", PLUGIN_TAG, "No Votes Cast");
|
||||||
}
|
}
|
||||||
else if (action == MenuAction_VoteEnd)
|
else if (action == MenuAction_VoteEnd)
|
||||||
{
|
{
|
||||||
char item[64], display[64];
|
char item[64];
|
||||||
float percent, limit;
|
|
||||||
int votes, totalVotes;
|
int votes, totalVotes;
|
||||||
|
|
||||||
GetMenuVoteInfo(param2, votes, totalVotes);
|
GetMenuVoteInfo(param2, votes, totalVotes);
|
||||||
menu.GetItem(param1, item, sizeof(item), _, display, sizeof(display));
|
menu.GetItem(param1, item, sizeof(item));
|
||||||
|
|
||||||
if (strcmp(item, VOTE_NO) == 0)
|
if (strcmp(item, VOTE_NO) == 0)
|
||||||
{
|
|
||||||
votes = totalVotes - votes;
|
votes = totalVotes - votes;
|
||||||
}
|
|
||||||
|
|
||||||
limit = g_cvarExtendVotePercent.FloatValue;
|
// votes is now the yes count; the result depends only on it, not on which option won
|
||||||
percent = FloatDiv(float(votes),float(totalVotes));
|
float fYesRatio = float(votes) / float(totalVotes);
|
||||||
|
char sRequired[16], sYes[16];
|
||||||
|
FormatPercent(g_fVoteRequired, sRequired, sizeof(sRequired));
|
||||||
|
FormatPercent(fYesRatio, sYes, sizeof(sYes));
|
||||||
|
|
||||||
if ((strcmp(item, VOTE_YES) == 0 && FloatCompare(percent, limit) < 0) || strcmp(item, VOTE_NO) == 0)
|
// Small epsilon so sums like 0.6 + 0.05 * 2 (0.70000005) still accept exactly 70%
|
||||||
|
if (fYesRatio + 0.0001 < g_fVoteRequired)
|
||||||
{
|
{
|
||||||
LogAction(-1, -1, "Extend vote failed.");
|
LogAction(-1, -1, "Extend vote failed. %s%% vote required. (Received %s%% of %d votes)", sRequired, sYes, totalVotes);
|
||||||
PrintToChatAll("[SM] %t", "Vote Failed", RoundToNearest(100.0 * limit), RoundToNearest(100.0 * percent), totalVotes);
|
PrintToServer("[SM] Vote failed. %s%% vote required. (Received %s%% of %d votes)", sRequired, sYes, totalVotes);
|
||||||
|
CPrintToChatAll("%s {default}%t", PLUGIN_TAG, "Extend Vote Failed", sRequired, sYes, totalVotes);
|
||||||
|
g_iNumAttempts++;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LogAction(-1, -1, "Extend vote successful, extending current map by \"%d\" minutes", g_ExtendTime);
|
// The limit may have changed while the vote was running
|
||||||
PrintToChatAll("[SM] %t", "Vote Successful", RoundToNearest(100.0 * percent), totalVotes);
|
if (!CanChangeLimit(0, g_cvarMpTimeLimit, g_iExtendTime))
|
||||||
|
|
||||||
g_cvarMpTimeLimit.IntValue += g_ExtendTime;
|
|
||||||
CancelGameOver();
|
|
||||||
|
|
||||||
if (strcmp(item, VOTE_NO) == 0 || strcmp(item, VOTE_YES) == 0)
|
|
||||||
{
|
{
|
||||||
strcopy(item, sizeof(item), display);
|
LogAction(-1, -1, "Extend vote passed, but \"mp_timelimit\" can no longer be extended. Extension skipped.");
|
||||||
|
CPrintToChatAll("%s {default}%t", PLUGIN_TAG, "Extend Vote Passed No Limit");
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char sOldTimeleft[128];
|
||||||
|
GenerateTimeleft(sOldTimeleft, sizeof(sOldTimeleft));
|
||||||
|
|
||||||
|
ChangeLimit(g_cvarMpTimeLimit, g_iExtendTime);
|
||||||
|
|
||||||
|
char sTimeleft[128];
|
||||||
|
GenerateTimeleft(sTimeleft, sizeof(sTimeleft));
|
||||||
|
LogAction(-1, -1, "Extend vote successful. (Received %s%% of %d votes)\nExtending current map by \"%d\" minutes.\nPrevious TimeLeft: %s\nNew TimeLeft: %s", sYes, totalVotes, g_iExtendTime, sOldTimeleft, sTimeleft);
|
||||||
|
PrintToServer("[SM] Vote successful. (Received %s%% of %d votes)", sYes, totalVotes);
|
||||||
|
CPrintToChatAll("%s {default}%t", PLUGIN_TAG, "Extend Vote Successful", sYes, totalVotes);
|
||||||
|
g_iNumAttempts = 0;
|
||||||
|
g_iExtendCount++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Action HandleLimitCommand(int client, int argc, ConVar cvar, const char[] sCommand, const char[] sUnit, const char[] sUnitOne, const char[] sUnitMany)
|
||||||
|
{
|
||||||
|
if (argc < 1)
|
||||||
|
{
|
||||||
|
CReplyToCommand(client, "%s {default}%t", PLUGIN_TAG, "Command Usage", sCommand, sUnit);
|
||||||
|
return Plugin_Handled;
|
||||||
|
}
|
||||||
|
|
||||||
|
char sArg[16];
|
||||||
|
GetCmdArg(1, sArg, sizeof(sArg));
|
||||||
|
|
||||||
|
int delta;
|
||||||
|
if (!ParseValue(sArg, delta))
|
||||||
|
{
|
||||||
|
CReplyToCommand(client, "%s {default}%t", PLUGIN_TAG, "Invalid Value");
|
||||||
|
return Plugin_Handled;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!CanChangeLimit(client, cvar, delta))
|
||||||
|
return Plugin_Handled;
|
||||||
|
|
||||||
|
char sName[32];
|
||||||
|
cvar.GetName(sName, sizeof(sName));
|
||||||
|
|
||||||
|
bool isTime = (cvar == g_cvarMpTimeLimit);
|
||||||
|
char sOldTimeleft[128];
|
||||||
|
if (isTime)
|
||||||
|
GenerateTimeleft(sOldTimeleft, sizeof(sOldTimeleft));
|
||||||
|
|
||||||
|
ChangeLimit(cvar, delta);
|
||||||
|
|
||||||
|
// Messages show the amount without its sign and say added or deducted instead
|
||||||
|
bool isNegative = (delta < 0);
|
||||||
|
int value = isNegative ? -delta : delta;
|
||||||
|
|
||||||
|
char sAction[16], sPrep[8];
|
||||||
|
strcopy(sAction, sizeof(sAction), isNegative ? "deducted" : "added");
|
||||||
|
strcopy(sPrep, sizeof(sPrep), isNegative ? "from" : "to");
|
||||||
|
|
||||||
|
CShowActivity2(client, PLUGIN_TAG ... " ", "{default}%t", isNegative ? "Activity Limit Deducted" : "Activity Limit Added", value, value == 1 ? sUnitOne : sUnitMany, sName);
|
||||||
|
|
||||||
|
if (isTime)
|
||||||
|
{
|
||||||
|
char sTimeleft[128];
|
||||||
|
GenerateTimeleft(sTimeleft, sizeof(sTimeleft));
|
||||||
|
LogAction(client, -1, "\"%L\" %s \"%d\" %s %s \"%s\"\nPrevious Timeleft: %s\nNew Timeleft: %s", client, sAction, value, sUnit, sPrep, sName, sOldTimeleft, sTimeleft);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
LogAction(client, -1, "\"%L\" %s \"%d\" %s %s \"%s\"", client, sAction, value, sUnit, sPrep, sName);
|
||||||
|
|
||||||
|
return Plugin_Handled;
|
||||||
|
}
|
||||||
|
|
||||||
|
stock float GetRequiredVoteRatio()
|
||||||
|
{
|
||||||
|
float fBase = g_cvarExtendVotePercent.FloatValue;
|
||||||
|
float limit = fBase + (g_cvarExtendVotePercentIncrement.FloatValue * float(g_iExtendCount));
|
||||||
|
float fMax = g_cvarExtendVotePercentMax.FloatValue;
|
||||||
|
|
||||||
|
// The cap only limits the increments, it never lowers the base requirement
|
||||||
|
if (limit > fMax)
|
||||||
|
limit = (fMax > fBase) ? fMax : fBase;
|
||||||
|
|
||||||
|
return limit;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Formats a 0-1 ratio as a percentage with one decimal, dropping a trailing ".0"
|
||||||
|
stock void FormatPercent(float ratio, char[] buffer, int size)
|
||||||
|
{
|
||||||
|
FormatEx(buffer, size, "%.1f", 100.0 * ratio);
|
||||||
|
|
||||||
|
int len = strlen(buffer);
|
||||||
|
if (len > 2 && StrEqual(buffer[len - 2], ".0"))
|
||||||
|
buffer[len - 2] = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
stock void GenerateTimeleft(char[] sTimeleft, int size)
|
||||||
|
{
|
||||||
|
int TimeLeft;
|
||||||
|
if (!GetMapTimeLeft(TimeLeft) || TimeLeft < 0)
|
||||||
|
{
|
||||||
|
strcopy(sTimeleft, size, "N/A");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
FormatEx(sTimeleft, size, "%02d:%02d", TimeLeft / 60, TimeLeft % 60);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Parses "<n>" or "-<n>" into a signed amount
|
||||||
|
stock bool ParseValue(const char[] sArg, int &delta)
|
||||||
|
{
|
||||||
|
bool isNegative = (sArg[0] == '-');
|
||||||
|
int start = isNegative ? 1 : 0;
|
||||||
|
|
||||||
|
if (sArg[start] == '\0')
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// Accept plain digits only and build the number by hand, so nothing can wrap past cellmax
|
||||||
|
int value = 0;
|
||||||
|
for (int i = start; sArg[i] != '\0'; i++)
|
||||||
|
{
|
||||||
|
if (sArg[i] < '0' || sArg[i] > '9')
|
||||||
|
return false;
|
||||||
|
|
||||||
|
int digit = sArg[i] - '0';
|
||||||
|
if (value > (cellmax - digit) / 10)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
value = value * 10 + digit;
|
||||||
|
}
|
||||||
|
|
||||||
|
delta = isNegative ? -value : value;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
stock bool CanChangeLimit(int client, ConVar cvar, int delta)
|
||||||
|
{
|
||||||
|
char sName[32];
|
||||||
|
cvar.GetName(sName, sizeof(sName));
|
||||||
|
|
||||||
|
// Read as a float for every limit, since mp_timelimit can be fractional
|
||||||
|
bool isTime = (cvar == g_cvarMpTimeLimit);
|
||||||
|
float fCurrent = cvar.FloatValue;
|
||||||
|
|
||||||
|
// Adding to "no limit" would set a limit that may already be exceeded
|
||||||
|
if (fCurrent <= 0.0)
|
||||||
|
{
|
||||||
|
CReplyToCommand(client, "%s {default}%t", PLUGIN_TAG, "Limit Not Set", sName);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (delta < 0 && fCurrent + float(delta) <= 0.0)
|
||||||
|
{
|
||||||
|
if (isTime)
|
||||||
|
CReplyToCommand(client, "%s {default}%t", PLUGIN_TAG, "Time Limit Below Zero", sName, fCurrent + float(delta));
|
||||||
|
else
|
||||||
|
CReplyToCommand(client, "%s {default}%t", PLUGIN_TAG, "Limit Below Zero", sName, cvar.IntValue + delta);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (delta > 0 && isTime && fCurrent + float(delta) > MAX_TIMELIMIT_MINUTES)
|
||||||
|
{
|
||||||
|
CReplyToCommand(client, "%s {default}%t", PLUGIN_TAG, "Value Too Large", sName);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (delta > 0 && !isTime && delta > cellmax - cvar.IntValue)
|
||||||
|
{
|
||||||
|
CReplyToCommand(client, "%s {default}%t", PLUGIN_TAG, "Value Too Large", sName);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Adds a signed amount to a limit; mp_timelimit keeps fractional minutes
|
||||||
|
stock void ChangeLimit(ConVar cvar, int delta)
|
||||||
|
{
|
||||||
|
if (cvar == g_cvarMpTimeLimit)
|
||||||
|
cvar.FloatValue += float(delta);
|
||||||
|
else
|
||||||
|
cvar.IntValue += delta;
|
||||||
|
|
||||||
|
if (delta >= 0)
|
||||||
|
CancelGameOver();
|
||||||
|
}
|
||||||
|
|
||||||
void CancelGameOver()
|
void CancelGameOver()
|
||||||
{
|
{
|
||||||
if (!g_bGameOver)
|
if (!g_bCanCancelGameOver)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Only undo game over when it actually happened, so normal extends don't reset movement
|
||||||
|
if (LoadFromAddress(g_pGameOver, NumberType_Int8) == 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
StoreToAddress(g_pGameOver, 0, NumberType_Int8);
|
StoreToAddress(g_pGameOver, 0, NumberType_Int8);
|
||||||
@@ -387,3 +523,15 @@ void CancelGameOver()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
stock bool AreExtendsRemaining()
|
||||||
|
{
|
||||||
|
#if defined _mapchooser_extended_included_
|
||||||
|
if (GetFeatureStatus(FeatureType_Native, "GetExtendsLeft") == FeatureStatus_Available)
|
||||||
|
return GetExtendsLeft();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// SourceMod's stock MapChooser has no way to read how many extends are left
|
||||||
|
// (sm_mapvote_extend is the configured amount and never goes down), so don't block
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|||||||
@@ -0,0 +1,456 @@
|
|||||||
|
"Phrases"
|
||||||
|
{
|
||||||
|
"Feature Disabled"
|
||||||
|
{
|
||||||
|
"en" "Extend votes are currently disabled."
|
||||||
|
"fr" "Les votes de prolongation sont actuellement désactivés."
|
||||||
|
"ru" "Голосования за продление сейчас отключены."
|
||||||
|
"chi" "延长投票当前已禁用。"
|
||||||
|
"zho" "延長投票目前已停用。"
|
||||||
|
"es" "Las votaciones de extensión están desactivadas actualmente."
|
||||||
|
"de" "Verlängerungsabstimmungen sind derzeit deaktiviert."
|
||||||
|
"pt" "As votações de extensão estão desativadas no momento."
|
||||||
|
"pl" "Głosowania o przedłużenie są obecnie wyłączone."
|
||||||
|
"tr" "Uzatma oylamaları şu anda devre dışı."
|
||||||
|
"it" "Le votazioni per l'estensione sono attualmente disabilitate."
|
||||||
|
"ua" "Голосування за продовження зараз вимкнені."
|
||||||
|
"cze" "Hlasování o prodloužení jsou momentálně vypnutá."
|
||||||
|
}
|
||||||
|
|
||||||
|
"Max Failed Votes"
|
||||||
|
{
|
||||||
|
"#format" "{1:d}"
|
||||||
|
"en" "The extend vote has already failed {1} time(s). No more extend votes can be started."
|
||||||
|
"fr" "Le vote de prolongation a déjà échoué {1} fois. Aucun autre vote de prolongation ne peut être lancé."
|
||||||
|
"ru" "Количество неудачных голосований за продление: {1}. Новые голосования за продление запустить нельзя."
|
||||||
|
"chi" "延长投票已失败 {1} 次,无法再发起延长投票。"
|
||||||
|
"zho" "延長投票已失敗 {1} 次,無法再發起延長投票。"
|
||||||
|
"es" "La votación de extensión ya ha fallado {1} vez/veces. No se pueden iniciar más votaciones de extensión."
|
||||||
|
"de" "Die Verlängerungsabstimmung ist bereits {1}-mal gescheitert. Es können keine weiteren Verlängerungsabstimmungen gestartet werden."
|
||||||
|
"pt" "A votação de extensão já falhou {1} vez(es). Não é possível iniciar mais votações de extensão."
|
||||||
|
"pl" "Głosowanie o przedłużenie nie powiodło się już {1} raz(y). Nie można rozpocząć kolejnych głosowań."
|
||||||
|
"tr" "Uzatma oylaması şimdiden {1} kez başarısız oldu. Daha fazla uzatma oylaması başlatılamaz."
|
||||||
|
"it" "La votazione per l'estensione è già fallita {1} volta/e. Non è possibile avviare altre votazioni."
|
||||||
|
"ua" "Голосування за продовження вже провалилося {1} раз(ів). Нові голосування запустити не можна."
|
||||||
|
"cze" "Hlasování o prodloužení již selhalo {1}krát. Další hlasování nelze zahájit."
|
||||||
|
}
|
||||||
|
|
||||||
|
"Extends Remaining"
|
||||||
|
{
|
||||||
|
"en" "Cannot start an extend vote until all extends are used."
|
||||||
|
"fr" "Impossible de lancer un vote de prolongation tant que toutes les prolongations n'ont pas été utilisées."
|
||||||
|
"ru" "Нельзя начать голосование за продление, пока не использованы все продления."
|
||||||
|
"chi" "在所有延长次数用完之前,无法发起延长投票。"
|
||||||
|
"zho" "在所有延長次數用完之前,無法發起延長投票。"
|
||||||
|
"es" "No se puede iniciar una votación de extensión hasta que se usen todas las extensiones."
|
||||||
|
"de" "Eine Verlängerungsabstimmung ist erst möglich, wenn alle Verlängerungen aufgebraucht sind."
|
||||||
|
"pt" "Não é possível iniciar uma votação de extensão até que todas as extensões sejam usadas."
|
||||||
|
"pl" "Nie można rozpocząć głosowania o przedłużenie, dopóki nie zostaną wykorzystane wszystkie przedłużenia."
|
||||||
|
"tr" "Tüm uzatmalar kullanılana kadar uzatma oylaması başlatılamaz."
|
||||||
|
"it" "Non è possibile avviare una votazione per l'estensione finché non sono state usate tutte le estensioni."
|
||||||
|
"ua" "Не можна почати голосування за продовження, доки не використано всі продовження."
|
||||||
|
"cze" "Hlasování o prodloužení nelze zahájit, dokud nejsou využita všechna prodloužení."
|
||||||
|
}
|
||||||
|
|
||||||
|
"Invalid Value"
|
||||||
|
{
|
||||||
|
"en" "Invalid value specified."
|
||||||
|
"fr" "Valeur spécifiée invalide."
|
||||||
|
"ru" "Указано недопустимое значение."
|
||||||
|
"chi" "指定的数值无效。"
|
||||||
|
"zho" "指定的數值無效。"
|
||||||
|
"es" "Valor especificado no válido."
|
||||||
|
"de" "Ungültiger Wert angegeben."
|
||||||
|
"pt" "Valor especificado inválido."
|
||||||
|
"pl" "Podano nieprawidłową wartość."
|
||||||
|
"tr" "Geçersiz değer belirtildi."
|
||||||
|
"it" "Valore specificato non valido."
|
||||||
|
"ua" "Указано недопустиме значення."
|
||||||
|
"cze" "Zadána neplatná hodnota."
|
||||||
|
}
|
||||||
|
|
||||||
|
"Command Usage"
|
||||||
|
{
|
||||||
|
"#format" "{1:s},{2:s}"
|
||||||
|
"en" "Usage: {1} {olive}<{2}>"
|
||||||
|
"fr" "Utilisation : {1} {olive}<{2}>"
|
||||||
|
"ru" "Использование: {1} {olive}<{2}>"
|
||||||
|
"chi" "用法:{1} {olive}<{2}>"
|
||||||
|
"zho" "用法:{1} {olive}<{2}>"
|
||||||
|
"es" "Uso: {1} {olive}<{2}>"
|
||||||
|
"de" "Verwendung: {1} {olive}<{2}>"
|
||||||
|
"pt" "Uso: {1} {olive}<{2}>"
|
||||||
|
"pl" "Użycie: {1} {olive}<{2}>"
|
||||||
|
"tr" "Kullanım: {1} {olive}<{2}>"
|
||||||
|
"it" "Uso: {1} {olive}<{2}>"
|
||||||
|
"ua" "Використання: {1} {olive}<{2}>"
|
||||||
|
"cze" "Použití: {1} {olive}<{2}>"
|
||||||
|
}
|
||||||
|
|
||||||
|
"Round Too Short"
|
||||||
|
{
|
||||||
|
"en" "Failed to adjust round time because less than a minute of the round has elapsed."
|
||||||
|
"fr" "Impossible d'ajuster le temps de la manche car moins d'une minute s'est écoulée depuis son début."
|
||||||
|
"ru" "Не удалось изменить время раунда: с начала раунда прошло меньше минуты."
|
||||||
|
"chi" "无法调整回合时间,因为本回合开始还不到一分钟。"
|
||||||
|
"zho" "無法調整回合時間,因為本回合開始還不到一分鐘。"
|
||||||
|
"es" "No se pudo ajustar el tiempo de la ronda porque ha transcurrido menos de un minuto."
|
||||||
|
"de" "Die Rundenzeit konnte nicht angepasst werden, da weniger als eine Minute der Runde vergangen ist."
|
||||||
|
"pt" "Não foi possível ajustar o tempo da rodada porque passou menos de um minuto desde o início."
|
||||||
|
"pl" "Nie udało się zmienić czasu rundy, ponieważ upłynęło mniej niż minuta od jej rozpoczęcia."
|
||||||
|
"tr" "Turun başlamasının üzerinden bir dakikadan az geçtiği için tur süresi ayarlanamadı."
|
||||||
|
"it" "Impossibile modificare il tempo del round perché è trascorso meno di un minuto."
|
||||||
|
"ua" "Не вдалося змінити час раунду: з початку раунду минуло менше хвилини."
|
||||||
|
"cze" "Čas kola nelze upravit, protože od jeho začátku uplynula méně než minuta."
|
||||||
|
}
|
||||||
|
|
||||||
|
"Round Extended"
|
||||||
|
{
|
||||||
|
"#format" "{1:N},{2:d}"
|
||||||
|
"en" "{1} added {2} minutes to \"mp_timelimit\" based on the current round time elapsed."
|
||||||
|
"fr" "{1} a ajouté {2} minutes à \"mp_timelimit\" en fonction du temps écoulé de la manche en cours."
|
||||||
|
"ru" "{1} добавил(а) {2} мин. к \"mp_timelimit\" с учётом времени, прошедшего в текущем раунде."
|
||||||
|
"chi" "{1} 根据当前回合已进行的时间,为 \"mp_timelimit\" 增加了 {2} 分钟。"
|
||||||
|
"zho" "{1} 根據目前回合已進行的時間,為 \"mp_timelimit\" 增加了 {2} 分鐘。"
|
||||||
|
"es" "{1} añadió {2} minutos a \"mp_timelimit\" según el tiempo transcurrido de la ronda actual."
|
||||||
|
"de" "{1} hat basierend auf der bisherigen Rundenzeit {2} Minuten zu \"mp_timelimit\" hinzugefügt."
|
||||||
|
"pt" "{1} adicionou {2} minutos a \"mp_timelimit\" com base no tempo decorrido da rodada atual."
|
||||||
|
"pl" "{1} dodał(a) {2} min do \"mp_timelimit\" na podstawie czasu bieżącej rundy."
|
||||||
|
"tr" "{1}, mevcut turun geçen süresine göre \"mp_timelimit\" değerine {2} dakika ekledi."
|
||||||
|
"it" "{1} ha aggiunto {2} minuti a \"mp_timelimit\" in base al tempo trascorso del round attuale."
|
||||||
|
"ua" "{1} додав(ла) {2} хв. до \"mp_timelimit\" з урахуванням часу, що минув у поточному раунді."
|
||||||
|
"cze" "{1} přidal(a) {2} min. k \"mp_timelimit\" podle uplynulého času aktuálního kola."
|
||||||
|
}
|
||||||
|
|
||||||
|
"Vote Menu Title"
|
||||||
|
{
|
||||||
|
"#format" "{1:d},{2:s}"
|
||||||
|
"en" "Extend map by {1} minutes? ({2}%% required)"
|
||||||
|
"fr" "Prolonger la carte de {1} minutes ? ({2}%% requis)"
|
||||||
|
"ru" "Продлить карту на {1} мин.? (Требуется {2}%%)"
|
||||||
|
"chi" "将地图延长 {1} 分钟?(需要 {2}%%)"
|
||||||
|
"zho" "將地圖延長 {1} 分鐘?(需要 {2}%%)"
|
||||||
|
"es" "¿Extender el mapa {1} minutos? ({2}%% requerido)"
|
||||||
|
"de" "Map um {1} Minuten verlängern? ({2}%% benötigt)"
|
||||||
|
"pt" "Estender o mapa em {1} minutos? ({2}%% necessário)"
|
||||||
|
"pl" "Przedłużyć mapę o {1} min? (Wymagane {2}%%)"
|
||||||
|
"tr" "Harita {1} dakika uzatılsın mı? ({2}%% gerekli)"
|
||||||
|
"it" "Estendere la mappa di {1} minuti? (richiesto {2}%%)"
|
||||||
|
"ua" "Продовжити мапу на {1} хв.? (Потрібно {2}%%)"
|
||||||
|
"cze" "Prodloužit mapu o {1} min.? (Vyžadováno {2}%%)"
|
||||||
|
}
|
||||||
|
|
||||||
|
"Extend Vote Failed"
|
||||||
|
{
|
||||||
|
"#format" "{1:s},{2:s},{3:d}"
|
||||||
|
"en" "Extend vote failed. {1}%% vote required. (Received {2}%% of {3} votes)"
|
||||||
|
"fr" "Le vote de prolongation a échoué. {1}%% des votes requis. ({2}%% reçus sur {3} votes)"
|
||||||
|
"ru" "Голосование за продление не прошло. Требуется {1}%% голосов. (Получено {2}%%, всего голосов: {3})"
|
||||||
|
"chi" "延长投票失败。需要 {1}%% 的票数。(共 {3} 票,获得 {2}%%)"
|
||||||
|
"zho" "延長投票失敗。需要 {1}%% 的票數。(共 {3} 票,獲得 {2}%%)"
|
||||||
|
"es" "La votación de extensión ha fallado. Se requiere {1}%% de votos. (Recibido {2}%% de {3} votos)"
|
||||||
|
"de" "Verlängerungsabstimmung gescheitert. {1}%% der Stimmen benötigt. ({2}%% von {3} Stimmen erhalten)"
|
||||||
|
"pt" "A votação de extensão falhou. {1}%% dos votos necessários. (Recebeu {2}%% de {3} votos)"
|
||||||
|
"pl" "Głosowanie o przedłużenie nie powiodło się. Wymagane {1}%% głosów. (Otrzymano {2}%% z {3} głosów)"
|
||||||
|
"tr" "Uzatma oylaması başarısız oldu. Oyların {1}%% gerekli. ({3} oyun {2}%% alındı)"
|
||||||
|
"it" "Votazione per l'estensione fallita. Richiesto il {1}%% dei voti. (Ricevuto il {2}%% su {3} voti)"
|
||||||
|
"ua" "Голосування за продовження провалилося. Потрібно {1}%% голосів. (Отримано {2}%% із {3} голосів)"
|
||||||
|
"cze" "Hlasování o prodloužení selhalo. Vyžadováno {1}%% hlasů. (Získáno {2}%% z {3} hlasů)"
|
||||||
|
}
|
||||||
|
|
||||||
|
"Extend Vote Successful"
|
||||||
|
{
|
||||||
|
"#format" "{1:s},{2:d}"
|
||||||
|
"en" "Extend vote successful. (Received {1}%% of {2} votes)"
|
||||||
|
"fr" "Le vote de prolongation a réussi. ({1}%% reçus sur {2} votes)"
|
||||||
|
"ru" "Голосование за продление прошло успешно. (Получено {1}%%, всего голосов: {2})"
|
||||||
|
"chi" "延长投票成功。(共 {2} 票,获得 {1}%%)"
|
||||||
|
"zho" "延長投票成功。(共 {2} 票,獲得 {1}%%)"
|
||||||
|
"es" "La votación de extensión ha sido aprobada. (Recibido {1}%% de {2} votos)"
|
||||||
|
"de" "Verlängerungsabstimmung erfolgreich. ({1}%% von {2} Stimmen erhalten)"
|
||||||
|
"pt" "A votação de extensão foi aprovada. (Recebeu {1}%% de {2} votos)"
|
||||||
|
"pl" "Głosowanie o przedłużenie zakończone sukcesem. (Otrzymano {1}%% z {2} głosów)"
|
||||||
|
"tr" "Uzatma oylaması başarılı. ({2} oyun {1}%% alındı)"
|
||||||
|
"it" "Votazione per l'estensione riuscita. (Ricevuto il {1}%% su {2} voti)"
|
||||||
|
"ua" "Голосування за продовження пройшло успішно. (Отримано {1}%% із {2} голосів)"
|
||||||
|
"cze" "Hlasování o prodloužení bylo úspěšné. (Získáno {1}%% z {2} hlasů)"
|
||||||
|
}
|
||||||
|
|
||||||
|
"Extend Vote Passed No Limit"
|
||||||
|
{
|
||||||
|
"en" "The vote passed but \"mp_timelimit\" cannot be extended."
|
||||||
|
"fr" "Le vote a réussi, mais \"mp_timelimit\" ne peut pas être prolongé."
|
||||||
|
"ru" "Голосование прошло, но \"mp_timelimit\" нельзя продлить."
|
||||||
|
"chi" "投票已通过,但 \"mp_timelimit\" 无法延长。"
|
||||||
|
"zho" "投票已通過,但 \"mp_timelimit\" 無法延長。"
|
||||||
|
"es" "La votación fue aprobada, pero \"mp_timelimit\" no se puede extender."
|
||||||
|
"de" "Die Abstimmung war erfolgreich, aber \"mp_timelimit\" kann nicht verlängert werden."
|
||||||
|
"pt" "A votação foi aprovada, mas \"mp_timelimit\" não pode ser estendido."
|
||||||
|
"pl" "Głosowanie zakończyło się sukcesem, ale \"mp_timelimit\" nie może zostać przedłużony."
|
||||||
|
"tr" "Oylama geçti ancak \"mp_timelimit\" uzatılamıyor."
|
||||||
|
"it" "La votazione è passata ma \"mp_timelimit\" non può essere esteso."
|
||||||
|
"ua" "Голосування пройшло, але \"mp_timelimit\" не можна продовжити."
|
||||||
|
"cze" "Hlasování prošlo, ale \"mp_timelimit\" nelze prodloužit."
|
||||||
|
}
|
||||||
|
|
||||||
|
"Limit Not Set"
|
||||||
|
{
|
||||||
|
"#format" "{1:s}"
|
||||||
|
"en" "Cannot change \"{1}\" because it is set to 0 (no limit)."
|
||||||
|
"fr" "Impossible de modifier \"{1}\" car sa valeur est 0 (aucune limite)."
|
||||||
|
"ru" "Нельзя изменить \"{1}\", так как его значение равно 0 (без ограничения)."
|
||||||
|
"chi" "无法更改 \"{1}\",因为它被设置为 0(无限制)。"
|
||||||
|
"zho" "無法變更 \"{1}\",因為它被設定為 0(無限制)。"
|
||||||
|
"es" "No se puede cambiar \"{1}\" porque está en 0 (sin límite)."
|
||||||
|
"de" "\"{1}\" kann nicht geändert werden, da es auf 0 (kein Limit) steht."
|
||||||
|
"pt" "Não é possível alterar \"{1}\" porque está definido como 0 (sem limite)."
|
||||||
|
"pl" "Nie można zmienić \"{1}\", ponieważ ma wartość 0 (brak limitu)."
|
||||||
|
"tr" "\"{1}\" değeri 0 (limitsiz) olduğu için değiştirilemez."
|
||||||
|
"it" "Impossibile modificare \"{1}\" perché è impostato a 0 (nessun limite)."
|
||||||
|
"ua" "Не можна змінити \"{1}\", бо його значення дорівнює 0 (без обмеження)."
|
||||||
|
"cze" "Nelze změnit \"{1}\", protože je nastaveno na 0 (bez limitu)."
|
||||||
|
}
|
||||||
|
|
||||||
|
"Limit Below Zero"
|
||||||
|
{
|
||||||
|
"#format" "{1:s},{2:d}"
|
||||||
|
"en" "\"{1}\" ({2}) can't be zero or negative."
|
||||||
|
"fr" "\"{1}\" ({2}) ne peut pas être nul ou négatif."
|
||||||
|
"ru" "\"{1}\" ({2}) не может быть нулевым или отрицательным."
|
||||||
|
"chi" "\"{1}\" ({2}) 不能为零或负数。"
|
||||||
|
"zho" "\"{1}\" ({2}) 不能為零或負數。"
|
||||||
|
"es" "\"{1}\" ({2}) no puede ser cero ni negativo."
|
||||||
|
"de" "\"{1}\" ({2}) darf nicht null oder negativ sein."
|
||||||
|
"pt" "\"{1}\" ({2}) não pode ser zero ou negativo."
|
||||||
|
"pl" "\"{1}\" ({2}) nie może wynosić zero ani być ujemne."
|
||||||
|
"tr" "\"{1}\" ({2}) sıfır veya negatif olamaz."
|
||||||
|
"it" "\"{1}\" ({2}) non può essere zero o negativo."
|
||||||
|
"ua" "\"{1}\" ({2}) не може бути нульовим або від'ємним."
|
||||||
|
"cze" "\"{1}\" ({2}) nemůže být nula ani záporné."
|
||||||
|
}
|
||||||
|
|
||||||
|
"Time Limit Below Zero"
|
||||||
|
{
|
||||||
|
"#format" "{1:s},{2:.2f}"
|
||||||
|
"en" "\"{1}\" ({2}) can't be zero or negative."
|
||||||
|
"fr" "\"{1}\" ({2}) ne peut pas être nul ou négatif."
|
||||||
|
"ru" "\"{1}\" ({2}) не может быть нулевым или отрицательным."
|
||||||
|
"chi" "\"{1}\" ({2}) 不能为零或负数。"
|
||||||
|
"zho" "\"{1}\" ({2}) 不能為零或負數。"
|
||||||
|
"es" "\"{1}\" ({2}) no puede ser cero ni negativo."
|
||||||
|
"de" "\"{1}\" ({2}) darf nicht null oder negativ sein."
|
||||||
|
"pt" "\"{1}\" ({2}) não pode ser zero ou negativo."
|
||||||
|
"pl" "\"{1}\" ({2}) nie może wynosić zero ani być ujemne."
|
||||||
|
"tr" "\"{1}\" ({2}) sıfır veya negatif olamaz."
|
||||||
|
"it" "\"{1}\" ({2}) non può essere zero o negativo."
|
||||||
|
"ua" "\"{1}\" ({2}) не може бути нульовим або від'ємним."
|
||||||
|
"cze" "\"{1}\" ({2}) nemůže být nula ani záporné."
|
||||||
|
}
|
||||||
|
|
||||||
|
"Value Too Large"
|
||||||
|
{
|
||||||
|
"#format" "{1:s}"
|
||||||
|
"en" "Value is too large for \"{1}\"."
|
||||||
|
"fr" "La valeur est trop grande pour \"{1}\"."
|
||||||
|
"ru" "Слишком большое значение для \"{1}\"."
|
||||||
|
"chi" "\"{1}\" 的数值过大。"
|
||||||
|
"zho" "\"{1}\" 的數值過大。"
|
||||||
|
"es" "El valor es demasiado grande para \"{1}\"."
|
||||||
|
"de" "Der Wert ist zu groß für \"{1}\"."
|
||||||
|
"pt" "O valor é grande demais para \"{1}\"."
|
||||||
|
"pl" "Wartość jest zbyt duża dla \"{1}\"."
|
||||||
|
"tr" "Değer \"{1}\" için çok büyük."
|
||||||
|
"it" "Il valore è troppo grande per \"{1}\"."
|
||||||
|
"ua" "Занадто велике значення для \"{1}\"."
|
||||||
|
"cze" "Hodnota je příliš velká pro \"{1}\"."
|
||||||
|
}
|
||||||
|
|
||||||
|
"Activity Vote Started"
|
||||||
|
{
|
||||||
|
"en" "Initiated an extend vote."
|
||||||
|
"fr" "A lancé un vote de prolongation."
|
||||||
|
"ru" "Начал(а) голосование за продление."
|
||||||
|
"chi" "发起了延长投票。"
|
||||||
|
"zho" "發起了延長投票。"
|
||||||
|
"es" "Inició una votación de extensión."
|
||||||
|
"de" "Hat eine Verlängerungsabstimmung gestartet."
|
||||||
|
"pt" "Iniciou uma votação de extensão."
|
||||||
|
"pl" "Rozpoczął(-ęła) głosowanie o przedłużenie."
|
||||||
|
"tr" "Uzatma oylaması başlattı."
|
||||||
|
"it" "Ha avviato una votazione per l'estensione."
|
||||||
|
"ua" "Розпочав(ла) голосування за продовження."
|
||||||
|
"cze" "Zahájil(a) hlasování o prodloužení."
|
||||||
|
}
|
||||||
|
|
||||||
|
"Activity Limit Added"
|
||||||
|
{
|
||||||
|
"#format" "{1:d},{2:t},{3:s}"
|
||||||
|
"en" "added {1} {2} to \"{3}\""
|
||||||
|
"fr" "a ajouté {1} {2} à \"{3}\""
|
||||||
|
"ru" "добавил(а) {1} {2} к \"{3}\""
|
||||||
|
"chi" "增加了 {1} {2}(\"{3}\")"
|
||||||
|
"zho" "為 \"{3}\" 增加了 {1} {2}"
|
||||||
|
"es" "añadió {1} {2} a \"{3}\""
|
||||||
|
"de" "hat {1} {2} zu \"{3}\" hinzugefügt"
|
||||||
|
"pt" "adicionou {1} {2} a \"{3}\""
|
||||||
|
"pl" "dodał(a) {1} {2} do \"{3}\""
|
||||||
|
"tr" "\"{3}\" değerine {1} {2} ekledi"
|
||||||
|
"it" "ha aggiunto {1} {2} a \"{3}\""
|
||||||
|
"ua" "додав(ла) {1} {2} до \"{3}\""
|
||||||
|
"cze" "přidal(a) {1} {2} k \"{3}\""
|
||||||
|
}
|
||||||
|
|
||||||
|
"Activity Limit Deducted"
|
||||||
|
{
|
||||||
|
"#format" "{1:d},{2:t},{3:s}"
|
||||||
|
"en" "deducted {1} {2} from \"{3}\""
|
||||||
|
"fr" "a retiré {1} {2} de \"{3}\""
|
||||||
|
"ru" "вычел(а) {1} {2} из \"{3}\""
|
||||||
|
"chi" "扣除了 {1} {2}(\"{3}\")"
|
||||||
|
"zho" "從 \"{3}\" 中扣除了 {1} {2}"
|
||||||
|
"es" "restó {1} {2} de \"{3}\""
|
||||||
|
"de" "hat {1} {2} von \"{3}\" abgezogen"
|
||||||
|
"pt" "subtraiu {1} {2} de \"{3}\""
|
||||||
|
"pl" "odjął(-ęła) {1} {2} od \"{3}\""
|
||||||
|
"tr" "\"{3}\" değerinden {1} {2} düştü"
|
||||||
|
"it" "ha sottratto {1} {2} da \"{3}\""
|
||||||
|
"ua" "відняв(ла) {1} {2} від \"{3}\""
|
||||||
|
"cze" "odečetl(a) {1} {2} z \"{3}\""
|
||||||
|
}
|
||||||
|
|
||||||
|
"Unit Round"
|
||||||
|
{
|
||||||
|
"en" "round"
|
||||||
|
"fr" "round"
|
||||||
|
"ru" "раунд"
|
||||||
|
"chi" "回合"
|
||||||
|
"es" "ronda"
|
||||||
|
"de" "Runde"
|
||||||
|
"pt" "rodada"
|
||||||
|
"pl" "runda"
|
||||||
|
"tr" "tur"
|
||||||
|
"it" "round"
|
||||||
|
"ua" "раунд"
|
||||||
|
"zho" "回合"
|
||||||
|
"cze" "kolo"
|
||||||
|
}
|
||||||
|
|
||||||
|
"Unit Rounds"
|
||||||
|
{
|
||||||
|
"en" "rounds"
|
||||||
|
"fr" "rounds"
|
||||||
|
"ru" "раунд(ов)"
|
||||||
|
"chi" "回合"
|
||||||
|
"es" "rondas"
|
||||||
|
"de" "Runden"
|
||||||
|
"pt" "rodadas"
|
||||||
|
"pl" "rund(y)"
|
||||||
|
"tr" "tur"
|
||||||
|
"it" "round"
|
||||||
|
"ua" "раунд(ів)"
|
||||||
|
"zho" "回合"
|
||||||
|
"cze" "kol"
|
||||||
|
}
|
||||||
|
|
||||||
|
"Unit Frag"
|
||||||
|
{
|
||||||
|
"en" "frag"
|
||||||
|
"fr" "frag"
|
||||||
|
"ru" "фраг"
|
||||||
|
"chi" "次击杀"
|
||||||
|
"es" "frag"
|
||||||
|
"de" "Frag"
|
||||||
|
"pt" "frag"
|
||||||
|
"pl" "frag"
|
||||||
|
"tr" "öldürme"
|
||||||
|
"it" "frag"
|
||||||
|
"ua" "фраг"
|
||||||
|
"zho" "次擊殺"
|
||||||
|
"cze" "frag"
|
||||||
|
}
|
||||||
|
|
||||||
|
"Unit Frags"
|
||||||
|
{
|
||||||
|
"en" "frags"
|
||||||
|
"fr" "frags"
|
||||||
|
"ru" "фраг(ов)"
|
||||||
|
"chi" "次击杀"
|
||||||
|
"es" "frags"
|
||||||
|
"de" "Frags"
|
||||||
|
"pt" "frags"
|
||||||
|
"pl" "fragi"
|
||||||
|
"tr" "öldürme"
|
||||||
|
"it" "frag"
|
||||||
|
"ua" "фраг(ів)"
|
||||||
|
"zho" "次擊殺"
|
||||||
|
"cze" "fragů"
|
||||||
|
}
|
||||||
|
|
||||||
|
"Unit Win"
|
||||||
|
{
|
||||||
|
"en" "win"
|
||||||
|
"fr" "victoire"
|
||||||
|
"ru" "победу"
|
||||||
|
"chi" "场胜利"
|
||||||
|
"es" "victoria"
|
||||||
|
"de" "Sieg"
|
||||||
|
"pt" "vitória"
|
||||||
|
"pl" "wygraną"
|
||||||
|
"tr" "galibiyet"
|
||||||
|
"it" "vittoria"
|
||||||
|
"ua" "перемогу"
|
||||||
|
"zho" "場勝利"
|
||||||
|
"cze" "výhru"
|
||||||
|
}
|
||||||
|
|
||||||
|
"Unit Wins"
|
||||||
|
{
|
||||||
|
"en" "wins"
|
||||||
|
"fr" "victoires"
|
||||||
|
"ru" "побед(ы)"
|
||||||
|
"chi" "场胜利"
|
||||||
|
"es" "victorias"
|
||||||
|
"de" "Siege"
|
||||||
|
"pt" "vitórias"
|
||||||
|
"pl" "wygrane"
|
||||||
|
"tr" "galibiyet"
|
||||||
|
"it" "vittorie"
|
||||||
|
"ua" "перемог(и)"
|
||||||
|
"zho" "場勝利"
|
||||||
|
"cze" "výhry"
|
||||||
|
}
|
||||||
|
|
||||||
|
"Unit Minute"
|
||||||
|
{
|
||||||
|
"en" "minute"
|
||||||
|
"fr" "minute"
|
||||||
|
"ru" "мин."
|
||||||
|
"chi" "分钟"
|
||||||
|
"es" "minuto"
|
||||||
|
"de" "Minute"
|
||||||
|
"pt" "minuto"
|
||||||
|
"pl" "minutę"
|
||||||
|
"tr" "dakika"
|
||||||
|
"it" "minuto"
|
||||||
|
"ua" "хв."
|
||||||
|
"zho" "分鐘"
|
||||||
|
"cze" "minutu"
|
||||||
|
}
|
||||||
|
|
||||||
|
"Unit Minutes"
|
||||||
|
{
|
||||||
|
"en" "minutes"
|
||||||
|
"fr" "minutes"
|
||||||
|
"ru" "мин."
|
||||||
|
"chi" "分钟"
|
||||||
|
"es" "minutos"
|
||||||
|
"de" "Minuten"
|
||||||
|
"pt" "minutos"
|
||||||
|
"pl" "minut(y)"
|
||||||
|
"tr" "dakika"
|
||||||
|
"it" "minuti"
|
||||||
|
"ua" "хв."
|
||||||
|
"zho" "分鐘"
|
||||||
|
"cze" "minut"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -10,6 +10,10 @@
|
|||||||
{
|
{
|
||||||
"signature" "CFuncRotating::UpdateSpeed"
|
"signature" "CFuncRotating::UpdateSpeed"
|
||||||
}
|
}
|
||||||
|
"linux64"
|
||||||
|
{
|
||||||
|
"signature" "CFuncRotating::UpdateSpeed"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
"CFuncRotating::InputStartForward"
|
"CFuncRotating::InputStartForward"
|
||||||
{
|
{
|
||||||
@@ -17,6 +21,10 @@
|
|||||||
{
|
{
|
||||||
"signature" "CFuncRotating::InputStartForward"
|
"signature" "CFuncRotating::InputStartForward"
|
||||||
}
|
}
|
||||||
|
"linux64"
|
||||||
|
{
|
||||||
|
"signature" "CFuncRotating::InputStartForward"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
"Signatures"
|
"Signatures"
|
||||||
@@ -25,11 +33,13 @@
|
|||||||
{
|
{
|
||||||
"library" "server"
|
"library" "server"
|
||||||
"linux" "@_ZN13CFuncRotating11UpdateSpeedEf"
|
"linux" "@_ZN13CFuncRotating11UpdateSpeedEf"
|
||||||
|
"linux64" "@_ZN13CFuncRotating11UpdateSpeedEf"
|
||||||
}
|
}
|
||||||
"CFuncRotating::InputStartForward"
|
"CFuncRotating::InputStartForward"
|
||||||
{
|
{
|
||||||
"library" "server"
|
"library" "server"
|
||||||
"linux" "@_ZN13CFuncRotating17InputStartForwardER11inputdata_t"
|
"linux" "@_ZN13CFuncRotating17InputStartForwardER11inputdata_t"
|
||||||
|
"linux64" "@_ZN13CFuncRotating17InputStartForwardER11inputdata_t"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,5 @@
|
|||||||
#pragma semicolon 1
|
#pragma semicolon 1
|
||||||
|
|
||||||
#pragma newdecls required
|
|
||||||
|
|
||||||
#define PLUGIN_AUTHOR "Cloud Strife"
|
|
||||||
#define PLUGIN_VERSION "1.0"
|
|
||||||
|
|
||||||
#include <sourcemod>
|
#include <sourcemod>
|
||||||
#include <sdktools>
|
#include <sdktools>
|
||||||
#include <dhooks>
|
#include <dhooks>
|
||||||
@@ -14,26 +9,14 @@
|
|||||||
public Plugin myinfo =
|
public Plugin myinfo =
|
||||||
{
|
{
|
||||||
name = "FixFuncRotating",
|
name = "FixFuncRotating",
|
||||||
author = PLUGIN_AUTHOR,
|
author = "Cloud Strife",
|
||||||
description = "Fixes func_rotating`s StartForward and StopAtStartPos inputs",
|
description = "Fixes func_rotating`s StartForward and StopAtStartPos inputs",
|
||||||
version = PLUGIN_VERSION,
|
version = "1.0.6",
|
||||||
url = ""
|
url = ""
|
||||||
};
|
};
|
||||||
|
|
||||||
Handle g_CFuncRotating_StartForward = null;
|
DynamicDetour g_CFuncRotating_StartForward = null;
|
||||||
Handle g_CFuncRotating_UpdateSpeed = null;
|
DynamicDetour g_CFuncRotating_UpdateSpeed = null;
|
||||||
|
|
||||||
/*
|
|
||||||
float FloatMod(float num, float denom)
|
|
||||||
{
|
|
||||||
return num - denom * RoundToFloor(num / denom);
|
|
||||||
}
|
|
||||||
|
|
||||||
float operator%(float oper1, float oper2)
|
|
||||||
{
|
|
||||||
return FloatMod(oper1, oper2);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Set m_bStopAtStartPos to false
|
// Set m_bStopAtStartPos to false
|
||||||
public MRESReturn CFuncRotating_InputStartForward(int entity)
|
public MRESReturn CFuncRotating_InputStartForward(int entity)
|
||||||
@@ -42,11 +25,11 @@ public MRESReturn CFuncRotating_InputStartForward(int entity)
|
|||||||
return MRES_Ignored;
|
return MRES_Ignored;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MRESReturn CFuncRotating_UpdateSpeed(int entity, Handle hParams)
|
public MRESReturn CFuncRotating_UpdateSpeed(int entity, DHookParam hParams)
|
||||||
{
|
{
|
||||||
if(GetEntProp(entity, Prop_Data, "m_bStopAtStartPos", 1))
|
if(GetEntProp(entity, Prop_Data, "m_bStopAtStartPos", 1))
|
||||||
{
|
{
|
||||||
float flNewSpeed = view_as<float>(DHookGetParam(hParams, 1));
|
float flNewSpeed = hParams.Get(1);
|
||||||
if(flNewSpeed <= 25)
|
if(flNewSpeed <= 25)
|
||||||
{
|
{
|
||||||
float vecMoveAng[3], angStart[3], angRotation[3], avelpertick[3];
|
float vecMoveAng[3], angStart[3], angRotation[3], avelpertick[3];
|
||||||
@@ -76,38 +59,40 @@ public MRESReturn CFuncRotating_UpdateSpeed(int entity, Handle hParams)
|
|||||||
|
|
||||||
public void OnPluginStart()
|
public void OnPluginStart()
|
||||||
{
|
{
|
||||||
Handle hGameConf = LoadGameConfigFile("FixFuncRotating.games");
|
GameData hGameConf = new GameData("FixFuncRotating.games");
|
||||||
if(hGameConf == INVALID_HANDLE)
|
if(hGameConf == null)
|
||||||
{
|
{
|
||||||
LogError("Couldn't load FixFuncRotating.games game config!");
|
LogError("Couldn't load FixFuncRotating.games game config!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Address pStartForward = GameConfGetAddress(hGameConf, "CFuncRotating::InputStartForward");
|
Address pStartForward = hGameConf.GetAddress("CFuncRotating::InputStartForward");
|
||||||
if(pStartForward)
|
if(pStartForward)
|
||||||
{
|
{
|
||||||
g_CFuncRotating_StartForward = DHookCreateDetour(pStartForward, CallConv_THISCALL, ReturnType_Void, ThisPointer_CBaseEntity);
|
g_CFuncRotating_StartForward = new DynamicDetour(pStartForward, CallConv_THISCALL, ReturnType_Void, ThisPointer_CBaseEntity);
|
||||||
|
|
||||||
if(!DHookEnableDetour(g_CFuncRotating_StartForward, false, CFuncRotating_InputStartForward))
|
if(!g_CFuncRotating_StartForward.Enable(Hook_Pre, CFuncRotating_InputStartForward))
|
||||||
{
|
{
|
||||||
LogError("Could not enable detour for CFuncRotating::InputStartForward");
|
LogError("Could not enable detour for CFuncRotating::InputStartForward");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else LogError("Could not find CFuncRotating::InputStartForward address");
|
else LogError("Could not find CFuncRotating::InputStartForward address");
|
||||||
|
|
||||||
|
Address pUpdateSpeed = hGameConf.GetAddress("CFuncRotating::UpdateSpeed");
|
||||||
Address pUpdateSpeed = GameConfGetAddress(hGameConf, "CFuncRotating::UpdateSpeed");
|
|
||||||
if(!pUpdateSpeed)
|
if(!pUpdateSpeed)
|
||||||
{
|
{
|
||||||
LogError("Could not find CFuncRotating::UpdateSpeed address");
|
LogError("Could not find CFuncRotating::UpdateSpeed address");
|
||||||
|
delete hGameConf;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_CFuncRotating_UpdateSpeed = DHookCreateDetour(pUpdateSpeed, CallConv_THISCALL, ReturnType_Void, ThisPointer_CBaseEntity);
|
g_CFuncRotating_UpdateSpeed = new DynamicDetour(pUpdateSpeed, CallConv_THISCALL, ReturnType_Void, ThisPointer_CBaseEntity);
|
||||||
DHookAddParam(g_CFuncRotating_UpdateSpeed, HookParamType_Float);
|
g_CFuncRotating_UpdateSpeed.AddParam(HookParamType_Float);
|
||||||
|
|
||||||
if(!DHookEnableDetour(g_CFuncRotating_UpdateSpeed, false, CFuncRotating_UpdateSpeed))
|
if(!g_CFuncRotating_UpdateSpeed.Enable(Hook_Pre, CFuncRotating_UpdateSpeed))
|
||||||
{
|
{
|
||||||
LogError("Could not enable detour for CFuncRotating::UpdateSpeed");
|
LogError("Could not enable detour for CFuncRotating::UpdateSpeed");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
delete hGameConf;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,13 +7,27 @@
|
|||||||
"SetGameFlags"
|
"SetGameFlags"
|
||||||
{
|
{
|
||||||
"linux" "19"
|
"linux" "19"
|
||||||
|
"linux64" "19"
|
||||||
"windows" "18"
|
"windows" "18"
|
||||||
}
|
}
|
||||||
"GetGameFlags"
|
"GetGameFlags"
|
||||||
{
|
{
|
||||||
"linux" "20"
|
"linux" "20"
|
||||||
|
"linux64" "20"
|
||||||
"windows" "19"
|
"windows" "19"
|
||||||
}
|
}
|
||||||
|
"PointerSize"
|
||||||
|
{
|
||||||
|
"linux" "4"
|
||||||
|
"linux64" "8"
|
||||||
|
"windows" "4"
|
||||||
|
}
|
||||||
|
"variant_t_size"
|
||||||
|
{
|
||||||
|
"linux" "20"
|
||||||
|
"linux64" "24"
|
||||||
|
"windows" "20"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,41 +12,29 @@ public Plugin myinfo =
|
|||||||
name = "FixVPhysicsCrush",
|
name = "FixVPhysicsCrush",
|
||||||
author = "BotoX",
|
author = "BotoX",
|
||||||
description = "",
|
description = "",
|
||||||
version = "0.0",
|
version = "0.1",
|
||||||
url = ""
|
url = ""
|
||||||
};
|
};
|
||||||
|
|
||||||
Handle g_hAcceptInput;
|
Handle g_hAcceptInput;
|
||||||
Handle g_hSetGameFlags;
|
Handle g_hSetGameFlags;
|
||||||
Handle g_hGetGameFlags;
|
Handle g_hGetGameFlags;
|
||||||
int g_hPhysicsObject;
|
int g_iPhysicsObjectOffset;
|
||||||
|
|
||||||
|
|
||||||
public void OnPluginStart()
|
public void OnPluginStart()
|
||||||
{
|
{
|
||||||
Handle hGameData = LoadGameConfigFile("sdktools.games");
|
Handle hGameData = LoadGameConfigFile("FixVPhysicsCrush.games");
|
||||||
if(!hGameData)
|
|
||||||
SetFailState("Couldn't load sdktools gamedata.");
|
|
||||||
|
|
||||||
// CBaseEntity::AcceptInput( const char *szInputName, CBaseEntity *pActivator, CBaseEntity *pCaller, variant_t Value, int outputID )
|
|
||||||
int Offset = GameConfGetOffset(hGameData, "AcceptInput");
|
|
||||||
if(Offset == -1)
|
|
||||||
SetFailState("Failed to find AcceptInput offset.");
|
|
||||||
|
|
||||||
g_hAcceptInput = DHookCreate(Offset, HookType_Entity, ReturnType_Bool, ThisPointer_CBaseEntity, OnAcceptInput);
|
|
||||||
if(g_hAcceptInput == INVALID_HANDLE)
|
|
||||||
SetFailState("Failed to DHook AcceptInput.");
|
|
||||||
|
|
||||||
DHookAddParam(g_hAcceptInput, HookParamType_CharPtr);
|
|
||||||
DHookAddParam(g_hAcceptInput, HookParamType_CBaseEntity);
|
|
||||||
DHookAddParam(g_hAcceptInput, HookParamType_CBaseEntity);
|
|
||||||
DHookAddParam(g_hAcceptInput, HookParamType_Object, 20, DHookPass_ByVal|DHookPass_ODTOR|DHookPass_OCTOR|DHookPass_OASSIGNOP); //varaint_t is a union of 12 (float[3]) plus two int type params 12 + 8 = 20
|
|
||||||
DHookAddParam(g_hAcceptInput, HookParamType_Int);
|
|
||||||
|
|
||||||
hGameData = LoadGameConfigFile("FixVPhysicsCrush.games");
|
|
||||||
if(!hGameData)
|
if(!hGameData)
|
||||||
SetFailState("Couldn't load FixVPhysicsCrush gamedata.");
|
SetFailState("Couldn't load FixVPhysicsCrush gamedata.");
|
||||||
|
|
||||||
|
int iPointerSize = GameConfGetOffset(hGameData, "PointerSize");
|
||||||
|
int iVariantSize = GameConfGetOffset(hGameData, "variant_t_size");
|
||||||
|
if(iPointerSize == -1 || iVariantSize == -1)
|
||||||
|
{
|
||||||
|
delete hGameData;
|
||||||
|
SetFailState("Missing PointerSize / variant_t_size in FixVPhysicsCrush gamedata.");
|
||||||
|
}
|
||||||
|
|
||||||
// CPhysicsObject::SetGameFlags(unsigned short)
|
// CPhysicsObject::SetGameFlags(unsigned short)
|
||||||
StartPrepSDKCall(SDKCall_Raw);
|
StartPrepSDKCall(SDKCall_Raw);
|
||||||
if(!PrepSDKCall_SetFromConf(hGameData, SDKConf_Virtual, "SetGameFlags"))
|
if(!PrepSDKCall_SetFromConf(hGameData, SDKConf_Virtual, "SetGameFlags"))
|
||||||
@@ -66,14 +54,36 @@ public void OnPluginStart()
|
|||||||
}
|
}
|
||||||
PrepSDKCall_SetReturnInfo(SDKType_PlainOldData, SDKPass_Plain);
|
PrepSDKCall_SetReturnInfo(SDKType_PlainOldData, SDKPass_Plain);
|
||||||
g_hGetGameFlags = EndPrepSDKCall();
|
g_hGetGameFlags = EndPrepSDKCall();
|
||||||
|
delete hGameData;
|
||||||
|
|
||||||
|
hGameData = LoadGameConfigFile("sdktools.games");
|
||||||
|
if(!hGameData)
|
||||||
|
SetFailState("Couldn't load sdktools gamedata.");
|
||||||
|
|
||||||
|
// CBaseEntity::AcceptInput( const char *szInputName, CBaseEntity *pActivator, CBaseEntity *pCaller, variant_t Value, int outputID )
|
||||||
|
int Offset = GameConfGetOffset(hGameData, "AcceptInput");
|
||||||
|
delete hGameData;
|
||||||
|
if(Offset == -1)
|
||||||
|
SetFailState("Failed to find AcceptInput offset.");
|
||||||
|
|
||||||
|
g_hAcceptInput = DHookCreate(Offset, HookType_Entity, ReturnType_Bool, ThisPointer_CBaseEntity, OnAcceptInput);
|
||||||
|
if(g_hAcceptInput == INVALID_HANDLE)
|
||||||
|
SetFailState("Failed to DHook AcceptInput.");
|
||||||
|
|
||||||
|
DHookAddParam(g_hAcceptInput, HookParamType_CharPtr);
|
||||||
|
DHookAddParam(g_hAcceptInput, HookParamType_CBaseEntity);
|
||||||
|
DHookAddParam(g_hAcceptInput, HookParamType_CBaseEntity);
|
||||||
|
DHookAddParam(g_hAcceptInput, HookParamType_Object, iVariantSize, DHookPass_ByVal|DHookPass_ODTOR|DHookPass_OCTOR|DHookPass_OASSIGNOP); // variant_t: 20 bytes on x86, 24 bytes on x64
|
||||||
|
DHookAddParam(g_hAcceptInput, HookParamType_Int);
|
||||||
|
|
||||||
int hCollisionGroup = FindSendPropInfo("CBaseEntity", "m_CollisionGroup");
|
int hCollisionGroup = FindSendPropInfo("CBaseEntity", "m_CollisionGroup");
|
||||||
if (hCollisionGroup == -1)
|
if (hCollisionGroup == -1)
|
||||||
SetFailState("Couldn't find CBaseEntity::m_CollisionGroup");
|
SetFailState("Couldn't find CBaseEntity::m_CollisionGroup");
|
||||||
|
|
||||||
// CNetworkVar( int, m_CollisionGroup );
|
// CNetworkVar( int, m_CollisionGroup );
|
||||||
// IPhysicsObject *m_pPhysicsObject;
|
// IPhysicsObject *m_pPhysicsObject; <- pointer, aligned to pointer size (4 on x86, 8 on x64)
|
||||||
g_hPhysicsObject = hCollisionGroup + 4;
|
g_iPhysicsObjectOffset = hCollisionGroup + 4;
|
||||||
|
g_iPhysicsObjectOffset = (g_iPhysicsObjectOffset + iPointerSize - 1) & ~(iPointerSize - 1);
|
||||||
|
|
||||||
// Late load.
|
// Late load.
|
||||||
int entity = INVALID_ENT_REFERENCE;
|
int entity = INVALID_ENT_REFERENCE;
|
||||||
@@ -94,7 +104,7 @@ public void OnEntityCreated(int entity, const char[] classname)
|
|||||||
public MRESReturn OnAcceptInput(int entity, Handle hReturn, Handle hParams)
|
public MRESReturn OnAcceptInput(int entity, Handle hReturn, Handle hParams)
|
||||||
{
|
{
|
||||||
if(!IsValidEntity(entity))
|
if(!IsValidEntity(entity))
|
||||||
return;
|
return MRES_Ignored;
|
||||||
|
|
||||||
char sCommand[128];
|
char sCommand[128];
|
||||||
DHookGetParamString(hParams, 1, sCommand, sizeof(sCommand));
|
DHookGetParamString(hParams, 1, sCommand, sizeof(sCommand));
|
||||||
@@ -104,8 +114,8 @@ public MRESReturn OnAcceptInput(int entity, Handle hReturn, Handle hParams)
|
|||||||
int attachedObject = GetEntPropEnt(entity, Prop_Data, "m_attachedObject");
|
int attachedObject = GetEntPropEnt(entity, Prop_Data, "m_attachedObject");
|
||||||
if(attachedObject != INVALID_ENT_REFERENCE)
|
if(attachedObject != INVALID_ENT_REFERENCE)
|
||||||
{
|
{
|
||||||
int vphysObj = GetVPhysicsObject(attachedObject);
|
Address vphysObj = GetVPhysicsObject(attachedObject);
|
||||||
if(vphysObj)
|
if(vphysObj != Address_Null)
|
||||||
{
|
{
|
||||||
int flags = VPhysicsGetGameFlags(vphysObj);
|
int flags = VPhysicsGetGameFlags(vphysObj);
|
||||||
flags |= FVPHYSICS_NO_IMPACT_DMG;
|
flags |= FVPHYSICS_NO_IMPACT_DMG;
|
||||||
@@ -113,19 +123,22 @@ public MRESReturn OnAcceptInput(int entity, Handle hReturn, Handle hParams)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return MRES_Ignored;
|
||||||
}
|
}
|
||||||
|
|
||||||
int VPhysicsGetGameFlags(int vphysicsObj)
|
int VPhysicsGetGameFlags(Address vphysicsObj)
|
||||||
{
|
{
|
||||||
return SDKCall(g_hGetGameFlags, vphysicsObj);
|
return SDKCall(g_hGetGameFlags, vphysicsObj) & 0xFFFF; // returns unsigned short
|
||||||
}
|
}
|
||||||
|
|
||||||
void VPhysicsSetGameFlags(int vphysicsObj, int flags)
|
void VPhysicsSetGameFlags(Address vphysicsObj, int flags)
|
||||||
{
|
{
|
||||||
SDKCall(g_hSetGameFlags, vphysicsObj, flags);
|
SDKCall(g_hSetGameFlags, vphysicsObj, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
int GetVPhysicsObject(int entity)
|
Address GetVPhysicsObject(int entity)
|
||||||
{
|
{
|
||||||
return GetEntData(entity, g_hPhysicsObject, 4);
|
// Read the full IPhysicsObject* (4 bytes on x86, 8 bytes on x64)
|
||||||
|
return LoadAddressFromAddress(GetEntityAddress(entity) + view_as<Address>(g_iPhysicsObjectOffset));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,24 +0,0 @@
|
|||||||
#if defined _FullUpdate_Included
|
|
||||||
#endinput
|
|
||||||
#endif
|
|
||||||
#define _FullUpdate_Included
|
|
||||||
|
|
||||||
native bool ClientFullUpdate(int client);
|
|
||||||
|
|
||||||
public SharedPlugin __pl_FullUpdate =
|
|
||||||
{
|
|
||||||
name = "FullUpdate",
|
|
||||||
file = "FullUpdate.smx",
|
|
||||||
#if defined REQUIRE_PLUGIN
|
|
||||||
required = 1,
|
|
||||||
#else
|
|
||||||
required = 0,
|
|
||||||
#endif
|
|
||||||
};
|
|
||||||
|
|
||||||
#if !defined REQUIRE_PLUGIN
|
|
||||||
public __pl_FullUpdate_SetNTVOptional()
|
|
||||||
{
|
|
||||||
MarkNativeAsOptional("ClientFullUpdate");
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
+20
-29
@@ -6,7 +6,6 @@
|
|||||||
{
|
{
|
||||||
"engine" "orangebox_valve"
|
"engine" "orangebox_valve"
|
||||||
"engine" "css"
|
"engine" "css"
|
||||||
"engine" "csgo"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
"Addresses"
|
"Addresses"
|
||||||
@@ -22,6 +21,10 @@
|
|||||||
{
|
{
|
||||||
"signature" "sv"
|
"signature" "sv"
|
||||||
}
|
}
|
||||||
|
"linux64"
|
||||||
|
{
|
||||||
|
"signature" "sv"
|
||||||
|
}
|
||||||
"mac"
|
"mac"
|
||||||
{
|
{
|
||||||
"signature" "sv"
|
"signature" "sv"
|
||||||
@@ -41,6 +44,7 @@
|
|||||||
{
|
{
|
||||||
"library" "engine"
|
"library" "engine"
|
||||||
"linux" "@sv"
|
"linux" "@sv"
|
||||||
|
"linux64" "@sv"
|
||||||
"mac" "@sv"
|
"mac" "@sv"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -68,6 +72,10 @@
|
|||||||
{
|
{
|
||||||
"signature" "sv"
|
"signature" "sv"
|
||||||
}
|
}
|
||||||
|
"linux64"
|
||||||
|
{
|
||||||
|
"signature" "sv"
|
||||||
|
}
|
||||||
"mac"
|
"mac"
|
||||||
{
|
{
|
||||||
"signature" "sv"
|
"signature" "sv"
|
||||||
@@ -87,6 +95,7 @@
|
|||||||
{
|
{
|
||||||
"library" "engine"
|
"library" "engine"
|
||||||
"linux" "@sv"
|
"linux" "@sv"
|
||||||
|
"linux64" "@sv"
|
||||||
"mac" "@sv"
|
"mac" "@sv"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -107,11 +116,21 @@
|
|||||||
{
|
{
|
||||||
"windows" "6"
|
"windows" "6"
|
||||||
"linux" "7"
|
"linux" "7"
|
||||||
|
"linux64" "7"
|
||||||
"mac" "7"
|
"mac" "7"
|
||||||
}
|
}
|
||||||
"CBaseClient::UpdateAcknowledgedFramecount"
|
"CBaseClient::UpdateAcknowledgedFramecount"
|
||||||
{
|
{
|
||||||
"linux" "44"
|
"linux" "44"
|
||||||
|
"linux64" "44"
|
||||||
|
}
|
||||||
|
// IClient comes after the IGameEventListener2 vtable pointer in CBaseClient
|
||||||
|
"CBaseClient::IClient"
|
||||||
|
{
|
||||||
|
"windows" "4"
|
||||||
|
"linux" "4"
|
||||||
|
"linux64" "8"
|
||||||
|
"mac" "4"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -122,7 +141,6 @@
|
|||||||
{
|
{
|
||||||
"engine" "left4dead"
|
"engine" "left4dead"
|
||||||
"engine" "left4dead2"
|
"engine" "left4dead2"
|
||||||
"engine" "csgo"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
"Offsets"
|
"Offsets"
|
||||||
@@ -135,31 +153,4 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
"csgo"
|
|
||||||
{
|
|
||||||
"Offsets"
|
|
||||||
{
|
|
||||||
// a1[134] * 4
|
|
||||||
"m_nDeltaTick"
|
|
||||||
{
|
|
||||||
"linux" "536"
|
|
||||||
}
|
|
||||||
// a1[206] * 4
|
|
||||||
"m_nForceWaitForTick"
|
|
||||||
{
|
|
||||||
"linux" "824"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
"Signatures"
|
|
||||||
{
|
|
||||||
// Str: "Sending full update to Client %s (%s)\n" ^ CBaseClient::OnRequestFullUpdate
|
|
||||||
"CBaseClient::OnRequestFullUpdate"
|
|
||||||
{
|
|
||||||
"library" "engine"
|
|
||||||
"linux" "\x55\x89\xE5\x53\x83\xEC\x14\x8B\x5D\x08\xC7\x44\x24\x04\x00\x00\x00\x00\x8D\x83\x24\x02\x00\x00"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
+25
-69
@@ -6,13 +6,10 @@
|
|||||||
#include <FullUpdate>
|
#include <FullUpdate>
|
||||||
|
|
||||||
Handle g_hCBaseClient_UpdateAcknowledgedFramecount;
|
Handle g_hCBaseClient_UpdateAcknowledgedFramecount;
|
||||||
Handle g_hCBaseClient_OnRequestFullUpdate;
|
|
||||||
Handle g_hGetClient;
|
Handle g_hGetClient;
|
||||||
|
|
||||||
Address m_nDeltaTick;
|
|
||||||
Address m_nForceWaitForTick;
|
|
||||||
|
|
||||||
Address g_pBaseServer;
|
Address g_pBaseServer;
|
||||||
|
int g_iIClientOffset = 4;
|
||||||
|
|
||||||
int g_iLastFullUpdate[MAXPLAYERS + 1] = { 0, ... };
|
int g_iLastFullUpdate[MAXPLAYERS + 1] = { 0, ... };
|
||||||
|
|
||||||
@@ -21,7 +18,8 @@ public Plugin myinfo =
|
|||||||
name = "FullUpdate",
|
name = "FullUpdate",
|
||||||
author = "BotoX, PŠΣ™ SHUFEN, maxime1907",
|
author = "BotoX, PŠΣ™ SHUFEN, maxime1907",
|
||||||
description = "Serverside cl_fullupdate",
|
description = "Serverside cl_fullupdate",
|
||||||
version = "1.3.0"
|
version = FullUpdate_VERSION,
|
||||||
|
url = "https://github.com/srcdslab/sm-plugin-FullUpdate"
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnPluginStart()
|
public void OnPluginStart()
|
||||||
@@ -33,9 +31,10 @@ public void OnPluginStart()
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if !defined GetClientIClient
|
#if !defined GetClientIClient
|
||||||
g_pBaseServer = GameConfGetAddress(hGameData, "CBaseServer");
|
g_pBaseServer = hGameData.GetAddress("CBaseServer");
|
||||||
if(g_pBaseServer == Address_Null)
|
if(g_pBaseServer == Address_Null)
|
||||||
{
|
{
|
||||||
|
delete hGameData;
|
||||||
SetFailState("Couldn't get BaseServer address!");
|
SetFailState("Couldn't get BaseServer address!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -47,16 +46,18 @@ public void OnPluginStart()
|
|||||||
SetFailState("PrepSDKCall_SetFromConf(hGameData, SDKConf_Virtual, \"CBaseServer::GetClient\" failed!");
|
SetFailState("PrepSDKCall_SetFromConf(hGameData, SDKConf_Virtual, \"CBaseServer::GetClient\" failed!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
#if SOURCEMOD_V_MAJOR == 1 && SOURCEMOD_V_MINOR < 13
|
||||||
|
// SM 1.12 has no SDKType_Address (x86 only): the pointer comes back as plain data
|
||||||
PrepSDKCall_SetReturnInfo(SDKType_PlainOldData, SDKPass_Plain);
|
PrepSDKCall_SetReturnInfo(SDKType_PlainOldData, SDKPass_Plain);
|
||||||
|
#else
|
||||||
|
PrepSDKCall_SetReturnInfo(SDKType_Address, SDKPass_Plain);
|
||||||
|
#endif
|
||||||
PrepSDKCall_AddParameter(SDKType_PlainOldData, SDKPass_Plain);
|
PrepSDKCall_AddParameter(SDKType_PlainOldData, SDKPass_Plain);
|
||||||
g_hGetClient = EndPrepSDKCall();
|
g_hGetClient = EndPrepSDKCall();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (GetEngineVersion() != Engine_CSGO)
|
|
||||||
{
|
|
||||||
// void CBaseClient::UpdateAcknowledgedFramecount()
|
// void CBaseClient::UpdateAcknowledgedFramecount()
|
||||||
StartPrepSDKCall(SDKCall_Raw);
|
StartPrepSDKCall(SDKCall_Raw);
|
||||||
|
|
||||||
if(!PrepSDKCall_SetFromConf(hGameData, SDKConf_Virtual, "CBaseClient::UpdateAcknowledgedFramecount"))
|
if(!PrepSDKCall_SetFromConf(hGameData, SDKConf_Virtual, "CBaseClient::UpdateAcknowledgedFramecount"))
|
||||||
{
|
{
|
||||||
delete hGameData;
|
delete hGameData;
|
||||||
@@ -67,46 +68,22 @@ public void OnPluginStart()
|
|||||||
PrepSDKCall_AddParameter(SDKType_PlainOldData, SDKPass_Plain);
|
PrepSDKCall_AddParameter(SDKType_PlainOldData, SDKPass_Plain);
|
||||||
|
|
||||||
g_hCBaseClient_UpdateAcknowledgedFramecount = EndPrepSDKCall();
|
g_hCBaseClient_UpdateAcknowledgedFramecount = EndPrepSDKCall();
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// void CBaseClient::OnRequestFullUpdate(char const *pchReason)
|
|
||||||
StartPrepSDKCall(SDKCall_Raw);
|
|
||||||
if (!PrepSDKCall_SetFromConf(hGameData, SDKConf_Signature, "CBaseClient::OnRequestFullUpdate")) {
|
|
||||||
delete hGameData;
|
|
||||||
SetFailState("PrepSDKCall_SetFromConf(hGameData, SDKConf_Signature, \"CBaseClient::OnRequestFullUpdate\") failed!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
PrepSDKCall_AddParameter(SDKType_String, SDKPass_Pointer);
|
|
||||||
g_hCBaseClient_OnRequestFullUpdate = EndPrepSDKCall();
|
|
||||||
|
|
||||||
int offset = hGameData.GetOffset("m_nDeltaTick");
|
int iOffset = hGameData.GetOffset("CBaseClient::IClient");
|
||||||
if (offset == -1) {
|
if (iOffset != -1)
|
||||||
delete hGameData;
|
g_iIClientOffset = iOffset;
|
||||||
SetFailState("Cannot get offset CBaseClient->m_nDeltaTick");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
m_nDeltaTick = view_as<Address>(offset);
|
|
||||||
|
|
||||||
offset = hGameData.GetOffset("m_nForceWaitForTick");
|
|
||||||
if (offset == -1) {
|
|
||||||
delete hGameData;
|
|
||||||
SetFailState("Cannot get offset CBaseClient->m_nForceWaitForTick");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
m_nForceWaitForTick = view_as<Address>(offset);
|
|
||||||
}
|
|
||||||
|
|
||||||
delete hGameData;
|
delete hGameData;
|
||||||
|
|
||||||
|
RegConsoleCmd("fullupdate", Command_FullUpdate);
|
||||||
RegConsoleCmd("sm_fullupdate", Command_FullUpdate);
|
RegConsoleCmd("sm_fullupdate", Command_FullUpdate);
|
||||||
AddCommandListener(Command_cl_fullupdate, "cl_fullupdate");
|
AddCommandListener(Command_cl_fullupdate, "cl_fullupdate");
|
||||||
RegConsoleCmd("fullupdate", Command_FullUpdate);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max)
|
public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max)
|
||||||
{
|
{
|
||||||
CreateNative("ClientFullUpdate", Native_FullUpdate);
|
CreateNative("ClientFullUpdate", Native_FullUpdate);
|
||||||
|
|
||||||
RegPluginLibrary("FullUpdate");
|
RegPluginLibrary("FullUpdate");
|
||||||
|
|
||||||
return APLRes_Success;
|
return APLRes_Success;
|
||||||
@@ -125,39 +102,11 @@ bool FullUpdate(int client)
|
|||||||
if (IsFakeClient(client))
|
if (IsFakeClient(client))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (GetEngineVersion() != Engine_CSGO)
|
|
||||||
{
|
|
||||||
Address pIClient = GetBaseClient(client);
|
Address pIClient = GetBaseClient(client);
|
||||||
if (!pIClient)
|
if (!pIClient)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
SDKCall(g_hCBaseClient_UpdateAcknowledgedFramecount, pIClient, -1);
|
SDKCall(g_hCBaseClient_UpdateAcknowledgedFramecount, pIClient, -1);
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Address pIClient = GetBaseClient(client);
|
|
||||||
if (!pIClient)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
int iDeltaTick = LoadFromAddress(pIClient + m_nDeltaTick, NumberType_Int32);
|
|
||||||
int iForceWaitForTick = LoadFromAddress(pIClient + m_nForceWaitForTick, NumberType_Int32);
|
|
||||||
|
|
||||||
if (iForceWaitForTick > 0) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (iDeltaTick == -1)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
char sReason[128];
|
|
||||||
FormatEx(sReason, sizeof(sReason), "%N called this function by 'sm_fullupdate' command", client);
|
|
||||||
|
|
||||||
SDKCall(g_hCBaseClient_OnRequestFullUpdate, pIClient, sReason);
|
|
||||||
}
|
|
||||||
|
|
||||||
// get acknowledged client frame
|
|
||||||
StoreToAddress(pIClient + m_nDeltaTick, -1, NumberType_Int32);
|
|
||||||
}
|
|
||||||
|
|
||||||
g_iLastFullUpdate[client] = GetTime();
|
g_iLastFullUpdate[client] = GetTime();
|
||||||
return true;
|
return true;
|
||||||
@@ -203,7 +152,14 @@ public Action Command_FullUpdate(int client, int args)
|
|||||||
#if !defined GetClientIClient
|
#if !defined GetClientIClient
|
||||||
stock Address GetClientIClient(int client)
|
stock Address GetClientIClient(int client)
|
||||||
{
|
{
|
||||||
return SDKCall(g_hGetClient, g_pBaseServer, client-1);
|
#if SOURCEMOD_V_MAJOR == 1 && SOURCEMOD_V_MINOR < 13
|
||||||
|
return view_as<Address>(SDKCall(g_hGetClient, g_pBaseServer, client-1));
|
||||||
|
#else
|
||||||
|
// SDKType_Address results come back through a by-ref argument (64-bit Address).
|
||||||
|
Address pIClient;
|
||||||
|
SDKCall(g_hGetClient, g_pBaseServer, pIClient, client-1);
|
||||||
|
return pIClient;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -213,6 +169,6 @@ stock Address GetBaseClient(int client)
|
|||||||
if(!pIClientTmp)
|
if(!pIClientTmp)
|
||||||
return Address_Null;
|
return Address_Null;
|
||||||
|
|
||||||
// The IClient vtable is +4 from the IGameEventListener2 (CBaseClient) vtable due to multiple inheritance.
|
// The IClient vtable comes after the IGameEventListener2 (CBaseClient) one due to multiple inheritance.
|
||||||
return pIClientTmp - view_as<Address>(4);
|
return pIClientTmp - view_as<Address>(g_iIClientOffset);
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
#if defined _FullUpdate_Included
|
||||||
|
#endinput
|
||||||
|
#endif
|
||||||
|
#define _FullUpdate_Included
|
||||||
|
|
||||||
|
#define FullUpdate_V_MAJOR "1"
|
||||||
|
#define FullUpdate_V_MINOR "4"
|
||||||
|
#define FullUpdate_V_PATCH "1"
|
||||||
|
|
||||||
|
#define FullUpdate_VERSION FullUpdate_V_MAJOR..."."...FullUpdate_V_MINOR..."."...FullUpdate_V_PATCH
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Forces a full update (cl_fullupdate) for a client.
|
||||||
|
*
|
||||||
|
* @param client Client index
|
||||||
|
* @return True if update was successful, false otherwise
|
||||||
|
* @error Invalid client index, client not in game, or client is fake
|
||||||
|
*/
|
||||||
|
native bool ClientFullUpdate(int client);
|
||||||
|
|
||||||
|
public SharedPlugin __pl_FullUpdate =
|
||||||
|
{
|
||||||
|
name = "FullUpdate",
|
||||||
|
file = "FullUpdate.smx",
|
||||||
|
#if defined REQUIRE_PLUGIN
|
||||||
|
required = 1,
|
||||||
|
#else
|
||||||
|
required = 0,
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
#if !defined REQUIRE_PLUGIN
|
||||||
|
public __pl_FullUpdate_SetNTVOptional()
|
||||||
|
{
|
||||||
|
MarkNativeAsOptional("ClientFullUpdate");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
@@ -8,6 +8,7 @@
|
|||||||
{
|
{
|
||||||
"library" "server"
|
"library" "server"
|
||||||
"linux" "@_ZN11CBaseEntity12OnTakeDamageERK15CTakeDamageInfo"
|
"linux" "@_ZN11CBaseEntity12OnTakeDamageERK15CTakeDamageInfo"
|
||||||
|
"linux64" "@_ZN11CBaseEntity12OnTakeDamageERK15CTakeDamageInfo"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
"Games"
|
||||||
|
{
|
||||||
|
"cstrike"
|
||||||
|
{
|
||||||
|
"Offsets"
|
||||||
|
{
|
||||||
|
"RadiusDamage"
|
||||||
|
{
|
||||||
|
"windows" "68"
|
||||||
|
"linux" "69"
|
||||||
|
"linux64" "69"
|
||||||
|
"mac" "69"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,74 @@
|
|||||||
|
#pragma semicolon 1
|
||||||
|
#pragma newdecls required
|
||||||
|
|
||||||
|
#include <sourcemod>
|
||||||
|
#include <sdkhooks>
|
||||||
|
#include <sdktools>
|
||||||
|
#include <dhooks>
|
||||||
|
|
||||||
|
DynamicHook g_hRadiusDamage;
|
||||||
|
|
||||||
|
public Plugin myinfo =
|
||||||
|
{
|
||||||
|
name = "Napalm Lag Fix",
|
||||||
|
author = "GoD-Tony + BotoX",
|
||||||
|
description = "Prevents lag when napalm is used on players",
|
||||||
|
version = "1.0.8",
|
||||||
|
url = "https://forums.alliedmods.net/showthread.php?t=188093"
|
||||||
|
};
|
||||||
|
|
||||||
|
public void OnPluginStart()
|
||||||
|
{
|
||||||
|
// Gamedata.
|
||||||
|
GameData hConfig = new GameData("fixnapalmlag.games");
|
||||||
|
if (!hConfig)
|
||||||
|
SetFailState("Could not find gamedata file: fixnapalmlag.games.txt");
|
||||||
|
|
||||||
|
int offset = hConfig.GetOffset("RadiusDamage");
|
||||||
|
if (offset == -1)
|
||||||
|
{
|
||||||
|
delete hConfig;
|
||||||
|
SetFailState("Failed to find RadiusDamage offset");
|
||||||
|
}
|
||||||
|
|
||||||
|
delete hConfig;
|
||||||
|
|
||||||
|
// DHooks
|
||||||
|
g_hRadiusDamage = new DynamicHook(offset, HookType_GameRules, ReturnType_Void, ThisPointer_Ignore);
|
||||||
|
g_hRadiusDamage.AddParam(HookParamType_ObjectPtr); // 1 - CTakeDamageInfo &info
|
||||||
|
g_hRadiusDamage.AddParam(HookParamType_VectorPtr); // 2 - Vector &vecSrc
|
||||||
|
g_hRadiusDamage.AddParam(HookParamType_Float); // 3 - float flRadius
|
||||||
|
g_hRadiusDamage.AddParam(HookParamType_Int); // 4 - int iClassIgnore
|
||||||
|
g_hRadiusDamage.AddParam(HookParamType_CBaseEntity); // 5 - CBaseEntity *pEntityIgnore
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnMapStart()
|
||||||
|
{
|
||||||
|
g_hRadiusDamage.HookGamerules(Hook_Pre, Hook_RadiusDamage);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MRESReturn Hook_RadiusDamage(DHookParam hParams)
|
||||||
|
{
|
||||||
|
if (hParams.IsNull(5))
|
||||||
|
return MRES_Ignored;
|
||||||
|
|
||||||
|
int iDmgBits = hParams.GetObjectVar(1, 60, ObjectValueType_Int);
|
||||||
|
int iEntIgnore = hParams.Get(5);
|
||||||
|
|
||||||
|
if (!(iDmgBits & DMG_BURN))
|
||||||
|
return MRES_Ignored;
|
||||||
|
|
||||||
|
// Block napalm damage if it's coming from another client.
|
||||||
|
if (iEntIgnore >= 1 && iEntIgnore <= MaxClients)
|
||||||
|
return MRES_Supercede;
|
||||||
|
|
||||||
|
// Block napalm that comes from grenades
|
||||||
|
char sEntClassName[64];
|
||||||
|
if (GetEntityClassname(iEntIgnore, sEntClassName, sizeof(sEntClassName)))
|
||||||
|
{
|
||||||
|
if (!strcmp(sEntClassName, "hegrenade_projectile"))
|
||||||
|
return MRES_Supercede;
|
||||||
|
}
|
||||||
|
|
||||||
|
return MRES_Ignored;
|
||||||
|
}
|
||||||
@@ -6,8 +6,22 @@
|
|||||||
{
|
{
|
||||||
"OnDamagedByExplosion"
|
"OnDamagedByExplosion"
|
||||||
{
|
{
|
||||||
"windows" "341"
|
"windows" "342"
|
||||||
"linux" "342"
|
"linux" "343"
|
||||||
|
"linux64" "343"
|
||||||
|
"mac" "343"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"csgo"
|
||||||
|
{
|
||||||
|
"Offsets"
|
||||||
|
{
|
||||||
|
"OnDamagedByExplosion"
|
||||||
|
{
|
||||||
|
"windows" "376"
|
||||||
|
"linux" "377"
|
||||||
|
"mac" "377"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,30 +1,31 @@
|
|||||||
#pragma semicolon 1
|
#pragma semicolon 1
|
||||||
|
#pragma newdecls required
|
||||||
#include <sourcemod>
|
#include <sourcemod>
|
||||||
#include <sdktools>
|
#include <sdktools>
|
||||||
#include <dhooks>
|
#include <dhooks>
|
||||||
|
|
||||||
// int CCSPlayer::OnDamagedByExplosion(CTakeDamageInfo const&)
|
// int CCSPlayer::OnDamagedByExplosion(CTakeDamageInfo const&)
|
||||||
Handle g_hDamagedByExplosion;
|
DynamicHook g_hDamagedByExplosion;
|
||||||
|
|
||||||
public Plugin myinfo =
|
public Plugin myinfo =
|
||||||
{
|
{
|
||||||
name = "NoGrenadeRinging",
|
name = "NoGrenadeRinging",
|
||||||
author = "BotoX",
|
author = "BotoX",
|
||||||
description = "Block the annoying ringing noise when a grenade explodes next to you",
|
description = "Block the annoying ringing noise when a grenade explodes next to you",
|
||||||
version = "1.0.1",
|
version = "1.2.2",
|
||||||
url = ""
|
url = ""
|
||||||
};
|
};
|
||||||
|
|
||||||
public void OnPluginStart()
|
public void OnPluginStart()
|
||||||
{
|
{
|
||||||
Handle hTemp = LoadGameConfigFile("NoGrenadeRinging.games");
|
GameData hTemp = new GameData("NoGrenadeRinging.games");
|
||||||
if(hTemp == INVALID_HANDLE)
|
if(hTemp == null)
|
||||||
SetFailState("Why you no has gamedata?");
|
SetFailState("Why you no has gamedata?");
|
||||||
|
|
||||||
int Offset = GameConfGetOffset(hTemp, "OnDamagedByExplosion");
|
int Offset = hTemp.GetOffset("OnDamagedByExplosion");
|
||||||
g_hDamagedByExplosion = DHookCreate(Offset, HookType_Entity, ReturnType_Int, ThisPointer_CBaseEntity, OnDamagedByExplosion);
|
g_hDamagedByExplosion = new DynamicHook(Offset, HookType_Entity, ReturnType_Int, ThisPointer_CBaseEntity);
|
||||||
DHookAddParam(g_hDamagedByExplosion, HookParamType_ObjectPtr);
|
g_hDamagedByExplosion.AddParam(HookParamType_ObjectPtr);
|
||||||
CloseHandle(hTemp);
|
delete hTemp;
|
||||||
|
|
||||||
/* Late load */
|
/* Late load */
|
||||||
for(int client = 1; client <= MaxClients; client++)
|
for(int client = 1; client <= MaxClients; client++)
|
||||||
@@ -37,13 +38,13 @@ public void OnPluginStart()
|
|||||||
public void OnClientPutInServer(int client)
|
public void OnClientPutInServer(int client)
|
||||||
{
|
{
|
||||||
// Don't add removal callback for this one
|
// Don't add removal callback for this one
|
||||||
DHookEntity(g_hDamagedByExplosion, false, client);
|
g_hDamagedByExplosion.HookEntity(Hook_Pre, client, OnDamagedByExplosion);
|
||||||
}
|
}
|
||||||
|
|
||||||
// int CCSPlayer::OnDamagedByExplosion(CTakeDamageInfo const&)
|
// int CCSPlayer::OnDamagedByExplosion(CTakeDamageInfo const&)
|
||||||
public MRESReturn OnDamagedByExplosion(int pThis, Handle hReturn, Handle hParams)
|
public MRESReturn OnDamagedByExplosion(int pThis, DHookReturn hReturn, DHookParam hParams)
|
||||||
{
|
{
|
||||||
// Block call
|
// Block call
|
||||||
DHookSetReturn(hReturn, 0);
|
hReturn.Value = 0;
|
||||||
return MRES_Supercede;
|
return MRES_Supercede;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,12 +7,14 @@
|
|||||||
"PlayerUse"
|
"PlayerUse"
|
||||||
{
|
{
|
||||||
"linux" "414"
|
"linux" "414"
|
||||||
|
"linux64" "414"
|
||||||
"windows" "413"
|
"windows" "413"
|
||||||
}
|
}
|
||||||
|
|
||||||
"ForceVPhysicsCollide"
|
"ForceVPhysicsCollide"
|
||||||
{
|
{
|
||||||
"linux" "160"
|
"linux" "160"
|
||||||
|
"linux64" "160"
|
||||||
"windows" "159"
|
"windows" "159"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,83 @@
|
|||||||
|
"Games"
|
||||||
|
{
|
||||||
|
"cstrike"
|
||||||
|
{
|
||||||
|
"Signatures"
|
||||||
|
{
|
||||||
|
"CGameServer::SpawnServer"
|
||||||
|
{
|
||||||
|
"library" "engine"
|
||||||
|
"linux" "@_ZN11CGameServer11SpawnServerEPKcS1_S1_"
|
||||||
|
"linux64" "@_ZN11CGameServer11SpawnServerEPKcS1_S1_"
|
||||||
|
}
|
||||||
|
"sv"
|
||||||
|
{
|
||||||
|
"library" "engine"
|
||||||
|
"linux" "@sv"
|
||||||
|
"linux64" "@sv"
|
||||||
|
}
|
||||||
|
"host_state"
|
||||||
|
{
|
||||||
|
"library" "engine"
|
||||||
|
"linux" "@host_state"
|
||||||
|
"linux64" "@host_state"
|
||||||
|
}
|
||||||
|
"g_ServerGameDLL"
|
||||||
|
{
|
||||||
|
"library" "server"
|
||||||
|
"linux" "@g_ServerGameDLL"
|
||||||
|
"linux64" "@g_ServerGameDLL"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"Offsets"
|
||||||
|
{
|
||||||
|
"CServerGameDLL::GetTickInterval"
|
||||||
|
{
|
||||||
|
"linux" "10"
|
||||||
|
"linux64" "10"
|
||||||
|
}
|
||||||
|
"CBaseServer::m_flTickInterval"
|
||||||
|
{
|
||||||
|
"linux" "0x154"
|
||||||
|
"linux64" "0x17c" // CBaseServer::GetTickInterval(): movss 0x17c(%rdi),%xmm0
|
||||||
|
}
|
||||||
|
"CCommonHostState::interval_per_tick"
|
||||||
|
{
|
||||||
|
"linux" "0x8"
|
||||||
|
"linux64" "0x10" // Host_AccumulateTime(): movss host_state+0x10,%xmm1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"Functions"
|
||||||
|
{
|
||||||
|
"CGameServer::SpawnServer"
|
||||||
|
{
|
||||||
|
"signature" "CGameServer::SpawnServer"
|
||||||
|
"callconv" "thiscall"
|
||||||
|
"return" "bool"
|
||||||
|
"this" "address"
|
||||||
|
"arguments"
|
||||||
|
{
|
||||||
|
"szMapName"
|
||||||
|
{
|
||||||
|
"type" "charptr"
|
||||||
|
}
|
||||||
|
"szMapFile"
|
||||||
|
{
|
||||||
|
"type" "charptr"
|
||||||
|
}
|
||||||
|
"startspot"
|
||||||
|
{
|
||||||
|
"type" "charptr"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"CServerGameDLL::GetTickInterval"
|
||||||
|
{
|
||||||
|
"offset" "CServerGameDLL::GetTickInterval"
|
||||||
|
"hooktype" "raw"
|
||||||
|
"return" "float"
|
||||||
|
"this" "ignore"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,153 @@
|
|||||||
|
#pragma newdecls required
|
||||||
|
#pragma semicolon 1
|
||||||
|
|
||||||
|
#include <dhooks>
|
||||||
|
|
||||||
|
#define MINIMUM_TICK_INTERVAL (0.001)
|
||||||
|
#define MAXIMUM_TICK_INTERVAL (0.1)
|
||||||
|
|
||||||
|
ConVar sm_interval_per_tick;
|
||||||
|
|
||||||
|
Address sv; // CBaseServer
|
||||||
|
Address host_state; // CCommonHostState
|
||||||
|
Address g_ServerGameDLL; // CServerGameDLL
|
||||||
|
|
||||||
|
int m_flTickInterval; // CBaseServer::m_flTickInterval
|
||||||
|
int interval_per_tick; // CCommonHostState::interval_per_tick
|
||||||
|
|
||||||
|
public Plugin myinfo =
|
||||||
|
{
|
||||||
|
name = "Runtime Tickrate Changer",
|
||||||
|
author = "Mikusch, ficool2",
|
||||||
|
description = "Allows changing the server's tickrate at runtime.",
|
||||||
|
version = "1.1.1",
|
||||||
|
url = "https://github.com/Mikusch/SM-TickrateChanger"
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnPluginStart()
|
||||||
|
{
|
||||||
|
GameData gamedata = new GameData("tickrate_changer");
|
||||||
|
if (!gamedata)
|
||||||
|
SetFailState("Failed to find gamedata/tickrate_changer.txt");
|
||||||
|
|
||||||
|
sv = GetMemSig(gamedata, "sv");
|
||||||
|
host_state = GetMemSig(gamedata, "host_state");
|
||||||
|
g_ServerGameDLL = GetMemSig(gamedata, "g_ServerGameDLL");
|
||||||
|
|
||||||
|
m_flTickInterval = GetOffset(gamedata, "CBaseServer::m_flTickInterval");
|
||||||
|
interval_per_tick = GetOffset(gamedata, "CCommonHostState::interval_per_tick");
|
||||||
|
|
||||||
|
char defInterval[32];
|
||||||
|
FloatToString(GetDefaultTickInterval(gamedata), defInterval, sizeof(defInterval));
|
||||||
|
|
||||||
|
DynamicDetour detour = CreateDynamicDetour(gamedata, "CGameServer::SpawnServer");
|
||||||
|
detour.Enable(Hook_Pre, CGameServer_SpawnServer);
|
||||||
|
|
||||||
|
DynamicHook hook = CreateDynamicHook(gamedata, "CServerGameDLL::GetTickInterval");
|
||||||
|
hook.HookRaw(Hook_Pre, g_ServerGameDLL, CServerGameDLL_GetTickInterval);
|
||||||
|
|
||||||
|
delete detour;
|
||||||
|
delete hook;
|
||||||
|
delete gamedata;
|
||||||
|
|
||||||
|
sm_interval_per_tick = CreateConVar("sm_interval_per_tick", defInterval, "Time between server ticks (applied on level change).", FCVAR_NOTIFY, true, MINIMUM_TICK_INTERVAL, true, MAXIMUM_TICK_INTERVAL);
|
||||||
|
RegServerCmd("sm_tickrate", OnTickRateChanged, "Sets the tickrate of the server (applied on level change).");
|
||||||
|
}
|
||||||
|
|
||||||
|
public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max)
|
||||||
|
{
|
||||||
|
RegPluginLibrary("tickrate_changer");
|
||||||
|
|
||||||
|
return APLRes_Success;
|
||||||
|
}
|
||||||
|
|
||||||
|
float GetCustomTickInterval()
|
||||||
|
{
|
||||||
|
int tickrate = GetCommandLineParamInt("-tickrate", 0);
|
||||||
|
if (tickrate)
|
||||||
|
sm_interval_per_tick.FloatValue = (1.0 / tickrate);
|
||||||
|
|
||||||
|
return sm_interval_per_tick.FloatValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
DynamicDetour CreateDynamicDetour(GameData gamedata, const char[] name)
|
||||||
|
{
|
||||||
|
DynamicDetour detour = DynamicDetour.FromConf(gamedata, name);
|
||||||
|
if (detour == null)
|
||||||
|
SetFailState("Failed to setup '%s' detour", name);
|
||||||
|
|
||||||
|
return detour;
|
||||||
|
}
|
||||||
|
|
||||||
|
DynamicHook CreateDynamicHook(GameData gamedata, const char[] name)
|
||||||
|
{
|
||||||
|
DynamicHook hook = DynamicHook.FromConf(gamedata, name);
|
||||||
|
if (hook == null)
|
||||||
|
SetFailState("Failed to setup '%s' hook", name);
|
||||||
|
|
||||||
|
return hook;
|
||||||
|
}
|
||||||
|
|
||||||
|
Address GetMemSig(GameData gamedata, const char[] name)
|
||||||
|
{
|
||||||
|
Address adr = gamedata.GetMemSig(name);
|
||||||
|
if (adr == Address_Null)
|
||||||
|
SetFailState("Failed to find '%s' signature", name);
|
||||||
|
|
||||||
|
return adr;
|
||||||
|
}
|
||||||
|
|
||||||
|
int GetOffset(GameData gamedata, const char[] name)
|
||||||
|
{
|
||||||
|
int offset = gamedata.GetOffset(name);
|
||||||
|
if (offset == -1)
|
||||||
|
SetFailState("Failed to find '%s' offset", name);
|
||||||
|
|
||||||
|
return offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
float GetDefaultTickInterval(GameData gamedata)
|
||||||
|
{
|
||||||
|
StartPrepSDKCall(SDKCall_Raw);
|
||||||
|
PrepSDKCall_SetFromConf(gamedata, SDKConf_Virtual, "CServerGameDLL::GetTickInterval");
|
||||||
|
PrepSDKCall_SetReturnInfo(SDKType_Float, SDKPass_ByValue);
|
||||||
|
Handle call = EndPrepSDKCall();
|
||||||
|
if (!call)
|
||||||
|
SetFailState("Failed to create SDKCall 'CServerGameDLL::GetTickInterval'");
|
||||||
|
|
||||||
|
float interval = SDKCall(call, g_ServerGameDLL);
|
||||||
|
delete call;
|
||||||
|
return interval;
|
||||||
|
}
|
||||||
|
|
||||||
|
static MRESReturn CServerGameDLL_GetTickInterval(DHookReturn ret)
|
||||||
|
{
|
||||||
|
float interval = GetCustomTickInterval();
|
||||||
|
StoreToAddress(sv + view_as<Address>(m_flTickInterval), interval, NumberType_Int32);
|
||||||
|
ret.Value = interval;
|
||||||
|
return MRES_Supercede;
|
||||||
|
}
|
||||||
|
|
||||||
|
static MRESReturn CGameServer_SpawnServer(DHookReturn ret, DHookParam params)
|
||||||
|
{
|
||||||
|
// This will make sure certain tick-related properties in CGameServer are set correctly
|
||||||
|
StoreToAddress(host_state + view_as<Address>(interval_per_tick), GetCustomTickInterval(), NumberType_Int32);
|
||||||
|
return MRES_Ignored;
|
||||||
|
}
|
||||||
|
|
||||||
|
static Action OnTickRateChanged(int args)
|
||||||
|
{
|
||||||
|
if (args < 1)
|
||||||
|
{
|
||||||
|
ReplyToCommand(0, "[SM] Usage: sm_tickrate <tickrate>");
|
||||||
|
return Plugin_Handled;
|
||||||
|
}
|
||||||
|
|
||||||
|
int tickrate = GetCmdArgInt(1);
|
||||||
|
if (tickrate)
|
||||||
|
sm_interval_per_tick.FloatValue = (1.0 / tickrate);
|
||||||
|
else
|
||||||
|
sm_interval_per_tick.RestoreDefault();
|
||||||
|
|
||||||
|
return Plugin_Handled;
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
"Games"
|
||||||
|
{
|
||||||
|
"cstrike"
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
Build Label: 6630498 # Uniquely identifies each build
|
||||||
|
Network PatchVersion: 6630498 # Determines client and server compatibility
|
||||||
|
Protocol version: 24 # High level network protocol version
|
||||||
|
Server version: 6630498
|
||||||
|
Server AppID: 232330
|
||||||
|
*/
|
||||||
|
"Offsets"
|
||||||
|
{
|
||||||
|
"CBaseCombatWeapon::OnPickedUp" // Called after pickup
|
||||||
|
{
|
||||||
|
"windows" "307"
|
||||||
|
"linux" "308"
|
||||||
|
"linux64" "308"
|
||||||
|
}
|
||||||
|
|
||||||
|
"CBaseCombatWeapon::GetSlot" // Gets the slot of the weapon
|
||||||
|
{
|
||||||
|
"windows" "327"
|
||||||
|
"linux" "328"
|
||||||
|
"linux64" "328"
|
||||||
|
}
|
||||||
|
|
||||||
|
"CBasePlayer::BumpWeapon" // Checks if pickup is possible
|
||||||
|
{
|
||||||
|
"windows" "405"
|
||||||
|
"linux" "406"
|
||||||
|
"linux64" "406"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,27 @@
|
|||||||
|
"Games"
|
||||||
|
{
|
||||||
|
"cstrike"
|
||||||
|
{
|
||||||
|
"Offsets"
|
||||||
|
{
|
||||||
|
"GetSlot"
|
||||||
|
{
|
||||||
|
"windows" "320"
|
||||||
|
"linux" "321"
|
||||||
|
"linux64" "321"
|
||||||
|
}
|
||||||
|
"BumpWeapon"
|
||||||
|
{
|
||||||
|
"windows" "397"
|
||||||
|
"linux" "398"
|
||||||
|
"linux64" "398"
|
||||||
|
}
|
||||||
|
"OnPickedUp"
|
||||||
|
{
|
||||||
|
"windows" "300"
|
||||||
|
"linux" "301"
|
||||||
|
"linux64" "301"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,142 @@
|
|||||||
|
"Games"
|
||||||
|
{
|
||||||
|
"#default"
|
||||||
|
{
|
||||||
|
"Keys"
|
||||||
|
{
|
||||||
|
"EngineInterface" "VEngineServer021"
|
||||||
|
}
|
||||||
|
"Signatures"
|
||||||
|
{
|
||||||
|
"CreateInterface"
|
||||||
|
{
|
||||||
|
"library" "engine"
|
||||||
|
"linux" "@CreateInterface"
|
||||||
|
"linux64" "@CreateInterface"
|
||||||
|
"windows" "@CreateInterface"
|
||||||
|
"windows64" "@CreateInterface"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"Offsets"
|
||||||
|
{
|
||||||
|
"GetPlayerNetInfo"
|
||||||
|
{
|
||||||
|
"linux" "20"
|
||||||
|
"linux64" "20"
|
||||||
|
"windows" "20"
|
||||||
|
"windows64" "20"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"Functions"
|
||||||
|
{
|
||||||
|
"CGameClient::FileReceived"
|
||||||
|
{
|
||||||
|
"signature" "CGameClient::FileReceived"
|
||||||
|
"callconv" "thiscall"
|
||||||
|
"return" "void"
|
||||||
|
"this" "address"
|
||||||
|
"arguments"
|
||||||
|
{
|
||||||
|
"fileName"
|
||||||
|
{
|
||||||
|
"type" "charptr"
|
||||||
|
}
|
||||||
|
"transferID"
|
||||||
|
{
|
||||||
|
"type" "int"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"CGameClient::FileDenied"
|
||||||
|
{
|
||||||
|
"signature" "CGameClient::FileDenied"
|
||||||
|
"callconv" "thiscall"
|
||||||
|
"return" "void"
|
||||||
|
"this" "address"
|
||||||
|
"arguments"
|
||||||
|
{
|
||||||
|
"fileName"
|
||||||
|
{
|
||||||
|
"type" "charptr"
|
||||||
|
}
|
||||||
|
"transferID"
|
||||||
|
{
|
||||||
|
"type" "int"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"cstrike"
|
||||||
|
{
|
||||||
|
"Keys"
|
||||||
|
{
|
||||||
|
"EngineInterface" "VEngineServer023"
|
||||||
|
}
|
||||||
|
"Signatures"
|
||||||
|
{
|
||||||
|
"CNetChan::SendFile"
|
||||||
|
{
|
||||||
|
"library" "engine"
|
||||||
|
"linux" "@_ZN8CNetChan8SendFileEPKcj"
|
||||||
|
"linux64" "@_ZN8CNetChan8SendFileEPKcj"
|
||||||
|
"windows" "\x55\x8B\xEC\x57\x8B\xF9\x8D\x8F\x94\x00\x00\x00\xE8\x2A\x2A\x2A\x2A\x85\xC0\x75\x2A\xB0\x01\x5F\x5D\xC2\x08\x00"
|
||||||
|
"windows64" "\x48\x89\x5C\x24\x08\x48\x89\x74\x24\x10\x57\x48\x83\xEC\x20\x48\x8B\xF9\x41\x8B\xF0\x48\x81\xC1\xC0\x00\x00\x00"
|
||||||
|
// "SendFile: %s (ID %i)\n"
|
||||||
|
}
|
||||||
|
"CNetChan::RequestFile"
|
||||||
|
{
|
||||||
|
"library" "engine"
|
||||||
|
"linux" "@_ZN8CNetChan11RequestFileEPKc"
|
||||||
|
"linux64" "@_ZN8CNetChan11RequestFileEPKc"
|
||||||
|
"windows" "\x55\x8B\xEC\x83\xEC\x14\x53\x8B\xD9\x56\x89\x5D\xF8"
|
||||||
|
"windows64" "\x40\x55\x56\x48\x83\xEC\x28\x44\x8B\x81\xB8\x04\x00\x00"
|
||||||
|
// "RequestFile: %s (ID %i)\n"
|
||||||
|
}
|
||||||
|
"CNetChan::IsFileInWaitingList"
|
||||||
|
{
|
||||||
|
"library" "engine"
|
||||||
|
"linux" "@_ZN8CNetChan19IsFileInWaitingListEPKc"
|
||||||
|
"linux64" "@_ZN8CNetChan19IsFileInWaitingListEPKc"
|
||||||
|
// "CreateFragmentsFromFile: '%s' doesn't e" -> CNetChan::CreateFragmentsFromFile
|
||||||
|
// Top Call -> CNetChan::IsFileInWaitingList
|
||||||
|
}
|
||||||
|
"CNetChan::CreateFragmentsFromFile"
|
||||||
|
{
|
||||||
|
"library" "engine"
|
||||||
|
"windows" "\x55\x8B\xEC\x83\xEC\x0C\x53\x8B\x5D\x08\x8B\xD1"
|
||||||
|
"windows64" "\x48\x89\x5C\x24\x08\x48\x89\x6C\x24\x18\x56\x57\x41\x54\x41\x56\x41\x57\x48\x83\xEC\x20\x4D\x63\xF8"
|
||||||
|
// "CreateFragmentsFromFile: '%s' doesn't e"
|
||||||
|
}
|
||||||
|
"CGameClient::FileReceived"
|
||||||
|
{
|
||||||
|
"library" "engine"
|
||||||
|
"linux" "\x55\x31\xC0\x89\xE5\x53\x8B\x55\x08\x8B\x5D\x0C\x8B\x4D\x10\x39\x8C\xC2\xA4\x00\x00\x00"
|
||||||
|
"linux64" "\x48\x8D\x87\xC0\x00\x00\x00\x48\x8D\x8F\xE0\x00\x00\x00"
|
||||||
|
// cant use base words, need full sig for linux.
|
||||||
|
//"@_ZN11CGameClient12FileReceivedEPKcj"
|
||||||
|
"windows" "\x55\x8B\xEC\x56\x8B\x75\x0C\x33\xD2\x57\x8B\xF9"
|
||||||
|
"windows64" "\x4C\x8B\xD2\x48\x8D\x81\xB8\x00\x00\x00"
|
||||||
|
// "CGameClient::FileReceived: %s not wanted.\n"
|
||||||
|
}
|
||||||
|
"CGameClient::FileDenied"
|
||||||
|
{
|
||||||
|
"library" "engine"
|
||||||
|
"linux" "@_ZN11CGameClient10FileDeniedEPKcj"
|
||||||
|
"linux64" "@_ZN11CGameClient10FileDeniedEPKcj"
|
||||||
|
"windows" "\x55\x8B\xEC\x8B\x01\xFF\x50\x44\x50\xFF\x75\x08\x68"
|
||||||
|
"windows64" "\x40\x53\x48\x83\xEC\x20\x48\x8B\x01\x48\x8B\xDA\xFF\x90\x88\x00\x00\x00\x48\x8B\xD3\x48\x8D\x0D\x14\x56\x26\x00"
|
||||||
|
// "Downloading file '%s' from client %s failed.\n"
|
||||||
|
}
|
||||||
|
"CBaseClient::GetNetChannel"
|
||||||
|
{
|
||||||
|
"library" "engine"
|
||||||
|
"linux" "@_ZN11CBaseClient13GetNetChannelEv"
|
||||||
|
"linux64" "@_ZN11CBaseClient13GetNetChannelEv"
|
||||||
|
"windows" "\x8B\x81\xC0\x00\x00\x00"
|
||||||
|
"windows64" "\x48\x8B\x81\xD8\x00\x00\x00\xC3"
|
||||||
|
// Good Luck
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,714 @@
|
|||||||
|
#include <sourcemod>
|
||||||
|
#include <sdktools>
|
||||||
|
#include <dhooks>
|
||||||
|
|
||||||
|
#pragma semicolon 1
|
||||||
|
#pragma newdecls required
|
||||||
|
|
||||||
|
#define PLUGIN_VERSION "manual"
|
||||||
|
|
||||||
|
#define TIMEOUT_PERIOD 90 // How long until we consider a requested file to be timed out
|
||||||
|
|
||||||
|
enum struct FileEnum
|
||||||
|
{
|
||||||
|
int Client;
|
||||||
|
char Filename[PLATFORM_MAX_PATH];
|
||||||
|
Handle Plugin;
|
||||||
|
Function Func;
|
||||||
|
any Data;
|
||||||
|
|
||||||
|
int Id;
|
||||||
|
int Timeout;
|
||||||
|
}
|
||||||
|
|
||||||
|
Handle SDKGetPlayerNetInfo;
|
||||||
|
Handle SDKSendFile;
|
||||||
|
Handle SDKRequestFile;
|
||||||
|
Handle SDKIsFileInWaitingList;
|
||||||
|
Handle SDKCreateFragmentsFromFile;
|
||||||
|
Handle SDKGetNetChannel;
|
||||||
|
Address EngineAddress;
|
||||||
|
ConVar CvarMaxFileSize;
|
||||||
|
|
||||||
|
// Sending
|
||||||
|
int TransferID;
|
||||||
|
ArrayList SendListing;
|
||||||
|
Handle SendingTimer[MAXPLAYERS+1];
|
||||||
|
char CurrentlySending[MAXPLAYERS+1][PLATFORM_MAX_PATH];
|
||||||
|
|
||||||
|
// Requesting
|
||||||
|
ArrayList RequestListing;
|
||||||
|
Handle RequestingTimer[MAXPLAYERS+1];
|
||||||
|
int CurrentlyRequesting[MAXPLAYERS+1] = {-1, ...};
|
||||||
|
int FailRequestingAt[MAXPLAYERS+1];
|
||||||
|
|
||||||
|
// CNetChan pointers are handled as Address (int64 on SourceMod 1.13 x64 builds).
|
||||||
|
// SDKType_Address return values are written into the Address variable passed right after
|
||||||
|
// the |this| pointer (or as the first argument for static calls).
|
||||||
|
Address GetNetChan(int client)
|
||||||
|
{
|
||||||
|
Address chan = Address_Null;
|
||||||
|
SDKCall(SDKGetPlayerNetInfo, EngineAddress, chan, client);
|
||||||
|
return chan;
|
||||||
|
}
|
||||||
|
|
||||||
|
Address GetNetChannelOfClient(Address baseClient)
|
||||||
|
{
|
||||||
|
Address chan = Address_Null;
|
||||||
|
SDKCall(SDKGetNetChannel, baseClient, chan);
|
||||||
|
return chan;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool NetChan_SendFile(Address chan, const char[] filename)
|
||||||
|
{
|
||||||
|
return SDKCall(SDKSendFile, chan, filename, TransferID++);
|
||||||
|
}
|
||||||
|
|
||||||
|
int NetChan_RequestFile(Address chan, const char[] filename)
|
||||||
|
{
|
||||||
|
int id = SDKCall(SDKRequestFile, chan, filename);
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool NetChan_IsFileInWaitingList(Address chan, const char[] filename)
|
||||||
|
{
|
||||||
|
bool result;
|
||||||
|
|
||||||
|
if(SDKIsFileInWaitingList)
|
||||||
|
{
|
||||||
|
result = SDKCall(SDKIsFileInWaitingList, chan, filename);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int value = CvarMaxFileSize.IntValue;
|
||||||
|
CvarMaxFileSize.IntValue = -1;
|
||||||
|
result = SDKCall(SDKCreateFragmentsFromFile, chan, filename, 0, 0);
|
||||||
|
CvarMaxFileSize.IntValue = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Plugin myinfo =
|
||||||
|
{
|
||||||
|
name = "File Network",
|
||||||
|
author = "Batfoxkid, Artvin",
|
||||||
|
description = "But what if, no loading screen",
|
||||||
|
version = PLUGIN_VERSION,
|
||||||
|
url = "github.com/Batfoxkid/File-Network"
|
||||||
|
}
|
||||||
|
|
||||||
|
public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max)
|
||||||
|
{
|
||||||
|
CreateNative("FileNet_SendFile", Native_SendFile);
|
||||||
|
CreateNative("FileNet_RequestFile", Native_RequestFile);
|
||||||
|
CreateNative("FileNet_IsFileInWaitingList", Native_IsFileInWaitingList);
|
||||||
|
CreateNative("FileNet_GetNetChanPtr", Native_GetNetChanPtr);
|
||||||
|
|
||||||
|
RegPluginLibrary("filenetwork");
|
||||||
|
return APLRes_Success;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnPluginStart()
|
||||||
|
{
|
||||||
|
GameData gamedata = new GameData("filenetwork");
|
||||||
|
|
||||||
|
char identifier[64];
|
||||||
|
if(!gamedata.GetKeyValue("EngineInterface", identifier, sizeof(identifier)))
|
||||||
|
SetFailState("[Gamedata] Could not find EngineInterface");
|
||||||
|
|
||||||
|
StartPrepSDKCall(SDKCall_Static);
|
||||||
|
PrepSDKCall_SetFromConf(gamedata, SDKConf_Signature, "CreateInterface");
|
||||||
|
PrepSDKCall_AddParameter(SDKType_String, SDKPass_Pointer);
|
||||||
|
PrepSDKCall_AddParameter(SDKType_PlainOldData, SDKPass_Pointer, VDECODE_FLAG_ALLOWNULL);
|
||||||
|
PrepSDKCall_SetReturnInfo(SDKType_Address, SDKPass_Plain);
|
||||||
|
Handle sdkcall = EndPrepSDKCall();
|
||||||
|
if(!sdkcall)
|
||||||
|
SetFailState("[Gamedata] Could not find CreateInterface");
|
||||||
|
|
||||||
|
EngineAddress = Address_Null;
|
||||||
|
SDKCall(sdkcall, EngineAddress, identifier, 0);
|
||||||
|
if(EngineAddress == Address_Null)
|
||||||
|
SetFailState("[Gamedata] EngineInterface is incorrect for mod");
|
||||||
|
|
||||||
|
delete sdkcall;
|
||||||
|
|
||||||
|
bool failed;
|
||||||
|
|
||||||
|
StartPrepSDKCall(SDKCall_Raw);
|
||||||
|
PrepSDKCall_SetFromConf(gamedata, SDKConf_Virtual, "GetPlayerNetInfo");
|
||||||
|
PrepSDKCall_AddParameter(SDKType_PlainOldData, SDKPass_Plain);
|
||||||
|
PrepSDKCall_SetReturnInfo(SDKType_Address, SDKPass_Plain);
|
||||||
|
SDKGetPlayerNetInfo = EndPrepSDKCall();
|
||||||
|
if(!SDKGetPlayerNetInfo)
|
||||||
|
{
|
||||||
|
LogError("[Gamedata] Could not find GetPlayerNetInfo");
|
||||||
|
failed = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
StartPrepSDKCall(SDKCall_Raw);
|
||||||
|
PrepSDKCall_SetFromConf(gamedata, SDKConf_Signature, "CNetChan::SendFile");
|
||||||
|
PrepSDKCall_AddParameter(SDKType_String, SDKPass_Pointer);
|
||||||
|
PrepSDKCall_AddParameter(SDKType_PlainOldData, SDKPass_Plain);
|
||||||
|
PrepSDKCall_SetReturnInfo(SDKType_Bool, SDKPass_ByValue);
|
||||||
|
SDKSendFile = EndPrepSDKCall();
|
||||||
|
if(!SDKSendFile)
|
||||||
|
{
|
||||||
|
LogError("[Gamedata] Could not find CNetChan::SendFile");
|
||||||
|
failed = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
StartPrepSDKCall(SDKCall_Raw);
|
||||||
|
PrepSDKCall_SetFromConf(gamedata, SDKConf_Signature, "CNetChan::RequestFile");
|
||||||
|
PrepSDKCall_AddParameter(SDKType_String, SDKPass_Pointer);
|
||||||
|
PrepSDKCall_SetReturnInfo(SDKType_PlainOldData, SDKPass_ByValue);
|
||||||
|
SDKRequestFile = EndPrepSDKCall();
|
||||||
|
if(!SDKRequestFile)
|
||||||
|
{
|
||||||
|
LogError("[Gamedata] Could not find CNetChan::RequestFile");
|
||||||
|
failed = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
StartPrepSDKCall(SDKCall_Raw);
|
||||||
|
PrepSDKCall_SetFromConf(gamedata, SDKConf_Signature, "CNetChan::IsFileInWaitingList");
|
||||||
|
PrepSDKCall_AddParameter(SDKType_String, SDKPass_Pointer);
|
||||||
|
PrepSDKCall_SetReturnInfo(SDKType_Bool, SDKPass_ByValue);
|
||||||
|
SDKIsFileInWaitingList = EndPrepSDKCall();
|
||||||
|
if(!SDKIsFileInWaitingList)
|
||||||
|
{
|
||||||
|
CvarMaxFileSize = FindConVar("net_maxfilesize");
|
||||||
|
if(!CvarMaxFileSize)
|
||||||
|
{
|
||||||
|
LogError("[Game] Could not find net_maxfilesize");
|
||||||
|
failed = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
StartPrepSDKCall(SDKCall_Raw);
|
||||||
|
PrepSDKCall_SetFromConf(gamedata, SDKConf_Signature, "CNetChan::CreateFragmentsFromFile");
|
||||||
|
PrepSDKCall_AddParameter(SDKType_String, SDKPass_Pointer);
|
||||||
|
PrepSDKCall_AddParameter(SDKType_PlainOldData, SDKPass_Plain);
|
||||||
|
PrepSDKCall_AddParameter(SDKType_PlainOldData, SDKPass_Plain);
|
||||||
|
PrepSDKCall_SetReturnInfo(SDKType_Bool, SDKPass_ByValue);
|
||||||
|
SDKCreateFragmentsFromFile = EndPrepSDKCall();
|
||||||
|
if(!SDKCreateFragmentsFromFile)
|
||||||
|
{
|
||||||
|
LogError("[Gamedata] Could not find CNetChan::IsFileInWaitingList or CNetChan::CreateFragmentsFromFile");
|
||||||
|
failed = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
StartPrepSDKCall(SDKCall_Raw);
|
||||||
|
PrepSDKCall_SetFromConf(gamedata, SDKConf_Signature, "CBaseClient::GetNetChannel");
|
||||||
|
PrepSDKCall_SetReturnInfo(SDKType_Address, SDKPass_Plain);
|
||||||
|
SDKGetNetChannel = EndPrepSDKCall();
|
||||||
|
if(!SDKGetNetChannel)
|
||||||
|
{
|
||||||
|
LogError("[Gamedata] Could not find CBaseClient::GetNetChannel");
|
||||||
|
failed = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
DynamicDetour detour = DynamicDetour.FromConf(gamedata, "CGameClient::FileReceived");
|
||||||
|
if(detour)
|
||||||
|
{
|
||||||
|
if(!detour.Enable(Hook_Post, OnFileReceived))
|
||||||
|
{
|
||||||
|
LogError("[Gamedata] Failed to enable detour: CGameClient::FileReceived");
|
||||||
|
failed = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
delete detour;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LogError("[Gamedata] Could not find CGameClient::FileReceived");
|
||||||
|
failed = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
detour = DynamicDetour.FromConf(gamedata, "CGameClient::FileDenied");
|
||||||
|
if(detour)
|
||||||
|
{
|
||||||
|
if(!detour.Enable(Hook_Post, OnFileDenied))
|
||||||
|
{
|
||||||
|
LogError("[Gamedata] Failed to enable detour: CGameClient::FileDenied");
|
||||||
|
failed = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
delete detour;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LogError("[Gamedata] Could not find CGameClient::FileDenied");
|
||||||
|
failed = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(failed)
|
||||||
|
ThrowError("Gamedata failed, see error logs");
|
||||||
|
|
||||||
|
SendListing = new ArrayList(sizeof(FileEnum));
|
||||||
|
RequestListing = new ArrayList(sizeof(FileEnum));
|
||||||
|
RegAdminCmd("sm_filenet_send", Command_TestSend, ADMFLAG_ROOT, "Test using send file");
|
||||||
|
RegAdminCmd("sm_filenet_request", Command_TestRequest, ADMFLAG_ROOT, "Test using request file");
|
||||||
|
}
|
||||||
|
|
||||||
|
public Action Command_TestSend(int client, int args)
|
||||||
|
{
|
||||||
|
char buffer[PLATFORM_MAX_PATH];
|
||||||
|
GetCmdArgString(buffer, sizeof(buffer));
|
||||||
|
ReplaceString(buffer, sizeof(buffer), "\"", "");
|
||||||
|
|
||||||
|
Address chan = GetNetChan(client);
|
||||||
|
if(chan == Address_Null)
|
||||||
|
{
|
||||||
|
ReplyToCommand(client, "Address invalid");
|
||||||
|
}
|
||||||
|
else if(NetChan_IsFileInWaitingList(chan, buffer))
|
||||||
|
{
|
||||||
|
ReplyToCommand(client, "File already in waiting list");
|
||||||
|
}
|
||||||
|
else if(NetChan_SendFile(chan, buffer))
|
||||||
|
{
|
||||||
|
ReplyToCommand(client, "Sent file to client");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ReplyToCommand(client, "File failed to send");
|
||||||
|
}
|
||||||
|
return Plugin_Handled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Action Command_TestRequest(int client, int args)
|
||||||
|
{
|
||||||
|
char buffer[PLATFORM_MAX_PATH];
|
||||||
|
GetCmdArgString(buffer, sizeof(buffer));
|
||||||
|
ReplaceString(buffer, sizeof(buffer), "\"", "");
|
||||||
|
|
||||||
|
Address chan = GetNetChan(client);
|
||||||
|
if(chan == Address_Null)
|
||||||
|
{
|
||||||
|
ReplyToCommand(client, "Address invalid");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
NetChan_RequestFile(chan, buffer);
|
||||||
|
ReplyToCommand(client, "Requested file from client");
|
||||||
|
}
|
||||||
|
return Plugin_Handled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnClientDisconnect_Post(int client)
|
||||||
|
{
|
||||||
|
static FileEnum info;
|
||||||
|
|
||||||
|
int match = -1;
|
||||||
|
while((match = SendListing.FindValue(client, FileEnum::Client)) != -1)
|
||||||
|
{
|
||||||
|
SendListing.GetArray(match, info);
|
||||||
|
SendListing.Erase(match);
|
||||||
|
|
||||||
|
CallSentFileFinish(info, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
match = -1;
|
||||||
|
while((match = RequestListing.FindValue(client, FileEnum::Client)) != -1)
|
||||||
|
{
|
||||||
|
RequestListing.GetArray(match, info);
|
||||||
|
RequestListing.Erase(match);
|
||||||
|
|
||||||
|
CallRequestFileFinish(info, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
delete SendingTimer[client];
|
||||||
|
CurrentlySending[client][0] = 0;
|
||||||
|
|
||||||
|
delete RequestingTimer[client];
|
||||||
|
CurrentlyRequesting[client] = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnNotifyPluginUnloaded(Handle plugin)
|
||||||
|
{
|
||||||
|
int match = -1;
|
||||||
|
while((match = SendListing.FindValue(plugin, FileEnum::Plugin)) != -1)
|
||||||
|
{
|
||||||
|
SendListing.Erase(match);
|
||||||
|
}
|
||||||
|
|
||||||
|
match = -1;
|
||||||
|
while((match = RequestListing.FindValue(plugin, FileEnum::Plugin)) != -1)
|
||||||
|
{
|
||||||
|
RequestListing.Erase(match);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Requesting Files
|
||||||
|
*/
|
||||||
|
|
||||||
|
public MRESReturn OnFileReceived(Address address, DHookParam param)
|
||||||
|
{
|
||||||
|
int id = param.Get(2);
|
||||||
|
Address chan = GetNetChannelOfClient(address);
|
||||||
|
|
||||||
|
int length = RequestListing.Length;
|
||||||
|
for(int i; i < length; i++)
|
||||||
|
{
|
||||||
|
static FileEnum info;
|
||||||
|
RequestListing.GetArray(i, info);
|
||||||
|
if(info.Id == id && chan == GetNetChan(info.Client))
|
||||||
|
{
|
||||||
|
if(CurrentlyRequesting[info.Client] == id)
|
||||||
|
CurrentlyRequesting[info.Client] = -1;
|
||||||
|
|
||||||
|
RequestListing.Erase(i);
|
||||||
|
CallRequestFileFinish(info, true);
|
||||||
|
|
||||||
|
delete RequestingTimer[info.Client];
|
||||||
|
SendNextRequest(info.Client);
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return MRES_Ignored;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MRESReturn OnFileDenied(Address address, DHookParam param)
|
||||||
|
{
|
||||||
|
int id = param.Get(2);
|
||||||
|
Address chan = GetNetChannelOfClient(address);
|
||||||
|
|
||||||
|
int length = RequestListing.Length;
|
||||||
|
for(int i; i < length; i++)
|
||||||
|
{
|
||||||
|
static FileEnum info;
|
||||||
|
RequestListing.GetArray(i, info);
|
||||||
|
if(info.Id == id && chan == GetNetChan(info.Client))
|
||||||
|
{
|
||||||
|
if(CurrentlyRequesting[info.Client] == id)
|
||||||
|
CurrentlyRequesting[info.Client] = -1;
|
||||||
|
|
||||||
|
RequestListing.Erase(i);
|
||||||
|
CallRequestFileFinish(info, false);
|
||||||
|
|
||||||
|
delete RequestingTimer[info.Client];
|
||||||
|
SendNextRequest(info.Client);
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return MRES_Ignored;
|
||||||
|
}
|
||||||
|
|
||||||
|
void StartRequestingClient(int client)
|
||||||
|
{
|
||||||
|
// Small delay between requesting files, Linux Server issue
|
||||||
|
if(!RequestingTimer[client])
|
||||||
|
RequestingTimer[client] = CreateTimer(1.5, Timer_RequestingClient, client, TIMER_REPEAT);
|
||||||
|
}
|
||||||
|
|
||||||
|
void SendNextRequest(int client)
|
||||||
|
{
|
||||||
|
if(CurrentlyRequesting[client] == -1)
|
||||||
|
{
|
||||||
|
Address chan = GetNetChan(client);
|
||||||
|
if(chan != Address_Null)
|
||||||
|
{
|
||||||
|
int length = RequestListing.Length;
|
||||||
|
for(int i; i < length; i++)
|
||||||
|
{
|
||||||
|
static FileEnum info;
|
||||||
|
RequestListing.GetArray(i, info);
|
||||||
|
if(info.Client == client)
|
||||||
|
{
|
||||||
|
info.Id = NetChan_RequestFile(chan, info.Filename);
|
||||||
|
RequestListing.SetArray(i, info);
|
||||||
|
|
||||||
|
CurrentlyRequesting[client] = info.Id;
|
||||||
|
FailRequestingAt[client] = GetTime() + info.Timeout;
|
||||||
|
StartRequestingClient(client);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
StartRequestingClient(client);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Action Timer_RequestingClient(Handle timer, int client)
|
||||||
|
{
|
||||||
|
if(CurrentlyRequesting[client] == -1)
|
||||||
|
{
|
||||||
|
SendNextRequest(client);
|
||||||
|
return Plugin_Continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Client still giving this file
|
||||||
|
if(FailRequestingAt[client] > GetTime())
|
||||||
|
return Plugin_Continue;
|
||||||
|
|
||||||
|
/*
|
||||||
|
We timed out!
|
||||||
|
|
||||||
|
1. This can be a case of the client getting stuck from too many missing file requests.
|
||||||
|
2. A Linux server may not get the notice that the file was missing on the client.
|
||||||
|
|
||||||
|
Request a different file that exists to fix issue 1,
|
||||||
|
fail and return the callback to fix issue 2.
|
||||||
|
*/
|
||||||
|
|
||||||
|
Address chan = GetNetChan(client);
|
||||||
|
if(chan == Address_Null)
|
||||||
|
return Plugin_Continue;
|
||||||
|
|
||||||
|
static FileEnum info;
|
||||||
|
int length = RequestListing.Length;
|
||||||
|
for(int i; i < length; i++)
|
||||||
|
{
|
||||||
|
RequestListing.GetArray(i, info);
|
||||||
|
if(info.Id == CurrentlyRequesting[client] && info.Client == client)
|
||||||
|
{
|
||||||
|
CurrentlyRequesting[info.Client] = -1;
|
||||||
|
|
||||||
|
RequestListing.Erase(i);
|
||||||
|
CallRequestFileFinish(info, false);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(info.Plugin == null)
|
||||||
|
{
|
||||||
|
// We already tried unstucking with this method, don't try it again
|
||||||
|
SendNextRequest(client);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DeleteFile("download/scripts/cheatcodes.txt");
|
||||||
|
|
||||||
|
info.Plugin = null;
|
||||||
|
info.Client = client;
|
||||||
|
strcopy(info.Filename, sizeof(info.Filename), "scripts/cheatcodes.txt");
|
||||||
|
info.Func = INVALID_FUNCTION;
|
||||||
|
info.Id = NetChan_RequestFile(chan, info.Filename);
|
||||||
|
info.Timeout = 30;
|
||||||
|
RequestListing.PushArray(info);
|
||||||
|
|
||||||
|
CurrentlyRequesting[client] = info.Id;
|
||||||
|
FailRequestingAt[client] = GetTime() + info.Timeout;
|
||||||
|
}
|
||||||
|
return Plugin_Continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void CallRequestFileFinish(const FileEnum info, bool success)
|
||||||
|
{
|
||||||
|
if(info.Func && info.Func != INVALID_FUNCTION)
|
||||||
|
{
|
||||||
|
Call_StartFunction(info.Plugin, info.Func);
|
||||||
|
Call_PushCell(info.Client);
|
||||||
|
Call_PushString(info.Filename);
|
||||||
|
Call_PushCell(info.Id);
|
||||||
|
Call_PushCell(success);
|
||||||
|
Call_PushCell(info.Data);
|
||||||
|
Call_Finish();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Sending Files
|
||||||
|
*/
|
||||||
|
|
||||||
|
void StartSendingClient(int client)
|
||||||
|
{
|
||||||
|
if(!SendingTimer[client])
|
||||||
|
{
|
||||||
|
SendingTimer[client] = CreateTimer(0.1, Timer_SendingClient, client, TIMER_REPEAT);
|
||||||
|
TriggerTimer(SendingTimer[client]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Action Timer_SendingClient(Handle timer, int client)
|
||||||
|
{
|
||||||
|
Address chan = GetNetChan(client);
|
||||||
|
if(chan == Address_Null)
|
||||||
|
return Plugin_Continue;
|
||||||
|
|
||||||
|
if(CurrentlySending[client][0])
|
||||||
|
{
|
||||||
|
// Client still downloading this file
|
||||||
|
if(NetChan_IsFileInWaitingList(chan, CurrentlySending[client]))
|
||||||
|
{
|
||||||
|
return Plugin_Continue;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// We finished this file
|
||||||
|
int length = SendListing.Length;
|
||||||
|
for(int i; i < length; i++)
|
||||||
|
{
|
||||||
|
static FileEnum info;
|
||||||
|
SendListing.GetArray(i, info);
|
||||||
|
if(info.Client == client && StrEqual(info.Filename, CurrentlySending[client], false))
|
||||||
|
{
|
||||||
|
SendListing.Erase(i);
|
||||||
|
CallSentFileFinish(info, true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
CurrentlySending[client][0] = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int length = SendListing.Length;
|
||||||
|
for(int i; i < length; i++)
|
||||||
|
{
|
||||||
|
static FileEnum info;
|
||||||
|
SendListing.GetArray(i, info);
|
||||||
|
if(info.Client == client)
|
||||||
|
{
|
||||||
|
if(NetChan_SendFile(chan, info.Filename))
|
||||||
|
{
|
||||||
|
strcopy(CurrentlySending[client], sizeof(CurrentlySending[]), info.Filename);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Failed reasons tend to be bad names, bad sizes, etc.
|
||||||
|
SendListing.Erase(i);
|
||||||
|
CallSentFileFinish(info, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Plugin_Continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// No more files to send
|
||||||
|
SendingTimer[client] = null;
|
||||||
|
return Plugin_Stop;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void CallSentFileFinish(const FileEnum info, bool success)
|
||||||
|
{
|
||||||
|
if(info.Func && info.Func != INVALID_FUNCTION)
|
||||||
|
{
|
||||||
|
Call_StartFunction(info.Plugin, info.Func);
|
||||||
|
Call_PushCell(info.Client);
|
||||||
|
Call_PushString(info.Filename);
|
||||||
|
Call_PushCell(success);
|
||||||
|
Call_PushCell(info.Data);
|
||||||
|
Call_Finish();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Natives
|
||||||
|
*/
|
||||||
|
|
||||||
|
void StartNative()
|
||||||
|
{
|
||||||
|
if(!SendListing)
|
||||||
|
ThrowNativeError(SP_ERROR_NATIVE, "Please wait until OnAllPluginsLoaded");
|
||||||
|
}
|
||||||
|
|
||||||
|
int GetNativeClient(int param)
|
||||||
|
{
|
||||||
|
int client = GetNativeCell(param);
|
||||||
|
if(client < 1 || client > MaxClients)
|
||||||
|
ThrowNativeError(SP_ERROR_NATIVE, "Invalid client index %d", client);
|
||||||
|
|
||||||
|
if(!IsClientInGame(client))
|
||||||
|
ThrowNativeError(SP_ERROR_NATIVE, "Client %d is not in-game", client);
|
||||||
|
|
||||||
|
if(IsFakeClient(client))
|
||||||
|
ThrowNativeError(SP_ERROR_NATIVE, "Client %d is a bot player", client);
|
||||||
|
|
||||||
|
return client;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool FileExistsForClient(int client, const char[] filename)
|
||||||
|
{
|
||||||
|
int length = SendListing.Length;
|
||||||
|
for(int i; i < length; i++)
|
||||||
|
{
|
||||||
|
static FileEnum info;
|
||||||
|
SendListing.GetArray(i, info);
|
||||||
|
if(info.Client == client)
|
||||||
|
{
|
||||||
|
if(StrEqual(info.Filename, filename, false))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public any Native_SendFile(Handle plugin, int params)
|
||||||
|
{
|
||||||
|
StartNative();
|
||||||
|
|
||||||
|
FileEnum info;
|
||||||
|
info.Client = GetNativeClient(1);
|
||||||
|
GetNativeString(2, info.Filename, sizeof(info.Filename));
|
||||||
|
|
||||||
|
info.Plugin = plugin;
|
||||||
|
info.Func = GetNativeFunction(3);
|
||||||
|
info.Data = GetNativeCell(4);
|
||||||
|
|
||||||
|
SendListing.PushArray(info);
|
||||||
|
|
||||||
|
StartSendingClient(info.Client);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public any Native_RequestFile(Handle plugin, int params)
|
||||||
|
{
|
||||||
|
StartNative();
|
||||||
|
|
||||||
|
FileEnum info;
|
||||||
|
info.Client = GetNativeClient(1);
|
||||||
|
GetNativeString(2, info.Filename, sizeof(info.Filename));
|
||||||
|
|
||||||
|
info.Plugin = plugin;
|
||||||
|
info.Func = GetNativeFunction(3);
|
||||||
|
info.Data = GetNativeCell(4);
|
||||||
|
info.Timeout = params < 5 ? TIMEOUT_PERIOD : GetNativeCell(5);
|
||||||
|
|
||||||
|
RequestListing.PushArray(info);
|
||||||
|
|
||||||
|
StartRequestingClient(info.Client);
|
||||||
|
return CurrentlyRequesting[info.Client];
|
||||||
|
}
|
||||||
|
|
||||||
|
public any Native_IsFileInWaitingList(Handle plugin, int params)
|
||||||
|
{
|
||||||
|
StartNative();
|
||||||
|
|
||||||
|
int client = GetNativeCell(1);
|
||||||
|
|
||||||
|
if(SendingTimer[client]) // Just to double check with CNetChan::IsFileInWaitingList
|
||||||
|
TriggerTimer(SendingTimer[client], true);
|
||||||
|
|
||||||
|
int length;
|
||||||
|
GetNativeStringLength(2, length);
|
||||||
|
char[] filename = new char[++length];
|
||||||
|
GetNativeString(2, filename, length);
|
||||||
|
|
||||||
|
return FileExistsForClient(client, filename);
|
||||||
|
}
|
||||||
|
|
||||||
|
public any Native_GetNetChanPtr(Handle plugin, int params)
|
||||||
|
{
|
||||||
|
StartNative();
|
||||||
|
|
||||||
|
int client = GetNativeCell(1);
|
||||||
|
|
||||||
|
Address chan = GetNetChan(client);
|
||||||
|
|
||||||
|
// Address is 64-bit, which doesn't fit in a native's return value.
|
||||||
|
// Write it into the caller's Address variable instead (2 cells, little endian).
|
||||||
|
int parts[2];
|
||||||
|
parts[0] = view_as<int>(chan & view_as<Address>(0xFFFFFFFF));
|
||||||
|
parts[1] = view_as<int>(chan >> 32);
|
||||||
|
SetNativeArray(2, parts, 2);
|
||||||
|
|
||||||
|
return chan != Address_Null;
|
||||||
|
}
|
||||||
@@ -0,0 +1,134 @@
|
|||||||
|
#if defined _filenetwork_included
|
||||||
|
#endinput
|
||||||
|
#endif
|
||||||
|
#define _filenetwork_included
|
||||||
|
|
||||||
|
#pragma semicolon 1
|
||||||
|
#pragma newdecls required
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when file sending is finished
|
||||||
|
*/
|
||||||
|
typeset FileNet_SendFileResult
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @param client Client index
|
||||||
|
* @param file Filepath of sent file
|
||||||
|
* @param success If the file was sent
|
||||||
|
* @param data Value that was passed
|
||||||
|
*
|
||||||
|
* @noreturn
|
||||||
|
*/
|
||||||
|
function void(int client, const char[] file, bool success, any data);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param client Client index
|
||||||
|
* @param file Filepath of sent file
|
||||||
|
* @param success If the file was sent
|
||||||
|
*
|
||||||
|
* @noreturn
|
||||||
|
*/
|
||||||
|
function void(int client, const char[] file, bool success);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when file request is finished
|
||||||
|
*/
|
||||||
|
typeset FileNet_RequestFileResult
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @note May be written to the downloads folder
|
||||||
|
*
|
||||||
|
* @param client Client index
|
||||||
|
* @param file Filepath of requested file
|
||||||
|
* @param id Request ID
|
||||||
|
* @param success If the file was sent
|
||||||
|
* @param data Value that was passed
|
||||||
|
*
|
||||||
|
* @noreturn
|
||||||
|
*/
|
||||||
|
function void(int client, const char[] file, int id, bool success, any data);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @note May be written to the downloads folder
|
||||||
|
*
|
||||||
|
* @param client Client index
|
||||||
|
* @param file Filepath of requested file
|
||||||
|
* @param id Request ID
|
||||||
|
* @param success If the file was sent
|
||||||
|
*
|
||||||
|
* @noreturn
|
||||||
|
*/
|
||||||
|
function void(int client, const char[] file, int id, bool success);
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* If a file is currently in queue for that client
|
||||||
|
*
|
||||||
|
* @param client Client index
|
||||||
|
* @param file Filepath of sent file
|
||||||
|
*
|
||||||
|
* @return True if the file in is queue, false otherwise
|
||||||
|
*/
|
||||||
|
native bool FileNet_IsFileInWaitingList(int client, const char[] file);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a file in a queue to be sent over to the client
|
||||||
|
*
|
||||||
|
* @param client Client index
|
||||||
|
* @param file Filepath of sent file
|
||||||
|
* @param callback Optional callback when file is done
|
||||||
|
* @param data Optional value to pass to the callback function
|
||||||
|
*
|
||||||
|
* @error Invalid client index, client is not in game, or a fake client
|
||||||
|
*
|
||||||
|
* @return True if the file is now queued to be sent, false otherwise
|
||||||
|
*/
|
||||||
|
native bool FileNet_SendFile(int client, const char[] file, FileNet_SendFileResult callback = INVALID_FUNCTION, any data = 0);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Requests a file to be sent from the client
|
||||||
|
*
|
||||||
|
* @param client Client index
|
||||||
|
* @param file Filepath of requested file
|
||||||
|
* @param callback Optional callback when file is done
|
||||||
|
* @param data Optional value to pass to the callback function
|
||||||
|
* @param timeout Timeout period in seconds
|
||||||
|
*
|
||||||
|
* @error Invalid client index, client is not in game, or a fake client
|
||||||
|
*
|
||||||
|
* @noreturn
|
||||||
|
*/
|
||||||
|
native void FileNet_RequestFile(int client, const char[] file, FileNet_RequestFileResult callback = INVALID_FUNCTION, any data = 0, int timeout = 90);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the CNetChan object of a specific client
|
||||||
|
*
|
||||||
|
* @param client Client index
|
||||||
|
* @param chan Address variable that receives the CNetChan object, Address_Null if none.
|
||||||
|
* (Address is 64-bit on x64 SourceMod, so it is returned by reference.)
|
||||||
|
*
|
||||||
|
* @return True if the client has a CNetChan object, false otherwise
|
||||||
|
*/
|
||||||
|
native bool FileNet_GetNetChanPtr(int client, Address &chan);
|
||||||
|
|
||||||
|
public SharedPlugin __pl_filenetwork =
|
||||||
|
{
|
||||||
|
name = "filenetwork",
|
||||||
|
file = "filenetwork.smx",
|
||||||
|
#if defined REQUIRE_PLUGIN
|
||||||
|
required = 1,
|
||||||
|
#else
|
||||||
|
required = 0,
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
|
||||||
|
#if !defined REQUIRE_PLUGIN
|
||||||
|
public void __pl_filenetwork_SetNTVOptional()
|
||||||
|
{
|
||||||
|
MarkNativeAsOptional("FileNet_SendFile");
|
||||||
|
MarkNativeAsOptional("FileNet_IsFileInWaitingList");
|
||||||
|
MarkNativeAsOptional("FileNet_RequestFile");
|
||||||
|
MarkNativeAsOptional("FileNet_GetNetChanPtr");
|
||||||
|
}
|
||||||
|
#endif
|
||||||
@@ -15,7 +15,9 @@
|
|||||||
{
|
{
|
||||||
"library" "server"
|
"library" "server"
|
||||||
"windows" "@CreateInterface"
|
"windows" "@CreateInterface"
|
||||||
|
"windows64" "@CreateInterface"
|
||||||
"linux" "@CreateInterface"
|
"linux" "@CreateInterface"
|
||||||
|
"linux64" "@CreateInterface"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -24,7 +26,9 @@
|
|||||||
"ProcessMovement"
|
"ProcessMovement"
|
||||||
{
|
{
|
||||||
"windows" "1"
|
"windows" "1"
|
||||||
|
"windows64" "1"
|
||||||
"linux" "2"
|
"linux" "2"
|
||||||
|
"linux64" "2"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -36,15 +40,15 @@
|
|||||||
// applies to trigger_vphysics_motion and trigger_wind
|
// applies to trigger_vphysics_motion and trigger_wind
|
||||||
"CBaseVPhysicsTrigger::PassesTriggerFilters"
|
"CBaseVPhysicsTrigger::PassesTriggerFilters"
|
||||||
{
|
{
|
||||||
"windows" "199"
|
"windows" "200"
|
||||||
"linux" "200"
|
"linux" "201"
|
||||||
}
|
}
|
||||||
|
|
||||||
// applies to all other triggers
|
// applies to all other triggers
|
||||||
"CBaseTrigger::PassesTriggerFilters"
|
"CBaseTrigger::PassesTriggerFilters"
|
||||||
{
|
{
|
||||||
"windows" "209"
|
"windows" "210"
|
||||||
"linux" "210"
|
"linux" "211"
|
||||||
}
|
}
|
||||||
|
|
||||||
"IServerGameEnts::MarkEntitiesAsTouching"
|
"IServerGameEnts::MarkEntitiesAsTouching"
|
||||||
@@ -52,6 +56,36 @@
|
|||||||
"windows" "1"
|
"windows" "1"
|
||||||
"linux" "2"
|
"linux" "2"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
"CMoveData::m_flForwardMove"
|
||||||
|
{
|
||||||
|
"windows" "44"
|
||||||
|
"linux" "44"
|
||||||
|
}
|
||||||
|
|
||||||
|
"CMoveData::m_flSideMove"
|
||||||
|
{
|
||||||
|
"windows" "48"
|
||||||
|
"linux" "48"
|
||||||
|
}
|
||||||
|
|
||||||
|
"CMoveData::m_flMaxSpeed"
|
||||||
|
{
|
||||||
|
"windows" "56"
|
||||||
|
"linux" "56"
|
||||||
|
}
|
||||||
|
|
||||||
|
"CMoveData::m_vecVelocity"
|
||||||
|
{
|
||||||
|
"windows" "64"
|
||||||
|
"linux" "64"
|
||||||
|
}
|
||||||
|
|
||||||
|
"CMoveData::m_vecAbsOrigin"
|
||||||
|
{
|
||||||
|
"windows" "172"
|
||||||
|
"linux" "172"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,24 +93,70 @@
|
|||||||
{
|
{
|
||||||
"Offsets"
|
"Offsets"
|
||||||
{
|
{
|
||||||
|
"CMoveData::m_flForwardMove"
|
||||||
|
{
|
||||||
|
"windows" "44"
|
||||||
|
"windows64" "44"
|
||||||
|
"linux" "44"
|
||||||
|
"linux64" "44"
|
||||||
|
}
|
||||||
|
|
||||||
|
"CMoveData::m_flSideMove"
|
||||||
|
{
|
||||||
|
"windows" "52"
|
||||||
|
"windows64" "52"
|
||||||
|
"linux" "52"
|
||||||
|
"linux64" "52"
|
||||||
|
}
|
||||||
|
|
||||||
|
"CMoveData::m_flMaxSpeed"
|
||||||
|
{
|
||||||
|
"windows" "60"
|
||||||
|
"windows64" "60"
|
||||||
|
"linux" "60"
|
||||||
|
"linux64" "60"
|
||||||
|
}
|
||||||
|
|
||||||
|
"CMoveData::m_vecVelocity"
|
||||||
|
{
|
||||||
|
"windows" "68"
|
||||||
|
"windows64" "68"
|
||||||
|
"linux" "68"
|
||||||
|
"linux64" "68"
|
||||||
|
}
|
||||||
|
|
||||||
|
"CMoveData::m_vecAbsOrigin"
|
||||||
|
{
|
||||||
|
"windows" "156"
|
||||||
|
"windows64" "156"
|
||||||
|
"linux" "156"
|
||||||
|
"linux64" "156"
|
||||||
|
}
|
||||||
|
|
||||||
// applies to trigger_vphysics_motion and trigger_wind
|
// applies to trigger_vphysics_motion and trigger_wind
|
||||||
"CBaseVPhysicsTrigger::PassesTriggerFilters"
|
"CBaseVPhysicsTrigger::PassesTriggerFilters"
|
||||||
{
|
{
|
||||||
"windows" "188"
|
"windows" "195"
|
||||||
"linux" "189"
|
"windows64" "195"
|
||||||
|
"linux" "196"
|
||||||
|
"linux64" "196"
|
||||||
}
|
}
|
||||||
|
|
||||||
// applies to all other triggers
|
// applies to all other triggers
|
||||||
"CBaseTrigger::PassesTriggerFilters"
|
"CBaseTrigger::PassesTriggerFilters"
|
||||||
{
|
{
|
||||||
"windows" "197"
|
"windows" "204"
|
||||||
"linux" "198"
|
"windows64" "204"
|
||||||
|
"linux" "205"
|
||||||
|
"linux64" "205"
|
||||||
}
|
}
|
||||||
|
|
||||||
"IServerGameEnts::MarkEntitiesAsTouching"
|
"IServerGameEnts::MarkEntitiesAsTouching"
|
||||||
{
|
{
|
||||||
"windows" "2"
|
"windows" "2"
|
||||||
|
"windows64" "2"
|
||||||
"linux" "3"
|
"linux" "3"
|
||||||
|
"linux64" "3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,51 @@
|
|||||||
|
#if defined _rngfix_included
|
||||||
|
#endinput
|
||||||
|
#endif
|
||||||
|
#define _rngfix_included
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when trigger_* is Hooked.
|
||||||
|
*
|
||||||
|
* @param entity Entity
|
||||||
|
* @param classname Clasname
|
||||||
|
* @noreturn
|
||||||
|
*/
|
||||||
|
forward void RNGFix_OnTriggerDetected(int entity, const char[] classname);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when trigger_* on StartTouch.
|
||||||
|
*
|
||||||
|
* @param entity Entity
|
||||||
|
* @param other Activator
|
||||||
|
* @noreturn
|
||||||
|
*/
|
||||||
|
forward void RNGFix_OnTriggerStartTouch(int entity, int other);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when trigger_* on EndTouch.
|
||||||
|
*
|
||||||
|
* @param entity Entity
|
||||||
|
* @param other Activator
|
||||||
|
* @noreturn
|
||||||
|
*/
|
||||||
|
forward void RNGFix_OnTriggerEndTouch(int entity, int other);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called after trigger_teleport is touched.
|
||||||
|
*
|
||||||
|
* @param entity Entity
|
||||||
|
* @param other Activator
|
||||||
|
* @noreturn
|
||||||
|
*/
|
||||||
|
forward void RNGFix_OnTriggerTeleportTouchPost(int entity, int other);
|
||||||
|
|
||||||
|
public SharedPlugin __pl_rngfix =
|
||||||
|
{
|
||||||
|
name = "rngfix",
|
||||||
|
file = "rngfix.smx",
|
||||||
|
#if defined REQUIRE_PLUGIN
|
||||||
|
required = 1
|
||||||
|
#else
|
||||||
|
required = 0
|
||||||
|
#endif
|
||||||
|
};
|
||||||
+392
-41
@@ -6,7 +6,7 @@
|
|||||||
#pragma semicolon 1
|
#pragma semicolon 1
|
||||||
#pragma newdecls required
|
#pragma newdecls required
|
||||||
|
|
||||||
#define PLUGIN_VERSION "1.1.2"
|
#define PLUGIN_VERSION "1.1.8"
|
||||||
|
|
||||||
public Plugin myinfo =
|
public Plugin myinfo =
|
||||||
{
|
{
|
||||||
@@ -33,6 +33,11 @@ float g_flDuckDelta;
|
|||||||
int g_iTick[MAXPLAYERS+1];
|
int g_iTick[MAXPLAYERS+1];
|
||||||
float g_flFrameTime[MAXPLAYERS+1];
|
float g_flFrameTime[MAXPLAYERS+1];
|
||||||
|
|
||||||
|
bool g_bTouchingTrigger[MAXPLAYERS+1][2048];
|
||||||
|
|
||||||
|
// Teleport target name -> reference of the last entity found with that name (see NameExists)
|
||||||
|
StringMap g_smTargetEntity;
|
||||||
|
|
||||||
int g_iButtons[MAXPLAYERS+1];
|
int g_iButtons[MAXPLAYERS+1];
|
||||||
float g_vVel[MAXPLAYERS+1][3];
|
float g_vVel[MAXPLAYERS+1][3];
|
||||||
float g_vAngles[MAXPLAYERS+1][3];
|
float g_vAngles[MAXPLAYERS+1][3];
|
||||||
@@ -80,10 +85,24 @@ ConVar g_cvJumpImpulse;
|
|||||||
ConVar g_cvAutoBunnyHopping;
|
ConVar g_cvAutoBunnyHopping;
|
||||||
|
|
||||||
Handle g_hPassesTriggerFilters;
|
Handle g_hPassesTriggerFilters;
|
||||||
Handle g_hProcessMovementHookPre;
|
DynamicHook g_hProcessMovementHookPre;
|
||||||
Address g_IServerGameEnts;
|
Address g_IServerGameEnts;
|
||||||
Handle g_hMarkEntitiesAsTouching;
|
Handle g_hMarkEntitiesAsTouching;
|
||||||
|
|
||||||
|
int g_iCMoveData_ForwardMove;
|
||||||
|
int g_iCMoveData_SideMove;
|
||||||
|
int g_iCMoveData_MaxSpeed;
|
||||||
|
int g_iCMoveData_Velocity;
|
||||||
|
int g_iCMoveData_Origin;
|
||||||
|
|
||||||
|
// API
|
||||||
|
GlobalForward g_hOnTriggerDetected;
|
||||||
|
GlobalForward g_hOnTriggerStartTouch;
|
||||||
|
GlobalForward g_hOnTriggerEndTouch;
|
||||||
|
GlobalForward g_hOnTriggerTeleportTouchPost;
|
||||||
|
|
||||||
|
bool g_bIsSurfMap;
|
||||||
|
|
||||||
bool g_bLateLoad;
|
bool g_bLateLoad;
|
||||||
|
|
||||||
int g_iLaserIndex;
|
int g_iLaserIndex;
|
||||||
@@ -110,14 +129,23 @@ void DebugLaser(int client, const float p1[3], const float p2[3], float life, fl
|
|||||||
public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max)
|
public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max)
|
||||||
{
|
{
|
||||||
g_bLateLoad = late;
|
g_bLateLoad = late;
|
||||||
|
RegPluginLibrary("rngfix");
|
||||||
|
|
||||||
|
g_hOnTriggerDetected = new GlobalForward("RNGFix_OnTriggerDetected", ET_Ignore, Param_Cell, Param_String);
|
||||||
|
g_hOnTriggerStartTouch = new GlobalForward("RNGFix_OnTriggerStartTouch", ET_Ignore, Param_Cell, Param_Cell);
|
||||||
|
g_hOnTriggerEndTouch = new GlobalForward("RNGFix_OnTriggerEndTouch", ET_Ignore, Param_Cell, Param_Cell);
|
||||||
|
g_hOnTriggerTeleportTouchPost = new GlobalForward("RNGFix_OnTriggerTeleportTouchPost", ET_Ignore, Param_Cell, Param_Cell);
|
||||||
|
|
||||||
return APLRes_Success;
|
return APLRes_Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnPluginStart()
|
public void OnPluginStart()
|
||||||
{
|
{
|
||||||
|
g_smTargetEntity = new StringMap();
|
||||||
|
|
||||||
EngineVersion engine = GetEngineVersion();
|
EngineVersion engine = GetEngineVersion();
|
||||||
|
|
||||||
if (engine != Engine_CSGO && engine != Engine_CSS)
|
if (engine != Engine_CSS)
|
||||||
{
|
{
|
||||||
SetFailState("Game is not supported");
|
SetFailState("Game is not supported");
|
||||||
}
|
}
|
||||||
@@ -126,19 +154,8 @@ public void OnPluginStart()
|
|||||||
g_vecMaxsUnducked = view_as<float>({16.0, 16.0, 0.0});
|
g_vecMaxsUnducked = view_as<float>({16.0, 16.0, 0.0});
|
||||||
g_vecMaxsDucked = view_as<float>({16.0, 16.0, 0.0});
|
g_vecMaxsDucked = view_as<float>({16.0, 16.0, 0.0});
|
||||||
|
|
||||||
switch (engine)
|
|
||||||
{
|
|
||||||
case Engine_CSGO:
|
|
||||||
{
|
|
||||||
g_vecMaxsUnducked[2] = 72.0;
|
|
||||||
g_vecMaxsDucked[2] = 64.0;
|
|
||||||
}
|
|
||||||
case Engine_CSS:
|
|
||||||
{
|
|
||||||
g_vecMaxsUnducked[2] = 62.0;
|
g_vecMaxsUnducked[2] = 62.0;
|
||||||
g_vecMaxsDucked[2] = 45.0;
|
g_vecMaxsDucked[2] = 45.0;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
g_flDuckDelta = (g_vecMaxsUnducked[2]-g_vecMaxsDucked[2]) / 2;
|
g_flDuckDelta = (g_vecMaxsUnducked[2]-g_vecMaxsDucked[2]) / 2;
|
||||||
|
|
||||||
@@ -153,7 +170,7 @@ public void OnPluginStart()
|
|||||||
|
|
||||||
g_cvDebug = CreateConVar("rngfix_debug", "0", "1 = Enable debug messages. 2 = Enable debug messages and lasers.", _, true, 0.0, true, 2.0);
|
g_cvDebug = CreateConVar("rngfix_debug", "0", "1 = Enable debug messages. 2 = Enable debug messages and lasers.", _, true, 0.0, true, 2.0);
|
||||||
|
|
||||||
AutoExecConfig();
|
AutoExecConfig(true);
|
||||||
|
|
||||||
g_cvMaxVelocity = FindConVar("sv_maxvelocity");
|
g_cvMaxVelocity = FindConVar("sv_maxvelocity");
|
||||||
g_cvGravity = FindConVar("sv_gravity");
|
g_cvGravity = FindConVar("sv_gravity");
|
||||||
@@ -169,7 +186,7 @@ public void OnPluginStart()
|
|||||||
g_cvJumpImpulse = FindConVar("sv_jump_impulse");
|
g_cvJumpImpulse = FindConVar("sv_jump_impulse");
|
||||||
g_cvAutoBunnyHopping = FindConVar("sv_autobunnyhopping");
|
g_cvAutoBunnyHopping = FindConVar("sv_autobunnyhopping");
|
||||||
|
|
||||||
Handle gamedataConf = LoadGameConfigFile("rngfix.games");
|
GameData gamedataConf = new GameData("rngfix.games");
|
||||||
if (gamedataConf == null) SetFailState("Failed to load rngfix gamedata");
|
if (gamedataConf == null) SetFailState("Failed to load rngfix gamedata");
|
||||||
|
|
||||||
// PassesTriggerFilters
|
// PassesTriggerFilters
|
||||||
@@ -193,7 +210,13 @@ public void OnPluginStart()
|
|||||||
}
|
}
|
||||||
PrepSDKCall_AddParameter(SDKType_String, SDKPass_Pointer);
|
PrepSDKCall_AddParameter(SDKType_String, SDKPass_Pointer);
|
||||||
PrepSDKCall_AddParameter(SDKType_PlainOldData, SDKPass_Pointer, VDECODE_FLAG_ALLOWNULL);
|
PrepSDKCall_AddParameter(SDKType_PlainOldData, SDKPass_Pointer, VDECODE_FLAG_ALLOWNULL);
|
||||||
|
#if SOURCEMOD_V_MINOR >= 13
|
||||||
|
// A pointer does not fit in a cell on x64: SM 1.13 returns it through an Address (int64) argument
|
||||||
|
PrepSDKCall_SetReturnInfo(SDKType_Address, SDKPass_Plain);
|
||||||
|
#else
|
||||||
|
// SM 1.12 has no SDKType_Address: the pointer is returned in a cell, which only works on 32-bit servers
|
||||||
PrepSDKCall_SetReturnInfo(SDKType_PlainOldData, SDKPass_Plain);
|
PrepSDKCall_SetReturnInfo(SDKType_PlainOldData, SDKPass_Plain);
|
||||||
|
#endif
|
||||||
Handle CreateInterface = EndPrepSDKCall();
|
Handle CreateInterface = EndPrepSDKCall();
|
||||||
|
|
||||||
if (CreateInterface == null) SetFailState("Unable to prepare SDKCall for CreateInterface");
|
if (CreateInterface == null) SetFailState("Unable to prepare SDKCall for CreateInterface");
|
||||||
@@ -201,31 +224,52 @@ public void OnPluginStart()
|
|||||||
char interfaceName[64];
|
char interfaceName[64];
|
||||||
|
|
||||||
// ProcessMovement
|
// ProcessMovement
|
||||||
if (!GameConfGetKeyValue(gamedataConf, "IGameMovement", interfaceName, sizeof(interfaceName)))
|
if (!gamedataConf.GetKeyValue("IGameMovement", interfaceName, sizeof(interfaceName)))
|
||||||
{
|
{
|
||||||
SetFailState("Failed to get IGameMovement interface name");
|
SetFailState("Failed to get IGameMovement interface name");
|
||||||
}
|
}
|
||||||
Address IGameMovement = SDKCall(CreateInterface, interfaceName, 0);
|
Address IGameMovement = GetInterface(CreateInterface, interfaceName);
|
||||||
if (!IGameMovement)
|
if (IGameMovement == Address_Null)
|
||||||
{
|
{
|
||||||
SetFailState("Failed to get IGameMovement pointer");
|
SetFailState("Failed to get IGameMovement pointer");
|
||||||
}
|
}
|
||||||
|
|
||||||
int offset = GameConfGetOffset(gamedataConf, "ProcessMovement");
|
int offset = gamedataConf.GetOffset("ProcessMovement");
|
||||||
if (offset == -1) SetFailState("Failed to get ProcessMovement offset");
|
if (offset == -1) SetFailState("Failed to get ProcessMovement offset");
|
||||||
|
|
||||||
g_hProcessMovementHookPre = DHookCreate(offset, HookType_Raw, ReturnType_Void, ThisPointer_Ignore, DHook_ProcessMovementPre);
|
g_hProcessMovementHookPre = new DynamicHook(offset, HookType_Raw, ReturnType_Void, ThisPointer_Ignore);
|
||||||
DHookAddParam(g_hProcessMovementHookPre, HookParamType_CBaseEntity);
|
g_hProcessMovementHookPre.AddParam(HookParamType_CBaseEntity);
|
||||||
DHookAddParam(g_hProcessMovementHookPre, HookParamType_ObjectPtr);
|
g_hProcessMovementHookPre.AddParam(HookParamType_ObjectPtr);
|
||||||
DHookRaw(g_hProcessMovementHookPre, false, IGameMovement);
|
g_hProcessMovementHookPre.HookRaw(Hook_Pre, IGameMovement, DHook_ProcessMovementPre);
|
||||||
|
|
||||||
|
if ((g_iCMoveData_ForwardMove = gamedataConf.GetOffset("CMoveData::m_flForwardMove")) == -1)
|
||||||
|
{
|
||||||
|
SetFailState("Failed to get CMoveData::m_flForwardMove");
|
||||||
|
}
|
||||||
|
if ((g_iCMoveData_SideMove = gamedataConf.GetOffset("CMoveData::m_flSideMove")) == -1)
|
||||||
|
{
|
||||||
|
SetFailState("Failed to get CMoveData::m_flSideMove");
|
||||||
|
}
|
||||||
|
if ((g_iCMoveData_MaxSpeed = gamedataConf.GetOffset("CMoveData::m_flMaxSpeed")) == -1)
|
||||||
|
{
|
||||||
|
SetFailState("Failed to get CMoveData::m_flMaxSpeed");
|
||||||
|
}
|
||||||
|
if ((g_iCMoveData_Velocity = gamedataConf.GetOffset("CMoveData::m_vecVelocity")) == -1)
|
||||||
|
{
|
||||||
|
SetFailState("Failed to get CMoveData::m_vecVelocity");
|
||||||
|
}
|
||||||
|
if ((g_iCMoveData_Origin = gamedataConf.GetOffset("CMoveData::m_vecAbsOrigin")) == -1)
|
||||||
|
{
|
||||||
|
SetFailState("Failed to get CMoveData::m_vecAbsOrigin");
|
||||||
|
}
|
||||||
|
|
||||||
// MarkEntitiesAsTouching
|
// MarkEntitiesAsTouching
|
||||||
if (!GameConfGetKeyValue(gamedataConf, "IServerGameEnts", interfaceName, sizeof(interfaceName)))
|
if (!gamedataConf.GetKeyValue("IServerGameEnts", interfaceName, sizeof(interfaceName)))
|
||||||
{
|
{
|
||||||
SetFailState("Failed to get IServerGameEnts interface name");
|
SetFailState("Failed to get IServerGameEnts interface name");
|
||||||
}
|
}
|
||||||
g_IServerGameEnts = SDKCall(CreateInterface, interfaceName, 0);
|
g_IServerGameEnts = GetInterface(CreateInterface, interfaceName);
|
||||||
if (!g_IServerGameEnts)
|
if (g_IServerGameEnts == Address_Null)
|
||||||
{
|
{
|
||||||
SetFailState("Failed to get IServerGameEnts pointer");
|
SetFailState("Failed to get IServerGameEnts pointer");
|
||||||
}
|
}
|
||||||
@@ -250,16 +294,56 @@ public void OnPluginStart()
|
|||||||
{
|
{
|
||||||
if (IsClientInGame(client)) OnClientPutInServer(client);
|
if (IsClientInGame(client)) OnClientPutInServer(client);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char classname[64];
|
||||||
|
for (int entity = MaxClients+1; entity < sizeof(g_bTouchingTrigger[]); entity++)
|
||||||
|
{
|
||||||
|
if (!IsValidEntity(entity)) continue;
|
||||||
|
GetEntPropString(entity, Prop_Data, "m_iClassname", classname, sizeof(classname));
|
||||||
|
HookTrigger(entity, classname);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Calls CreateInterface(name, NULL) and returns the interface pointer
|
||||||
|
Address GetInterface(Handle createInterface, const char[] name)
|
||||||
|
{
|
||||||
|
#if SOURCEMOD_V_MINOR >= 13
|
||||||
|
Address pInterface = Address_Null;
|
||||||
|
SDKCall(createInterface, pInterface, name, 0);
|
||||||
|
return pInterface;
|
||||||
|
#else
|
||||||
|
return SDKCall(createInterface, name, 0);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
public void OnMapStart()
|
public void OnMapStart()
|
||||||
{
|
{
|
||||||
|
delete g_smTargetEntity;
|
||||||
|
g_smTargetEntity = new StringMap();
|
||||||
|
|
||||||
g_iLaserIndex = PrecacheModel("materials/sprites/laserbeam.vmt", true);
|
g_iLaserIndex = PrecacheModel("materials/sprites/laserbeam.vmt", true);
|
||||||
|
|
||||||
|
char map[PLATFORM_MAX_PATH];
|
||||||
|
GetCurrentMap(map, sizeof(map));
|
||||||
|
g_bIsSurfMap = StrContains(map, "surf_", false) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnEntityCreated(int entity, const char[] classname)
|
public void OnEntityCreated(int entity, const char[] classname)
|
||||||
{
|
{
|
||||||
|
if (entity >= sizeof(g_bTouchingTrigger[])) return;
|
||||||
|
HookTrigger(entity, classname);
|
||||||
|
}
|
||||||
|
|
||||||
|
void HookTrigger(int entity, const char[] classname)
|
||||||
|
{
|
||||||
|
if (StrContains(classname, "trigger_") != -1)
|
||||||
|
{
|
||||||
|
SDKHook(entity, SDKHook_StartTouchPost, Hook_TriggerStartTouch);
|
||||||
|
SDKHook(entity, SDKHook_EndTouchPost, Hook_TriggerEndTouch);
|
||||||
|
Forward_OnTriggerDetected(entity, classname);
|
||||||
|
}
|
||||||
|
|
||||||
if (StrContains(classname, "trigger_teleport") != -1)
|
if (StrContains(classname, "trigger_teleport") != -1)
|
||||||
{
|
{
|
||||||
SDKHook(entity, SDKHook_TouchPost, Hook_TriggerTeleportTouchPost);
|
SDKHook(entity, SDKHook_TouchPost, Hook_TriggerTeleportTouchPost);
|
||||||
@@ -269,6 +353,7 @@ public void OnEntityCreated(int entity, const char[] classname)
|
|||||||
public void OnClientConnected(int client)
|
public void OnClientConnected(int client)
|
||||||
{
|
{
|
||||||
g_iTick[client] = 0;
|
g_iTick[client] = 0;
|
||||||
|
for (int i = 0; i < sizeof(g_bTouchingTrigger[]); i++) g_bTouchingTrigger[client][i] = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnClientPutInServer(int client)
|
public void OnClientPutInServer(int client)
|
||||||
@@ -277,6 +362,18 @@ public void OnClientPutInServer(int client)
|
|||||||
SDKHook(client, SDKHook_PostThink, Hook_PlayerPostThink);
|
SDKHook(client, SDKHook_PostThink, Hook_PlayerPostThink);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Action Hook_TriggerStartTouch(int entity, int other)
|
||||||
|
{
|
||||||
|
if (1 <= other <= MaxClients)
|
||||||
|
{
|
||||||
|
g_bTouchingTrigger[other][entity] = true;
|
||||||
|
DebugMsg(other, "StartTouch %i", entity);
|
||||||
|
Forward_OnTriggerStartTouch(entity, other);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Plugin_Continue;
|
||||||
|
}
|
||||||
|
|
||||||
// TODO Would be nice to have IServerTools::FindEntityByName / CGlobalEntityList::FindEntityByName
|
// TODO Would be nice to have IServerTools::FindEntityByName / CGlobalEntityList::FindEntityByName
|
||||||
bool NameExists(const char[] targetname)
|
bool NameExists(const char[] targetname)
|
||||||
{
|
{
|
||||||
@@ -285,15 +382,34 @@ bool NameExists(const char[] targetname)
|
|||||||
|
|
||||||
char targetname2[128];
|
char targetname2[128];
|
||||||
|
|
||||||
|
// This runs on every tick a player touches a trigger_teleport, and a mass teleport touches it
|
||||||
|
// with every player in the same tick: check the entity found last time before walking all edicts.
|
||||||
|
// Teleport destinations rarely change, so the walk below only runs again when that entity is gone
|
||||||
|
// or renamed, or when no entity has the name.
|
||||||
|
int ref;
|
||||||
|
if (g_smTargetEntity.GetValue(targetname, ref))
|
||||||
|
{
|
||||||
|
int entity = EntRefToEntIndex(ref);
|
||||||
|
if (entity != INVALID_ENT_REFERENCE
|
||||||
|
&& GetEntPropString(entity, Prop_Data, "m_iName", targetname2, sizeof(targetname2)) != 0
|
||||||
|
&& StrEqual(targetname, targetname2))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
int max = GetMaxEntities();
|
int max = GetMaxEntities();
|
||||||
for (int entity = 1; entity < max; entity++)
|
for (int entity = 1; entity < max; entity++)
|
||||||
{
|
{
|
||||||
if (!IsValidEntity(entity)) continue;
|
if (!IsValidEntity(entity)) continue;
|
||||||
if (GetEntPropString(entity, Prop_Data, "m_iName", targetname2, sizeof(targetname2)) == 0) continue;
|
if (GetEntPropString(entity, Prop_Data, "m_iName", targetname2, sizeof(targetname2)) == 0) continue;
|
||||||
|
|
||||||
if (StrEqual(targetname, targetname2)) return true;
|
if (StrEqual(targetname, targetname2))
|
||||||
|
{
|
||||||
|
g_smTargetEntity.SetValue(targetname, EntIndexToEntRef(entity));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_smTargetEntity.Remove(targetname);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -316,6 +432,18 @@ public void Hook_TriggerTeleportTouchPost(int entity, int other)
|
|||||||
g_iLastMapTeleportTick[other] = g_iTick[other];
|
g_iLastMapTeleportTick[other] = g_iTick[other];
|
||||||
|
|
||||||
DebugMsg(other, "Triggered teleport %i", entity);
|
DebugMsg(other, "Triggered teleport %i", entity);
|
||||||
|
Forward_OnTriggerTeleportEndTouch(entity, other);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Action Hook_TriggerEndTouch(int entity, int other)
|
||||||
|
{
|
||||||
|
if (1 <= other <= MaxClients)
|
||||||
|
{
|
||||||
|
g_bTouchingTrigger[other][entity] = false;
|
||||||
|
DebugMsg(other, "EndTouch %i", entity);
|
||||||
|
Forward_OnTriggerEndTouch(entity, other);
|
||||||
|
}
|
||||||
|
return Plugin_Continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool PlayerFilter(int entity, int mask)
|
public bool PlayerFilter(int entity, int mask)
|
||||||
@@ -419,7 +547,7 @@ void CheckJumpButton(int client, float velocity[3])
|
|||||||
FinishGravity(client, velocity);
|
FinishGravity(client, velocity);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AirAccelerate(int client, float velocity[3], Handle hParams)
|
void AirAccelerate(int client, float velocity[3], DHookParam hParams)
|
||||||
{
|
{
|
||||||
// This also includes the initial parts of AirMove()
|
// This also includes the initial parts of AirMove()
|
||||||
|
|
||||||
@@ -436,7 +564,7 @@ void AirAccelerate(int client, float velocity[3], Handle hParams)
|
|||||||
for (int i = 0; i < 2; i++) wishvel[i] = fore[i] * g_vVel[client][0] + side[i] * g_vVel[client][1];
|
for (int i = 0; i < 2; i++) wishvel[i] = fore[i] * g_vVel[client][0] + side[i] * g_vVel[client][1];
|
||||||
|
|
||||||
float wishspeed = NormalizeVector(wishvel, wishdir);
|
float wishspeed = NormalizeVector(wishvel, wishdir);
|
||||||
float m_flMaxSpeed = DHookGetParamObjectPtrVar(hParams, 2, 56, ObjectValueType_Float);
|
float m_flMaxSpeed = hParams.GetObjectVar(2, g_iCMoveData_MaxSpeed, ObjectValueType_Float);
|
||||||
if (wishspeed > m_flMaxSpeed && m_flMaxSpeed != 0.0) wishspeed = m_flMaxSpeed;
|
if (wishspeed > m_flMaxSpeed && m_flMaxSpeed != 0.0) wishspeed = m_flMaxSpeed;
|
||||||
|
|
||||||
if (wishspeed)
|
if (wishspeed)
|
||||||
@@ -499,7 +627,7 @@ bool CheckWater(int client)
|
|||||||
return GetEntProp(client, Prop_Data, "m_nWaterLevel") > 1;
|
return GetEntProp(client, Prop_Data, "m_nWaterLevel") > 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PreventCollision(int client, Handle hParams, const float origin[3], const float collisionPoint[3], const float velocity_tick[3])
|
void PreventCollision(int client, DHookParam hParams, const float origin[3], const float collisionPoint[3], const float velocity_tick[3])
|
||||||
{
|
{
|
||||||
DebugLaser(client, origin, collisionPoint, 15.0, 0.5, g_color1);
|
DebugLaser(client, origin, collisionPoint, 15.0, 0.5, g_color1);
|
||||||
|
|
||||||
@@ -515,7 +643,7 @@ void PreventCollision(int client, Handle hParams, const float origin[3], const f
|
|||||||
|
|
||||||
// Since the MoveData for this tick has already been filled and is about to be used, we need
|
// Since the MoveData for this tick has already been filled and is about to be used, we need
|
||||||
// to modify it directly instead of changing the player entity's actual position (such as with TeleportEntity).
|
// to modify it directly instead of changing the player entity's actual position (such as with TeleportEntity).
|
||||||
DHookSetParamObjectPtrVarVector(hParams, 2, GetEngineVersion() == Engine_CSGO ? 172 : 152, ObjectValueType_Vector, newOrigin);
|
hParams.SetObjectVarVector(2, g_iCMoveData_Origin, ObjectValueType_Vector, newOrigin);
|
||||||
|
|
||||||
DebugLaser(client, origin, newOrigin, 15.0, 0.5, g_color2);
|
DebugLaser(client, origin, newOrigin, 15.0, 0.5, g_color2);
|
||||||
|
|
||||||
@@ -563,9 +691,12 @@ void SetVelocity(int client, float velocity[3], bool dontUseTeleportEntity = fal
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public MRESReturn DHook_ProcessMovementPre(Handle hParams)
|
public MRESReturn DHook_ProcessMovementPre(DHookParam hParams)
|
||||||
{
|
{
|
||||||
int client = DHookGetParam(hParams, 1);
|
int client = hParams.Get(1);
|
||||||
|
|
||||||
|
if (!IsClientInGame(client))
|
||||||
|
return MRES_Ignored;
|
||||||
|
|
||||||
g_iTick[client]++;
|
g_iTick[client]++;
|
||||||
g_flFrameTime[client] = GetTickInterval() * GetEntPropFloat(client, Prop_Data, "m_flLaggedMovementValue");
|
g_flFrameTime[client] = GetTickInterval() * GetEntPropFloat(client, Prop_Data, "m_flLaggedMovementValue");
|
||||||
@@ -582,7 +713,7 @@ public MRESReturn DHook_ProcessMovementPre(Handle hParams)
|
|||||||
return MRES_Ignored;
|
return MRES_Ignored;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RunPreTickChecks(int client, Handle hParams)
|
void RunPreTickChecks(int client, DHookParam hParams)
|
||||||
{
|
{
|
||||||
// Recreate enough of CGameMovement::ProcessMovement to predict if fixes are needed.
|
// Recreate enough of CGameMovement::ProcessMovement to predict if fixes are needed.
|
||||||
// We only really care about a limited set of scenarios (less than waist-deep in water, MOVETYPE_WALK, air movement).
|
// We only really care about a limited set of scenarios (less than waist-deep in water, MOVETYPE_WALK, air movement).
|
||||||
@@ -598,20 +729,22 @@ void RunPreTickChecks(int client, Handle hParams)
|
|||||||
|
|
||||||
g_iLastTickPredicted[client] = g_iTick[client];
|
g_iLastTickPredicted[client] = g_iTick[client];
|
||||||
|
|
||||||
g_iButtons[client] = DHookGetParamObjectPtrVar(hParams, 2, 36, ObjectValueType_Int);
|
g_iButtons[client] = hParams.GetObjectVar(2, 36, ObjectValueType_Int);
|
||||||
g_iOldButtons[client] = DHookGetParamObjectPtrVar(hParams, 2, 40, ObjectValueType_Int);
|
g_iOldButtons[client] = hParams.GetObjectVar(2, 40, ObjectValueType_Int);
|
||||||
DHookGetParamObjectPtrVarVector(hParams, 2, 44, ObjectValueType_Vector, g_vVel[client]);
|
g_vVel[client][0] = hParams.GetObjectVar(2, g_iCMoveData_ForwardMove, ObjectValueType_Float);
|
||||||
DHookGetParamObjectPtrVarVector(hParams, 2, 12, ObjectValueType_Vector, g_vAngles[client]);
|
g_vVel[client][1] = hParams.GetObjectVar(2, g_iCMoveData_SideMove, ObjectValueType_Float);
|
||||||
|
g_vVel[client][2] = 0.0;
|
||||||
|
hParams.GetObjectVarVector(2, 12, ObjectValueType_Vector, g_vAngles[client]);
|
||||||
|
|
||||||
float velocity[3];
|
float velocity[3];
|
||||||
DHookGetParamObjectPtrVarVector(hParams, 2, 64, ObjectValueType_Vector, velocity);
|
hParams.GetObjectVarVector(2, g_iCMoveData_Velocity, ObjectValueType_Vector, velocity);
|
||||||
|
|
||||||
float baseVelocity[3];
|
float baseVelocity[3];
|
||||||
// basevelocity is not stored in MoveData
|
// basevelocity is not stored in MoveData
|
||||||
GetEntPropVector(client, Prop_Data, "m_vecBaseVelocity", baseVelocity);
|
GetEntPropVector(client, Prop_Data, "m_vecBaseVelocity", baseVelocity);
|
||||||
|
|
||||||
float origin[3];
|
float origin[3];
|
||||||
DHookGetParamObjectPtrVarVector(hParams, 2, GetEngineVersion() == Engine_CSGO ? 172 : 152, ObjectValueType_Vector, origin);
|
hParams.GetObjectVarVector(2, g_iCMoveData_Origin, ObjectValueType_Vector, origin);
|
||||||
|
|
||||||
float nextOrigin[3], mins[3], maxs[3];
|
float nextOrigin[3], mins[3], maxs[3];
|
||||||
|
|
||||||
@@ -779,6 +912,173 @@ public void Hook_PlayerGroundEntChanged(int client)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool DoTriggerjumpFix(int client, const float landingPoint[3], const float landingMins[3], const float landingMaxs[3])
|
||||||
|
{
|
||||||
|
if (!g_cvTriggerjump.BoolValue) return false;
|
||||||
|
|
||||||
|
// It's possible to land above a trigger but also in another trigger_teleport, have the teleport move you to
|
||||||
|
// another location, and then the trigger jumping fix wouldn't fire the other trigger you technically landed above,
|
||||||
|
// but I can't imagine a mapper would ever actually stack triggers like that.
|
||||||
|
|
||||||
|
float origin[3];
|
||||||
|
GetEntPropVector(client, Prop_Data, "m_vecAbsOrigin", origin);
|
||||||
|
|
||||||
|
float landingMaxsBelow[3];
|
||||||
|
landingMaxsBelow[0] = landingMaxs[0];
|
||||||
|
landingMaxsBelow[1] = landingMaxs[1];
|
||||||
|
landingMaxsBelow[2] = origin[2] - landingPoint[2];
|
||||||
|
|
||||||
|
ArrayList triggers = new ArrayList();
|
||||||
|
|
||||||
|
// Find triggers that are between us and the ground (using the bounding box quadrant we landed with if applicable).
|
||||||
|
TR_EnumerateEntitiesHull(landingPoint, landingPoint, landingMins, landingMaxsBelow, true, AddTrigger, triggers);
|
||||||
|
|
||||||
|
bool didSomething = false;
|
||||||
|
|
||||||
|
for (int i = 0; i < triggers.Length; i++)
|
||||||
|
{
|
||||||
|
int trigger = triggers.Get(i);
|
||||||
|
|
||||||
|
// MarkEntitiesAsTouching always fires the Touch function even if it was already fired this tick.
|
||||||
|
// In case that could cause side-effects, manually keep track of triggers we are actually touching
|
||||||
|
// and don't re-touch them.
|
||||||
|
if (g_bTouchingTrigger[client][trigger]) continue;
|
||||||
|
|
||||||
|
DebugMsg(client, "DO FIX: Trigger Jumping (entity %i)", trigger);
|
||||||
|
|
||||||
|
SDKCall(g_hMarkEntitiesAsTouching, g_IServerGameEnts, client, trigger);
|
||||||
|
didSomething = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
delete triggers;
|
||||||
|
|
||||||
|
return didSomething;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DoStairsFix(int client)
|
||||||
|
{
|
||||||
|
if (!g_cvStairs.BoolValue) return false;
|
||||||
|
if (g_iLastTickPredicted[client] != g_iTick[client]) return false;
|
||||||
|
|
||||||
|
// This fix has undesirable side-effects on bhop. It is also very unlikely to help on bhop.
|
||||||
|
if (!g_bIsSurfMap) return false;
|
||||||
|
|
||||||
|
// Let teleports take precedence (including teleports activated by the trigger jumping fix).
|
||||||
|
if (g_iLastMapTeleportTick[client] == g_iTick[client]) return false;
|
||||||
|
|
||||||
|
// If moving upward, the player would never be able to slide up with any current position.
|
||||||
|
if (g_vPreCollisionVelocity[client][2] > 0.0) return false;
|
||||||
|
|
||||||
|
// Stair step faces don't necessarily have to be completely vertical, but, if they are not,
|
||||||
|
// sliding up them at high speed -- or even just walking up -- usually doesn't work.
|
||||||
|
// Plus, it's really unlikely that there are actual stairs shaped like that.
|
||||||
|
if (g_iLastCollisionTick[client] == g_iTick[client] && g_vCollisionNormal[client][2] == 0.0)
|
||||||
|
{
|
||||||
|
// Do this first and stop if we are moving slowly (less than 1 unit per tick).
|
||||||
|
float velocity_dir[3];
|
||||||
|
velocity_dir = g_vPreCollisionVelocity[client];
|
||||||
|
velocity_dir[2] = 0.0;
|
||||||
|
if (NormalizeVector(velocity_dir, velocity_dir) * g_flFrameTime[client] < 1.0) return false;
|
||||||
|
|
||||||
|
float mins[3], maxs[3];
|
||||||
|
GetEntPropVector(client, Prop_Data, "m_vecMins", mins);
|
||||||
|
GetEntPropVector(client, Prop_Data, "m_vecMaxs", maxs);
|
||||||
|
|
||||||
|
// We seem to have collided with a "wall", now figure out if it's a stair step.
|
||||||
|
|
||||||
|
// Look for ground below us
|
||||||
|
float stepsize = GetEntPropFloat(client, Prop_Data, "m_flStepSize");
|
||||||
|
|
||||||
|
float end[3];
|
||||||
|
end = g_vCollisionPoint[client];
|
||||||
|
end[2] -= stepsize;
|
||||||
|
|
||||||
|
TR_TraceHullFilter(g_vCollisionPoint[client], end, mins, maxs, MASK_PLAYERSOLID, PlayerFilter);
|
||||||
|
|
||||||
|
if (TR_DidHit())
|
||||||
|
{
|
||||||
|
float nrm[3];
|
||||||
|
TR_GetPlaneNormal(null, nrm);
|
||||||
|
|
||||||
|
// Ground below is not walkable, not stairs
|
||||||
|
if (nrm[2] < MIN_STANDABLE_ZNRM) return false;
|
||||||
|
|
||||||
|
float start[3];
|
||||||
|
TR_GetEndPosition(start);
|
||||||
|
|
||||||
|
// Find triggers that we would trigger if we did touch the ground here.
|
||||||
|
ArrayList triggers = new ArrayList();
|
||||||
|
|
||||||
|
TR_EnumerateEntitiesHull(start, start, mins, maxs, true, AddTrigger, triggers);
|
||||||
|
|
||||||
|
for (int i = 0; i < triggers.Length; i++)
|
||||||
|
{
|
||||||
|
int trigger = triggers.Get(i);
|
||||||
|
|
||||||
|
if (SDKCall(g_hPassesTriggerFilters, trigger, client))
|
||||||
|
{
|
||||||
|
// We would have triggered something on the ground here, so we cant be sure the stairs fix is safe to do.
|
||||||
|
// The most likely scenario here is this isn't stairs, but just a short ledge with a fail teleport in front.
|
||||||
|
delete triggers;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
delete triggers;
|
||||||
|
|
||||||
|
// Now follow CGameMovement::StepMove behavior.
|
||||||
|
|
||||||
|
// Trace up
|
||||||
|
end = start;
|
||||||
|
end[2] += stepsize;
|
||||||
|
TR_TraceHullFilter(start, end, mins, maxs, MASK_PLAYERSOLID, PlayerFilter);
|
||||||
|
|
||||||
|
if (TR_DidHit()) TR_GetEndPosition(end);
|
||||||
|
|
||||||
|
// Trace over (only 1 unit, just to find a stair step)
|
||||||
|
start = end;
|
||||||
|
AddVectors(start, velocity_dir, end);
|
||||||
|
|
||||||
|
TR_TraceHullFilter(start, end, mins, maxs, MASK_PLAYERSOLID, PlayerFilter);
|
||||||
|
|
||||||
|
if (TR_DidHit())
|
||||||
|
{
|
||||||
|
// The plane we collided with is too tall to be a stair step (i.e. it's a wall, not stairs).
|
||||||
|
// Or possibly: the ceiling is too low to get on top of it.
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Trace downward
|
||||||
|
start = end;
|
||||||
|
end[2] -= stepsize;
|
||||||
|
|
||||||
|
TR_TraceHullFilter(start, end, mins, maxs, MASK_PLAYERSOLID, PlayerFilter);
|
||||||
|
|
||||||
|
if (!TR_DidHit()) return false; // Shouldn't happen
|
||||||
|
|
||||||
|
TR_GetPlaneNormal(null, nrm);
|
||||||
|
|
||||||
|
// Ground atop "stair" is not walkable, not stairs
|
||||||
|
if (nrm[2] < MIN_STANDABLE_ZNRM) return false;
|
||||||
|
|
||||||
|
// It looks like we actually collided with a stair step.
|
||||||
|
// Put the player just barely on top of the stair step we found and restore their speed
|
||||||
|
TR_GetEndPosition(end);
|
||||||
|
|
||||||
|
DebugMsg(client, "DO FIX: Stair Sliding");
|
||||||
|
|
||||||
|
TeleportEntity(client, end, NULL_VECTOR, NULL_VECTOR);
|
||||||
|
SetVelocity(client, g_vPreCollisionVelocity[client]);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool DoInclineCollisionFixes(int client, const float nrm[3])
|
bool DoInclineCollisionFixes(int client, const float nrm[3])
|
||||||
{
|
{
|
||||||
if (!g_cvDownhill.BoolValue && g_cvUphill.IntValue != UPHILL_LOSS) return false;
|
if (!g_cvDownhill.BoolValue && g_cvUphill.IntValue != UPHILL_LOSS) return false;
|
||||||
@@ -968,6 +1268,17 @@ public void Hook_PlayerPostThink(int client)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (landed && TR_GetFraction() > 0.0)
|
||||||
|
{
|
||||||
|
DoTriggerjumpFix(client, landingPoint, landingMins, landingMaxs);
|
||||||
|
|
||||||
|
// Check if a trigger we just touched put us in the air (probably due to a teleport).
|
||||||
|
if (GetEntityFlags(client) & FL_ONGROUND == 0) landed = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// The stair sliding fix changes the outcome of this tick more significantly, so it doesn't really make sense to do incline fixes too.
|
||||||
|
if (DoStairsFix(client)) return;
|
||||||
|
|
||||||
if (landed)
|
if (landed)
|
||||||
{
|
{
|
||||||
DoInclineCollisionFixes(client, nrm);
|
DoInclineCollisionFixes(client, nrm);
|
||||||
@@ -976,6 +1287,14 @@ public void Hook_PlayerPostThink(int client)
|
|||||||
DoTelehopFix(client);
|
DoTelehopFix(client);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool AddTrigger(int entity, ArrayList triggers)
|
||||||
|
{
|
||||||
|
TR_ClipCurrentRayToEntity(MASK_ALL, entity);
|
||||||
|
if (TR_DidHit()) triggers.Push(entity);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool TracePlayerBBoxForGround(const float origin[3], const float originBelow[3], float mins[3], float maxs[3])
|
bool TracePlayerBBoxForGround(const float origin[3], const float originBelow[3], float mins[3], float maxs[3])
|
||||||
{
|
{
|
||||||
// See CGameMovement::TracePlayerBBoxForGround()
|
// See CGameMovement::TracePlayerBBoxForGround()
|
||||||
@@ -1052,3 +1371,35 @@ bool TracePlayerBBoxForGround(const float origin[3], const float originBelow[3],
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Forward_OnTriggerDetected(int entity, const char[] classname)
|
||||||
|
{
|
||||||
|
Call_StartForward(g_hOnTriggerDetected);
|
||||||
|
Call_PushCell(entity);
|
||||||
|
Call_PushString(classname);
|
||||||
|
Call_Finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Forward_OnTriggerStartTouch(int entity, int other)
|
||||||
|
{
|
||||||
|
Call_StartForward(g_hOnTriggerStartTouch);
|
||||||
|
Call_PushCell(entity);
|
||||||
|
Call_PushCell(other);
|
||||||
|
Call_Finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Forward_OnTriggerEndTouch(int entity, int other)
|
||||||
|
{
|
||||||
|
Call_StartForward(g_hOnTriggerEndTouch);
|
||||||
|
Call_PushCell(entity);
|
||||||
|
Call_PushCell(other);
|
||||||
|
Call_Finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Forward_OnTriggerTeleportEndTouch(int entity, int other)
|
||||||
|
{
|
||||||
|
Call_StartForward(g_hOnTriggerTeleportTouchPost);
|
||||||
|
Call_PushCell(entity);
|
||||||
|
Call_PushCell(other);
|
||||||
|
Call_Finish();
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user