Fix some stuff (including #167)

Fix insane CS:S lag; make spectator list/keys look proper in CS:S; fix
one bot not being set to what it should if there's sourcetv, don't
precache the unused zone model
This commit is contained in:
shavitush 2016-08-15 17:36:58 +03:00
parent aeb9c4b3fc
commit 0cc1963544
8 changed files with 91 additions and 45 deletions

View File

@ -3,7 +3,7 @@
[AlliedModders thread](https://forums.alliedmods.net/showthread.php?t=265456) [AlliedModders thread](https://forums.alliedmods.net/showthread.php?t=265456)
[Download](https://github.com/Shavitush/bhoptimer/releases) [Download](https://github.com/shavitush/bhoptimer/releases)
# shavit's simple bhop timer # shavit's simple bhop timer
a bhop server should be simple a bhop server should be simple
@ -56,7 +56,7 @@ a bhop server should be simple
2. Copy the desired .smx files to your plugins (addons/sourcemod/plugins) folder 2. Copy the desired .smx files to your plugins (addons/sourcemod/plugins) folder
2.1. Copy shavit.games.txt to /gamedata if you have DHooks installed. 2.1. Copy shavit.games.txt to /gamedata if you have DHooks installed.
3. Copy base.nav to the `maps` folder. 3. Copy base.nav to the `maps` folder.
4. Copy the files from the `sound` folder to the one on your server. Make sure to also have equivelant bz2 files on your FastDL server! 4. Copy the files from the `sound` folder to the one on your server. Make sure to also have equivalent bz2 files on your FastDL server!
4.1. Do the same for the `materials` folder. 4.1. Do the same for the `materials` folder.
5. Copy the `configs` file to your server and modify `shavit-sounds.cfg` if you wish to. 5. Copy the `configs` file to your server and modify `shavit-sounds.cfg` if you wish to.
5.1. Changing `shavit-prefix.txt` to contain your MySQL database prefix might be needed depending on your usage. 5.1. Changing `shavit-prefix.txt` to contain your MySQL database prefix might be needed depending on your usage.

View File

@ -754,9 +754,9 @@ public SharedPlugin __pl_shavit =
name = "shavit", name = "shavit",
file = "shavit-core.smx", file = "shavit-core.smx",
#if defined REQUIRE_PLUGIN #if defined REQUIRE_PLUGIN
required = 1, required = 1
#else #else
required = 0, required = 0
#endif #endif
}; };

View File

@ -82,7 +82,6 @@ bool gB_Late = false;
// modules // modules
bool gB_Zones = false; bool gB_Zones = false;
bool gB_HUD = false;
// cvars // cvars
ConVar gCV_Autobhop = null; ConVar gCV_Autobhop = null;
@ -254,7 +253,6 @@ public void OnPluginStart()
} }
gB_Zones = LibraryExists("shavit-zones"); gB_Zones = LibraryExists("shavit-zones");
gB_HUD = LibraryExists("shavit-hud");
} }
public void OnLibraryAdded(const char[] name) public void OnLibraryAdded(const char[] name)
@ -263,11 +261,6 @@ public void OnLibraryAdded(const char[] name)
{ {
gB_Zones = true; gB_Zones = true;
} }
else if(StrEqual(name, "shavit-hud"))
{
gB_HUD = true;
}
} }
public void OnLibraryRemoved(const char[] name) public void OnLibraryRemoved(const char[] name)
@ -276,11 +269,6 @@ public void OnLibraryRemoved(const char[] name)
{ {
gB_Zones = false; gB_Zones = false;
} }
else if(StrEqual(name, "shavit-hud"))
{
gB_HUD = false;
}
} }
public void OnAdminMenuReady(Handle topmenu) public void OnAdminMenuReady(Handle topmenu)
@ -1166,11 +1154,6 @@ public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3
buttons |= IN_JUMP; buttons |= IN_JUMP;
} }
if(gI_ButtonCache[client] != buttons && gB_HUD)
{
Shavit_ForceHUDUpdate(client, true);
}
// velocity limit // velocity limit
if(iGroundEntity != -1 && gI_StyleProperties[gBS_Style[client]] & STYLE_VEL_LIMIT && gF_VelocityLimit[gBS_Style[client]] != VELOCITY_UNLIMITED && (!gB_Zones || !Shavit_InsideZone(client, Zone_NoVelLimit))) if(iGroundEntity != -1 && gI_StyleProperties[gBS_Style[client]] & STYLE_VEL_LIMIT && gF_VelocityLimit[gBS_Style[client]] != VELOCITY_UNLIMITED && (!gB_Zones || !Shavit_InsideZone(client, Zone_NoVelLimit)))
{ {

View File

@ -308,9 +308,10 @@ public void TriggerHUDUpdate(int client)
{ {
UpdateTopLeftHUD(client, true); UpdateTopLeftHUD(client, true);
UpdateKeyHint(client); UpdateKeyHint(client);
UpdateCenterKeys(client);
} }
if((gI_HUDSettings[client] & HUD_KEYOVERLAY || gI_HUDSettings[client] & HUD_SPECTATORS) && (!gB_Zones || !Shavit_IsClientCreatingZone(client)) && (GetClientMenu(client, null) == MenuSource_None || GetClientMenu(client, null) == MenuSource_RawPanel)) else if((gI_HUDSettings[client] & HUD_KEYOVERLAY || gI_HUDSettings[client] & HUD_SPECTATORS) && (!gB_Zones || !Shavit_IsClientCreatingZone(client)) && (GetClientMenu(client, null) == MenuSource_None || GetClientMenu(client, null) == MenuSource_RawPanel))
{ {
bool bShouldDraw = false; bool bShouldDraw = false;
Panel pHUD = new Panel(); Panel pHUD = new Panel();
@ -576,6 +577,33 @@ public void UpdateKeyOverlay(int client, Panel panel, bool &draw)
draw = true; draw = true;
} }
public void UpdateCenterKeys(int client)
{
if(!(gI_HUDSettings[client] & HUD_KEYOVERLAY))
{
return;
}
int target = GetHUDTarget(client);
if((!(gI_HUDSettings[client] & HUD_OBSERVE) && client != target) || !IsValidClient(target) || IsClientObserver(target))
{
return;
}
int buttons = GetClientButtons(target);
if(gI_StyleProperties[Shavit_GetBhopStyle(target)] & STYLE_AUTOBHOP) // don't include [JUMP] for autobhop styles
{
PrintCenterText(client, "[%s]\n %s\n%s %s %s", buttons & IN_DUCK? "DUCK":"----", buttons & IN_FORWARD? "W":"-", buttons & IN_MOVELEFT? "A":"-", buttons & IN_BACK? "S":"-", buttons & IN_MOVERIGHT? "D":"-");
}
else
{
PrintCenterText(client, "[%s] [%s]\n %s\n%s %s %s", buttons & IN_JUMP? "JUMP":"----", buttons & IN_DUCK? "DUCK":"----", buttons & IN_FORWARD? "W":"-", buttons & IN_MOVELEFT? "A":"-", buttons & IN_BACK? "S":"-", buttons & IN_MOVERIGHT? "D":"-");
}
}
public void UpdateSpectatorList(int client, Panel panel, bool &draw) public void UpdateSpectatorList(int client, Panel panel, bool &draw)
{ {
if(!(gI_HUDSettings[client] & HUD_SPECTATORS)) if(!(gI_HUDSettings[client] & HUD_SPECTATORS))
@ -671,19 +699,62 @@ public void UpdateKeyHint(int client)
{ {
if(gI_Cycle % 10 == 0 && (gI_HUDSettings[client] & HUD_SYNC || gI_HUDSettings[client] & HUD_TIMELEFT)) if(gI_Cycle % 10 == 0 && (gI_HUDSettings[client] & HUD_SYNC || gI_HUDSettings[client] & HUD_TIMELEFT))
{ {
char[] sMessage = new char[128]; char[] sMessage = new char[256];
int iTimeLeft = -1; int iTimeLeft = -1;
if(gI_HUDSettings[client] & HUD_TIMELEFT && GetMapTimeLeft(iTimeLeft) && iTimeLeft > 0) if(gI_HUDSettings[client] & HUD_TIMELEFT && GetMapTimeLeft(iTimeLeft) && iTimeLeft > 0)
{ {
FormatEx(sMessage, 128, (iTimeLeft > 60)? "Time left: %d minutes":"Time left: <1 minute", (iTimeLeft / 60)); FormatEx(sMessage, 256, (iTimeLeft > 60)? "Time left: %d minutes":"Time left: <1 minute", (iTimeLeft / 60));
} }
int target = GetHUDTarget(client); int target = GetHUDTarget(client);
if(gI_HUDSettings[client] & HUD_SYNC && Shavit_GetTimerStatus(target) == Timer_Running && gI_StyleProperties[Shavit_GetBhopStyle(target)] & STYLE_MEASURESYNC && !IsFakeClient(target) && (!gB_Zones || !Shavit_InsideZone(target, Zone_Start))) if(IsValidClient(target) && (target == client || gI_HUDSettings[client] & HUD_OBSERVE))
{ {
Format(sMessage, 128, "%s%sSync: %.02f", sMessage, (strlen(sMessage) > 0)? "\n\n":"", Shavit_GetSync(target)); if(gI_HUDSettings[client] & HUD_SYNC && Shavit_GetTimerStatus(target) == Timer_Running && gI_StyleProperties[Shavit_GetBhopStyle(target)] & STYLE_MEASURESYNC && !IsFakeClient(target) && (!gB_Zones || !Shavit_InsideZone(target, Zone_Start)))
{
Format(sMessage, 256, "%s%sSync: %.02f", sMessage, (strlen(sMessage) > 0)? "\n\n":"", Shavit_GetSync(target));
}
if(gI_HUDSettings[client] & HUD_SPECTATORS)
{
int[] iSpectatorClients = new int[MaxClients];
int iSpectators = 0;
for(int i = 1; i <= MaxClients; i++)
{
if(i == client || !IsValidClient(i) || IsFakeClient(i) || !IsClientObserver(i) || GetEntPropEnt(i, Prop_Send, "m_hObserverTarget") != target)
{
continue;
}
int iObserverMode = GetEntProp(i, Prop_Send, "m_iObserverMode");
if(iObserverMode >= 3 && iObserverMode <= 5)
{
iSpectatorClients[iSpectators++] = i;
}
}
if(iSpectators > 0)
{
Format(sMessage, 256, "%s%s%spectators (%d):", sMessage, (strlen(sMessage) > 0)? "\n\n":"", (client == target)? "S":"Other s", iSpectators);
for(int i = 0; i < iSpectators; i++)
{
if(i == 7)
{
Format(sMessage, 256, "%s\n...", sMessage);
break;
}
char[] sName = new char[gI_NameLength];
GetClientName(iSpectatorClients[i], sName, gI_NameLength);
Format(sMessage, 256, "%s\n%s", sMessage, sName);
}
}
}
} }
if(strlen(sMessage) > 0) if(strlen(sMessage) > 0)

View File

@ -969,8 +969,6 @@ public void SQL_DBConnect()
} }
} }
OnMapStart();
char[] sDriver = new char[8]; char[] sDriver = new char[8];
gH_SQL.Driver.GetIdentifier(sDriver, 8); gH_SQL.Driver.GetIdentifier(sDriver, 8);
gB_MySQL = StrEqual(sDriver, "mysql", false); gB_MySQL = StrEqual(sDriver, "mysql", false);

View File

@ -433,6 +433,11 @@ public bool DeleteReplay(BhopStyle style)
public void OnClientPutInServer(int client) public void OnClientPutInServer(int client)
{ {
if(IsClientSourceTV(client))
{
return;
}
if(!IsFakeClient(client)) if(!IsFakeClient(client))
{ {
gA_PlayerFrames[client] = new ArrayList(5); gA_PlayerFrames[client] = new ArrayList(5);

View File

@ -391,38 +391,27 @@ public void SQL_UpdateWRCache_Callback(Database db, DBResultSet results, const c
public int Native_GetWRTime(Handle handler, int numParams) public int Native_GetWRTime(Handle handler, int numParams)
{ {
BhopStyle style = GetNativeCell(1); SetNativeCellRef(2, gF_WRTime[GetNativeCell(1)]);
SetNativeCellRef(2, gF_WRTime[style]);
} }
public int Native_GetWRRecordID(Handle handler, int numParams) public int Native_GetWRRecordID(Handle handler, int numParams)
{ {
BhopStyle style = GetNativeCell(1); SetNativeCellRef(2, gI_WRRecordID[GetNativeCell(1)]);
SetNativeCellRef(2, gI_WRRecordID[style]);
} }
public int Native_GetWRName(Handle handler, int numParams) public int Native_GetWRName(Handle handler, int numParams)
{ {
BhopStyle style = GetNativeCell(1); SetNativeString(2, gS_WRName[GetNativeCell(1)], GetNativeCell(3));
int maxlength = GetNativeCell(3);
SetNativeString(2, gS_WRName[style], maxlength);
} }
public int Native_GetPlayerPB(Handle handler, int numParams) public int Native_GetPlayerPB(Handle handler, int numParams)
{ {
int client = GetNativeCell(1); SetNativeCellRef(3, gF_PlayerRecord[GetNativeCell(1)][GetNativeCell(2)]);
BhopStyle style = GetNativeCell(2);
SetNativeCellRef(3, gF_PlayerRecord[client][style]);
} }
public int Native_GetRankForTime(Handle handler, int numParams) public int Native_GetRankForTime(Handle handler, int numParams)
{ {
BhopStyle style = GetNativeCell(1); return GetRankForTime(GetNativeCell(1), GetNativeCell(2));
float time = GetNativeCell(2);
return GetRankForTime(style, time);
} }
#if defined DEBUG #if defined DEBUG

View File

@ -397,7 +397,7 @@ public void OnMapStart()
} }
} }
PrecacheModel("models/props/cs_office/vending_machine.mdl"); // placeholder model // PrecacheModel("models/props/cs_office/vending_machine.mdl"); // placeholder model
// draw // draw
// start drawing mapzones here // start drawing mapzones here