laurirasanen / groundfix

A Sourcemod plugin for preventing various movement bugs related to hitting the ground.
The Unlicense
11 stars 4 forks source link

Invalid comparison operation #9

Closed PazerOP closed 1 year ago

PazerOP commented 6 years ago

https://github.com/laurirasanen/groundfix/blob/b2d52d45bca2391eb2e3c9b8cc0e1c27b198c699/scripting/groundfix.sp#L247

This looks like a typo to me? According to sourcemod documentation, "the result [of comparison operators] is either true (non-zero) or false (zero)"

laurirasanen commented 1 year ago

Sorry for the lack of response, I haven't touched this project since 2018 :)

Chaining comparision operators like this is valid in sourcemod although undocumented it seems. You can try this out with a simple repro, such as:

public void OnPluginStart() {

    if (1 > 0.8 > 0.7) {
        PrintToServer("all good");
    }

    if (1 > 0.5 > 0.7) {
        SetFailState("no good");
    }
}

You can explicitly add parantheses around the first operation to get a bool out of it but the compiler will warn you about bool-float comparisions. Anyway, I'll separate it to 2 ops for clarity.

laurirasanen commented 1 year ago

changed in af0880c262ad8b705d3ed8d7a97dc257f5266148