diff --git a/source/src/server.cpp b/source/src/server.cpp index f2df7cbb..c7bf4b7e 100644 --- a/source/src/server.cpp +++ b/source/src/server.cpp @@ -49,7 +49,7 @@ static int interm = 0, minremain = 0, gamemillis = 0, gamelimit = 0, /*lmsitemty mapstats smapstats; vector sents; char *maplayout = NULL, *testlayout = NULL; -int maplayout_factor, testlayout_factor; +int maplayout_factor, testlayout_factor, maplayoutssize; servermapbuffer mapbuffer; // cmod diff --git a/source/src/serveractions.h b/source/src/serveractions.h index 878bb0e8..2d3fcf05 100644 --- a/source/src/serveractions.h +++ b/source/src/serveractions.h @@ -81,10 +81,10 @@ struct mapaction : serveraction bool notify = valid_client(caller); int maploc = MAP_NOTFOUND; mapstats *ms = map[0] ? getservermapstats(map, false, &maploc) : NULL; - mapok = ( ms != NULL && mapisok(ms) && mode != GMODE_COOPEDIT) || ( mode == GMODE_COOPEDIT && !readonlymap(maploc) ); + mapok = ms != NULL && ( mapisok(ms) || mode == GMODE_COOPEDIT ) && !readonlymap(maploc); if(!mapok) { - defformatstring(msg)("%s", ms ? "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 ? ( 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" ); if(notify) sendservmsg(msg, caller); } else diff --git a/source/src/serverchecks.h b/source/src/serverchecks.h index be651440..f8bb5994 100644 --- a/source/src/serverchecks.h +++ b/source/src/serverchecks.h @@ -1,4 +1,3 @@ - inline bool is_lagging(client *cl) { return ( cl->spj > 55 || cl->ping > 500 || cl->ldt > 80 ); // do not change this except if you really know what are you doing @@ -9,6 +8,24 @@ inline float pow2(float x) return x*x; } +inline bool outside_border(vec &po) +{ + return (po.x < 0 || po.y < 0 || po.x >= maplayoutssize || po.y >= maplayoutssize); +} + +inline void checkclientpos(client *cl) +{ + vec &po = cl->state.o; + if( outside_border(po) || maplayout[((int) po.x) + (((int) po.y) << maplayout_factor)] > po.z + 3) + { + if(gamemillis > 10000 && (servmillis - cl->connectmillis) > 10000) cl->mapcollisions++; + if(cl->mapcollisions && !(cl->mapcollisions % 25)) + { + logline(ACLOG_INFO, "[%s] %s is colliding with the map", cl->hostname, cl->name); + } + } +} + #define POW2XY(A,B) (pow2(A.x-B.x)+pow2(A.y-B.y)) #ifdef ACAC @@ -512,21 +529,6 @@ void check_ffire (client *target, client *actor, int damage) } } -inline void checkclientpos(client *cl) -{ - vec &po = cl->state.o; - int ls = (1 << maplayout_factor) - 1; - - if(po.x < 0 || po.y < 0 || po.x > ls || po.y > ls || maplayout[((int) po.x) + (((int) po.y) << maplayout_factor)] > po.z + 3) - { - if(gamemillis > 10000 && (servmillis - cl->connectmillis) > 10000) cl->mapcollisions++; - if(cl->mapcollisions && !(cl->mapcollisions % 25)) - { - logline(ACLOG_INFO, "[%s] %s is colliding with the map", cl->hostname, cl->name); - } - } -} - inline int check_pdist(client *c, float & dist) // pick up distance { // ping 1000ms at max velocity can produce an error of 20 cubes diff --git a/source/src/tools.cpp b/source/src/tools.cpp index 2593059d..d8a96aa2 100644 --- a/source/src/tools.cpp +++ b/source/src/tools.cpp @@ -134,6 +134,8 @@ mapstats *loadmapstats(const char *filename, bool getlayout) if (testlayout) { maplayout_factor = testlayout_factor; + extern int maplayoutssize; + maplayoutssize = 1 << testlayout_factor; int layoutsize = 1 << (testlayout_factor * 2); maplayout = new char[layoutsize + 256]; memcpy(maplayout, testlayout, layoutsize * sizeof(char));