Jump to content

Joelma's Time Control


Donnovan

Recommended Posts

IMPORTANT

Thankyou for all reply.

I worked a lot after the release to fix the fps problem, and seens i was not able.

My players had a big fps hit.

So, something i need to do to give this script new life.

There is one possibilitie right now: No clouds.

Draw back: sun on your face on dusk.

Link to comment
Share on other sites

You guys can try this new control_time.sqf is wanted:

//===========================================
// Time share: 50% day, 30% dusk, 20% night.
//===========================================
private ["_multi","_maxFPS","_overcast","_fog"];

// General Settings
_multi = 2; 		// 1 for a 4 hours day, 4/3 for a 3 hours day, 2 a for a 2 hours day.
_maxFPS = false; 	// true = remove clouds and set cycles to minimum for maximum fps.
                        // true require disabled dynamic weather effects.

// increase clouds smoothness and possibily decrease fps
_xtraSmooth = 1.0; 	// Try values from 1.0 to 1.5 - Powerfull value.

// Static weather, if you have disabled dynamic weather effects.
_overcast = 0.25; 	// set overcast, from 0 to 1. If _maxFPS = true, it will be 0.
_fog = 0.05; 		// set fog, from 0 to 1. 0 - no fog, 1 - full fog.

if (isNil "drn_fnc_DynamicWeather_SetWeatherLocal") then {
	if (_maxFPS) then {0 setOvercast 0;} else {0 setOvercast _overcast;};
	0 setFog _fog;
	setWind [0.3, 0.4, true];
};
donn_skipFix = 0;
donn_multi=_multi;
donn_maxFPS=_maxFPS;
donn_xs = _xtraSmooth;
if (!isServer) then {
	"cad_pvar_server_date" addPublicVariableEventHandler {_this call donn_setdate;};
	changeCycles = {
		private ["_col","_cyclesArray","_speed"]; _speed = _this select 0;
		_cya = [[0.5,13],[0.5,15],[0.5,18],[1,21],[1,23],[2,30],[4,40],[5,45],[5,50]];
		_col = 1; if (donn_maxFPS) then {_col = 0;};
		switch true do {
			case (_speed <=   4.0): {donn_cycles = (_cya select 0 select _col)+((ceil((_cya select 0 select _col)*(donn_xs-1))) min 10)};
			case (_speed <=   6.7): {donn_cycles = (_cya select 1 select _col)+((ceil((_cya select 1 select _col)*(donn_xs-1))) min 10)};
			case (_speed <=   8.9): {donn_cycles = (_cya select 2 select _col)+((ceil((_cya select 2 select _col)*(donn_xs-1))) min 10)};
			case (_speed <=  13.4): {donn_cycles = (_cya select 3 select _col)+((ceil((_cya select 3 select _col)*(donn_xs-1))) min 10)};
			case (_speed <=  20.0): {donn_cycles = (_cya select 4 select _col)+((ceil((_cya select 4 select _col)*(donn_xs-1))) min 10)};
			case (_speed <=  40.0): {donn_cycles = (_cya select 5 select _col)+((ceil((_cya select 5 select _col)*(donn_xs-1))) min 10)};
			case (_speed <=  80.0): {donn_cycles = (_cya select 6 select _col)+((ceil((_cya select 6 select _col)*(donn_xs-1))) min 10)};
			case (_speed <= 160.0): {donn_cycles = (_cya select 7 select _col)+((ceil((_cya select 7 select _col)*(donn_xs-1))) min 10)};
			case (_speed >  160.0): {donn_cycles = (_cya select 8 select _col)+((ceil((_cya select 8 select _col)*(donn_xs-1))) min 10)};
		};
	};
	donn_setdate = {
		private ["_maxError","_sendTime","_dateSer","_dateCli","_date_diff"];
		_dateSer = ((_this select 1) select 0);
		_dateCli = date;
		_date_diff = (
			((_dateSer select 0) - (_dateCli select 0))*12*31*24 +
			((_dateSer select 1) - (_dateCli select 1))*31*24 +
			((_dateSer select 2) - (_dateCli select 2))*24 +
			((_dateSer select 3) - (_dateCli select 3)) +
			((_dateSer select 4) - (_dateCli select 4))/60
		);
		diag_log format ["DATE DIFFERENCE: %1", _date_diff*60];
		if (isNil "donn_speed") then {
			donn_speed = ((_this select 1) select 1);
			[donn_speed*donn_multi] call changeCycles;
			donn_skipExit = false;
		} else {
			if (((_this select 1) select 1) != donn_speed) then {
				donn_speed = ((_this select 1) select 1);
				[donn_speed*donn_multi] call changeCycles;
				donn_skipExit = true;
			};
		};
		_sendTime = 30;
		_maxError = 0.5*donn_speed*_sendTime/60;
		if (abs _date_diff*60 > 0 && abs _date_diff*60 <= _maxError) then {donn_skipFix = (_date_diff*3600)/(donn_cycles*_sendTime);};
		if (abs _date_diff*60 >  10) then {donn_skipFix = 0; skipTime _date_diff;};
	};
};
waitUntil {!isNil "donn_speed" && !isNil "donn_skipExit"};
if (isServer) then {donn_cycles = 1;};
while {true} do {
	private ["_speed","_cycleTime","_timePixel","_skipTime","_tickTimeLenAvg","_tickTimeInitial","_tickTime","_tickTimeLenLast"];
	_speed = donn_speed*donn_multi;
	_cycleTime = 1/donn_cycles;
	_timePixel = 0;
	_skipTime = 0;
	_tickTimeLenAvg = _cycleTime;
	_tickTimeInitial = diag_tickTime;
	_tickTime = _tickTimeInitial;
	donn_skipExit=false;
	while {!donn_skipExit} do {
		skipTime ((_timePixel+donn_skipFix)/3600);
		_skipTime=_skipTime+_timePixel;
		_tickTimeLenLast=diag_tickTime-_tickTime;
		_tickTimeLenAvg=(_tickTimeLenAvg*3+_tickTimeLenLast)/4;
		sleep (_cycleTime*2-_tickTimeLenAvg);
		_tickTime=_tickTime+_tickTimeLenLast;
		_timePixel=(_speed-1)*(_tickTime-_tickTimeInitial)-_skipTime;
	};
};
Link to comment
Share on other sites

I haven't seen an FPS hit, but I just logged into my server and I asked players what times their watches said. One said 6:50, another said 7:00 and mine said 6:30.

The new control_time.sqf in post 33 will provide a lot less difference in players sync.

It's really easy to do perfect sync, it's just a matter of correct the error on the client when he receive the server time each 30 seconds (server time is the rule, it also runs the control_time script, with no fps loose).

On the original script i just fix the sync when the error reach 0.5 hours.

On the new script (post 33), i fix the sync ervey 30 seconds. Smooth fix!

Link to comment
Share on other sites

The new control_time.sqf in post 33 will provide a lot less difference in players sync.

It's really easy to do perfect sync, it's just a matter of correct the error on the client when he receive the server time each 30 seconds (server time is the rule, it also runs the control_time script, with no fps loose).

On the original script i just fix the sync when the error reach 0.5 hours.

On the new script (post 33), i fix the sync 30 seconds. Smooth fix!

 

Ok, I'll give it another shot and see what happens. Thanks for working on this!

Link to comment
Share on other sites

Right now you can't set the balance of time in day/dusk/night, it's static at:

50% day

30% dusk (sunset + sunrise)

20% night

But you can set how much real hours a in-game day will have:

 

_multi = 1;   -> 4 hours day
_multi = 4/3; -> 3 hours day
_multi = 2;   -> 2 hours day

If your server have a 3 hours lifetime, use 4/3. If you server have a 4 hours lifetime use 1 or 2.
Link to comment
Share on other sites

Right now you can't set the balance of time in day/dusk/night, it's static at:

50% day

30% dusk (sunset + sunrise)

20% night

But you can set how much real hours a in-game day will have:

 

_multi = 1;   -> 4 hours day
_multi = 4/3; -> 3 hours day
_multi = 2;   -> 2 hours day

If your server have a 3 hours lifetime, use 4/3. If you server have a 4 hours lifetime use 1 or 2.

 

 

Ok then. My server has a 4 hour restart and I want day/sunset/night/sunrise/day so I'd set _multi = 2. 

Link to comment
Share on other sites

No you'd want to set it exactly like this: _multi = 4/3; - 4/3 means 4 divided by 3 which = 1.33333333333333r

 

Think of it this way... what he's saying is that 4hours day means that 4 hours REAL time will make one day go past if the server is up.

 

If you have a 4 hour restart and you set it to 2, you'll get 2 days going by his key above.

 

Which means you should set it to "_multi = 4/3;" as you will see in 3 hours real time which is one full ingame day go past and then another real hour still before a restart, so if your hive ext is around noon 0800-1000 and you set the multi to 4/3 it should be fine. Example, if your hiveext is set to 1000 and you reboot the server, three hours later it will be 1000 ingame again and you should see roughly 6 more ingame hours pass by the restart, possibly more as dusk moves quicker than day.

 

Also it appears that the new time_control addresses an rpt error that I didnt notice before until I checked some previous rpts and all seems smoother and better fps, maybe because of the rpt error fix or better coding, either way its looking good.

Link to comment
Share on other sites

You guys can try this new control_time.sqf is wanted:

//===========================================
// Time share: 50% day, 30% dusk, 20% night.
//===========================================
private ["_multi","_maxFPS","_overcast","_fog"];

// General Settings
_multi = 2; 		// 1 for a 4 hours day, 4/3 for a 3 hours day, 2 a for a 2 hours day.
_maxFPS = false; 	// true = remove clouds and set cycles to minimum for maximum fps.
                        // true require disabled dynamic weather effects.

// increase clouds smoothness and possibily decrease fps
_xtraSmooth = 1.0; 	// Try values from 1.0 to 1.5 - Powerfull value.

// Static weather, if you have disabled dynamic weather effects.
_overcast = 0.25; 	// set overcast, from 0 to 1. If _maxFPS = true, it will be 0.
_fog = 0.05; 		// set fog, from 0 to 1. 0 - no fog, 1 - full fog.

if (isNil "drn_fnc_DynamicWeather_SetWeatherLocal") then {
	if (_maxFPS) then {0 setOvercast 0;} else {0 setOvercast _overcast;};
	0 setFog _fog;
	setWind [0.3, 0.4, true];
};
donn_skipFix = 0;
donn_multi=_multi;
donn_maxFPS=_maxFPS;
donn_xs = _xtraSmooth;
if (!isServer) then {
	"cad_pvar_server_date" addPublicVariableEventHandler {_this call donn_setdate;};
	changeCycles = {
		private ["_col","_cyclesArray","_speed"]; _speed = _this select 0;
		_cya = [[0.5,13],[0.5,15],[0.5,18],[1,21],[1,23],[2,30],[4,40],[5,45],[5,50]];
		_col = 1; if (donn_maxFPS) then {_col = 0;};
		switch true do {
			case (_speed <=   4.0): {donn_cycles = (_cya select 0 select _col)+((ceil((_cya select 0 select _col)*(donn_xs-1))) min 10)};
			case (_speed <=   6.7): {donn_cycles = (_cya select 1 select _col)+((ceil((_cya select 1 select _col)*(donn_xs-1))) min 10)};
			case (_speed <=   8.9): {donn_cycles = (_cya select 2 select _col)+((ceil((_cya select 2 select _col)*(donn_xs-1))) min 10)};
			case (_speed <=  13.4): {donn_cycles = (_cya select 3 select _col)+((ceil((_cya select 3 select _col)*(donn_xs-1))) min 10)};
			case (_speed <=  20.0): {donn_cycles = (_cya select 4 select _col)+((ceil((_cya select 4 select _col)*(donn_xs-1))) min 10)};
			case (_speed <=  40.0): {donn_cycles = (_cya select 5 select _col)+((ceil((_cya select 5 select _col)*(donn_xs-1))) min 10)};
			case (_speed <=  80.0): {donn_cycles = (_cya select 6 select _col)+((ceil((_cya select 6 select _col)*(donn_xs-1))) min 10)};
			case (_speed <= 160.0): {donn_cycles = (_cya select 7 select _col)+((ceil((_cya select 7 select _col)*(donn_xs-1))) min 10)};
			case (_speed >  160.0): {donn_cycles = (_cya select 8 select _col)+((ceil((_cya select 8 select _col)*(donn_xs-1))) min 10)};
		};
	};
	donn_setdate = {
		private ["_maxError","_sendTime","_dateSer","_dateCli","_date_diff"];
		_dateSer = ((_this select 1) select 0);
		_dateCli = date;
		_date_diff = (
			((_dateSer select 0) - (_dateCli select 0))*12*31*24 +
			((_dateSer select 1) - (_dateCli select 1))*31*24 +
			((_dateSer select 2) - (_dateCli select 2))*24 +
			((_dateSer select 3) - (_dateCli select 3)) +
			((_dateSer select 4) - (_dateCli select 4))/60
		);
		diag_log format ["DATE DIFFERENCE: %1", _date_diff*60];
		if (isNil "donn_speed") then {
			donn_speed = ((_this select 1) select 1);
			[donn_speed*donn_multi] call changeCycles;
			donn_skipExit = false;
		} else {
			if (((_this select 1) select 1) != donn_speed) then {
				donn_speed = ((_this select 1) select 1);
				[donn_speed*donn_multi] call changeCycles;
				donn_skipExit = true;
			};
		};
		_sendTime = 30;
		_maxError = 0.5*donn_speed*_sendTime/60;
		if (abs _date_diff*60 > 0 && abs _date_diff*60 <= _maxError) then {donn_skipFix = (_date_diff*3600)/(donn_cycles*_sendTime);};
		if (abs _date_diff*60 >  10) then {donn_skipFix = 0; skipTime _date_diff;};
	};
};
waitUntil {!isNil "donn_speed" && !isNil "donn_skipExit"};
if (isServer) then {donn_cycles = 1;};
while {true} do {
	private ["_speed","_cycleTime","_timePixel","_skipTime","_tickTimeLenAvg","_tickTimeInitial","_tickTime","_tickTimeLenLast"];
	_speed = donn_speed*donn_multi;
	_cycleTime = 1/donn_cycles;
	_timePixel = 0;
	_skipTime = 0;
	_tickTimeLenAvg = _cycleTime;
	_tickTimeInitial = diag_tickTime;
	_tickTime = _tickTimeInitial;
	donn_skipExit=false;
	while {!donn_skipExit} do {
		skipTime ((_timePixel+donn_skipFix)/3600);
		_skipTime=_skipTime+_timePixel;
		_tickTimeLenLast=diag_tickTime-_tickTime;
		_tickTimeLenAvg=(_tickTimeLenAvg*3+_tickTimeLenLast)/4;
		sleep (_cycleTime*2-_tickTimeLenAvg);
		_tickTime=_tickTime+_tickTimeLenLast;
		_timePixel=(_speed-1)*(_tickTime-_tickTimeInitial)-_skipTime;
	};
};



Working pretty good, however the clouds look a bit choppy/fast set at 1.0 IMO, will try some other settings later!

Thanks for this thread!

Link to comment
Share on other sites

justcametomind,

"set at 1.0" What have you set to 1.0, _xtraSmooth??

You have _maxFPS set to false?

You got choppy clouds in what ingame time?

We can fix clouds smoothness on this specific time.

If clouds are choppy in general, you can try to increase _xtraSmooth to 1.2 or 1.4.

If you increase it, try to notice the fps change, it may decrease, but is necessary to gain more cloud smoothness.

Link to comment
Share on other sites

justcametomind,

"set at 1.0" What have you set to 1.0, _xtraSmooth??

You have _maxFPS set to false?

You got choppy clouds in what ingame time?

We can fix clouds smoothness on this specific time.

If clouds are choppy in general, you can try to increase _xtraSmooth to 1.2 or 1.4.

If you increase it, try to notice the fps change, it may decrease, but is necessary to gain more cloud smoothness.

Yes _xtraSmooth = 1.0

_maxFPS = false

_multi = 4/3

I will mess with the xtrasmooth setting later

Anyway to slow the clouds down?

Link to comment
Share on other sites

BetterDeadThanZed,

You is right, there is a bug about:

- Clouds appears at night with _maxFPS = true.

- The error correction code have a bug that happens for some minutes when time speed changes.

Those two are fixed, and i will post it soon.

The fix for fps problem after night is still a work in progress.

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...