Skip to content

Commit

Permalink
Merge pull request #708 from shavitush/very_good_yes
Browse files Browse the repository at this point in the history
2.3.5
  • Loading branch information
shavitush authored Dec 7, 2018
2 parents 398c9ee + 7e8eb0c commit f527455
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 40 deletions.
10 changes: 5 additions & 5 deletions addons/sourcemod/gamedata/shavit.games.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{
"Offsets"
{
"GetPlayerMaxSpeed"
"CCSPlayer::GetPlayerMaxSpeed"
{
"windows" "438"
"linux" "439"
Expand All @@ -17,11 +17,11 @@
{
"Offsets"
{
"GetPlayerMaxSpeed"
"CCSPlayer::GetPlayerMaxSpeed"
{
"windows" "498"
"linux" "499"
"mac" "499"
"windows" "504"
"linux" "505"
"mac" "505"
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion addons/sourcemod/scripting/include/shavit.inc
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#endif
#define _shavit_included

#define SHAVIT_VERSION "2.3.4"
#define SHAVIT_VERSION "2.3.5"
#define STYLE_LIMIT 256
#define MAX_ZONES 64
#define MAX_NAME_LENGTH_SQL 32
Expand Down
33 changes: 20 additions & 13 deletions addons/sourcemod/scripting/shavit-chat.sp
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,16 @@ public Action OnClientSayCommand(int client, const char[] command, const char[]
return Plugin_Continue;
}

void ReplaceFormats(char[] formatting, int maxlen, char[] name, char[] colon, char[] text)
{
FormatColors(formatting, maxlen, true, false);
FormatRandom(formatting, maxlen);
ReplaceString(formatting, maxlen, "{name}", name);
ReplaceString(formatting, maxlen, "{def}", "\x01");
ReplaceString(formatting, maxlen, "{colon}", colon);
ReplaceString(formatting, maxlen, "{msg}", text);
}

public Action Hook_SayText2(UserMsg msg_id, any msg, const int[] players, int playersNum, bool reliable, bool init)
{
int client = 0;
Expand Down Expand Up @@ -433,10 +443,7 @@ public Action Hook_SayText2(UserMsg msg_id, any msg, const int[] players, int pl
}
}

ReplaceString(sTextFormatting, MAXLENGTH_BUFFER, "{name}", sOriginalName);
ReplaceString(sTextFormatting, MAXLENGTH_BUFFER, "{def}", "\x01");
ReplaceString(sTextFormatting, MAXLENGTH_BUFFER, "{colon}", gS_Colon);
ReplaceString(sTextFormatting, MAXLENGTH_BUFFER, "{msg}", sOriginalText);
ReplaceFormats(sTextFormatting, MAXLENGTH_BUFFER, sName, gS_Colon, sOriginalText);

DataPack pack = new DataPack();
pack.WriteCell(GetClientSerial(client)); // client serial
Expand Down Expand Up @@ -1042,13 +1049,9 @@ void PreviewChat(int client, int rank)
FormatChat(client, sCMessage, MAXLENGTH_CMESSAGE);

char sSampleText[MAXLENGTH_MESSAGE];
strcopy(sSampleText, MAXLENGTH_MESSAGE, "The quick brown fox jumps over the lazy dog");
Format(sSampleText, MAXLENGTH_MESSAGE, "%s%s", sCMessage, sSampleText);
FormatEx(sSampleText, MAXLENGTH_MESSAGE, "%sThe quick brown fox jumps over the lazy dog", sCMessage);

ReplaceString(sTextFormatting, MAXLENGTH_BUFFER, "{name}", sOriginalName);
ReplaceString(sTextFormatting, MAXLENGTH_BUFFER, "{def}", "\x01");
ReplaceString(sTextFormatting, MAXLENGTH_BUFFER, "{colon}", gS_Colon);
ReplaceString(sTextFormatting, MAXLENGTH_BUFFER, "{msg}", sSampleText);
ReplaceFormats(sTextFormatting, MAXLENGTH_BUFFER, sName, gS_Colon, sSampleText);

Handle hSayText2 = StartMessageOne("SayText2", client, USERMSG_RELIABLE|USERMSG_BLOCKHOOKS);

Expand Down Expand Up @@ -1266,10 +1269,8 @@ void FormatColors(char[] buffer, int size, bool colors, bool escape)
}
}

void FormatChat(int client, char[] buffer, int size)
void FormatRandom(char[] buffer, int size)
{
FormatColors(buffer, size, true, true);

char temp[8];

do
Expand All @@ -1290,6 +1291,12 @@ void FormatChat(int client, char[] buffer, int size)
}

while(ReplaceStringEx(buffer, size, "{rand}", temp) > 0);
}

void FormatChat(int client, char[] buffer, int size)
{
FormatColors(buffer, size, true, true);
FormatRandom(buffer, size);

if(gEV_Type != Engine_TF2)
{
Expand Down
31 changes: 17 additions & 14 deletions addons/sourcemod/scripting/shavit-misc.sp
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,8 @@ public void OnPluginStart()
RegConsoleCmd("sm_tele", Command_Tele, "Teleports to checkpoint. Usage: sm_tele [number]");
gH_CheckpointsCookie = RegClientCookie("shavit_checkpoints", "Checkpoints settings", CookieAccess_Protected);
gSM_Checkpoints = new StringMap();
gA_Targetnames = new ArrayList(ByteCountToCells(32));
gA_Classnames = new ArrayList(ByteCountToCells(32));
gA_Targetnames = new ArrayList(ByteCountToCells(64));
gA_Classnames = new ArrayList(ByteCountToCells(64));

gI_Ammo = FindSendPropInfo("CCSPlayer", "m_iAmmo");

Expand Down Expand Up @@ -380,16 +380,16 @@ public void OnPluginStart()

if(hGameData != null)
{
int iOffset = GameConfGetOffset(hGameData, "GetPlayerMaxSpeed");
int iOffset = GameConfGetOffset(hGameData, "CCSPlayer::GetPlayerMaxSpeed");

if(iOffset != -1)
{
gH_GetPlayerMaxSpeed = DHookCreate(iOffset, HookType_Entity, ReturnType_Float, ThisPointer_CBaseEntity, DHook_GetPlayerMaxSpeed);
gH_GetPlayerMaxSpeed = DHookCreate(iOffset, HookType_Entity, ReturnType_Float, ThisPointer_CBaseEntity, CCSPlayer__GetPlayerMaxSpeed);
}

else
{
SetFailState("Couldn't get the offset for \"GetPlayerMaxSpeed\" - make sure your gamedata is updated!");
SetFailState("Couldn't get the offset for \"CCSPlayer::GetPlayerMaxSpeed\" - make sure your gamedata is updated!");
}
}

Expand Down Expand Up @@ -798,7 +798,7 @@ public Action Command_Radio(int client, const char[] command, int args)
return Plugin_Continue;
}

public MRESReturn DHook_GetPlayerMaxSpeed(int pThis, Handle hReturn)
public MRESReturn CCSPlayer__GetPlayerMaxSpeed(int pThis, Handle hReturn)
{
if(!gB_StaticPrestrafe || !IsValidClient(pThis, true))
{
Expand Down Expand Up @@ -1810,8 +1810,8 @@ bool SaveCheckpoint(int client, int index, bool overflow = false)
GetEntPropVector(target, Prop_Data, "m_vecAbsVelocity", temp);
CopyArray(temp, cpcache[fCPVelocity], 3);

char sTargetname[32];
GetEntPropString(target, Prop_Data, "m_iName", sTargetname, 32);
char sTargetname[64];
GetEntPropString(target, Prop_Data, "m_iName", sTargetname, 64);

int iTargetname = gA_Targetnames.FindString(sTargetname);

Expand All @@ -1820,8 +1820,8 @@ bool SaveCheckpoint(int client, int index, bool overflow = false)
iTargetname = gA_Targetnames.PushString(sTargetname);
}

char sClassname[32];
GetEntityClassname(target, sClassname, 32);
char sClassname[64];
GetEntityClassname(target, sClassname, 64);

int iClassname = gA_Classnames.FindString(sClassname);

Expand All @@ -1830,6 +1830,8 @@ bool SaveCheckpoint(int client, int index, bool overflow = false)
iClassname = gA_Classnames.PushString(sClassname);
}

cpcache[iCPTargetname] = iTargetname;
cpcache[iCPClassname] = iClassname;
cpcache[mtCPMoveType] = GetEntityMoveType(target);
cpcache[fCPGravity] = GetEntityGravity(target);
cpcache[fCPSpeed] = GetEntPropFloat(target, Prop_Send, "m_flLaggedMovementValue");
Expand Down Expand Up @@ -2036,8 +2038,8 @@ void TeleportToCheckpoint(int client, int index, bool suppressMessage)

if(iTargetname != -1)
{
char sTargetname[32];
gA_Targetnames.GetString(iTargetname, sTargetname, 32);
char sTargetname[64];
gA_Targetnames.GetString(iTargetname, sTargetname, 64);

SetEntPropString(client, Prop_Data, "m_iName", sTargetname);
}
Expand All @@ -2046,8 +2048,8 @@ void TeleportToCheckpoint(int client, int index, bool suppressMessage)

if(iClassname != -1)
{
char sClassname[32];
gA_Classnames.GetString(iClassname, sClassname, 32);
char sClassname[64];
gA_Classnames.GetString(iClassname, sClassname, 64);

SetEntPropString(client, Prop_Data, "m_iClassname", sClassname);
}
Expand Down Expand Up @@ -2259,6 +2261,7 @@ public Action Shavit_OnStart(int client)
if(gB_ResetTargetname || Shavit_IsPracticeMode(client)) // practice mode can be abused to break map triggers
{
DispatchKeyValue(client, "targetname", "");
SetEntPropString(client, Prop_Data, "m_iClassname", "player");
}

return Plugin_Continue;
Expand Down
12 changes: 6 additions & 6 deletions addons/sourcemod/scripting/shavit-stats.sp
Original file line number Diff line number Diff line change
Expand Up @@ -378,19 +378,19 @@ Action OpenStatsMenu(int client, const char[] authid)
if(gB_Rankings)
{
FormatEx(sQuery, 2048, "SELECT a.clears, b.maps, c.wrs, d.name, d.country, d.lastlogin, d.points, e.rank FROM " ...
"(SELECT COUNT(*) clears FROM (SELECT id FROM %splayertimes WHERE auth = '%s' AND track = 0 GROUP BY map, id) s) a " ...
"JOIN (SELECT COUNT(*) maps FROM (SELECT id FROM %smapzones WHERE track = 0 GROUP BY map, id) s) b " ...
"(SELECT COUNT(*) clears FROM (SELECT id FROM %splayertimes WHERE auth = '%s' AND track = 0 GROUP BY map) s) a " ...
"JOIN (SELECT COUNT(*) maps FROM (SELECT id FROM %smapzones WHERE track = 0 AND type = 0 GROUP BY map) s) b " ...
"JOIN (SELECT COUNT(*) wrs FROM %splayertimes a JOIN (SELECT MIN(time) time FROM %splayertimes WHERE style = 0 AND track = 0 GROUP by map) b ON a.time = b.time WHERE auth = '%s') c " ...
"JOIN (SELECT name, country, lastlogin, FORMAT(points, 2) points FROM %susers WHERE auth = '%s' LIMIT 1) d " ...
"JOIN (SELECT FORMAT(COUNT(*), 0) rank FROM %susers WHERE points >= (SELECT points FROM %susers WHERE auth = '%s' LIMIT 1) GROUP BY points ORDER BY points DESC LIMIT 1) e " ...
"JOIN (SELECT FORMAT(COUNT(*), 0) rank FROM %susers WHERE points >= (SELECT points FROM %susers WHERE auth = '%s' LIMIT 1) ORDER BY points DESC) e " ...
"LIMIT 1;", gS_MySQLPrefix, authid, gS_MySQLPrefix, gS_MySQLPrefix, gS_MySQLPrefix, authid, gS_MySQLPrefix, authid, gS_MySQLPrefix, gS_MySQLPrefix, authid);
}

else
{
FormatEx(sQuery, 2048, "SELECT a.clears, b.maps, c.wrs, d.name, d.country, d.lastlogin FROM " ...
"(SELECT COUNT(*) clears FROM (SELECT id FROM %splayertimes WHERE auth = '%s' AND track = 0 GROUP BY map, id) s) a " ...
"JOIN (SELECT COUNT(*) maps FROM (SELECT id FROM %smapzones WHERE track = 0 GROUP BY map, id) s) b " ...
"(SELECT COUNT(*) clears FROM (SELECT id FROM %splayertimes WHERE auth = '%s' AND track = 0 GROUP BY map) s) a " ...
"JOIN (SELECT COUNT(*) maps FROM (SELECT id FROM %smapzones WHERE track = 0 AND type = 0 GROUP BY map) s) b " ...
"JOIN (SELECT COUNT(*) wrs FROM %splayertimes a JOIN (SELECT MIN(time) time FROM %splayertimes WHERE style = 0 AND track = 0 GROUP by map) b ON a.time = b.time WHERE auth = '%s') c " ...
"JOIN (SELECT name, country, lastlogin FROM %susers WHERE auth = '%s' LIMIT 1) d " ...
"LIMIT 1;", gS_MySQLPrefix, authid, gS_MySQLPrefix, gS_MySQLPrefix, gS_MySQLPrefix, authid, gS_MySQLPrefix, authid);
Expand Down Expand Up @@ -600,7 +600,7 @@ void ShowMaps(int client)

if(gI_MapType[client] == MAPSDONE)
{
FormatEx(sQuery, 512, "SELECT a.map, a.time, a.jumps, a.id, COUNT(b.map) + 1 rank, a.points FROM %splayertimes a LEFT JOIN %splayertimes b ON a.time > b.time AND a.map = b.map AND a.style = b.style AND a.track = b.track WHERE a.auth = '%s' AND a.style = %d AND a.track = %d GROUP BY a.map, a.time, a.jumps, a.id, a.points ORDER BY a.%s;", gS_MySQLPrefix, gS_MySQLPrefix, gS_TargetAuth[client], gBS_Style[client], gI_Track[client], (gB_Rankings)? "points DESC":"map");
FormatEx(sQuery, 512, "SELECT a.map, a.time, a.jumps, a.id, COUNT(b.map) + 1 rank, a.points FROM %splayertimes a LEFT JOIN %splayertimes b ON a.time > b.time AND a.map = b.map AND a.style = b.style AND a.track = b.track WHERE a.auth = '%s' AND a.style = %d AND a.track = %d GROUP BY a.map ORDER BY a.%s;", gS_MySQLPrefix, gS_MySQLPrefix, gS_TargetAuth[client], gBS_Style[client], gI_Track[client], (gB_Rankings)? "points DESC":"map");
}

else
Expand Down
2 changes: 1 addition & 1 deletion addons/sourcemod/scripting/shavit-wr.sp
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,7 @@ void UpdateWRCache()

if(gB_MySQL)
{
FormatEx(sQuery, 512, "SELECT p.style, p.id, TRUNCATE(LEAST(s.time, p.time), 3), u.name, p.track FROM %splayertimes p JOIN(SELECT style, MIN(time) time, map, track FROM %splayertimes WHERE map = '%s' GROUP BY style, track, map ORDER BY date ASC) s ON p.style = s.style AND p.time = s.time AND p.map = s.map JOIN %susers u ON p.auth = u.auth GROUP BY p.style, p.track, p.id, p.time, s.time, u.name ORDER BY date ASC;", gS_MySQLPrefix, gS_MySQLPrefix, gS_Map, gS_MySQLPrefix);
FormatEx(sQuery, 512, "SELECT p.style, p.id, TRUNCATE(LEAST(s.time, p.time), 3), u.name, p.track FROM %splayertimes p JOIN(SELECT style, MIN(time) time, map, track FROM %splayertimes WHERE map = '%s' GROUP BY style, track ORDER BY date ASC) s ON p.style = s.style AND p.time = s.time AND p.map = s.map JOIN %susers u ON p.auth = u.auth GROUP BY p.style, p.track ORDER BY date ASC;", gS_MySQLPrefix, gS_MySQLPrefix, gS_Map, gS_MySQLPrefix);
}

// sorry, LEAST() isn't available for SQLITE!
Expand Down

0 comments on commit f527455

Please sign in to comment.