ID:138991
 
Code:
    proc
Create_Trackers()
switch(src.Piece)
if("Rook")
var/X = 4
var/Y = NORTH
while(X > 0)
var/obj/Tracker/A = new (get_step(src,Y),src)
A.Move(A.loc)
walk(A,Y,0)
A.density = 1
X --
Y = turn(Y, -90)
if("Bishop")
var/X = 4
var/Y = NORTHWEST
while(X > 0)
var/obj/Tracker/A = new (get_step(src,Y),src)
A.Move(A.loc)
walk(A,Y,0)
X --
Y = turn(Y, -90)
if("Queen")
var/X = 8
var/Y = NORTH
while(X > 0)
var/obj/Tracker/A = new (get_step(src,Y),src)
A.Move(A.loc)
walk(A,Y,0)
X --
Y = turn(Y,45)
if("Knight")
var/obj/Tracker/A = new (src.loc,src)
var/obj/Tracker/B = new (src.loc,src)
var/obj/Tracker/C = new (src.loc,src)
var/obj/Tracker/D = new (src.loc,src)
var/obj/Tracker/E = new (src.loc,src)
var/obj/Tracker/F = new (src.loc,src)
var/obj/Tracker/G = new (src.loc,src)
var/obj/Tracker/H = new (src.loc,src)
A.Move(locate(src.x - 1, src.y + 2, src.z))
B.Move(locate(src.x + 1, src.y + 2, src.z))
C.Move(locate(src.x + 2, src.y + 1, src.z))
D.Move(locate(src.x + 2, src.y - 1, src.z))
E.Move(locate(src.x + 1, src.y - 2, src.z))
F.Move(locate(src.x - 1, src.y - 2, src.z))
G.Move(locate(src.x - 2, src.y - 1, src.z))
H.Move(locate(src.x - 2, src.y + 1, src.z))
for(var/obj/O in world)
if(O.loc == src.loc)
del O


Problem description:
This is the code I use to create trackers in my game. Trackers are dense objects that tell you where you can go. This code works fine when only one mob does it, but when I have 2 mobs do it at the same time, the game crashes. What's up with that?

Edit: Woah, never noticed how bad my knight code was. I could've sworn I coded a dblstep proc to handle that O.O
What exactly crashes? Runtime error, Dream Daemon, Dream Seeker or just freezes?
In response to Zaoshi
Dreamseeker clients for everyone in game (or perhaps just the hoster?) is what crashes. Hosting though dream daemon does not change this. I am pretty sure that this means that the problem is in the code. So I was wondering if anyone knew what in that code could crash dreamseeker.

When I say crashes, I mean that it "Stops Responding"
In response to Lugia319
Hm... Interesting.

How do you know it's this proc's fault? Try to comment it out and see how it goes. If it fixes, try uncomment only one piece and call proc for two mobs to see how it goes, if it crashes comment out few lines and check again. Just try to figure which line exactly causes it. Once you find it, you could add debug messages to check if world continues running past that line/etc.

P.S.
/*
are you sure you need to loop world if you
remove only objects at same location?
*/

> for(var/obj/O in world)
> if(O.loc == src.loc)
> del O
// I mean this could work too
> for(var/obj/O in src.loc)
> del O
>
In response to Zaoshi
For your note, touche.

I can only assume that it is the proc because when I take it out the game works fine, it just doesn't create the trackers. It locks up when I press the Start button. Before I fixed my code to actually create the trackers, it would run fine, just not do what I wanted it to do.
In response to Lugia319
I guess you didn't read whole thing of what I wrote. Try this code if your problem persists:

    proc
Create_Trackers()
switch(src.Piece)
if("Rook")
var/X = 4
var/Y = NORTH
while(X > 0)
var/obj/Tracker/A = new (get_step(src,Y),src)
A.density = 1
X --
Y = turn(Y, -90)
if("Bishop")
var/X = 4
var/Y = NORTHWEST
while(X > 0)
var/obj/Tracker/A = new (get_step(src,Y),src)
X --
Y = turn(Y, -90)
if("Queen")
var/X = 8
var/Y = NORTH
while(X > 0)
var/obj/Tracker/A = new (get_step(src,Y),src)
X --
Y = turn(Y,45)
if("Knight")
var/obj/Tracker/A = new (src.loc,src)
var/obj/Tracker/B = new (src.loc,src)
var/obj/Tracker/C = new (src.loc,src)
var/obj/Tracker/D = new (src.loc,src)
var/obj/Tracker/E = new (src.loc,src)
var/obj/Tracker/F = new (src.loc,src)
var/obj/Tracker/G = new (src.loc,src)
var/obj/Tracker/H = new (src.loc,src)
for(var/obj/O in world)
if(O.loc == src.loc)
del O


I removed Move() proc's to see if they are source of the problem...
In response to Zaoshi
The crashing still happens. Might have to do with my checkstart proc. I'll have to dig a bit.
I don't see anything inherently wrong with the code you posted. (Though there is some inefficiency/bad practices/whatever.)

The only thing that would cause the game to stop responding is an infinite loop of some sort.

Personally, I wouldn't handle a chess board this way. (Using dense trackers and relying on the density check in Move() to make sure they don't go onto wrong spots.)

I would calculate the positions the trackers needed to go onto and then spawn them there. (But, that's just because I like to have really precise control of things.)


That said, I think the error with your code has something either to do with Move() or Tracker/New causing some sort of infinite loop. (walk() calls Move() forever, even after it bumps into something, it will keep trying to move. And, of course, keep bumping.)
It's hard to say what's causing it without seeing the entire source. (I'm not asking for it!)
It could be something entirely unrelated to what I'm thinking.