From 54a98702232a9a3f5bf10030ec74543ce20945fe Mon Sep 17 00:00:00 2001 From: flowtron Date: Sun, 27 Jun 2010 17:18:53 +0000 Subject: [PATCH] improved showmap and checkarea replacment candidate git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@5244 e016b1c5-ed68-44aa-a2f7-31cac88cffde --- source/src/clientgame.cpp | 7 ++++--- source/src/protos.h | 1 + source/src/renderhud.cpp | 7 +++++-- source/src/worldio.cpp | 44 +++++++++++++++++++++++++++++++++++++-- 4 files changed, 52 insertions(+), 7 deletions(-) diff --git a/source/src/clientgame.cpp b/source/src/clientgame.cpp index c98de324..ad599d06 100644 --- a/source/src/clientgame.cpp +++ b/source/src/clientgame.cpp @@ -3,9 +3,10 @@ #include "cube.h" #include "bot/bot.h" -int nextmode = 0; // nextmode becomes gamemode after next map load +int nextmode = 0; // nextmode becomes gamemode after next map load +int mapdims[7]; // min/max X/Y VAR(gamemode, 1, 0, 0); -VARP(modeacronyms, 0, 0, 1); +VARP(modeacronyms, 0, 1, 1); flaginfo flaginfos[2]; @@ -593,7 +594,7 @@ bool tryrespawn() } else if(spawnpermission > SP_OK_NUM) { - hudeditf(HUDMSG_TIMER, "\f%s", spawnpermission == SP_WRONGMAP ? "3You have to be on the correct map to spawn. Type /getmap" : "4Waiting permission to spawn. Don\'t panic!"); + hudeditf(HUDMSG_TIMER, "\f%s", spawnpermission == SP_WRONGMAP ? "3You have to be on the correct map to spawn. Type /getmap" : "4Awaiting permission to spawn. Don\'t panic!"); } else if(player1->state==CS_DEAD) { diff --git a/source/src/protos.h b/source/src/protos.h index 26b6abb6..22ce81c4 100644 --- a/source/src/protos.h +++ b/source/src/protos.h @@ -327,6 +327,7 @@ extern void getdemo(int i); extern void listdemos(); // clientgame +extern int mapdims[7]; extern flaginfo flaginfos[2]; extern int sessionid; extern bool watchingdemo; diff --git a/source/src/renderhud.cpp b/source/src/renderhud.cpp index d9309988..718b63b6 100644 --- a/source/src/renderhud.cpp +++ b/source/src/renderhud.cpp @@ -394,8 +394,11 @@ vec getradarpos() void drawradar(playerent *p, int w, int h) { - vec center = showmap ? vec(ssize/2, ssize/2, 0) : p->o; - int res = showmap ? ssize : radarres; + // vec center = showmap ? vec(ssize/2, ssize/2, 0) : p->o; int res = showmap ? ssize : radarres; + // improved center (for maps that don't use all worldspace) + int gdim = max(mapdims[4], mapdims[5]); + vec center = showmap ? vec(mapdims[0] + mapdims[4]/2, mapdims[1] + mapdims[5]/2, 0) : p->o; + int res = showmap ? gdim : radarres; float worldsize = (float)ssize; float radarviewsize = showmap ? VIRTH : VIRTH/6; diff --git a/source/src/worldio.cpp b/source/src/worldio.cpp index 46307d3b..cdd5cb51 100644 --- a/source/src/worldio.cpp +++ b/source/src/worldio.cpp @@ -444,7 +444,7 @@ void save_world(char *mname) extern void preparectf(bool cleanonly = false); int numspawn[3], maploaded = 0, numflagspawn[2]; VAR(curmaprevision, 1, 0, 0); - +VAR(showmapdims, 0, 0, 1); // for testing extern char *mlayout; extern int Mv, Ma; extern float Mh; @@ -626,10 +626,50 @@ bool load_world(char *mname) // still supports all map formats that have Mh = Ma ? (float)Mv/Ma : 0; if(f) delete f; c2skeepalive(); + int cwx, cwy; + loopk(4) mapdims[k] = k < 2 ? ssize : 0; + loopk(cubicsize) + { + switch(world[k].type) + { + case CORNER: + case FHF: + case CHF: + case SPACE: + case SEMISOLID: + { + cwx = k%ssize; + cwy = k/ssize; + if(cwx < mapdims[0]) mapdims[0] = cwx; + if(cwy < mapdims[1]) mapdims[1] = cwy; + if(cwx > mapdims[2]) mapdims[2] = cwx; + if(cwy > mapdims[3]) mapdims[3] = cwy; + } + default: break; + } + } + loopk(2) mapdims[k+4] = mapdims[k+2] - mapdims[k]; + int mapll[ssize]; // for testing + loopj(ssize) + { + int crc = 0; + loopk(ssize) + { + int a = j*ssize + k; + if(world[a].type >= CORNER && world[a].type <= SEMISOLID) crc++; + } + mapll[j] = crc; + mapdims[6] += crc; + } + //loopk(ssize) printf( "ROW %02d: %d\n", k, mapll[k]); // test output calclight(); conoutf("read map %s rev %d (%d milliseconds)", cgzname, hdr.maprevision, watch.stop()); conoutf("%s", hdr.maptitle); - + if(showmapdims) conoutf("MAPDIM: %03d:%03d - %03d:%03d : maxW %03d maxH %03d : Area %03d", + mapdims[0], mapdims[1], mapdims[2], mapdims[3], + mapdims[4], mapdims[5], + mapdims[6] + ); // TESTING pushscontext(IEXC_MAPCFG); // untrusted altogether persistidents = false; execfile("config/default_map_settings.cfg");