Sorry about the vague topic title, but I have no idea what's going on here and was therefor not able to give a more precise topic title. Anyway...
I'm programming in FreePascal 2.2.2 on Win32 and have run into a strange issue with a real variable. I have a procedure called PlaceLightsource like this:
Code:
PROCEDURE PlaceLightSource(Const LightSourceNumber : Byte; Const Radius, HotSpot, X, Y, Red, Green, Blue : Real; Const Life : SmallInt);
BEGIN
LightSource[LightSourceNumber].AbsoluteX := X;
LightSource[LightSourceNumber].AbsoluteY := Y;
LightSource[LightSourceNumber].Active := T;
LightSource[LightSourceNumber].HotSpot := HotSpot;
LightSource[LightSourceNumber].Life := Life;
LightSource[LightSourceNumber].Radius := Radius;
LightSource[LightSourceNumber].R := Red;
LightSource[LightSourceNumber].G := Green;
LightSource[LightSourceNumber].B := Blue;
PlaceLightSourceReferencesOnTiles(LightSourceNumber);
RecalculateTileLighting := T;
END;
I then call this procedure like this:
Code:
PlaceLightSource(I, 1.5, 0, X, Y, 0.5, 0.5, 0.3, -1);
So, LightSource[I].Radius should now be set to 1.5, LightSource[I].R to 0.5, LightSource[I].G to 0.5, and LightSource[I].B to 0.3. If I get the program to print the values of these variables to the screen, it checks out fine.
However, when I call this piece of code...
Code:
IF (LightSource[I].Radius = 1.5) AND (LightSource[I].R = 0.5) AND (LightSource[I].G = 0.5) AND (LightSource[I].B = 0.3) THEN BEGIN
Character[CharacterNumber].LightSource := 0;
LightSource[I].Active := F;
RemoveLightSourceReferencesOnTiles(I);
RecalculateTileLighting := T;
END;
...it never gets past the IF check. Weird. Even more weird, if I comment out the "AND (LightSource[I].B = 0.3)", it does everything it's supposed to do. So I double checked that LightSource[I].B = 0.3 by printing the value to the screen again, and it IS 0.3. Now, if I set it to 0.5, it also works fine!
I'm completely stumped by this. Is anybody aware of some things to look out for when checking the value of real variables?
Bookmarks