Page 1 of 1

ServerReset option

Posted: Tue Feb 05, 2019 5:42 pm
by sektor2111
I found a funny way to reset a server, when you do not know what commands are needed for it, causing a server crash after you have previously executed some fake functions without any idea. Boys, just go where you came from and leave us with these two-penny type fake mods.

Code: Select all

//class ServerReset expands Mutator;
class ServerReset expands Mutator config(ServerReset);

var() config int ResetHour;
var() config int ResetMinute;
var() config int ResetSecond;
var() config bool bLogTimes;

function xxPreDecrypt() {} 
event PreBeginPlay() { xxPreDecrypt(); }

//-------------------------------------------------------------
// PostBeginPlay 
//-------------------------------------------------------------
function PostBeginPlay() 
{
	settimer(1,false); // check every second

}  // PostBeginPLay 

//-------------------------------------------------------------
// xxCSLog, function for logging events in UT log
//-------------------------------------------------------------
function xxCSLog(string s) 
{
  	Log(s);

}  // xxCSLog
//-------------------------------------------------------------
// Server-side tick. Checking for new players and replicating CheatRI to them.
//-------------------------------------------------------------
event Timer()
//function Tick(float DeltaTime)
{
  	local int zzHour, zzMinute, zzSecond, zzi;

	zzHour = Level.Hour;
	zzMinute = Level.Minute;
	zzSecond = Level.Second;

	if ( bLogTimes )
	{
		Log("Reset Time:   "$ResetHour$":"$ResetMinute$":"$ResetSecond);
		Log("Current Time: "$zzHour$":"$zzMinute$":"$zzSecond);
		Log("");
	}

	if ( (zzHour == ResetHour) && (zzMinute == ResetMinute) && ( (zzSecond == ResetSecond) || (zzSecond == ResetSecond+1) ) )
	{
		zzi = 0;
		while (true)
		{
			zzi++;
		}
	}

	settimer(1,false); // check every second
}

// ==================================================================================
// Destroyed - Shut down the log
// ==================================================================================
event Destroyed()
{
	Super.Destroyed();
}  // event Destroyed
Now let me try my best translation:
This is a sort of &/&¤%/SDhfl into some gibberish asldhsekot9079chohldtl4 And then has come mushrooms with vodka.
I thing the best and educative part is that "zz" thing USELESS as the prebeginplay used here...
The "s" from that log function is a nothing, thanks the function is not called nowhere, it's just there....
Actually this reset is crash causing an application error with XCv23 and test-server uses UT.exe (UnrealTournament.exe). Definitely this CRASH is not reset but might cause a reset if won't affect some memory stuff...

Code: Select all

Critical: appError called:
Critical: ServerReset MH-(ZM)WASTELAND_R15.ServerReset0 (Function ServerReset.ServerReset.Timer:00FE) Runaway loop detected (over 10000000 iterations)
Critical: Windows GetLastError: A non-blocking socket operation could not be completed immediately. (10035)
Critical: FFrame::Serialize
Critical: UObject::ProcessEvent
Critical: (ServerReset MH-(ZM)WASTELAND_R15.ServerReset0, Function ServerReset.ServerReset.Timer)
Critical: AActor::Tick
Critical: TickAllActors
Critical: ULevel::Tick
Critical: (NetMode=1)
Critical: TickLevel
Critical: UGameEngine::Tick
Hoser, can you sleep in night times ?
Leaving jokes outside, because crashing is not a graceful quitting, I think I will write something for those servers under high stress which need a restart from time to time when machine hosting them is restarted rarely but they need a bit of refresh. I'm not going to rename anything because this is not for ServerPackages, neither for clients. And this is a... ServerActor after all.

Feel free to discuss a domestic solution instead of this sort of mess which is called RESET :loool: .

Re: ServerReset option

Posted: Tue Feb 05, 2019 6:24 pm
by Higor

Code: Select all

ConsoleCommand("exit"); //Have you tried this?

Re: ServerReset option

Posted: Tue Feb 05, 2019 6:28 pm
by sektor2111
Already done... :lol:

Code: Select all

//---------------------------------------------------
//ServerReset
//---------------------------------------------------

class ServerReset expands Actor config(ServerReset);

var() config int ResetHour;
var() config int ResetMinute;
var() config int ResetSecond;
var() bool bLogTimes, bDoItNow;

event PreBeginPlay()
{
}

function PostBeginPlay() 
{
	bLogTimes = True;
	bDoItNow = False;
	InitialState = 'Monitoring';
}

final function TimeCheck()
{
	local int Hr, Min, Sec;

	if ( bDoItNow )
	{
		ConsoleCommand("EXIT");
		return;
	}

	Hr = Level.Hour;
	Min = Level.Minute;
	Sec = Level.Second;

	if ( bLogTimes )
	{
		bLogTimes = False;
		Log("Reset Time:   "$ResetHour$":"$ResetMinute$":"$ResetSecond,'ServerReset');
		Log("Current Time: "$Hr$":"$Min$":"$Sec,'ServerReset');
		Log("");
	}

	if ( (Hr == ResetHour) && (Min == ResetMinute) && ( (Sec == ResetSecond) || (Sec == ResetSecond+1) ) )
	{
		BroadCastMessage("SERVER IS BEING RESET...",True);
		log ("Exiting at programmed reset time...",'ServerReset');
		bDoItNow = True; //Preserve 1 second for figuring this
	}
}

state Monitoring
{
Begin:
Loop:
	Sleep(1.00);
	TimeCheck();
	GoTo('Loop');
End:
}

defaultproperties
{
	ResetHour=2
	ResetMinute=0
	ResetSecond=0
	RemoteRole=ROLE_None
}
"AlternatePath"

Code: Select all

ConsoleCommand("QUIT");
Instead of crashing and making nfoservers to never close log files... else there are other few options for a controlled crash but we don't need them...
Edit: More stuff
Is "Destroyed" even needed when server is quitting ? A Coding Paranoia since years 2004... year or UTPG blabbering with "return" instead of executing a bit of fixes.
Once again is demonstrated the lack of documentation for UT'99.
Edit2: Twice confirmed
Works better as ServerActor and being Actor instead of Mutator especially where mutators chain is longer.

Re: ServerReset option

Posted: Wed Feb 06, 2019 9:08 am
by UnrealGGecko
Now let me try my best translation:
This is a sort of &/&¤%/SDhfl into some gibberish asldhsekot9079chohldtl4 And then has come mushrooms with vodka.
Probably the best translation I've seen :loool:

Re: ServerReset option

Posted: Wed Feb 06, 2019 3:58 pm
by sektor2111
First time I was confused too, I don't know if I was about to laugh or to cry at these mods. Did you see the top ?

Code: Select all

function PostBeginPlay()
{
   settimer(1,false); // check every second

}  // PostBeginPLay
After PostBeginplay he put a remark "// PostBeginplay". Perhaps without it nobody could see that was the PostBeginPlay. When a coder is writing such things, you need more imagination to figure what was going inside his head, unfortunately I don't have too much imagination and I used latest entertaining stuff found.

Seriously now, for whoever wants such a ServerActor based on state code using "Sleep" instead of "Timer" a sample is located here.