Alef/JIP – User

From Bohemia Interactive Community
Jump to navigation Jump to search

Work in progress

General

The server is already running a mission. At least has the mission.sqm processed. Instanced of object/vehicles are in the server address space.

Now, the JIP needs to download from the server the status and keep it updated.

mission.sqm can't be processed like the server does, because of the randomness of units/vehicles. What if server creates and object and the client not, or if the position is different? This should be an easy remember thing. However,OFPEC says mission.sqm/init fields are executed too.

Client get data from server. Sickboy's MP page explains that.

JIP test

source

#define SPON_THIS_FILE init.sqf
#include "SPON\Core\core.inc.sqf"
#include "SPON\Core\macros\macros.inc.sqf"

["DEBUG_CLIENT",9999,true] call compile preprocessFileLineNumbers "SPON\Core\initCore.sqf";
// JIP test only. Put "p" as variable name in mission.sqm for JIP player.
#define  TEST( xx ) if (xx) then { s=#xx } else { s="not "+#xx };
#define PRINT( xx ) s=#xx+" = "+(xx);
#define PRINTF( xx ) s=#xx+" = "+format["%1",(xx)];
c=0;
waitUntil
{
    TEST( isNull p )
    SPON_TRACE_1( s, c );
    TEST( isNull player )
    SPON_TRACE_1( s, c );
    TEST( local p )
    SPON_TRACE_1( s, c );
    TEST( local player )
    SPON_TRACE_1( s, c );
    TEST( isPlayer p )
    SPON_TRACE_1( s, c );
    TEST( isPlayer player )
    SPON_TRACE_1( s, c );
    PRINT( name p )
    SPON_TRACE_1( s, c );
    PRINT( name player )
    SPON_TRACE_1( s, c );
    PRINTF( vehicle p )
    SPON_TRACE_1( s, c );
    PRINTF( vehicle player )
    SPON_TRACE_1( s, c );
    PRINTF( alive p )
    SPON_TRACE_1( s, c );
    PRINTF( alive player )
    SPON_TRACE_1( s, c );
// what about getVariable ?
    PRINT( p getVariable "undefined" );
    SPON_TRACE_1( s, c );
    PRINT( player getVariable "undefined" );
    SPON_TRACE_1( s, c );
    c=c+1;
    name player != "Error: No vehicle";
};

output (edited)

hosting game (p != player)
time
isNull
local
isPlayer
name
vehicle
alive
p player p player p player p player p player p player
any false false true true false true Roberto Duarte alef TODO TODO TODO TODO
JIP
time
isNull
local
isPlayer
name
vehicle
alive
p player p player p player p player p player p player
0 false true false false false false Roberto Duarte Error: No vehicle TODO TODO TODO TODO
0.001 false true false false false false Roberto Duarte Error: No vehicle TODO TODO TODO TODO
JIP, changed to sleep 1 second
time
isNull
local
isPlayer
name
vehicle
alive
p player p player p player p player p player p player
0 false true false false false false Roberto Duarte Error: No vehicle TODO TODO TODO TODO
1 false false true true true true alef (2) alef (2) TODO TODO TODO TODO
JIP, monitored with SPON Core, waitUntil name player != "no veh"
time
isNull
local
isPlayer
name
vehicle
alive
p player p player p player p player p player p player
0 false true false false false false Roberto Duarte Error: No vehicle p <NULL-object> true false
c=1 false true false false false false Roberto Duarte Error: No vehicle p <NULL-object> true false
c=2 false true false false false false Roberto Duarte Error: No vehicle p <NULL-object> true false
c=3 false false true true true true alef (2) alef (2) p p true true

comments

So what's happened?

ok, as we enter, player is null. so just waitUntil{!(isNull player)}, like XEH does.

  • name p = Roberto Duarte
  • name player = Error: No vehicle

name of unit p is the random created. No setIdentity in the mission: it would work looking in description.ext/CfgIdentities.
"name player" says there is no vehicle for it, because player is still null.

  • local p ; local player ;
  • isPlayer p ; isPlayer player ;
  • name p = alef (2) ; name player = alef (2) ;

Now the name of unit p has been assigned to the player's name. p is player, I suppose is just a check on the player pointer.

XEH relevant code for JIP:

waitUntil{!(isNull player)}
waitUntil{local player}


Call stack in ace tracking for bug #778

XEH: PostInit.sqf, time == 0
XEH:  isNull player
XEH:   waited for !(isNull player)
XEH:   waited for local player
time > 0
XEH:   waited for !isNull (group player)
XEH: ... { [] call _x } forEach _PostInits; -> XEH_PostInit_Once.sqf: register fUpdateUnits
XEH: { _x call SLX_XEH_init } forEach SLX_XEH_OBJECTS; // Run InitPosts
SLX_XEH_init=XEH\Init.sqf
config.cpp:h\Eventhandlers.hpp:
 Extended_InitPost_EventHandlers::CAManBase::ace_sys_tracking::
		init = "(_this select 0) call ace_sys_tracking_initMan";
		onRespawn = 1;
XEH_PreInit_Once.sqf:ace_sys_tracking_initMan = { ace_sys_tracking_units += [_this]; ...}
s/initMan.sqf: spawn s/loopGroup.sqf
s/loopGroup.sqf:      first time and every 10 or more seconds (very roughly)
s/loopGroup.sqf:35:   call { call ace_sys_tracking_fUpdateUnits }
s/fUpdateUnits.sqf: [_units] 
s/fUpdateUnits.sqf:  alive _x &&  "<null>" == _x getVariable "ace_sys_tracking_player"
s/fUpdateUnits.sqf:   _x setVariable ["ace_sys_tracking_name", name _x]