From eae70d420d184bfef8e7e3a254650cf2c092ca1e Mon Sep 17 00:00:00 2001 From: Lee Salzman Date: Fri, 1 Jun 2007 17:29:15 +0000 Subject: [PATCH] *** empty log message *** git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@1063 e016b1c5-ed68-44aa-a2f7-31cac88cffde --- source/src/client.cpp | 20 ++++++++++++++++++-- source/src/main.cpp | 1 + source/src/worldio.cpp | 5 +++-- 3 files changed, 22 insertions(+), 4 deletions(-) diff --git a/source/src/client.cpp b/source/src/client.cpp index 9f8ab01f..0f75dadb 100644 --- a/source/src/client.cpp +++ b/source/src/client.cpp @@ -397,6 +397,22 @@ void gets2c() // get updates from the server // sendmap/getmap commands, should be replaced by more intuitive map downloading +cvector securemaps; + +void clearsecuremaps() { securemaps.deletecontentsa(); } +void securemap(char *map) { if(map) securemaps.add(newstring(map)); } +bool securemapcheck(char *map) +{ + if(strstr(map, "maps/")==map || strstr(map, "maps\\")==map) map += strlen("maps/"); + loopv(securemaps) if(!strcmp(securemaps[i], map)) + { + conoutf("\f3map %s is secured, you can not send or overwrite it", map); + return true; + } + return false; +} + + void sendmap(char *mapname) { if(*mapname) @@ -405,7 +421,7 @@ void sendmap(char *mapname) changemap(mapname); } mapname = getclientmap(); - if(mapinfo.access(mapname)) return; + if(securemapcheck(mapname)) return; int mapsize; uchar *mapdata = readmap(mapname, &mapsize); if(!mapdata) return; @@ -432,7 +448,7 @@ void sendmap(char *mapname) void getmap() { - if(mapinfo.access(getclientmap())) return; + if(securemapcheck(getclientmap())) return; ENetPacket *packet = enet_packet_create(NULL, MAXTRANS, ENET_PACKET_FLAG_RELIABLE); ucharbuf p(packet->data, packet->dataLength); putint(p, SV_RECVMAP); diff --git a/source/src/main.cpp b/source/src/main.cpp index 8148ca34..359ff117 100644 --- a/source/src/main.cpp +++ b/source/src/main.cpp @@ -284,6 +284,7 @@ int main(int argc, char **argv) exec("config/menus.cfg"); exec("config/prefabs.cfg"); exec("config/sounds.cfg"); + exec("config/securemaps.cfg"); execfile("config/servers.cfg"); persistidents = true; diff --git a/source/src/worldio.cpp b/source/src/worldio.cpp index 391d91ce..faa55491 100644 --- a/source/src/worldio.cpp +++ b/source/src/worldio.cpp @@ -127,12 +127,13 @@ uchar *readmap(char *mname, int *msize) void save_world(char *mname) { + extern bool securemapcheck(char *map); + if(securemapcheck(mname)) return; voptimize(); toptimize(); if(!*mname) mname = getclientmap(); setnames(mname); - if(mapinfo.access(mname)) cgzname[strlen(cgzname)-1] = 'o'; - else backup(cgzname, bakname); + backup(cgzname, bakname); gzFile f = gzopen(cgzname, "wb9"); if(!f) { conoutf("could not write map to %s", cgzname); return; } hdr.version = MAPVERSION;