User Tag List

Results 1 to 6 of 6

Thread: Strange Compiler Error

  1. #1
    Keese ywkls's Avatar
    Join Date
    Feb 2016
    Posts
    62
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    331
    Level
    6
    vBActivity - Bars
    Lv. Percent
    65.58%

    Sick Bug Strange Compiler Error

    So, I was attempting to compile a script today which included this line...

    Code:
    if(Link->CollDetection==true)
    This gave me an error... Cannot cast from bool to float. (I don't remember the precise number of said error.)
    I should note that this didn't occur on every instance where I had this in the script. Possibly because of the way that the parser examines things? I don't know.

    Changing it to this worked...

    Code:
    if(Link->CollDetection)
    Since as far as I know, most bools accept the syntax in the first section of code, I'm pretty sure the fact this doesn't is a bug.

  2. #2
    Is this the end?
    ZC Developer
    Saffith's Avatar
    Join Date
    Jan 2001
    Age
    37
    Posts
    3,384
    Mentioned
    178 Post(s)
    Tagged
    6 Thread(s)
    vBActivity - Stats
    Points
    6,232
    Level
    24
    vBActivity - Bars
    Lv. Percent
    36.59%
    Huh. Yep, getCollDetection returns TYPE_FLOAT, and it's not the only one. Changing that shouldn't cause any problems, I don't think.

  3. #3
    The Timelord
    QDB Manager
    ZC Developer
    ZoriaRPG's Avatar
    Join Date
    Oct 2006
    Location
    Prydon Academy
    Posts
    1,369
    Mentioned
    110 Post(s)
    Tagged
    1 Thread(s)
    vBActivity - Stats
    Points
    4,553
    Level
    21
    vBActivity - Bars
    Lv. Percent
    27.4%
    Quote Originally Posted by Saffith View Post
    Huh. Yep, getCollDetection returns TYPE_FLOAT, and it's not the only one. Changing that shouldn't cause any problems, I don't think.
    Nah, I fixed it for 2.55/2.60, and I will apply the same fix in 2.53. I knew what it was as soon as @ywkls reported it on Skype, but I wanted him to post it here as a reminder for me.

    For the record, this affected CollDetection for lweapon, eweapon, and npc; but none of the other vars, or functions seem to have an incorrect return type at this time. My apologies if this created extra work for you @Saffith . I merely needed a reminder, and I asked @ywkls to post it in the dev chat. I didn't expect him to submit a full bug report, although it was nice of him to do that.

    Update: Fixed for 2.53/2.50.2.1.sheep, too.

    P.S. @ywkls : if ( ptr->CollDetection ) only worked because float is typecast to bool in that type of statement. When there is an explicit COMPARE to a boolean type (true/false), the proper bool return is mandatory. -- Clearly, no-one had ever tried if ( ptr->CollDetection = true ) in the past ???.
    Last edited by ZoriaRPG; 06-30-2017 at 09:29 AM.

  4. #4
    Is this the end?
    ZC Developer
    Saffith's Avatar
    Join Date
    Jan 2001
    Age
    37
    Posts
    3,384
    Mentioned
    178 Post(s)
    Tagged
    6 Thread(s)
    vBActivity - Stats
    Points
    6,232
    Level
    24
    vBActivity - Bars
    Lv. Percent
    36.59%
    Link->Invisible needs it, too. I think that's the only other one.
    Shouldn't this be corrected in the repo before it's marked as fixed?

  5. #5
    Keese ywkls's Avatar
    Join Date
    Feb 2016
    Posts
    62
    Mentioned
    5 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    331
    Level
    6
    vBActivity - Bars
    Lv. Percent
    65.58%
    Quote Originally Posted by ZoriaRPG View Post
    P.S. @ywkls : if ( ptr->CollDetection ) only worked because float is typecast to bool in that type of statement. When there is an explicit COMPARE to a boolean type (true/false), the proper bool return is mandatory. -- Clearly, no-one had ever tried if ( ptr->CollDetection = true ) in the past ???.
    It does seem odd to me that this has never turned up before, but I figured it would be an easy fix.

    I'm guessing that the setters were all correct, otherwise they'd have complained long hence. There's no telling why the getters were wrong.

  6. #6
    The Timelord
    QDB Manager
    ZC Developer
    ZoriaRPG's Avatar
    Join Date
    Oct 2006
    Location
    Prydon Academy
    Posts
    1,369
    Mentioned
    110 Post(s)
    Tagged
    1 Thread(s)
    vBActivity - Stats
    Points
    4,553
    Level
    21
    vBActivity - Bars
    Lv. Percent
    27.4%
    Quote Originally Posted by Saffith View Post
    Link->Invisible needs it, too. I think that's the only other one.
    Shouldn't this be corrected in the repo before it's marked as fixed?
    It is corrected in the stuff that I have staged to merge. DarkDragon asked not to make any new commits until he finishes his internal changes. I can put the 2.50.2.1 source up separately if you want, but I do not have access to dump it to GH/AGN.

    Here is the revision for this fix for master:

    https://github.com/ZoriaRPG/ZeldaCla...eturn?expand=1

    I thought that marking a bug as 'sick' was the appropriate middle-ground between implementing the fix, and verifying that it was fixed in use?

    Here is the 2.50.2.1 code: https://github.com/ZoriaRPG/ZeldaClassic_2.53

    Edit: I re-applied the changes to the 2.50.x branch:
    https://github.com/ArmageddonGames/Z...oriaRPG:2.50.x

    Let's hope that I did not overlook anything, and that this compiles properly.

    Quote Originally Posted by ywkls View Post
    It does seem odd to me that this has never turned up before, but I figured it would be an easy fix.

    I'm guessing that the setters were all correct, otherwise they'd have complained long hence. There's no telling why the getters were wrong.
    Aye. The setters are fine, and as I said, i suspect it is because the syntax if ( Link->CollDetection ) or if ( Link->Invisible ) is cleaner, or easier to type, and read; as compared to if ( foo == true ) . It is also less error-prone, as you cannot have an assign here where you intend a compare, when doing a simple boolean evaluation, so fewer people use == true in these cases.

    Similarly, most users will do if ( !foo ) rather than if ( foo == false ). I would still have expected it to be reported before, but the userbase is clearly not reporting issues when they should, and they try to find hacks, or workarounds to the, rather than alerting us fix them.

    Internally all of these values are integers. Only the ZScript parser distinguishes between float, and bool; or other types.
    Last edited by ZoriaRPG; 07-01-2017 at 08:31 PM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Armageddon Games is a game development group founded in 1997. We are extremely passionate about our work and our inspirations are mostly drawn from games of the 8-bit and 16-bit era.
Social