ID:139589
 
Code:
//The procedure that is repeating itself.

proc/GameEnd()
if(Entries.len)
world << "<center><font color = red><big>Game over! your winner is:"
for(var/mob/A in Entries)
world << A
A.Move(locate(10,14,2))
A.cantshoot = abs(1)
A.wins++
A.hit = abs(0)
A.upgradepoints += 2
A << "You gained two upgrade points!"
Entries.Remove(A)
for(var/obj/powerup/P in world)
del(P)
for(var/obj/Mine/M in world)
del(M)
for(var/mob/M in world)
M.movement = 1
M.cantshoot = 1
M.tourny = 0
Gameon = abs(0)

/*-------------------------------------
---------------------------------------
How The proc is called: */


mob/proc/Eliminate()
if(src.hit >= 10)
world << "[src] has been hit 10 times and is therefor eliminated!"
Entries -= src
src.loc = locate(10,14,2)
src.cantshoot = abs(1)
src.losses += 1
src.hit = abs(0)
src.scores()
GameEnd()


Problem description: My problem is GameEnd() is called in a really fast loop until it cant call anymore. I cant find the problem myself. Also any Constructive criticism would be appreciated.


First, I don't see where GameEnd() is being looped.

Second, if it is already being looped then why are you calling it in the Eliminate() proc? Wouldn't that result in two loops running at once?

Third, what is the point of
A.cantshoot = abs(1)

as well as your other uses of the abs() proc.

I think you need to read up on what an absolute value is before you just start throwing around unnecessary abs().

Can you give a little more clarification on how GameEnd is looping and when exactly your infinite loop (which is what "a really fast loop until it cant call anymore" usually is) is occurring? Does it happen the second you run the server or when the first player joins, or is it at some other time?

Just need a little more info to help you out.
In response to Gunbuddy13 (#1)
Thanks for taking the time to answer.

Ok, So. GameEnd() is being called from Eliminate(). I probably should have also shown you where Eliminate() is being called so here is:

obj/Paintball1
density = 1
icon = 'Paintbal.dmi'
Bump(var/mob/M)
if(ismob(M))
M.hit += 1
view(src) << "<small>[M] was hit by [owner]!"
flick("Hurt",M)
M.Eliminate()
del(src)


Maybe I worded it wrong before. GameEnd() shouldn't be looped, but just called when a player is eliminated. This is my problem. GameEnd() is infinitelooping itself instead of just being called once.

As for the abs() proc. I just looked at it in the reference and decided it was cool and used it xD. It has no proper reason and I guess would be better if I didn't use it.

I hope this is more informing =)

In response to Slic3y (#2)
I believe your problem would be a usual one that beginners run into with Bump() procs.
By default, when an atom Bump()s into something, it does not stop moving. Unless you tell the atom to stop, it will keep attempting to move (assuming it is moving with a walk proc) and keep Bump()ing as well.

And basically, if you have the atom moving with 0 delay, it means that the Bump proc is being called without any delay. This is most likely where your infinite loop is.

The solution to this is to just make the first line of the Bump proc have
walk(src,0)

which is how you end any walk procs on the referenced atom:
    Bump(var/mob/M)
walk(src,0)
if(ismob(M))
M.hit += 1
view(src) << "<small>[M] was hit by [owner]!"
flick("Hurt",M)
M.Eliminate()
del(src)
In response to Gunbuddy13 (#3)
Wow, thanks so much for the quick and helpful replies. This solved my problem!

In response to Slic3y (#4)
No problem! Lucky you that I woke up at 5am to my stupid cat scratching my arm.

That Bump problem is just one of those sneaky little mistakes that everyone does at least once while learning to program. I know I've done it a few times in my years on BYOND, and they can be hard to pinpoint because infinite loops don't always give debug info, the server usually just locks up until you alt+F4 and close it.

Just remember that if something is supposed to stop moving and THEN do an action when it Bumps, you need to stop the movement before you do the action.
In response to Gunbuddy13 (#5)
Thanks again! and yeah it was hard to pick. I spent a good 2 hours trying to pick out the problem. Gladly I'm not alone!