1 (edited by Ikaron 2012-04-08 19:19:40)

Topic: [Help] Crash on reading file

This code crashes my server...

std::ifstream accFile;
char buf[1024];
char buf2[1024];
str_format(buf, sizeof(buf), "./accounts/%s.acc", name);

accFile.open(buf);
accFile >> buf2;
accFile.close();

return sscanf(buf2, "%s/%d/%d/%d/%d/%d", pass, upgrades[UPGRADE_RELOAD], upgrades[UPGRADE_SPREAD], upgrades[UPGRADE_AUTOFIRE], upgrades[UPGRADE_RANGE], upgrades[UPGRADE_SPAWN]) == 6;

Saving to the same file works. I can not provide further information, because all I know is that it crashes sad
All the variables exist (pass, upgrades, etc...) and accessing them works, except for pass. When accessing pass, the same happens...

Example of what a file looks like: "password/0/0/0/0/0"

(I hate C++ big_smile)

2

Re: [Help] Crash on reading file

What lines does crash?

You definitely should use the teeworlds baselib functions instead of the c++ streams for that imo.

Not Luck, Just Magic.

3

Re: [Help] Crash on reading file

Well, using a debugger might help. That's something you should do before posting.

4

Re: [Help] Crash on reading file

Is there a trend on collecting thumbs-down, dune? O.o
Okey, any tips on how to use teeworlds_server_d.exe? It creates a file called teeworlds_server_d.pdb, but how can I read it? (I ran the server into this crash, because I thought it would record it.)

and Dune, where can I find the teeworlds baselib functions?

5

Re: [Help] Crash on reading file

Ikaron wrote:

Iwhere can I find the teeworlds baselib functions?

Take a look in src/base

6

Re: [Help] Crash on reading file

Ikaron wrote:

Is there a trend on collecting thumbs-down, dune? O.o
Okey, any tips on how to use teeworlds_server_d.exe? It creates a file called teeworlds_server_d.pdb, but how can I read it? (I ran the server into this crash, because I thought it would record it.)

and Dune, where can I find the teeworlds baselib functions?

The file you really want to search in is src/base/system.h. But I usually prefer just to look elsewhere how Teeworlds handles with files. It's quite important when working on a community project (Teeworlds may have about 30 contributors) to adapt to the coding style/rules of the base project.

Ah, and yeah, the thumbs system is actually reverted, nevermind that.

Not Luck, Just Magic.