|
Server Help Community forums for Subgame, ASSS, and bots
|
Author |
Message |
Smong Server Help Squatter
Joined: 1043048991 Posts: 0x91E Offline
|
Posted: Tue Apr 15, 2003 2:56 am Post subject: Some kind of infinite loop |
|
|
|
|
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?
#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 |
|
|
Mine GO BOOM Hunch Hunch What What
Age:40 Gender: Joined: Aug 01 2002 Posts: 3614 Location: Las Vegas Offline
|
Posted: Tue Apr 15, 2003 10:53 am Post subject: |
|
|
|
|
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 |
|
|
Smong Server Help Squatter
Joined: 1043048991 Posts: 0x91E Offline
|
Posted: Tue Apr 15, 2003 4:04 pm Post subject: |
|
|
|
|
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 |
|
|
|
|
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
|
Software by php BB © php BB Group Server Load: 827 page(s) served in previous 5 minutes.
|