PDA

View Full Version : Save Settings: .BIN --> .CFG


[JAPS]Suicide
15th August 2002, 21:29
Hey,
I was trying 2 make ogc 9 save to a cfg instead of bin, and i came up with this:


void writetofile2(const char *str)
{
FILE *file=fopen("save.cfg", "a"); //w= wright, r= read, a= append
if(!file) return;
fputs(str, file);
fputs("\n", file);
fclose(file);
}

void func_save_cvar_list()
{
// remove("save.cfg");
for(int j=0;j<cvarList.size();j++)
writetofile2(cvarList[j].c_str());
Con_Echo("&gSave Successful");

}

But that doesnt do ne thing but create the file, it doesnt save cvars in there or anything, but i looked at CommandInterpreter::exec_one, and i saw it does some stuff with the cvars, ltfx had his display of cvars in console with this:


void func_listcvars()
{
for(int i=0;i<cvarList.size();i++)
cmd.exec_one(cvarList[i].c_str());
}


I was thinking if I could add it into CommandInterpreter::exec_one...

Any ideas of an easier way or to save it in CommandInterpreter::exec_one?

Thanx