1

Topic: question about code: src/engine/shared/datafile

Hi teeworlds community,
I'm developping a  teeworlds mod and want to add stats for players that stay on server restarts. I found the "src/engine/shared/datafile" functions and they looked like they were useful to write and read variables to/from files. Then i saw that only map related stuff is using the functions. My question is if there is a documentation about this and if its maybe only for writing and reading maps. I tried to use it without looking in the code but i get a segmentation fault when opening a file. Do i have to create the file first and has it to be a ".map" file? If my idea is possible tell me and I'll give u some code i tried.

Thanks in advance, DoNe

2 (edited by unsigned char* 2014-12-01 19:20:18)

Re: question about code: src/engine/shared/datafile

CDataFileReader -> Read .map (raw mode)
CDataFileWriter -> Write .map (raw mode)


Using TW Engine (Write File):

    IOHANDLE File = Storage()->OpenFile("mifile.dat", IOFLAG_WRITE, IStorageTW::TYPE_SAVE);
    if(!File)
        return false;

        int points = 100;
    io_write(File, &points , sizeof(int));

    io_close(File);

If you need "Storage()" interface you can request it:

m_pStorage = Kernel()->RequestInterface<IStorage>();