Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified addons/sourcemod/plugins/confoglcompmod.smx
Binary file not shown.
12 changes: 6 additions & 6 deletions addons/sourcemod/scripting/confoglcompmod.sp
Original file line number Diff line number Diff line change
Expand Up @@ -289,11 +289,15 @@ public void OnMapStart()
}
#endif

#if MODULE_MAPINFO || MODULE_WEAPONINFORMATION || MODULE_PASSWORDSYSTEM || MODULE_WATERSLOWDOWN
#if MODULE_MAPINFO || MODULE_REQMATCH || MODULE_WEAPONINFORMATION || MODULE_PASSWORDSYSTEM || MODULE_WATERSLOWDOWN

public void OnMapEnd()
{
// Modules
#if MODULE_REQMATCH
RM_OnMapEnd(); // ReqMatch
#endif

#if MODULE_MAPINFO
MI_OnMapEnd(); // MapInfo
#endif
Expand Down Expand Up @@ -344,15 +348,11 @@ public bool OnClientConnect(int client, char[] rejectmsg, int maxlen)
}
#endif

#if MODULE_REQMATCH || MODULE_UNRESERVELOBBY || MODULE_PASSWORDSYSTEM || MODULE_FINALESPAWN
#if MODULE_UNRESERVELOBBY || MODULE_PASSWORDSYSTEM || MODULE_FINALESPAWN

public void OnClientPutInServer(int client)
{
// Modules
#if MODULE_REQMATCH
RM_OnClientPutInServer(); // ReqMatch
#endif

#if MODULE_UNRESERVELOBBY
UL_OnClientPutInServer(); // UnreserveLobby
#endif
Expand Down
45 changes: 44 additions & 1 deletion addons/sourcemod/scripting/confoglcompmod/ReqMatch.sp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#define MAPRESTARTTIME 3.0
#define RESETMINTIME 60.0

static int RM_iAutoloadGeneration;

static bool
RM_bDebugEnabled = RM_DEBUG,
// RM_bMatchRequest[2] = {false, ...},
Expand Down Expand Up @@ -44,6 +46,8 @@ void RM_APL()

void RM_OnModuleStart()
{
HookEvent("player_connect_full", RM_Event_PlayerConnectFull, EventHookMode_Post);

RM_hDoRestart = CreateConVarEx("match_restart", "1", "Sets whether the plugin will restart the map upon match mode being forced or requested", _, true, 0.0, true, 1.0);
// RM_hAllowVoting = CreateConVarEx("match_allowvoting", "1", "Sets whether players can vote/request for match mode", _, true, 0.0, true, 1.0);
RM_hAutoLoad = CreateConVarEx("match_autoload", "0", "Has match mode start up automatically when a player connects and the server is not in match mode", _, true, 0.0, true, 1.0);
Expand Down Expand Up @@ -102,13 +106,50 @@ void RM_OnMapStart()
RM_Match_Load();
}

void RM_OnClientPutInServer()
void RM_OnMapEnd()
{
// A queued autoload must not survive a map transition.
RM_iAutoloadGeneration++;
}

static void RM_Event_PlayerConnectFull(Event event, const char[] name, bool dontBroadcast)
{
if (!RM_hAutoLoad.BoolValue || RM_bIsAMatchActive)
{
return;
}

int client = GetClientOfUserId(event.GetInt("userid"));
if (client == 0 || !IsClientInGame(client) || IsFakeClient(client))
{
return;
}

// PutInServer is too early to reload mode plugins during initial sign-on.
// Wait for the final connection acknowledgement, then leave its callback.
DataPack data = new DataPack();
data.WriteCell(GetClientSerial(client));
data.WriteCell(RM_iAutoloadGeneration);
RequestFrame(RM_Frame_Autoload, data);
}

static void RM_Frame_Autoload(DataPack data)
{
data.Reset();
int client = GetClientFromSerial(data.ReadCell());
int generation = data.ReadCell();
delete data;

if (generation != RM_iAutoloadGeneration || !RM_hAutoLoad.BoolValue || RM_bIsAMatchActive)
{
return;
}

if (client == 0 || !IsClientInGame(client) || IsFakeClient(client))
{
return;
}

char buffer[128];
RM_hAutoCfg.GetString(buffer, sizeof(buffer));

Expand Down Expand Up @@ -218,6 +259,8 @@ static void RM_Match_Load()

static void RM_Match_Unload(bool bForced = false)
{
RM_iAutoloadGeneration++;

bool bIsHumansOnServer = IsHumansOnServer();

if (!bIsHumansOnServer || bForced)
Expand Down