logo
Main

Forums

Downloads

Unreal-Netiquette

Donate for Oldunreal:
Donate

borderline

Links to our wiki:
Wiki

Walkthrough

Links

Tutorials

Unreal Reference

Usermaps

borderline

Contact us:
Submit News
Page Index Toggle Pages: 1 Send TopicPrint
Hot Topic (More than 10 Replies) Invalid operations in the standard game packages. (Read 2672 times)
Masterkent
Developer Team
Offline



Posts: 845
Location: Russia
Joined: Apr 5th, 2013
Gender: Male
Invalid operations in the standard game packages.
Oct 7th, 2014 at 5:44pm
Print Post  
This thread is about invalid operations (accessing non-static variables or functions through none, division by zero, out-of-bound array access) in the standard game packages (Engine.u, UnrealShare.u, UnrealI.u, UPak.u) that happen from time to time under some circumstances.

There are a lot of such places in scripts, I'll describe the most frequently observable first, description of others will be added later.

Even though these issues are mostly not critical, they should be resolved. Some ScriptWarnings help to detect severe bugs in custom scripts, but it's hard to find useful warnings among tons of spam produced by standard scripts.

1. ScriptWarning: Rifle MapName.Rifle2 (Function UnrealI.Rifle.ProcessTraceHit:02E0) Accessed None 'Other'

This happens due to missing check Other != None in

Code
Select All
if (Other == Level || Other.bWorldGeometry) 


Other may be None when the shooter aims too far, so the line checked by Trace doesn't cross anything.

2. ScriptWarning: GESBioRifle MapName.GESBioRifle (Function UnrealI.GESBioRifle.RateSelf:00B1) Vector division by zero error.

There is only one place where we have division in UnrealI.GESBioRifle.RateSelf:

Code
Select All
bRetreating = ( ((EnemyDir/EnemyDist) Dot Owner.Velocity) < -0.7 ); 


I dunno why EnemyDist happens to be zero so often, but the logs are full of such warnings nevertheless.
  
Back to top
 
IP Logged
 
Masterkent
Developer Team
Offline



Posts: 845
Location: Russia
Joined: Apr 5th, 2013
Gender: Male
Re: Invalid operations in the standard game packages.
Reply #1 - Oct 7th, 2014 at 6:19pm
Print Post  
3. ScriptWarning: SearchLight MapName.SearchLight (State UnrealShare.Flashlight.DeActivated:0006) Accessed None 'S'

4. ScriptWarning: RazorBladeAlt MapName.RazorBladeAlt (Function UnrealI.RazorBladeAlt.Flying.Tick:0030) Accessed None 'Instigator'

Common scenario: a SkaarjOfficer dies, the pawn object is destroyed, Instigator becomes none.
  
Back to top
 
IP Logged
 
Smirftsch
Forum Administrator
*****
Offline



Posts: 7471
Location: at home
Joined: Apr 30th, 1998
Gender: Male
Re: Invalid operations in the standard game packages.
Reply #2 - Oct 8th, 2014 at 6:24am
Print Post  
thanks, will check & fix those

And btw, the "Vector division by zero error" was specifically added for this purpose, to find such situations, so it fully serves its purpose  Smiley
  

Sometimes you have to lose a fight to win the war.
Back to top
WWWICQ  
IP Logged
 
Smirftsch
Forum Administrator
*****
Offline



Posts: 7471
Location: at home
Joined: Apr 30th, 1998
Gender: Male
Re: Invalid operations in the standard game packages.
Reply #3 - Oct 10th, 2014 at 9:20am
Print Post  
Masterkent wrote on Oct 7th, 2014 at 6:19pm:
3. ScriptWarning: SearchLight MapName.SearchLight (State UnrealShare.Flashlight.DeActivated:0006) Accessed None 'S'.

That's a bit funny one, since we have
function BeginState()
     {
           bActive = true;
           TimeChange = 0;
           Owner.PlaySound(ActivateSound);
           GetAxes(Pawn(Owner).ViewRotation,X,Y,Z);
           EndTrace = Pawn(Owner).Location + 10000* Vector(Pawn(Owner).ViewRotation);
           Trace(HitLocation,HitNormal,EndTrace,Pawn(Owner).Location+Y*17);
           s = Spawn(class'FlashLightBeam',Owner, '', HitLocation+HitNormal*40);
           s.LightHue = LightHue;
           s.LightRadius = LightRadius;
           if (Charge<400) s.LightBrightness=byte(Charge*0.6+10);
           if (s==None) GoToState('DeActivated');
     }

a few lines above Smiley
  

Sometimes you have to lose a fight to win the war.
Back to top
WWWICQ  
IP Logged
 
BobIsUnreal
God Member
*****
Offline


Guy who has too much time
invested to quit now

Posts: 732
Joined: Apr 12th, 2010
Gender: Male
Re: Invalid operations in the standard game packages.
Reply #4 - Oct 10th, 2014 at 7:17pm
Print Post  
if (s==None) GoToState('DeActivated');


yeah ... but wouldnt it be awsome when you died with the flashlight on it stayed lit , and fell to the drop shining its bean around as it dropped to the floor.....
  

[REM_img]http://i.imgur.com/V3OSsDu.gif.disable[/img]http://i.imgur.com/JOu38Gs.gif
Back to top
IP Logged
 
Smirftsch
Forum Administrator
*****
Offline



Posts: 7471
Location: at home
Joined: Apr 30th, 1998
Gender: Male
Re: Invalid operations in the standard game packages.
Reply #5 - Oct 12th, 2014 at 7:10am
Print Post  
indeed, but I think such things we better leave for the modders Smiley
  

Sometimes you have to lose a fight to win the war.
Back to top
WWWICQ  
IP Logged
 
Masterkent
Developer Team
Offline



Posts: 845
Location: Russia
Joined: Apr 5th, 2013
Gender: Male
Re: Invalid operations in the standard game packages.
Reply #6 - Oct 20th, 2014 at 4:47pm
Print Post  
5. ScriptWarning: Eightball MapName.Eightball (Function UnrealShare.Eightball.NormalFire.Tick:00D2) Accessed None 'Target'

6. ScriptWarning: NaliPriest MapName.NaliPriest (State UnrealShare.ScriptedPawn.TriggerAlarm:030E) Accessed None 'Enemy'

7. ScriptWarning: Mercenary MapName.Mercenary (Function UnrealShare.ScriptedPawn.Trigger:0052) Accessed None 'EventInstigator'

8. ScriptWarning: SpecialEvent MapName.SpecialEvent (Function Engine.SpecialEvent.DamageInstigator.Trigger:0059) Accessed None 'EventInstigator'

Smirftsch wrote on Oct 8th, 2014 at 6:24am:
And btw, the "Vector division by zero error" was specifically added for this purpose, to find such situations, so it fully serves its purpose  Smiley

I wonder if there are scripters who used division by zero in order to get vectors with infinite X, Y, Z.
  
Back to top
 
IP Logged
 
Smirftsch
Forum Administrator
*****
Offline



Posts: 7471
Location: at home
Joined: Apr 30th, 1998
Gender: Male
Re: Invalid operations in the standard game packages.
Reply #7 - Oct 21st, 2014 at 5:54am
Print Post  
Masterkent wrote on Oct 20th, 2014 at 4:47pm:
5. ScriptWarning: Eightball MapName.Eightball (Function UnrealShare.Eightball.NormalFire.Tick:00D2) Accessed None 'Target'

6. ScriptWarning: NaliPriest MapName.NaliPriest (State UnrealShare.ScriptedPawn.TriggerAlarm:030E) Accessed None 'Enemy'

7. ScriptWarning: Mercenary MapName.Mercenary (Function UnrealShare.ScriptedPawn.Trigger:0052) Accessed None 'EventInstigator'

8. ScriptWarning: SpecialEvent MapName.SpecialEvent (Function Engine.SpecialEvent.DamageInstigator.Trigger:0059) Accessed None 'EventInstigator'

And I thought we pretty much ruled out all None's over the years ^^

Masterkent wrote on Oct 20th, 2014 at 4:47pm:
Smirftsch wrote on Oct 8th, 2014 at 6:24am:
And btw, the "Vector division by zero error" was specifically added for this purpose, to find such situations, so it fully serves its purpose  Smiley

I wonder if there are scripters who used division by zero in order to get vectors with infinite X, Y, Z.

I think I wouldn't be even surprised, but division by zero == evil.
  

Sometimes you have to lose a fight to win the war.
Back to top
WWWICQ  
IP Logged
 
Masterkent
Developer Team
Offline



Posts: 845
Location: Russia
Joined: Apr 5th, 2013
Gender: Male
Re: Invalid operations in the standard game packages.
Reply #8 - Oct 21st, 2014 at 8:31am
Print Post  
Smirftsch wrote on Oct 21st, 2014 at 5:54am:
I think I wouldn't be even surprised, but division by zero == evil.

In C++ we can use std::numeric_limits<float>::infinity() in order to get infinite value. As far as I can see, UScript does not provide any similar function, and the only way to get infinity then is to divide a non-zero value by zero.

Sometimes there is a need in special values. For example, assume that we want to synchronize projectile's location and velocity observable on a client with the corresponding location and velocity of the same projectile on a server. The synchronization should take place only when the client receives new data from the server. This could be implemented as follows:

Code
Select All
var vector ReplicatedLocation, ReplicatedVelocity;

replication
{
    reliable if (Role == ROLE_Authority)
        ReplicatedLocation, ReplicatedVelocity;
}

simulated function Tick(float DeltaTime)
{
    if (Level.NetMode == NM_Client)
    {
        if (IsFiniteVector(ReplicatedLocation))
        {
            SetLocation(ReplicatedLocation);
            ReplicatedLocation = InfiniteVector();
        }
        if (IsFiniteVector(ReplicatedVelocity))
        {
            Velocity = ReplicatedVelocity;
            SetRotation(rotator(Velocity));
            ReplicatedVelocity = InfiniteVector();
        }
    }
    else
    {
        ReplicatedLocation = Location;
        ReplicatedVelocity = Velocity;
    }
}

static function vector InfiniteVector()
{
    return vect(1, 1, 1) / 0.0;
}

static function bool IsFiniteVector(vector V)
{
    return 1 / VSize(V) != 0;
} 


If ReplicatedLocation or ReplicatedVelocity is just updated, we perform the synchronization; otherwise, ReplicatedLocation or ReplicatedVelocity holds the special value (that we can treat as "not-a-vector") which is ignored, so the client updates the projectile's position using the simulation algorithms (enabled due to Role == ROLE_SimulatedProxy).

Although there are alternative ways to implement such a thing, this method looks reasonable enough, IMO. On the other hand, in most cases division by zero is unintended and erroneous behavior, and it would be good if such errors were diagnosed. So, this handling of division by zero appears to be a useful feature, but we should remember that it may also have some drawbacks.
  
Back to top
 
IP Logged
 
.:..:
Board Moderator
Developer Team
*****
Offline



Posts: 1414
Location: Finland
Joined: Aug 16th, 2005
Gender: Male
Re: Invalid operations in the standard game packages.
Reply #9 - Oct 21st, 2014 at 7:10pm
Print Post  
I always go with a specific vector value (mostly zero):
Code
Select All
simulated function PostNetReceive()
{
	if ( ReplicatedLocation!=vect(0,0,0) )
	{
		SetLocation(ReplicatedLocation);
		ReplicatedLocation = vect(0,0,0);
	}
	if ( ReplicatedVelocity!=vect(0.5,0,0) )
	{
		Velocity = ReplicatedVelocity;
		SetRotation(rotator(Velocity));
		ReplicatedVelocity = vect(0.5,0,0);
	}
} 


A vector value of something like 0.5 is fail proof in this case because vector components are replicated as integers.
  

Shivaxi wrote on Jul 25th, 2013 at 12:50pm:
...and now im stuck trying to fix everything you broke for the next 227 release xD Tongue

(ಠ_ಠ)
Back to top
ICQYIM  
IP Logged
 
Masterkent
Developer Team
Offline



Posts: 845
Location: Russia
Joined: Apr 5th, 2013
Gender: Male
Re: Invalid operations in the standard game packages.
Reply #10 - Sep 9th, 2015 at 4:42pm
Print Post  
9. ScriptWarning: Cloak Jegesbaseparttwo.Cloak (Function UPak.Cloak.DeActivated.Tick:001E) Accessed None 'Weapon'
Note: Pawn(Owner) can be None (the wearer left the game) and Pawn(Owner).Weapon can be None (no any weapon selected).

10. ScriptWarning: JumpBoots Cliffside.JumpBoots (Function UnrealI.JumpBoots.Timer:0046) Accessed None 'Owner'
I think, JumpBoots.Timer() should check if condition (Owner != none && !Owner.bDeleteMe) holds, and if it's not satisfied, immediately return.

11. ScriptWarning: TriggerLight QueenShip.TriggerLight2 (Function Engine.TriggerLight.TriggerTurnsOn.Trigger:002B) Accessed None 'SavedTrigger'
Value of parameter Other can be None.

12. ScriptWarning: Counter Canals.Counter0 (Function Engine.Counter.Trigger:0165) Accessed None 'EventInstigator'


  
Back to top
 
IP Logged
 
Smirftsch
Forum Administrator
*****
Offline



Posts: 7471
Location: at home
Joined: Apr 30th, 1998
Gender: Male
Re: Invalid operations in the standard game packages.
Reply #11 - Sep 10th, 2015 at 11:19am
Print Post  
you can always make the fixes and send me the corresponding uc files or add it here if you want. Less work for me since you checked it already anyway Smiley
  

Sometimes you have to lose a fight to win the war.
Back to top
WWWICQ  
IP Logged
 
[]KAOS[]Casey
Oldunreal MasterPoster
*
Offline


nedm

Posts: 3069
Joined: Aug 7th, 2011
Gender: Male
Re: Invalid operations in the standard game packages.
Reply #12 - Sep 10th, 2015 at 8:59pm
Print Post  
BigRock fragmenting likes to divide by zero when any of its x/y/z components are zero. This spams to hell on my server. I'm posting this here to help myself remember to figure out how to properly fix that.
  
Back to top
 
IP Logged
 
Masterkent
Developer Team
Offline



Posts: 845
Location: Russia
Joined: Apr 5th, 2013
Gender: Male
Re: Invalid operations in the standard game packages.
Reply #13 - Feb 5th, 2017 at 12:59pm
Print Post  
13.
ScriptWarning: Predator 7ronbr.Predator0 (Function UPak.Predator.Hiding.PickDestination:05D9) Accessed None 'home'
ScriptWarning: Predator 7ronbr.Predator0 (Function UPak.Predator.Hiding.PickDestination:02BB) Accessed None 'Enemy'

(found a lot of such lines in a log)

Not sure if this is fixed already - too much time passed since the last update.

Suggested resolution:

In function UPak.Predator.Hiding.PickDestination,

1) insert

Code
Select All
		if (Enemy == none || Enemy.health <= 0 || Enemy.bDeleteMe || Enemy == self)
		{
			WhatToDoNext('', '');
			return;
		}
 


right after

Code
Select All
		local NavigationPoint OldHome;
		local NavigationPoint NavPt;
		//local HomeBase Base;
		local float Distance;
		local float NavPtDist;
		local int i, j;

		// Check for state change 


2) replace

Code
Select All
			for( i = 0; i < DestListSize; i++ )
			{
				// Build a path to the destination using the path nodes in the level.
				pni.BuildPath( Location, Home.Location ); 


with

Code
Select All
			for( i = 0; i < DestListSize && Home != none; i++ )
			{
				// Build a path to the destination using the path nodes in the level.
				pni.BuildPath( Location, Home.Location ); 

  
Back to top
 
IP Logged
 
Page Index Toggle Pages: 1
Send TopicPrint
Bookmarks: del.icio.us Digg Facebook Google Google+ Linked in reddit StumbleUpon Twitter Yahoo