Raised This Month: $ Target: $400
 0% 

New syntax broken?.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Benoist3012
Veteran Member
Join Date: Mar 2014
Location: CWave::ForceFinish()
Old 08-30-2015 , 15:13   New syntax broken?.
Reply With Quote #1

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?
__________________

Last edited by Benoist3012; 08-30-2015 at 15:23.
Benoist3012 is offline
Darkness_
Veteran Member
Join Date: Nov 2014
Old 08-30-2015 , 15:35   Re: New syntax broken?.
Reply With Quote #2

I don't think you need to use view_as when comparing two integers.
Darkness_ is offline
Miu
Veteran Member
Join Date: Nov 2013
Old 08-30-2015 , 16:07   Re: New syntax broken?.
Reply With Quote #3

yeah the precedence is wrong, just wrapit in parentheses or use _:
Miu is offline
WildCard65
Veteran Member
Join Date: Aug 2013
Location: Canada
Old 08-30-2015 , 17:38   Re: New syntax broken?.
Reply With Quote #4

Quote:
Originally Posted by Darkness_ View Post
I don't think you need to use view_as when comparing two integers.
TFTeam_Red IS NOT AN INT
__________________
WildCard65 is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 08-30-2015 , 21:57   Re: New syntax broken?.
Reply With Quote #5

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.
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
pheadxdll
AlliedModders Donor
Join Date: Jun 2008
Old 08-31-2015 , 00:41   Re: New syntax broken?.
Reply With Quote #6

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]) 
__________________

Last edited by pheadxdll; 08-31-2015 at 00:50.
pheadxdll is offline
Benoist3012
Veteran Member
Join Date: Mar 2014
Location: CWave::ForceFinish()
Old 08-31-2015 , 04:54   Re: New syntax broken?.
Reply With Quote #7

Quote:
Originally Posted by pheadxdll View Post
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 View Post
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 View Post
or use _:
Yes I need parentheses, but you can't use _: else you get a error.

Quote:
Originally Posted by Darkness_ View Post
I don't think you need to use view_as when comparing two integers.
It's need with the new syntax.
__________________

Last edited by Benoist3012; 08-31-2015 at 04:57.
Benoist3012 is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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