showmapstats and mapstats_hud commands (client side map quality information), putting scopesens alias back to defaults, commenting spectating logs info, and updating docs

git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@5775 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
Rafael Barreto
2010-10-19 21:21:17 +00:00
parent a4066c0237
commit 8c24608ca6
6 changed files with 83 additions and 7 deletions
+2
View File
@@ -9,6 +9,8 @@ skin 0 // Change your look.
autoreload 1 // Reload the guns automatically by default.
setfont default // Choose your font
alias scopesens [ *f $sensitivity $scopesensscale ]
//bind MOUSE2 [ zoom 1; onrelease [ zoom 0 ] ]
// alternative zoom toggle
+6 -3
View File
@@ -475,7 +475,7 @@ dockey [TAB] [] [autocompletes commands/variables/aliases];
dockey [UP] [] [browse command history forwards];
dockey [DOWN] [] [browse command history backwards];
docident [scopefov] [Determines the FOV when scoping.];
docargument [V] [] [min 5/max 50/default 50];
docargument [V] [] [min 5/max 60/default 50];
docident [setscope] [will display a scope for the sniper-rifle. used in the zoom-script (config/scripts.cfg [l. 92ff "alias zoom"]];
docargument [Y] [scope on?] [0||1] [0];
docident [shiftweapon] [shifts your selected weapon by a given delta. By default the mouse-wheel shifts one up or down according to your scroll direction.];
@@ -530,8 +530,8 @@ docident [addpath2way2] [];
docident [addwp] [];
docident [advancemaprevision] [Select the increment of the map revision number for the next 'savemap'.];
docargument [N] [increment] [min 1/max 100/default 1];
docident [ambientsoundvol] [Deletes the entity closest to the player];
docremark [hotkey x];
//docident [ambientsoundvol] [Deletes the entity closest to the player]; WHAT IS THIS!??!?
//docremark [hotkey x];
docident [applymapsoundchanges] [during map editing, drop all mapsounds so they can be re-added];
docident [arch] [Makes an arch out of the current selection.];
docargument [S] [side delta (optional)] [] [0];
@@ -1466,6 +1466,8 @@ docargument [N] [TODO] [min 0/max 4/default 2];
docident [maploaditemlength] [change at what position to truncate the map title string];
docargument [N] [CHAR] [min 0/max 255/default 46];
docident [mapshot] [save an image of the entire radar-overview of the map.];
docident [mapstats_hud] [use the showmapstats command every new map];
docargument [N] [CHAR] [min 0/max 1/default 0];
docident [maxrollremote] [TODO];
docargument [N] [TODO] [min 0/max 1/default 1];
docident [mdldlist] [TODO];
@@ -1513,6 +1515,7 @@ docident [showmapbackdrop] [change wether to have a see-through map overview (0)
docargument [B] [backdrop-style] [min 0/max 2/default 0];
docident [showmapbackdroptransparency] [];
docargument [T] [transparency] [min 0/max 100/default 75];
docident [showmapstats] [show the map quality stats];
docident [soundmuted] [TODO: Description];
docargument [A] [TODO] [] [0];
docident [testvel] [TODO];
+16
View File
@@ -927,6 +927,21 @@ void resetmap(bool mrproper)
int suicided = -1;
extern bool good_map();
extern bool item_fail;
extern int MA, F2F;
extern float Mh;
VARP(mapstats_hud, 0, 0, 1);
void showmapstats()
{
conoutf("\f2Map Quality Stats");
conoutf(" The mean height is: %.2f", Mh);
if (MA) conoutf(" The max area is: %d", MA);
if (m_flags && F2F < 1000) conoutf(" Flag-to-flag distance is: %d", F2F);
if (item_fail) conoutf(" There are one or more items too close to each other in this map");
}
COMMAND(showmapstats, ARG_NONE);
void startmap(const char *name, bool reset) // called just after a map load
{
@@ -944,6 +959,7 @@ void startmap(const char *name, bool reset) // called just after a map load
if(m_valid(gamemode) && !m_mp(gamemode)) respawnself();
else findplayerstart(player1);
if(good_map()==MAP_IS_BAD) conoutf(_("You cannot play in this map due to quality requisites. Please, report this incident."));
if (mapstats_hud) showmapstats();
if(!reset) return;
+58 -2
View File
@@ -240,14 +240,70 @@ void parsepositions(ucharbuf &p)
extern int checkarea(int maplayout_factor, char *maplayout);
char *mlayout = NULL;
int Mv = 0, Ma = 0; // moved up:, MA = 0;
int Mv = 0, Ma = 0, F2F = 1000 * MINFF; // moved up:, MA = 0;
float Mh = 0;
extern int connected;
extern bool noflags;
bool item_fail = false;
int map_quality = MAP_IS_EDITABLE;
/// TODO: many functions and variables are redundant between client and server... someone should redo the entire server code and unify client and server.
bool good_map() // call this function only at startmap
{
map_quality = ((MA = checkarea(sfactor, mlayout)) < MAXMAREA && Mh < MAXMHEIGHT) ? MAP_IS_GOOD : MAP_IS_BAD;
if (mlayout) MA = checkarea(sfactor, mlayout);
if(m_flags)
{
flaginfo &f0 = flaginfos[0];
flaginfo &f1 = flaginfos[1];
#define DIST(x) (f0.pos.x - f1.pos.x)
F2F = (!numflagspawn[0] || !numflagspawn[1]) ? 1000 * MINFF : (int) fSqrt(DIST(x)*DIST(x)+DIST(y)*DIST(y));
#undef DIST
}
item_fail = false;
loopv(ents)
{
entity &e1 = ents[i];
if (e1.type < I_CLIPS || e1.type > I_AKIMBO) continue;
float density = 0, hdensity = 0;
loopvj(ents)
{
entity &e2 = ents[j];
if (e2.type < I_CLIPS || e2.type > I_AKIMBO || i == j) continue;
#define DIST(x) (e1.x - e2.x)
#define DIST_ATT ((e1.z + e1.attr1) - (e2.z + e2.attr1))
float r2 = DIST(x)*DIST(x) + DIST(y)*DIST(y) + DIST_ATT*DIST_ATT;
#undef DIST_ATT
#undef DIST
if ( r2 == 0.0f ) { conoutf("\f3MAP CHECK FAIL: Items too close %s %s (%hd,%hd)", entnames[e1.type], entnames[e2.type],e1.x,e1.y); item_fail = true; break; }
r2 = 1/r2;
if (r2 < 0.0025f) continue;
if (e1.type != e2.type)
{
hdensity += r2;
continue;
}
density += r2;
}
if ( hdensity > 0.5f ) { conoutf("\f3MAP CHECK FAIL: Items too close %s %.2f (%hd,%hd)", entnames[e1.type],hdensity,e1.x,e1.y); item_fail = true; break; }
switch(e1.type)
{
#define LOGTHISSWITCH(X) if( density > X ) { conoutf("\f3MAP CHECK FAIL: Items too close %s %.2f (%hd,%hd)", entnames[e1.type],density,e1.x,e1.y); item_fail = true; break; }
case I_CLIPS:
case I_HEALTH: LOGTHISSWITCH(0.24f); break;
case I_AMMO: LOGTHISSWITCH(0.04f); break;
case I_HELMET: LOGTHISSWITCH(0.02f); break;
case I_ARMOUR:
case I_GRENADE:
case I_AKIMBO: LOGTHISSWITCH(0.005f); break;
default: break;
#undef LOGTHISSWITCH
}
}
map_quality = (!item_fail && F2F > MINFF && MA < MAXMAREA && Mh < MAXMHEIGHT) ? MAP_IS_GOOD : MAP_IS_BAD;
if ( (!connected || gamemode == GMODE_COOPEDIT) && map_quality == MAP_IS_BAD ) map_quality = MAP_IS_EDITABLE;
return map_quality;
}
+1 -1
View File
@@ -2838,7 +2838,7 @@ void process(ENetPacket *packet, int sender, int chan)
}
case SV_SPECTCN:
cl->spectcn = getint(p);
logline(ACLOG_DEBUG, "[%s] %s is now spectating cn %d", cl->hostname, cl->name, cl->spectcn); // FIXME: comment out later
// logline(ACLOG_DEBUG, "[%s] %s is now spectating cn %d", cl->hostname, cl->name, cl->spectcn); // FIXME: comment out later
QUEUE_MSG;
break;
-1
View File
@@ -93,7 +93,6 @@ int getmaxarea(int inversed_x, int inversed_y, int transposed, int ml_factor, ch
int checkarea(int maplayout_factor, char *maplayout)
{
int area = 0, maxarea = 0;
if (!maplayout) { printf("WARNING: there is no maplayout to read in checkarea!"); return 0; }
for (int i=0; i < 8; i++) {
area = getmaxarea((i & 1),(i & 2),(i & 4), maplayout_factor, maplayout);
if ( area > maxarea ) maxarea = area;