AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   General (https://forums.alliedmods.net/forumdisplay.php?f=58)
-   -   New syntax broken?. (https://forums.alliedmods.net/showthread.php?t=270843)

Benoist3012 08-30-2015 15:13

New syntax broken?.
 
After worked on ItHunts I discovered maybe a bug very annoying.

Look this:
PHP Code:

if(IsClientInGame(ii) && GetClientTeam(ii) == view_as<int>TFTeam_Red && bEscaped[ii]) 

and this
PHP Code:

if(IsClientInGame(ii) && bEscaped[ii] && GetClientTeam(ii) == view_as<int>TFTeam_Red

It seem both are checking same thing?
Yes you are right, but one is broken.

PHP Code:

if(IsClientInGame(ii) && GetClientTeam(ii) == view_as<int>TFTeam_Red && bEscaped[ii]) 

This one doesn't work, and I'm sure it's because of "view_as<>", I did something wrong, if not can you fix it?

Darkness_ 08-30-2015 15:35

Re: New syntax broken?.
 
I don't think you need to use view_as when comparing two integers.

Miu 08-30-2015 16:07

Re: New syntax broken?.
 
yeah the precedence is wrong, just wrapit in parentheses or use _:

WildCard65 08-30-2015 17:38

Re: New syntax broken?.
 
Quote:

Originally Posted by Darkness_ (Post 2338407)
I don't think you need to use view_as when comparing two integers.

TFTeam_Red IS NOT AN INT

Powerlord 08-30-2015 21:57

Re: New syntax broken?.
 
Side note: view_as<int>something is not supposed to be valid syntax and will fail if you're using a recent SM 1.8 compiler. view_as<int>(something) is the correct syntax.

pheadxdll 08-31-2015 00:41

Re: New syntax broken?.
 
I'm guessing the first code snippet is the errant one. I reported this bug back in June. No word on it.

Two stopgaps:
PHP Code:

// Put parenthesis around the tag conversion.
if(IsClientInGame(ii) && GetClientTeam(ii) == (view_as<int>(TFTeam_Red)) && bEscaped[ii]) 
// Put the tag conversion first.
if(IsClientInGame(ii) && view_as<int>(TFTeam_Red) == GetClientTeam(ii) && bEscaped[ii]) 


Benoist3012 08-31-2015 04:54

Re: New syntax broken?.
 
Quote:

Originally Posted by pheadxdll (Post 2338501)
I'm guessing the first code snippet is the errant one. I reported this bug back in June. No word on it.

Two stopgaps:
PHP Code:

// Put parenthesis around the tag conversion.
if(IsClientInGame(ii) && GetClientTeam(ii) == (view_as<int>(TFTeam_Red)) && bEscaped[ii]) 
// Put the tag conversion first.
if(IsClientInGame(ii) && view_as<int>(TFTeam_Red) == GetClientTeam(ii) && bEscaped[ii]) 


Alright thanks, it fixed my problem, I should maybe use same way you did in STT define TFTeam_Red and TFTeam_Blue.


Quote:

Originally Posted by Powerlord (Post 2338485)
Side note: view_as<int>something is not supposed to be valid syntax and will fail if you're using a recent SM 1.8 compiler. view_as<int>(something) is the correct syntax.

Alright, thanks! So I guess this "bug" isn't going to appear again.

Quote:

Originally Posted by Miu (Post 2338413)
or use _:

Yes I need parentheses, but you can't use _: else you get a error.

Quote:

Originally Posted by Darkness_ (Post 2338407)
I don't think you need to use view_as when comparing two integers.

It's need with the new syntax.


All times are GMT -4. The time now is 22:46.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.