From 35a96d83d337b0109c614007d21ac2aebf7a4c7f Mon Sep 17 00:00:00 2001 From: Lee Salzman Date: Wed, 10 Oct 2007 06:13:20 +0000 Subject: [PATCH] *** empty log message *** git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@1343 e016b1c5-ed68-44aa-a2f7-31cac88cffde --- source/src/client.cpp | 2 +- source/src/clients2c.cpp | 2 +- source/src/serverbrowser.cpp | 2 +- source/src/tools.cpp | 8 +++++++- source/src/tools.h | 2 +- 5 files changed, 11 insertions(+), 5 deletions(-) diff --git a/source/src/client.cpp b/source/src/client.cpp index d2825bda..def90c6c 100644 --- a/source/src/client.cpp +++ b/source/src/client.cpp @@ -432,7 +432,7 @@ void sendmap(char *mapname) else mapname = getclientmap(); if(securemapcheck(mapname)) return; int mapsize; - uchar *mapdata = readmap(mapname, &mapsize); + uchar *mapdata = readmap(path(mapname), &mapsize); if(!mapdata) return; ENetPacket *packet = enet_packet_create(NULL, MAXTRANS + mapsize, ENET_PACKET_FLAG_RELIABLE); ucharbuf p(packet->data, packet->dataLength); diff --git a/source/src/clients2c.cpp b/source/src/clients2c.cpp index de2423e6..44f1e872 100644 --- a/source/src/clients2c.cpp +++ b/source/src/clients2c.cpp @@ -445,7 +445,7 @@ void parsemessages(int cn, playerent *d, ucharbuf &p) p.len += mapsize; break; } - writemap(text, mapsize, &p.buf[p.len]); + writemap(path(text), mapsize, &p.buf[p.len]); p.len += mapsize; changemapserv(text, gamemode); break; diff --git a/source/src/serverbrowser.cpp b/source/src/serverbrowser.cpp index c3cccca7..47398efb 100644 --- a/source/src/serverbrowser.cpp +++ b/source/src/serverbrowser.cpp @@ -479,7 +479,7 @@ COMMAND(updatefrommaster, ARG_NONE); void writeservercfg() { - FILE *f = openfile("config/servers.cfg", "w"); + FILE *f = openfile(path("config/servers.cfg", true), "w"); if(!f) return; fprintf(f, "// servers connected to are added here automatically\n\n"); loopvrev(servers) fprintf(f, "addserver %s %d\n", servers[i].name, servers[i].port); diff --git a/source/src/tools.cpp b/source/src/tools.cpp index 462f49df..97e7407d 100644 --- a/source/src/tools.cpp +++ b/source/src/tools.cpp @@ -14,8 +14,14 @@ string homedir = ""; vector packagedirs; -char *path(char *s) +char *path(char *s, bool copy) { + if(copy) + { + static string tmp; + s_strcpy(tmp, s); + s = tmp; + } for(char *t = s; (t = strpbrk(t, "/\\")); *t++ = PATHDIV); for(char *prevdir = NULL, *curdir = s;;) { diff --git a/source/src/tools.h b/source/src/tools.h index e5c92335..8dcff8f3 100644 --- a/source/src/tools.h +++ b/source/src/tools.h @@ -466,7 +466,7 @@ inline char *newstring(const char *s, size_t l) { return s_strncpy(newstring(l), inline char *newstring(const char *s) { return newstring(s, strlen(s)); } inline char *newstringbuf(const char *s) { return newstring(s, _MAXDEFSTR-1); } -extern char *path(char *s); +extern char *path(char *s, bool copy = false); extern const char *parentdir(const char *directory); extern bool fileexists(const char *path, const char *mode); extern bool createdir(const char *path);