Skip to content

Commit

Permalink
Add spawnbug, clean up mapcrashfix
Browse files Browse the repository at this point in the history
* Spawnbug disables a function that allows CTs to spawn in T zones
* Removed logging from mapcrashfix
  • Loading branch information
Mooshua committed Jul 4, 2023
1 parent 22be534 commit 2afa119
Show file tree
Hide file tree
Showing 5 changed files with 120 additions and 12 deletions.
35 changes: 35 additions & 0 deletions gamedata/sourceforks_ghostknife.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
"Games"
{
"csgo"
{
"Functions"
{
"CGameUI::Deactivate"
{
"signature" "CKnife::Swing"
"callconv" "thiscall"
"return" "void"
"this" "entity"
"hooktype" "raw"

"arguments"
{
"mode"
{
"type" "int"
}
}
}
}
"Signatures"
{
"CKnife::Swing"
{
// "Weapon_Knife.Hit" "Weapon_Knife.HitWall" "Player.GhostKnifeHit" "KnifeSlash"
// NOT the precache function.
"library" "server"

}
}
}
}
36 changes: 36 additions & 0 deletions gamedata/sourceforks_spawnbug.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
"Games"
{
"csgo"
{
"Keys"
{
// How many bytes to no-op.
// Note we are patching a ret so this value really doesn't matter
"SpawnbugSize"
{
"windows" "10"
"linux" "10"
}
}

"Addresses"
{
"Spawnbug"
{
"signature" "CCSPlayer::GoToViewControl"
}
}

"Signatures"
{
"CCSPlayer::GoToViewControl"
{
// "info_player_terrorist" and "point_viewcontrol"
// This should be a method that looks up both of those entity classnames.
"library" "server"
"windows" "\x55\x8B\xEC\x83\xE4\xF8\x83\xEC\x34\x53\x56\x8B\xF1\x57\x8B\x8E\xA4\x1B\x00\x00"
"linux" "\x55\x31\xC9\x89\xE5\x57\x56\x53\x83\xEC\x4C\x8B\x5D\x08"
}
}
}
}
13 changes: 13 additions & 0 deletions src/scripting/include/asm_x86.sp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,19 @@ enum JSHORT
JSHORT_GE = JSHORT_NL,
};

enum RET
{
// Return, deconstruct stack frame
// Should almost always use RET_NEAR.
RET_NEAR = 0xC3,
RET_FAR = 0xCB,

// Return, pop values, THEN deconstruct stack frame.
// Has IMM16 value of bytes to pop.
RET_NPOP = 0xC2,
RET_FPOP = 0xCA
};

enum PREFIX
{
PREFIX_OPERAND = 0x66,
Expand Down
12 changes: 0 additions & 12 deletions src/scripting/sourceforks_mapcrashfix.sp
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,6 @@ public MRESReturn GameUIDeactivate(int self, DHookParam params)
// Get the player entity
int player = GetEntPropEnt(self, Prop_Data, "m_player");

#if DEBUG
PrintToServer("CGameUI::Deactivate - Player (%d)", player);
#endif

// Is the player still valid/in game?
// If so, handle some funky logic
if (player != -1)
Expand All @@ -76,10 +72,6 @@ public MRESReturn GameUIDeactivate(int self, DHookParam params)
// Remove the frozen flag from the player
int old_flags = GetEntProp(player, Prop_Data, "m_fFlags");

#if DEBUG
PrintToServer("CGameUI::Deactivate - Unfreezing");
#endif

SetEntProp(player, Prop_Data, "m_fFlags", old_flags & (~FLAG_FROZEN));
}

Expand All @@ -92,10 +84,6 @@ public MRESReturn GameUIDeactivate(int self, DHookParam params)

SetEntProp(player, Prop_Send, "m_iHideHUD", old_flags & (~HIDE_HUD_FLAG));

#if DEBUG
PrintToServer("CGameUI::Deactivate - Re-Weaponing (%d)", old_weapon);
#endif

if (old_weapon != -1)
EquipPlayerWeapon(player, old_weapon);
}
Expand Down
36 changes: 36 additions & 0 deletions src/scripting/sourceforks_spawnbug.sp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#include <sourcemod>
#include "asm_patch.sp"
#include "sourceforks_version.sp"

public Plugin myinfo = {
name = "[SourceForks] [CSGO] Spawn Bug Fix",
author = "EdgeGamers Development",
description = "Patches an issue where players are able to spawn in enemy spawn zones.",
version = PLUGIN_VERSION,
url = PLUGIN_WEBSITE
}

#define GAMEDATA_FILE "sourceforks_spawnbug"

GameData Config;

public OnPluginStart()
{
PatchInit();

Config = LoadGameConfigFile(GAMEDATA_FILE);

if (GetEngineVersion() != Engine_CSGO)
SetFailState("This plugin is only compatible with CS:GO.");

PatchCommand("noop_spawnbug");

// Just disable the whole thing
any spawnbug_patch[] = { RET_NEAR };
PatchFunction(Config, "Spawnbug", "SpawnbugSize", spawnbug_patch, sizeof(spawnbug_patch));
}

public OnPluginEnd()
{
RecoverFunction(Config, "Spawnbug", "SpawnbugSize");
}

0 comments on commit 2afa119

Please sign in to comment.