mirror of
https://github.com/valmojr/armatak.git
synced 2026-06-13 15:43:29 +00:00
Added whole websocket handling to the client addon
This commit is contained in:
1
addons/client/$PBOPREFIX$
Normal file
1
addons/client/$PBOPREFIX$
Normal file
@@ -0,0 +1 @@
|
||||
armatak\armatak\armatak_client
|
||||
11
addons/client/CfgEventHandlers.hpp
Normal file
11
addons/client/CfgEventHandlers.hpp
Normal file
@@ -0,0 +1,11 @@
|
||||
class Extended_PreStart_EventHandlers {
|
||||
class ADDON {
|
||||
init = QUOTE(call COMPILE_SCRIPT(XEH_preStart));
|
||||
};
|
||||
};
|
||||
|
||||
class Extended_PreInit_EventHandlers {
|
||||
class ADDON {
|
||||
init = QUOTE(call COMPILE_SCRIPT(XEH_preInit));
|
||||
};
|
||||
};
|
||||
3
addons/client/XEH_PREP.hpp
Normal file
3
addons/client/XEH_PREP.hpp
Normal file
@@ -0,0 +1,3 @@
|
||||
PREP(convertLocation);
|
||||
PREP(extractClientPosition);
|
||||
PREP(socketRouter);
|
||||
9
addons/client/XEH_preInit.sqf
Normal file
9
addons/client/XEH_preInit.sqf
Normal file
@@ -0,0 +1,9 @@
|
||||
#include "script_component.hpp"
|
||||
|
||||
ADDON = false;
|
||||
|
||||
PREP_RECOMPILE_START;
|
||||
#include "XEH_PREP.hpp"
|
||||
PREP_RECOMPILE_END;
|
||||
|
||||
ADDON = true;
|
||||
3
addons/client/XEH_preStart.sqf
Normal file
3
addons/client/XEH_preStart.sqf
Normal file
@@ -0,0 +1,3 @@
|
||||
#include "script_component.hpp"
|
||||
|
||||
#include "XEH_PREP.hpp"
|
||||
@@ -21,3 +21,5 @@ class Extended_PostInit_EventHandlers {
|
||||
init = "call compileScript ['\armatak\armatak\armatak_client\initPlayerLocal.sqf']";
|
||||
};
|
||||
};
|
||||
|
||||
#include "CfgEventHandlers.hpp"
|
||||
30
addons/client/functions/fnc_extractClientPosition.sqf
Normal file
30
addons/client/functions/fnc_extractClientPosition.sqf
Normal file
@@ -0,0 +1,30 @@
|
||||
#include "..\script_component.hpp"
|
||||
|
||||
/*
|
||||
* Author: Valmo Trindade
|
||||
* This function is used to extract the position of a unit and convert it to a format suitable for SIMTAK.
|
||||
*
|
||||
* Argument:
|
||||
* 0: The first argument <OBJECT> is the unit whose position you want to extract.
|
||||
*
|
||||
* Return Value:
|
||||
* ARRAY -> [latitude, longitude, altitude, bearing]
|
||||
*
|
||||
* Example:
|
||||
* [player] call armatak_client_fnc_extractClientPosition;
|
||||
*
|
||||
* Public: Yes
|
||||
*/
|
||||
|
||||
params["_unit"];
|
||||
|
||||
private _location = (getPos _unit) call armatak_client_fnc_convertClientLocation;
|
||||
|
||||
private _atak_latitude = _location select 0;
|
||||
private _atak_longitude = _location select 1;
|
||||
private _atak_altitude = _location select 2;
|
||||
private _atak_bearing = parseNumber ((getDir _unit) toFixed 0);
|
||||
|
||||
_unit_info = [_atak_latitude,_atak_longitude,_atak_altitude,_atak_bearing];
|
||||
|
||||
_unit_info
|
||||
11
addons/client/functions/fnc_socketRouter.sqf
Normal file
11
addons/client/functions/fnc_socketRouter.sqf
Normal file
@@ -0,0 +1,11 @@
|
||||
#include "..\script_component.hpp"
|
||||
|
||||
if (!hasInterface) exitWith {};
|
||||
|
||||
_local_address = "armatak" callExtension ["local_ip", []] select 0;
|
||||
|
||||
SETVAR(player, localAddress, _local_address);
|
||||
|
||||
[{
|
||||
"armatak" callExtension ["websocket:location", [player call FUNC(extractClientPosition)]];
|
||||
}, 1, []] call CBA_fnc_addPerFrameHandler;
|
||||
@@ -1,18 +0,0 @@
|
||||
if (!hasInterface) exitWith {};
|
||||
|
||||
_local_address = "armatak" callExtension ["local_ip", []] select 0;
|
||||
|
||||
player setVariable ["localAddress", _local_address];
|
||||
|
||||
player addEventHandler ["Respawn", {
|
||||
params["_unit", "_corpse"];
|
||||
[{
|
||||
if (alive _this) then {
|
||||
"armatak" callExtension ["websocket:location", [player call armatak_fnc_extract_position]];
|
||||
};
|
||||
}, 1, []] call CBA_fnc_addPerFrameHandler;
|
||||
}];
|
||||
|
||||
[{
|
||||
"armatak" callExtension ["websocket:location", [player call armatak_fnc_extract_position]];
|
||||
}, 1, []] call CBA_fnc_addPerFrameHandler;
|
||||
@@ -1,17 +1,17 @@
|
||||
#define COMPONENT client
|
||||
#define COMPONENT_BEAUTIFIED WebSocket
|
||||
#define COMPONENT_BEAUTIFIED WebSocket Client
|
||||
#include "\armatak\armatak\armatak_main\script_mod.hpp"
|
||||
|
||||
// #define DEBUG_MODE_FULL
|
||||
// #define DISABLE_COMPILE_CACHE
|
||||
// #define ENABLE_PERFORMANCE_COUNTERS
|
||||
|
||||
#ifdef DEBUG_ENABLED_MAIN
|
||||
#ifdef DEBUG_ENABLED_CLIENT
|
||||
#define DEBUG_MODE_FULL
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG_SETTINGS_MAIN
|
||||
#define DEBUG_SETTINGS DEBUG_SETTINGS_MAIN
|
||||
#ifdef DEBUG_SETTINGS_CLIENT
|
||||
#define DEBUG_SETTINGS DEBUG_SETTINGS_CLIENT
|
||||
#endif
|
||||
|
||||
#include "\z\ace\addons\main\script_macros.hpp"
|
||||
|
||||
@@ -40,9 +40,6 @@ class CfgFunctions {
|
||||
class extract_marker_callsign {
|
||||
file = "\armatak\armatak\armatak_main\functions\extract_data\fn_extract_marker_callsign.sqf";
|
||||
};
|
||||
class extract_position {
|
||||
file = "\armatak\armatak\armatak_main\functions\extract_data\fn_extract_position.sqf";
|
||||
};
|
||||
class extract_role {
|
||||
file = "\armatak\armatak\armatak_main\functions\extract_data\fn_extract_role.sqf";
|
||||
};
|
||||
@@ -63,9 +60,6 @@ class CfgFunctions {
|
||||
file = "\armatak\armatak\armatak_main\functions\gui\fn_ZeusCoreModule_configure.sqf";
|
||||
};
|
||||
|
||||
class convert_location {
|
||||
file = "\armatak\armatak\armatak_main\functions\map\fn_convert_location.sqf";
|
||||
};
|
||||
class convert_to_altis {
|
||||
file = "\armatak\armatak\armatak_main\functions\map\fn_convert_to_altis.sqf";
|
||||
};
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
// function name: armatak_fnc_extract_position
|
||||
// function author: Valmo
|
||||
// function description: Receives a player's unit as param and return the information array for SIMTAK
|
||||
|
||||
params["_unit"];
|
||||
|
||||
private _location = (getPos _unit) call armatak_fnc_convert_location;
|
||||
|
||||
private _atak_latitude = _location select 0;
|
||||
private _atak_longitude = _location select 1;
|
||||
private _atak_altitude = _location select 2;
|
||||
private _atak_bearing = parseNumber ((getDir _unit) toFixed 0);
|
||||
|
||||
_unit_info = [_atak_latitude,_atak_longitude,_atak_altitude,_atak_bearing];
|
||||
|
||||
_unit_info
|
||||
@@ -23,3 +23,10 @@
|
||||
#else
|
||||
#define COMPONENT_NAME QUOTE(ARMATAK - COMPONENT_BEAUTIFIED)
|
||||
#endif
|
||||
|
||||
// Custom ARMATAK MACRO defines
|
||||
|
||||
#define EXTENSION_NAME QUOTE(armatak)
|
||||
|
||||
#define CALLEXT(var) EXTENSION_NAME callExtension [var]
|
||||
#define CALLEXTP(var1, var2) EXTENSION_NAME callExtension [QUOTE(var1), var2] select 0
|
||||
@@ -1,17 +0,0 @@
|
||||
#define COMPONENT server
|
||||
#define COMPONENT_BEAUTIFIED TCP Socket
|
||||
#include "\armatak\armatak\armatak_main\script_mod.hpp"
|
||||
|
||||
// #define DEBUG_MODE_FULL
|
||||
// #define DISABLE_COMPILE_CACHE
|
||||
// #define ENABLE_PERFORMANCE_COUNTERS
|
||||
|
||||
#ifdef DEBUG_ENABLED_MAIN
|
||||
#define DEBUG_MODE_FULL
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG_SETTINGS_MAIN
|
||||
#define DEBUG_SETTINGS DEBUG_SETTINGS_MAIN
|
||||
#endif
|
||||
|
||||
#include "\z\ace\addons\main\script_macros.hpp"
|
||||
Reference in New Issue
Block a user