From 945a60a20ccf8e89eecb04c9c317abaa76eb720f Mon Sep 17 00:00:00 2001 From: Enno Rehling Date: Sun, 18 Dec 2005 21:53:12 +0000 Subject: [PATCH] =?UTF-8?q?Sicherstellen,=20dass=20keien=20hardlinks=20aut?= =?UTF-8?q?omatisch=20=C3=BCbermeiert=20werden=20(unlink).=20Schnelleres?= =?UTF-8?q?=20Backup=20ohne=20system()=20mit=20Hardlinks.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common/kernel/save.c | 25 ++++++++++++--------- src/common/spells/unitcurse.c | 42 +++++++++++++++++------------------ src/config.h | 1 + src/scripts/eressea.lua | 2 +- 4 files changed, 38 insertions(+), 32 deletions(-) diff --git a/src/common/kernel/save.c b/src/common/kernel/save.c index baf909051..1e3ce0452 100644 --- a/src/common/kernel/save.c +++ b/src/common/kernel/save.c @@ -718,16 +718,15 @@ typus2race(unsigned char typus) void create_backup(char *file) { -#if defined(HAVE_ACCESS) - char bfile[MAX_PATH]; - char command[MAX_PATH*2+10]; - int c = 1; - do { - sprintf(bfile, "%s.backup%d", file, c); - c++; - } while(access(bfile, R_OK) == 0); - sprintf(command, "cp %s %s", file, bfile); - system(command); +#ifdef HAVE_UNISTD_H + char bfile[MAX_PATH]; + char command[MAX_PATH*2+10]; + int c = 1; + do { + sprintf(bfile, "%s.backup%d", file, c); + c++; + } while(access(bfile, R_OK) == 0); + link(file, bfile); #endif } @@ -2017,6 +2016,12 @@ writegame(const char *filename, char quiet) #endif sprintf(buf, "%s/%s", datapath(), filename); +#ifdef HAVE_UNISTD_H + if (access(buf, R_OK) == 0) { + /* make sure we don't overwrite some hardlinkedfile */ + unlink(buf); + } +#endif F = cfopen(buf, "w"); if (F==NULL) return -1; diff --git a/src/common/spells/unitcurse.c b/src/common/spells/unitcurse.c index b6f0ed029..3d4b6c474 100644 --- a/src/common/spells/unitcurse.c +++ b/src/common/spells/unitcurse.c @@ -154,28 +154,28 @@ static struct curse_type ct_slavery = { "slavery", static int cinfo_calm(const struct locale * lang, const void * obj, typ_t typ, struct curse *c, int self) { - unit *u; - const struct race * rc; - faction *f; - unused(typ); + unit *u; + const struct race * rc; + faction *f; + unused(typ); - assert(typ == TYP_UNIT); - u = (unit *)obj; - if (c->magician){ - rc = c->magician->irace; - f = c->magician->faction; - if (self != 0) { - sprintf(buf, "%s mag %s", u->name, factionname(f)); - } else { - sprintf(buf, "%s scheint %s zu mögen", u->name, LOC(f->locale, rc_name(rc, 1))); - } - scat(". ("); - scat(itoa36(c->no)); - scat(")"); - - return 1; - } - return 0; + assert(typ == TYP_UNIT); + u = (unit *)obj; + if (c->magician && c->magician->faction) { + rc = c->magician->irace; + f = c->magician->faction; + if (f!=NULL && self != 0) { + sprintf(buf, "%s mag %s", u->name, factionname(f)); + } else { + sprintf(buf, "%s scheint %s zu mögen", u->name, LOC(lang, rc_name(rc, 1))); + } + scat(". ("); + scat(itoa36(c->no)); + scat(")"); + + return 1; + } + return 0; } static struct curse_type ct_calmmonster = { "calmmonster", CURSETYP_NORM, CURSE_SPREADNEVER, NO_MERGE, diff --git a/src/config.h b/src/config.h index a20de3c3d..3dd02153f 100644 --- a/src/config.h +++ b/src/config.h @@ -94,6 +94,7 @@ extern "C" { #if defined(__USE_SVID) || defined(_BSD_SOURCE) || defined(__USE_XOPEN_EXTENDED) || defined(_BE_SETUP_H) || defined(CYGWIN) # include +# define HAVE_UNISTD_H # define HAVE_STRCASECMP # define HAVE_STRNCASECMP # define HAVE_ACCESS diff --git a/src/scripts/eressea.lua b/src/scripts/eressea.lua index 8a84c4780..c7c096b26 100644 --- a/src/scripts/eressea.lua +++ b/src/scripts/eressea.lua @@ -8,7 +8,7 @@ end function change_locales() -- local localechange = { } - local localechange = { de = { "2xwr" } } + local localechange = { de = { "bLub" } } for loc, flist in localechange do for index, name in flist do