Raised This Month: $ Target: $400
 0% 

Quick for-loop question..


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 03-30-2005 , 00:53   Quick for-loop question..
Reply With Quote #1

Just wondering if my mind serves me correctly from my past C++ experience.

Code:
for( new chk2=1; chk2<=get_maxplayers(); ++chk2)

That would Loop from 2 through maxplayers and

Code:
for( new chk2=1; chk2<=get_maxplayers(); chk2++)

would loop from 1 to maxplayers... correct?

thanks
__________________
Bugsy is offline
Freecode
Never Fall Asleep
Join Date: Jan 2004
Old 03-30-2005 , 00:54  
Reply With Quote #2

yes
Freecode is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 03-30-2005 , 01:26  
Reply With Quote #3

Thanks, chief.
__________________
Bugsy is offline
BAILOPAN
Join Date: Jan 2004
Old 03-30-2005 , 01:39  
Reply With Quote #4

Optimization tip of the day: store get_maxplayers in a variable before the for loop, that way it's not called every time.
__________________
egg
BAILOPAN is offline
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 03-30-2005 , 23:00  
Reply With Quote #5

Didn't PM or someone also say something against declaring a variable in the syntax of a for loop (chk2 in this case)?
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX is offline
xeroblood
BANNED
Join Date: Mar 2004
Location: Toronto, Canada
Old 03-31-2005 , 00:16  
Reply With Quote #6

I believe that was because breaking out of the loop before the condition is met results in the memory of the variable (declared within the for-loop using 'new') fails to get released/freed properly..

But wasn't that an issue with the old compiler released by CompuPhase and addressed properly in the newer compiler released with AMXX??
xeroblood is offline
Send a message via MSN to xeroblood
Reply



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 09:56.


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