Login x
User Name:
Password:
Social Links Facebook Twitter YouTube Steam RSS News Feeds

Members Online

»
0 Active | 7 Guests
Online:

LATEST FORUM THREADS

»
warfare
CoD4 Map + Mod Releases
Voting menu on maps
CoD+UO General
Hauling 911
CoDBO3 General

Forums

»

Welcome to the MODSonline.com forums. Looking for Frequently Asked Questions? Check out our FAQs section or search it out using the SEARCH link below. If you are new here, you may want to check out our rules and this great user's guide to the forums and the website.
For more mapping and modding information, see our Wiki: MODSonWiki.com

Jump To:
Forum: All Forums : Call of Duty 2
Category: CoD2 MP Mapping
CoD 2 mapping and level design.
Moderators: foyleman, Foxhound, Mystic, StrYdeR, batistablr, Welshy, DrBiggzz, supersword, playername
Latest Posts
Subscribed Posts
Search
Restricted Access Topic is Locked subscribe
Author Topic: infinite loop error
xxxsniper
General Member
Since: Mar 19, 2006
Posts: 110
Last: Sep 5, 2008
[view latest posts]
Level 4
Category: CoD2 MP Mapping
Posted: Friday, Jun. 22, 2007 02:47 pm
what is the infinite loop error in this script??


Code:
main() 
{ 
   //must precache before all else!
   level._rain = loadfx ("fx/misc/rain_light.efx");
   //now start the thread
   wait(0.3);
   level thread cod2_rain(); 
} 

cod2_rain() 
{ 
   while(1)
   { 
      players = getentarray("player", "classname"); 
      if(players.size > 0)
      { 
         max_nodes = 20; 
         max_nodes_per_player = max_nodes/players.size; 

         for(ii = 0 ; ii < max_nodes_per_player.size ; ii ++)
         {
            for(i = 0; i < players.size; i++)
            { 
               player = players[i]; 
               if(isAlive(player))
               { 
                  x= 350-randomfloat(700); 
                  y= 350-randomfloat(700); 
                  pos = player.origin +(x,y,200) ; 
                  trace = bulletTrace(pos,pos +(0,0,-250), true, undefined); 
                  if(trace["fraction"] != 1) playfx(level._rain,trace["position"]); 
                     wait 0.05; 
               } 
            } 
         } 
      } 
   wait 0.05; 
   } 
}
Share |
The_Caretaker
General Member
Since: Jun 8, 2004
Posts: 11625
Last: Jul 7, 2009
[view latest posts]
Level 10
Category: CoD2 MP Mapping
Posted: Friday, Jun. 22, 2007 06:58 pm
does it give you any more info in the error message?

Because I don't see an infinite loop at first glance.
Share |
Scharfschuetze
General Member
Since: Dec 23, 2006
Posts: 162
Last: Jul 7, 2011
[view latest posts]
Level 4
Im a fan of MODSonair
Category: CoD2 MP Mapping
Posted: Saturday, Jun. 23, 2007 07:54 am
It is a common way of programming, but is not the best way of doing it.

the command while(1) is in fact an infinite loop, but may not be what the compiler is complaining about. You can use this loop. Usually the error message will point to some other line or command. Or it may be timing.

I have noticed the frequent use of this while loop, however, the part that the compiler does NOT like when you use this way of making a loop is when you have no wait time or a wait time of a very small amount inside the loop. What this does is in effect just as an infinite loop, in that the processor is too busy processing this thread to be able to do anything much else. That is the real reason why it does not like infinite loops, not that it is unable to stop it, only that it hogs the processor too much.

Solution, try increasing the wait time just a little bit more and retry it.

[sniper]


Scharfschütze
Amerikanischer Soldat der Niederlage, sind Sie tot
My Radiant Manual - Work In Progress

My Progress In Modeling Included Here

Share |
WHC_Grassy
General Member
Since: Apr 20, 2005
Posts: 1426
Last: Aug 25, 2007
[view latest posts]
Level 8
Category: CoD2 MP Mapping
Posted: Saturday, Jun. 23, 2007 09:22 am
The problem was caused by me I'm afraid, even though I corrected the corrupted code I inadvertently added a new error which was only one line that has been correctly identified by Scharfschuetze in another thread.

My apologies, this version should be error free:

Code:
main() 
{ 
   //must precache before all else!
   level._rain = loadfx ("fx/misc/rain_light.efx");
   //now start the thread
   wait(0.3);
   level thread cod2_rain(); 
} 

cod2_rain() 
{ 
   while(1)
   { 
      players = getentarray("player", "classname"); 
      if(players.size > 0)
      { 
         max_nodes = 20; 
         max_nodes_per_player = max_nodes/players.size; 

         for(ii = 0 ; ii < max_nodes_per_player ; ii ++)
         {
            for(i = 0; i < players.size; i++)
            { 
               player = players[i]; 
               if(isAlive(player))
               { 
                  x= 350-randomfloat(700); 
                  y= 350-randomfloat(700); 
                  pos = player.origin +(x,y,200) ; 
                  trace = bulletTrace(pos,pos +(0,0,-250), true, undefined); 
                  if(trace["fraction"] != 1) playfx(level._rain,trace["position"]); 
                     wait 0.05; 
               } 
            } 
         } 
      } 
   wait 0.05; 
   } 
}


The problem was this line originally read,
for(ii = 0 ; ii < max_nodes_per_player.size ; ii ++)

Now corrected in the above code block to read,
for(ii = 0 ; ii < max_nodes_per_player ; ii ++)


Regards Grassy
Share |
Scharfschuetze
General Member
Since: Dec 23, 2006
Posts: 162
Last: Jul 7, 2011
[view latest posts]
Level 4
Im a fan of MODSonair
Category: CoD2 MP Mapping
Posted: Saturday, Jun. 23, 2007 10:02 am
[jumping]

Wow, I got something right, gee whiz.

I will have to write this down as a day in history, just kidding.[biggrin]

I am glad now that it is fixed. I hope to be able to use it in my map. If I ever get to that point. Stuck in model designing and can't fight the urge to create something. Besides my big project I am working on needs some things before I can finish it. More delays, more research, more reading. Wish I could just spend all day making a map like others are doing.

Oh well, back to the grind. Hmm, maybe I will just side track a bit and put some rain in my map.[thumbs_up]

[sniper]



Scharfschütze
Amerikanischer Soldat der Niederlage, sind Sie tot
My Radiant Manual - Work In Progress

My Progress In Modeling Included Here


Share |
Restricted Access Topic is Locked subscribe
MODSonline.com Forums : Call of Duty 2 : CoD2 MP Mapping

Latest Syndicated News

»
Codutility.com up and runn...
Nice, and there still using the logo and template for the screenshots, which...
Codutility.com up and runn...
dundy writes...Quote:Call of Duty modding and mapping is barly alive only a ...
Codutility.com up and runn...
Mystic writes...Quote:It seems to me the like the site is completely dead? ...
Codutility.com up and runn...
It seems to me the like the site is completely dead?

Partners & Friends

»