Skip to content

Commit

Permalink
Full SM transitional syntax upconversion including methodmaps
Browse files Browse the repository at this point in the history
A few DataPack memory leaks patched
Minor code tidying
  • Loading branch information
geominorai committed Jun 17, 2018
1 parent 695080a commit 75cc5b6
Show file tree
Hide file tree
Showing 10 changed files with 1,318 additions and 1,697 deletions.
2 changes: 1 addition & 1 deletion game/addons/sourcemod/scripting/include/sourcebanspp.inc
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public SharedPlugin __pl_sourcebanspp =
};

#if !defined REQUIRE_PLUGIN
public __pl_sourcebanspp_SetNTVOptional()
public void __pl_sourcebanspp_SetNTVOptional()
{
MarkNativeAsOptional("SBBanPlayer");
MarkNativeAsOptional("SBPP_BanPlayer");
Expand Down
14 changes: 7 additions & 7 deletions game/addons/sourcemod/scripting/include/sourcecomms.inc
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ enum bType {
* @param reason Reason for punishment.
* @return True if this caused a change in mute state, false otherwise.
*/
native bool:SourceComms_SetClientMute(client, bool:muteState, muteLength = -1, bool:saveToDB = false, const String:reason[] = "Muted through natives");
native bool SourceComms_SetClientMute(int client, bool muteState, int muteLength = -1, bool saveToDB = false, const char[] reason = "Muted through natives");

/**
* Sets a client's gag state.
Expand All @@ -77,15 +77,15 @@ native bool:SourceComms_SetClientMute(client, bool:muteState, muteLength = -1, b
* @param reason Reason for punishment.
* @return True if this caused a change in gag state, false otherwise.
*/
native bool:SourceComms_SetClientGag(client, bool:gagState, gagLength = -1, bool:saveToDB = false, const String:reason[] = "Gagged through natives");
native bool SourceComms_SetClientGag(int client, bool gagState, int gagLength = -1, bool saveToDB = false, const char[] reason = "Gagged through natives");

/**
* Returns the client's mute type
*
* @param client The client index of the player to check mute status
* @return The client's current mute type index (see enum bType in the begin).
*/
native bType:SourceComms_GetClientMuteType(client);
native bType SourceComms_GetClientMuteType(int client);


/**
Expand All @@ -94,7 +94,7 @@ native bType:SourceComms_GetClientMuteType(client);
* @param client The client index of the player to check gag status
* @return The client's current gag type index (see enum bType in the begin).
*/
native bType:SourceComms_GetClientGagType(client);
native bType SourceComms_GetClientGagType(int client);

/**
* Called when added communication block for player.
Expand All @@ -105,9 +105,9 @@ native bType:SourceComms_GetClientGagType(client);
* @param type The type of block. See section "Int definitions for punishments types".
* @param reason The reason to block the player.
*/
forward SourceComms_OnBlockAdded(client, target, time, type, String:reason[]);
forward void SourceComms_OnBlockAdded(int client, int target, int time, int type, char[] reason);

public SharedPlugin:__pl_sourcecomms =
public SharedPlugin __pl_sourcecomms =
{
name = "sourcecomms++",
file = "sbpp_comms.smx",
Expand All @@ -118,7 +118,7 @@ public SharedPlugin:__pl_sourcecomms =
#endif
};

public __pl_sourcecomms_SetNTVOptional()
public void __pl_sourcecomms_SetNTVOptional()
{
MarkNativeAsOptional("SourceComms_SetClientMute");
MarkNativeAsOptional("SourceComms_SetClientGag");
Expand Down
27 changes: 2 additions & 25 deletions game/addons/sourcemod/scripting/sbpp_admcfg.sp
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,11 @@
// *************************************************************************

#pragma semicolon 1
#pragma newdecls required

#include <sourcemod>

#if SOURCEMOD_V_MAJOR >= 1 && SOURCEMOD_V_MINOR >= 7
public Plugin:myinfo =
#else
public Plugin myinfo =
#endif
{
name = "SourceBans++: Admin Config Loader",
author = "AlliedModders LLC, SourceBans++ Dev Team",
Expand All @@ -43,28 +40,16 @@ public Plugin myinfo =


/** Various parsing globals */
#if SOURCEMOD_V_MAJOR >= 1 && SOURCEMOD_V_MINOR >= 7
new bool:g_LoggedFileName = false; /* Whether or not the file name has been logged */
new g_ErrorCount = 0; /* Current error count */
new g_IgnoreLevel = 0; /* Nested ignored section count, so users can screw up files safely */
new g_CurrentLine = 0; /* Current line we're on */
new String:g_Filename[PLATFORM_MAX_PATH]; /* Used for error messages */
#else
bool g_LoggedFileName = false; /* Whether or not the file name has been logged */
int g_ErrorCount = 0; /* Current error count */
int g_IgnoreLevel = 0; /* Nested ignored section count, so users can screw up files safely */
int g_CurrentLine = 0; /* Current line we're on */
char g_Filename[PLATFORM_MAX_PATH]; /* Used for error messages */
#endif

#include "sbpp_admcfg/sbpp_admin_groups.sp"
#include "sbpp_admcfg/sbpp_admin_users.sp"

#if SOURCEMOD_V_MAJOR >= 1 && SOURCEMOD_V_MINOR >= 7
public OnRebuildAdminCache(AdminCachePart:part)
#else
public void OnRebuildAdminCache(AdminCachePart part)
#endif
{
if (part == AdminCache_Groups) {
ReadGroups();
Expand All @@ -73,18 +58,10 @@ public void OnRebuildAdminCache(AdminCachePart part)
}
}

#if SOURCEMOD_V_MAJOR >= 1 && SOURCEMOD_V_MINOR >= 7
ParseError(const String:format[], any:...)
#else
void ParseError(const char[] format, any...)
#endif
{
#if SOURCEMOD_V_MAJOR >= 1 && SOURCEMOD_V_MINOR >= 7
decl String:buffer[512];
#else
char buffer[512];
#endif


if (!g_LoggedFileName)
{
LogError("Error(s) Detected Parsing %s", g_Filename);
Expand Down
212 changes: 0 additions & 212 deletions game/addons/sourcemod/scripting/sbpp_admcfg/sbpp_admin_groups.sp
Original file line number Diff line number Diff line change
Expand Up @@ -24,217 +24,6 @@
//
// *************************************************************************

#if SOURCEMOD_V_MAJOR >= 1 && SOURCEMOD_V_MINOR >= 7
#define GROUP_STATE_NONE 0
#define GROUP_STATE_GROUPS 1
#define GROUP_STATE_INGROUP 2
#define GROUP_STATE_OVERRIDES 3
#define GROUP_PASS_FIRST 1
#define GROUP_PASS_SECOND 2

static SMCParser g_hGroupParser;
static GroupId:g_CurGrp = INVALID_GROUP_ID;
static g_GroupState = GROUP_STATE_NONE;
static g_GroupPass = 0;
static bool:g_NeedReparse = false;

public SMCResult ReadGroups_NewSection(SMCParser smc, const char[] name, bool opt_quotes)
{
if (g_IgnoreLevel)
{
g_IgnoreLevel++;
return SMCParse_Continue;
}

if (g_GroupState == GROUP_STATE_NONE)
{
if (StrEqual(name, "Groups", false))
{
g_GroupState = GROUP_STATE_GROUPS;
} else {
g_IgnoreLevel++;
}
} else if (g_GroupState == GROUP_STATE_GROUPS) {
if ((g_CurGrp = CreateAdmGroup(name)) == INVALID_GROUP_ID)
{
g_CurGrp = FindAdmGroup(name);
}
g_GroupState = GROUP_STATE_INGROUP;
} else if (g_GroupState == GROUP_STATE_INGROUP) {
if (StrEqual(name, "Overrides", false))
{
g_GroupState = GROUP_STATE_OVERRIDES;
} else {
g_IgnoreLevel++;
}
} else {
g_IgnoreLevel++;
}

return SMCParse_Continue;
}

public SMCResult ReadGroups_KeyValue(SMCParser smc,
const char[] key,
const char[] value,
bool key_quotes,
bool value_quotes)
{
if (g_CurGrp == INVALID_GROUP_ID || g_IgnoreLevel)
{
return SMCParse_Continue;
}

new AdminFlag:flag;

if (g_GroupPass == GROUP_PASS_FIRST)
{
if (g_GroupState == GROUP_STATE_INGROUP)
{
if (StrEqual(key, "flags", false))
{
new len = strlen(value);
for (new i = 0; i < len; i++)
{
if (!FindFlagByChar(value[i], flag))
{
continue;
}
SetAdmGroupAddFlag(g_CurGrp, flag, true);
}
} else if (StrEqual(key, "immunity", false)) {
g_NeedReparse = true;
}
} else if (g_GroupState == GROUP_STATE_OVERRIDES) {
new OverrideRule:rule = Command_Deny;

if (StrEqual(value, "allow", false))
{
rule = Command_Allow;
}

if (key[0] == '@')
{
AddAdmGroupCmdOverride(g_CurGrp, key[1], Override_CommandGroup, rule);
} else {
AddAdmGroupCmdOverride(g_CurGrp, key, Override_Command, rule);
}
}
} else if (g_GroupPass == GROUP_PASS_SECOND
&& g_GroupState == GROUP_STATE_INGROUP) {
/* Check for immunity again, core should handle double inserts */
if (StrEqual(key, "immunity", false))
{
/* If it's a value we know about, use it */
if (StrEqual(value, "*"))
{
SetAdmGroupImmunityLevel(g_CurGrp, 2);
} else if (StrEqual(value, "$")) {
SetAdmGroupImmunityLevel(g_CurGrp, 1);
} else {
new level;
if (StringToIntEx(value, level))
{
SetAdmGroupImmunityLevel(g_CurGrp, level);
} else {
new GroupId:id;
if (value[0] == '@')
{
id = FindAdmGroup(value[1]);
} else {
id = FindAdmGroup(value);
}
if (id != INVALID_GROUP_ID)
{
SetAdmGroupImmuneFrom(g_CurGrp, id);
} else {
ParseError("Unable to find group: \"%s\"", value);
}
}
}
}
}

return SMCParse_Continue;
}

public SMCResult ReadGroups_EndSection(SMCParser smc)
{
/* If we're ignoring, skip out */
if (g_IgnoreLevel)
{
g_IgnoreLevel--;
return SMCParse_Continue;
}

if (g_GroupState == GROUP_STATE_OVERRIDES)
{
g_GroupState = GROUP_STATE_INGROUP;
} else if (g_GroupState == GROUP_STATE_INGROUP) {
g_GroupState = GROUP_STATE_GROUPS;
g_CurGrp = INVALID_GROUP_ID;
} else if (g_GroupState == GROUP_STATE_GROUPS) {
g_GroupState = GROUP_STATE_NONE;
}

return SMCParse_Continue;
}

public SMCResult ReadGroups_CurrentLine(SMCParser smc, const char[] line, int lineno)
{
g_CurrentLine = lineno;

return SMCParse_Continue;
}

static InitializeGroupParser()
{
if (!g_hGroupParser)
{
g_hGroupParser = new SMCParser();
g_hGroupParser.OnEnterSection = ReadGroups_NewSection;
g_hGroupParser.OnKeyValue = ReadGroups_KeyValue;
g_hGroupParser.OnLeaveSection = ReadGroups_EndSection;
g_hGroupParser.OnRawLine = ReadGroups_CurrentLine;
}
}

static InternalReadGroups(const String:path[], pass)
{
/* Set states */
InitGlobalStates();
g_GroupState = GROUP_STATE_NONE;
g_CurGrp = INVALID_GROUP_ID;
g_GroupPass = pass;
g_NeedReparse = false;

SMCError err = g_hGroupParser.ParseFile(path);
if (err != SMCError_Okay)
{
char buffer[64];
if (g_hGroupParser.GetErrorString(err, buffer, sizeof(buffer)))
{
ParseError("%s", buffer);
} else {
ParseError("Fatal parse error");
}
}
}

ReadGroups()
{
InitializeGroupParser();

BuildPath(Path_SM, g_Filename, sizeof(g_Filename), "configs/sourcebans/sb_admin_groups.cfg");

InternalReadGroups(g_Filename, GROUP_PASS_FIRST);
if (g_NeedReparse)
{
InternalReadGroups(g_Filename, GROUP_PASS_SECOND);
}
}
/* SOURCEMOD 1.7 PLUGIN STOPS HERE */
#else
enum GroupState
{
GroupState_None,
Expand Down Expand Up @@ -451,4 +240,3 @@ void ReadGroups()
InternalReadGroups(g_Filename, GroupPass_Second);
}
}
#endif
Loading

0 comments on commit 75cc5b6

Please sign in to comment.