Server Help Forum Index Server Help
Community forums for Subgame, ASSS, and bots
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   StatisticsStatistics   RegisterRegister 
 ProfileProfile   Login to check your private messagesLogin to check your private messages   LoginLogin (SSL) 

Server Help | ASSS Wiki (0) | Shanky.com
Some kind of infinite loop

 
Post new topic   Reply to topic Printable version
 View previous topic  Toggle lvz object Post :: Post ASSS dir (DOS) equivalent  View next topic  
Author Message
Smong
Server Help Squatter


Joined: 1043048991
Posts: 0x91E
Offline

PostPosted: Tue Apr 15, 2003 2:56 am    Post subject: Some kind of infinite loop Reply to topic Reply with quote

I'm trying to make a race module. When ?race is typed it checks to to see if anyone is in the start box and adds them to its internal list of drivers, then it starts the race. If I'm not in the box everything is OK. But when I go into the box it adds me to the list then locks-up/goes into an infinte loop. Can anyone see what is wrong with my code?
Code: Show/Hide

#define maxDrivers   6

typedef struct {
   Player *p;
   int active;
   int chkpt;
   int lap;
   int kills;
   float times[11];
} Driver;

local Driver dvr[maxDrivers];

//Requires chat, pd and mainloop
local void startRace() {
   int drivers=0, i;
   Link *link;
   Player *p;
   if (!pd) return; //Safety
   if (!chat) return; //Safety
   lm->Log(L_INFO, "<hio> Adding players to race:");

   pd->Lock();
   FOR_EACH_PLAYER(p) {
      //In starting area?
      if (!inArea(startBox, p)) {
         lm->Log(L_DRIVEL, "<hio> [%s] not in start box", p->name);
//         continue;
      } else

      //PM if not enough slots
      if (drivers >= maxDrivers) {
         lm->Log(L_DRIVEL, "<hio> [%s] race full", p->name);
         chat->SendMessage(p, "This race is full, sorry");
//         continue;
      } else

      //Add to race
      for(i=0; i<maxDrivers; i++) {
         if (dvr[i].active == 0) { //== 1) continue;
         drivers++;
         dvr[i].active = 1;
         dvr[i].chkpt  = 1;
         dvr[i].lap    = 0;
         dvr[i].kills  = 0;
         dvr[i].p      = p;
         lm->Log(L_INFO, "<hio> [%s] added to race", p->name);
         chat->SendMessage(p, "Get ready to race...");
         i = maxDrivers; //break;
         }
      }
   }
   pd->Unlock();

   //Ready? Go Go Go!
   lm->Log(L_INFO, "<hio> Starting race...");
   if (mainloop)
      mainloop->SetTimer(checkCheckpoint, 100, 120, NULL, p->arena);
   chat->SendArenaMessage(p->arena, "Go Go Go!"); //104

   //Set time()
/*   for(i=0; i<maxDrivers; i++) {
      if (dvr[i].active == 0) continue;
      dvr[i].lstime = time();
   }*/
   //lm->Log(L_INFO, "<hio> Race in progress");
}

I replaced all break/continues with else just incase it was breaking/continuing the wrong bit of code.
Back to top
View users profile Send private message Add User to Ignore List Visit posters website MSN Messenger
Mine GO BOOM
Hunch Hunch
What What
Hunch Hunch<br>What What


Age:40
Gender:Gender:Male
Joined: Aug 01 2002
Posts: 3614
Location: Las Vegas
Offline

PostPosted: Tue Apr 15, 2003 10:53 am    Post subject: Reply to topic Reply with quote

Upload full file so can debug locally. What debugging are/can you use?

If cannot upload full file, when is startRace called? Place some debugging messages throughout loops, or run in a debugger locally with breakpoints around certain code points in the source to see which loop breaks, and what some of the variables contain for values.
Back to top
View users profile Send private message Add User to Ignore List Send email
Smong
Server Help Squatter


Joined: 1043048991
Posts: 0x91E
Offline

PostPosted: Tue Apr 15, 2003 4:04 pm    Post subject: Reply to topic Reply with quote

I found it, "chat->SendMessage(p, "Get ready to race...");" was inside a pd->Lock()/Unlock().
That means I will also have to remove "chat->SendMessage(p, "This race is full, sorry");"
Back to top
View users profile Send private message Add User to Ignore List Visit posters website MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Server Help Forum Index -> ASSS Custom Projects All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum
View online users | View Statistics | View Ignored List


Software by php BB © php BB Group
Server Load: 682 page(s) served in previous 5 minutes.

phpBB Created this page in 0.479813 seconds : 28 queries executed (82.2%): GZIP compression disabled