Armor icon hud, and blocking too much open maps

git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@4937 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
Rafael Barreto
2010-05-19 20:31:15 +00:00
parent b6d4722032
commit be1d72d7cc
8 changed files with 97 additions and 456 deletions
+2 -2
View File
@@ -10,7 +10,7 @@ void drawicon(Texture *tex, float x, float y, float s, int col, int row, float t
void drawequipicon(float x, float y, int col, int row, float blend)
{
static Texture *tex = NULL;
if(!tex) tex = textureload("packages/misc/items-tmp.png", 4);
if(!tex) tex = textureload("packages/misc/items.png", 4);
if(tex)
{
if(blend) glEnable(GL_BLEND);
@@ -268,7 +268,7 @@ void drawequipicons(playerent *p)
glColor4f(1.0f, 1.0f, 1.0f, 0.2f+(sinf(lastmillis/100.0f)+1.0f)/2.0f);
// health & armor
if(p->armour) drawequipicon(620, 1650, 3, 3, false);
if(p->armour) drawequipicon(620, 1650, (p->armour-1)/25, 2, false);
drawequipicon(20, 1650, 2, 3, (p->state!=CS_DEAD && p->health<=20 && !m_osok));
// weapons
+3 -2
View File
@@ -1625,7 +1625,7 @@ void startdemoplayback(const char *newname)
setupdemoplayback();
}
int Mvolume, Marea, Mopen;
int Mvolume, Marea, Mopen = 0;
float Mheight = 0;
void startgame(const char *newname, int newmode, int newtime, bool notify)
@@ -1673,7 +1673,7 @@ void startgame(const char *newname, int newmode, int newtime, bool notify)
if(e.fitsmode(smode)) sents[i].spawned = sents[i].legalpickup = true;
}
mapbuffer.setrevision();
logline(ACLOG_INFO, "Map height density information for %s: H = %.2f V = %d and A = %d", smapname, Mheight, Mvolume, Marea);
logline(ACLOG_INFO, "Map height density information for %s: H = %.2f V = %d, A = %d and MA = %d", smapname, Mheight, Mvolume, Marea, Mopen);
}
else if(isdedicated) sendservmsg("\f3server error: map not found - please start another map");
if(notify)
@@ -2102,6 +2102,7 @@ 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++;
+1 -1
View File
@@ -49,7 +49,7 @@ struct mapaction : serveraction
bool notify = valid_client(caller);
int maploc = MAP_NOTFOUND;
mapstats *ms = map[0] ? getservermapstats(map, true, &maploc) : NULL; // this is very redundant, since startgame gets the layout
mapok = mode == GMODE_COOPEDIT || ( ms != NULL && Mheight < 30 );
mapok = mode == GMODE_COOPEDIT || ( ms != NULL && Mheight < 30 && (Mopen = checkarea()) < 10000 );
if(!mapok)
{
if(notify) sendservmsg("the server does not have/support this map", caller);
+82 -3
View File
@@ -1,7 +1,86 @@
int checkarea(char *maplayout)
#define MINELINE 50
int getmaxarea(bool inversed_x, bool inversed_y, bool transposed)
{
return 0;
int ls = (1 << maplayout_factor);
int xi = 0, oxi = 0, xf = 0, oxf = 0, yi = 0, yf = 0, fx = 0, fy = 0;
int area = 0, maxarea = 0;
bool sav_x = false, sav_y = false;
if (transposed) fx = maplayout_factor;
else fy = maplayout_factor;
// walk on x for each y
for ( int y = (inversed_y ? ls-1 : 0); (inversed_y ? y >= 0 : y < ls); (inversed_y ? y-- : y++) ) {
/* Analyzing each cube of the line */
for ( int x = (inversed_x ? ls-1 : 0); (inversed_x ? x >= 0 : x < ls); (inversed_x ? x-- : x++) ) {
if ( maplayout[ ( x << fx ) + ( y << fy ) ] != 127 ) { // if it is not solid
if ( sav_x ) { // if the last cube was saved
xf = x; // new end for this line
}
else {
xi = x; // new begin of the line
sav_x = true; // accumulating cubes from now
}
} else { // solid
if ( xf - xi > MINELINE ) break; // if the empty line is greater than a minimum, get out
sav_x = false; // stop the accumulation of cubes
}
}
/* Analyzing this line with the previous one */
if ( xf - xi > MINELINE ) { // if the line has the minimun threshold of emptiness
if ( sav_y ) { // if the last line was saved
if ( 2*oxi + MINELINE < 2*xf &&
2*xi + MINELINE < 2*oxf ) { // if the last line intersect this one
yf = y; // new end of area
area += xf - xi;
} else {
oxi = xi; // new area vertices
oxf = xf;
}
}
else {
oxi = xi;
oxf = xf;
yi = y; // new begin of area
sav_y = true; // accumulating lines from now
}
} else {
sav_y = false; // stop the accumulation of lines
if (area > maxarea) maxarea = area; // new max area
area=0;
}
sav_x = false; // reset
xi = xf = 0;
}
return maxarea;
}
/* Please... someone more skilled do a better job here... this is ridiculous */
int checkarea() {
int area = 0, maxarea = 0;
area = getmaxarea(false,false,false);
if ( area > maxarea ) maxarea = area;
area = getmaxarea(true,false,false);
if ( area > maxarea ) maxarea = area;
area = getmaxarea(false,true,false);
if ( area > maxarea ) maxarea = area;
area = getmaxarea(true,true,false);
if ( area > maxarea ) maxarea = area;
area = getmaxarea(false,false,true);
if ( area > maxarea ) maxarea = area;
area = getmaxarea(true,false,true);
if ( area > maxarea ) maxarea = area;
area = getmaxarea(false,true,true);
if ( area > maxarea ) maxarea = area;
area = getmaxarea(true,true,true);
if ( area > maxarea ) maxarea = area;
return maxarea;
}
/**
@@ -16,7 +95,7 @@ one coding this kind of check must pay a special attention to the lag effect and
affect the data observed. This is not a trivial task, and probably it is the main reason why
such tools were never implemented.
This file is here for compatibility purposes.
This part is here for compatibility purposes.
If you know nothing about these detections, please, just ignore it.
*/
+9 -12
View File
@@ -25,9 +25,9 @@ const char *numtime()
}
extern char *maplayout;
extern int maplayout_factor, Mvolume, Marea, Mopen;
extern int maplayout_factor, Mvolume, Marea;
extern float Mheight;
extern int checkarea(char *maplayout);
extern int checkarea();
mapstats *loadmapstats(const char *filename, bool getlayout)
{
@@ -83,8 +83,8 @@ mapstats *loadmapstats(const char *filename, bool getlayout)
memset(maplayout, 0, layoutsize * sizeof(char));
char *t = NULL;
char floor = 0, ceil;
int diff;
Mvolume = Marea = Mopen = 0;
int diff = 0;
Mvolume = Marea = 0;
loopk(layoutsize)
{
char *c = maplayout + k;
@@ -110,10 +110,6 @@ mapstats *loadmapstats(const char *filename, bool getlayout)
ceil = f->getchar();
if(floor >= ceil && ceil > -128) floor = ceil - 1; // for pre 12_13
diff = ceil - floor;
if ( diff > 6 ) {
Marea++;
Mvolume+=diff;
}
if(type == FHF) floor = -128;
f->getchar(); f->getchar();
if(s.hdr.version>=2) f->getchar();
@@ -125,14 +121,15 @@ mapstats *loadmapstats(const char *filename, bool getlayout)
if(s.hdr.version<=2) { f->getchar(); f->getchar(); }
break;
}
if ( type != SOLID && diff > 6 ) {
Marea++;
Mvolume+=diff;
}
if(fail) break;
t = c;
}
if(fail) { DELETEA(maplayout); }
else {
Mheight = Marea ? (float)Mvolume/Marea : 0;
Mopen = checkarea(maplayout);
}
else Mheight = Marea ? (float)Mvolume/Marea : 0;
}
}
delete f;