I can't publish bn880's stuff uiox, and i haven't updated my stuff to make sure it still works. Here's my scribblings, for what it's worth. In a few days, the code that makes it work will be available.
init.sqs lines
@rNClientsReady
[] exec "publicArray\PublicArrayInit.sqs"
PublicArrayInit.sqs
;dinger@raf303.org
_publicarrays = ["Test1", "Test2", "Test3"]
?rNisServer == rNisServer:goto "NetworkInitRunning"
;insert variable initialized function
call preprocessFile "string\string.sqf"
call preprocessFile "numSystem\numSys.sqf"
call preProcessFile "Network\COMM_HEADER.sqf";
_connectTimeout = 10;
rNClientsReady = false;
_connectTimeout call loadFile "Network\initializeNetwork.sqf";
#NetworkInitRunning
_timeout = _time + 60
@(rNClientsReady || _time > _timeout)
?_Time > _Timeout: player sidechat "CoC_PublicArrayInit Error: failed to initialize network"; exit
if !ecool function ehre then {rPublicArrays = rPublicArrays + _publicarrays} else {rPublicArrays = +_publicarrays}
rPublicArrays = ["Test1", "Test2", "test3"]
;rPublicArrays = the names of the arrays to share
rNPA_PollInterval = .1
;set higher interval for lower urgency/traffic and higher overall performance, lower interval for high traffic/urgency
rNPA_Terminate = False
;set to TRUE to shut down polling
;rNPA_cc# = server/client channel (0 = master update) = time hack
;rNPA_ci# = server/client index = index to rPublicArrays
;rNPA_ind# = index reference from rPublicArrays -> nPAs
;rNPA_tim# = time hack for rPublicArrays updates
;rNPA_cp# = port opened to client
;rNPAA-rNPA9 = ports
;checkandload libraries
fPublicArray = preprocessfile "publicArray\fPublicArray.sqf"
?LIBNUMSYS > 0:goto "LoadPALib"
call loadfile "numSys\numSys.sqf"
#LoadPALIb
?LIBARRAYCNV > 0:goto "Initialize"
call preprocessfile "arrayConversions\arrayConversions.sqf"
#Initialize
rPublicArrayCount = count rPublicArrays
rPublicArrayPorts = []
_rPortStackDepth = 36
;nb This system is good only for 36 channels
;if you want more, we can add 36 to index, and go double-digit
rPublicArrayStem = "rNPa"
_i = 0
#BuildStack
_currentPort = rPublicArrayStem + (_i call fDecToAlpha)
call format ["%1 = time", _currentPort]
rPublicArrayPorts = rPublicArrayPorts + [_currentPort]
_i = _i + 1
?_i < _rPortStackDepth: goto "BuildStack"
#BuildIndices
_i = 0
{call format ["rNPA_ind%1 = -1; rNPA_tim = -1", (_i call fDecToAlpha)]; _i = _i + 1} ForEach rPublicArrays
;debug
player sidechat format ["%1", rPublicArrayPorts]
;start server
?local server:[] exec "publicArray\Server.sqs"
;start client
?player == player:[] exec "publicArray\Client.sqs"
exit
PublicArray.sqs
;dinger@raf303.org
_channel = rNClientChannel call fDecToAlpha
_push = format ["rNPA_cc%1", _channel]
_pushi = format ["rNPA_ci%1", _channel]
_tune = format ["rNPA_cp%1", _channel]
#Top
?count rPublicArrayOut == 0:exit
_arrayIndex = rPublicArrayOut select 0
call format ["%1 = time; %2 = _arrayIndex", _push, _pushi]
call {PublicVariable _pushi; PublicVariable _push}
player sidechat "Pushi = "+_pushi + " _push = " + _push
_timeout = time + 10
#WaitForServer
?(call format ["%1 == (-1 * (_arrayIndex+5))", _pushi]):goto "FFE"
~rNPA_PollInterval
?time < _timeout: goto "WaitForServer"
player sidechat "PublicArray.sqs server timeout"
?!rNPA_Terminate:goto "Top"
exit
#FFE
;call format ["%1 = 0
_stemName = format ["rNPA%1", (call _tune) call fDecToAlpha]
_transmitArray = [call (rPublicArrays select _arrayIndex), _stemName] call fArrayToVar
{publicvariable _x} foreach _transmitArray
player sidechat format ["DEBUG - XMIT: %1: %2/Stem: %3, pushi: %4 = %5", (rPUblicArrays select _arrayIndex), _transmitArray, _stemname, _Pushi, call _pushi]
_timeout = time + 20
#WaitForAck
~rNPA_PollInterval
?time > _timeout:goto "TimeOut"
?(call format ["((%1 < -4) or (%1 > -1))", _pushi]):goto "WaitforAck"
?(call format ["%1 == -1", _pushi]):rPublicArrayOut set [0, -666]; rPublicArrayOut = rPublicArrayOut - [-666];goto "Top"
#TimeOut
player sidechat format ["PublicArray.sqs: NoAck (pushi: %1 = %2)", _pushi, call _pushi]
?!rNPA_Terminate:goto "Top"
exit
server.sqs
;dinger@raf303.org
;initialize clientchannels
_clients = (count rNClientList)
_i = 0
{call format ["rNPA_cc%1 = -1; rNPA_ci%1 = -1", (_i call fDecToAlpha)]; _i = _i + 1} ForEach rNClientList
rPublicArrayPortCurrent = 0
rPublicArrayPortsOpen = []
#RequestScan
_i = 0
#RequestScanLoop
_Channel = Format ["rNPA_cc%1", (_i call fDecToAlpha)]
? (call (_channel + " != -1")):player sidechat format ["Opening Channel %1", _channel]; call format [{%1 = -1; [_i] exec "PublicArray\ServerOpen.sqs"}, _channel]
_i = _i + 1
?_i < _clients: goto "RequestScanLoop"
~rNPA_PollInterval
?!rNPA_Terminate:goto "RequestScan"
exit
ServerOpen.sqs
;dinger@raf303.org
_channel = ((_this select 0) call fDecToAlpha)
_indexVar = format ["rNPA_ci%1", _channel]
_portVar = format ["rNPA_cp%1", _channel]
_index = call _indexVar
_ia = _index call fDecToAlpha
_port = 0
call format ["_port = %1; rPublicArrayPortsOpen = rPublicArrayPortsOpen + [%1]", rPublicArrayPortCurrent]
call {while {rPublicArrayPortCurrent in rPublicArrayPortsOpen} do {rPublicArrayPOrtCurrent = rPublicArrayPortCurrent + 1; if (rPublicArrayPortCurrent >= count rPublicArrayPorts) then {rPublicArrayPOrtCurrent = 0;}}}
_portIndexName = format [rPublicArrayStem + "%1_", _port call fDecToAlpha]
call (_portIndexNAme + " = nil")
call format ["%1 = _port", _portVar]
call (_indexVar + { = -1 * (_index+5)})
call {PublicVariable _portVar; PublicVariable _indexVar}
player sidechat format ["SO.sqs: Portvar: %1:%2, _port %3, IndxVar: %4,%5, _portIndexName %6", _portvar, call _portvar, _port, _indexvar, call _indexvar, _portIndexName]
_timeout = _time + 30
player sidechat "SO.sqs: Waiting for Xmission"
#WaitForTransmission
?(call _portIndexName) == (call _portIndexName):goto "TransmissionReceived"
?_time > _TimeOut:goto "TimeOut"
~rNPA_PollInterval
goto "WaitForTransmission"
#TransmissionReceived
player sidechat "SO.sqs: Xmission received"
call (_indexVar + { = -1})
_arrayIndex = format ["rNPA_ind%1", _ia]
_arrayTimeIndex = format ["rNPA_tim%1", _ia]
;player sidechat format ["aI = %1, ATI = %2, IV:%3 = %4, Ind = %5, IA = %6", _ArrayIndex, _ArrayTimeIndex, _IndexVAr, call _indexVar, _index, _ia]
_portAuthentication = _portIndexName + "_tim"
call (_portAuthentication + "=time")
call (_arrayIndex + " = _port")
call (_arrayTimeIndex + "= time")
rNPA_hack = time
call {publicvariable _arrayindex; publicvariable _arrayTimeIndex; publicVariable _portauthentication, publicvariable "RNPA_hack", publicvariable _indexVar}
goto "end"
#TimeOut
player sidechat "SO.sqs TimeOut"
call (_indexVar + { = -2})
publicvariable _indexVar
;wait for client to finish transmission or disconnect
~60
#end
rPublicArrayPortsOpen = rPublicArrayPortsOpen - [_port]
exit
Client.sqs
;dinger@raf303.org
_i = 0
fReceiveArray = preprocessfile "publicArray\fReceiveArray.sqf"
rPublicArrayOut = []
rPublicArrayIndex = []
{rPublicArrayIndex = rPublicArrayIndex + [-1]} ForEach rPublicArrays
{call format ["rNPA_ind%1", _i call fDecToAlpha]; _i = _i + 1} ForEach rPublicArrays
_hack = -1
rNPA_ccA = _hack
~(random 1)
player sidechat "ClientProcessRunning"
#MonitorLoop
?rNPA_hack != _hack: rNPA_hack = _hack; call fReceiveArray; player sidechat "hack"
~rNPA_PollInterval
?!rNPA_Terminate:goto "MonitorLoop"
exit
ArrayVar.sqf
/*
Array conversion sublibrary
Dinger March 6, 2003.
www.thechainofcommand.net
*/
If (local server) then {CoCArrayWidget = "Logic" createvehicle [-10000,-10000,0]; CoCArrayNullWidget = "Logic" createvehicle [-900,900,0]; PublicVariable "CoCArrayWidget"; PublicVariable "CoCArrayNullWidget"};
fVarToArray = preprocessfile {fVarToArray.sqf};
fArrayToVar = preprocessfile {fArrayToVar.sqf};
LIBARRAYVAR = 1
fPublicArray.sqf
private ["_array", "_arrayname", "_i"];
_arrayname = _this;
_i = 0;
if (!(_arrayname in rPublicArrays)) then {hintc format ["ERROR: ARRAY %1 NOT IN PUBLIC ARRAY LIST", _arrayname]}
else
{While {(rPublicArrays select _i) != _arrayname} do
{_i = _i + 1}};
if (count rPublicArrayOut > 0) then
{rPublicArrayOut = rPublicArrayOut + [_arrayname]}
else
{
rPublicArrayOut = +[_i];
[] exec "PublicArray\PublicArray.sqs";
};
;
private ["_i", "_ind", "_ia", "_tim", "_channel", "_stemname"];
_i = 0;
while {_i < rPublicArrayCount} do
{
_ia = (_i call fDecToAlpha);
_tim = format ["rNPA_tim%1", _ia];
if (call format ["rNPA_tim%1 > (rPublicArrayIndex select _i)", _ia]) then
{
_ind = (call format ["rNPA_ind%1", _ia]) call fDecToAlpha;
_stemname = format [{%1%2}, rPublicArrayStem, _ind];
player sidechat format ["Receiving: %1 = %2", _stemname, call _stemname];
call format [{%1 = +((_stemname) call fVarToArray)}, (rPublicArrays select _i)];
rPublicArrayIndex set [_i, (call format ["rNPA_tim%1", _ia])];
player sidechat format ["DEBUG - REC: %1 : %2", rPublicArrays select _i, call (rPublicArrays select _i)];
};
_i = _i + 1;
};
;