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
22 changes: 22 additions & 0 deletions addons/acre2/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,28 @@ if (_tmfNetworkEnabled) then {


if (hasInterface) then {
// Set up god mode
if GVAR(godmodeEnabled) then {
["Admins", 0] call acre_api_fnc_godModeNameGroup;
["Spectators", 1] call acre_api_fnc_godModeNameGroup;
["Curators", 2] call acre_api_fnc_godModeNameGroup;

private _canBroadcast = [player, "acreBroadcast"] call EFUNC(adminMenu,isAuthorized);
private _canGroupChat = [player, "acreGroupChat"] call EFUNC(adminMenu,isAuthorized);

TRACE_3("Initializing god mode",getPlayerUID player,_canBroadcast,_canGroupChat);
[_canBroadcast, _canGroupChat] call acre_api_fnc_godModeConfigureAccess;

if _canGroupChat then {
[getPlayerUID player, 0, 1] remoteExecCall ["acre_api_fnc_godModeModifyGroup", 0, true];
};
[{
allPlayers select {_x isKindOf QEGVAR(spectator,unit) || {[_x] call acre_api_fnc_isSpectator}}
}, 1, 0] call acre_api_fnc_godModeModifyGroup;
[{[] call BIS_fnc_listCuratorPlayers}, 2, 0] call acre_api_fnc_godModeModifyGroup;
};

// Handle VarSync
[{
if (isNull player) exitWith {};
params ["_tmfNetworkEnabled"];
Expand Down
1 change: 1 addition & 0 deletions addons/acre2/XEH_preInit.sqf
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "script_component.hpp"

#include "XEH_PREP.sqf"
#include "initSettings.sqf"

GVAR(showSpectatorRadios) = false;
10 changes: 10 additions & 0 deletions addons/acre2/initSettings.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[
QGVAR(godmodeEnabled),
"CHECKBOX",
["Handle God Mode", "Whether TMF should handle ACRE God Mode configuration. \nDefault Configuration: \n- Group 1: Admins \n- Group 2: Spectators \n- Group 3: Curators\nSee ACRE wiki for more info on God Mode."],
["TMF", "ACRE2"],
true,
1,
{},
true
] call CBA_fnc_addSetting;
1 change: 1 addition & 0 deletions addons/adminmenu/CfgEventHandlers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ class Extended_PostInit_EventHandlers {
};

XEH_PREINIT;
XEH_PRESTART;
1 change: 1 addition & 0 deletions addons/adminmenu/XEH_PREP.sqf
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
PREP(fpsHandlerServer);
PREP(isAuthorized);
PREP(checkPermission);
PREP(getCurrentAdminClient);
PREP(getCurrentAdminServer);
PREP(keyPressed);
Expand Down
2 changes: 1 addition & 1 deletion addons/adminmenu/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ GVAR(playerManagement_selected) = [];

if (isTMF) then {
[
{time > 5 && [] call FUNC(isAuthorized)},
{time > 5 && [player, "logs"] call FUNC(isAuthorized)},
{
_this call FUNC(resyncLog);

Expand Down
2 changes: 1 addition & 1 deletion addons/adminmenu/XEH_preServerInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[ // Emit new log messages to admins
QGVAR(serverLog),
{
private _targets = (allPlayers select {[_x] call FUNC(isAuthorized)});
private _targets = (allPlayers select {[_x, "logs"] call FUNC(isAuthorized)});
if (isServer && !hasInterface) then {
GVAR(logEntries) pushBack _this;
GVAR(logEntries) sort true;
Expand Down
5 changes: 5 additions & 0 deletions addons/adminmenu/XEH_preStart.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include "script_component.hpp"

#include "XEH_PREP.sqf"

uiNamespace setVariable [QGVAR(storedPerms), [[],false] call CBA_fnc_hashCreate];
26 changes: 24 additions & 2 deletions addons/adminmenu/config.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#include "\a3\ui_f\hpp\defineCommon.inc"
#include "\a3\ui_f\hpp\defineResincl.inc"
#include "script_component.hpp"

class CfgPatches {
Expand All @@ -13,10 +15,30 @@ class CfgPatches {
};
};

// SteamID64 of players authorized to access admin tools (matches against getPlayerUID)
/*
#define TMF_ALLOW_NONE 0
#define TMF_ALLOW_DASHBOARD 1
#define TMF_ALLOW_PLAYERMANAGEMENT 2
#define TMF_ALLOW_RESPAWN 4
#define TMF_ALLOW_ENDMISSION 8
#define TMF_ALLOW_LOGS 16
#define TMF_ALLOW_ALL 31
*/
class GVAR(authorized_players) {
// Default values if none otherwise defined
debugConsole = 1; // Access to debug console, also controls execute code in Player Management
zeus = 1; // Allowed to grab or use Zeus
spectatorRC = 1; // Allow remote controlling units while in spectator
map = 1; // Allow using the admin map
safestart = 1; // Allow toggling safestart

adminmenu = __EVAL(TMF_ALLOW_ALL); // Which adminmenu tabs are allowed
//adminmenu = __EVAL(TMF_ALLOW_DASHBOARD + TMF_ALLOW_PLAYERMANAGEMENT); // Macros

/*class Bear {
uid = "12345";
uid = "12345"; // SteamID64 of players authorized to access admin tools (matches against getPlayerUID)
adminmenu = __EVAL(TMF_ALLOW_DASHBOARD + TMF_ALLOW_PLAYERMANAGEMENT); // Only allow dashboard and playermanagement
zeus = 0; // Disallow zeus
};*/
};

Expand Down
2 changes: 1 addition & 1 deletion addons/adminmenu/fnc_isDebugConsoleAllowed.sqf
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#include "\x\tmf\addons\adminmenu\script_component.hpp"

([] call BIS_fnc_isDebugConsoleAllowed_old || {[] call FUNC(isAuthorized)})
([] call BIS_fnc_isDebugConsoleAllowed_old || {[player, "debugConsole"] call FUNC(isAuthorized)})
78 changes: 78 additions & 0 deletions addons/adminmenu/functions/fnc_checkPermission.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
#include "\x\tmf\addons\adminmenu\script_component.hpp"
/* ----------------------------------------------------------------------------
Internal Function: TMF_adminmenu_fnc_checkPermission

Description:
Checks if a config class within tmf_adminmenu_authorized_players has the specified permission.
If no permission is set, it falls back to the default values set directly in
tmf_adminmenu_authorized_players.

Parameters:
_class - Config class in (configFile >> "tmf_adminmenu_authorized_players") [Config]
_perm - Permission to check [String]

Returns:
Whether config has the specified permission. [Boolean]

Examples:
(begin example)
[(configFile >> "tmf_adminmenu_authorized_players" >> "bear"), "debugConsole"] call TMF_adminmenu_fnc_checkPermission;
// true
(end)

Author:
Freddo
---------------------------------------------------------------------------- */
params [
["_class", configNull, [configNull]],
["_perm", "", [""]]
];
TRACE_2("Checking permission",_class,_perm);

_perm = toLower _perm;
private _defaultsClass = (configFile >> QGVAR(authorized_players));

// Check cached values
private _cachedPerms = uiNamespace getVariable QGVAR(storedPerms);
private _entry = [configName _class, _perm] joinString "_";
if ([_cachedPerms,_entry] call CBA_fnc_hashHasKey) exitWith {
TRACE_1("Found cached permission value",_entry);
[_cachedPerms, _entry] call CBA_fnc_hashGet
};

#define CHECK_BOOL(var1) \
if (isNumber (_class >> var1)) then { \
(_class >> var1) call BIS_fnc_getCfgDataBool \
} else { \
(_defaultsClass >> var1) call BIS_fnc_getCfgDataBool \
};
#define CHECK_BITWISE(var1,var2) \
if (isNumber (_class >> var1)) then { \
[getNumber (_class >> var1), var2] call BIS_fnc_bitflagsCheck; \
} else { \
[getNumber (_defaultsClass >> var1), var2] call BIS_fnc_bitflagsCheck; \
};

private _hasPerm = switch _perm do {
/* Go to default instead
case "debugconsole";
case "zeus";
case "spectatorrc";
case "map";
case "safestart";
case "adminmenu": {CHECK_BOOL(_perm))};
*/
case "dashboard": {CHECK_BITWISE("adminmenu",TMF_ALLOW_DASHBOARD)};
case "playermanagement":{CHECK_BITWISE("adminmenu",TMF_ALLOW_PLAYERMANAGEMENT)};
case "respawn": {CHECK_BITWISE("adminmenu",TMF_ALLOW_RESPAWN)};
case "endmission": {CHECK_BITWISE("adminmenu",TMF_ALLOW_ENDMISSION)};
case "logs": {CHECK_BITWISE("adminmenu",TMF_ALLOW_LOGS)};

default {CHECK_BOOL(_perm)};
};

// Store value
TRACE_2("Caching permission value",_entry,_hasPerm);
[_cachedPerms, _entry, _hasPerm] call CBA_fnc_hashSet;

_hasPerm
24 changes: 24 additions & 0 deletions addons/adminmenu/functions/fnc_claimZeus.sqf
Original file line number Diff line number Diff line change
@@ -1,5 +1,29 @@
#include "\x\tmf\addons\adminmenu\script_component.hpp"

disableSerialization;
if !canSuspend exitWith {
_this spawn FUNC(claimZeus);
};

// Because people don't understand that grabbing zeus after mission start is a bad idea
if !(
[
[
"Claiming Zeus after mission start may cause certain functionality to break.",
"As such it should only be used for debug purposes or in emergencies.",
"To prevent any issues you should use the Game Master editor module whenever possible.",
"",
"Do you still wish to proceed?"
] joinString "<br/>",
"WARNING",
true,
true,
uiNamespace getVariable [QGVAR(display),displayNull],
true,
false
] call BIS_fnc_guiMessage
) exitWith {};

if (isNull (getAssignedCuratorLogic player)) then {
player remoteExec [QFUNC(makeZeusServer), 2];
systemChat "[TMF Admin Menu] You now have access to Zeus";
Expand Down
39 changes: 31 additions & 8 deletions addons/adminmenu/functions/fnc_isAuthorized.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,45 @@
* Return:
* Boolean. - Whether player is an authorized admin
*/
params [["_unit", player,[objNull]]];
params [["_unit", player,[objNull]], ["_perm","",[""]]];

private _index = ("true" configClasses (configFile >> QGVAR(authorized_players))) findIf {getText (_x >> "uid") isEqualTo getPlayerUID _unit};
TRACE_2("Checking if unit is authorized",_unit,_perm);

private _uid = getPlayerUID _unit;
private _classes = "true" configClasses (configFile >> QGVAR(authorized_players));
private _index = _classes findIf {getText (_x >> "uid") isEqualTo getPlayerUID _unit};

#ifdef DEBUG_MODE_FULL
private _authorized = switch true do {
#else
switch true do {
// Return true for server/HCs
case ((isServer || !hasInterface) && {isNull _unit});
// Player UID listed in authorized_players config
case (_index != -1);
// Check if local client is admin
#endif
case (isServer);
case (!hasInterface);
case ((local _unit || isNull _unit) && {[] call BIS_fnc_admin > 0});
// Check if remote client is admin (only available for servers)
case (isServer && {admin owner _unit > 0});
case (!isMultiplayer);
case (is3DEN);
case (is3DENMultiplayer): {true};
case (is3DENPreview): {true};

// Player UID listed in authorized_players config
case (_index != -1): {
if (_perm != "") then {
// Check specific permission
private _class = _classes # _index;

[_class,_perm] call FUNC(checkPermission)
} else {
// Overall true
true
};
};

default {false};
#ifndef DEBUG_MODE_FULL
}; // Because otherwise github validation fails
#else
};
TRACE_1("Authorization check complete",_authorized);
#endif
18 changes: 10 additions & 8 deletions addons/adminmenu/functions/fnc_keyPressed.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,27 @@
params ["", "_keyPressed"];
private _modifiersPressed = _this select [2, 3];

private _authorized = [player] call FUNC(isAuthorized);
private _rtrn = false;

private _binding = ["TMF", QGVAR(openKey)] call CBA_fnc_getKeybind;
if (isNil "_binding") exitWith {};
(_binding select 5) params ["_DIK", "_modifiers"];

private _handleKeypress = (_keyPressed isEqualTo _DIK) && (_modifiersPressed isEqualTo _modifiers);
if (_handleKeypress) then {
if (_authorized) then {
if ([player, "adminmenu"] call FUNC(isAuthorized)) then {
if (dialog && !isNull (uiNamespace getVariable [QGVAR(display), displayNull])) then {
systemChat "[TMF Admin Menu] The admin menu is already open"
} else {
if (!isNull (findDisplay 312)) then {
systemChat "[TMF Admin Menu] Can't open the admin menu in the Zeus interface";
} else {
createDialog QUOTE(ADDON);
_rtrn = true;
};
};
} else {
systemChat "[TMF Admin Menu] You're not authorized to use the admin menu";
};
} else {
_binding = ["TMF", QGVAR(spectatorRemoteControl)] call CBA_fnc_getKeybind;
Expand All @@ -29,7 +32,7 @@ if (_handleKeypress) then {

_handleKeypress = (_keyPressed isEqualTo _DIK) && (_modifiersPressed isEqualTo _modifiers);
if (_handleKeypress) then {
if (_authorized) then {
if ([player, "spectatorRC"] call FUNC(isAuthorized)) then {
if (isNull (findDisplay 5454)) then {
if (isNull (missionNamespace getVariable ["bis_fnc_moduleRemoteControl_unit", objNull])) then {
systemChat "[TMF Admin Menu] Remote Control is available only through TMF Spectator";
Expand All @@ -44,14 +47,13 @@ if (_handleKeypress) then {
} else {
[EGVAR(spectator,target), true] call FUNC(remoteControl);
[format ["%1 remote controlled unit: %2", profileName,EGVAR(spectator,target)],false,"Admin Menu"] call FUNC(log);
_rtrn = true;
};
};
} else {
systemChat "[TMF Admin Menu] You're not authorized to remote control units";
};
};
};

if (_handleKeypress && !_authorized) then {
systemChat "[TMF Admin Menu] You're not authorized to use the admin menu";
};

true;
_rtrn
Loading