Application crashes without error
Posted: Wed Apr 10, 2013 4:58 pm
Hi guys,
I registered here because my application is crashing without error.. I'm trying to write a maze generation algorithm while the maze is displayed on the user's screen. Here is the procedure within the application crashes (I think, since OGRE doesn't give any error). The Procedure MazeGen is called as a thread.
So why is the application crashing? Is it because of the massive calls of maps/lists?
~ Thiefbrain
I registered here because my application is crashing without error.. I'm trying to write a maze generation algorithm while the maze is displayed on the user's screen. Here is the procedure within the application crashes (I think, since OGRE doesn't give any error). The Procedure MazeGen is called as a thread.
Code: Select all
Structure Cell
x.a
y.a
EndStructure
Global NewList VisitedCells.Cell()
Global NewMap Cells.a()
Global NewMap Walls.l()
Procedure HasUnvisitedNeighbours(x, y)
If x = 0
ProcedureReturn Bool(Cells(Str((x + 1) << 5 | y)) Or Cells(Str(x << 5 | (y + 1))) Or Cells(Str(x << 5 | (y - 1))))
ElseIf x = 23
ProcedureReturn Bool(Cells(Str((x - 1) << 5 | y)) Or Cells(Str(x << 5 | (y + 1))) Or Cells(Str(x << 5 | (y - 1))))
ElseIf y = 0
ProcedureReturn Bool(Cells(Str((x - 1) << 5 | y)) Or Cells(Str((x + 1) << 5 | y)) Or Cells(Str(x << 5 | (y + 1))))
ElseIf y = 23
ProcedureReturn Bool(Cells(Str((x - 1) << 5 | y)) Or Cells(Str((x + 1) << 5 | y)) Or Cells(Str(x << 5 | (y - 1))))
Else
ProcedureReturn Bool(Cells(Str((x - 1) << 5 | y)) Or Cells(Str((x + 1) << 5 | y)) Or Cells(Str(x << 5 | (y - 1))) Or Cells(Str(x << 5 | (y + 1))))
EndIf
EndProcedure
Procedure GenMaze(*var)
Protected x.a = Random(23), y.a = Random(23), dir.a
Repeat
While HasUnvisitedNeighbours(x, y)
dir = Random(3)
If dir = 0 And y > 0 And Walls(Str(x << 5 | y))
DeleteMapElement(Cells(), Str(x << 5 | y))
AddElement(VisitedCells())
VisitedCells()\x = x : VisitedCells()\y = y
FreeEntity(Walls(Str(x << 5 | y)))
DeleteMapElement(Walls(), Str(x << 5 | y))
y = y - 1
ElseIf dir = 1 And x < 23 And Walls(Str(1024 | (x + 1) << 5 | y))
DeleteMapElement(Cells(), Str(x << 5 | y))
AddElement(VisitedCells())
VisitedCells()\x = x : VisitedCells()\y = y
x = x + 1
FreeEntity(Walls(Str(1024 | x << 5 | y)))
DeleteMapElement(Walls(), Str(1024 | x << 5 | y))
ElseIf dir = 2 And y < 23 And Walls(Str(x << 5 | (y + 1)))
DeleteMapElement(Cells(), Str(x << 5 | y))
AddElement(VisitedCells())
VisitedCells()\x = x : VisitedCells()\y = y
y = y + 1
FreeEntity(Walls(Str(x << 5 | y)))
DeleteMapElement(Walls(), Str(x << 5 | y))
ElseIf dir = 3 And x > 0 And Walls(Str(1024 | x << 5 | y))
DeleteMapElement(Cells(), Str(x << 5 | y))
AddElement(VisitedCells())
VisitedCells()\x = x : VisitedCells()\y = y
FreeEntity(Walls(Str(1024 | x << 5 | y)))
DeleteMapElement(Walls(), Str(1024 | x << 5 | y))
x = x - 1
EndIf
Delay(100)
Wend
DeleteElement(VisitedCells())
x = VisitedCells()\x
y = VisitedCells()\y
Until MapSize(Cells()) = 0
EndProcedure~ Thiefbrain