From b720455bb84de5074d8aec35847497d735f0f258 Mon Sep 17 00:00:00 2001 From: TimeServ Date: Sun, 28 May 2006 21:56:04 +0000 Subject: [PATCH] fix without Q2CLIENT/NQPROT build, software renderer with plugins fix, misc fixes git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@2298 fc73d0e0-1445-4013-8a0c-d673dee63da5 --- engine/client/cl_input.c | 5 +++++ engine/client/cl_parse.c | 4 +++- engine/client/cl_plugin.inc | 10 +++------ engine/client/cl_tent.c | 42 +++++++++++++++++++++++++++++++------ engine/client/snd_dma.c | 29 +++++++------------------ engine/common/pmove.c | 13 ++++-------- engine/common/pmove.h | 32 ++++++++++++++-------------- engine/sw/sw_draw.c | 11 +++++----- 8 files changed, 80 insertions(+), 66 deletions(-) diff --git a/engine/client/cl_input.c b/engine/client/cl_input.c index 9d8eab85a..02ae49d95 100644 --- a/engine/client/cl_input.c +++ b/engine/client/cl_input.c @@ -813,6 +813,11 @@ void CLNQ_SendCmd(void) memset(&independantphysics[0], 0, sizeof(independantphysics[0])); cl.allowsendpacket = false; +} +#else +void Name_Callback(struct cvar_s *var, char *oldvalue) +{ + } #endif diff --git a/engine/client/cl_parse.c b/engine/client/cl_parse.c index 832b3e203..279ce3396 100644 --- a/engine/client/cl_parse.c +++ b/engine/client/cl_parse.c @@ -2162,6 +2162,8 @@ void CL_ParseModellist (qboolean lots) } void CL_ProcessUserInfo (int slot, player_info_t *player); + +#ifdef Q2CLIENT void CLQ2_ParseClientinfo(int i, char *s) { char *model, *name; @@ -2314,7 +2316,7 @@ void CLQ2_ParseConfigString (void) UI_StringChanged(i); #endif } - +#endif /* diff --git a/engine/client/cl_plugin.inc b/engine/client/cl_plugin.inc index 4ee15fb96..81338b859 100644 --- a/engine/client/cl_plugin.inc +++ b/engine/client/cl_plugin.inc @@ -128,11 +128,9 @@ int VARGS Plug_Draw_LoadImage(void *offset, unsigned int mask, const long *arg) pic = Draw_SafePicFromWad(name); else { -#ifdef RGLQUAKE //GL saves images persistantly (so don't bother with cachepic stuff) - if (qrenderer == QR_OPENGL && Draw_SafeCachePic) + if (Draw_SafeCachePic) pic = Draw_SafeCachePic(name); else -#endif pic = NULL; } } @@ -157,12 +155,10 @@ void Plug_DrawReloadImages(void) continue; } - if (pluginimagearray[i].picfromwad) + if (Draw_SafePicFromWad) pluginimagearray[i].pic = Draw_SafePicFromWad(pluginimagearray[i].name); -#ifdef RGLQUAKE - else if (qrenderer == QR_OPENGL) + else if (Draw_SafeCachePic) pluginimagearray[i].pic = Draw_SafeCachePic(pluginimagearray[i].name); -#endif else pluginimagearray[i].pic = NULL; } diff --git a/engine/client/cl_tent.c b/engine/client/cl_tent.c index eaf3a6843..90b7b7824 100644 --- a/engine/client/cl_tent.c +++ b/engine/client/cl_tent.c @@ -165,6 +165,9 @@ typedef struct explosion_t cl_explosions[MAX_EXPLOSIONS]; +static int explosions_running; +static int beams_running; + sfx_t *cl_sfx_wizhit; sfx_t *cl_sfx_knighthit; sfx_t *cl_sfx_tink1; @@ -277,13 +280,24 @@ explosion_t *CL_AllocExplosion (void) float time; int index; - for (i=0 ; ientity == entity && b->tag == tag) { return b; @@ -320,13 +334,20 @@ beam_t *CL_NewBeam (int entity, int tag) } // find a free beam - for (i=0, b=cl_beams ; i< MAX_BEAMS ; i++, b++) + for (i=0, b=cl_beams; i < beams_running; i++, b++) { if (!b->model) { return b; } } + + if (i == beams_running && i != MAX_BEAMS) + { + beams_running++; + return &cl_beams[i]; + } + return NULL; } #define STREAM_ATTACHED 16 @@ -393,7 +414,7 @@ void CL_AddBeam (int tent, int ent, vec3_t start, vec3_t end) //fixme: use TE_ n // save end position for truelightning if (ent) { - for (i = 0; i < MAX_SPLITS; i++) + for (i = 0; i < cl.splitclients; i++) { if (ent == (autocam[i]?spec_track[i]:(cl.playernum[i]+1))) { @@ -2424,11 +2445,12 @@ void CL_UpdateBeams (void) entity_state_t *st; float yaw, pitch; float forward, offset; + int lastrunningbeam = -1; extern cvar_t cl_truelightning, v_viewheight; // update lightning - for (i=0, b=cl_beams ; i< MAX_BEAMS ; i++, b++) + for (i=0, b=cl_beams; i < beams_running; i++, b++) { if (!b->model) continue; @@ -2441,6 +2463,8 @@ void CL_UpdateBeams (void) continue; } + lastrunningbeam = i; + // if coming from the player, update the start position if ((b->flags & 1) && b->entity > 0 && b->entity <= MAX_CLIENTS) { @@ -2600,6 +2624,7 @@ void CL_UpdateBeams (void) } } + beams_running = lastrunningbeam+1; } /* @@ -2616,11 +2641,14 @@ void CL_UpdateExplosions (void) int firstframe; explosion_t *ex; entity_t *ent; + int lastrunningexplosion = -1; - for (i=0, ex=cl_explosions ; i< MAX_EXPLOSIONS ; i++, ex++) + for (i=0, ex=cl_explosions; i < explosions_running; i++, ex++) { if (!ex->model) continue; + + lastrunningexplosion = i; f = ex->framerate*(cl.time - ex->start); if (ex->firstframe >= 0) { @@ -2659,6 +2687,8 @@ void CL_UpdateExplosions (void) ent->shaderRGBAf[3] = 1.0 - f/(numframes); ent->flags = ex->flags; } + + explosions_running = lastrunningexplosion + 1; } entity_state_t *CL_FindPacketEntity(int num); diff --git a/engine/client/snd_dma.c b/engine/client/snd_dma.c index aea4767da..7f6d8bb05 100644 --- a/engine/client/snd_dma.c +++ b/engine/client/snd_dma.c @@ -956,7 +956,7 @@ qboolean S_IsPlayingSomewhere(sfx_t *s) int i; for (si = sndcardinfo; si; si=si->next) { - for (i = 0; i < MAX_CHANNELS; i++) + for (i = 0; i < si->total_chans; i++) if (si->channel[i].sfx == s) return true; } @@ -999,9 +999,7 @@ void S_StopAllSounds(qboolean clear) return; - sc->total_chans = MAX_DYNAMIC_CHANNELS + NUM_AMBIENTS + NUM_MUSICS; // no statics - - for (i=0 ; itotal_chans ; i++) if (sc->channel[i].sfx) { s = sc->channel[i].sfx; @@ -1013,6 +1011,8 @@ void S_StopAllSounds(qboolean clear) } } + sc->total_chans = MAX_DYNAMIC_CHANNELS + NUM_AMBIENTS + NUM_MUSICS; // no statics + Q_memset(sc->channel, 0, MAX_CHANNELS * sizeof(channel_t)); if (clear) @@ -1627,7 +1627,7 @@ void S_RawAudio(int sourceid, qbyte *data, int speed, int samples, int channels, prepadl = 0x7fffffff; for (si = sndcardinfo; si; si=si->next) //make sure all cards are playing, and that we still get a prepad if just one is. { - for (i = 0; i < MAX_CHANNELS; i++) + for (i = 0; i < si->total_chans; i++) if (si->channel[i].sfx == &s->sfx) { if (prepadl > si->channel[i].pos) @@ -1661,21 +1661,6 @@ void S_RawAudio(int sourceid, qbyte *data, int speed, int samples, int channels, } } -/* else if (spare > snd_speed) - { - for (si = sndcardinfo; si; si=si->next) - { - for (i = 0; i < MAX_CHANNELS; i++) - if (si->channel[i].sfx == &s->sfx) - { - break; - } - if (i == MAX_CHANNELS) //this one wasn't playing. - S_StartSoundCard(si, -1, 0, &s->sfx, r_origin, 1, 32767, prepadl); - } - return; //let the slower sound cards catch up. (This shouldn't really happen, but it's possible two cards have slightly different timings but report the same speed) - }*/ - newcache = BZ_Malloc(sizeof(sfxcache_t) + (spare+outsamples) * (s->sfxcache->numchannels) * s->sfxcache->width); memcpy(newcache, s->sfxcache, sizeof(sfxcache_t)); memcpy(newcache->data, s->sfxcache->data + prepadl * (s->sfxcache->numchannels) * s->sfxcache->width, spare * (s->sfxcache->numchannels) * s->sfxcache->width); @@ -1785,7 +1770,7 @@ void S_RawAudio(int sourceid, qbyte *data, int speed, int samples, int channels, for (si = sndcardinfo; si; si=si->next) { - for (i = 0; i < MAX_CHANNELS; i++) + for (i = 0; i < si->total_chans; i++) if (si->channel[i].sfx == &s->sfx) { si->channel[i].pos -= prepadl; @@ -1799,7 +1784,7 @@ void S_RawAudio(int sourceid, qbyte *data, int speed, int samples, int channels, } break; } - if (i == MAX_CHANNELS) //this one wasn't playing. + if (i == si->total_chans) //this one wasn't playing. { S_StartSoundCard(si, -1, 0, &s->sfx, r_origin, 1, 32767, 500); // Con_Printf("Restarted\n"); diff --git a/engine/common/pmove.c b/engine/common/pmove.c index 6a01521a8..b525c5d60 100644 --- a/engine/common/pmove.c +++ b/engine/common/pmove.c @@ -53,14 +53,12 @@ void PM_Init (void) */ static void PM_AddTouchedEnt (int num) { - int i; - - if (pmove.numtouch == sizeof(pmove.touchindex)/sizeof(pmove.touchindex[0])) + if (pmove.numtouch == MAX_PHYSENTS) return; - for (i = 0; i < pmove.numtouch; i++) - if (pmove.touchindex[i] == num) - return; // already added + if (pmove.numtouch) + if (pmove.touchindex[pmove.numtouch - 1] == num) + return; // already added pmove.touchindex[pmove.numtouch] = num; pmove.numtouch++; @@ -271,9 +269,6 @@ int PM_StepSlideMove (qboolean in_air) if (!(blocked & BLOCKED_STEP)) return blocked; - //FIXME: "pmove.velocity < 0" ???? :) - // Of course I meant pmove.velocity[2], but I'm afraid I don't understand - // the code's purpose any more, so let it stay just this way for now :) -- Tonik org = (pmove.velocity < 0) ? pmove.origin : original; // cryptic, eh? VectorCopy (org, dest); dest[2] -= pm_stepheight; diff --git a/engine/common/pmove.h b/engine/common/pmove.h index ded6c1704..a3e92c339 100644 --- a/engine/common/pmove.h +++ b/engine/common/pmove.h @@ -77,22 +77,22 @@ typedef struct } playermove_t; typedef struct { - float gravity; - float stopspeed; - float maxspeed; - float spectatormaxspeed; - float accelerate; - float airaccelerate; - float wateraccelerate; - float friction; - float waterfriction; - float entgravity; - float bunnyspeedcap; - float ktjump; - qboolean slidefix; - qboolean airstep; - qboolean walljump; - qboolean slidyslopes; + float gravity; + float stopspeed; + float maxspeed; + float spectatormaxspeed; + float accelerate; + float airaccelerate; + float wateraccelerate; + float friction; + float waterfriction; + float entgravity; + float bunnyspeedcap; + float ktjump; + int walljump; + qboolean slidefix; + qboolean airstep; + qboolean slidyslopes; } movevars_t; diff --git a/engine/sw/sw_draw.c b/engine/sw/sw_draw.c index 82f071811..4cd769e1a 100644 --- a/engine/sw/sw_draw.c +++ b/engine/sw/sw_draw.c @@ -473,19 +473,20 @@ void SWDraw_Init (void) // add conchars into sw menu cache swmenu_numcachepics = 0; - strcpy(swmenu_cachepics[swmenu_numcachepics].name, "conchars"); + // lame hack but whatever works + strcpy(swmenu_cachepics[swmenu_numcachepics].name, "pics/conchars.pcx"); swmenu_cachepics[swmenu_numcachepics].cache.fake = true; - swmenu_cachepics[swmenu_numcachepics].cache.data = BZ_Malloc(sizeof(qpic_t) + 128*128); + swmenu_cachepics[swmenu_numcachepics].cache.data = BZ_Malloc(sizeof(mpic_t) + 128*128); { - qpic_t *dat = (qpic_t *)swmenu_cachepics[swmenu_numcachepics].cache.data; + mpic_t *dat = (mpic_t *)swmenu_cachepics[swmenu_numcachepics].cache.data; // reformat conchars for use in cache int j; for (j = 0; j < 128*128; j++) dat->data[j] = (draw_chars[j] == 255 || !draw_chars[j]) ? draw_chars[j] ^ 255 : draw_chars[j]; - ((mpic_t*)dat)->width = ((mpic_t*)dat)->height = 128; - ((mpic_t*)dat)->flags = 1; + dat->width = dat->height = 128; + dat->flags = 1; } swmenu_numcachepics++;