ID:269132
 
runtime error:
Maximum recursion level reached (perhaps there is an infinite loop)
To avoid this safety check, set world.loop_checks=0.
proc name: nextturn (/mob/proc/nextturn)
usr: Issu (/mob/cleric)
src: the curer (/monster/curer)
call stack:
the curer (/monster/curer): nextturn()
The above line like, 50 times

=/
        nextturn()
var
mob/T
t=1
for(var/mob/q in src.turnorder)
if(q.client&&q.leader)
T=src.turnorder[t]
break
t++
if(!T)
src.nextturn()
T.currentturn++
T.currentturn=listcheck(T.turnorder,T.currentturn)
var/mob/M=T.turnorder[T.currentturn]
if(!M)
src.endbattle()
return
if(M.dead)
src.nextturn()
M.turn=1
M.taketurn()



It always loops on the person who attacks. =/ I don't get why...(I know it's inefficient, so, go me. :D)
[edit]It has something to do with the mob/T thing, I know it. ;o The problem didn't occur until I added parties.
        nextturn()
> var
> mob/T
> t=1
> for(var/mob/q in src.turnorder)
> if(q.client&&q.leader)
> T=src.turnorder[t]
> break
> t++
> if(!T)
> src.nextturn()


I'm not sure I see the logic here. You're looking for a mob in src.turnorder that has a client and leader is non-zero. If no such mob if found you recurse by calling the same function over. However none of the previous conditions could have possibly changed so it'll only recurse again. And again. And again. Of course even if the recursion eventually terminated(though in your case there is no possible way) it would continue to execute the next line and you would be errors because T would be null. You should probably add in comments explaining what you are trying to do so people would know how to help you as right now all I see is a bunch of source that makes absolutly no logical sense.
In response to Theodis
Theodis wrote:
        nextturn()
> > var
> > mob/T
> > t=1
> > for(var/mob/q in src.turnorder)
> > if(q.client&&q.leader)
> > T=src.turnorder[t]
> > break
> > t++
> > if(!T)
> > src.nextturn()
>

I'm not sure I see the logic here. You're looking for a mob in src.turnorder that has a client and leader is non-zero. If no such mob if found you recurse by calling the same function over. However none of the previous conditions could have possibly changed so it'll only recurse again. And again. And again. Of course even if the recursion eventually terminated(though in your case there is no possible way) it would continue to execute the next line and you would be errors because T would be null. You should probably add in comments explaining what you are trying to do so people would know how to help you as right now all I see is a bunch of source that makes absolutly no logical sense.

Find the mob with a client, that's also the leader of the party (yay, innefficency), then it'll use vars from the mob later on. =/
In response to Hell Ramen
Find the mob with a client, that's also the leader of the party (yay, innefficency), then it'll use vars from the mob later on. =/

Thats not the issue. The issue is what you do when you don't find one. This is where things blow up on you.

Also you probably shouldn't be using recursion for this to begin with. Rather a loop that continues until the fight is over.
In response to Theodis
Theodis wrote:
Find the mob with a client, that's also the leader of the party (yay, innefficency), then it'll use vars from the mob later on. =/

Thats not the issue. The issue is what you do when you don't find one. This is where things blow up on you.

Yeah, but the problem is...there is one, so that shouldn't even be occuring...
In response to Hell Ramen
Yeah, but the problem is...there is one, so that shouldn't even be occuring...

Obviously there isn't because otherwise you wouldn't have the problem. However regardless you should make you bail case do soemthing better than cause an obscure bug. Output all the mobs in the list to make sure the contents of the list are what they should be.
In response to Theodis
Theodis wrote:
Yeah, but the problem is...there is one, so that shouldn't even be occuring...

Obviously there isn't because otherwise you wouldn't have the problem. However regardless you should make you bail case do soemthing better than cause an obscure bug. Output all the mobs in the list to make sure the contents of the list are what they should be.

Ungh, damn turnbased systems and their party systems!
I know little about them (lists going to all mobs without using:
for(var/mob/M in src.party)
M.battlers=src.battlers.Copy(), etc.)
, so I'm going to read up on them then come back up on it. =/
Thanks Theodis.
In response to Hell Ramen
Hell Ramen wrote:
Yeah, but the problem is...there is one, so that shouldn't even be occuring...

You don't actually have a loop handling this, or at least not one that's visible in this proc. You need to have one single proc handle the turn order for the battle, and call people to take their turns appropriately.

while(side1.len && side2.len)      // a simple 2-sided battle
for(var/i=1, i<=turnorder.len, ++i)
var/mob/M = turnorder[i]
if(!M) continue
var/list
enemies; friends
// enemies and friends are not copies of side1/side2, but the same lists
// so if you delete from enemies, you delete from that side
if(M in side1)
enemies=side2; friends=side1
else
enemies=side1; friends=side2
M.TakeTurn(enemies, friends)
// account for M logging out and being deleted
// even if mobs are not deleted on logout, keep this for robustness
if(!M)
friends-=M
if(!friends.len) break
// remove mobs who are dead but; they must be reset or deleted
for(var/mob/M2 in enemies)
if(M2.HP <= 0)
enemies -= M2
var/j = turnorder.Find(M2)
if(j<i) --i
turnorder.Cut(j,j+1)
// add to accumulated exp or assign exp to M now; this will just add to the total
// this model will simply add to a total for the side
expgain[friends] += M2.ExpValue(M)
// get spoils of war (treasures, etc.) to divvy later
spoils += M2.Spoils()
// complete the death process and respawn/delete
M2.DeathCheck(M)
if(!enemies.len) break
// do this after i loop completes; otherwise i must be adjusted
while(turnorder.Remove(null)) // empty loop; remove nulls


Once only one of the lists, side1 or side2, has any mobs in it, that side wins. Then it's time to hand out any treasures found, and any exp points gained.

Lummox JR