Page 1 of 1

[SOLVED] UpdateINIFile returns MAV error?

Posted: Sun May 01, 2016 12:52 pm
by Marios
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.)

Re: UpdateINIFile returns MAV error?

Posted: Sun May 01, 2016 1:17 pm
by juanjp600
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?

Posted: Sun May 01, 2016 1:24 pm
by Marios
Well, the exe is located at the game directory, and the source code folder is there too.

Do I have to have the source code itself directly on the game's directory, or is it fine there in the source code folder?

This is what I got on the debug log:

Code: Select all

CREATE BANK FOR options.ini
UpdateINIFile: options.ini

Re: UpdateINIFile returns MAV error?

Posted: Sun May 01, 2016 1:26 pm
by juanjp600
Marios wrote:Do I have to have the source code itself directly on the game's directory, or is it fine there in the source code folder?
The former, you should just move the source code out of the directory it comes in, and put it directly into the root directory.

Re: UpdateINIFile returns MAV error?

Posted: Sun May 01, 2016 5:40 pm
by Marios
Well, that was fixed nicely. Now, the other problem is that the game now MAVs on the SetBuffer function of Fast Extensions. I am still unable to reach the launcher or the main game.

Re: UpdateINIFile returns MAV error?

Posted: Sun May 01, 2016 5:46 pm
by juanjp600
What version of Blitz3D are you using? The latest version will not work, since FastExt hasn't been updated for about six years.

You'll need v1.106 to get a working build.

Re: UpdateINIFile returns MAV error?

Posted: Sun May 01, 2016 10:40 pm
by Marios
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)