From b75856ceedad3cc7020d7010a6b46a2a082230eb Mon Sep 17 00:00:00 2001 From: Rafael Barreto Date: Tue, 3 Aug 2010 01:08:42 +0000 Subject: [PATCH] clean up, and checking the distance of the items (all official maps pass in the check) git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@5531 e016b1c5-ed68-44aa-a2f7-31cac88cffde --- source/src/clients2c.cpp | 3 +- source/src/entity.h | 4 +- source/src/serveractions.h | 43 ++++++++++++++++++++- source/src/tools.cpp | 2 +- source/src/world.h | 76 +++++++++++++++++++------------------- 5 files changed, 85 insertions(+), 43 deletions(-) diff --git a/source/src/clients2c.cpp b/source/src/clients2c.cpp index f5f4e0f7..3cdfd219 100644 --- a/source/src/clients2c.cpp +++ b/source/src/clients2c.cpp @@ -633,7 +633,8 @@ void parsemessages(int cn, playerent *d, ucharbuf &p) case SV_SCOPE: // FIXME remove in the next protocol change { - int cn = getint(p), val = getint(p); + getint(p); + getint(p); break; } diff --git a/source/src/entity.h b/source/src/entity.h index 7069ba8a..2de1bdcf 100644 --- a/source/src/entity.h +++ b/source/src/entity.h @@ -4,8 +4,8 @@ enum // static entity types LIGHT, // lightsource, attr1 = radius, attr2 = intensity PLAYERSTART, // attr1 = angle, attr2 = team I_CLIPS, I_AMMO, I_GRENADE, - I_HEALTH, I_HELMET, I_ARMOUR, I_AKIMBO, - // helmet : 2010may16 -> mapversion:8 + I_HEALTH, I_HELMET, I_ARMOUR, I_AKIMBO, + // helmet : 2010may16 -> mapversion:8 MAPMODEL, // attr1 = angle, attr2 = idx CARROT, // attr1 = tag, attr2 = type LADDER, diff --git a/source/src/serveractions.h b/source/src/serveractions.h index 9ae6838f..ef5941f3 100644 --- a/source/src/serveractions.h +++ b/source/src/serveractions.h @@ -50,6 +50,47 @@ bool mapisok(mapstats *ms) FlagFlag = pow2(fl[0].x - fl[1].x) + pow2(fl[0].y - fl[1].y); } else FlagFlag = MINFF * 1000; // the map has no flags + + for (int i = 0; i < ms->hdr.numents; i++) + { + int v = ms->enttypes[i]; + if (v < I_CLIPS || v > I_AKIMBO) continue; + short *p = &ms->entposs[i*3]; + float density = 0, hdensity = 0; + for(int j = 0; j < ms->hdr.numents; j++) + { + int w = ms->enttypes[j]; + if (w < I_CLIPS || w > I_AKIMBO || i == j) continue; + short *q = &ms->entposs[j*3]; + float r2 = 0; + loopk(3){ r2 += (p[k]-q[k])*(p[k]-q[k]); } + if ( r2 == 0.0f ) return false; + r2 = 1/r2; + if (r2 < 0.0025f) continue; + if (w != v) + { + hdensity += r2; + continue; + } + density += r2; + } +/* if (hdensity > 0.0f) { logline(ACLOG_INFO, "ITEM CHECK H %s %f", entnames[v], hdensity); } + if (density > 0.0f) { logline(ACLOG_INFO, "ITEM CHECK D %s %f", entnames[v], density); }*/ + if ( hdensity > 0.5f ) return false; + if (v==I_HEALTH) + { + if( density > 0.24f ) return false; + } + else if (v==I_GRENADE) + { + if( density > 0.005f ) return false; + } + else + { + if( density > 0.04f ) return false; + } + + } return Mheight < MAXMHEIGHT && (Mopen = checkarea(testlayout_factor, testlayout)) < MAXMAREA && FlagFlag > MINFF; } @@ -84,7 +125,7 @@ struct mapaction : serveraction mapok = ms != NULL && ( (mode != GMODE_COOPEDIT && mapisok(ms)) || (mode == GMODE_COOPEDIT && !readonlymap(maploc)) ); if(!mapok) { - defformatstring(msg)("%s", ms ? ( readonlymap(maploc) ? "this map cannot be coopedited in this server" : "sorry, but this map does not satisfy some quality requisites to be played in MultiPlayer Mode" ) : "the server does not have this map" ); + defformatstring(msg)("%s", ms ? ( mode == GMODE_COOPEDIT ? "this map cannot be coopedited in this server" : "sorry, but this map does not satisfy some quality requisites to be played in MultiPlayer Mode" ) : "the server does not have this map" ); if(notify) sendservmsg(msg, caller); } else diff --git a/source/src/tools.cpp b/source/src/tools.cpp index d8a96aa2..fa6cc250 100644 --- a/source/src/tools.cpp +++ b/source/src/tools.cpp @@ -68,7 +68,7 @@ mapstats *loadmapstats(const char *filename, bool getlayout) if(e.type == CTF_FLAG && (e.attr2 == 0 || e.attr2 == 1)) { s.flags[e.attr2]++; s.flagents[e.attr2] = i; } s.entcnt[e.type]++; enttypes[i] = e.type; - entposs[i * 3] = e.x; entposs[i * 3 + 1] = e.y; entposs[i * 3 + 2] = e.z; + entposs[i * 3] = e.x; entposs[i * 3 + 1] = e.y; entposs[i * 3 + 2] = e.z + e.attr1; } DELETEA(testlayout); if(s.hdr.sfactor <= LARGEST_FACTOR && s.hdr.sfactor >= SMALLEST_FACTOR) diff --git a/source/src/world.h b/source/src/world.h index b89ce225..bf9c8c5a 100644 --- a/source/src/world.h +++ b/source/src/world.h @@ -74,45 +74,45 @@ struct mapstats } \ if(headr.version<6 && strncmp(headr.head,"CUBE",4)==0) /* only render lights, pl starts and map models on old maps // <6 was =6 && headr.version<8) { \ - if( e.type >= I_HELMET && e.type < (MAXENTTYPES - 1) ) { e.type += 1; } \ - } + if(headr.version>=6 && headr.version<8) { \ + if( e.type >= I_HELMET && e.type < (MAXENTTYPES - 1) ) { e.type += 1; } \ + } #define SWS(w,x,y,s) (&(w)[((y)<<(s))+(x)]) #define SW(w,x,y) SWS(w,x,y,sfactor)