If statement compatibility issue in Swift (it worked before) - if-statement

i reopened a project i stop working on for some days and without edditing any line, when i tried to run it, it gave me two errors i never saw before and i persoanlly think they make no sense. Please help me, the code is like this:
if normals == true && numberOfTaps > highScoreN.integerForKey("highscoren") || normals == 1 && highScoreN.integerForKey("highscoren") == 0
It gives me this error: "Cannot invoke '==' with an argument list of type '($T16, $T31)'"
and in another line, which is practically the same:
if pros == true && numberOfTaps > highScoreP.integerForKey("highscorep") || pros == 1 && highScoreP.integerForKey("highscorep") == 0
It gives me this error: "Cannot invoke '==' with an argument list of type '($T16, $T31)'"
I repeat, it had worked properly some days before, i dont know why it isn't..
Thank you so much!
PSD:// highScoreP and highScoreN are NSUserDefault type

The error is on the == in both lines, so that narrows it down. The only place you have == is comparing the normals variable to true and 1. Swift is very type safe, so your normals variable cannot be both true (a boolean) and 1 (an Int). Check the type of your normals variable and proceed form there.

Related

How to resolve Exception Error in C++ Builder

I am in the process of converting an older DOS based 16-bit application into a current Windows console app. Each time I run the application in debug mode I receive the following error:
Project xxxx.exe raised exception class $C0000005 with message 'access violation at 0x004151f9: read of address 0x00000000'.
The following is the code line that blows up:
if ((argc < 1) || (strcmp(argv[1],"/?")) == 0) prg_syntax();
The code evaluates and should run the function to display the programs syntax but doesn't and instead throws the error.
I am using C++ Builder version (11.1.5).
Any help of where or how to overcome I would greatly appreciate.
Thanks,
Kent
By the convention argc cannot be lower than 1, because it will have at least the name / symbolic link to the execution (binary) file. In the case of no arguments passed to your program it will try to deference NULL pointer (the last element of argv[]).
if ((1 < 1) || (strcmp(NULL,"/?")) == 0) prg_syntax();
I believe you've wanted to do something like this:
if ((argc < 2) || (strcmp(argv[1],"/?")) == 0) prg_syntax();

USplineComponent Bounds SphereRadius failed infinite

I`m new here.I have a problem using USplineComponent.
I`m using C++ project (Unreal 4.22) and I use USplineComponent to make a Animation in my pickup items event.
The problem occurs exactly when I build my Game (Development, Shipping, etc..)
In Editor Mode it doesn`t!
I`m getting this error:
> LogOutputDevice: Error: Ensure condition failed:
> !Primitive->Bounds.BoxExtent.ContainsNaN() &&
> !Primitive->Bounds.Origin.ContainsNaN() &&
> !FMath::IsNaN(Primitive->Bounds.SphereRadius) &&
> FMath::IsFinite(Primitive->Bounds.SphereRadius)
> [File:D:\Build\++UE4\Sync\Engine\Source\Runtime\Renderer\Private\RendererScene.cpp]
> [Line: 1187] [2020.01.19-17.16.43:790][ 57]LogOutputDevice: Error:
> Nans found on Bounds for Primitive SplineComp: Origin
> X=-4853943853456317127469964460032.000
> Y=41148151269357898046636032.000
> Z=18115167077902705087822314864640.000, BoxExtent
> X=4853943853456317127469964460032.000 Y=41148151269357898046636032.000
> Z=18115167077902705087822314864640.000, SphereRadius inf
My SphereRadius is "inf" (Infinite?)
UE_LOG(LogClass, Warning, TEXT("BOUNDS SPLINE: %f"), SplineComp->Bounds.SphereRadius); // return "inf"
Other detail is that my "Bounds.Origin" and "Bounds.BoxExtent" has a large number.
It doesn't always happen, it's variable. This error causes a fail in my game and does not generate my item.
Has anyone had this problem? Is there a possibility to limit this?
Thanks.
I changed my implementation. I removed the GetLocationatDistanceAlongSpline.
This function was returns inaccurate information...
https://issues.unrealengine.com/issue/UE-27979
Now, I have used a Linear Interpolation with Timeline function
Thanks for Help!

Velocity Template Language: Connect two conditions in one #elseif() statement

In my example the parameters are:
$p2.length
which has the value "0"
and the boolean
$suspectYesNo which is set to "false".
I would expect, that in my code the second #elseif will run due to my set parameters, but however it shows up that "Code 4 runs"
I guess, that my mistake is the connection of both conditions using "&&", but I have no clue how to correctly define the line with two conditions.
That brings me to the question: How to correctly combine the two conditions ($p2.length()==0) AND ($suspectYesNo.value.contains("true")) in one #elseif().
Or did I define the boolean wrong?
#if($p2.length()>0)
Code 1 runs
#elseif($p2.length()==0 && $suspectYesNo.value.contains("true"))
Code 2 runs
#elseif($p2.length()==0 && $suspectYesNo.value.contains("false"))
Code 3 runs
#else
Code 4 runs
#end
Thanks to user7294900 for providing me a reference with which I could solve the problem.
It did not read the boolean value as a string, which could be fixed by adding "toString()" method.
With this code here it works as desired:
#if($p2.length > 0)
Code 1 runs
#elseif($p2.length == 0 && $suspectYesNo.value.toString().contains("true"))
Code 2 runs
#elseif($p2.length == 0 && $suspectYesNo.value.toString().contains("false"))
Code 3 runs
#else
Code 4 runs
#end

Two && in a while condition?

I was trying to help a friend with a problem, he asked me how can he make the GCD of 3 numbers using the Nicomachus method. Everything went great until I tried to enter this condition:
while (a!=b && b!=c && a!=c)
But the problem is it would only execute once. I changed it into this:
while (a!=b && b!=c)
I know it results into the same thing but I was just wondering why the first one can't work ? I can't add 2 && in the same condition ?
You certainly can have 2 && in the same condition - you can have as many as you want. The fact that the loop stops depends on something else.
By the way, if you had a=10, b=20, C=10, the first condition (while (a!=b && b!=c && a!=c)) would stop (because a != c would be false), but the second one (while (a!=b && b!=c)) would continue. Probably this is what happened.
Transforming 3 conditions into just 2 can be done in the opposite case, that is, if you want to make sure they are all equal: a ==b && b == c automatically implies that a == c (see Transitive relation of equality), so adding this 3rd condition or not doesn't make any difference. But the same is not true for inequality, as I have shown.

"Invalid expression, assumed zero" error on if-statement

I'm getting the following error whenever I compile my code: "Error 029: Invalid expression, assumed zero"
The error is thrown on the following line:
if ((PlayerInfo[playerid][ADMINLevel])) || (IsPlayerAdmin(playerid))
I want the if-statement to check if "ADMINLevel" is above zero or if the player is logged in as an RCON admin.
You're constructing your if-statement wrong. The correct way to do it is
if(PlayerInfo[playerid][ADMINLevel] > 0 || IsPlayerAdmin(playerid))
{
/* Put your desired script here */
}
Your code was nearly correct (although it did have some unnecessary brackets), you just need to actually add a comparison to the ADMINLevel check. An if-statement should be like a question ("is admin level more than 0", rather than just "is admin level"). You can find more information about if-statements in Pawn here, and I think it will be useful for you to read.
PlayerInfo[..][..] does not return a boolean. Add > 0 to fix it