[SOLVED] UpdateINIFile returns MAV error?

#1
I'm trying to make this mod for myself, wherein the only difference is edited player mechanics more or less. "Check for errors" detects no errors so I go ahead to compile the new game. I end up on a MAV, with or without the launcher, so I enter debug mode to find that the UpdateINIFile function errors on "While Not Eof(f)", with message "Stream does not exist".

I have found nothing myself. I never touched this function at all. What have I really done that could be causing this? Here's the UpdateINIFile function for reference:

Code: Select all

Function UpdateINIFile$(filename$)
	Local file.INIFile = Null
	For k.INIFile = Each INIFile
		If k\name = Lower(filename) Then
			file = k
		EndIf
	Next
	
	If file=Null Then Return
	
	If file\bank<>0 Then FreeBank file\bank
	Local f% = ReadFile(filename)
	Local fleSize% = 1
	While fleSize<FileSize(file\name)
		fleSize=fleSize*2
	Wend
	file\bank = CreateBank(fleSize)
	file\size = 0
	While Not Eof(f) ;This is the line where the error occurs
		PokeByte(file\bank,file\size,ReadByte(f))
		file\size=file\size+1
	Wend
	CloseFile(f)
End Function
(I'm using Windows 10, I have latest version of Blitz3D and I also have all files necessary for a compilation to be possible.)
Last edited by Marios on Sun May 01, 2016 10:40 pm, edited 1 time in total.

Re: UpdateINIFile returns MAV error?

#2
UpdateINIFile will crash the game if it fails to read a file. Make sure your source code and executable are in the main game directory. Working from a subfolder will not work properly unless you do some tricks with the code.

If it still doesn't work after setting everything up properly, add this to the top of the UpdateINIFile function:

Code: Select all

DebugLog "UpdateINIFile: "+filename
This will let you know if you're not putting in a filename correctly, probably through an implicit string-to-integer cast.

Re: UpdateINIFile returns MAV error?

#7
Oh, you needed that exact version? I expected the latest version would be compatible with the recent older versions.
Anyway, reverting to V.1.106 worked wonders. I have no problems anymore! Well, any more problems with the code are of my own concern.

Thank you, juanjpro! You truly are.. a pro.


For future reference, I shall put two useful tips for other modders here:

-Source code and executable must all be directly parented to the game directory
-BLITZ3D V.1.106 ONLY (for Containment Breach, at least)