Skip to content

Make precedence explicit, fix crosshair blur

Martin Taibr requested to merge martin-t/precedence into master

We decided to make the precedence explicit for some combinations of ops but never had tools to check so i wrote a little lint in qc2rust that finds expressions where || and && are mixed and fixed those.

The spectatee_status == -1 && shottype == SHOTTYPE_HITTEAM condition in crosshair code was never true so i removed it entirely. Could also make it depend on another cvar but imho blurring when aiming at teammates is very annoying when trying to shoot an enemy through a teammate.

Another suspicious condition is the last one in Arc_Smoke. I made it explicit but kept the logic the same. I however suspect the parentheses should go around the || instead - there's no point in stopping the sound on weapon switch if it wasn't looping in the first place but i am not sure if maybe something else uses that channel. Which way is correct?

What is our policy on bit ops vs logical ops? There are quite a few cases where &, ^ and | are not inside parenthesee when mixed with && and ||. I recall we decided to parenthesize bit ops? They're IMHO not so ambiguous though, we might wanna keep them as is to reduce the number of parens.

Also found a case of mixing bit and aritmetic ops - PHYS_INPUT_BUTTON_MASK - and made it explicit (though the line breaks already hinted which way the precedence goes).

Edited by Martin Taibr

Merge request reports