Legacy GM Q:Ini files

Z

zendraw

Guest
Hi,

i have 2 questions about ini filies
1. when you open an ini file does the size of the ini file matter? does it affect performence?
2. is it wise to use ini files without specifying a directory? and is it wise to use ini`s atall for saving ds_grids?

my game will use ini`s alot.
 
P

PandaPenguin

Guest
regarding 1)
I think you have to try very hard to make "big" ini files as they are just plain text and therefore rather small in filesize

as for 2)
due to GM being sandboxed you have the "choice" of 2 directories only anyway... the working_directory and the programm_directory (or any sub-directories of these) and GM will pick the working_directory by default if you not specify one yourself
 
Z

zendraw

Guest
lets say the ini file gets to 100mbs. will that get tedious for the pc?
also note i wont aways use all the information from the ini file, just few lines. the big chunk to load comes when loading a grid string from it.
 
Z

zendraw

Guest
from my calculations the biggest map that i can export will be around 4mb.
so if i make like 100 maps that will be 400mb.
and my problem is shuld i make separate files for each map or collect them all in 1 file?
 
P

PandaPenguin

Guest
from my calculations the biggest map that i can export will be around 4mb.
so if i make like 100 maps that will be 400mb.
and my problem is shuld i make separate files for each map or collect them all in 1 file?
.... Oo

I'm just wondering right now what you are gonna be storing in these... is all of the data created on runtime? do you really need to store all that?
that sounds like a lot of optimization potential here ...
not saying you doing something wrong ;) just might be good to take a look at that data and sift out stuff you don't really need to store
 
Z

zendraw

Guest
im savin a ds_grid in it. the minimum size of the grid is 50x50. and yea i pretty much need all the grid spaces.
the smallest grid 50x50 is 58kb
the biggest 300x300 is around 4mb.
 
P

PandaPenguin

Guest
ya what I meant is what you store inside the grid

I'm guessing now but is it some sort of "world" data that you generated at some point and now want to store for later use?
 
R

rui.rosario

Guest
I'm replying out of memory here, so don't quote me on this because I might be wrong, but if I recall GM loads the complete INI contents in memory when you load an INI. So yes, large INI files will affect performance (and memory footprint).

My advice: With that amount of data look into buffers that allow you to define a custom format that can be trimmed in size and optimized for fast loading (also, consider storing each grid separately, unless you have some sort of lookup table by which you can just skip part of the file directly into the grid you want to load).
 
Z

zendraw

Guest
it stores numbers. grid[# x, y]=n;

rui. what do you mean by lookup table? currently im saving the grids separately, but have them in a 'world' file that has all the maps. also can you direct me to these buffers?
 
P

PandaPenguin

Guest
it stores numbers. grid[# x, y]=n;

rui. what do you mean by lookup table? currently im saving the grids separately, but have them in a 'world' file that has all the maps. also can you direct me to these buffers?
just numbers? where do you get them from? do you generate them at some point?

what I'm trying to go for here is that you might be better off with "world seeds" to reduce the amount of data you need to store ;)
 

YanBG

Member
If the grids are for wall and floor tile and only needed on room creation, you can just use the seed functions. The game will save and load the same variation/randomness but if you change the terrain types during the gameplay, seeds might not work idk.

For grids it's better(easier to read by humans/faster to load?) to use CSV instead of INI(dll could be the best, but i haven't worked with it yet). GM 2 has a proper fuction to load csv but you can do it in 1.4 with scripts as well https://forum.yoyogames.com/index.php?threads/solved-csv-to-grid.10172/
 
R

rui.rosario

Guest
rui. what do you mean by lookup table? currently im saving the grids separately, but have them in a 'world' file that has all the maps. also can you direct me to these buffers?
The lookup table was a suggestion if you use custom formats and keep only one file with all grids.
Basically the beginning of the file would be an encoded table with the offset from the start of the file to the beginning of each different grid, so you could quickly skip the first N bytes and go directly to the grid you wanted to load.

Concerning buffers, here's the documentation for GameMaker: Studio 1.4 and GameMaker: Studio 2.
 
Z

zendraw

Guest
the maps are custom, will seed work with custom maps? i know that you can save the seed and just load it but i thought it can be used in this way only with a generated terrain.
 
P

PandaPenguin

Guest
the maps are custom, will seed work with custom maps? i know that you can save the seed and just load it but i thought it can be used in this way only with a generated terrain.
what do you mean with "custom" ^^
you made them "by hand" and not by some formula?
 
Z

zendraw

Guest
yes.

also another question, can i get the name of all the files in the directory theyr saved in? is there a function for this or somthing?
 
P

PandaPenguin

Guest
also another question, can i get the name of all the files in the directory theyr saved in? is there a function for this or somthing?
sure, use the file_find_first() and file_find_next() in combination with a loop (probably do/until) and "read" all file names into an array or other data structure

EDIT: just dug up my own "directory scan" code I use in my game to find all PNG files in a directory (used a FOR loop in that case)

Code:
for(fName = file_find_first(tempDir + "\*.png", 0); fName != ""; fName = file_find_next())
{
 //do stuff with fName
}
 
Z

zendraw

Guest
how do you access the default directory? just '*.sav'?
also is there a proble to use other filetypes like .wor .map .whatever? ive heard somewhere that there might be legal issues if you use certain types.
 
P

PandaPenguin

Guest
ah right the "tempDir" in my code was a specific directory I use
for the default just use "*.sav" as you guessed right

name it whatever you like, I use my "own" file extensions for my files as it is just a "label" with no effect on the "content" of the file
if you create/modify it with the INI functions it will still be an ini file on the inside regardless of what you name the file extension
 
R

rui.rosario

Guest
sure, use the file_find_first() and file_find_next() in combination with a loop (probably do/until) and "read" all file names into an array or other data structure

EDIT: just dug up my own "directory scan" code I use in my game to find all PNG files in a directory (used a FOR loop in that case)

Code:
for(fName = file_find_first(tempDir + "\*.png", 0); fName != ""; fName = file_find_next())
{
 //do stuff with fName
}
Don't forget file_find_close.
 
Z

zendraw

Guest
okay but what is this size limit? i go out of this limit aways and i get no errors or w/e. so what exactly is this limit?
 

Tsa05

Member
@blacklemon I used to as well, but I would not depend upon it working on all platforms and for all future uses. YYG has been modifying ini file handling behind the scenes in a few ways in recent months, and the trend seems to be that they are trying to make the functions obey the strictest set of ini limitations rather than the most liberal set. Note the explicit addition of this file size limitation in the next version of the documentation:

 
Z

zendraw

Guest
but im working in gms1.4.
so how do you suggest saving things like grids and such?
 
Z

zendraw

Guest
whats the difference with buffers and just writin info in a file?
 
R

rui.rosario

Guest
Buffers allow you to do some nicer operations directly in memory, however if you look at it only for writing / reading files then it can pretty much be the same (only difference will be performance. I bet buffers will be faster).
 
Z

zendraw

Guest
the fact that things will get more complicated discourages me, its not like im just starting to build up. i will check youtube for tutorials. perhaps you know a good one?
 
R

rui.rosario

Guest
I don't know any YouTube tutorials myself, but searching should yield some of them.
Also, yes INIs are basically text files with a specific format.

Btw, learning how to use buffers will only contribute towards a better knowledge of GM:S itself and it is also a very important part (you can do a lot with buffers). I can help you with any trouble regarding buffers viw PM if you want.
 
P

PandaPenguin

Guest
i will keep that in mind and thanks.
just to get back to this topic:

out of curiosity I just created a small GMS:2 project that creates one INI file and fills it with a set amount of sections and keys
the keys are 128 char long random generated strings

so far I had no problem with big ini file handling
and with big I'm talking about 1.2 GB file size of a single INI file! (some 1000 sections with 1000 keys each)

aside from creating that file the project also "reads" random sections/keys from that created ini with no problem

so... I'm not really sure what this 64kb size limit is supposed to be
maybe it is just my Windows 10 x64 handling that humongous ini file better than "older" OS?
 
Z

zendraw

Guest
from what i understood this limit is for phones and such, not pc`s.
 
Top