secure maps

git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@995 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
driAn
2007-05-10 19:26:32 +00:00
parent bd73df094b
commit 2dd2224a7a
4 changed files with 39 additions and 14 deletions
+18 -1
View File
@@ -383,6 +383,20 @@ 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)
{
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)
@@ -391,6 +405,7 @@ void sendmap(char *mapname)
changemap(mapname);
}
mapname = getclientmap();
if(securemapcheck(mapname)) return;
int mapsize;
uchar *mapdata = readmap(mapname, &mapsize);
if(!mapdata) return;
@@ -417,6 +432,7 @@ void sendmap(char *mapname)
void getmap()
{
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);
@@ -427,4 +443,5 @@ void getmap()
COMMAND(sendmap, ARG_1STR);
COMMAND(getmap, ARG_NONE);
COMMAND(clearsecuremaps, ARG_NONE);
COMMAND(securemap, ARG_1STR);