Memory Access Violation

Blitz3D Forums/Blitz3D Beginners Area/Memory Access Violation

Lordon(Posted 2004) [#1]
im trying to test an internet game with another computer, i run the program, it connects to mine, but when i create the map, i get "Memory Access Violation". it compiles on my machine fine, even the executable works.

the computer im trying it on is also a better computer than mine. same internet connection too. so im not sure what's causing this.

this is Blitz3D btw, i also transfered the file using AIM if that helps

it's run by multiple files so it'd be kinda hard to post the code =/

any info on why this is happening and how i can fix it would be greatly appreciated =)


Zethrax(Posted 2004) [#2]
Are you storing any Blitz handles in float variables? If so, stop doing it. Only put them in integer variables.

Failing that, more info is needed.


WolRon(Posted 2004) [#3]
Memory Access Violations are often caused by a certain media not being loaded which causes you to use an 'empty' handle.

Always check that the media handle isn't equal to zero after loading the media, regardless of what it is.

For example:
fntFixedSys = LoadFont("FixedSys", 14)
If fntFixedSys = 0
	RunTimeError("Unable to load FixedSys font.")
EndIf



BlackD(Posted 2004) [#4]
Or even better, write a swathe of custom load routines which do this for you. For example, I've made my own LoadImage routine called LoadPic which simply loads the image and returns it, but also:
a) Handles errors. If image isn't present, it either loads a "default" image instead (very handing when using 3d and you want a "checker" pattern for missing tex's), or returns an error code.
b) Masks the image to 255,0,255 instead of 0,0,0.

So instead of:
myimage=loadimage("myphoto.bmp")
it does
myimage=loadpic("myphoto.bmp")

By writing your own fool-proof (make sure they ARE before continuing :)) custom functions, you save a lot of typing time for debugging and errorchecking.

As for your particular error, Liss, we really need more information. When exactly is it crashing? What is the relationship between the client and your computer. Is the memory being allocated in the client software to load the map? Are you accidently trying to load a tcpstream as an image? Try putting in a few:
Text 0,0,"Connecting to server":waitkey()
text 0,0,"loading map":waitkey()
statements in to see exactly where you're up to just before the crash occurs.

+BlackD


Lordon(Posted 2004) [#5]
ok now im really confused, i put in the messages into the program to see where i get the error, and i get to this function...

Water= Function_CreatePlane(80,True)
ScaleEntity Water,50000,1,50000
PositionEntity Water,0,Height,0
EntityAlpha Water,Alpha#

Print "water positioned"
WaitKey()

EntityColor Water,0,0,128
EntityShininess Water,Shininess#

Print "water colored"
WaitKey()
Print "water colored 2"
WaitKey()
Print "water colored 3"
WaitKey()


it's wierd because, it prints the line water colored, but then it crashes somewhere between

Print "water colored"
WaitKey()

and

Print "water colored 2"
WaitKey()

there is no code between those 2 lines! i rebooted the computer.

as for allocating memory, im not exactly sure what you mean by that.

ive loaded everything in the folder over to the other computer over AIM, and we're connecting over a LAN

u guys see/know something i don't? =/


WolRon(Posted 2004) [#6]
If there is no code between then why did you bother with the Print/Waitkey() statements?

Remember that you also have the Debuglog command at your disposal. I suggest you make use of it.


Lordon(Posted 2004) [#7]
ok, i shut down both computers and let them sit overnight and then resent the info and it runs, except that the terrain doesn't load, ive loaded the entire folder over to the othe computer so im gonna hav to look over all the code to make sure im not referring to something outside of the folder.

EDIT: ok, it was trying to call the height map from a specific folder, not the folder it was in. (Guess that's how TerraEd defaults.) but that file didn't exist on the computer i was transfering to. so i got it working now it seems.

thx for pointing me in the right direction =)