From 32712318da2ad815442e3eaf4ebdfec018f40c4b Mon Sep 17 00:00:00 2001 From: Rafael Barreto Date: Sat, 4 Jun 2011 14:14:37 +0000 Subject: [PATCH] doing it better... (still testing the exploit, tbh) git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@6494 e016b1c5-ed68-44aa-a2f7-31cac88cffde --- source/src/clients2c.cpp | 3 +-- source/src/geom.h | 5 +---- source/src/serverfiles.h | 5 +---- source/src/tools.cpp | 2 +- source/src/world.h | 2 +- source/src/worldio.cpp | 2 +- 6 files changed, 6 insertions(+), 13 deletions(-) diff --git a/source/src/clients2c.cpp b/source/src/clients2c.cpp index 7f3192a6..33d9b40e 100644 --- a/source/src/clients2c.cpp +++ b/source/src/clients2c.cpp @@ -303,8 +303,7 @@ bool good_map() // call this function only at startmap } } - map_quality = (!item_fail && F2F > MINFF && MA < MAXMAREA && Mh < MAXMHEIGHT && - Hhits < MAXHHITS && Hhits * 3 < Ma) ? MAP_IS_GOOD : MAP_IS_BAD; + map_quality = (!item_fail && F2F > MINFF && MA < MAXMAREA && Mh < MAXMHEIGHT && Hhits < MAXHHITS) ? MAP_IS_GOOD : MAP_IS_BAD; if ( (!connected || gamemode == GMODE_COOPEDIT) && map_quality == MAP_IS_BAD ) map_quality = MAP_IS_EDITABLE; return map_quality > 0; } diff --git a/source/src/geom.h b/source/src/geom.h index 898e665e..89b91737 100644 --- a/source/src/geom.h +++ b/source/src/geom.h @@ -26,10 +26,7 @@ inline float fACos( float x ) } #undef UFINVSQRT -inline float pow2(float x) -{ - return x*x; -} +template inline T pow2(T x) { return x*x; } // Fast Cosine // inspired after http://www.devmaster.net/forums/showthread.php?t=5784 diff --git a/source/src/serverfiles.h b/source/src/serverfiles.h index d7568e91..7b479f10 100644 --- a/source/src/serverfiles.h +++ b/source/src/serverfiles.h @@ -239,10 +239,7 @@ bool mapisok(mapstats *ms) { if ( Mheight > MAXMHEIGHT ) { logline(ACLOG_INFO, "MAP CHECK FAIL: The overall ceil height is too high (%.1f cubes)", Mheight); return false; } if ( Mopen > MAXMAREA ) { logline(ACLOG_INFO, "MAP CHECK FAIL: There is a big open area in this (hint: use more solid walls)", Mheight); return false; } - if ( SHhits > MAXHHITS || SHhits * 3 > Marea ) - { - logline(ACLOG_INFO, "MAP CHECK FAIL: Too high height in some parts of the map (%d hits)", SHhits); return false; - } + if ( SHhits > MAXHHITS ) { logline(ACLOG_INFO, "MAP CHECK FAIL: Too high height in some parts of the map (%d hits)", SHhits); return false; } if ( ms->hasflags ) // Check if flags are ok { diff --git a/source/src/tools.cpp b/source/src/tools.cpp index 13228795..a72b4343 100644 --- a/source/src/tools.cpp +++ b/source/src/tools.cpp @@ -126,7 +126,7 @@ mapstats *loadmapstats(const char *filename, bool getlayout) } if ( type != SOLID && diff > 6 ) { - if (diff > MAXMHEIGHT) SHhits += diff * n; + if (diff > MAXMHEIGHT) SHhits += pow2(diff-MAXMHEIGHT)*n; Marea += n; Mvolume += diff * n; } diff --git a/source/src/world.h b/source/src/world.h index 1c91e096..73205917 100644 --- a/source/src/world.h +++ b/source/src/world.h @@ -127,7 +127,7 @@ struct mapstats #define OUTBORDRAD(x,y,rad) (int(x-rad)=ssize-MINBORD || (y+rad)>=ssize-MINBORD) #define MAXMHEIGHT 30 #define MAXMAREA 10000 -#define MAXHHITS 30000 +#define MAXHHITS 5000 #define MINFF 2500 struct block { int x, y, xs, ys; }; diff --git a/source/src/worldio.cpp b/source/src/worldio.cpp index bc1452ef..e518077d 100644 --- a/source/src/worldio.cpp +++ b/source/src/worldio.cpp @@ -643,7 +643,7 @@ bool load_world(char *mname) // still supports all map formats that have } if ( type != SOLID && diff > 6 ) { - if (diff > MAXMHEIGHT) Hhits += diff * n; + if (diff > MAXMHEIGHT) Hhits += pow2(diff-MAXMHEIGHT)*n; Ma += n; Mv += diff * n; }