Old draw cleanups, frogot I had them around..

Clean up of Dabb's mess, he dies.
This commit is contained in:
Zephaniah E. Hull 2000-08-14 04:53:45 +00:00
parent 9a2ec3c094
commit 23d81824dc
6 changed files with 152 additions and 243 deletions

View file

@ -35,7 +35,6 @@ extern qpic_t *draw_disc; // also used on sbar
void Draw_Init (void); void Draw_Init (void);
void Draw_Character8 (int x, int y, int num); void Draw_Character8 (int x, int y, int num);
void Draw_DebugChar (char num);
void Draw_SubPic(int x, int y, qpic_t *pic, int srcx, int srcy, int width, int height); void Draw_SubPic(int x, int y, qpic_t *pic, int srcx, int srcy, int width, int height);
void Draw_Pic (int x, int y, qpic_t *pic); void Draw_Pic (int x, int y, qpic_t *pic);
void Draw_TransPic (int x, int y, qpic_t *pic); void Draw_TransPic (int x, int y, qpic_t *pic);

View file

@ -90,11 +90,9 @@ extern int texture_mode;
extern float gldepthmin, gldepthmax; extern float gldepthmin, gldepthmax;
void GL_Upload32 (unsigned *data, int width, int height, qboolean mipmap, qboolean alpha);
void GL_Upload8 (byte *data, int width, int height, qboolean mipmap, qboolean alpha); void GL_Upload8 (byte *data, int width, int height, qboolean mipmap, qboolean alpha);
void GL_Upload8_EXT (byte *data, int width, int height, qboolean mipmap, qboolean alpha); void GL_Upload8_EXT (byte *data, int width, int height, qboolean mipmap, qboolean alpha);
int GL_LoadTexture (char *identifier, int width, int height, byte *data, qboolean mipmap, qboolean alpha, int bytesperpixel); int GL_LoadTexture (char *identifier, int width, int height, byte *data, qboolean mipmap, qboolean alpha, int bytesperpixel);
int GL_FindTexture (char *identifier);
typedef struct typedef struct
{ {
@ -291,7 +289,6 @@ void R_DrawSky (void);
// //
// gl_draw.c // gl_draw.c
// //
int GL_LoadPicTexture (qpic_t *pic);
void GL_Set2D (void); void GL_Set2D (void);
// //

View file

@ -285,7 +285,15 @@ typedef struct
double firstseen; double firstseen;
} flood_t; } flood_t;
enum {FLOOD_PING, FLOOD_LOG, FLOOD_CONNECT, FLOOD_STATUS, FLOOD_RCON, FLOOD_BAN}; typedef enum
{
FLOOD_PING,
FLOOD_LOG,
FLOOD_CONNECT,
FLOOD_STATUS,
FLOOD_RCON,
FLOOD_BAN
} flood_enum_t;
#define DOSFLOODCMDS 6 #define DOSFLOODCMDS 6
#define DOSFLOODIP 64 // remember latest 64 IP's for each cmd. #define DOSFLOODIP 64 // remember latest 64 IP's for each cmd.

View file

@ -324,49 +324,6 @@ void Draw_Crosshair(void)
'+'); '+');
} }
/*
================
Draw_DebugChar
Draws a single character directly to the upper right corner of the screen.
This is for debugging lockups by drawing different chars in different parts
of the code.
================
*/
void Draw_DebugChar (char num)
{
byte *dest;
byte *source;
int drawline;
extern byte *draw_chars;
int row, col;
if (!vid.direct)
return; // don't have direct FB access, so no debugchars...
drawline = 8;
row = num>>4;
col = num&15;
source = draw_chars + (row<<10) + (col<<3);
dest = vid.direct + 312;
while (drawline--)
{
dest[0] = source[0];
dest[1] = source[1];
dest[2] = source[2];
dest[3] = source[3];
dest[4] = source[4];
dest[5] = source[5];
dest[6] = source[6];
dest[7] = source[7];
source += 128;
dest += 320;
}
}
/* /*
============= =============
Draw_Pic Draw_Pic

View file

@ -56,8 +56,7 @@
#include "console.h" #include "console.h"
#include "glquake.h" #include "glquake.h"
// FIXME: Do this right.. static int GL_LoadPicTexture (qpic_t *pic);
void LoadTGA (FILE *fin);
extern byte *host_basepal; extern byte *host_basepal;
extern unsigned char d_15to8table[65536]; extern unsigned char d_15to8table[65536];
@ -80,12 +79,12 @@ extern byte *draw_chars; // 8*8 graphic characters
qpic_t *draw_disc; qpic_t *draw_disc;
qpic_t *draw_backtile; qpic_t *draw_backtile;
int ltexcrctable[256]; // cache mismatch checking --KB static int ltexcrctable[256]; // cache mismatch checking --KB
int translate_texture; static int translate_texture;
int char_texture; static int char_texture;
int cs_texture; // crosshair texturea static int cs_texture; // crosshair texturea
static byte cs_data[64] = { static byte cs_data[64] = {
0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xfe, 0xff, 0xff, 0xff, 0xff,
@ -110,12 +109,10 @@ int gl_lightmap_format = 4;
int gl_solid_format = 3; int gl_solid_format = 3;
int gl_alpha_format = 4; int gl_alpha_format = 4;
int gl_filter_min = GL_LINEAR_MIPMAP_NEAREST; static int gl_filter_min = GL_LINEAR_MIPMAP_NEAREST;
int gl_filter_max = GL_LINEAR; static int gl_filter_max = GL_LINEAR;
int texels;
typedef struct typedef struct
{ {
int texnum; int texnum;
@ -127,9 +124,8 @@ typedef struct
} gltexture_t; } gltexture_t;
#define MAX_GLTEXTURES 1024 #define MAX_GLTEXTURES 1024
gltexture_t gltextures[MAX_GLTEXTURES]; static gltexture_t gltextures[MAX_GLTEXTURES];
int numgltextures; static int numgltextures = 0;
/* /*
============================================================================= =============================================================================
@ -139,42 +135,45 @@ int numgltextures;
Allocate all the little status bar obejcts into a single texture Allocate all the little status bar obejcts into a single texture
to crutch up stupid hardware / drivers to crutch up stupid hardware / drivers
Note, this is a kluge, which may slow down sane cards..
As such its all contained in ifdefs..
============================================================================= =============================================================================
*/ */
#undef gl_draw_scraps
#ifdef gl_draw_scraps
#define MAX_SCRAPS 1 #define MAX_SCRAPS 1
#define BLOCK_WIDTH 256 #define BLOCK_WIDTH 256
#define BLOCK_HEIGHT 256 #define BLOCK_HEIGHT 256
int scrap_allocated[MAX_SCRAPS][BLOCK_WIDTH]; static int scrap_allocated[MAX_SCRAPS][BLOCK_WIDTH];
byte scrap_texels[MAX_SCRAPS][BLOCK_WIDTH*BLOCK_HEIGHT*4]; static byte scrap_texels[MAX_SCRAPS][BLOCK_WIDTH*BLOCK_HEIGHT*4];
qboolean scrap_dirty; static qboolean scrap_dirty;
int scrap_texnum; static int scrap_texnum;
// returns a texture number and the position inside it // returns a texture number and the position inside it
int Scrap_AllocBlock (int w, int h, int *x, int *y) static int Scrap_AllocBlock (int w, int h, int *x, int *y)
{ {
int i, j; int i, j;
int best, best2; int best, best2;
int texnum; int texnum;
for (texnum=0 ; texnum<MAX_SCRAPS ; texnum++) for (texnum=0 ; texnum<MAX_SCRAPS ; texnum++) {
{
best = BLOCK_HEIGHT; best = BLOCK_HEIGHT;
for (i=0 ; i<BLOCK_WIDTH-w ; i++) for (i=0 ; i<BLOCK_WIDTH-w ; i++) {
{
best2 = 0; best2 = 0;
for (j=0 ; j<w ; j++) for (j=0 ; j<w ; j++) {
{
if (scrap_allocated[texnum][i+j] >= best) if (scrap_allocated[texnum][i+j] >= best)
break; break;
if (scrap_allocated[texnum][i+j] > best2) if (scrap_allocated[texnum][i+j] > best2)
best2 = scrap_allocated[texnum][i+j]; best2 = scrap_allocated[texnum][i+j];
} }
if (j == w) if (j == w) { // this is a valid spot
{ // this is a valid spot
*x = i; *x = i;
*y = best = best2; *y = best = best2;
} }
@ -186,6 +185,7 @@ int Scrap_AllocBlock (int w, int h, int *x, int *y)
for (i=0 ; i<w ; i++) for (i=0 ; i<w ; i++)
scrap_allocated[texnum][*x + i] = best + h; scrap_allocated[texnum][*x + i] = best + h;
scrap_dirty = true;
return texnum; return texnum;
} }
@ -193,16 +193,15 @@ int Scrap_AllocBlock (int w, int h, int *x, int *y)
return 0; return 0;
} }
int scrap_uploads; static void Scrap_Upload (void)
void Scrap_Upload (void)
{ {
scrap_uploads++;
glBindTexture (GL_TEXTURE_2D, scrap_texnum); glBindTexture (GL_TEXTURE_2D, scrap_texnum);
GL_Upload8 (scrap_texels[0], BLOCK_WIDTH, BLOCK_HEIGHT, false, true); GL_Upload8 (scrap_texels[0], BLOCK_WIDTH, BLOCK_HEIGHT, false, true);
scrap_dirty = false; scrap_dirty = false;
} }
#endif
//============================================================================= //=============================================================================
/* Support Routines */ /* Support Routines */
@ -215,13 +214,10 @@ typedef struct cachepic_s
} cachepic_t; } cachepic_t;
#define MAX_CACHED_PICS 128 #define MAX_CACHED_PICS 128
cachepic_t cachepics[MAX_CACHED_PICS]; static cachepic_t cachepics[MAX_CACHED_PICS];
int numcachepics; static int numcachepics;
byte menuplyr_pixels[4096]; static byte menuplyr_pixels[4096];
int pic_texels;
int pic_count;
qpic_t *Draw_PicFromWad (char *name) qpic_t *Draw_PicFromWad (char *name)
{ {
@ -231,15 +227,14 @@ qpic_t *Draw_PicFromWad (char *name)
p = W_GetLumpName (name); p = W_GetLumpName (name);
gl = (glpic_t *)p->data; gl = (glpic_t *)p->data;
#ifdef gl_draw_scraps
// load little ones into the scrap // load little ones into the scrap
if (p->width < 64 && p->height < 64) if (p->width < 64 && p->height < 64) {
{
int x, y; int x, y;
int i, j, k; int i, j, k;
int texnum; int texnum;
texnum = Scrap_AllocBlock (p->width, p->height, &x, &y); texnum = Scrap_AllocBlock (p->width, p->height, &x, &y);
scrap_dirty = true;
k = 0; k = 0;
for (i=0 ; i<p->height ; i++) for (i=0 ; i<p->height ; i++)
for (j=0 ; j<p->width ; j++, k++) for (j=0 ; j<p->width ; j++, k++)
@ -250,11 +245,9 @@ qpic_t *Draw_PicFromWad (char *name)
gl->sh = (x+p->width-0.01)/(float)BLOCK_WIDTH; gl->sh = (x+p->width-0.01)/(float)BLOCK_WIDTH;
gl->tl = (y+0.01)/(float)BLOCK_WIDTH; gl->tl = (y+0.01)/(float)BLOCK_WIDTH;
gl->th = (y+p->height-0.01)/(float)BLOCK_WIDTH; gl->th = (y+p->height-0.01)/(float)BLOCK_WIDTH;
pic_count++;
pic_texels += p->width*p->height;
} }
else else
#endif
{ {
gl->texnum = GL_LoadPicTexture (p); gl->texnum = GL_LoadPicTexture (p);
gl->sl = 0; gl->sl = 0;
@ -262,6 +255,7 @@ qpic_t *Draw_PicFromWad (char *name)
gl->tl = 0; gl->tl = 0;
gl->th = 1; gl->th = 1;
} }
return p; return p;
} }
@ -287,45 +281,53 @@ qpic_t *Draw_CachePic (char *path)
qpic_t *dat; qpic_t *dat;
glpic_t *gl; glpic_t *gl;
// First, check and see if its cached..
for (pic=cachepics, i=0 ; i<numcachepics ; pic++, i++) for (pic=cachepics, i=0 ; i<numcachepics ; pic++, i++)
if (!strcmp (path, pic->name)) if ((!strcmp (path, pic->name)) && !pic->dirty)
break;
if (i == numcachepics)
{
if (numcachepics == MAX_CACHED_PICS)
Sys_Error ("menu_numcachepics == MAX_CACHED_PICS");
numcachepics++;
strcpy (pic->name, path);
}
else if (!pic->dirty)
return &pic->pic; return &pic->pic;
// // Its not cached, lets make sure we have space in the cache..
// load the pic from disk if (numcachepics == MAX_CACHED_PICS)
// Sys_Error ("menu_numcachepics == MAX_CACHED_PICS");
// Load the picture..
dat = (qpic_t *)COM_LoadTempFile (path); dat = (qpic_t *)COM_LoadTempFile (path);
if (!dat) if (!dat)
Sys_Error ("Draw_CachePic: failed to load %s", path); Sys_Error ("Draw_CachePic: failed to load %s", path);
// Adjust for endian..
SwapPic (dat); SwapPic (dat);
// HACK HACK HACK --- we need to keep the bytes for // Ok, the image is here, lets load it up into the cache..
// the translatable player picture just for the menu
// configuration dialog // First the image name..
strncpy (pic->name, path, sizeof(pic->name));
// Now the width and height.
pic->pic.width = dat->width;
pic->pic.height = dat->height;
// Now feed it to the GL stuff and get a texture number..
gl = (glpic_t *)pic->pic.data;
gl->texnum = GL_LoadPicTexture (dat);
// Alignment stuff..
gl->sl = 0; gl->sh = 1; gl->tl = 0; gl->th = 1;
// Now lets mark this cache entry as used..
pic->dirty = false;
numcachepics++;
// FIXME:
// A really ugly kluge, keep a specific image in memory
// for the menu system.
//
// Some days I really dislike legacy support..
if (!strcmp (path, "gfx/menuplyr.lmp")) if (!strcmp (path, "gfx/menuplyr.lmp"))
memcpy (menuplyr_pixels, dat->data, dat->width*dat->height); memcpy (menuplyr_pixels, dat->data, dat->width*dat->height);
pic->pic.width = dat->width; // And now we are done, return what was asked for..
pic->pic.height = dat->height;
pic->dirty = false;
gl = (glpic_t *)pic->pic.data;
gl->texnum = GL_LoadPicTexture (dat);
gl->sl = 0;
gl->sh = 1;
gl->tl = 0;
gl->th = 1;
return &pic->pic; return &pic->pic;
} }
@ -336,7 +338,7 @@ typedef struct
int minimize, maximize; int minimize, maximize;
} glmode_t; } glmode_t;
glmode_t modes[] = { static glmode_t modes[] = {
{"GL_NEAREST", GL_NEAREST, GL_NEAREST}, {"GL_NEAREST", GL_NEAREST, GL_NEAREST},
{"GL_LINEAR", GL_LINEAR, GL_LINEAR}, {"GL_LINEAR", GL_LINEAR, GL_LINEAR},
{"GL_NEAREST_MIPMAP_NEAREST", GL_NEAREST_MIPMAP_NEAREST, GL_NEAREST}, {"GL_NEAREST_MIPMAP_NEAREST", GL_NEAREST_MIPMAP_NEAREST, GL_NEAREST},
@ -350,7 +352,7 @@ glmode_t modes[] = {
Draw_TextureMode_f Draw_TextureMode_f
=============== ===============
*/ */
void Draw_TextureMode_f (void) static void Draw_TextureMode_f (void)
{ {
int i; int i;
gltexture_t *glt; gltexture_t *glt;
@ -461,9 +463,11 @@ void Draw_Init (void)
// save a texture slot for translated picture // save a texture slot for translated picture
translate_texture = texture_extension_number++; translate_texture = texture_extension_number++;
#ifdef gl_draw_scraps
// save slots for scraps // save slots for scraps
scrap_texnum = texture_extension_number; scrap_texnum = texture_extension_number;
texture_extension_number += MAX_SCRAPS; texture_extension_number += MAX_SCRAPS;
#endif
// //
// get the other pics we need // get the other pics we need
@ -589,20 +593,6 @@ void Draw_Crosshair(void)
scr_vrect.y + scr_vrect.height/2-4 + cl_crossy->value, '+'); scr_vrect.y + scr_vrect.height/2-4 + cl_crossy->value, '+');
} }
/*
================
Draw_DebugChar
Draws a single character directly to the upper right corner of the screen.
This is for debugging lockups by drawing different chars in different parts
of the code.
================
*/
void Draw_DebugChar (char num)
{
}
/* /*
============= =============
Draw_Pic Draw_Pic
@ -612,8 +602,10 @@ void Draw_Pic (int x, int y, qpic_t *pic)
{ {
glpic_t *gl; glpic_t *gl;
#ifdef gl_draw_scraps
if (scrap_dirty) if (scrap_dirty)
Scrap_Upload (); Scrap_Upload ();
#endif
gl = (glpic_t *)pic->data; gl = (glpic_t *)pic->data;
if (lighthalf) if (lighthalf)
glColor3f(0.4,0.4,0.4); glColor3f(0.4,0.4,0.4);
@ -632,47 +624,16 @@ void Draw_Pic (int x, int y, qpic_t *pic)
glEnd (); glEnd ();
} }
/*
=============
Draw_AlphaPic
=============
*/
void Draw_AlphaPic (int x, int y, qpic_t *pic, float alpha)
{
glpic_t *gl;
if (scrap_dirty)
Scrap_Upload ();
gl = (glpic_t *)pic->data;
if (lighthalf)
glColor4f(0.4,0.4,0.4,alpha);
else
glColor4f(0.8,0.8,0.8,alpha);
glBindTexture (GL_TEXTURE_2D, gl->texnum);
glBegin (GL_QUADS);
glTexCoord2f (gl->sl, gl->tl);
glVertex2f (x, y);
glTexCoord2f (gl->sh, gl->tl);
glVertex2f (x+pic->width, y);
glTexCoord2f (gl->sh, gl->th);
glVertex2f (x+pic->width, y+pic->height);
glTexCoord2f (gl->sl, gl->th);
glVertex2f (x, y+pic->height);
glEnd ();
if (lighthalf)
glColor3f(0.5,0.5,0.5);
else
glColor3f(1,1,1);
}
void Draw_SubPic(int x, int y, qpic_t *pic, int srcx, int srcy, int width, int height) void Draw_SubPic(int x, int y, qpic_t *pic, int srcx, int srcy, int width, int height)
{ {
glpic_t *gl; glpic_t *gl;
float newsl, newtl, newsh, newth; float newsl, newtl, newsh, newth;
float oldglwidth, oldglheight; float oldglwidth, oldglheight;
#ifdef gl_draw_scraps
if (scrap_dirty) if (scrap_dirty)
Scrap_Upload (); Scrap_Upload ();
#endif
gl = (glpic_t *)pic->data; gl = (glpic_t *)pic->data;
oldglwidth = gl->sh - gl->sl; oldglwidth = gl->sh - gl->sl;
@ -1013,31 +974,12 @@ void GL_Set2D (void)
//==================================================================== //====================================================================
/*
================
GL_FindTexture
================
*/
int GL_FindTexture (char *identifier)
{
int i;
gltexture_t *glt;
for (i=0, glt=gltextures ; i<numgltextures ; i++, glt++)
{
if (!strcmp (identifier, glt->identifier))
return gltextures[i].texnum;
}
return -1;
}
/* /*
================ ================
GL_ResampleTexture GL_ResampleTexture
================ ================
*/ */
void GL_ResampleTexture (unsigned *in, int inwidth, int inheight, unsigned *out, int outwidth, int outheight) static void GL_ResampleTexture (unsigned *in, int inwidth, int inheight, unsigned *out, int outwidth, int outheight)
{ {
int i, j; int i, j;
unsigned *inrow; unsigned *inrow;
@ -1067,7 +1009,7 @@ void GL_ResampleTexture (unsigned *in, int inwidth, int inheight, unsigned *out,
GL_Resample8BitTexture -- JACK GL_Resample8BitTexture -- JACK
================ ================
*/ */
void GL_Resample8BitTexture (unsigned char *in, int inwidth, int inheight, unsigned char *out, int outwidth, int outheight) static void GL_Resample8BitTexture (unsigned char *in, int inwidth, int inheight, unsigned char *out, int outwidth, int outheight)
{ {
int i, j; int i, j;
unsigned char *inrow; unsigned char *inrow;
@ -1099,7 +1041,7 @@ GL_MipMap
Operates in place, quartering the size of the texture Operates in place, quartering the size of the texture
================ ================
*/ */
void GL_MipMap (byte *in, int width, int height) static void GL_MipMap (byte *in, int width, int height)
{ {
int i, j; int i, j;
byte *out; byte *out;
@ -1126,7 +1068,7 @@ GL_MipMap8Bit
Mipping for 8 bit textures Mipping for 8 bit textures
================ ================
*/ */
void GL_MipMap8Bit (byte *in, int width, int height) static void GL_MipMap8Bit (byte *in, int width, int height)
{ {
int i, j; int i, j;
byte *out; byte *out;
@ -1156,7 +1098,7 @@ void GL_MipMap8Bit (byte *in, int width, int height)
GL_Upload32 GL_Upload32
=============== ===============
*/ */
void GL_Upload32 (unsigned *data, int width, int height, qboolean mipmap, qboolean alpha) static void GL_Upload32 (unsigned *data, int width, int height, qboolean mipmap, qboolean alpha)
{ {
int samples; int samples;
static unsigned scaled[1024*512]; // [512*256]; static unsigned scaled[1024*512]; // [512*256];
@ -1190,7 +1132,6 @@ static unsigned scaled[1024*512]; // [512*256];
glTexImage2D (GL_TEXTURE_2D, 0, samples, scaled_width, scaled_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, scaled); glTexImage2D (GL_TEXTURE_2D, 0, samples, scaled_width, scaled_height, 0, GL_RGBA, GL_UNSIGNED_BYTE, scaled);
} }
#else #else
texels += scaled_width * scaled_height;
if (scaled_width == width && scaled_height == height) if (scaled_width == width && scaled_height == height)
{ {
@ -1278,8 +1219,6 @@ void GL_Upload8_EXT (byte *data, int width, int height, qboolean mipmap, qboole
samples = 1; // alpha ? gl_alpha_format : gl_solid_format; samples = 1; // alpha ? gl_alpha_format : gl_solid_format;
texels += scaled_width * scaled_height;
if (scaled_width == width && scaled_height == height) if (scaled_width == width && scaled_height == height)
{ {
if (!mipmap) if (!mipmap)
@ -1384,7 +1323,12 @@ static unsigned trans[640*480]; // FIXME, temporary
} }
} }
if (VID_Is8bit() && !alpha && (data!=scrap_texels[0])) { #ifdef gl_draw_scraps
if (VID_Is8bit() && !alpha && (data!=scrap_texels[0]))
#else
if (VID_Is8bit() && !alpha)
#endif
{
GL_Upload8_EXT (data, width, height, mipmap, alpha); GL_Upload8_EXT (data, width, height, mipmap, alpha);
return; return;
} }
@ -1399,9 +1343,7 @@ GL_LoadTexture
*/ */
int GL_LoadTexture (char *identifier, int width, int height, byte *data, qboolean mipmap, qboolean alpha, int bytesperpixel) int GL_LoadTexture (char *identifier, int width, int height, byte *data, qboolean mipmap, qboolean alpha, int bytesperpixel)
{ {
int i; int i, s, lcrc;
int s;
int lcrc;
gltexture_t *glt; gltexture_t *glt;
// LordHavoc's cache check, not a standard crc but it works --KB // LordHavoc's cache check, not a standard crc but it works --KB
@ -1430,10 +1372,15 @@ int GL_LoadTexture (char *identifier, int width, int height, byte *data, qboolea
} }
} }
if (numgltextures == MAX_GLTEXTURES)
Sys_Error ("numgltextures == MAX_GLTEXTURES");
glt = &gltextures[numgltextures]; glt = &gltextures[numgltextures];
numgltextures++; numgltextures++;
strcpy (glt->identifier, identifier); strncpy (glt->identifier, identifier, sizeof(glt->identifier) - 1);
glt->identifier[sizeof(glt->identifier) - 1] = '\0';
glt->texnum = texture_extension_number; glt->texnum = texture_extension_number;
texture_extension_number++; texture_extension_number++;
@ -1468,7 +1415,7 @@ SetupTexture:
GL_LoadPicTexture GL_LoadPicTexture
================ ================
*/ */
int GL_LoadPicTexture (qpic_t *pic) static int GL_LoadPicTexture (qpic_t *pic)
{ {
return GL_LoadTexture ("", pic->width, pic->height, pic->data, false, true, 1); return GL_LoadTexture ("", pic->width, pic->height, pic->data, false, true, 1);
} }

View file

@ -392,7 +392,7 @@ Bad sides: affects gamespy and spytools somewhat...
================ ================
*/ */
int CheckForFlood(char cmdtype) int CheckForFlood(flood_enum_t cmdtype)
{ {
static qboolean firsttime = true; static qboolean firsttime = true;
static flood_t floodstatus[DOSFLOODCMDS][DOSFLOODIP]; static flood_t floodstatus[DOSFLOODCMDS][DOSFLOODIP];
@ -403,7 +403,8 @@ int CheckForFlood(char cmdtype)
static double lastmessagetime=0; static double lastmessagetime=0;
int oldest; int oldest;
if (!sv_netdosprotect->value) return 0; if (!sv_netdosprotect->value)
return 0;
oldestTime = 0x7fffffff; oldestTime = 0x7fffffff;
oldest = 0; oldest = 0;
@ -415,35 +416,35 @@ int CheckForFlood(char cmdtype)
currenttime = Sys_DoubleTime(); currenttime = Sys_DoubleTime();
for (i = 0 ; i < DOSFLOODIP ; i++) for (i = 0 ; i < DOSFLOODIP ; i++) {
{
if (NET_CompareBaseAdr (net_from, floodstatus[cmdtype][i].adr)) if (NET_CompareBaseAdr (net_from, floodstatus[cmdtype][i].adr))
break; break;
if (floodstatus[cmdtype][i].issued < oldestTime) if (floodstatus[cmdtype][i].issued < oldestTime) {
{
oldestTime = floodstatus[cmdtype][i].issued; oldestTime = floodstatus[cmdtype][i].issued;
oldest = i; oldest = i;
} }
} }
if (i<DOSFLOODIP && floodstatus[cmdtype][i].issued) if (i < DOSFLOODIP && floodstatus[cmdtype][i].issued) {
if(floodstatus[cmdtype][i].issued+netdosexpire[cmdtype]>currenttime) if ((floodstatus[cmdtype][i].issued + netdosexpire[cmdtype])
{ > currenttime) {
floodstatus[cmdtype][i].floodcount += 1; floodstatus[cmdtype][i].floodcount += 1;
if (floodstatus[cmdtype][i].floodcount>netdosvalues[cmdtype]) if (floodstatus[cmdtype][i].floodcount > netdosvalues[cmdtype]) {
{ if ((lastmessagetime + 5) < currenttime)
if (lastmessagetime+5<currenttime) Con_Printf("Blocking type %d flood from (or to) %s\n",
Con_Printf("Blocking type %d flood from (or to) %s\n",cmdtype,NET_AdrToString(net_from)); cmdtype, NET_AdrToString(net_from));
floodstatus[cmdtype][i].floodcount = 0; floodstatus[cmdtype][i].floodcount = 0;
floodstatus[cmdtype][i].issued = currenttime; floodstatus[cmdtype][i].issued = currenttime;
floodstatus[cmdtype][i].cmdcount += 1; floodstatus[cmdtype][i].cmdcount += 1;
lastmessagetime = currenttime; lastmessagetime = currenttime;
return 1; return 1;
} }
} else floodstatus[cmdtype][i].floodcount=0; } else {
floodstatus[cmdtype][i].floodcount = 0;
}
}
if (i == DOSFLOODIP) if (i == DOSFLOODIP) {
{
i = oldest; i = oldest;
floodstatus[cmdtype][i].adr = net_from; floodstatus[cmdtype][i].adr = net_from;
floodstatus[cmdtype][i].firstseen = currenttime; floodstatus[cmdtype][i].firstseen = currenttime;