From 7f42db0d0bf3c82efc5ea1f1740bed350f34d1f0 Mon Sep 17 00:00:00 2001 From: driAn Date: Sun, 28 Sep 2008 11:42:31 +0000 Subject: [PATCH] more robust config reset git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@2784 e016b1c5-ed68-44aa-a2f7-31cac88cffde --- source/src/command.cpp | 15 ++++++++------- source/src/protos.h | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/source/src/command.cpp b/source/src/command.cpp index b8d50cb0..93ef2a3d 100644 --- a/source/src/command.cpp +++ b/source/src/command.cpp @@ -762,17 +762,18 @@ void writecfg() COMMAND(writecfg, ARG_NONE); -bool deletecfg() +void deletecfg() { string configs[] = { "config/saved.cfg", "config/init.cfg" }; - bool failure = false; - loopi(sizeof(configs)/sizeof(configs[0])) + loopj(2) // delete files in homedir and basedir if possible { - const char *file = findfile(path(configs[i], true), "wb"); - if(!file) continue; - if(!delfile(file)) failure = true; + loopi(sizeof(configs)/sizeof(configs[0])) + { + const char *file = findfile(path(configs[i], true), "r"); + if(!file) continue; + delfile(file); + } } - return !failure; } void identnames(vector &names, bool builtinonly) diff --git a/source/src/protos.h b/source/src/protos.h index df10b4ff..0ec373e7 100644 --- a/source/src/protos.h +++ b/source/src/protos.h @@ -56,7 +56,7 @@ extern void pop(const char *name); extern void alias(const char *name, const char *action); extern const char *getalias(const char *name); extern void writecfg(); -extern bool deletecfg(); +extern void deletecfg(); extern void identnames(vector &names, bool builtinonly); extern void changescriptcontext(int newcontext); extern void explodelist(const char *s, vector &elems);