Variable is not None even if there's no assignment
Posted: Wed Jan 10, 2018 7:11 am
Here I'm again, this time with this function:
trackActor() just checks if the actor should be included in the following body, LocationInfo.isGoodCandidate() checks if a location info is compatible with an actor(it works fine), it is called only on LocationInfo's around the actor which its distance is 100 maximum.
The log 0 is printed if the actor has been included.
The log 1 is printed for each LocationInfo around the actor(within a radius of 100uu in my case).
The log 2 prints the nearestLocInfo, None if there was no any good LocationInfo candidate.
I start the match with one player(me) only, since there are no LocationInfo at the beginning, logs start by printing 0 and then 2, showing the nearestLocInfo as None, then they start printing 0, 1 and 2 since at least one LocationInfo has been spawned.
The problem comes when I spawn my cavy(a Nali of course), I don't move anymore to see what happens and I hurt the Nali so that he moves away, when he does it the logs keep printing 0, 2.
I mean, it never prints 1 and I could handle a bug like that but the problem is that, when it prints 2 the nearestLocInfo is not None!(The printed one is the same used by the player).
So, how does it come that nearestLocInfo is not None if the logs show 0, 2 only, without going through the log 1?
If nearestLocInfo is set, then the log 1 should be printed, unless I'm blind or whatever...
(Also, I checked and nearestLocInfo is nowhere else than in this function)
Code: Select all
event Timer() {
local Actor actor;
local LocationInfo nearestlocInfo, locInfo, newLocInfo;
foreach AllActors(class'Actor', actor)
if (trackActor(actor) || actor.IsA('Bot') || actor.IsA('PlayerPawn')) {
//FIXME
Level.Game.BroadcastMessage(0@actor);
if (actor.IsA('Pawn') && (Pawn(actor).PlayerReplicationInfo != None) && Pawn(actor).PlayerReplicationInfo.bIsSpectator && Pawn(actor).PlayerReplicationInfo.bWaitingPlayer) {
//If the actor is a spectating pawn do nothing.
} else {
foreach actor.RadiusActors(class'LocationInfo', locInfo, minDist - actor.CollisionRadius, actor.Location) {
//FIXME
Level.Game.BroadcastMessage(1@actor);
if (locInfo.isGoodCandidate(actor.class))
if ((nearestlocInfo == None) || VSize(locInfo.Location - actor.Location) < VSize(nearestlocInfo.Location - actor.Location))
if (FastTrace(actor.Location, locInfo.Location))
nearestlocInfo = locInfo;
}
//FIXME
Level.Game.BroadcastMessage(2@actor@nearestlocInfo);
if (nearestlocInfo == None) {
newLocInfo = Spawn(class'LocationInfo', Self,, actor.Location);
newLocInfo.actorClass = actor.class;
newLocInfo.attentionLevel++;
} else {
nearestlocInfo.attentionLevel++;
}
}
}
}
The log 0 is printed if the actor has been included.
The log 1 is printed for each LocationInfo around the actor(within a radius of 100uu in my case).
The log 2 prints the nearestLocInfo, None if there was no any good LocationInfo candidate.
I start the match with one player(me) only, since there are no LocationInfo at the beginning, logs start by printing 0 and then 2, showing the nearestLocInfo as None, then they start printing 0, 1 and 2 since at least one LocationInfo has been spawned.
The problem comes when I spawn my cavy(a Nali of course), I don't move anymore to see what happens and I hurt the Nali so that he moves away, when he does it the logs keep printing 0, 2.
I mean, it never prints 1 and I could handle a bug like that but the problem is that, when it prints 2 the nearestLocInfo is not None!(The printed one is the same used by the player).
So, how does it come that nearestLocInfo is not None if the logs show 0, 2 only, without going through the log 1?
If nearestLocInfo is set, then the log 1 should be printed, unless I'm blind or whatever...
(Also, I checked and nearestLocInfo is nowhere else than in this function)