Skip to content

Commit

Permalink
adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
Vauff committed Dec 5, 2024
1 parent a4be389 commit 87b605c
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 46 deletions.
2 changes: 1 addition & 1 deletion CS2Fixes.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="buttonwatch.cpp" />
<ClCompile Include="src\buttonwatch.cpp" />
<ClCompile Include="protobuf\generated\cs_usercmd.pb.cc" />
<ClCompile Include="protobuf\generated\networkbasetypes.pb.cc" />
<ClCompile Include="protobuf\generated\network_connection.pb.cc" />
Expand Down
2 changes: 1 addition & 1 deletion CS2Fixes.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@
<ClCompile Include="sdk\public\tier0\memoverride.cpp">
<Filter>Source Files\sdk</Filter>
</ClCompile>
<ClCompile Include="buttonwatch.cpp">
<ClCompile Include="src\buttonwatch.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion cfg/cs2fixes/cs2fixes.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -136,4 +136,4 @@ cs2f_idle_kick_min_players 0 // Minimum amount of connected clients to kick id
cs2f_idle_kick_admins 1 // Whether to kick idle players with ADMFLAG_GENERIC
// Button watch
cs2f_enable_button_watch 0 // CS# BREAKS IF THIS IS EVER ENABLED. Whether to enable button watch or not.
cs2f_enable_button_watch 0 // INCOMPATIBLE WITH CS#. Whether to enable button watch or not.
41 changes: 0 additions & 41 deletions src/adminsystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
#include "gamesystem.h"
#include "votemanager.h"
#include "map_votes.h"
#include "buttonwatch.h"
#include <vector>

extern IVEngineServer2 *g_pEngineServer2;
Expand Down Expand Up @@ -1127,46 +1126,6 @@ CON_COMMAND_CHAT_FLAGS(add_dc, "<name> <SteamID 64> <IP Address> - Adds a fake p
}
#endif

CON_COMMAND_CHAT_FLAGS(bw, "- Toggle button watch display", ADMFLAG_GENERIC)
{
if (!IsButtonWatchEnabled())
{
ClientPrint(player, HUD_PRINTTALK, CHAT_PREFIX "Button watch is disabled on this server.");
return;
}

if (!player)
{
ClientPrint(player, HUD_PRINTTALK, CHAT_PREFIX "You cannot use this command from the server console.");
return;
}

ZEPlayer* zpPlayer = player->GetZEPlayer();
if (!zpPlayer)
{
ClientPrint(player, HUD_PRINTTALK, CHAT_PREFIX "Something went wrong, please wait a moment before trying this command again.");
return;
}

zpPlayer->CycleButtonWatch();

switch (zpPlayer->GetButtonWatchMode())
{
case 0:
ClientPrint(player, HUD_PRINTTALK, CHAT_PREFIX "You have\x02 disabled\1 button watch.");
break;
case 1:
ClientPrint(player, HUD_PRINTTALK, CHAT_PREFIX "You have\x04 enabled\1 button watch in chat.");
break;
case 2:
ClientPrint(player, HUD_PRINTTALK, CHAT_PREFIX "You have\x04 enabled\1 button watch in console.");
break;
case 3:
ClientPrint(player, HUD_PRINTTALK, CHAT_PREFIX "You have\x04 enabled\1 button watch in chat and console.");
break;
}
}

CAdminSystem::CAdminSystem()
{
LoadAdmins();
Expand Down
42 changes: 41 additions & 1 deletion src/buttonwatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#include "cs2fixes.h"
#include "commands.h"

CON_COMMAND_F(cs2f_enable_button_watch, "CS# BREAKS IF THIS IS EVER ENABLED. Whether to enable button watch or not.", FCVAR_LINKED_CONCOMMAND | FCVAR_SPONLY | FCVAR_PROTECTED)
CON_COMMAND_F(cs2f_enable_button_watch, "INCOMPATIBLE WITH CS#. Whether to enable button watch or not.", FCVAR_LINKED_CONCOMMAND | FCVAR_SPONLY | FCVAR_PROTECTED)
{
if (args.ArgC() < 2)
{
Expand All @@ -46,6 +46,46 @@ CON_COMMAND_F(cs2f_enable_button_watch, "CS# BREAKS IF THIS IS EVER ENABLED. Whe
mapIOFunctions["buttonwatch"] = ButtonWatch;
}

CON_COMMAND_CHAT_FLAGS(bw, "- Toggle button watch display", ADMFLAG_GENERIC)
{
if (!IsButtonWatchEnabled())
{
ClientPrint(player, HUD_PRINTTALK, CHAT_PREFIX "Button watch is disabled on this server.");
return;
}

if (!player)
{
ClientPrint(player, HUD_PRINTTALK, CHAT_PREFIX "You cannot use this command from the server console.");
return;
}

ZEPlayer* zpPlayer = player->GetZEPlayer();
if (!zpPlayer)
{
ClientPrint(player, HUD_PRINTTALK, CHAT_PREFIX "Something went wrong, please wait a moment before trying this command again.");
return;
}

zpPlayer->CycleButtonWatch();

switch (zpPlayer->GetButtonWatchMode())
{
case 0:
ClientPrint(player, HUD_PRINTTALK, CHAT_PREFIX "You have\x02 disabled\1 button watch.");
break;
case 1:
ClientPrint(player, HUD_PRINTTALK, CHAT_PREFIX "You have\x04 enabled\1 button watch in chat.");
break;
case 2:
ClientPrint(player, HUD_PRINTTALK, CHAT_PREFIX "You have\x04 enabled\1 button watch in console.");
break;
case 3:
ClientPrint(player, HUD_PRINTTALK, CHAT_PREFIX "You have\x04 enabled\1 button watch in chat and console.");
break;
}
}

bool IsButtonWatchEnabled()
{
return std::any_of(mapIOFunctions.begin(), mapIOFunctions.end(), [](const auto& p) {
Expand Down
2 changes: 1 addition & 1 deletion src/detours.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@ bool SetupFireOutputInternalDetour()
CEntityIOOutput_FireOutputInternal = new CDetour(Detour_CEntityIOOutput_FireOutputInternal, "CEntityIOOutput_FireOutputInternal");
if (!CEntityIOOutput_FireOutputInternal->CreateDetour(g_GameConfig))
{
Msg("Failed to detour CEntityIOOutput_FireOutputInternal\n");
Panic("Failed to detour CEntityIOOutput_FireOutputInternal\n");
delete CEntityIOOutput_FireOutputInternal;
CEntityIOOutput_FireOutputInternal = nullptr;
return false;
Expand Down

0 comments on commit 87b605c

Please sign in to comment.