# ENIGMA Development Environment

 Pages: 1
 Author Topic: ISO C99 Scalar Boolean Casting  (Read 977 times)
Goombert
 Posted on: October 23, 2013, 04:28:24 AM

Location: Cappuccino, CA
Joined: Jan 2013
Posts: 3017

Well it appears we need to get on this. Basically I don't why Josh, you think that negative numbers are not boolean true, according to C99 ISO any integer value that does not equate to 0 is boolean true when cast.
http://stackoverflow.com/questions/4254318/are-negative-boolean-values-defined

Quote
ยง 6.3.1.2
When any scalar value is converted to _Bool, the result is 0 if the value compares equal to 0; otherwise, the result is 1.

So my question is basically this, what is wrong with our compiler that it is not working for collision functions that return -4 (noone)

Also, Studio does continue this behavior from the earlier versions of Game Maker as I have tested the following code which does show a message box with -4 in it.
Code: (EDL) [Select]
if (noone) {
show_message(string(noone));
}

I only began questioning this after looking at the following code from a tutorial game that comes with Stupido I got running now that I added event inheritance.
Code: (EDL) [Select]
first_instance = collision_line(x, y, xx, yy, obj_Col_Parent, true, true);

if first_instance != noone
{
dx = xx - x;
dy = yy - y;
while (abs(dx) >= 1 || abs(dy) >= 1)
{
dx /= 2;
dy /= 2;
instance = collision_line(x, y, xx - dx, yy - dy, obj_Col_Parent, true, true);
if (instance != noone)
I only got curious because for some reason they took the extra precaution with the result of the collision functions. I am really failing to see something here.

Here is a picture of the game...

I just ran this same test in ENIGMA and I get the expected results. So what exactly is the issue with the collision functions again and why they don't behavior properly as the result of negative values?
 « Last Edit: April 12, 2019, 01:02:04 PM by Goombert » Logged
I think it was Leonardo da Vinci who once said something along the lines of "If you build the robots, they will make games." or something to that effect.

Ideka
 Reply #1 Posted on: October 23, 2013, 04:44:54 AM

Joined: Apr 2011
Posts: 85

The problem is this:
In GM, a value of -4 is false, as are all other values less than 0.5. In ENIGMA, only a value of 0 is false.

If noone evaluates to true in Studio, then they changed it. Its false in GM8 and lower.
 Logged
Goombert
 Reply #2 Posted on: October 23, 2013, 04:47:31 AM

Location: Cappuccino, CA
Joined: Jan 2013
Posts: 3017

Ohhhhhhhhh so the problem is that we actually do follow the standard, and apparantly Studio does now as well, so my initial assumptions were correct, thank you Ideka, then I guess we can just keep everything like this since Stupido has finally caught up to the correct behaviour, I need to forward this post tomorrow for Josh to read, thanks
 Logged
I think it was Leonardo da Vinci who once said something along the lines of "If you build the robots, they will make games." or something to that effect.

Ideka
 Reply #3 Posted on: October 23, 2013, 04:52:14 AM

Joined: Apr 2011
Posts: 85

You're welcome.

And actually, I think Josh said he was going to create a new type for this to preserve backwards compatibility.
 Logged
Goombert
 Reply #4 Posted on: October 23, 2013, 04:55:30 AM

Location: Cappuccino, CA
Joined: Jan 2013
Posts: 3017

He'll need to make it a setting then, could be just the same as the others in ENIGMA settings...

Inherit boolean scalar: GML ( )   ISO C99 (*)

I'd rather have the ISO standard set as the default, I may actually change a few of his settings there too because I want literals such as ++/-- by default to be ISO C as well because Stupido has those by default too, and we've had them forever I don't want people complaining we don't have it yet or something.

It would basically look like this, keep in mind I am also working on adding in some settings for the other things I have implemented.
 « Last Edit: October 23, 2013, 05:10:10 AM by Robert B Colton » Logged
I think it was Leonardo da Vinci who once said something along the lines of "If you build the robots, they will make games." or something to that effect.

 Pages: 1