"Process complete" on function call?

BlitzMax Forums/BlitzMax Programming/"Process complete" on function call?

This only happens when debug is on. (when debug is off it compiles and runs fine)

I tried to compile this old game I was making a year ago and the program crashes on the "ttilekind.setup(0)" line. The execution doesn't reach the inside of that function. It just says process complete.

Anyone know why this kind of thing happens?

Quick build is off.

Strict

Import "gui/gui.bmx"
Import "guykind.bmx"
Import "tilekind.bmx"

Global You:tguy
Global Battle:tbattle
Global BattleIn

Global Timer:ttimer
Global AllColor:Byte[]=[255:Byte,255:Byte,255:Byte]
Global DebugText:String

Include "tile.bmx"
Include "guy.bmx"
Include "battle.bmx"
Include "screen.bmx"
Include "item.bmx"



SeedRnd MilliSecs()
SetGraphicsDriver GLMax2DDriver()
Graphics 1024,768,0
SetMaskColor 255,0,255


tdir.setup(1)
tfont.make()

tentrance.setup()

ttilekind.areaset(1,2,3,4,5,6,7,8,9)

ttilekind.fontdraw=tfont.draw
ttilekind.setup(0)


I have been re-running some older programs and noticed the same thing. Generally, there is an error in my program but, rather than display an error, the program just returns 'Process Complete' and finishes.
I've only really noticed it with includes though.
I'll see if I can find a small, recreatable example.

Well the first line of ttilekind.setup(0) is Print "hello" and it isn't printed. But everything runs fine when debug is off.

I've also tried changing Import to Include and the same thing happens.

The function is 3500 lines, mabye the debugger overflows? I'll test it when I have more time.

Well the first line of ttilekind.setup(0) is Print "hello" and it isn't printed.
Which indicates that it is failing somewhere before that point.

Since there are potentially 1000's of lines of code before that, it doesn't really give us much to go on.


Since there are potentially 1000's of lines of code before that, it doesn't really give us much to go on.

Well I used the debugger to step through each line and it doesn't crash until that function call.

is the function a callback?

Bear in mind that if you do something dangerous like yutzing with pointers or misdeclaring external C stuff, then you may error unexpectedly on a line which appears to be very mundane and unlikely to error in itself. You may actually find ( in that instance ) that the error occurs a few lines ( or more 0 previously to where execution actually stops or breaks.

Could you post the function prototype and the line(s) which call it?

Thanks for the replies.

I am not doing any extern stuff. I don't know what a callback is. I'm not using any dangerous pointers. Unless stuff like this is dangerous: "Global Area:Byte[,][,][]"



None of the include files are executing anything except CreateList() comands as initializers to global fields.
I've cut the code down to this:
Strict
Import "gui/gui.bmx"
Import "guykind.bmx"
Import "tilekind.bmx"
Include "tile.bmx"
Include "guy.bmx"
Include "battle.bmx"
Include "screen.bmx"
Include "item.bmx"

Print "about to call ttilekind.setup(0)"
ttilekind.setup(0)
Each include also declares and initializes a few globals.

Here is the erroring function definition and its type fields:
Type TTileKind
	Global FontDraw(Text:String,X:Int,Y:Int,CenterX:Byte,CenterY:Byte,AlignRight:Byte)

	'has it loaded the full size version yet?
	Field LoadedBig:Byte
	'the small version is stored in Image, until the big one is loaded and overwrites it.
	'smallimage holds the small version for the editor to use at any time.
	Field SmallImage:timage
	Field Image:timage
	'
	Field ShadowImage:timage
	'
	Field ImageArray:timage[]
	'
	Field ImageArrayAm:Int
	
	'if the drawtile is not the bottom right of its area,. how far away from the bottom.
	Field DrawTileYLess:Int
	
	Field Color:Byte[3]

	'how fast a guy will walk when on this tilekind.
	'multiplier. default is 1, which is will make to guy move at his normal speed.
	Field Speed:Float
	'How fast a guy will change his speed to the speed of this tile.
	'the lower the speedchange the more momentum will carry over to the tile.
	'And when low, it will take longer to start going fast.
	'multiplier. 1=normal.
	Field SpeedChange:Float
	'
	Field Id:Int
	'for the editor
	Field Group:Int
	'pixel offset for drawing
	Field HandleX:Int
	Field HandleY:Int
	'size in tiles
	Field SizeX:Int
	Field SizeY:Int
	'standard scale. or if min<>max then random scales when the tile is created
	Field ScaleXMin:Float
	Field ScaleXMax:Float
	'if scaleymin=0 then it will always scale the y to whatever it scales the x to.
	Field ScaleYMin:Float
	Field ScaleYMax:Float
	'how much could be subtracted at random from its normal color.
	Field ColorMinus:Byte[3]
	'what area the tile takes up. used for collision
	Field Area:Byte[,][,]
	'what area has its terrain.
	'differs from regular area when a tile has some walkable terrain and some unwalkable area.
	'in that case the area[] will be the unwalkable, and the areawalk will be the terrain area.
	Field AreaWalk:Byte[,][,]
	'a twalk const. what kind of terrain
	Field Walk:Int
	'if this tile is unwalkable on its area, but there is also another terrain here. for editor
	Field Walk2:Int
	'if this tilekind actually uses the image of another.
	Field KindImageUse:ttilekind
	'all the tiles that can be automatiacally randomly placed insteadof/on this tile.
	Field PutRandomList:TList
	
	Global All:Byte[,][,]

	Global Am:Int=874
	Global Array:ttilekind[]
	Global grouplist:TList[]
	Global GroupAm:Int
	
	
	Const GroupBeach=1
	Const GroupSand=2
	Const GroupGrass=3
	Const GroupRock=4
	Const GroupLavaCave=5
	Const GroupIceCave=6
	Const GroupSnow=7
	Const GroupDirtRocky=8
	Const GroupDirtSmooth=9
	Const GroupStoneGround=10
	Const GroupBrickCrystal=11
	Const GroupTileGrey=12
	Const GroupStoneRockGround=13

	Const GroupGrassBorder=14
	Const GroupCaveBorder=15
	Const GroupWaterBorder=16

	Const GroupCliff=17
	Const GroupStoneWall=18
	Const GroupFence=19

	Const GroupPlant=20
	Const GroupTree=21
	Const GroupBuilding=22

	Const GroupOutDoor=23
	Const GroupInDoor=24
	Const GroupRug=25
	Const GroupFloorBoard=26
	Const GroupCarpet=27
	Const GroupCounter=28
	Const GroupWhiteWall=29
	Const GroupBridge=30

	Function Setup(LoadAll:Byte)
		Print "in ttilekind.setup"


I reproduced the bug, its in the bug forum. thanks all