JIP Sync events complete.

This commit is contained in:
jaynus 2015-04-17 19:26:27 -07:00
parent da09b74fe4
commit 93d03b404f
8 changed files with 58 additions and 36 deletions

View File

@ -65,9 +65,31 @@ if (_currentVersion != _previousVersion) then {
0 spawn COMPILE_FILE(scripts\Version\checkVersionNumber);
// ACE events
"ACEg" addPublicVariableEventHandler { _this call FUNC(_handleNetEvent); };
"ACEc" addPublicVariableEventHandler { _this call FUNC(_handleNetEvent); };
// Synced ACE events
// Handle JIP scenario
if(!isServer) then {
["PlayerJip", {
diag_log text format["[ACE] * JIP event synchronization initialized"];
["SEH_all", [player]] call FUNC(serverEvent);
}] call FUNC(addEventHandler);
} else {
["SEH_all", FUNC(_handleRequestAllSyncedEvents)] call FUNC(addEventHandler);
};
["SEH", FUNC(_handleSyncedEvent)] call FUNC(addEventHandler);
["SEH_s", FUNC(_handleRequestSyncedEvent)] call FUNC(addEventHandler);
[FUNC(syncedEventPFH), 0.5, []] call cba_fnc_addPerFrameHandler;
/***************************************************************/
/***************************************************************/
/***************************************************************/
/***************************************************************/
/***************************************************************/
// everything that only player controlled machines need, goes below this
if (!hasInterface) exitWith {};
@ -87,7 +109,7 @@ enableCamShake true;
// Set the name for the current player
["playerChanged", {
EXPLODE_2_PVT(_this,_newPlayer,_oldPlayer);
diag_log text format["PLAYER CHANGED!", _this];
if (alive _newPlayer) then {
[_newPlayer] call FUNC(setName)
};
@ -188,30 +210,15 @@ GVAR(OldPlayerWeapon) = currentWeapon ACE_player;
{!((_this select 0) isEqualTo (_this select 1)) && {vehicle (_this select 0) == vehicle (_this select 1)}}
}] call FUNC(addCanInteractWithCondition);
// Synced ACE events
// Handle JIP scenario
if(!isServer) then{
["PlayerJip", {
diag_log text format["[ACE] - JIP event synchronization initialized"];
["SEH_all", [player]] call FUNC(serverEvent);
}] call FUNC(addEventHandler);
} else {
["SEH_all", FUNC(_handleRequestAllSyncedEvents)] call FUNC(addEventHandler);
};
["SEH", FUNC(_handleSyncedEvent)] call FUNC(addEventHandler);
["SEH_s", FUNC(_handleRequestSyncedEvent)] call FUNC(addEventHandler);
[FUNC(syncedEventPFH), 0.5, []] call cba_fnc_addPerFrameHandler;
// Lastly, do JIP events
// JIP Detection and event trigger. Run this at the very end, just in case anything uses it
if(!isServer && {isNull player}) then {
if(isMultiplayer && { time > 0 || isNull player } ) then {
// We are jipping! Get ready and wait, and throw the event
[{
PARAMS_2(_args,_handle);
if(!isNull player) then {
diag_log text format["JIP Detected, waiting"];
if(!(isNull player)) then {
["PlayerJip", [player] ] call FUNC(localEvent);
[_handle] call cba_fnc_removePerFrameHandler;
[(_this select 1)] call cba_fnc_removePerFrameHandler;
};
}, 0, []] call cba_fnc_addPerFrameHandler;
};

View File

@ -273,10 +273,13 @@ PREP(hashListPush);
PREP(syncedEventPFH);
PREP(addSyncedEventHandler);
PREP(removeSyncedEventHandler);
PREP(requestSyncedEvent);
PREP(syncedEvent);
PREP(_handleSyncedEvent);
PREP(_handleRequestSyncedEvent);
PREP(requestSyncedEvent);
PREP(_handleRequestAllSyncedEvents);
GVAR(syncedEvents) = HASH_CREATE;
// @TODO: Generic local-managed global-synced objects (createVehicleLocal)

View File

@ -1,13 +1,15 @@
/*
* Author: jaynus
*
* Handles a server-side request for synchronization ALL events on JIP to a client.
*
* Argument:
* 0: client (object)
*
* Return value:
* Boolean of success
*/
#define DEBUG_MODE_FULL
//#define DEBUG_MODE_FULL
#include "script_component.hpp"
PARAMS_1(_client);

View File

@ -1,13 +1,20 @@
/*
* Author: jaynus
*
* Receives either requests for synchronization from clients, or the synchronization data from the server.
*
* Argument:
* Arguments [Client] :
* 0: eventName (String)
* 1: eventLog (Array)
*
* Arguments [Server] :
* 0: eventName (String)
* 1: client (Object)
*
* Return value:
* Boolean of success
*/
#define DEBUG_MODE_FULL
//#define DEBUG_MODE_FULL
#include "script_component.hpp"
//SEH_s
@ -32,6 +39,7 @@ if(isServer) then {
_eventArgs = _x select 1;
[_eventName, _eventArgs, (_x select 2)] call FUNC(_handleSyncedEvent);
} forEach _eventLog;
diag_log text format["[ACE] + [%1] synchronized", _eventName];
};
true

View File

@ -1,17 +1,17 @@
/*
* Author: jaynus
*
* Call and propegate a synced event
* Handles synced events being received. Server will log them, and server/client will execute them.
*
* Argument:
* 0: Name (String)
* 1: Arguments (Array)
* 2: TTL (Number or Code) [Optional]
* Arguments [Client] :
* 0: eventName (String)
* 1: arguments (Array)
* 2: ttl (Scalar)
*
* Return value:
* Boolean of success
*/
#define DEBUG_MODE_FULL
//#define DEBUG_MODE_FULL
#include "script_component.hpp"
PARAMS_3(_name,_args,_ttl);
private["_internalData", "_eventLog", "_eventCode"];

View File

@ -11,7 +11,7 @@
* Return value:
* Boolean of success
*/
#define DEBUG_MODE_FULL
//#define DEBUG_MODE_FULL
#include "script_component.hpp"
PARAMS_2(_name,_handler);

View File

@ -1,13 +1,15 @@
/*
* Author: jaynus
*
* Send a request to synchronize an event name from the client->server. Execute on client only.
*
* Argument:
* 0: eventName (String)
*
* Return value:
* Boolean of success
*/
#define DEBUG_MODE_FULL
//#define DEBUG_MODE_FULL
#include "script_component.hpp"
PARAMS_1(_eventName);

View File

@ -11,7 +11,7 @@
* Return value:
* Boolean of success
*/
#define DEBUG_MODE_FULL
//#define DEBUG_MODE_FULL
#include "script_component.hpp"
PARAMS_2(_name,_args);
private["_ttl", "_eventData", "_internalData", "_eventLog"];