diff --git a/src/console.c b/src/console.c index 6f9579bef..d3c2623f4 100644 --- a/src/console.c +++ b/src/console.c @@ -33,6 +33,8 @@ #include "d_main.h" #include "m_menu.h" #include "m_textinput.h" +#include "m_emotes.h" +#include "i_time.h" #include "filesrch.h" #ifdef HWRENDER @@ -1453,7 +1455,18 @@ static void CON_DrawHudlines(void) } if (c >= con_width) break; - if (*p < HU_FONTSTART) + + int emotelen; + emote_t *emote; + + if ((emote = M_VerifyEmote((const char *)p, &emotelen))) + { + M_DrawScaledEmote(x<= con_width) break; + + int emotelen; + emote_t *emote; + + if ((emote = M_VerifyEmote((const char *)p, &emotelen))) + { + M_DrawScaledEmote(x< HWRAPI() (); -// If _CREATE_DLL_ is defined the above declaration translates to : -// __declspec(dllexport) WINAPI (); -// If _CREATE_DLL_ is NOT DEFINED the above declaration translates to : -// __declspec(dllexport) type> (WINAPI *) (); - -#ifdef _CREATE_DLL_ - #ifdef __cplusplus - #define EXPORT extern "C" - #else - #define EXPORT - #endif - #ifdef _WIN32 - #define HWRAPI(fn) WINAPI fn - #else - #define HWRAPI(fn) fn - #endif -#else // _CREATE_DLL_ - #define EXPORT typedef - #ifdef _WIN32 - #define HWRAPI(fn) (WINAPI *fn) - #else - #define HWRAPI(fn) (*fn) - #endif -#endif - -// ========================================================================== -// MATHS -// ========================================================================== - -// Constants -#define DEGREE (0.017453292519943295769236907684883l) // 2*PI/360 - -void GL_DBG_Printf(const char *format, ...) /*FUNCPRINTF*/; -#define DBG_Printf GL_DBG_Printf - -#if defined (__CYGWIN__) -void _init() __attribute__((constructor)); -void _fini() __attribute__((destructor)); -#else -void _init(); -void _fini(); -#endif - -#endif diff --git a/src/hardware/hw_main.cpp b/src/hardware/hw_main.cpp index 4f6620880..5ef8d72f4 100644 --- a/src/hardware/hw_main.cpp +++ b/src/hardware/hw_main.cpp @@ -84,6 +84,13 @@ float gl_viewsin = 0.0f, gl_viewcos = 0.0f; static float gl_viewludsin, gl_viewludcos; static angle_t gl_aimingangle; +static float yaw = 0.0f; +static float inv_yaw = 0.0f; +static float cos_inv_yaw = 0.0f; +static float sin_inv_yaw = 0.0f; + +static constexpr float deg2radians = (M_PIf / 180.0f); + seg_t *gl_curline = NULL; side_t *gl_sidedef = NULL; line_t *gl_linedef = NULL; @@ -2348,12 +2355,22 @@ static inline void DoAddLine(seg_t* line, angle_t angle1, angle_t angle2) static sector_t tempsec; auto do_addline = [&](bool dontdraw) { + // Single sided line? if (!line->backsector) { gld_clipper_SafeAddClipRange(angle2, angle1); } else { + if (line->frontsector == line->backsector) + { + if (R_GetTextureNum(line->sidedef->midtexture) == 0) + { + //e6y: nothing to do here! + return; + } + } + gl_backsector = R_FakeFlat(gl_backsector, &tempsec, NULL, NULL, true); if (CheckClip(gl_frontsector, gl_backsector)) @@ -2520,7 +2537,7 @@ static boolean HWR_CheckBBox(const fixed_t *bspcoord) // one if statement will split the space in two for one coordinate // for example: // x < BOXLEFT || BOXLEFT || !(x < BOXLEFT) <-- (same as x >= BOXLEFT) - fixed_t mindist;// = min(min(mindist1, mindist2), min(mindist3, mindist4)); + fixed_t mindist = 0;// = min(min(mindist1, mindist2), min(mindist3, mindist4)); // new thing // calculate distance to axis aligned bounding box. @@ -2965,7 +2982,7 @@ static void HWR_Subsector(size_t num) if (anyMoved == true) { gl_frontsector->numlights = sub->sector->numlights = 0; - R_Prep3DFloors(gl_frontsector); + R_Prep3DFloors(gl_frontsector, locCeilingHeight); sub->sector->lightlist = gl_frontsector->lightlist; sub->sector->numlights = gl_frontsector->numlights; sub->sector->moved = gl_frontsector->moved = false; @@ -3013,7 +3030,7 @@ static void HWR_Subsector(size_t num) // Hack to make things continue to work around slopes. locCeilingHeight == cullCeilingHeight ? locCeilingHeight : gl_frontsector->ceilingheight, // We now return you to your regularly scheduled rendering. - PF_Occlude, ceilinglightlevel, levelflats[gl_frontsector->ceilingpic].lumpnum,NULL, 255, ceilingcolormap); + PF_Occlude, ceilinglightlevel, levelflats[gl_frontsector->ceilingpic].lumpnum, NULL, 255, ceilingcolormap); } } } @@ -3045,8 +3062,8 @@ static void HWR_Subsector(size_t num) centerHeight = P_GetFFloorBottomZAt(rover, gl_frontsector->soundorg.x, gl_frontsector->soundorg.y); if (centerHeight <= locCeilingHeight && centerHeight >= locFloorHeight && - ((viewz < bottomCullHeight && !(rover->flags & FF_INVERTPLANES)) || - (viewz > bottomCullHeight && (rover->flags & FF_BOTHPLANES || rover->flags & FF_INVERTPLANES)))) + ((viewz < bottomCullHeight && !(rover->flags & FF_INVERTPLANES)) || + (viewz > bottomCullHeight && (rover->flags & FF_BOTHPLANES || rover->flags & FF_INVERTPLANES)))) { if (rover->flags & FF_FOG) { @@ -3090,9 +3107,9 @@ static void HWR_Subsector(size_t num) centerHeight = P_GetFFloorTopZAt(rover, gl_frontsector->soundorg.x, gl_frontsector->soundorg.y); if (centerHeight >= locFloorHeight && - centerHeight <= locCeilingHeight && - ((viewz > topCullHeight && !(rover->flags & FF_INVERTPLANES)) || - (viewz < topCullHeight && (rover->flags & FF_BOTHPLANES || rover->flags & FF_INVERTPLANES)))) + centerHeight <= locCeilingHeight && + ((viewz > topCullHeight && !(rover->flags & FF_INVERTPLANES)) || + (viewz < topCullHeight && (rover->flags & FF_BOTHPLANES || rover->flags & FF_INVERTPLANES)))) { if (rover->flags & FF_FOG) { @@ -3171,12 +3188,15 @@ doaddline: // hurdler: false: we only add the sprites, the walls are drawn first if (line) { - // draw sprites first, coz they are clipped to the solidsegs of - // subsectors more 'in front' - if (cv_drawdist.value || current_bsp_culling_distance) - HWR_AddSprites(gl_frontsector); - else - HWR_AddSprites(gl_frontsector); + if (sub->sector->validcount != validcount) + { + // draw sprites first, coz they are clipped to the solidsegs of + // subsectors more 'in front' + if (cv_drawdist.value || current_bsp_culling_distance) + HWR_AddSprites(gl_frontsector); + else + HWR_AddSprites(gl_frontsector); + } //Hurdler: at this point validcount must be the same, but is not because // gl_frontsector doesn't point anymore to sub->sector due to @@ -4633,6 +4653,7 @@ static void HWR_ProjectSprite(mobj_t *thing) float tr_x, tr_y; float tz; float x1, x2; + float y1, y2; float z1, z2; float rightsin, rightcos; float this_scale; @@ -4855,17 +4876,6 @@ static void HWR_ProjectSprite(mobj_t *thing) spr_offset += interp.spritexoffset; spr_topoffset += interp.spriteyoffset; - if (papersprite) - { - rightsin = FixedToFloat(FINESINE(interp.angle >> ANGLETOFINESHIFT)); - rightcos = FixedToFloat(FINECOSINE(interp.angle >> ANGLETOFINESHIFT)); - } - else - { - rightsin = FixedToFloat(FINESINE((viewangle + ANGLE_90)>>ANGLETOFINESHIFT)); - rightcos = FixedToFloat(FINECOSINE((viewangle + ANGLE_90)>>ANGLETOFINESHIFT)); - } - spritexscale *= this_scale; spriteyscale *= this_scale; @@ -4882,19 +4892,17 @@ static void HWR_ProjectSprite(mobj_t *thing) x2 = (FixedToFloat(spr_width - spr_offset) * spritexscale); } - z1 = tr_y + x1 * rightsin; - z2 = tr_y - x2 * rightsin; - x1 = tr_x + x1 * rightcos; - x2 = tr_x - x2 * rightcos; + y1 = (FixedToFloat(spr_topoffset) * spriteyscale); + y2 = (FixedToFloat(spr_height - spr_topoffset) * spriteyscale); if (vflip) { - gz = FixedToFloat(interp.z + thing->height) - (FixedToFloat(spr_topoffset) * spriteyscale); + gz = FixedToFloat(interp.z + thing->height) - y1; gzt = gz + (FixedToFloat(spr_height) * spriteyscale); } else { - gzt = FixedToFloat(interp.z) + (FixedToFloat(spr_topoffset) * spriteyscale); + gzt = FixedToFloat(interp.z) + y1; gz = gzt - (FixedToFloat(spr_height) * spriteyscale); } @@ -4904,6 +4912,32 @@ static void HWR_ProjectSprite(mobj_t *thing) return; } + // rest in piece sweet prince + /*if (cv_glshearing.value && !papersprite) + { + // killough 4/9/98: clip things which are out of view due to height + // e6y: fix of hanging decoration disappearing in Batman Doom MAP02 + // centeryfrac -> viewheightfrac + // [kb] add +1 so sprites are shown even with the extended freelook + // lug: attempt to account for freelook properly + const fixed_t fixedtz = FloatToFixed(tz); + if (interp.z > viewz + FixedMul(centeryfrac, fixedtz) || // view center accounted for aspect (i hope) + FloatToFixed(gzt) < viewz + FixedMul((centeryfrac - (viewheight << FRACBITS)), fixedtz)) // view center accounted for aspect but the bottom (OwO) + { + return; + } + }*/ + + if (!gld_SphereInFrustum( + (FixedToFloat(interp.x)) + cos_inv_yaw * (x1 + x2) / 2.0f, + FixedToFloat(interp.z) + (y1 + y2) / 2.0f, + FixedToFloat(interp.y) - sin_inv_yaw * (x1 + x2) / 2.0f, + //1.5 == sqrt(2) + small delta for MF_FOREGROUND + std::max(FixedToFloat(spr_width), FixedToFloat(spr_height)) / 2.0f * 1.5f)) + { + return; + } + heightsec = thing->subsector->sector->heightsec; if (viewplayer && viewplayer->mo && viewplayer->mo->subsector) phs = viewplayer->mo->subsector->sector->heightsec; @@ -4912,16 +4946,40 @@ static void HWR_ProjectSprite(mobj_t *thing) if (heightsec != -1 && phs != -1) // only clip things which are in special sectors { - if (gl_viewz < FixedToFloat(sectors[phs].floorheight) ? - FixedToFloat(interp.z) >= FixedToFloat(sectors[heightsec].floorheight) : - gzt < FixedToFloat(sectors[heightsec].floorheight)) + fixed_t secheight; + const fixed_t fgzt = FloatToFixed(gzt); + + secheight = P_GetSectorFloorZAt(§ors[heightsec], viewx, viewy); + if (viewz < P_GetSectorFloorZAt(§ors[phs], interp.x, interp.y) ? + interp.z >= secheight : + fgzt < secheight) return; - if (gl_viewz > FixedToFloat(sectors[phs].ceilingheight) ? - gzt < FixedToFloat(sectors[heightsec].ceilingheight) && gl_viewz >= FixedToFloat(sectors[heightsec].ceilingheight) : - FixedToFloat(interp.z) >= FixedToFloat(sectors[heightsec].ceilingheight)) + + secheight = P_GetSectorCeilingZAt(§ors[heightsec], viewx, viewy); + if (viewz > P_GetSectorCeilingZAt(§ors[phs], interp.x, interp.y) ? + fgzt < secheight && viewz >= secheight : + interp.z >= secheight) return; } + if (papersprite) + { + rightsin = FixedToFloat(FINESINE(interp.angle >> ANGLETOFINESHIFT)); + rightcos = FixedToFloat(FINECOSINE(interp.angle >> ANGLETOFINESHIFT)); + } + else + { + rightsin = FixedToFloat(FINESINE((viewangle + ANGLE_90)>>ANGLETOFINESHIFT)); + rightcos = FixedToFloat(FINECOSINE((viewangle + ANGLE_90)>>ANGLETOFINESHIFT)); + } + + z1 = tr_y + x1 * rightsin; + z2 = tr_y - x2 * rightsin; + x1 = tr_x + x1 * rightcos; + x2 = tr_x - x2 * rightcos; + //y1 = tr_y + y1 * rightcos; + //y2 = tr_y - y2 * rightcos; + // store information in a vissprite vis = HWR_NewVisSprite(); vis->x1 = x1; @@ -4997,12 +5055,16 @@ static void HWR_ProjectPrecipitationSprite(precipmobj_t *thing) float tr_x, tr_y; float tz; float x1, x2; + float y1, y2; float z1, z2; + float gz, gzt; float rightsin, rightcos; float this_scale; spritedef_t *sprdef; spriteframe_t *sprframe; size_t lumpoff; + fixed_t spr_width, spr_height; + fixed_t spr_offset, spr_topoffset; unsigned rot = 0; UINT8 flip; @@ -5063,22 +5125,46 @@ static void HWR_ProjectPrecipitationSprite(precipmobj_t *thing) lumpoff = sprframe->lumpid[0]; flip = sprframe->flip; // Will only be 0x00 or 0xFF - rightsin = FixedToFloat(FINESINE((viewangle + ANGLE_90)>>ANGLETOFINESHIFT)); - rightcos = FixedToFloat(FINECOSINE((viewangle + ANGLE_90)>>ANGLETOFINESHIFT)); + spr_width = spritecachedinfo[lumpoff].width; + spr_height = spritecachedinfo[lumpoff].height; + spr_offset = spritecachedinfo[lumpoff].offset; + spr_topoffset = spritecachedinfo[lumpoff].topoffset; if (flip) { - x1 = FixedToFloat(spritecachedinfo[lumpoff].width - spritecachedinfo[lumpoff].offset); - x2 = FixedToFloat(spritecachedinfo[lumpoff].offset); + x1 = FixedToFloat(spr_width - spr_offset); + x2 = FixedToFloat(spr_offset); } else { - x1 = FixedToFloat(spritecachedinfo[lumpoff].offset); - x2 = FixedToFloat(spritecachedinfo[lumpoff].width - spritecachedinfo[lumpoff].offset); + x1 = FixedToFloat(spr_offset); + x2 = FixedToFloat(spr_offset); } + y1 = (FixedToFloat(spr_topoffset)); + y2 = (FixedToFloat(spr_height - spr_topoffset)); + x1 *= this_scale; x2 *= this_scale; + y1 *= this_scale; + y2 *= this_scale; + + if (!gld_SphereInFrustum( + (FixedToFloat(interp.x)) + cos_inv_yaw * (x1 + x2) / 2.0f, + FixedToFloat(interp.z) + (y1 + y2) / 2.0f, + FixedToFloat(interp.y) - sin_inv_yaw * (x1 + x2) / 2.0f, + //1.5 == sqrt(2) + small delta for MF_FOREGROUND + std::max(FixedToFloat(spr_width), FixedToFloat(spr_height)) / 2.0f * 1.5f)) + { + return; + } + + // set top/bottom coords + gzt = FixedToFloat(interp.z) + y1; + gz = gzt - (FixedToFloat(spr_height) * this_scale); + + rightsin = FixedToFloat(FINESINE((viewangle + ANGLE_90)>>ANGLETOFINESHIFT)); + rightcos = FixedToFloat(FINECOSINE((viewangle + ANGLE_90)>>ANGLETOFINESHIFT)); z1 = tr_y + x1 * rightsin; z2 = tr_y - x2 * rightsin; @@ -5107,8 +5193,8 @@ static void HWR_ProjectPrecipitationSprite(precipmobj_t *thing) #endif // set top/bottom coords - vis->gzt = FixedToFloat(interp.z) + (FixedToFloat(spritecachedinfo[lumpoff].topoffset) * this_scale); - vis->gz = vis->gzt - (FixedToFloat(spritecachedinfo[lumpoff].height) * this_scale); + vis->gzt = gzt; + vis->gz = gz; vis->precip = thing; } @@ -5122,11 +5208,10 @@ static gl_sky_t gl_sky; static void HWR_SkyDomeVertex(gl_sky_t *sky, gl_skyvertex_t *vbo, int r, int c, signed char yflip, float delta, boolean foglayer) { - static constexpr float radians = (M_PIf / 180.0f); static constexpr float scale = 10000.0f; - static constexpr float maxSideAngle = 60.0f * radians; + static constexpr float maxSideAngle = 60.0f * deg2radians; - float topAngle = ((float)c / (float)sky->columns * 360.0f) * radians; + float topAngle = ((float)c / (float)sky->columns * 360.0f) * deg2radians; float sideAngle = (maxSideAngle * (float)(sky->rows - r) / (float)sky->rows); float height = sinf(sideAngle); float realRadius = (scale * cosf(sideAngle)); @@ -5184,7 +5269,6 @@ void HWR_ClearSkyDome(void) sky->rows = sky->columns = 0; sky->loopcount = 0; - sky->detail = 0; sky->texture = -1; sky->width = sky->height = 0; @@ -5203,8 +5287,7 @@ void HWR_BuildSkyDome(void) gl_skyvertex_t *vertex_p; const texture_t *texture = textures[texturetranslation[skytexture]]; - sky->detail = 16; - col_count *= sky->detail; + col_count *= 16; if ((sky->columns != col_count) || (sky->rows != row_count)) HWR_ClearSkyDome(); @@ -5367,6 +5450,12 @@ void HWR_SetTransform(float fpov) HWR_SetTransformAiming(&atransform); atransform.angley = (float)(viewangle>>ANGLETOFINESHIFT)*(FINEDEGREE); + yaw = 270.0f - atransform.angley; + inv_yaw = 180.0f - yaw; + const float inv_yaw_radians = inv_yaw * deg2radians; + cos_inv_yaw = cosf(inv_yaw_radians); + sin_inv_yaw = sinf(inv_yaw_radians); + // only needed for sprite billboarding if (cv_glspritebillboarding.value && !cv_glshearing.value) { @@ -5474,7 +5563,6 @@ void HWR_RenderViewpoint(gl_portal_t *rootportal, player_t *player, int stencil_ HWR_SetStencilState(HWR_STENCIL_NORMAL, stencil_level); HWR_SetTransform(fpov); - HWR_ClearSprites(); HWR_ClearClipper(); diff --git a/src/hardware/hw_portal.h b/src/hardware/hw_portal.h index 494110d79..23876281c 100644 --- a/src/hardware/hw_portal.h +++ b/src/hardware/hw_portal.h @@ -65,7 +65,7 @@ extern SINT8 gl_portal_state; // new thing extern gl_portallist_t *currentportallist; -static inline void HWR_SetPortalState (SINT8 state) +static inline void HWR_SetPortalState(SINT8 state) { gl_portal_state = state; } diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 185bc7e8a..c69d8c1b1 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -127,7 +127,7 @@ GLuint gl_num_extensions; int majorGL = 0, minorGL = 0; //Hurdler: 04/10/2000: added for the kick ass coronas as Boris wanted;-) -static GLfloat modelMatrix[16]; +GLfloat modelMatrix[16]; GLfloat projMatrix[16] = {0}; static GLint viewport[4]; @@ -1734,14 +1734,6 @@ void GL_SetBlend(FBITFIELD PolyFlags) if (Xor & PF_Modulated) { -#if defined (__unix__) || defined (UNIXCOMMON) - if (oglflags & GLF_NOTEXENV) - { - if (!(PolyFlags & PF_Modulated)) - pglColor4ubv(white); - } - else -#endif if (PolyFlags & PF_Modulated) { // mix texture colour with Surface->PolyColor pglTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); diff --git a/src/hardware/r_opengl/r_opengl.h b/src/hardware/r_opengl/r_opengl.h index 256731083..13ba9f6f5 100644 --- a/src/hardware/r_opengl/r_opengl.h +++ b/src/hardware/r_opengl/r_opengl.h @@ -38,8 +38,6 @@ extern "C" { #endif #endif -#define _CREATE_DLL_ // necessary for Unix AND Windows - #include "../../doomdef.h" #include "../hw_gl.h" #include "../../z_zone.h" @@ -126,18 +124,9 @@ extern GLint maximumAnisotropy; extern boolean supportNPO2tex; extern boolean supportMipMap; -/** \brief OpenGL flags for video driver -*/ -extern INT32 oglflags; - +extern GLfloat modelMatrix[16]; extern GLfloat projMatrix[16]; -typedef enum -{ - GLF_NOZBUFREAD = 0x01, - GLF_NOTEXENV = 0x02, -} oglflags_t; - #ifdef __cplusplus } // extern "C" #endif diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 814120b91..1f1885a5f 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -1387,9 +1387,9 @@ boolean HU_Responder(event_t *ev) && ev->data1 != gamecontrol[0][gc_talkkey][1])) return false; - M_TextInputHandleEmotes(&w_chat, c, &emote_autocomplete); - - if (c == KEY_ENTER) + if (M_TextInputHandleEmotes(&w_chat, c, &emote_autocomplete)) + ; // Do nothing + else if (c == KEY_ENTER) { chat_on = false; chat_scrollmedown = true; // you hit enter, so you might wanna autoscroll to see what you just sent. :) @@ -1426,8 +1426,6 @@ boolean HU_Responder(event_t *ev) // HEADS UP DRAWING //====================================================================== -#define HU_DrawEmote(x, y, emote, flags) M_DrawEmote((x), (y), (emote), hu_emoteanim, (flags)) - // Precompile a wordwrapped string to any given width. // This is a muuuch better method than V_WORDWRAP. // again stolen and modified a bit from video.c, don't mind me, will need to rearrange this one day. @@ -1630,7 +1628,7 @@ static void HU_drawMiniChat(void) if (cv_chatbacktint.value) // on request of wolfy V_DrawFillConsoleMap(x + dx + 2, y+dy, EMOTEWIDTH, charheight, 239|V_SNAPTOBOTTOM|V_SNAPTOLEFT); - HU_DrawEmote(x+dx+2, y+dy, emote, V_SNAPTOBOTTOM|V_SNAPTOLEFT|transflag); + M_DrawEmote(x+dx+2, y+dy, emote, V_SNAPTOBOTTOM|V_SNAPTOLEFT|transflag); dx += EMOTEWIDTH - charwidth; j += emotelen; @@ -1740,7 +1738,7 @@ static void HU_drawChatLog(INT32 offset) { if ((y+dy+2 >= chat_topy) && (y+dy < (chat_bottomy))) { - HU_DrawEmote(x+dx+2, y+dy, emote, V_SNAPTOBOTTOM|V_SNAPTOLEFT); + M_DrawEmote(x+dx+2, y+dy, emote, V_SNAPTOBOTTOM|V_SNAPTOLEFT); dx += EMOTEWIDTH - charwidth; } j += emotelen; @@ -1880,7 +1878,7 @@ static void HU_DrawChat(void) if ((emote = M_VerifyEmote(w_chat_buf+i, &emotelen))) { - HU_DrawEmote(chatx + c + 2, y-1, emote, V_SNAPTOBOTTOM|V_SNAPTOLEFT|t); + M_DrawEmote(chatx + c + 2, y-1, emote, V_SNAPTOBOTTOM|V_SNAPTOLEFT|t); c += EMOTEWIDTH - charwidth; i += emotelen-1; drawwidth = EMOTEWIDTH; @@ -1917,7 +1915,7 @@ static void HU_DrawChat(void) } } - if (emote_autocomplete.emotestart != -1 && (emote_autocomplete.complete[0] || (w_chat.cursor - emote_autocomplete.emotestart) > 0)) + if (emote_autocomplete.emotestart != -1 && (emote_autocomplete.complete[0] || (w_chat.cursor - emote_autocomplete.emotestart) > 1)) { emote_t *suggest; int skip = 0; @@ -1969,7 +1967,7 @@ static void HU_DrawChat(void) hlflag = V_YELLOWMAP; V_DrawSmallString(chatx + boxw + 4 + EMOTEWIDTH, suggesty - (7*skip), hlflag|V_SNAPTOBOTTOM|V_SNAPTOLEFT|V_ALLOWLOWERCASE, va(":%s:", suggest->name)); - HU_DrawEmote(chatx + boxw + 2, suggesty - skip*7, suggest, V_SNAPTOBOTTOM|V_SNAPTOLEFT); + M_DrawEmote(chatx + boxw + 2, suggesty - skip*7, suggest, V_SNAPTOBOTTOM|V_SNAPTOLEFT); ++skip; } @@ -2106,15 +2104,15 @@ static void HU_DrawChat_Old(void) i = 0; while (w_chat_buf[i]) { - if (w_chat.cursor == (i+1) && hu_tick < 4) - { - INT32 cursorx = (HU_INPUTX+c+charwidth < vid.width) ? (HU_INPUTX + c + charwidth) : (HU_INPUTX); // we may have to go down. - INT32 cursory = (cursorx != HU_INPUTX) ? (y) : (y+charheight); - V_DrawCharacter(cursorx, cursory+2*con_scalefactor, '_' |cv_constextsize.value | V_NOSCALESTART|t, !cv_allcaps.value); - } + int emotelen; + emote_t *emote; - //Hurdler: isn't it better like that? - if (w_chat_buf[i] >= HU_FONTSTART) + if ((emote = M_VerifyEmote(w_chat_buf+i, &emotelen))) + { + M_DrawScaledEmote((HU_INPUTX + c)<= HU_FONTSTART) //Hurdler: isn't it better like that? { //charwidth = hu_font[w_chat[i]-HU_FONTSTART]->width * con_scalefactor; V_DrawCharacter(HU_INPUTX + c, y, w_chat_buf[i] | cv_constextsize.value | V_NOSCALESTART | t, !cv_allcaps.value); @@ -2126,6 +2124,13 @@ static void HU_DrawChat_Old(void) ++i; + if (w_chat.cursor == i && hu_tick < 4) + { + INT32 cursorx = (HU_INPUTX+c+charwidth < vid.width) ? (HU_INPUTX + c + charwidth) : (HU_INPUTX); // we may have to go down. + INT32 cursory = (cursorx != HU_INPUTX) ? (y) : (y+charheight); + V_DrawCharacter(cursorx, cursory+2*con_scalefactor, '_' |cv_constextsize.value | V_NOSCALESTART|t, !cv_allcaps.value); + } + c += charwidth; if (c >= vid.width) { diff --git a/src/k_kart.c b/src/k_kart.c index 141af3481..201438234 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -809,8 +809,10 @@ boolean K_IsPlayerLosing(player_t *player) boolean K_IsPlayerWanted(player_t *player) { UINT8 i; - if (!(G_BattleGametype())) + + if (!G_BattleGametype()) return false; + for (i = 0; i < 4; i++) { if (battlewanted[i] == -1) @@ -818,6 +820,7 @@ boolean K_IsPlayerWanted(player_t *player) if (player == &players[battlewanted[i]]) return true; } + return false; } @@ -1242,7 +1245,9 @@ static void K_KartItemRoulette(player_t *player, ticcmd_t *cmd) { if (!playeringame[i] || players[i].spectator) continue; + pingame++; + if (players[i].exiting) dontforcespb = true; if (players[i].kartstuff[k_bumper] > bestbumper) @@ -1256,13 +1261,11 @@ static void K_KartItemRoulette(player_t *player, ticcmd_t *cmd) // This makes the roulette produce the random noises. if ((player->kartstuff[k_itemroulette] % 3) == 1 && P_IsDisplayPlayer(player)) { -#define PLAYROULETTESND S_StartSound(NULL, sfx_itrol1 + ((player->kartstuff[k_itemroulette] / 3) % 8)) for (i = 0; i <= splitscreen; i++) { if (player == &players[displayplayers[i]] && players[displayplayers[i]].kartstuff[k_itemroulette]) - PLAYROULETTESND; + S_StartSound(NULL, sfx_itrol1 + ((player->kartstuff[k_itemroulette] / 3) % 8)); } -#undef PLAYROULETTESND } roulettestop = TICRATE + (3*(pingame - player->kartstuff[k_position])); @@ -1361,8 +1364,9 @@ static fixed_t K_GetMobjWeight(mobj_t *mobj, mobj_t *against) else { weight = (mobj->player->kartweight)<player->speed > K_GetKartSpeed(mobj->player, false)) - weight += (mobj->player->speed - K_GetKartSpeed(mobj->player, false))/8; + const fixed_t kartspeed = K_GetKartSpeed(mobj->player, false); + if (mobj->player->speed > kartspeed) + weight += (mobj->player->speed - kartspeed)/8; } break; case MT_FALLINGROCK: @@ -1484,9 +1488,9 @@ void K_KartBouncing(mobj_t *mobj1, mobj_t *mobj2, boolean bounce, boolean solid) } // if the speed difference is less than this let's assume they're going proportionately faster from each other - if (P_AproxDistance(momdifx, momdify) < (25*mapobjectscale)) + const fixed_t momdiflength = P_AproxDistance(momdifx, momdify); + if (momdiflength < (25*mapobjectscale)) { - fixed_t momdiflength = P_AproxDistance(momdifx, momdify); fixed_t normalisedx = FixedDiv(momdifx, momdiflength); fixed_t normalisedy = FixedDiv(momdify, momdiflength); momdifx = FixedMul((25*mapobjectscale), normalisedx); @@ -1650,7 +1654,7 @@ static void K_UpdateOffroad(player_t *player) // If you are in offroad, a timer starts. if (offroadstrength) { - if (/*K_CheckOffroadCollide(player->mo) &&*/ player->kartstuff[k_offroad] == 0) // With the way offroad is detected now that first check is no longer necessary. -Lat' + if (/*K_CheckOffroadCollide(player->mo) &&*/ player->kartstuff[k_offroad] == 0) // With the way offroad is detected now that first check is no longer necessary. -Lat' player->kartstuff[k_offroad] = (TICRATE/2); if (player->kartstuff[k_offroad] > 0) @@ -2394,7 +2398,7 @@ void K_SpinPlayer(player_t *player, mobj_t *source, INT32 type, mobj_t *inflicto || player->kartstuff[k_invincibilitytimer] > 0 || player->kartstuff[k_growshrinktimer] > 0 || player->kartstuff[k_hyudorotimer] > 0 || (G_BattleGametype() && ((player->kartstuff[k_bumper] <= 0 && player->kartstuff[k_comebacktimer]) || player->kartstuff[k_comebackmode] == 1))) { - if (!force) // if shoulddamage force, we go THROUGH that. + if (!force) // if shoulddamage force, we go THROUGH that. { K_DoInstashield(player); return; @@ -2439,6 +2443,7 @@ void K_SpinPlayer(player_t *player, mobj_t *source, INT32 type, mobj_t *inflicto P_SetScale(karmahitbox, player->mo->scale); CONS_Printf(M_GetText("%s lost all of their bumpers!\n"), player_names[player-players]); } + player->kartstuff[k_bumper]--; if (K_IsPlayerWanted(player)) K_CalculateBattleWanted(); @@ -2573,6 +2578,7 @@ void K_SquishPlayer(player_t *player, mobj_t *source, mobj_t *inflictor) P_SetScale(karmahitbox, player->mo->scale); CONS_Printf(M_GetText("%s lost all of their bumpers!\n"), player_names[player-players]); } + player->kartstuff[k_bumper]--; if (K_IsPlayerWanted(player)) K_CalculateBattleWanted(); @@ -2692,6 +2698,7 @@ void K_ExplodePlayer(player_t *player, mobj_t *source, mobj_t *inflictor) // A b P_SetScale(karmahitbox, player->mo->scale); CONS_Printf(M_GetText("%s lost all of their bumpers!\n"), player_names[player-players]); } + player->kartstuff[k_bumper]--; if (K_IsPlayerWanted(player)) K_CalculateBattleWanted(); @@ -2852,9 +2859,9 @@ void K_SpawnKartExplosion(fixed_t x, fixed_t y, fixed_t z, fixed_t radius, INT32 for (i = 0; i < number; i++) { fa = (i*degrees); - v[0] = FixedMul(FINECOSINE(fa),radius); + v[0] = FixedMul(FINECOSINE(fa), radius); v[1] = 0; - v[2] = FixedMul(FINESINE(fa),radius); + v[2] = FixedMul(FINESINE(fa), radius); v[3] = FRACUNIT; res = VectorMatrixMultiply(v, *RotateXMatrix(rotangle)); @@ -6285,7 +6292,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground) K_KartUpdatePosition(player); - if (LIKELY(!player->exiting)) + if (!player->exiting) { if (player->kartstuff[k_oldposition] < player->kartstuff[k_position]) // But first, if you lost a place, { diff --git a/src/m_emotes.cpp b/src/m_emotes.cpp index c4dc05ba1..e45dcff58 100644 --- a/src/m_emotes.cpp +++ b/src/m_emotes.cpp @@ -15,6 +15,7 @@ #include #include "m_emotes.h" +#include "i_time.h" // I_GetTime extern "C" { #include "w_wad.h" @@ -200,7 +201,7 @@ emote_t *M_FindEmote(const char *name, int len, int skip) for (auto &pair: emotes) { - if (pair.first.rfind(query) == std::string::npos) + if (strcasestr(pair.first.c_str(), query) == NULL) continue; if (skip > 0) @@ -248,23 +249,18 @@ emote_t *M_VerifyEmote(const char *name, int *emotelen) return match; } -void M_DrawEmote(INT32 x, INT32 y, emote_t *emote, tic_t anim, INT32 flags) +void M_DrawScaledEmote(fixed_t x, fixed_t y, fixed_t scale, emote_t *emote, INT32 flags) { if (emote->numframes == 0) return; - const char *lumpname = emote->frames[(anim/emote->timeperframe) % emote->numframes]; + const char *lumpname = emote->frames[(I_GetTime()/emote->timeperframe) % emote->numframes]; patch_t *emotepatch = (patch_t*)W_CachePatchName(lumpname, PU_CACHE); const int CHARHEIGHT = 6; - fixed_t scale = FRACUNIT; - - x *= FRACUNIT; - y *= FRACUNIT; - if (emotepatch->width > EMOTEWIDTH) - scale = (FRACUNIT/emotepatch->width)*EMOTEWIDTH; + scale = FixedMul(scale, (FRACUNIT/emotepatch->width)*EMOTEWIDTH); else if (emotepatch->width < EMOTEWIDTH) x += (EMOTEWIDTH-emotepatch->width)*FRACUNIT/2; diff --git a/src/m_emotes.h b/src/m_emotes.h index 9921e4444..594e219f8 100644 --- a/src/m_emotes.h +++ b/src/m_emotes.h @@ -17,6 +17,7 @@ extern "C" { #endif #include "doomdef.h" +#include "m_fixed.h" #include "command.h" extern consvar_t cv_emotes; @@ -48,9 +49,9 @@ emote_t *M_FindEmote(const char *name, int len, int skips); // needs to be skipped to get past emote name emote_t *M_VerifyEmote(const char *name, int *emotelen); -// Draw the emote, anim should be some kind of timer ticking every game tic -// for animated emotes -void M_DrawEmote(INT32 x, INT32 y, emote_t *emote, tic_t anim, INT32 flags); +// Draw the emote, animation for animated emotes is done via I_GetTime +#define M_DrawEmote(x, y, emote, flags) M_DrawScaledEmote((x)<cursor == 0) - return; + return false; // If we're in "autocomplete" state, delete ':' for latest autocompleted emote if (autocomplete->complete[0]) @@ -457,8 +457,8 @@ static void M_TextInputCompleteEmote(textinput_t *input, emote_autocomplete_t *a int emotestart = autocomplete->emotestart; // No emote - no autocomplete - if (emotestart == -1 || (size_t)emotestart == input->cursor) - return; + if (emotestart == -1 || input->cursor - emotestart < 2) + return false; strlcpy(autocomplete->complete, &input->buffer[emotestart], input->cursor-emotestart+1); } @@ -476,7 +476,7 @@ static void M_TextInputCompleteEmote(textinput_t *input, emote_autocomplete_t *a { // Clear autocompletion state autocomplete->complete[0] = 0; - return; + return false; } } @@ -488,6 +488,8 @@ static void M_TextInputCompleteEmote(textinput_t *input, emote_autocomplete_t *a M_TextInputAddString(input, completed->name); M_TextInputAddChar(input, ':'); + + return true; } boolean M_TextInputHandleEmotes(textinput_t *input, INT32 key, emote_autocomplete_t *autocomplete) @@ -503,7 +505,8 @@ boolean M_TextInputHandleEmotes(textinput_t *input, INT32 key, emote_autocomplet if (key == '\t' || (autocomplete->complete[0] == 0 && key == KEY_ENTER)) { - M_TextInputCompleteEmote(input, autocomplete); + if (M_TextInputCompleteEmote(input, autocomplete) && key == KEY_ENTER) // Don't send message if we've autocompleted an emote + ret = true; } else { diff --git a/src/p_ceilng.c b/src/p_ceilng.c index a00d78008..1ec076325 100644 --- a/src/p_ceilng.c +++ b/src/p_ceilng.c @@ -33,7 +33,6 @@ void T_MoveCeiling(ceiling_t *ceiling) { result_e res; - boolean dontupdate = false; if (ceiling->delaytimer) { @@ -69,9 +68,7 @@ void T_MoveCeiling(ceiling_t *ceiling) case instantMoveCeilingByFrontSector: ceiling->sector->ceilingpic = ceiling->texture; ceiling->sector->ceilingdata = NULL; - ceiling->sector->ceilspeed = 0; P_RemoveThinker(&ceiling->thinker); - dontupdate = true; break; case moveCeilingByFrontSector: if (ceiling->texture < -1) // chained linedef executing @@ -83,9 +80,7 @@ void T_MoveCeiling(ceiling_t *ceiling) // case raiseCeilingByLine: case moveCeilingByFrontTexture: ceiling->sector->ceilingdata = NULL; - ceiling->sector->ceilspeed = 0; P_RemoveThinker(&ceiling->thinker); - dontupdate = true; break; case fastCrushAndRaise: @@ -189,9 +184,7 @@ void T_MoveCeiling(ceiling_t *ceiling) case instantMoveCeilingByFrontSector: ceiling->sector->ceilingpic = ceiling->texture; ceiling->sector->ceilingdata = NULL; - ceiling->sector->ceilspeed = 0; P_RemoveThinker(&ceiling->thinker); - dontupdate = true; break; case moveCeilingByFrontSector: @@ -209,9 +202,7 @@ void T_MoveCeiling(ceiling_t *ceiling) // case lowerCeilingByLine: case moveCeilingByFrontTexture: ceiling->sector->ceilingdata = NULL; - ceiling->sector->ceilspeed = 0; P_RemoveThinker(&ceiling->thinker); - dontupdate = true; break; case bounceCeiling: { @@ -290,10 +281,6 @@ void T_MoveCeiling(ceiling_t *ceiling) } break; } - if (!dontupdate) - ceiling->sector->ceilspeed = ceiling->speed*ceiling->direction; - else - ceiling->sector->ceilspeed = 0; } /** Moves a ceiling crusher. @@ -335,12 +322,9 @@ void T_CrushCeiling(ceiling_t *ceiling) switch(ceiling->type) { case crushCeilOnce: - ceiling->sector->ceilspeed = 0; ceiling->sector->ceilingdata = NULL; break; case crushBothOnce: - ceiling->sector->floorspeed = 0; - ceiling->sector->ceilspeed = 0; ceiling->sector->ceilingdata = NULL; break; default: @@ -377,11 +361,6 @@ void T_CrushCeiling(ceiling_t *ceiling) } break; } - - if (ceiling->type == crushBothOnce) - ceiling->sector->floorspeed = ceiling->speed*(-ceiling->direction); - - ceiling->sector->ceilspeed = ceiling->speed*ceiling->direction; } /** Starts a ceiling mover. diff --git a/src/p_floor.c b/src/p_floor.c index f4cc3e992..856d14f09 100644 --- a/src/p_floor.c +++ b/src/p_floor.c @@ -279,7 +279,6 @@ result_e T_MovePlane(sector_t *sector, fixed_t speed, fixed_t dest, boolean crus void T_MoveFloor(floormove_t *movefloor) { result_e res = 0; - boolean dontupdate = false; if (movefloor->delaytimer) { @@ -325,7 +324,6 @@ void T_MoveFloor(floormove_t *movefloor) else movefloor->floordestheight = lines[movefloor->texture].frontsector->floorheight; movefloor->direction = (movefloor->floordestheight < movefloor->sector->floorheight) ? -1 : 1; - movefloor->sector->floorspeed = movefloor->speed * movefloor->direction; movefloor->delaytimer = movefloor->delay; movefloor->sector->moved = true; return; // not break, why did this work? Graue 04-03-2004 @@ -341,7 +339,6 @@ void T_MoveFloor(floormove_t *movefloor) movefloor->speed = movefloor->origspeed = FixedDiv(abs(lines[movefloor->texture].dx),4*FRACUNIT); // forward again, use dx } movefloor->direction = (movefloor->floordestheight < movefloor->sector->floorheight) ? -1 : 1; - movefloor->sector->floorspeed = movefloor->speed * movefloor->direction; movefloor->delaytimer = movefloor->delay; movefloor->sector->moved = true; return; // not break, why did this work? Graue 04-03-2004 @@ -374,7 +371,6 @@ void T_MoveFloor(floormove_t *movefloor) else movefloor->floordestheight = lines[movefloor->texture].frontsector->floorheight; movefloor->direction = (movefloor->floordestheight < movefloor->sector->floorheight) ? -1 : 1; - movefloor->sector->floorspeed = movefloor->speed * movefloor->direction; movefloor->delaytimer = movefloor->delay; movefloor->sector->moved = true; return; // not break, why did this work? Graue 04-03-2004 @@ -390,14 +386,12 @@ void T_MoveFloor(floormove_t *movefloor) movefloor->speed = movefloor->origspeed = FixedDiv(abs(lines[movefloor->texture].dx),4*FRACUNIT); // forward again, use dx } movefloor->direction = (movefloor->floordestheight < movefloor->sector->floorheight) ? -1 : 1; - movefloor->sector->floorspeed = movefloor->speed * movefloor->direction; movefloor->delaytimer = movefloor->delay; movefloor->sector->moved = true; return; // not break, why did this work? Graue 04-03-2004 case crushFloorOnce: movefloor->sector->floordata = NULL; // Clear up the thinker so others can use it P_RemoveThinker(&movefloor->thinker); - movefloor->sector->floorspeed = 0; movefloor->sector->moved = true; return; default: @@ -406,14 +400,8 @@ void T_MoveFloor(floormove_t *movefloor) } movefloor->sector->floordata = NULL; // Clear up the thinker so others can use it - movefloor->sector->floorspeed = 0; P_RemoveThinker(&movefloor->thinker); - dontupdate = true; } - if (!dontupdate) - movefloor->sector->floorspeed = movefloor->speed*movefloor->direction; - else - movefloor->sector->floorspeed = 0; movefloor->sector->moved = true; } @@ -623,22 +611,13 @@ void T_MoveElevator(elevator_t *elevator) { elevator->sector->floordata = NULL; //jff 2/22/98 elevator->sector->ceilingdata = NULL; //jff 2/22/98 - elevator->sector->ceilspeed = 0; - elevator->sector->floorspeed = 0; P_RemoveThinker(&elevator->thinker); // remove elevator from actives dontupdate = true; } } - if (!dontupdate) + if (dontupdate) { - elevator->sector->floorspeed = elevator->speed*elevator->direction; - elevator->sector->ceilspeed = 42; - } - else - { - elevator->sector->floorspeed = 0; - elevator->sector->ceilspeed = 0; elevator->sector->floordata = NULL; elevator->sector->ceilingdata = NULL; } @@ -695,8 +674,6 @@ void T_ContinuousFalling(levelspecthink_t *faller) } } - faller->sector->floorspeed = faller->speed*faller->direction; - faller->sector->ceilspeed = 42; faller->sector->moved = true; #undef speed #undef direction @@ -767,9 +744,7 @@ void T_BounceCheese(levelspecthink_t *bouncer) { bouncer->sector->crumblestate = 1; bouncer->sector->ceilingdata = NULL; - bouncer->sector->ceilspeed = 0; bouncer->sector->floordata = NULL; - bouncer->sector->floorspeed = 0; P_RemoveThinker(&bouncer->thinker); // remove bouncer from actives return; } @@ -795,8 +770,6 @@ void T_BounceCheese(levelspecthink_t *bouncer) T_MovePlane(bouncer->sector, 0, bouncer->sector->floorheight, 0, 0, -1); // update things on floor bouncer->sector->ceilingdata = NULL; bouncer->sector->floordata = NULL; - bouncer->sector->floorspeed = 0; - bouncer->sector->ceilspeed = 0; bouncer->sector->moved = true; P_RemoveThinker(&bouncer->thinker); // remove bouncer from actives return; @@ -810,8 +783,6 @@ void T_BounceCheese(levelspecthink_t *bouncer) T_MovePlane(bouncer->sector, 0, bouncer->sector->floorheight, 0, 0, -1); // update things on floor bouncer->sector->ceilingdata = NULL; bouncer->sector->floordata = NULL; - bouncer->sector->floorspeed = 0; - bouncer->sector->ceilspeed = 0; bouncer->sector->moved = true; P_RemoveThinker(&bouncer->thinker); // remove bouncer from actives return; @@ -827,9 +798,6 @@ void T_BounceCheese(levelspecthink_t *bouncer) T_MovePlane(bouncer->sector, bouncer->speed/2, bouncer->sector->floorheight - 70*FRACUNIT, 0, 0, -1); // move floor - bouncer->sector->floorspeed = -bouncer->speed/2; - bouncer->sector->ceilspeed = 42; - if (bouncer->sector->ceilingheight < bouncer->ceilingwasheight && bouncer->low == 0) // Down { if (abs(bouncer->speed) < 6*FRACUNIT) @@ -878,9 +846,7 @@ void T_BounceCheese(levelspecthink_t *bouncer) T_MovePlane(bouncer->sector, 0, bouncer->sector->ceilingheight, 0, 1, -1); // update things on ceiling T_MovePlane(bouncer->sector, 0, bouncer->sector->floorheight, 0, 0, -1); // update things on floor bouncer->sector->ceilingdata = NULL; - bouncer->sector->floordata = NULL; - bouncer->sector->floorspeed = 0; - bouncer->sector->ceilspeed = 0; + bouncer->sector->floordata = NULL;; bouncer->sector->moved = true; P_RemoveThinker(&bouncer->thinker); // remove bouncer from actives } @@ -920,8 +886,6 @@ void T_StartCrumble(elevator_t *elevator) || (elevator->floordestheight == 0 && elevator->direction == 1)) && elevator->type == elevateContinuous) // No return crumbler { - elevator->sector->ceilspeed = 0; - elevator->sector->floorspeed = 0; return; } @@ -934,9 +898,6 @@ void T_StartCrumble(elevator_t *elevator) elevator->distance = -15*TICRATE; // Timer until platform returns to original position. else { - // Timer isn't up yet, so just keep waiting. - elevator->sector->ceilspeed = 0; - elevator->sector->floorspeed = 0; return; } } @@ -965,8 +926,6 @@ void T_StartCrumble(elevator_t *elevator) else elevator->direction = 1; - elevator->sector->ceilspeed = 0; - elevator->sector->floorspeed = 0; return; } @@ -1050,9 +1009,6 @@ void T_StartCrumble(elevator_t *elevator) 0, // move ceiling elevator->direction ); - - elevator->sector->ceilspeed = 42; - elevator->sector->floorspeed = elevator->speed*elevator->direction; } } } @@ -1063,8 +1019,6 @@ void T_StartCrumble(elevator_t *elevator) elevator->sector->floorheight = elevator->floorwasheight; elevator->sector->floordata = NULL; elevator->sector->ceilingdata = NULL; - elevator->sector->ceilspeed = 0; - elevator->sector->floorspeed = 0; elevator->sector->moved = true; P_RemoveThinker(&elevator->thinker); } @@ -1121,8 +1075,6 @@ void T_MarioBlock(levelspecthink_t *block) P_RemoveThinker(&block->thinker); block->sector->floordata = NULL; block->sector->ceilingdata = NULL; - block->sector->floorspeed = 0; - block->sector->ceilspeed = 0; } for (i = -1; (i = P_FindSectorFromTag((INT16)block->vars[0], i)) >= 0 ;) @@ -1365,8 +1317,6 @@ wegotit: { bridge->sector->floorheight = LOWCEILINGHEIGHT - (bridge->sector->ceilingheight - bridge->sector->floorheight); bridge->sector->ceilingheight = LOWCEILINGHEIGHT; - bridge->sector->ceilspeed = 0; - bridge->sector->floorspeed = 0; goto dorest; } @@ -1422,9 +1372,6 @@ wegotit: DIRECTION // direction ); - bridge->sector->ceilspeed = 42; - bridge->sector->floorspeed = CURSPEED*DIRECTION; - dorest: // Adjust joined sector heights { @@ -1463,8 +1410,6 @@ wegotit: { bridge->sector->floorheight = ORIGCEILINGHEIGHT - (bridge->sector->ceilingheight - bridge->sector->floorheight); bridge->sector->ceilingheight = ORIGCEILINGHEIGHT; - bridge->sector->ceilspeed = 0; - bridge->sector->floorspeed = 0; continue; } @@ -1519,9 +1464,6 @@ wegotit: 0, // floor or ceiling (0 for floor) DIRECTION // direction ); - - bridge->sector->ceilspeed = 42; - bridge->sector->floorspeed = CURSPEED*DIRECTION; } } } @@ -1558,8 +1500,6 @@ wegotit: { bridge->sector->floorheight = ORIGCEILINGHEIGHT - (bridge->sector->ceilingheight - bridge->sector->floorheight); bridge->sector->ceilingheight = ORIGCEILINGHEIGHT; - bridge->sector->ceilspeed = 0; - bridge->sector->floorspeed = 0; continue; } @@ -1614,9 +1554,6 @@ wegotit: 0, // floor or ceiling (0 for floor) DIRECTION // direction ); - - bridge->sector->ceilspeed = 42; - bridge->sector->floorspeed = CURSPEED*DIRECTION; } } } @@ -1642,8 +1579,6 @@ wegotit: { bridge->sector->floorheight = ORIGCEILINGHEIGHT - (bridge->sector->ceilingheight - bridge->sector->floorheight); bridge->sector->ceilingheight = ORIGCEILINGHEIGHT; - bridge->sector->ceilspeed = 0; - bridge->sector->floorspeed = 0; continue; } @@ -1698,9 +1633,6 @@ wegotit: 0, // floor or ceiling (0 for floor) DIRECTION // direction ); - - bridge->sector->ceilspeed = 42; - bridge->sector->floorspeed = CURSPEED*DIRECTION; } } // Update precip @@ -1875,9 +1807,6 @@ void T_ThwompSector(levelspecthink_t *thwomp) if (res == pastdest) thwomp->direction = 0; // stop moving - - thwomp->sector->ceilspeed = 42; - thwomp->sector->floorspeed = thwomp->speed*thwomp->direction; } else if (thwomp->direction < 0) // Crashing down! { @@ -1932,16 +1861,10 @@ void T_ThwompSector(levelspecthink_t *thwomp) thwomp->direction = 1; // start heading back up thwomp->distance = TICRATE; // but only after a small delay } - - thwomp->sector->ceilspeed = 42; - thwomp->sector->floorspeed = thwomp->speed*thwomp->direction; } else // Not going anywhere, so look for players. { thwomp->direction = -1; - - thwomp->sector->ceilspeed = 0; - thwomp->sector->floorspeed = 0; } actionsector->moved = true; @@ -2355,8 +2278,6 @@ void T_RaiseSector(levelspecthink_t *raise) { raise->sector->floorheight = raise->vars[7] - (raise->sector->ceilingheight - raise->sector->floorheight); raise->sector->ceilingheight = raise->vars[7]; - raise->sector->ceilspeed = 0; - raise->sector->floorspeed = 0; return; } @@ -2370,8 +2291,6 @@ void T_RaiseSector(levelspecthink_t *raise) { raise->sector->floorheight = raise->vars[5] - (raise->sector->ceilingheight - raise->sector->floorheight); raise->sector->ceilingheight = raise->vars[5]; - raise->sector->ceilspeed = 0; - raise->sector->floorspeed = 0; return; } @@ -2390,8 +2309,6 @@ void T_RaiseSector(levelspecthink_t *raise) { raise->sector->floorheight = raise->vars[5] - (raise->sector->ceilingheight - raise->sector->floorheight); raise->sector->ceilingheight = raise->vars[5]; - raise->sector->ceilspeed = 0; - raise->sector->floorspeed = 0; return; } raise->vars[8] = 1; @@ -2404,8 +2321,6 @@ void T_RaiseSector(levelspecthink_t *raise) { raise->sector->floorheight = raise->vars[7] - (raise->sector->ceilingheight - raise->sector->floorheight); raise->sector->ceilingheight = raise->vars[7]; - raise->sector->ceilspeed = 0; - raise->sector->floorspeed = 0; return; } raise->vars[8] = -1; @@ -2460,9 +2375,6 @@ void T_RaiseSector(levelspecthink_t *raise) raise->vars[8] // direction ); - raise->sector->ceilspeed = 42; - raise->sector->floorspeed = raise->vars[3]*raise->vars[8]; - for (i = -1; (i = P_FindSectorFromTag(raise->sourceline->tag, i)) >= 0 ;) sectors[i].moved = true; } diff --git a/src/p_inter.c b/src/p_inter.c index 3518684e3..c95735506 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -2164,7 +2164,9 @@ static void P_KillPlayer(player_t *player, mobj_t *source) P_SetScale(karmahitbox, player->mo->scale); CONS_Printf(M_GetText("%s lost all of their bumpers!\n"), player_names[player-players]); } + player->kartstuff[k_bumper]--; + if (K_IsPlayerWanted(player)) K_CalculateBattleWanted(); } diff --git a/src/p_spec.c b/src/p_spec.c index c8e36176a..7cf2694d0 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -1978,13 +1978,11 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) { P_RemoveThinker(&((elevator_t *)sectors[secnum].floordata)->thinker); sectors[secnum].floordata = sectors[secnum].ceilingdata = NULL; - sectors[secnum].floorspeed = sectors[secnum].ceilspeed = 0; } else // floormove { P_RemoveThinker(&((floormove_t *)sectors[secnum].floordata)->thinker); sectors[secnum].floordata = NULL; - sectors[secnum].floorspeed = 0; } } @@ -1992,7 +1990,6 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) { P_RemoveThinker(&((ceiling_t *)sectors[secnum].ceilingdata)->thinker); sectors[secnum].ceilingdata = NULL; - sectors[secnum].ceilspeed = 0; } } break; diff --git a/src/r_bsp.cpp b/src/r_bsp.cpp index e680783dd..ac9ab081b 100644 --- a/src/r_bsp.cpp +++ b/src/r_bsp.cpp @@ -322,9 +322,6 @@ static void R_AddLine(seg_t *line) g_portal = NULL; - if (line->polyseg && !(line->polyseg->flags & POF_RENDERSIDES)) - return; - // big room fix angle1 = R_PointToAngle64(line->v1->x, line->v1->y); angle2 = R_PointToAngle64(line->v2->x, line->v2->y); @@ -722,6 +719,8 @@ static void R_AddPolyObjects(subsector_t *sub) po = (polyobj_t *)(po->link.next); } + g_portal = NULL; + // for render stats ps_numpolyobjects.value.i += numpolys; @@ -732,8 +731,16 @@ static void R_AddPolyObjects(subsector_t *sub) for (i = 0; i < numpolys; ++i) { qs22j(po_ptrs[i]->segs, po_ptrs[i]->segCount, sizeof(seg_t *), R_PolysegCompare); + for (j = 0; j < po_ptrs[i]->segCount; ++j) - R_AddLine(po_ptrs[i]->segs[j]); + { + seg_t *seg = po_ptrs[i]->segs[j]; + + if (!(seg->polyseg->flags & POF_RENDERSIDES)) + continue; + + R_AddLine(seg); + } } } @@ -805,7 +812,7 @@ static void R_Subsector(size_t num) if (anyMoved == true) { frontsector->numlights = sub->sector->numlights = 0; - R_Prep3DFloors(frontsector); + R_Prep3DFloors(frontsector, ceilingcenterz); sub->sector->lightlist = frontsector->lightlist; sub->sector->numlights = frontsector->numlights; sub->sector->moved = frontsector->moved = false; @@ -1055,7 +1062,7 @@ static void R_Subsector(size_t num) // // This function creates the lightlists that the given sector uses to light // floors/ceilings/walls according to the 3D floors. -void R_Prep3DFloors(sector_t *sector) +void R_Prep3DFloors(sector_t *sector, fixed_t secceilz) { ffloor_t *rover; ffloor_t *best; @@ -1081,13 +1088,13 @@ void R_Prep3DFloors(sector_t *sector) if (count != sector->numlights) { Z_Free(sector->lightlist); - sector->lightlist = static_cast(Z_Calloc(sizeof (*sector->lightlist) * count, PU_LEVEL, NULL)); + sector->lightlist = static_cast(Z_Malloc(sizeof(*sector->lightlist) * count, PU_LEVEL, NULL)); sector->numlights = count; } - else - memset(sector->lightlist, 0, sizeof (lightlist_t) * count); - heighttest = P_GetSectorCeilingZAt(sector, sector->soundorg.x, sector->soundorg.y); + memset(sector->lightlist, 0, sizeof(lightlist_t) * count); + + heighttest = secceilz; // sector ceiling z sector->lightlist[0].height = heighttest + 1; sector->lightlist[0].slope = sector->c_slope; @@ -1117,6 +1124,7 @@ void R_Prep3DFloors(sector_t *sector) bestslope = *rover->t_slope; continue; } + if (rover->flags & FF_DOUBLESHADOW) { heighttest = P_GetFFloorBottomZAt(rover, sector->soundorg.x, sector->soundorg.y); diff --git a/src/r_bsp.h b/src/r_bsp.h index 1d00704f7..5f208f015 100644 --- a/src/r_bsp.h +++ b/src/r_bsp.h @@ -65,7 +65,7 @@ sector_t *R_FakeFlat(sector_t *sec, sector_t *tempsec, INT32 *floorlightlevel, boolean R_IsEmptyLine(seg_t *line, const sector_t *front, const sector_t *back); INT32 R_GetPlaneLight(sector_t *sector, fixed_t planeheight, boolean underside); -void R_Prep3DFloors(sector_t *sector); +void R_Prep3DFloors(sector_t *sector, fixed_t secceilz); #ifdef __cplusplus } // extern "C" diff --git a/src/r_defs.h b/src/r_defs.h index 876c63485..e6c5866c6 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -397,9 +397,6 @@ typedef struct sector_s // Sprite culling feature struct line_s *cullheight; - // Current speed of ceiling/floor. For Knuckles to hold onto stuff. - fixed_t floorspeed, ceilspeed; - // Eternity engine slope boolean hasslope; // The sector, or one of its visible FOFs, contains a slope } sector_t; @@ -549,12 +546,10 @@ typedef struct seg_s sector_t *backsector; fixed_t length; // precalculated seg length - #ifdef HWRENDER - floatvertex_t fv1; - floatvertex_t fv2; + floatvertex_t fv1; // v1 in floats - precalculated + floatvertex_t fv2; // v2 in floats - precalculated #endif - polyobj_t *polyseg; // Fake contrast calculated on level load diff --git a/src/r_fps.h b/src/r_fps.h index 7ad5e9f16..c1447897e 100644 --- a/src/r_fps.h +++ b/src/r_fps.h @@ -75,15 +75,11 @@ typedef struct { fixed_t y; fixed_t z; boolean sky; - sector_t *sector; player_t *player; angle_t angle; angle_t aim; angle_t roll; - fixed_t cos; - fixed_t sin; - mobj_t *mobj; } viewvars_t; extern viewvars_t *newview; diff --git a/src/r_main.cpp b/src/r_main.cpp index 452ed79c7..af5e821b2 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -1094,7 +1094,7 @@ subsector_t *R_IsPointInSubsector(fixed_t x, fixed_t y) mobj_t *viewmobj = NULL; -static void R_SetupCommonFrame(player_t * player, sector_t * sector) +static void R_SetupCommonFrame(player_t * player) { newview->player = player; @@ -1104,11 +1104,6 @@ static void R_SetupCommonFrame(player_t * player, sector_t * sector) newview->roll = R_ViewRollAngle(player); - if (sector != NULL) - newview->sector = sector; - else - newview->sector = R_PointInSubsectorFast(newview->x, newview->y)->sector; - R_InterpolateView(R_GetTimeFrac(RTF_CAMERA), false); } @@ -1207,7 +1202,6 @@ void R_SkyboxFrame(UINT8 pnum) { player_t *player = &players[displayplayers[pnum]]; camera_t *thiscam = &camera[pnum]; - sector_t *viewsec = NULL; mapheader_t *mh = mapheaderinfo[gamemap-1]; R_SetViewContext(static_cast(VIEWCONTEXT_SKY1 + pnum)); @@ -1233,9 +1227,6 @@ void R_SkyboxFrame(UINT8 pnum) newview->x = viewmobj->x; newview->y = viewmobj->y; newview->z = (viewmobj->spawnpoint) ? (((fixed_t)viewmobj->spawnpoint->angle) << FRACBITS) : 0; - - if (viewmobj->subsector) - viewsec = viewmobj->subsector->sector; } if (mh) @@ -1243,7 +1234,7 @@ void R_SkyboxFrame(UINT8 pnum) R_SetupSkyScale(player, thiscam, mh); } - R_SetupCommonFrame(player, viewsec); + R_SetupCommonFrame(player); } void R_SetupFrame(UINT8 pnum, boolean skybox) @@ -1251,7 +1242,6 @@ void R_SetupFrame(UINT8 pnum, boolean skybox) player_t *player = &players[displayplayers[pnum]]; camera_t *thiscam = &camera[pnum]; boolean chasecam = (cv_chasecam[pnum].value); - sector_t *viewsec = NULL; R_SetViewContext(static_cast(VIEWCONTEXT_PLAYER1 + pnum)); @@ -1295,10 +1285,7 @@ void R_SetupFrame(UINT8 pnum, boolean skybox) newview->y = viewmobj->y; newview->z = viewmobj->z + 20*FRACUNIT; - if (viewmobj->subsector) - viewsec = viewmobj->subsector->sector; - - R_SetupCommonFrame(player, viewsec); + R_SetupCommonFrame(player); } else if (thiscam && chasecam) // use outside cam view { @@ -1309,10 +1296,7 @@ void R_SetupFrame(UINT8 pnum, boolean skybox) newview->y = thiscam->y; newview->z = thiscam->z + (thiscam->height>>1); - if (thiscam->subsector) - viewsec = thiscam->subsector->sector; - - R_SetupCommonFrame(player, viewsec); + R_SetupCommonFrame(player); } else if (player->mo) // use the player's eyes view { @@ -1323,10 +1307,7 @@ void R_SetupFrame(UINT8 pnum, boolean skybox) newview->y = viewmobj->y; newview->z = player->viewz; - if (viewmobj->subsector) - viewsec = viewmobj->subsector->sector; - - R_SetupCommonFrame(player, viewsec); + R_SetupCommonFrame(player); } } diff --git a/src/r_things.cpp b/src/r_things.cpp index 1fe07b9db..489ce8911 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -1612,6 +1612,47 @@ static void R_ProjectSprite(mobj_t *thing) return; } + if (!papersprite) + { + // killough 4/9/98: clip things which are out of view due to height + // e6y: fix of hanging decoration disappearing in Batman Doom MAP02 + // centeryfrac -> viewheightfrac + // [kb] add +1 so sprites are shown even with the extended freelook + // lug: attempt to account for freelook properly + if (interp.z > viewz + FixedMul(FixedDiv(centeryfrac, projectiony), tz) || + gzt < viewz + FixedMul(FixedDiv(centeryfrac - (viewheight << FRACBITS), projectiony), tz)) + { + return; + } + } + + // killough 3/27/98: exclude things totally separated + // from the viewer, by either water or fake ceilings + // killough 4/11/98: improve sprite clipping for underwater/fake ceilings + + heightsec = thing->subsector->sector->heightsec; + if (viewplayer && viewplayer->mo && viewplayer->mo->subsector) + phs = viewplayer->mo->subsector->sector->heightsec; + else + phs = -1; + + if (heightsec != -1 && phs != -1) // only clip things which are in special sectors + { + fixed_t secheight; + + secheight = P_GetSectorFloorZAt(§ors[heightsec], viewx, viewy); + if (viewz < P_GetSectorFloorZAt(§ors[phs], interp.x, interp.y) ? + interp.z >= secheight : + gzt < secheight) + return; + + secheight = P_GetSectorCeilingZAt(§ors[heightsec], viewx, viewy); + if (viewz > P_GetSectorCeilingZAt(§ors[phs], interp.x, interp.y) ? + gzt < secheight && viewz >= secheight : + interp.z >= secheight) + return; + } + if (thing->frame & FF_ABSOLUTELIGHTLEVEL) { const UINT8 n = R_ThingLightLevel(thing); @@ -1689,24 +1730,6 @@ static void R_ProjectSprite(mobj_t *thing) lights_array = scalelight[lightnum]; } - heightsec = thing->subsector->sector->heightsec; - if (viewplayer && viewplayer->mo && viewplayer->mo->subsector) - phs = viewplayer->mo->subsector->sector->heightsec; - else - phs = -1; - - if (heightsec != -1 && phs != -1) // only clip things which are in special sectors - { - if (viewz < sectors[phs].floorheight ? - interp.z >= sectors[heightsec].floorheight : - gzt < sectors[heightsec].floorheight) - return; - if (viewz > sectors[phs].ceilingheight ? - gzt < sectors[heightsec].ceilingheight && viewz >= sectors[heightsec].ceilingheight : - interp.z >= sectors[heightsec].ceilingheight) - return; - } - // store information in a vissprite vis = R_NewVisSprite(); vis->heightsec = heightsec; //SoM: 3/17/2000 @@ -1952,6 +1975,17 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing) return; } + // killough 4/9/98: clip things which are out of view due to height + // e6y: fix of hanging decoration disappearing in Batman Doom MAP02 + // centeryfrac -> viewheightfrac + // [kb] add +1 so sprites are shown even with the extended freelook + // lug: attempt to account for freelook properly + if (interp.z > viewz + FixedMul(FixedDiv(centeryfrac, projectiony), tz) || + gzt < viewz + FixedMul(FixedDiv(centeryfrac - (viewheight << FRACBITS), projectiony), tz)) + { + return; + } + // aspect ratio stuff : yscale = FixedDiv(projectiony, tz);