Compare commits

...

5 Commits
v1.0.52 ... v57

Author SHA1 Message Date
Roflmuffin
15e1260146 feat: update schema from 17.11.23 update 2023-11-19 09:44:15 +10:00
Roflmuffin
517607d962 fix: chat command config prefixes 2023-11-18 15:40:02 +10:00
Boink
0f72631eb0 Update CommitSuicide offset for 17-11-2023 update (#98) 2023-11-18 09:43:06 +10:00
Nexd
75fcf21fb7 feat: managed coreconfig implementation (#79) 2023-11-17 17:50:59 +10:00
Nexd
0ddf6bcdfa fix: new signature for CBaseModelEntity_SetModel (#84) 2023-11-15 15:18:03 +10:00
17 changed files with 418 additions and 23 deletions

View File

@@ -29,6 +29,8 @@ SET(SOURCE_FILES
src/core/utils.h
src/core/globals.h
src/core/globals.cpp
src/core/coreconfig.h
src/core/coreconfig.cpp
src/core/gameconfig.h
src/core/gameconfig.cpp
src/core/log.h
@@ -84,7 +86,7 @@ SET(SOURCE_FILES
if (LINUX)
# memoverride.cpp is not usable on CMake Windows, cuz CMake default link libraries (seems) always link ucrt.lib
set(SOURCE_FILES
set(SOURCE_FILES
${SOURCE_FILES}
libraries/hl2sdk-cs2/public/tier0/memoverride.cpp
)

View File

@@ -1,5 +1,5 @@
{
"PublicChatTrigger": "!",
"SilentChatTrigger": "/",
"PublicChatTrigger": [ "!" ],
"SilentChatTrigger": [ "/" ],
"FollowCS2ServerGuidelines": true
}

View File

@@ -50,14 +50,14 @@
"CBaseModelEntity_SetModel": {
"signatures": {
"library": "server",
"windows": "\\x48\\x89\\x5C\\x24\\x2A\\x48\\x89\\x7C\\x24\\x2A\\x55\\x48\\x8B\\xEC\\x48\\x83\\xEC\\x50\\x48\\x8B\\xF9",
"linux": "\\x55\\x48\\x89\\xF2\\x48\\x89\\xE5\\x41\\x54\\x49\\x89\\xFC\\x48\\x8D\\x7D\\xE0\\x48\\x83\\xEC\\x18\\x48\\x8D\\x05\\xE5\\xD1\\xBF\\x00"
"windows": "\\x48\\x89\\x5C\\x24\\x10\\x48\\x89\\x7C\\x24\\x20\\x55\\x48\\x8B\\xEC\\x48\\x83\\xEC\\x50\\x48\\x8B\\xF9\\x4C\\x8B\\xC2\\x48\\x8B\\x0D\\x69\\x07\\xD9\\x00",
"linux": "\\x55\\x48\\x89\\xF2\\x48\\x89\\xE5\\x41\\x54\\x49\\x89\\xFC\\x48\\x8D\\x7D\\xE0\\x48\\x83\\xEC\\x18\\x48\\x8D\\x05\\x15\\xD4\\xBF\\x00"
}
},
"CBasePlayerPawn_CommitSuicide": {
"offsets": {
"windows": 355,
"linux": 355
"windows": 356,
"linux": 356
}
},
"CBaseEntity_Teleport": {

View File

@@ -23,6 +23,7 @@ using System.Text.Json.Serialization;
using CounterStrikeSharp.API.Modules.Utils;
using CounterStrikeSharp.API.Modules.Admin;
using CounterStrikeSharp.API.Modules.Commands;
using System.Collections.Generic;
namespace CounterStrikeSharp.API.Core
{
@@ -31,9 +32,9 @@ namespace CounterStrikeSharp.API.Core
/// </summary>
internal sealed partial class CoreConfigData
{
[JsonPropertyName("PublicChatTrigger")] public string PublicChatTrigger { get; set; } = "!";
[JsonPropertyName("PublicChatTrigger")] public IEnumerable<string> PublicChatTrigger { get; set; } = new HashSet<string>() { "!" };
[JsonPropertyName("SilentChatTrigger")] public string SilentChatTrigger { get; set; } = "/";
[JsonPropertyName("SilentChatTrigger")] public IEnumerable<string> SilentChatTrigger { get; set; } = new HashSet<string>() { "/" };
[JsonPropertyName("FollowCS2ServerGuidelines")] public bool FollowCS2ServerGuidelines { get; set; } = true;
}
@@ -46,12 +47,12 @@ namespace CounterStrikeSharp.API.Core
/// <summary>
/// List of characters to use for public chat triggers.
/// </summary>
public static string PublicChatTrigger => _coreConfig.PublicChatTrigger;
public static IEnumerable<string> PublicChatTrigger => _coreConfig.PublicChatTrigger;
/// <summary>
/// List of characters to use for silent chat triggers.
/// </summary>
public static string SilentChatTrigger => _coreConfig.SilentChatTrigger;
public static IEnumerable<string> SilentChatTrigger => _coreConfig.SilentChatTrigger;
/// <summary>
/// <para>

View File

@@ -355,6 +355,13 @@ public enum BrushSolidities_e : uint
BRUSHSOLID_ALWAYS = 0x2,
}
public enum C4LightEffect_t : uint
{
eLightEffectNone = 0x0,
eLightEffectDropped = 0x1,
eLightEffectThirdPersonHeld = 0x2,
}
public enum CAnimationGraphVisualizerPrimitiveType : uint
{
ANIMATIONGRAPHVISUALIZERPRIMITIVETYPE_Text = 0x0,
@@ -2773,6 +2780,7 @@ public enum TakeDamageFlags_t : uint
DFLAG_RADIUS_DMG = 0x400,
DMG_LASTDFLAG = 0x400,
DFLAG_IGNORE_ARMOR = 0x800,
DFLAG_SUPPRESS_UTILREMOVE = 0x1000,
}
public enum TextureRepetitionMode_t : uint
@@ -3927,6 +3935,9 @@ public partial class CBaseCSGrenadeProjectile : CBaseGrenade
{
public CBaseCSGrenadeProjectile (IntPtr pointer) : base(pointer) {}
// m_vInitialPosition
public Vector InitialPosition => Schema.GetDeclaredClass<Vector>(this.Handle, "CBaseCSGrenadeProjectile", "m_vInitialPosition");
// m_vInitialVelocity
public Vector InitialVelocity => Schema.GetDeclaredClass<Vector>(this.Handle, "CBaseCSGrenadeProjectile", "m_vInitialVelocity");
@@ -3972,6 +3983,12 @@ public partial class CBaseCSGrenadeProjectile : CBaseGrenade
// m_nTicksAtZeroVelocity
public ref Int32 TicksAtZeroVelocity => ref Schema.GetRef<Int32>(this.Handle, "CBaseCSGrenadeProjectile", "m_nTicksAtZeroVelocity");
// m_bHasEverHitPlayer
public ref bool HasEverHitPlayer => ref Schema.GetRef<bool>(this.Handle, "CBaseCSGrenadeProjectile", "m_bHasEverHitPlayer");
// m_bClearFromPlayers
public ref bool ClearFromPlayers => ref Schema.GetRef<bool>(this.Handle, "CBaseCSGrenadeProjectile", "m_bClearFromPlayers");
}
public partial class CBaseDMStart : CPointEntity
@@ -7099,8 +7116,8 @@ public partial class CCSGameRules : CTeamplayRules
// m_nShorthandedBonusLastEvalRound
public ref Int32 ShorthandedBonusLastEvalRound => ref Schema.GetRef<Int32>(this.Handle, "CCSGameRules", "m_nShorthandedBonusLastEvalRound");
// m_bMatchAbortedDueToPlayerBan
public ref bool MatchAbortedDueToPlayerBan => ref Schema.GetRef<bool>(this.Handle, "CCSGameRules", "m_bMatchAbortedDueToPlayerBan");
// m_nMatchAbortedEarlyReason
public ref Int32 MatchAbortedEarlyReason => ref Schema.GetRef<Int32>(this.Handle, "CCSGameRules", "m_nMatchAbortedEarlyReason");
// m_bHasTriggeredRoundStartMusic
public ref bool HasTriggeredRoundStartMusic => ref Schema.GetRef<bool>(this.Handle, "CCSGameRules", "m_bHasTriggeredRoundStartMusic");
@@ -7515,6 +7532,12 @@ public partial class CCSPlayer_MovementServices : CPlayer_MovementServices_Human
// m_flStamina
public ref float Stamina => ref Schema.GetRef<float>(this.Handle, "CCSPlayer_MovementServices", "m_flStamina");
// m_flHeightAtJumpStart
public ref float HeightAtJumpStart => ref Schema.GetRef<float>(this.Handle, "CCSPlayer_MovementServices", "m_flHeightAtJumpStart");
// m_flMaxJumpHeightThisJump
public ref float MaxJumpHeightThisJump => ref Schema.GetRef<float>(this.Handle, "CCSPlayer_MovementServices", "m_flMaxJumpHeightThisJump");
}
public partial class CCSPlayer_PingServices : CPlayerPawnComponent
@@ -7792,6 +7815,9 @@ public partial class CCSPlayerController : CBasePlayerController
// m_uiAbandonRecordedReason
public ref UInt32 UiAbandonRecordedReason => ref Schema.GetRef<UInt32>(this.Handle, "CCSPlayerController", "m_uiAbandonRecordedReason");
// m_bCannotBeKicked
public ref bool CannotBeKicked => ref Schema.GetRef<bool>(this.Handle, "CCSPlayerController", "m_bCannotBeKicked");
// m_bEverFullyConnected
public ref bool EverFullyConnected => ref Schema.GetRef<bool>(this.Handle, "CCSPlayerController", "m_bEverFullyConnected");
@@ -7909,9 +7935,15 @@ public partial class CCSPlayerController : CBasePlayerController
// m_bGaveTeamDamageWarningThisRound
public ref bool GaveTeamDamageWarningThisRound => ref Schema.GetRef<bool>(this.Handle, "CCSPlayerController", "m_bGaveTeamDamageWarningThisRound");
// m_dblLastReceivedPacketPlatFloatTime
public ref double DblLastReceivedPacketPlatFloatTime => ref Schema.GetRef<double>(this.Handle, "CCSPlayerController", "m_dblLastReceivedPacketPlatFloatTime");
// m_LastTeamDamageWarningTime
public ref float LastTeamDamageWarningTime => ref Schema.GetRef<float>(this.Handle, "CCSPlayerController", "m_LastTeamDamageWarningTime");
// m_LastTimePlayerWasDisconnectedForPawnsRemove
public ref float LastTimePlayerWasDisconnectedForPawnsRemove => ref Schema.GetRef<float>(this.Handle, "CCSPlayerController", "m_LastTimePlayerWasDisconnectedForPawnsRemove");
}
public partial class CCSPlayerController_ActionTrackingServices : CPlayerControllerComponent
@@ -8046,6 +8078,9 @@ public partial class CCSPlayerPawn : CCSPlayerPawnBase
set { Schema.SetString(this.Handle, "CCSPlayerPawn", "m_szLastPlaceName", value); }
}
// m_bInHostageResetZone
public ref bool InHostageResetZone => ref Schema.GetRef<bool>(this.Handle, "CCSPlayerPawn", "m_bInHostageResetZone");
// m_bInBuyZone
public ref bool InBuyZone => ref Schema.GetRef<bool>(this.Handle, "CCSPlayerPawn", "m_bInBuyZone");
@@ -12825,6 +12860,9 @@ public partial class CHostage : CHostageExpresserShim
// m_vecSpawnGroundPos
public Vector SpawnGroundPos => Schema.GetDeclaredClass<Vector>(this.Handle, "CHostage", "m_vecSpawnGroundPos");
// m_vecHostageResetPosition
public Vector HostageResetPosition => Schema.GetDeclaredClass<Vector>(this.Handle, "CHostage", "m_vecHostageResetPosition");
}
public partial class CHostageAlias_info_hostage_spawn : CHostage
@@ -14153,6 +14191,28 @@ public partial class CLogicDistanceCheck : CLogicalEntity
}
public partial class CLogicEventListener : CLogicalEntity
{
public CLogicEventListener (IntPtr pointer) : base(pointer) {}
// m_strEventName
public string StrEventName
{
get { return Schema.GetUtf8String(this.Handle, "CLogicEventListener", "m_strEventName"); }
set { Schema.SetString(this.Handle, "CLogicEventListener", "m_strEventName", value); }
}
// m_bIsEnabled
public ref bool IsEnabled => ref Schema.GetRef<bool>(this.Handle, "CLogicEventListener", "m_bIsEnabled");
// m_nTeam
public ref Int32 Team => ref Schema.GetRef<Int32>(this.Handle, "CLogicEventListener", "m_nTeam");
// m_OnEventFired
public CEntityIOOutput OnEventFired => Schema.GetDeclaredClass<CEntityIOOutput>(this.Handle, "CLogicEventListener", "m_OnEventFired");
}
public partial class CLogicGameEvent : CLogicalEntity
{
public CLogicGameEvent (IntPtr pointer) : base(pointer) {}
@@ -20138,6 +20198,12 @@ public partial class CTriggerGravity : CBaseTrigger
}
public partial class CTriggerHostageReset : CBaseTrigger
{
public CTriggerHostageReset (IntPtr pointer) : base(pointer) {}
}
public partial class CTriggerHurt : CBaseTrigger
{
public CTriggerHurt (IntPtr pointer) : base(pointer) {}

View File

@@ -4855,6 +4855,14 @@
},
"CBaseCSGrenadeProjectile": {
"fields": [
{
"name": "m_vInitialPosition",
"type": {
"atomic": 0,
"category": 4,
"name": "Vector"
}
},
{
"name": "m_vInitialVelocity",
"type": {
@@ -4970,6 +4978,20 @@
"category": 0,
"name": "int32"
}
},
{
"name": "m_bHasEverHitPlayer",
"type": {
"category": 0,
"name": "bool"
}
},
{
"name": "m_bClearFromPlayers",
"type": {
"category": 0,
"name": "bool"
}
}
],
"parent": "CBaseGrenade"
@@ -13245,10 +13267,10 @@
}
},
{
"name": "m_bMatchAbortedDueToPlayerBan",
"name": "m_nMatchAbortedEarlyReason",
"type": {
"category": 0,
"name": "bool"
"name": "int32"
}
},
{
@@ -13828,6 +13850,13 @@
"name": "uint32"
}
},
{
"name": "m_bCannotBeKicked",
"type": {
"category": 0,
"name": "bool"
}
},
{
"name": "m_bEverFullyConnected",
"type": {
@@ -14125,12 +14154,26 @@
"name": "bool"
}
},
{
"name": "m_dblLastReceivedPacketPlatFloatTime",
"type": {
"category": 0,
"name": "float64"
}
},
{
"name": "m_LastTeamDamageWarningTime",
"type": {
"category": 5,
"name": "GameTime_t"
}
},
{
"name": "m_LastTimePlayerWasDisconnectedForPawnsRemove",
"type": {
"category": 5,
"name": "GameTime_t"
}
}
],
"parent": "CBasePlayerController"
@@ -14439,6 +14482,13 @@
"name": "char[18]"
}
},
{
"name": "m_bInHostageResetZone",
"type": {
"category": 0,
"name": "bool"
}
},
{
"name": "m_bInBuyZone",
"type": {
@@ -16244,6 +16294,20 @@
"category": 0,
"name": "float32"
}
},
{
"name": "m_flHeightAtJumpStart",
"type": {
"category": 0,
"name": "float32"
}
},
{
"name": "m_flMaxJumpHeightThisJump",
"type": {
"category": 0,
"name": "float32"
}
}
],
"parent": "CPlayer_MovementServices_Humanoid"
@@ -30081,6 +30145,14 @@
"category": 4,
"name": "Vector"
}
},
{
"name": "m_vecHostageResetPosition",
"type": {
"atomic": 0,
"category": 4,
"name": "Vector"
}
}
],
"parent": "CHostageExpresserShim"
@@ -32719,6 +32791,40 @@
],
"parent": "CLogicalEntity"
},
"CLogicEventListener": {
"fields": [
{
"name": "m_strEventName",
"type": {
"atomic": 0,
"category": 4,
"name": "CUtlString"
}
},
{
"name": "m_bIsEnabled",
"type": {
"category": 0,
"name": "bool"
}
},
{
"name": "m_nTeam",
"type": {
"category": 0,
"name": "int32"
}
},
{
"name": "m_OnEventFired",
"type": {
"category": 5,
"name": "CEntityIOOutput"
}
}
],
"parent": "CLogicalEntity"
},
"CLogicGameEvent": {
"fields": [
{
@@ -54460,6 +54566,10 @@
"fields": [],
"parent": "CBaseTrigger"
},
"CTriggerHostageReset": {
"fields": [],
"parent": "CBaseTrigger"
},
"CTriggerHurt": {
"fields": [
{
@@ -90276,6 +90386,23 @@
}
]
},
"C4LightEffect_t": {
"align": 4,
"items": [
{
"name": "eLightEffectNone",
"value": 0
},
{
"name": "eLightEffectDropped",
"value": 1
},
{
"name": "eLightEffectThirdPersonHeld",
"value": 2
}
]
},
"CAnimationGraphVisualizerPrimitiveType": {
"align": 4,
"items": [
@@ -96794,6 +96921,10 @@
{
"name": "DFLAG_IGNORE_ARMOR",
"value": 2048
},
{
"name": "DFLAG_SUPPRESS_UTILREMOVE",
"value": 4096
}
]
},

79
src/core/coreconfig.cpp Normal file
View File

@@ -0,0 +1,79 @@
/*
* This file is part of CounterStrikeSharp.
* CounterStrikeSharp is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* CounterStrikeSharp is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with CounterStrikeSharp. If not, see <https://www.gnu.org/licenses/>. *
*/
#include <fstream>
#include "core/log.h"
#include "core/coreconfig.h"
namespace counterstrikesharp {
CCoreConfig::CCoreConfig(const std::string& path) { m_sPath = path; }
CCoreConfig::~CCoreConfig() = default;
bool CCoreConfig::Init(char* conf_error, int conf_error_size)
{
std::ifstream ifs(m_sPath);
if (!ifs) {
V_snprintf(conf_error, conf_error_size, "CoreConfig file not found.");
return false;
}
m_json = json::parse(ifs);
try {
PublicChatTrigger = m_json["PublicChatTrigger"];
SilentChatTrigger = m_json["SilentChatTrigger"];
FollowCS2ServerGuidelines = m_json["FollowCS2ServerGuidelines"];
} catch (const std::exception& ex) {
V_snprintf(conf_error, conf_error_size, "Failed to parse CoreConfig file: %s", ex.what());
return false;
}
return true;
}
const std::string CCoreConfig::GetPath() const
{
return m_sPath;
}
bool CCoreConfig::IsTriggerInternal(std::vector<std::string> triggers, const std::string& message, std::string& prefix) const
{
for (std::string& trigger : triggers)
{
if (message.rfind(trigger, 0) == 0)
{
prefix = trigger;
CSSHARP_CORE_TRACE("Trigger found, prefix is {}", prefix);
return true;
}
}
return false;
}
bool CCoreConfig::IsSilentChatTrigger(const std::string& message, std::string& prefix) const
{
return IsTriggerInternal(SilentChatTrigger, message, prefix);
}
bool CCoreConfig::IsPublicChatTrigger(const std::string& message, std::string& prefix) const
{
return IsTriggerInternal(PublicChatTrigger, message, prefix);
}
} // namespace counterstrikesharp

50
src/core/coreconfig.h Normal file
View File

@@ -0,0 +1,50 @@
/*
* This file is part of CounterStrikeSharp.
* CounterStrikeSharp is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* CounterStrikeSharp is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with CounterStrikeSharp. If not, see <https://www.gnu.org/licenses/>. *
*/
#pragma once
#include "core/globals.h"
#include <string>
#include <nlohmann/json.hpp>
namespace counterstrikesharp {
class CCoreConfig
{
public:
std::vector<std::string> PublicChatTrigger = { std::string("!") };
std::vector<std::string> SilentChatTrigger = { std::string("/") };
bool FollowCS2ServerGuidelines = true;
using json = nlohmann::json;
CCoreConfig(const std::string& path);
~CCoreConfig();
bool Init(char* conf_error, int conf_error_size);
const std::string GetPath() const;
bool IsSilentChatTrigger(const std::string& message, std::string& prefix) const;
bool IsPublicChatTrigger(const std::string& message, std::string& prefix) const;
private:
bool IsTriggerInternal(std::vector<std::string> triggers, const std::string& message, std::string& prefix) const;
private:
std::string m_sPath;
json m_json;
};
} // namespace counterstrikesharp

View File

@@ -23,6 +23,8 @@
#include "const.h"
#include "utils/virtual.h"
#include <string>
#include <vector>
#include <stdint.h>
#include <type_traits>
@@ -54,6 +56,45 @@ inline uint64_t hash_64_fnv1a_const(const char *str, const uint64_t value = val_
}
namespace schema {
static std::vector<std::string> CS2BadList = {
"m_bIsValveDS",
"m_bIsQuestEligible",
"m_iItemDefinitionIndex", // in unmanaged this cannot be set.
"m_iEntityLevel",
"m_iItemIDHigh",
"m_iItemIDLow",
"m_iAccountID",
"m_iEntityQuality",
"m_bInitialized",
"m_szCustomName",
"m_iAttributeDefinitionIndex",
"m_iRawValue32",
"m_iRawInitialValue32",
"m_flValue", // MNetworkAlias "m_iRawValue32"
"m_flInitialValue", // MNetworkAlias "m_iRawInitialValue32"
"m_bSetBonus",
"m_nRefundableCurrency",
"m_OriginalOwnerXuidLow",
"m_OriginalOwnerXuidHigh",
"m_nFallbackPaintKit",
"m_nFallbackSeed",
"m_flFallbackWear",
"m_nFallbackStatTrak",
"m_iCompetitiveWins",
"m_iCompetitiveRanking",
"m_iCompetitiveRankType",
"m_iCompetitiveRankingPredicted_Win",
"m_iCompetitiveRankingPredicted_Loss",
"m_iCompetitiveRankingPredicted_Tie",
"m_nActiveCoinRank",
"m_nMusicID",
};
int16_t FindChainOffset(const char *className);
SchemaKey GetOffset(const char *className, uint32_t classKey, const char *memberName, uint32_t memberKey);
} // namespace schema

View File

@@ -65,6 +65,7 @@ SourceHook::Impl::CSourceHookImpl source_hook_impl;
SourceHook::ISourceHook *source_hook = &source_hook_impl;
ISmmAPI *ismm = nullptr;
CGameEntitySystem* entitySystem = nullptr;
CCoreConfig* coreConfig = nullptr;
CGameConfig* gameConfig = nullptr;
// Custom Managers

View File

@@ -49,6 +49,7 @@ class HookManager;
class EntityManager;
class ChatManager;
class ServerManager;
class CCoreConfig;
class CGameConfig;
namespace globals {
@@ -99,6 +100,7 @@ extern int source_hook_pluginid;
extern IGameEventSystem *gameEventSystem;
extern CounterStrikeSharpMMPlugin *mmPlugin;
extern ISmmAPI *ismm;
extern CCoreConfig* coreConfig;
extern CGameConfig* gameConfig;
void Initialize();

View File

@@ -24,6 +24,7 @@
#include <public/eiface.h>
#include "core/memory.h"
#include "core/log.h"
#include "core/coreconfig.h"
#include "core/gameconfig.h"
#include <funchook.h>
@@ -67,8 +68,9 @@ void DetourHostSay(CBaseEntity* pController, CCommand& args, bool teamonly, int
}
}
bool bSilent = *args[1] == '/';
bool bCommand = *args[1] == '!' || *args[1] == '/';
std::string prefix;
bool bSilent = globals::coreConfig->IsSilentChatTrigger(args[1], prefix);
bool bCommand = globals::coreConfig->IsPublicChatTrigger(args[1], prefix) || bSilent;
if (!bSilent) {
m_pHostSay(pController, args, teamonly, unk1, unk2);
@@ -76,7 +78,7 @@ void DetourHostSay(CBaseEntity* pController, CCommand& args, bool teamonly, int
if (bCommand)
{
char *pszMessage = (char *)(args.ArgS() + 2);
char *pszMessage = (char *)(args.ArgS() + prefix.length() + 1);
// Trailing slashes are only removed if Host_Say has been called.
if (bSilent)

View File

@@ -54,7 +54,6 @@ class ChatManager : public GlobalClass
bool OnSayCommandPre(CBaseEntity* pController, CCommand& args);
void OnSayCommandPost(CBaseEntity* pController, CCommand& args);
private:
void InternalDispatch(CBaseEntity* pPlayerController, const char* szTriggerPhrase,
CCommand& pFullCommand);

View File

@@ -20,7 +20,9 @@ inline std::string GameDirectory() {
return gameDirectory;
}
inline std::string PluginDirectory() { return GameDirectory() + "/addons/counterstrikesharp"; }
inline std::string GetRootDirectory() { return GameDirectory() + "/addons/counterstrikesharp"; }
inline std::string PluginsDirectory() { return GameDirectory() + "/addons/counterstrikesharp/plugins"; }
inline std::string ConfigsDirectory() { return GameDirectory() + "/addons/counterstrikesharp/configs"; }
inline std::string GamedataDirectory() { return GameDirectory() + "/addons/counterstrikesharp/gamedata"; }
} // namespace utils

View File

@@ -18,6 +18,7 @@
#include "core/global_listener.h"
#include "core/log.h"
#include "core/coreconfig.h"
#include "core/gameconfig.h"
#include "core/timer_system.h"
#include "core/utils.h"
@@ -83,6 +84,17 @@ bool CounterStrikeSharpMMPlugin::Load(PluginId id, ISmmAPI* ismm, char* error, s
GET_V_IFACE_ANY(GetEngineFactory, globals::gameEventSystem, IGameEventSystem,
GAMEEVENTSYSTEM_INTERFACE_VERSION);
auto coreconfig_path = std::string(utils::ConfigsDirectory() + "/core.json");
globals::coreConfig = new CCoreConfig(coreconfig_path);
char coreconfig_error[255] = "";
if (!globals::coreConfig->Init(coreconfig_error, sizeof(coreconfig_error))) {
CSSHARP_CORE_ERROR("Could not read \'{}\'. Error: {}", coreconfig_path, coreconfig_error);
return false;
}
CSSHARP_CORE_INFO("CoreConfig loaded.");
auto gamedata_path = std::string(utils::GamedataDirectory() + "/gamedata.json");
globals::gameConfig = new CGameConfig(gamedata_path);
char conf_error[255] = "";

View File

@@ -96,7 +96,7 @@ void* get_export(void* h, const char* name)
// Using the nethost library, discover the location of hostfxr and get exports
bool load_hostfxr()
{
std::string base_dir = counterstrikesharp::utils::PluginDirectory();
std::string base_dir = counterstrikesharp::utils::GetRootDirectory();
namespace css = counterstrikesharp;
#if _WIN32
std::wstring buffer =
@@ -164,7 +164,7 @@ CDotNetManager::~CDotNetManager() {}
bool CDotNetManager::Initialize()
{
const std::string base_dir = counterstrikesharp::utils::PluginDirectory();
const std::string base_dir = counterstrikesharp::utils::GetRootDirectory();
CSSHARP_CORE_INFO("Loading .NET runtime...");
@@ -184,7 +184,7 @@ bool CDotNetManager::Initialize()
std::string((base_dir + "/api/CounterStrikeSharp.API.runtimeconfig.json").c_str());
CSSHARP_CORE_INFO("Loading CSS API, Runtime Config: {}", wide_str);
#endif
const auto load_assembly_and_get_function_pointer = get_dotnet_load_assembly(wide_str.c_str());
if (load_assembly_and_get_function_pointer == nullptr) {
CSSHARP_CORE_ERROR("Failed to load CSS API.");

View File

@@ -23,6 +23,7 @@
#include "core/log.h"
#include "schema.h"
#include "core/function.h"
#include "core/coreconfig.h"
namespace counterstrikesharp {
@@ -122,6 +123,12 @@ void SetSchemaValueByName(ScriptContext& script_context)
auto dataType = script_context.GetArgument<DataType_t>(1);
auto className = script_context.GetArgument<const char*>(2);
auto memberName = script_context.GetArgument<const char*>(3);
if (globals::coreConfig->FollowCS2ServerGuidelines && std::find(schema::CS2BadList.begin(), schema::CS2BadList.end(), memberName) != schema::CS2BadList.end()) {
CSSHARP_CORE_ERROR("Cannot set '{}::{}' with \"FollowCS2ServerGuidelines\" option enabled.", className, memberName);
return;
}
auto classKey = hash_32_fnv1a_const(className);
auto memberKey = hash_32_fnv1a_const(memberName);