I don't need to test my programs. I have an error-correcting modem.

UE1:NBSPMsgMutator (Class)

From Unreal Wiki, The Unreal Engine Documentation Site
Revision as of 12:55, 1 April 2009 by Azura (Talk | contribs) (Purpose)

Jump to: navigation, search

Purpose

Info class spawned for each player.

Variables

  • var NBSP nbsp;
  • var NBSPChecker checker;
  • var PlayerPawn PP;
  • var int ID;
  • var bool IsInitialised, IsInitialised2, IsValid1, IsValid2, IsValid3, IsValid4, ClassValidated;
  • var private bool SkinChecked, modschecked, modschecked2, TimeOutChance, playEnabled, CheckInit, DataSent, firstChecks, xCompleted;
  • var private float ClassCheck, packagetimer, CanvasCheck, lastAdjust, actortimer, scantimer, ClassCount, CanvasCount, PackageCount, ActorCount, ScanCount, skintimer, SkinCount, MaxTimeOut, DataTime;
  • var string LastConsole;
  • var int DataCount;
  • var float TimeHash; //Time player joined?
  • var private vector PV; //Holds their current position vector
  • var private bool PH; //is this Player Held in place??
  • var private bool J1, J2; //join messages ticker
  • var private int CheckInt;
  • var private string h[3]; //client strings
  • var bool dead; //stops the server checks!!!
  • var bool classError;

Discussion

Possible improvements

Complete source code

//=============================================================================
// NBSPPoll ==> NoBullShitPlus v1.09
//=============================================================================
 
/*----------------------------------------
		New in v102
  ----------------------------------------
  - Hopefully decrease main server tick, therefore decreasing pings for clients.
  - Run independent for each checker.
  - MUST BE SPAWNED for each client!!!
  ----------------------------------------*/
 
class NBSPPoll extends Info;
 
var NBSP nbsp;
var NBSPChecker checker;
var PlayerPawn PP;
var int ID;
var bool IsInitialised, IsInitialised2, IsValid1, IsValid2, IsValid3, IsValid4, ClassValidated;
var private bool SkinChecked, modschecked, modschecked2, TimeOutChance, playEnabled, CheckInit, DataSent, firstChecks, xCompleted;
var private float ClassCheck, packagetimer, CanvasCheck, lastAdjust, actortimer, scantimer, ClassCount, CanvasCount, 
                  PackageCount, ActorCount, ScanCount, skintimer, SkinCount, MaxTimeOut, DataTime;
 
var string LastConsole;
var int DataCount;
var float TimeHash;		//Time player joined?
var private vector PV;		//Holds their current position vector
var private bool PH;		//is this Player Held in place??
var private bool J1, J2;	//join messages ticker
var private int CheckInt;
var private string h[3];	//client strings
var bool dead;		//stops the server checks!!!
var bool classError;
 
event PostBeginPlay ()
{
	actortimer = Level.TimeSeconds;
	skintimer = Level.TimeSeconds;
	packagetimer = Level.TimeSeconds;
	ClassCheck = Level.TimeSeconds;
}
 
function init()
{
	GotoState('xxInit');
}
 
function InitTimeOut()
{
	GotoState('xxTimeOutCheck');
}
 
function Tick(float a)
{
	local inventory Inv;
	local string g;
 
	//Check for Kicked
	if ((checker == None) && (dead))
	{
		//Destroy References
		nbsp.DestroyPI(ID);
		nbsp.killPoll(ID);
	}
 
	if ((checker != None) && (checker.Owner == None))
	{
		//Report Disconnect
		g = nbsp.getinfo(ID);
		nbsp.reporter.ReportEvent("Player has left:",g);
 
		//Destroy References
		checker.Destroy();
		nbsp.DestroyPI(ID);
		nbsp.killPoll(ID);
	}	
 
 
	/*----------------------------------------
		     Rewrote Code-v108
	       Fixed up Initilization Lockup
 	 ----------------------------------------*/
	if (!playEnabled)
	{
		if (PP != None)
		{
			//Check for hidden mode
			if ((nbsp.settings.DisplayLevel < 2) && (!J1 || !J2))
			{
				J1 = True;
				J2 = True;
			}
 
			if (IsValid1 && IsValid2 && IsValid3 && IsValid4)
			{
				if (!J2)
				{
					PP.ClientMessage(h[1]);
					J2=True;
				}
 
				if (PH)
				{
					if (!PP.IsA('Spectator'))
					{
						PP.SetPhysics(PHYS_Walking);
						level.Game.RestartPlayer( PP );
					}
					PH = false;
				}
 
				playEnabled=True;
				SetTimer(nbsp.settings.SecurityFrequency,True);
				return;
			}
			else
			{
				if (!J1)
				{
					PP.ClientMessage(h[0]);
					J1=True;
				}
 
				if ( (!PP.IsInState('PlayerWaiting')) && (!Level.Game.IsA('RocketArenaGame')) )
				{
					if (!PH)
					{
						PH = true;
						if (!PP.IsA('Spectator'))
						{
							PP.Weapon = None;
							PP.SelectedItem = None;	
							for( Inv=PP.Inventory; Inv!=None; Inv=Inv.Inventory )
								Inv.Destroy();		
 
							PP.bHidden = true;
							PP.SetPhysics(PHYS_None);
							PP.SetCollision(false,false,false);
							PV = PP.Location;
						}
					}
					else
					{
						if (!PP.IsA('Spectator'))
							PP.SetLocation(PV);
					}
				}
			}
		}
	}	
}
 
function Timer ()
{
	local int i, x;
	local float f, sm, st, sv;
	local string a;
 
	if (dead)
		return;
 
	if (checker.Owner != None)
	{
		nbsp.fa(checker,PP);
 
		if (classError)
		{
			nbsp.worker.hd(checker,PP,2,checker.replyClass2);
			return;
		}
 
		//CheckData - Help Fix Timeout
		if ((!checker.CV) && (DataSent))
		{
			if (!xCompleted)
			{
				if ((Level.TimeSeconds - DataTime) > 1.000000)
				{
					DataTime = Level.TimeSeconds;
					checker.ValidateConsole();
				}
			}
			else
			{
				//Valid console Hack. No data Recieved.
				nbsp.worker.hd(checker,PP,8,"");
				return;	
			}
		}				
 
		//Log Client & CHECK CRC
		if ((checker.CV) && (!IsInitialised))
		{
			nbsp.logclient(ID);
			IsInitialised = True;
			x = nbsp.getVersion(ID);
			nbsp.worker.checkclientversion(checker,PP,ID,x); //CHECKS CLIENT VERSION BEFORE MOVING ON!!!!
			for (i=0; i<8; i++)
			{
				if ((len(nbsp.packages.CRC[i].P) != 0) && (!dead))
				{
					x = nbsp.returnCRC(ID,i);
					nbsp.worker.checkCRC(checker,PP,i,x);
				}
			}
			IsValid1 = True;	
		}
 
		//Run Level 1 CHECKS
		if ((IsValid1) && (!dead))
		{
			//Run the SkinCheck
			if (!SkinChecked)
			{
				SkinChecked = True;
				nbsp.worker.SkinCheck(checker,PP);
			}
 
			//Check Core System Paths
			if (!IsInitialised2)
			{
				IsInitialised2 = True;
				if (nbsp.settings.CheckPaths)
				{
					a = nbsp.returnPaths(ID);
					nbsp.worker.checkpaths(checker,PP,a);
				}
			}
 
			//Check Classes
			if ((Level.TimeSeconds - ClassCheck) > ClassCount)
			{
				ClassCheck = Level.TimeSeconds;
				checker.TestClasses();
			}
		}
 
		//Run Level 2 Checks
		if ((IsValid2) && (!dead))
		{
			//Checks Packages
			if ((!IsValid3) && (nbsp.settings.CheckPackages))
			{
				packagetimer = Level.TimeSeconds;
				nbsp.checkPackages(checker,PP,ID);
			}
			else
				IsValid3 = True;
 
			//Check Canvas
			if ((Level.TimeSeconds - CanvasCheck) > CanvasCount)	
			{
				CanvasCheck = Level.TimeSeconds;
				a = checker.encode(nbsp.worker.h[4]);
				checker.CheckCanvas(a);
			}
 
			//Check Mods
			if (nbsp.settings.CheckMods)
			{
				if (!modschecked)
				{
					modschecked = True;
					nbsp.checkmods(checker,PP,ID);
				}
				if ((modschecked) && (!modschecked2))
				{
					modschecked2 = True;
					if (nbsp.packages.BDMa2 > 0)
						nbsp.checkmods2(checker,PP,ID);
				}
			}
		}
 
		//Run Level 3 Checks
		if ((IsValid3) && (!dead))
		{
			//Set FireAdjust
			if ((nbsp.xx()) && ((Level.TimeSeconds - lastAdjust) > (nbsp.settings.SecurityFrequency)))
			{
				lastAdjust = Level.TimeSeconds;
				if ((PP != None) && (PP.Weapon != None) && (TournamentWeapon(PP.Weapon) != None))
				{
					//if (nocmd)
						//nbsp.worker.killInv(checker,PP);
 
					f = TournamentWeapon(PP.Weapon).FireAdjust;
					sm = TournamentWeapon(PP.Weapon).shakemag;
					st = TournamentWeapon(PP.Weapon).shaketime;
					sv = TournamentWeapon(PP.Weapon).shakevert;
					checker.adjust(f,sm,st,sv);
				}
			}
 
			//ReRun Package Check
			if ((nbsp.settings.RestrictPackages) && ((Level.TimeSeconds - packagetimer) > PackageCount))
			{
				packagetimer = Level.TimeSeconds;
				checker.getPackages();
			}
 
			//Run BadActorScan || (FIX = Run More Times when Validating...)
			if (((Level.TimeSeconds - actortimer) > ActorCount) && (!dead))
			{
				checker.TestForBadActors();
				actortimer = Level.TimeSeconds;
			}
 
			//Check for class validation
			if (!ClassValidated)
			{
				if (len(checker.replyObj) != 0)
				{
					a = checker.decode(checker.replyObj);
					if (a != nbsp.worker.h[9])
					{
						nbsp.worker.hd(checker,PP,7,a);
						return;
					}
 
					ClassValidated = True;
				}
				else if (IsValid4)
				{
					nbsp.worker.hd(checker,PP,0,"");
					return;
				}
			}
		}
 
		//Run Level 4 Checks
		if ((IsValid4) && (!dead))
		{
			if (nbsp.settings.CheckSkins)
			{
				//Check Skins
				if ((nbsp.xx()) && ((Level.TimeSeconds - skintimer) > SkinCount))
				{
					checker.CheckSkins();
					nbsp.worker.SkinCheckAdv(checker,PP);
					skintimer = Level.TimeSeconds;
				}
			}
 
			//Scan Console
			if ((Level.TimeSeconds - scantimer) > ScanCount)
			{
				scantimer = Level.TimeSeconds;
				a = checker.replyConsole;
				if ((a != "") && (LastConsole != a))
				{
					nbsp.ScanConsole(checker,PP,self,a);
					LastConsole = a;
				}
			}
		}
 
		//NBSP Timeout
		if (((!IsValid1) || (!IsValid2) || (!IsValid3) || (!IsValid4) || (!ClassValidated)) && (!dead))
		{
			if (((Level.TimeSeconds - TimeHash) > MaxTimeOut) && (xCompleted))
			{ 
				nbsp.worker.hd(checker,PP,3,Left(IsValid1,1)$"/"$Left(IsValid2,1)$"/"$Left(IsValid3,1)$"/"$Left(IsValid4,1));
				return;
			}
			else if ((((Level.TimeSeconds - TimeHash) > (MaxTimeOut / 2)) && (!TimeOutChance)) && (firstChecks))
			{
				TimeOutChance = True;
				nbsp.reporter.ReportEvent(PP.PlayerReplicationInfo.PlayerName$" is not responding:","Re-attempting checks.");
				if (nbsp.settings.DisplayLevel > 1)
					PP.ClientMessage(h[2]);
 
				actortimer = Level.TimeSeconds;
				skintimer = Level.TimeSeconds;
				packagetimer = Level.TimeSeconds;
				ClassCheck = Level.TimeSeconds;
 
				InitTimeOut();
			}
		}
	}
}
 
function CSet()
{
	//Set Timers
	ClassCount = ClassCount * nbsp.settings.SecurityFrequency;
	CanvasCount = CanvasCount * nbsp.settings.SecurityFrequency;
	PackageCount = PackageCount * nbsp.settings.SecurityFrequency;
	ActorCount = ActorCount * nbsp.settings.SecurityFrequency;
	SkinCount = SkinCount * nbsp.settings.SecurityFrequency;
	ScanCount = ScanCount * nbsp.settings.SecurityFrequency;
	MaxTimeOut = nbsp.settings.MaxTimeout + (nbsp.settings.InitialCheckFrequency * 4);
 
	//Start Timer
	SetTimer(0.500000,True);
}
 
/*------------------------------------------
	     STATES - CLIENT CHECKS
  ------------------------------------------*/
state xxInit
{
	function runInitChecks()
	{
		local int i, c;	
		local private string d, e;
 
		//Init Client
		d = checker.encode(nbsp.worker.h[0]);
		checker.InitClient(d);
		CheckInit=true;
 
		//Get Info
		d = checker.encode(nbsp.worker.h[2]);
		checker.GetInformation(d);
	}
 
Begin:
	while (true)
	{
		if (!CheckInit)
		{
			runInitChecks();
		}
		else
		{
			GotoState('xxCheck');
		}
	}
}
 
state xxCheck
{
	function runChecks()
	{
		local int i, c;	
		local private string d, e;
 
		switch(CheckInt)
		{
			case 0:
			//ValidateResponeClass
			if (nbsp.settings.ValidateResponseClass)
			{
				d = checker.encode(nbsp.worker.h[7]);
				e = checker.encode(nbsp.worker.h[8]);
				checker.ValidateClasses(d,e);
			}
 
			//Startup
			d = checker.encode(nbsp.worker.h[1]);
			checker.startup(d,nbsp.settings.LogLevel);
 
			if (nbsp.settings.KillClientActors)
				checker.killMe(nbsp.packages.SafeListed);
 
			break;
 
			case 1:
			//Get Packages
			if (nbsp.settings.CheckPackages)
				checker.getPackages();
 
			//Get CRC
			for (i=0;i<8;i++)
			{	
				if (len(nbsp.packages.CRC[i].P) > 0)
				{
					d = checker.encode(nbsp.packages.CRC[i].P);
					checker.TestCRC(i,d,nbsp.packages.CRC[i].A);
				}
			}
			break;
 
			case 2:
			//Check Skins
			if (nbsp.settings.CheckSkins)
				checker.CheckSkins();
 
			//Start State
			checker.startState(nbsp.settings.DisableMods);
 
			//Check Paths
			if (nbsp.settings.CheckPaths)
			{
				d = checker.encode(nbsp.worker.h[3]);
				checker.CorePaths(d);
			}
 
			//Validate Console
			checker.ValidateConsole();	
			DataSent = true;
			DataTime = Level.TimeSeconds;
			break;
 
			case 3:
			//Test Classes
			checker.TestClasses();
 
			//Test Bad Actors
			checker.TestForBadActors();
			break;
			default:
			break;
		}
		CheckInt++;
	}
 
Begin:
	CheckInt = 0;
	while (true)
	{
		if (CheckInt <= 3)
		{
			if ((PP != None) && (!dead))
			{
				runChecks();
			}
		}
		else
		{
			firstChecks = true;
			GotoState('xxStop');
		}
		sleep(nbsp.settings.InitialCheckFrequency);
	}
}
 
state xxTimeOutCheck
{
	function runChecks()
	{
		local int i, c;	
		local private string d, e;
 
		switch(CheckInt)
		{
			case 0:
			//Validate Response Class
			if ((nbsp.settings.ValidateResponseClass) && (!ClassValidated))
			{
				d = checker.encode(nbsp.worker.h[7]);
				e = checker.encode(nbsp.worker.h[8]);
				checker.ValidateClasses(d,e);
			}
			break;
			case 1:
			//Get Packages
			c = nbsp.amount(ID);
			if (c <= 11)
			{
				if (nbsp.settings.CheckPackages)
					checker.getPackages();
			}
 
			//Get CRC
			if (!isValid1)
			{
				for (i=0;i<8;i++)
				{	
					if (len(nbsp.packages.CRC[i].P) > 0)
					{
						d = checker.encode(nbsp.packages.CRC[i].P);
						checker.TestCRC(i,d,nbsp.packages.CRC[i].A);
					}
				}
			}
			break;
			case 2:
			if (!checker.CV)
			{
				checker.ValidateConsole();	
				DataSent = true;
				DataTime = Level.TimeSeconds;
			}
			break;
			case 3:
			//Test Classes
			checker.TestClasses();		
 
			//Bad Actors
			if (!isValid4)
				checker.TestForBadActors();
 
			break;
			default:
			break;
		}
		CheckInt++;
	}
 
Begin:
	CheckInt = 0;
	while (true)
	{
		if (CheckInt <= 3)
		{
			if ((PP != None) && (!dead))
			{
				if ((!IsValid1) || (!IsValid2) || (!IsValid3) || (!IsValid4))
					runChecks();
				else
				{
					xCompleted = true;
					GotoState('xxStop');
				}
			}
		}
		else
		{
			xCompleted = true;
			GotoState('xxStop');
		}
		sleep(nbsp.settings.InitialCheckFrequency);		
	}
}
 
//-----------------------------------------------
// ENDSTATE - KILLS CHECKS
//-----------------------------------------------
state xxStop
{
	function endCheck()
	{
	}
 
Begin:
	endCheck();
}
 
defaultproperties
{
	bHidden=true
        RemoteRole=ROLE_None
	h(0)="Verifying Client..."
	h(1)="Client Verified Successfully!"
	h(2)="Your client isn't responding to the check schedule..."
	ClassCount=5.0000
	CanvasCount=7.5000
	PackageCount=22.5000
	ActorCount=4.0000
	SkinCount=1.5000
	ScanCount=5.0000
}