From 661d8818d698bf76711bf6efe57fe71e8151dc67 Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 10 Apr 2021 19:37:20 -0700 Subject: [PATCH 001/156] Squash and stretch player sprite with sudden changes in vertical momentum Stretch with a sudden increase of momentum, squash with a decrease. --- src/d_player.h | 1 + src/k_kart.c | 1 + src/p_user.c | 37 +++++++++++++++++++++++++++++++++++++ 3 files changed, 39 insertions(+) diff --git a/src/d_player.h b/src/d_player.h index 08a0f1cde..a245bf096 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -597,6 +597,7 @@ typedef struct player_s fixed_t speed; // Player's speed (distance formula of MOMX and MOMY values) fixed_t lastspeed; + fixed_t lastmomz; UINT8 secondjump; // Jump counter UINT8 fly1; // Tails flying diff --git a/src/k_kart.c b/src/k_kart.c index 280916f57..bf8065e49 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -2288,6 +2288,7 @@ void K_KartMoveAnimation(player_t *player) // Update lastspeed value -- we use to display slow driving frames instead of fast driving when slowing down. player->lastspeed = player->speed; + player->lastmomz = player->mo->momz; } static void K_TauntVoiceTimers(player_t *player) diff --git a/src/p_user.c b/src/p_user.c index 0ea75e3bf..9c3c7a30f 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1845,6 +1845,41 @@ static void P_DoBubbleBreath(player_t *player) } } +static void squish(player_t *player) +{ + const fixed_t maxstretch = 2*FRACUNIT; + const fixed_t factor = 3 * player->mo->height / 2; + const fixed_t threshold = factor / 6; + + const fixed_t old3dspeed = abs(player->lastmomz); + const fixed_t new3dspeed = abs(player->mo->momz); + + const fixed_t delta = abs(old3dspeed - new3dspeed); + + if (delta > threshold) + { + player->mo->spritexscale = + FRACUNIT + FixedDiv(delta, factor); + + if (player->mo->spritexscale > maxstretch) + player->mo->spritexscale = maxstretch; + + if (abs(new3dspeed) > abs(old3dspeed)) + { + player->mo->spritexscale = + FixedDiv(FRACUNIT, player->mo->spritexscale); + } + } + else + { + player->mo->spritexscale -= + (player->mo->spritexscale - FRACUNIT) / 8; + } + + player->mo->spriteyscale = + FixedDiv(FRACUNIT, player->mo->spritexscale); +} + //#define OLD_MOVEMENT_CODE 1 static void P_3dMovement(player_t *player) { @@ -2031,6 +2066,8 @@ static void P_3dMovement(player_t *player) } } } + + squish(player); } // From 9771a6405320ab5f02293648cf9641dd2fca91c3 Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 11 Apr 2021 01:04:33 -0700 Subject: [PATCH 002/156] Unsquash the player more quickly Also don't apply squashing/stretching on slope launches. --- src/p_user.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index 9c3c7a30f..0cba996ff 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1873,7 +1873,8 @@ static void squish(player_t *player) else { player->mo->spritexscale -= - (player->mo->spritexscale - FRACUNIT) / 8; + (player->mo->spritexscale - FRACUNIT) + / (player->mo->spritexscale < FRACUNIT ? 8 : 2); } player->mo->spriteyscale = @@ -2067,7 +2068,10 @@ static void P_3dMovement(player_t *player) } } - squish(player); + if (!player->powers[pw_justlaunched]) + { + squish(player); + } } // From e2c0f6638f66094586e7fd3d4d2b1b29d3d3d64b Mon Sep 17 00:00:00 2001 From: lachablock Date: Mon, 2 Aug 2021 13:57:27 +1000 Subject: [PATCH 003/156] Fix item capsules in reverse gravity --- src/deh_tables.c | 7 +- src/info.c | 10 +-- src/info.h | 8 +- src/p_enemy.c | 189 --------------------------------------- src/p_local.h | 2 - src/p_mobj.c | 228 ++++++++++++++++++++++++++++++++++++++++++++--- 6 files changed, 228 insertions(+), 216 deletions(-) diff --git a/src/deh_tables.c b/src/deh_tables.c index a97d56865..154455a83 100644 --- a/src/deh_tables.c +++ b/src/deh_tables.c @@ -334,7 +334,6 @@ actionpointer_t actionpointers[] = {{A_ReaperThinker}, "A_REAPERTHINKER"}, {{A_FlameShieldPaper}, "A_FLAMESHIELDPAPER"}, {{A_InvincSparkleRotate}, "A_INVINCSPARKLEROTATE"}, - {{A_SpawnItemCapsuleParts}, "A_SPAWNITEMCAPSULEPARTS"}, {{NULL}, "NONE"}, @@ -3490,9 +3489,9 @@ const char *const STATE_LIST[] = { // array length left dynamic for sanity testi "S_ITEMCAPSULE_TOP_SIDE", "S_ITEMCAPSULE_BOTTOM_SIDE_AIR", "S_ITEMCAPSULE_BOTTOM_SIDE_GROUND", - "S_ITEMCAPSULE_TOP", - "S_ITEMCAPSULE_BOTTOM", - "S_ITEMCAPSULE_INSIDE", + //"S_ITEMCAPSULE_TOP", + //"S_ITEMCAPSULE_BOTTOM", + //"S_ITEMCAPSULE_INSIDE", // Signpost sparkles "S_SIGNSPARK1", diff --git a/src/info.c b/src/info.c index 7f2e06f56..67596f9b4 100644 --- a/src/info.c +++ b/src/info.c @@ -4067,13 +4067,13 @@ state_t states[NUMSTATES] = {SPR_NULL, FF_FULLBRIGHT, -1, {NULL}, 0, 0, S_NULL}, // S_ITEMICON - {SPR_ICAP, FF_ADD|0, -1, {A_SpawnItemCapsuleParts}, 0, 0, S_NULL}, // S_ITEMCAPSULE + {SPR_ICAP, FF_ADD|0, -1, {NULL}, 0, 0, S_NULL}, // S_ITEMCAPSULE {SPR_ICAP, FF_PAPERSPRITE|1, -1, {NULL}, 0, 0, S_NULL}, // S_ITEMCAPSULE_TOP_SIDE {SPR_ICAP, FF_VERTICALFLIP|FF_PAPERSPRITE|1, -1, {NULL}, 0, 0, S_NULL}, // S_ITEMCAPSULE_BOTTOM_SIDE_AIR {SPR_ICAP, FF_PAPERSPRITE|2, -1, {NULL}, 0, 0, S_NULL}, // S_ITEMCAPSULE_BOTTOM_SIDE_GROUND - {SPR_ICAP, FF_FLOORSPRITE|3, -1, {NULL}, 0, 0, S_NULL}, // S_ITEMCAPSULE_TOP - {SPR_ICAP, FF_FLOORSPRITE|4, -1, {NULL}, 0, 0, S_NULL}, // S_ITEMCAPSULE_BOTTOM - {SPR_ICAP, FF_FLOORSPRITE|5, -1, {NULL}, 0, 0, S_NULL}, // S_ITEMCAPSULE_INSIDE + //{SPR_ICAP, FF_FLOORSPRITE|3, -1, {NULL}, 0, 0, S_NULL}, // S_ITEMCAPSULE_TOP + //{SPR_ICAP, FF_FLOORSPRITE|4, -1, {NULL}, 0, 0, S_NULL}, // S_ITEMCAPSULE_BOTTOM + //{SPR_ICAP, FF_FLOORSPRITE|5, -1, {NULL}, 0, 0, S_NULL}, // S_ITEMCAPSULE_INSIDE {SPR_SGNS, FF_FULLBRIGHT, 1, {NULL}, 0, 0, S_SIGNSPARK2}, // S_SIGNSPARK1 {SPR_SGNS, FF_FULLBRIGHT|1, 1, {NULL}, 0, 0, S_SIGNSPARK3}, // S_SIGNSPARK2 @@ -23088,7 +23088,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = 100, // mass 0, // damage sfx_None, // activesound - MF_SLIDEME|MF_SPECIAL|MF_RUNSPAWNFUNC|MF_DONTENCOREMAP, // flags + MF_SLIDEME|MF_SPECIAL|MF_DONTENCOREMAP, // flags S_NULL // raisestate }, diff --git a/src/info.h b/src/info.h index ab9456cae..8435889a5 100644 --- a/src/info.h +++ b/src/info.h @@ -287,7 +287,6 @@ enum actionnum A_REAPERTHINKER, A_FLAMESHIELDPAPER, A_INVINCSPARKLEROTATE, - A_SPAWNITEMCAPSULEPARTS, NUMACTIONS }; @@ -558,7 +557,6 @@ void A_ReaperThinker(); void A_MementosTPParticles(); void A_FlameShieldPaper(); void A_InvincSparkleRotate(); -void A_SpawnItemCapsuleParts(); extern boolean actionsoverridden[NUMACTIONS]; @@ -4465,9 +4463,9 @@ typedef enum state S_ITEMCAPSULE_TOP_SIDE, S_ITEMCAPSULE_BOTTOM_SIDE_AIR, S_ITEMCAPSULE_BOTTOM_SIDE_GROUND, - S_ITEMCAPSULE_TOP, - S_ITEMCAPSULE_BOTTOM, - S_ITEMCAPSULE_INSIDE, + //S_ITEMCAPSULE_TOP, + //S_ITEMCAPSULE_BOTTOM, + //S_ITEMCAPSULE_INSIDE, // Signpost sparkles S_SIGNSPARK1, diff --git a/src/p_enemy.c b/src/p_enemy.c index 9f5fc86d8..9dbeb8f5b 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -321,7 +321,6 @@ void A_ReaperThinker(mobj_t *actor); void A_MementosTPParticles(mobj_t *actor); void A_FlameShieldPaper(mobj_t *actor); void A_InvincSparkleRotate(mobj_t *actor); -void A_SpawnItemCapsuleParts(mobj_t *actor); //for p_enemy.c @@ -14652,191 +14651,3 @@ void A_InvincSparkleRotate(mobj_t *actor) actor->angle += ANG1*10*(actor->extravalue2); // Arbitrary value, change this if you want, I suppose. } - -void P_RefreshItemCapsuleParts(mobj_t *mobj) -{ - UINT8 numNumbers = 0; - INT32 count = 0; - INT32 itemType = mobj->threshold; - mobj_t *part; - skincolornum_t color; - UINT32 newRenderFlags = 0; - boolean colorized; - - if (itemType < 1 || itemType >= NUMKARTITEMS) - itemType = KITEM_SAD; - - // update invincibility properties - if (itemType == KITEM_INVINCIBILITY) - { - mobj->renderflags = (mobj->renderflags & ~RF_BRIGHTMASK) | RF_FULLBRIGHT; - mobj->colorized = true; - } - else - { - mobj->renderflags = (mobj->renderflags & ~RF_BRIGHTMASK) | RF_SEMIBRIGHT; - mobj->color = SKINCOLOR_NONE; - mobj->colorized = false; - } - - // update cap colors - if (itemType == KITEM_SUPERRING) - { - color = SKINCOLOR_GOLD; - newRenderFlags |= RF_SEMIBRIGHT; - } - else if (mobj->spawnpoint && (mobj->spawnpoint->options & MTF_EXTRA)) - color = SKINCOLOR_SAPPHIRE; - else if (itemType == KITEM_SPB) - color = SKINCOLOR_JET; - else - color = SKINCOLOR_NONE; - - colorized = (color != SKINCOLOR_NONE); - part = mobj; - while (!P_MobjWasRemoved(part->hnext)) - { - part = part->hnext; - part->color = color; - part->colorized = colorized; - part->renderflags = (part->renderflags & ~RF_BRIGHTMASK) | newRenderFlags; - } - - // update inside item frame - part = mobj->tracer; - if (P_MobjWasRemoved(part)) - return; - - part->threshold = mobj->threshold; - part->movecount = mobj->movecount; - - switch (itemType) - { - case KITEM_ORBINAUT: - part->sprite = SPR_ITMO; - part->frame = FF_FULLBRIGHT|FF_PAPERSPRITE|K_GetOrbinautItemFrame(mobj->movecount); - break; - case KITEM_INVINCIBILITY: - part->sprite = SPR_ITMI; - part->frame = FF_FULLBRIGHT|FF_PAPERSPRITE|K_GetInvincibilityItemFrame(); - break; - case KITEM_SAD: - part->sprite = SPR_ITEM; - part->frame = FF_FULLBRIGHT|FF_PAPERSPRITE; - break; - default: - part->sprite = SPR_ITEM; - part->frame = FF_FULLBRIGHT|FF_PAPERSPRITE|(itemType); - break; - } - - // update number frame - if (K_GetShieldFromItem(itemType) != KSHIELD_NONE) // shields don't stack, so don't show a number - ; - else - { - switch (itemType) - { - case KITEM_ORBINAUT: // only display the number when the sprite no longer changes - if (mobj->movecount - 1 > K_GetOrbinautItemFrame(mobj->movecount)) - count = mobj->movecount; - break; - case KITEM_SUPERRING: // always display the number, and multiply it by 5 - count = mobj->movecount * 5; - break; - case KITEM_SAD: // never display the number - case KITEM_SPB: - break; - default: - if (mobj->movecount > 1) - count = mobj->movecount; - break; - } - } - - while (count > 0) - { - if (P_MobjWasRemoved(part->tracer)) - { - P_SetTarget(&part->tracer, P_SpawnMobjFromMobj(mobj, 0, 0, 0, MT_OVERLAY)); - P_SetTarget(&part->tracer->target, part); - P_SetMobjState(part->tracer, S_INVISIBLE); - part->tracer->spriteyoffset = 10*FRACUNIT; - part->tracer->spritexoffset = 13*numNumbers*FRACUNIT; - } - part = part->tracer; - part->sprite = SPR_ITMN; - part->frame = FF_FULLBRIGHT|(count % 10); - count /= 10; - numNumbers++; - } - - // delete any extra overlays (I guess in case the number changes?) - if (part->tracer) - { - P_RemoveMobj(part->tracer); - P_SetTarget(&part->tracer, NULL); - } -} - -#define CAPSULESIDES 5 -#define ANG_CAPSULE (UINT32_MAX / CAPSULESIDES) -#define ROTATIONSPEED (2*ANG2) -void A_SpawnItemCapsuleParts(mobj_t *actor) -{ - UINT8 i; - mobj_t *part; - fixed_t buttScale = 0; - statenum_t buttState = S_ITEMCAPSULE_BOTTOM_SIDE_AIR; - angle_t spin = ANGLE_MAX - ROTATIONSPEED; - - if (LUA_CallAction(A_SPAWNITEMCAPSULEPARTS, actor)) - return; - - if (P_IsObjectOnGround(actor)) - { - buttScale = 13*FRACUNIT/10; - buttState = S_ITEMCAPSULE_BOTTOM_SIDE_GROUND; - spin = 0; - } - - // inside item - part = P_SpawnMobjFromMobj(actor, 0, 0, 0, MT_ITEMCAPSULE_PART); - P_SetTarget(&part->target, actor); - P_SetMobjState(part, S_ITEMICON); - part->movedir = ROTATIONSPEED; // rotation speed - part->extravalue1 = 175*FRACUNIT/100; // relative scale - part->flags2 |= MF2_CLASSICPUSH; // classicpush = centered horizontally - P_SetTarget(&actor->tracer, part); // pointer to this item, so we can modify its sprite/frame - - // capsule caps - part = actor; - for (i = 0; i < CAPSULESIDES; i++) - { - // a bottom side - P_SetTarget(&part->hnext, P_SpawnMobjFromMobj(actor, 0, 0, 0, MT_ITEMCAPSULE_PART)); - P_SetTarget(&part->hnext->hprev, part); - part = part->hnext; - P_SetTarget(&part->target, actor); - P_SetMobjState(part, buttState); - part->angle = i * ANG_CAPSULE; - part->movedir = spin; // rotation speed - part->movefactor = 0; // z offset - part->extravalue1 = buttScale; // relative scale - - // a top side - P_SetTarget(&part->hnext, P_SpawnMobjFromMobj(actor, 0, 0, 0, MT_ITEMCAPSULE_PART)); - P_SetTarget(&part->hnext->hprev, part); - part = part->hnext; - P_SetTarget(&part->target, actor); - P_SetMobjState(part, S_ITEMCAPSULE_TOP_SIDE); - part->angle = i * ANG_CAPSULE; - part->movedir = spin; // rotation speed - part->movefactor = actor->info->height - part->info->height; // z offset - } - - P_RefreshItemCapsuleParts(actor); -} -#undef CAPSULESIDES -#undef ANG_CAPSULE -#undef ROTATIONSPEED diff --git a/src/p_local.h b/src/p_local.h index 9c282499f..a143ba9ab 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -365,8 +365,6 @@ void P_InternalFlickyBubble(mobj_t *actor); void P_InternalFlickyFly(mobj_t *actor, fixed_t flyspeed, fixed_t targetdist, fixed_t chasez); void P_InternalFlickyHop(mobj_t *actor, fixed_t momz, fixed_t momh, angle_t angle); -void P_RefreshItemCapsuleParts(mobj_t *mobj); - // // P_MAP // diff --git a/src/p_mobj.c b/src/p_mobj.c index 91f8c9403..629775908 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -3781,8 +3781,12 @@ static void P_ItemCapsulePartThinker(mobj_t *mobj) P_SetScale(mobj, mobj->destscale = targetScale); // find z position - K_GenericExtraFlagsNoZAdjust(mobj, target); - if (mobj->flags & MFE_VERTICALFLIP) + if (mobj->flags2 & MF2_CLASSICPUSH) // centered items should not be flipped + mobj->renderflags = (mobj->renderflags & ~RF_DONTDRAW) | (target->renderflags & RF_DONTDRAW); + else + K_GenericExtraFlagsNoZAdjust(mobj, target); + + if (mobj->eflags & MFE_VERTICALFLIP) z = target->z + target->height - mobj->height - FixedMul(mobj->scale, mobj->movefactor); else z = target->z + FixedMul(mobj->scale, mobj->movefactor); @@ -3799,6 +3803,193 @@ static void P_ItemCapsulePartThinker(mobj_t *mobj) } } +static void P_RefreshItemCapsuleParts(mobj_t *mobj) +{ + UINT8 numNumbers = 0; + INT32 count = 0; + INT32 itemType = mobj->threshold; + mobj_t *part; + skincolornum_t color; + UINT32 newRenderFlags = 0; + boolean colorized; + + if (itemType < 1 || itemType >= NUMKARTITEMS) + itemType = KITEM_SAD; + + // update invincibility properties + if (itemType == KITEM_INVINCIBILITY) + { + mobj->renderflags = (mobj->renderflags & ~RF_BRIGHTMASK) | RF_FULLBRIGHT; + mobj->colorized = true; + } + else + { + mobj->renderflags = (mobj->renderflags & ~RF_BRIGHTMASK) | RF_SEMIBRIGHT; + mobj->color = SKINCOLOR_NONE; + mobj->colorized = false; + } + + // update cap colors + if (itemType == KITEM_SUPERRING) + { + color = SKINCOLOR_GOLD; + newRenderFlags |= RF_SEMIBRIGHT; + } + else if (mobj->spawnpoint && (mobj->spawnpoint->options & MTF_EXTRA)) + color = SKINCOLOR_SAPPHIRE; + else if (itemType == KITEM_SPB) + color = SKINCOLOR_JET; + else + color = SKINCOLOR_NONE; + + colorized = (color != SKINCOLOR_NONE); + part = mobj; + while (!P_MobjWasRemoved(part->hnext)) + { + part = part->hnext; + part->color = color; + part->colorized = colorized; + part->renderflags = (part->renderflags & ~RF_BRIGHTMASK) | newRenderFlags; + } + + // update inside item frame + part = mobj->tracer; + if (P_MobjWasRemoved(part)) + return; + + part->threshold = mobj->threshold; + part->movecount = mobj->movecount; + + switch (itemType) + { + case KITEM_ORBINAUT: + part->sprite = SPR_ITMO; + part->frame = FF_FULLBRIGHT|FF_PAPERSPRITE|K_GetOrbinautItemFrame(mobj->movecount); + break; + case KITEM_INVINCIBILITY: + part->sprite = SPR_ITMI; + part->frame = FF_FULLBRIGHT|FF_PAPERSPRITE|K_GetInvincibilityItemFrame(); + break; + case KITEM_SAD: + part->sprite = SPR_ITEM; + part->frame = FF_FULLBRIGHT|FF_PAPERSPRITE; + break; + default: + part->sprite = SPR_ITEM; + part->frame = FF_FULLBRIGHT|FF_PAPERSPRITE|(itemType); + break; + } + + // update number frame + if (K_GetShieldFromItem(itemType) != KSHIELD_NONE) // shields don't stack, so don't show a number + ; + else + { + switch (itemType) + { + case KITEM_ORBINAUT: // only display the number when the sprite no longer changes + if (mobj->movecount - 1 > K_GetOrbinautItemFrame(mobj->movecount)) + count = mobj->movecount; + break; + case KITEM_SUPERRING: // always display the number, and multiply it by 5 + count = mobj->movecount * 5; + break; + case KITEM_SAD: // never display the number + case KITEM_SPB: + break; + default: + if (mobj->movecount > 1) + count = mobj->movecount; + break; + } + } + + while (count > 0) + { + if (P_MobjWasRemoved(part->tracer)) + { + P_SetTarget(&part->tracer, P_SpawnMobjFromMobj(mobj, 0, 0, 0, MT_OVERLAY)); + P_SetTarget(&part->tracer->target, part); + P_SetMobjState(part->tracer, S_INVISIBLE); + part->tracer->spriteyoffset = 10*FRACUNIT; + part->tracer->spritexoffset = 13*numNumbers*FRACUNIT; + } + part = part->tracer; + part->sprite = SPR_ITMN; + part->frame = FF_FULLBRIGHT|(count % 10); + count /= 10; + numNumbers++; + } + + // delete any extra overlays (I guess in case the number changes?) + if (part->tracer) + { + P_RemoveMobj(part->tracer); + P_SetTarget(&part->tracer, NULL); + } +} + +#define CAPSULESIDES 5 +#define ANG_CAPSULE (UINT32_MAX / CAPSULESIDES) +#define ROTATIONSPEED (2*ANG2) +static void P_SpawnItemCapsuleParts(mobj_t *mobj) +{ + UINT8 i; + mobj_t *part; + fixed_t buttScale = 0; + statenum_t buttState = S_ITEMCAPSULE_BOTTOM_SIDE_AIR; + angle_t spin = ANGLE_MAX - ROTATIONSPEED; + + if (P_IsObjectOnGround(mobj)) + { + buttScale = 13*FRACUNIT/10; + buttState = S_ITEMCAPSULE_BOTTOM_SIDE_GROUND; + spin = 0; + } + + // inside item + part = P_SpawnMobjFromMobj(mobj, 0, 0, 0, MT_ITEMCAPSULE_PART); + P_SetTarget(&part->target, mobj); + P_SetMobjState(part, S_ITEMICON); + part->movedir = ROTATIONSPEED; // rotation speed + part->extravalue1 = 175*FRACUNIT/100; // relative scale + part->flags2 |= MF2_CLASSICPUSH; // classicpush = centered horizontally + part->flags2 &= ~MF2_OBJECTFLIP; // centered item should not be flipped + part->eflags &= ~MFE_VERTICALFLIP; + P_SetTarget(&mobj->tracer, part); // pointer to this item, so we can modify its sprite/frame + + // capsule caps + part = mobj; + for (i = 0; i < CAPSULESIDES; i++) + { + // a bottom side + P_SetTarget(&part->hnext, P_SpawnMobjFromMobj(mobj, 0, 0, 0, MT_ITEMCAPSULE_PART)); + P_SetTarget(&part->hnext->hprev, part); + part = part->hnext; + P_SetTarget(&part->target, mobj); + P_SetMobjState(part, buttState); + part->angle = i * ANG_CAPSULE; + part->movedir = spin; // rotation speed + part->movefactor = 0; // z offset + part->extravalue1 = buttScale; // relative scale + + // a top side + P_SetTarget(&part->hnext, P_SpawnMobjFromMobj(mobj, 0, 0, 0, MT_ITEMCAPSULE_PART)); + P_SetTarget(&part->hnext->hprev, part); + part = part->hnext; + P_SetTarget(&part->target, mobj); + P_SetMobjState(part, S_ITEMCAPSULE_TOP_SIDE); + part->angle = i * ANG_CAPSULE; + part->movedir = spin; // rotation speed + part->movefactor = mobj->info->height - part->info->height; // z offset + } + + P_RefreshItemCapsuleParts(mobj); +} +#undef CAPSULESIDES +#undef ANG_CAPSULE +#undef ROTATIONSPEED + // // P_BossTargetPlayer // If closest is true, find the closest player. @@ -6153,6 +6344,14 @@ static boolean P_MobjRegularThink(mobj_t *mobj) mobj->z -= (mobj->height - oldHeight); } + // spawn parts if not done yet + // (this SHOULD be done when the capsule is spawned, but gravflip isn't set up at that point) + if (!(mobj->flags2 & MF2_JUSTATTACKED)) + { + mobj->flags2 |= MF2_JUSTATTACKED; + P_SpawnItemCapsuleParts(mobj); + } + // update & animate capsule if (!P_MobjWasRemoved(mobj->tracer)) { @@ -9433,8 +9632,6 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) // SRB2Kart case MT_ITEMCAPSULE: { - fixed_t oldHeight = mobj->height; - // set default item & count #if 0 // set to 1 to test capsules with random items, e.g. with objectplace if (P_RandomChance(FRACUNIT/3)) @@ -9451,17 +9648,10 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) mobj->movecount = 1; #endif - // grounded/aerial properties - P_AdjustMobjFloorZ_FFloors(mobj, mobj->subsector->sector, 0); - if (!P_IsObjectOnGround(mobj)) - mobj->flags |= MF_NOGRAVITY; - // set starting scale mobj->extravalue1 = mobj->scale; // this acts as the capsule's destscale; we're avoiding P_MobjScaleThink because we want aerial capsules not to scale from their center mobj->scalespeed >>= 1; P_SetScale(mobj, mobj->destscale = mapobjectscale >> 4); - if (mobj->eflags & MFE_VERTICALFLIP) - mobj->z += (oldHeight - mobj->height); break; } @@ -11721,6 +11911,22 @@ static boolean P_SetupSpawnedMapThing(mapthing_t *mthing, mobj_t *mobj, boolean } case MT_ITEMCAPSULE: { + // we have to adjust for reverse gravity early so that the below grounded checks work + if (mthing->options & MTF_OBJECTFLIP) + { + mobj->eflags |= MFE_VERTICALFLIP; + mobj->flags2 |= MF2_OBJECTFLIP; + mobj->z += FixedMul(mobj->extravalue1, mobj->info->height) - mobj->height; + } + + // determine whether this capsule is grounded or aerial + if (mobj->subsector->sector->ffloors) + P_AdjustMobjFloorZ_FFloors(mobj, mobj->subsector->sector, 0); + if (mobj->subsector->polyList) + P_AdjustMobjFloorZ_PolyObjs(mobj, mobj->subsector); + if (!P_IsObjectOnGround(mobj)) + mobj->flags |= MF_NOGRAVITY; + // Angle = item type if (mthing->angle > 0 && mthing->angle < NUMKARTITEMS) mobj->threshold = mthing->angle; From caf1ed37ac01714d6bbf108b276db5536d2d8b71 Mon Sep 17 00:00:00 2001 From: SinnamonLat Date: Thu, 2 Sep 2021 08:17:43 +0200 Subject: [PATCH 004/156] fix janky follower movements due to lag type being changed from int32 to uint32 in the struct --- src/p_user.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index d577faab2..a8523bdf6 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3918,9 +3918,10 @@ static void P_HandleFollower(player_t *player) P_SetFollowerState(player->follower, player->follower->state->nextstate); // move the follower next to us (yes, this is really basic maths but it looks pretty damn clean in practice)! - player->follower->momx = (sx - player->follower->x)/fl.horzlag; - player->follower->momy = (sy - player->follower->y)/fl.horzlag; - player->follower->momz = (sz - player->follower->z)/fl.vertlag; + // 02/09/2021: cast lag to int32 otherwise funny things happen since it was changed to uint32 in the struct + player->follower->momx = (sx - player->follower->x)/ (INT32)fl.horzlag; + player->follower->momy = (sy - player->follower->y)/ (INT32)fl.horzlag; + player->follower->momz = (sz - player->follower->z)/ (INT32)fl.vertlag; player->follower->angle = player->mo->angle; if (player->mo->colorized) From 2df8aa69b7653c1d328365018f658dca77f8681c Mon Sep 17 00:00:00 2001 From: SinnamonLat Date: Thu, 2 Sep 2021 08:33:49 +0200 Subject: [PATCH 005/156] missing follower check in SendNameAndColor --- src/d_netcmd.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 4ed110f35..cd6189e8a 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -1398,7 +1398,9 @@ static void SendNameAndColor(UINT8 n) if (!strcmp(cv_playername[n].string, player_names[playernum]) && cv_playercolor[n].value == player->skincolor - && !strcmp(cv_skin[n].string, skins[player->skin].name)) + && !strcmp(cv_skin[n].string, skins[player->skin].name) + && cv_follower[n].value == player->followerskin + && cv_followercolor[n].value == player->followercolor) return; player->availabilities = R_GetSkinAvailabilities(); From f96f7c6ba3ce0064076507deb88da47440229da6 Mon Sep 17 00:00:00 2001 From: SinnamonLat Date: Thu, 2 Sep 2021 13:34:17 +0200 Subject: [PATCH 006/156] Fix follower colours 'Match' and 'Opposite' not working --- src/d_netcmd.c | 18 ++++++++++++------ src/p_user.c | 9 ++++----- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/src/d_netcmd.c b/src/d_netcmd.c index cd6189e8a..2556ab0ac 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -768,15 +768,21 @@ void D_RegisterClientCommands(void) for (i = 0; i < MAXSKINCOLORS; i++) { - Color_cons_t[i].value = Followercolor_cons_t[i].value = i; - Color_cons_t[i].strvalue = Followercolor_cons_t[i].strvalue = skincolors[i].name; + Color_cons_t[i].value = i; + Color_cons_t[i].strvalue = skincolors[i].name; } - Followercolor_cons_t[MAXSKINCOLORS].value = MAXSKINCOLORS; - Followercolor_cons_t[MAXSKINCOLORS].strvalue = "Match"; // Add "Match" option, which will make the follower color match the player's + for (i = 2; i < MAXSKINCOLORS; i++) + { + Followercolor_cons_t[i].value = i-2; + Followercolor_cons_t[i].strvalue = skincolors[i-2].name; + } - Followercolor_cons_t[MAXSKINCOLORS+1].value = MAXSKINCOLORS+1; - Followercolor_cons_t[MAXSKINCOLORS+1].strvalue = "Opposite"; // Add "Opposite" option, ...which is like "Match", but for coloropposite. + Followercolor_cons_t[1].value = -1; + Followercolor_cons_t[1].strvalue = "Match"; // Add "Match" option, which will make the follower color match the player's + + Followercolor_cons_t[0].value = -2; + Followercolor_cons_t[0].strvalue = "Opposite"; // Add "Opposite" option, ...which is like "Match", but for coloropposite. Color_cons_t[MAXSKINCOLORS].value = Followercolor_cons_t[MAXSKINCOLORS+2].value = 0; Color_cons_t[MAXSKINCOLORS].strvalue = Followercolor_cons_t[MAXSKINCOLORS+2].strvalue = NULL; diff --git a/src/p_user.c b/src/p_user.c index a8523bdf6..bbc28a504 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3804,7 +3804,7 @@ static void P_HandleFollower(player_t *player) angle_t an; fixed_t zoffs; fixed_t sx, sy, sz; - UINT16 color; + INT16 color; fixed_t bubble; // bubble scale (0 if no bubble) mobj_t *bmobj; // temp bubble mobj @@ -3851,19 +3851,18 @@ static void P_HandleFollower(player_t *player) } // Set follower colour - switch (player->followercolor) { - case MAXSKINCOLORS: // "Match" + case 255: // "Match" (-1) color = player->skincolor; break; - case MAXSKINCOLORS+1: // "Opposite" + case 254: // "Opposite" (-2) color = skincolors[player->skincolor].invcolor; break; default: color = player->followercolor; - if (!color || color > MAXSKINCOLORS+2) // Make sure this isn't garbage + if (color < -2 || !color || color > MAXSKINCOLORS+2) // Make sure this isn't garbage color = player->skincolor; // "Match" as fallback. break; From 647dfd98fbe78cddf6830c5e1d3c77f7c0889e11 Mon Sep 17 00:00:00 2001 From: SinnamonLat Date: Thu, 2 Sep 2021 13:40:57 +0200 Subject: [PATCH 007/156] forgot to change something back --- src/p_user.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/p_user.c b/src/p_user.c index bbc28a504..f748a04bb 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -3804,7 +3804,7 @@ static void P_HandleFollower(player_t *player) angle_t an; fixed_t zoffs; fixed_t sx, sy, sz; - INT16 color; + UINT16 color; fixed_t bubble; // bubble scale (0 if no bubble) mobj_t *bmobj; // temp bubble mobj @@ -3862,7 +3862,7 @@ static void P_HandleFollower(player_t *player) default: color = player->followercolor; - if (color < -2 || !color || color > MAXSKINCOLORS+2) // Make sure this isn't garbage + if (!color || color > MAXSKINCOLORS+2) // Make sure this isn't garbage color = player->skincolor; // "Match" as fallback. break; From 8ce5dc69ff69e71244233c3a56b264d5a0a8c60e Mon Sep 17 00:00:00 2001 From: lachablock Date: Fri, 10 Sep 2021 10:28:20 +1000 Subject: [PATCH 008/156] Add SegaSonic Arcade sounds --- src/sounds.c | 132 +++++++++++++++++++++++++++++++++++++++++++++++++++ src/sounds.h | 132 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 264 insertions(+) diff --git a/src/sounds.c b/src/sounds.c index b46e11ba1..e9a13da77 100644 --- a/src/sounds.c +++ b/src/sounds.c @@ -908,6 +908,138 @@ sfxinfo_t S_sfx[NUMSFX] = {"mbv96", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, {"mbv97", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + // SegaSonic Arcade sounds + {"ssa001", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa002", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa003", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa004", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa005", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa006", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa007", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa008", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa009", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa010", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa011", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa012", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa013", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa014", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa015", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa016", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa017", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa018", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa019", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa020", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa021", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa022", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa023", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa024", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa025", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa026", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa027", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa028", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa029", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa030", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa031", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa032", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa033", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa034", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa035", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa036", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa037", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa038", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa039", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa040", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa041", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa042", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa043", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa044", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa045", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa046", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa047", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa048", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa049", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa050", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa051", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa052", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa053", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa054", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa055", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa056", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa057", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa058", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa059", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa060", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa061", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa062", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa063", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa064", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa065", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa066", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa067", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa068", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa069", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa070", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa071", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa072", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa073", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa074", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa075", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa076", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa077", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa078", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa079", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa080", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa081", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa082", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa083", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa084", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa085", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa086", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa087", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa088", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa089", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa090", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa091", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa092", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa093", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa094", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa095", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa096", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa097", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa098", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa099", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa100", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa101", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa102", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa103", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa104", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa105", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa106", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa107", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa108", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa109", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa110", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa111", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa112", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa113", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa114", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa115", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa116", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa117", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa118", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa119", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa120", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa121", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa122", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa123", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa124", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa125", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa126", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa127", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa128", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa129", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + {"ssa130", false, 64, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, + // SRB2kart {"slip", false, 96, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, // Spinout {"screec", false, 48, 0, -1, NULL, 0, -1, -1, LUMPERROR, ""}, // Tight turning screech diff --git a/src/sounds.h b/src/sounds.h index 8d81aae20..9abf99117 100644 --- a/src/sounds.h +++ b/src/sounds.h @@ -972,6 +972,138 @@ typedef enum sfx_mbv96, sfx_mbv97, + // SegaSonic Arcade sounds + sfx_ssa001, + sfx_ssa002, + sfx_ssa003, + sfx_ssa004, + sfx_ssa005, + sfx_ssa006, + sfx_ssa007, + sfx_ssa008, + sfx_ssa009, + sfx_ssa010, + sfx_ssa011, + sfx_ssa012, + sfx_ssa013, + sfx_ssa014, + sfx_ssa015, + sfx_ssa016, + sfx_ssa017, + sfx_ssa018, + sfx_ssa019, + sfx_ssa020, + sfx_ssa021, + sfx_ssa022, + sfx_ssa023, + sfx_ssa024, + sfx_ssa025, + sfx_ssa026, + sfx_ssa027, + sfx_ssa028, + sfx_ssa029, + sfx_ssa030, + sfx_ssa031, + sfx_ssa032, + sfx_ssa033, + sfx_ssa034, + sfx_ssa035, + sfx_ssa036, + sfx_ssa037, + sfx_ssa038, + sfx_ssa039, + sfx_ssa040, + sfx_ssa041, + sfx_ssa042, + sfx_ssa043, + sfx_ssa044, + sfx_ssa045, + sfx_ssa046, + sfx_ssa047, + sfx_ssa048, + sfx_ssa049, + sfx_ssa050, + sfx_ssa051, + sfx_ssa052, + sfx_ssa053, + sfx_ssa054, + sfx_ssa055, + sfx_ssa056, + sfx_ssa057, + sfx_ssa058, + sfx_ssa059, + sfx_ssa060, + sfx_ssa061, + sfx_ssa062, + sfx_ssa063, + sfx_ssa064, + sfx_ssa065, + sfx_ssa066, + sfx_ssa067, + sfx_ssa068, + sfx_ssa069, + sfx_ssa070, + sfx_ssa071, + sfx_ssa072, + sfx_ssa073, + sfx_ssa074, + sfx_ssa075, + sfx_ssa076, + sfx_ssa077, + sfx_ssa078, + sfx_ssa079, + sfx_ssa080, + sfx_ssa081, + sfx_ssa082, + sfx_ssa083, + sfx_ssa084, + sfx_ssa085, + sfx_ssa086, + sfx_ssa087, + sfx_ssa088, + sfx_ssa089, + sfx_ssa090, + sfx_ssa091, + sfx_ssa092, + sfx_ssa093, + sfx_ssa094, + sfx_ssa095, + sfx_ssa096, + sfx_ssa097, + sfx_ssa098, + sfx_ssa099, + sfx_ssa100, + sfx_ssa101, + sfx_ssa102, + sfx_ssa103, + sfx_ssa104, + sfx_ssa105, + sfx_ssa106, + sfx_ssa107, + sfx_ssa108, + sfx_ssa109, + sfx_ssa110, + sfx_ssa111, + sfx_ssa112, + sfx_ssa113, + sfx_ssa114, + sfx_ssa115, + sfx_ssa116, + sfx_ssa117, + sfx_ssa118, + sfx_ssa119, + sfx_ssa120, + sfx_ssa121, + sfx_ssa122, + sfx_ssa123, + sfx_ssa124, + sfx_ssa125, + sfx_ssa126, + sfx_ssa127, + sfx_ssa128, + sfx_ssa129, + sfx_ssa130, + // SRB2kart sfx_slip, sfx_screec, From 303df77b68110cf3653f4379315d0c0b4781a012 Mon Sep 17 00:00:00 2001 From: toaster Date: Sun, 17 Oct 2021 21:52:37 +0100 Subject: [PATCH 009/156] Unassigned variable fix (probably going to rip out the closed caption system out of Kart at some point, but this is good for now). --- src/s_sound.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/s_sound.c b/src/s_sound.c index 71e97c27b..c4af37082 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -678,9 +678,6 @@ void S_StartSoundAtVolume(const void *origin_p, sfxenum_t sfx_id, INT32 volume) sep = (~sep) & 255; } - // Handle closed caption input. - S_StartCaption(actual_id, cnum, MAXCAPTIONTICS); - // At this point it is determined that a sound can and should be played, so find a free channel to play it on cnum = S_getChannel(origin, sfx); @@ -689,6 +686,9 @@ void S_StartSoundAtVolume(const void *origin_p, sfxenum_t sfx_id, INT32 volume) return; // If there's no free channels, there won't be any for anymore players either } + // Handle closed caption input. + S_StartCaption(actual_id, cnum, MAXCAPTIONTICS); + // Now that we know we are going to play a sound, fill out this info channels[cnum].sfxinfo = sfx; channels[cnum].origin = origin; From a43b64cb7635054903c21794127d3177dd910321 Mon Sep 17 00:00:00 2001 From: toaster Date: Sun, 17 Oct 2021 22:14:42 +0100 Subject: [PATCH 010/156] Tumble nerfing, on Oni's request. - Maximum tumble height that leads into last bounce is now 60 mfu (mobjscaled fracunits), from 40 mfu. - All tumbles that are over 100 mfu high have extra attenuation applied to them. - Tumble into lightsnake now puts you in 1.5 seconds of wipeout, rather than the last tumble. --- src/k_kart.c | 4 ++-- src/k_respawn.c | 9 ++++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 7074fe42a..e6c066939 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -3215,14 +3215,14 @@ void K_TumblePlayer(player_t *player, mobj_t *inflictor, mobj_t *source) static boolean K_LastTumbleBounceCondition(player_t *player) { - return (player->tumbleBounces > TUMBLEBOUNCES && player->tumbleHeight < 40); + return (player->tumbleBounces > TUMBLEBOUNCES && player->tumbleHeight < 60); } static void K_HandleTumbleBounce(player_t *player) { fixed_t gravityadjust; player->tumbleBounces++; - player->tumbleHeight = (player->tumbleHeight * 4) / 5; + player->tumbleHeight = (player->tumbleHeight * ((player->tumbleHeight > 100) ? 3 : 4)) / 5; player->pflags &= ~PF_TUMBLESOUND; if (player->tumbleHeight < 10) diff --git a/src/k_respawn.c b/src/k_respawn.c index fcce1b632..f09358dcc 100644 --- a/src/k_respawn.c +++ b/src/k_respawn.c @@ -155,9 +155,12 @@ void K_DoIngameRespawn(player_t *player) // If player was tumbling, set variables so that they don't tumble like crazy after they're done respawning if (player->tumbleBounces > 0) { - player->tumbleBounces = TUMBLEBOUNCES-1; // Max # of bounces-1 (so you still tumble once) - player->pflags &= ~PF_TUMBLELASTBOUNCE; // Still force them to bounce at least once for the funny - players->tumbleHeight = 20; // force tumble height + player->tumbleBounces = 0; // MAXBOUNCES-1; + player->pflags &= ~PF_TUMBLELASTBOUNCE; + //players->tumbleHeight = 20; + players->mo->rollangle = 0; + player->spinouttype = KSPIN_WIPEOUT; + player->spinouttimer = player->wipeoutslow = (3*TICRATE/2)+2; } P_ResetPlayer(player); From 42629264b1fd58b8694fb535f2ae9473ce5a7ce5 Mon Sep 17 00:00:00 2001 From: toaster Date: Sun, 17 Oct 2021 22:18:04 +0100 Subject: [PATCH 011/156] Extra comment just in case someone else tries to perform maintenance on tumble and gets confused like I did. --- src/d_player.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/d_player.h b/src/d_player.h index 3bd99cecb..ec4bb1b63 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -375,7 +375,7 @@ typedef struct player_s UINT8 wipeoutslow; // Timer before you slowdown when getting wiped out UINT8 justbumped; // Prevent players from endlessly bumping into each other UINT8 tumbleBounces; - UINT16 tumbleHeight; + UINT16 tumbleHeight; // In *mobjscaled* fracunits, or mfu, not raw fu SINT8 drift; // (-5 to 5) - Drifting Left or Right, plus a bigger counter = sharper turn fixed_t driftcharge; // Charge your drift so you can release a burst of speed From dc8b5fb80364640b0938ec93baeb550d551ba622 Mon Sep 17 00:00:00 2001 From: RJPFonseca Date: Sun, 9 May 2021 19:10:53 +0100 Subject: [PATCH 012/156] Used spaces instead of tabs in Makefile.cfg (cherry picked from commit 69647eb78d36c0b2f5febecd2c4e55f622325217) --- src/Makefile.cfg | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Makefile.cfg b/src/Makefile.cfg index a4fef3c3e..e9bdcfbde 100644 --- a/src/Makefile.cfg +++ b/src/Makefile.cfg @@ -61,10 +61,10 @@ ifeq (,$(filter GCC% CLEANONLY,$(.VARIABLES))) # If this version is not in the list, default to the latest supported ifeq (,$(filter $(v),$(SUPPORTED_GCC_VERSIONS))) - define line = + define line = Your compiler version, GCC $(version), is not supported by the Makefile. The Makefile will assume GCC $(LATEST_GCC_VERSION).)) - endef + endef $(call print,$(line)) GCC$(subst .,,$(LATEST_GCC_VERSION))=1 else From d22705727b0dfac76e8b7e8289e6b97e393a36b3 Mon Sep 17 00:00:00 2001 From: James R Date: Mon, 8 Nov 2021 16:59:57 -0800 Subject: [PATCH 013/156] Fix unsigned comparison with zero --- src/k_kart.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/k_kart.c b/src/k_kart.c index e6c066939..042efc179 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -696,7 +696,7 @@ INT32 K_KartGetItemOdds( } else { - const INT32 distFromStart = max(0, secondToFirst - SPBSTARTDIST); + const INT32 distFromStart = max(0, (INT32)secondToFirst - SPBSTARTDIST); const INT32 distRange = SPBFORCEDIST - SPBSTARTDIST; const INT32 mulMax = 3; From e82bba18f6925c3710aaa646cd220cb0b25dee39 Mon Sep 17 00:00:00 2001 From: James R Date: Mon, 8 Nov 2021 18:50:19 -0800 Subject: [PATCH 014/156] Use volume field of sound, access with SOC/lua Volumes may be defined on a 0-100 scale, but any number is accepted. If the volume is negative then the sound will play at normal volume (therefore the info table won't need to be modified.) --- src/deh_soc.c | 4 ++++ src/lua_infolib.c | 13 +++++++++++++ src/s_sound.c | 12 ++++++++++-- src/s_sound.h | 2 ++ 4 files changed, 29 insertions(+), 2 deletions(-) diff --git a/src/deh_soc.c b/src/deh_soc.c index 7b5318f2b..4ab4a29aa 100644 --- a/src/deh_soc.c +++ b/src/deh_soc.c @@ -2683,6 +2683,10 @@ void readsound(MYFILE *f, INT32 num) { S_sfx[num].pitch = value; } + else if (fastcmp(word, "VOLUME")) + { + S_sfx[num].volume = value; + } else if (fastcmp(word, "CAPTION") || fastcmp(word, "DESCRIPTION")) { deh_strlcpy(S_sfx[num].caption, word2, diff --git a/src/lua_infolib.c b/src/lua_infolib.c index bbf640b85..880496770 100644 --- a/src/lua_infolib.c +++ b/src/lua_infolib.c @@ -41,6 +41,7 @@ enum sfxinfo_read { sfxinfor_singular, sfxinfor_priority, sfxinfor_flags, // "pitch" + sfxinfor_volume, sfxinfor_caption, sfxinfor_skinsound }; @@ -49,6 +50,7 @@ const char *const sfxinfo_ropt[] = { "singular", "priority", "flags", + "volume", "caption", "skinsound", NULL}; @@ -57,12 +59,14 @@ enum sfxinfo_write { sfxinfow_singular = 0, sfxinfow_priority, sfxinfow_flags, // "pitch" + sfxinfow_volume, sfxinfow_caption }; const char *const sfxinfo_wopt[] = { "singular", "priority", "flags", + "volume", "caption", NULL}; @@ -1328,6 +1332,9 @@ static int lib_setSfxInfo(lua_State *L) case sfxinfow_flags: info->pitch = (INT32)luaL_checkinteger(L, 3); break; + case sfxinfow_volume: + info->volume = (INT32)luaL_checkinteger(L, 3); + break; case sfxinfow_caption: strlcpy(info->caption, luaL_checkstring(L, 3), sizeof(info->caption)); break; @@ -1368,6 +1375,9 @@ static int sfxinfo_get(lua_State *L) case sfxinfor_flags: lua_pushinteger(L, sfx->pitch); return 1; + case sfxinfor_volume: + lua_pushinteger(L, sfx->volume); + return 1; case sfxinfor_caption: lua_pushstring(L, sfx->caption); return 1; @@ -1408,6 +1418,9 @@ static int sfxinfo_set(lua_State *L) case sfxinfow_flags: sfx->pitch = luaL_checkinteger(L, 1); break; + case sfxinfow_volume: + sfx->volume = luaL_checkinteger(L, 1); + break; case sfxinfow_caption: strlcpy(sfx->caption, luaL_checkstring(L, 1), sizeof(sfx->caption)); break; diff --git a/src/s_sound.c b/src/s_sound.c index c4af37082..d4a63b59e 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -693,7 +693,7 @@ void S_StartSoundAtVolume(const void *origin_p, sfxenum_t sfx_id, INT32 volume) channels[cnum].sfxinfo = sfx; channels[cnum].origin = origin; channels[cnum].volume = initial_volume; - channels[cnum].handle = I_StartSound(sfx_id, volume, sep, pitch, priority, cnum); + channels[cnum].handle = I_StartSound(sfx_id, S_GetSoundVolume(sfx, volume), sep, pitch, priority, cnum); } } @@ -899,7 +899,7 @@ void S_UpdateSounds(void) } if (audible) - I_UpdateSoundParams(c->handle, volume, sep, pitch); + I_UpdateSoundParams(c->handle, S_GetSoundVolume(c->sfxinfo, volume), sep, pitch); else S_StopChannel(cnum); } @@ -1011,6 +1011,14 @@ fixed_t S_CalculateSoundDistance(fixed_t sx1, fixed_t sy1, fixed_t sz1, fixed_t return FixedDiv(approx_dist, mapobjectscale); // approx_dist } +INT32 S_GetSoundVolume(sfxinfo_t *sfx, INT32 volume) +{ + if (sfx->volume < 0) + return volume; + else + return volume * sfx->volume / 100; +} + // // Changes volume, stereo-separation, and pitch variables // from the norm of a sound effect to be played. diff --git a/src/s_sound.h b/src/s_sound.h index 80a53fb3e..816a90fb5 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -295,6 +295,8 @@ void S_UpdateClosedCaptions(void); FUNCMATH fixed_t S_CalculateSoundDistance(fixed_t px1, fixed_t py1, fixed_t pz1, fixed_t px2, fixed_t py2, fixed_t pz2); +INT32 S_GetSoundVolume(sfxinfo_t *sfx, INT32 volume); + void S_SetSfxVolume(INT32 volume); void S_SetMusicVolume(INT32 digvolume); #define S_SetDigMusicVolume S_SetMusicVolume From fa8bffabfc51ea1d7be86d833190bb7dcf494fca Mon Sep 17 00:00:00 2001 From: toaster Date: Sun, 21 Nov 2021 13:35:08 +0000 Subject: [PATCH 015/156] Have replay recording of "hits" use the reference count system, so that it doesn't potentially access free'd memory. (This is not THE replay fix, but it is A replay fix.) --- src/g_demo.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/g_demo.c b/src/g_demo.c index a30d78878..16ca2a859 100644 --- a/src/g_demo.c +++ b/src/g_demo.c @@ -621,7 +621,7 @@ void G_GhostAddHit(INT32 playernum, mobj_t *victim) ghostext[playernum].flags |= EZT_HIT; ghostext[playernum].hits++; ghostext[playernum].hitlist = Z_Realloc(ghostext[playernum].hitlist, ghostext[playernum].hits * sizeof(mobj_t *), PU_LEVEL, NULL); - ghostext[playernum].hitlist[ghostext[playernum].hits-1] = victim; + P_SetTarget(ghostext[playernum].hitlist + (ghostext[playernum].hits-1), victim); } void G_WriteAllGhostTics(void) @@ -793,6 +793,7 @@ void G_WriteGhostTic(mobj_t *ghost, INT32 playernum) WRITEFIXED(demo_p,mo->y); WRITEFIXED(demo_p,mo->z); WRITEANGLE(demo_p,mo->angle); + P_SetTarget(ghostext[playernum].hitlist+i, NULL); } Z_Free(ghostext[playernum].hitlist); ghostext[playernum].hits = 0; From 6ad177cb42b3849f510d73ff7c480a13fa965d8c Mon Sep 17 00:00:00 2001 From: toaster Date: Sun, 21 Nov 2021 21:39:43 +0000 Subject: [PATCH 016/156] Gainax eyesparkle (surprisingly, not a name for a pony...) * Hold lookback to create a tiny twinkle in your eye. * If an opponent is behind you, that sparkle is pretty big and plays a cool animation. * If an opponent is behind you and you have an item, initiate the Chengi Gleam. * These sparkles are only visible for every player except you. (Currently even with hyuu ghostliness) --- src/d_player.h | 2 +- src/deh_tables.c | 8 +++++++- src/info.c | 32 ++++++++++++++++++++++++++++++++ src/info.h | 7 +++++++ src/k_kart.c | 25 ++++++++++++++++++++++++- src/p_inter.c | 2 ++ src/p_mobj.c | 46 +++++++++++++++++++++++++++++++++++++++++++++- src/p_user.c | 16 +++++----------- 8 files changed, 123 insertions(+), 15 deletions(-) diff --git a/src/d_player.h b/src/d_player.h index ec4bb1b63..4701a019d 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -62,7 +62,7 @@ typedef enum PF_ATTACKDOWN = 1, PF_ACCELDOWN = 1<<1, PF_BRAKEDOWN = 1<<2, - PF_WPNDOWN = 1<<3, // reserved - gonna turn this into lookback when i'm done with all the major reengineering + PF_LOOKDOWN = 1<<3, // Accessibility and cheats PF_KICKSTARTACCEL = 1<<4, // Is accelerate in kickstart mode? diff --git a/src/deh_tables.c b/src/deh_tables.c index a97d56865..3f5a56d27 100644 --- a/src/deh_tables.c +++ b/src/deh_tables.c @@ -4593,6 +4593,11 @@ const char *const STATE_LIST[] = { // array length left dynamic for sanity testi "S_RINGSPARKS14", "S_RINGSPARKS15", + "S_GAINAX_TINY", + "S_GAINAX_HUGE", + "S_GAINAX_MID1", + "S_GAINAX_MID2", + "S_DRAFTDUST1", "S_DRAFTDUST2", "S_DRAFTDUST3", @@ -5730,6 +5735,7 @@ const char *const MOBJTYPE_LIST[] = { // array length left dynamic for sanity t "MT_KARMAFIREWORK", "MT_RINGSPARKS", + "MT_GAINAX", "MT_DRAFTDUST", "MT_SPBDUST", "MT_TIREGREASE", @@ -5852,7 +5858,7 @@ const char *const PLAYERFLAG_LIST[] = { "ATTACKDOWN", "ACCELDOWN", "BRAKEDOWN", - "WPNDOWN", // reserved - gonna turn this into lookback when i'm done with all the major reengineering + "LOOKDOWN", // Accessibility and cheats "KICKSTARTACCEL", // Is accelerate in kickstart mode? diff --git a/src/info.c b/src/info.c index 7f2e06f56..e333de1b0 100644 --- a/src/info.c +++ b/src/info.c @@ -727,6 +727,7 @@ char sprnames[NUMSPRITES + 1][5] = "FWRK", "MXCL", "RGSP", + "LENS", "DRAF", "GRES", @@ -5178,6 +5179,11 @@ state_t states[NUMSTATES] = {SPR_RGSP, FF_PAPERSPRITE|FF_FULLBRIGHT|13, 1, {NULL}, 0, 0, S_RINGSPARKS15}, // S_RINGSPARKS14 {SPR_RGSP, FF_PAPERSPRITE|FF_FULLBRIGHT|14, 1, {NULL}, 0, 0, S_NULL}, // S_RINGSPARKS15 + {SPR_LENS, FF_FULLBRIGHT|FF_ADD|FF_TRANS10|FF_ANIMATE|11, -1, {NULL}, 3, 1, S_NULL}, // S_GAINAX_TINY + {SPR_LENS, FF_FULLBRIGHT|FF_ADD|FF_TRANS10|FF_ANIMATE, 5, {NULL}, 5, 1, S_GAINAX_MID1}, // S_GAINAX_HUGE + {SPR_LENS, FF_FULLBRIGHT|FF_ADD|FF_TRANS10|FF_ANIMATE|5, 14, {NULL}, 14, 1, S_GAINAX_MID2}, // S_GAINAX_MID1 + {SPR_LENS, FF_FULLBRIGHT|FF_ADD|FF_TRANS10|FF_ANIMATE|19, -1, {NULL}, 1, 1, S_NULL}, // S_GAINAX_MID2 + {SPR_DRAF, 0, 2, {NULL}, 0, 0, S_DRAFTDUST2}, // S_DRAFTDUST1 {SPR_DRAF, 1, 1, {NULL}, 0, 0, S_DRAFTDUST3}, // S_DRAFTDUST2 {SPR_DRAF, 2, 1, {NULL}, 0, 0, S_DRAFTDUST4}, // S_DRAFTDUST3 @@ -28683,6 +28689,32 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = MF_NOBLOCKMAP|MF_NOGRAVITY|MF_DONTENCOREMAP, // flags S_NULL // raisestate }, + { // MT_GAINAX + -1, // doomednum + S_INVISIBLE, // spawnstate + 1000, // spawnhealth + S_NULL, // seestate + sfx_None, // seesound + 8, // reactiontime + sfx_None, // attacksound + S_NULL, // painstate + 0, // painchance + sfx_None, // painsound + S_NULL, // meleestate + S_NULL, // missilestate + S_NULL, // deathstate + S_NULL, // xdeathstate + sfx_None, // deathsound + 0, // speed + 8<pflags &= ~PF_LOOKDOWN; + } + else if (drift == 0) { // Prioritize looking back frames over turning turndir = 0; @@ -2218,6 +2222,7 @@ void K_KartMoveAnimation(player_t *player) destGlanceDir = -(2*intsign(player->aizdriftturn)); player->glanceDir = destGlanceDir; drift = turndir = 0; + player->pflags &= ~PF_LOOKDOWN; } else if (player->aizdriftturn) { @@ -2232,6 +2237,7 @@ void K_KartMoveAnimation(player_t *player) if (lookback == true) { + statenum_t gainaxstate = S_GAINAX_TINY; if (destGlanceDir == 0) { if (player->glanceDir != 0) @@ -2256,6 +2262,20 @@ void K_KartMoveAnimation(player_t *player) { // Looking back AND glancing? Amplify the look! destGlanceDir *= 2; + if (player->itemamount && player->itemtype) + gainaxstate = S_GAINAX_HUGE; + else + gainaxstate = S_GAINAX_MID1; + } + + if (destGlanceDir && !(player->pflags & PF_LOOKDOWN)) + { + mobj_t *gainax = P_SpawnMobjFromMobj(player->mo, 0, 0, 0, MT_GAINAX); + gainax->movedir = (destGlanceDir < 0) ? (ANGLE_270-ANG10) : (ANGLE_90+ANG10); + P_SetTarget(&gainax->target, player->mo); + P_SetMobjState(gainax, gainaxstate); + gainax->flags2 |= MF2_AMBUSH; + player->pflags |= PF_LOOKDOWN; } } else if (K_GetForwardMove(player) < 0 && destGlanceDir == 0) @@ -2511,6 +2531,9 @@ void K_KartMoveAnimation(player_t *player) player->glanceDir++; } + if (!player->glanceDir) + player->pflags &= ~PF_LOOKDOWN; + // Update lastspeed value -- we use to display slow driving frames instead of fast driving when slowing down. player->lastspeed = player->speed; } diff --git a/src/p_inter.c b/src/p_inter.c index 968357096..e0ba88296 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -1996,6 +1996,8 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da player->sneakertimer = player->numsneakers = 0; player->driftboost = player->strongdriftboost = 0; player->ringboost = 0; + player->glanceDir = 0; + player->pflags &= ~PF_LOOKDOWN; switch (type) { diff --git a/src/p_mobj.c b/src/p_mobj.c index 91f8c9403..34b48dc9c 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -6783,7 +6783,51 @@ static boolean P_MobjRegularThink(mobj_t *mobj) P_TeleportMove(mobj, mobj->target->x + FINECOSINE(mobj->angle >> ANGLETOFINESHIFT), mobj->target->y + FINESINE(mobj->angle >> ANGLETOFINESHIFT), - mobj->z + mobj->target->height * P_MobjFlip(mobj)); + mobj->z + (mobj->target->height * P_MobjFlip(mobj))); + break; + case MT_GAINAX: + if (!mobj->target || P_MobjWasRemoved(mobj->target) // sanity + || !mobj->target->player // ditto + || !mobj->target->player->glanceDir // still glancing? + || mobj->target->player->aizdriftturn // only other circumstance where can glance + || ((K_GetKartButtons(mobj->target->player) & BT_LOOKBACK) != BT_LOOKBACK)) // it's a lookback indicator... + { + P_RemoveMobj(mobj); + return false; + } + + mobj->angle = mobj->target->player->drawangle; + mobj->z = mobj->target->z; + + K_MatchGenericExtraFlags(mobj, mobj->target); + mobj->renderflags = (mobj->renderflags & ~RF_DONTDRAW)|K_GetPlayerDontDrawFlag(mobj->target->player); + + P_TeleportMove(mobj, mobj->target->x + FixedMul(34 * mapobjectscale, FINECOSINE((mobj->angle + mobj->movedir) >> ANGLETOFINESHIFT)), + mobj->target->y + FixedMul(34 * mapobjectscale, FINESINE((mobj->angle + mobj->movedir) >> ANGLETOFINESHIFT)), + mobj->z + (32 * mapobjectscale * P_MobjFlip(mobj))); + + { + statenum_t gainaxstate = mobj->state-states; + if (gainaxstate == S_GAINAX_TINY) + { + if (abs(mobj->target->player->glanceDir) > 1) + { + if (mobj->target->player->itemamount && mobj->target->player->itemtype) + gainaxstate = S_GAINAX_HUGE; + else + gainaxstate = S_GAINAX_MID1; + P_SetMobjState(mobj, gainaxstate); + } + } + else if (abs(mobj->target->player->glanceDir) <= 1) + { + if (mobj->flags2 & MF2_AMBUSH) + mobj->flags2 &= ~MF2_AMBUSH; + else + P_SetMobjState(mobj, S_GAINAX_TINY); + } + } + break; case MT_FLAMESHIELDPAPER: if (!mobj->target || P_MobjWasRemoved(mobj->target)) diff --git a/src/p_user.c b/src/p_user.c index d577faab2..23f67e531 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -467,6 +467,7 @@ void P_ResetPlayer(player_t *player) //player->drift = player->driftcharge = 0; player->trickpanel = 0; + player->glanceDir = 0; } // @@ -2003,6 +2004,8 @@ void P_MovePlayer(player_t *player) P_SetPlayerMobjState(player->mo, S_KART_SPINOUT); player->drawangle -= ANGLE_22h; player->mo->rollangle = 0; + player->glanceDir = 0; + player->pflags &= ~PF_LOOKDOWN; } else if ((player->pflags & PF_FAULT) || (player->spinouttimer > 0)) { @@ -2021,17 +2024,6 @@ void P_MovePlayer(player_t *player) player->mo->rollangle = 0; } - /*else if (player->pflags & PF_FAULT) -- v1 fault - { - P_SetPlayerMobjState(player->mo, S_KART_SPINOUT); - - if (((player->nocontrol + 5) % 20) < 10) - player->drawangle += ANGLE_11hh; - else - player->drawangle -= ANGLE_11hh; - - player->mo->rollangle = 0; - }*/ else { K_KartMoveAnimation(player); @@ -4406,6 +4398,8 @@ void P_PlayerThink(player_t *player) else player->pflags &= ~PF_BRAKEDOWN; + // PF_LOOKDOWN handled in K_KartMoveAnimation + // Counters, time dependent power ups. // Time Bonus & Ring Bonus count settings From f205d6d8fd296e429a479f19e816a359aa192858 Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 21 Nov 2021 22:02:45 -0800 Subject: [PATCH 017/156] Speed up lightsnaking if dying with airtime --- src/d_player.h | 1 + src/k_respawn.c | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/d_player.h b/src/d_player.h index ec4bb1b63..d09aa408e 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -263,6 +263,7 @@ typedef struct respawnvars_s fixed_t pointz; boolean flip; // Flip upside down or not tic_t timer; // Time left on respawn animation once you're there + tic_t airtimer; // Time spent in the air before respawning UINT32 distanceleft; // How far along the course to respawn you tic_t dropdash; // Drop Dash charge timer } respawnvars_t; diff --git a/src/k_respawn.c b/src/k_respawn.c index f09358dcc..2e93a57d8 100644 --- a/src/k_respawn.c +++ b/src/k_respawn.c @@ -276,6 +276,8 @@ void K_DoIngameRespawn(player_t *player) player->respawn.timer = RESPAWN_TIME; player->respawn.state = RESPAWNST_MOVE; + + player->respawn.airtimer = player->airtime; } /*-------------------------------------------------- @@ -318,8 +320,9 @@ size_t K_NextRespawnWaypointIndex(waypoint_t *waypoint) --------------------------------------------------*/ static void K_MovePlayerToRespawnPoint(player_t *player) { - const fixed_t realstepamt = (64 * mapobjectscale); - fixed_t stepamt = realstepamt; + const int airCompensation = 128; + fixed_t realstepamt = (64 * mapobjectscale); + fixed_t stepamt; vector3_t dest, step, laser; angle_t stepha, stepva; @@ -330,6 +333,13 @@ static void K_MovePlayerToRespawnPoint(player_t *player) waypoint_t *laserwp; boolean laserflip; + /* speed up if in the air for a long time */ + realstepamt += FixedMul(realstepamt, + (player->respawn.airtimer * FRACUNIT) + / airCompensation); + + stepamt = realstepamt; + player->mo->momx = player->mo->momy = player->mo->momz = 0; player->flashing = 2; From 239e91c439e34a9f7769fdb8826fa1845d1613e1 Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 21 Nov 2021 22:15:11 -0800 Subject: [PATCH 018/156] Do not tilt while respawning; speed up camera (snappier) --- src/p_user.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/p_user.c b/src/p_user.c index d577faab2..728ce31a6 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -2974,6 +2974,10 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall else lookbackdelay[num]--; } + else if (player->respawn.state != RESPAWNST_NONE) + { + camspeed = 3*FRACUNIT/4; + } lookbackdown = (lookbackdelay[num] == MAXLOOKBACKDELAY) != lookbackactive[num]; lookbackactive[num] = (lookbackdelay[num] == MAXLOOKBACKDELAY); #undef MAXLOOKBACKDELAY @@ -4098,6 +4102,12 @@ DoABarrelRoll (player_t *player) fixed_t smoothing; + if (player->respawn.state != RESPAWNST_NONE) + { + player->tilt = 0; + return; + } + if (player->exiting) { return; From d5c08ac034ca360631022783d67e9b8ebfcb1369 Mon Sep 17 00:00:00 2001 From: James R Date: Thu, 25 Nov 2021 02:09:01 -0800 Subject: [PATCH 019/156] Backport 2021 SRB2 makefile overhaul This is a squashed commit of the following commits from upstream: James R on 2021-05-01 Commit 44d217807f71d15bd7ca69dad226458e7060ccab > Collect makefiles James R on 2021-05-04 Commit f637e28d0c1877c44acd7b01f7130625d5ea4099 > Remove bin, objs and dep directories James R on 2021-05-02 Commit b31056c7d977fe3c2a5e0637589fd9521f1f6c04 > Rewrite Makefile to be modular as well as more automated > > Some key points for programmers: > - Source code files are mostly listed in a 'Sourcefile'. > So you no longer directly edit the object list. There > can be multiple Sourcefiles and they can even live in > subdirectories--the directory name will be prepended to > every filename in the list. Of course, the Makefile > still needs to be edited to read from each Sourcefile. > - Different rules are no longer required for source code > files that live in subdirectories (such as sdl/ or > hardware/). Subdirectories Just Work so go ham! > > In addition to those points, another important change is > that the bin directory is no longer divided into platform > subdirectories (Linux64, Mingw, etc). Executables now go > directly into bin. If you use DEBUGMODE or target 64-bit, > then subdirectories for 'debug' and '64' will be made > though. > > Oh by the way, I don't think make clean actually removed > files before on Windows. It should now. I also fixed as > many little inconsistencies like that as I noticed. > > And now just an overview of the technical aspects that > shouldn't affect anyone who doesn't REALLY care about the > Makefile... > > objs and dep directories have been moved to a make > directory. Makefile.cfg and its variants have been moved > out of their various subdirectories to src/Makefile.d > make distclean removes the bin and make directories > entirely, but make clean and cleandep still only affect > the current build target. > > When I say automation, I mean that a lot of copy pasting > in the Makefile has been reduced. James R on 2021-05-04 Commit 53d1cbe8264196e46911c86bc4be13d44aa35dfe > Appveyor: update executable directory James R on 2021-05-04 Commit 888073d64d1885cae0ad8b5d54bfec31e9793e0a > Fix make clean printing header James R on 2021-05-04 Commit 3d7205d4942d1e1b2627fdf5acf9d9c82437a97b > Fix minor errors with Windows ECHO, DEL, MD > > - Quotes were not removed by ECHO. > - DEL would print an error on nonexistent file. > - MD would do this plus return a nonzero exit code. James R on 2021-05-05 Commit f9813844e7f0dfa6229062b1ebd83e4e8150c120 > Update CMakeLists.txt to use Sourcefiles > > This establishes (near) parity of source code file lists > between the Makefile and CMakeLists.txt > > To make that change I messed around CMakeLists.txt a bit. > It now uses target_sources and target_compile_definitions. > I also removed some MSVC stuff since we don't actually > care about MSVC--it made things easier. > > CMake minimum version 3.0 -> 3.13 for target_sources. James R on 2021-05-05 Commit ec8b63d6759f0c124693ea6d5a521e8d82efd566 > Makefile: remove last of unused flags James R on 2021-05-07 Commit c06817d0085ee77b0027917bca91a24e60c7deba > Makefile: fix mingw/64 swapped with 32-bit James R on 2021-05-07 Commit 9e7d80c2c44199126fa451c59fca0f98d23ad14d > Makefile: suppress DEL error James R on 2021-05-07 Commit 87afa7655a71539c7cbc7db12df18c4253187fbc > CMake: fix ASM compile > > - target_sources from correct directory > - enable_language must be used in add_executable directory James R on 2021-05-08 Commit 210c9419e4bddd1fe8e9be7cb66de31119fa0d68 > Ignore -Wtrigraphs James R on 2021-06-16 Commit 3a044e71cc7cf6c80d9836189511c1a58c108370 > Disable EXE disassembly and compression by default > > NOOBJDUMP=1 and NOUPX=1 have been removed. Make 'dump' > target to disassemble. UPX=upx to compress executable. > > Setting UPX used to cause it to fail. That has been fixed. James R on 2021-06-16 Commit c142b3241ddb8f1ea9b5090d20dffa43a17129ab > Makefile: alert full path of final executable > > With added textual contrast. James R on 2021-06-16 Commit b04c79d8a7ba4ae8f888ab94d394b6714699e107 > Say 'at' James R on 2021-06-21 Commit 2d7a8c3c571bcc5335437e9db074c75af00408ce > Makefile: use shell commands to read in Sourcefile > > File function is not supported < Make 4.2. James R on 2021-06-21 Commit d5146945a69ebf30e6fc1fbb64558e456e0b7459 > Makefile: don't automatically set WINDOWSHELL unless PATH matches Windows norms > > This is for MSYS2, which requires unix shell commands. James R on 2021-06-22 Commit 5f4d7e3c5b013afe03ae2a441c82ad79bae7c66c > Makefile: fail if old build directories exist > > After a checkout from before revision, old directories > such as bin/Linux64 only remain if untracked files exist > within. This may be confusing to the user. They may even > use an outdated executable if it is one of those untracked > files. James R on 2021-06-22 Commit c3ad5de912fccfdd64c510f5684883afceaa7d36 > Makefile: let variables be defined on Make line > > If a variable is defined as in 'make CC=gcc-10', then that > definition overrides anything other definition in the > Makefile. James R on 2021-06-22 Commit ed85e994a46ace07cf022b38a9abac1698a8667e > Remove misplaced parentheses James R on 2021-06-29 Commit c1ecfa306f6a0b168d4f6cbc3224ebebd4deec51 > Makefile: 'dep' not 'deps' James R on 2021-06-29 Commit 6c03f9b5b3590e01773f05bc1c31cc67a2d88fc2 > fuck James R on 2021-06-29 Commit abdf5c101cbe80657f210c0b90800e2c4c6f0c05 > Makefile: report SHELL James R on 2021-06-29 Commit 22ab611daa17bd23225f3afeeba39147c0d0fe17 > Makefile: do not automatically set WINDOWSHELL > > According to this answer-- > https://stackoverflow.com/a/45952425 > --Make will always prefer a unix shell, even on Windows, > if one can be found in Path. So we can't check PATH to > determine if it's a Windows shell... this is just too much > bother. James R on 2021-06-29 Commit f79e0ee540564fcec5da7c0dc4006906492a7f30 > Appveyor: remove 64-bit target James R on 2021-06-29 Commit faee657572f23cd6f8b68c077873e01c4278414e > Appveyor: update for new Makefile James R on 2021-06-29 Commit 44b82dea58612e6f07830647e2b08555f54a7caa > Appveyor: remove redundant CFLAGS > > Also changed -Wno-error=implicit-fallthrough to > -Wno-implicit-fallthrough. For some reason Appveyor's > version of GCC is triggering these warnings despite the > comments, so just shut it up. James R on 2021-06-29 Commit db919accd22350c087c1fd0e5122d8e490e2f171 > Appveyor: suppress real time file names James R on 2021-07-12 Commit 58fa44e8dc0444eecbe701f31872fad9fa563a6a > CMP0115 SteelT on 2021-07-16 Commit 71f905f95bd4fe62dbca87208cf71b7309f12de1 > Fix gme support being effectively disabled > > I found this easier than trying to adjust the makefile, as it uses the same thing to automatically generate the various NO* compile options. James R on 2021-08-14 Commit 824b1ab28cdddfd1c018454a9af14dabaab49fcd > Makefile: use full stem in dependency generation > > Previously took only the filename, so the directory > component was stripped. This broke dependencies for > basically every file. GoldenTails on 2021-08-28 Commit 1a8ec7975c20e1d652cbbdb7a9e366192e41c05f > Makefile: Improve gcc detection > > Wasn't working for me until I fixed it. > Turns out gcc really doesn't like giving its name out. > Most of the time it reads argv[0]. --- .gitignore | 4 +- CMakeLists.txt | 13 +- appveyor.yml | 32 +- bin/FreeBSD/Debug/.gitignore | 2 - bin/FreeBSD/Release/.gitignore | 2 - bin/Linux/Debug/.gitignore | 1 - bin/Linux/Release/.gitignore | 3 - bin/Linux64/Debug/.gitignore | 1 - bin/Linux64/Release/.gitignore | 1 - bin/Mingw/Debug/.gitignore | 4 - bin/Mingw/Release/.gitignore | 4 - bin/Mingw64/Debug/.gitignore | 3 - bin/Mingw64/Release/.gitignore | 3 - bin/SDL/Debug/.gitignore | 2 - bin/SDL/Release/.gitignore | 2 - bin/VC/.gitignore | 2 - bin/VC9/.gitignore | 2 - bin/dummy/.gitignore | 2 - dep/.gitignore | 2 - dep/FreeBSD/SDL/Debug/.gitignore | 2 - dep/FreeBSD/SDL/Release/.gitignore | 2 - dep/Linux/SDL/Debug/.gitignore | 2 - dep/Linux/SDL/Release/.gitignore | 2 - dep/Linux64/SDL/Debug/.gitignore | 2 - dep/Linux64/SDL/Release/.gitignore | 2 - dep/MasterClient/.gitignore | 2 - dep/MasterServer/.gitignore | 2 - dep/Mingw/Debug/.gitignore | 2 - dep/Mingw/Release/.gitignore | 2 - dep/Mingw/SDL/Debug/.gitignore | 2 - dep/Mingw/SDL/Release/.gitignore | 2 - dep/Mingw64/Debug/.gitignore | 2 - dep/Mingw64/Release/.gitignore | 2 - dep/Mingw64/SDL/Debug/.gitignore | 2 - dep/Mingw64/SDL/Release/.gitignore | 2 - dep/SDL/Release/.gitignore | 2 - dep/VC/.gitignore | 2 - dep/VC9/.gitignore | 2 - dep/cygwin/Debug/.gitignore | 2 - dep/cygwin/Release/.gitignore | 2 - dep/dummy/.gitignore | 2 - objs/.gitignore | 8 - objs/FreeBSD/SDL/Debug/.gitignore | 2 - objs/FreeBSD/SDL/Release/.gitignore | 2 - objs/Linux/SDL/Debug/.gitignore | 2 - objs/Linux/SDL/Release/.gitignore | 2 - objs/Linux64/SDL/Debug/.gitignore | 2 - objs/Linux64/SDL/Release/.gitignore | 2 - objs/MasterClient/.gitignore | 2 - objs/MasterServer/.gitignore | 2 - objs/Mingw/Debug/.gitignore | 2 - objs/Mingw/Release/.gitignore | 2 - objs/Mingw/SDL/Debug/.gitignore | 2 - objs/Mingw/SDL/Release/.gitignore | 2 - objs/Mingw64/Debug/.gitignore | 2 - objs/Mingw64/Release/.gitignore | 2 - objs/Mingw64/SDL/Debug/.gitignore | 2 - objs/Mingw64/SDL/Release/.gitignore | 2 - objs/SDL/Release/.gitignore | 2 - objs/VC/.gitignore | 2 - objs/VC9/.gitignore | 2 - objs/cygwin/Debug/.gitignore | 2 - objs/cygwin/Release/.gitignore | 2 - objs/dummy/.gitignore | 2 - src/CMakeLists.txt | 438 +---------- src/Makefile | 1137 ++++++++------------------- src/Makefile.cfg | 482 ------------ src/Makefile.d/detect.mk | 107 +++ src/Makefile.d/features.mk | 76 ++ src/Makefile.d/nix.mk | 40 + src/Makefile.d/old.mk | 16 + src/Makefile.d/platform.mk | 69 ++ src/Makefile.d/sdl.mk | 79 ++ src/Makefile.d/util.mk | 93 +++ src/Makefile.d/versions.mk | 181 +++++ src/Makefile.d/win32.mk | 99 +++ src/Sourcefile | 87 ++ src/blua/CMakeLists.txt | 1 + src/blua/Makefile.cfg | 53 -- src/blua/Sourcefile | 25 + src/hardware/CMakeLists.txt | 1 + src/hardware/Sourcefile | 13 + src/sdl/CMakeLists.txt | 138 +--- src/sdl/MakeNIX.cfg | 74 -- src/sdl/Makefile.cfg | 125 --- src/sdl/Sourcefile | 7 + src/sdl/mixer_sound.c | 46 +- src/win32/Makefile.cfg | 161 ---- 88 files changed, 1318 insertions(+), 2411 deletions(-) delete mode 100644 bin/FreeBSD/Debug/.gitignore delete mode 100644 bin/FreeBSD/Release/.gitignore delete mode 100644 bin/Linux/Debug/.gitignore delete mode 100644 bin/Linux/Release/.gitignore delete mode 100644 bin/Linux64/Debug/.gitignore delete mode 100644 bin/Linux64/Release/.gitignore delete mode 100644 bin/Mingw/Debug/.gitignore delete mode 100644 bin/Mingw/Release/.gitignore delete mode 100644 bin/Mingw64/Debug/.gitignore delete mode 100644 bin/Mingw64/Release/.gitignore delete mode 100644 bin/SDL/Debug/.gitignore delete mode 100644 bin/SDL/Release/.gitignore delete mode 100644 bin/VC/.gitignore delete mode 100644 bin/VC9/.gitignore delete mode 100644 bin/dummy/.gitignore delete mode 100644 dep/.gitignore delete mode 100644 dep/FreeBSD/SDL/Debug/.gitignore delete mode 100644 dep/FreeBSD/SDL/Release/.gitignore delete mode 100644 dep/Linux/SDL/Debug/.gitignore delete mode 100644 dep/Linux/SDL/Release/.gitignore delete mode 100644 dep/Linux64/SDL/Debug/.gitignore delete mode 100644 dep/Linux64/SDL/Release/.gitignore delete mode 100644 dep/MasterClient/.gitignore delete mode 100644 dep/MasterServer/.gitignore delete mode 100644 dep/Mingw/Debug/.gitignore delete mode 100644 dep/Mingw/Release/.gitignore delete mode 100644 dep/Mingw/SDL/Debug/.gitignore delete mode 100644 dep/Mingw/SDL/Release/.gitignore delete mode 100644 dep/Mingw64/Debug/.gitignore delete mode 100644 dep/Mingw64/Release/.gitignore delete mode 100644 dep/Mingw64/SDL/Debug/.gitignore delete mode 100644 dep/Mingw64/SDL/Release/.gitignore delete mode 100644 dep/SDL/Release/.gitignore delete mode 100644 dep/VC/.gitignore delete mode 100644 dep/VC9/.gitignore delete mode 100644 dep/cygwin/Debug/.gitignore delete mode 100644 dep/cygwin/Release/.gitignore delete mode 100644 dep/dummy/.gitignore delete mode 100644 objs/.gitignore delete mode 100644 objs/FreeBSD/SDL/Debug/.gitignore delete mode 100644 objs/FreeBSD/SDL/Release/.gitignore delete mode 100644 objs/Linux/SDL/Debug/.gitignore delete mode 100644 objs/Linux/SDL/Release/.gitignore delete mode 100644 objs/Linux64/SDL/Debug/.gitignore delete mode 100644 objs/Linux64/SDL/Release/.gitignore delete mode 100644 objs/MasterClient/.gitignore delete mode 100644 objs/MasterServer/.gitignore delete mode 100644 objs/Mingw/Debug/.gitignore delete mode 100644 objs/Mingw/Release/.gitignore delete mode 100644 objs/Mingw/SDL/Debug/.gitignore delete mode 100644 objs/Mingw/SDL/Release/.gitignore delete mode 100644 objs/Mingw64/Debug/.gitignore delete mode 100644 objs/Mingw64/Release/.gitignore delete mode 100644 objs/Mingw64/SDL/Debug/.gitignore delete mode 100644 objs/Mingw64/SDL/Release/.gitignore delete mode 100644 objs/SDL/Release/.gitignore delete mode 100644 objs/VC/.gitignore delete mode 100644 objs/VC9/.gitignore delete mode 100644 objs/cygwin/Debug/.gitignore delete mode 100644 objs/cygwin/Release/.gitignore delete mode 100644 objs/dummy/.gitignore delete mode 100644 src/Makefile.cfg create mode 100644 src/Makefile.d/detect.mk create mode 100644 src/Makefile.d/features.mk create mode 100644 src/Makefile.d/nix.mk create mode 100644 src/Makefile.d/old.mk create mode 100644 src/Makefile.d/platform.mk create mode 100644 src/Makefile.d/sdl.mk create mode 100644 src/Makefile.d/util.mk create mode 100644 src/Makefile.d/versions.mk create mode 100644 src/Makefile.d/win32.mk create mode 100644 src/Sourcefile create mode 100644 src/blua/CMakeLists.txt delete mode 100644 src/blua/Makefile.cfg create mode 100644 src/blua/Sourcefile create mode 100644 src/hardware/CMakeLists.txt create mode 100644 src/hardware/Sourcefile delete mode 100644 src/sdl/MakeNIX.cfg delete mode 100644 src/sdl/Makefile.cfg create mode 100644 src/sdl/Sourcefile delete mode 100644 src/win32/Makefile.cfg diff --git a/.gitignore b/.gitignore index 3090417dd..7023aaa80 100644 --- a/.gitignore +++ b/.gitignore @@ -13,11 +13,11 @@ Win32_LIB_ASM_Release *.dgb *.debug *.debug.txt -/bin/VC10/ -/objs/VC10/ *.user *.db *.opendb /.vs /debian /assets/debian +/make +/bin diff --git a/CMakeLists.txt b/CMakeLists.txt index 39ad80698..b58101f7f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.0) +cmake_minimum_required(VERSION 3.13) # Enable CCache early set(SRB2_USE_CCACHE OFF CACHE BOOL "Use CCache") @@ -34,12 +34,11 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/") ### Useful functions -# Prepend sources with current source directory -function(prepend_sources SOURCE_FILES) - foreach(SOURCE_FILE ${${SOURCE_FILES}}) - set(MODIFIED ${MODIFIED} ${CMAKE_CURRENT_SOURCE_DIR}/${SOURCE_FILE}) - endforeach() - set(${SOURCE_FILES} ${MODIFIED} PARENT_SCOPE) +# Add sources from Sourcefile +function(target_sourcefile type) + file(STRINGS Sourcefile list + REGEX "[-0-9A-Za-z_]+\.${type}") + target_sources(SRB2SDL2 PRIVATE ${list}) endfunction() # Macro to add OSX framework diff --git a/appveyor.yml b/appveyor.yml index aa7a4c7cd..474a2adb3 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -2,15 +2,11 @@ version: 2.0.{branch}-{build} os: MinGW environment: - CC: ccache - CCACHE_CC: i686-w64-mingw32-gcc - CCACHE_CC_64: x86_64-w64-mingw32-gcc + CC: i686-w64-mingw32-gcc WINDRES: windres # c:\mingw-w64 i686 has gcc 6.3.0, so use c:\msys64 7.3.0 instead MINGW_SDK: c:\msys64\mingw32 - # c:\msys64 x86_64 has gcc 8.2.0, so use c:\mingw-w64 7.3.0 instead - MINGW_SDK_64: C:\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64 - CFLAGS: -Wall -W -Werror -Wno-error=implicit-fallthrough -Wimplicit-fallthrough=3 -Wno-tautological-compare -Wno-error=suggest-attribute=noreturn + CFLAGS: -Wno-implicit-fallthrough NASM_ZIP: nasm-2.12.01 NASM_URL: http://www.nasm.us/pub/nasm/releasebuilds/2.12.01/win64/nasm-2.12.01-win64.zip UPX_ZIP: upx391w @@ -19,8 +15,6 @@ environment: CCACHE_URL: http://alam.srb2.org/ccache.exe CCACHE_COMPRESS: true CCACHE_DIR: C:\Users\appveyor\.ccache - # Disable UPX by default. The user can override this in their Appveyor project settings - NOUPX: 1 ############################## # DEPLOYER VARIABLES # DPL_ENABLED=1 builds installers for branch names starting with `deployer`. @@ -53,11 +47,6 @@ cache: - C:\Users\appveyor\srb2_cache install: -- if [%CONFIGURATION%] == [SDL64] ( set "X86_64=1" ) -- if [%CONFIGURATION%] == [SDL64] ( set "CONFIGURATION=SDL" ) -- if [%X86_64%] == [1] ( set "MINGW_SDK=%MINGW_SDK_64%" ) -- if [%X86_64%] == [1] ( set "CCACHE_CC=%CCACHE_CC_64%" ) - - if not exist "%NASM_ZIP%.zip" appveyor DownloadFile "%NASM_URL%" -FileName "%NASM_ZIP%.zip" - 7z x -y "%NASM_ZIP%.zip" -o%TMP% >null - robocopy /S /xx /ns /nc /nfl /ndl /np /njh /njs "%TMP%\%NASM_ZIP%" "%MINGW_SDK%\bin" nasm.exe || exit 0 @@ -72,39 +61,27 @@ install: configuration: - SDL -- SDL64 before_build: - set "Path=%MINGW_SDK%\bin;%Path%" -- if [%X86_64%] == [1] ( x86_64-w64-mingw32-gcc --version ) else ( i686-w64-mingw32-gcc --version ) - mingw32-make --version -- if not [%X86_64%] == [1] ( nasm -v ) +- nasm -v - if not [%NOUPX%] == [1] ( upx -V ) - ccache -V - ccache -s -- if [%NOUPX%] == [1] ( set "NOUPX=NOUPX=1" ) else ( set "NOUPX=" ) - if defined [%APPVEYOR_PULL_REQUEST_HEAD_COMMIT%] ( set "COMMIT=%APPVEYOR_PULL_REQUEST_HEAD_COMMIT%" ) else ( set "COMMIT=%APPVEYOR_REPO_COMMIT%" ) - cmd: git rev-parse --short %COMMIT%>%TMP%/gitshort.txt - cmd: set /P GITSHORT=<%TMP%/gitshort.txt # for pull requests, take the owner's name only, if this isn't the same repo of course - set "REPO=%APPVEYOR_REPO_BRANCH%" - if not [%APPVEYOR_PULL_REQUEST_HEAD_REPO_NAME%] == [] ( if not [%APPVEYOR_PULL_REQUEST_HEAD_REPO_NAME%] == [%APPVEYOR_REPO_NAME%] ( for /f "delims=/" %%a in ("%APPVEYOR_PULL_REQUEST_HEAD_REPO_NAME%") do set "REPO=%%a-%APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH%" ) ) -- set "EXENAME=EXENAME=srb2win-%REPO%-%GITSHORT%.exe" -- set "SRB2_MFLAGS=-C src WARNINGMODE=1 CCACHE=1 NOOBJDUMP=1 %NOUPX% %EXENAME%" -- if [%X86_64%] == [1] ( set "MINGW_FLAGS=MINGW64=1 X86_64=1 GCC81=1" ) else ( set "MINGW_FLAGS=MINGW=1 GCC91=1" ) -- set "SRB2_MFLAGS=%SRB2_MFLAGS% %MINGW_FLAGS% %CONFIGURATION%=1" +- set "SRB2_MFLAGS=-C src NOECHOFILENAMES=1 CCACHE=1 EXENAME=srb2win-%REPO%-%GITSHORT%.exe" build_script: - cmd: mingw32-make.exe %SRB2_MFLAGS% clean - cmd: mingw32-make.exe %SRB2_MFLAGS% ERRORMODE=1 -k after_build: -- if [%X86_64%] == [1] ( - set "BUILD_PATH=bin\Mingw64\Release" - ) else ( - set "BUILD_PATH=bin\Mingw\Release" - ) -- if [%X86_64%] == [1] ( set "CONFIGURATION=%CONFIGURATION%64" ) - ccache -s - set BUILD_ARCHIVE=%REPO%-%GITSHORT%-%CONFIGURATION%.7z - set BUILDSARCHIVE=%REPO%-%CONFIGURATION%.7z @@ -139,3 +116,4 @@ test: off on_finish: #- cmd: echo xfreerdp /u:appveyor /cert-ignore +clipboard /v:: #- ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1')) +# vim: et ts=1 diff --git a/bin/FreeBSD/Debug/.gitignore b/bin/FreeBSD/Debug/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/bin/FreeBSD/Debug/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/bin/FreeBSD/Release/.gitignore b/bin/FreeBSD/Release/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/bin/FreeBSD/Release/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/bin/Linux/Debug/.gitignore b/bin/Linux/Debug/.gitignore deleted file mode 100644 index 56dee6f95..000000000 --- a/bin/Linux/Debug/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/lsdlsrb2 diff --git a/bin/Linux/Release/.gitignore b/bin/Linux/Release/.gitignore deleted file mode 100644 index 5b5c54a54..000000000 --- a/bin/Linux/Release/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -/lsdlsrb2 -/pnd -/*.mo diff --git a/bin/Linux64/Debug/.gitignore b/bin/Linux64/Debug/.gitignore deleted file mode 100644 index 56dee6f95..000000000 --- a/bin/Linux64/Debug/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/lsdlsrb2 diff --git a/bin/Linux64/Release/.gitignore b/bin/Linux64/Release/.gitignore deleted file mode 100644 index 56dee6f95..000000000 --- a/bin/Linux64/Release/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/lsdlsrb2 diff --git a/bin/Mingw/Debug/.gitignore b/bin/Mingw/Debug/.gitignore deleted file mode 100644 index 3458ff764..000000000 --- a/bin/Mingw/Debug/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -*.exe -*.mo -r_opengl.dll -*.bat diff --git a/bin/Mingw/Release/.gitignore b/bin/Mingw/Release/.gitignore deleted file mode 100644 index 3458ff764..000000000 --- a/bin/Mingw/Release/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -*.exe -*.mo -r_opengl.dll -*.bat diff --git a/bin/Mingw64/Debug/.gitignore b/bin/Mingw64/Debug/.gitignore deleted file mode 100644 index e431dca5d..000000000 --- a/bin/Mingw64/Debug/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -/srb2sdl.exe -/srb2win.exe -/r_opengl.dll diff --git a/bin/Mingw64/Release/.gitignore b/bin/Mingw64/Release/.gitignore deleted file mode 100644 index e431dca5d..000000000 --- a/bin/Mingw64/Release/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -/srb2sdl.exe -/srb2win.exe -/r_opengl.dll diff --git a/bin/SDL/Debug/.gitignore b/bin/SDL/Debug/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/bin/SDL/Debug/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/bin/SDL/Release/.gitignore b/bin/SDL/Release/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/bin/SDL/Release/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/bin/VC/.gitignore b/bin/VC/.gitignore deleted file mode 100644 index e52f825b2..000000000 --- a/bin/VC/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/Release -/Debug diff --git a/bin/VC9/.gitignore b/bin/VC9/.gitignore deleted file mode 100644 index 205fe45de..000000000 --- a/bin/VC9/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/Win32 -/x64 diff --git a/bin/dummy/.gitignore b/bin/dummy/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/bin/dummy/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/dep/.gitignore b/dep/.gitignore deleted file mode 100644 index fb941664f..000000000 --- a/dep/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -#All folders -*.d diff --git a/dep/FreeBSD/SDL/Debug/.gitignore b/dep/FreeBSD/SDL/Debug/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/dep/FreeBSD/SDL/Debug/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/dep/FreeBSD/SDL/Release/.gitignore b/dep/FreeBSD/SDL/Release/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/dep/FreeBSD/SDL/Release/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/dep/Linux/SDL/Debug/.gitignore b/dep/Linux/SDL/Debug/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/dep/Linux/SDL/Debug/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/dep/Linux/SDL/Release/.gitignore b/dep/Linux/SDL/Release/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/dep/Linux/SDL/Release/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/dep/Linux64/SDL/Debug/.gitignore b/dep/Linux64/SDL/Debug/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/dep/Linux64/SDL/Debug/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/dep/Linux64/SDL/Release/.gitignore b/dep/Linux64/SDL/Release/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/dep/Linux64/SDL/Release/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/dep/MasterClient/.gitignore b/dep/MasterClient/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/dep/MasterClient/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/dep/MasterServer/.gitignore b/dep/MasterServer/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/dep/MasterServer/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/dep/Mingw/Debug/.gitignore b/dep/Mingw/Debug/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/dep/Mingw/Debug/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/dep/Mingw/Release/.gitignore b/dep/Mingw/Release/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/dep/Mingw/Release/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/dep/Mingw/SDL/Debug/.gitignore b/dep/Mingw/SDL/Debug/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/dep/Mingw/SDL/Debug/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/dep/Mingw/SDL/Release/.gitignore b/dep/Mingw/SDL/Release/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/dep/Mingw/SDL/Release/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/dep/Mingw64/Debug/.gitignore b/dep/Mingw64/Debug/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/dep/Mingw64/Debug/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/dep/Mingw64/Release/.gitignore b/dep/Mingw64/Release/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/dep/Mingw64/Release/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/dep/Mingw64/SDL/Debug/.gitignore b/dep/Mingw64/SDL/Debug/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/dep/Mingw64/SDL/Debug/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/dep/Mingw64/SDL/Release/.gitignore b/dep/Mingw64/SDL/Release/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/dep/Mingw64/SDL/Release/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/dep/SDL/Release/.gitignore b/dep/SDL/Release/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/dep/SDL/Release/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/dep/VC/.gitignore b/dep/VC/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/dep/VC/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/dep/VC9/.gitignore b/dep/VC9/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/dep/VC9/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/dep/cygwin/Debug/.gitignore b/dep/cygwin/Debug/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/dep/cygwin/Debug/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/dep/cygwin/Release/.gitignore b/dep/cygwin/Release/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/dep/cygwin/Release/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/dep/dummy/.gitignore b/dep/dummy/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/dep/dummy/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/objs/.gitignore b/objs/.gitignore deleted file mode 100644 index 35ecd6def..000000000 --- a/objs/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -#All folders -SRB2.res -depend.dep -depend.ped -*.o -#VC9 folder only -/VC9/Win32 -/VC9/x64 diff --git a/objs/FreeBSD/SDL/Debug/.gitignore b/objs/FreeBSD/SDL/Debug/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/objs/FreeBSD/SDL/Debug/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/objs/FreeBSD/SDL/Release/.gitignore b/objs/FreeBSD/SDL/Release/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/objs/FreeBSD/SDL/Release/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/objs/Linux/SDL/Debug/.gitignore b/objs/Linux/SDL/Debug/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/objs/Linux/SDL/Debug/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/objs/Linux/SDL/Release/.gitignore b/objs/Linux/SDL/Release/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/objs/Linux/SDL/Release/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/objs/Linux64/SDL/Debug/.gitignore b/objs/Linux64/SDL/Debug/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/objs/Linux64/SDL/Debug/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/objs/Linux64/SDL/Release/.gitignore b/objs/Linux64/SDL/Release/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/objs/Linux64/SDL/Release/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/objs/MasterClient/.gitignore b/objs/MasterClient/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/objs/MasterClient/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/objs/MasterServer/.gitignore b/objs/MasterServer/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/objs/MasterServer/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/objs/Mingw/Debug/.gitignore b/objs/Mingw/Debug/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/objs/Mingw/Debug/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/objs/Mingw/Release/.gitignore b/objs/Mingw/Release/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/objs/Mingw/Release/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/objs/Mingw/SDL/Debug/.gitignore b/objs/Mingw/SDL/Debug/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/objs/Mingw/SDL/Debug/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/objs/Mingw/SDL/Release/.gitignore b/objs/Mingw/SDL/Release/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/objs/Mingw/SDL/Release/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/objs/Mingw64/Debug/.gitignore b/objs/Mingw64/Debug/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/objs/Mingw64/Debug/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/objs/Mingw64/Release/.gitignore b/objs/Mingw64/Release/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/objs/Mingw64/Release/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/objs/Mingw64/SDL/Debug/.gitignore b/objs/Mingw64/SDL/Debug/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/objs/Mingw64/SDL/Debug/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/objs/Mingw64/SDL/Release/.gitignore b/objs/Mingw64/SDL/Release/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/objs/Mingw64/SDL/Release/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/objs/SDL/Release/.gitignore b/objs/SDL/Release/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/objs/SDL/Release/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/objs/VC/.gitignore b/objs/VC/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/objs/VC/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/objs/VC9/.gitignore b/objs/VC9/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/objs/VC9/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/objs/cygwin/Debug/.gitignore b/objs/cygwin/Debug/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/objs/cygwin/Debug/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/objs/cygwin/Release/.gitignore b/objs/cygwin/Release/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/objs/cygwin/Release/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/objs/dummy/.gitignore b/objs/dummy/.gitignore deleted file mode 100644 index 42c6dc2c6..000000000 --- a/objs/dummy/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -# DON'T REMOVE -# This keeps the folder from disappearing diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d2678bb31..8fd39f721 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,269 +1,14 @@ # SRB2 Core +add_executable(SRB2SDL2 MACOSX_BUNDLE WIN32) + # Core sources -set(SRB2_CORE_SOURCES - am_map.c - command.c - comptime.c - console.c - d_clisrv.c - d_main.c - d_net.c - d_netcmd.c - d_netfil.c - dehacked.c - deh_soc.c - deh_lua.c - deh_tables.c - f_finale.c - f_wipe.c - filesrch.c - g_demo.c - g_game.c - g_input.c - g_splitscreen.c - font.c - hu_stuff.c - i_tcp.c - info.c - lzf.c - m_aatree.c - m_anigif.c - m_argv.c - m_bbox.c - m_cheat.c - m_cond.c - m_fixed.c - m_menu.c - m_misc.c - m_perfstats.c - m_queue.c - m_random.c - md5.c - mserv.c - http-mserv.c - s_sound.c - screen.c - sounds.c - st_stuff.c - #string.c - tables.c - v_video.c - w_wad.c - y_inter.c - z_zone.c -) +target_sourcefile(c) +target_sources(SRB2SDL2 PRIVATE comptime.c md5.c config.h.in) -set(SRB2_CORE_HEADERS - am_map.h - byteptr.h - command.h - console.h - d_clisrv.h - d_event.h - d_main.h - d_net.h - d_netcmd.h - d_netfil.h - d_player.h - d_think.h - d_ticcmd.h - dehacked.h - deh_soc.h - deh_lua.h - deh_tables.h - doomdata.h - doomdef.h - doomstat.h - doomtype.h - endian.h - f_finale.h - fastcmp.h - filesrch.h - g_demo.h - g_game.h - g_input.h - g_state.h - font.h - hu_stuff.h - i_joy.h - i_net.h - i_sound.h - i_system.h - i_tcp.h - i_video.h - info.h - keys.h - lzf.h - m_aatree.h - m_anigif.h - m_argv.h - m_bbox.h - m_cheat.h - m_cond.h - m_dllist.h - m_fixed.h - m_menu.h - m_misc.h - m_perfstats.h - m_queue.h - m_random.h - m_swap.h - md5.h - mserv.h - p5prof.h - s_sound.h - screen.h - sounds.h - st_stuff.h - tables.h - v_video.h - w_wad.h - y_inter.h - z_zone.h - - config.h.in -) - -set(SRB2_CORE_RENDER_SOURCES - r_bsp.c - r_data.c - r_draw.c - r_main.c - r_plane.c - r_segs.c - r_skins.c - r_sky.c - r_splats.c - r_things.c - r_textures.c - r_patch.c - r_patchrotation.c - r_picformats.c - r_portal.c - - r_bsp.h - r_data.h - r_defs.h - r_draw.h - r_local.h - r_main.h - r_plane.h - r_segs.h - r_skins.h - r_sky.h - r_splats.h - r_state.h - r_things.h - r_textures.h - r_patch.h - r_patchrotation.h - r_picformats.h - r_portal.h -) - -set(SRB2_CORE_GAME_SOURCES - p_ceilng.c - p_enemy.c - p_floor.c - p_inter.c - p_lights.c - p_map.c - p_maputl.c - p_mobj.c - p_polyobj.c - p_saveg.c - p_setup.c - p_sight.c - p_slopes.c - p_spec.c - p_telept.c - p_tick.c - p_user.c - taglist.c - - k_race.c - k_battle.c - k_bheap.c - k_collide.c - k_kart.c - k_pathfind.c - k_pwrlv.c - k_waypoint.c - k_color.c - k_bot.c - k_botitem.c - k_botsearch.c - k_respawn.c - k_grandprix.c - k_hud.c - - p_local.h - p_maputl.h - p_mobj.h - p_polyobj.h - p_pspr.h - p_saveg.h - p_setup.h - p_slopes.h - p_spec.h - p_tick.h - taglist.h - - k_race.h - k_battle.h - k_bheap.h - k_collide.h - k_kart.h - k_pathfind.h - k_pwrlv.h - k_waypoint.h - k_color.h - k_bot.h - k_respawn.h - k_grandprix.h - k_hud.h -) - -if(NOT (CMAKE_CXX_COMPILER_ID MATCHES "Clang")) - set(SRB2_CORE_SOURCES ${SRB2_CORE_SOURCES} string.c) -endif() - -prepend_sources(SRB2_CORE_SOURCES) -prepend_sources(SRB2_CORE_HEADERS) -prepend_sources(SRB2_CORE_RENDER_SOURCES) -prepend_sources(SRB2_CORE_GAME_SOURCES) - -set(SRB2_CORE_HEADERS ${SRB2_CORE_HEADERS} ${CMAKE_CURRENT_BINARY_DIR}/config.h) -source_group("Main" FILES ${SRB2_CORE_SOURCES} ${SRB2_CORE_HEADERS}) -source_group("Renderer" FILES ${SRB2_CORE_RENDER_SOURCES}) -source_group("Game" FILES ${SRB2_CORE_GAME_SOURCES}) - - -set(SRB2_ASM_SOURCES - ${CMAKE_CURRENT_SOURCE_DIR}/vid_copy.s -) - -set(SRB2_NASM_SOURCES - ${CMAKE_CURRENT_SOURCE_DIR}/tmap_mmx.nas - ${CMAKE_CURRENT_SOURCE_DIR}/tmap.nas -) - -if(MSVC) - list(APPEND SRB2_NASM_SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/tmap_vc.nas) -endif() - -set(SRB2_NASM_OBJECTS - ${CMAKE_CURRENT_BINARY_DIR}/tmap_mmx.obj - ${CMAKE_CURRENT_BINARY_DIR}/tmap.obj -) - -if(MSVC) - list(APPEND SRB2_NASM_OBJECTS ${CMAKE_CURRENT_BINARY_DIR}/tmap_vc.obj) -endif() - -source_group("Assembly" FILES ${SRB2_ASM_SOURCES} ${SRB2_NASM_SOURCES}) +set(SRB2_ASM_SOURCES vid_copy.s) +set(SRB2_NASM_SOURCES tmap_mmx.nas tmap.nas) ### Configuration set(SRB2_CONFIG_HAVE_PNG ON CACHE BOOL @@ -303,92 +48,7 @@ if(${CMAKE_SYSTEM} MATCHES "Windows") ###set on Windows only "Use SRB2Kart's internal copies of required dependencies (SDL2, PNG, zlib, GME, OpenMPT, cURL).") endif() -set(SRB2_LUA_SOURCES - lua_baselib.c - lua_blockmaplib.c - lua_consolelib.c - lua_hooklib.c - lua_hudlib.c - lua_infolib.c - lua_maplib.c - lua_taglib.c - lua_mathlib.c - lua_mobjlib.c - lua_playerlib.c - lua_polyobjlib.c - lua_script.c - lua_skinlib.c - lua_thinkerlib.c -) -set(SRB2_LUA_HEADERS - lua_hook.h - lua_hud.h - lua_libs.h - lua_script.h -) - -prepend_sources(SRB2_LUA_SOURCES) -prepend_sources(SRB2_LUA_HEADERS) - -source_group("LUA" FILES ${SRB2_LUA_SOURCES} ${SRB2_LUA_HEADERS}) - -set(SRB2_BLUA_SOURCES - blua/lapi.c - blua/lauxlib.c - blua/lbaselib.c - blua/lcode.c - blua/ldebug.c - blua/ldo.c - blua/ldump.c - blua/lfunc.c - blua/lgc.c - blua/linit.c - blua/liolib.c - blua/llex.c - blua/lmem.c - blua/lobject.c - blua/lopcodes.c - blua/lparser.c - blua/lstate.c - blua/lstring.c - blua/lstrlib.c - blua/ltable.c - blua/ltablib.c - blua/ltm.c - blua/lundump.c - blua/lvm.c - blua/lzio.c -) -set(SRB2_BLUA_HEADERS - blua/lapi.h - blua/lauxlib.h - blua/lcode.h - blua/ldebug.h - blua/ldo.h - blua/lfunc.h - blua/lgc.h - blua/llex.h - blua/llimits.h - blua/lmem.h - blua/lobject.h - blua/lopcodes.h - blua/lparser.h - blua/lstate.h - blua/lstring.h - blua/ltable.h - blua/ltm.h - blua/lua.h - blua/luaconf.h - blua/lualib.h - blua/lundump.h - blua/lvm.h - blua/lzio.h -) - -prepend_sources(SRB2_BLUA_SOURCES) -prepend_sources(SRB2_BLUA_HEADERS) - -source_group("LUA\\Interpreter" FILES ${SRB2_BLUA_SOURCES} ${SRB2_BLUA_HEADERS}) +add_subdirectory(blua) if(${SRB2_CONFIG_HAVE_GME}) if(${SRB2_CONFIG_USE_INTERNAL_LIBRARIES}) @@ -404,7 +64,7 @@ if(${SRB2_CONFIG_HAVE_GME}) endif() if(${GME_FOUND}) set(SRB2_HAVE_GME ON) - add_definitions(-DHAVE_LIBGME) + target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_GME) else() message(WARNING "You have specified that GME is available but it was not found.") endif() @@ -424,7 +84,7 @@ if(${SRB2_CONFIG_HAVE_OPENMPT}) endif() if(${OPENMPT_FOUND}) set(SRB2_HAVE_OPENMPT ON) - add_definitions(-DHAVE_OPENMPT) + target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_OPENMPT) else() message(WARNING "You have specified that OpenMPT is available but it was not found.") endif() @@ -447,8 +107,7 @@ if(${SRB2_CONFIG_HAVE_MIXERX}) endif() if(${MIXERX_FOUND}) set(SRB2_HAVE_MIXERX ON) - set(SRB2_SDL2_SOUNDIMPL mixer_sound.c) - add_definitions(-DHAVE_MIXERX) + target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_MIXERX) else() message(WARNING "You have specified that SDL Mixer X is available but it was not found.") endif() @@ -495,7 +154,7 @@ if(${SRB2_CONFIG_HAVE_ZLIB}) endif() if(${ZLIB_FOUND}) set(SRB2_HAVE_ZLIB ON) - add_definitions(-DHAVE_ZLIB) + target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_ZLIB) else() message(WARNING "You have specified that ZLIB is available but it was not found. SRB2Kart may not compile correctly.") endif() @@ -516,14 +175,9 @@ if(${SRB2_CONFIG_HAVE_PNG} AND ${SRB2_CONFIG_HAVE_ZLIB}) endif() if(${PNG_FOUND}) set(SRB2_HAVE_PNG ON) - add_definitions(-DHAVE_PNG) - add_definitions(-D_LARGEFILE64_SOURCE) - set(SRB2_PNG_SOURCES apng.c) - set(SRB2_PNG_HEADERS apng.h) - prepend_sources(SRB2_PNG_SOURCES) - prepend_sources(SRB2_PNG_HEADERS) - source_group("Main" FILES ${SRB2_CORE_SOURCES} ${SRB2_CORE_HEADERS} - ${SRB2_PNG_SOURCES} ${SRB2_PNG_HEADERS}) + target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_PNG) + target_compile_definitions(SRB2SDL2 PRIVATE -D_LARGEFILE64_SOURCE) + target_sources(SRB2SDL2 PRIVATE apng.c) else() message(WARNING "You have specified that PNG is available but it was not found. SRB2Kart may not compile correctly.") endif() @@ -544,7 +198,7 @@ if(${SRB2_CONFIG_HAVE_CURL}) endif() if(${CURL_FOUND}) set(SRB2_HAVE_CURL ON) - add_definitions(-DHAVE_CURL) + target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_CURL) else() message(WARNING "You have specified that CURL is available but it was not found. SRB2Kart may not compile correctly.") endif() @@ -552,59 +206,19 @@ endif() if(${SRB2_CONFIG_HAVE_THREADS}) set(SRB2_HAVE_THREADS ON) - set(SRB2_CORE_HEADERS ${SRB2_CORE_HEADERS} ${CMAKE_CURRENT_SOURCE_DIR}/i_threads.h) - add_definitions(-DHAVE_THREADS) + target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_THREADS) endif() if(${SRB2_CONFIG_HWRENDER}) - add_definitions(-DHWRENDER) - set(SRB2_HWRENDER_SOURCES - ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_batching.c - ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_bsp.c - ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_cache.c - ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_clip.c - ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_draw.c - ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_light.c - ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_main.c - ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_md2.c - ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_md2load.c - ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_md3load.c - ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_model.c - ${CMAKE_CURRENT_SOURCE_DIR}/hardware/u_list.c - ) - - set (SRB2_HWRENDER_HEADERS - ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_batching.h - ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_clip.h - ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_data.h - ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_defs.h - ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_dll.h - ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_drv.h - ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_glob.h - ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_light.h - ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_main.h - ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_md2.h - ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_md2load.h - ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_md3load.h - ${CMAKE_CURRENT_SOURCE_DIR}/hardware/hw_model.h - ${CMAKE_CURRENT_SOURCE_DIR}/hardware/u_list.h - ) - - set(SRB2_R_OPENGL_SOURCES - ${CMAKE_CURRENT_SOURCE_DIR}/hardware/r_opengl/r_opengl.c - ) - - set(SRB2_R_OPENGL_HEADERS - ${CMAKE_CURRENT_SOURCE_DIR}/hardware/r_opengl/r_opengl.h - ) - + target_compile_definitions(SRB2SDL2 PRIVATE -DHWRENDER) + add_subdirectory(hardware) endif() if(${SRB2_CONFIG_HWRENDER} AND ${SRB2_CONFIG_STATIC_OPENGL}) find_package(OpenGL) if(${OPENGL_FOUND}) - add_definitions(-DHWRENDER) - add_definitions(-DSTATIC_OPENGL) + target_compile_definitions(SRB2SDL2 PRIVATE -DHWRENDER) + target_compile_definitions(SRB2SDL2 PRIVATE -DSTATIC_OPENGL) else() message(WARNING "You have specified static opengl but opengl was not found. Not setting HWRENDER.") endif() @@ -625,12 +239,16 @@ if(${SRB2_CONFIG_USEASM}) set(CMAKE_ASM_NASM_FLAGS "${SRB2_ASM_FLAGS}" CACHE STRING "Flags used by the assembler during all build types.") enable_language(ASM_NASM) endif() + set(SRB2_USEASM ON) - add_definitions(-DUSEASM) + target_compile_definitions(SRB2SDL2 PRIVATE -DUSEASM) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -msse3 -mfpmath=sse") + + target_sources(SRB2SDL2 PRIVATE ${SRB2_ASM_SOURCES} + ${SRB2_NASM_SOURCES}) else() set(SRB2_USEASM OFF) - add_definitions(-DNONX86 -DNORUSEASM) + target_compile_definitions(SRB2SDL2 PRIVATE -DNONX86 -DNORUSEASM) endif() # Targets @@ -666,7 +284,9 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} -Wno-absolute-value) endif() -add_definitions(-DCMAKECONFIG) +set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} -Wno-trigraphs) + +target_compile_definitions(SRB2SDL2 PRIVATE -DCMAKECONFIG) #add_library(SRB2Core STATIC # ${SRB2_CORE_SOURCES} diff --git a/src/Makefile b/src/Makefile index a390557a6..9659a4994 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,861 +1,416 @@ - -# GNU Make makefile for SRB2 -############################################################################# -# Copyright (C) 1998-2000 by DooM Legacy Team. -# Copyright (C) 2003-2021 by Sonic Team Junior. +# GNU Makefile for SRB2 +# the poly3 Makefile adapted over and over... +# +# Copyright 1998-2000 DooM Legacy Team. +# Copyright 2020-2021 James R. +# Copyright 2003-2021 Sonic Team Junior. # # This program is free software distributed under the # terms of the GNU General Public License, version 2. # See the 'LICENSE' file for more details. # -# -DLINUX -> use for the GNU/Linux specific -# -D_WINDOWS -> use for the Win32/DirectX specific -# -DHAVE_SDL -> use for the SDL interface +# Special targets: # -# Sets: -# Compile the SDL/Mingw version with 'make MINGW=1' -# Compile the SDL/Linux version with 'make LINUX=1' -# Compile the SDL/Solaris version with 'make SOLARIS=1' -# Compile the SDL/FreeBSD version with 'gmake FREEBSD=1' -# Compile the SDL/Cygwin version with 'make CYGWIN32=1' -# Compile the SDL/other version try with 'make SDL=1' +# clean - remove executables and objects for this build +# cleandep - remove dependency files for this build +# distclean - remove entire executable, object and +# dependency file directory structure. +# dump - disassemble executable +# info - print settings # -# 'Targets': -# clean -# Remove all object files -# cleandep -# Remove dependency files -# distclean -# Remove autogenerated files -# dll -# compile primary HW render DLL/SO -# all_dll -# compile all HW render and 3D sound DLLs for the set -# opengl_dll -# Pure Mingw only, compile OpenGL HW render DLL -# ds3d_dll -# Pure Mingw only, compile DirectX DirectSound HW sound DLL -# fmod_dll -# Pure Mingw only, compile FMOD HW sound DLL -# openal_dll -# Pure Mingw only, compile OpenAL HW sound DLL -# fmod_so -# Non-Mingw, compile FMOD HW sound SO -# openal_so -# Non-Mingw, compile OpenAL HW sound SO +# This Makefile can automatically detect the host system +# as well as the compiler version. If system or compiler +# version cannot be detected, you may need to set a flag +# manually. # +# On Windows machines, 32-bit Windows is always targetted. # -# Addon: -# To Cross-Compile, CC=gcc-version make * PREFIX= -# Compile with GCC 2.97 version, add 'GCC29=1' -# Compile with GCC 4.0x version, add 'GCC40=1' -# Compile with GCC 4.1x version, add 'GCC41=1' -# Compile with GCC 4.2x version, add 'GCC42=1' -# Compile with GCC 4.3x version, add 'GCC43=1' -# Compile with GCC 4.4x version, add 'GCC44=1' -# Compile with GCC 4.5x version, add 'GCC45=1' -# Compile with GCC 4.6x version, add 'GCC46=1' -# Compile a profile version, add 'PROFILEMODE=1' -# Compile a debug version, add 'DEBUGMODE=1' -# Compile for the testers group (they don't get to play unless we're watching *wink*), add 'TESTERS=1' -# Compile with less warnings, add 'RELAXWARNINGS=1' -# Generate compiler errors for most compiler warnings, add 'ERRORMODE=1' -# Compile without NASM's tmap.nas, add 'NOASM=1' -# Compile without 3D hardware support, add 'NOHW=1' -# Compile with GDBstubs, add 'RDB=1' -# Compile without PNG, add 'NOPNG=1' -# Compile without zlib, add 'NOZLIB=1' +# Platform/system flags: # -# Addon for SDL: -# To Cross-Compile, add 'SDL_CONFIG=/usr/*/bin/sdl-config' -# Compile without SDL_Mixer, add 'NOMIXER=1' -# Compile without SDL_Mixer_X, add 'NOMIXERX=1' (Win32 only) -# Compile without GME, add 'NOGME=1' -# Compile without BSD API, add 'NONET=1' -# Compile without IPX/SPX, add 'NOIPX=1' -# Compile Mingw/SDL with S_DS3S, add 'DS3D=1' -# Compile without libopenmpt, add 'NOOPENMPT=1' -# Compile with S_FMOD3D, add 'FMOD=1' (WIP) -# Compile with S_OPENAL, add 'OPENAL=1' (WIP) -# To link with the whole SDL_Image lib to load Icons, add 'SDL_IMAGE=1' but it isn't not realy needed -# To link with SDLMain to hide console or make on a console-less binary, add 'SDLMAIN=1' +# LINUX=1, LINUX64=1 +# MINGW=1, MINGW64=1 - Windows (MinGW toolchain) +# UNIX=1 - Generic Unix like system +# FREEBSD=1 +# SDL=1 - Use SDL backend. SDL is the only backend though +# and thus, always enabled. # -############################################################################# +# A list of supported GCC versions can be found in +# Makefile.d/detect.mk -- search 'gcc_versions'. +# +# Feature flags: +# +# Safe to use online +# ------------------ +# NO_IPV6=1 - Disable IPv6 address support. +# NOHW=1 - Disable OpenGL renderer. +# ZDEBUG=1 - Enable more detailed memory debugging +# HAVE_MINIUPNPC=1 - Enable automated port forwarding. +# Already enabled by default for 32-bit +# Windows. +# NOASM=1 - Disable hand optimized assembly code for the +# Software renderer. +# NOPNG=1 - Disable PNG graphics support. (TODO: double +# check netplay compatible.) +# NOCURL=1 - Disable libcurl--HTTP capability. +# NOGME=1 - Disable game music emu, retro VGM support. +# NOOPENMPT=1 - Disable module (tracker) music support. +# NOMIXER=1 - Disable SDL Mixer (audio playback). +# NOMIXERX=1 - Forgo SDL Mixer X--revert to standard SDL +# Mixer. Mixer X is the default for Windows +# builds. +# HAVE_MIXERX=1 - Enable SDL Mixer X. Outside of Windows +# builds, SDL Mixer X is not the default. +# NOTHREADS=1 - Disable multithreading. +# +# Netplay incompatible +# -------------------- +# NONET=1 - Disable online capability. +# NOMD5=1 - Disable MD5 checksum (validation tool). +# NOPOSTPROCESSING=1 - ? +# MOBJCONSISTANCY=1 - ?? +# PACKETDROP=1 - ?? +# DEBUGMODE=1 - Enable various debugging capabilities. +# Also disables optimizations. +# NOZLIB=1 - Disable some compression capability. Implies +# NOPNG=1. +# +# Development flags: +# +# VALGRIND=1 - Enable Valgrind memory debugging support. +# PROFILEMODE=1 - Enable performance profiling (gprof). +# +# General flags for building: +# +# STATIC=1 - Use static linking. +# DISTCC=1 +# CCACHE=1 +# UPX= - UPX command to use for compressing final +# executable. +# WINDOWSHELL=1 - Use Windows commands. +# PREFIX= - Prefix to many commands, for cross compiling. +# YASM=1 - Use Yasm instead of NASM assembler. +# STABS=1 - ? +# ECHO=1 - Print out each command in the build process. +# NOECHOFILENAMES=1 - Don't print out each that is being +# worked on. +# SILENT=1 - Print absolutely nothing except errors. +# RELAXWARNINGS=1 - Use less compiler warnings/errors. +# ERRORMODE=1 - Treat most compiler warnings as errors. +# NOCASTALIGNWARN=1 - ? +# NOLDWARNING=1 - ? +# NOSDLMAIN=1 - ? +# SDLMAIN=1 - ? +# +# Library configuration flags: +# Everything here is an override. +# +# PNG_PKGCONFIG= - libpng-config command. +# PNG_CFLAGS=, PNG_LDFLAGS= +# +# CURLCONFIG= - curl-config command. +# CURL_CFLAGS=, CURL_LDFLAGS= +# +# VALGRIND_PKGCONFIG= - pkg-config package name. +# VALGRIND_CFLAGS=, VALGRIND_LDFLAGS= +# +# LIBGME_PKGCONFIG=, LIBGME_CFLAGS=, LIBGME_LDFLAGS= -,=, +# LIBOPENMPT_PKGCONFIG= +# LIBOPENMPT_CFLAGS=, LIBOPENMPT_LDFLAGS= +# +# ZLIB_PKGCONFIG=, ZLIB_CFLAGS=, ZLIB_LDFLAGS= +# +# SDL_PKGCONFIG= +# SDL_CONFIG= - sdl-config command. +# SDL_CFLAGS=, SDL_LDFLAGS= -ifeq (,$(filter-out cleandep clean distclean,$(or $(MAKECMDGOALS),all))) -CLEANONLY=1 -else ifndef SILENT -echo=@echo "$(1)" -ifndef MAKE_RESTARTS -print=$(info $(1)) -endif +clean_targets=cleandep clean distclean info + +.PHONY : $(clean_targets) all + +goals:=$(or $(MAKECMDGOALS),all) +cleanonly:=$(filter $(clean_targets),$(goals)) +destructive:=$(filter-out info,$(cleanonly)) + +ifndef cleanonly +include Makefile.d/old.mk endif -ALL_SYSTEMS=\ - PANDORA\ - LINUX64\ - MINGW64\ - HAIKU\ - DUMMY\ - DJGPPDOS\ - MINGW\ - UNIX\ - LINUX\ - SOLARIS\ - FREEBSD\ - MACOSX\ - SDL\ +include Makefile.d/util.mk -# check for user specified system -ifeq (,$(filter $(ALL_SYSTEMS),$(.VARIABLES))) -ifeq ($(OS),Windows_NT) # all windows are Windows_NT... - - $(call print,Detected a Windows system$(,) compiling for 32-bit MinGW SDL2...) - - # go for a 32-bit sdl mingw exe by default - MINGW=1 - WINDOWSHELL=1 - -else # if you on the *nix - - system:=$(shell uname -s) - - ifeq ($(system),Linux) - new_system=LINUX - else - - $(error \ - Could not automatically detect your system,\ - try specifying a system manually) - - endif - - ifeq ($(shell getconf LONG_BIT),64) - system+=64-bit - new_system:=$(new_system)64 - endif - - $(call print,Detected $(system) ($(new_system))...) - $(new_system)=1 - -endif -endif - - -# SRB2 data files -D_DIR?=../bin/Resources -D_FILES=$(D_DIR)/main.kart \ - $(D_DIR)/gfx.pk3 \ - $(D_DIR)/textures.pk3 \ - $(D_DIR)/chars.pk3 \ - $(D_DIR)/maps.wad \ - $(D_DIR)/patch.pk3 \ - $(D_DIR)/sounds.wad \ - $(D_DIR)/music.wad \ - -PKG_CONFIG?=pkg-config - -ifdef PANDORA -LINUX=1 -endif - -ifdef LINUX64 -LINUX=1 -NONX86=1 -# LINUX64 does not imply X86_64=1; could mean ARM64 or Itanium -endif - -ifdef MINGW64 -MINGW=1 -NONX86=1 -NOASM=1 -# MINGW64 should not necessarily imply X86_64=1, but we make that assumption elsewhere -# Once that changes, remove this -X86_64=1 -endif #ifdef MINGW64 - -ifdef HAIKU -SDL=1 -endif - -include Makefile.cfg - -ifdef DUMMY -NOPNG=1 -NOZLIB=1 -NONET=1 -NOHW=1 -NOASM=1 -NOIPX=1 -EXENAME?=srb2dummy -OBJS=$(OBJDIR)/i_video.o -LIBS=-lm -endif - -ifdef HAIKU -NOIPX=1 -NOASM=1 -ifndef NONET -LIBS=-lnetwork -endif -CFLAGS+=-DUNIXCOMMON -PNG_CFLAGS?= -PNG_LDFLAGS?=-lpng -endif - -ifdef PANDORA -NONX86=1 -NOHW=1 -endif - -ifndef NOOPENMPT -HAVE_OPENMPT=1 -endif - -ifdef MINGW -include win32/Makefile.cfg -endif #ifdef MINGW - -ifdef UNIX -UNIXCOMMON=1 -endif - -ifdef LINUX -UNIXCOMMON=1 -ifndef NOGME -HAVE_LIBGME=1 -endif -endif - -ifdef SOLARIS -UNIXCOMMON=1 -endif - -ifdef FREEBSD -UNIXCOMMON=1 -endif - -ifdef MACOSX -UNIXCOMMON=1 -endif - -ifdef SDL - include sdl/Makefile.cfg -endif #ifdef SDL - -ifdef DISTCC - CC:=distcc $(CC) -endif - -ifdef CCACHE - CC:=ccache $(CC) -endif - -MSGFMT?=msgfmt - -ifdef WINDOWSHELL - COMPTIME=-..\comptime.bat -else - COMPTIME=-../comptime.sh -endif - -ifndef ECHO - NASM:=@$(NASM) - REMOVE:=@$(REMOVE) - CC:=@$(CC) - CXX:=@$(CXX) - OBJCOPY:=@$(OBJCOPY) - OBJDUMP:=@$(OBJDUMP) - STRIP:=@$(STRIP) - WINDRES:=@$(WINDRES) - MKDIR:=@$(MKDIR) - GZIP:=@$(GZIP) - MSGFMT:=@$(MSGFMT) - UPX:=@$(UPX) - UPX_OPTS+=-q - COMPTIME:=@$(COMPTIME) -endif - -ifdef NONET - OPTS+=-DNONET - NOCURL=1 -else -ifdef NO_IPV6 - OPTS+=-DNO_IPV6 -endif -endif - -ifdef NOHW - OPTS+=-DNOHW -else - OPTS+=-DHWRENDER - OBJS+=$(OBJDIR)/hw_bsp.o $(OBJDIR)/hw_draw.o $(OBJDIR)/hw_light.o \ - $(OBJDIR)/hw_main.o $(OBJDIR)/hw_clip.o $(OBJDIR)/hw_md2.o $(OBJDIR)/hw_cache.o \ - $(OBJDIR)/hw_md2load.o $(OBJDIR)/hw_md3load.o $(OBJDIR)/hw_model.o $(OBJDIR)/u_list.o $(OBJDIR)/hw_batching.o -endif - -OPTS += -DCOMPVERSION - -ifndef NONX86 -ifndef GCC29 - ARCHOPTS?=-msse3 -mfpmath=sse -else - ARCHOPTS?=-mpentium -endif -else -ifdef X86_64 - ARCHOPTS?=-march=nocona -endif -endif - -ifndef NOASM -ifndef NONX86 - OBJS+=$(OBJDIR)/tmap.o $(OBJDIR)/tmap_mmx.o - OPTS+=-DUSEASM -endif -endif - -ifndef NOPNG -OPTS+=-DHAVE_PNG - -ifdef PNG_PKGCONFIG -PNG_CFLAGS?=$(shell $(PKG_CONFIG) $(PNG_PKGCONFIG) --cflags) -PNG_LDFLAGS?=$(shell $(PKG_CONFIG) $(PNG_PKGCONFIG) --libs) -else ifdef PREFIX -PNG_CONFIG?=$(PREFIX)-libpng-config +CC:=$(PREFIX)-gcc +endif + +OBJDUMP_OPTS?=--wide --source --line-numbers + +OBJCOPY:=$(call Prefix,objcopy) +OBJDUMP:=$(call Prefix,objdump) +WINDRES:=$(call Prefix,windres) + +ifdef YASM +NASM?=yasm else -PNG_CONFIG?=libpng-config -endif - -ifdef PNG_STATIC -PNG_CFLAGS?=$(shell $(PNG_CONFIG) --static --cflags) -PNG_LDFLAGS?=$(shell $(PNG_CONFIG) --static --ldflags) -else -PNG_CFLAGS?=$(shell $(PNG_CONFIG) --cflags) -PNG_LDFLAGS?=$(shell $(PNG_CONFIG) --ldflags) -endif -endif - -ifdef LINUX -PNG_CFLAGS+=-D_LARGEFILE64_SOURCE -endif - -LIBS+=$(PNG_LDFLAGS) -CFLAGS+=$(PNG_CFLAGS) - -OBJS+=$(OBJDIR)/apng.o -endif - -ifdef HAVE_LIBGME -OPTS+=-DHAVE_LIBGME - -LIBGME_PKGCONFIG?=libgme -LIBGME_CFLAGS?=$(shell $(PKG_CONFIG) $(LIBGME_PKGCONFIG) --cflags) -LIBGME_LDFLAGS?=$(shell $(PKG_CONFIG) $(LIBGME_PKGCONFIG) --libs) - -LIBS+=$(LIBGME_LDFLAGS) -CFLAGS+=$(LIBGME_CFLAGS) -endif - -ifdef HAVE_OPENMPT -OPTS+=-DHAVE_OPENMPT - -LIBOPENMPT_PKGCONFIG?=libopenmpt -LIBOPENMPT_CFLAGS?=$(shell $(PKG_CONFIG) $(LIBOPENMPT_PKGCONFIG) --cflags) -LIBOPENMPT_LDFLAGS?=$(shell $(PKG_CONFIG) $(LIBOPENMPT_PKGCONFIG) --libs) - -LIBS+=$(LIBOPENMPT_LDFLAGS) -CFLAGS+=$(LIBOPENMPT_CFLAGS) -endif - -ifndef NOZLIB -OPTS+=-DHAVE_ZLIB -ZLIB_PKGCONFIG?=zlib -ZLIB_CFLAGS?=$(shell $(PKG_CONFIG) $(ZLIB_PKGCONFIG) --cflags) -ZLIB_LDFLAGS?=$(shell $(PKG_CONFIG) $(ZLIB_PKGCONFIG) --libs) - -LIBS+=$(ZLIB_LDFLAGS) -CFLAGS+=$(ZLIB_CFLAGS) -else -NOPNG=1 -endif - -ifndef NOCURL -OPTS+=-DHAVE_CURL -CURLCONFIG?=curl-config -CURL_CFLAGS?=$(shell $(CURLCONFIG) --cflags) -CURL_LDFLAGS?=$(shell $(CURLCONFIG) --libs) - -LIBS+=$(CURL_LDFLAGS) -CFLAGS+=$(CURL_CFLAGS) -endif - -ifdef STATIC -LIBS:=-static $(LIBS) -endif - -ifdef HAVE_MINIUPNPC -ifdef NONET -HAVE_MINIUPNPC='' -else -LIBS+=-lminiupnpc -ifdef MINGW -LIBS+=-lws2_32 -liphlpapi -endif -CFLAGS+=-DHAVE_MINIUPNPC -endif -endif - -ifdef HAVE_DISCORDRPC -LIBS+=-ldiscord-rpc -CFLAGS+=-DHAVE_DISCORDRPC -DUSE_STUN -OBJS+=$(OBJDIR)/discord.o $(OBJDIR)/stun.o -endif - -include blua/Makefile.cfg - -ifdef NOMD5 - OPTS+=-DNOMD5 -else - OBJS:=$(OBJDIR)/md5.o $(OBJS) -endif - -ifdef NOPOSTPROCESSING - OPTS+=-DNOPOSTPROCESSING -endif - - OPTS:=-fno-exceptions $(OPTS) - -ifdef MOBJCONSISTANCY - OPTS+=-DMOBJCONSISTANCY -endif - -ifdef PACKETDROP - OPTS+=-DPACKETDROP -endif - -ifdef DEBUGMODE - - # build with debugging information - WINDRESFLAGS = -D_DEBUG -ifdef GCC48 - CFLAGS+=-Og -else - CFLAGS+=-O0 -endif - CFLAGS+= -Wall -DPARANOIA -DRANGECHECK -DPACKETDROP -else - - - # build a normal optimised version - WINDRESFLAGS = -DNDEBUG - CFLAGS+=-O3 -endif - CFLAGS+=-g $(OPTS) $(ARCHOPTS) $(WINDRESFLAGS) - -ifdef TESTERS - OPTS+=-DTESTERS +NASM?=nasm endif ifdef YASM ifdef STABS - NASMOPTS?= -g stabs +NASMOPTS?=-g stabs else - NASMOPTS?= -g dwarf2 +NASMOPTS?=-g dwarf2 endif else - NASMOPTS?= -g +NASMOPTS?=-g endif -ifdef PROFILEMODE - # build with profiling information - CFLAGS+=-pg - LDFLAGS+=-pg +GZIP?=gzip +GZIP_OPTS?=-9 -f -n +ifdef WINDOWSHELL +GZIP_OPTS+=--rsyncable endif -ifdef ZDEBUG - CPPFLAGS+=-DZDEBUG +UPX_OPTS?=--best --preserve-build-id +ifndef ECHO +UPX_OPTS+=-qq endif -ifdef DEVELOP - CPPFLAGS+=-DDEVELOP +include Makefile.d/detect.mk + +# make would try to remove the implicitly made directories +.PRECIOUS : %/ comptime.c + +sources:= +makedir:=../make + +# -DCOMPVERSION: flag to use comptime.h +opts:=-DCOMPVERSION -g +libs:= + +nasm_format:= + +# This is a list of variables names, of which if defined, +# also defines the name as a macro to the compiler. +passthru_opts:= + +include Makefile.d/platform.mk +include Makefile.d/features.mk +include Makefile.d/versions.mk + +ifdef DEBUGMODE +makedir:=$(makedir)/debug endif -OPTS+=$(CPPFLAGS) +depdir:=$(makedir)/deps +objdir:=$(makedir)/objs -# default EXENAME if all else fails +# very sophisticated dependency +sources+=\ + $(call List,Sourcefile)\ + $(call List,blua/Sourcefile)\ + +depends:=$(basename $(filter %.c %.s,$(sources))) +objects:=$(basename $(filter %.c %.s %.nas,$(sources))) + +depends:=$(depends:%=$(depdir)/%.d) + +# comptime.o added directly to objects instead of thru +# sources because comptime.c includes comptime.h, but +# comptime.h may not exist yet. It's a headache so this is +# easier. +objects:=$(objects:=.o) comptime.o + +# windows resource file +rc_file:=$(basename $(filter %.rc,$(sources))) +ifdef rc_file +objects+=$(rc_file:=.res) +endif + +objects:=$(addprefix $(objdir)/,$(objects)) + +ifdef DEBUGMODE +bin:=../bin/debug +else +bin:=../bin +endif + +# default EXENAME (usually set by platform) EXENAME?=srb2 DBGNAME?=$(EXENAME).debug -# $(OBJDIR)/dstrings.o \ +exe:=$(bin)/$(EXENAME) +dbg:=$(bin)/$(DBGNAME) -# not too sophisticated dependency -# SRB2kart kart.o on line 433 below -OBJS:=$(i_main_o) \ - $(OBJDIR)/string.o \ - $(OBJDIR)/d_main.o \ - $(OBJDIR)/d_clisrv.o \ - $(OBJDIR)/d_net.o \ - $(OBJDIR)/d_netfil.o \ - $(OBJDIR)/d_netcmd.o \ - $(OBJDIR)/dehacked.o \ - $(OBJDIR)/deh_soc.o \ - $(OBJDIR)/deh_lua.o \ - $(OBJDIR)/deh_tables.o \ - $(OBJDIR)/z_zone.o \ - $(OBJDIR)/f_finale.o \ - $(OBJDIR)/f_wipe.o \ - $(OBJDIR)/g_demo.o \ - $(OBJDIR)/g_game.o \ - $(OBJDIR)/g_input.o \ - $(OBJDIR)/g_splitscreen.o\ - $(OBJDIR)/am_map.o \ - $(OBJDIR)/command.o \ - $(OBJDIR)/console.o \ - $(OBJDIR)/font.o \ - $(OBJDIR)/hu_stuff.o \ - $(OBJDIR)/y_inter.o \ - $(OBJDIR)/st_stuff.o \ - $(OBJDIR)/m_aatree.o \ - $(OBJDIR)/m_anigif.o \ - $(OBJDIR)/m_argv.o \ - $(OBJDIR)/m_bbox.o \ - $(OBJDIR)/m_cheat.o \ - $(OBJDIR)/m_cond.o \ - $(OBJDIR)/m_fixed.o \ - $(OBJDIR)/m_menu.o \ - $(OBJDIR)/m_misc.o \ - $(OBJDIR)/m_perfstats.o \ - $(OBJDIR)/m_random.o \ - $(OBJDIR)/m_queue.o \ - $(OBJDIR)/info.o \ - $(OBJDIR)/p_ceilng.o \ - $(OBJDIR)/p_enemy.o \ - $(OBJDIR)/p_floor.o \ - $(OBJDIR)/p_inter.o \ - $(OBJDIR)/p_lights.o \ - $(OBJDIR)/p_map.o \ - $(OBJDIR)/p_maputl.o \ - $(OBJDIR)/p_mobj.o \ - $(OBJDIR)/p_polyobj.o\ - $(OBJDIR)/p_saveg.o \ - $(OBJDIR)/p_setup.o \ - $(OBJDIR)/p_sight.o \ - $(OBJDIR)/p_spec.o \ - $(OBJDIR)/p_telept.o \ - $(OBJDIR)/p_tick.o \ - $(OBJDIR)/p_user.o \ - $(OBJDIR)/p_slopes.o \ - $(OBJDIR)/tables.o \ - $(OBJDIR)/r_bsp.o \ - $(OBJDIR)/r_data.o \ - $(OBJDIR)/r_draw.o \ - $(OBJDIR)/r_main.o \ - $(OBJDIR)/r_plane.o \ - $(OBJDIR)/r_segs.o \ - $(OBJDIR)/r_skins.o \ - $(OBJDIR)/r_sky.o \ - $(OBJDIR)/r_splats.o \ - $(OBJDIR)/r_things.o \ - $(OBJDIR)/r_textures.o \ - $(OBJDIR)/r_patch.o \ - $(OBJDIR)/r_patchrotation.o \ - $(OBJDIR)/r_picformats.o \ - $(OBJDIR)/r_portal.o \ - $(OBJDIR)/screen.o \ - $(OBJDIR)/taglist.o \ - $(OBJDIR)/v_video.o \ - $(OBJDIR)/s_sound.o \ - $(OBJDIR)/sounds.o \ - $(OBJDIR)/w_wad.o \ - $(OBJDIR)/filesrch.o \ - $(OBJDIR)/mserv.o \ - $(OBJDIR)/http-mserv.o\ - $(OBJDIR)/i_tcp.o \ - $(OBJDIR)/lzf.o \ - $(OBJDIR)/vid_copy.o \ - $(OBJDIR)/k_kart.o \ - $(OBJDIR)/k_respawn.o\ - $(OBJDIR)/k_collide.o\ - $(OBJDIR)/k_color.o \ - $(OBJDIR)/k_race.o \ - $(OBJDIR)/k_battle.o \ - $(OBJDIR)/k_pwrlv.o \ - $(OBJDIR)/k_waypoint.o\ - $(OBJDIR)/k_pathfind.o\ - $(OBJDIR)/k_bheap.o \ - $(OBJDIR)/k_bot.o \ - $(OBJDIR)/k_botitem.o\ - $(OBJDIR)/k_botsearch.o\ - $(OBJDIR)/k_grandprix.o\ - $(OBJDIR)/k_hud.o \ - $(i_cdmus_o) \ - $(i_net_o) \ - $(i_system_o) \ - $(i_sound_o) \ - $(OBJS) +build_done==== Build is done, look for \ + $( $@ + $(.)$(GZIP) $(GZIP_OPTS) $@ -ifdef SDL -all: $(BIN)/$(EXENAME) -endif - -ifdef DUMMY -all: $(BIN)/$(EXENAME) -endif - -cleandep: - $(REMOVE) $(DEPS) - $(REMOVE) comptime.h - -clean: - $(REMOVE) *~ *.flc - $(REMOVE) $(OBJDIR)/*.o - -distclean: clean cleandep - -ifdef MINGW - $(REMOVE) $(OBJDIR)/*.res -endif - -ifdef CYGWIN32 - $(REMOVE) $(OBJDIR)/*.res -endif - -#make a big srb2.s that is the disasm of the exe (dos only ?) -asm: - $(CC) $(LDFLAGS) $(OBJS) -o $(OBJDIR)/tmp.exe $(LIBS) - $(OBJDUMP) -d $(OBJDIR)/tmp.exe --no-show-raw-insn > srb2.s - $(REMOVE) $(OBJDIR)/tmp.exe - -# executable -# NOTE: DJGPP's objcopy do not have --add-gnu-debuglink - -$(BIN)/$(EXENAME): $(POS) $(OBJS) - -$(MKDIR) $(BIN) - $(call echo,Linking $(EXENAME)...) - $(LD) $(LDFLAGS) $(OBJS) -o $(BIN)/$(EXENAME) $(LIBS) -ifndef VALGRIND -ifndef NOOBJDUMP - $(call echo,Dumping debugging info) - $(OBJDUMP) $(OBJDUMP_OPTS) $(BIN)/$(EXENAME) > $(BIN)/$(DBGNAME).txt +# '::' means run unconditionally +# this really updates comptime.h +comptime.c :: ifdef WINDOWSHELL - -$(GZIP) $(GZIP_OPTS) $(BIN)/$(DBGNAME).txt + $(.)..\comptime.bat . else - -$(GZIP) $(GZIP_OPT2) $(BIN)/$(DBGNAME).txt -endif + $(.)../comptime.sh . endif -# mac os x lsdlsrb2 does not like objcopy -ifndef MACOSX - $(OBJCOPY) $(BIN)/$(EXENAME) $(BIN)/$(DBGNAME) - $(OBJCOPY) --strip-debug $(BIN)/$(EXENAME) - -$(OBJCOPY) --add-gnu-debuglink=$(BIN)/$(DBGNAME) $(BIN)/$(EXENAME) -endif -ifndef NOUPX - -$(UPX) $(UPX_OPTS) $(BIN)/$(EXENAME) -endif -endif - $(call echo,Build is done$(,) please look for $(EXENAME) in $(BIN)$(,) (checking for post steps)) +# I wish I could make dependencies out of rc files :( +$(objdir)/win32/Srb2win.res : \ + win32/afxres.h win32/resource.h -reobjdump: - $(call echo,Redumping debugging info) - $(OBJDUMP) $(OBJDUMP_OPTS) $(BIN)/$(DBGNAME) > $(BIN)/$(DBGNAME).txt -ifdef WINDOWSHELL - -$(GZIP) $(GZIP_OPTS) $(BIN)/$(DBGNAME).txt -else - -$(GZIP) $(GZIP_OPT2) $(BIN)/$(DBGNAME).txt -endif - -$(OBJDIR): - -$(MKDIR) $(OBJDIR) - -ifdef SDL -ifdef MINGW -$(OBJDIR)/r_opengl.o: hardware/r_opengl/r_opengl.c hardware/r_opengl/r_opengl.h \ - doomdef.h doomtype.h g_state.h m_swap.h hardware/hw_drv.h screen.h \ - command.h hardware/hw_data.h hardware/hw_defs.h \ - hardware/hw_md2.h hardware/hw_glob.h hardware/hw_main.h hardware/hw_clip.h \ - hardware/hw_md2load.h hardware/hw_md3load.h hardware/hw_model.h hardware/u_list.h \ - am_map.h d_event.h d_player.h p_pspr.h m_fixed.h tables.h info.h d_think.h \ - p_mobj.h doomdata.h d_ticcmd.h r_defs.h hardware/hw_dll.h - $(echoName) - $(CC) $(CFLAGS) $(WFLAGS) -c $< -o $@ -else -$(OBJDIR)/r_opengl.o: hardware/r_opengl/r_opengl.c hardware/r_opengl/r_opengl.h \ - doomdef.h doomtype.h g_state.h m_swap.h hardware/hw_drv.h screen.h \ - command.h hardware/hw_data.h hardware/hw_defs.h \ - hardware/hw_md2.h hardware/hw_glob.h hardware/hw_main.h hardware/hw_clip.h \ - hardware/hw_md2load.h hardware/hw_md3load.h hardware/hw_model.h hardware/u_list.h \ - am_map.h d_event.h d_player.h p_pspr.h m_fixed.h tables.h info.h d_think.h \ - p_mobj.h doomdata.h d_ticcmd.h r_defs.h hardware/hw_dll.h - $(echoName) - $(CC) $(CFLAGS) $(WFLAGS) -I/usr/X11R6/include -c $< -o $@ -endif -endif - -#dependecy made by gcc itself ! -ifndef DUMMY -ifndef CLEANONLY -$(call print,Checking dependency files...) --include $(DEPS) -endif -endif - -undefine deps_rule - -# windows makes it too hard ! +# dependency recipe template +# 1: source file suffix +# 2: extra flags to gcc +define _recipe = +$(depdir)/%.d : %.$(1) | $$$$(@D)/ ifndef WINDOWSHELL -ifdef echoName -define deps_rule = - @printf "%-20.20s\r" $< - -endef +ifdef Echo_name + @printf '%-20.20s\r' $$< endif endif - -define deps_rule += - $(CC) $(CFLAGS) -M -MF $@ -MT $(OBJDIR)/$(<:.c=.o) $< + $(.)$(cc) -MM -MF $$@ -MT $(objdir)/$$*.o $(2) $$< endef -$(DEPDIR)/%.d: %.c - $(deps_rule) +$(eval $(call _recipe,c)) +$(eval $(call _recipe,s,$(asflags))) -$(DEPDIR)/%.d: $(INTERFACE)/%.c - $(deps_rule) +# compiling recipe template +# 1: target file suffix +# 2: source file suffix +# 3: compile command +define _recipe = +$(objdir)/%.$(1) : %.$(2) | $$$$(@D)/ + $(call Echo_name,$$<) + $(.)$(3) +endef -$(DEPDIR)/%.d: hardware/%.c - $(deps_rule) +$(eval $(call _recipe,o,c,$(cc) -c -o $$@ $$<)) +$(eval $(call _recipe,o,nas,$(nasm) -o $$@ $$<)) +$(eval $(call _recipe,o,s,$(cc) $(asflags) -c -o $$@ $$<)) +$(eval $(call _recipe,res,rc,$(windres) -i $$< -o $$@)) -$(DEPDIR)/%.d: blua/%.c - $(deps_rule) +_rm=$(.)$(rmrf) $(call Windows_path,$(1)) -ifdef VALGRIND -$(OBJDIR)/z_zone.o: z_zone.c - $(echoName) - $(CC) $(CFLAGS) $(WFLAGS) -DHAVE_VALGRIND $(VALGRIND_CFLAGS) -c $< -o $@ -endif +cleandep : + $(call _rm,$(depends) comptime.h) -$(OBJDIR)/comptime.o:: -ifdef echoName - @echo -- comptime.c ... -endif - $(COMPTIME) . - $(CC) $(CFLAGS) $(WFLAGS) -c comptime.c -o $@ +clean : + $(call _rm,$(exe) $(dbg) $(dbg).txt $(objects)) -$(BIN)/%.mo: locale/%.po - -$(MKDIR) $(BIN) - $(echoName) - $(MSGFMT) -f -o $@ $< +distclean : + $(call _rm,../bin ../objs ../dep ../make comptime.h) -$(OBJDIR)/%.o: %.c - $(echoName) - $(CC) $(CFLAGS) $(WFLAGS) -c $< -o $@ - -$(OBJDIR)/%.o: $(INTERFACE)/%.c - $(echoName) - $(CC) $(CFLAGS) $(WFLAGS) -c $< -o $@ - -ifdef MACOSX -$(OBJDIR)/%.o: sdl/macosx/%.c - $(echoName) - $(CC) $(CFLAGS) $(WFLAGS) -c $< -o $@ -endif - -$(OBJDIR)/%.o: hardware/%.c - $(echoName) - $(CC) $(CFLAGS) $(WFLAGS) -c $< -o $@ - -$(OBJDIR)/%.o: blua/%.c - $(echoName) - $(CC) $(CFLAGS) $(LUA_CFLAGS) $(WFLAGS) -c $< -o $@ - -$(OBJDIR)/%.o: %.nas - $(echoName) - $(NASM) $(NASMOPTS) -o $@ -f $(NASMFORMAT) $< - -$(OBJDIR)/vid_copy.o: vid_copy.s asm_defs.inc - $(echoName) - $(CC) $(OPTS) $(ASFLAGS) -x assembler-with-cpp -c $< -o $@ - -$(OBJDIR)/%.o: %.s - $(echoName) - $(CC) $(OPTS) -x assembler-with-cpp -c $< -o $@ - -$(OBJDIR)/SRB2.res: win32/Srb2win.rc win32/afxres.h win32/resource.h - $(echoName) - $(WINDRES) -i $< -O rc $(WINDRESFLAGS) --include-dir=win32 -o $@ -O coff - - -ifdef SDL - -ifdef MINGW -$(OBJDIR)/win_dbg.o: win32/win_dbg.c - $(echoName) - $(CC) $(CFLAGS) $(WFLAGS) -c $< -o $@ -endif - -ifdef STATICHS -$(OBJDIR)/s_openal.o: hardware/s_openal/s_openal.c hardware/hw3dsdrv.h \ - hardware/hw_dll.h - $(echoName) - $(CC) $(CFLAGS) $(WFLAGS) -c $< -o $@ - -$(OBJDIR)/s_fmod.o: hardware/s_fmod/s_fmod.c hardware/hw3dsdrv.h \ - hardware/hw_dll.h - $(echoName) - $(CC) $(CFLAGS) $(WFLAGS) -c $< -o $@ - -ifdef MINGW -$(OBJDIR)/s_ds3d.o: hardware/s_ds3d/s_ds3d.c hardware/hw3dsdrv.h \ - hardware/hw_dll.h - $(echoName) - $(CC) $(CFLAGS) $(WFLAGS) -c $< -o $@ -endif +info: +ifdef WINDOWSHELL + @REM else - -$(OBJDIR)/s_fmod.o: hardware/s_fmod/s_fmod.c hardware/hw3dsdrv.h \ - hardware/hw_dll.h - $(echoName) - $(CC) $(ARCHOPTS) -Os -o $(OBJDIR)/s_fmod.o -DHW3SOUND -DUNIXCOMMON -shared -nostartfiles -c hardware/s_fmod/s_fmod.c - -$(OBJDIR)/s_openal.o: hardware/s_openal/s_openal.c hardware/hw3dsdrv.h \ - hardware/hw_dll.h - $(echoName) - $(CC) $(ARCHOPTS) -Os -o $(OBJDIR)/s_openal.o -DHW3SOUND -DUNIXCOMMON -shared -nostartfiles -c hardware/s_openal/s_openal.c + @: endif -endif - -############################################################# -# -############################################################# diff --git a/src/Makefile.cfg b/src/Makefile.cfg deleted file mode 100644 index e9bdcfbde..000000000 --- a/src/Makefile.cfg +++ /dev/null @@ -1,482 +0,0 @@ -# vim: ft=make -# -# Makefile.cfg for SRB2 -# - -# -# GNU compiler & tools' flags -# and other things -# - -# See the following variable don't start with 'GCC'. This is -# to avoid a false positive with the version detection... - -SUPPORTED_GCC_VERSIONS:=\ - 101 102\ - 91 92 93\ - 81 82 83 84\ - 71 72 73 74 75\ - 61 62 63 64\ - 51 52 53 54 55\ - 40 41 42 43 44 45 46 47 48 49 - -LATEST_GCC_VERSION=10.2 - -# gcc or g++ -ifdef PREFIX - CC=$(PREFIX)-gcc - CXX=$(PREFIX)-g++ - OBJCOPY=$(PREFIX)-objcopy - OBJDUMP=$(PREFIX)-objdump - STRIP=$(PREFIX)-strip - WINDRES=$(PREFIX)-windres -else - OBJCOPY=objcopy - OBJDUMP=objdump - STRIP=strip - WINDRES=windres -endif - -# because Apple screws with us on this -# need to get bintools from homebrew -ifdef MACOSX - CC=clang - CXX=clang - OBJCOPY=gobjcopy - OBJDUMP=gobjdump -endif - -# Automatically set version flag, but not if one was manually set -# And don't bother if this is a clean only run -ifeq (,$(filter GCC% CLEANONLY,$(.VARIABLES))) - version:=$(shell $(CC) --version) - # check if this is in fact GCC - ifneq (,$(or $(findstring gcc,$(version)),$(findstring GCC,$(version)))) - version:=$(shell $(CC) -dumpversion) - - # Turn version into words of major, minor - v:=$(subst ., ,$(version)) - # concat. major minor - v:=$(word 1,$(v))$(word 2,$(v)) - - # If this version is not in the list, default to the latest supported - ifeq (,$(filter $(v),$(SUPPORTED_GCC_VERSIONS))) - define line = - Your compiler version, GCC $(version), is not supported by the Makefile. - The Makefile will assume GCC $(LATEST_GCC_VERSION).)) - endef - $(call print,$(line)) - GCC$(subst .,,$(LATEST_GCC_VERSION))=1 - else - $(call print,Detected GCC $(version) (GCC$(v))) - GCC$(v)=1 - endif - endif -endif - -ifdef GCC102 -GCC101=1 -endif - -ifdef GCC101 -GCC93=1 -endif - -ifdef GCC93 -GCC92=1 -endif - -ifdef GCC92 -GCC91=1 -endif - -ifdef GCC91 -GCC84=1 -endif - -ifdef GCC84 -GCC83=1 -endif - -ifdef GCC83 -GCC82=1 -endif - -ifdef GCC82 -GCC81=1 -endif - -ifdef GCC81 -GCC75=1 -endif - -ifdef GCC75 -GCC74=1 -endif - -ifdef GCC74 -GCC73=1 -endif - -ifdef GCC73 -GCC72=1 -endif - -ifdef GCC72 -GCC71=1 -endif - -ifdef GCC71 -GCC64=1 -endif - -ifdef GCC64 -GCC63=1 -endif - -ifdef GCC63 -GCC62=1 -endif - -ifdef GCC62 -GCC61=1 -endif - -ifdef GCC61 -GCC55=1 -endif - -ifdef GCC55 -GCC54=1 -endif - -ifdef GCC54 -GCC53=1 -endif - -ifdef GCC53 -GCC52=1 -endif - -ifdef GCC52 -GCC51=1 -endif - -ifdef GCC51 -GCC49=1 -endif - -ifdef GCC49 -GCC48=1 -endif - -ifdef GCC48 -GCC47=1 -endif - -ifdef GCC47 -GCC46=1 -endif - -ifdef GCC46 -GCC45=1 -endif - -ifdef GCC45 -GCC44=1 -endif - -ifdef GCC44 -GCC43=1 -endif - -ifdef GCC43 -GCC42=1 -endif - -ifdef GCC42 -GCC41=1 -endif - -ifdef GCC41 -GCC40=1 -VCHELP=1 -endif - -ifdef GCC295 -GCC29=1 -endif - -OLDWFLAGS:=$(WFLAGS) -# -W -Wno-unused -WFLAGS=-Wall -ifndef GCC295 -#WFLAGS+=-Wno-packed -endif -ifndef RELAXWARNINGS - WFLAGS+=-W -#WFLAGS+=-Wno-sign-compare -ifndef GCC295 - WFLAGS+=-Wno-div-by-zero -endif -#WFLAGS+=-Wsystem-headers -WFLAGS+=-Wfloat-equal -#WFLAGS+=-Wtraditional -ifdef VCHELP - WFLAGS+=-Wdeclaration-after-statement - WFLAGS+=-Wno-error=declaration-after-statement -endif - WFLAGS+=-Wundef -ifndef GCC295 - WFLAGS+=-Wendif-labels -endif -ifdef GCC40 - WFLAGS+=-std=gnu89 -endif -ifdef GCC41 - WFLAGS+=-Wshadow -endif -#WFLAGS+=-Wlarger-than-%len% - WFLAGS+=-Wpointer-arith -Wbad-function-cast -ifdef GCC45 -#WFLAGS+=-Wc++-compat -endif - WFLAGS+=-Wcast-qual -ifndef NOCASTALIGNWARN - WFLAGS+=-Wcast-align -endif - WFLAGS+=-Wwrite-strings -ifndef ERRORMODE -#WFLAGS+=-Wconversion -ifdef GCC43 - #WFLAGS+=-Wno-sign-conversion -endif -endif - WFLAGS+=-Wsign-compare -ifdef GCC91 - WFLAGS+=-Wno-error=address-of-packed-member -endif -ifdef GCC45 - WFLAGS+=-Wlogical-op -endif - WFLAGS+=-Waggregate-return -ifdef HAIKU -ifdef GCC41 - #WFLAGS+=-Wno-attributes -endif -endif -#WFLAGS+=-Wstrict-prototypes -ifdef GCC40 - WFLAGS+=-Wold-style-definition -endif - WFLAGS+=-Wmissing-prototypes -Wmissing-declarations -ifdef GCC40 - WFLAGS+=-Wmissing-field-initializers -endif - WFLAGS+=-Wmissing-noreturn -#WFLAGS+=-Wmissing-format-attribute -#WFLAGS+=-Wno-multichar -#WFLAGS+=-Wno-deprecated-declarations -#WFLAGS+=-Wpacked -#WFLAGS+=-Wpadded -#WFLAGS+=-Wredundant-decls - WFLAGS+=-Wnested-externs -#WFLAGS+=-Wunreachable-code - WFLAGS+=-Winline -ifdef GCC43 - WFLAGS+=-funit-at-a-time - WFLAGS+=-Wlogical-op -endif -ifndef GCC295 - WFLAGS+=-Wdisabled-optimization -endif -endif -WFLAGS+=-Wformat-y2k -ifdef GCC71 -WFLAGS+=-Wno-error=format-overflow=2 -endif -WFLAGS+=-Wformat-security -ifndef GCC29 -#WFLAGS+=-Winit-self -endif -ifdef GCC46 -WFLAGS+=-Wno-suggest-attribute=noreturn -endif - -ifdef NOLDWARNING -LDFLAGS+=-Wl,--as-needed -endif - -ifdef ERRORMODE -WFLAGS+=-Werror -endif - -WFLAGS+=$(OLDWFLAGS) - -ifdef GCC43 - #WFLAGS+=-Wno-error=clobbered -endif -ifdef GCC44 - WFLAGS+=-Wno-error=array-bounds -endif -ifdef GCC46 - WFLAGS+=-Wno-error=suggest-attribute=noreturn -endif -ifdef GCC54 - WFLAGS+=-Wno-logical-op -Wno-error=logical-op -endif -ifdef GCC61 - WFLAGS+=-Wno-tautological-compare -Wno-error=tautological-compare -endif -ifdef GCC71 - WFLAGS+=-Wimplicit-fallthrough=4 - WFLAGS+=-Wno-format-truncation -endif -ifdef GCC81 - WFLAGS+=-Wno-error=format-overflow - WFLAGS+=-Wno-error=stringop-truncation - WFLAGS+=-Wno-error=stringop-overflow - WFLAGS+=-Wno-format-overflow - WFLAGS+=-Wno-stringop-truncation - WFLAGS+=-Wno-stringop-overflow - WFLAGS+=-Wno-error=multistatement-macros -endif - - -#indicate platform and what interface use with -ifndef LINUX -ifndef FREEBSD -ifndef CYGWIN32 -ifndef MINGW -ifndef MINGW64 -ifndef SDL -ifndef DUMMY -$(error No interface or platform flag defined) -endif -endif -endif -endif -endif -endif -endif - -#determine the interface directory (where you put all i_*.c) -i_net_o=$(OBJDIR)/i_net.o -i_system_o=$(OBJDIR)/i_system.o -i_sound_o=$(OBJDIR)/i_sound.o -i_main_o=$(OBJDIR)/i_main.o -#set OBJDIR and BIN's starting place -OBJDIR=../objs -BIN=../bin -DEPDIR=../dep -#Nasm ASM and rm -ifdef YASM -NASM?=yasm -else -NASM?=nasm -endif -REMOVE?=rm -f -MKDIR?=mkdir -p -GZIP?=gzip -GZIP_OPTS?=-9 -f -n -GZIP_OPT2=$(GZIP_OPTS) --rsyncable -UPX?=upx -UPX_OPTS?=--best --preserve-build-id -ifndef ECHO -UPX_OPTS+=-q -endif - -#Interface Setup -ifdef DUMMY - INTERFACE=dummy - OBJDIR:=$(OBJDIR)/dummy - BIN:=$(BIN)/dummy - DEPDIR:=$(DEPDIR)/dummy -else -ifdef LINUX - NASMFORMAT=elf -DLINUX - SDL=1 -ifdef LINUX64 - OBJDIR:=$(OBJDIR)/Linux64 - BIN:=$(BIN)/Linux64 - DEPDIR:=$(DEPDIR)/Linux64 -else - OBJDIR:=$(OBJDIR)/Linux - BIN:=$(BIN)/Linux - DEPDIR:=$(DEPDIR)/Linux -endif -else -ifdef FREEBSD - INTERFACE=sdl - NASMFORMAT=elf -DLINUX - SDL=1 - - OBJDIR:=$(OBJDIR)/FreeBSD - BIN:=$(BIN)/FreeBSD - DEPDIR:=$(DEPDIR)/Linux -else -ifdef SOLARIS - INTERFACE=sdl - NASMFORMAT=elf -DLINUX - SDL=1 - - OBJDIR:=$(OBJDIR)/Solaris - BIN:=$(BIN)/Solaris - DEPDIR:=$(DEPDIR)/Solaris -else -ifdef CYGWIN32 - INTERFACE=sdl - NASMFORMAT=win32 - SDL=1 - - OBJDIR:=$(OBJDIR)/cygwin - BIN:=$(BIN)/Cygwin - DEPDIR:=$(DEPDIR)/Cygwin -else -ifdef MINGW64 - #NASMFORMAT=win64 - SDL=1 - OBJDIR:=$(OBJDIR)/Mingw64 - BIN:=$(BIN)/Mingw64 - DEPDIR:=$(DEPDIR)/Mingw64 -else -ifdef MINGW - NASMFORMAT=win32 - SDL=1 - OBJDIR:=$(OBJDIR)/Mingw - BIN:=$(BIN)/Mingw - DEPDIR:=$(DEPDIR)/Mingw -endif -endif -endif -endif -endif -endif -endif - -ifdef ARCHNAME - OBJDIR:=$(OBJDIR)/$(ARCHNAME) - BIN:=$(BIN)/$(ARCHNAME) - DEPDIR:=$(DEPDIR)/$(ARCHNAME) -endif - -OBJDUMP_OPTS?=--wide --source --line-numbers -LD=$(CC) - -ifdef SDL - INTERFACE=sdl - OBJDIR:=$(OBJDIR)/SDL - DEPDIR:=$(DEPDIR)/SDL -endif - -ifndef DUMMY -ifdef DEBUGMODE - OBJDIR:=$(OBJDIR)/Debug - BIN:=$(BIN)/Debug - DEPDIR:=$(DEPDIR)/Debug -else - OBJDIR:=$(OBJDIR)/Release - BIN:=$(BIN)/Release - DEPDIR:=$(DEPDIR)/Release -endif -endif diff --git a/src/Makefile.d/detect.mk b/src/Makefile.d/detect.mk new file mode 100644 index 000000000..f458b044c --- /dev/null +++ b/src/Makefile.d/detect.mk @@ -0,0 +1,107 @@ +# +# Detect the host system and compiler version. +# + +# Previously featured:\ + PANDORA\ + HAIKU\ + DUMMY\ + DJGPPDOS\ + SOLARIS\ + MACOSX\ + +all_systems:=\ + LINUX64\ + MINGW64\ + MINGW\ + UNIX\ + LINUX\ + FREEBSD\ + SDL\ + +# check for user specified system +ifeq (,$(filter $(all_systems),$(.VARIABLES))) +ifeq ($(OS),Windows_NT) # all windows are Windows_NT... + +_m=Detected a Windows system,\ + compiling for 32-bit MinGW SDL...) +$(call Print,$(_m)) + +# go for a 32-bit sdl mingw exe by default +MINGW:=1 + +else # if you on the *nix + +system:=$(shell uname -s) + +ifeq ($(system),Linux) +new_system:=LINUX +else + +$(error \ + Could not automatically detect your system,\ + try specifying a system manually) + +endif + +ifeq ($(shell getconf LONG_BIT),64) +system+=64-bit +new_system:=$(new_system)64 +endif + +$(call Print,Detected $(system) ($(new_system))...) +$(new_system):=1 + +endif +endif + +# This must have high to low order. +gcc_versions:=\ + 102 101\ + 93 92 91\ + 84 83 82 81\ + 75 74 73 72 71\ + 64 63 62 61\ + 55 54 53 52 51\ + 49 48 47 46 45 44 43 42 41 40 + +latest_gcc_version:=10.2 + +# Automatically set version flag, but not if one was +# manually set. And don't bother if this is a clean only +# run. +ifeq (,$(call Wildvar,GCC% destructive)) + +# can't use $(CC) --version here since that uses argv[0] to display the name +# also gcc outputs the information to stderr, so I had to do 2>&1 +# this program really doesn't like identifying itself +version:=$(shell $(CC) -v 2>&1) + +# check if this is in fact GCC +ifneq (,$(findstring gcc version,$(version))) + +# in stark contrast to the name, gcc will give me a nicely formatted version number for free +version:=$(shell $(CC) -dumpfullversion) + +# Turn version into words of major, minor +v:=$(subst ., ,$(version)) +# concat. major minor +v:=$(word 1,$(v))$(word 2,$(v)) + +# If this version is not in the list, +# default to the latest supported +ifeq (,$(filter $(v),$(gcc_versions))) +define line = +Your compiler version, GCC $(version), \ +is not supported by the Makefile. +The Makefile will assume GCC $(latest_gcc_version). +endef +$(call Print,$(line)) +GCC$(subst .,,$(latest_gcc_version)):=1 +else +$(call Print,Detected GCC $(version) (GCC$(v))) +GCC$(v):=1 +endif + +endif +endif diff --git a/src/Makefile.d/features.mk b/src/Makefile.d/features.mk new file mode 100644 index 000000000..abdc342b7 --- /dev/null +++ b/src/Makefile.d/features.mk @@ -0,0 +1,76 @@ +# +# Makefile for feature flags. +# + +passthru_opts+=\ + NONET NO_IPV6 NOHW NOMD5 NOPOSTPROCESSING\ + MOBJCONSISTANCY PACKETDROP ZDEBUG\ + HAVE_MINIUPNPC\ + +# build with debugging information +ifdef DEBUGMODE +MOBJCONSISTANCY=1 +PACKETDROP=1 +opts+=-DPARANOIA -DRANGECHECK +endif + +ifndef NOHW +opts+=-DHWRENDER +sources+=$(call List,hardware/Sourcefile) +endif + +ifndef NOASM +ifndef NONX86 +sources+=tmap.nas tmap_mmx.nas +opts+=-DUSEASM +endif +endif + +ifndef NOMD5 +sources+=md5.c +endif + +ifndef NOZLIB +ifndef NOPNG +ifdef PNG_PKGCONFIG +$(eval $(call Use_pkg_config,PNG_PKGCONFIG)) +else +PNG_CONFIG?=$(call Prefix,libpng-config) +$(eval $(call Configure,PNG,$(PNG_CONFIG) \ + $(if $(PNG_STATIC),--static),,--ldflags)) +endif +ifdef LINUX +opts+=-D_LARGFILE64_SOURCE +endif +opts+=-DHAVE_PNG +sources+=apng.c +endif +endif + +ifndef NONET +ifndef NOCURL +CURLCONFIG?=curl-config +$(eval $(call Configure,CURL,$(CURLCONFIG))) +opts+=-DHAVE_CURL +endif +endif + +ifdef HAVE_MINIUPNPC +libs+=-lminiupnpc +endif + +# (Valgrind is a memory debugger.) +ifdef VALGRIND +VALGRIND_PKGCONFIG?=valgrind +$(eval $(call Use_pkg_config,VALGRIND)) +ZDEBUG=1 +opts+=-DHAVE_VALGRIND +endif + +default_packages:=\ + GME/libgme/LIBGME\ + OPENMPT/libopenmpt/LIBOPENMPT\ + ZLIB/zlib\ + +$(foreach p,$(default_packages),\ + $(eval $(call Check_pkg_config,$(p)))) diff --git a/src/Makefile.d/nix.mk b/src/Makefile.d/nix.mk new file mode 100644 index 000000000..98703e769 --- /dev/null +++ b/src/Makefile.d/nix.mk @@ -0,0 +1,40 @@ +# +# Makefile options for unices (linux, bsd...) +# + +EXENAME?=lsdl2srb2kart + +opts+=-DUNIXCOMMON -DLUA_USE_POSIX +libs+=-lm + +ifndef nasm_format +nasm_format:=elf -DLINUX +endif + +ifndef NOHW +opts+=-I/usr/X11R6/include +libs+=-L/usr/X11R6/lib +endif + +SDL=1 + +# In common usage. +ifdef LINUX +libs+=-lrt +passthru_opts+=NOTERMIOS +endif + +# Tested by Steel, as of release 2.2.8. +ifdef FREEBSD +opts+=-I/usr/X11R6/include -DLINUX -DFREEBSD +libs+=-L/usr/X11R6/lib -lipx -lkvm +endif + +# FIXME: UNTESTED +#ifdef SOLARIS +#NOIPX=1 +#NOASM=1 +#opts+=-I/usr/local/include -I/opt/sfw/include \ +# -DSOLARIS -DINADDR_NONE=INADDR_ANY -DBSD_COMP +#libs+=-L/opt/sfw/lib -lsocket -lnsl +#endif diff --git a/src/Makefile.d/old.mk b/src/Makefile.d/old.mk new file mode 100644 index 000000000..ec9b6d776 --- /dev/null +++ b/src/Makefile.d/old.mk @@ -0,0 +1,16 @@ +# +# Warn about old build directories and offer to purge. +# + +_old:=$(wildcard $(addprefix ../bin/,FreeBSD Linux \ + Linux64 Mingw Mingw64 SDL dummy) ../objs ../dep) + +ifdef _old +$(foreach v,$(_old),$(info $(abspath $(v)))) +$(info ) +$(info These directories are no longer\ + required and should be removed.) +$(info You may remove them manually or\ + by using 'make distclean') +$(error ) +endif diff --git a/src/Makefile.d/platform.mk b/src/Makefile.d/platform.mk new file mode 100644 index 000000000..fad4be191 --- /dev/null +++ b/src/Makefile.d/platform.mk @@ -0,0 +1,69 @@ +# +# Platform specific options. +# + +PKG_CONFIG?=pkg-config + +ifdef WINDOWSHELL +rmrf=-2>NUL DEL /S /Q +mkdir=-2>NUL MD +cat=TYPE +else +rmrf=rm -rf +mkdir=mkdir -p +cat=cat +endif + +ifdef LINUX64 +LINUX=1 +endif + +ifdef MINGW64 +MINGW=1 +endif + +ifdef LINUX +UNIX=1 +ifdef LINUX64 +NONX86=1 +# LINUX64 does not imply X86_64=1; +# could mean ARM64 or Itanium +platform=linux/64 +else +platform=linux +endif +else ifdef FREEBSD +UNIX=1 +platform=freebsd +else ifdef SOLARIS # FIXME: UNTESTED +UNIX=1 +platform=solaris +else ifdef CYGWIN32 # FIXME: UNTESTED +nasm_format=win32 +platform=cygwin +else ifdef MINGW +ifdef MINGW64 +NONX86=1 +NOASM=1 +# MINGW64 should not necessarily imply X86_64=1, +# but we make that assumption elsewhere +# Once that changes, remove this +X86_64=1 +platform=mingw/64 +else +platform=mingw +endif +include Makefile.d/win32.mk +endif + +ifdef platform +makedir:=$(makedir)/$(platform) +endif + +ifdef UNIX +include Makefile.d/nix.mk +endif + +ifdef SDL +include Makefile.d/sdl.mk +endif diff --git a/src/Makefile.d/sdl.mk b/src/Makefile.d/sdl.mk new file mode 100644 index 000000000..99ca624e6 --- /dev/null +++ b/src/Makefile.d/sdl.mk @@ -0,0 +1,79 @@ +# +# Makefile options for SDL2 backend. +# + +# +# SDL...., *looks at Alam*, THIS IS A MESS! +# +# ...a little bird flexes its muscles... +# + +makedir:=$(makedir)/SDL + +sources+=$(call List,sdl/Sourcefile) +opts+=-DDIRECTFULLSCREEN -DHAVE_SDL + +# FIXME: UNTESTED +#ifdef PANDORA +#include sdl/SRB2Pandora/Makefile.cfg +#endif #ifdef PANDORA + +# FIXME: UNTESTED +#ifdef CYGWIN32 +#include sdl/MakeCYG.cfg +#endif #ifdef CYGWIN32 + +ifndef NOHW +sources+=sdl/ogl_sdl.c +endif + +ifdef NOMIXER +sources+=sdl/sdl_sound.c +else +opts+=-DHAVE_MIXER +sources+=sdl/mixer_sound.c + + ifdef HAVE_MIXERX + opts+=-DHAVE_MIXERX + libs+=-lSDL2_mixer_ext + else + libs+=-lSDL2_mixer + endif +endif + +ifndef NOTHREADS +opts+=-DHAVE_THREADS +sources+=sdl/i_threads.c +endif + +ifdef SDL_PKGCONFIG +$(eval $(call Use_pkg_config,SDL)) +else +SDL_CONFIG?=$(call Prefix,sdl2-config) +SDL_CFLAGS?=$(shell $(SDL_CONFIG) --cflags) +SDL_LDFLAGS?=$(shell $(SDL_CONFIG) \ + $(if $(STATIC),--static-libs,--libs)) +$(eval $(call Propogate_flags,SDL)) +endif + +# use the x86 asm code +ifndef CYGWIN32 +ifndef NOASM +USEASM=1 +endif +endif + +ifdef MINGW +ifndef NOSDLMAIN +SDLMAIN=1 +endif +endif + +ifdef SDLMAIN +opts+=-DSDLMAIN +else +ifdef MINGW +opts+=-Umain +libs+=-mconsole +endif +endif diff --git a/src/Makefile.d/util.mk b/src/Makefile.d/util.mk new file mode 100644 index 000000000..bda68df13 --- /dev/null +++ b/src/Makefile.d/util.mk @@ -0,0 +1,93 @@ +# +# Utility macros for the rest of the Makefiles. +# + +Ifnot=$(if $(1),$(3),$(2)) +Ifndef=$(call Ifnot,$($(1)),$(2),$(3)) + +# Match and expand a list of variables by pattern. +Wildvar=$(foreach v,$(filter $(1),$(.VARIABLES)),$($(v))) + +# Read a list of words from file and prepend each with the +# directory of the file. +_cat=$(shell $(cat) $(call Windows_path,$(1))) +List=$(addprefix $(dir $(1)),$(call _cat,$(1))) + +# Convert path separators to backslash on Windows. +Windows_path=$(if $(WINDOWSHELL),$(subst /,\,$(1)),$(1)) + +define Propogate_flags = +opts+=$$($(1)_CFLAGS) +libs+=$$($(1)_LDFLAGS) +endef + +# Set library's _CFLAGS and _LDFLAGS from some command. +# Automatically propogates the flags too. +# 1: variable prefix (e.g. CURL) +# 2: start of command (e.g. curl-config) +# --- optional ---- +# 3: CFLAGS command arguments, default '--cflags' +# 4: LDFLAGS command arguments, default '--libs' +# 5: common command arguments at the end of command +define Configure = +$(1)_CFLAGS?=$$(shell $(2) $(or $(3),--cflags) $(5)) +$(1)_LDFLAGS?=$$(shell $(2) $(or $(4),--libs) $(5)) +$(call Propogate_flags,$(1)) +endef + +# Configure library with pkg-config. The package name is +# taken from a _PKGCONFIG variable. +# 1: variable prefix +# +# LIBGME_PKGCONFIG=libgme +# $(eval $(call Use_pkg_config,LIBGME)) +define Use_pkg_config = +$(call Configure,$(1),$(PKG_CONFIG),,,$($(1)_PKGCONFIG)) +endef + +# Check disabling flag and configure package in one step +# according to delimited argument. +# (There is only one argument, but it split by slash.) +# 1/: short form library name (uppercase). This is +# prefixed with 'NO' and 'HAVE_'. E.g. NOGME, HAVE_GME +# /2: package name (e.g. libgme) +# /3: variable prefix +# +# The following example would check if NOGME is not +# defined before attempting to define LIBGME_CFLAGS and +# LIBGME_LDFLAGS as with Use_pkg_config. +# +# $(eval $(call Check_pkg_config,GME/libgme/LIBGME)) +define Check_pkg_config = +_p:=$(subst /, ,$(1)) +_v1:=$$(word 1,$$(_p)) +_v2:=$$(or $$(word 3,$$(_p)),$$(_v1)) +ifndef NO$$(_v1) +$$(_v2)_PKGCONFIG?=$$(word 2,$$(_p)) +$$(eval $$(call Use_pkg_config,$$(_v2))) +opts+=-DHAVE_$$(_v1) +endif +endef + +# $(call Prefix,gcc) +Prefix=$(if $(PREFIX),$(PREFIX)-)$(1) + +Echo= +Echo_name= +Print= + +ifndef SILENT +Echo=@echo $(1) +ifndef ECHO +ifndef NOECHOFILENAMES +Echo_name=$(call Echo,-- $(1) ...) +endif +endif +ifndef MAKE_RESTARTS +ifndef destructive +Print=$(info $(1)) +endif +endif +endif + +.=$(call Ifndef,ECHO,@) diff --git a/src/Makefile.d/versions.mk b/src/Makefile.d/versions.mk new file mode 100644 index 000000000..7a021dda7 --- /dev/null +++ b/src/Makefile.d/versions.mk @@ -0,0 +1,181 @@ +# +# Flags to put a sock in GCC! +# + +# See the versions list in detect.mk +# This will define all version flags going backward. +# Yes, it's magic. +define _predecessor = +ifdef GCC$(firstword $(1)) +GCC$(lastword $(1)):=1 +endif +endef +_n:=$(words $(gcc_versions)) +$(foreach v,$(join $(wordlist 2,$(_n),- $(gcc_versions)),\ + $(addprefix =,$(wordlist 2,$(_n),$(gcc_versions)))),\ + $(and $(findstring =,$(v)),\ + $(eval $(call _predecessor,$(subst =, ,$(v)))))) + +# -W -Wno-unused +WFLAGS:=-Wall -Wno-trigraphs +ifndef GCC295 +#WFLAGS+=-Wno-packed +endif +ifndef RELAXWARNINGS + WFLAGS+=-W +#WFLAGS+=-Wno-sign-compare +ifndef GCC295 + WFLAGS+=-Wno-div-by-zero +endif +#WFLAGS+=-Wsystem-headers +WFLAGS+=-Wfloat-equal +#WFLAGS+=-Wtraditional + WFLAGS+=-Wundef +ifndef GCC295 + WFLAGS+=-Wendif-labels +endif +ifdef GCC40 + WFLAGS+=-std=gnu89 +endif +ifdef GCC41 + WFLAGS+=-Wdeclaration-after-statement + WFLAGS+=-Wno-error=declaration-after-statement + WFLAGS+=-Wshadow +endif +#WFLAGS+=-Wlarger-than-%len% + WFLAGS+=-Wpointer-arith -Wbad-function-cast +ifdef GCC45 +#WFLAGS+=-Wc++-compat +endif + WFLAGS+=-Wcast-qual +ifndef NOCASTALIGNWARN + WFLAGS+=-Wcast-align +endif + WFLAGS+=-Wwrite-strings +ifndef ERRORMODE +#WFLAGS+=-Wconversion +ifdef GCC43 + #WFLAGS+=-Wno-sign-conversion +endif +endif + WFLAGS+=-Wsign-compare +ifdef GCC91 + WFLAGS+=-Wno-error=address-of-packed-member +endif +ifdef GCC45 + WFLAGS+=-Wlogical-op +endif + WFLAGS+=-Waggregate-return +ifdef HAIKU +ifdef GCC41 + #WFLAGS+=-Wno-attributes +endif +endif +#WFLAGS+=-Wstrict-prototypes +ifdef GCC40 + WFLAGS+=-Wold-style-definition +endif + WFLAGS+=-Wmissing-prototypes -Wmissing-declarations +ifdef GCC40 + WFLAGS+=-Wmissing-field-initializers +endif + WFLAGS+=-Wmissing-noreturn +#WFLAGS+=-Wmissing-format-attribute +#WFLAGS+=-Wno-multichar +#WFLAGS+=-Wno-deprecated-declarations +#WFLAGS+=-Wpacked +#WFLAGS+=-Wpadded +#WFLAGS+=-Wredundant-decls + WFLAGS+=-Wnested-externs +#WFLAGS+=-Wunreachable-code + WFLAGS+=-Winline +ifdef GCC43 + WFLAGS+=-funit-at-a-time + WFLAGS+=-Wlogical-op +endif +ifndef GCC295 + WFLAGS+=-Wdisabled-optimization +endif +endif +WFLAGS+=-Wformat-y2k +ifdef GCC71 +WFLAGS+=-Wno-error=format-overflow=2 +endif +WFLAGS+=-Wformat-security +ifndef GCC29 +#WFLAGS+=-Winit-self +endif +ifdef GCC46 +WFLAGS+=-Wno-suggest-attribute=noreturn +endif + +ifdef NOLDWARNING +LDFLAGS+=-Wl,--as-needed +endif + +ifdef ERRORMODE +WFLAGS+=-Werror +endif + +ifdef GCC43 + #WFLAGS+=-Wno-error=clobbered +endif +ifdef GCC44 + WFLAGS+=-Wno-error=array-bounds +endif +ifdef GCC46 + WFLAGS+=-Wno-error=suggest-attribute=noreturn +endif +ifdef GCC54 + WFLAGS+=-Wno-logical-op -Wno-error=logical-op +endif +ifdef GCC61 + WFLAGS+=-Wno-tautological-compare -Wno-error=tautological-compare +endif +ifdef GCC71 + WFLAGS+=-Wimplicit-fallthrough=4 + WFLAGS+=-Wno-format-truncation +endif +ifdef GCC81 + WFLAGS+=-Wno-error=format-overflow + WFLAGS+=-Wno-error=stringop-truncation + WFLAGS+=-Wno-error=stringop-overflow + WFLAGS+=-Wno-format-overflow + WFLAGS+=-Wno-stringop-truncation + WFLAGS+=-Wno-stringop-overflow + WFLAGS+=-Wno-error=multistatement-macros +endif + +ifdef NONX86 + ifdef X86_64 # yeah that SEEMS contradictory + opts+=-march=nocona + endif +else + ifndef GCC29 + opts+=-msse3 -mfpmath=sse + else + opts+=-mpentium + endif +endif + +ifdef DEBUGMODE +ifdef GCC48 +opts+=-Og +else +opts+=O0 +endif +endif + +ifdef VALGRIND +ifdef GCC46 +WFLAGS+=-Wno-error=unused-but-set-variable +WFLAGS+=-Wno-unused-but-set-variable +endif +endif + +# Lua +ifdef GCC43 +ifndef GCC44 +WFLAGS+=-Wno-logical-op +endif +endif diff --git a/src/Makefile.d/win32.mk b/src/Makefile.d/win32.mk new file mode 100644 index 000000000..0e54f369c --- /dev/null +++ b/src/Makefile.d/win32.mk @@ -0,0 +1,99 @@ +# +# Mingw, if you don't know, that's Win32/Win64 +# + +ifndef MINGW64 +EXENAME?=srb2kart.exe +else +EXENAME?=srb2kart64.exe +endif + +sources+=win32/Srb2win.rc +opts+=-DSTDC_HEADERS +libs+=-ladvapi32 -lkernel32 -lmsvcrt -luser32 + +nasm_format:=win32 + +SDL=1 + +ifndef NOHW +opts+=-DUSE_WGL_SWAP +endif + +ifdef MINGW64 +libs+=-lws2_32 +else +ifdef NO_IPV6 +libs+=-lwsock32 +else +libs+=-lws2_32 +endif +endif + +ifndef NONET +ifndef MINGW64 # miniupnc is broken with MINGW64 +opts+=-I../libs -DSTATIC_MINIUPNPC +libs+=-L../libs/miniupnpc/mingw$(32) -lws2_32 -liphlpapi +endif +endif + +ifndef MINGW64 +32=32 +x86=x86 +i686=i686 +else +32=64 +x86=x86_64 +i686=x86_64 +endif + +mingw:=$(i686)-w64-mingw32 + +define _set = +$(1)_CFLAGS?=$($(1)_opts) +$(1)_LDFLAGS?=$($(1)_libs) +endef + +lib:=../libs/gme +LIBGME_opts:=-I$(lib)/include +LIBGME_libs:=-L$(lib)/win$(32) -lgme +$(eval $(call _set,LIBGME)) + +lib:=../libs/libopenmpt +LIBOPENMPT_opts:=-I$(lib)/inc +LIBOPENMPT_libs:=-L$(lib)/lib/$(x86)/mingw -lopenmpt +$(eval $(call _set,LIBOPENMPT)) + +ifndef NOMIXERX +HAVE_MIXERX=1 +lib:=../libs/SDLMixerX/$(mingw) +else +lib:=../libs/SDL2_mixer/$(mingw) +endif + +mixer_opts:=-I$(lib)/include/SDL2 +mixer_libs:=-L$(lib)/lib + +lib:=../libs/SDL2/$(mingw) +SDL_opts:=-I$(lib)/include/SDL2\ + $(mixer_opts) -Dmain=SDL_main +SDL_libs:=-L$(lib)/lib $(mixer_libs)\ + -lmingw32 -lSDL2main -lSDL2 -mwindows +$(eval $(call _set,SDL)) + +lib:=../libs/zlib +ZLIB_opts:=-I$(lib) +ZLIB_libs:=-L$(lib)/win32 -lz$(32) +$(eval $(call _set,ZLIB)) + +ifndef PNG_CONFIG +lib:=../libs/libpng-src +PNG_opts:=-I$(lib) +PNG_libs:=-L$(lib)/projects -lpng$(32) +$(eval $(call _set,PNG)) +endif + +lib:=../libs/curl +CURL_opts:=-I$(lib)/include +CURL_libs:=-L$(lib)/lib$(32) -lcurl +$(eval $(call _set,CURL)) diff --git a/src/Sourcefile b/src/Sourcefile new file mode 100644 index 000000000..9f27f2810 --- /dev/null +++ b/src/Sourcefile @@ -0,0 +1,87 @@ +string.c +d_main.c +d_clisrv.c +d_net.c +d_netfil.c +d_netcmd.c +dehacked.c +z_zone.c +f_finale.c +f_wipe.c +g_demo.c +g_game.c +g_input.c +am_map.c +command.c +console.c +hu_stuff.c +y_inter.c +st_stuff.c +m_aatree.c +m_anigif.c +m_argv.c +m_bbox.c +m_cheat.c +m_cond.c +m_fixed.c +m_menu.c +m_misc.c +m_random.c +m_queue.c +info.c +p_ceilng.c +p_enemy.c +p_floor.c +p_inter.c +p_lights.c +p_map.c +p_maputl.c +p_mobj.c +p_polyobj.c +p_saveg.c +p_setup.c +p_sight.c +p_spec.c +p_telept.c +p_tick.c +p_user.c +p_slopes.c +tables.c +r_bsp.c +r_data.c +r_draw.c +r_main.c +r_plane.c +r_segs.c +r_skins.c +r_sky.c +r_splats.c +r_things.c +r_textures.c +r_picformats.c +r_portal.c +screen.c +v_video.c +s_sound.c +sounds.c +w_wad.c +filesrch.c +mserv.c +http-mserv.c +i_tcp.c +lzf.c +vid_copy.s +b_bot.c +lua_script.c +lua_baselib.c +lua_mathlib.c +lua_hooklib.c +lua_consolelib.c +lua_infolib.c +lua_mobjlib.c +lua_playerlib.c +lua_skinlib.c +lua_thinkerlib.c +lua_maplib.c +lua_blockmaplib.c +lua_hudlib.c diff --git a/src/blua/CMakeLists.txt b/src/blua/CMakeLists.txt new file mode 100644 index 000000000..4e9c67d2f --- /dev/null +++ b/src/blua/CMakeLists.txt @@ -0,0 +1 @@ +target_sourcefile(c) diff --git a/src/blua/Makefile.cfg b/src/blua/Makefile.cfg deleted file mode 100644 index 3a2962e65..000000000 --- a/src/blua/Makefile.cfg +++ /dev/null @@ -1,53 +0,0 @@ -ifdef UNIXCOMMON -LUA_CFLAGS+=-DLUA_USE_POSIX -endif -ifdef LINUX -LUA_CFLAGS+=-DLUA_USE_POSIX -endif -ifdef GCC43 -ifndef GCC44 -WFLAGS+=-Wno-logical-op -endif -endif - -OBJS:=$(OBJS) \ - $(OBJDIR)/lapi.o \ - $(OBJDIR)/lbaselib.o \ - $(OBJDIR)/ldo.o \ - $(OBJDIR)/lfunc.o \ - $(OBJDIR)/linit.o \ - $(OBJDIR)/liolib.o \ - $(OBJDIR)/llex.o \ - $(OBJDIR)/lmem.o \ - $(OBJDIR)/lobject.o \ - $(OBJDIR)/lstate.o \ - $(OBJDIR)/lstrlib.o \ - $(OBJDIR)/ltablib.o \ - $(OBJDIR)/lundump.o \ - $(OBJDIR)/lzio.o \ - $(OBJDIR)/lauxlib.o \ - $(OBJDIR)/lcode.o \ - $(OBJDIR)/ldebug.o \ - $(OBJDIR)/ldump.o \ - $(OBJDIR)/lgc.o \ - $(OBJDIR)/lopcodes.o \ - $(OBJDIR)/lparser.o \ - $(OBJDIR)/lstring.o \ - $(OBJDIR)/ltable.o \ - $(OBJDIR)/ltm.o \ - $(OBJDIR)/lvm.o \ - $(OBJDIR)/lua_script.o \ - $(OBJDIR)/lua_baselib.o \ - $(OBJDIR)/lua_mathlib.o \ - $(OBJDIR)/lua_hooklib.o \ - $(OBJDIR)/lua_consolelib.o \ - $(OBJDIR)/lua_infolib.o \ - $(OBJDIR)/lua_mobjlib.o \ - $(OBJDIR)/lua_playerlib.o \ - $(OBJDIR)/lua_skinlib.o \ - $(OBJDIR)/lua_thinkerlib.o \ - $(OBJDIR)/lua_maplib.o \ - $(OBJDIR)/lua_taglib.o \ - $(OBJDIR)/lua_polyobjlib.o \ - $(OBJDIR)/lua_blockmaplib.o \ - $(OBJDIR)/lua_hudlib.o diff --git a/src/blua/Sourcefile b/src/blua/Sourcefile new file mode 100644 index 000000000..f99c89c8d --- /dev/null +++ b/src/blua/Sourcefile @@ -0,0 +1,25 @@ +lapi.c +lbaselib.c +ldo.c +lfunc.c +linit.c +liolib.c +llex.c +lmem.c +lobject.c +lstate.c +lstrlib.c +ltablib.c +lundump.c +lzio.c +lauxlib.c +lcode.c +ldebug.c +ldump.c +lgc.c +lopcodes.c +lparser.c +lstring.c +ltable.c +ltm.c +lvm.c diff --git a/src/hardware/CMakeLists.txt b/src/hardware/CMakeLists.txt new file mode 100644 index 000000000..4e9c67d2f --- /dev/null +++ b/src/hardware/CMakeLists.txt @@ -0,0 +1 @@ +target_sourcefile(c) diff --git a/src/hardware/Sourcefile b/src/hardware/Sourcefile new file mode 100644 index 000000000..1c05de76c --- /dev/null +++ b/src/hardware/Sourcefile @@ -0,0 +1,13 @@ +hw_bsp.c +hw_draw.c +hw_light.c +hw_main.c +hw_clip.c +hw_md2.c +hw_cache.c +hw_md2load.c +hw_md3load.c +hw_model.c +u_list.c +hw_batching.c +r_opengl/r_opengl.c diff --git a/src/sdl/CMakeLists.txt b/src/sdl/CMakeLists.txt index 92d6a5184..65ff383ed 100644 --- a/src/sdl/CMakeLists.txt +++ b/src/sdl/CMakeLists.txt @@ -21,46 +21,25 @@ if(${SRB2_CONFIG_SDL2_USEMIXER}) endif() if(${SDL2_MIXER_FOUND}) set(SRB2_HAVE_MIXER ON) - set(SRB2_SDL2_SOUNDIMPL mixer_sound.c) + target_sources(SRB2SDL2 PRIVATE mixer_sound.c) else() message(WARNING "You specified that SDL2_mixer is available, but it was not found. Falling back to sdl sound.") - set(SRB2_SDL2_SOUNDIMPL sdl_sound.c) + target_sources(SRB2SDL2 PRIVATE sdl_sound.c) endif() elseif(${MIXERX_FOUND}) - set(SRB2_SDL2_SOUNDIMPL mixer_sound.c) + target_sources(SRB2SDL2 PRIVATE mixer_sound.c) else() - set(SRB2_SDL2_SOUNDIMPL sdl_sound.c) + target_sources(SRB2SDL2 PRIVATE sdl_sound.c) endif() -set(SRB2_SDL2_SOURCES - dosstr.c - endtxt.c - hwsym_sdl.c - i_main.c - i_net.c - i_system.c - i_ttf.c - i_video.c - #IMG_xpm.c - ogl_sdl.c +target_sourcefile(c) - ${SRB2_SDL2_SOUNDIMPL} -) - -set(SRB2_SDL2_HEADERS - endtxt.h - hwsym_sdl.h - i_ttf.h - ogl_sdl.h - sdlmain.h -) +target_sources(SRB2SDL2 PRIVATE ogl_sdl.c) if(${SRB2_CONFIG_HAVE_THREADS}) - set(SRB2_SDL2_SOURCES ${SRB2_SDL2_SOURCES} i_threads.c) + target_sources(SRB2SDL2 PRIVATE i_threads.c) endif() -source_group("Interface Code" FILES ${SRB2_SDL2_SOURCES} ${SRB2_SDL2_HEADERS}) - # Dependency if(${SRB2_CONFIG_USE_INTERNAL_LIBRARIES}) set(SDL2_FOUND ON) @@ -76,83 +55,29 @@ else() endif() if(${SDL2_FOUND}) - set(SRB2_SDL2_TOTAL_SOURCES - ${SRB2_CORE_SOURCES} - ${SRB2_CORE_HEADERS} - ${SRB2_DISCORDRPC_SOURCES} - ${SRB2_DISCORDRPC_HEADERS} - ${SRB2_PNG_SOURCES} - ${SRB2_PNG_HEADERS} - ${SRB2_CORE_RENDER_SOURCES} - ${SRB2_CORE_GAME_SOURCES} - ${SRB2_LUA_SOURCES} - ${SRB2_LUA_HEADERS} - ${SRB2_BLUA_SOURCES} - ${SRB2_BLUA_HEADERS} - ${SRB2_SDL2_SOURCES} - ${SRB2_SDL2_HEADERS} - ) - - source_group("Main" FILES ${SRB2_CORE_SOURCES} ${SRB2_CORE_HEADERS} - ${SRB2_PNG_SOURCES} ${SRB2_PNG_HEADERS}) - source_group("Renderer" FILES ${SRB2_CORE_RENDER_SOURCES}) - source_group("Game" FILES ${SRB2_CORE_GAME_SOURCES}) - source_group("Discord Rich Presence" FILES ${SRB2_DISCORDRPC_SOURCES} ${SRB2_DISCORDRPC_HEADERS}) - source_group("Assembly" FILES ${SRB2_ASM_SOURCES} ${SRB2_NASM_SOURCES}) - source_group("LUA" FILES ${SRB2_LUA_SOURCES} ${SRB2_LUA_HEADERS}) - source_group("LUA\\Interpreter" FILES ${SRB2_BLUA_SOURCES} ${SRB2_BLUA_HEADERS}) - - - if(${SRB2_CONFIG_HWRENDER}) - set(SRB2_SDL2_TOTAL_SOURCES ${SRB2_SDL2_TOTAL_SOURCES} - ${SRB2_HWRENDER_SOURCES} - ${SRB2_HWRENDER_HEADERS} - ${SRB2_R_OPENGL_SOURCES} - ${SRB2_R_OPENGL_HEADERS} - ) - - source_group("Hardware" FILES ${SRB2_HWRENDER_SOURCES} ${SRB2_HWRENDER_HEADERS}) - source_group("Hardware\\OpenGL Renderer" FILES ${SRB2_R_OPENGL_SOURCES} ${SRB2_R_OPENGL_HEADERS}) - endif() - if(${SRB2_USEASM}) - set(SRB2_SDL2_TOTAL_SOURCES ${SRB2_SDL2_TOTAL_SOURCES} - ${SRB2_NASM_SOURCES} - ) - if(MSVC) - set(SRB2_SDL2_TOTAL_SOURCES ${SRB2_SDL2_TOTAL_SOURCES} - ${SRB2_NASM_OBJECTS} - ) - set_source_files_properties(${SRB2_NASM_OBJECTS} PROPERTIES GENERATED ON) - else() - list(APPEND SRB2_SDL2_TOTAL_SOURCES ${SRB2_ASM_SOURCES}) - set_source_files_properties(${SRB2_ASM_SOURCES} PROPERTIES LANGUAGE C) - set_source_files_properties(${SRB2_ASM_SOURCES} PROPERTIES COMPILE_FLAGS "-x assembler-with-cpp") - endif() + set_source_files_properties(${SRB2_ASM_SOURCES} PROPERTIES LANGUAGE C) + set_source_files_properties(${SRB2_ASM_SOURCES} PROPERTIES COMPILE_FLAGS "-x assembler-with-cpp") endif() if(${CMAKE_SYSTEM} MATCHES Windows) - set(SRB2_SDL2_TOTAL_SOURCES ${SRB2_SDL2_TOTAL_SOURCES} - ${CMAKE_SOURCE_DIR}/src/win32/win_dbg.c - ${CMAKE_SOURCE_DIR}/src/win32/Srb2win.rc - ) + target_sources(SRB2SDL2 PRIVATE + ../win32/win_dbg.c + ../win32/Srb2win.rc) endif() if(${CMAKE_SYSTEM} MATCHES Darwin) set(MACOSX_BUNDLE_ICON_FILE Srb2mac.icns) set_source_files_properties(macosx/Srb2mac.icns PROPERTIES MACOSX_PACKAGE_LOCATION "Resources") - set(SRB2_SDL2_MAC_SOURCES + target_sources(SRB2SDL2 PRIVATE macosx/mac_alert.c macosx/mac_alert.h macosx/mac_resources.c macosx/mac_resources.h macosx/Srb2mac.icns ) - source_group("Interface Code\\OSX Compatibility" FILES ${SRB2_SDL2_MAC_SOURCES}) - set(SRB2_SDL2_TOTAL_SOURCES ${SRB2_SDL2_TOTAL_SOURCES} ${SRB2_SDL2_MAC_SOURCES}) endif() - add_executable(SRB2SDL2 MACOSX_BUNDLE WIN32 ${SRB2_SDL2_TOTAL_SOURCES}) if(${CMAKE_SYSTEM} MATCHES Windows) set_target_properties(SRB2SDL2 PROPERTIES OUTPUT_NAME srb2win) elseif(${CMAKE_SYSTEM} MATCHES Linux) @@ -211,18 +136,6 @@ if(${SDL2_FOUND}) set(ASM_ASSEMBLER_OBJFORMAT ${CMAKE_ASM_NASM_OBJECT_FORMAT}) set_source_files_properties(${SRB2_NASM_SOURCES} LANGUAGE ASM_NASM) endif() - - if(MSVC) - # using assembler with msvc doesn't work, must do it manually - foreach(ASMFILE ${SRB2_NASM_SOURCES}) - get_filename_component(ASMFILE_NAME ${ASMFILE} NAME_WE) - set(ASMFILE_NAME ${ASMFILE_NAME}.obj) - add_custom_command(TARGET SRB2SDL2 PRE_LINK - COMMAND ${ASM_ASSEMBLER_TEMP} ARGS -f ${ASM_ASSEMBLER_OBJFORMAT} -o ${CMAKE_CURRENT_BINARY_DIR}/${ASMFILE_NAME} ${ASMFILE} - COMMENT "assemble ${ASMFILE_NAME}." - ) - endforeach() - endif() endif() set_target_properties(SRB2SDL2 PROPERTIES VERSION ${SRB2_VERSION}) @@ -236,31 +149,6 @@ if(${SDL2_FOUND}) ) endif() - if(MSVC) - if(${SRB2_CONFIG_USE_INTERNAL_LIBRARIES}) - set(SDL2_MAIN_FOUND ON) - if(${SRB2_SYSTEM_BITS} EQUAL 64) - set(SDL2_MAIN_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/libs/SDL2/x86_64-w64-mingw32/include/SDL2) - set(SDL2_MAIN_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/SDL2/x86_64-w64-mingw32/lib -lSDL2main") - else() # 32-bit - set(SDL2_MAIN_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/libs/SDL2/i686-w64-mingw32/include/SDL2) - set(SDL2_MAIN_LIBRARIES "-L${CMAKE_SOURCE_DIR}/libs/SDL2/i686-w64-mingw32/lib -lSDL2main") - endif() - else() - find_package(SDL2_MAIN REQUIRED) - endif() - target_link_libraries(SRB2SDL2 PRIVATE - ${SDL2_MAIN_LIBRARIES} - ) - target_compile_options(SRB2SDL2 PRIVATE - /Umain - /D_CRT_SECURE_NO_WARNINGS # something about string functions. - /D_CRT_NONSTDC_NO_DEPRECATE - /DSDLMAIN - /D_WINSOCK_DEPRECATED_NO_WARNINGS # Don't care - ) - endif() - target_include_directories(SRB2SDL2 PRIVATE ${SDL2_INCLUDE_DIRS} ${SDL2_MIXER_INCLUDE_DIRS} diff --git a/src/sdl/MakeNIX.cfg b/src/sdl/MakeNIX.cfg deleted file mode 100644 index 6998a03ad..000000000 --- a/src/sdl/MakeNIX.cfg +++ /dev/null @@ -1,74 +0,0 @@ -# -# sdl/makeNIX.cfg for SRB2/?nix -# - -#Valgrind support -ifdef VALGRIND -VALGRIND_PKGCONFIG?=valgrind -VALGRIND_CFLAGS?=$(shell $(PKG_CONFIG) $(VALGRIND_PKGCONFIG) --cflags) -VALGRIND_LDFLAGS?=$(shell $(PKG_CONFIG) $(VALGRIND_PKGCONFIG) --libs) -ZDEBUG=1 -LIBS+=$(VALGRIND_LDFLAGS) -ifdef GCC46 -WFLAGS+=-Wno-error=unused-but-set-variable -WFLAGS+=-Wno-unused-but-set-variable -endif -endif - -# -#here is GNU/Linux and other -# - - OPTS=-DUNIXCOMMON - - #LDFLAGS = -L/usr/local/lib - LIBS=-lm -ifdef LINUX - LIBS+=-lrt -ifdef NOTERMIOS - OPTS+=-DNOTERMIOS -endif -endif - -ifdef LINUX64 - OPTS+=-DLINUX64 -endif - -# -#here is Solaris -# -ifdef SOLARIS - NOIPX=1 - NOASM=1 - OPTS+=-DSOLARIS -DINADDR_NONE=INADDR_ANY -DBSD_COMP - OPTS+=-I/usr/local/include -I/opt/sfw/include - LDFLAGS+=-L/opt/sfw/lib - LIBS+=-lsocket -lnsl -endif - -# -#here is FreeBSD -# -ifdef FREEBSD - OPTS+=-DLINUX -DFREEBSD -I/usr/X11R6/include - SDL_CONFIG?=sdl11-config - LDFLAGS+=-L/usr/X11R6/lib - LIBS+=-lipx -lkvm -endif - -# -#here is Mac OS X -# -ifdef MACOSX - OBJS+=$(OBJDIR)/mac_resources.o - OBJS+=$(OBJDIR)/mac_alert.o - LIBS+=-framework CoreFoundation -endif - -ifndef NOHW - OPTS+=-I/usr/X11R6/include - LDFLAGS+=-L/usr/X11R6/lib -endif - - # name of the exefile - EXENAME?=lsdl2srb2kart diff --git a/src/sdl/Makefile.cfg b/src/sdl/Makefile.cfg deleted file mode 100644 index 45d0d6ba7..000000000 --- a/src/sdl/Makefile.cfg +++ /dev/null @@ -1,125 +0,0 @@ -# -# sdl/makefile.cfg for SRB2/SDL -# - -# -#SDL...., *looks at Alam*, THIS IS A MESS! -# - -ifdef UNIXCOMMON -include sdl/MakeNIX.cfg -endif - -ifdef PANDORA -include sdl/SRB2Pandora/Makefile.cfg -endif #ifdef PANDORA - -ifdef CYGWIN32 -include sdl/MakeCYG.cfg -endif #ifdef CYGWIN32 - -ifdef SDL_PKGCONFIG -SDL_CFLAGS?=$(shell $(PKG_CONFIG) $(SDL_PKGCONFIG) --cflags) -SDL_LDFLAGS?=$(shell $(PKG_CONFIG) $(SDL_PKGCONFIG) --libs) -else -ifdef PREFIX - SDL_CONFIG?=$(PREFIX)-sdl2-config -else - SDL_CONFIG?=sdl2-config -endif - -ifdef STATIC - SDL_CFLAGS?=$(shell $(SDL_CONFIG) --cflags) - SDL_LDFLAGS?=$(shell $(SDL_CONFIG) --static-libs) -else - SDL_CFLAGS?=$(shell $(SDL_CONFIG) --cflags) - SDL_LDFLAGS?=$(shell $(SDL_CONFIG) --libs) -endif -endif - - - #use the x86 asm code -ifndef CYGWIN32 -ifndef NOASM - USEASM=1 -endif -endif - - OBJS+=$(OBJDIR)/i_video.o $(OBJDIR)/dosstr.o $(OBJDIR)/endtxt.o $(OBJDIR)/hwsym_sdl.o - - OPTS+=-DDIRECTFULLSCREEN -DHAVE_SDL - -ifndef NOHW - OBJS+=$(OBJDIR)/r_opengl.o $(OBJDIR)/ogl_sdl.o -endif - -ifdef NOMIXER - i_sound_o=$(OBJDIR)/sdl_sound.o -else - i_sound_o=$(OBJDIR)/mixer_sound.o - OPTS+=-DHAVE_MIXER -ifdef HAVE_MIXERX - OPTS+=-DHAVE_MIXERX - SDL_LDFLAGS+=-lSDL2_mixer_ext -else - SDL_LDFLAGS+=-lSDL2_mixer -endif -endif - -ifndef NOTHREADS - OPTS+=-DHAVE_THREADS - OBJS+=$(OBJDIR)/i_threads.o -endif - -ifdef SDL_TTF - OPTS+=-DHAVE_TTF - SDL_LDFLAGS+=-lSDL2_ttf -lfreetype -lz - OBJS+=$(OBJDIR)/i_ttf.o -endif - -ifdef SDL_IMAGE - OPTS+=-DHAVE_IMAGE - SDL_LDFLAGS+=-lSDL2_image -endif - -ifdef SDL_NET - OPTS+=-DHAVE_SDLNET - SDL_LDFLAGS+=-lSDL2_net -endif - -ifdef MINGW -ifndef NOSDLMAIN - SDLMAIN=1 -endif -endif - -ifdef SDLMAIN - OPTS+=-DSDLMAIN -else -ifdef MINGW - SDL_CFLAGS+=-Umain - SDL_LDFLAGS+=-mconsole -endif -endif - -ifndef NOHW -ifdef OPENAL -ifdef MINGW - LIBS:=-lopenal32 $(LIBS) -else - LIBS:=-lopenal $(LIBS) -endif -else -ifdef MINGW -ifdef DS3D - LIBS:=-ldsound -luuid $(LIBS) -endif -endif -endif -endif - -CFLAGS+=$(SDL_CFLAGS) -LIBS:=$(SDL_LDFLAGS) $(LIBS) -ifdef STATIC - LIBS+=$(shell $(SDL_CONFIG) --static-libs) -endif diff --git a/src/sdl/Sourcefile b/src/sdl/Sourcefile new file mode 100644 index 000000000..82d5ce073 --- /dev/null +++ b/src/sdl/Sourcefile @@ -0,0 +1,7 @@ +i_net.c +i_system.c +i_main.c +i_video.c +dosstr.c +endtxt.c +hwsym_sdl.c diff --git a/src/sdl/mixer_sound.c b/src/sdl/mixer_sound.c index ea5a12f3d..4a135c136 100644 --- a/src/sdl/mixer_sound.c +++ b/src/sdl/mixer_sound.c @@ -9,7 +9,7 @@ /// \file /// \brief SDL Mixer interface for sound -#ifdef HAVE_LIBGME +#ifdef HAVE_GME #ifdef HAVE_ZLIB #ifndef _MSC_VER #ifndef _LARGEFILE64_SOURCE @@ -27,7 +27,7 @@ #include #endif // HAVE_ZLIB -#endif // HAVE_LIBGME +#endif // HAVE_GME #include "../doomdef.h" #include "../doomstat.h" // menuactive @@ -79,11 +79,11 @@ write netcode into the sound code, OKAY? #define MUS_MODPLUG MUS_MODPLUG_UNUSED #endif -#ifdef HAVE_LIBGME +#ifdef HAVE_GME #include "gme/gme.h" #define GME_TREBLE 5.0f #define GME_BASS 1.0f -#endif // HAVE_LIBGME +#endif // HAVE_GME static UINT16 BUFFERSIZE = 2048; static UINT16 SAMPLERATE = 44100; @@ -123,7 +123,7 @@ static INT32 fading_id; static void (*fading_callback)(void); static boolean fading_nocleanup; -#ifdef HAVE_LIBGME +#ifdef HAVE_GME static Music_Emu *gme; static UINT16 current_track; #endif @@ -157,7 +157,7 @@ static void var_cleanup(void) internal_volume = 100; } -#if defined (HAVE_LIBGME) && defined (HAVE_ZLIB) +#if defined (HAVE_GME) && defined (HAVE_ZLIB) static const char* get_zlib_error(int zErr) { switch (zErr) @@ -250,7 +250,7 @@ void I_ShutdownSound(void) SDL_QuitSubSystem(SDL_INIT_AUDIO); -#ifdef HAVE_LIBGME +#ifdef HAVE_GME if (gme) gme_delete(gme); #endif @@ -394,7 +394,7 @@ void *I_GetSfx(sfxinfo_t *sfx) void *lump; Mix_Chunk *chunk; SDL_RWops *rw; -#ifdef HAVE_LIBGME +#ifdef HAVE_GME Music_Emu *emu; gme_info_t *info; #endif @@ -414,7 +414,7 @@ void *I_GetSfx(sfxinfo_t *sfx) } // Not a doom sound? Try something else. -#ifdef HAVE_LIBGME +#ifdef HAVE_GME // VGZ format if (((UINT8 *)lump)[0] == 0x1F && ((UINT8 *)lump)[1] == 0x8B) @@ -700,7 +700,7 @@ static UINT32 music_fade(UINT32 interval, void *param) } } -#ifdef HAVE_LIBGME +#ifdef HAVE_GME static void mix_gme(void *udata, Uint8 *stream, int len) { int i; @@ -760,7 +760,7 @@ void I_ShutdownMusic(void) musictype_t I_SongType(void) { -#ifdef HAVE_LIBGME +#ifdef HAVE_GME if (gme) return MU_GME; else @@ -791,7 +791,7 @@ musictype_t I_SongType(void) boolean I_SongPlaying(void) { return ( -#ifdef HAVE_LIBGME +#ifdef HAVE_GME (I_SongType() == MU_GME && gme) || #endif #ifdef HAVE_OPENMPT @@ -814,7 +814,7 @@ boolean I_SetSongSpeed(float speed) { if (speed > 250.0f) speed = 250.0f; //limit speed up to 250x -#ifdef HAVE_LIBGME +#ifdef HAVE_GME if (gme) { SDL_LockAudio(); @@ -856,7 +856,7 @@ UINT32 I_GetSongLength(void) { INT32 length; -#ifdef HAVE_LIBGME +#ifdef HAVE_GME if (gme) { gme_info_t *info; @@ -926,7 +926,7 @@ boolean I_SetSongLoopPoint(UINT32 looppoint) UINT32 I_GetSongLoopPoint(void) { -#ifdef HAVE_LIBGME +#ifdef HAVE_GME if (gme) { INT32 looppoint; @@ -955,7 +955,7 @@ UINT32 I_GetSongLoopPoint(void) boolean I_SetSongPosition(UINT32 position) { UINT32 length; -#ifdef HAVE_LIBGME +#ifdef HAVE_GME if (gme) { // this is unstable, so fail silently @@ -1020,7 +1020,7 @@ boolean I_SetSongPosition(UINT32 position) UINT32 I_GetSongPosition(void) { -#ifdef HAVE_LIBGME +#ifdef HAVE_GME if (gme) { INT32 position = gme_tell(gme); @@ -1105,7 +1105,7 @@ boolean I_LoadSong(char *data, size_t len) SDL_RWops *rw; if (music -#ifdef HAVE_LIBGME +#ifdef HAVE_GME || gme #endif #ifdef HAVE_OPENMPT @@ -1117,7 +1117,7 @@ boolean I_LoadSong(char *data, size_t len) // always do this whether or not a music already exists var_cleanup(); -#ifdef HAVE_LIBGME +#ifdef HAVE_GME if ((UINT8)data[0] == 0x1F && (UINT8)data[1] == 0x8B) { @@ -1244,7 +1244,7 @@ void I_UnloadSong(void) { I_StopSong(); -#ifdef HAVE_LIBGME +#ifdef HAVE_GME if (gme) { gme_delete(gme); @@ -1267,7 +1267,7 @@ void I_UnloadSong(void) boolean I_PlaySong(boolean looping) { -#ifdef HAVE_LIBGME +#ifdef HAVE_GME if (gme) { gme_equalizer_t eq = {GME_TREBLE, GME_BASS, 0,0,0,0,0,0,0,0}; @@ -1333,7 +1333,7 @@ void I_StopSong(void) if (!fading_nocleanup) I_StopFadingSong(); -#ifdef HAVE_LIBGME +#ifdef HAVE_GME if (gme) { Mix_HookMusic(NULL, NULL); @@ -1395,7 +1395,7 @@ void I_SetMusicVolume(int volume) boolean I_SetSongTrack(int track) { -#ifdef HAVE_LIBGME +#ifdef HAVE_GME // If the specified track is within the number of tracks playing, then change it if (gme) { diff --git a/src/win32/Makefile.cfg b/src/win32/Makefile.cfg deleted file mode 100644 index 85ee0d6b5..000000000 --- a/src/win32/Makefile.cfg +++ /dev/null @@ -1,161 +0,0 @@ -# -# win32/Makefile.cfg for SRB2/Minwgw -# - -# -#Mingw, if you don't know, that's Win32/Win64 -# - -ifdef MINGW64 - HAVE_LIBGME=1 - LIBGME_CFLAGS=-I../libs/gme/include - LIBGME_LDFLAGS=-L../libs/gme/win64 -lgme -ifdef HAVE_OPENMPT - LIBOPENMPT_CFLAGS?=-I../libs/libopenmpt/inc - LIBOPENMPT_LDFLAGS?=-L../libs/libopenmpt/lib/x86_64/mingw -lopenmpt -endif -ifndef NOMIXERX - HAVE_MIXERX=1 - SDL_CFLAGS?=-I../libs/SDL2/x86_64-w64-mingw32/include/SDL2 -I../libs/SDLMixerX/x86_64-w64-mingw32/include/SDL2 -Dmain=SDL_main - SDL_LDFLAGS?=-L../libs/SDL2/x86_64-w64-mingw32/lib -L../libs/SDLMixerX/x86_64-w64-mingw32/lib -lmingw32 -lSDL2main -lSDL2 -mwindows -else - SDL_CFLAGS?=-I../libs/SDL2/x86_64-w64-mingw32/include/SDL2 -I../libs/SDL2_mixer/x86_64-w64-mingw32/include/SDL2 -Dmain=SDL_main - SDL_LDFLAGS?=-L../libs/SDL2/x86_64-w64-mingw32/lib -L../libs/SDL2_mixer/x86_64-w64-mingw32/lib -lmingw32 -lSDL2main -lSDL2 -mwindows -endif -else - HAVE_LIBGME=1 - LIBGME_CFLAGS=-I../libs/gme/include - LIBGME_LDFLAGS=-L../libs/gme/win32 -lgme -ifdef HAVE_OPENMPT - LIBOPENMPT_CFLAGS?=-I../libs/libopenmpt/inc - LIBOPENMPT_LDFLAGS?=-L../libs/libopenmpt/lib/x86/mingw -lopenmpt -endif -ifndef NOMIXERX - HAVE_MIXERX=1 - SDL_CFLAGS?=-I../libs/SDL2/i686-w64-mingw32/include/SDL2 -I../libs/SDLMixerX/i686-w64-mingw32/include/SDL2 -Dmain=SDL_main - SDL_LDFLAGS?=-L../libs/SDL2/i686-w64-mingw32/lib -L../libs/SDLMixerX/i686-w64-mingw32/lib -lmingw32 -lSDL2main -lSDL2 -mwindows -else - SDL_CFLAGS?=-I../libs/SDL2/i686-w64-mingw32/include/SDL2 -I../libs/SDL2_mixer/i686-w64-mingw32/include/SDL2 -Dmain=SDL_main - SDL_LDFLAGS?=-L../libs/SDL2/i686-w64-mingw32/lib -L../libs/SDL2_mixer/i686-w64-mingw32/lib -lmingw32 -lSDL2main -lSDL2 -mwindows -endif -endif - -ifndef NOASM - USEASM=1 -endif - -ifndef NONET -ifndef MINGW64 #miniupnc is broken with MINGW64 - HAVE_MINIUPNPC=1 -endif -endif - -ifndef NO_DISCORDRPC - HAVE_DISCORDRPC=1 -endif - - OPTS=-DSTDC_HEADERS - -ifndef GCC44 - #OPTS+=-mms-bitfields -endif - - LIBS+=-ladvapi32 -lkernel32 -lmsvcrt -luser32 -ifdef MINGW64 - LIBS+=-lws2_32 -else -ifdef NO_IPV6 - LIBS+=-lwsock32 -else - LIBS+=-lws2_32 -endif -endif - -ifndef MINGW64 - CPPFLAGS+=-I../libs/drmingw/include - LDFLAGS+=-L../libs/drmingw/lib/win32 - LIBS+=-lmgwhelp -lexchndl -endif - - # name of the exefile - EXENAME?=srb2kart.exe - -ifdef SDL - i_system_o+=$(OBJDIR)/SRB2.res - #i_main_o+=$(OBJDIR)/win_dbg.o -ifndef NOHW - OPTS+=-DUSE_WGL_SWAP -endif -endif - - -ZLIB_CFLAGS?=-I../libs/zlib -ifdef MINGW64 -ZLIB_LDFLAGS?=-L../libs/zlib/win32 -lz64 -else -ZLIB_LDFLAGS?=-L../libs/zlib/win32 -lz32 -endif - -ifndef NOPNG -ifndef PNG_CONFIG - PNG_CFLAGS?=-I../libs/libpng-src -ifdef MINGW64 - PNG_LDFLAGS?=-L../libs/libpng-src/projects -lpng64 -else - PNG_LDFLAGS?=-L../libs/libpng-src/projects -lpng32 -endif #MINGW64 -endif #PNG_CONFIG -endif #NOPNG - -ifdef GETTEXT -ifndef CCBS - MSGFMT?=../libs/gettext/bin32/msgfmt.exe -endif -ifdef MINGW64 - CPPFLAGS+=-I../libs/gettext/include64 - LDFLAGS+=-L../libs/gettext/lib64 - LIBS+=-lmingwex -else - CPPFLAGS+=-I../libs/gettext/include32 - LDFLAGS+=-L../libs/gettext/lib32 - STATIC_GETTEXT=1 -endif #MINGW64 -ifdef STATIC_GETTEXT - LIBS+=-lasprintf -lintl -else - LIBS+=-lintl.dll -endif #STATIC_GETTEXT -endif #GETTEXT - -ifdef HAVE_MINIUPNPC - CPPFLAGS+=-I../libs/ -DSTATIC_MINIUPNPC -ifdef MINGW64 - LDFLAGS+=-L../libs/miniupnpc/mingw64 -else - LDFLAGS+=-L../libs/miniupnpc/mingw32 -endif #MINGW64 -endif - -ifndef NOCURL - CURL_CFLAGS+=-I../libs/curl/include -ifdef MINGW64 - CURL_LDFLAGS+=-L../libs/curl/lib64 -lcurl -else - CURL_LDFLAGS+=-L../libs/curl/lib32 -lcurl -endif #MINGW64 -endif - -ifdef HAVE_DISCORDRPC -ifdef MINGW64 - CPPFLAGS+=-I../libs/discord-rpc/win64-dynamic/include - LDFLAGS+=-L../libs/discord-rpc/win64-dynamic/lib -else - CPPFLAGS+=-I../libs/discord-rpc/win32-dynamic/include - LDFLAGS+=-L../libs/discord-rpc/win32-dynamic/lib -endif - LIBS+=-ldiscord-rpc -endif - -ifndef MINGW64 - LDFLAGS+=-Wl,--large-address-aware -endif From 9ae0e0a8d73c22f76dccd8716eec08c8d70260a9 Mon Sep 17 00:00:00 2001 From: James R Date: Thu, 25 Nov 2021 04:02:38 -0800 Subject: [PATCH 020/156] Fix Kart conflicts Conflicts from d5c08ac03 Some parts are reworked into the new build system. --- src/CMakeLists.txt | 10 +++------- src/Makefile.d/features.mk | 8 ++++++++ src/Makefile.d/win32.mk | 18 ++++++++++++++++++ src/Sourcefile | 27 ++++++++++++++++++++++++++- 4 files changed, 55 insertions(+), 8 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8fd39f721..39b71cda7 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -128,13 +128,9 @@ if(${SRB2_CONFIG_HAVE_DISCORDRPC}) endif() if(${DISCORDRPC_FOUND}) set(SRB2_HAVE_DISCORDRPC ON) - add_definitions(-DHAVE_DISCORDRPC) - add_definitions(-DUSE_STUN) - set(SRB2_DISCORDRPC_SOURCES discord.c stun.c) - set(SRB2_DISCORDRPC_HEADERS discord.h stun.h) - prepend_sources(SRB2_DISCORDRPC_SOURCES) - prepend_sources(SRB2_DISCORDRPC_HEADERS) - source_group("Discord Rich Presence" FILES ${SRB2_DISCORDRPC_SOURCES} ${SRB2_DISCORDRPC_HEADERS}) + target_compile_definitions(SRB2SDL2 PRIVATE -DHAVE_DISCORDRPC) + target_compile_definitions(SRB2SDL2 PRIVATE -DUSE_STUN) + target_sources(SRB2SDL2 PRIVATE discord.c stun.c) else() message(WARNING "You have specified that Discord Rich Presence is available but it was not found.") endif() diff --git a/src/Makefile.d/features.mk b/src/Makefile.d/features.mk index abdc342b7..a29a8a153 100644 --- a/src/Makefile.d/features.mk +++ b/src/Makefile.d/features.mk @@ -6,6 +6,7 @@ passthru_opts+=\ NONET NO_IPV6 NOHW NOMD5 NOPOSTPROCESSING\ MOBJCONSISTANCY PACKETDROP ZDEBUG\ HAVE_MINIUPNPC\ + HAVE_DISCORDRPC TESTERS DEVELOP # build with debugging information ifdef DEBUGMODE @@ -59,6 +60,13 @@ ifdef HAVE_MINIUPNPC libs+=-lminiupnpc endif +ifdef HAVE_DISCORDRPC +$(eval $(call Propogate_flags,DISCORDRPC)) +libs+=-ldiscord-rpc +opts+=-DUSE_STUN +sources+=discord.c stun.c +endif + # (Valgrind is a memory debugger.) ifdef VALGRIND VALGRIND_PKGCONFIG?=valgrind diff --git a/src/Makefile.d/win32.mk b/src/Makefile.d/win32.mk index 0e54f369c..ec66107d4 100644 --- a/src/Makefile.d/win32.mk +++ b/src/Makefile.d/win32.mk @@ -30,6 +30,15 @@ libs+=-lws2_32 endif endif +ifndef MINGW64 +opts+=-I../libs/drmingw/include +libs+=-L../libs/drmingw/lib/win32 -lmgwhelp -lexchndl +endif + +ifndef MINGW64 +libs+=-Wl,--large-address-aware +endif + ifndef NONET ifndef MINGW64 # miniupnc is broken with MINGW64 opts+=-I../libs -DSTATIC_MINIUPNPC @@ -37,6 +46,10 @@ libs+=-L../libs/miniupnpc/mingw$(32) -lws2_32 -liphlpapi endif endif +ifndef NO_DISCORDRPC +HAVE_DISCORDRPC=1 +endif + ifndef MINGW64 32=32 x86=x86 @@ -97,3 +110,8 @@ lib:=../libs/curl CURL_opts:=-I$(lib)/include CURL_libs:=-L$(lib)/lib$(32) -lcurl $(eval $(call _set,CURL)) + +lib:=../libs/discord-rpc/win$(32)-dynamic +DISCORDRPC_opts:=-I$(lib)/include +DISCORDRPC_libs:=-L$(lib)/lib +$(eval $(call _set,DISCORDRPC)) diff --git a/src/Sourcefile b/src/Sourcefile index 9f27f2810..384af8da7 100644 --- a/src/Sourcefile +++ b/src/Sourcefile @@ -5,15 +5,20 @@ d_net.c d_netfil.c d_netcmd.c dehacked.c +deh_soc.c +deh_lua.c +deh_tables.c z_zone.c f_finale.c f_wipe.c g_demo.c g_game.c g_input.c +g_splitscreen.c am_map.c command.c console.c +font.c hu_stuff.c y_inter.c st_stuff.c @@ -26,6 +31,7 @@ m_cond.c m_fixed.c m_menu.c m_misc.c +m_perfstats.c m_random.c m_queue.c info.c @@ -58,9 +64,12 @@ r_sky.c r_splats.c r_things.c r_textures.c +r_patch.c +r_patchrotation.c r_picformats.c r_portal.c screen.c +taglist.c v_video.c s_sound.c sounds.c @@ -71,7 +80,6 @@ http-mserv.c i_tcp.c lzf.c vid_copy.s -b_bot.c lua_script.c lua_baselib.c lua_mathlib.c @@ -83,5 +91,22 @@ lua_playerlib.c lua_skinlib.c lua_thinkerlib.c lua_maplib.c +lua_taglib.c +lua_polyobjlib.c lua_blockmaplib.c lua_hudlib.c +k_kart.c +k_respawn.c +k_collide.c +k_color.c +k_race.c +k_battle.c +k_pwrlv.c +k_waypoint.c +k_pathfind.c +k_bheap.c +k_bot.c +k_botitem.c +k_botsearch.c +k_grandprix.c +k_hud.c From d7e5d178e795fe7c713813c130b190bcc3b78635 Mon Sep 17 00:00:00 2001 From: toaster Date: Thu, 25 Nov 2021 17:01:41 +0000 Subject: [PATCH 021/156] Fix ring capsules popping for you if you have an SPB. --- src/p_inter.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/src/p_inter.c b/src/p_inter.c index e0ba88296..1b0ca880d 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -278,19 +278,27 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) P_KillMobj(special, toucher, toucher, DMG_NORMAL); break; case MT_ITEMCAPSULE: - if (special->threshold != KITEM_SUPERRING - && special->threshold != KITEM_SPB - && !P_CanPickupItem(player, 1)) - return; - if ((gametyperules & GTR_BUMPERS) && player->bumpers <= 0) return; if (special->scale < special->extravalue1) // don't break it while it's respawning return; - if (special->threshold == KITEM_SPB && K_IsSPBInGame()) // don't spawn a second SPB - return; + switch (special->threshold) + { + case KITEM_SPB: + if (K_IsSPBInGame()) // don't spawn a second SPB + return; + break; + case KITEM_SUPERRING: + if (player->pflags & PF_RINGLOCK) // no cheaty rings + return; + break; + default: + if (!P_CanPickupItem(player, 1)) + return; + break; + } S_StartSound(toucher, special->info->deathsound); P_KillMobj(special, toucher, toucher, DMG_NORMAL); From 170d0a2fb9e03e3003b2fcf443479c06b45065f4 Mon Sep 17 00:00:00 2001 From: James R Date: Thu, 25 Nov 2021 13:43:17 -0800 Subject: [PATCH 022/156] Toaster suggestions for e82bba18 --- src/s_sound.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/s_sound.c b/src/s_sound.c index d4a63b59e..7e44bb207 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -1013,10 +1013,10 @@ fixed_t S_CalculateSoundDistance(fixed_t sx1, fixed_t sy1, fixed_t sz1, fixed_t INT32 S_GetSoundVolume(sfxinfo_t *sfx, INT32 volume) { - if (sfx->volume < 0) - return volume; - else - return volume * sfx->volume / 100; + if (sfx->volume > 0) + return (volume * sfx->volume) / 100; + + return volume; } // From 1958f3f61c80388cfc2a708824f454cc06dc199b Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 26 Nov 2021 12:55:23 -0800 Subject: [PATCH 023/156] Sync respawn.airtimer Oops! --- src/p_saveg.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/p_saveg.c b/src/p_saveg.c index 27e100ccd..740272874 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -334,6 +334,7 @@ static void P_NetArchivePlayers(void) WRITEFIXED(save_p, players[i].respawn.pointz); WRITEUINT8(save_p, players[i].respawn.flip); WRITEUINT32(save_p, players[i].respawn.timer); + WRITEUINT32(save_p, players[i].respawn.airtimer); WRITEUINT32(save_p, players[i].respawn.distanceleft); WRITEUINT32(save_p, players[i].respawn.dropdash); @@ -590,6 +591,7 @@ static void P_NetUnArchivePlayers(void) players[i].respawn.pointz = READFIXED(save_p); players[i].respawn.flip = (boolean)READUINT8(save_p); players[i].respawn.timer = READUINT32(save_p); + players[i].respawn.airtimer = READUINT32(save_p); players[i].respawn.distanceleft = READUINT32(save_p); players[i].respawn.dropdash = READUINT32(save_p); From 5f625437a827b750f2128bca01107e8386fb4e0f Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 26 Nov 2021 18:20:16 -0800 Subject: [PATCH 024/156] Move level music check out of player thinker Hitlag during this tic will skip playing the music. --- src/k_kart.c | 7 ------- src/p_tick.c | 7 +++++++ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 3d46bbfca..629eecf94 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -6983,13 +6983,6 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd) // Handle invincibility sfx K_UpdateInvincibilitySounds(player); // Also thanks, VAda! - - // Plays the music after the starting countdown. - if (P_IsLocalPlayer(player) && leveltime == (starttime + (TICRATE/2))) - { - S_ChangeMusic(mapmusname, mapmusflags, true); - S_ShowMusicCredit(); - } } void K_KartPlayerAfterThink(player_t *player) diff --git a/src/p_tick.c b/src/p_tick.c index 5e92649cb..be82b9d40 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -608,6 +608,13 @@ void P_Ticker(boolean run) if (playeringame[i] && players[i].mo && !P_MobjWasRemoved(players[i].mo)) P_PlayerAfterThink(&players[i]); + // Plays the music after the starting countdown. + if (leveltime == (starttime + (TICRATE/2))) + { + S_ChangeMusic(mapmusname, mapmusflags, true); + S_ShowMusicCredit(); + } + ps_lua_thinkframe_time = I_GetPreciseTime(); LUAh_ThinkFrame(); ps_lua_thinkframe_time = I_GetPreciseTime() - ps_lua_thinkframe_time; From 25c6852482c60fb22443b7e8b1c306c72ab0fb49 Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 26 Nov 2021 19:17:53 -0800 Subject: [PATCH 025/156] Let the player touch balloons --- src/info.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/info.c b/src/info.c index e333de1b0..c28c81dfd 100644 --- a/src/info.c +++ b/src/info.c @@ -8686,7 +8686,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = 20*FRACUNIT, // mass 0, // damage sfx_None, // activesound - MF_NOGRAVITY, // flags + MF_SPECIAL|MF_NOGRAVITY, // flags S_BALLOONPOP1 // raisestate }, From db4bb74c424e1267fd2dd3f2493f6b0985389410 Mon Sep 17 00:00:00 2001 From: SteelT Date: Fri, 26 Nov 2021 23:13:17 -0500 Subject: [PATCH 026/156] All springs give spring grease --- src/d_player.h | 2 +- src/k_kart.c | 2 +- src/p_map.c | 21 +++++++++------------ 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/src/d_player.h b/src/d_player.h index dd765bb0b..b8add36aa 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -390,7 +390,7 @@ typedef struct player_s fixed_t offroad; // In Super Mario Kart, going offroad has lee-way of about 1 second before you start losing speed UINT8 waterskip; // Water skipping counter - UINT16 tiregrease; // Reduced friction timer after hitting a horizontal spring + UINT16 tiregrease; // Reduced friction timer after hitting a spring UINT16 springstars; // Spawn stars around a player when they hit a spring UINT16 springcolor; // Color of spring stars UINT8 dashpadcooldown; // Separate the vanilla SA-style dash pads from using flashing diff --git a/src/k_kart.c b/src/k_kart.c index 3d46bbfca..20e1df91f 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -8342,7 +8342,7 @@ void K_AdjustPlayerFriction(player_t *player) return; } - // Reduce friction after hitting a horizontal spring + // Reduce friction after hitting a spring if (player->tiregrease) { player->mo->friction += ((FRACUNIT - prevfriction) / greasetics) * player->tiregrease; diff --git a/src/p_map.c b/src/p_map.c index 829393d32..28c747997 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -347,20 +347,17 @@ boolean P_DoSpring(mobj_t *spring, mobj_t *object) if (object->player) { - // Less friction when hitting horizontal springs - if (!vertispeed) + // Less friction when hitting springs + if (!object->player->tiregrease) { - if (!object->player->tiregrease) + UINT8 i; + for (i = 0; i < 2; i++) { - UINT8 i; - for (i = 0; i < 2; i++) - { - mobj_t *grease; - grease = P_SpawnMobj(object->x, object->y, object->z, MT_TIREGREASE); - P_SetTarget(&grease->target, object); - grease->angle = K_MomentumAngle(object); - grease->extravalue1 = i; - } + mobj_t *grease; + grease = P_SpawnMobj(object->x, object->y, object->z, MT_TIREGREASE); + P_SetTarget(&grease->target, object); + grease->angle = K_MomentumAngle(object); + grease->extravalue1 = i; } object->player->tiregrease = greasetics; //FixedMul(greasetics << FRACBITS, finalSpeed/72) >> FRACBITS From d1a5a829806c84352ddfaac59fd388e1dc77db2b Mon Sep 17 00:00:00 2001 From: SteelT Date: Fri, 26 Nov 2021 23:44:06 -0500 Subject: [PATCH 027/156] Spring grease vfx is no longer visible when you're airborne --- src/p_mobj.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/p_mobj.c b/src/p_mobj.c index 34b48dc9c..2204003b4 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -6889,6 +6889,9 @@ static boolean P_MobjRegularThink(mobj_t *mobj) z); mobj->angle = ang; + if (!P_IsObjectOnGround(mobj->target)) + mobj->renderflags |= RF_DONTDRAW; + if (leveltime & 1) mobj->renderflags |= RF_DONTDRAW; From 059058476eb697a09312238fdc597fae70bdc856 Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 26 Nov 2021 21:55:32 -0800 Subject: [PATCH 028/156] Elimination timer for karma bombs during overtime Every hit on another player while you are alive awards you five seconds of karma bomb time during overtime. When this timer is empty, you will DIE. --- src/d_player.h | 1 + src/g_game.c | 1 + src/k_hud.c | 5 ++++- src/k_kart.c | 26 ++++++++++++++++++-------- src/p_inter.c | 4 ++++ src/p_saveg.c | 2 ++ 6 files changed, 30 insertions(+), 9 deletions(-) diff --git a/src/d_player.h b/src/d_player.h index dd765bb0b..993a9de4d 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -468,6 +468,7 @@ typedef struct player_s UINT8 emeralds; UINT8 bumpers; INT16 karmadelay; + tic_t overtimekarma; // time to live in overtime comeback INT16 spheres; SINT8 glanceDir; // Direction the player is trying to look backwards in diff --git a/src/g_game.c b/src/g_game.c index 580b3bf0d..c675e9a22 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -2281,6 +2281,7 @@ void G_PlayerReborn(INT32 player, boolean betweenmaps) p->growshrinktimer = growshrinktimer; p->bumpers = bumper; p->karmadelay = comebacktime; + p->overtimekarma = 0; p->eggmanblame = -1; p->lastdraft = -1; p->karthud[khud_fault] = khudfault; diff --git a/src/k_hud.c b/src/k_hud.c index 1b7894da9..2d821ddd4 100644 --- a/src/k_hud.c +++ b/src/k_hud.c @@ -2460,7 +2460,10 @@ static void K_drawKartBumpersOrKarma(void) else V_DrawMappedPatch(LAPS_X, LAPS_Y, V_HUDTRANS|V_SLIDEIN|splitflags, kp_bumpersticker, colormap); - V_DrawKartString(LAPS_X+47, LAPS_Y+3, V_HUDTRANS|V_SLIDEIN|splitflags, va("%d/%d", stplyr->bumpers, maxbumper)); + if (stplyr->bumpers > 0) + V_DrawKartString(LAPS_X+47, LAPS_Y+3, V_HUDTRANS|V_SLIDEIN|splitflags, va("%d/%d", stplyr->bumpers, maxbumper)); + else // TODO - BETTER HUD + V_DrawKartString(LAPS_X+47, LAPS_Y+3, V_HUDTRANS|V_SLIDEIN|splitflags, va("%d", stplyr->overtimekarma / TICRATE)); } } } diff --git a/src/k_kart.c b/src/k_kart.c index 3d46bbfca..5fe2b7ef6 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -6890,18 +6890,28 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd) K_KartPlayerHUDUpdate(player); - if ((battleovertime.enabled >= 10*TICRATE) && !(player->pflags & PF_ELIMINATED)) + if (battleovertime.enabled && !(player->pflags & PF_ELIMINATED)) { - fixed_t distanceToBarrier = 0; - - if (battleovertime.radius > 0) + if (battleovertime.enabled >= 10*TICRATE) { - distanceToBarrier = R_PointToDist2(player->mo->x, player->mo->y, battleovertime.x, battleovertime.y) - (player->mo->radius * 2); + fixed_t distanceToBarrier = 0; + + if (battleovertime.radius > 0) + { + distanceToBarrier = R_PointToDist2(player->mo->x, player->mo->y, battleovertime.x, battleovertime.y) - (player->mo->radius * 2); + } + + if (distanceToBarrier > battleovertime.radius) + { + P_DamageMobj(player->mo, NULL, NULL, 1, DMG_TIMEOVER); + } } - - if (distanceToBarrier > battleovertime.radius) + else if (player->bumpers <= 0) { - P_DamageMobj(player->mo, NULL, NULL, 1, DMG_TIMEOVER); + if (player->overtimekarma) + player->overtimekarma--; + else + P_DamageMobj(player->mo, NULL, NULL, 1, DMG_TIMEOVER); } } diff --git a/src/p_inter.c b/src/p_inter.c index e0ba88296..ea14e5f7c 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -1972,6 +1972,10 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da // Destroy any remainder bumpers from the player for karma comeback damage K_DestroyBumpers(player, player->bumpers); } + else + { + source->player->overtimekarma += 5*TICRATE; + } if (damagetype & DMG_STEAL) { diff --git a/src/p_saveg.c b/src/p_saveg.c index 27e100ccd..cd8f1d208 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -317,6 +317,7 @@ static void P_NetArchivePlayers(void) WRITEUINT8(save_p, players[i].emeralds); WRITEUINT8(save_p, players[i].bumpers); WRITEINT16(save_p, players[i].karmadelay); + WRITEUINT32(save_p, players[i].overtimekarma); WRITEINT16(save_p, players[i].spheres); WRITESINT8(save_p, players[i].glanceDir); @@ -573,6 +574,7 @@ static void P_NetUnArchivePlayers(void) players[i].emeralds = READUINT8(save_p); players[i].bumpers = READUINT8(save_p); players[i].karmadelay = READINT16(save_p); + players[i].overtimekarma = READUINT32(save_p); players[i].spheres = READINT16(save_p); players[i].glanceDir = READSINT8(save_p); From 5f9ec5caa6b604367cde67130d9910212c889181 Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 27 Nov 2021 00:06:01 -0800 Subject: [PATCH 029/156] Fix karma overtime not counting down after 10 seconds :) --- src/k_hud.c | 6 ++---- src/k_kart.c | 34 ++++++++++++++++------------------ 2 files changed, 18 insertions(+), 22 deletions(-) diff --git a/src/k_hud.c b/src/k_hud.c index 2d821ddd4..87cc99f17 100644 --- a/src/k_hud.c +++ b/src/k_hud.c @@ -2460,10 +2460,8 @@ static void K_drawKartBumpersOrKarma(void) else V_DrawMappedPatch(LAPS_X, LAPS_Y, V_HUDTRANS|V_SLIDEIN|splitflags, kp_bumpersticker, colormap); - if (stplyr->bumpers > 0) - V_DrawKartString(LAPS_X+47, LAPS_Y+3, V_HUDTRANS|V_SLIDEIN|splitflags, va("%d/%d", stplyr->bumpers, maxbumper)); - else // TODO - BETTER HUD - V_DrawKartString(LAPS_X+47, LAPS_Y+3, V_HUDTRANS|V_SLIDEIN|splitflags, va("%d", stplyr->overtimekarma / TICRATE)); + // TODO BETTER HUD + V_DrawKartString(LAPS_X+47, LAPS_Y+3, V_HUDTRANS|V_SLIDEIN|splitflags, va("%d - %d", stplyr->bumpers, stplyr->overtimekarma / TICRATE)); } } } diff --git a/src/k_kart.c b/src/k_kart.c index 5fe2b7ef6..b6587364a 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -6890,28 +6890,26 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd) K_KartPlayerHUDUpdate(player); - if (battleovertime.enabled && !(player->pflags & PF_ELIMINATED)) + if (battleovertime.enabled && !(player->pflags & PF_ELIMINATED) && player->bumpers <= 0) { - if (battleovertime.enabled >= 10*TICRATE) + if (player->overtimekarma) + player->overtimekarma--; + else + P_DamageMobj(player->mo, NULL, NULL, 1, DMG_TIMEOVER); + } + + if ((battleovertime.enabled >= 10*TICRATE) && !(player->pflags & PF_ELIMINATED)) + { + fixed_t distanceToBarrier = 0; + + if (battleovertime.radius > 0) { - fixed_t distanceToBarrier = 0; - - if (battleovertime.radius > 0) - { - distanceToBarrier = R_PointToDist2(player->mo->x, player->mo->y, battleovertime.x, battleovertime.y) - (player->mo->radius * 2); - } - - if (distanceToBarrier > battleovertime.radius) - { - P_DamageMobj(player->mo, NULL, NULL, 1, DMG_TIMEOVER); - } + distanceToBarrier = R_PointToDist2(player->mo->x, player->mo->y, battleovertime.x, battleovertime.y) - (player->mo->radius * 2); } - else if (player->bumpers <= 0) + + if (distanceToBarrier > battleovertime.radius) { - if (player->overtimekarma) - player->overtimekarma--; - else - P_DamageMobj(player->mo, NULL, NULL, 1, DMG_TIMEOVER); + P_DamageMobj(player->mo, NULL, NULL, 1, DMG_TIMEOVER); } } From fd6c65a339dab2f1907ebb3e85b7a2370eae34da Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 27 Nov 2021 00:14:48 -0800 Subject: [PATCH 030/156] Don't count down overtime karma timer while waiting to become bomb --- src/k_hud.c | 2 +- src/k_kart.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/k_hud.c b/src/k_hud.c index 87cc99f17..7143396e5 100644 --- a/src/k_hud.c +++ b/src/k_hud.c @@ -2461,7 +2461,7 @@ static void K_drawKartBumpersOrKarma(void) V_DrawMappedPatch(LAPS_X, LAPS_Y, V_HUDTRANS|V_SLIDEIN|splitflags, kp_bumpersticker, colormap); // TODO BETTER HUD - V_DrawKartString(LAPS_X+47, LAPS_Y+3, V_HUDTRANS|V_SLIDEIN|splitflags, va("%d - %d", stplyr->bumpers, stplyr->overtimekarma / TICRATE)); + V_DrawKartString(LAPS_X+47, LAPS_Y+3, V_HUDTRANS|V_SLIDEIN|splitflags, va("%d/%d %d", stplyr->bumpers, maxbumper, stplyr->overtimekarma / TICRATE)); } } } diff --git a/src/k_kart.c b/src/k_kart.c index b6587364a..0282f8c90 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -6890,7 +6890,7 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd) K_KartPlayerHUDUpdate(player); - if (battleovertime.enabled && !(player->pflags & PF_ELIMINATED) && player->bumpers <= 0) + if (battleovertime.enabled && !(player->pflags & PF_ELIMINATED) && player->bumpers <= 0 && player->karmadelay <= 0) { if (player->overtimekarma) player->overtimekarma--; From eb9e3d3e1bf66b7f9a14c688f6c55f318c3789c2 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Sat, 27 Nov 2021 03:24:29 -0500 Subject: [PATCH 031/156] Snap da sentinel like hitlag - Added a hitlag cap of 18 frames (can be decreased to 12 if it's too much) - Hitlag amount can't be reduced, only increased - Hitlag added is the same between both objects, instead of being different between the two - Objects in hitlag can be interacted with again with TryMove (I was too nervous of it but it's fine in Snap lol) - Rebalanced the damage hitlag lengths to make it feel relatively the same with all of the above considered --- src/k_kart.c | 81 +++++++++++++++++++++++---------------------------- src/k_kart.h | 2 ++ src/p_inter.c | 8 ++--- src/p_map.c | 2 ++ 4 files changed, 44 insertions(+), 49 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 3d46bbfca..015821165 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -3021,74 +3021,65 @@ angle_t K_MomentumAngle(mobj_t *mo) } } +void K_AddHitLag(mobj_t *mo, INT32 tics) +{ + if (mo == NULL || P_MobjWasRemoved(mo)) + { + return; + } + + if (mo->player != NULL && P_IsLocalPlayer(mo->player)) + { + // temporary :) + CONS_Printf("tics: %d\n", tics); + } + + mo->hitlag += tics; + mo->hitlag = min(mo->hitlag, MAXHITLAGTICS); +} + void K_SetHitLagForObjects(mobj_t *mo1, mobj_t *mo2, INT32 tics) { - boolean mo1valid = (mo1 && !P_MobjWasRemoved(mo1)); - boolean mo2valid = (mo2 && !P_MobjWasRemoved(mo2)); - - INT32 tics1 = tics; - INT32 tics2 = tics; + INT32 finalTics = tics; if (tics <= 0) { return; } - if (mo1valid == true && mo2valid == true) + if ((mo1 && !P_MobjWasRemoved(mo1)) == true && (mo2 && !P_MobjWasRemoved(mo2)) == true) { - const INT32 mintics = tics; - const fixed_t ticaddfactor = mapobjectscale * 8; + const fixed_t speedTicFactor = (mapobjectscale * 8); + const INT32 angleTicFactor = ANGLE_22h; const fixed_t mo1speed = FixedHypot(FixedHypot(mo1->momx, mo1->momy), mo1->momz); const fixed_t mo2speed = FixedHypot(FixedHypot(mo2->momx, mo2->momy), mo2->momz); - const fixed_t speeddiff = mo2speed - mo1speed; + const fixed_t speedDiff = abs(mo2speed - mo1speed); - const fixed_t scalediff = mo2->scale - mo1->scale; + const fixed_t scaleDiff = abs(mo2->scale - mo1->scale); - const angle_t mo1angle = K_MomentumAngle(mo1); - const angle_t mo2angle = K_MomentumAngle(mo2); + angle_t mo1angle = K_MomentumAngle(mo1); + angle_t mo2angle = K_MomentumAngle(mo2); + INT32 angleDiff = 0; - angle_t anglediff = mo1angle - mo2angle; - fixed_t anglemul = FRACUNIT; - - if (anglediff > ANGLE_180) + if (mo1speed > 0 && mo2speed > 0) { - anglediff = InvAngle(anglediff); + // If either object is completely not moving, their speed doesn't matter. + angleDiff = AngleDelta(mo1angle, mo2angle); } - anglemul = FRACUNIT + (AngleFixed(anglediff) / 180); // x1.0 at 0, x1.5 at 90, x2.0 at 180 + // Add extra "damage" based on what was happening to the objects on impact. + finalTics += (FixedMul(speedDiff, FRACUNIT + scaleDiff) / speedTicFactor) + (angleDiff / angleTicFactor); - /* - CONS_Printf("anglemul: %f\n", FIXED_TO_FLOAT(anglemul)); - CONS_Printf("speeddiff: %f\n", FIXED_TO_FLOAT(speeddiff)); - CONS_Printf("scalediff: %f\n", FIXED_TO_FLOAT(scalediff)); - */ - - tics1 += FixedMul(speeddiff, FixedMul(anglemul, FRACUNIT + scalediff)) / ticaddfactor; - tics2 += FixedMul(-speeddiff, FixedMul(anglemul, FRACUNIT - scalediff)) / ticaddfactor; - - if (tics1 < mintics) + // This shouldn't happen anymore, but just in case something funky happens. + if (finalTics < tics) { - tics1 = mintics; - } - - if (tics2 < mintics) - { - tics2 = mintics; + finalTics = tics; } } - //CONS_Printf("tics1: %d, tics2: %d\n", tics1, tics2); - - if (mo1valid == true) - { - mo1->hitlag = max(tics1, mo1->hitlag); - } - - if (mo2valid == true) - { - mo2->hitlag = max(tics2, mo2->hitlag); - } + K_AddHitLag(mo1, finalTics); + K_AddHitLag(mo2, finalTics); } void K_DoInstashield(player_t *player) diff --git a/src/k_kart.h b/src/k_kart.h index 0694488d3..24d16cf81 100644 --- a/src/k_kart.h +++ b/src/k_kart.h @@ -19,6 +19,7 @@ Make sure this matches the actual number of states */ #define KART_NUMINVSPARKLESANIM 12 +#define MAXHITLAGTICS 18 //12 player_t *K_GetItemBoxPlayer(mobj_t *mobj); angle_t K_ReflectAngle(angle_t angle, angle_t against, fixed_t maxspeed, fixed_t yourspeed); @@ -55,6 +56,7 @@ void K_KartPlayerHUDUpdate(player_t *player); void K_KartPlayerThink(player_t *player, ticcmd_t *cmd); void K_KartPlayerAfterThink(player_t *player); angle_t K_MomentumAngle(mobj_t *mo); +void K_AddHitLag(mobj_t *mo, INT32 tics); void K_SetHitLagForObjects(mobj_t *mo1, mobj_t *mo2, INT32 tics); void K_DoInstashield(player_t *player); void K_BattleAwardHit(player_t *player, player_t *victim, mobj_t *inflictor, UINT8 bumpersRemoved); diff --git a/src/p_inter.c b/src/p_inter.c index e0ba88296..7b2e09249 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -960,7 +960,7 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, UINT8 damaget if (LUAh_MobjDeath(target, inflictor, source, damagetype) || P_MobjWasRemoved(target)) return; - //K_SetHitLagForObjects(target, inflictor, 15); + //K_SetHitLagForObjects(target, inflictor, MAXHITLAGTICS); // SRB2kart // I wish I knew a better way to do this @@ -1737,7 +1737,7 @@ static boolean P_KillPlayer(player_t *player, mobj_t *inflictor, mobj_t *source, } K_DropEmeraldsFromPlayer(player, player->emeralds); - K_SetHitLagForObjects(player->mo, inflictor, 15); + K_SetHitLagForObjects(player->mo, inflictor, MAXHITLAGTICS); player->carry = CR_NONE; @@ -1797,7 +1797,7 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da player_t *player; boolean force = false; - INT32 laglength = 10; + INT32 laglength = 6; INT32 kinvextend = 0; if (objectplacing) @@ -1816,7 +1816,7 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da if (((damagetype & DMG_TYPEMASK) == DMG_STING) || ((inflictor && !P_MobjWasRemoved(inflictor)) && inflictor->type == MT_BANANA && inflictor->health <= 1)) { - laglength = 5; + laglength = 2; } // Everything above here can't be forced. diff --git a/src/p_map.c b/src/p_map.c index 829393d32..099ace8e4 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -2408,11 +2408,13 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) if (radius < mapobjectscale) radius = mapobjectscale; +#if 0 if (thing->hitlag > 0) { // Do not move during hitlag return false; } +#endif do { if (thing->flags & MF_NOCLIP) { From f6e6c2010ebcf7d88b06954a7c539e73516a10c7 Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 27 Nov 2021 01:21:46 -0800 Subject: [PATCH 032/156] Reintroduce battle overtime barrier minimum radius - 768 fracunit minimum. - Emerald spawning arc reduced so they spawn right next to the barrier at minimum radius. - Items always spawn. --- src/k_battle.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/k_battle.c b/src/k_battle.c index 5fc7cc05a..c33ea6bcc 100644 --- a/src/k_battle.c +++ b/src/k_battle.c @@ -179,7 +179,7 @@ mobj_t *K_SpawnChaosEmerald(fixed_t x, fixed_t y, fixed_t z, angle_t angle, SINT P_Thrust(emerald, FixedAngle(P_RandomFixed() * 180) + angle, - 32 * mapobjectscale); + 24 * mapobjectscale); emerald->momz = flip * 24 * mapobjectscale; if (emerald->eflags & MFE_UNDERWATER) @@ -288,12 +288,6 @@ void K_RunPaperItemSpawners(void) if (overtime == true) { - if (battleovertime.radius < 512*mapobjectscale) - { - // Barrier has closed in too much - return; - } - // Double frequency of items interval /= 2; } @@ -557,10 +551,12 @@ void K_RunBattleOvertime(void) } else if (battleovertime.radius > 0) { - if (battleovertime.radius > 2*mapobjectscale) + const fixed_t minradius = 768 * mapobjectscale; + + if (battleovertime.radius > minradius) battleovertime.radius -= 2*mapobjectscale; else - battleovertime.radius = 0; + battleovertime.radius = minradius; } if (battleovertime.radius > 0) From 0d3a1b72cb4535ebfce2662d16f78e618f6b7711 Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 27 Nov 2021 03:05:04 -0800 Subject: [PATCH 033/156] Apply grease to vertical only springs too --- src/p_map.c | 35 ++++++++++++++++------------------- 1 file changed, 16 insertions(+), 19 deletions(-) diff --git a/src/p_map.c b/src/p_map.c index 28c747997..ff83a22a4 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -345,25 +345,6 @@ boolean P_DoSpring(mobj_t *spring, mobj_t *object) } } - if (object->player) - { - // Less friction when hitting springs - if (!object->player->tiregrease) - { - UINT8 i; - for (i = 0; i < 2; i++) - { - mobj_t *grease; - grease = P_SpawnMobj(object->x, object->y, object->z, MT_TIREGREASE); - P_SetTarget(&grease->target, object); - grease->angle = K_MomentumAngle(object); - grease->extravalue1 = i; - } - - object->player->tiregrease = greasetics; //FixedMul(greasetics << FRACBITS, finalSpeed/72) >> FRACBITS - } - } - // Horizontal speed is used as a minimum thrust, not a direct replacement finalSpeed = max(objectSpeed, finalSpeed); @@ -386,6 +367,22 @@ boolean P_DoSpring(mobj_t *spring, mobj_t *object) object->player->springstars = max(vertispeed, horizspeed) / FRACUNIT / 2; object->player->springcolor = starcolor; + + // Less friction when hitting springs + if (!object->player->tiregrease) + { + UINT8 i; + for (i = 0; i < 2; i++) + { + mobj_t *grease; + grease = P_SpawnMobj(object->x, object->y, object->z, MT_TIREGREASE); + P_SetTarget(&grease->target, object); + grease->angle = K_MomentumAngle(object); + grease->extravalue1 = i; + } + + object->player->tiregrease = greasetics; //FixedMul(greasetics << FRACBITS, finalSpeed/72) >> FRACBITS + } } return true; From cb5ea8b3353372d285574be9d1b806fc7347e2b3 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Sat, 27 Nov 2021 13:38:45 -0500 Subject: [PATCH 034/156] Add basic damage hitlag effects - Invert high contrast greyscale colorization effect for damage hitlag - Jitter is now also exclusive to damage-related hitlag - Since jitter is now just tied to a flag, removed the old trick momentum hack --- src/d_player.h | 3 -- src/deh_tables.c | 1 + src/hardware/hw_main.c | 10 ++++-- src/hardware/hw_md2.c | 15 +++++++-- src/k_color.c | 62 +++++++++++++++++++++++++++++++++-- src/k_color.h | 29 +++++++++++++++++ src/k_hud.c | 2 +- src/k_kart.c | 74 ++++++++++++++---------------------------- src/k_kart.h | 4 +-- src/lua_playerlib.c | 12 ------- src/p_inter.c | 11 ++++--- src/p_mobj.c | 2 +- src/p_mobj.h | 2 ++ src/p_saveg.c | 10 +++--- src/r_draw.c | 6 +++- src/r_draw.h | 1 + src/r_things.c | 8 +++-- 17 files changed, 161 insertions(+), 91 deletions(-) diff --git a/src/d_player.h b/src/d_player.h index dd765bb0b..1350e7a7d 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -456,9 +456,6 @@ typedef struct player_s UINT8 trickpanel; // Trick panel state UINT8 tricktime; // Increases while you're tricking. You can't input any trick until it's reached a certain threshold - fixed_t trickmomx; - fixed_t trickmomy; - fixed_t trickmomz; fixed_t trickboostpower; // Save the rough speed multiplier. Used for upwards tricks. UINT8 trickboostdecay; // used to know how long you've waited UINT8 trickboost; // Trick boost. This one is weird and has variable speed. Dear god. diff --git a/src/deh_tables.c b/src/deh_tables.c index 3f5a56d27..ae9b90964 100644 --- a/src/deh_tables.c +++ b/src/deh_tables.c @@ -6845,6 +6845,7 @@ struct int_const_s const INT_CONST[] = { {"TC_RAINBOW",TC_RAINBOW}, {"TC_BLINK",TC_BLINK}, {"TC_DASHMODE",TC_DASHMODE}, + {"TC_HITLAG",TC_HITLAG}, // marathonmode flags {"MA_INIT",MA_INIT}, diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index ed0523119..3e113bd76 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -3643,7 +3643,7 @@ static void HWR_DrawDropShadow(mobj_t *thing, fixed_t scale) pslope_t *groundslope; // hitlag vibrating - if (thing->hitlag > 0) + if (thing->hitlag > 0 && (thing->eflags & MFE_DAMAGEHITLAG)) { fixed_t mul = thing->hitlag * (FRACUNIT / 10); @@ -5062,7 +5062,7 @@ static void HWR_ProjectSprite(mobj_t *thing) return; // hitlag vibrating - if (thing->hitlag > 0) + if (thing->hitlag > 0 && (thing->eflags & MFE_DAMAGEHITLAG)) { fixed_t mul = thing->hitlag * (FRACUNIT / 10); @@ -5401,7 +5401,11 @@ static void HWR_ProjectSprite(mobj_t *thing) vis->mobj = thing; //Hurdler: 25/04/2000: now support colormap in hardware mode - if ((vis->mobj->flags & (MF_ENEMY|MF_BOSS)) && (vis->mobj->flags2 & MF2_FRET) && !(vis->mobj->flags & MF_GRENADEBOUNCE) && (leveltime & 1)) // Bosses "flash" + if (vis->mobj->hitlag > 0 && (vis->mobj->eflags & MFE_DAMAGEHITLAG)) + { + vis->colormap = R_GetTranslationColormap(TC_HITLAG, 0, GTC_CACHE); + } + else if ((vis->mobj->flags & (MF_ENEMY|MF_BOSS)) && (vis->mobj->flags2 & MF2_FRET) && !(vis->mobj->flags & MF_GRENADEBOUNCE) && (leveltime & 1)) // Bosses "flash" { if (vis->mobj->type == MT_CYBRAKDEMON || vis->mobj->colorized) vis->colormap = R_GetTranslationColormap(TC_ALLWHITE, 0, GTC_CACHE); diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index f6c18db97..4b8d1de6f 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -819,7 +819,12 @@ static void HWR_CreateBlendedTexture(patch_t *gpatch, patch_t *blendgpatch, GLMi while (size--) { - if (skinnum == TC_BOSS) + if (skinnum == TC_HITLAG) + { + cur->s.red = cur->s.green = cur->s.blue = K_HitlagColorValue(*image); + cur->s.alpha = image->s.alpha; + } + else if (skinnum == TC_BOSS) { // Turn everything below a certain threshold white if ((image->s.red == image->s.green) && (image->s.green == image->s.blue) && image->s.blue < 127) @@ -1367,7 +1372,7 @@ boolean HWR_DrawModel(gl_vissprite_t *spr) float finalscale; // hitlag vibrating - if (spr->mobj->hitlag > 0) + if (spr->mobj->hitlag > 0 && (spr->mobj->eflags & MFE_DAMAGEHITLAG)) { fixed_t mul = spr->mobj->hitlag * (FRACUNIT / 10); @@ -1486,7 +1491,11 @@ boolean HWR_DrawModel(gl_vissprite_t *spr) { INT32 skinnum = TC_DEFAULT; - if ((spr->mobj->flags & (MF_ENEMY|MF_BOSS)) && (spr->mobj->flags2 & MF2_FRET) && !(spr->mobj->flags & MF_GRENADEBOUNCE) && (leveltime & 1)) // Bosses "flash" + if (spr->mobj->hitlag > 0 && (spr->mobj->eflags & MFE_DAMAGEHITLAG)) + { + skinnum = TC_HITLAG; + } + else if ((spr->mobj->flags & (MF_ENEMY|MF_BOSS)) && (spr->mobj->flags2 & MF2_FRET) && !(spr->mobj->flags & MF_GRENADEBOUNCE) && (leveltime & 1)) // Bosses "flash" { if (spr->mobj->type == MT_CYBRAKDEMON || spr->mobj->colorized) skinnum = TC_ALLWHITE; diff --git a/src/k_color.c b/src/k_color.c index 6cfe4d5a8..0821c4437 100644 --- a/src/k_color.c +++ b/src/k_color.c @@ -90,6 +90,59 @@ void K_RainbowColormap(UINT8 *dest_colormap, UINT8 skincolor) } } +/*-------------------------------------------------- + UINT8 K_HitlagColorValue(RGBA_t color) + + See header file for description. +--------------------------------------------------*/ +UINT8 K_HitlagColorValue(RGBA_t color) +{ + // Outputs a raw brightness value (makes OGL support easier) + INT32 output = K_ColorRelativeLuminance(color.s.red, color.s.green, color.s.blue); + + // Invert the color + output = 255 - output; + + // Increase the contrast + output = ((output-128) * 2) + 128; + + // Make sure to cap it. + if (output > 255) + { + output = 255; + } + else if (output < 0) + { + output = 0; + } + + return output; +} + +/*-------------------------------------------------- + void K_HitlagColormap(UINT8 *dest_colormap) + + See header file for description. +--------------------------------------------------*/ +void K_HitlagColormap(UINT8 *dest_colormap) +{ + RGBA_t color; + UINT8 v, offset; + INT32 i; + + // for every colour in the palette, invert, greyscale, and increase the contrast. + for (i = 0; i < NUM_PALETTE_ENTRIES; i++) + { + color = V_GetColor(i); + v = K_HitlagColorValue(color); + + // Convert raw brightness value to an offset from the greyscale palette line + offset = (255 - v) / 8; + + dest_colormap[i] = offset; // Starts from 0, add it if greyscale moves. + } +} + /*-------------------------------------------------- void K_GenerateKartColormap(UINT8 *dest_colormap, INT32 skinnum, UINT8 color) @@ -100,13 +153,18 @@ void K_GenerateKartColormap(UINT8 *dest_colormap, INT32 skinnum, UINT8 color) INT32 i; INT32 starttranscolor; - // Handle a couple of simple special cases - if (skinnum == TC_BOSS + if (skinnum == TC_HITLAG) + { + K_HitlagColormap(dest_colormap); + return; + } + else if (skinnum == TC_BOSS || skinnum == TC_ALLWHITE || skinnum == TC_METALSONIC || skinnum == TC_BLINK || color == SKINCOLOR_NONE) { + // Handle a couple of simple special cases for (i = 0; i < NUM_PALETTE_ENTRIES; i++) { if (skinnum == TC_ALLWHITE) diff --git a/src/k_color.h b/src/k_color.h index e90ab0fc4..6e6778d75 100644 --- a/src/k_color.h +++ b/src/k_color.h @@ -66,6 +66,35 @@ UINT16 K_RainbowColor(tic_t time); void K_RainbowColormap(UINT8 *dest_colormap, UINT8 skincolor); +/*-------------------------------------------------- + UINT8 K_HitlagColorValue(RGBA_t color); + + Gets the new replacement brightness value for the hitlag effect. + + Input Arguments:- + color - Input color we intend to replace. + + Return:- + 0 to 255 brightness value. +--------------------------------------------------*/ + +UINT8 K_HitlagColorValue(RGBA_t color); + +/*-------------------------------------------------- + void K_HitlagColormap(UINT8 *dest_colormap); + + Generates a inverted hi-contrast greyscale colormap, + for the hitlag effect. + + Input Arguments:- + dest_colormap - Colormap to populate. + + Return:- + None +--------------------------------------------------*/ + +void K_HitlagColormap(UINT8 *dest_colormap); + /*-------------------------------------------------- void K_GenerateKartColormap(UINT8 *dest_colormap, INT32 skinnum, UINT8 color); diff --git a/src/k_hud.c b/src/k_hud.c index 1b7894da9..25b437f5c 100644 --- a/src/k_hud.c +++ b/src/k_hud.c @@ -3742,7 +3742,7 @@ static void K_drawKartFirstPerson(void) fixed_t yoffs = -P_ReturnThrustX(stplyr->mo, ang, 4*FRACUNIT); // hitlag vibrating - if (stplyr->mo->hitlag > 0) + if (stplyr->mo->hitlag > 0 && (stplyr->mo->eflags & MFE_DAMAGEHITLAG)) { fixed_t mul = stplyr->mo->hitlag * (FRACUNIT / 10); if (r_splitscreen && mul > FRACUNIT) diff --git a/src/k_kart.c b/src/k_kart.c index 015821165..068fe9b6e 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -3021,24 +3021,25 @@ angle_t K_MomentumAngle(mobj_t *mo) } } -void K_AddHitLag(mobj_t *mo, INT32 tics) +void K_AddHitLag(mobj_t *mo, INT32 tics, boolean fromDamage) { if (mo == NULL || P_MobjWasRemoved(mo)) { return; } - if (mo->player != NULL && P_IsLocalPlayer(mo->player)) - { - // temporary :) - CONS_Printf("tics: %d\n", tics); - } - mo->hitlag += tics; mo->hitlag = min(mo->hitlag, MAXHITLAGTICS); + + if (fromDamage == true) + { + // Dunno if this should flat-out &~ the flag out too. + // Decided it probably just just keep it since it's "adding" hitlag. + mo->eflags |= MFE_DAMAGEHITLAG; + } } -void K_SetHitLagForObjects(mobj_t *mo1, mobj_t *mo2, INT32 tics) +void K_SetHitLagForObjects(mobj_t *mo1, mobj_t *mo2, INT32 tics, boolean fromDamage) { INT32 finalTics = tics; @@ -3078,8 +3079,8 @@ void K_SetHitLagForObjects(mobj_t *mo1, mobj_t *mo2, INT32 tics) } } - K_AddHitLag(mo1, finalTics); - K_AddHitLag(mo2, finalTics); + K_AddHitLag(mo1, finalTics, fromDamage); + K_AddHitLag(mo2, finalTics, fromDamage); } void K_DoInstashield(player_t *player) @@ -5112,7 +5113,7 @@ void K_DoPogoSpring(mobj_t *mo, fixed_t vertispeed, UINT8 sound) thrust = FixedMul(thrust, 9*FRACUNIT/8); } - mo->player->trickmomx = mo->player->trickmomy = mo->player->trickmomz = mo->player->tricktime = 0; // Reset post-hitlag momentums and timer + mo->player->tricktime = 0; // Reset post-hitlag timer // Setup the boost for potential upwards trick, at worse, make it your regular max speed. (boost = curr speed*1.25) mo->player->trickboostpower = max(FixedDiv(mo->player->speed, K_GetKartSpeed(mo->player, false)) - FRACUNIT, 0)*125/100; //CONS_Printf("Got boost: %d%\n", mo->player->trickboostpower*100 / FRACUNIT); @@ -9199,29 +9200,21 @@ void K_MoveKartPlayer(player_t *player, boolean onground) if (cmd->turning > 0) { P_InstaThrust(player->mo, player->mo->angle + lr, max(basespeed, speed*5/2)); - - player->trickmomx = player->mo->momx; - player->trickmomy = player->mo->momy; - player->trickmomz = player->mo->momz; - P_InstaThrust(player->mo, 0, 0); // Sike, you have no speed :) - player->mo->momz = 0; - player->trickpanel = 2; + player->mo->hitlag = TRICKLAG; + player->mo->eflags &= ~MFE_DAMAGEHITLAG; + K_trickPanelTimingVisual(player, momz); } else if (cmd->turning < 0) { P_InstaThrust(player->mo, player->mo->angle - lr, max(basespeed, speed*5/2)); - - player->trickmomx = player->mo->momx; - player->trickmomy = player->mo->momy; - player->trickmomz = player->mo->momz; - P_InstaThrust(player->mo, 0, 0); // Sike, you have no speed :) - player->mo->momz = 0; - player->trickpanel = 3; + player->mo->hitlag = TRICKLAG; + player->mo->eflags &= ~MFE_DAMAGEHITLAG; + K_trickPanelTimingVisual(player, momz); } else if (player->throwdir == 1) @@ -9232,15 +9225,11 @@ void K_MoveKartPlayer(player_t *player, boolean onground) } P_InstaThrust(player->mo, player->mo->angle, max(basespeed, speed*3)); - - player->trickmomx = player->mo->momx; - player->trickmomy = player->mo->momy; - player->trickmomz = player->mo->momz; - P_InstaThrust(player->mo, 0, 0); // Sike, you have no speed :) - player->mo->momz = 0; - player->trickpanel = 2; + player->mo->hitlag = TRICKLAG; + player->mo->eflags &= ~MFE_DAMAGEHITLAG; + K_trickPanelTimingVisual(player, momz); } else if (player->throwdir == -1) @@ -9262,30 +9251,15 @@ void K_MoveKartPlayer(player_t *player, boolean onground) //CONS_Printf("decay: %d\n", player->trickboostdecay); P_SetObjectMomZ(player->mo, 48*FRACUNIT, relative); - - player->trickmomx = player->mo->momx; - player->trickmomy = player->mo->momy; - player->trickmomz = player->mo->momz; - P_InstaThrust(player->mo, 0, 0); // Sike, you have no speed :) - player->mo->momz = 0; - player->trickpanel = 4; + player->mo->hitlag = TRICKLAG; + player->mo->eflags &= ~MFE_DAMAGEHITLAG; + K_trickPanelTimingVisual(player, momz); } } } - // After hitlag, we will get here and will be able to apply the desired momentums! - else if (player->trickmomx || player->trickmomy || player->trickmomz) - { - player->mo->momx = player->trickmomx; - player->mo->momy = player->trickmomy; - player->mo->momz = player->trickmomz; - - player->trickmomx = player->trickmomy = player->trickmomz = 0; - - } - else if (player->trickpanel == 4 && P_IsObjectOnGround(player->mo)) // Upwards trick landed! { //CONS_Printf("apply boost\n"); diff --git a/src/k_kart.h b/src/k_kart.h index 24d16cf81..540e6845c 100644 --- a/src/k_kart.h +++ b/src/k_kart.h @@ -56,8 +56,8 @@ void K_KartPlayerHUDUpdate(player_t *player); void K_KartPlayerThink(player_t *player, ticcmd_t *cmd); void K_KartPlayerAfterThink(player_t *player); angle_t K_MomentumAngle(mobj_t *mo); -void K_AddHitLag(mobj_t *mo, INT32 tics); -void K_SetHitLagForObjects(mobj_t *mo1, mobj_t *mo2, INT32 tics); +void K_AddHitLag(mobj_t *mo, INT32 tics, boolean fromDamage); +void K_SetHitLagForObjects(mobj_t *mo1, mobj_t *mo2, INT32 tics, boolean fromDamage); void K_DoInstashield(player_t *player); void K_BattleAwardHit(player_t *player, player_t *victim, mobj_t *inflictor, UINT8 bumpersRemoved); void K_SpinPlayer(player_t *player, mobj_t *inflictor, mobj_t *source, INT32 type); diff --git a/src/lua_playerlib.c b/src/lua_playerlib.c index d628b7016..f7c20ab64 100644 --- a/src/lua_playerlib.c +++ b/src/lua_playerlib.c @@ -356,12 +356,6 @@ static int player_get(lua_State *L) lua_pushinteger(L, plr->trickpanel); else if (fastcmp(field,"tricktime")) lua_pushinteger(L, plr->tricktime); - else if (fastcmp(field,"trickmomx")) - lua_pushfixed(L, plr->trickmomx); - else if (fastcmp(field,"trickmomy")) - lua_pushfixed(L, plr->trickmomy); - else if (fastcmp(field,"trickmomz")) - lua_pushfixed(L, plr->trickmomz); else if (fastcmp(field,"trickboostpower")) lua_pushfixed(L, plr->trickboostpower); else if (fastcmp(field,"trickboostdecay")) @@ -707,12 +701,6 @@ static int player_set(lua_State *L) plr->trickpanel = luaL_checkinteger(L, 3); else if (fastcmp(field,"tricktime")) plr->tricktime = luaL_checkinteger(L, 3); - else if (fastcmp(field,"trickmomx")) - plr->trickmomx = luaL_checkfixed(L, 3); - else if (fastcmp(field,"trickmomy")) - plr->trickmomy = luaL_checkfixed(L, 3); - else if (fastcmp(field,"trickmomz")) - plr->trickmomz = luaL_checkfixed(L, 3); else if (fastcmp(field,"trickboostpower")) plr->trickboostpower = luaL_checkfixed(L, 3); else if (fastcmp(field,"trickboostdecay")) diff --git a/src/p_inter.c b/src/p_inter.c index 7b2e09249..b6bb28b69 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -960,7 +960,7 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, UINT8 damaget if (LUAh_MobjDeath(target, inflictor, source, damagetype) || P_MobjWasRemoved(target)) return; - //K_SetHitLagForObjects(target, inflictor, MAXHITLAGTICS); + //K_SetHitLagForObjects(target, inflictor, MAXHITLAGTICS, true); // SRB2kart // I wish I knew a better way to do this @@ -1247,6 +1247,7 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, UINT8 damaget kart->angle = target->angle; kart->color = target->color; kart->hitlag = target->hitlag; + kart->eflags |= MFE_DAMAGEHITLAG; P_SetObjectMomZ(kart, 6*FRACUNIT, false); kart->extravalue1 = target->player->kartweight; } @@ -1737,7 +1738,7 @@ static boolean P_KillPlayer(player_t *player, mobj_t *inflictor, mobj_t *source, } K_DropEmeraldsFromPlayer(player, player->emeralds); - K_SetHitLagForObjects(player->mo, inflictor, MAXHITLAGTICS); + K_SetHitLagForObjects(player->mo, inflictor, MAXHITLAGTICS, true); player->carry = CR_NONE; @@ -2050,7 +2051,7 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da } player->instashield = 15; - K_SetHitLagForObjects(target, inflictor, laglength); + K_SetHitLagForObjects(target, inflictor, laglength, true); return true; } } @@ -2072,7 +2073,7 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da if (source && source->player && target) G_GhostAddHit((INT32) (source->player - players), target); - K_SetHitLagForObjects(target, inflictor, laglength); + K_SetHitLagForObjects(target, inflictor, laglength, true); if (target->health <= 0) { @@ -2080,7 +2081,7 @@ boolean P_DamageMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, INT32 da return true; } - //K_SetHitLagForObjects(target, inflictor, laglength); + //K_SetHitLagForObjects(target, inflictor, laglength, true); if (player) P_ResetPlayer(target->player); diff --git a/src/p_mobj.c b/src/p_mobj.c index 34b48dc9c..7d372fab1 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -8613,7 +8613,7 @@ void P_MobjThinker(mobj_t *mobj) return; } - mobj->eflags &= ~(MFE_PUSHED|MFE_SPRUNG|MFE_JUSTBOUNCEDWALL); + mobj->eflags &= ~(MFE_PUSHED|MFE_SPRUNG|MFE_JUSTBOUNCEDWALL|MFE_DAMAGEHITLAG); tmfloorthing = tmhitthing = NULL; diff --git a/src/p_mobj.h b/src/p_mobj.h index 997b00f65..16055907b 100644 --- a/src/p_mobj.h +++ b/src/p_mobj.h @@ -247,6 +247,8 @@ typedef enum MFE_TRACERANGLE = 1<<11, // SRB2Kart: The mobj just hit & bounced off a wall, this is cleared on next frame MFE_JUSTBOUNCEDWALL = 1<<12, + // SRB2Kart: In damage hitlag (displays different visual efx) + MFE_DAMAGEHITLAG = 1<<13, // free: to and including 1<<15 } mobjeflag_t; diff --git a/src/p_saveg.c b/src/p_saveg.c index 27e100ccd..00b76c14a 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -306,9 +306,6 @@ static void P_NetArchivePlayers(void) WRITEUINT8(save_p, players[i].trickpanel); WRITEUINT8(save_p, players[i].tricktime); - WRITEUINT32(save_p, players[i].trickmomx); - WRITEUINT32(save_p, players[i].trickmomy); - WRITEUINT32(save_p, players[i].trickmomz); WRITEUINT32(save_p, players[i].trickboostpower); WRITEUINT8(save_p, players[i].trickboostdecay); WRITEUINT8(save_p, players[i].trickboost); @@ -562,9 +559,6 @@ static void P_NetUnArchivePlayers(void) players[i].trickpanel = READUINT8(save_p); players[i].tricktime = READUINT8(save_p); - players[i].trickmomx = READUINT32(save_p); - players[i].trickmomy = READUINT32(save_p); - players[i].trickmomz = READUINT32(save_p); players[i].trickboostpower = READUINT32(save_p); players[i].trickboostdecay = READUINT8(save_p); players[i].trickboost = READUINT8(save_p); @@ -1965,7 +1959,9 @@ static void SaveMobjThinker(const thinker_t *th, const UINT8 type) WRITEFIXED(save_p, slope->normal.z); } if (diff2 & MD2_HITLAG) + { WRITEINT32(save_p, mobj->hitlag); + } WRITEUINT32(save_p, mobj->mobjnum); } @@ -3057,7 +3053,9 @@ static thinker_t* LoadMobjThinker(actionf_p1 thinker) slope->normal.z = READFIXED(save_p); } if (diff2 & MD2_HITLAG) + { mobj->hitlag = READINT32(save_p); + } if (diff & MD_REDFLAG) { diff --git a/src/r_draw.c b/src/r_draw.c index 565d4a1fa..4adfb6663 100644 --- a/src/r_draw.c +++ b/src/r_draw.c @@ -141,7 +141,9 @@ UINT32 nflatxshift, nflatyshift, nflatshiftup, nflatmask; #define RAINBOW_TT_CACHE_INDEX (MAXSKINS + 4) #define BLINK_TT_CACHE_INDEX (MAXSKINS + 5) #define DASHMODE_TT_CACHE_INDEX (MAXSKINS + 6) -#define TT_CACHE_SIZE (MAXSKINS + 7) +#define HITLAG_TT_CACHE_INDEX (MAXSKINS + 7) +#define TT_CACHE_SIZE (MAXSKINS + 8) + #define SKIN_RAMP_LENGTH 16 #define DEFAULT_STARTTRANSCOLOR 96 #define NUM_PALETTE_ENTRIES 256 @@ -160,6 +162,7 @@ static INT32 SkinToCacheIndex(INT32 skinnum) case TC_RAINBOW: return RAINBOW_TT_CACHE_INDEX; case TC_BLINK: return BLINK_TT_CACHE_INDEX; case TC_DASHMODE: return DASHMODE_TT_CACHE_INDEX; + case TC_HITLAG: return HITLAG_TT_CACHE_INDEX; default: break; } @@ -177,6 +180,7 @@ static INT32 CacheIndexToSkin(INT32 ttc) case RAINBOW_TT_CACHE_INDEX: return TC_RAINBOW; case BLINK_TT_CACHE_INDEX: return TC_BLINK; case DASHMODE_TT_CACHE_INDEX: return TC_DASHMODE; + case HITLAG_TT_CACHE_INDEX: return TC_HITLAG; default: break; } diff --git a/src/r_draw.h b/src/r_draw.h index 687448c98..646eb5ec8 100644 --- a/src/r_draw.h +++ b/src/r_draw.h @@ -119,6 +119,7 @@ enum TC_RAINBOW, // For single colour TC_BLINK, // For item blinking, according to kart TC_DASHMODE, // For Metal Sonic's dashmode + TC_HITLAG, // Damage hitlag effect TC_DEFAULT }; diff --git a/src/r_things.c b/src/r_things.c index 21e0228a3..defd02a5f 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -737,7 +737,11 @@ boolean R_SpriteIsFlashing(vissprite_t *vis) UINT8 *R_GetSpriteTranslation(vissprite_t *vis) { - if (R_SpriteIsFlashing(vis)) // Bosses "flash" + if (vis->mobj->hitlag > 0 && (vis->mobj->eflags & MFE_DAMAGEHITLAG)) + { + return R_GetTranslationColormap(TC_HITLAG, 0, GTC_CACHE); + } + else if (R_SpriteIsFlashing(vis)) // Bosses "flash" { if (vis->mobj->type == MT_CYBRAKDEMON || vis->mobj->colorized) return R_GetTranslationColormap(TC_ALLWHITE, 0, GTC_CACHE); @@ -1432,7 +1436,7 @@ static void R_ProjectSprite(mobj_t *thing) #endif // hitlag vibrating - if (thing->hitlag > 0) + if (thing->hitlag > 0 && (thing->eflags & MFE_DAMAGEHITLAG)) { fixed_t mul = thing->hitlag * (FRACUNIT / 10); From a17f11e6c55110dbca634211109f25d5351ce156 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Sat, 27 Nov 2021 13:45:23 -0500 Subject: [PATCH 035/156] Ignore collisions between 2 objects that are BOTH in hitlag Still allows it if a new object interferes to add more hitlag, but this should hooopefully prevent super big knockback stacking from 1 object? --- src/p_map.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/p_map.c b/src/p_map.c index 099ace8e4..9c3a6ffbf 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -485,6 +485,10 @@ static boolean PIT_CheckThing(mobj_t *thing) || (thing->player && thing->player->spectator)) return true; + // Ignore the collision if BOTH things are in hitlag. + if (thing->hitlag > 0 && tmthing->hitlag > 0) + return true; + if ((thing->flags & MF_NOCLIPTHING) || !(thing->flags & (MF_SOLID|MF_SPECIAL|MF_PAIN|MF_SHOOTABLE|MF_SPRING))) return true; From c142648d0320a228277953ebe9044ce7744b6dce Mon Sep 17 00:00:00 2001 From: SteelT Date: Sat, 27 Nov 2021 20:36:40 -0500 Subject: [PATCH 036/156] Add cmake config option to compile a dev build --- src/CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 39b71cda7..1355c85ee 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -41,6 +41,8 @@ set(SRB2_CONFIG_YASM OFF CACHE BOOL "Use YASM in place of NASM.") set(SRB2_CONFIG_STATIC_OPENGL OFF CACHE BOOL "Use statically linked OpenGL. NOT RECOMMENDED.") +set(SRB2_CONFIG_DEV_BUILD OFF CACHE BOOL + "Compile a development build of SRB2Kart.") ### use internal libraries? if(${CMAKE_SYSTEM} MATCHES "Windows") ###set on Windows only @@ -280,6 +282,10 @@ if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} -Wno-absolute-value) endif() +if(${SRB2_CONFIG_DEV_BUILD}) + target_compile_definitions(SRB2SDL2 PRIVATE -DDEVELOP) +endif() + set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} -Wno-trigraphs) target_compile_definitions(SRB2SDL2 PRIVATE -DCMAKECONFIG) From 0b744767077d7d3537c7ff47f6ab5c0290c0d1b5 Mon Sep 17 00:00:00 2001 From: SteelT Date: Sat, 27 Nov 2021 21:02:04 -0500 Subject: [PATCH 037/156] Don't make asset hashing be required under dev builds --- CMakeLists.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b58101f7f..bc4f6ec6b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -118,8 +118,9 @@ set(SRB2_SDL2_EXE_NAME srb2kart CACHE STRING "Executable binary output name") include_directories(${CMAKE_CURRENT_BINARY_DIR}/src) add_subdirectory(src) -add_subdirectory(assets) - +if(NOT ${SRB2_CONFIG_DEV_BUILD}) + add_subdirectory(assets) +endif() ## config.h generation set(GIT_EXECUTABLE "git" CACHE FILEPATH "Path to git binary") From 0974d6d1f47c125f25ca51fee8b4ae55c5d3847f Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Sun, 28 Nov 2021 00:08:50 -0500 Subject: [PATCH 038/156] Reduced hitlag jitter Makes a little easier to parse. I might have gone overboard but I really wanted to test my hunch if Ivo's issue was mostly the fact it jitters so hard :V --- src/hardware/hw_main.c | 5 +++-- src/hardware/hw_md2.c | 3 ++- src/k_hud.c | 2 +- src/k_kart.h | 1 + src/r_things.c | 7 +++++-- 5 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 3e113bd76..ecb7f7436 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -39,6 +39,7 @@ #include "../f_finale.h" #include "../r_things.h" // R_GetShadowZ #include "../p_slopes.h" +#include "../k_kart.h" // HITLAGJITTERS #include "hw_md2.h" #ifdef NEWCLIP @@ -3645,7 +3646,7 @@ static void HWR_DrawDropShadow(mobj_t *thing, fixed_t scale) // hitlag vibrating if (thing->hitlag > 0 && (thing->eflags & MFE_DAMAGEHITLAG)) { - fixed_t mul = thing->hitlag * (FRACUNIT / 10); + fixed_t mul = thing->hitlag * HITLAGJITTERS; if (leveltime & 1) { @@ -5064,7 +5065,7 @@ static void HWR_ProjectSprite(mobj_t *thing) // hitlag vibrating if (thing->hitlag > 0 && (thing->eflags & MFE_DAMAGEHITLAG)) { - fixed_t mul = thing->hitlag * (FRACUNIT / 10); + fixed_t mul = thing->hitlag * HITLAGJITTERS; if (leveltime & 1) { diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index 4b8d1de6f..69f00d898 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -45,6 +45,7 @@ // SRB2Kart #include "../k_color.h" +#include "../k_kart.h" // HITLAGJITTERS #ifdef HAVE_PNG @@ -1374,7 +1375,7 @@ boolean HWR_DrawModel(gl_vissprite_t *spr) // hitlag vibrating if (spr->mobj->hitlag > 0 && (spr->mobj->eflags & MFE_DAMAGEHITLAG)) { - fixed_t mul = spr->mobj->hitlag * (FRACUNIT / 10); + fixed_t mul = spr->mobj->hitlag * HITLAGJITTERS; if (leveltime & 1) { diff --git a/src/k_hud.c b/src/k_hud.c index 25b437f5c..39ce118e8 100644 --- a/src/k_hud.c +++ b/src/k_hud.c @@ -3744,7 +3744,7 @@ static void K_drawKartFirstPerson(void) // hitlag vibrating if (stplyr->mo->hitlag > 0 && (stplyr->mo->eflags & MFE_DAMAGEHITLAG)) { - fixed_t mul = stplyr->mo->hitlag * (FRACUNIT / 10); + fixed_t mul = stplyr->mo->hitlag * HITLAGJITTERS; if (r_splitscreen && mul > FRACUNIT) mul = FRACUNIT; diff --git a/src/k_kart.h b/src/k_kart.h index 540e6845c..1efc5fb2f 100644 --- a/src/k_kart.h +++ b/src/k_kart.h @@ -20,6 +20,7 @@ Make sure this matches the actual number of states #define KART_NUMINVSPARKLESANIM 12 #define MAXHITLAGTICS 18 //12 +#define HITLAGJITTERS (FRACUNIT / 32) player_t *K_GetItemBoxPlayer(mobj_t *mobj); angle_t K_ReflectAngle(angle_t angle, angle_t against, fixed_t maxspeed, fixed_t yourspeed); diff --git a/src/r_things.c b/src/r_things.c index defd02a5f..197100470 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -35,7 +35,6 @@ #include "p_slopes.h" #include "d_netfil.h" // blargh. for nameonly(). #include "m_cheat.h" // objectplace -#include "k_color.h" // SRB2kart #include "p_local.h" // stplyr #ifdef HWRENDER #include "hardware/hw_md2.h" @@ -44,6 +43,10 @@ #include "hardware/hw_drv.h" #endif +// SRB2kart +#include "k_color.h" +#include "k_kart.h" // HITLAGJITTERS + #define MINZ (FRACUNIT*4) #define BASEYCENTER (BASEVIDHEIGHT/2) @@ -1438,7 +1441,7 @@ static void R_ProjectSprite(mobj_t *thing) // hitlag vibrating if (thing->hitlag > 0 && (thing->eflags & MFE_DAMAGEHITLAG)) { - fixed_t mul = thing->hitlag * (FRACUNIT / 10); + fixed_t mul = thing->hitlag * HITLAGJITTERS; if (leveltime & 1) { From 15556dce0bcaec8105b5891bb3a6a738cf7ba0bd Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Sun, 28 Nov 2021 00:25:40 -0500 Subject: [PATCH 039/156] Quakes are scaled with map scale Finally --- src/p_enemy.c | 4 ++-- src/p_spec.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/p_enemy.c b/src/p_enemy.c index 9f5fc86d8..2fdbc6f58 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -12205,9 +12205,9 @@ void A_Boss5BombExplode(mobj_t *actor) P_DustRing(locvar1, 4, actor->x, actor->y, actor->z+actor->height, 2*actor->radius, 0, FRACUNIT, actor->scale); P_DustRing(locvar1, 6, actor->x, actor->y, actor->z+actor->height/2, 3*actor->radius, FRACUNIT, FRACUNIT, actor->scale); - //P_StartQuake(9*actor->scale, TICRATE/6, {actor->x, actor->y, actor->z}, 20*actor->radius); + //P_StartQuake(9*FRACUNIT, TICRATE/6, {actor->x, actor->y, actor->z}, 20*actor->radius); // the above does not exist, so we set the quake values directly instead - quake.intensity = 9*actor->scale; + quake.intensity = 9*FRACUNIT; quake.time = TICRATE/6; // the following quake values have no effect atm? ah well, may as well set them anyway { diff --git a/src/p_spec.c b/src/p_spec.c index 16823916e..764f9c738 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -8746,6 +8746,6 @@ static void P_SpawnPushers(void) // epicenter and radius are not yet used. void P_StartQuake(fixed_t intensity, tic_t time) { - quake.intensity = intensity; + quake.intensity = FixedMul(intensity, mapobjectscale); quake.time = time; } From c1b34d4d4ff276826713d619b62630c32a1661db Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Sun, 28 Nov 2021 00:32:07 -0500 Subject: [PATCH 040/156] A few more instances --- src/p_enemy.c | 3 +++ src/p_spec.c | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/p_enemy.c b/src/p_enemy.c index 2fdbc6f58..7a67fc2af 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -11195,10 +11195,13 @@ void A_MineExplode(mobj_t *actor) A_Scream(actor); actor->flags = MF_NOGRAVITY|MF_NOCLIP; + /* quake.epicenter = NULL; quake.radius = 512*FRACUNIT; quake.intensity = 8*FRACUNIT; quake.time = TICRATE/3; + */ + P_StartQuake(8<tracer, 192*FRACUNIT, 0, true); P_MobjCheckWater(actor); diff --git a/src/p_spec.c b/src/p_spec.c index 764f9c738..d428444a3 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -2976,9 +2976,9 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec) // reasonable defaults. if (!quake.intensity) - quake.intensity = 8< Date: Sun, 28 Nov 2021 02:57:45 -0800 Subject: [PATCH 041/156] TRIPWIRE Set a sidedef's midtexture to "TRIPWIRE" to turn that line into a tripwire. Players can't drive through a tripwire and will bounce back at high speed if they're in one of the following states: 1. Invincibility / Grow 2. Sneakers 3. Flame Shield dash 4. >200% on the speedometer Hitting a tripwire plays a sound, sends you into hitlag, then plays another sound when the hitlag is over. The sounds used depend on whether you can drive through the tripwire. --- src/d_player.h | 9 +++++++++ src/g_game.c | 1 + src/k_kart.c | 34 ++++++++++++++++++++++++++++++++++ src/k_kart.h | 2 ++ src/p_local.h | 1 + src/p_map.c | 37 ++++++++++++++++++++++++++++++++----- src/p_maputl.c | 3 ++- src/p_saveg.c | 2 ++ src/p_spec.c | 7 +++++++ 9 files changed, 90 insertions(+), 6 deletions(-) diff --git a/src/d_player.h b/src/d_player.h index 3d9ac11dc..be16320cd 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -198,6 +198,13 @@ typedef enum #undef KSPIN_TYPE } kartspinoutflags_t; +typedef enum +{ + TRIP_NONE, + TRIP_PASSED, + TRIP_BLOCKED, +} tripwirestate_t; + typedef enum { // Unsynced, HUD or clientsided effects @@ -470,6 +477,8 @@ typedef struct player_s SINT8 glanceDir; // Direction the player is trying to look backwards in + UINT8 tripWireState; // see tripwirestate_t + // SINT8 lives; diff --git a/src/g_game.c b/src/g_game.c index c675e9a22..e964fb65d 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -2287,6 +2287,7 @@ void G_PlayerReborn(INT32 player, boolean betweenmaps) p->karthud[khud_fault] = khudfault; p->nocontrol = nocontrol; p->kickstartaccel = kickstartaccel; + p->tripWireState = TRIP_NONE; memcpy(&p->respawn, &respawn, sizeof (p->respawn)); diff --git a/src/k_kart.c b/src/k_kart.c index 4ab844c2d..7ee285fed 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -2673,6 +2673,19 @@ boolean K_SlopeResistance(player_t *player) return false; } +boolean K_TripwirePass(player_t *player) +{ + if ( + player->invincibilitytimer || + player->sneakertimer || + player->growshrinktimer > 0 || + player->flamedash || + player->speed > 2 * K_GetKartSpeed(player, false) + ) + return true; + return false; +} + static fixed_t K_FlameShieldDashVar(INT32 val) { // 1 second = 75% + 50% top speed @@ -3300,6 +3313,17 @@ static void K_HandleTumbleSound(player_t *player) } } +void K_ApplyTripWire(player_t *player, tripwirestate_t state) +{ + if (state == TRIP_PASSED) + S_StartSound(player->mo, sfx_ssa015); + else if (state == TRIP_BLOCKED) + S_StartSound(player->mo, sfx_kc40); + + player->tripWireState = state; + K_AddHitLag(player->mo, 10, false); +} + INT32 K_ExplodePlayer(player_t *player, mobj_t *inflictor, mobj_t *source) // A bit of a hack, we just throw the player up higher here and extend their spinout timer { INT32 ringburst = 10; @@ -6983,6 +7007,16 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd) // Handle invincibility sfx K_UpdateInvincibilitySounds(player); // Also thanks, VAda! + + if (player->tripWireState != TRIP_NONE) + { + if (player->tripWireState == TRIP_PASSED) + S_StartSound(player->mo, sfx_cdfm63); + else if (player->tripWireState == TRIP_BLOCKED) + S_StartSound(player->mo, sfx_kc4c); + + player->tripWireState = TRIP_NONE; + } } void K_KartPlayerAfterThink(player_t *player) diff --git a/src/k_kart.h b/src/k_kart.h index 540e6845c..b8e74539b 100644 --- a/src/k_kart.h +++ b/src/k_kart.h @@ -105,6 +105,8 @@ void K_StripOther(player_t *player); void K_MomentumToFacing(player_t *player); boolean K_ApplyOffroad(player_t *player); boolean K_SlopeResistance(player_t *player); +boolean K_TripwirePass(player_t *player); +void K_ApplyTripWire(player_t *player, tripwirestate_t state); INT16 K_GetSpindashChargeTime(player_t *player); fixed_t K_GetSpindashChargeSpeed(player_t *player); fixed_t K_GetKartSpeedFromStat(UINT8 kartspeed); diff --git a/src/p_local.h b/src/p_local.h index 9c282499f..f97f31810 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -398,6 +398,7 @@ void P_SetThingPosition(mobj_t *thing); void P_SetUnderlayPosition(mobj_t *thing); boolean P_IsLineBlocking(const line_t *ld, const mobj_t *thing); +boolean P_IsLineTripWire(const line_t *ld); boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y); boolean P_CheckCameraPosition(fixed_t x, fixed_t y, camera_t *thiscam); boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff); diff --git a/src/p_map.c b/src/p_map.c index acb47ab63..631f41ac9 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -1552,6 +1552,12 @@ boolean P_IsLineBlocking(const line_t *ld, const mobj_t *thing) } } +boolean P_IsLineTripWire(const line_t *ld) +{ + return (sides[ld->sidenum[0]].midtexture == + R_TextureNumForName("TRIPWIRE")); +} + // // PIT_CheckLine // Adjusts tmfloorz and tmceilingz as lines are contacted @@ -1666,7 +1672,8 @@ static boolean PIT_CheckLine(line_t *ld) tmdropoffz = lowfloor; // we've crossed the line - if (P_SpecialIsLinedefCrossType(ld->special)) + if (P_SpecialIsLinedefCrossType(ld->special) || + P_IsLineTripWire(ld)) { add_spechit(ld); } @@ -3022,6 +3029,7 @@ static void P_PlayerHitBounceLine(line_t *ld) INT32 side; angle_t lineangle; fixed_t movelen; + fixed_t x, y; side = P_PointOnLineSide(slidemo->x, slidemo->y, ld); lineangle = R_PointToAngle2(0, 0, ld->dx, ld->dy)-ANGLE_90; @@ -3036,8 +3044,19 @@ static void P_PlayerHitBounceLine(line_t *ld) if (slidemo->player && movelen < (15*mapobjectscale)) movelen = (15*mapobjectscale); - tmxmove += FixedMul(movelen, FINECOSINE(lineangle)); - tmymove += FixedMul(movelen, FINESINE(lineangle)); + x = FixedMul(movelen, FINECOSINE(lineangle)); + y = FixedMul(movelen, FINESINE(lineangle)); + + if (P_IsLineTripWire(ld)) + { + tmxmove = x * 4; + tmymove = y * 4; + } + else + { + tmxmove += x; + tmymove += y; + } } // @@ -3675,6 +3694,11 @@ void P_BouncePlayerMove(mobj_t *mo) tmymove = FixedMul(mmomy, (FRACUNIT - (FRACUNIT>>2) - (FRACUNIT>>3))); } + if (P_IsLineTripWire(bestslideline)) + { + K_ApplyTripWire(mo->player, TRIP_BLOCKED); + } + else { mobj_t *fx = P_SpawnMobj(mo->x, mo->y, mo->z, MT_BUMP); if (mo->eflags & MFE_VERTICALFLIP) @@ -3694,8 +3718,11 @@ void P_BouncePlayerMove(mobj_t *mo) mo->player->cmomx = tmxmove; mo->player->cmomy = tmymove; - if (!P_TryMove(mo, mo->x + tmxmove, mo->y + tmymove, true)) { - P_TryMove(mo, mo->x - oldmomx, mo->y - oldmomy, true); + if (!P_IsLineTripWire(bestslideline)) + { + if (!P_TryMove(mo, mo->x + tmxmove, mo->y + tmymove, true)) { + P_TryMove(mo, mo->x - oldmomx, mo->y - oldmomy, true); + } } } diff --git a/src/p_maputl.c b/src/p_maputl.c index 5cf2e81fe..2e21f5ee3 100644 --- a/src/p_maputl.c +++ b/src/p_maputl.c @@ -15,6 +15,7 @@ #include "doomdef.h" #include "doomstat.h" +#include "k_kart.h" #include "p_local.h" #include "r_main.h" #include "r_data.h" @@ -588,7 +589,7 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) if (mobj) { // Check for collision with front side's midtexture if Effect 4 is set - if (linedef->flags & ML_EFFECT4 + if ((linedef->flags & ML_EFFECT4 || (mobj->player && P_IsLineTripWire(linedef) && !K_TripwirePass(mobj->player))) && !linedef->polyobj // don't do anything for polyobjects! ...for now ) { side_t *side = &sides[linedef->sidenum[0]]; diff --git a/src/p_saveg.c b/src/p_saveg.c index c13220afb..ce1093061 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -318,6 +318,7 @@ static void P_NetArchivePlayers(void) WRITEINT16(save_p, players[i].spheres); WRITESINT8(save_p, players[i].glanceDir); + WRITEUINT8(save_p, players[i].tripWireState); WRITEUINT8(save_p, players[i].typing_timer); WRITEUINT8(save_p, players[i].typing_duration); @@ -573,6 +574,7 @@ static void P_NetUnArchivePlayers(void) players[i].spheres = READINT16(save_p); players[i].glanceDir = READSINT8(save_p); + players[i].tripWireState = READUINT8(save_p); players[i].typing_timer = READUINT8(save_p); players[i].typing_duration = READUINT8(save_p); diff --git a/src/p_spec.c b/src/p_spec.c index 16823916e..7099cf79f 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -2018,6 +2018,13 @@ void P_CrossSpecialLine(line_t *line, INT32 side, mobj_t *thing) return; { player_t *player = thing->player; + + if (P_IsLineTripWire(line)) + { + K_ApplyTripWire(player, TRIP_PASSED); + return; + } + switch (line->special) { case 2001: // Finish Line From 0e6bb7523086762162411acb6efe766970ebc279 Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 28 Nov 2021 04:08:38 -0800 Subject: [PATCH 042/156] Check TRIPWIRE texture at map load So it can be animated. --- src/p_map.c | 3 +-- src/p_setup.c | 8 ++++++++ src/r_defs.h | 2 ++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/p_map.c b/src/p_map.c index 631f41ac9..c1d3d27a6 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -1554,8 +1554,7 @@ boolean P_IsLineBlocking(const line_t *ld, const mobj_t *thing) boolean P_IsLineTripWire(const line_t *ld) { - return (sides[ld->sidenum[0]].midtexture == - R_TextureNumForName("TRIPWIRE")); + return ld->tripwire; } // diff --git a/src/p_setup.c b/src/p_setup.c index 654eb6eb1..4acc53e42 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -1044,6 +1044,8 @@ static void P_InitializeLinedef(line_t *ld) ld->validcount = 0; ld->polyobj = NULL; + ld->tripwire = false; + ld->text = NULL; ld->callcount = 0; @@ -1941,6 +1943,12 @@ static void P_ProcessLinedefsAfterSidedefs(void) ld->frontsector = sides[ld->sidenum[0]].sector; //e6y: Can't be -1 here ld->backsector = ld->sidenum[1] != 0xffff ? sides[ld->sidenum[1]].sector : 0; + if (sides[ld->sidenum[0]].midtexture == + R_TextureNumForName("TRIPWIRE")) + { + ld->tripwire = true; + } + switch (ld->special) { // Compile linedef 'text' from both sidedefs 'text' for appropriate specials. diff --git a/src/r_defs.h b/src/r_defs.h index 41b0cdaab..7decdfeab 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -420,6 +420,8 @@ typedef struct line_s size_t validcount; // if == validcount, already checked polyobj_t *polyobj; // Belongs to a polyobject? + boolean tripwire; + char *text; // a concatenation of all front and back texture names, for linedef specials that require a string. INT16 callcount; // no. of calls left before triggering, for the "X calls" linedef specials, defaults to 0 } line_t; From 2276304c1d74231abc920d920f7a6a27766af907 Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 28 Nov 2021 04:09:15 -0800 Subject: [PATCH 043/156] Don't skip other line specials if a trip wire is passed --- src/p_spec.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/p_spec.c b/src/p_spec.c index 7099cf79f..07825759c 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -2022,7 +2022,6 @@ void P_CrossSpecialLine(line_t *line, INT32 side, mobj_t *thing) if (P_IsLineTripWire(line)) { K_ApplyTripWire(player, TRIP_PASSED); - return; } switch (line->special) From 0c35e3f8b7c83506811daf1f62c1b225100d1ad6 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Sun, 28 Nov 2021 13:31:25 -0500 Subject: [PATCH 044/156] Bring back more jitter --- src/k_kart.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/k_kart.h b/src/k_kart.h index 1efc5fb2f..53e0e8bc1 100644 --- a/src/k_kart.h +++ b/src/k_kart.h @@ -20,7 +20,7 @@ Make sure this matches the actual number of states #define KART_NUMINVSPARKLESANIM 12 #define MAXHITLAGTICS 18 //12 -#define HITLAGJITTERS (FRACUNIT / 32) +#define HITLAGJITTERS (FRACUNIT / 20) player_t *K_GetItemBoxPlayer(mobj_t *mobj); angle_t K_ReflectAngle(angle_t angle, angle_t against, fixed_t maxspeed, fixed_t yourspeed); From dca887e23e519aec983cbd0bcb63164f084893b9 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Sun, 28 Nov 2021 14:36:58 -0500 Subject: [PATCH 045/156] Do not adjust friction on bots for tire grease --- src/k_bot.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/k_bot.c b/src/k_bot.c index 29aa4f177..96c488e0f 100644 --- a/src/k_bot.c +++ b/src/k_bot.c @@ -482,7 +482,7 @@ fixed_t K_BotFrictionRubberband(player_t *player, fixed_t frict) fixed_t rubberband = K_BotRubberband(player) - FRACUNIT; fixed_t origFrict, newFrict; - if (rubberband <= 0) + if (rubberband <= 0 || player->tiregrease > 0) { // Never get weaker than normal friction return frict; From c7caf7ab441424cd216015434295dac764005c7b Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Sun, 28 Nov 2021 14:37:21 -0500 Subject: [PATCH 046/156] Pull the prediction a lot more forward by default --- src/k_bot.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/k_bot.c b/src/k_bot.c index 96c488e0f..375b1794d 100644 --- a/src/k_bot.c +++ b/src/k_bot.c @@ -571,7 +571,7 @@ static botprediction_t *K_CreateBotPrediction(player_t *player) const fixed_t radreduce = min(distreduce + FRACUNIT/4, FRACUNIT); const tic_t futuresight = (TICRATE * normal) / max(1, handling); // How far ahead into the future to try and predict - const fixed_t speed = max(P_AproxDistance(player->mo->momx, player->mo->momy), K_GetKartSpeed(player, false) / 4); + const fixed_t speed = max(P_AproxDistance(player->rmomx, player->rmomy), K_GetKartSpeed(player, false)); const INT32 startDist = (768 * mapobjectscale) / FRACUNIT; const INT32 distance = ((FixedMul(speed, distreduce) / FRACUNIT) * futuresight) + startDist; From 40958073e39f17a8063b455b1022e2a6e1fa1e6d Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Sun, 28 Nov 2021 14:42:44 -0500 Subject: [PATCH 047/156] Increase bot max top speed now that everything around it is fixed lol --- src/k_bot.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/k_bot.c b/src/k_bot.c index 375b1794d..44269cf58 100644 --- a/src/k_bot.c +++ b/src/k_bot.c @@ -430,8 +430,8 @@ fixed_t K_BotTopSpeedRubberband(player_t *player) } else { - // Max at +10% for level 9 bots - rubberband = FRACUNIT + ((rubberband - FRACUNIT) / 10); + // Max at +20% for level 9 bots + rubberband = FRACUNIT + ((rubberband - FRACUNIT) / 5); } // Only allow you to go faster than your regular top speed if you're facing the right direction From 6be351a3043c72f38e6dfab5e6b6de5b1ad9fb72 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Sun, 28 Nov 2021 14:55:03 -0500 Subject: [PATCH 048/156] Improved item throwing - Bots attempt to do fast item snipes (they will throw more often when above top speed) - They will not waste double jawz anymore (they check for a jawz already targetting who they want to shoot before they decide to shoot it) --- src/k_botitem.c | 36 ++++++++++++++++++++++++++++++++---- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/src/k_botitem.c b/src/k_botitem.c index 212a84929..a7acea642 100644 --- a/src/k_botitem.c +++ b/src/k_botitem.c @@ -690,17 +690,19 @@ static void K_BotItemOrbinaut(player_t *player, ticcmd_t *cmd) const fixed_t topspeed = K_GetKartSpeed(player, false); fixed_t radius = (player->mo->radius * 32); SINT8 throwdir = -1; + UINT8 snipeMul = 2; if (player->speed > topspeed) { radius = FixedMul(radius, FixedDiv(player->speed, topspeed)); + snipeMul = 3; // Confirm faster when you'll throw it with a bunch of extra speed!! } player->botvars.itemconfirm++; if (K_PlayerInCone(player, radius, 10, false)) { - player->botvars.itemconfirm += player->botvars.difficulty * 2; + player->botvars.itemconfirm += player->botvars.difficulty * snipeMul; throwdir = 1; } else if (K_PlayerInCone(player, radius, 10, true)) @@ -732,10 +734,13 @@ static void K_BotItemJawz(player_t *player, ticcmd_t *cmd) const fixed_t topspeed = K_GetKartSpeed(player, false); fixed_t radius = (player->mo->radius * 32); SINT8 throwdir = 1; + UINT8 snipeMul = 2; + INT32 lastTarg = player->lastjawztarget; if (player->speed > topspeed) { radius = FixedMul(radius, FixedDiv(player->speed, topspeed)); + snipeMul = 3; // Confirm faster when you'll throw it with a bunch of extra speed!! } player->botvars.itemconfirm++; @@ -746,10 +751,33 @@ static void K_BotItemJawz(player_t *player, ticcmd_t *cmd) throwdir = -1; } - if (player->lastjawztarget != -1) + if (lastTarg != -1 + && playeringame[lastTarg] == true + && players[lastTarg].spectator == false + && players[lastTarg].mo != NULL + && P_MobjWasRemoved(players[lastTarg].mo) == false) { - player->botvars.itemconfirm += player->botvars.difficulty * 2; - throwdir = 1; + mobj_t *targ = players[lastTarg].mo; + mobj_t *mobj = NULL, *next = NULL; + boolean targettedAlready = false; + + // Make sure no other Jawz are targetting this player. + for (mobj = kitemcap; mobj; mobj = next) + { + next = mobj->itnext; + + if (mobj->type == MT_JAWZ && mobj->target == targ) + { + targettedAlready = true; + break; + } + } + + if (targettedAlready == false) + { + player->botvars.itemconfirm += player->botvars.difficulty * snipeMul; + throwdir = 1; + } } if (player->botvars.itemconfirm > 5*TICRATE) From 3141ca022117cb3bb5d62b2d3d31c260c54e6e26 Mon Sep 17 00:00:00 2001 From: toaster Date: Sun, 28 Nov 2021 20:03:49 +0000 Subject: [PATCH 049/156] Replay fixes mark whatever Not a pancaea for EVERYTHING, just a bunch of good stuff. * Some issues with spectators not == true because the assignment wasn't casted. * Netgame status (or rather its inverse) is recorded in netreplays now, to allow for power levels controlling spawn position. * Fixed tally screen for replays to not scream infinitely at you. * P_IsLocalPlayer now uses display players in replays. * A bunch of good testing prints that helped me find these problems, commented out for now just in case we need them again soonish. --- src/g_demo.c | 35 +++++++++++++++++++++++++++-------- src/g_demo.h | 1 + src/g_game.c | 6 +++--- src/k_kart.c | 5 ++++- src/k_pwrlv.c | 4 ++-- src/p_user.c | 4 ++++ src/y_inter.c | 12 +++++------- 7 files changed, 46 insertions(+), 21 deletions(-) diff --git a/src/g_demo.c b/src/g_demo.c index 16ca2a859..eda590420 100644 --- a/src/g_demo.c +++ b/src/g_demo.c @@ -112,6 +112,10 @@ demoghost *ghosts = NULL; #define DF_BREAKTHECAPSULES 0x04 // This demo is from Break the Capsules and contains its final completion time! #define DF_ATTACKMASK 0x06 // This demo is from ??? attack and contains ??? +// 0x08 free + +#define DF_NONETMP 0x10 // multiplayer but not netgame + #define DF_LUAVARS 0x20 // this demo contains extra lua vars #define DF_ATTACKSHIFT 1 @@ -309,6 +313,7 @@ void G_ReadDemoExtraData(void) switch (extradata) { case DXD_PST_PLAYING: players[p].pflags |= PF_WANTSTOJOIN; // fuck you + //CONS_Printf("player %s is despectating on tic %d\n", player_names[p], leveltime); break; case DXD_PST_SPECTATING: @@ -319,9 +324,11 @@ void G_ReadDemoExtraData(void) playeringame[p] = true; G_AddPlayer(p); players[p].spectator = true; + //CONS_Printf("player %s is joining server on tic %d\n", player_names[p], leveltime); } else { + //CONS_Printf("player %s is spectating on tic %d\n", player_names[p], leveltime); players[p].spectator = true; if (players[p].mo) P_DamageMobj(players[p].mo, NULL, NULL, 1, DMG_INSTAKILL); @@ -366,7 +373,7 @@ void G_ReadDemoExtraData(void) P_SetRandSeed(rng); if (demosynced) - CONS_Alert(CONS_WARNING, M_GetText("Demo playback has desynced!\n")); + CONS_Alert(CONS_WARNING, M_GetText("Demo playback has desynced (RNG)!\n")); demosynced = false; } } @@ -863,7 +870,12 @@ void G_WriteGhostTic(mobj_t *ghost, INT32 playernum) void G_ConsAllGhostTics(void) { - UINT8 p = READUINT8(demo_p); + UINT8 p; + + if (!demo_p || !demo.deferstart) + return; + + p = READUINT8(demo_p); while (p != 0xFF) { @@ -888,8 +900,6 @@ void G_ConsGhostTic(INT32 playernum) mobj_t *testmo; UINT32 syncleeway; - if (!demo_p || !demo.deferstart) - return; if (!(demoflags & DF_GHOST)) return; // No ghost data to use. @@ -966,7 +976,7 @@ void G_ConsGhostTic(INT32 playernum) if (th != &thlist[THINK_MOBJ] && mobj->health != health) // Wasn't damaged?! This is desync! Fix it! { if (demosynced) - CONS_Alert(CONS_WARNING, M_GetText("Demo playback has desynced!\n")); + CONS_Alert(CONS_WARNING, M_GetText("Demo playback has desynced (health)!\n")); demosynced = false; P_DamageMobj(mobj, players[0].mo, players[0].mo, 1, DMG_NORMAL); } @@ -1019,7 +1029,7 @@ void G_ConsGhostTic(INT32 playernum) if (ghostext[playernum].desyncframes >= 2) { if (demosynced) - CONS_Alert(CONS_WARNING, M_GetText("Demo playback has desynced!\n")); + CONS_Alert(CONS_WARNING, "Demo playback has desynced (player %s)!\n", player_names[playernum]); demosynced = false; P_UnsetThingPosition(testmo); @@ -1042,7 +1052,7 @@ void G_ConsGhostTic(INT32 playernum) || players[playernum].bumpers != ghostext[playernum].kartbumpers) { if (demosynced) - CONS_Alert(CONS_WARNING, M_GetText("Demo playback has desynced!\n")); + CONS_Alert(CONS_WARNING, M_GetText("Demo playback has desynced (item/bumpers)!\n")); demosynced = false; players[playernum].itemtype = ghostext[playernum].kartitem; @@ -1921,6 +1931,9 @@ void G_BeginRecording(void) demo_p = demobuffer; demoflags = DF_GHOST|(multiplayer ? DF_MULTIPLAYER : (modeattacking<>DF_ATTACKSHIFT; multiplayer = !!(demoflags & DF_MULTIPLAYER); + demo.netgame = (multiplayer && !(demoflags & DF_NONETMP)); CON_ToggleOff(); hu_demotime = UINT32_MAX; @@ -2927,7 +2941,7 @@ void G_DoPlayDemo(char *defdemoname) while (p != 0xFF) { - if ((spectator = (p & DEMO_SPECTATOR))) + if ((spectator = !!(p & DEMO_SPECTATOR))) { p &= ~DEMO_SPECTATOR; @@ -2975,6 +2989,11 @@ void G_DoPlayDemo(char *defdemoname) M_Memcpy(player_names[p],demo_p,16); demo_p += 16; + /*if (players[p].spectator) + { + CONS_Printf("player %s is spectator at start\n", player_names[p]); + }*/ + // Skin M_Memcpy(skin,demo_p,16); demo_p += 16; diff --git a/src/g_demo.h b/src/g_demo.h index 03d75cf4b..53f49be4d 100644 --- a/src/g_demo.h +++ b/src/g_demo.h @@ -41,6 +41,7 @@ struct demovars_s { boolean inreplayhut; // Go back to replayhut after demos boolean quitafterplaying; // quit after playing a demo from cmdline boolean deferstart; // don't start playing demo right away + boolean netgame; // multiplayer netgame tic_t savebutton; // Used to determine when the local player can choose to save the replay while the race is still going enum { diff --git a/src/g_game.c b/src/g_game.c index c675e9a22..6c3d8650b 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -2551,7 +2551,7 @@ mapthing_t *G_FindRaceStart(INT32 playernum) if (j == i) continue; - if (netgame && cv_kartusepwrlv.value) + if ((netgame || (demo.playback && demo.netgame)) && cv_kartusepwrlv.value) { if (clientpowerlevels[j][PWRLV_RACE] == clientpowerlevels[i][PWRLV_RACE]) num++; @@ -2572,7 +2572,7 @@ mapthing_t *G_FindRaceStart(INT32 playernum) pos++; else { - if (netgame && cv_kartusepwrlv.value) + if ((netgame || (demo.playback && demo.netgame)) && cv_kartusepwrlv.value) { if (clientpowerlevels[i][PWRLV_RACE] > clientpowerlevels[playernum][PWRLV_RACE]) pos++; @@ -3112,7 +3112,7 @@ boolean G_GametypeHasTeams(void) // boolean G_GametypeHasSpectators(void) { - return (netgame || (multiplayer && demo.playback)); + return (netgame || (multiplayer && demo.netgame)); } // diff --git a/src/k_kart.c b/src/k_kart.c index 4ab844c2d..09c666dc5 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -52,7 +52,7 @@ void K_TimerReset(void) void K_TimerInit(void) { UINT8 i; - UINT8 numPlayers = 0; + UINT8 numPlayers = 0;//, numspec = 0; for (i = 0; i < MAXPLAYERS; i++) { @@ -63,6 +63,7 @@ void K_TimerInit(void) if (players[i].spectator == true) { + //numspec++; continue; } @@ -98,6 +99,7 @@ void K_TimerInit(void) // NOW you can try to spawn in the Battle capsules, if there's not enough players for a match K_SpawnBattleCapsules(); + //CONS_Printf("numbulbs set to %d (%d players, %d spectators) on tic %d\n", numbulbs, numPlayers, numspec, leveltime); } UINT32 K_GetPlayerDontDrawFlag(player_t *player) @@ -9387,6 +9389,7 @@ void K_CheckSpectateStatus(void) { if (cv_ingamecap.value && numingame+i >= cv_ingamecap.value) // Hit the in-game player cap while adding people? break; + //CONS_Printf("player %s is joining on tic %d\n", player_names[respawnlist[i]], leveltime); P_SpectatorJoinGame(&players[respawnlist[i]]); } diff --git a/src/k_pwrlv.c b/src/k_pwrlv.c index ac2d009bc..860727184 100644 --- a/src/k_pwrlv.c +++ b/src/k_pwrlv.c @@ -30,7 +30,7 @@ SINT8 K_UsingPowerLevels(void) { SINT8 pt = PWRLV_DISABLED; - if (!cv_kartusepwrlv.value || !netgame || grandprixinfo.gp == true) + if (!cv_kartusepwrlv.value || !(netgame || (demo.playback && demo.netgame)) || grandprixinfo.gp == true) { return PWRLV_DISABLED; } @@ -346,7 +346,7 @@ void K_PlayerForfeit(UINT8 playernum, boolean pointloss) clientpowerlevels[playernum][powertype] += inc; - if (playernum == consoleplayer) + if (!demo.playback && playernum == consoleplayer) { vspowerlevel[powertype] = clientpowerlevels[playernum][powertype]; if (M_UpdateUnlockablesAndExtraEmblems()) diff --git a/src/p_user.c b/src/p_user.c index c58e61b4d..b67b23781 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1058,6 +1058,9 @@ boolean P_IsLocalPlayer(player_t *player) { UINT8 i; + if (demo.playback) + return P_IsDisplayPlayer(player); + for (i = 0; i <= r_splitscreen; i++) // DON'T skip P1 { if (player == &players[g_localplayers[i]]) @@ -4352,6 +4355,7 @@ void P_PlayerThink(player_t *player) player->flashing = TICRATE/2 + 1; /*if (P_SpectatorJoinGame(player)) return; // player->mo was removed.*/ + //CONS_Printf("player %s wants to join on tic %d\n", player_names[player-players], leveltime); } if (player->respawn.state != RESPAWNST_NONE) diff --git a/src/y_inter.c b/src/y_inter.c index 68a6019ad..e050deddc 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -481,7 +481,7 @@ void Y_IntermissionDrawer(void) else hilicol = ((intertype == int_race) ? V_SKYMAP : V_REDMAP); - if (sorttic != -1 && intertic > sorttic && !demo.playback) + if (sorttic != -1 && intertic > sorttic && multiplayer) { INT32 count = (intertic - sorttic); @@ -586,7 +586,7 @@ void Y_IntermissionDrawer(void) y2 = y; - if (netgame && playerconsole[data.num[i]] == 0 && server_lagless && !players[data.num[i]].bot) + if ((netgame || (demo.playback && demo.netgame)) && playerconsole[data.num[i]] == 0 && server_lagless && !players[data.num[i]].bot) { static int alagles_timer = 0; patch_t *alagles; @@ -799,7 +799,7 @@ void Y_Ticker(void) if (intertype == int_race || intertype == int_battle) { - if (!(multiplayer && demo.playback)) // Don't advance to rankings in replays + //if (!(multiplayer && demo.playback)) // Don't advance to rankings in replays { if (!data.rankingsmode && (intertic >= sorttic + 8)) { @@ -868,8 +868,6 @@ void Y_Ticker(void) endtic = intertic + 3*TICRATE; // 3 second pause after end of tally } } - else if (!(intertic & 1)) - S_StartSound(NULL, sfx_ptally); // tally sound effect } } @@ -1013,7 +1011,7 @@ static void K_UpdatePowerLevels(void) data.increase[i] = increment[i]; clientpowerlevels[i][powertype] += data.increase[i]; - if (i == consoleplayer) + if (!demo.playback && i == consoleplayer) { CONS_Debug(DBG_GAMELOGIC, "Player %d is you! Saving...\n", i); vspowerlevel[powertype] = clientpowerlevels[i][powertype]; @@ -1069,7 +1067,7 @@ void Y_StartIntermission(void) { if (cv_inttime.value == 0) timer = 0; - else if (demo.playback) // Override inttime (which is pulled from the replay anyway + else if (demo.playback && !multiplayer) // Override inttime (which is pulled from the replay anyway timer = 10*TICRATE; else { From 3536c73b6634d7a66f459c17f32728c9055a9c39 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Sun, 28 Nov 2021 15:08:54 -0500 Subject: [PATCH 050/156] Fix eggbox stealth being bugged and never being used... --- src/k_botsearch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/k_botsearch.c b/src/k_botsearch.c index 55533d02a..80650030d 100644 --- a/src/k_botsearch.c +++ b/src/k_botsearch.c @@ -122,7 +122,7 @@ UINT8 K_EggboxStealth(fixed_t x, fixed_t y) } } - return (globalsmuggle.randomitems * globalsmuggle.eggboxes); + return (globalsmuggle.randomitems * (globalsmuggle.eggboxes + 1)); } /*-------------------------------------------------- From e4b27933f2e75e8879c2de267584c73deb5632aa Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Sun, 28 Nov 2021 15:13:54 -0500 Subject: [PATCH 051/156] Comment the tire grease change --- src/k_bot.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/k_bot.c b/src/k_bot.c index 44269cf58..435eb1c6b 100644 --- a/src/k_bot.c +++ b/src/k_bot.c @@ -482,12 +482,20 @@ fixed_t K_BotFrictionRubberband(player_t *player, fixed_t frict) fixed_t rubberband = K_BotRubberband(player) - FRACUNIT; fixed_t origFrict, newFrict; - if (rubberband <= 0 || player->tiregrease > 0) + if (rubberband <= 0) { // Never get weaker than normal friction return frict; } + if (player->tiregrease > 0) + { + // This isn't great -- it means rubberbanding will slow down when they hit a spring + // But it's better than the opposite where they accelerate into hyperspace :V + // (would appreciate an actual fix though ... could try being additive instead of multiplicative) + return frict; + } + origFrict = FixedDiv(ORIG_FRICTION, FRACUNIT + (rubberband / 2)); if (frict == ORIG_FRICTION) From ba3e89665534d5ab6a38e9a86e1874631e4a1fe8 Mon Sep 17 00:00:00 2001 From: toaster Date: Sun, 28 Nov 2021 20:15:42 +0000 Subject: [PATCH 052/156] Make the game loading-bar miniwindow do OS polling, to allow you to tab back into it without it being considered frozen by the OS. --- src/console.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/console.c b/src/console.c index 5eda4f7fa..4d71e74d3 100644 --- a/src/console.c +++ b/src/console.c @@ -1916,6 +1916,8 @@ void CON_SetLoadingProgress(con_loadprogress_t newStep) if (con_startup_loadprogress < LOADED_ISTARTUPGRAPHICS) // rendering not possible? return; CON_DrawLoadBar(); // here we display the console text + I_OsPolling(); + I_UpdateNoBlit(); I_FinishUpdate(); // page flip or blit buffer } From 15741da0a486b4724cca4eb19acf15c3d26275d6 Mon Sep 17 00:00:00 2001 From: toaster Date: Sun, 28 Nov 2021 20:18:41 +0000 Subject: [PATCH 053/156] Improve some of the efficiency loss in F_DoWipe compared to K.S.'s 2.1 code by seperating out some of the loops. --- src/f_wipe.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/f_wipe.c b/src/f_wipe.c index ddc719e6d..db343d050 100644 --- a/src/f_wipe.c +++ b/src/f_wipe.c @@ -299,16 +299,23 @@ static void F_DoWipe(fademask_t *fademask, lighttable_t *fadecolormap, boolean r e = e_base + relativepos; draw_rowstogo = draw_rowend - draw_rowstart; - while (draw_rowstogo--) + if (fadecolormap) { - if (fadecolormap != NULL) + if (reverse) + s = e; + while (draw_rowstogo--) + *w++ = fadecolormap[ ( m << 8 ) + *s++ ]; + } + else while (draw_rowstogo--) + { + /*if (fadecolormap != NULL) { if (reverse) *w++ = fadecolormap[ ( m << 8 ) + *e++ ]; else *w++ = fadecolormap[ ( m << 8 ) + *s++ ]; } - else + else*/ *w++ = transtbl[ ( *e++ << 8 ) + *s++ ]; } From fbaa57a39c50f3991730523f47951ad426cb0888 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Sun, 28 Nov 2021 15:20:57 -0500 Subject: [PATCH 054/156] Give Landmines its own bot usage function Prevents them from attempting to use landmines tossed forward. (Not really notable at all, since there's no one in front of you when you get landmine, at most means they may hold onto it longer, but it was just a weird thing I always meant to fix) --- src/k_botitem.c | 37 ++++++++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/src/k_botitem.c b/src/k_botitem.c index a7acea642..67d858ea4 100644 --- a/src/k_botitem.c +++ b/src/k_botitem.c @@ -546,6 +546,39 @@ static void K_BotItemMine(player_t *player, ticcmd_t *cmd, INT16 turnamt) } } +/*-------------------------------------------------- + static void K_BotItemLandmine(player_t *player, ticcmd_t *cmd, INT16 turnamt) + + Item usage for landmine tossing. + + Input Arguments:- + player - Bot to do this for. + cmd - Bot's ticcmd to edit. + turnamt - How hard they currently are turning. + + Return:- + None +--------------------------------------------------*/ +static void K_BotItemLandmine(player_t *player, ticcmd_t *cmd, INT16 turnamt) +{ + player->botvars.itemconfirm++; + + if (abs(turnamt) >= KART_FULLTURN/2) + { + player->botvars.itemconfirm += player->botvars.difficulty / 2; + } + + if (K_PlayerInCone(player, player->mo->radius * 16, 10, true)) + { + player->botvars.itemconfirm += player->botvars.difficulty; + } + + if (player->botvars.itemconfirm > 2*TICRATE) + { + K_BotGenericPressItem(player, cmd, -1); + } +} + /*-------------------------------------------------- static void K_BotItemEggman(player_t *player, ticcmd_t *cmd) @@ -1064,7 +1097,6 @@ void K_BotItemUsage(player_t *player, ticcmd_t *cmd, INT16 turnamt) K_BotItemSneaker(player, cmd); break; case KITEM_BANANA: - case KITEM_LANDMINE: if (!(player->pflags & PF_ITEMOUT)) { K_BotItemGenericTrapShield(player, cmd, turnamt, false); @@ -1109,6 +1141,9 @@ void K_BotItemUsage(player_t *player, ticcmd_t *cmd, INT16 turnamt) K_BotItemMine(player, cmd, turnamt); } break; + case KITEM_LANDMINE: + K_BotItemLandmine(player, cmd, turnamt); + break; case KITEM_THUNDERSHIELD: K_BotItemThunder(player, cmd); break; From 88528744650482f469488b3bf80716a95e6a222b Mon Sep 17 00:00:00 2001 From: toaster Date: Sun, 28 Nov 2021 20:27:32 +0000 Subject: [PATCH 055/156] KHUD NOT NETSYNCED, hyuu cannot safely use it as a reference point --- src/d_player.h | 2 +- src/k_kart.c | 16 +++++++--------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/src/d_player.h b/src/d_player.h index 3d9ac11dc..94310f06e 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -202,7 +202,7 @@ typedef enum { // Unsynced, HUD or clientsided effects // Item box - khud_itemblink, // Item flashing after roulette, prevents Hyudoro stealing AND serves as a mashing indicator + khud_itemblink, // Item flashing after roulette, serves as a mashing indicator khud_itemblinkmode, // Type of flashing: 0 = white (normal), 1 = red (mashing), 2 = rainbow (enhanced items) // Rings diff --git a/src/k_kart.c b/src/k_kart.c index 4ab844c2d..e702be207 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -4885,8 +4885,7 @@ static void K_DoHyudoroSteal(player_t *player) // Has an item && (players[i].itemtype && players[i].itemamount - && !(players[i].pflags & PF_ITEMOUT) - && !players[i].karthud[khud_itemblink])) + && !(players[i].pflags & PF_ITEMOUT)) { playerswappable[numplayers] = i; numplayers++; @@ -6355,6 +6354,12 @@ void K_KartPlayerHUDUpdate(player_t *player) else if (player->karthud[khud_fault] > 0 && player->karthud[khud_fault] < 2*TICRATE) player->karthud[khud_fault]++; + if (player->karthud[khud_itemblink] && player->karthud[khud_itemblink]-- <= 0) + { + player->karthud[khud_itemblinkmode] = 0; + player->karthud[khud_itemblink] = 0; + } + if (gametype == GT_RACE) { // 0 is the fast spin animation, set at 30 tics of ring boost or higher! @@ -6873,13 +6878,6 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd) K_HandleTumbleBounce(player); } - // This doesn't go in HUD update because it has potential gameplay ramifications - if (player->karthud[khud_itemblink] && player->karthud[khud_itemblink]-- <= 0) - { - player->karthud[khud_itemblinkmode] = 0; - player->karthud[khud_itemblink] = 0; - } - K_KartPlayerHUDUpdate(player); if (battleovertime.enabled && !(player->pflags & PF_ELIMINATED) && player->bumpers <= 0 && player->karmadelay <= 0) From 54aaf6d98e514a05d512f149748d4d048d5c65a5 Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 28 Nov 2021 16:23:37 -0800 Subject: [PATCH 056/156] Apply tripwire effect to TRIPWIRE and 4RIPWIRE --- src/p_setup.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/p_setup.c b/src/p_setup.c index 4acc53e42..fab5429b8 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -1938,13 +1938,19 @@ static void P_ProcessLinedefsAfterSidedefs(void) { size_t i = numlines; register line_t *ld = lines; + + const INT32 TEX_TRIPWIRE = R_TextureNumForName("TRIPWIRE"); + const INT32 TEX_4RIPWIRE = R_TextureNumForName("4RIPWIRE"); + for (; i--; ld++) { + INT32 midtexture = sides[ld->sidenum[0]].midtexture; + ld->frontsector = sides[ld->sidenum[0]].sector; //e6y: Can't be -1 here ld->backsector = ld->sidenum[1] != 0xffff ? sides[ld->sidenum[1]].sector : 0; - if (sides[ld->sidenum[0]].midtexture == - R_TextureNumForName("TRIPWIRE")) + if (midtexture == TEX_TRIPWIRE || + midtexture == TEX_4RIPWIRE) { ld->tripwire = true; } From 2cab15c7a397e6c0581659a37b8d5a7c3c8e91fe Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 28 Nov 2021 16:34:46 -0800 Subject: [PATCH 057/156] Automatically apply additive to tripwires --- src/hardware/hw_main.c | 3 ++- src/r_segs.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 3e113bd76..205fc3ff6 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -1478,7 +1478,8 @@ static void HWR_ProcessSeg(void) // Sort of like GLWall::Process in GZDoom transnum_t transtable = R_GetLinedefTransTable(gl_linedef); if (transtable == NUMTRANSMAPS) transtable = 0; - if (gl_linedef->special == 910) + if (gl_linedef->special == 910 || + P_IsLineTripWire(gl_linedef)) blend = AST_ADD; else if (gl_linedef->special == 911) blend = AST_SUBTRACT; diff --git a/src/r_segs.c b/src/r_segs.c index 8d056a295..5c9538e34 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -162,7 +162,7 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2) return; transtable = R_GetLinedefTransTable(ldef); - if (ldef->special == 910) + if (ldef->special == 910 || P_IsLineTripWire(ldef)) { if (transtable == NUMTRANSMAPS) transtable = 0; From 9750e2cd07ae5786168c055b33730f8d6429ee99 Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 28 Nov 2021 17:27:06 -0800 Subject: [PATCH 058/156] Tumble when passing tripwire while spinning out and with >200% speed --- src/k_kart.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 7ee285fed..e8b424179 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -3210,10 +3210,18 @@ void K_TumblePlayer(player_t *player, mobj_t *inflictor, mobj_t *source) player->tumbleBounces = 1; - player->mo->momx = 2 * player->mo->momx / 3; - player->mo->momy = 2 * player->mo->momy / 3; + if (player->tripWireState == TRIP_PASSED) + { + player->tumbleHeight = 50; + } + else + { + player->mo->momx = 2 * player->mo->momx / 3; + player->mo->momy = 2 * player->mo->momy / 3; + + player->tumbleHeight = 30; + } - player->tumbleHeight = 30; player->pflags &= ~PF_TUMBLESOUND; if (inflictor && !P_MobjWasRemoved(inflictor)) @@ -3322,6 +3330,12 @@ void K_ApplyTripWire(player_t *player, tripwirestate_t state) player->tripWireState = state; K_AddHitLag(player->mo, 10, false); + + if (state == TRIP_PASSED && player->spinouttimer && + player->speed > 2* K_GetKartSpeed(player, false)) + { + K_TumblePlayer(player, NULL, NULL); + } } INT32 K_ExplodePlayer(player_t *player, mobj_t *inflictor, mobj_t *source) // A bit of a hack, we just throw the player up higher here and extend their spinout timer From 332d3bfa121cb7e61ba25b8b4212da1ce9f3d8f9 Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 28 Nov 2021 18:48:27 -0800 Subject: [PATCH 059/156] Fix passing tripwire not triggering SOMETIMES --- src/p_map.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/src/p_map.c b/src/p_map.c index c1d3d27a6..42fa89b73 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -206,11 +206,14 @@ static void add_spechit(line_t *ld) numspechit++; } -static boolean P_SpecialIsLinedefCrossType(UINT16 ldspecial) +static boolean P_SpecialIsLinedefCrossType(line_t *ld) { boolean linedefcrossspecial = false; - switch (ldspecial) + if (P_IsLineTripWire(ld)) + return true; + + switch (ld->special) { case 2001: // Finish line case 2003: // Respawn line @@ -1671,8 +1674,7 @@ static boolean PIT_CheckLine(line_t *ld) tmdropoffz = lowfloor; // we've crossed the line - if (P_SpecialIsLinedefCrossType(ld->special) || - P_IsLineTripWire(ld)) + if (P_SpecialIsLinedefCrossType(ld)) { add_spechit(ld); } @@ -2666,10 +2668,7 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) oldside = P_PointOnLineSide(oldx, oldy, ld); if (side != oldside) { - if (ld->special) - { - P_CrossSpecialLine(ld, oldside, thing); - } + P_CrossSpecialLine(ld, oldside, thing); } } } @@ -2751,7 +2750,7 @@ static boolean PTR_GetSpecialLines(intercept_t *in) return true; } - if (P_SpecialIsLinedefCrossType(ld->special)) + if (P_SpecialIsLinedefCrossType(ld)) { add_spechit(ld); } @@ -2821,10 +2820,7 @@ void P_HitSpecialLines(mobj_t *thing, fixed_t x, fixed_t y, fixed_t momx, fixed_ oldside = P_PointOnLineSide(x, y, ld); if (side != oldside) { - if (ld->special) - { - P_CrossSpecialLine(ld, oldside, thing); - } + P_CrossSpecialLine(ld, oldside, thing); } } } From 72ded01ac835107d8d9094e14b1c11cef3222bc3 Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 28 Nov 2021 20:23:03 -0800 Subject: [PATCH 060/156] Smoother ceiling clipping - Apply some gravity immediately. - Play the bump (like against walls) effect. --- src/k_kart.c | 12 ++++++++++++ src/k_kart.h | 1 + src/p_map.c | 9 +-------- src/p_mobj.c | 9 +++++++++ 4 files changed, 23 insertions(+), 8 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index e8b424179..1865487f3 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -2077,6 +2077,18 @@ void K_SpawnInvincibilitySpeedLines(mobj_t *mo) fast->destscale = 6*((mo->player->invincibilitytimer/TICRATE)*FRACUNIT)/8; } +void K_SpawnBumpEffect(mobj_t *mo) +{ + mobj_t *fx = P_SpawnMobj(mo->x, mo->y, mo->z, MT_BUMP); + if (mo->eflags & MFE_VERTICALFLIP) + fx->eflags |= MFE_VERTICALFLIP; + else + fx->eflags &= ~MFE_VERTICALFLIP; + fx->scale = mo->scale; + + S_StartSound(mo, sfx_s3k49); +} + static SINT8 K_GlanceAtPlayers(player_t *glancePlayer) { const fixed_t maxdistance = FixedMul(1280 * mapobjectscale, K_GetKartGameSpeedScalar(gamespeed)); diff --git a/src/k_kart.h b/src/k_kart.h index b8e74539b..98d948d7e 100644 --- a/src/k_kart.h +++ b/src/k_kart.h @@ -51,6 +51,7 @@ void K_SpawnDriftBoostClip(player_t *player); void K_SpawnDriftBoostClipSpark(mobj_t *clip); void K_SpawnNormalSpeedLines(player_t *player); void K_SpawnInvincibilitySpeedLines(mobj_t *mo); +void K_SpawnBumpEffect(mobj_t *mo); void K_KartMoveAnimation(player_t *player); void K_KartPlayerHUDUpdate(player_t *player); void K_KartPlayerThink(player_t *player, ticcmd_t *cmd); diff --git a/src/p_map.c b/src/p_map.c index 42fa89b73..de1337f2b 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -3695,14 +3695,7 @@ void P_BouncePlayerMove(mobj_t *mo) } else { - mobj_t *fx = P_SpawnMobj(mo->x, mo->y, mo->z, MT_BUMP); - if (mo->eflags & MFE_VERTICALFLIP) - fx->eflags |= MFE_VERTICALFLIP; - else - fx->eflags &= ~MFE_VERTICALFLIP; - fx->scale = mo->scale; - - S_StartSound(mo, sfx_s3k49); + K_SpawnBumpEffect(mo); } P_PlayerHitBounceLine(bestslideline); diff --git a/src/p_mobj.c b/src/p_mobj.c index 2b2cfc251..63179523d 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -2775,6 +2775,15 @@ void P_PlayerZMovement(mobj_t *mo) P_CheckMarioBlocks(mo); mo->momz = 0; + P_CheckGravity(mo, true); + + if (abs(mo->momz) < 15 * mapobjectscale) + { + mo->momz = 15 * mapobjectscale + * -(P_MobjFlip(mo)); + } + + K_SpawnBumpEffect(mo); } } } From 696ca049d89609078eb23b0983d2f0f3ad3478f4 Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 28 Nov 2021 22:43:48 -0800 Subject: [PATCH 061/156] Apply momentum based squash and stretch to every object Also netsave. --- src/d_player.h | 1 - src/k_kart.c | 37 ++++++++++++++++++++++++++++++++++++- src/k_kart.h | 1 + src/p_mobj.c | 7 ++++++- src/p_mobj.h | 3 +++ src/p_saveg.c | 13 ++++++++++++- src/p_slopes.c | 2 ++ src/p_user.c | 41 ----------------------------------------- 8 files changed, 60 insertions(+), 45 deletions(-) diff --git a/src/d_player.h b/src/d_player.h index f5808a166..be16320cd 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -487,7 +487,6 @@ typedef struct player_s fixed_t speed; // Player's speed (distance formula of MOMX and MOMY values) fixed_t lastspeed; - fixed_t lastmomz; INT32 deadtimer; // End game if game over lasts too long tic_t exiting; // Exitlevel timer diff --git a/src/k_kart.c b/src/k_kart.c index bb709a850..85b62c4c2 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -2536,7 +2536,6 @@ void K_KartMoveAnimation(player_t *player) // Update lastspeed value -- we use to display slow driving frames instead of fast driving when slowing down. player->lastspeed = player->speed; - player->lastmomz = player->mo->momz; } static void K_TauntVoiceTimers(player_t *player) @@ -4509,6 +4508,42 @@ void K_DriftDustHandling(mobj_t *spawner) } } +void K_Squish(mobj_t *mo) +{ + const fixed_t maxstretch = 2*FRACUNIT; + const fixed_t factor = 3 * mo->height / 2; + const fixed_t threshold = factor / 6; + + const fixed_t old3dspeed = abs(mo->lastmomz); + const fixed_t new3dspeed = abs(mo->momz); + + const fixed_t delta = abs(old3dspeed - new3dspeed); + + if (delta > threshold) + { + mo->spritexscale = + FRACUNIT + FixedDiv(delta, factor); + + if (mo->spritexscale > maxstretch) + mo->spritexscale = maxstretch; + + if (abs(new3dspeed) > abs(old3dspeed)) + { + mo->spritexscale = + FixedDiv(FRACUNIT, mo->spritexscale); + } + } + else + { + mo->spritexscale -= + (mo->spritexscale - FRACUNIT) + / (mo->spritexscale < FRACUNIT ? 8 : 2); + } + + mo->spriteyscale = + FixedDiv(FRACUNIT, mo->spritexscale); +} + static mobj_t *K_FindLastTrailMobj(player_t *player) { mobj_t *trail; diff --git a/src/k_kart.h b/src/k_kart.h index b8e74539b..9a07fe609 100644 --- a/src/k_kart.h +++ b/src/k_kart.h @@ -76,6 +76,7 @@ void K_SpawnSparkleTrail(mobj_t *mo); void K_SpawnWipeoutTrail(mobj_t *mo, boolean offroad); void K_SpawnDraftDust(mobj_t *mo); void K_DriftDustHandling(mobj_t *spawner); +void K_Squish(mobj_t *mo); mobj_t *K_ThrowKartItem(player_t *player, boolean missile, mobjtype_t mapthing, INT32 defaultDir, INT32 altthrow); void K_PuntMine(mobj_t *mine, mobj_t *punter); void K_DoSneaker(player_t *player, INT32 type); diff --git a/src/p_mobj.c b/src/p_mobj.c index 2b2cfc251..ee1fa0890 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -8616,7 +8616,7 @@ void P_MobjThinker(mobj_t *mobj) return; } - mobj->eflags &= ~(MFE_PUSHED|MFE_SPRUNG|MFE_JUSTBOUNCEDWALL|MFE_DAMAGEHITLAG); + mobj->eflags &= ~(MFE_PUSHED|MFE_SPRUNG|MFE_JUSTBOUNCEDWALL|MFE_DAMAGEHITLAG|MFE_SLOPELAUNCHED); tmfloorthing = tmhitthing = NULL; @@ -8867,6 +8867,11 @@ void P_MobjThinker(mobj_t *mobj) default: break; } + + if (!(mobj->eflags & MFE_SLOPELAUNCHED)) + K_Squish(mobj); + + mobj->lastmomz = mobj->momz; } // Quick, optimized function for the Rail Rings diff --git a/src/p_mobj.h b/src/p_mobj.h index 16055907b..28395f85a 100644 --- a/src/p_mobj.h +++ b/src/p_mobj.h @@ -249,6 +249,8 @@ typedef enum MFE_JUSTBOUNCEDWALL = 1<<12, // SRB2Kart: In damage hitlag (displays different visual efx) MFE_DAMAGEHITLAG = 1<<13, + // Slope physics sent you airborne + MFE_SLOPELAUNCHED = 1<<14, // free: to and including 1<<15 } mobjeflag_t; @@ -360,6 +362,7 @@ typedef struct mobj_s fixed_t friction; fixed_t movefactor; + fixed_t lastmomz; INT32 fuse; // Does something in P_MobjThinker on reaching 0. fixed_t watertop; // top of the water FOF the mobj is in diff --git a/src/p_saveg.c b/src/p_saveg.c index ce1093061..83625026d 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -1534,7 +1534,8 @@ typedef enum MD2_HITLAG = 1<<24, MD2_WAYPOINTCAP = 1<<25, MD2_KITEMCAP = 1<<26, - MD2_ITNEXT = 1<<27 + MD2_ITNEXT = 1<<27, + MD2_LASTMOMZ = 1<<28, } mobj_diff2_t; typedef enum @@ -1775,6 +1776,8 @@ static void SaveMobjThinker(const thinker_t *th, const UINT8 type) diff2 |= MD2_KITEMCAP; if (mobj->itnext) diff2 |= MD2_ITNEXT; + if (mobj->lastmomz) + diff2 |= MD2_LASTMOMZ; if (diff2 != 0) diff |= MD_MORE; @@ -1968,6 +1971,10 @@ static void SaveMobjThinker(const thinker_t *th, const UINT8 type) { WRITEINT32(save_p, mobj->hitlag); } + if (diff2 & MD2_LASTMOMZ) + { + WRITEINT32(save_p, mobj->lastmomz); + } WRITEUINT32(save_p, mobj->mobjnum); } @@ -3062,6 +3069,10 @@ static thinker_t* LoadMobjThinker(actionf_p1 thinker) { mobj->hitlag = READINT32(save_p); } + if (diff2 & MD2_LASTMOMZ) + { + mobj->lastmomz = READINT32(save_p); + } if (diff & MD_REDFLAG) { diff --git a/src/p_slopes.c b/src/p_slopes.c index d1e8f5f54..1bde8f4ee 100644 --- a/src/p_slopes.c +++ b/src/p_slopes.c @@ -844,6 +844,8 @@ void P_SlopeLaunch(mobj_t *mo) mo->momy = slopemom.y; mo->momz = slopemom.z; #endif + + mo->eflags |= MFE_SLOPELAUNCHED; } //CONS_Printf("Launched off of slope.\n"); diff --git a/src/p_user.c b/src/p_user.c index 63bd09c96..c58e61b4d 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1658,42 +1658,6 @@ static void P_DoBubbleBreath(player_t *player) } } -static void squish(player_t *player) -{ - const fixed_t maxstretch = 2*FRACUNIT; - const fixed_t factor = 3 * player->mo->height / 2; - const fixed_t threshold = factor / 6; - - const fixed_t old3dspeed = abs(player->lastmomz); - const fixed_t new3dspeed = abs(player->mo->momz); - - const fixed_t delta = abs(old3dspeed - new3dspeed); - - if (delta > threshold) - { - player->mo->spritexscale = - FRACUNIT + FixedDiv(delta, factor); - - if (player->mo->spritexscale > maxstretch) - player->mo->spritexscale = maxstretch; - - if (abs(new3dspeed) > abs(old3dspeed)) - { - player->mo->spritexscale = - FixedDiv(FRACUNIT, player->mo->spritexscale); - } - } - else - { - player->mo->spritexscale -= - (player->mo->spritexscale - FRACUNIT) - / (player->mo->spritexscale < FRACUNIT ? 8 : 2); - } - - player->mo->spriteyscale = - FixedDiv(FRACUNIT, player->mo->spritexscale); -} - //#define OLD_MOVEMENT_CODE 1 static void P_3dMovement(player_t *player) { @@ -1890,11 +1854,6 @@ static void P_3dMovement(player_t *player) } } } - - if (!player->powers[pw_justlaunched]) - { - squish(player); - } } // From 1e73c842e2132ac23c46516c2e252cfa174640c6 Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 28 Nov 2021 23:14:31 -0800 Subject: [PATCH 062/156] Run squish effect for players too This is ironic. --- src/p_mobj.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index ee1fa0890..27b668a46 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -3511,6 +3511,16 @@ static void P_CheckFloatbobPlatforms(mobj_t *mobj) } } +static void P_SquishThink(mobj_t *mobj) +{ + if (!(mobj->eflags & MFE_SLOPELAUNCHED)) + { + K_Squish(mobj); + } + + mobj->lastmomz = mobj->momz; +} + static void P_PlayerMobjThinker(mobj_t *mobj) { I_Assert(mobj != NULL); @@ -3576,6 +3586,8 @@ static void P_PlayerMobjThinker(mobj_t *mobj) mobj->eflags &= ~MFE_JUSTHITFLOOR; } + P_SquishThink(mobj); + animonly: P_CyclePlayerMobjState(mobj); } @@ -8805,6 +8817,8 @@ void P_MobjThinker(mobj_t *mobj) P_ButteredSlope(mobj); } + P_SquishThink(mobj); + if (mobj->flags & (MF_ENEMY|MF_BOSS) && mobj->health && P_CheckDeathPitCollide(mobj)) // extra pit check in case these didn't have momz { @@ -8867,11 +8881,6 @@ void P_MobjThinker(mobj_t *mobj) default: break; } - - if (!(mobj->eflags & MFE_SLOPELAUNCHED)) - K_Squish(mobj); - - mobj->lastmomz = mobj->momz; } // Quick, optimized function for the Rail Rings From 0e25de897d02ba496df0f663b854f3b373d81695 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Mon, 29 Nov 2021 05:27:44 -0500 Subject: [PATCH 063/156] Instead of gentlemens dropping packets, it simply delays what it sends --- src/d_clisrv.c | 70 +++++++++++++++++++++++++++----------------------- src/d_clisrv.h | 9 +++++++ 2 files changed, 47 insertions(+), 32 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 5b4141328..f33649cc7 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -141,7 +141,7 @@ UINT8 adminpassmd5[16]; boolean adminpasswordset = false; // Client specific -static ticcmd_t localcmds[MAXSPLITSCREENPLAYERS]; +static ticcmd_t localcmds[MAXSPLITSCREENPLAYERS][MAXGENTLEMENDELAY]; static boolean cl_packetmissed; // here it is for the secondary local player (splitscreen) static UINT8 mynode; // my address pointofview server @@ -440,10 +440,15 @@ static void D_Clearticcmd(tic_t tic) void D_ResetTiccmds(void) { - INT32 i; + INT32 i, j; for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) - memset(&localcmds[i], 0, sizeof(ticcmd_t)); + { + for (j = 0; j < MAXGENTLEMENDELAY; j++) + { + memset(&localcmds[i][j], 0, sizeof(ticcmd_t)); + } + } // Reset the net command list for (i = 0; i < TEXTCMD_HASH_SIZE; i++) @@ -4934,12 +4939,6 @@ static void CL_SendClientCmd(void) size_t packetsize = 0; boolean mis = false; - if (lowest_lag && ( gametic % lowest_lag )) - { - cl_packetmissed = true; - return; - } - netbuffer->packettype = PT_CLIENTCMD; if (cl_packetmissed) @@ -4960,27 +4959,35 @@ static void CL_SendClientCmd(void) } else if (gamestate != GS_NULL && (addedtogame || dedicated)) { + UINT8 lagDelay = 0; + + if (lowest_lag > 0) + { + // Gentlemens' ping. + lagDelay = min(lowest_lag, MAXGENTLEMENDELAY); + } + packetsize = sizeof (clientcmd_pak); - G_MoveTiccmd(&netbuffer->u.clientpak.cmd, &localcmds[0], 1); - netbuffer->u.clientpak.consistancy = SHORT(consistancy[gametic%TICQUEUE]); + G_MoveTiccmd(&netbuffer->u.clientpak.cmd, &localcmds[0][lagDelay], 1); + netbuffer->u.clientpak.consistancy = SHORT(consistancy[gametic % TICQUEUE]); if (splitscreen) // Send a special packet with 2 cmd for splitscreen { netbuffer->packettype = (mis ? PT_CLIENT2MIS : PT_CLIENT2CMD); packetsize = sizeof (client2cmd_pak); - G_MoveTiccmd(&netbuffer->u.client2pak.cmd2, &localcmds[1], 1); + G_MoveTiccmd(&netbuffer->u.client2pak.cmd2, &localcmds[1][lagDelay], 1); if (splitscreen > 1) { netbuffer->packettype = (mis ? PT_CLIENT3MIS : PT_CLIENT3CMD); packetsize = sizeof (client3cmd_pak); - G_MoveTiccmd(&netbuffer->u.client3pak.cmd3, &localcmds[2], 1); + G_MoveTiccmd(&netbuffer->u.client3pak.cmd3, &localcmds[2][lagDelay], 1); if (splitscreen > 2) { netbuffer->packettype = (mis ? PT_CLIENT4MIS : PT_CLIENT4CMD); packetsize = sizeof (client4cmd_pak); - G_MoveTiccmd(&netbuffer->u.client4pak.cmd4, &localcmds[3], 1); + G_MoveTiccmd(&netbuffer->u.client4pak.cmd4, &localcmds[3][lagDelay], 1); } } } @@ -5143,8 +5150,23 @@ static void SV_SendTics(void) // // TryRunTics // +static void CreateNewLocalCMD(UINT8 p, INT32 realtics) +{ + INT32 i; + + for (i = MAXGENTLEMENDELAY-1; i > 0; i--) + { + G_MoveTiccmd(&localcmds[p][i], &localcmds[p][i-1], 1); + } + + G_BuildTiccmd(&localcmds[p][0], realtics, p+1); + localcmds[p][0].flags |= TICCMD_RECEIVED; +} + static void Local_Maketic(INT32 realtics) { + INT32 i; + I_OsPolling(); // I_Getevent D_ProcessEvents(); // menu responder, cons responder, // game responder calls HU_Responder, AM_Responder, @@ -5153,25 +5175,9 @@ static void Local_Maketic(INT32 realtics) if (!dedicated) rendergametic = gametic; // translate inputs (keyboard/mouse/joystick) into game controls - G_BuildTiccmd(&localcmds[0], realtics, 1); - localcmds[0].flags |= TICCMD_RECEIVED; - - if (splitscreen) + for (i = 0; i <= splitscreen; i++) { - G_BuildTiccmd(&localcmds[1], realtics, 2); - localcmds[1].flags |= TICCMD_RECEIVED; - - if (splitscreen > 1) - { - G_BuildTiccmd(&localcmds[2], realtics, 3); - localcmds[2].flags |= TICCMD_RECEIVED; - - if (splitscreen > 2) - { - G_BuildTiccmd(&localcmds[3], realtics, 4); - localcmds[3].flags |= TICCMD_RECEIVED; - } - } + CreateNewLocalCMD(i, realtics); } } diff --git a/src/d_clisrv.h b/src/d_clisrv.h index 93593d736..88712f01c 100644 --- a/src/d_clisrv.h +++ b/src/d_clisrv.h @@ -39,6 +39,15 @@ applications may follow different packet versions. // Networking and tick handling related. #define TICQUEUE 512 // more than enough for most timeouts.... #define MAXTEXTCMD 256 + +// No. of tics your controls can be delayed by. + +// TODO: Instead of storing a ton of extra cmds for gentlemens' delay, +// keep them in a linked-list, with timestamps to discard everything that's older than already sent. +// That will support any amount of lag, and be less wasteful for clients who don't use it. +// This just works as a quick implementation. +#define MAXGENTLEMENDELAY TICRATE + // // Packet structure // From 1550210188b6a115b4e62f2a2e99c1b198c7fd9f Mon Sep 17 00:00:00 2001 From: Eidolon Date: Sun, 6 Oct 2019 17:40:52 -0500 Subject: [PATCH 064/156] Implement interpolation at the renderer level Instead of interpolating thinkers, we interpolate mobjs inside the renderer. Further interpolation is TBI. --- src/Makefile.d/versions.mk | 2 +- src/Sourcefile | 1 + src/android/i_system.c | 6 ++ src/d_clisrv.c | 1 + src/d_main.c | 35 +++++++- src/d_main.h | 1 + src/dummy/i_system.c | 2 +- src/g_game.c | 12 ++- src/hardware/hw_main.c | 97 +++++++++++++++----- src/i_system.h | 4 + src/p_mobj.c | 20 +++++ src/p_mobj.h | 2 + src/p_tick.c | 1 + src/r_fps.c | 175 +++++++++++++++++++++++++++++++++++++ src/r_fps.h | 63 +++++++++++++ src/r_main.c | 167 ++++++++++++++++------------------- src/r_main.h | 6 ++ src/r_things.c | 106 +++++++++++++++------- src/sdl/i_system.c | 29 ++++-- src/win32/win_sys.c | 6 ++ 20 files changed, 573 insertions(+), 163 deletions(-) create mode 100644 src/r_fps.c create mode 100644 src/r_fps.h diff --git a/src/Makefile.d/versions.mk b/src/Makefile.d/versions.mk index 7a021dda7..27ac64e78 100644 --- a/src/Makefile.d/versions.mk +++ b/src/Makefile.d/versions.mk @@ -162,7 +162,7 @@ ifdef DEBUGMODE ifdef GCC48 opts+=-Og else -opts+=O0 +opts+=-O0 endif endif diff --git a/src/Sourcefile b/src/Sourcefile index 384af8da7..9bc27d4da 100644 --- a/src/Sourcefile +++ b/src/Sourcefile @@ -56,6 +56,7 @@ tables.c r_bsp.c r_data.c r_draw.c +r_fps.c r_main.c r_plane.c r_segs.c diff --git a/src/android/i_system.c b/src/android/i_system.c index 908629bea..d8b81dcec 100644 --- a/src/android/i_system.c +++ b/src/android/i_system.c @@ -88,6 +88,12 @@ tic_t I_GetTime(void) return (since_start*TICRATE)/1000000; } +fixed_t I_GetTimeFrac(void) +{ + //stub + return 0; +} + void I_Sleep(void){} void I_GetEvent(void){} diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 5b4141328..0f7227cb6 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -5288,6 +5288,7 @@ void TryRunTics(tic_t realtics) while (neededtic > gametic) { DEBFILE(va("============ Running tic %d (local %d)\n", gametic, localgametic)); + prev_tics = I_GetTime(); ps_tictime = I_GetPreciseTime(); diff --git a/src/d_main.c b/src/d_main.c index 5ded2bf14..f611c4c3f 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -63,6 +63,7 @@ #include "deh_tables.h" // Dehacked list test #include "m_cond.h" // condition initialization #include "fastcmp.h" +#include "r_fps.h" // Frame interpolation/uncapped #include "keys.h" #include "filesrch.h" // refreshdirmenu #include "g_input.h" // tutorial mode control scheming @@ -154,6 +155,7 @@ event_t events[MAXEVENTS]; INT32 eventhead, eventtail; boolean dedicated = false; +boolean tic_happened = false; // Frame interpolation/uncapped // // D_PostEvent @@ -755,7 +757,7 @@ void D_SRB2Loop(void) debugload--; #endif - if (!realtics && !singletics) + if (!realtics && !singletics && cv_frameinterpolation.value != 1) { I_Sleep(); continue; @@ -771,15 +773,27 @@ void D_SRB2Loop(void) realtics = 1; // process tics (but maybe not if realtic == 0) + tic_happened = realtics ? true : false; TryRunTics(realtics); + if (cv_frameinterpolation.value == 1) + rendertimefrac = I_GetTimeFrac(); + else + rendertimefrac = FRACUNIT; + + if (cv_frameinterpolation.value == 1) + { + D_Display(); + } + if (lastdraw || singletics || gametic > rendergametic) { rendergametic = gametic; rendertimeout = entertic+TICRATE/17; // Update display, next frame, with current state. - D_Display(); + // (Only display if not already done for frame interp) + cv_frameinterpolation.value == 0 ? D_Display() : 0; if (moviemode) M_SaveFrame(); @@ -788,7 +802,22 @@ void D_SRB2Loop(void) } else if (rendertimeout < entertic) // in case the server hang or netsplit { - D_Display(); +#if 0 + // Lagless camera! Yay! + if (gamestate == GS_LEVEL && netgame) + { + INT32 i; + + for (i = 0; i <= r_splitscreen; i++) + { + if (camera[i].chase) + P_MoveChaseCamera(&players[displayplayers[i]], &camera[i], false); + } + } +#endif + + // (Only display if not already done for frame interp) + cv_frameinterpolation.value == 0 ? D_Display() : 0; if (moviemode) M_SaveFrame(); diff --git a/src/d_main.h b/src/d_main.h index 81de0634d..26b5c4528 100644 --- a/src/d_main.h +++ b/src/d_main.h @@ -26,6 +26,7 @@ extern char srb2home[256]; //Alam: My Home extern boolean usehome; //Alam: which path? extern const char *pandf; //Alam: how to path? extern char srb2path[256]; //Alam: SRB2's Home +extern boolean tic_happened; // Frame interpolation/uncapped // the infinite loop of D_SRB2Loop() called from win_main for windows version void D_SRB2Loop(void) FUNCNORETURN; diff --git a/src/dummy/i_system.c b/src/dummy/i_system.c index 4a657ed19..f3d0bc5e8 100644 --- a/src/dummy/i_system.c +++ b/src/dummy/i_system.c @@ -16,7 +16,7 @@ tic_t I_GetTime(void) return 0; } -int I_GetTimeMicros(void) +fixed_t I_GetTimeFrac(void) { return 0; } diff --git a/src/g_game.c b/src/g_game.c index e964fb65d..cb2fa4e77 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -45,8 +45,8 @@ #include "y_inter.h" #include "v_video.h" #include "lua_hook.h" -#include "k_bot.h" #include "m_cond.h" // condition sets +#include "r_fps.h" // frame interpolation/uncapped #include "lua_hud.h" // SRB2kart @@ -56,6 +56,7 @@ #include "k_color.h" #include "k_respawn.h" #include "k_grandprix.h" +#include "k_bot.h" #include "doomstat.h" #ifdef HAVE_DISCORDRPC @@ -1920,6 +1921,8 @@ void G_Ticker(boolean run) F_TextPromptTicker(); AM_Ticker(); HU_Ticker(); + R_UpdateViewInterpolation(); + break; case GS_INTERMISSION: @@ -1976,7 +1979,12 @@ void G_Ticker(boolean run) break; case GS_TITLESCREEN: - if (titlemapinaction) P_Ticker(run); + if (titlemapinaction) + { + P_Ticker(run); + R_UpdateViewInterpolation(); + } + F_TitleScreenTicker(run); break; diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 205fc3ff6..c950e3b32 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -38,6 +38,7 @@ #include "../m_cheat.h" #include "../f_finale.h" #include "../r_things.h" // R_GetShadowZ +#include "../d_main.h" #include "../p_slopes.h" #include "hw_md2.h" @@ -5013,10 +5014,6 @@ static void HWR_AddSprites(sector_t *sec) // BP why not use xtoviexangle/viewangletox like in bsp ?.... static void HWR_ProjectSprite(mobj_t *thing) { - fixed_t thingxpos = thing->x + thing->sprxoff; - fixed_t thingypos = thing->y + thing->spryoff; - fixed_t thingzpos = thing->z + thing->sprzoff; - gl_vissprite_t *vis; float tr_x, tr_y; float tz; @@ -5056,13 +5053,34 @@ static void HWR_ProjectSprite(mobj_t *thing) angle_t spriterotangle = 0; #endif + // uncapped/interpolation + fixed_t interpx; + fixed_t interpy; + fixed_t interpz; + angle_t interpangle; + if (!thing) return; if (thing->spritexscale < 1 || thing->spriteyscale < 1) return; - // hitlag vibrating + dispoffset = thing->info->dispoffset; + + interpx = thing->x + thing->sprxoff; + interpy = thing->y + thing->spryoff; + interpz = thing->z + thing->sprzoff; + interpangle = mobjangle; + + if (cv_frameinterpolation.value == 1 && !paused) + { + interpx = thing->old_x + FixedMul(rendertimefrac, thing->x - thing->old_x); + interpy = thing->old_y + FixedMul(rendertimefrac, thing->y - thing->old_y); + interpz = thing->old_z + FixedMul(rendertimefrac, thing->z - thing->old_z); + interpangle = mobjangle; + } + + // hitlag vibrating (todo: interp somehow?) if (thing->hitlag > 0 && (thing->eflags & MFE_DAMAGEHITLAG)) { fixed_t mul = thing->hitlag * (FRACUNIT / 10); @@ -5072,20 +5090,18 @@ static void HWR_ProjectSprite(mobj_t *thing) mul = -mul; } - thingxpos += FixedMul(thing->momx, mul); - thingypos += FixedMul(thing->momy, mul); - thingzpos += FixedMul(thing->momz, mul); + interpx += FixedMul(thing->momx, mul); + interpy += FixedMul(thing->momy, mul); + interpz += FixedMul(thing->momz, mul); } - dispoffset = thing->info->dispoffset; - this_scale = FIXED_TO_FLOAT(thing->scale); spritexscale = FIXED_TO_FLOAT(thing->spritexscale); spriteyscale = FIXED_TO_FLOAT(thing->spriteyscale); // transform the origin point - tr_x = FIXED_TO_FLOAT(thingxpos) - gl_viewx; - tr_y = FIXED_TO_FLOAT(thingypos) - gl_viewy; + tr_x = FIXED_TO_FLOAT(interpx) - gl_viewx; + tr_y = FIXED_TO_FLOAT(interpy) - gl_viewy; // rotation around vertical axis tz = (tr_x * gl_viewcos) + (tr_y * gl_viewsin); @@ -5108,8 +5124,8 @@ static void HWR_ProjectSprite(mobj_t *thing) } // The above can stay as it works for cutting sprites that are too close - tr_x = FIXED_TO_FLOAT(thingxpos); - tr_y = FIXED_TO_FLOAT(thingypos); + tr_x = FIXED_TO_FLOAT(interpx); + tr_y = FIXED_TO_FLOAT(interpy); // decide which patch to use for sprite relative to player #ifdef RANGECHECK @@ -5157,7 +5173,7 @@ static void HWR_ProjectSprite(mobj_t *thing) I_Error("sprframes NULL for sprite %d\n", thing->sprite); #endif - ang = R_PointToAngle (thingxpos, thingypos) - mobjangle; + ang = R_PointToAngle (interpx, interpy) - interpangle; if (mirrored) ang = InvAngle(ang); @@ -5304,12 +5320,12 @@ static void HWR_ProjectSprite(mobj_t *thing) if (vflip) { - gz = FIXED_TO_FLOAT(thingzpos + thing->height) - (FIXED_TO_FLOAT(spr_topoffset) * this_yscale); + gz = FIXED_TO_FLOAT(interpz + thing->height) - (FIXED_TO_FLOAT(spr_topoffset) * this_yscale); gzt = gz + (FIXED_TO_FLOAT(spr_height) * this_yscale); } else { - gzt = FIXED_TO_FLOAT(thingzpos) + (FIXED_TO_FLOAT(spr_topoffset) * this_yscale); + gzt = FIXED_TO_FLOAT(interpz) + (FIXED_TO_FLOAT(spr_topoffset) * this_yscale); gz = gzt - (FIXED_TO_FLOAT(spr_height) * this_yscale); } @@ -5328,12 +5344,12 @@ static void HWR_ProjectSprite(mobj_t *thing) if (heightsec != -1 && phs != -1) // only clip things which are in special sectors { if (gl_viewz < FIXED_TO_FLOAT(sectors[phs].floorheight) ? - FIXED_TO_FLOAT(thingzpos) >= FIXED_TO_FLOAT(sectors[heightsec].floorheight) : + FIXED_TO_FLOAT(interpz) >= FIXED_TO_FLOAT(sectors[heightsec].floorheight) : gzt < FIXED_TO_FLOAT(sectors[heightsec].floorheight)) return; if (gl_viewz > FIXED_TO_FLOAT(sectors[phs].ceilingheight) ? gzt < FIXED_TO_FLOAT(sectors[heightsec].ceilingheight) && gl_viewz >= FIXED_TO_FLOAT(sectors[heightsec].ceilingheight) : - FIXED_TO_FLOAT(thingzpos) >= FIXED_TO_FLOAT(sectors[heightsec].ceilingheight)) + FIXED_TO_FLOAT(interpz) >= FIXED_TO_FLOAT(sectors[heightsec].ceilingheight)) return; } @@ -5468,9 +5484,29 @@ static void HWR_ProjectPrecipitationSprite(precipmobj_t *thing) unsigned rot = 0; UINT8 flip; + // uncapped/interpolation + fixed_t interpx; + fixed_t interpy; + fixed_t interpz; + + if (!thing) + return; + + interpx = thing->x; + interpy = thing->y; + interpz = thing->z; + + // do interpolation + if (cv_frameinterpolation.value == 1 && !paused) + { + interpx = thing->old_x + FixedMul(rendertimefrac, thing->x - thing->old_x); + interpy = thing->old_y + FixedMul(rendertimefrac, thing->y - thing->old_y); + interpz = thing->old_z + FixedMul(rendertimefrac, thing->z - thing->old_z); + } + // transform the origin point - tr_x = FIXED_TO_FLOAT(thing->x) - gl_viewx; - tr_y = FIXED_TO_FLOAT(thing->y) - gl_viewy; + tr_x = FIXED_TO_FLOAT(interpx) - gl_viewx; + tr_y = FIXED_TO_FLOAT(interpy) - gl_viewy; // rotation around vertical axis tz = (tr_x * gl_viewcos) + (tr_y * gl_viewsin); @@ -5479,8 +5515,8 @@ static void HWR_ProjectPrecipitationSprite(precipmobj_t *thing) if (tz < ZCLIP_PLANE) return; - tr_x = FIXED_TO_FLOAT(thing->x); - tr_y = FIXED_TO_FLOAT(thing->y); + tr_x = FIXED_TO_FLOAT(interpx); + tr_y = FIXED_TO_FLOAT(interpy); // decide which patch to use for sprite relative to player if ((unsigned)thing->sprite >= numsprites) @@ -5547,7 +5583,7 @@ static void HWR_ProjectPrecipitationSprite(precipmobj_t *thing) #endif // set top/bottom coords - vis->gzt = FIXED_TO_FLOAT(thing->z + spritecachedinfo[lumpoff].topoffset); + vis->gzt = FIXED_TO_FLOAT(interpz + spritecachedinfo[lumpoff].topoffset); vis->gz = vis->gzt - FIXED_TO_FLOAT(spritecachedinfo[lumpoff].height); vis->precip = true; @@ -6651,6 +6687,7 @@ INT32 HWR_GetTextureUsed(void) void HWR_DoPostProcessor(player_t *player) { postimg_t *type = &postimgtype[0]; + fixed_t fractime; SINT8 i; HWD.pfnUnSetShader(); @@ -6702,6 +6739,8 @@ void HWR_DoPostProcessor(player_t *player) // 10 by 10 grid. 2 coordinates (xy) float v[SCREENVERTS][SCREENVERTS][2]; static double disStart = 0; + static float last_fractime = 0; + UINT8 x, y; INT32 WAVELENGTH; INT32 AMPLITUDE; @@ -6733,6 +6772,16 @@ void HWR_DoPostProcessor(player_t *player) HWD.pfnPostImgRedraw(v); if (!(paused || P_AutoPause())) disStart += 1; + fractime = I_GetTimeFrac(); + if (tic_happened) + { + disStart = disStart - last_fractime + 1 + FIXED_TO_FLOAT(fractime); + } + else + { + disStart = disStart - last_fractime + FIXED_TO_FLOAT(fractime); + } + last_fractime = fractime; // Capture the screen again for screen waving on the intermission if(gamestate != GS_INTERMISSION) diff --git a/src/i_system.h b/src/i_system.h index 0d5898a72..4bc0e73da 100644 --- a/src/i_system.h +++ b/src/i_system.h @@ -46,6 +46,10 @@ UINT32 I_GetFreeMem(UINT32 *total); */ tic_t I_GetTime(void); +/** \brief Get the current time as a fraction of a tic since the last tic. +*/ +fixed_t I_GetTimeFrac(void); + /** \brief Returns precise time value for performance measurement. */ precise_t I_GetPreciseTime(void); diff --git a/src/p_mobj.c b/src/p_mobj.c index 2b2cfc251..e28c64a33 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -3636,6 +3636,11 @@ void P_NullPrecipThinker(precipmobj_t *mobj) void P_PrecipThinker(precipmobj_t *mobj) { + // reset old state (for interpolation) + mobj->old_x = mobj->x; + mobj->old_y = mobj->y; + mobj->old_z = mobj->z; + P_CycleStateAnimation((mobj_t *)mobj); if (mobj->state == &states[S_RAINRETURN]) @@ -8593,6 +8598,11 @@ void P_MobjThinker(mobj_t *mobj) I_Assert(mobj != NULL); I_Assert(!P_MobjWasRemoved(mobj)); + // Set old position (for interpolation) + mobj->old_x = mobj->x; + mobj->old_y = mobj->y; + mobj->old_z = mobj->z; + // Remove dead target/tracer. if (mobj->target && P_MobjWasRemoved(mobj->target)) P_SetTarget(&mobj->target, NULL); @@ -9743,6 +9753,11 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) if (CheckForReverseGravity && !(mobj->flags & MF_NOBLOCKMAP)) P_CheckGravity(mobj, false); + // set initial old positions (for interpolation) + mobj->old_x = mobj->x; + mobj->old_y = mobj->y; + mobj->old_z = mobj->z; + return mobj; } @@ -9794,6 +9809,11 @@ static precipmobj_t *P_SpawnPrecipMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype || mobj->subsector->sector->floorpic == skyflatnum) mobj->precipflags |= PCF_PIT; + // set initial old positions (for interpolation) + mobj->old_x = mobj->x; + mobj->old_y = mobj->y; + mobj->old_z = mobj->z; + return mobj; } diff --git a/src/p_mobj.h b/src/p_mobj.h index 16055907b..3247c14d7 100644 --- a/src/p_mobj.h +++ b/src/p_mobj.h @@ -275,6 +275,7 @@ typedef struct mobj_s // Info for drawing: position. fixed_t x, y, z; + fixed_t old_x, old_y, old_z; // position interpolation // More list: links in sector (if needed) struct mobj_s *snext; @@ -412,6 +413,7 @@ typedef struct precipmobj_s // Info for drawing: position. fixed_t x, y, z; + fixed_t old_x, old_y, old_z; // position interpolation // More list: links in sector (if needed) struct precipmobj_s *snext; diff --git a/src/p_tick.c b/src/p_tick.c index be82b9d40..9a4baa092 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -24,6 +24,7 @@ #include "lua_hook.h" #include "m_perfstats.h" #include "i_system.h" // I_GetPreciseTime +#include "r_fps.h" // Object place #include "m_cheat.h" diff --git a/src/r_fps.c b/src/r_fps.c new file mode 100644 index 000000000..ca1fa0852 --- /dev/null +++ b/src/r_fps.c @@ -0,0 +1,175 @@ +// SONIC ROBO BLAST 2 +//----------------------------------------------------------------------------- +// Copyright (C) 1993-1996 by id Software, Inc. +// Copyright (C) 1998-2000 by DooM Legacy Team. +// Copyright (C) 1999-2000 by Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze, Andrey Budko (prboom) +// Copyright (C) 1999-2019 by Sonic Team Junior. +// +// This program is free software distributed under the +// terms of the GNU General Public License, version 2. +// See the 'LICENSE' file for more details. +//----------------------------------------------------------------------------- +/// \file r_fps.h +/// \brief Uncapped framerate stuff. + +#include "r_fps.h" + +#include "r_main.h" +#include "g_game.h" +#include "i_video.h" +#include "r_plane.h" +#include "p_spec.h" +#include "r_state.h" +#include "doomstat.h" // MAXSPLITSCREENPLAYERS +#ifdef HWRENDER +#include "hardware/hw_main.h" // for cv_glshearing +#endif + +static viewvars_t pview_old[MAXSPLITSCREENPLAYERS]; +static viewvars_t pview_new[MAXSPLITSCREENPLAYERS]; +static viewvars_t skyview_old[MAXSPLITSCREENPLAYERS]; +static viewvars_t skyview_new[MAXSPLITSCREENPLAYERS]; + +static viewvars_t *oldview = &pview_old[0]; +viewvars_t *newview = &pview_new[0]; + + +enum viewcontext_e viewcontext = VIEWCONTEXT_PLAYER1; + +// recalc necessary stuff for mouseaiming +// slopes are already calculated for the full possible view (which is 4*viewheight). +// 18/08/18: (No it's actually 16*viewheight, thanks Jimita for finding this out) +static void R_SetupFreelook(player_t *player, boolean skybox) +{ +#ifndef HWRENDER + (void)player; + (void)skybox; +#endif + + // clip it in the case we are looking a hardware 90 degrees full aiming + // (lmps, network and use F12...) + if (rendermode == render_soft +#ifdef HWRENDER + || (rendermode == render_opengl + && (cv_glshearing.value == 1 + || (cv_glshearing.value == 2 && R_IsViewpointThirdPerson(player, skybox)))) +#endif + ) + { + G_SoftwareClipAimingPitch((INT32 *)&aimingangle); + } + + centeryfrac = (viewheight/2)<x + R_LerpFixed(oldview->x, newview->x, frac); + viewy = oldview->y + R_LerpFixed(oldview->y, newview->y, frac); + viewz = oldview->z + R_LerpFixed(oldview->z, newview->z, frac); + + viewangle = oldview->angle + R_LerpAngle(oldview->angle, newview->angle, frac); + aimingangle = oldview->aim + R_LerpAngle(oldview->aim, newview->aim, frac); + + viewsin = FINESINE(viewangle>>ANGLETOFINESHIFT); + viewcos = FINECOSINE(viewangle>>ANGLETOFINESHIFT); + + // this is gonna create some interesting visual errors for long distance teleports... + // might want to recalculate the view sector every frame instead... + if (frac >= FRACUNIT) + { + viewplayer = newview->player; + viewsector = newview->sector; + } + else + { + viewplayer = oldview->player; + viewsector = oldview->sector; + } + + // well, this ain't pretty + for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) + { + if (newview == &skyview_new[i]) + { + skybox = true; + break; + } + } + + R_SetupFreelook(newview->player, skybox); +} + +void R_UpdateViewInterpolation(void) +{ + INT32 i; + + for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) + { + pview_old[i] = pview_new[i]; + skyview_old[i] = skyview_new[i]; + } +} + +void R_SetViewContext(enum viewcontext_e _viewcontext) +{ + INT32 i; + + I_Assert(_viewcontext >= VIEWCONTEXT_PLAYER1 + && _viewcontext <= VIEWCONTEXT_SKY4); + viewcontext = _viewcontext; + + switch (viewcontext) + { + case VIEWCONTEXT_PLAYER1: + case VIEWCONTEXT_PLAYER2: + case VIEWCONTEXT_PLAYER3: + case VIEWCONTEXT_PLAYER4: + i = viewcontext - VIEWCONTEXT_PLAYER1; + oldview = &pview_old[i]; + newview = &pview_new[i]; + break; + case VIEWCONTEXT_SKY1: + case VIEWCONTEXT_SKY2: + case VIEWCONTEXT_SKY3: + case VIEWCONTEXT_SKY4: + i = viewcontext - VIEWCONTEXT_SKY1; + oldview = &skyview_old[i]; + newview = &skyview_new[i]; + break; + default: + I_Error("viewcontext value is invalid: we should never get here without an assert!!"); + break; + } +} + +fixed_t R_LerpFixed(fixed_t from, fixed_t to, fixed_t frac) +{ + return FixedMul(frac, to - from); +} + +INT32 R_LerpInt32(INT32 from, INT32 to, fixed_t frac) +{ + return FixedInt(FixedMul(frac, (to*FRACUNIT) - (from*FRACUNIT))); +} + +angle_t R_LerpAngle(angle_t from, angle_t to, fixed_t frac) +{ + return FixedMul(frac, to - from); +} diff --git a/src/r_fps.h b/src/r_fps.h new file mode 100644 index 000000000..24b79c922 --- /dev/null +++ b/src/r_fps.h @@ -0,0 +1,63 @@ +// SONIC ROBO BLAST 2 +//----------------------------------------------------------------------------- +// Copyright (C) 1993-1996 by id Software, Inc. +// Copyright (C) 1998-2000 by DooM Legacy Team. +// Copyright (C) 1999-2000 by Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze, Andrey Budko (prboom) +// Copyright (C) 1999-2019 by Sonic Team Junior. +// +// This program is free software distributed under the +// terms of the GNU General Public License, version 2. +// See the 'LICENSE' file for more details. +//----------------------------------------------------------------------------- +/// \file r_fps.h +/// \brief Uncapped framerate stuff. + +#ifndef __R_FPS_H__ +#define __R_FPS_H__ + +#include "m_fixed.h" +#include "p_local.h" +#include "r_state.h" + +enum viewcontext_e +{ + VIEWCONTEXT_PLAYER1 = 0, + VIEWCONTEXT_PLAYER2, + VIEWCONTEXT_PLAYER3, + VIEWCONTEXT_PLAYER4, + VIEWCONTEXT_SKY1, + VIEWCONTEXT_SKY2, + VIEWCONTEXT_SKY3, + VIEWCONTEXT_SKY4 +}; + +typedef struct { + fixed_t x; + fixed_t y; + fixed_t z; + boolean sky; + sector_t *sector; + player_t *player; + + angle_t angle; + angle_t aim; + fixed_t cos; + fixed_t sin; + mobj_t *mobj; +} viewvars_t; + +extern viewvars_t *newview; + +// Interpolates the current view variables (r_state.h) against the selected view context in R_SetViewContext +void R_InterpolateView(fixed_t frac); +// Buffer the current new views into the old views. Call once after each real tic. +void R_UpdateViewInterpolation(void); +// Set the current view context (the viewvars pointed to by newview) +void R_SetViewContext(enum viewcontext_e _viewcontext); + +fixed_t R_LerpFixed(fixed_t from, fixed_t to, fixed_t frac); +INT32 R_LerpInt32(INT32 from, INT32 to, fixed_t frac); +UINT32 R_LerpUInt32(UINT32 from, UINT32 to, fixed_t frac); +angle_t R_LerpAngle(angle_t from, angle_t to, fixed_t frac); + +#endif diff --git a/src/r_main.c b/src/r_main.c index dfc11ab4a..6cb05801c 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -36,6 +36,7 @@ #include "r_main.h" #include "i_system.h" // I_GetPreciseTime #include "doomstat.h" // MAXSPLITSCREENPLAYERS +#include "r_fps.h" // Frame interpolation/uncapped #ifdef HWRENDER #include "hardware/hw_main.h" @@ -79,6 +80,8 @@ mobj_t *r_viewmobj; int r_splitscreen; +fixed_t rendertimefrac; + // // precalculated math tables // @@ -100,6 +103,9 @@ lighttable_t *scalelight[LIGHTLEVELS][MAXLIGHTSCALE]; lighttable_t *scalelightfixed[MAXLIGHTSCALE]; lighttable_t *zlight[LIGHTLEVELS][MAXLIGHTZ]; +// Frame interpolation/uncapped +tic_t prev_tics; + // Hack to support extra boom colormaps. extracolormap_t *extra_colormaps = NULL; @@ -172,6 +178,9 @@ consvar_t cv_fov[MAXSPLITSCREENPLAYERS] = { CVAR_INIT ("fov4", "90", CV_FLOAT|CV_CALL, fov_cons_t, Fov_OnChange) }; +// Frame interpolation/uncapped +consvar_t cv_frameinterpolation = CVAR_INIT ("frameinterpolation", "On", CV_SAVE, CV_OnOff, NULL); + // Okay, whoever said homremoval causes a performance hit should be shot. consvar_t cv_homremoval = CVAR_INIT ("homremoval", "Yes", CV_SAVE, homremoval_cons_t, NULL); @@ -1193,40 +1202,6 @@ subsector_t *R_PointInSubsectorOrNull(fixed_t x, fixed_t y) // R_SetupFrame // -// recalc necessary stuff for mouseaiming -// slopes are already calculated for the full possible view (which is 4*viewheight). -// 18/08/18: (No it's actually 16*viewheight, thanks Jimita for finding this out) -static void R_SetupFreelook(player_t *player, boolean skybox) -{ -#ifndef HWRENDER - (void)player; - (void)skybox; -#endif - - // clip it in the case we are looking a hardware 90 degrees full aiming - // (lmps, network and use F12...) - if (rendermode == render_soft -#ifdef HWRENDER - || (rendermode == render_opengl - && (cv_glshearing.value == 1 - || (cv_glshearing.value == 2 && R_IsViewpointThirdPerson(player, skybox)))) -#endif - ) - { - G_SoftwareClipAimingPitch((INT32 *)&aimingangle); - } - - centeryfrac = (viewheight/2)<chase = false; + newview->sky = false; + if (player->awayviewtics) { // cut-away view stuff r_viewmobj = player->awayviewmobj; // should be a MT_ALTVIEWMAN I_Assert(r_viewmobj != NULL); - viewz = r_viewmobj->z + 20*FRACUNIT; - aimingangle = player->awayviewaiming; - viewangle = r_viewmobj->angle; + newview->z = r_viewmobj->z + 20*FRACUNIT; + newview->aim = player->awayviewaiming; + newview->angle = r_viewmobj->angle; } else if (!player->spectator && chasecam) // use outside cam view { r_viewmobj = NULL; - viewz = thiscam->z + (thiscam->height>>1); - aimingangle = thiscam->aiming; - viewangle = thiscam->angle; + newview->z = thiscam->z + (thiscam->height>>1); + newview->aim = thiscam->aiming; + newview->angle = thiscam->angle; } else // use the player's eyes view { - viewz = player->viewz; + newview->z = player->viewz; r_viewmobj = player->mo; I_Assert(r_viewmobj != NULL); - aimingangle = player->aiming; - viewangle = r_viewmobj->angle; + newview->aim = player->aiming; + newview->angle = r_viewmobj->angle; if (!demo.playback && player->playerstate != PST_DEAD) { - viewangle = localangle[i]; // WARNING: camera uses this - aimingangle = localaiming[i]; + newview->angle = localangle[i]; // WARNING: camera uses this + newview->aim = localaiming[i]; } } - viewz += quake.z; + newview->z += quake.z; - viewplayer = player; + newview->player = player; if (chasecam && !player->awayviewtics && !player->spectator) { - viewx = thiscam->x; - viewy = thiscam->y; - viewx += quake.x; - viewy += quake.y; + newview->x = thiscam->x; + newview->y = thiscam->y; + newview->x += quake.x; + newview->y += quake.y; if (thiscam->subsector) - viewsector = thiscam->subsector->sector; + newview->sector = thiscam->subsector->sector; else - viewsector = R_PointInSubsector(viewx, viewy)->sector; + newview->sector = R_PointInSubsector(newview->x, newview->y)->sector; } else { - viewx = r_viewmobj->x; - viewy = r_viewmobj->y; - viewx += quake.x; - viewy += quake.y; + newview->x = r_viewmobj->x; + newview->y = r_viewmobj->y; + newview->x += quake.x; + newview->y += quake.y; if (r_viewmobj->subsector) - viewsector = r_viewmobj->subsector->sector; + newview->sector = r_viewmobj->subsector->sector; else - viewsector = R_PointInSubsector(viewx, viewy)->sector; + newview->sector = R_PointInSubsector(newview->x, newview->y)->sector; } - viewsin = FINESINE(viewangle>>ANGLETOFINESHIFT); - viewcos = FINECOSINE(viewangle>>ANGLETOFINESHIFT); + // newview->sin = FINESINE(viewangle>>ANGLETOFINESHIFT); + // newview->cos = FINECOSINE(viewangle>>ANGLETOFINESHIFT); - R_SetupFreelook(player, false); + R_InterpolateView(cv_frameinterpolation.value == 1 ? rendertimefrac : FRACUNIT); } void R_SkyboxFrame(player_t *player) @@ -1338,6 +1316,7 @@ void R_SkyboxFrame(player_t *player) if (player == &players[displayplayers[i]]) { thiscam = &camera[i]; + R_SetViewContext(VIEWCONTEXT_SKY1 + i); break; } } @@ -1349,6 +1328,7 @@ void R_SkyboxFrame(player_t *player) } // cut-away view stuff + newview->sky = true; r_viewmobj = skyboxmo[0]; #ifdef PARANOIA if (!r_viewmobj) @@ -1359,31 +1339,31 @@ void R_SkyboxFrame(player_t *player) #endif if (player->awayviewtics) { - aimingangle = player->awayviewaiming; - viewangle = player->awayviewmobj->angle; + newview->aim = player->awayviewaiming; + newview->angle = player->awayviewmobj->angle; } else if (thiscam->chase) { - aimingangle = thiscam->aiming; - viewangle = thiscam->angle; + newview->aim = thiscam->aiming; + newview->angle = thiscam->angle; } else { - aimingangle = player->aiming; - viewangle = player->mo->angle; + newview->aim = player->aiming; + newview->angle = player->mo->angle; if (/*!demo.playback && */player->playerstate != PST_DEAD) { - viewangle = localangle[i]; - aimingangle = localaiming[i]; + newview->angle = localangle[i]; + newview->aim = localaiming[i]; } } - viewangle += r_viewmobj->angle; + newview->angle += r_viewmobj->angle; - viewplayer = player; + newview->player = player; - viewx = r_viewmobj->x; - viewy = r_viewmobj->y; - viewz = r_viewmobj->z; // 26/04/17: use actual Z position instead of spawnpoint angle! + newview->x = r_viewmobj->x; + newview->y = r_viewmobj->y; + newview->z = r_viewmobj->z; // 26/04/17: use actual Z position instead of spawnpoint angle! if (mapheaderinfo[gamemap-1]) { @@ -1425,46 +1405,46 @@ void R_SkyboxFrame(player_t *player) if (r_viewmobj->angle == 0) { - viewx += x; - viewy += y; + newview->x += x; + newview->y += y; } else if (r_viewmobj->angle == ANGLE_90) { - viewx -= y; - viewy += x; + newview->x -= y; + newview->y += x; } else if (r_viewmobj->angle == ANGLE_180) { - viewx -= x; - viewy -= y; + newview->x -= x; + newview->y -= y; } else if (r_viewmobj->angle == ANGLE_270) { - viewx += y; - viewy -= x; + newview->x += y; + newview->y -= x; } else { angle_t ang = r_viewmobj->angle>>ANGLETOFINESHIFT; - viewx += FixedMul(x,FINECOSINE(ang)) - FixedMul(y, FINESINE(ang)); - viewy += FixedMul(x, FINESINE(ang)) + FixedMul(y,FINECOSINE(ang)); + newview->x += FixedMul(x,FINECOSINE(ang)) - FixedMul(y, FINESINE(ang)); + newview->y += FixedMul(x, FINESINE(ang)) + FixedMul(y,FINECOSINE(ang)); } } if (mh->skybox_scalez > 0) - viewz += campos.z / mh->skybox_scalez; + newview->z += campos.z / mh->skybox_scalez; else if (mh->skybox_scalez < 0) - viewz += campos.z * -mh->skybox_scalez; + newview->z += campos.z * -mh->skybox_scalez; } if (r_viewmobj->subsector) - viewsector = r_viewmobj->subsector->sector; + newview->sector = r_viewmobj->subsector->sector; else - viewsector = R_PointInSubsector(viewx, viewy)->sector; + newview->sector = R_PointInSubsector(newview->x, newview->y)->sector; - viewsin = FINESINE(viewangle>>ANGLETOFINESHIFT); - viewcos = FINECOSINE(viewangle>>ANGLETOFINESHIFT); + // newview->sin = FINESINE(viewangle>>ANGLETOFINESHIFT); + // newview->cos = FINECOSINE(viewangle>>ANGLETOFINESHIFT); - R_SetupFreelook(player, true); + R_InterpolateView(cv_frameinterpolation.value == 1 ? rendertimefrac : FRACUNIT); } boolean R_ViewpointHasChasecam(player_t *player) @@ -1737,4 +1717,7 @@ void R_RegisterEngineStuff(void) CV_RegisterVar(&cv_maxportals); CV_RegisterVar(&cv_movebob); + + // Frame interpolation/uncapped + CV_RegisterVar(&cv_frameinterpolation); } diff --git a/src/r_main.h b/src/r_main.h index 5208b52a3..2ddec0ff1 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -33,6 +33,8 @@ extern fixed_t fovtan[MAXSPLITSCREENPLAYERS]; extern size_t validcount, linecount, loopcount, framecount; +extern fixed_t rendertimefrac; + // // Lighting LUT. // Used for z-depth cuing per column/row, @@ -111,6 +113,10 @@ extern consvar_t cv_fov[MAXSPLITSCREENPLAYERS]; extern consvar_t cv_skybox; extern consvar_t cv_tailspickup; +// Frame interpolation (uncapped framerate) +extern tic_t prev_tics; +extern consvar_t cv_frameinterpolation; + // Called by startup code. void R_Init(void); diff --git a/src/r_things.c b/src/r_things.c index defd02a5f..90a0cb2c9 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1361,15 +1361,11 @@ static void R_ProjectDropShadow(mobj_t *thing, vissprite_t *vis, fixed_t scale, // static void R_ProjectSprite(mobj_t *thing) { - fixed_t thingxpos = thing->x + thing->sprxoff; - fixed_t thingypos = thing->y + thing->spryoff; - fixed_t thingzpos = thing->z + thing->sprzoff; - mobj_t *oldthing = thing; //const fixed_t oldthingxpos = oldthing->x + oldthing->sprxoff; //const fixed_t oldthingypos = oldthing->y + oldthing->spryoff; - const fixed_t oldthingzpos = oldthing->z + oldthing->sprzoff; + //const fixed_t oldthingzpos = oldthing->z + oldthing->sprzoff; fixed_t tr_x, tr_y; fixed_t tx, tz; @@ -1435,7 +1431,32 @@ static void R_ProjectSprite(mobj_t *thing) angle_t spriterotangle = 0; #endif - // hitlag vibrating + // uncapped/interpolation + fixed_t interpx = thing->x + thing->sprxoff; + fixed_t interpy = thing->y + thing->spryoff; + fixed_t interpz = thing->z + thing->sprzoff; + angle_t interpangle = thing->angle; + + // use player drawangle if player + if (thing->player) interpangle = thing->player->drawangle; + + // do interpolation + if (cv_frameinterpolation.value == 1 && !paused) + { + interpx = thing->old_x + FixedMul(rendertimefrac, thing->x - thing->old_x); + interpy = thing->old_y + FixedMul(rendertimefrac, thing->y - thing->old_y); + interpz = thing->old_z + FixedMul(rendertimefrac, thing->z - thing->old_z); + if (thing->player) + { + interpangle = thing->player->drawangle; + } + else + { + interpangle = thing->angle; + } + } + + // hitlag vibrating (todo: interp somehow?) if (thing->hitlag > 0 && (thing->eflags & MFE_DAMAGEHITLAG)) { fixed_t mul = thing->hitlag * (FRACUNIT / 10); @@ -1445,14 +1466,14 @@ static void R_ProjectSprite(mobj_t *thing) mul = -mul; } - thingxpos += FixedMul(thing->momx, mul); - thingypos += FixedMul(thing->momy, mul); - thingzpos += FixedMul(thing->momz, mul); + interpx += FixedMul(thing->momx, mul); + interpy += FixedMul(thing->momy, mul); + interpz += FixedMul(thing->momz, mul); } // transform the origin point - tr_x = thingxpos - viewx; - tr_y = thingypos - viewy; + tr_x = interpx - viewx; + tr_y = interpy - viewy; basetz = tz = FixedMul(tr_x, viewcos) + FixedMul(tr_y, viewsin); // near/far distance @@ -1529,7 +1550,7 @@ static void R_ProjectSprite(mobj_t *thing) if (sprframe->rotate != SRF_SINGLE || papersprite) { - ang = R_PointToAngle (thingxpos, thingypos) - (thing->player ? thing->player->drawangle : thing->angle); + ang = R_PointToAngle (interpx, interpy) - interpangle; if (mirrored) ang = InvAngle(ang); } @@ -1544,7 +1565,7 @@ static void R_ProjectSprite(mobj_t *thing) else { // choose a different rotation based on player view - //ang = R_PointToAngle (thingxpos, thingypos) - thing->angle; + //ang = R_PointToAngle (interpx, interpy) - interpangle; if ((sprframe->rotate & SRF_RIGHT) && (ang < ANGLE_180)) // See from right rot = 6; // F7 slot @@ -1755,12 +1776,17 @@ static void R_ProjectSprite(mobj_t *thing) fixed_t linkscale; thing = thing->tracer; + if (cv_frameinterpolation.value == 1 && !paused) + { + interpx = thing->old_x + FixedMul(thing->x - thing->old_x, rendertimefrac); + interpy = thing->old_y + FixedMul(thing->y - thing->old_y, rendertimefrac); + } if (! R_ThingVisible(thing)) return; - tr_x = (thingxpos + sort_x) - viewx; - tr_y = (thingypos + sort_y) - viewy; + tr_x = (interpx + sort_x) - viewx; + tr_y = (interpy + sort_y) - viewy; tz = FixedMul(tr_x, viewcos) + FixedMul(tr_y, viewsin); linkscale = FixedDiv(projectiony[viewssnum], tz); @@ -1775,8 +1801,8 @@ static void R_ProjectSprite(mobj_t *thing) } else if (splat) { - tr_x = (thingxpos + sort_x) - viewx; - tr_y = (thingypos + sort_y) - viewy; + tr_x = (interpx + sort_x) - viewx; + tr_y = (interpy + sort_y) - viewy; sort_z = FixedMul(tr_x, viewcos) + FixedMul(tr_y, viewsin); sortscale = FixedDiv(projectiony[viewssnum], sort_z); } @@ -1796,7 +1822,7 @@ static void R_ProjectSprite(mobj_t *thing) if (x2 < portalclipstart || x1 >= portalclipend) return; - if (P_PointOnLineSide(thingxpos, thingypos, portalclipline) != 0) + if (P_PointOnLineSide(interpx, interpy, portalclipline) != 0) return; } @@ -1865,12 +1891,12 @@ static void R_ProjectSprite(mobj_t *thing) // When vertical flipped, draw sprites from the top down, at least as far as offsets are concerned. // sprite height - sprite topoffset is the proper inverse of the vertical offset, of course. // remember gz and gzt should be seperated by sprite height, not thing height - thing height can be shorter than the sprite itself sometimes! - gz = oldthingzpos + oldthing->height - FixedMul(spr_topoffset, FixedMul(spriteyscale, this_scale)); + gz = interpz + oldthing->height - FixedMul(spr_topoffset, FixedMul(spriteyscale, this_scale)); gzt = gz + FixedMul(spr_height, FixedMul(spriteyscale, this_scale)); } else { - gzt = oldthingzpos + FixedMul(spr_topoffset, FixedMul(spriteyscale, this_scale)); + gzt = interpz + FixedMul(spr_topoffset, FixedMul(spriteyscale, this_scale)); gz = gzt - FixedMul(spr_height, FixedMul(spriteyscale, this_scale)); } } @@ -1889,7 +1915,7 @@ static void R_ProjectSprite(mobj_t *thing) // R_GetPlaneLight won't work on sloped lights! for (lightnum = 1; lightnum < thing->subsector->sector->numlights; lightnum++) { - fixed_t h = P_GetLightZAt(&thing->subsector->sector->lightlist[lightnum], thingxpos, thingypos); + fixed_t h = P_GetLightZAt(&thing->subsector->sector->lightlist[lightnum], interpx, interpy); if (h <= top) { light = lightnum - 1; break; @@ -1915,12 +1941,12 @@ static void R_ProjectSprite(mobj_t *thing) if (heightsec != -1 && phs != -1) // only clip things which are in special sectors { if (viewz < sectors[phs].floorheight ? - thingzpos >= sectors[heightsec].floorheight : + interpz >= sectors[heightsec].floorheight : gzt < sectors[heightsec].floorheight) return; if (viewz > sectors[phs].ceilingheight ? gzt < sectors[heightsec].ceilingheight && viewz >= sectors[heightsec].ceilingheight : - thingzpos >= sectors[heightsec].ceilingheight) + interpz >= sectors[heightsec].ceilingheight) return; } @@ -1933,12 +1959,12 @@ static void R_ProjectSprite(mobj_t *thing) vis->sortscale = sortscale; vis->sortsplat = sortsplat; vis->dispoffset = dispoffset; // Monster Iestyn: 23/11/15 - vis->gx = thingxpos; - vis->gy = thingypos; + vis->gx = interpx; + vis->gy = interpy; vis->gz = gz; vis->gzt = gzt; vis->thingheight = thing->height; - vis->pz = thingzpos; + vis->pz = interpz; vis->pzt = vis->pz + vis->thingheight; vis->texturemid = FixedDiv(gzt - viewz, spriteyscale); vis->scalestep = scalestep; @@ -2073,9 +2099,22 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing) //SoM: 3/17/2000 fixed_t gz, gzt; + // uncapped/interpolation + fixed_t interpx = thing->x; + fixed_t interpy = thing->y; + fixed_t interpz = thing->z; + + // do interpolation + if (cv_frameinterpolation.value == 1 && !paused) + { + interpx = thing->old_x + FixedMul(rendertimefrac, thing->x - thing->old_x); + interpy = thing->old_y + FixedMul(rendertimefrac, thing->y - thing->old_y); + interpz = thing->old_z + FixedMul(rendertimefrac, thing->z - thing->old_z); + } + // transform the origin point - tr_x = thing->x - viewx; - tr_y = thing->y - viewy; + tr_x = interpx - viewx; + tr_y = interpy - viewy; tz = FixedMul(tr_x, viewcos) + FixedMul(tr_y, viewsin); // near/far distance @@ -2139,12 +2178,12 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing) if (x2 < portalclipstart || x1 >= portalclipend) return; - if (P_PointOnLineSide(thing->x, thing->y, portalclipline) != 0) + if (P_PointOnLineSide(interpx, interpy, portalclipline) != 0) return; } //SoM: 3/17/2000: Disregard sprites that are out of view.. - gzt = thing->z + spritecachedinfo[lump].topoffset; + gzt = interpz + spritecachedinfo[lump].topoffset; gz = gzt - spritecachedinfo[lump].height; if (thing->subsector->sector->cullheight) @@ -2157,10 +2196,13 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing) vis = R_NewVisSprite(); vis->scale = vis->sortscale = yscale; //<dispoffset = 0; // Monster Iestyn: 23/11/15 - vis->gx = thing->x; - vis->gy = thing->y; + vis->gx = interpx; + vis->gy = interpy; vis->gz = gz; vis->gzt = gzt; + vis->thingheight = 4*FRACUNIT; + vis->pz = interpz; + vis->pzt = vis->pz + vis->thingheight; vis->texturemid = vis->gzt - viewz; vis->scalestep = 0; vis->paperdistance = 0; diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index 2778e6b6f..71b5af958 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -181,7 +181,7 @@ static char returnWadPath[256]; #include "../m_argv.h" -#include "../m_menu.h" +#include "../r_main.h" // Frame interpolation/uncapped #ifdef MAC_ALERT #include "macosx/mac_alert.h" @@ -1640,17 +1640,29 @@ static Uint64 timer_frequency; static double tic_frequency; static Uint64 tic_epoch; +static double elapsed_tics; + +static void UpdateElapsedTics(void) +{ + const Uint64 now = SDL_GetPerformanceCounter(); + + elapsed_tics += (now - tic_epoch) / tic_frequency; + tic_epoch = now; // moving epoch +} tic_t I_GetTime(void) { - static double elapsed; + double f = 0.0; + UpdateElapsedTics(); + f = floor(elapsed_tics); + return (tic_t)f; +} - const Uint64 now = SDL_GetPerformanceCounter(); - - elapsed += (now - tic_epoch) / tic_frequency; - tic_epoch = now; // moving epoch - - return (tic_t)elapsed; +fixed_t I_GetTimeFrac(void) +{ + UpdateElapsedTics(); + + return FLOAT_TO_FIXED((float) (elapsed_tics - floor(elapsed_tics))); } precise_t I_GetPreciseTime(void) @@ -1672,6 +1684,7 @@ void I_StartupTimer(void) tic_epoch = SDL_GetPerformanceCounter(); tic_frequency = timer_frequency / (double)NEWTICRATE; + elapsed_tics = 0.0; } void I_Sleep(void) diff --git a/src/win32/win_sys.c b/src/win32/win_sys.c index 2609c3e31..9b2c5bd07 100644 --- a/src/win32/win_sys.c +++ b/src/win32/win_sys.c @@ -45,6 +45,7 @@ #include "../d_main.h" #include "../m_argv.h" +#include "../m_fixed.h" #include "../w_wad.h" #include "../z_zone.h" @@ -261,6 +262,11 @@ tic_t I_GetTime(void) return newtics; } +fixed_t I_GetTimeFrac(void) +{ + return 0; +} + void I_Sleep(void) { if (cv_sleep.value > 0) From 5325431450a0530dab3585d9d696e8bf48f77f71 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Mon, 29 Nov 2021 07:15:02 -0500 Subject: [PATCH 065/156] Fix crash on level load --- src/hardware/hw_main.c | 2 +- src/r_fps.c | 1 - src/r_things.c | 2 +- 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index c950e3b32..997978a31 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -5336,7 +5336,7 @@ static void HWR_ProjectSprite(mobj_t *thing) } heightsec = thing->subsector->sector->heightsec; - if (viewplayer->mo && viewplayer->mo->subsector) + if (viewplayer && viewplayer->mo && viewplayer->mo->subsector) phs = viewplayer->mo->subsector->sector->heightsec; else phs = -1; diff --git a/src/r_fps.c b/src/r_fps.c index ca1fa0852..c678c2519 100644 --- a/src/r_fps.c +++ b/src/r_fps.c @@ -20,7 +20,6 @@ #include "r_plane.h" #include "p_spec.h" #include "r_state.h" -#include "doomstat.h" // MAXSPLITSCREENPLAYERS #ifdef HWRENDER #include "hardware/hw_main.h" // for cv_glshearing #endif diff --git a/src/r_things.c b/src/r_things.c index 90a0cb2c9..6c9693d14 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1933,7 +1933,7 @@ static void R_ProjectSprite(mobj_t *thing) } heightsec = thing->subsector->sector->heightsec; - if (viewplayer->mo && viewplayer->mo->subsector) + if (viewplayer && viewplayer->mo && viewplayer->mo->subsector) phs = viewplayer->mo->subsector->sector->heightsec; else phs = -1; From f16b5673196c19e667013129bdcb59f043d78436 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Mon, 29 Nov 2021 07:23:04 -0500 Subject: [PATCH 066/156] Menu interpolation (`renderdeltatics`) `renderdeltatics` can be used as a standard delta time in any place, allowing for smooth menus. It will always be equal to `realtics` when frame interpolation is turned off, producing consistent framerate behavior everywhere it is used. Co-Authored-By: Eidolon --- src/d_main.c | 17 ++++++++++++++--- src/d_main.h | 1 - src/hardware/hw_main.c | 12 +++++------- src/r_main.c | 1 + src/r_main.h | 3 +++ 5 files changed, 23 insertions(+), 11 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index f611c4c3f..d24cc4b58 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -155,7 +155,6 @@ event_t events[MAXEVENTS]; INT32 eventhead, eventtail; boolean dedicated = false; -boolean tic_happened = false; // Frame interpolation/uncapped // // D_PostEvent @@ -773,13 +772,25 @@ void D_SRB2Loop(void) realtics = 1; // process tics (but maybe not if realtic == 0) - tic_happened = realtics ? true : false; TryRunTics(realtics); if (cv_frameinterpolation.value == 1) - rendertimefrac = I_GetTimeFrac(); + { + fixed_t entertimefrac = I_GetTimeFrac(); + // renderdeltatics is a bit awkard to evaluate, since the system time interface is whole tic-based + renderdeltatics = realtics * FRACUNIT; + if (entertimefrac > rendertimefrac) + renderdeltatics += entertimefrac - rendertimefrac; + else + renderdeltatics -= rendertimefrac - entertimefrac; + + rendertimefrac = entertimefrac; + } else + { rendertimefrac = FRACUNIT; + renderdeltatics = realtics * FRACUNIT; + } if (cv_frameinterpolation.value == 1) { diff --git a/src/d_main.h b/src/d_main.h index 26b5c4528..81de0634d 100644 --- a/src/d_main.h +++ b/src/d_main.h @@ -26,7 +26,6 @@ extern char srb2home[256]; //Alam: My Home extern boolean usehome; //Alam: which path? extern const char *pandf; //Alam: how to path? extern char srb2path[256]; //Alam: SRB2's Home -extern boolean tic_happened; // Frame interpolation/uncapped // the infinite loop of D_SRB2Loop() called from win_main for windows version void D_SRB2Loop(void) FUNCNORETURN; diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 997978a31..e3f56f831 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -6687,7 +6687,6 @@ INT32 HWR_GetTextureUsed(void) void HWR_DoPostProcessor(player_t *player) { postimg_t *type = &postimgtype[0]; - fixed_t fractime; SINT8 i; HWD.pfnUnSetShader(); @@ -6739,7 +6738,7 @@ void HWR_DoPostProcessor(player_t *player) // 10 by 10 grid. 2 coordinates (xy) float v[SCREENVERTS][SCREENVERTS][2]; static double disStart = 0; - static float last_fractime = 0; + static fixed_t last_fractime = 0; UINT8 x, y; INT32 WAVELENGTH; @@ -6772,16 +6771,15 @@ void HWR_DoPostProcessor(player_t *player) HWD.pfnPostImgRedraw(v); if (!(paused || P_AutoPause())) disStart += 1; - fractime = I_GetTimeFrac(); - if (tic_happened) + if (renderdeltatics > FRACUNIT) { - disStart = disStart - last_fractime + 1 + FIXED_TO_FLOAT(fractime); + disStart = disStart - FIXED_TO_FLOAT(last_fractime) + 1 + FIXED_TO_FLOAT(rendertimefrac); } else { - disStart = disStart - last_fractime + FIXED_TO_FLOAT(fractime); + disStart = disStart - FIXED_TO_FLOAT(last_fractime) + FIXED_TO_FLOAT(rendertimefrac); } - last_fractime = fractime; + last_fractime = rendertimefrac; // Capture the screen again for screen waving on the intermission if(gamestate != GS_INTERMISSION) diff --git a/src/r_main.c b/src/r_main.c index 6cb05801c..231bde280 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -81,6 +81,7 @@ mobj_t *r_viewmobj; int r_splitscreen; fixed_t rendertimefrac; +fixed_t renderdeltatics; // // precalculated math tables diff --git a/src/r_main.h b/src/r_main.h index 2ddec0ff1..a2acf60d9 100644 --- a/src/r_main.h +++ b/src/r_main.h @@ -33,7 +33,10 @@ extern fixed_t fovtan[MAXSPLITSCREENPLAYERS]; extern size_t validcount, linecount, loopcount, framecount; +// The fraction of a tic being drawn (for interpolation between two tics) extern fixed_t rendertimefrac; +// Evaluated delta tics for this frame (how many tics since the last frame) +extern fixed_t renderdeltatics;; // // Lighting LUT. From e2482edce31151900bc5f8a0d26130219b584eb1 Mon Sep 17 00:00:00 2001 From: Eidolon Date: Sun, 22 Dec 2019 01:16:57 -0600 Subject: [PATCH 067/156] Ensure viewsector is accurate to viewx/viewy This fixes a potential crash in OpenGL when changing between levels. --- src/r_fps.c | 39 ++++++++++++++------------------------- src/r_fps.h | 5 ----- 2 files changed, 14 insertions(+), 30 deletions(-) diff --git a/src/r_fps.c b/src/r_fps.c index c678c2519..2d2b4f61e 100644 --- a/src/r_fps.c +++ b/src/r_fps.c @@ -35,6 +35,16 @@ viewvars_t *newview = &pview_new[0]; enum viewcontext_e viewcontext = VIEWCONTEXT_PLAYER1; +static fixed_t R_LerpFixed(fixed_t from, fixed_t to, fixed_t frac) +{ + return FixedMul(frac, to - from); +} + +static angle_t R_LerpAngle(angle_t from, angle_t to, fixed_t frac) +{ + return FixedMul(frac, to - from); +} + // recalc necessary stuff for mouseaiming // slopes are already calculated for the full possible view (which is 4*viewheight). // 18/08/18: (No it's actually 16*viewheight, thanks Jimita for finding this out) @@ -78,6 +88,8 @@ void R_InterpolateView(fixed_t frac) if (FIXED_TO_FLOAT(frac) < 0) frac = 0; + if (frac > FRACUNIT) + frac = FRACUNIT; viewx = oldview->x + R_LerpFixed(oldview->x, newview->x, frac); viewy = oldview->y + R_LerpFixed(oldview->y, newview->y, frac); @@ -91,16 +103,8 @@ void R_InterpolateView(fixed_t frac) // this is gonna create some interesting visual errors for long distance teleports... // might want to recalculate the view sector every frame instead... - if (frac >= FRACUNIT) - { - viewplayer = newview->player; - viewsector = newview->sector; - } - else - { - viewplayer = oldview->player; - viewsector = oldview->sector; - } + viewplayer = newview->player; + viewsector = R_PointInSubsector(viewx, viewy)->sector; // well, this ain't pretty for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) @@ -157,18 +161,3 @@ void R_SetViewContext(enum viewcontext_e _viewcontext) break; } } - -fixed_t R_LerpFixed(fixed_t from, fixed_t to, fixed_t frac) -{ - return FixedMul(frac, to - from); -} - -INT32 R_LerpInt32(INT32 from, INT32 to, fixed_t frac) -{ - return FixedInt(FixedMul(frac, (to*FRACUNIT) - (from*FRACUNIT))); -} - -angle_t R_LerpAngle(angle_t from, angle_t to, fixed_t frac) -{ - return FixedMul(frac, to - from); -} diff --git a/src/r_fps.h b/src/r_fps.h index 24b79c922..2d4dbe874 100644 --- a/src/r_fps.h +++ b/src/r_fps.h @@ -55,9 +55,4 @@ void R_UpdateViewInterpolation(void); // Set the current view context (the viewvars pointed to by newview) void R_SetViewContext(enum viewcontext_e _viewcontext); -fixed_t R_LerpFixed(fixed_t from, fixed_t to, fixed_t frac); -INT32 R_LerpInt32(INT32 from, INT32 to, fixed_t frac); -UINT32 R_LerpUInt32(UINT32 from, UINT32 to, fixed_t frac); -angle_t R_LerpAngle(angle_t from, angle_t to, fixed_t frac); - #endif From f398004a1853e43773c34010ab304e0ea6c08320 Mon Sep 17 00:00:00 2001 From: Eidolon Date: Wed, 25 Dec 2019 20:00:21 -0600 Subject: [PATCH 068/156] Ensure + commands get executed before map start --- src/d_main.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/d_main.c b/src/d_main.c index d24cc4b58..52cd7b46c 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -1679,6 +1679,8 @@ void D_SRB2Main(void) // as having been modified for the first game. M_PushSpecialParameters(); // push all "+" parameter at the command buffer + COM_BufExecute(); // ensure the command buffer gets executed before the map starts (+skin) + strncpy(connectedservername, cv_servername.string, MAXSERVERNAME); if (M_CheckParm("-gametype") && M_IsNextParm()) From c43f8da5e635ba6400a82880b17f9d975ab98102 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Mon, 29 Nov 2021 08:20:27 -0500 Subject: [PATCH 069/156] P_SetOrigin & P_MoveOrigin to replace P_TeleportMove --- src/g_demo.c | 2 +- src/k_kart.c | 14 ++++++------ src/lua_baselib.c | 39 ++++++++++++++++++++++++++++++- src/lua_mobjlib.c | 2 +- src/m_cheat.c | 6 ++--- src/p_enemy.c | 34 +++++++++++++-------------- src/p_inter.c | 2 +- src/p_local.h | 3 ++- src/p_map.c | 29 ++++++++++++++++++++++-- src/p_mobj.c | 58 +++++++++++++++++++++++------------------------ src/p_telept.c | 2 +- 11 files changed, 127 insertions(+), 64 deletions(-) diff --git a/src/g_demo.c b/src/g_demo.c index 16ca2a859..08b9cddb3 100644 --- a/src/g_demo.c +++ b/src/g_demo.c @@ -1580,7 +1580,7 @@ void G_ReadMetalTic(mobj_t *metal) oldmetal.x = READFIXED(metal_p); oldmetal.y = READFIXED(metal_p); oldmetal.z = READFIXED(metal_p); - P_TeleportMove(metal, oldmetal.x, oldmetal.y, oldmetal.z); + P_MoveOrigin(metal, oldmetal.x, oldmetal.y, oldmetal.z); oldmetal.x = metal->x; oldmetal.y = metal->y; oldmetal.z = metal->z; diff --git a/src/k_kart.c b/src/k_kart.c index e8b424179..b88ace530 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -3754,7 +3754,7 @@ static mobj_t *K_SpawnKartMissile(mobj_t *source, mobjtype_t type, angle_t an, I { // floorz and ceilingz aren't properly set to account for FOFs and Polyobjects on spawn // This should set it for FOFs - P_TeleportMove(th, th->x, th->y, th->z); + P_SetOrigin(th, th->x, th->y, th->z); // spawn on the ground if the player is on the ground if (P_MobjFlip(source) < 0) { @@ -4717,7 +4717,7 @@ mobj_t *K_ThrowKartItem(player_t *player, boolean missile, mobjtype_t mapthing, { // floorz and ceilingz aren't properly set to account for FOFs and Polyobjects on spawn // This should set it for FOFs - P_TeleportMove(mo, mo->x, mo->y, mo->z); // however, THIS can fuck up your day. just absolutely ruin you. + P_SetOrigin(mo, mo->x, mo->y, mo->z); // however, THIS can fuck up your day. just absolutely ruin you. if (P_MobjWasRemoved(mo)) return NULL; @@ -5347,7 +5347,7 @@ void K_DropHnextList(player_t *player, boolean keepshields) { // floorz and ceilingz aren't properly set to account for FOFs and Polyobjects on spawn // This should set it for FOFs - //P_TeleportMove(dropwork, dropwork->x, dropwork->y, dropwork->z); -- handled better by above floorz/ceilingz passing + //P_SetOrigin(dropwork, dropwork->x, dropwork->y, dropwork->z); -- handled better by above floorz/ceilingz passing if (flip == 1) { @@ -5873,7 +5873,7 @@ static void K_MoveHeldObjects(player_t *player) z = player->mo->z + player->mo->height - cur->height; cur->flags |= MF_NOCLIPTHING; // temporarily make them noclip other objects so they can't hit anyone while in the player - P_TeleportMove(cur, player->mo->x, player->mo->y, z); + P_MoveOrigin(cur, player->mo->x, player->mo->y, z); cur->momx = FixedMul(FINECOSINE(cur->angle>>ANGLETOFINESHIFT), cur->extravalue1); cur->momy = FixedMul(FINESINE(cur->angle>>ANGLETOFINESHIFT), cur->extravalue1); cur->flags &= ~MF_NOCLIPTHING; @@ -5986,7 +5986,7 @@ static void K_MoveHeldObjects(player_t *player) P_SetObjectMomZ(cur, FixedMul(targz - cur->z, 7*FRACUNIT/8) - gravity, false); if (R_PointToDist2(cur->x, cur->y, targx, targy) > 768*FRACUNIT) - P_TeleportMove(cur, targx, targy, cur->z); + P_MoveOrigin(cur, targx, targy, cur->z); if (P_IsObjectOnGround(cur)) { @@ -6076,12 +6076,12 @@ static void K_MoveHeldObjects(player_t *player) diffy = targy - cur->y; diffz = targz - cur->z; - P_TeleportMove(cur->tracer, cur->tracer->x + diffx + P_ReturnThrustX(cur, cur->angle + angoffset, 6*cur->scale), + P_MoveOrigin(cur->tracer, cur->tracer->x + diffx + P_ReturnThrustX(cur, cur->angle + angoffset, 6*cur->scale), cur->tracer->y + diffy + P_ReturnThrustY(cur, cur->angle + angoffset, 6*cur->scale), cur->tracer->z + diffz); P_SetScale(cur->tracer, (cur->tracer->destscale = 3*cur->scale/4)); } - P_TeleportMove(cur, targx, targy, targz); + P_MoveOrigin(cur, targx, targy, targz); K_FlipFromObject(cur, player->mo); // Update graviflip in real time thanks. cur->roll = player->mo->roll; diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 0ce78b6f9..e07c41bd4 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -1415,7 +1415,42 @@ static int lib_pTeleportMove(lua_State *L) INLEVEL if (!thing) return LUA_ErrInvalid(L, "mobj_t"); - lua_pushboolean(L, P_TeleportMove(thing, x, y, z)); + LUA_Deprecated(L, "P_TeleportMove", "P_SetOrigin or P_MoveOrigin"); + lua_pushboolean(L, P_SetOrigin(thing, x, y, z)); + LUA_PushUserdata(L, tmthing, META_MOBJ); + P_SetTarget(&tmthing, ptmthing); + return 2; +} + +static int lib_pSetOrigin(lua_State *L) +{ + mobj_t *ptmthing = tmthing; + mobj_t *thing = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); + fixed_t x = luaL_checkfixed(L, 2); + fixed_t y = luaL_checkfixed(L, 3); + fixed_t z = luaL_checkfixed(L, 4); + NOHUD + INLEVEL + if (!thing) + return LUA_ErrInvalid(L, "mobj_t"); + lua_pushboolean(L, P_SetOrigin(thing, x, y, z)); + LUA_PushUserdata(L, tmthing, META_MOBJ); + P_SetTarget(&tmthing, ptmthing); + return 2; +} + +static int lib_pMoveOrigin(lua_State *L) +{ + mobj_t *ptmthing = tmthing; + mobj_t *thing = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); + fixed_t x = luaL_checkfixed(L, 2); + fixed_t y = luaL_checkfixed(L, 3); + fixed_t z = luaL_checkfixed(L, 4); + NOHUD + INLEVEL + if (!thing) + return LUA_ErrInvalid(L, "mobj_t"); + lua_pushboolean(L, P_MoveOrigin(thing, x, y, z)); LUA_PushUserdata(L, tmthing, META_MOBJ); P_SetTarget(&tmthing, ptmthing); return 2; @@ -3835,6 +3870,8 @@ static luaL_Reg lib[] = { {"P_TryMove",lib_pTryMove}, {"P_Move",lib_pMove}, {"P_TeleportMove",lib_pTeleportMove}, + {"P_SetOrigin",lib_pSetOrigin}, + {"P_MoveOrigin",lib_pMoveOrigin}, {"P_SlideMove",lib_pSlideMove}, {"P_BounceMove",lib_pBounceMove}, {"P_CheckSight", lib_pCheckSight}, diff --git a/src/lua_mobjlib.c b/src/lua_mobjlib.c index 0821cac6d..8a4a1e7a5 100644 --- a/src/lua_mobjlib.c +++ b/src/lua_mobjlib.c @@ -477,7 +477,7 @@ static int mobj_get(lua_State *L) } #define NOSET luaL_error(L, LUA_QL("mobj_t") " field " LUA_QS " should not be set directly.", mobj_opt[field]) -#define NOSETPOS luaL_error(L, LUA_QL("mobj_t") " field " LUA_QS " should not be set directly. Use " LUA_QL("P_Move") ", " LUA_QL("P_TryMove") ", or " LUA_QL("P_TeleportMove") " instead.", mobj_opt[field]) +#define NOSETPOS luaL_error(L, LUA_QL("mobj_t") " field " LUA_QS " should not be set directly. Use " LUA_QL("P_Move") ", " LUA_QL("P_TryMove") ", or " LUA_QL("P_SetOrigin") ", or " LUA_QL("P_MoveOrigin") " instead.", mobj_opt[field]) static int mobj_set(lua_State *L) { mobj_t *mo = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); diff --git a/src/m_cheat.c b/src/m_cheat.c index b45a7cbb6..384edbba2 100644 --- a/src/m_cheat.c +++ b/src/m_cheat.c @@ -420,7 +420,7 @@ void Command_RTeleport_f(void) CONS_Printf(M_GetText("Teleporting by %d, %d, %d...\n"), intx, inty, FixedInt((intz-p->mo->z))); P_MapStart(); - if (!P_TeleportMove(p->mo, p->mo->x+intx*FRACUNIT, p->mo->y+inty*FRACUNIT, intz)) + if (!P_SetOrigin(p->mo, p->mo->x+intx*FRACUNIT, p->mo->y+inty*FRACUNIT, intz)) CONS_Alert(CONS_WARNING, M_GetText("Unable to teleport to that spot!\n")); else S_StartSound(p->mo, sfx_mixup); @@ -641,7 +641,7 @@ void Command_Teleport_f(void) } P_MapStart(); - if (!P_TeleportMove(p->mo, intx, inty, intz)) + if (!P_SetOrigin(p->mo, intx, inty, intz)) CONS_Alert(CONS_WARNING, M_GetText("Unable to teleport to that spot!\n")); else S_StartSound(p->mo, sfx_mixup); @@ -1039,7 +1039,7 @@ void OP_ObjectplaceMovement(player_t *player) if (cmd->forwardmove != 0) { P_Thrust(player->mo, player->mo->angle, (cmd->forwardmove*player->mo->scale/MAXPLMOVE)*cv_speed.value); - P_TeleportMove(player->mo, player->mo->x+player->mo->momx, player->mo->y+player->mo->momy, player->mo->z); + P_MoveOrigin(player->mo, player->mo->x+player->mo->momx, player->mo->y+player->mo->momy, player->mo->z); player->mo->momx = player->mo->momy = 0; } diff --git a/src/p_enemy.c b/src/p_enemy.c index 9f5fc86d8..0befaa293 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -1145,7 +1145,7 @@ void A_FaceStabHurl(mobj_t *actor) hwork->destscale = FixedSqrt(step*basesize); P_SetScale(hwork, hwork->destscale); hwork->fuse = 2; - P_TeleportMove(hwork, actor->x + xo*(15-step), actor->y + yo*(15-step), actor->z + (actor->height - hwork->height)/2 + (P_MobjFlip(actor)*(8<x + xo*(15-step), actor->y + yo*(15-step), actor->z + (actor->height - hwork->height)/2 + (P_MobjFlip(actor)*(8<x + P_ReturnThrustX(actor, actor->angle, locvar1*crab->scale), crab->y + P_ReturnThrustY(actor, actor->angle, locvar1*crab->scale), crab->z + locvar2*crab->scale); @@ -2043,7 +2043,7 @@ void A_CrushclawLaunch(mobj_t *actor) fixed_t idx = dx, idy = dy, idz = dz; while (chain) { - P_TeleportMove(chain, actor->target->x + idx, actor->target->y + idy, actor->target->z + idz); + P_MoveOrigin(chain, actor->target->x + idx, actor->target->y + idy, actor->target->z + idz); chain->movefactor = chain->z; idx += dx; idy += dy; @@ -4023,7 +4023,7 @@ void A_AttractChase(mobj_t *actor) //P_SetScale(actor, (actor->destscale = actor->target->scale)); actor->z = actor->target->z; K_MatchGenericExtraFlags(actor, actor->target); - P_TeleportMove(actor, actor->target->x, actor->target->y, + P_MoveOrigin(actor, actor->target->x, actor->target->y, actor->z + ( actor->target->height + offz )* P_MobjFlip(actor)); actor->extravalue1++; @@ -4052,7 +4052,7 @@ void A_AttractChase(mobj_t *actor) P_SetScale(actor, (actor->destscale = actor->target->scale - ((actor->target->scale/14) * actor->extravalue1))); actor->z = actor->target->z; K_MatchGenericExtraFlags(actor, actor->target); - P_TeleportMove(actor, + P_MoveOrigin(actor, actor->target->x + FixedMul(dist, FINECOSINE(actor->angle >> ANGLETOFINESHIFT)), actor->target->y + FixedMul(dist, FINESINE(actor->angle >> ANGLETOFINESHIFT)), actor->z + actor->target->scale * 24 * P_MobjFlip(actor)); @@ -9911,7 +9911,7 @@ void A_VileAttack(mobj_t *actor) // move the fire between the vile and the player //fire->x = actor->target->x - FixedMul (24*FRACUNIT, finecosine[an]); //fire->y = actor->target->y - FixedMul (24*FRACUNIT, finesine[an]); - P_TeleportMove(fire, + P_MoveOrigin(fire, actor->target->x - P_ReturnThrustX(fire, actor->angle, FixedMul(24*FRACUNIT, fire->scale)), actor->target->y - P_ReturnThrustY(fire, actor->angle, FixedMul(24*FRACUNIT, fire->scale)), fire->z); @@ -9956,7 +9956,7 @@ void A_VileAttack(mobj_t *actor) // move the fire between the vile and the player //fire->x = actor->target->x - FixedMul (24*FRACUNIT, finecosine[an]); //fire->y = actor->target->y - FixedMul (24*FRACUNIT, finesine[an]); - P_TeleportMove(fire, + P_MoveOrigin(fire, actor->target->x - P_ReturnThrustX(fire, actor->angle, FixedMul(24*FRACUNIT, fire->scale)), actor->target->y - P_ReturnThrustY(fire, actor->angle, FixedMul(24*FRACUNIT, fire->scale)), fire->z); @@ -10629,13 +10629,13 @@ void A_FlickyCenter(mobj_t *actor) if (actor->target && P_AproxDistance(actor->target->x - originx, actor->target->y - originy) < actor->extravalue1) { actor->extravalue2 = 1; - P_TeleportMove(actor, actor->target->x, actor->target->y, actor->target->z); + P_SetOrigin(actor, actor->target->x, actor->target->y, actor->target->z); tmthing = NULL; } else if(actor->extravalue2) { actor->extravalue2 = 0; - P_TeleportMove(actor, originx, originy, originz); + P_SetOrigin(actor, originx, originy, originz); tmthing = NULL; } } @@ -11172,7 +11172,7 @@ void A_LightBeamReset(mobj_t *actor) actor->momy = (P_SignedRandom()*FINECOSINE(((actor->spawnpoint->angle*ANG1)>>ANGLETOFINESHIFT) & FINEMASK))/128; actor->momz = (P_SignedRandom()*FRACUNIT)/128; - P_TeleportMove(actor, + P_SetOrigin(actor, actor->spawnpoint->x*FRACUNIT - (P_SignedRandom()*FINESINE(((actor->spawnpoint->angle*ANG1)>>ANGLETOFINESHIFT) & FINEMASK))/2, actor->spawnpoint->y*FRACUNIT + (P_SignedRandom()*FINECOSINE(((actor->spawnpoint->angle*ANG1)>>ANGLETOFINESHIFT) & FINEMASK))/2, actor->spawnpoint->z*FRACUNIT + (P_SignedRandom()*FRACUNIT)/2); @@ -11757,7 +11757,7 @@ void A_DoNPCSkid(mobj_t *actor) actor->momy = (2*actor->momy)/3; } - P_TeleportMove(actor, x, y, z); + P_MoveOrigin(actor, x, y, z); // Spawn a particle every 3 tics. if (!(leveltime % 3)) @@ -12098,7 +12098,7 @@ void A_Boss5MakeJunk(mobj_t *actor) if (locvar1 > 0) P_SetMobjState(broked, locvar1); if (!P_MobjWasRemoved(broked)) - P_TeleportMove(broked, broked->x + broked->momx, broked->y + broked->momy, broked->z); + P_MoveOrigin(broked, broked->x + broked->momx, broked->y + broked->momy, broked->z); ang += ANGLE_45; } @@ -13161,7 +13161,7 @@ void A_DragonWing(mobj_t *actor) actor->angle = target->angle + actor->movedir; x = target->x + P_ReturnThrustX(actor, actor->angle, -target->radius); y = target->y + P_ReturnThrustY(actor, actor->angle, -target->radius); - P_TeleportMove(actor, x, y, target->z); + P_MoveOrigin(actor, x, y, target->z); } // Function: A_DragonSegment @@ -13202,7 +13202,7 @@ void A_DragonSegment(mobj_t *actor) zdist = P_ReturnThrustY(target, zangle, radius); actor->angle = hangle; - P_TeleportMove(actor, target->x + xdist, target->y + ydist, target->z + zdist); + P_MoveOrigin(actor, target->x + xdist, target->y + ydist, target->z + zdist); } // Function: A_ChangeHeight @@ -14164,10 +14164,10 @@ void A_LightningFollowPlayer(mobj_t *actor) { sx = actor->target->x + FixedMul((actor->target->scale*actor->extravalue1), FINECOSINE((actor->angle)>>ANGLETOFINESHIFT)); sy = actor->target->y + FixedMul((actor->target->scale*actor->extravalue1), FINESINE((actor->angle)>>ANGLETOFINESHIFT)); - P_TeleportMove(actor, sx, sy, actor->target->z); + P_MoveOrigin(actor, sx, sy, actor->target->z); } else // else just teleport to player directly - P_TeleportMove(actor, actor->target->x, actor->target->y, actor->target->z); + P_MoveOrigin(actor, actor->target->x, actor->target->y, actor->target->z); K_MatchGenericExtraFlags(actor, actor->target); // copy our target for graviflip actor->momx = actor->target->momx; @@ -14644,7 +14644,7 @@ void A_InvincSparkleRotate(mobj_t *actor) sx = actor->target->x + FixedMul((actor->movefactor), FINECOSINE((actor->angle)>>ANGLETOFINESHIFT)); sy = actor->target->y + FixedMul((actor->movefactor), FINESINE((actor->angle)>>ANGLETOFINESHIFT)); sz = actor->target->z + (actor->extravalue1) + FixedMul((actor->cvmem), FINECOSINE((leveltime*ANG1*10 + actor->angle)>>ANGLETOFINESHIFT)); - P_TeleportMove(actor, sx, sy, sz); + P_MoveOrigin(actor, sx, sy, sz); actor->momx = actor->target->momx; actor->momy = actor->target->momy; diff --git a/src/p_inter.c b/src/p_inter.c index e5df84913..0a2bb4e13 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -237,7 +237,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) if (!special->target) return; // foolproof crash prevention check!!!!! - P_TeleportMove(player->mo, special->target->x, special->target->y, special->target->z + (48<mo, special->target->x, special->target->y, special->target->z + (48<mo->angle = special->target->angle; P_SetObjectMomZ(player->mo, 12<mo, player->mo->angle, 20<old_x = thing->x; + thing->old_y = thing->y; + thing->old_z = thing->z; + } + + return result; +} + +// +// P_MoveOrigin - P_TeleportMove which KEEPS interpolation values. +// +boolean P_MoveOrigin(mobj_t *thing, fixed_t x, fixed_t y, fixed_t z) +{ + return P_TeleportMove(thing, x, y, z); +} + // ========================================================================= // MOVEMENT ITERATOR FUNCTIONS // ========================================================================= @@ -1598,7 +1623,7 @@ static boolean PIT_CheckLine(line_t *ld) cosradius = FixedMul(dist, FINECOSINE(langle>>ANGLETOFINESHIFT)); sinradius = FixedMul(dist, FINESINE(langle>>ANGLETOFINESHIFT)); tmthing->flags |= MF_NOCLIP; - P_TeleportMove(tmthing, result.x + cosradius - tmthing->momx, result.y + sinradius - tmthing->momy, tmthing->z); + P_MoveOrigin(tmthing, result.x + cosradius - tmthing->momx, result.y + sinradius - tmthing->momy, tmthing->z); tmthing->flags &= ~MF_NOCLIP; } #endif diff --git a/src/p_mobj.c b/src/p_mobj.c index e28c64a33..27c23ea92 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -3795,9 +3795,9 @@ static void P_ItemCapsulePartThinker(mobj_t *mobj) // rotate & move to capsule mobj->angle += mobj->movedir; if (mobj->flags2 & MF2_CLASSICPUSH) // centered - P_TeleportMove(mobj, target->x, target->y, z); + P_MoveOrigin(mobj, target->x, target->y, z); else - P_TeleportMove(mobj, + P_MoveOrigin(mobj, target->x + P_ReturnThrustX(mobj, mobj->angle + ANGLE_90, mobj->radius), target->y + P_ReturnThrustY(mobj, mobj->angle + ANGLE_90, mobj->radius), z); @@ -4216,7 +4216,7 @@ void P_Attract(mobj_t *source, mobj_t *dest, boolean nightsgrab) // Home in on y if (dist < source->movefactor) { source->momx = source->momy = source->momz = 0; - P_TeleportMove(source, tx, ty, tz); + P_MoveOrigin(source, tx, ty, tz); } else { @@ -6547,7 +6547,7 @@ static boolean P_MobjRegularThink(mobj_t *mobj) mobj->angle += ANGLE_90; } - P_TeleportMove(mobj, + P_MoveOrigin(mobj, mobj->target->x + P_ReturnThrustX(mobj, angle + ANGLE_180, nudge), mobj->target->y + P_ReturnThrustY(mobj, angle + ANGLE_180, nudge), mobj->target->z); @@ -6626,7 +6626,7 @@ static boolean P_MobjRegularThink(mobj_t *mobj) } mobj->angle = mobj->target->angle; - P_TeleportMove(mobj, mobj->target->x + P_ReturnThrustX(mobj, mobj->angle+ANGLE_180, mobj->target->radius), + P_MoveOrigin(mobj, mobj->target->x + P_ReturnThrustX(mobj, mobj->angle+ANGLE_180, mobj->target->radius), mobj->target->y + P_ReturnThrustY(mobj, mobj->angle+ANGLE_180, mobj->target->radius), mobj->target->z); P_SetScale(mobj, mobj->target->scale); @@ -6678,7 +6678,7 @@ static boolean P_MobjRegularThink(mobj_t *mobj) P_RemoveMobj(mobj); return false; } - P_TeleportMove(mobj, mobj->target->x, mobj->target->y, mobj->target->z); + P_MoveOrigin(mobj, mobj->target->x, mobj->target->y, mobj->target->z); break; case MT_BRAKEDRIFT: if ((!mobj->target || !mobj->target->health || !mobj->target->player || !P_IsObjectOnGround(mobj->target)) @@ -6699,7 +6699,7 @@ static boolean P_MobjRegularThink(mobj_t *mobj) newx = mobj->target->x + P_ReturnThrustX(mobj->target, travelangle+ANGLE_180, 24*mobj->target->scale); newy = mobj->target->y + P_ReturnThrustY(mobj->target, travelangle+ANGLE_180, 24*mobj->target->scale); - P_TeleportMove(mobj, newx, newy, mobj->target->z); + P_MoveOrigin(mobj, newx, newy, mobj->target->z); mobj->angle = travelangle - ((ANGLE_90/5)*mobj->target->player->drift); P_SetScale(mobj, (mobj->destscale = mobj->target->scale)); @@ -6728,7 +6728,7 @@ static boolean P_MobjRegularThink(mobj_t *mobj) { mobj->fuse = 9; } - P_TeleportMove(mobj, mobj->target->x, + P_MoveOrigin(mobj, mobj->target->x, mobj->target->y, mobj->target->z); mobj->angle = mobj->target->angle + mobj->cusval; break; @@ -6738,7 +6738,7 @@ static boolean P_MobjRegularThink(mobj_t *mobj) P_RemoveMobj(mobj); return false; } - P_TeleportMove(mobj, mobj->target->x, mobj->target->y, mobj->target->z); + P_MoveOrigin(mobj, mobj->target->x, mobj->target->y, mobj->target->z); break; case MT_INSTASHIELDB: mobj->renderflags ^= RF_DONTDRAW; @@ -6750,7 +6750,7 @@ static boolean P_MobjRegularThink(mobj_t *mobj) P_RemoveMobj(mobj); return false; } - P_TeleportMove(mobj, mobj->target->x, mobj->target->y, mobj->target->z); + P_MoveOrigin(mobj, mobj->target->x, mobj->target->y, mobj->target->z); K_MatchGenericExtraFlags(mobj, mobj->target); break; case MT_BATTLEPOINT: @@ -6773,7 +6773,7 @@ static boolean P_MobjRegularThink(mobj_t *mobj) mobj->movefactor = mobj->target->height; } K_MatchGenericExtraFlags(mobj, mobj->target); - P_TeleportMove(mobj, mobj->target->x, mobj->target->y, mobj->target->z + (mobj->target->height/2) + mobj->movefactor); + P_MoveOrigin(mobj, mobj->target->x, mobj->target->y, mobj->target->z + (mobj->target->height/2) + mobj->movefactor); break; case MT_RINGSPARKS: if (!mobj->target || P_MobjWasRemoved(mobj->target)) @@ -6786,7 +6786,7 @@ static boolean P_MobjRegularThink(mobj_t *mobj) K_MatchGenericExtraFlags(mobj, mobj->target); - P_TeleportMove(mobj, mobj->target->x + FINECOSINE(mobj->angle >> ANGLETOFINESHIFT), + P_MoveOrigin(mobj, mobj->target->x + FINECOSINE(mobj->angle >> ANGLETOFINESHIFT), mobj->target->y + FINESINE(mobj->angle >> ANGLETOFINESHIFT), mobj->z + (mobj->target->height * P_MobjFlip(mobj))); break; @@ -6807,7 +6807,7 @@ static boolean P_MobjRegularThink(mobj_t *mobj) K_MatchGenericExtraFlags(mobj, mobj->target); mobj->renderflags = (mobj->renderflags & ~RF_DONTDRAW)|K_GetPlayerDontDrawFlag(mobj->target->player); - P_TeleportMove(mobj, mobj->target->x + FixedMul(34 * mapobjectscale, FINECOSINE((mobj->angle + mobj->movedir) >> ANGLETOFINESHIFT)), + P_MoveOrigin(mobj, mobj->target->x + FixedMul(34 * mapobjectscale, FINECOSINE((mobj->angle + mobj->movedir) >> ANGLETOFINESHIFT)), mobj->target->y + FixedMul(34 * mapobjectscale, FINESINE((mobj->angle + mobj->movedir) >> ANGLETOFINESHIFT)), mobj->z + (32 * mapobjectscale * P_MobjFlip(mobj))); @@ -6850,7 +6850,7 @@ static boolean P_MobjRegularThink(mobj_t *mobj) fixed_t newx = mobj->target->x + P_ReturnThrustX(NULL, mobj->target->angle + perpendicular, 8*mobj->target->scale); fixed_t newy = mobj->target->y + P_ReturnThrustY(NULL, mobj->target->angle + perpendicular, 8*mobj->target->scale); - P_TeleportMove(mobj, newx, newy, mobj->target->z); + P_MoveOrigin(mobj, newx, newy, mobj->target->z); if (mobj->extravalue1 & 1) mobj->angle = mobj->target->angle - ANGLE_45; @@ -6888,7 +6888,7 @@ static boolean P_MobjRegularThink(mobj_t *mobj) else ang = (signed)(ang + off); - P_TeleportMove(mobj, + P_MoveOrigin(mobj, mobj->target->x - FixedMul(mobj->target->radius, FINECOSINE(ang >> ANGLETOFINESHIFT)), mobj->target->y - FixedMul(mobj->target->radius, FINESINE(ang >> ANGLETOFINESHIFT)), z); @@ -6943,7 +6943,7 @@ static boolean P_MobjRegularThink(mobj_t *mobj) desty = mobj->target->y; } - P_TeleportMove(mobj, destx, desty, mobj->target->z); + P_MoveOrigin(mobj, destx, desty, mobj->target->z); break; } case MT_BUBBLESHIELD: @@ -7071,7 +7071,7 @@ static boolean P_MobjRegularThink(mobj_t *mobj) desty = mobj->target->y; } - P_TeleportMove(mobj, destx, desty, mobj->target->z); + P_MoveOrigin(mobj, destx, desty, mobj->target->z); break; } case MT_FLAMESHIELD: @@ -7179,7 +7179,7 @@ static boolean P_MobjRegularThink(mobj_t *mobj) desty = mobj->target->y; } - P_TeleportMove(mobj, destx, desty, mobj->target->z); + P_MoveOrigin(mobj, destx, desty, mobj->target->z); mobj->angle = K_MomentumAngle(mobj->target); if (underlayst != S_NULL) @@ -7223,7 +7223,7 @@ static boolean P_MobjRegularThink(mobj_t *mobj) return false; } - P_TeleportMove(mobj, mobj->target->x, mobj->target->y, mobj->target->z); + P_MoveOrigin(mobj, mobj->target->x, mobj->target->y, mobj->target->z); mobj->angle = mobj->target->angle; mobj->scalespeed = mobj->target->scalespeed; mobj->destscale = mobj->target->destscale; @@ -7273,7 +7273,7 @@ static boolean P_MobjRegularThink(mobj_t *mobj) if (cur->lastlook == 2 || cur->lastlook == 3) offy *= -1; - P_TeleportMove(cur, mobj->x + offx, mobj->y + offy, mobj->z); + P_MoveOrigin(cur, mobj->x + offx, mobj->y + offy, mobj->z); cur->scalespeed = mobj->target->scalespeed; cur->destscale = mobj->target->destscale; P_SetScale(cur, mobj->target->scale); @@ -7412,7 +7412,7 @@ static boolean P_MobjRegularThink(mobj_t *mobj) amt += 1; } - P_TeleportMove( + P_MoveOrigin( cur, mobj->x + FixedMul(amt, FINECOSINE(dir >> ANGLETOFINESHIFT)), mobj->y + FixedMul(amt, FINESINE(dir >> ANGLETOFINESHIFT)), @@ -7502,7 +7502,7 @@ static boolean P_MobjRegularThink(mobj_t *mobj) while (cur && !P_MobjWasRemoved(cur)) { cur->angle += FixedAngle(mobj->info->speed); - P_TeleportMove(cur, mobj->x + FINECOSINE((cur->angle*8)>>ANGLETOFINESHIFT), + P_MoveOrigin(cur, mobj->x + FINECOSINE((cur->angle*8)>>ANGLETOFINESHIFT), mobj->y + FINESINE((cur->angle*8)>>ANGLETOFINESHIFT), mobj->z); //P_SpawnGhostMobj(cur)->tics = 2; @@ -7635,7 +7635,7 @@ static boolean P_MobjRegularThink(mobj_t *mobj) fixed_t wz = mobj->tracer->z + (joint * ((mobj->z + (mobj->height/2)) - mobj->tracer->z) / (numjoints+1)); if (cur && !P_MobjWasRemoved(cur)) - P_TeleportMove(cur, wx, wy, wz); + P_MoveOrigin(cur, wx, wy, wz); else cur = P_SpawnMobj(wx, wy, wz, MT_FROGTONGUE_JOINT); @@ -7746,7 +7746,7 @@ static boolean P_MobjRegularThink(mobj_t *mobj) continue; } else // Move into place - P_TeleportMove(cur, mobj->x, mobj->y, segz); + P_MoveOrigin(cur, mobj->x, mobj->y, segz); } else { @@ -7820,7 +7820,7 @@ static boolean P_MobjRegularThink(mobj_t *mobj) mobj->extravalue1 = 1; player->offroad += 2<mo->x + P_ReturnThrustX(NULL, player->mo->angle, player->mo->radius) + P_ReturnThrustX(NULL, player->mo->angle+ANGLE_90, (mobj->threshold)<mo->y + P_ReturnThrustY(NULL, player->mo->angle, player->mo->radius) @@ -7981,7 +7981,7 @@ static boolean P_MobjRegularThink(mobj_t *mobj) mobj->tracer->momx = mobj->tracer->momy = 0; } - P_TeleportMove(mobj, + P_MoveOrigin(mobj, mobj->tracer->x + P_ReturnThrustX(NULL, mobj->tracer->angle+ANGLE_90, (mobj->cvmem)<tracer->y + P_ReturnThrustY(NULL, mobj->tracer->angle+ANGLE_90, (mobj->cvmem)<tracer->z - (4*mobj->tracer->scale) + (P_RandomRange(-abs(mobj->cvmem), abs(mobj->cvmem))<angle = angle + ANGLE_90; } - P_TeleportMove(cur, newx, newy, newz); + P_MoveOrigin(cur, newx, newy, newz); cur = cur->hnext; } @@ -8350,7 +8350,7 @@ static boolean P_MobjRegularThink(mobj_t *mobj) mobj->extravalue1++; dist = mobj->extravalue1 * mapobjectscale; - P_TeleportMove(mobj, battleovertime.x + P_ReturnThrustX(NULL, ang, dist), + P_MoveOrigin(mobj, battleovertime.x + P_ReturnThrustX(NULL, ang, dist), battleovertime.y + P_ReturnThrustY(NULL, ang, dist), z); ghost = P_SpawnGhostMobj(mobj); @@ -9680,7 +9680,7 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) cur = P_SpawnMobj(mobj->x, mobj->y, mobj->z, MT_SMK_ICEBLOCK_SIDE); P_SetTarget(&cur->target, mobj); cur->threshold = i; - P_TeleportMove(cur, cur->x + ((cur->radius>>FRACBITS) * FINECOSINE((FixedAngle((90*cur->threshold)<>ANGLETOFINESHIFT) & FINEMASK)), + P_MoveOrigin(cur, cur->x + ((cur->radius>>FRACBITS) * FINECOSINE((FixedAngle((90*cur->threshold)<>ANGLETOFINESHIFT) & FINEMASK)), cur->y + ((cur->radius>>FRACBITS) * FINESINE((FixedAngle((90*cur->threshold)<>ANGLETOFINESHIFT) & FINEMASK)), cur->z); cur->angle = ANGLE_90*(cur->threshold+1); diff --git a/src/p_telept.c b/src/p_telept.c index 0c324c8c9..3e2917092 100644 --- a/src/p_telept.c +++ b/src/p_telept.c @@ -120,7 +120,7 @@ boolean P_Teleport(mobj_t *thing, fixed_t x, fixed_t y, fixed_t z, angle_t angle { UINT8 i; - if (!P_TeleportMove(thing, x, y, z)) + if (!P_SetOrigin(thing, x, y, z)) return false; if (!dontstopmove) From 5fea80c61b59f961cbfcbaa1bddaa949ecf6b2a1 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Mon, 29 Nov 2021 08:46:56 -0500 Subject: [PATCH 070/156] Apply interp to models, apply sprite world offsets properly --- src/hardware/hw_main.c | 46 +++++++++++++++++++++++++++++------------- src/hardware/hw_md2.c | 35 ++++++++++++++++++++++---------- src/r_things.c | 35 +++++++++++++++++++++++++------- 3 files changed, 84 insertions(+), 32 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index e3f56f831..b74bd71ea 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -3624,10 +3624,6 @@ static boolean HWR_DoCulling(line_t *cullheight, line_t *viewcullheight, float v static void HWR_DrawDropShadow(mobj_t *thing, fixed_t scale) { - fixed_t thingxpos = thing->x + thing->sprxoff; - fixed_t thingypos = thing->y + thing->spryoff; - fixed_t thingzpos = thing->z + thing->sprzoff; - patch_t *gpatch; FOutVector shadowVerts[4]; FSurfaceInfo sSurf; @@ -3644,7 +3640,19 @@ static void HWR_DrawDropShadow(mobj_t *thing, fixed_t scale) fixed_t slopez; pslope_t *groundslope; - // hitlag vibrating + fixed_t interpx = thing->x; + fixed_t interpy = thing->y; + fixed_t interpz = thing->z; + + // do interpolation + if (cv_frameinterpolation.value == 1 && !paused) + { + interpx = thing->old_x + FixedMul(rendertimefrac, thing->x - thing->old_x); + interpy = thing->old_y + FixedMul(rendertimefrac, thing->y - thing->old_y); + interpz = thing->old_z + FixedMul(rendertimefrac, thing->z - thing->old_z); + } + + // hitlag vibrating (todo: interp somehow?) if (thing->hitlag > 0 && (thing->eflags & MFE_DAMAGEHITLAG)) { fixed_t mul = thing->hitlag * (FRACUNIT / 10); @@ -3654,14 +3662,19 @@ static void HWR_DrawDropShadow(mobj_t *thing, fixed_t scale) mul = -mul; } - thingxpos += FixedMul(thing->momx, mul); - thingypos += FixedMul(thing->momy, mul); - thingzpos += FixedMul(thing->momz, mul); + interpx += FixedMul(thing->momx, mul); + interpy += FixedMul(thing->momy, mul); + interpz += FixedMul(thing->momz, mul); } + // sprite offset + interpx += thing->sprxoff; + interpy += thing->spryoff; + interpz += thing->sprzoff; + groundz = R_GetShadowZ(thing, &groundslope); - floordiff = abs((flip < 0 ? thing->height : 0) + thingzpos - groundz); + floordiff = abs((flip < 0 ? thing->height : 0) + interpz - groundz); alpha = floordiff / (4*FRACUNIT) + 75; if (alpha >= 255) return; @@ -3675,8 +3688,8 @@ static void HWR_DrawDropShadow(mobj_t *thing, fixed_t scale) scalemul = FixedMul(scalemul, (thing->radius*2) / gpatch->height); fscale = FIXED_TO_FLOAT(scalemul); - fx = FIXED_TO_FLOAT(thingxpos); - fy = FIXED_TO_FLOAT(thingypos); + fx = FIXED_TO_FLOAT(interpx); + fy = FIXED_TO_FLOAT(interpy); // 3--2 // | /| @@ -5067,9 +5080,9 @@ static void HWR_ProjectSprite(mobj_t *thing) dispoffset = thing->info->dispoffset; - interpx = thing->x + thing->sprxoff; - interpy = thing->y + thing->spryoff; - interpz = thing->z + thing->sprzoff; + interpx = thing->x; + interpy = thing->y; + interpz = thing->z; interpangle = mobjangle; if (cv_frameinterpolation.value == 1 && !paused) @@ -5095,6 +5108,11 @@ static void HWR_ProjectSprite(mobj_t *thing) interpz += FixedMul(thing->momz, mul); } + // sprite offset + interpx += thing->sprxoff; + interpy += thing->spryoff; + interpz += thing->sprzoff; + this_scale = FIXED_TO_FLOAT(thing->scale); spritexscale = FIXED_TO_FLOAT(thing->spritexscale); spriteyscale = FIXED_TO_FLOAT(thing->spriteyscale); diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index 4b8d1de6f..70c064081 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -1355,10 +1355,6 @@ boolean HWR_DrawModel(gl_vissprite_t *spr) // Look at HWR_ProjectSprite for more { - fixed_t thingxpos = spr->mobj->x + spr->mobj->sprxoff; - fixed_t thingypos = spr->mobj->y + spr->mobj->spryoff; - fixed_t thingzpos = spr->mobj->z + spr->mobj->sprzoff; - patch_t *gpatch, *blendgpatch; GLPatch_t *hwrPatch = NULL, *hwrBlendPatch = NULL; INT32 durs = spr->mobj->state->tics; @@ -1371,6 +1367,18 @@ boolean HWR_DrawModel(gl_vissprite_t *spr) INT32 mod; float finalscale; + fixed_t interpx = spr->mobj->x; + fixed_t interpy = spr->mobj->y; + fixed_t interpz = spr->mobj->z; + + // do interpolation + if (cv_frameinterpolation.value == 1 && !paused) + { + interpx = spr->mobj->old_x + FixedMul(rendertimefrac, spr->mobj->x - spr->mobj->old_x); + interpy = spr->mobj->old_y + FixedMul(rendertimefrac, spr->mobj->y - spr->mobj->old_y); + interpz = spr->mobj->old_z + FixedMul(rendertimefrac, spr->mobj->z - spr->mobj->old_z); + } + // hitlag vibrating if (spr->mobj->hitlag > 0 && (spr->mobj->eflags & MFE_DAMAGEHITLAG)) { @@ -1381,11 +1389,16 @@ boolean HWR_DrawModel(gl_vissprite_t *spr) mul = -mul; } - thingxpos += FixedMul(spr->mobj->momx, mul); - thingypos += FixedMul(spr->mobj->momy, mul); - thingzpos += FixedMul(spr->mobj->momz, mul); + interpx += FixedMul(spr->mobj->momx, mul); + interpy += FixedMul(spr->mobj->momy, mul); + interpy += FixedMul(spr->mobj->momz, mul); } + // sprite offset + interpx += spr->mobj->sprxoff; + interpy += spr->mobj->spryoff; + interpz += spr->mobj->sprzoff; + // Apparently people don't like jump frames like that, so back it goes //if (tics > durs) //durs = tics; @@ -1605,13 +1618,13 @@ boolean HWR_DrawModel(gl_vissprite_t *spr) #endif //Hurdler: it seems there is still a small problem with mobj angle - p.x = FIXED_TO_FLOAT(thingxpos); - p.y = FIXED_TO_FLOAT(thingypos) + md2->offset; + p.x = FIXED_TO_FLOAT(interpx); + p.y = FIXED_TO_FLOAT(interpy) + md2->offset; if (flip) p.z = FIXED_TO_FLOAT(spr->mobj->z + spr->mobj->height); else - p.z = FIXED_TO_FLOAT(thingzpos); + p.z = FIXED_TO_FLOAT(interpz); if (spr->mobj->skin && spr->mobj->sprite == SPR_PLAY) sprdef = &((skin_t *)spr->mobj->skin)->sprites[spr->mobj->sprite2]; @@ -1631,7 +1644,7 @@ boolean HWR_DrawModel(gl_vissprite_t *spr) } else { - const fixed_t anglef = AngleFixed((R_PointToAngle(thingxpos, thingypos))-ANGLE_180); + const fixed_t anglef = AngleFixed((R_PointToAngle(interpx, interpy))-ANGLE_180); p.angley = FIXED_TO_FLOAT(anglef); } diff --git a/src/r_things.c b/src/r_things.c index 6c9693d14..6d9cca7a4 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1363,10 +1363,6 @@ static void R_ProjectSprite(mobj_t *thing) { mobj_t *oldthing = thing; - //const fixed_t oldthingxpos = oldthing->x + oldthing->sprxoff; - //const fixed_t oldthingypos = oldthing->y + oldthing->spryoff; - //const fixed_t oldthingzpos = oldthing->z + oldthing->sprzoff; - fixed_t tr_x, tr_y; fixed_t tx, tz; fixed_t xscale, yscale; //added : 02-02-98 : aaargll..if I were a math-guy!!! @@ -1432,9 +1428,9 @@ static void R_ProjectSprite(mobj_t *thing) #endif // uncapped/interpolation - fixed_t interpx = thing->x + thing->sprxoff; - fixed_t interpy = thing->y + thing->spryoff; - fixed_t interpz = thing->z + thing->sprzoff; + fixed_t interpx = thing->x; + fixed_t interpy = thing->y; + fixed_t interpz = thing->z; angle_t interpangle = thing->angle; // use player drawangle if player @@ -1471,6 +1467,11 @@ static void R_ProjectSprite(mobj_t *thing) interpz += FixedMul(thing->momz, mul); } + // sprite offset + interpx += thing->sprxoff; + interpy += thing->spryoff; + interpz += thing->sprzoff; + // transform the origin point tr_x = interpx - viewx; tr_y = interpy - viewy; @@ -1782,6 +1783,26 @@ static void R_ProjectSprite(mobj_t *thing) interpy = thing->old_y + FixedMul(thing->y - thing->old_y, rendertimefrac); } + // hitlag vibrating (todo: interp somehow?) + if (thing->hitlag > 0 && (thing->eflags & MFE_DAMAGEHITLAG)) + { + fixed_t mul = thing->hitlag * (FRACUNIT / 10); + + if (leveltime & 1) + { + mul = -mul; + } + + interpx += FixedMul(thing->momx, mul); + interpy += FixedMul(thing->momy, mul); + interpz += FixedMul(thing->momz, mul); + } + + // sprite offset + interpx += thing->sprxoff; + interpy += thing->spryoff; + interpz += thing->sprzoff; + if (! R_ThingVisible(thing)) return; From 4b42f99ca75c3427da5149132a5d77f204f5c9a7 Mon Sep 17 00:00:00 2001 From: toaster Date: Mon, 29 Nov 2021 19:41:11 +0000 Subject: [PATCH 071/156] Fix player removal not being recorded in netreplays. (Will not work with existing replays that lack this data) --- src/d_clisrv.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 5b4141328..1bb3675cf 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -2390,6 +2390,7 @@ void CL_RemovePlayer(INT32 playernum, kickreason_t reason) // remove avatar of player playeringame[playernum] = false; + demo_extradata[playernum] |= DXD_PLAYSTATE; playernode[playernum] = UINT8_MAX; while (!playeringame[doomcom->numslots-1] && doomcom->numslots > 1) doomcom->numslots--; From 9e121958405b3b389d861667868e56a81e20d3a3 Mon Sep 17 00:00:00 2001 From: toaster Date: Mon, 29 Nov 2021 19:45:01 +0000 Subject: [PATCH 072/156] Fix two more minor issues with reading and writing replays. * DXD_PLAYSTATE and DXD_WEAPONPREF no longer conflict when both are read during the same tic. (VERY rare bug, but was possible) * Fixed G_WriteDemoTiccmd not considering the sign of forwardmove properly. (Of basically no consequence r/n, but could bite us down the line if not caught) --- src/g_demo.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/g_demo.c b/src/g_demo.c index eda590420..99e6e2622 100644 --- a/src/g_demo.c +++ b/src/g_demo.c @@ -308,9 +308,9 @@ void G_ReadDemoExtraData(void) } if (extradata & DXD_PLAYSTATE) { - extradata = READUINT8(demo_p); + i = READUINT8(demo_p); - switch (extradata) { + switch (i) { case DXD_PST_PLAYING: players[p].pflags |= PF_WANTSTOJOIN; // fuck you //CONS_Printf("player %s is despectating on tic %d\n", player_names[p], leveltime); @@ -350,11 +350,11 @@ void G_ReadDemoExtraData(void) } if (extradata & DXD_WEAPONPREF) { - extradata = READUINT8(demo_p); + i = READUINT8(demo_p); players[p].pflags &= ~(PF_KICKSTARTACCEL); - if (extradata & 1) + if (i & 1) players[p].pflags |= PF_KICKSTARTACCEL; - //CONS_Printf("weaponpref is %d for player %d\n", extradata, p); + //CONS_Printf("weaponpref is %d for player %d\n", i, p); } p = READUINT8(demo_p); @@ -500,6 +500,7 @@ void G_ReadDemoTiccmd(ticcmd_t *cmd, INT32 playernum) if (!demo_p || !demo.deferstart) return; + ziptic = READUINT8(demo_p); if (ziptic & ZT_FWD) @@ -537,7 +538,7 @@ void G_WriteDemoTiccmd(ticcmd_t *cmd, INT32 playernum) if (cmd->forwardmove != oldcmd[playernum].forwardmove) { - WRITEUINT8(demo_p,cmd->forwardmove); + WRITESINT8(demo_p,cmd->forwardmove); oldcmd[playernum].forwardmove = cmd->forwardmove; ziptic |= ZT_FWD; } From aaeaef5223efe520310d35ef19bf642319ba8082 Mon Sep 17 00:00:00 2001 From: James R Date: Mon, 29 Nov 2021 14:40:30 -0800 Subject: [PATCH 073/156] Do not set hu_stopped on interpolated frame --- src/d_clisrv.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 0f7227cb6..aa3ef2cd6 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -5264,12 +5264,14 @@ void TryRunTics(tic_t realtics) if (neededtic > gametic) { - hu_stopped = false; + if (realtics) + hu_stopped = false; } if (player_joining) { - hu_stopped = true; + if (realtics) + hu_stopped = true; return; } @@ -5307,7 +5309,8 @@ void TryRunTics(tic_t realtics) } else { - hu_stopped = true; + if (realtics) + hu_stopped = true; } } From 3d2ad0b95e90b864128511fa846c50625966cab3 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Mon, 29 Nov 2021 17:59:15 -0500 Subject: [PATCH 074/156] Fix water trails not interpolating properly --- src/p_user.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/p_user.c b/src/p_user.c index c58e61b4d..77d81df80 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -2115,6 +2115,9 @@ void P_MovePlayer(player_t *player) ((player->mo->eflags & MFE_VERTICALFLIP) ? player->mo->waterbottom - FixedMul(mobjinfo[MT_WATERTRAILUNDERLAY].height, player->mo->scale) : player->mo->watertop), MT_WATERTRAILUNDERLAY); water->angle = forwardangle - ANGLE_180 - ANGLE_22h; water->destscale = trailScale; + water->momx = player->mo->momx; + water->momy = player->mo->momy; + water->momz = player->mo->momz; P_SetScale(water, trailScale); P_SetMobjState(water, curUnderlayFrame); @@ -2123,6 +2126,9 @@ void P_MovePlayer(player_t *player) ((player->mo->eflags & MFE_VERTICALFLIP) ? player->mo->waterbottom - FixedMul(mobjinfo[MT_WATERTRAIL].height, player->mo->scale) : player->mo->watertop), MT_WATERTRAIL); water->angle = forwardangle - ANGLE_180 - ANGLE_22h; water->destscale = trailScale; + water->momx = player->mo->momx; + water->momy = player->mo->momy; + water->momz = player->mo->momz; P_SetScale(water, trailScale); P_SetMobjState(water, curOverlayFrame); @@ -2132,6 +2138,9 @@ void P_MovePlayer(player_t *player) ((player->mo->eflags & MFE_VERTICALFLIP) ? player->mo->waterbottom - FixedMul(mobjinfo[MT_WATERTRAILUNDERLAY].height, player->mo->scale) : player->mo->watertop), MT_WATERTRAILUNDERLAY); water->angle = forwardangle - ANGLE_180 + ANGLE_22h; water->destscale = trailScale; + water->momx = player->mo->momx; + water->momy = player->mo->momy; + water->momz = player->mo->momz; P_SetScale(water, trailScale); P_SetMobjState(water, curUnderlayFrame); @@ -2140,6 +2149,9 @@ void P_MovePlayer(player_t *player) ((player->mo->eflags & MFE_VERTICALFLIP) ? player->mo->waterbottom - FixedMul(mobjinfo[MT_WATERTRAIL].height, player->mo->scale) : player->mo->watertop), MT_WATERTRAIL); water->angle = forwardangle - ANGLE_180 + ANGLE_22h; water->destscale = trailScale; + water->momx = player->mo->momx; + water->momy = player->mo->momy; + water->momz = player->mo->momz; P_SetScale(water, trailScale); P_SetMobjState(water, curOverlayFrame); From f917c606377177ae064eda9ef0b569449d8145f2 Mon Sep 17 00:00:00 2001 From: James R Date: Mon, 29 Nov 2021 15:29:01 -0800 Subject: [PATCH 075/156] Remove MF_NOTHINK from sign pieces Without a thinker, interpolation doesn't change state. --- src/info.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/info.c b/src/info.c index c28c81dfd..c0268d075 100644 --- a/src/info.c +++ b/src/info.c @@ -9199,7 +9199,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = 0, // mass 0, // damage sfx_None, // activesound - MF_NOCLIP|MF_NOCLIPHEIGHT|MF_NOGRAVITY|MF_NOTHINK|MF_DONTENCOREMAP, // flags + MF_NOCLIP|MF_NOCLIPHEIGHT|MF_NOGRAVITY|MF_SCENERY|MF_DONTENCOREMAP, // flags S_NULL // raisestate }, From bea5d9dce71504226cd4d858d4b4ad21ff520cc2 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Mon, 29 Nov 2021 19:28:41 -0500 Subject: [PATCH 076/156] Fix trick timing efx in uncapped --- src/k_kart.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/k_kart.c b/src/k_kart.c index b88ace530..1e742ca60 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -8480,7 +8480,12 @@ static void K_trickPanelTimingVisual(player_t *player, fixed_t momz) flame->frame = i|FF_FULLBRIGHT; if (player->trickpanel <= 1 && !player->tumbleBounces) + { flame->tics = 2; + flame->momx = player->mo->momx; + flame->momy = player->mo->momy; + flame->momz = player->mo->momz; + } else { flame->tics = TICRATE; From c6bf534f29318aade93046e4c33b43986f9c3e3f Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Mon, 29 Nov 2021 20:00:41 -0500 Subject: [PATCH 077/156] HUD items with V_SLIDEIN interpolate --- src/k_hud.c | 7 ++++++- src/st_stuff.c | 4 ++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/k_hud.c b/src/k_hud.c index 0068bc836..e2224c579 100644 --- a/src/k_hud.c +++ b/src/k_hud.c @@ -761,9 +761,14 @@ void K_AdjustXYWithSnap(INT32 *x, INT32 *y, UINT32 options, INT32 dupx, INT32 du if (lt_exitticker < length) { - INT32 offset = screenwidth - ((lt_exitticker * screenwidth) / length); boolean slidefromright = false; + const INT32 offsetAmount = (screenwidth * FRACUNIT) / length; + fixed_t offset = (screenwidth * FRACUNIT) - (lt_exitticker * offsetAmount); + + offset += FixedMul(offsetAmount, renderdeltatics); + offset /= FRACUNIT; + if (r_splitscreen > 1) { if (stplyr == &players[displayplayers[1]] || stplyr == &players[displayplayers[3]]) diff --git a/src/st_stuff.c b/src/st_stuff.c index ee03a07a4..3e0788f4d 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -1260,6 +1260,7 @@ void ST_Drawer(void) if (rendermode != render_none) ST_doPaletteStuff(); { +#if 0 const tic_t length = TICRATE/2; if (lt_exitticker) @@ -1270,6 +1271,9 @@ void ST_Drawer(void) } else st_translucency = 0; +#else + st_translucency = cv_translucenthud.value; +#endif } // Check for a valid level title From c4ca097224a17bd9df790eddd91572d3fafd256f Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Mon, 29 Nov 2021 20:12:51 -0500 Subject: [PATCH 078/156] Interpolate minimap icons Was this completely unnecessary? Yes. Is it cool? Hell yeah --- src/k_hud.c | 58 +++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 50 insertions(+), 8 deletions(-) diff --git a/src/k_hud.c b/src/k_hud.c index e2224c579..ecce816ca 100644 --- a/src/k_hud.c +++ b/src/k_hud.c @@ -3046,6 +3046,7 @@ static void K_drawKartMinimap(void) SINT8 numlocalplayers = 0; INT32 hyu = hyudorotime; mobj_t *mobj, *next; // for SPB drawing (or any other item(s) we may wanna draw, I dunno!) + fixed_t interpx, interpy; // Draw the HUD only when playing in a level. // hu_stuff needs this, unlike st_stuff. @@ -3140,7 +3141,17 @@ static void K_drawKartMinimap(void) } else colormap = NULL; - K_drawKartMinimapIcon(g->mo->x, g->mo->y, x, y, splitflags, faceprefix[skin][FACE_MINIMAP], colormap, AutomapPic); + + interpx = g->mo->x; + interpy = g->mo->y; + + if (cv_frameinterpolation.value == 1 && !paused) + { + interpx = g->mo->old_x + FixedMul(rendertimefrac, g->mo->x - g->mo->old_x); + interpy = g->mo->old_y + FixedMul(rendertimefrac, g->mo->y - g->mo->old_y); + } + + K_drawKartMinimapIcon(interpx, interpy, x, y, splitflags, faceprefix[skin][FACE_MINIMAP], colormap, AutomapPic); g = g->next; } @@ -3196,11 +3207,22 @@ static void K_drawKartMinimap(void) else colormap = NULL; - K_drawKartMinimapIcon(players[i].mo->x, players[i].mo->y, x, y, splitflags, faceprefix[skin][FACE_MINIMAP], colormap, AutomapPic); + interpx = players[i].mo->x; + interpy = players[i].mo->y; + + if (cv_frameinterpolation.value == 1 && !paused) + { + interpx = players[i].mo->old_x + FixedMul(rendertimefrac, players[i].mo->x - players[i].mo->old_x); + interpy = players[i].mo->old_y + FixedMul(rendertimefrac, players[i].mo->y - players[i].mo->old_y); + } + + K_drawKartMinimapIcon(interpx, interpy, x, y, splitflags, faceprefix[skin][FACE_MINIMAP], colormap, AutomapPic); // Target reticule if ((gametype == GT_RACE && players[i].position == spbplace) - || (gametype == GT_BATTLE && K_IsPlayerWanted(&players[i]))) - K_drawKartMinimapIcon(players[i].mo->x, players[i].mo->y, x, y, splitflags, kp_wantedreticle, NULL, AutomapPic); + || (gametype == GT_BATTLE && K_IsPlayerWanted(&players[i]))) + { + K_drawKartMinimapIcon(interpx, interpy, x, y, splitflags, kp_wantedreticle, NULL, AutomapPic); + } } } @@ -3220,7 +3242,16 @@ static void K_drawKartMinimap(void) colormap = R_GetTranslationColormap(TC_RAINBOW, mobj->color, GTC_CACHE); } - K_drawKartMinimapIcon(mobj->x, mobj->y, x, y, splitflags, kp_spbminimap, colormap, AutomapPic); + interpx = mobj->x; + interpy = mobj->y; + + if (cv_frameinterpolation.value == 1 && !paused) + { + interpx = mobj->old_x + FixedMul(rendertimefrac, mobj->x - mobj->old_x); + interpy = mobj->old_y + FixedMul(rendertimefrac, mobj->y - mobj->old_y); + } + + K_drawKartMinimapIcon(interpx, interpy, x, y, splitflags, kp_spbminimap, colormap, AutomapPic); } } @@ -3248,12 +3279,23 @@ static void K_drawKartMinimap(void) else colormap = NULL; - K_drawKartMinimapIcon(players[localplayers[i]].mo->x, players[localplayers[i]].mo->y, x, y, splitflags, faceprefix[skin][FACE_MINIMAP], colormap, AutomapPic); + interpx = players[localplayers[i]].mo->x; + interpy = players[localplayers[i]].mo->y; + + if (cv_frameinterpolation.value == 1 && !paused) + { + interpx = players[localplayers[i]].mo->old_x + FixedMul(rendertimefrac, players[localplayers[i]].mo->x - players[localplayers[i]].mo->old_x); + interpy = players[localplayers[i]].mo->old_y + FixedMul(rendertimefrac, players[localplayers[i]].mo->y - players[localplayers[i]].mo->old_y); + } + + K_drawKartMinimapIcon(interpx, interpy, x, y, splitflags, faceprefix[skin][FACE_MINIMAP], colormap, AutomapPic); // Target reticule if ((gametype == GT_RACE && players[localplayers[i]].position == spbplace) - || (gametype == GT_BATTLE && K_IsPlayerWanted(&players[localplayers[i]]))) - K_drawKartMinimapIcon(players[localplayers[i]].mo->x, players[localplayers[i]].mo->y, x, y, splitflags, kp_wantedreticle, NULL, AutomapPic); + || (gametype == GT_BATTLE && K_IsPlayerWanted(&players[localplayers[i]]))) + { + K_drawKartMinimapIcon(interpx, interpy, x, y, splitflags, kp_wantedreticle, NULL, AutomapPic); + } } } From 8f11cd66038c7bf33acb35f4e902b10e22105e43 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Mon, 29 Nov 2021 20:18:17 -0500 Subject: [PATCH 079/156] Interpolate FINISH hud scroll --- src/k_hud.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/k_hud.c b/src/k_hud.c index ecce816ca..c530cdffc 100644 --- a/src/k_hud.c +++ b/src/k_hud.c @@ -3555,7 +3555,7 @@ static void K_drawKartFinish(void) //else -- 1/2p, scrolling FINISH { - INT32 x, xval; + INT32 x, xval, ox, interpx; if (r_splitscreen) // wide splitscreen pnum += 4; @@ -3563,11 +3563,14 @@ static void K_drawKartFinish(void) x = ((vid.width<width)<karthud[khud_cardanimation])*(xval > x ? xval : x))/TICRATE; + ox = ((TICRATE - (stplyr->karthud[khud_cardanimation] - 1))*(xval > x ? xval : x))/TICRATE; + + interpx = ox + FixedMul(rendertimefrac, x - ox); if (r_splitscreen && stplyr == &players[displayplayers[1]]) - x = -x; + interpx = -interpx; - V_DrawFixedPatch(x + (STCD_X<>1), + V_DrawFixedPatch(interpx + (STCD_X<>1), (STCD_Y<height)<<(FRACBITS-1)), FRACUNIT, splitflags, kp_racefinish[pnum], NULL); From e5244c7e8cfcbd60764eda858037c486f90d20ba Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Mon, 29 Nov 2021 20:36:17 -0500 Subject: [PATCH 080/156] Lap start HUD interpolates --- src/k_hud.c | 67 ++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 56 insertions(+), 11 deletions(-) diff --git a/src/k_hud.c b/src/k_hud.c index c530cdffc..589467bd6 100644 --- a/src/k_hud.c +++ b/src/k_hud.c @@ -3959,33 +3959,63 @@ static void K_drawChallengerScreen(void) static void K_drawLapStartAnim(void) { // This is an EVEN MORE insanely complicated animation. - const UINT8 progress = 80-stplyr->karthud[khud_lapanimation]; + const UINT8 t = stplyr->karthud[khud_lapanimation]; + const UINT8 progress = 80 - t; + + const UINT8 tOld = t - 1; + const UINT8 progressOld = 80 - tOld; + + const tic_t leveltimeOld = leveltime - 1; + UINT8 *colormap = R_GetTranslationColormap(TC_DEFAULT, stplyr->skincolor, GTC_CACHE); - V_DrawFixedPatch((BASEVIDWIDTH/2 + (32*max(0, stplyr->karthud[khud_lapanimation]-76)))*FRACUNIT, - (48 - (32*max(0, progress-76)))*FRACUNIT, + fixed_t interpx, interpy, newval, oldval; + + newval = (BASEVIDWIDTH/2 + (32 * max(0, t - 76))) * FRACUNIT; + oldval = (BASEVIDWIDTH/2 + (32 * max(0, tOld - 76))) * FRACUNIT; + interpx = oldval + FixedMul(rendertimefrac, newval - oldval); + + newval = (48 - (32 * max(0, progress - 76))) * FRACUNIT; + oldval = (48 - (32 * max(0, progressOld - 76))) * FRACUNIT; + interpy = oldval + FixedMul(rendertimefrac, newval - oldval); + + V_DrawFixedPatch( + interpx, interpy, FRACUNIT, V_SNAPTOTOP|V_HUDTRANS, (modeattacking ? kp_lapanim_emblem[1] : kp_lapanim_emblem[0]), colormap); if (stplyr->karthud[khud_laphand] >= 1 && stplyr->karthud[khud_laphand] <= 3) { - V_DrawFixedPatch((BASEVIDWIDTH/2 + (32*max(0, stplyr->karthud[khud_lapanimation]-76)))*FRACUNIT, - (48 - (32*max(0, progress-76)) - + 4 - abs((signed)((leveltime % 8) - 4)))*FRACUNIT, + newval = (4 - abs((signed)((leveltime % 8) - 4))) * FRACUNIT; + oldval = (4 - abs((signed)((leveltimeOld % 8) - 4))) * FRACUNIT; + interpy += oldval + FixedMul(rendertimefrac, newval - oldval); + + V_DrawFixedPatch( + interpx, interpy, FRACUNIT, V_SNAPTOTOP|V_HUDTRANS, kp_lapanim_hand[stplyr->karthud[khud_laphand]-1], NULL); } if (stplyr->laps == (UINT8)(cv_numlaps.value)) { - V_DrawFixedPatch((62 - (32*max(0, progress-76)))*FRACUNIT, // 27 + newval = (62 - (32 * max(0, progress - 76))) * FRACUNIT; + oldval = (62 - (32 * max(0, progressOld - 76))) * FRACUNIT; + interpx = oldval + FixedMul(rendertimefrac, newval - oldval); + + V_DrawFixedPatch( + interpx, // 27 30*FRACUNIT, // 24 FRACUNIT, V_SNAPTOTOP|V_HUDTRANS, kp_lapanim_final[min(progress/2, 10)], NULL); if (progress/2-12 >= 0) { - V_DrawFixedPatch((188 + (32*max(0, progress-76)))*FRACUNIT, // 194 + newval = (188 + (32 * max(0, progress - 76))) * FRACUNIT; + oldval = (188 + (32 * max(0, progressOld - 76))) * FRACUNIT; + interpx = oldval + FixedMul(rendertimefrac, newval - oldval); + + V_DrawFixedPatch( + interpx, // 194 30*FRACUNIT, // 24 FRACUNIT, V_SNAPTOTOP|V_HUDTRANS, kp_lapanim_lap[min(progress/2-12, 6)], NULL); @@ -3993,21 +4023,36 @@ static void K_drawLapStartAnim(void) } else { - V_DrawFixedPatch((82 - (32*max(0, progress-76)))*FRACUNIT, // 61 + newval = (82 - (32 * max(0, progress - 76))) * FRACUNIT; + oldval = (82 - (32 * max(0, progressOld - 76))) * FRACUNIT; + interpx = oldval + FixedMul(rendertimefrac, newval - oldval); + + V_DrawFixedPatch( + interpx, // 61 30*FRACUNIT, // 24 FRACUNIT, V_SNAPTOTOP|V_HUDTRANS, kp_lapanim_lap[min(progress/2, 6)], NULL); if (progress/2-8 >= 0) { - V_DrawFixedPatch((188 + (32*max(0, progress-76)))*FRACUNIT, // 194 + newval = (188 + (32 * max(0, progress - 76))) * FRACUNIT; + oldval = (188 + (32 * max(0, progressOld - 76))) * FRACUNIT; + interpx = oldval + FixedMul(rendertimefrac, newval - oldval); + + V_DrawFixedPatch( + interpx, // 194 30*FRACUNIT, // 24 FRACUNIT, V_SNAPTOTOP|V_HUDTRANS, kp_lapanim_number[(((UINT32)stplyr->laps) / 10)][min(progress/2-8, 2)], NULL); if (progress/2-10 >= 0) { - V_DrawFixedPatch((208 + (32*max(0, progress-76)))*FRACUNIT, // 221 + newval = (208 + (32 * max(0, progress - 76))) * FRACUNIT; + oldval = (208 + (32 * max(0, progressOld - 76))) * FRACUNIT; + interpx = oldval + FixedMul(rendertimefrac, newval - oldval); + + V_DrawFixedPatch( + interpx, // 221 30*FRACUNIT, // 24 FRACUNIT, V_SNAPTOTOP|V_HUDTRANS, kp_lapanim_number[(((UINT32)stplyr->laps) % 10)][min(progress/2-10, 2)], NULL); From a52dc0f8451c05285c2e2b6bf4182dff3c6e6404 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Mon, 29 Nov 2021 20:47:28 -0500 Subject: [PATCH 081/156] Copy interpolation data to afterimages --- src/p_user.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/p_user.c b/src/p_user.c index 77d81df80..2d849c312 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1138,6 +1138,11 @@ mobj_t *P_SpawnGhostMobj(mobj_t *mobj) ghost2->flags2 |= (mobj->player->followmobj->flags2 & MF2_LINKDRAW); } + // Copy interpolation data :) + ghost->old_x = mobj->old_x; + ghost->old_y = mobj->old_y; + ghost->old_z = mobj->old_z; + return ghost; } From 6457ab0a9cdd6f50d815e6d31a8f7918f21145f8 Mon Sep 17 00:00:00 2001 From: James R Date: Mon, 29 Nov 2021 19:56:33 -0800 Subject: [PATCH 082/156] Raise squish max --- src/k_kart.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/k_kart.c b/src/k_kart.c index 85b62c4c2..bd2f33220 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -4510,7 +4510,7 @@ void K_DriftDustHandling(mobj_t *spawner) void K_Squish(mobj_t *mo) { - const fixed_t maxstretch = 2*FRACUNIT; + const fixed_t maxstretch = 4*FRACUNIT; const fixed_t factor = 3 * mo->height / 2; const fixed_t threshold = factor / 6; From f19e8be3a00f55093e036c8added754ab6cd24a6 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Tue, 30 Nov 2021 14:03:56 -0500 Subject: [PATCH 083/156] Enable lagless cam I left it off because I think Kart intentionally removed it, but the reason we did might not apply anymore...? --- src/d_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/d_main.c b/src/d_main.c index 52cd7b46c..f185d7430 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -813,7 +813,7 @@ void D_SRB2Loop(void) } else if (rendertimeout < entertic) // in case the server hang or netsplit { -#if 0 +#if 1 // Lagless camera! Yay! if (gamestate == GS_LEVEL && netgame) { From 4a8222d397a41119ffb51e6a835f06be46531d8d Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Tue, 30 Nov 2021 14:28:27 -0500 Subject: [PATCH 084/156] Just set default renderdelta when paused Supports multiple pause types too --- src/d_main.c | 2 +- src/hardware/hw_main.c | 6 +++--- src/hardware/hw_md2.c | 2 +- src/r_things.c | 6 +++--- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index f185d7430..a220e0c34 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -774,7 +774,7 @@ void D_SRB2Loop(void) // process tics (but maybe not if realtic == 0) TryRunTics(realtics); - if (cv_frameinterpolation.value == 1) + if (cv_frameinterpolation.value == 1 && !(paused || P_AutoPause())) { fixed_t entertimefrac = I_GetTimeFrac(); // renderdeltatics is a bit awkard to evaluate, since the system time interface is whole tic-based diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index b74bd71ea..e605b6c66 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -3645,7 +3645,7 @@ static void HWR_DrawDropShadow(mobj_t *thing, fixed_t scale) fixed_t interpz = thing->z; // do interpolation - if (cv_frameinterpolation.value == 1 && !paused) + if (cv_frameinterpolation.value == 1) { interpx = thing->old_x + FixedMul(rendertimefrac, thing->x - thing->old_x); interpy = thing->old_y + FixedMul(rendertimefrac, thing->y - thing->old_y); @@ -5085,7 +5085,7 @@ static void HWR_ProjectSprite(mobj_t *thing) interpz = thing->z; interpangle = mobjangle; - if (cv_frameinterpolation.value == 1 && !paused) + if (cv_frameinterpolation.value == 1) { interpx = thing->old_x + FixedMul(rendertimefrac, thing->x - thing->old_x); interpy = thing->old_y + FixedMul(rendertimefrac, thing->y - thing->old_y); @@ -5515,7 +5515,7 @@ static void HWR_ProjectPrecipitationSprite(precipmobj_t *thing) interpz = thing->z; // do interpolation - if (cv_frameinterpolation.value == 1 && !paused) + if (cv_frameinterpolation.value == 1) { interpx = thing->old_x + FixedMul(rendertimefrac, thing->x - thing->old_x); interpy = thing->old_y + FixedMul(rendertimefrac, thing->y - thing->old_y); diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index 70c064081..aadb1b398 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -1372,7 +1372,7 @@ boolean HWR_DrawModel(gl_vissprite_t *spr) fixed_t interpz = spr->mobj->z; // do interpolation - if (cv_frameinterpolation.value == 1 && !paused) + if (cv_frameinterpolation.value == 1) { interpx = spr->mobj->old_x + FixedMul(rendertimefrac, spr->mobj->x - spr->mobj->old_x); interpy = spr->mobj->old_y + FixedMul(rendertimefrac, spr->mobj->y - spr->mobj->old_y); diff --git a/src/r_things.c b/src/r_things.c index 6d9cca7a4..f383d6d6a 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1437,7 +1437,7 @@ static void R_ProjectSprite(mobj_t *thing) if (thing->player) interpangle = thing->player->drawangle; // do interpolation - if (cv_frameinterpolation.value == 1 && !paused) + if (cv_frameinterpolation.value == 1) { interpx = thing->old_x + FixedMul(rendertimefrac, thing->x - thing->old_x); interpy = thing->old_y + FixedMul(rendertimefrac, thing->y - thing->old_y); @@ -1777,7 +1777,7 @@ static void R_ProjectSprite(mobj_t *thing) fixed_t linkscale; thing = thing->tracer; - if (cv_frameinterpolation.value == 1 && !paused) + if (cv_frameinterpolation.value == 1) { interpx = thing->old_x + FixedMul(thing->x - thing->old_x, rendertimefrac); interpy = thing->old_y + FixedMul(thing->y - thing->old_y, rendertimefrac); @@ -2126,7 +2126,7 @@ static void R_ProjectPrecipitationSprite(precipmobj_t *thing) fixed_t interpz = thing->z; // do interpolation - if (cv_frameinterpolation.value == 1 && !paused) + if (cv_frameinterpolation.value == 1) { interpx = thing->old_x + FixedMul(rendertimefrac, thing->x - thing->old_x); interpy = thing->old_y + FixedMul(rendertimefrac, thing->y - thing->old_y); From b716e142a8c715edfc1035a38e8aa3a3aebd7fdf Mon Sep 17 00:00:00 2001 From: toaster Date: Tue, 30 Nov 2021 21:24:00 +0000 Subject: [PATCH 085/156] Some fixes for bad player info on joining servers. * Don't overwrite the first player's name when joining with multiple local splitscreen players. (resolves #151) * The defaults for unprovided names are now consistently "Player A/B/C/D" as opposed to some being letter-based and some being number-based. * Send local player info once per local splitscreen player, rather than n^2 times (where n is the number of local splitscreen players). * Since the packet *requires* four names to be sent every time you join a server, send dummy names for local splitscreen players who aren't connecting, instead of your actual cvars (no data leakage you didn't ask for!) --- src/d_clisrv.c | 37 ++++++++++++++-------- src/d_netcmd.c | 86 +++++++++++++++++++++++++++----------------------- src/d_netcmd.h | 3 +- src/g_game.c | 1 - src/r_main.c | 4 --- 5 files changed, 72 insertions(+), 59 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 2148804df..e6fcb6643 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -795,10 +795,14 @@ static boolean CL_SendJoin(void) sizeof netbuffer->u.clientcfg.application); for (i = 0; i <= splitscreen; i++) - CleanupPlayerName(g_localplayers[i], cv_playername[i].zstring); - - for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) + { + // the MAXPLAYERS addition is necessary to communicate that g_localplayers is not yet safe to reference + CleanupPlayerName(MAXPLAYERS+i, cv_playername[i].zstring); strncpy(netbuffer->u.clientcfg.names[i], cv_playername[i].zstring, MAXPLAYERNAME); + } + // privacy shield for the local players not joining this session + for (; i < MAXSPLITSCREENPLAYERS; i++) + strncpy(netbuffer->u.clientcfg.names[i], va("Player %c", 'A' + i), MAXPLAYERNAME); return HSendPacket(servernode, false, 0, sizeof (clientconfig_pak)); } @@ -1334,7 +1338,7 @@ static void CL_ReloadReceivedSavegame(void) for (i = 0; i < MAXPLAYERS; i++) { LUA_InvalidatePlayer(&players[i]); - sprintf(player_names[i], "Player %d", i + 1); + sprintf(player_names[i], "Player %c", 'A' + i); } CL_LoadReceivedSavegame(true); @@ -2401,7 +2405,7 @@ void CL_RemovePlayer(INT32 playernum, kickreason_t reason) doomcom->numslots--; // Reset the name - sprintf(player_names[playernum], "Player %d", playernum+1); + sprintf(player_names[playernum], "Player %c", 'A' + playernum); player_name_changes[playernum] = 0; @@ -3213,7 +3217,7 @@ void SV_ResetServer(void) playeringame[i] = false; playernode[i] = UINT8_MAX; memset(playeraddress[i], 0, sizeof(*playeraddress)); - sprintf(player_names[i], "Player %d", i + 1); + sprintf(player_names[i], "Player %c", 'A' + i); adminplayers[i] = -1; // Populate the entire adminplayers array with -1. K_ClearClientPowerLevels(); splitscreen_invitations[i] = -1; @@ -3412,7 +3416,7 @@ static void Got_AddPlayer(UINT8 **p, INT32 playernum) P_ForceLocalAngle(newplayer, newplayer->angleturn); - D_SendPlayerConfig(); + D_SendPlayerConfig(splitscreenplayer); addedtogame = true; if (rejoined) @@ -3558,14 +3562,13 @@ static void Got_AddBot(UINT8 **p, INT32 playernum) LUAh_PlayerJoin(newplayernum); } -static boolean SV_AddWaitingPlayers(const char *name, const char *name2, const char *name3, const char *name4) +static boolean SV_AddWaitingPlayers(SINT8 node, const char *name, const char *name2, const char *name3, const char *name4) { - INT32 node, n, newplayer = false; + INT32 n, newplayernum; UINT8 buf[4 + MAXPLAYERNAME]; UINT8 *buf_p = buf; - INT32 newplayernum; + boolean newplayer = false; - for (node = 0; node < MAXNETNODES; node++) { // splitscreen can allow 2+ players in one node for (; nodewaiting[node] > 0; nodewaiting[node]--) @@ -3684,6 +3687,7 @@ boolean SV_SpawnServer(void) I_Error("What do you think you're doing?"); return false; #else + boolean result = false; if (demo.playback) G_StopDemo(); // reset engine parameter if (metalplayback) @@ -3710,7 +3714,14 @@ boolean SV_SpawnServer(void) else doomcom->numslots = 1; } - return SV_AddWaitingPlayers(cv_playername[0].zstring, cv_playername[1].zstring, cv_playername[2].zstring, cv_playername[3].zstring); + // strictly speaking, i'm not convinced the following is necessary + // but I'm not confident enough to remove it entirely in case it breaks something + { + SINT8 node = 0; + for (; node < MAXNETNODES; node++) + result |= SV_AddWaitingPlayers(node, cv_playername[0].zstring, cv_playername[1].zstring, cv_playername[2].zstring, cv_playername[3].zstring); + } + return result; #endif } @@ -3882,7 +3893,7 @@ static void HandleConnect(SINT8 node) SV_SendSaveGame(node, false); // send a complete game state DEBFILE("send savegame\n"); } - SV_AddWaitingPlayers(names[0], names[1], names[2], names[3]); + SV_AddWaitingPlayers(node, names[0], names[1], names[2], names[3]); joindelay += cv_joindelay.value * TICRATE; player_joining = true; } diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 4ed110f35..3524790f6 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -222,8 +222,6 @@ static void Command_KartGiveItem_f(void); // CLIENT VARIABLES // ========================================================================= -void SendWeaponPref(UINT8 n); - static CV_PossibleValue_t usemouse_cons_t[] = {{0, "Off"}, {1, "On"}, {2, "Force"}, {0, NULL}}; #ifdef LJOYSTICK @@ -1110,6 +1108,7 @@ boolean EnsurePlayerNameIsGood(char *name, INT32 playernum) * is restored to what it was before. * * We assume that if playernum is in ::g_localplayers + * (unless clientjoin is true, a necessary evil) * the console variable ::cv_playername[n] is * already set to newname. However, the player name table is assumed to * contain the old name. @@ -1128,6 +1127,10 @@ void CleanupPlayerName(INT32 playernum, const char *newname) char *tmpname = NULL; INT32 i; boolean namefailed = true; + boolean clientjoin = !!(playernum >= MAXPLAYERS); + + if (clientjoin) + playernum -= MAXPLAYERS; buf = Z_StrDup(newname); @@ -1185,17 +1188,20 @@ void CleanupPlayerName(INT32 playernum, const char *newname) } // no stealing another player's name - for (i = 0; i < MAXPLAYERS; i++) + if (!clientjoin) { - if (i != playernum && playeringame[i] - && strcasecmp(tmpname, player_names[i]) == 0) + for (i = 0; i < MAXPLAYERS; i++) { - break; + if (i != playernum && playeringame[i] + && strcasecmp(tmpname, player_names[i]) == 0) + { + break; + } } - } - if (i < MAXPLAYERS) - break; + if (i < MAXPLAYERS) + break; + } // name is okay then namefailed = false; @@ -1206,18 +1212,23 @@ void CleanupPlayerName(INT32 playernum, const char *newname) // set consvars whether namefailed or not, because even if it succeeded, // spaces may have been removed - for (i = 0; i <= splitscreen; i++) + if (clientjoin) + CV_StealthSet(&cv_playername[playernum], tmpname); + else { - if (playernum == g_localplayers[i]) + for (i = 0; i <= splitscreen; i++) { - CV_StealthSet(&cv_playername[i], tmpname); - break; + if (playernum == g_localplayers[i]) + { + CV_StealthSet(&cv_playername[i], tmpname); + break; + } } - } - if (i > splitscreen) - { - I_Assert(((void)"CleanupPlayerName used on non-local player", 0)); + if (i > splitscreen) + { + I_Assert(((void)"CleanupPlayerName used on non-local player", 0)); + } } Z_Free(buf); @@ -1811,33 +1822,28 @@ static void Got_LeaveParty(UINT8 **cp,INT32 playernum) } } -void D_SendPlayerConfig(void) +void D_SendPlayerConfig(UINT8 n) { - UINT8 i; + UINT8 buf[4]; + UINT8 *p = buf; - for (i = 0; i <= splitscreen; i++) + SendNameAndColor(n); + SendWeaponPref(n); + + if (n == 0) { - UINT8 buf[4]; - UINT8 *p = buf; - - SendNameAndColor(i); - SendWeaponPref(i); - - if (i == 0) - { - // Send it over - WRITEUINT16(p, vspowerlevel[PWRLV_RACE]); - WRITEUINT16(p, vspowerlevel[PWRLV_BATTLE]); - } - else - { - // Splitscreen players have invalid powerlevel - WRITEUINT16(p, 0); - WRITEUINT16(p, 0); - } - - SendNetXCmdForPlayer(i, XD_POWERLEVEL, buf, p-buf); + // Send it over + WRITEUINT16(p, vspowerlevel[PWRLV_RACE]); + WRITEUINT16(p, vspowerlevel[PWRLV_BATTLE]); } + else + { + // Splitscreen players have invalid powerlevel + WRITEUINT16(p, 0); + WRITEUINT16(p, 0); + } + + SendNetXCmdForPlayer(n, XD_POWERLEVEL, buf, p-buf); } // Only works for displayplayer, sorry! diff --git a/src/d_netcmd.h b/src/d_netcmd.h index 41dc3fdf7..0e8ef25e2 100644 --- a/src/d_netcmd.h +++ b/src/d_netcmd.h @@ -207,7 +207,8 @@ void D_RegisterServerCommands(void); void D_RegisterClientCommands(void); void CleanupPlayerName(INT32 playernum, const char *newname); boolean EnsurePlayerNameIsGood(char *name, INT32 playernum); -void D_SendPlayerConfig(void); +void SendWeaponPref(UINT8 n); +void D_SendPlayerConfig(UINT8 n); void Command_ExitGame_f(void); void Command_Retry_f(void); void D_GameTypeChanged(INT32 lastgametype); // not a real _OnChange function anymore diff --git a/src/g_game.c b/src/g_game.c index 000be94cd..e4fd7d209 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -346,7 +346,6 @@ static void kickstartaccel_OnChange(void); static void kickstartaccel2_OnChange(void); static void kickstartaccel3_OnChange(void); static void kickstartaccel4_OnChange(void); -void SendWeaponPref(UINT8 n); static CV_PossibleValue_t joyaxis_cons_t[] = {{0, "None"}, {1, "X-Axis"}, {2, "Y-Axis"}, {-1, "X-Axis-"}, {-2, "Y-Axis-"}, diff --git a/src/r_main.c b/src/r_main.c index 231bde280..cd9a6bf22 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -149,10 +149,6 @@ static void ChaseCam_OnChange(void); static void ChaseCam2_OnChange(void); static void ChaseCam3_OnChange(void); static void ChaseCam4_OnChange(void); -void SendWeaponPref(void); -void SendWeaponPref2(void); -void SendWeaponPref3(void); -void SendWeaponPref4(void); consvar_t cv_tailspickup = CVAR_INIT ("tailspickup", "On", CV_NETVAR|CV_NOSHOWHELP, CV_OnOff, NULL); consvar_t cv_chasecam[MAXSPLITSCREENPLAYERS] = { From 43356ca73eaf0c4cd49a2e90a41a8537a408eccb Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Tue, 30 Nov 2021 18:10:51 -0500 Subject: [PATCH 086/156] Nope, it actually just causes camera hitches even when alone, even if this fixes the problem its not the solution --- src/d_main.c | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index a220e0c34..425231347 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -813,20 +813,6 @@ void D_SRB2Loop(void) } else if (rendertimeout < entertic) // in case the server hang or netsplit { -#if 1 - // Lagless camera! Yay! - if (gamestate == GS_LEVEL && netgame) - { - INT32 i; - - for (i = 0; i <= r_splitscreen; i++) - { - if (camera[i].chase) - P_MoveChaseCamera(&players[displayplayers[i]], &camera[i], false); - } - } -#endif - // (Only display if not already done for frame interp) cv_frameinterpolation.value == 0 ? D_Display() : 0; From 87c31cb89fe6701298ce82fb221f1b7c954f8b32 Mon Sep 17 00:00:00 2001 From: lachablock Date: Wed, 1 Dec 2021 22:42:49 +1100 Subject: [PATCH 087/156] Fix drift clips suddenly inverting gravity --- src/p_mobj.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index 533eb8de7..491b371b3 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -2295,7 +2295,7 @@ boolean P_ZMovement(mobj_t *mo) S_StartSound(mo, sfx_tink); } else - mo->flags2 ^= RF_DONTDRAW; + mo->renderflags ^= RF_DONTDRAW; } else if (mo->type == MT_DEBTSPIKE) { From 6ecac4159a9f58eae87b1846c104419531a5a143 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Wed, 1 Dec 2021 06:45:02 -0500 Subject: [PATCH 088/156] This seems to fix the camera stuttering in netgames when I try it on my own Feel like this might be wrong so TRY IT first!! --- src/d_main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/d_main.c b/src/d_main.c index 425231347..b8fad8ec6 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -774,7 +774,7 @@ void D_SRB2Loop(void) // process tics (but maybe not if realtic == 0) TryRunTics(realtics); - if (cv_frameinterpolation.value == 1 && !(paused || P_AutoPause())) + if (cv_frameinterpolation.value == 1 && !(paused || P_AutoPause() || hu_stopped)) { fixed_t entertimefrac = I_GetTimeFrac(); // renderdeltatics is a bit awkard to evaluate, since the system time interface is whole tic-based From 55f48be6ab33a82f92628d2c602be5189db88057 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Wed, 1 Dec 2021 07:55:09 -0500 Subject: [PATCH 089/156] Missing parenthesis. --- src/k_kart.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/k_kart.c b/src/k_kart.c index 7364dab7a..73661c018 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -4973,7 +4973,7 @@ static void K_DoHyudoroSteal(player_t *player) // Has an item && (players[i].itemtype && players[i].itemamount - && !(players[i].pflags & PF_ITEMOUT)) + && !(players[i].pflags & PF_ITEMOUT))) { playerswappable[numplayers] = i; numplayers++; From 7238a1be837ada9b2e55eedccdf8edaca1592a8f Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Wed, 1 Dec 2021 10:53:15 -0500 Subject: [PATCH 090/156] Interpolate camera roll, fix skybox in opengl --- src/hardware/hw_main.c | 7 +++--- src/r_fps.c | 26 ++++++----------------- src/r_fps.h | 1 + src/r_main.c | 48 ++++++++++++++++++++++++------------------ src/r_state.h | 2 +- 5 files changed, 38 insertions(+), 46 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index e605b6c66..38fdd0e3c 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -5803,8 +5803,7 @@ static void HWR_DrawSkyBackground(player_t *player) dometransform.scalez = 1; dometransform.fovxangle = fpov; // Tails dometransform.fovyangle = fpov; // Tails - HWR_RollTransform(&dometransform, - R_ViewRollAngle(player)); + HWR_RollTransform(&dometransform, viewroll); dometransform.splitscreen = r_splitscreen; HWR_GetTexture(texturetranslation[skytexture]); @@ -6096,7 +6095,7 @@ void HWR_RenderSkyboxView(player_t *player) atransform.fovxangle = fpov; // Tails atransform.fovyangle = fpov; // Tails - HWR_RollTransform(&atransform, R_ViewRollAngle(player)); + HWR_RollTransform(&atransform, viewroll); atransform.splitscreen = r_splitscreen; gl_fovlud = (float)(1.0l/tan((double)(fpov*M_PIl/360l))); @@ -6308,7 +6307,7 @@ void HWR_RenderPlayerView(void) atransform.fovxangle = fpov; // Tails atransform.fovyangle = fpov; // Tails - HWR_RollTransform(&atransform, R_ViewRollAngle(player)); + HWR_RollTransform(&atransform, viewroll); atransform.splitscreen = r_splitscreen; gl_fovlud = (float)(1.0l/tan((double)(fpov*M_PIl/360l))); diff --git a/src/r_fps.c b/src/r_fps.c index 2d2b4f61e..fe1adb062 100644 --- a/src/r_fps.c +++ b/src/r_fps.c @@ -83,10 +83,7 @@ static void R_SetupFreelook(player_t *player, boolean skybox) void R_InterpolateView(fixed_t frac) { - boolean skybox = false; - INT32 i; - - if (FIXED_TO_FLOAT(frac) < 0) + if (frac < 0) frac = 0; if (frac > FRACUNIT) frac = FRACUNIT; @@ -97,31 +94,20 @@ void R_InterpolateView(fixed_t frac) viewangle = oldview->angle + R_LerpAngle(oldview->angle, newview->angle, frac); aimingangle = oldview->aim + R_LerpAngle(oldview->aim, newview->aim, frac); + viewroll = oldview->roll + R_LerpAngle(oldview->roll, newview->roll, frac); viewsin = FINESINE(viewangle>>ANGLETOFINESHIFT); viewcos = FINECOSINE(viewangle>>ANGLETOFINESHIFT); - // this is gonna create some interesting visual errors for long distance teleports... - // might want to recalculate the view sector every frame instead... viewplayer = newview->player; viewsector = R_PointInSubsector(viewx, viewy)->sector; - // well, this ain't pretty - for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) - { - if (newview == &skyview_new[i]) - { - skybox = true; - break; - } - } - - R_SetupFreelook(newview->player, skybox); + R_SetupFreelook(newview->player, newview->sky); } void R_UpdateViewInterpolation(void) { - INT32 i; + UINT8 i; for (i = 0; i < MAXSPLITSCREENPLAYERS; i++) { @@ -132,7 +118,7 @@ void R_UpdateViewInterpolation(void) void R_SetViewContext(enum viewcontext_e _viewcontext) { - INT32 i; + UINT8 i = 0; I_Assert(_viewcontext >= VIEWCONTEXT_PLAYER1 && _viewcontext <= VIEWCONTEXT_SKY4); @@ -149,7 +135,7 @@ void R_SetViewContext(enum viewcontext_e _viewcontext) newview = &pview_new[i]; break; case VIEWCONTEXT_SKY1: - case VIEWCONTEXT_SKY2: + case VIEWCONTEXT_SKY2:; case VIEWCONTEXT_SKY3: case VIEWCONTEXT_SKY4: i = viewcontext - VIEWCONTEXT_SKY1; diff --git a/src/r_fps.h b/src/r_fps.h index 2d4dbe874..eb674b142 100644 --- a/src/r_fps.h +++ b/src/r_fps.h @@ -41,6 +41,7 @@ typedef struct { angle_t angle; angle_t aim; + angle_t roll; fixed_t cos; fixed_t sin; mobj_t *mobj; diff --git a/src/r_main.c b/src/r_main.c index 231bde280..ea0d8482d 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -71,7 +71,7 @@ size_t framecount; size_t loopcount; fixed_t viewx, viewy, viewz; -angle_t viewangle, aimingangle; +angle_t viewangle, aimingangle, viewroll; UINT8 viewssnum; fixed_t viewcos, viewsin; sector_t *viewsector; @@ -656,7 +656,7 @@ void R_CheckViewMorph(int s) float fisheyemap[MAXVIDWIDTH/2 + 1]; #endif - angle_t rollangle = R_ViewRollAngle(&players[displayplayers[s]]); + angle_t rollangle = viewroll; #ifdef WOUGHMP_WOUGHMP fixed_t fisheye = cv_cam2_turnmultiplier.value; // temporary test value #endif @@ -1206,8 +1206,8 @@ subsector_t *R_PointInSubsectorOrNull(fixed_t x, fixed_t y) void R_SetupFrame(player_t *player) { camera_t *thiscam = &camera[0]; - boolean chasecam = false; - UINT8 i; + boolean chasecam = (cv_chasecam[0].value != 0); + UINT8 i = 0; for (i = 0; i <= r_splitscreen; i++) { @@ -1221,12 +1221,17 @@ void R_SetupFrame(player_t *player) } if (i > r_splitscreen) - return; // shouldn't be possible, but just in case + { + i = 0; // Shouldn't be possible, but just in case. + thiscam = &camera[0]; + chasecam = (cv_chasecam[0].value != 0); + R_SetViewContext(VIEWCONTEXT_PLAYER1); + } if (player->spectator) // no spectator chasecam chasecam = false; // force chasecam off - if (chasecam && !thiscam->chase) + if (chasecam && (thiscam && !thiscam->chase)) { P_ResetCamera(player, thiscam); thiscam->chase = true; @@ -1270,6 +1275,7 @@ void R_SetupFrame(player_t *player) newview->aim = localaiming[i]; } } + newview->roll = R_ViewRollAngle(player); newview->z += quake.z; newview->player = player; @@ -1302,7 +1308,7 @@ void R_SetupFrame(player_t *player) // newview->sin = FINESINE(viewangle>>ANGLETOFINESHIFT); // newview->cos = FINECOSINE(viewangle>>ANGLETOFINESHIFT); - R_InterpolateView(cv_frameinterpolation.value == 1 ? rendertimefrac : FRACUNIT); + R_InterpolateView(rendertimefrac); } void R_SkyboxFrame(player_t *player) @@ -1310,22 +1316,21 @@ void R_SkyboxFrame(player_t *player) camera_t *thiscam = &camera[0]; UINT8 i = 0; - if (r_splitscreen) + for (i = 0; i <= r_splitscreen; i++) { - for (i = 1; i <= r_splitscreen; i++) + if (player == &players[displayplayers[i]]) { - if (player == &players[displayplayers[i]]) - { - thiscam = &camera[i]; - R_SetViewContext(VIEWCONTEXT_SKY1 + i); - break; - } + thiscam = &camera[i]; + R_SetViewContext(VIEWCONTEXT_SKY1 + i); + break; } + } - if (i > r_splitscreen) - { - i = 0; - } + if (i > r_splitscreen) + { + i = 0; // Shouldn't be possible, but just in case. + thiscam = &camera[0]; + R_SetViewContext(VIEWCONTEXT_SKY1); } // cut-away view stuff @@ -1343,7 +1348,7 @@ void R_SkyboxFrame(player_t *player) newview->aim = player->awayviewaiming; newview->angle = player->awayviewmobj->angle; } - else if (thiscam->chase) + else if (thiscam && thiscam->chase) { newview->aim = thiscam->aiming; newview->angle = thiscam->angle; @@ -1359,6 +1364,7 @@ void R_SkyboxFrame(player_t *player) } } newview->angle += r_viewmobj->angle; + newview->roll = R_ViewRollAngle(player); newview->player = player; @@ -1445,7 +1451,7 @@ void R_SkyboxFrame(player_t *player) // newview->sin = FINESINE(viewangle>>ANGLETOFINESHIFT); // newview->cos = FINECOSINE(viewangle>>ANGLETOFINESHIFT); - R_InterpolateView(cv_frameinterpolation.value == 1 ? rendertimefrac : FRACUNIT); + R_InterpolateView(rendertimefrac); } boolean R_ViewpointHasChasecam(player_t *player) diff --git a/src/r_state.h b/src/r_state.h index cb55e2c2b..6f9008cc7 100644 --- a/src/r_state.h +++ b/src/r_state.h @@ -93,7 +93,7 @@ extern side_t *spawnsides; // POV data. // extern fixed_t viewx, viewy, viewz; -extern angle_t viewangle, aimingangle; +extern angle_t viewangle, aimingangle, viewroll; extern UINT8 viewssnum; // splitscreen view number extern boolean viewsky, skyVisible; extern boolean skyVisiblePerPlayer[MAXSPLITSCREENPLAYERS]; // saved values of skyVisible of each splitscreen player From 3e227654c7b5925db5a83ec40a4a34e8927ce2fe Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Wed, 1 Dec 2021 12:46:41 -0500 Subject: [PATCH 091/156] Little unneeded semicolon --- src/r_fps.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_fps.c b/src/r_fps.c index fe1adb062..7258d3b75 100644 --- a/src/r_fps.c +++ b/src/r_fps.c @@ -135,7 +135,7 @@ void R_SetViewContext(enum viewcontext_e _viewcontext) newview = &pview_new[i]; break; case VIEWCONTEXT_SKY1: - case VIEWCONTEXT_SKY2:; + case VIEWCONTEXT_SKY2: case VIEWCONTEXT_SKY3: case VIEWCONTEXT_SKY4: i = viewcontext - VIEWCONTEXT_SKY1; From 225590b7ba099348a013dcfc306ee5c9e77f4b48 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Wed, 1 Dec 2021 13:52:51 -0500 Subject: [PATCH 092/156] Draw framerate counter properly in uncapped --- src/i_system.h | 2 +- src/screen.c | 89 ++++++++++++++++++++++++++++++++++++++++------- src/screen.h | 3 ++ src/sdl/i_video.c | 2 ++ 4 files changed, 82 insertions(+), 14 deletions(-) diff --git a/src/i_system.h b/src/i_system.h index 4bc0e73da..789117eaa 100644 --- a/src/i_system.h +++ b/src/i_system.h @@ -56,7 +56,7 @@ precise_t I_GetPreciseTime(void); /** \brief Returns the difference between precise times as microseconds. */ -int I_PreciseToMicros(precise_t); +int I_PreciseToMicros(precise_t d); /** \brief The I_Sleep function diff --git a/src/screen.c b/src/screen.c index abc302748..ef5fa7769 100644 --- a/src/screen.c +++ b/src/screen.c @@ -453,9 +453,46 @@ boolean SCR_IsAspectCorrect(INT32 width, INT32 height) // XMOD FPS display // moved out of os-specific code for consistency -static boolean fpsgraph[TICRATE]; +static boolean ticsgraph[TICRATE]; static tic_t lasttic; +static UINT32 fpstime = 0; +static UINT32 lastupdatetime = 0; + +#define FPSUPDATERATE 1/20 // What fraction of a second to update at. The fraction will not simplify to 0, trust me. +#define FPSMAXSAMPLES 16 + +static UINT32 fpssamples[FPSMAXSAMPLES]; +static UINT32 fpssampleslen = 0; +static UINT32 fpssum = 0; +double aproxfps = 0.0f; + +void SCR_CalcAproxFps(void) +{ + tic_t i = 0; + if (I_PreciseToMicros(fpstime - lastupdatetime) > 1000000 * FPSUPDATERATE) + { + if (fpssampleslen == FPSMAXSAMPLES) + { + fpssum -= fpssamples[0]; + + for (i = 1; i < fpssampleslen; i++) + fpssamples[i-1] = fpssamples[i]; + } + else + fpssampleslen++; + + fpssamples[fpssampleslen-1] = I_GetPreciseTime() - fpstime; + fpssum += fpssamples[fpssampleslen-1]; + + aproxfps = 1000000 / (I_PreciseToMicros(fpssum) / (double)fpssampleslen); + + lastupdatetime = I_GetPreciseTime(); + } + + fpstime = I_GetPreciseTime(); +} + void SCR_DisplayTicRate(void) { tic_t i; @@ -464,25 +501,51 @@ void SCR_DisplayTicRate(void) const UINT8 *ticcntcolor = NULL; for (i = lasttic + 1; i < TICRATE+lasttic && i < ontic; ++i) - fpsgraph[i % TICRATE] = false; + ticsgraph[i % TICRATE] = false; - fpsgraph[ontic % TICRATE] = true; + ticsgraph[ontic % TICRATE] = true; for (i = 0;i < TICRATE;++i) - if (fpsgraph[i]) + if (ticsgraph[i]) ++totaltics; - if (totaltics <= TICRATE/2) ticcntcolor = R_GetTranslationColormap(TC_RAINBOW, SKINCOLOR_RASPBERRY, GTC_CACHE); - else if (totaltics == TICRATE) ticcntcolor = R_GetTranslationColormap(TC_RAINBOW, SKINCOLOR_MINT, GTC_CACHE); - // draw "FPS" V_DrawFixedPatch(306<= 60.0f) ticcntcolor = R_GetTranslationColormap(TC_RAINBOW, SKINCOLOR_MINT, GTC_CACHE); + + /* + if (cv_fpscap.value != 0) + { + // draw total frame: + //V_DrawPingNum(318, 190, V_SNAPTOBOTTOM|V_SNAPTORIGHT|V_HUDTRANS, cv_fpscap.value, ticcntcolor); + // draw "/" + //V_DrawFixedPatch(306<= TICRATE) ticcntcolor = R_GetTranslationColormap(TC_RAINBOW, SKINCOLOR_MINT, GTC_CACHE); + + // draw total frame: + V_DrawPingNum(318, 190, V_SNAPTOBOTTOM|V_SNAPTORIGHT|V_HUDTRANS, TICRATE, ticcntcolor); + // draw "/" + V_DrawFixedPatch(306< Date: Wed, 1 Dec 2021 15:51:57 -0500 Subject: [PATCH 093/156] Enable the thinker of NOTHINK... OK so we kind of need NOTHINK objects to still think because otherwise they can never update their interpolation values. This should probably replaced with some other kind of system, consider this temporary... (MF_NOTHINK is still mostly covered by a very early return in MobjThinker, if you're unaware, just means this might have to waste the extra time iterating through them...) --- src/p_mobj.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/p_mobj.c b/src/p_mobj.c index 533eb8de7..c70c9a2cc 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -9930,7 +9930,13 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) } } + // OK so we kind of need NOTHINK objects to still think + // because otherwise they can never update their + // interpolation values. They might need some other kind + // of system, so consider this temporary... +#if 0 if (!(mobj->flags & MF_NOTHINK)) +#endif P_AddThinker(THINK_MOBJ, &mobj->thinker); if (mobj->skin) // correct inadequecies above. From 83444ce5d583445c24f774f849e62dad93912080 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Wed, 1 Dec 2021 16:50:17 -0500 Subject: [PATCH 094/156] Interpolate angle & nametags --- src/d_player.h | 2 + src/hardware/hw_main.c | 17 +++++--- src/k_hud.c | 96 +++++++++++++++++++++++++++++++++++------- src/p_local.h | 4 ++ src/p_mobj.c | 12 ++++++ src/p_mobj.h | 2 + src/p_user.c | 22 +++++++--- src/r_things.c | 10 ++--- 8 files changed, 134 insertions(+), 31 deletions(-) diff --git a/src/d_player.h b/src/d_player.h index 0a406f785..e1ec7f2e8 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -312,6 +312,7 @@ typedef struct player_s fixed_t bob; angle_t viewrollangle; + angle_t old_viewrollangle; // camera tilt // TODO: expose to lua angle_t tilt; @@ -325,6 +326,7 @@ typedef struct player_s // fun thing for player sprite angle_t drawangle; + angle_t old_drawangle; // interp // Bit flags. // See pflags_t, above. diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 38fdd0e3c..ffb8ef521 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -5055,7 +5055,6 @@ static void HWR_ProjectSprite(mobj_t *thing) INT32 heightsec, phs; const boolean splat = R_ThingIsFloorSprite(thing); const boolean papersprite = (R_ThingIsPaperSprite(thing) && !splat); - angle_t mobjangle = (thing->player ? thing->player->drawangle : thing->angle); float z1, z2; fixed_t spr_width, spr_height; @@ -5083,14 +5082,22 @@ static void HWR_ProjectSprite(mobj_t *thing) interpx = thing->x; interpy = thing->y; interpz = thing->z; - interpangle = mobjangle; + interpangle = (thing->player ? thing->player->drawangle : thing->angle); if (cv_frameinterpolation.value == 1) { interpx = thing->old_x + FixedMul(rendertimefrac, thing->x - thing->old_x); interpy = thing->old_y + FixedMul(rendertimefrac, thing->y - thing->old_y); interpz = thing->old_z + FixedMul(rendertimefrac, thing->z - thing->old_z); - interpangle = mobjangle; + + if (thing->player) + { + interpangle = thing->player->old_drawangle + FixedMul(rendertimefrac, thing->player->drawangle - thing->player->old_drawangle); + } + else + { + interpangle = thing->old_angle + FixedMul(rendertimefrac, thing->angle - thing->old_angle); + } } // hitlag vibrating (todo: interp somehow?) @@ -5276,8 +5283,8 @@ static void HWR_ProjectSprite(mobj_t *thing) if (papersprite) { - rightsin = FIXED_TO_FLOAT(FINESINE((mobjangle)>>ANGLETOFINESHIFT)); - rightcos = FIXED_TO_FLOAT(FINECOSINE((mobjangle)>>ANGLETOFINESHIFT)); + rightsin = FIXED_TO_FLOAT(FINESINE((interpangle)>>ANGLETOFINESHIFT)); + rightcos = FIXED_TO_FLOAT(FINECOSINE((interpangle)>>ANGLETOFINESHIFT)); } else { diff --git a/src/k_hud.c b/src/k_hud.c index 589467bd6..b4ef2f32a 100644 --- a/src/k_hud.c +++ b/src/k_hud.c @@ -801,7 +801,7 @@ void K_ObjectTracking(trackingResult_t *result, vector3_t *point, UINT8 cameraNu player_t *player; fixed_t viewpointX, viewpointY, viewpointZ; - angle_t viewpointAngle, viewpointAiming; + angle_t viewpointAngle, viewpointAiming, viewpointRoll; INT32 screenWidth, screenHeight; fixed_t screenHalfW, screenHalfH; @@ -829,12 +829,13 @@ void K_ObjectTracking(trackingResult_t *result, vector3_t *point, UINT8 cameraNu cam = &camera[cameraNum]; player = &players[displayplayers[cameraNum]]; - if (cam == NULL || player == NULL) + if (cam == NULL || player == NULL || player->mo == NULL || P_MobjWasRemoved(player->mo) == true) { // Shouldn't be possible? return; } + // TODO: needs da interp if (cam->chase == true && !player->spectator) { // Use the camera's properties. @@ -843,26 +844,45 @@ void K_ObjectTracking(trackingResult_t *result, vector3_t *point, UINT8 cameraNu viewpointZ = cam->z - point->z; viewpointAngle = (INT32)cam->angle; viewpointAiming = (INT32)cam->aiming; + viewpointRoll = (INT32)player->viewrollangle; + + if (cv_frameinterpolation.value == 1) + { + viewpointX = cam->old_x + FixedMul(rendertimefrac, cam->x - cam->old_x); + viewpointY = cam->old_y + FixedMul(rendertimefrac, cam->y - cam->old_y); + viewpointZ = (cam->old_z + FixedMul(rendertimefrac, cam->z - cam->old_z)) - point->z; + + viewpointAngle = (INT32)(cam->old_angle + FixedMul(rendertimefrac, cam->angle - cam->old_angle)); + viewpointAiming = (INT32)(cam->old_aiming + FixedMul(rendertimefrac, cam->aiming - cam->old_aiming)); + viewpointRoll = (INT32)(player->old_viewrollangle + FixedMul(rendertimefrac, player->viewrollangle - player->old_viewrollangle)); + } } else { // Use player properties. - - if (player->mo == NULL || P_MobjWasRemoved(player->mo) == true) - { - // This shouldn't happen. - return; - } - viewpointX = player->mo->x; viewpointY = player->mo->y; viewpointZ = player->viewz - point->z; viewpointAngle = (INT32)player->mo->angle; viewpointAiming = (INT32)player->aiming; + viewpointRoll = (INT32)player->viewrollangle; + + if (cv_frameinterpolation.value == 1) + { + viewpointX = player->mo->old_x + FixedMul(rendertimefrac, player->mo->x - player->mo->old_x); + viewpointY = player->mo->old_y + FixedMul(rendertimefrac, player->mo->y - player->mo->old_y); + viewpointZ = (player->mo->old_z + FixedMul(rendertimefrac, player->viewz - player->mo->old_z)) - point->z; //player->old_viewz + + viewpointAngle = (INT32)(player->mo->old_angle + FixedMul(rendertimefrac, player->mo->angle - player->mo->old_angle)); + //viewpointAiming = (INT32)(player->mo->old_aiming + FixedMul(rendertimefrac, player->mo->aiming - player->mo->old_aiming)); + viewpointRoll = (INT32)(player->old_viewrollangle + FixedMul(rendertimefrac, player->viewrollangle - player->old_viewrollangle)); + } } viewpointAngle += (INT32)angleOffset; + (void)viewpointRoll; // will be used later... + // Calculate screen size adjustments. // TODO: Anyone want to make this support non-green resolutions somehow? :V screenWidth = BASEVIDWIDTH; @@ -2590,6 +2610,7 @@ static void K_drawKartPlayerCheck(void) UINT8 *colormap = NULL; UINT8 pnum = 0; vector3_t v; + vector3_t pPos; trackingResult_t result; if (!playeringame[i] || checkplayer->spectator) @@ -2614,7 +2635,22 @@ static void K_drawKartPlayerCheck(void) v.y = checkplayer->mo->y; v.z = checkplayer->mo->z; - distance = R_PointToDist2(stplyr->mo->x, stplyr->mo->y, v.x, v.y); + pPos.x = stplyr->mo->x; + pPos.y = stplyr->mo->y; + pPos.z = stplyr->mo->z; + + if (cv_frameinterpolation.value == 1) + { + v.x = checkplayer->mo->old_x + FixedMul(rendertimefrac, checkplayer->mo->x - checkplayer->mo->old_x); + v.y = checkplayer->mo->old_y + FixedMul(rendertimefrac, checkplayer->mo->y - checkplayer->mo->old_y); + v.z = checkplayer->mo->old_z + FixedMul(rendertimefrac, checkplayer->mo->z - checkplayer->mo->old_z); + + pPos.x = stplyr->mo->old_x + FixedMul(rendertimefrac, stplyr->mo->x - stplyr->mo->old_x); + pPos.y = stplyr->mo->old_y + FixedMul(rendertimefrac, stplyr->mo->y - stplyr->mo->old_y); + pPos.z = stplyr->mo->old_z + FixedMul(rendertimefrac, stplyr->mo->z - stplyr->mo->old_z); + } + + distance = R_PointToDist2(pPos.x, pPos.y, v.x, v.y); if (distance > maxdistance) { @@ -2801,12 +2837,26 @@ static void K_drawKartNameTags(void) c.x = thiscam->x; c.y = thiscam->y; c.z = thiscam->z; + + if (cv_frameinterpolation.value == 1) + { + c.x = thiscam->old_x + FixedMul(rendertimefrac, thiscam->x - thiscam->old_x); + c.y = thiscam->old_y + FixedMul(rendertimefrac, thiscam->y - thiscam->old_y); + c.z = thiscam->old_z + FixedMul(rendertimefrac, thiscam->z - thiscam->old_z); + } } else { c.x = stplyr->mo->x; c.y = stplyr->mo->y; c.z = stplyr->mo->z; + + if (cv_frameinterpolation.value == 1) + { + c.x = stplyr->mo->old_x + FixedMul(rendertimefrac, stplyr->mo->x - stplyr->mo->old_x); + c.y = stplyr->mo->old_y + FixedMul(rendertimefrac, stplyr->mo->y - stplyr->mo->old_y); + c.z = stplyr->mo->old_z + FixedMul(rendertimefrac, stplyr->mo->z - stplyr->mo->old_z); + } } for (i = 0; i < MAXPLAYERS; i++) @@ -2849,6 +2899,13 @@ static void K_drawKartNameTags(void) v.y = ntplayer->mo->y; v.z = ntplayer->mo->z; + if (cv_frameinterpolation.value == 1) + { + v.x = ntplayer->mo->old_x + FixedMul(rendertimefrac, ntplayer->mo->x - ntplayer->mo->old_x); + v.y = ntplayer->mo->old_y + FixedMul(rendertimefrac, ntplayer->mo->y - ntplayer->mo->old_y); + v.z = ntplayer->mo->old_z + FixedMul(rendertimefrac, ntplayer->mo->z - ntplayer->mo->old_z); + } + if (!(ntplayer->mo->eflags & MFE_VERTICALFLIP)) { v.z += ntplayer->mo->height; @@ -2904,7 +2961,16 @@ static void K_drawKartNameTags(void) v.x = ntplayer->mo->x; v.y = ntplayer->mo->y; - v.z = ntplayer->mo->z + (ntplayer->mo->height / 2); + v.z = ntplayer->mo->z; + + if (cv_frameinterpolation.value == 1) + { + v.x = ntplayer->mo->old_x + FixedMul(rendertimefrac, ntplayer->mo->x - ntplayer->mo->old_x); + v.y = ntplayer->mo->old_y + FixedMul(rendertimefrac, ntplayer->mo->y - ntplayer->mo->old_y); + v.z = ntplayer->mo->old_z + FixedMul(rendertimefrac, ntplayer->mo->z - ntplayer->mo->old_z); + } + + v.z += (ntplayer->mo->height / 2); if (stplyr->mo->eflags & MFE_VERTICALFLIP) { @@ -3145,7 +3211,7 @@ static void K_drawKartMinimap(void) interpx = g->mo->x; interpy = g->mo->y; - if (cv_frameinterpolation.value == 1 && !paused) + if (cv_frameinterpolation.value == 1) { interpx = g->mo->old_x + FixedMul(rendertimefrac, g->mo->x - g->mo->old_x); interpy = g->mo->old_y + FixedMul(rendertimefrac, g->mo->y - g->mo->old_y); @@ -3210,7 +3276,7 @@ static void K_drawKartMinimap(void) interpx = players[i].mo->x; interpy = players[i].mo->y; - if (cv_frameinterpolation.value == 1 && !paused) + if (cv_frameinterpolation.value == 1) { interpx = players[i].mo->old_x + FixedMul(rendertimefrac, players[i].mo->x - players[i].mo->old_x); interpy = players[i].mo->old_y + FixedMul(rendertimefrac, players[i].mo->y - players[i].mo->old_y); @@ -3245,7 +3311,7 @@ static void K_drawKartMinimap(void) interpx = mobj->x; interpy = mobj->y; - if (cv_frameinterpolation.value == 1 && !paused) + if (cv_frameinterpolation.value == 1) { interpx = mobj->old_x + FixedMul(rendertimefrac, mobj->x - mobj->old_x); interpy = mobj->old_y + FixedMul(rendertimefrac, mobj->y - mobj->old_y); @@ -3282,7 +3348,7 @@ static void K_drawKartMinimap(void) interpx = players[localplayers[i]].mo->x; interpy = players[localplayers[i]].mo->y; - if (cv_frameinterpolation.value == 1 && !paused) + if (cv_frameinterpolation.value == 1) { interpx = players[localplayers[i]].mo->old_x + FixedMul(rendertimefrac, players[localplayers[i]].mo->x - players[localplayers[i]].mo->old_x); interpy = players[localplayers[i]].mo->old_y + FixedMul(rendertimefrac, players[localplayers[i]].mo->y - players[localplayers[i]].mo->old_y); diff --git a/src/p_local.h b/src/p_local.h index 631920bb6..61a8cf3a0 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -112,6 +112,10 @@ typedef struct camera_s fixed_t pan; // SRB2Kart: camera pitches on slopes angle_t pitch; + + // Interpolation data + fixed_t old_x, old_y, old_z; + angle_t old_angle, old_aiming; } camera_t; // demo freecam or something before i commit die diff --git a/src/p_mobj.c b/src/p_mobj.c index c70c9a2cc..5a7c4d0d5 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -3661,6 +3661,9 @@ void P_PrecipThinker(precipmobj_t *mobj) mobj->old_x = mobj->x; mobj->old_y = mobj->y; mobj->old_z = mobj->z; + mobj->old_angle = mobj->angle; + mobj->old_pitch = mobj->pitch; + mobj->old_roll = mobj->roll; P_CycleStateAnimation((mobj_t *)mobj); @@ -8822,6 +8825,9 @@ void P_MobjThinker(mobj_t *mobj) mobj->old_x = mobj->x; mobj->old_y = mobj->y; mobj->old_z = mobj->z; + mobj->old_angle = mobj->angle; + mobj->old_pitch = mobj->pitch; + mobj->old_roll = mobj->roll; // Remove dead target/tracer. if (mobj->target && P_MobjWasRemoved(mobj->target)) @@ -9976,6 +9982,9 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type) mobj->old_x = mobj->x; mobj->old_y = mobj->y; mobj->old_z = mobj->z; + mobj->old_angle = mobj->angle; + mobj->old_pitch = mobj->pitch; + mobj->old_roll = mobj->roll; return mobj; } @@ -10032,6 +10041,9 @@ static precipmobj_t *P_SpawnPrecipMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype mobj->old_x = mobj->x; mobj->old_y = mobj->y; mobj->old_z = mobj->z; + mobj->old_angle = mobj->angle; + mobj->old_pitch = mobj->pitch; + mobj->old_roll = mobj->roll; return mobj; } diff --git a/src/p_mobj.h b/src/p_mobj.h index 3c7ab4367..2373bdca4 100644 --- a/src/p_mobj.h +++ b/src/p_mobj.h @@ -285,6 +285,7 @@ typedef struct mobj_s // More drawing info: to determine current sprite. angle_t angle, pitch, roll; // orientation + angle_t old_angle, old_pitch, old_roll; // orientation interpolation angle_t rollangle; spritenum_t sprite; // used to find patch_t and flip value UINT32 frame; // frame number, plus bits see p_pspr.h @@ -424,6 +425,7 @@ typedef struct precipmobj_s // More drawing info: to determine current sprite. angle_t angle, pitch, roll; // orientation + angle_t old_angle, old_pitch, old_roll; // orientation interpolation angle_t rollangle; spritenum_t sprite; // used to find patch_t and flip value UINT32 frame; // frame number, plus bits see p_pspr.h diff --git a/src/p_user.c b/src/p_user.c index c36ef75f0..4b857972d 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1145,6 +1145,9 @@ mobj_t *P_SpawnGhostMobj(mobj_t *mobj) ghost->old_x = mobj->old_x; ghost->old_y = mobj->old_y; ghost->old_z = mobj->old_z; + ghost->old_angle = (mobj->player ? mobj->player->old_drawangle : mobj->old_angle); + ghost->old_pitch = mobj->old_pitch; + ghost->old_roll = mobj->old_roll; return ghost; } @@ -2848,6 +2851,12 @@ boolean P_MoveChaseCamera(player_t *player, camera_t *thiscam, boolean resetcall subsector_t *newsubsec; #endif + thiscam->old_x = thiscam->x; + thiscam->old_y = thiscam->y; + thiscam->old_z = thiscam->z; + thiscam->old_angle = thiscam->angle; + thiscam->old_aiming = thiscam->aiming; + democam.soundmobj = NULL; // reset this each frame, we don't want the game crashing for stupid reasons now do we // We probably shouldn't move the camera if there is no player or player mobj somehow @@ -4160,6 +4169,9 @@ void P_PlayerThink(player_t *player) ticcmd_t *cmd; const size_t playeri = (size_t)(player - players); + player->old_drawangle = player->drawangle; + player->old_viewrollangle = player->viewrollangle; + #ifdef PARANOIA if (!player->mo) I_Error("p_playerthink: players[%s].mo == NULL", sizeu1(playeri)); @@ -4172,11 +4184,6 @@ void P_PlayerThink(player_t *player) player->playerstate = PST_DEAD; } - if (player->mo->hitlag > 0) - { - return; - } - if (player->awayviewmobj && P_MobjWasRemoved(player->awayviewmobj)) { P_SetTarget(&player->awayviewmobj, NULL); // remove awayviewmobj asap if invalid @@ -4192,6 +4199,11 @@ void P_PlayerThink(player_t *player) if (player->awayviewtics && player->awayviewtics != -1) player->awayviewtics--; + if (player->mo->hitlag > 0) + { + return; + } + // Track airtime if (P_IsObjectOnGround(player->mo)) { diff --git a/src/r_things.c b/src/r_things.c index f383d6d6a..2e50e732c 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -1431,10 +1431,7 @@ static void R_ProjectSprite(mobj_t *thing) fixed_t interpx = thing->x; fixed_t interpy = thing->y; fixed_t interpz = thing->z; - angle_t interpangle = thing->angle; - - // use player drawangle if player - if (thing->player) interpangle = thing->player->drawangle; + angle_t interpangle = (thing->player ? thing->player->drawangle : thing->angle); // do interpolation if (cv_frameinterpolation.value == 1) @@ -1442,13 +1439,14 @@ static void R_ProjectSprite(mobj_t *thing) interpx = thing->old_x + FixedMul(rendertimefrac, thing->x - thing->old_x); interpy = thing->old_y + FixedMul(rendertimefrac, thing->y - thing->old_y); interpz = thing->old_z + FixedMul(rendertimefrac, thing->z - thing->old_z); + if (thing->player) { - interpangle = thing->player->drawangle; + interpangle = thing->player->old_drawangle + FixedMul(rendertimefrac, thing->player->drawangle - thing->player->old_drawangle); } else { - interpangle = thing->angle; + interpangle = thing->old_angle + FixedMul(rendertimefrac, thing->angle - thing->old_angle); } } From 234403f1f2c8510bfb8dd52b6ae7086c518dca3b Mon Sep 17 00:00:00 2001 From: toaster Date: Thu, 2 Dec 2021 16:49:13 +0000 Subject: [PATCH 095/156] Fixed the bad merge that prevented non-transparent surfaces from rippling. --- src/r_plane.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/r_plane.c b/src/r_plane.c index 648a9ee01..8ec7e2b99 100644 --- a/src/r_plane.c +++ b/src/r_plane.c @@ -883,12 +883,12 @@ void R_DrawSinglePlane(visplane_t *pl) { INT32 top, bottom; + planeripple.active = true; if (spanfunctype == SPANDRAWFUNC_TRANS) { UINT8 i; spanfunctype = SPANDRAWFUNC_WATER; - planeripple.active = true; // Copy the current scene, ugh top = pl->high-8; From 2a74ee07f101e450fb30c6fd09e5524277aa8366 Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 5 Dec 2021 20:10:52 -0800 Subject: [PATCH 096/156] Update underwater physics - Reduce steering effect and remove increased friction. - Strafe into turns and tilt the inside wheels up. --- src/d_player.h | 2 ++ src/k_kart.c | 23 ++++++++++++++++++++--- src/k_kart.h | 1 + src/p_saveg.c | 4 ++++ src/p_user.c | 40 ++++++++++++++++++++++++++++++++++++++++ src/r_patchrotation.c | 6 +++++- 6 files changed, 72 insertions(+), 4 deletions(-) diff --git a/src/d_player.h b/src/d_player.h index 0a406f785..0578e0301 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -394,6 +394,8 @@ typedef struct player_s INT32 aizdrifttilt; INT32 aizdriftturn; + INT32 underwatertilt; + fixed_t offroad; // In Super Mario Kart, going offroad has lee-way of about 1 second before you start losing speed UINT8 waterskip; // Water skipping counter diff --git a/src/k_kart.c b/src/k_kart.c index 73661c018..a516f996b 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -7565,7 +7565,7 @@ static INT16 K_GetKartDriftValue(player_t *player, fixed_t countersteer) basedrift += (basedrift / greasetics) * player->tiregrease; } - if (player->mo->eflags & (MFE_UNDERWATER|MFE_TOUCHWATER)) + if (player->mo->eflags & (MFE_TOUCHWATER)) { countersteer = FixedMul(countersteer, 3*FRACUNIT/2); } @@ -7672,7 +7672,11 @@ INT16 K_GetKartTurnValue(player_t *player, INT16 turnvalue) turnfixed = FixedMul(turnfixed, FRACUNIT + player->handleboost); } - if (player->mo->eflags & (MFE_UNDERWATER|MFE_TOUCHWATER)) + if (player->mo->eflags & MFE_UNDERWATER) + { + turnfixed /= 2; + } + else if (player->mo->eflags & MFE_TOUCHWATER) { turnfixed = FixedMul(turnfixed, 3*FRACUNIT/2); } @@ -7683,6 +7687,19 @@ INT16 K_GetKartTurnValue(player_t *player, INT16 turnvalue) return (turnfixed / FRACUNIT); } +INT32 K_GetUnderwaterTurnAdjust(player_t *player) +{ + if (player->mo->eflags & MFE_UNDERWATER) + { + INT32 steer = (K_GetKartTurnValue(player, + player->steering) << TICCMD_REDUCE); + return FixedMul(steer, 8 * FixedDiv(player->speed, + 2 * K_GetKartSpeed(player, false) / 3)); + } + else + return 0; +} + INT32 K_GetKartDriftSparkValue(player_t *player) { return (26*4 + player->kartspeed*2 + (9 - player->kartweight))*8; @@ -8449,7 +8466,7 @@ void K_AdjustPlayerFriction(player_t *player) */ // Water gets ice physics too - if (player->mo->eflags & (MFE_UNDERWATER|MFE_TOUCHWATER)) + if (player->mo->eflags & MFE_TOUCHWATER) { player->mo->friction += 614; } diff --git a/src/k_kart.h b/src/k_kart.h index 8b0f755d6..af8751e6a 100644 --- a/src/k_kart.h +++ b/src/k_kart.h @@ -92,6 +92,7 @@ void K_UpdateDistanceFromFinishLine(player_t *const player); boolean K_CheckPlayersRespawnColliding(INT32 playernum, fixed_t x, fixed_t y); void K_UpdateSteeringValue(player_t *player, INT16 destSteering); INT16 K_GetKartTurnValue(player_t *player, INT16 turnvalue); +INT32 K_GetUnderwaterTurnAdjust(player_t *player); INT32 K_GetKartDriftSparkValue(player_t *player); INT32 K_StairJankFlip(INT32 value); INT32 K_GetKartDriftSparkValueForStage(player_t *player, UINT8 stage); diff --git a/src/p_saveg.c b/src/p_saveg.c index 83625026d..39a4fec28 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -239,6 +239,8 @@ static void P_NetArchivePlayers(void) WRITEINT32(save_p, players[i].aizdrifttilt); WRITEINT32(save_p, players[i].aizdriftturn); + WRITEINT32(save_p, players[i].underwatertilt); + WRITEFIXED(save_p, players[i].offroad); WRITEUINT8(save_p, players[i].waterskip); @@ -495,6 +497,8 @@ static void P_NetUnArchivePlayers(void) players[i].aizdrifttilt = READINT32(save_p); players[i].aizdriftturn = READINT32(save_p); + players[i].underwatertilt = READINT32(save_p); + players[i].offroad = READFIXED(save_p); players[i].waterskip = READUINT8(save_p); diff --git a/src/p_user.c b/src/p_user.c index c36ef75f0..9c1e87a53 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1769,6 +1769,42 @@ static void P_3dMovement(player_t *player) if (player->mo->movefactor != FRACUNIT) // Friction-scaled acceleration... movepushforward = FixedMul(movepushforward, player->mo->movefactor); + { + INT32 a = K_GetUnderwaterTurnAdjust(player); + INT32 adj = 0; + + if (a) + { + adj = a / 4; + + if (abs(player->underwatertilt + adj) > abs(a)) + adj = (a - player->underwatertilt); + + if (abs(a) < abs(player->underwatertilt)) + adj = 0; + + movepushangle += a; + } + + if (adj) + { + player->underwatertilt += adj; + + if (abs(player->underwatertilt) > ANG30) + { + player->underwatertilt = + player->underwatertilt > 0 ? ANG30 + : -(ANG30); + } + } + else + { + player->underwatertilt = + FixedMul(player->underwatertilt, + 7*FRACUNIT/8); + } + } + totalthrust.x += P_ReturnThrustX(player->mo, movepushangle, movepushforward); totalthrust.y += P_ReturnThrustY(player->mo, movepushangle, movepushforward); } @@ -2055,6 +2091,10 @@ void P_MovePlayer(player_t *player) else if (player->drift != 0) { INT32 a = (ANGLE_45 / 5) * player->drift; + + if (player->mo->eflags & MFE_UNDERWATER) + a /= 2; + player->drawangle += a; } } diff --git a/src/r_patchrotation.c b/src/r_patchrotation.c index 3744dfce2..24c1de5d2 100644 --- a/src/r_patchrotation.c +++ b/src/r_patchrotation.c @@ -42,7 +42,11 @@ static angle_t R_PlayerSpriteRotation(player_t *player, player_t *viewPlayer) angle_t rollAngle = 0; - if (sliptideLift) + if (player->mo->eflags & MFE_UNDERWATER) + { + rollAngle -= player->underwatertilt; + } + else if (sliptideLift) { /* (from side) tilt downward if turning toward camera, upward if away. */ From aebe6dd59ca61b485851c333f639a0dcb6c16876 Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 5 Dec 2021 20:13:20 -0800 Subject: [PATCH 097/156] Don't apply shallow water effects while in offroad --- src/k_kart.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index a516f996b..40ca0ca8f 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -7676,7 +7676,8 @@ INT16 K_GetKartTurnValue(player_t *player, INT16 turnvalue) { turnfixed /= 2; } - else if (player->mo->eflags & MFE_TOUCHWATER) + else if ((player->mo->eflags & MFE_TOUCHWATER) && + !player->offroad) { turnfixed = FixedMul(turnfixed, 3*FRACUNIT/2); } @@ -8466,7 +8467,8 @@ void K_AdjustPlayerFriction(player_t *player) */ // Water gets ice physics too - if (player->mo->eflags & MFE_TOUCHWATER) + if ((player->mo->eflags & MFE_TOUCHWATER) && + !player->offroad) { player->mo->friction += 614; } From f0c9e49a2baacb3c9032a8582912814e79e4775f Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 5 Dec 2021 22:38:59 -0800 Subject: [PATCH 098/156] Clip watertop and waterbottom between other sector and FOFs --- src/p_mobj.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index 491b371b3..96beed530 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -2956,6 +2956,8 @@ void P_MobjCheckWater(mobj_t *mobj) player_t *p = mobj->player; // Will just be null if not a player. fixed_t height = mobj->height; boolean wasgroundpounding = false; + fixed_t top2 = P_GetSectorCeilingZAt(sector, mobj->x, mobj->y); + fixed_t bot2 = P_GetSectorFloorZAt(sector, mobj->x, mobj->y); // Default if no water exists. mobj->watertop = mobj->waterbottom = mobj->z - 1000*FRACUNIT; @@ -2966,14 +2968,21 @@ void P_MobjCheckWater(mobj_t *mobj) for (rover = sector->ffloors; rover; rover = rover->next) { fixed_t topheight, bottomheight; - if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_SWIMMABLE) - || (((rover->flags & FF_BLOCKPLAYER) && mobj->player) - || ((rover->flags & FF_BLOCKOTHERS) && !mobj->player))) - continue; topheight = P_GetFFloorTopZAt (rover, mobj->x, mobj->y); bottomheight = P_GetFFloorBottomZAt(rover, mobj->x, mobj->y); + if (!(rover->flags & FF_EXISTS) || !(rover->flags & FF_SWIMMABLE) + || (((rover->flags & FF_BLOCKPLAYER) && mobj->player) + || ((rover->flags & FF_BLOCKOTHERS) && !mobj->player))) + { + if (topheight < top2 && topheight > thingtop) + top2 = topheight; + if (bottomheight > bot2 && bottomheight < mobj->z) + bot2 = bottomheight; + continue; + } + if (mobj->eflags & MFE_VERTICALFLIP) { if (topheight < (thingtop - (height>>1)) @@ -3011,6 +3020,12 @@ void P_MobjCheckWater(mobj_t *mobj) } } + if (mobj->watertop > top2) + mobj->watertop = top2; + + if (mobj->waterbottom < bot2) + mobj->waterbottom = bot2; + // Spectators and dead players don't get to do any of the things after this. if (p && (p->spectator || p->playerstate != PST_LIVE)) return; From 9bde266f9f210a82a1a5e6460e5e259436d01ce2 Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 5 Dec 2021 22:41:25 -0800 Subject: [PATCH 099/156] Water running You can run on water in any case where you would have slope resistance AND your speed is over 100%. You may run on water regardless if you're speed is above 200%. --- src/p_local.h | 1 + src/p_map.c | 2 +- src/p_maputl.c | 4 ++-- src/p_mobj.c | 39 ++++++++++++++++++++++++++++++++++----- 4 files changed, 38 insertions(+), 8 deletions(-) diff --git a/src/p_local.h b/src/p_local.h index 631920bb6..037e9aa50 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -329,6 +329,7 @@ void P_Attract(mobj_t *source, mobj_t *enemy, boolean nightsgrab); mobj_t *P_GetClosestAxis(mobj_t *source); boolean P_CanRunOnWater(player_t *player, ffloor_t *rover); +boolean P_CheckSolidFFloorSurface(player_t *player, ffloor_t *rover); void P_MaceRotate(mobj_t *center, INT32 baserot, INT32 baseprevrot); diff --git a/src/p_map.c b/src/p_map.c index d0716790b..f78a0b402 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -1848,7 +1848,7 @@ boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y) continue; } - if (thing->player && P_CheckSolidLava(rover)) + if (thing->player && P_CheckSolidFFloorSurface(thing->player, rover)) ; else if (thing->type == MT_SKIM && (rover->flags & FF_SWIMMABLE)) ; diff --git a/src/p_maputl.c b/src/p_maputl.c index 2e21f5ee3..5acddf09c 100644 --- a/src/p_maputl.c +++ b/src/p_maputl.c @@ -730,7 +730,7 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) if (!(rover->flags & FF_EXISTS)) continue; - if (mobj->player && P_CheckSolidLava(rover)) + if (mobj->player && P_CheckSolidFFloorSurface(mobj->player, rover)) ; else if (!((rover->flags & FF_BLOCKPLAYER && mobj->player) || (rover->flags & FF_BLOCKOTHERS && !mobj->player))) @@ -772,7 +772,7 @@ void P_LineOpening(line_t *linedef, mobj_t *mobj) if (!(rover->flags & FF_EXISTS)) continue; - if (mobj->player && P_CheckSolidLava(rover)) + if (mobj->player && P_CheckSolidFFloorSurface(mobj->player, rover)) ; else if (!((rover->flags & FF_BLOCKPLAYER && mobj->player) || (rover->flags & FF_BLOCKOTHERS && !mobj->player))) diff --git a/src/p_mobj.c b/src/p_mobj.c index 96beed530..6853c06f9 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -1879,7 +1879,7 @@ void P_AdjustMobjFloorZ_FFloors(mobj_t *mo, sector_t *sector, UINT8 motype) topheight = P_GetFOFTopZ(mo, sector, rover, mo->x, mo->y, NULL); bottomheight = P_GetFOFBottomZ(mo, sector, rover, mo->x, mo->y, NULL); - if (mo->player && P_CheckSolidLava(rover)) // only the player should stand on lava + if (mo->player && P_CheckSolidFFloorSurface(mo->player, rover)) // only the player should stand on lava or run on water ; else if (motype != 0 && rover->flags & FF_SWIMMABLE) // "scenery" only continue; @@ -2940,6 +2940,34 @@ boolean P_SceneryZMovement(mobj_t *mo) return true; } +// P_CanRunOnWater +// +// Returns true if player can waterrun on the 3D floor +// +boolean P_CanRunOnWater(player_t *player, ffloor_t *rover) +{ + boolean flip = player->mo->eflags & MFE_VERTICALFLIP; + fixed_t topspeed = K_GetKartSpeed(player, false); + fixed_t surfaceheight = flip ? player->mo->waterbottom : player->mo->watertop; + fixed_t playerbottom = flip ? (player->mo->z + player->mo->height) : player->mo->z; + fixed_t clip = flip ? (surfaceheight - playerbottom) : (playerbottom - surfaceheight); + fixed_t span = player->mo->watertop - player->mo->waterbottom; + + return + clip > -(player->mo->height / 2) && + span > player->mo->height && + player->speed / 3 > abs(player->mo->momz) && + (player->speed > 2 * topspeed || (player->speed > + topspeed && K_SlopeResistance(player))) && + (rover->flags & FF_SWIMMABLE); +} + +boolean P_CheckSolidFFloorSurface(player_t *player, ffloor_t *rover) +{ + return P_CheckSolidLava(rover) || + P_CanRunOnWater(player, rover); +} + // // P_MobjCheckWater // @@ -2955,6 +2983,7 @@ void P_MobjCheckWater(mobj_t *mobj) ffloor_t *rover; player_t *p = mobj->player; // Will just be null if not a player. fixed_t height = mobj->height; + fixed_t halfheight = height / 2; boolean wasgroundpounding = false; fixed_t top2 = P_GetSectorCeilingZAt(sector, mobj->x, mobj->y); fixed_t bot2 = P_GetSectorFloorZAt(sector, mobj->x, mobj->y); @@ -2985,14 +3014,14 @@ void P_MobjCheckWater(mobj_t *mobj) if (mobj->eflags & MFE_VERTICALFLIP) { - if (topheight < (thingtop - (height>>1)) - || bottomheight > thingtop) + if (topheight < (thingtop - halfheight) + || bottomheight > (thingtop + halfheight)) continue; } else { - if (topheight < mobj->z - || bottomheight > (mobj->z + (height>>1))) + if (topheight < (mobj->z - halfheight) + || bottomheight > (mobj->z + halfheight)) continue; } From a7a572a7eab280bcafa9f5c11d06bf7d5ddfb157 Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 5 Dec 2021 23:23:43 -0800 Subject: [PATCH 100/156] Water-run if you are above 100% speed and would cross a tripwire --- src/p_mobj.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index 6853c06f9..b52522a75 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -2947,7 +2947,6 @@ boolean P_SceneryZMovement(mobj_t *mo) boolean P_CanRunOnWater(player_t *player, ffloor_t *rover) { boolean flip = player->mo->eflags & MFE_VERTICALFLIP; - fixed_t topspeed = K_GetKartSpeed(player, false); fixed_t surfaceheight = flip ? player->mo->waterbottom : player->mo->watertop; fixed_t playerbottom = flip ? (player->mo->z + player->mo->height) : player->mo->z; fixed_t clip = flip ? (surfaceheight - playerbottom) : (playerbottom - surfaceheight); @@ -2957,8 +2956,8 @@ boolean P_CanRunOnWater(player_t *player, ffloor_t *rover) clip > -(player->mo->height / 2) && span > player->mo->height && player->speed / 3 > abs(player->mo->momz) && - (player->speed > 2 * topspeed || (player->speed > - topspeed && K_SlopeResistance(player))) && + player->speed > K_GetKartSpeed(player, false) && + K_TripWirePass(player) && (rover->flags & FF_SWIMMABLE); } From 58446441fe5db01b5720e9687134229c2b442fe7 Mon Sep 17 00:00:00 2001 From: James R Date: Mon, 6 Dec 2021 16:14:56 -0800 Subject: [PATCH 101/156] Don't water-run while in grow Also there was a typo lmao --- src/k_kart.c | 13 +++++++++++++ src/k_kart.h | 1 + src/p_mobj.c | 2 +- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/k_kart.c b/src/k_kart.c index 73661c018..a66f34d32 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -2700,6 +2700,19 @@ boolean K_TripwirePass(player_t *player) return false; } +boolean K_WaterRun(player_t *player) +{ + if ( + player->invincibilitytimer || + player->sneakertimer || + player->tiregrease || + player->flamedash || + player->speed > 2 * K_GetKartSpeed(player, false) + ) + return true; + return false; +} + static fixed_t K_FlameShieldDashVar(INT32 val) { // 1 second = 75% + 50% top speed diff --git a/src/k_kart.h b/src/k_kart.h index 8b0f755d6..0b60d521a 100644 --- a/src/k_kart.h +++ b/src/k_kart.h @@ -108,6 +108,7 @@ void K_MomentumToFacing(player_t *player); boolean K_ApplyOffroad(player_t *player); boolean K_SlopeResistance(player_t *player); boolean K_TripwirePass(player_t *player); +boolean K_WaterRun(player_t *player); void K_ApplyTripWire(player_t *player, tripwirestate_t state); INT16 K_GetSpindashChargeTime(player_t *player); fixed_t K_GetSpindashChargeSpeed(player_t *player); diff --git a/src/p_mobj.c b/src/p_mobj.c index b52522a75..dba88de15 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -2957,7 +2957,7 @@ boolean P_CanRunOnWater(player_t *player, ffloor_t *rover) span > player->mo->height && player->speed / 3 > abs(player->mo->momz) && player->speed > K_GetKartSpeed(player, false) && - K_TripWirePass(player) && + K_WaterRun(player) && (rover->flags & FF_SWIMMABLE); } From 8484ba929472ec1373a087a7b5c80dd50dc87fe9 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Mon, 6 Dec 2021 20:38:30 -0500 Subject: [PATCH 102/156] Alpha value for fade colormaps --- src/r_data.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/src/r_data.c b/src/r_data.c index 04b6c232b..46ae0dbd2 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -615,6 +615,7 @@ lighttable_t *R_CreateLightTable(extracolormap_t *extra_colormap) { double cmaskr, cmaskg, cmaskb, cdestr, cdestg, cdestb, cdestbright; double maskamt = 0, othermask = 0; + double fmaskamt = 0, fothermask = 0; UINT8 cr = R_GetRgbaR(extra_colormap->rgba), cg = R_GetRgbaG(extra_colormap->rgba), @@ -622,8 +623,8 @@ lighttable_t *R_CreateLightTable(extracolormap_t *extra_colormap) ca = R_GetRgbaA(extra_colormap->rgba), cfr = R_GetRgbaR(extra_colormap->fadergba), cfg = R_GetRgbaG(extra_colormap->fadergba), - cfb = R_GetRgbaB(extra_colormap->fadergba); -// cfa = R_GetRgbaA(extra_colormap->fadergba); // unused in software + cfb = R_GetRgbaB(extra_colormap->fadergba), + cfa = R_GetRgbaA(extra_colormap->fadergba); UINT8 fadestart = extra_colormap->fadestart, fadedist = extra_colormap->fadeend - extra_colormap->fadestart; @@ -654,14 +655,11 @@ lighttable_t *R_CreateLightTable(extracolormap_t *extra_colormap) cdestb = cfb; cdestbright = sqrt((cfr*cfr) + (cfg*cfg) + (cfb*cfb)); - // fade alpha unused in software - // maskamt = (double)(cfa/24.0l); - // othermask = 1 - maskamt; - // maskamt /= 0xff; + fmaskamt = (double)(cfa/24.0l); + fothermask = 1 - fmaskamt; + //fmaskamt /= 0xff; - // cdestr *= maskamt; - // cdestg *= maskamt; - // cdestb *= maskamt; + (void)fothermask; // unused, but don't feel like commenting it out ///////////////////// // This code creates the colormap array used by software renderer @@ -710,7 +708,7 @@ lighttable_t *R_CreateLightTable(extracolormap_t *extra_colormap) } // Add/subtract this value during fading. - brightChange[i] = fabs(cbest - cdist) / (double)fadedist; + brightChange[i] = (fabs(cbest - cdist) / (double)fadedist) * fmaskamt; } // Now allocate memory for the actual colormap array itself! From b03cfe302d0850a77e36d6186ad3007eb87dc783 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Mon, 6 Dec 2021 20:58:31 -0500 Subject: [PATCH 103/156] OGL fade alpha support --- src/hardware/hw_defs.h | 2 +- src/hardware/r_opengl/r_opengl.c | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/hardware/hw_defs.h b/src/hardware/hw_defs.h index 3f6ad01e5..b4dc1accb 100644 --- a/src/hardware/hw_defs.h +++ b/src/hardware/hw_defs.h @@ -284,7 +284,7 @@ struct FSurfaceInfo typedef struct FSurfaceInfo FSurfaceInfo; #define GL_DEFAULTMIX 0x00000000 -#define GL_DEFAULTFOG 0xFF000000 +#define GL_DEFAULTFOG 0x19000000 //Hurdler: added for backward compatibility enum hwdsetspecialstate diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 367ce8331..51a4dd99d 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -723,6 +723,7 @@ static GLRGBAFloat shader_defaultcolor = {1.0f, 1.0f, 1.0f, 1.0f}; "colorIntensity = abs(colorIntensity - (fogBrightness));\n" \ "}\n" \ "colorIntensity *= darkness;\n" \ + "colorIntensity *= fade_color.a * 10.0;\n" \ "if (abs(final_color.r - fade_color.r) <= colorIntensity) {\n" \ "final_color.r = fade_color.r;\n" \ "} else if (final_color.r < fade_color.r) {\n" \ From dbefc8fe5810d13f690c0549a1df8df1749e3bf3 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Mon, 6 Dec 2021 22:47:15 -0500 Subject: [PATCH 104/156] Fix yellow persist fade colormap bug I did the equivalent change to OpenGL and it broke Zoned City, despite it being fine in Software ... not sure what's up with that, since the color math is pretty similar. Just gonna leave that alone for now... --- src/hardware/r_opengl/r_opengl.c | 6 +++--- src/r_data.c | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 51a4dd99d..84d6ded6e 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -715,12 +715,12 @@ static GLRGBAFloat shader_defaultcolor = {1.0f, 1.0f, 1.0f, 1.0f}; "float colorBrightness = sqrt((final_color.r * final_color.r) + (final_color.g * final_color.g) + (final_color.b * final_color.b));\n" \ "float fogBrightness = sqrt((fade_color.r * fade_color.r) + (fade_color.g * fade_color.g) + (fade_color.b * fade_color.b));\n" \ "float colorIntensity = 0.0;\n" \ - "if (fogBrightness > colorBrightness) {\n" \ + "if (colorBrightness < fogBrightness) {\n" \ "colorIntensity = 1.0 - min(final_color.r, min(final_color.g, final_color.b));\n" \ - "colorIntensity = abs(colorIntensity - (1.0 - fogBrightness));\n" \ + "colorIntensity = abs(colorIntensity - (1.0 - max(fade_color.r, max(fade_color.g, fade_color.b))));\n" \ "} else {\n" \ "colorIntensity = max(final_color.r, max(final_color.g, final_color.b));\n" \ - "colorIntensity = abs(colorIntensity - (fogBrightness));\n" \ + "colorIntensity = abs(colorIntensity - min(fade_color.r, min(fade_color.g, fade_color.b)));\n" \ "}\n" \ "colorIntensity *= darkness;\n" \ "colorIntensity *= fade_color.a * 10.0;\n" \ diff --git a/src/r_data.c b/src/r_data.c index 46ae0dbd2..bb2e508ba 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -699,12 +699,12 @@ lighttable_t *R_CreateLightTable(extracolormap_t *extra_colormap) if (cbrightness < cdestbright) { cbest = 255.0l - min(r, min(g, b)); - cdist = 255.0l - cdestbright; + cdist = 255.0l - max(cdestr, max(cdestg, cdestb)); } else { cbest = max(r, max(g, b)); - cdist = cdestbright; + cdist = min(cdestr, min(cdestg, cdestb)); } // Add/subtract this value during fading. From ab77bceb886ff92afd08ecaaebe33968a452564e Mon Sep 17 00:00:00 2001 From: James R Date: Mon, 6 Dec 2021 20:33:41 -0800 Subject: [PATCH 105/156] Adjust underwater strafing - 3/4 steering ability while underwater (not drifting). - A little less friction while underwater. --- src/k_kart.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/k_kart.c b/src/k_kart.c index 40ca0ca8f..e4761ef59 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -7694,6 +7694,10 @@ INT32 K_GetUnderwaterTurnAdjust(player_t *player) { INT32 steer = (K_GetKartTurnValue(player, player->steering) << TICCMD_REDUCE); + + if (!player->drift) + steer = 3 * steer / 2; + return FixedMul(steer, 8 * FixedDiv(player->speed, 2 * K_GetKartSpeed(player, false) / 3)); } @@ -8472,6 +8476,10 @@ void K_AdjustPlayerFriction(player_t *player) { player->mo->friction += 614; } + else if (player->mo->eflags & MFE_UNDERWATER) + { + player->mo->friction += 312; + } // Wipeout slowdown if (player->spinouttimer && player->wipeoutslow) From 84170a59fa5d09658e554c41b8aeb79fee6f9398 Mon Sep 17 00:00:00 2001 From: James R Date: Mon, 6 Dec 2021 20:35:26 -0800 Subject: [PATCH 106/156] Cap underwater steering tilting --- src/p_user.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/p_user.c b/src/p_user.c index 9c1e87a53..591bdd8f7 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -1775,7 +1775,20 @@ static void P_3dMovement(player_t *player) if (a) { - adj = a / 4; + const fixed_t maxadj = ANG10/4; + + adj = a / 4; + + if (adj > 0) + { + if (adj > maxadj) + adj = maxadj; + } + else if (adj < 0) + { + if (adj < -(maxadj)) + adj = -(maxadj); + } if (abs(player->underwatertilt + adj) > abs(a)) adj = (a - player->underwatertilt); From ce366099b008711c8c240155a088d95c3b14db51 Mon Sep 17 00:00:00 2001 From: James R Date: Mon, 6 Dec 2021 21:07:34 -0800 Subject: [PATCH 107/156] Make horizontal versus vertical momentum more strict when deciding water-run --- src/p_mobj.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index dba88de15..23aa0cb13 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -2955,7 +2955,7 @@ boolean P_CanRunOnWater(player_t *player, ffloor_t *rover) return clip > -(player->mo->height / 2) && span > player->mo->height && - player->speed / 3 > abs(player->mo->momz) && + player->speed / 5 > abs(player->mo->momz) && player->speed > K_GetKartSpeed(player, false) && K_WaterRun(player) && (rover->flags & FF_SWIMMABLE); From 0cbd24e5891b2ff193453fddb2b6d60747e6f28f Mon Sep 17 00:00:00 2001 From: James R Date: Mon, 6 Dec 2021 21:30:35 -0800 Subject: [PATCH 108/156] 2x vertical speed for downward springs --- src/p_map.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/p_map.c b/src/p_map.c index d0716790b..858eb7600 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -310,6 +310,9 @@ boolean P_DoSpring(mobj_t *spring, mobj_t *object) if (spring->eflags & MFE_VERTICALFLIP) vertispeed *= -1; + if ((spring->eflags ^ object->eflags) & MFE_VERTICALFLIP) + vertispeed *= 2; + // Vertical springs teleport you on TOP of them. if (vertispeed > 0) { From 4a0d0f224f8ef8dafd131c247a3e14675cab1a33 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Tue, 7 Dec 2021 01:01:00 -0500 Subject: [PATCH 109/156] Fuck crazy turning --- src/k_kart.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 73661c018..2887ad32a 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -7565,10 +7565,12 @@ static INT16 K_GetKartDriftValue(player_t *player, fixed_t countersteer) basedrift += (basedrift / greasetics) * player->tiregrease; } - if (player->mo->eflags & (MFE_UNDERWATER|MFE_TOUCHWATER)) +#if 0 + if (player->mo->eflags & MFE_UNDERWATER) { countersteer = FixedMul(countersteer, 3*FRACUNIT/2); } +#endif return basedrift + (FixedMul(driftadjust * FRACUNIT, countersteer) / FRACUNIT); } @@ -7672,11 +7674,6 @@ INT16 K_GetKartTurnValue(player_t *player, INT16 turnvalue) turnfixed = FixedMul(turnfixed, FRACUNIT + player->handleboost); } - if (player->mo->eflags & (MFE_UNDERWATER|MFE_TOUCHWATER)) - { - turnfixed = FixedMul(turnfixed, 3*FRACUNIT/2); - } - // Weight has a small effect on turning turnfixed = FixedMul(turnfixed, weightadjust); From 2b3da168cb417f3ae4d33745fe08e91d576889ee Mon Sep 17 00:00:00 2001 From: SinnamonLat Date: Tue, 7 Dec 2021 09:54:00 +0100 Subject: [PATCH 110/156] New landmine explosion --- src/deh_tables.c | 1 + src/info.c | 2 +- src/info.h | 3 +++ src/k_kart.c | 21 ++++++++++++------ src/k_kart.h | 1 + src/p_enemy.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 78 insertions(+), 8 deletions(-) diff --git a/src/deh_tables.c b/src/deh_tables.c index aae6f660c..7e309c33f 100644 --- a/src/deh_tables.c +++ b/src/deh_tables.c @@ -323,6 +323,7 @@ actionpointer_t actionpointers[] = {{A_SPBChase}, "A_SPBCHASE"}, {{A_SSMineSearch}, "A_SSMINESEARCH"}, {{A_SSMineExplode}, "A_SSMINEEXPLODE"}, + {{A_LandMineExplode}, "A_LANDMINEEXPLODE"}, {{A_BallhogExplode}, "A_BALLHOGEXPLODE"}, {{A_LightningFollowPlayer}, "A_LIGHTNINGFOLLOWPLAYER"}, {{A_FZBoomFlash}, "A_FZBOOMFLASH"}, diff --git a/src/info.c b/src/info.c index 915702380..b4a8a8012 100644 --- a/src/info.c +++ b/src/info.c @@ -4358,7 +4358,7 @@ state_t states[NUMSTATES] = {SPR_KRBM, FF_FULLBRIGHT|9, 5, {NULL}, 0, 0, S_NULL}, // S_SLOWBOOM10 {SPR_LNDM, 0, -1, {NULL}, 0, 0, S_LANDMINE}, // S_LANDMINE - {SPR_NULL, 0, 1, {NULL}, 0, 0, S_NULL}, // S_LANDMINE_EXPLODE + {SPR_NULL, 0, 1, {A_LandMineExplode}, 0, 0, S_NULL}, // S_LANDMINE_EXPLODE {SPR_BHOG, 0, 3, {A_PlaySound}, sfx_s1bd, 1, S_BALLHOG2}, // S_BALLHOG1 {SPR_BHOG, FF_FULLBRIGHT|1, 1, {NULL}, 0, 0, S_BALLHOG3}, // S_BALLHOG2 diff --git a/src/info.h b/src/info.h index c9998c498..115948905 100644 --- a/src/info.h +++ b/src/info.h @@ -276,6 +276,7 @@ enum actionnum A_SPBCHASE, A_SSMINESEARCH, A_SSMINEEXPLODE, + A_LANDMINEEXPLODE, A_BALLHOGEXPLODE, A_LIGHTNINGFOLLOWPLAYER, A_FZBOOMFLASH, @@ -546,6 +547,8 @@ void A_JawzExplode(); void A_SPBChase(); void A_SSMineSearch(); void A_SSMineExplode(); +void A_LandMineExplode(); +void A_LandMineExplode(); void A_BallhogExplode(); void A_LightningFollowPlayer(); void A_FZBoomFlash(); diff --git a/src/k_kart.c b/src/k_kart.c index 73661c018..71255a8f8 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -3623,14 +3623,9 @@ void K_SpawnKartExplosion(fixed_t x, fixed_t y, fixed_t z, fixed_t radius, INT32 #define MINEQUAKEDIST 4096 -// Spawns the purely visual explosion -void K_SpawnMineExplosion(mobj_t *source, UINT8 color) +// Does the proximity screen flash and quake for explosions +void K_MineFlashScreen(mobj_t *source) { - INT32 i, radius, height; - mobj_t *smoldering = P_SpawnMobj(source->x, source->y, source->z, MT_SMOLDERING); - mobj_t *dust; - mobj_t *truc; - INT32 speed, speed2; INT32 pnum; player_t *p; @@ -3653,6 +3648,18 @@ void K_SpawnMineExplosion(mobj_t *source, UINT8 color) break; // we can break right now because quakes are global to all split players somehow. } } +} + +// Spawns the purely visual explosion +void K_SpawnMineExplosion(mobj_t *source, UINT8 color) +{ + INT32 i, radius, height; + mobj_t *smoldering = P_SpawnMobj(source->x, source->y, source->z, MT_SMOLDERING); + mobj_t *dust; + mobj_t *truc; + INT32 speed, speed2; + + K_MineFlashScreen(source); K_MatchGenericExtraFlags(smoldering, source); smoldering->tics = TICRATE*3; diff --git a/src/k_kart.h b/src/k_kart.h index 8b0f755d6..bf648dcf5 100644 --- a/src/k_kart.h +++ b/src/k_kart.h @@ -69,6 +69,7 @@ void K_HandleBumperChanges(player_t *player, UINT8 prevBumpers); void K_DestroyBumpers(player_t *player, UINT8 amount); void K_TakeBumpersFromPlayer(player_t *player, player_t *victim, UINT8 amount); void K_SpawnKartExplosion(fixed_t x, fixed_t y, fixed_t z, fixed_t radius, INT32 number, mobjtype_t type, angle_t rotangle, boolean spawncenter, boolean ghostit, mobj_t *source); +void K_MineFlashScreen(mobj_t *source); void K_SpawnMineExplosion(mobj_t *source, UINT8 color); void K_RunFinishLineBeam(void); UINT16 K_DriftSparkColor(player_t *player, INT32 charge); diff --git a/src/p_enemy.c b/src/p_enemy.c index 5417d3293..a0cf09820 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -310,6 +310,7 @@ void A_JawzExplode(mobj_t *actor); void A_SPBChase(mobj_t *actor); void A_SSMineSearch(mobj_t *actor); void A_SSMineExplode(mobj_t *actor); +void A_LandMineExplode(mobj_t *actor); void A_BallhogExplode(mobj_t *actor); void A_LightningFollowPlayer(mobj_t *actor); void A_FZBoomFlash(mobj_t *actor); @@ -14132,6 +14133,63 @@ void A_SSMineExplode(mobj_t *actor) actor->flags2 |= MF2_DEBRIS; // Set this flag to ensure that the explosion won't be effective more than 1 frame. } +void A_LandMineExplode(mobj_t *actor) +{ + + mobj_t *expl; + INT32 colour = SKINCOLOR_KETCHUP; // we spell words properly here + INT32 i; + mobj_t *smoldering; + mobj_t *dust; + + if (LUA_CallAction(A_LANDMINEEXPLODE, actor)) + return; + + // we'll base the explosion "timer" off of some stupid variable like uh... cvmem! + // Yeah let's use cvmem since nobody uses that + + if (actor->target && !P_MobjWasRemoved(actor->target)) + colour = actor->target->color; + + K_MineFlashScreen(actor); + + // Spawn smoke remains: + smoldering = P_SpawnMobj(actor->x, actor->y, actor->z, MT_SMOLDERING); + P_SetScale(smoldering, actor->scale); + smoldering->tics = TICRATE*3; + + // Spawn a ring: + for (i = 0; i < 32; i++) + { + dust = P_SpawnMobj(actor->x, actor->y, actor->z, MT_SMOKE); + P_SetMobjState(dust, S_OPAQUESMOKE1); + dust->angle = (ANGLE_180/16) * i; + P_SetScale(dust, actor->scale); + dust->destscale = actor->scale*4; + dust->scalespeed = actor->scale/4; + P_InstaThrust(dust, dust->angle, FixedMul(20*FRACUNIT, actor->scale)); + } + + actor->fuse = actor->tics; // disappear when this state ends. + + // spawn a few physics explosions + for (i = 0; i < 15; i++) + { + expl = P_SpawnMobj(actor->x, actor->y, actor->z + actor->scale, MT_BOOMEXPLODE); + expl->color = colour; + expl->tics = (i+1); + + //K_MatchGenericExtraFlags(expl, actor); + P_SetScale(expl, actor->scale*4); + + expl->momx = P_RandomRange(-3, 3)*actor->scale/2; + expl->momy = P_RandomRange(-3, 3)*actor->scale/2; + + // 100/45 = 2.22 fu/t + expl->momz = ((i+1)*actor->scale*5/2)*P_MobjFlip(expl); + } +} + void A_BallhogExplode(mobj_t *actor) { mobj_t *mo2; From a1e8cdf8c5dee9f1f1abe64282230bf2175b5fdf Mon Sep 17 00:00:00 2001 From: James R Date: Tue, 7 Dec 2021 15:33:45 -0800 Subject: [PATCH 111/156] Adjust underwater steering again - 1.5x strafe -> 1.8. - Do not nerf steering at 11 FU or below. --- src/k_kart.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index e4761ef59..58a82d128 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -7672,7 +7672,8 @@ INT16 K_GetKartTurnValue(player_t *player, INT16 turnvalue) turnfixed = FixedMul(turnfixed, FRACUNIT + player->handleboost); } - if (player->mo->eflags & MFE_UNDERWATER) + if ((player->mo->eflags & MFE_UNDERWATER) && + player->speed > 11 * player->mo->scale) { turnfixed /= 2; } @@ -7690,13 +7691,14 @@ INT16 K_GetKartTurnValue(player_t *player, INT16 turnvalue) INT32 K_GetUnderwaterTurnAdjust(player_t *player) { - if (player->mo->eflags & MFE_UNDERWATER) + if ((player->mo->eflags & MFE_UNDERWATER) && + player->speed > 11 * player->mo->scale) { INT32 steer = (K_GetKartTurnValue(player, player->steering) << TICCMD_REDUCE); if (!player->drift) - steer = 3 * steer / 2; + steer = 9 * steer / 5; return FixedMul(steer, 8 * FixedDiv(player->speed, 2 * K_GetKartSpeed(player, false) / 3)); From f2e8d7d469128efa5db3ee5f53436fd2edca337b Mon Sep 17 00:00:00 2001 From: James R Date: Tue, 7 Dec 2021 16:26:52 -0800 Subject: [PATCH 112/156] Increase step up with water-running just like water-skipping --- src/p_map.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/p_map.c b/src/p_map.c index f78a0b402..bcecb1dfa 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -2414,6 +2414,20 @@ boolean PIT_PushableMoved(mobj_t *thing) return true; } +static boolean P_WaterRunning(mobj_t *thing) +{ + ffloor_t *rover = thing->floorrover; + return rover && (rover->flags & FF_SWIMMABLE) && + P_IsObjectOnGround(thing); +} + +static boolean P_WaterStepUp(mobj_t *thing) +{ + player_t *player = thing->player; + return (player && player->waterskip) || + P_WaterRunning(thing); +} + // // P_TryMove // Attempt to move to a new position. @@ -2478,7 +2492,7 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) const fixed_t maxstepmove = FixedMul(MAXSTEPMOVE, mapobjectscale); fixed_t maxstep = maxstepmove; - if (thing->player && thing->player->waterskip) + if (thing->player && P_WaterStepUp(thing)) maxstep += maxstepmove; // Add some extra stepmove when waterskipping // If using type Section1:13, double the maxstep. From a149fa9db9e92a08c95ebaaaae28facd503dad97 Mon Sep 17 00:00:00 2001 From: toaster Date: Thu, 9 Dec 2021 20:57:15 +0000 Subject: [PATCH 113/156] GL now loads in netgames and doesn't memory leak What is broken: * Encore mode remapping in GL only * Seizure effect in Daytona (NOT IVO SAFE) * God knows what else has been waiting in the wings --- src/f_finale.c | 17 ++++++++++++++--- src/hardware/hw_cache.c | 10 ++++++++++ src/hardware/hw_glob.h | 2 +- src/hardware/hw_main.c | 2 ++ 4 files changed, 27 insertions(+), 4 deletions(-) diff --git a/src/f_finale.c b/src/f_finale.c index 099fa422d..eff9ed3f7 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -108,8 +108,12 @@ static patch_t *ttcheckers; // *vroom* KART static patch_t *ttkflash; // flash screen */ +#define NOWAY + +#ifdef NOWAY static patch_t *driver[2]; // Driving character on the waiting screen static UINT8 *waitcolormap; // colormap for the spinning character +#endif // ttmode user static patch_t *ttuser[TTMAX_USER]; @@ -2188,14 +2192,17 @@ void F_TitleDemoTicker(void) void F_StartWaitingPlayers(void) { +#ifdef NOWAY INT32 i; INT32 randskin; spritedef_t *sprdef; spriteframe_t *sprframe; +#endif wipegamestate = GS_TITLESCREEN; // technically wiping from title screen finalecount = 0; +#ifdef NOWAY randskin = M_RandomKey(numskins); if (waitcolormap) @@ -2208,8 +2215,9 @@ void F_StartWaitingPlayers(void) for (i = 0; i < 2; i++) { sprframe = &sprdef->spriteframes[i]; - driver[i] = W_CachePatchNum(sprframe->lumppat[0], PU_LEVEL); + driver[i] = W_CachePatchNum(sprframe->lumppat[0], PU_CACHE); } +#endif } void F_WaitingPlayersTicker(void) @@ -2226,14 +2234,17 @@ void F_WaitingPlayersTicker(void) void F_WaitingPlayersDrawer(void) { +#ifdef NOWAY UINT32 frame = (finalecount % 8) / 4; // The game only tics every other frame while waitingplayers - INT32 flags = V_FLIP; +#endif const char *waittext1 = "You will join"; const char *waittext2 = "the next race..."; V_DrawFill(0, 0, BASEVIDWIDTH, BASEVIDHEIGHT, 31); V_DrawCreditString((160 - (V_CreditStringWidth(waittext1)>>1))<>1))<width / 2, 150<width / 2, 150<mipmap.height = (UINT16)texture->height; grtex->mipmap.format = textureformat; +#ifdef GLENCORE if (encoremap) colormap += COLORMAP_REMAPOFFSET; grtex->mipmap.colormap = Z_Calloc(sizeof(*grtex->mipmap.colormap), PU_HWRPATCHCOLMIPMAP, NULL); grtex->mipmap.colormap->source = colormap; M_Memcpy(grtex->mipmap.colormap->data, colormap, 256 * sizeof(UINT8)); +#endif blockwidth = texture->width; blockheight = texture->height; @@ -891,7 +895,9 @@ void HWR_GetRawFlat(lumpnum_t flatlumpnum, boolean noencoremap) GLMipmap_t *grmip; patch_t *patch; +#ifdef GLENCORE UINT8 *colormap = colormaps; +#endif if (flatlumpnum == LUMPERROR) return; @@ -899,12 +905,16 @@ void HWR_GetRawFlat(lumpnum_t flatlumpnum, boolean noencoremap) patch = HWR_GetCachedGLPatch(flatlumpnum); grmip = ((GLPatch_t *)Patch_AllocateHardwarePatch(patch))->mipmap; +#ifdef GLENCORE if (!noencoremap && encoremap) colormap += COLORMAP_REMAPOFFSET; grmip->colormap = Z_Calloc(sizeof(*grmip->colormap), PU_HWRPATCHCOLMIPMAP, NULL); grmip->colormap->source = colormap; M_Memcpy(grmip->colormap->data, colormap, 256 * sizeof(UINT8)); +#else + (void)noencoremap; +#endif if (!grmip->downloaded && !grmip->data) HWR_CacheFlat(grmip, flatlumpnum); diff --git a/src/hardware/hw_glob.h b/src/hardware/hw_glob.h index aafef9eb4..79cdba4f3 100644 --- a/src/hardware/hw_glob.h +++ b/src/hardware/hw_glob.h @@ -26,7 +26,7 @@ //#define HWR_LOADING_SCREEN // SRB2Kart -#define GLENCORE +//#define GLENCORE // ----------- // structures diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 46f1e9fc9..3bd516a22 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -5478,8 +5478,10 @@ static void HWR_ProjectSprite(mobj_t *thing) { vis->colormap = colormaps; +#ifdef GLENCORE if (encoremap && (thing->flags & (MF_SCENERY|MF_NOTHINK)) && !(thing->flags & MF_DONTENCOREMAP)) vis->colormap += COLORMAP_REMAPOFFSET; +#endif } // set top/bottom coords From 69483f2578c5ff6cfb3595c4da89417e8a728f86 Mon Sep 17 00:00:00 2001 From: toaster Date: Thu, 9 Dec 2021 22:33:57 +0000 Subject: [PATCH 114/156] Additive sign/tether sparkles --- src/info.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/info.c b/src/info.c index b4a8a8012..5d506d98d 100644 --- a/src/info.c +++ b/src/info.c @@ -4076,17 +4076,17 @@ state_t states[NUMSTATES] = //{SPR_ICAP, FF_FLOORSPRITE|4, -1, {NULL}, 0, 0, S_NULL}, // S_ITEMCAPSULE_BOTTOM //{SPR_ICAP, FF_FLOORSPRITE|5, -1, {NULL}, 0, 0, S_NULL}, // S_ITEMCAPSULE_INSIDE - {SPR_SGNS, FF_FULLBRIGHT, 1, {NULL}, 0, 0, S_SIGNSPARK2}, // S_SIGNSPARK1 - {SPR_SGNS, FF_FULLBRIGHT|1, 1, {NULL}, 0, 0, S_SIGNSPARK3}, // S_SIGNSPARK2 - {SPR_SGNS, FF_FULLBRIGHT|2, 1, {NULL}, 0, 0, S_SIGNSPARK4}, // S_SIGNSPARK3 - {SPR_SGNS, FF_FULLBRIGHT|3, 1, {NULL}, 0, 0, S_SIGNSPARK5}, // S_SIGNSPARK4 - {SPR_SGNS, FF_FULLBRIGHT|4, 1, {NULL}, 0, 0, S_SIGNSPARK6}, // S_SIGNSPARK5 - {SPR_SGNS, FF_FULLBRIGHT|5, 1, {NULL}, 0, 0, S_SIGNSPARK7}, // S_SIGNSPARK6 - {SPR_SGNS, FF_FULLBRIGHT|6, 1, {NULL}, 0, 0, S_SIGNSPARK8}, // S_SIGNSPARK7 - {SPR_SGNS, FF_FULLBRIGHT|7, 1, {NULL}, 0, 0, S_SIGNSPARK9}, // S_SIGNSPARK8 - {SPR_SGNS, FF_FULLBRIGHT|8, 1, {NULL}, 0, 0, S_SIGNSPARK10}, // S_SIGNSPARK9 - {SPR_SGNS, FF_FULLBRIGHT|3, 1, {NULL}, 0, 0, S_SIGNSPARK11}, // S_SIGNSPARK10 - {SPR_SGNS, FF_FULLBRIGHT|2, 1, {NULL}, 0, 0, S_NULL}, // S_SIGNSPARK11 + {SPR_SGNS, FF_ADD|FF_FULLBRIGHT, 1, {NULL}, 0, 0, S_SIGNSPARK2}, // S_SIGNSPARK1 + {SPR_SGNS, FF_ADD|FF_FULLBRIGHT|1, 1, {NULL}, 0, 0, S_SIGNSPARK3}, // S_SIGNSPARK2 + {SPR_SGNS, FF_ADD|FF_FULLBRIGHT|2, 1, {NULL}, 0, 0, S_SIGNSPARK4}, // S_SIGNSPARK3 + {SPR_SGNS, FF_ADD|FF_FULLBRIGHT|3, 1, {NULL}, 0, 0, S_SIGNSPARK5}, // S_SIGNSPARK4 + {SPR_SGNS, FF_ADD|FF_FULLBRIGHT|4, 1, {NULL}, 0, 0, S_SIGNSPARK6}, // S_SIGNSPARK5 + {SPR_SGNS, FF_ADD|FF_FULLBRIGHT|5, 1, {NULL}, 0, 0, S_SIGNSPARK7}, // S_SIGNSPARK6 + {SPR_SGNS, FF_ADD|FF_FULLBRIGHT|6, 1, {NULL}, 0, 0, S_SIGNSPARK8}, // S_SIGNSPARK7 + {SPR_SGNS, FF_ADD|FF_FULLBRIGHT|7, 1, {NULL}, 0, 0, S_SIGNSPARK9}, // S_SIGNSPARK8 + {SPR_SGNS, FF_ADD|FF_FULLBRIGHT|8, 1, {NULL}, 0, 0, S_SIGNSPARK10}, // S_SIGNSPARK9 + {SPR_SGNS, FF_ADD|FF_FULLBRIGHT|3, 1, {NULL}, 0, 0, S_SIGNSPARK11}, // S_SIGNSPARK10 + {SPR_SGNS, FF_ADD|FF_FULLBRIGHT|2, 1, {NULL}, 0, 0, S_NULL}, // S_SIGNSPARK11 {SPR_DRIF, FF_FULLBRIGHT|2, 2, {NULL}, 0, 0, S_DRIFTSPARK_A2}, // S_DRIFTSPARK_A1 {SPR_DRIF, FF_FULLBRIGHT|FF_TRANS20|1, 1, {NULL}, 0, 0, S_DRIFTSPARK_A3}, // S_DRIFTSPARK_A2 From 76874de965719c914ff18165cc1fcc47543eff10 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Thu, 9 Dec 2021 18:32:52 -0500 Subject: [PATCH 115/156] Drop shadow tweaks for OGL - Shadow uses subtractive & additive, like software shadows - Shadow does not change scale or opacity, like software shadows - Fixed shadow the hedgehog seizure --- src/hardware/hw_main.c | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 3bd516a22..9eb7c1104 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -3629,14 +3629,14 @@ static void HWR_DrawDropShadow(mobj_t *thing, fixed_t scale) FOutVector shadowVerts[4]; FSurfaceInfo sSurf; float fscale; float fx; float fy; float offset; + float ph; extracolormap_t *colormap = NULL; UINT8 i; SINT8 flip = P_MobjFlip(thing); + UINT32 tFlag = PF_ReverseSubtract; INT32 light; fixed_t scalemul; - UINT16 alpha; - fixed_t floordiff; fixed_t groundz; fixed_t slopez; pslope_t *groundslope; @@ -3675,33 +3675,32 @@ static void HWR_DrawDropShadow(mobj_t *thing, fixed_t scale) groundz = R_GetShadowZ(thing, &groundslope); - floordiff = abs((flip < 0 ? thing->height : 0) + interpz - groundz); - - alpha = floordiff / (4*FRACUNIT) + 75; - if (alpha >= 255) return; - alpha = 255 - alpha; - gpatch = (patch_t *)W_CachePatchName("DSHADOW", PU_SPRITE); if (!(gpatch && ((GLPatch_t *)gpatch->hardware)->mipmap->format)) return; HWR_GetPatch(gpatch); - scalemul = FixedMul(FRACUNIT - floordiff/640, scale); - scalemul = FixedMul(scalemul, (thing->radius*2) / gpatch->height); + scalemul = FixedMul(scale, (thing->radius * 2) / gpatch->height); + + ph = (float)gpatch->height; fscale = FIXED_TO_FLOAT(scalemul); fx = FIXED_TO_FLOAT(interpx); fy = FIXED_TO_FLOAT(interpy); + if (fscale > 0.0) + { + offset = (ph / 2) * fscale; + } + else + { + return; + } + // 3--2 // | /| // |/ | // 0--1 - if (thing && fabsf(fscale - 1.0f) > 1.0E-36f) - offset = ((gpatch->height)/2) * fscale; - else - offset = (float)((gpatch->height)/2); - shadowVerts[2].x = shadowVerts[3].x = fx + offset; shadowVerts[1].x = shadowVerts[0].x = fx - offset; shadowVerts[1].z = shadowVerts[2].z = fy - offset; @@ -3749,10 +3748,15 @@ static void HWR_DrawDropShadow(mobj_t *thing, fixed_t scale) colormap = thing->subsector->sector->extra_colormap; } - HWR_Lighting(&sSurf, 0, colormap); - sSurf.PolyColor.s.alpha = alpha; + HWR_Lighting(&sSurf, 255, colormap); + sSurf.PolyColor.s.alpha = 255; - HWR_ProcessPolygon(&sSurf, shadowVerts, 4, PF_Translucent|PF_Modulated, SHADER_SPRITE, false); // sprite shader + if (thing->whiteshadow == true) + { + tFlag = PF_Additive; + } + + HWR_ProcessPolygon(&sSurf, shadowVerts, 4, tFlag|PF_Modulated, SHADER_SPRITE, false); // sprite shader } // This is expecting a pointer to an array containing 4 wallVerts for a sprite From a617563bd88c762f1579ad23fcf95c0a4d1eafb9 Mon Sep 17 00:00:00 2001 From: James R Date: Thu, 9 Dec 2021 17:44:23 -0800 Subject: [PATCH 116/156] Add gasp sfx when exiting water, but not with bubble shield --- src/p_mobj.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index 5a9f0925e..9550b0c41 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -3059,7 +3059,16 @@ void P_MobjCheckWater(mobj_t *mobj) return; // The rest of this code only executes on a water state change. - if (waterwasnotset || !!(mobj->eflags & MFE_UNDERWATER) == wasinwater) + if (!!(mobj->eflags & MFE_UNDERWATER) == wasinwater) + return; + + if (p && !p->waterskip && + p->curshield != KSHIELD_BUBBLE && wasinwater) + { + S_StartSound(mobj, sfx_gasp); + } + + if (waterwasnotset) return; if ((p) // Players From 95bfe07d66a2b577600ddd896b60530286e3d699 Mon Sep 17 00:00:00 2001 From: James R Date: Thu, 9 Dec 2021 21:34:41 -0800 Subject: [PATCH 117/156] Enable sprite rotation in OpenGL --- src/hardware/hw_main.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 9eb7c1104..0da791279 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -5249,6 +5249,8 @@ static void HWR_ProjectSprite(mobj_t *thing) spr_topoffset = spritecachedinfo[lumpoff].topoffset; #ifdef ROTSPRITE + spriterotangle = R_SpriteRotationAngle(thing, NULL); + if (spriterotangle != 0 && !(splat && !(thing->renderflags & RF_NOSPLATROLLANGLE))) { From c5e3eb7fff9c614c2f56e42fab49240fe09ea213 Mon Sep 17 00:00:00 2001 From: James R Date: Thu, 9 Dec 2021 18:35:41 -0800 Subject: [PATCH 118/156] Minorly extend squish time --- src/k_kart.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 7401b9d4c..c7b406dc4 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -4545,7 +4545,7 @@ void K_DriftDustHandling(mobj_t *spawner) void K_Squish(mobj_t *mo) { const fixed_t maxstretch = 4*FRACUNIT; - const fixed_t factor = 3 * mo->height / 2; + const fixed_t factor = 5 * mo->height / 4; const fixed_t threshold = factor / 6; const fixed_t old3dspeed = abs(mo->lastmomz); @@ -4571,7 +4571,7 @@ void K_Squish(mobj_t *mo) { mo->spritexscale -= (mo->spritexscale - FRACUNIT) - / (mo->spritexscale < FRACUNIT ? 8 : 2); + / (mo->spritexscale < FRACUNIT ? 8 : 3); } mo->spriteyscale = From 4fc82f0f531d60157ac59bf60327caab86e1f7d9 Mon Sep 17 00:00:00 2001 From: James R Date: Thu, 9 Dec 2021 21:28:46 -0800 Subject: [PATCH 119/156] Squish during huge vertical momentum YIKES --- src/k_kart.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index c7b406dc4..6b4a3dfc0 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -4548,10 +4548,15 @@ void K_Squish(mobj_t *mo) const fixed_t factor = 5 * mo->height / 4; const fixed_t threshold = factor / 6; - const fixed_t old3dspeed = abs(mo->lastmomz); - const fixed_t new3dspeed = abs(mo->momz); + fixed_t old3dspeed = abs(mo->lastmomz); + fixed_t new3dspeed = abs(mo->momz); - const fixed_t delta = abs(old3dspeed - new3dspeed); + fixed_t delta = abs(old3dspeed - new3dspeed); + fixed_t grav = mo->height/3; + fixed_t add = abs(grav - new3dspeed); + + if (delta < 2 * add && new3dspeed > grav) + delta += add; if (delta > threshold) { @@ -4561,7 +4566,7 @@ void K_Squish(mobj_t *mo) if (mo->spritexscale > maxstretch) mo->spritexscale = maxstretch; - if (abs(new3dspeed) > abs(old3dspeed)) + if (new3dspeed > old3dspeed || new3dspeed > grav) { mo->spritexscale = FixedDiv(FRACUNIT, mo->spritexscale); From 4f04c0c4309ab5d86f211e9a7b0a8e403fcca863 Mon Sep 17 00:00:00 2001 From: James R Date: Thu, 9 Dec 2021 22:13:56 -0800 Subject: [PATCH 120/156] Tilt models --- src/hardware/hw_md2.c | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index fc73f87e4..1887574d5 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -1649,23 +1649,26 @@ boolean HWR_DrawModel(gl_vissprite_t *spr) p.angley = FIXED_TO_FLOAT(anglef); } - p.rollangle = 0.0f; - - if (spr->mobj->rollangle) { - fixed_t camAngleDiff = AngleFixed(viewangle) - FLOAT_TO_FIXED(p.angley); // dumb reconversion back, I know - fixed_t anglef = AngleFixed(spr->mobj->rollangle); + fixed_t anglef = AngleFixed(R_SpriteRotationAngle(spr->mobj, NULL)); - p.rollangle = FIXED_TO_FLOAT(anglef); - p.roll = true; + p.rollangle = 0.0f; - // rotation pivot - p.centerx = FIXED_TO_FLOAT(spr->mobj->radius / 2); - p.centery = FIXED_TO_FLOAT(spr->mobj->height / 2); + if (anglef) + { + fixed_t camAngleDiff = AngleFixed(viewangle) - FLOAT_TO_FIXED(p.angley); // dumb reconversion back, I know - // rotation axes relative to camera - p.rollx = FIXED_TO_FLOAT(FINECOSINE(FixedAngle(camAngleDiff) >> ANGLETOFINESHIFT)); - p.rollz = FIXED_TO_FLOAT(FINESINE(FixedAngle(camAngleDiff) >> ANGLETOFINESHIFT)); + p.rollangle = FIXED_TO_FLOAT(anglef); + p.roll = true; + + // rotation pivot + p.centerx = FIXED_TO_FLOAT(spr->mobj->radius / 2); + p.centery = FIXED_TO_FLOAT(spr->mobj->height / 2); + + // rotation axes relative to camera + p.rollx = FIXED_TO_FLOAT(FINECOSINE(FixedAngle(camAngleDiff) >> ANGLETOFINESHIFT)); + p.rollz = FIXED_TO_FLOAT(FINESINE(FixedAngle(camAngleDiff) >> ANGLETOFINESHIFT)); + } } p.anglez = FIXED_TO_FLOAT(AngleFixed(spr->mobj->pitch)); From 1ac123246dfff52072d75f049449c87013d6459c Mon Sep 17 00:00:00 2001 From: James R Date: Thu, 9 Dec 2021 22:41:35 -0800 Subject: [PATCH 121/156] Model stretching --- src/hardware/hw_drv.h | 4 ++-- src/hardware/hw_md2.c | 6 +++++- src/hardware/r_opengl/r_opengl.c | 15 ++++++++------- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/hardware/hw_drv.h b/src/hardware/hw_drv.h index b48d39b9c..4f6046123 100644 --- a/src/hardware/hw_drv.h +++ b/src/hardware/hw_drv.h @@ -51,7 +51,7 @@ EXPORT void HWRAPI(ClearMipMapCache) (void); EXPORT void HWRAPI(SetSpecialState) (hwdspecialstate_t IdState, INT32 Value); //Hurdler: added for new development -EXPORT void HWRAPI(DrawModel) (model_t *model, INT32 frameIndex, INT32 duration, INT32 tics, INT32 nextFrameIndex, FTransform *pos, float scale, UINT8 flipped, UINT8 hflipped, FSurfaceInfo *Surface); +EXPORT void HWRAPI(DrawModel) (model_t *model, INT32 frameIndex, INT32 duration, INT32 tics, INT32 nextFrameIndex, FTransform *pos, float hscale, float vscale, UINT8 flipped, UINT8 hflipped, FSurfaceInfo *Surface); EXPORT void HWRAPI(CreateModelVBOs) (model_t *model); EXPORT void HWRAPI(SetTransform) (FTransform *stransform); EXPORT INT32 HWRAPI(GetTextureUsed) (void); @@ -136,4 +136,4 @@ extern struct hwdriver_s hwdriver; #endif //not defined _CREATE_DLL_ -#endif //__HWR_DRV_H__ \ No newline at end of file +#endif //__HWR_DRV_H__ diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index 1887574d5..259770fee 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -1681,7 +1681,11 @@ boolean HWR_DrawModel(gl_vissprite_t *spr) p.mirror = atransform.mirror; HWD.pfnSetShader(SHADER_MODEL); // model shader - HWD.pfnDrawModel(md2->model, frame, durs, tics, nextFrame, &p, finalscale, flip, hflip, &Surf); + { + float xs = finalscale * FIXED_TO_FLOAT(spr->mobj->spritexscale); + float ys = finalscale * FIXED_TO_FLOAT(spr->mobj->spriteyscale); + HWD.pfnDrawModel(md2->model, frame, durs, tics, nextFrame, &p, xs, ys, flip, hflip, &Surf); + } } return true; diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 84d6ded6e..b2762dcbf 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -2688,7 +2688,7 @@ EXPORT void HWRAPI(CreateModelVBOs) (model_t *model) #define BUFFER_OFFSET(i) ((void*)(i)) -static void DrawModelEx(model_t *model, INT32 frameIndex, INT32 duration, INT32 tics, INT32 nextFrameIndex, FTransform *pos, float scale, UINT8 flipped, UINT8 hflipped, FSurfaceInfo *Surface) +static void DrawModelEx(model_t *model, INT32 frameIndex, INT32 duration, INT32 tics, INT32 nextFrameIndex, FTransform *pos, float hscale, float vscale, UINT8 flipped, UINT8 hflipped, FSurfaceInfo *Surface) { static GLRGBAFloat poly = {0,0,0,0}; static GLRGBAFloat tint = {0,0,0,0}; @@ -2712,10 +2712,11 @@ static void DrawModelEx(model_t *model, INT32 frameIndex, INT32 duration, INT32 #endif // Affect input model scaling - scale *= 0.5f; - scalex = scale; - scaley = scale; - scalez = scale; + hscale *= 0.5f; + vscale *= 0.5f; + scalex = hscale; + scaley = vscale; + scalez = hscale; if (duration != 0 && duration != -1 && tics != -1) // don't interpolate if instantaneous or infinite in length { @@ -2973,9 +2974,9 @@ static void DrawModelEx(model_t *model, INT32 frameIndex, INT32 duration, INT32 // -----------------+ // HWRAPI DrawModel : Draw a model // -----------------+ -EXPORT void HWRAPI(DrawModel) (model_t *model, INT32 frameIndex, INT32 duration, INT32 tics, INT32 nextFrameIndex, FTransform *pos, float scale, UINT8 flipped, UINT8 hflipped, FSurfaceInfo *Surface) +EXPORT void HWRAPI(DrawModel) (model_t *model, INT32 frameIndex, INT32 duration, INT32 tics, INT32 nextFrameIndex, FTransform *pos, float hscale, float vscale, UINT8 flipped, UINT8 hflipped, FSurfaceInfo *Surface) { - DrawModelEx(model, frameIndex, duration, tics, nextFrameIndex, pos, scale, flipped, hflipped, Surface); + DrawModelEx(model, frameIndex, duration, tics, nextFrameIndex, pos, hscale, vscale, flipped, hflipped, Surface); } // -----------------+ From a90520ebdcad4f7485d53b86df8b057809bbddcd Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 10 Dec 2021 00:32:46 -0800 Subject: [PATCH 122/156] Do not factor roll and pitch into model rollangle Those transformations are applied separately so the model tilts in 3d space. --- src/hardware/hw_md2.c | 2 +- src/r_patch.h | 1 + src/r_patchrotation.c | 11 ++++++++--- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/hardware/hw_md2.c b/src/hardware/hw_md2.c index 259770fee..95077a54a 100644 --- a/src/hardware/hw_md2.c +++ b/src/hardware/hw_md2.c @@ -1650,7 +1650,7 @@ boolean HWR_DrawModel(gl_vissprite_t *spr) } { - fixed_t anglef = AngleFixed(R_SpriteRotationAngle(spr->mobj, NULL)); + fixed_t anglef = AngleFixed(R_ModelRotationAngle(spr->mobj, NULL)); p.rollangle = 0.0f; diff --git a/src/r_patch.h b/src/r_patch.h index 601144a1d..b86908281 100644 --- a/src/r_patch.h +++ b/src/r_patch.h @@ -42,6 +42,7 @@ patch_t *Patch_GetRotatedSprite( INT32 R_GetRollAngle(angle_t rollangle); angle_t R_GetPitchRollAngle(mobj_t *mobj, player_t *viewPlayer); +angle_t R_ModelRotationAngle(mobj_t *mobj, player_t *viewPlayer); angle_t R_SpriteRotationAngle(mobj_t *mobj, player_t *viewPlayer); #endif diff --git a/src/r_patchrotation.c b/src/r_patchrotation.c index 24c1de5d2..74afeb396 100644 --- a/src/r_patchrotation.c +++ b/src/r_patchrotation.c @@ -64,10 +64,9 @@ static angle_t R_PlayerSpriteRotation(player_t *player, player_t *viewPlayer) return rollAngle; } -angle_t R_SpriteRotationAngle(mobj_t *mobj, player_t *viewPlayer) +angle_t R_ModelRotationAngle(mobj_t *mobj, player_t *viewPlayer) { - angle_t rollOrPitch = R_GetPitchRollAngle(mobj, viewPlayer); - angle_t rollAngle = (rollOrPitch + mobj->rollangle); + angle_t rollAngle = mobj->rollangle; if (mobj->player) { @@ -77,6 +76,12 @@ angle_t R_SpriteRotationAngle(mobj_t *mobj, player_t *viewPlayer) return rollAngle; } +angle_t R_SpriteRotationAngle(mobj_t *mobj, player_t *viewPlayer) +{ + angle_t rollOrPitch = R_GetPitchRollAngle(mobj, viewPlayer); + return (rollOrPitch + R_ModelRotationAngle(mobj, viewPlayer)); +} + INT32 R_GetRollAngle(angle_t rollangle) { INT32 ra = AngleFixed(rollangle)>>FRACBITS; From a3d5804da9c80c8b872735a14239fe9f81ce6681 Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 10 Dec 2021 02:45:32 -0800 Subject: [PATCH 123/156] Let flame shield resist slope butter --- src/k_kart.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/k_kart.c b/src/k_kart.c index 6b4a3dfc0..924195239 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -2682,7 +2682,7 @@ boolean K_ApplyOffroad(player_t *player) boolean K_SlopeResistance(player_t *player) { - if (player->invincibilitytimer || player->sneakertimer || player->tiregrease) + if (player->invincibilitytimer || player->sneakertimer || player->tiregrease || player->flamedash) return true; return false; } From 1adbfcff03fd256793dad2761f88b9ac49475269 Mon Sep 17 00:00:00 2001 From: SinnamonLat Date: Fri, 10 Dec 2021 14:16:20 +0100 Subject: [PATCH 124/156] Remove Landmine dust ring on explosion --- src/p_enemy.c | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/src/p_enemy.c b/src/p_enemy.c index 7d4ad7400..51319d229 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -14143,7 +14143,6 @@ void A_LandMineExplode(mobj_t *actor) INT32 colour = SKINCOLOR_KETCHUP; // we spell words properly here INT32 i; mobj_t *smoldering; - mobj_t *dust; if (LUA_CallAction(A_LANDMINEEXPLODE, actor)) return; @@ -14161,18 +14160,6 @@ void A_LandMineExplode(mobj_t *actor) P_SetScale(smoldering, actor->scale); smoldering->tics = TICRATE*3; - // Spawn a ring: - for (i = 0; i < 32; i++) - { - dust = P_SpawnMobj(actor->x, actor->y, actor->z, MT_SMOKE); - P_SetMobjState(dust, S_OPAQUESMOKE1); - dust->angle = (ANGLE_180/16) * i; - P_SetScale(dust, actor->scale); - dust->destscale = actor->scale*4; - dust->scalespeed = actor->scale/4; - P_InstaThrust(dust, dust->angle, FixedMul(20*FRACUNIT, actor->scale)); - } - actor->fuse = actor->tics; // disappear when this state ends. // spawn a few physics explosions From 07d5691b73673635a9e77f25d6c141f89420c99f Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Fri, 10 Dec 2021 16:23:41 -0500 Subject: [PATCH 125/156] Make them commit harder to turning - Removed the "minor adjustment" threshold, since that was done before global easing - Removed the "accel + brake to slowdown and reorient yourself if you're facing too far away from the track" bit, because 1.) it was done before accel + brake was turned into EBrake (so it now often makes them come to a STOP instead of simply slowing down) and 2.) turning harshly will slow them down anyway, so maybe isn't necessary --- src/k_bot.c | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/src/k_bot.c b/src/k_bot.c index 435eb1c6b..9c5dff35b 100644 --- a/src/k_bot.c +++ b/src/k_bot.c @@ -1120,18 +1120,6 @@ void K_BuildBotTiccmd(player_t *player, ticcmd_t *cmd) // Don't turn at all turnamt = 0; } - else - { - // Make minor adjustments - turnamt /= 4; - } - } - - if (anglediff > 60) - { - // Actually, don't go too fast... - cmd->forwardmove /= 2; - cmd->buttons |= BT_BRAKE; } } } From 19463d6b207afb1a90f9e1b009ff48b473833fc0 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Fri, 10 Dec 2021 17:42:00 -0500 Subject: [PATCH 126/156] New bot prediction wall detection Instead of searching for walls around the player, and then deciding to make the radius tighter if it found anyway, it instead checks if the waypoint it's trying to predict towards was blocked by any walls / hazards. Needs adjusted some, I think its being pulled back too hard sometimes, but I am optimistic about some of the improvements I already saw. --- src/k_bot.c | 37 ++++++++-- src/k_bot.h | 15 ++-- src/k_botsearch.c | 181 +-------------------------------------------- src/p_local.h | 3 + src/p_map.c | 56 +++++++++----- src/p_sight.c | 182 +++++++++++++++++++++++++++++++++++++++++++++- 6 files changed, 265 insertions(+), 209 deletions(-) diff --git a/src/k_bot.c b/src/k_bot.c index 9c5dff35b..1d9b8ff83 100644 --- a/src/k_bot.c +++ b/src/k_bot.c @@ -575,14 +575,11 @@ static botprediction_t *K_CreateBotPrediction(player_t *player) const INT16 handling = K_GetKartTurnValue(player, KART_FULLTURN); // Reduce prediction based on how fast you can turn const INT16 normal = KART_FULLTURN; // "Standard" handling to compare to - const fixed_t distreduce = K_BotReducePrediction(player); - const fixed_t radreduce = min(distreduce + FRACUNIT/4, FRACUNIT); - const tic_t futuresight = (TICRATE * normal) / max(1, handling); // How far ahead into the future to try and predict - const fixed_t speed = max(P_AproxDistance(player->rmomx, player->rmomy), K_GetKartSpeed(player, false)); + const fixed_t speed = P_AproxDistance(player->rmomx, player->rmomy); - const INT32 startDist = (768 * mapobjectscale) / FRACUNIT; - const INT32 distance = ((FixedMul(speed, distreduce) / FRACUNIT) * futuresight) + startDist; + const INT32 startDist = (1536 * mapobjectscale) / FRACUNIT; + const INT32 distance = ((speed / FRACUNIT) * futuresight) + startDist; botprediction_t *predict = Z_Calloc(sizeof(botprediction_t), PU_STATIC, NULL); waypoint_t *wp = player->nextwaypoint; @@ -591,6 +588,9 @@ static botprediction_t *K_CreateBotPrediction(player_t *player) fixed_t smallestradius = INT32_MAX; angle_t angletonext = ANGLE_MAX; + // Halves radius when encountering a wall on your way to your destination. + fixed_t radreduce = FRACUNIT; + size_t nwp; size_t i; @@ -603,7 +603,7 @@ static botprediction_t *K_CreateBotPrediction(player_t *player) { predict->x = wp->mobj->x; predict->y = wp->mobj->y; - predict->radius = FixedMul(wp->mobj->radius, radreduce); + predict->radius = wp->mobj->radius; return predict; } @@ -653,6 +653,11 @@ static botprediction_t *K_CreateBotPrediction(player_t *player) continue; } + if (P_TraceBotTraversal(player->mo, wp->nextwaypoints[i]->mobj) == false) + { + continue; + } + // Unlike the other parts of this function, we're comparing the player's physical position, NOT the position of the waypoint!! // This should roughly correspond with how players will think about path splits. a = R_PointToAngle2( @@ -672,6 +677,24 @@ static botprediction_t *K_CreateBotPrediction(player_t *player) delta = a; } } + + if (i == wp->numnextwaypoints) + { + // No usable waypoint, we don't want to check any further + radreduce /= 2; + distanceleft = 0; + break; + } + } + else + { + if (P_TraceBotTraversal(player->mo, wp->nextwaypoints[nwp]->mobj) == false) + { + // If we can't get a direct path to this waypoint, we don't want to check any further. + radreduce /= 2; + distanceleft = 0; + break; + } } angletonext = R_PointToAngle2( diff --git a/src/k_bot.h b/src/k_bot.h index 94694c2dd..41c8df5e0 100644 --- a/src/k_bot.h +++ b/src/k_bot.h @@ -185,19 +185,22 @@ UINT8 K_EggboxStealth(fixed_t x, fixed_t y); /*-------------------------------------------------- - fixed_t K_BotReducePrediction(player_t *player); + boolean K_BotHatesThisSector(player_t *player, sector_t *sec, fixed_t x, fixed_t y) - Finds walls nearby the specified player, to create a multiplier - to pull bot predictions back by. + Tells us if a bot will play more careful around + this sector. Checks FOFs in the sector, as well. Input Arguments:- - player - Player to compare. + player - Player to check against. + sec - Sector to check against. + x - Linedef cross X position, for slopes + y - Linedef cross Y position, for slopes Return:- - Multiplier in fixed point scale. + true if avoiding this sector, false otherwise. --------------------------------------------------*/ -fixed_t K_BotReducePrediction(player_t *player); +boolean K_BotHatesThisSector(player_t *player, sector_t *sec, fixed_t x, fixed_t y); /*-------------------------------------------------- diff --git a/src/k_botsearch.c b/src/k_botsearch.c index 80650030d..846521e6f 100644 --- a/src/k_botsearch.c +++ b/src/k_botsearch.c @@ -162,21 +162,11 @@ static boolean K_BotHatesThisSectorsSpecial(player_t *player, sector_t *sec) } /*-------------------------------------------------- - static boolean K_BotHatesThisSector(player_t *player, sector_t *sec, fixed_t x, fixed_t y) + boolean K_BotHatesThisSector(player_t *player, sector_t *sec, fixed_t x, fixed_t y) - Tells us if a bot will play more careful around - this sector. Checks FOFs in the sector, as well. - - Input Arguments:- - player - Player to check against. - sec - Sector to check against. - x - Linedef cross X position, for slopes - y - Linedef cross Y position, for slopes - - Return:- - true if avoiding this sector, false otherwise. + See header file for description. --------------------------------------------------*/ -static boolean K_BotHatesThisSector(player_t *player, sector_t *sec, fixed_t x, fixed_t y) +boolean K_BotHatesThisSector(player_t *player, sector_t *sec, fixed_t x, fixed_t y) { const boolean flip = (player->mo->eflags & MFE_VERTICALFLIP); INT32 specialflag = 0; @@ -257,171 +247,6 @@ static boolean K_BotHatesThisSector(player_t *player, sector_t *sec, fixed_t x, return K_BotHatesThisSectorsSpecial(player, bestsector); } -/*-------------------------------------------------- - static boolean K_FindBlockingWalls(line_t *line) - - Blockmap search function. - Reels the bot prediction back in based on solid walls - or other obstacles surrounding the bot. - - Input Arguments:- - line - Linedef passed in from iteration. - - Return:- - true continues searching, false ends the search early. ---------------------------------------------------*/ -static boolean K_FindBlockingWalls(line_t *line) -{ - // Condensed version of PIT_CheckLine - const fixed_t maxstepmove = FixedMul(MAXSTEPMOVE, mapobjectscale); - fixed_t maxstep = maxstepmove; - fixed_t linedist = INT32_MAX; - INT32 lineside = 0; - vertex_t pos; - - if (!globalsmuggle.botmo || P_MobjWasRemoved(globalsmuggle.botmo) || !globalsmuggle.botmo->player) - { - return false; - } - - if (line->polyobj && !(line->polyobj->flags & POF_SOLID)) - { - return true; - } - - if (tmbbox[BOXRIGHT] <= line->bbox[BOXLEFT] || tmbbox[BOXLEFT] >= line->bbox[BOXRIGHT] - || tmbbox[BOXTOP] <= line->bbox[BOXBOTTOM] || tmbbox[BOXBOTTOM] >= line->bbox[BOXTOP]) - { - return true; - } - - if (P_BoxOnLineSide(tmbbox, line) != -1) - { - return true; - } - - lineside = P_PointOnLineSide(globalsmuggle.botmo->x, globalsmuggle.botmo->y, line); - - // one sided line - if (!line->backsector) - { - if (lineside) - { - // don't hit the back side - return true; - } - - goto blocked; - } - - if ((line->flags & ML_IMPASSABLE) || (line->flags & ML_BLOCKPLAYERS)) - { - goto blocked; - } - - // set openrange, opentop, openbottom - P_LineOpening(line, globalsmuggle.botmo); - - if (globalsmuggle.botmo->player->waterskip) - maxstep += maxstepmove; - - if (P_MobjTouchingSectorSpecial(globalsmuggle.botmo, 1, 13, false)) - maxstep <<= 1; - else if (P_MobjTouchingSectorSpecial(globalsmuggle.botmo, 1, 12, false)) - maxstep = 0; - - if ((openrange < globalsmuggle.botmo->height) // doesn't fit - || (opentop - globalsmuggle.botmo->z < globalsmuggle.botmo->height) // mobj is too high - || (openbottom - globalsmuggle.botmo->z > maxstep)) // too big a step up - { - goto blocked; - } - - // Treat damage sectors like walls - P_ClosestPointOnLine(globalsmuggle.botmo->x, globalsmuggle.botmo->y, line, &pos); - - if (lineside) - { - if (K_BotHatesThisSector(globalsmuggle.botmo->player, line->frontsector, pos.x, pos.y)) - goto blocked; - } - else - { - if (K_BotHatesThisSector(globalsmuggle.botmo->player, line->backsector, pos.x, pos.y)) - goto blocked; - } - - // We weren't blocked! - return true; - -blocked: - linedist = K_DistanceOfLineFromPoint(line->v1->x, line->v1->y, line->v2->x, line->v2->y, globalsmuggle.botmo->x, globalsmuggle.botmo->y); - linedist -= (globalsmuggle.botmo->radius * 8); // Maintain a reasonable distance away from it - - if (linedist > globalsmuggle.distancetocheck) - { - return true; - } - - if (linedist <= 0) - { - globalsmuggle.closestlinedist = 0; - return false; - } - - if (linedist < globalsmuggle.closestlinedist) - { - globalsmuggle.closestlinedist = linedist; - } - - return true; -} - -/*-------------------------------------------------- - fixed_t K_BotReducePrediction(player_t *player) - - See header file for description. ---------------------------------------------------*/ -fixed_t K_BotReducePrediction(player_t *player) -{ - INT32 xl, xh, yl, yh, bx, by; - - globalsmuggle.botmo = player->mo; - globalsmuggle.distancetocheck = (player->mo->radius * 32); - globalsmuggle.closestlinedist = INT32_MAX; - - tmx = player->mo->x; - tmy = player->mo->y; - - xl = (unsigned)(tmx - globalsmuggle.distancetocheck - bmaporgx)>>MAPBLOCKSHIFT; - xh = (unsigned)(tmx + globalsmuggle.distancetocheck - bmaporgx)>>MAPBLOCKSHIFT; - yl = (unsigned)(tmy - globalsmuggle.distancetocheck - bmaporgy)>>MAPBLOCKSHIFT; - yh = (unsigned)(tmy + globalsmuggle.distancetocheck - bmaporgy)>>MAPBLOCKSHIFT; - - BMBOUNDFIX(xl, xh, yl, yh); - - tmbbox[BOXTOP] = tmy + globalsmuggle.distancetocheck; - tmbbox[BOXBOTTOM] = tmy - globalsmuggle.distancetocheck; - tmbbox[BOXRIGHT] = tmx + globalsmuggle.distancetocheck; - tmbbox[BOXLEFT] = tmx - globalsmuggle.distancetocheck; - - // Check for lines that the bot might collide with - for (bx = xl; bx <= xh; bx++) - { - for (by = yl; by <= yh; by++) - { - P_BlockLinesIterator(bx, by, K_FindBlockingWalls); - } - } - - if (globalsmuggle.closestlinedist == INT32_MAX) - { - return FRACUNIT; - } - - return (FRACUNIT/2) + (FixedDiv(globalsmuggle.closestlinedist, globalsmuggle.distancetocheck) / 2); -} - /*-------------------------------------------------- static void K_AddAttackObject(mobj_t *thing, UINT8 side, UINT8 weight) diff --git a/src/p_local.h b/src/p_local.h index db9e9e6dd..d90bfde4c 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -404,6 +404,8 @@ boolean P_IsLineBlocking(const line_t *ld, const mobj_t *thing); boolean P_IsLineTripWire(const line_t *ld); boolean P_CheckPosition(mobj_t *thing, fixed_t x, fixed_t y); boolean P_CheckCameraPosition(fixed_t x, fixed_t y, camera_t *thiscam); +fixed_t P_BaseStepUp(void); +fixed_t P_GetThingStepUp(mobj_t *thing); boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff); boolean P_Move(mobj_t *actor, fixed_t speed); boolean P_SetOrigin(mobj_t *thing, fixed_t x, fixed_t y, fixed_t z); @@ -413,6 +415,7 @@ void P_BouncePlayerMove(mobj_t *mo); void P_BounceMove(mobj_t *mo); boolean P_CheckSight(mobj_t *t1, mobj_t *t2); boolean P_TraceBlockingLines(mobj_t *t1, mobj_t *t2); +boolean P_TraceBotTraversal(mobj_t *t1, mobj_t *t2); void P_CheckHoopPosition(mobj_t *hoopthing, fixed_t x, fixed_t y, fixed_t z, fixed_t radius); boolean P_CheckSector(sector_t *sector, boolean crunch); diff --git a/src/p_map.c b/src/p_map.c index bcecb1dfa..966c332b8 100644 --- a/src/p_map.c +++ b/src/p_map.c @@ -2428,6 +2428,42 @@ static boolean P_WaterStepUp(mobj_t *thing) P_WaterRunning(thing); } +fixed_t P_BaseStepUp(void) +{ + return FixedMul(MAXSTEPMOVE, mapobjectscale); +} + +fixed_t P_GetThingStepUp(mobj_t *thing) +{ + const fixed_t maxstepmove = P_BaseStepUp(); + fixed_t maxstep = maxstepmove; + + if (thing->type == MT_SKIM) + { + // Skim special (not needed for kart?) + return 0; + } + + if (P_WaterStepUp(thing) == true) + { + // Add some extra stepmove when waterskipping + maxstep += maxstepmove; + } + + if (P_MobjTouchingSectorSpecial(thing, 1, 13, false)) + { + // If using type Section1:13, double the maxstep. + maxstep <<= 1; + } + else if (P_MobjTouchingSectorSpecial(thing, 1, 12, false)) + { + // If using type Section1:12, no maxstep. For short walls, like Egg Zeppelin + maxstep = 0; + } + + return maxstep; +} + // // P_TryMove // Attempt to move to a new position. @@ -2489,21 +2525,7 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff) if (!(thing->flags & MF_NOCLIP)) { //All things are affected by their scale. - const fixed_t maxstepmove = FixedMul(MAXSTEPMOVE, mapobjectscale); - fixed_t maxstep = maxstepmove; - - if (thing->player && P_WaterStepUp(thing)) - maxstep += maxstepmove; // Add some extra stepmove when waterskipping - - // If using type Section1:13, double the maxstep. - if (P_MobjTouchingSectorSpecial(thing, 1, 13, false)) - maxstep <<= 1; - // If using type Section1:12, no maxstep. For short walls, like Egg Zeppelin - else if (P_MobjTouchingSectorSpecial(thing, 1, 12, false)) - maxstep = 0; - - if (thing->type == MT_SKIM) - maxstep = 0; + fixed_t maxstep = P_GetThingStepUp(thing); if (tmceilingz - tmfloorz < thing->height) { @@ -2740,7 +2762,7 @@ boolean P_SceneryTryMove(mobj_t *thing, fixed_t x, fixed_t y) if (!(thing->flags & MF_NOCLIP)) { - const fixed_t maxstep = FixedMul(MAXSTEPMOVE, mapobjectscale); + const fixed_t maxstep = P_BaseStepUp(); if (tmceilingz - tmfloorz < thing->height) return false; // doesn't fit @@ -3202,7 +3224,7 @@ static boolean PTR_LineIsBlocking(line_t *li) if (opentop - slidemo->z < slidemo->height) return true; // mobj is too high - if (openbottom - slidemo->z > FixedMul(MAXSTEPMOVE, mapobjectscale)) + if (openbottom - slidemo->z > P_GetThingStepUp(slidemo)) return true; // too big a step up return false; diff --git a/src/p_sight.c b/src/p_sight.c index 38a50df36..a5aebf55c 100644 --- a/src/p_sight.c +++ b/src/p_sight.c @@ -18,6 +18,8 @@ #include "r_main.h" #include "r_state.h" +#include "k_bot.h" // K_BotHatesThisSector + // // P_CheckSight // @@ -572,7 +574,7 @@ static boolean P_CrossBlockingSubsector(size_t num, register traceblocking_t *tb if (P_IsLineBlocking(line, tb->compareThing) == true) { - // This line will block us + // This line will always block us return false; } } @@ -656,3 +658,181 @@ boolean P_TraceBlockingLines(mobj_t *t1, mobj_t *t2) // the head node is the last node output return P_CrossBSPNodeBlocking((INT32)numnodes - 1, &tb); } + +// +// ANOTHER version, this time for bot traversal. +// (TODO: since we have so many versions of this function, the differences +// should maybe just be a function var that gets called?) +// + +static boolean P_CrossBotTraversalSubsector(size_t num, register traceblocking_t *tb) +{ + seg_t *seg; + INT32 count; + +#ifdef RANGECHECK + if (num >= numsubsectors) + I_Error("P_CrossBotTraversalSubsector: ss %s with numss = %s\n", sizeu1(num), sizeu2(numsubsectors)); +#endif + + // haleyjd 02/23/06: this assignment should be after the above check + seg = segs + subsectors[num].firstline; + + for (count = subsectors[num].numlines; --count >= 0; seg++) // check lines + { + line_t *line = seg->linedef; + divline_t divl; + const vertex_t *v1,*v2; + fixed_t maxstep = INT32_MAX; + + if (seg->glseg) + continue; + + // already checked other side? + if (line->validcount == validcount) + continue; + + line->validcount = validcount; + + // OPTIMIZE: killough 4/20/98: Added quick bounding-box rejection test + if (line->bbox[BOXLEFT ] > tb->bbox[BOXRIGHT ] || + line->bbox[BOXRIGHT ] < tb->bbox[BOXLEFT ] || + line->bbox[BOXBOTTOM] > tb->bbox[BOXTOP ] || + line->bbox[BOXTOP] < tb->bbox[BOXBOTTOM]) + continue; + + v1 = line->v1; + v2 = line->v2; + + // line isn't crossed? + if (P_DivlineSide(v1->x, v1->y, &tb->strace) == + P_DivlineSide(v2->x, v2->y, &tb->strace)) + continue; + + // stop because it is not two sided anyway + if (!(line->flags & ML_TWOSIDED)) + return false; + + divl.dx = v2->x - (divl.x = v1->x); + divl.dy = v2->y - (divl.y = v1->y); + + // line isn't crossed? + if (P_DivlineSide(tb->strace.x, tb->strace.y, &divl) == + P_DivlineSide(tb->t2x, tb->t2y, &divl)) + continue; + + if (P_IsLineBlocking(line, tb->compareThing) == true) + { + // This line will always block us + return false; + } + + // set openrange, opentop, openbottom + P_LineOpening(line, tb->compareThing); + maxstep = P_GetThingStepUp(tb->compareThing); + + if ((openrange < tb->compareThing->height) // doesn't fit + || (opentop - tb->compareThing->z < tb->compareThing->height) // mobj is too high + || (openbottom - tb->compareThing->z > maxstep)) // too big a step up + { + // This line situationally blocks us + return false; + } + + // Treat damage sectors like walls + if (tb->compareThing->player != NULL) + { + INT32 lineside = 0; + vertex_t pos; + + P_ClosestPointOnLine(tb->compareThing->x, tb->compareThing->y, line, &pos); + lineside = P_PointOnLineSide(tb->compareThing->x, tb->compareThing->y, line); + + if (K_BotHatesThisSector(tb->compareThing->player, lineside ? line->frontsector : line->backsector, pos.x, pos.y)) + { + // This line does not block us, but we don't want to be in it. + return false; + } + } + } + + // passed the subsector ok + return true; +} + +static boolean P_CrossBSPNodeBotTraversal(INT32 bspnum, register traceblocking_t *tb) +{ + while (!(bspnum & NF_SUBSECTOR)) + { + register node_t *bsp = nodes + bspnum; + INT32 side = P_DivlineSide(tb->strace.x,tb->strace.y,(divline_t *)bsp)&1; + if (side == P_DivlineSide(tb->t2x, tb->t2y, (divline_t *) bsp)) + bspnum = bsp->children[side]; // doesn't touch the other side + else // the partition plane is crossed here + { + if (!P_CrossBSPNodeBotTraversal(bsp->children[side], tb)) + return false; // cross the starting side + else + bspnum = bsp->children[side^1]; // cross the ending side + } + } + + return P_CrossBotTraversalSubsector((bspnum == -1 ? 0 : bspnum & ~NF_SUBSECTOR), tb); +} + +boolean P_TraceBotTraversal(mobj_t *t1, mobj_t *t2) +{ + const sector_t *s1, *s2; + size_t pnum; + traceblocking_t tb; + + // First check for trivial rejection. + if (!t1 || !t2) + return false; + + I_Assert(!P_MobjWasRemoved(t1)); + I_Assert(!P_MobjWasRemoved(t2)); + + if (!t1->subsector || !t2->subsector + || !t1->subsector->sector || !t2->subsector->sector) + return false; + + s1 = t1->subsector->sector; + s2 = t2->subsector->sector; + pnum = (s1-sectors)*numsectors + (s2-sectors); + + if (rejectmatrix != NULL) + { + // Check in REJECT table. + if (rejectmatrix[pnum>>3] & (1 << (pnum&7))) // can't possibly be connected + return false; + } + + // killough 11/98: shortcut for melee situations + // same subsector? obviously visible + // haleyjd 02/23/06: can't do this if there are polyobjects in the subsec + if (!t1->subsector->polyList && + t1->subsector == t2->subsector) + return true; + + validcount++; + + tb.strace.dx = (tb.t2x = t2->x) - (tb.strace.x = t1->x); + tb.strace.dy = (tb.t2y = t2->y) - (tb.strace.y = t1->y); + + if (t1->x > t2->x) + tb.bbox[BOXRIGHT] = t1->x, tb.bbox[BOXLEFT] = t2->x; + else + tb.bbox[BOXRIGHT] = t2->x, tb.bbox[BOXLEFT] = t1->x; + + if (t1->y > t2->y) + tb.bbox[BOXTOP] = t1->y, tb.bbox[BOXBOTTOM] = t2->y; + else + tb.bbox[BOXTOP] = t2->y, tb.bbox[BOXBOTTOM] = t1->y; + + tb.compareThing = t1; + + // the head node is the last node output + return P_CrossBSPNodeBotTraversal((INT32)numnodes - 1, &tb); +} + From 08bfd6e8811f77a666235f79215ce7d6104d72e4 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Sat, 11 Dec 2021 01:51:40 -0500 Subject: [PATCH 127/156] Improve the new wall detection further They didn't fall off on Hardhat, I'm so proud of my sons --- src/k_bot.c | 34 +++++++++------------------------- src/k_bot.h | 1 + src/p_sight.c | 21 +++++++++++++-------- 3 files changed, 23 insertions(+), 33 deletions(-) diff --git a/src/k_bot.c b/src/k_bot.c index 1d9b8ff83..d11142119 100644 --- a/src/k_bot.c +++ b/src/k_bot.c @@ -576,9 +576,9 @@ static botprediction_t *K_CreateBotPrediction(player_t *player) const INT16 normal = KART_FULLTURN; // "Standard" handling to compare to const tic_t futuresight = (TICRATE * normal) / max(1, handling); // How far ahead into the future to try and predict - const fixed_t speed = P_AproxDistance(player->rmomx, player->rmomy); + const fixed_t speed = P_AproxDistance(player->mo->momx, player->mo->momy); - const INT32 startDist = (1536 * mapobjectscale) / FRACUNIT; + const INT32 startDist = (768 * mapobjectscale) / FRACUNIT; const INT32 distance = ((speed / FRACUNIT) * futuresight) + startDist; botprediction_t *predict = Z_Calloc(sizeof(botprediction_t), PU_STATIC, NULL); @@ -653,11 +653,6 @@ static botprediction_t *K_CreateBotPrediction(player_t *player) continue; } - if (P_TraceBotTraversal(player->mo, wp->nextwaypoints[i]->mobj) == false) - { - continue; - } - // Unlike the other parts of this function, we're comparing the player's physical position, NOT the position of the waypoint!! // This should roughly correspond with how players will think about path splits. a = R_PointToAngle2( @@ -677,24 +672,6 @@ static botprediction_t *K_CreateBotPrediction(player_t *player) delta = a; } } - - if (i == wp->numnextwaypoints) - { - // No usable waypoint, we don't want to check any further - radreduce /= 2; - distanceleft = 0; - break; - } - } - else - { - if (P_TraceBotTraversal(player->mo, wp->nextwaypoints[nwp]->mobj) == false) - { - // If we can't get a direct path to this waypoint, we don't want to check any further. - radreduce /= 2; - distanceleft = 0; - break; - } } angletonext = R_PointToAngle2( @@ -704,6 +681,13 @@ static botprediction_t *K_CreateBotPrediction(player_t *player) disttonext = (INT32)wp->nextwaypointdistances[nwp]; + if (P_TraceBotTraversal(player->mo, wp->nextwaypoints[nwp]->mobj) == false) + { + // If we can't get a direct path to this waypoint, we don't want to check much further... + disttonext *= 2; + radreduce = FRACUNIT/2; + } + if (disttonext > distanceleft) { break; diff --git a/src/k_bot.h b/src/k_bot.h index 41c8df5e0..d354bbb2c 100644 --- a/src/k_bot.h +++ b/src/k_bot.h @@ -15,6 +15,7 @@ #include "k_waypoint.h" #include "d_player.h" +#include "r_defs.h" // Maximum value of botvars.difficulty #define MAXBOTDIFFICULTY 9 diff --git a/src/p_sight.c b/src/p_sight.c index a5aebf55c..8e63f1be4 100644 --- a/src/p_sight.c +++ b/src/p_sight.c @@ -742,16 +742,21 @@ static boolean P_CrossBotTraversalSubsector(size_t num, register traceblocking_t // Treat damage sectors like walls if (tb->compareThing->player != NULL) { - INT32 lineside = 0; - vertex_t pos; + boolean alreadyHates = K_BotHatesThisSector(tb->compareThing->player, tb->compareThing->subsector->sector, tb->compareThing->x, tb->compareThing->y); - P_ClosestPointOnLine(tb->compareThing->x, tb->compareThing->y, line, &pos); - lineside = P_PointOnLineSide(tb->compareThing->x, tb->compareThing->y, line); - - if (K_BotHatesThisSector(tb->compareThing->player, lineside ? line->frontsector : line->backsector, pos.x, pos.y)) + if (alreadyHates == false) { - // This line does not block us, but we don't want to be in it. - return false; + INT32 lineside = 0; + vertex_t pos; + + P_ClosestPointOnLine(tb->compareThing->x, tb->compareThing->y, line, &pos); + lineside = P_PointOnLineSide(tb->compareThing->x, tb->compareThing->y, line); + + if (K_BotHatesThisSector(tb->compareThing->player, ((lineside == 1) ? line->frontsector : line->backsector), pos.x, pos.y)) + { + // This line does not block us, but we don't want to be in it. + return false; + } } } } From ba26a3a22350b442e22e77e9e2f3c2a04b2804e8 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Sat, 11 Dec 2021 02:22:33 -0500 Subject: [PATCH 128/156] Require bots to be much slower to consider spindash --- src/k_bot.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/k_bot.c b/src/k_bot.c index d11142119..1a75ea06c 100644 --- a/src/k_bot.c +++ b/src/k_bot.c @@ -776,7 +776,7 @@ static UINT8 K_TrySpindash(player_t *player) return 0; } - if (speedDiff < (3 * baseAccel / 4)) + if (speedDiff < (baseAccel / 4)) { if (player->botvars.spindashconfirm < BOTSPINDASHCONFIRM) { From 8d5cec5ebf31b2cb74a042f4ebe2d335f82bc049 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Sat, 11 Dec 2021 04:12:06 -0500 Subject: [PATCH 129/156] Move where PF_HITFINISHLINE is removed Also removes a few remaining instances of player->bot being checked to affect gameplay where it shouldn't from vanilla, but it's code that is rarely used / completely unused anyway. --- src/k_kart.c | 2 -- src/p_mobj.c | 2 +- src/p_user.c | 8 +++++--- src/r_skins.c | 5 ----- 4 files changed, 6 insertions(+), 11 deletions(-) diff --git a/src/k_kart.c b/src/k_kart.c index 7401b9d4c..2b5d1ace9 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -8629,8 +8629,6 @@ void K_MoveKartPlayer(player_t *player, boolean onground) boolean HOLDING_ITEM = (player->pflags & (PF_ITEMOUT|PF_EGGMANOUT)); boolean NO_HYUDORO = (player->stealingtimer == 0); - player->pflags &= ~PF_HITFINISHLINE; - if (!player->exiting) { if (player->oldposition < player->position) // But first, if you lost a place, diff --git a/src/p_mobj.c b/src/p_mobj.c index 5a9f0925e..ad86d0434 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -4095,7 +4095,7 @@ boolean P_BossTargetPlayer(mobj_t *actor, boolean closest) player = &players[actor->lastlook]; - if (player->bot || player->spectator) + if (player->spectator) continue; // ignore notarget if (!player->mo || P_MobjWasRemoved(player->mo)) diff --git a/src/p_user.c b/src/p_user.c index 5f5242e66..5af3386d6 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -4222,9 +4222,6 @@ void P_PlayerThink(player_t *player) ticcmd_t *cmd; const size_t playeri = (size_t)(player - players); - player->old_drawangle = player->drawangle; - player->old_viewrollangle = player->viewrollangle; - #ifdef PARANOIA if (!player->mo) I_Error("p_playerthink: players[%s].mo == NULL", sizeu1(playeri)); @@ -4237,6 +4234,11 @@ void P_PlayerThink(player_t *player) player->playerstate = PST_DEAD; } + player->old_drawangle = player->drawangle; + player->old_viewrollangle = player->viewrollangle; + + player->pflags &= ~PF_HITFINISHLINE; + if (player->awayviewmobj && P_MobjWasRemoved(player->awayviewmobj)) { P_SetTarget(&player->awayviewmobj, NULL); // remove awayviewmobj asap if invalid diff --git a/src/r_skins.c b/src/r_skins.c index 1e80e18ce..ba7ed0811 100644 --- a/src/r_skins.c +++ b/src/r_skins.c @@ -311,11 +311,6 @@ void SetPlayerSkinByNum(INT32 playernum, INT32 skinnum) } player->skincolor = newcolor = skin->prefcolor; - if (player->bot && botingame) - { - botskin = (UINT8)(skinnum + 1); - botcolor = skin->prefcolor; - } } #endif From bfdae2840995b7031c1c8d64da6e6616bb840f94 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Sat, 11 Dec 2021 04:18:09 -0500 Subject: [PATCH 130/156] Not Climable flag on a bot controller disables rubberbanding --- src/k_bot.c | 142 +++++++++++++++++++++++++++++----------------------- 1 file changed, 78 insertions(+), 64 deletions(-) diff --git a/src/k_bot.c b/src/k_bot.c index 1a75ea06c..f3555deed 100644 --- a/src/k_bot.c +++ b/src/k_bot.c @@ -283,6 +283,70 @@ boolean K_BotCanTakeCut(player_t *player) return false; } +/*-------------------------------------------------- + static INT16 K_FindBotController(mobj_t *mo) + + Finds if any bot controller linedefs are tagged to the bot's sector. + + Input Arguments:- + mo - The bot player's mobj. + + Return:- + Line number of the bot controller. -1 if it doesn't exist. +--------------------------------------------------*/ +static INT16 K_FindBotController(mobj_t *mo) +{ + msecnode_t *node; + ffloor_t *rover; + INT16 lineNum = -1; + mtag_t tag; + + I_Assert(mo != NULL); + I_Assert(!P_MobjWasRemoved(mo)); + + for (node = mo->touching_sectorlist; node; node = node->m_sectorlist_next) + { + if (!node->m_sector) + { + continue; + } + + tag = Tag_FGet(&node->m_sector->tags); + lineNum = P_FindSpecialLineFromTag(2004, tag, -1); // todo: needs to not use P_FindSpecialLineFromTag + + if (lineNum != -1) + { + return lineNum; + } + + for (rover = node->m_sector->ffloors; rover; rover = rover->next) + { + sector_t *rs = NULL; + + if (!(rover->flags & FF_EXISTS)) + { + continue; + } + + if (mo->z > *rover->topheight || mo->z + mo->height < *rover->bottomheight) + { + continue; + } + + rs = §ors[rover->secnum]; + tag = Tag_FGet(&rs->tags); + lineNum = P_FindSpecialLineFromTag(2004, tag, -1); + + if (lineNum != -1) + { + return lineNum; + } + } + } + + return -1; +} + /*-------------------------------------------------- static UINT32 K_BotRubberbandDistance(player_t *player) @@ -346,6 +410,7 @@ fixed_t K_BotRubberband(player_t *player) fixed_t rubberband = FRACUNIT; fixed_t max, min; player_t *firstplace = NULL; + INT16 botController = -1; UINT8 i; if (player->exiting) @@ -354,6 +419,19 @@ fixed_t K_BotRubberband(player_t *player) return FRACUNIT; } + botController = K_FindBotController(player->mo); + + if (botController != -1) + { + line_t *controllerLine = &lines[botController]; + + // No Climb Flag: Disable rubberbanding + if (controllerLine->flags & ML_NOCLIMB) + { + return FRACUNIT; + } + } + for (i = 0; i < MAXPLAYERS; i++) { if (!playeringame[i] || players[i].spectator) @@ -812,70 +890,6 @@ static UINT8 K_TrySpindash(player_t *player) return 0; } -/*-------------------------------------------------- - static INT16 K_FindBotController(mobj_t *mo) - - Finds if any bot controller linedefs are tagged to the bot's sector. - - Input Arguments:- - mo - The bot player's mobj. - - Return:- - Line number of the bot controller. -1 if it doesn't exist. ---------------------------------------------------*/ -static INT16 K_FindBotController(mobj_t *mo) -{ - msecnode_t *node; - ffloor_t *rover; - INT16 lineNum = -1; - mtag_t tag; - - I_Assert(mo != NULL); - I_Assert(!P_MobjWasRemoved(mo)); - - for (node = mo->touching_sectorlist; node; node = node->m_sectorlist_next) - { - if (!node->m_sector) - { - continue; - } - - tag = Tag_FGet(&node->m_sector->tags); - lineNum = P_FindSpecialLineFromTag(2004, tag, -1); // todo: needs to not use P_FindSpecialLineFromTag - - if (lineNum != -1) - { - return lineNum; - } - - for (rover = node->m_sector->ffloors; rover; rover = rover->next) - { - sector_t *rs = NULL; - - if (!(rover->flags & FF_EXISTS)) - { - continue; - } - - if (mo->z > *rover->topheight || mo->z + mo->height < *rover->bottomheight) - { - continue; - } - - rs = §ors[rover->secnum]; - tag = Tag_FGet(&rs->tags); - lineNum = P_FindSpecialLineFromTag(2004, tag, -1); - - if (lineNum != -1) - { - return lineNum; - } - } - } - - return -1; -} - /*-------------------------------------------------- static void K_DrawPredictionDebug(botprediction_t *predict, player_t *player) From 0e43a04dee4196d8f7080b2038a4f6123d84753c Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Sun, 12 Dec 2021 02:07:21 -0500 Subject: [PATCH 131/156] Try adding tripwire support Kind of lazy. When checking bot traversal, it considers tripwires as walls. K_BotCanTakeCut now is limited to whatever can take tripwires (no more hyudoro invisibility). Probably should have something more foolproof, but it's annoying to test any changes to this. The only maps I can think of with really easy tripwires clearly don't have their waypoints with bots in mind, the rest are very optional or out of the way or otherwise the bots don't want to even touch them at all. --- src/k_bot.c | 16 ++++++++++++---- src/p_sight.c | 6 ++++++ 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/k_bot.c b/src/k_bot.c index f3555deed..6bb5a6080 100644 --- a/src/k_bot.c +++ b/src/k_bot.c @@ -273,14 +273,22 @@ boolean K_PlayerUsesBotMovement(player_t *player) --------------------------------------------------*/ boolean K_BotCanTakeCut(player_t *player) { - if (!K_ApplyOffroad(player) + if ( +#if 1 + K_TripwirePass(player) == true +#else + K_ApplyOffroad(player) == false +#endif || player->itemtype == KITEM_SNEAKER || player->itemtype == KITEM_ROCKETSNEAKER || player->itemtype == KITEM_INVINCIBILITY - || player->itemtype == KITEM_HYUDORO) + ) + { return true; + } return false; +#endif } /*-------------------------------------------------- @@ -721,12 +729,12 @@ static botprediction_t *K_CreateBotPrediction(player_t *player) for (i = 0; i < wp->numnextwaypoints; i++) { - if (!K_GetWaypointIsEnabled(wp->nextwaypoints[i])) + if (K_GetWaypointIsEnabled(wp->nextwaypoints[i]) == false) { continue; } - if (K_GetWaypointIsShortcut(wp->nextwaypoints[i]) && !K_BotCanTakeCut(player)) + if (K_GetWaypointIsShortcut(wp->nextwaypoints[i]) == true && K_BotCanTakeCut(player) == false) { continue; } diff --git a/src/p_sight.c b/src/p_sight.c index 8e63f1be4..00c2f09d9 100644 --- a/src/p_sight.c +++ b/src/p_sight.c @@ -758,6 +758,12 @@ static boolean P_CrossBotTraversalSubsector(size_t num, register traceblocking_t return false; } } + + if (P_IsLineTripWire(line) == true && K_TripwirePass(tb->compareThing->player) == false) + { + // Can't go through trip wire. + return false; + } } } From cd0a259bbead81294ccbd9f9bfe2c11769ed8e6e Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Sun, 12 Dec 2021 02:32:03 -0500 Subject: [PATCH 132/156] Code cleanup - K_FindBotController returns the line_t directly, instead of a linedef index. - Trick panel code is in its own function. - Try to fix infinite bot heat death --- src/k_bot.c | 108 ++++++++++++++++++++++++++++++-------------------- src/k_bot.h | 4 +- src/p_sight.c | 1 + src/p_user.c | 16 +++++++- 4 files changed, 84 insertions(+), 45 deletions(-) diff --git a/src/k_bot.c b/src/k_bot.c index 6bb5a6080..2a5bb665d 100644 --- a/src/k_bot.c +++ b/src/k_bot.c @@ -288,11 +288,10 @@ boolean K_BotCanTakeCut(player_t *player) } return false; -#endif } /*-------------------------------------------------- - static INT16 K_FindBotController(mobj_t *mo) + static line_t *K_FindBotController(mobj_t *mo) Finds if any bot controller linedefs are tagged to the bot's sector. @@ -300,9 +299,9 @@ boolean K_BotCanTakeCut(player_t *player) mo - The bot player's mobj. Return:- - Line number of the bot controller. -1 if it doesn't exist. + Linedef of the bot controller. NULL if it doesn't exist. --------------------------------------------------*/ -static INT16 K_FindBotController(mobj_t *mo) +static line_t *K_FindBotController(mobj_t *mo) { msecnode_t *node; ffloor_t *rover; @@ -324,7 +323,7 @@ static INT16 K_FindBotController(mobj_t *mo) if (lineNum != -1) { - return lineNum; + break; } for (rover = node->m_sector->ffloors; rover; rover = rover->next) @@ -347,12 +346,19 @@ static INT16 K_FindBotController(mobj_t *mo) if (lineNum != -1) { - return lineNum; + break; } } } - return -1; + if (lineNum != -1) + { + return &lines[lineNum]; + } + else + { + return NULL; + } } /*-------------------------------------------------- @@ -418,7 +424,7 @@ fixed_t K_BotRubberband(player_t *player) fixed_t rubberband = FRACUNIT; fixed_t max, min; player_t *firstplace = NULL; - INT16 botController = -1; + line_t *botController = NULL; UINT8 i; if (player->exiting) @@ -429,12 +435,10 @@ fixed_t K_BotRubberband(player_t *player) botController = K_FindBotController(player->mo); - if (botController != -1) + if (botController != NULL) { - line_t *controllerLine = &lines[botController]; - // No Climb Flag: Disable rubberbanding - if (controllerLine->flags & ML_NOCLIMB) + if (botController->flags & ML_NOCLIMB) { return FRACUNIT; } @@ -962,6 +966,50 @@ static void K_DrawPredictionDebug(botprediction_t *predict, player_t *player) } } +/*-------------------------------------------------- + static void K_BotTrick(player_t *player, ticcmd_t *cmd, line_t *botController) + + Determines inputs for trick panels. + + Input Arguments:- + player - Player to generate the ticcmd for. + cmd - The player's ticcmd to modify. + botController - Linedef for the bot controller. + + Return:- + None +--------------------------------------------------*/ +static void K_BotTrick(player_t *player, ticcmd_t *cmd, line_t *botController) +{ + // Trick panel state -- do nothing until a controller line is found, in which case do a trick. + if (botController == NULL) + { + return; + } + + if (player->trickpanel == 1) + { + INT32 type = (sides[botController->sidenum[0]].rowoffset / FRACUNIT); + + // Y Offset: Trick type + switch (type) + { + case 1: + cmd->turning = KART_FULLTURN; + break; + case 2: + cmd->turning = -KART_FULLTURN; + break; + case 3: + cmd->buttons |= BT_FORWARD; + break; + case 4: + cmd->buttons |= BT_BACKWARD; + break; + } + } +} + /*-------------------------------------------------- void K_BuildBotTiccmd(player_t *player, ticcmd_t *cmd) @@ -973,7 +1021,7 @@ void K_BuildBotTiccmd(player_t *player, ticcmd_t *cmd) boolean trySpindash = true; UINT8 spindash = 0; INT32 turnamt = 0; - INT16 botController = -1; + line_t *botController = NULL; // Can't build a ticcmd if we aren't spawned... if (!player->mo) @@ -996,7 +1044,7 @@ void K_BuildBotTiccmd(player_t *player, ticcmd_t *cmd) } // Complete override of all ticcmd functionality - if (LUAh_BotTiccmd(player, cmd)) + if (LUAh_BotTiccmd(player, cmd) == true) { return; } @@ -1005,30 +1053,7 @@ void K_BuildBotTiccmd(player_t *player, ticcmd_t *cmd) if (player->trickpanel != 0) { - // Trick panel state -- do nothing until a controller line is found, in which case do a trick. - - if (player->trickpanel == 1 && botController != -1) - { - line_t *controllerLine = &lines[botController]; - INT32 type = (sides[controllerLine->sidenum[0]].rowoffset / FRACUNIT); - - // Y Offset: Trick type - switch (type) - { - case 1: - cmd->turning = KART_FULLTURN; - break; - case 2: - cmd->turning = -KART_FULLTURN; - break; - case 3: - cmd->buttons |= BT_FORWARD; - break; - case 4: - cmd->buttons |= BT_BACKWARD; - break; - } - } + K_BotTrick(player, cmd, botController); // Don't do anything else. return; @@ -1037,20 +1062,19 @@ void K_BuildBotTiccmd(player_t *player, ticcmd_t *cmd) if ((player->nextwaypoint != NULL && player->nextwaypoint->mobj != NULL && !P_MobjWasRemoved(player->nextwaypoint->mobj)) - || (botController != -1)) + || (botController != NULL)) { // Handle steering towards waypoints! SINT8 turnsign = 0; angle_t destangle, moveangle, angle; INT16 anglediff; - if (botController != -1) + if (botController != NULL) { const fixed_t dist = (player->mo->radius * 4); - line_t *controllerLine = &lines[botController]; // X Offset: Movement direction - destangle = FixedAngle(sides[controllerLine->sidenum[0]].textureoffset); + destangle = FixedAngle(sides[botController->sidenum[0]].textureoffset); // Overwritten prediction predict = Z_Calloc(sizeof(botprediction_t), PU_STATIC, NULL); diff --git a/src/k_bot.h b/src/k_bot.h index d354bbb2c..a04d5c174 100644 --- a/src/k_bot.h +++ b/src/k_bot.h @@ -223,8 +223,8 @@ void K_NudgePredictionTowardsObjects(botprediction_t *predict, player_t *player) /*-------------------------------------------------- void K_BuildBotTiccmd(player_t *player, ticcmd_t *cmd); - Gives a multiplier for a bot's rubberbanding. Meant to be used for top speed, - acceleration, and handling. + Creates a bot's ticcmd, looking at its surroundings to + try and figure out what it should do. Input Arguments:- player - Player to generate the ticcmd for. diff --git a/src/p_sight.c b/src/p_sight.c index 00c2f09d9..cdc8df864 100644 --- a/src/p_sight.c +++ b/src/p_sight.c @@ -19,6 +19,7 @@ #include "r_state.h" #include "k_bot.h" // K_BotHatesThisSector +#include "k_kart.h" // K_TripwirePass // // P_CheckSight diff --git a/src/p_user.c b/src/p_user.c index 5af3386d6..7ab85b6ec 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -2502,6 +2502,8 @@ static void P_ConsiderAllGone(void) // static void P_DeathThink(player_t *player) { + boolean playerGone = false; + player->deltaviewheight = 0; if (player->deadtimer < INT32_MAX) @@ -2522,7 +2524,19 @@ static void P_DeathThink(player_t *player) K_KartPlayerHUDUpdate(player); - if (player->lives > 0 && !(player->pflags & PF_NOCONTEST) && player->deadtimer > TICRATE) + if (player->pflags & PF_NOCONTEST) + { + playerGone = true; + } + else if (player->bot == false) + { + if (G_GametypeUsesLives() == true && player->lives == 0) + { + playerGone = true; + } + } + + if (playerGone == false && player->deadtimer > TICRATE) { player->playerstate = PST_REBORN; } From bfa3311eca552fa57fba43f5ef948c55ce681a41 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Sun, 12 Dec 2021 03:28:49 -0500 Subject: [PATCH 133/156] Make rivals even more aggressive to players :) --- src/k_botitem.c | 204 ++++++++++++++++++++++++++++++++++++------------ 1 file changed, 152 insertions(+), 52 deletions(-) diff --git a/src/k_botitem.c b/src/k_botitem.c index 67d858ea4..4bb83931c 100644 --- a/src/k_botitem.c +++ b/src/k_botitem.c @@ -86,7 +86,7 @@ static boolean K_BotUseItemNearPlayer(player_t *player, ticcmd_t *cmd, fixed_t r } /*-------------------------------------------------- - static boolean K_PlayerNearSpot(player_t *player, fixed_t x, fixed_t y, fixed_t radius) + static player_t *K_PlayerNearSpot(player_t *player, fixed_t x, fixed_t y, fixed_t radius) Looks for players around a specified x/y coordinate. @@ -97,9 +97,9 @@ static boolean K_BotUseItemNearPlayer(player_t *player, ticcmd_t *cmd, fixed_t r radius - The radius to look for players in. Return:- - true if a player was found around the coordinate, otherwise false. + The player we found, NULL if nothing was found. --------------------------------------------------*/ -static boolean K_PlayerNearSpot(player_t *player, fixed_t x, fixed_t y, fixed_t radius) +static player_t *K_PlayerNearSpot(player_t *player, fixed_t x, fixed_t y, fixed_t radius) { UINT8 i; @@ -129,15 +129,15 @@ static boolean K_PlayerNearSpot(player_t *player, fixed_t x, fixed_t y, fixed_t if (dist <= radius) { - return true; + return target; } } - return false; + return NULL; } /*-------------------------------------------------- - static boolean K_PlayerPredictThrow(player_t *player, UINT8 extra) + static player_t *K_PlayerPredictThrow(player_t *player, UINT8 extra) Looks for players around the predicted coordinates of their thrown item. @@ -146,9 +146,9 @@ static boolean K_PlayerNearSpot(player_t *player, fixed_t x, fixed_t y, fixed_t extra - Extra throwing distance, for aim forward on mines. Return:- - true if a player was found around the coordinate, otherwise false. + The player we're trying to throw at, NULL if none was found. --------------------------------------------------*/ -static boolean K_PlayerPredictThrow(player_t *player, UINT8 extra) +static player_t *K_PlayerPredictThrow(player_t *player, UINT8 extra) { const fixed_t dist = (30 + (extra * 10)) * player->mo->scale; const UINT32 airtime = FixedDiv(dist + player->mo->momz, gravity); @@ -159,7 +159,7 @@ static boolean K_PlayerPredictThrow(player_t *player, UINT8 extra) } /*-------------------------------------------------- - static boolean K_PlayerInCone(player_t *player, UINT16 cone, boolean flip) + static player_t *K_PlayerInCone(player_t *player, UINT16 cone, boolean flip) Looks for players in the . @@ -172,7 +172,7 @@ static boolean K_PlayerPredictThrow(player_t *player, UINT8 extra) Return:- true if a player was found in the cone, otherwise false. --------------------------------------------------*/ -static boolean K_PlayerInCone(player_t *player, fixed_t radius, UINT16 cone, boolean flip) +static player_t *K_PlayerInCone(player_t *player, fixed_t radius, UINT16 cone, boolean flip) { UINT8 i; @@ -222,22 +222,96 @@ static boolean K_PlayerInCone(player_t *player, fixed_t radius, UINT16 cone, boo { if (ad >= 180-cone) { - return true; + return target; } } else { if (ad <= cone) { - return true; + return target; } } } } + return NULL; +} + +/*-------------------------------------------------- + static boolean K_RivalBotAggression(player_t *bot, player_t *target) + + Returns if a bot is a rival & wants to be aggressive to a player. + + Input Arguments:- + bot - Bot to check. + target - Who the bot wants to attack. + + Return:- + false if not the rival. false if the target is another bot. Otherwise, true. +--------------------------------------------------*/ +static boolean K_RivalBotAggression(player_t *bot, player_t *target) +{ + if (bot == NULL || target == NULL) + { + // Invalid. + return false; + } + + if (bot->bot == false) + { + // lol + return false; + } + + if (bot->botvars.rival == false) + { + // Not the rival, we aren't self-aware. + return false; + } + + if (target->bot == false) + { + // This bot knows that the real threat is the player. + return true; + } + + // Calling them your friends is misleading, but you'll at least spare them. return false; } +/*-------------------------------------------------- + static void K_ItemConfirmForTarget(player_t *bot, player_t *target, UINT16 amount) + + Handles updating item confirm values for offense items. + + Input Arguments:- + bot - Bot to check. + target - Who the bot wants to attack. + amount - Amount to increase item confirm time by. + + Return:- + None +--------------------------------------------------*/ +static void K_ItemConfirmForTarget(player_t *bot, player_t *target, UINT16 amount) +{ + if (bot == NULL || target == NULL) + { + return; + } + + if (K_RivalBotAggression(bot, target) == true) + { + // Double the rate when you're aggressive. + bot->botvars.itemconfirm += amount << 1; + } + else + { + // Do as normal. + bot->botvars.itemconfirm += amount; + } +} + /*-------------------------------------------------- static boolean K_BotGenericPressItem(player_t *player, ticcmd_t *cmd, SINT8 dir) @@ -316,21 +390,21 @@ static boolean K_BotRevealsGenericTrap(player_t *player, INT16 turnamt, boolean } // Check the predicted throws. - if (K_PlayerPredictThrow(player, 0)) + if (K_PlayerPredictThrow(player, 0) != NULL) { return true; } if (mine) { - if (K_PlayerPredictThrow(player, 1)) + if (K_PlayerPredictThrow(player, 1) != NULL) { return true; } } // Check your behind. - if (K_PlayerInCone(player, player->mo->radius * 16, 10, true)) + if (K_PlayerInCone(player, player->mo->radius * 16, 10, true) != NULL) { return true; } @@ -447,7 +521,6 @@ static void K_BotItemRocketSneaker(player_t *player, ticcmd_t *cmd) } } - /*-------------------------------------------------- static void K_BotItemBanana(player_t *player, ticcmd_t *cmd, INT16 turnamt) @@ -464,9 +537,17 @@ static void K_BotItemRocketSneaker(player_t *player, ticcmd_t *cmd) static void K_BotItemBanana(player_t *player, ticcmd_t *cmd, INT16 turnamt) { SINT8 throwdir = -1; + player_t *target = NULL; player->botvars.itemconfirm++; + target = K_PlayerInCone(player, player->mo->radius * 16, 10, true); + if (target != NULL) + { + K_ItemConfirmForTarget(player, target, player->botvars.difficulty); + throwdir = -1; + } + if (abs(turnamt) >= KART_FULLTURN/2) { player->botvars.itemconfirm += player->botvars.difficulty / 2; @@ -474,19 +555,15 @@ static void K_BotItemBanana(player_t *player, ticcmd_t *cmd, INT16 turnamt) } else { - if (K_PlayerPredictThrow(player, 0)) + target = K_PlayerPredictThrow(player, 0); + + if (target != NULL) { - player->botvars.itemconfirm += player->botvars.difficulty * 2; + K_ItemConfirmForTarget(player, target, player->botvars.difficulty * 2); throwdir = 1; } } - if (K_PlayerInCone(player, player->mo->radius * 16, 10, true)) - { - player->botvars.itemconfirm += player->botvars.difficulty; - throwdir = -1; - } - if (player->botvars.itemconfirm > 2*TICRATE || player->bananadrag >= TICRATE) { K_BotGenericPressItem(player, cmd, throwdir); @@ -509,12 +586,14 @@ static void K_BotItemBanana(player_t *player, ticcmd_t *cmd, INT16 turnamt) static void K_BotItemMine(player_t *player, ticcmd_t *cmd, INT16 turnamt) { SINT8 throwdir = 0; + player_t *target = NULL; player->botvars.itemconfirm++; - if (K_PlayerInCone(player, player->mo->radius * 16, 10, true)) + target = K_PlayerInCone(player, player->mo->radius * 16, 10, true); + if (target != NULL) { - player->botvars.itemconfirm += player->botvars.difficulty; + K_ItemConfirmForTarget(player, target, player->botvars.difficulty); throwdir = -1; } @@ -525,21 +604,21 @@ static void K_BotItemMine(player_t *player, ticcmd_t *cmd, INT16 turnamt) } else { - if (K_PlayerPredictThrow(player, 0)) + target = K_PlayerPredictThrow(player, 0); + if (target != NULL) { - player->botvars.itemconfirm += player->botvars.difficulty * 2; + K_ItemConfirmForTarget(player, target, player->botvars.difficulty * 2); throwdir = 0; } - if (K_PlayerPredictThrow(player, 1)) + target = K_PlayerPredictThrow(player, 1); + if (target != NULL) { - player->botvars.itemconfirm += player->botvars.difficulty * 2; + K_ItemConfirmForTarget(player, target, player->botvars.difficulty * 2); throwdir = 1; } } - - if (player->botvars.itemconfirm > 2*TICRATE || player->bananadrag >= TICRATE) { K_BotGenericPressItem(player, cmd, throwdir); @@ -561,6 +640,8 @@ static void K_BotItemMine(player_t *player, ticcmd_t *cmd, INT16 turnamt) --------------------------------------------------*/ static void K_BotItemLandmine(player_t *player, ticcmd_t *cmd, INT16 turnamt) { + player_t *target = NULL; + player->botvars.itemconfirm++; if (abs(turnamt) >= KART_FULLTURN/2) @@ -568,9 +649,10 @@ static void K_BotItemLandmine(player_t *player, ticcmd_t *cmd, INT16 turnamt) player->botvars.itemconfirm += player->botvars.difficulty / 2; } - if (K_PlayerInCone(player, player->mo->radius * 16, 10, true)) + target = K_PlayerInCone(player, player->mo->radius * 16, 10, true); + if (target != NULL) { - player->botvars.itemconfirm += player->botvars.difficulty; + K_ItemConfirmForTarget(player, target, player->botvars.difficulty); } if (player->botvars.itemconfirm > 2*TICRATE) @@ -595,18 +677,21 @@ static void K_BotItemEggman(player_t *player, ticcmd_t *cmd) { const UINT8 stealth = K_EggboxStealth(player->mo->x, player->mo->y); SINT8 throwdir = -1; + player_t *target = NULL; player->botvars.itemconfirm++; - if (K_PlayerPredictThrow(player, 0)) + target = K_PlayerPredictThrow(player, 0); + if (target != NULL) { - player->botvars.itemconfirm += player->botvars.difficulty / 2; + K_ItemConfirmForTarget(player, target, player->botvars.difficulty / 2); throwdir = 1; } - if (K_PlayerInCone(player, player->mo->radius * 16, 10, true)) + target = K_PlayerInCone(player, player->mo->radius * 16, 10, true); + if (target != NULL) { - player->botvars.itemconfirm += player->botvars.difficulty; + K_ItemConfirmForTarget(player, target, player->botvars.difficulty); throwdir = -1; } @@ -636,6 +721,7 @@ static void K_BotItemEggman(player_t *player, ticcmd_t *cmd) static boolean K_BotRevealsEggbox(player_t *player) { const UINT8 stealth = K_EggboxStealth(player->mo->x, player->mo->y); + player_t *target = NULL; // This is a stealthy spot for an eggbox, lets reveal it! if (stealth > 1) @@ -644,13 +730,15 @@ static boolean K_BotRevealsEggbox(player_t *player) } // Check the predicted throws. - if (K_PlayerPredictThrow(player, 0)) + target = K_PlayerPredictThrow(player, 0); + if (target != NULL) { return true; } // Check your behind. - if (K_PlayerInCone(player, player->mo->radius * 16, 10, true)) + target = K_PlayerInCone(player, player->mo->radius * 16, 10, true); + if (target != NULL) { return true; } @@ -677,7 +765,7 @@ static void K_BotItemEggmanShield(player_t *player, ticcmd_t *cmd) return; } - if (K_BotRevealsEggbox(player) || (player->botvars.itemconfirm++ > 20*TICRATE)) + if (K_BotRevealsEggbox(player) == true || (player->botvars.itemconfirm++ > 20*TICRATE)) { K_BotGenericPressItem(player, cmd, 0); } @@ -699,8 +787,9 @@ static void K_BotItemEggmanExplosion(player_t *player, ticcmd_t *cmd) { if (player->position == 1) { + // Hey, we aren't gonna find anyone up here... + // why don't we slow down a bit? :) cmd->forwardmove /= 2; - cmd->buttons |= BT_BRAKE; } K_BotUseItemNearPlayer(player, cmd, 128*player->mo->scale); @@ -724,6 +813,7 @@ static void K_BotItemOrbinaut(player_t *player, ticcmd_t *cmd) fixed_t radius = (player->mo->radius * 32); SINT8 throwdir = -1; UINT8 snipeMul = 2; + player_t *target = NULL; if (player->speed > topspeed) { @@ -733,15 +823,21 @@ static void K_BotItemOrbinaut(player_t *player, ticcmd_t *cmd) player->botvars.itemconfirm++; - if (K_PlayerInCone(player, radius, 10, false)) + target = K_PlayerInCone(player, radius, 10, false); + if (target != NULL) { - player->botvars.itemconfirm += player->botvars.difficulty * snipeMul; + K_ItemConfirmForTarget(player, target, player->botvars.difficulty * snipeMul); throwdir = 1; } else if (K_PlayerInCone(player, radius, 10, true)) { - player->botvars.itemconfirm += player->botvars.difficulty; - throwdir = -1; + target = K_PlayerInCone(player, radius, 10, true); + + if (target != NULL) + { + K_ItemConfirmForTarget(player, target, player->botvars.difficulty); + throwdir = -1; + } } if (player->botvars.itemconfirm > 5*TICRATE) @@ -769,6 +865,7 @@ static void K_BotItemJawz(player_t *player, ticcmd_t *cmd) SINT8 throwdir = 1; UINT8 snipeMul = 2; INT32 lastTarg = player->lastjawztarget; + player_t *target = NULL; if (player->speed > topspeed) { @@ -778,9 +875,10 @@ static void K_BotItemJawz(player_t *player, ticcmd_t *cmd) player->botvars.itemconfirm++; - if (K_PlayerInCone(player, radius, 10, true)) + target = K_PlayerInCone(player, radius, 10, true); + if (target != NULL) { - player->botvars.itemconfirm += player->botvars.difficulty; + K_ItemConfirmForTarget(player, target, player->botvars.difficulty); throwdir = -1; } @@ -790,16 +888,18 @@ static void K_BotItemJawz(player_t *player, ticcmd_t *cmd) && players[lastTarg].mo != NULL && P_MobjWasRemoved(players[lastTarg].mo) == false) { - mobj_t *targ = players[lastTarg].mo; + mobj_t *targMo = players[lastTarg].mo; mobj_t *mobj = NULL, *next = NULL; boolean targettedAlready = false; + target = &players[lastTarg]; + // Make sure no other Jawz are targetting this player. for (mobj = kitemcap; mobj; mobj = next) { next = mobj->itnext; - if (mobj->type == MT_JAWZ && mobj->target == targ) + if (mobj->type == MT_JAWZ && mobj->target == targMo) { targettedAlready = true; break; @@ -808,7 +908,7 @@ static void K_BotItemJawz(player_t *player, ticcmd_t *cmd) if (targettedAlready == false) { - player->botvars.itemconfirm += player->botvars.difficulty * snipeMul; + K_ItemConfirmForTarget(player, target, player->botvars.difficulty * snipeMul); throwdir = 1; } } @@ -833,7 +933,7 @@ static void K_BotItemJawz(player_t *player, ticcmd_t *cmd) --------------------------------------------------*/ static void K_BotItemThunder(player_t *player, ticcmd_t *cmd) { - if (!K_BotUseItemNearPlayer(player, cmd, 192*player->mo->scale)) + if (K_BotUseItemNearPlayer(player, cmd, 192*player->mo->scale) == false) { if (player->botvars.itemconfirm > 10*TICRATE) { From cec81378644f74f6675a43907678d89a638de8aa Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Sun, 12 Dec 2021 04:07:32 -0500 Subject: [PATCH 134/156] Require Effect 1 for using bot controller angle. --- src/k_bot.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/k_bot.c b/src/k_bot.c index 2a5bb665d..24f3517a2 100644 --- a/src/k_bot.c +++ b/src/k_bot.c @@ -1069,7 +1069,7 @@ void K_BuildBotTiccmd(player_t *player, ticcmd_t *cmd) angle_t destangle, moveangle, angle; INT16 anglediff; - if (botController != NULL) + if (botController != NULL && (botController->flags & ML_EFFECT1)) { const fixed_t dist = (player->mo->radius * 4); From 9e1146bc3052a2a766a8ebddb9e00df183700104 Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 12 Dec 2021 02:47:46 -0800 Subject: [PATCH 135/156] Disable downloading for now --- src/d_netfil.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/d_netfil.c b/src/d_netfil.c index 5714c39cd..f8edfbf03 100644 --- a/src/d_netfil.c +++ b/src/d_netfil.c @@ -276,11 +276,16 @@ boolean CL_CheckDownloadable(void) } // Downloading locally disabled +#if 0 if (!dlstatus && M_CheckParm("-nodownload")) dlstatus = 3; if (!dlstatus) return true; +#else + if (!dlstatus) + dlstatus = 3; +#endif // not downloadable, put reason in console CONS_Alert(CONS_NOTICE, M_GetText("You need additional files to connect to this server:\n")); From 32127f37ee5e94844178ab6414ae1ec116306baa Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 12 Dec 2021 02:58:06 -0800 Subject: [PATCH 136/156] Check mainwads netgame md5 in developer build --- src/d_netfil.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/d_netfil.c b/src/d_netfil.c index f8edfbf03..7aec8d13e 100644 --- a/src/d_netfil.c +++ b/src/d_netfil.c @@ -161,10 +161,16 @@ UINT8 *PutFileNeeded(UINT16 firstfile) char wadfilename[MAX_WADPATH] = ""; UINT8 filestatus; - for (i = mainwads+1; i < numwadfiles; i++) //mainwads+1, otherwise we start on the first mainwad +#ifdef DEVELOP + i = 0; +#else + i = mainwads + 1; +#endif + + for (; i < numwadfiles; i++) //mainwads+1, otherwise we start on the first mainwad { // If it has only music/sound lumps, don't put it in the list - if (!wadfiles[i]->important) + if (i > mainwads && !wadfiles[i]->important) continue; if (firstfile) @@ -494,7 +500,12 @@ INT32 CL_CheckFiles(void) CONS_Debug(DBG_NETPLAY, "searching for '%s' ", fileneeded[i].filename); // Check in already loaded files - for (j = mainwads+1; wadfiles[j]; j++) +#ifdef DEVELOP + j = 0; +#else + j = mainwads + 1; +#endif + for (; wadfiles[j]; j++) { nameonly(strcpy(wadfilename, wadfiles[j]->filename)); if (!stricmp(wadfilename, fileneeded[i].filename) && From 35238510e34d0fb3950170cee5436ea64dccb7b1 Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 12 Dec 2021 03:28:59 -0800 Subject: [PATCH 137/156] Use sfx_s3k38 --- src/p_mobj.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index 9550b0c41..0151b9114 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -3065,7 +3065,7 @@ void P_MobjCheckWater(mobj_t *mobj) if (p && !p->waterskip && p->curshield != KSHIELD_BUBBLE && wasinwater) { - S_StartSound(mobj, sfx_gasp); + S_StartSound(mobj, sfx_s3k38); } if (waterwasnotset) From 184a89db4399a61d27dd43d183a48b17e2872b3c Mon Sep 17 00:00:00 2001 From: James R Date: Sun, 12 Dec 2021 03:30:08 -0800 Subject: [PATCH 138/156] Always play splash sfx when entering/exiting water --- src/p_mobj.c | 112 +++++++++++++++++++++++++-------------------------- 1 file changed, 56 insertions(+), 56 deletions(-) diff --git a/src/p_mobj.c b/src/p_mobj.c index 0151b9114..61bbe60e5 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -3068,14 +3068,67 @@ void P_MobjCheckWater(mobj_t *mobj) S_StartSound(mobj, sfx_s3k38); } - if (waterwasnotset) - return; - if ((p) // Players || (mobj->flags & MF_PUSHABLE) // Pushables || ((mobj->info->flags & MF_PUSHABLE) && mobj->fuse) // Previously pushable, might be moving still ) { + // Time to spawn the bubbles! + { + INT32 i; + INT32 bubblecount; + UINT8 prandom[4]; + mobj_t *bubble; + mobjtype_t bubbletype; + + if (mobj->eflags & MFE_GOOWATER || wasingoo) + S_StartSound(mobj, sfx_ghit); + else if (mobj->eflags & MFE_TOUCHLAVA) + S_StartSound(mobj, sfx_splash); + else + S_StartSound(mobj, sfx_splish); // And make a sound! + + bubblecount = FixedDiv(abs(mobj->momz), mobj->scale)>>(FRACBITS-1); + // Max bubble count + if (bubblecount > 128) + bubblecount = 128; + + // Create tons of bubbles + for (i = 0; i < bubblecount; i++) + { + // P_RandomByte()s are called individually to allow consistency + // across various compilers, since the order of function calls + // in C is not part of the ANSI specification. + prandom[0] = P_RandomByte(); + prandom[1] = P_RandomByte(); + prandom[2] = P_RandomByte(); + prandom[3] = P_RandomByte(); + + bubbletype = MT_SMALLBUBBLE; + if (!(prandom[0] & 0x3)) // medium bubble chance up to 64 from 32 + bubbletype = MT_MEDIUMBUBBLE; + + bubble = P_SpawnMobj( + mobj->x + FixedMul((prandom[1]<<(FRACBITS-3)) * (prandom[0]&0x80 ? 1 : -1), mobj->scale), + mobj->y + FixedMul((prandom[2]<<(FRACBITS-3)) * (prandom[0]&0x40 ? 1 : -1), mobj->scale), + mobj->z + FixedMul((prandom[3]<<(FRACBITS-2)), mobj->scale), bubbletype); + + if (bubble) + { + if (P_MobjFlip(mobj)*mobj->momz < 0) + bubble->momz = mobj->momz >> 4; + else + bubble->momz = 0; + + bubble->destscale = mobj->scale; + P_SetScale(bubble, mobj->scale); + } + } + } + + if (waterwasnotset) + return; + // Check to make sure you didn't just cross into a sector to jump out of // that has shallower water than the block you were originally in. if ((!(mobj->eflags & MFE_VERTICALFLIP) && mobj->watertop-mobj->floorz <= height>>1) @@ -3160,59 +3213,6 @@ void P_MobjCheckWater(mobj_t *mobj) P_SetScale(splish, mobj->scale); } } - - // Time to spawn the bubbles! - { - INT32 i; - INT32 bubblecount; - UINT8 prandom[4]; - mobj_t *bubble; - mobjtype_t bubbletype; - - if (mobj->eflags & MFE_GOOWATER || wasingoo) - S_StartSound(mobj, sfx_ghit); - else if (mobj->eflags & MFE_TOUCHLAVA) - S_StartSound(mobj, sfx_splash); - else - S_StartSound(mobj, sfx_splish); // And make a sound! - - bubblecount = FixedDiv(abs(mobj->momz), mobj->scale)>>(FRACBITS-1); - // Max bubble count - if (bubblecount > 128) - bubblecount = 128; - - // Create tons of bubbles - for (i = 0; i < bubblecount; i++) - { - // P_RandomByte()s are called individually to allow consistency - // across various compilers, since the order of function calls - // in C is not part of the ANSI specification. - prandom[0] = P_RandomByte(); - prandom[1] = P_RandomByte(); - prandom[2] = P_RandomByte(); - prandom[3] = P_RandomByte(); - - bubbletype = MT_SMALLBUBBLE; - if (!(prandom[0] & 0x3)) // medium bubble chance up to 64 from 32 - bubbletype = MT_MEDIUMBUBBLE; - - bubble = P_SpawnMobj( - mobj->x + FixedMul((prandom[1]<<(FRACBITS-3)) * (prandom[0]&0x80 ? 1 : -1), mobj->scale), - mobj->y + FixedMul((prandom[2]<<(FRACBITS-3)) * (prandom[0]&0x40 ? 1 : -1), mobj->scale), - mobj->z + FixedMul((prandom[3]<<(FRACBITS-2)), mobj->scale), bubbletype); - - if (bubble) - { - if (P_MobjFlip(mobj)*mobj->momz < 0) - bubble->momz = mobj->momz >> 4; - else - bubble->momz = 0; - - bubble->destscale = mobj->scale; - P_SetScale(bubble, mobj->scale); - } - } - } } } From 033a489b8549517c2bfefe6c79a361a18e3b50ab Mon Sep 17 00:00:00 2001 From: James R Date: Mon, 13 Dec 2021 01:29:20 -0800 Subject: [PATCH 139/156] Fix bad merge @ 4a8340cd4 --- src/hardware/hw_defs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/hardware/hw_defs.h b/src/hardware/hw_defs.h index b4dc1accb..2cdbd02c3 100644 --- a/src/hardware/hw_defs.h +++ b/src/hardware/hw_defs.h @@ -113,7 +113,7 @@ typedef struct UINT8 splitscreen; boolean flip; // screenflip boolean shearing; // 14042019 - angle_t viewaiming; // 17052019 + float viewaiming; // 17052019 boolean roll; FLOAT rollangle; // done to not override USE_FTRANSFORM_ANGLEZ FLOAT centerx, centery; From 1140410e2cf11dedf6a1aa607e68d82a1d6f68be Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 10 Dec 2021 18:49:40 -0800 Subject: [PATCH 140/156] Spawn SPHERE BOXES randomly in Battle They look like random item boxes (the ones in Race) but have a blue sphere inside of them. One box is worth 10 blue spheres. More boxes spawn during Overtime. New sprite: SBOX --- src/deh_tables.c | 3 +++ src/info.c | 41 +++++++++++++++++++++++++++++++++++++++++ src/info.h | 16 ++++++++++++++++ src/k_battle.c | 38 ++++++++++++++++++++++++++++++++++++++ src/k_battle.h | 1 + src/p_enemy.c | 4 +++- src/p_inter.c | 23 ++++++++--------------- src/p_local.h | 2 +- src/p_mobj.c | 2 ++ src/p_user.c | 20 ++++++++++++++++++++ 10 files changed, 133 insertions(+), 17 deletions(-) diff --git a/src/deh_tables.c b/src/deh_tables.c index 7e309c33f..894157639 100644 --- a/src/deh_tables.c +++ b/src/deh_tables.c @@ -3476,6 +3476,9 @@ const char *const STATE_LIST[] = { // array length left dynamic for sanity testi "S_RANDOMITEM12", "S_DEADRANDOMITEM", + // Sphere Box (for Battle) + "S_SPHEREBOX", + // Random Item Pop "S_RANDOMITEMPOP1", "S_RANDOMITEMPOP2", diff --git a/src/info.c b/src/info.c index 5d506d98d..2db296b99 100644 --- a/src/info.c +++ b/src/info.c @@ -526,6 +526,7 @@ char sprnames[NUMSPRITES + 1][5] = //SRB2kart Sprites (sort later) "RNDM", // Random Item Box + "SBOX", // Sphere Box (for Battle) "RPOP", // Random Item Box Pop "SGNS", // Signpost sparkle "FAST", // Speed boost trail @@ -4061,6 +4062,19 @@ state_t states[NUMSTATES] = {SPR_RNDM, 22|FF_FULLBRIGHT|FF_ANIMATE|FF_GLOBALANIM, 4, {NULL}, 1, 1, S_RANDOMITEM1}, // S_RANDOMITEM12 {SPR_NULL, 0, 0, {A_ItemPop}, 0, 0, S_NULL}, // S_DEADRANDOMITEM + {SPR_SBOX, FF_FULLBRIGHT|FF_ANIMATE|FF_GLOBALANIM, 4, {NULL}, 1, 1, S_SPHEREBOX2}, // S_SPHEREBOX1 + {SPR_SBOX, 2|FF_FULLBRIGHT|FF_ANIMATE|FF_GLOBALANIM, 4, {NULL}, 1, 1, S_SPHEREBOX3}, // S_SPHEREBOX2 + {SPR_SBOX, 4|FF_FULLBRIGHT|FF_ANIMATE|FF_GLOBALANIM, 4, {NULL}, 1, 1, S_SPHEREBOX4}, // S_SPHEREBOX3 + {SPR_SBOX, 6|FF_FULLBRIGHT|FF_ANIMATE|FF_GLOBALANIM, 4, {NULL}, 1, 1, S_SPHEREBOX5}, // S_SPHEREBOX4 + {SPR_SBOX, 8|FF_FULLBRIGHT|FF_ANIMATE|FF_GLOBALANIM, 4, {NULL}, 1, 1, S_SPHEREBOX6}, // S_SPHEREBOX5 + {SPR_SBOX, 10|FF_FULLBRIGHT|FF_ANIMATE|FF_GLOBALANIM, 4, {NULL}, 1, 1, S_SPHEREBOX7}, // S_SPHEREBOX6 + {SPR_SBOX, 12|FF_FULLBRIGHT|FF_ANIMATE|FF_GLOBALANIM, 4, {NULL}, 1, 1, S_SPHEREBOX8}, // S_SPHEREBOX7 + {SPR_SBOX, 14|FF_FULLBRIGHT|FF_ANIMATE|FF_GLOBALANIM, 4, {NULL}, 1, 1, S_SPHEREBOX9}, // S_SPHEREBOX8 + {SPR_SBOX, 16|FF_FULLBRIGHT|FF_ANIMATE|FF_GLOBALANIM, 4, {NULL}, 1, 1, S_SPHEREBOX10}, // S_SPHEREBOX9 + {SPR_SBOX, 18|FF_FULLBRIGHT|FF_ANIMATE|FF_GLOBALANIM, 4, {NULL}, 1, 1, S_SPHEREBOX11}, // S_SPHEREBOX10 + {SPR_SBOX, 20|FF_FULLBRIGHT|FF_ANIMATE|FF_GLOBALANIM, 4, {NULL}, 1, 1, S_SPHEREBOX12}, // S_SPHEREBOX11 + {SPR_SBOX, 22|FF_FULLBRIGHT|FF_ANIMATE|FF_GLOBALANIM, 4, {NULL}, 1, 1, S_SPHEREBOX1}, // S_SPHEREBOX12 + {SPR_RPOP, FF_FULLBRIGHT, 5, {NULL}, 0, 0, S_RANDOMITEMPOP2}, // S_RANDOMITEMPOP1 {SPR_RPOP, FF_FULLBRIGHT|1, 5, {NULL}, 0, 0, S_RANDOMITEMPOP3}, // S_RANDOMITEMPOP2 {SPR_RPOP, FF_FULLBRIGHT|2, 5, {NULL}, 0, 0, S_RANDOMITEMPOP4}, // S_RANDOMITEMPOP3 @@ -23017,6 +23031,33 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = S_NULL // raisestate }, + { // MT_SPHEREBOX + -1, // doomednum + S_SPHEREBOX1, // spawnstate + 1000, // spawnhealth + S_NULL, // seestate + sfx_None, // seesound + 0, // reactiontime + sfx_None, // attacksound + S_NULL, // painstate + 0, // painchance + sfx_None, // painsound + S_NULL, // meleestate + S_NULL, // missilestate + S_DEADRANDOMITEM, // deathstate + S_NULL, // xdeathstate + sfx_kc2e, // deathsound + 60*FRACUNIT, // speed + 48*FRACUNIT, // radius + 48*FRACUNIT, // height + 0, // display offset + 100, // mass + MT_RANDOMITEMPOP, // damage + sfx_None, // activesound + MF_SLIDEME|MF_SPECIAL|MF_NOGRAVITY|MF_NOCLIPHEIGHT|MF_DONTENCOREMAP, // flags + S_NULL // raisestate + }, + { // MT_RANDOMITEMPOP -1, // doomednum S_INVISIBLE, // spawnstate diff --git a/src/info.h b/src/info.h index 115948905..eab11e86a 100644 --- a/src/info.h +++ b/src/info.h @@ -1070,6 +1070,7 @@ typedef enum sprite // SRB2Kart SPR_RNDM, // Random Item Box + SPR_SBOX, // Sphere Box (for Battle) SPR_RPOP, // Random Item Box Pop SPR_SGNS, // Signpost sparkle SPR_FAST, // Speed boost trail @@ -4453,6 +4454,20 @@ typedef enum state S_RANDOMITEM12, S_DEADRANDOMITEM, + // Sphere Box (for Battle) + S_SPHEREBOX1, + S_SPHEREBOX2, + S_SPHEREBOX3, + S_SPHEREBOX4, + S_SPHEREBOX5, + S_SPHEREBOX6, + S_SPHEREBOX7, + S_SPHEREBOX8, + S_SPHEREBOX9, + S_SPHEREBOX10, + S_SPHEREBOX11, + S_SPHEREBOX12, + // Random Item Pop S_RANDOMITEMPOP1, S_RANDOMITEMPOP2, @@ -6465,6 +6480,7 @@ typedef enum mobj_type // SRB2kart MT_RANDOMITEM, + MT_SPHEREBOX, MT_RANDOMITEMPOP, MT_FLOATINGITEM, MT_ITEMCAPSULE, diff --git a/src/k_battle.c b/src/k_battle.c index c33ea6bcc..83c47d43e 100644 --- a/src/k_battle.c +++ b/src/k_battle.c @@ -229,6 +229,28 @@ mobj_t *K_SpawnChaosEmerald(fixed_t x, fixed_t y, fixed_t z, angle_t angle, SINT return emerald; } +mobj_t *K_SpawnSphereBox(fixed_t x, fixed_t y, fixed_t z, angle_t angle, SINT8 flip, UINT8 amount) +{ + mobj_t *drop = P_SpawnMobj(x, y, z, MT_SPHEREBOX); + + (void)amount; + + drop->angle = angle; + P_Thrust(drop, + FixedAngle(P_RandomFixed() * 180) + angle, + P_RandomRange(4, 12) * mapobjectscale); + + drop->momz = flip * 12 * mapobjectscale; + if (drop->eflags & MFE_UNDERWATER) + drop->momz = (117 * drop->momz) / 200; + + drop->flags &= ~(MF_NOGRAVITY|MF_NOCLIPHEIGHT); + + drop->extravalue1 = amount; + + return drop; +} + void K_DropEmeraldsFromPlayer(player_t *player, UINT32 emeraldType) { UINT8 i; @@ -352,6 +374,14 @@ void K_RunPaperItemSpawners(void) firstUnspawnedEmerald ); } + else if (P_RandomChance(FRACUNIT/2)) + { + K_SpawnSphereBox( + battleovertime.x, battleovertime.y, battleovertime.z + (128 * mapobjectscale * flip), + FixedAngle(P_RandomRange(0, 359) * FRACUNIT), flip, + 10 + ); + } else { K_CreatePaperItem( @@ -441,6 +471,14 @@ void K_RunPaperItemSpawners(void) firstUnspawnedEmerald ); } + else if (P_RandomChance(FRACUNIT/3)) + { + drop = K_SpawnSphereBox( + spotList[r]->x, spotList[r]->y, spotList[r]->z + (128 * mapobjectscale * flip), + FixedAngle(P_RandomRange(0, 359) * FRACUNIT), flip, + 10 + ); + } else { drop = K_CreatePaperItem( diff --git a/src/k_battle.h b/src/k_battle.h index 221873b04..c56c576d6 100644 --- a/src/k_battle.h +++ b/src/k_battle.h @@ -22,6 +22,7 @@ void K_SpawnBattlePoints(player_t *source, player_t *victim, UINT8 amount); void K_CheckBumpers(void); void K_CheckEmeralds(player_t *player); mobj_t *K_SpawnChaosEmerald(fixed_t x, fixed_t y, fixed_t z, angle_t angle, SINT8 flip, UINT32 emeraldType); +mobj_t *K_SpawnSphereBox(fixed_t x, fixed_t y, fixed_t z, angle_t angle, SINT8 flip, UINT8 amount); void K_DropEmeraldsFromPlayer(player_t *player, UINT32 emeraldType); UINT8 K_NumEmeralds(player_t *player); void K_RunPaperItemSpawners(void); diff --git a/src/p_enemy.c b/src/p_enemy.c index 7d4ad7400..8bc40525e 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -13308,7 +13308,9 @@ void A_ItemPop(mobj_t *actor) if (actor->info->deathsound) S_StartSound(remains, actor->info->deathsound); - if (!((gametyperules & GTR_BUMPERS) && actor->target->player->bumpers <= 0)) + if (gametyperules & GTR_BUMPERS) + P_GivePlayerSpheres(actor->target->player, actor->extravalue1); + else actor->target->player->itemroulette = 1; remains->flags2 &= ~MF2_AMBUSH; diff --git a/src/p_inter.c b/src/p_inter.c index 0a2bb4e13..4dafa91c2 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -268,12 +268,14 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) if (!P_CanPickupItem(player, 1)) return; - if ((gametyperules & GTR_BUMPERS) && player->bumpers <= 0) - { - return; - } - special->momx = special->momy = special->momz = 0; + P_SetTarget(&special->target, toucher); + P_KillMobj(special, toucher, toucher, DMG_NORMAL); + break; + case MT_SPHEREBOX: + if (player->bumpers <= 0) + return; + P_SetTarget(&special->target, toucher); P_KillMobj(special, toucher, toucher, DMG_NORMAL); break; @@ -510,16 +512,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) if (!(P_CanPickupItem(player, 0))) return; - // Reached the cap, don't waste 'em! - if (player->spheres >= 40) - return; - - // Not alive - if ((gametyperules & GTR_BUMPERS) && (player->bumpers <= 0)) - return; - - special->momx = special->momy = special->momz = 0; - player->spheres++; + P_GivePlayerSpheres(player, 1); break; // Secret emblem thingy diff --git a/src/p_local.h b/src/p_local.h index d90bfde4c..227d915f8 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -175,7 +175,7 @@ void P_RestoreMusic(player_t *player); boolean P_EndingMusic(player_t *player); mobj_t *P_SpawnGhostMobj(mobj_t *mobj); INT32 P_GivePlayerRings(player_t *player, INT32 num_rings); -void P_GivePlayerSpheres(player_t *player, INT32 num_spheres); +INT32 P_GivePlayerSpheres(player_t *player, INT32 num_spheres); void P_GivePlayerLives(player_t *player, INT32 numlives); UINT8 P_GetNextEmerald(void); void P_GiveEmerald(boolean spawnObj); diff --git a/src/p_mobj.c b/src/p_mobj.c index ad86d0434..08c6ca088 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -8597,6 +8597,7 @@ static boolean P_MobjRegularThink(mobj_t *mobj) } break; case MT_RANDOMITEM: + case MT_SPHEREBOX: if (gametype == GT_BATTLE && mobj->threshold == 70) { mobj->color = K_RainbowColor(leveltime); @@ -9377,6 +9378,7 @@ static void P_DefaultMobjShadowScale(mobj_t *thing) thing->shadowscale = 12*FRACUNIT/5; break; case MT_RANDOMITEM: + case MT_SPHEREBOX: thing->shadowscale = FRACUNIT/2; thing->whiteshadow = false; break; diff --git a/src/p_user.c b/src/p_user.c index 7ab85b6ec..4837022e2 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -500,6 +500,26 @@ INT32 P_GivePlayerRings(player_t *player, INT32 num_rings) return num_rings; } +INT32 P_GivePlayerSpheres(player_t *player, INT32 num_spheres) +{ + num_spheres += player->spheres; + + // Not alive + if ((gametyperules & GTR_BUMPERS) && (player->bumpers <= 0)) + return 0; + + if (num_spheres > 40) // Reached the cap, don't waste 'em! + num_spheres = 40; + else if (num_spheres < 0) + num_spheres = 0; + + num_spheres -= player->spheres; + + player->spheres += num_spheres; + + return num_spheres; +} + // // P_GivePlayerLives // From 514501125193e32e8d80b1c52248c8d8b8edcd5f Mon Sep 17 00:00:00 2001 From: James R Date: Tue, 14 Dec 2021 18:11:08 -0800 Subject: [PATCH 141/156] Add some missing G_SetGametype calls Fixes timelimit not being reset when switching gametypes on the vote screen. --- src/g_demo.c | 1 + src/y_inter.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/g_demo.c b/src/g_demo.c index 712e628f8..2dd3cd277 100644 --- a/src/g_demo.c +++ b/src/g_demo.c @@ -2793,6 +2793,7 @@ void G_DoPlayDemo(char *defdemoname) demoflags = READUINT8(demo_p); gametype = READUINT8(demo_p); + G_SetGametype(gametype); if (demo.title) // Titledemos should always play and ought to always be compatible with whatever wadlist is running. G_SkipDemoExtraFiles(&demo_p); diff --git a/src/y_inter.c b/src/y_inter.c index e050deddc..415672713 100644 --- a/src/y_inter.c +++ b/src/y_inter.c @@ -1459,7 +1459,7 @@ static void Y_VoteStops(SINT8 pick, SINT8 level) if (gametype != votelevels[level][1]) { INT16 lastgametype = gametype; - gametype = votelevels[level][1]; + G_SetGametype(votelevels[level][1]); D_GameTypeChanged(lastgametype); forceresetplayers = true; } From 2ac9761af08301287a3e5a3cff6e1b6b449665ed Mon Sep 17 00:00:00 2001 From: James R Date: Tue, 14 Dec 2021 23:19:45 -0800 Subject: [PATCH 142/156] Free unused texture lumps in R_LoadTextures PU_CACHE never gets freed automatically and Z_Unlock does NOTHING. --- src/r_textures.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/r_textures.c b/src/r_textures.c index 9716724b5..df7709374 100644 --- a/src/r_textures.c +++ b/src/r_textures.c @@ -814,7 +814,7 @@ Rloadflats (INT32 i, INT32 w) patch->lump = texstart + j; patch->flip = 0; - Z_Unlock(flatlump); + Z_Free(flatlump); texturewidth[i] = texture->width; textureheight[i] = texture->height << FRACBITS; @@ -915,7 +915,7 @@ Rloadtextures (INT32 i, INT32 w) patch->lump = texstart + j; patch->flip = 0; - Z_Unlock(patchlump); + Z_Free(patchlump); texturewidth[i] = texture->width; textureheight[i] = texture->height << FRACBITS; From 152f4224d94c133c9cca17c63754e033535d0206 Mon Sep 17 00:00:00 2001 From: James R Date: Wed, 15 Dec 2021 14:02:56 -0800 Subject: [PATCH 143/156] Read only header bytes when creating textures list R_LoadTextures was reading in the entirety of every texture lump, now it only reads the 8 byte PNG header. This saved more than 1 second for me (1.68 s -> 0.24 s). PNG still need to be read in entirely to check their dimensions; I didn't bother looking into optimizing it since we don't have many PNG textures right now. --- src/r_picformats.h | 1 + src/r_textures.c | 26 +++++++++++++------------- 2 files changed, 14 insertions(+), 13 deletions(-) diff --git a/src/r_picformats.h b/src/r_picformats.h index 8d3999013..0a822cc48 100644 --- a/src/r_picformats.h +++ b/src/r_picformats.h @@ -105,6 +105,7 @@ typedef struct } spriteinfo_t; // Portable Network Graphics +#define PNG_HEADER_SIZE (8) boolean Picture_IsLumpPNG(const UINT8 *d, size_t s); #define Picture_ThrowPNGError(lumpname, wadfilename) I_Error("W_Wad: Lump \"%s\" in file \"%s\" is a .png - please convert to either Doom or Flat (raw) image format.", lumpname, wadfilename); // Fears Of LJ Sonic diff --git a/src/r_textures.c b/src/r_textures.c index df7709374..4ec110556 100644 --- a/src/r_textures.c +++ b/src/r_textures.c @@ -725,6 +725,7 @@ Rloadflats (INT32 i, INT32 w) UINT16 texstart, texend; texture_t *texture; texpatch_t *patch; + UINT8 header[PNG_HEADER_SIZE]; // Yes if (wadfiles[w]->type == RET_PK3) @@ -743,7 +744,6 @@ Rloadflats (INT32 i, INT32 w) // Work through each lump between the markers in the WAD. for (j = 0; j < (texend - texstart); j++) { - UINT8 *flatlump; UINT16 wadnum = (UINT16)w; lumpnum_t lumpnum = texstart + j; size_t lumplength; @@ -755,7 +755,7 @@ Rloadflats (INT32 i, INT32 w) continue; // If it is then SKIP IT } - flatlump = W_CacheLumpNumPwad(wadnum, lumpnum, PU_CACHE); + W_ReadLumpHeaderPwad(wadnum, lumpnum, header, sizeof header, 0); lumplength = W_LumpLengthPwad(wadnum, lumpnum); switch (lumplength) @@ -790,12 +790,14 @@ Rloadflats (INT32 i, INT32 w) M_Memcpy(texture->name, W_CheckNameForNumPwad(wadnum, lumpnum), sizeof(texture->name)); #ifndef NO_PNG_LUMPS - if (Picture_IsLumpPNG((UINT8 *)flatlump, lumplength)) + if (Picture_IsLumpPNG(header, lumplength)) { + UINT8 *flatlump = W_CacheLumpNumPwad(wadnum, lumpnum, PU_CACHE); INT32 width, height; Picture_PNGDimensions((UINT8 *)flatlump, &width, &height, NULL, NULL, lumplength); texture->width = (INT16)width; texture->height = (INT16)height; + Z_Free(flatlump); } else #endif @@ -814,8 +816,6 @@ Rloadflats (INT32 i, INT32 w) patch->lump = texstart + j; patch->flip = 0; - Z_Free(flatlump); - texturewidth[i] = texture->width; textureheight[i] = texture->height << FRACBITS; i++; @@ -835,8 +835,8 @@ Rloadtextures (INT32 i, INT32 w) UINT16 j; UINT16 texstart, texend, texturesLumpPos; texture_t *texture; - softwarepatch_t *patchlump; texpatch_t *patch; + softwarepatch_t patchlump; // Get the lump numbers for the markers in the WAD, if they exist. if (wadfiles[w]->type == RET_PK3) @@ -876,7 +876,7 @@ Rloadtextures (INT32 i, INT32 w) continue; // If it is then SKIP IT } - patchlump = W_CacheLumpNumPwad(wadnum, lumpnum, PU_CACHE); + W_ReadLumpHeaderPwad(wadnum, lumpnum, &patchlump, PNG_HEADER_SIZE, 0); #ifndef NO_PNG_LUMPS lumplength = W_LumpLengthPwad(wadnum, lumpnum); #endif @@ -888,18 +888,20 @@ Rloadtextures (INT32 i, INT32 w) M_Memcpy(texture->name, W_CheckNameForNumPwad(wadnum, lumpnum), sizeof(texture->name)); #ifndef NO_PNG_LUMPS - if (Picture_IsLumpPNG((UINT8 *)patchlump, lumplength)) + if (Picture_IsLumpPNG((UINT8 *)&patchlump, lumplength)) { + UINT8 *png = W_CacheLumpNumPwad(wadnum, lumpnum, PU_CACHE); INT32 width, height; - Picture_PNGDimensions((UINT8 *)patchlump, &width, &height, NULL, NULL, lumplength); + Picture_PNGDimensions(png, &width, &height, NULL, NULL, lumplength); texture->width = (INT16)width; texture->height = (INT16)height; + Z_Free(png); } else #endif { - texture->width = SHORT(patchlump->width); - texture->height = SHORT(patchlump->height); + texture->width = SHORT(patchlump.width); + texture->height = SHORT(patchlump.height); } texture->type = TEXTURETYPE_SINGLEPATCH; @@ -915,8 +917,6 @@ Rloadtextures (INT32 i, INT32 w) patch->lump = texstart + j; patch->flip = 0; - Z_Free(patchlump); - texturewidth[i] = texture->width; textureheight[i] = texture->height << FRACBITS; i++; From de2eab5e7a057ff30ae719868c3f33ac065210cc Mon Sep 17 00:00:00 2001 From: James R Date: Wed, 15 Dec 2021 14:01:40 -0800 Subject: [PATCH 144/156] Inflate only size out bytes Saves time uncompressing an entire lump when only part of it is needed. --- src/w_wad.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/w_wad.c b/src/w_wad.c index 4e7e97dbb..60339c426 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -1480,10 +1480,10 @@ size_t W_ReadLumpHeaderPwad(UINT16 wad, UINT16 lump, void *dest, size_t size, si int zErr; // Helper var. z_stream strm; unsigned long rawSize = l->disksize; - unsigned long decSize = l->size; + unsigned long decSize = size; rawData = Z_Malloc(rawSize, PU_STATIC, NULL); - decData = Z_Malloc(decSize, PU_STATIC, NULL); + decData = dest; if (fread(rawData, 1, rawSize, handle) < rawSize) I_Error("wad %d, lump %d: cannot read compressed data", wad, lump); @@ -1501,12 +1501,8 @@ size_t W_ReadLumpHeaderPwad(UINT16 wad, UINT16 lump, void *dest, size_t size, si zErr = inflateInit2(&strm, -15); if (zErr == Z_OK) { - zErr = inflate(&strm, Z_FINISH); - if (zErr == Z_STREAM_END) - { - M_Memcpy(dest, decData, size); - } - else + zErr = inflate(&strm, Z_SYNC_FLUSH); + if (zErr != Z_OK && zErr != Z_STREAM_END) { size = 0; zerr(zErr); @@ -1520,7 +1516,6 @@ size_t W_ReadLumpHeaderPwad(UINT16 wad, UINT16 lump, void *dest, size_t size, si } Z_Free(rawData); - Z_Free(decData); #ifdef NO_PNG_LUMPS if (Picture_IsLumpPNG((UINT8 *)dest, size)) From 29399f603389f587c6228a96a564995f8cbd4994 Mon Sep 17 00:00:00 2001 From: James R Date: Wed, 15 Dec 2021 15:34:51 -0800 Subject: [PATCH 145/156] Send R_GenerateBlendTables number crunch to parallel thread --- src/d_main.c | 3 +++ src/r_draw.c | 40 +++++++++++++++++++++++++++++++--------- src/r_main.c | 2 +- 3 files changed, 35 insertions(+), 10 deletions(-) diff --git a/src/d_main.c b/src/d_main.c index b8fad8ec6..27ee40926 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -1417,6 +1417,9 @@ void D_SRB2Main(void) // setup loading screen SCR_Startup(); + // Do this in background; lots of number crunching + R_InitTranslucencyTables(); + CON_SetLoadingProgress(LOADED_ISTARTUPGRAPHICS); CONS_Printf("HU_Init()...\n"); diff --git a/src/r_draw.c b/src/r_draw.c index 4adfb6663..377cca156 100644 --- a/src/r_draw.c +++ b/src/r_draw.c @@ -26,6 +26,7 @@ #include "z_zone.h" #include "console.h" // Until buffering gets finished #include "k_color.h" // SRB2kart +#include "i_threads.h" #ifdef HWRENDER #include "hardware/hw_main.h" @@ -192,6 +193,29 @@ CV_PossibleValue_t Followercolor_cons_t[MAXSKINCOLORS+3]; // +3 to account for " #define TRANSTAB_AMTMUL10 (255.0f / 10.0f) +static void R_AllocateBlendTables(void) +{ + INT32 i; + + for (i = 0; i < NUMBLENDMAPS; i++) + { + if (i == blendtab_modulate) + continue; + blendtables[i] = Z_MallocAlign((NUMTRANSTABLES + 1) * 0x10000, PU_STATIC, NULL, 16); + } + + // Modulation blending only requires a single table + blendtables[blendtab_modulate] = Z_MallocAlign(0x10000, PU_STATIC, NULL, 16); +} + +#ifdef HAVE_THREADS +static void R_GenerateBlendTables_Thread(void *userdata) +{ + (void)userdata; + R_GenerateBlendTables(); +} +#endif + /** \brief Initializes the translucency tables used by the Software renderer. */ void R_InitTranslucencyTables(void) @@ -212,20 +236,20 @@ void R_InitTranslucencyTables(void) W_ReadLump(W_GetNumForName("TRANS80"), transtables+0x70000); W_ReadLump(W_GetNumForName("TRANS90"), transtables+0x80000); + R_AllocateBlendTables(); + +#ifdef HAVE_THREADS + I_spawn_thread("blend-tables", + R_GenerateBlendTables_Thread, NULL); +#else R_GenerateBlendTables(); +#endif } void R_GenerateBlendTables(void) { INT32 i; - for (i = 0; i < NUMBLENDMAPS; i++) - { - if (i == blendtab_modulate) - continue; - blendtables[i] = Z_MallocAlign((NUMTRANSTABLES + 1) * 0x10000, PU_STATIC, NULL, 16); - } - for (i = 0; i <= 9; i++) { const size_t offs = (0x10000 * i); @@ -236,8 +260,6 @@ void R_GenerateBlendTables(void) R_GenerateTranslucencyTable(blendtables[blendtab_reversesubtract] + offs, AST_REVERSESUBTRACT, alpha); } - // Modulation blending only requires a single table - blendtables[blendtab_modulate] = Z_MallocAlign(0x10000, PU_STATIC, NULL, 16); R_GenerateTranslucencyTable(blendtables[blendtab_modulate], AST_MODULATE, 0); } diff --git a/src/r_main.c b/src/r_main.c index 210a97627..c3e044ef2 100644 --- a/src/r_main.c +++ b/src/r_main.c @@ -1137,7 +1137,7 @@ void R_Init(void) R_InitLightTables(); //I_OutputMsg("\nR_InitTranslucencyTables\n"); - R_InitTranslucencyTables(); + //R_InitTranslucencyTables(); R_InitDrawNodes(); From c39edbbf7fea25a8f915e970af78553d3102149d Mon Sep 17 00:00:00 2001 From: James R Date: Wed, 15 Dec 2021 16:02:23 -0800 Subject: [PATCH 146/156] Read only PNG header bytes to confirm a sprite is a PNG Saves about 300 ms for R_InitSkins. --- src/r_things.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/r_things.c b/src/r_things.c index eccbe7e23..c370a2c67 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -286,16 +286,18 @@ boolean R_AddSingleSpriteDef(const char *sprname, spritedef_t *spritedef, UINT16 #ifndef NO_PNG_LUMPS { - softwarepatch_t *png = W_CacheLumpNumPwad(wadnum, l, PU_STATIC); + UINT8 header[PNG_HEADER_SIZE]; size_t len = W_LumpLengthPwad(wadnum, l); - if (Picture_IsLumpPNG((UINT8 *)png, len)) + W_ReadLumpHeaderPwad(wadnum, l, header, sizeof header, 0); + + if (Picture_IsLumpPNG(header, len)) { + UINT8 *png = W_CacheLumpNumPwad(wadnum, l, PU_STATIC); Picture_PNGDimensions((UINT8 *)png, &width, &height, &topoffset, &leftoffset, len); isPNG = true; + Z_Free(png); } - - Z_Free(png); } if (!isPNG) From cfe8a1bfa4f11d80bf8d673e60d106ee1eedcd88 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Wed, 15 Dec 2021 21:21:54 -0500 Subject: [PATCH 147/156] No random chance for sphere box Asked Oni how it should be done, he said item + sphere box at the same time --- src/k_battle.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/k_battle.c b/src/k_battle.c index 83c47d43e..8a5257206 100644 --- a/src/k_battle.c +++ b/src/k_battle.c @@ -374,14 +374,6 @@ void K_RunPaperItemSpawners(void) firstUnspawnedEmerald ); } - else if (P_RandomChance(FRACUNIT/2)) - { - K_SpawnSphereBox( - battleovertime.x, battleovertime.y, battleovertime.z + (128 * mapobjectscale * flip), - FixedAngle(P_RandomRange(0, 359) * FRACUNIT), flip, - 10 - ); - } else { K_CreatePaperItem( @@ -389,6 +381,12 @@ void K_RunPaperItemSpawners(void) FixedAngle(P_RandomRange(0, 359) * FRACUNIT), flip, 0, 0 ); + + K_SpawnSphereBox( + battleovertime.x, battleovertime.y, battleovertime.z + (128 * mapobjectscale * flip), + FixedAngle(P_RandomRange(0, 359) * FRACUNIT), flip, + 10 + ); } } else From ccdbd9ccc9086e8a93f3a39eadecc7e94618ba4b Mon Sep 17 00:00:00 2001 From: James R Date: Wed, 15 Dec 2021 22:32:14 -0800 Subject: [PATCH 148/156] A_ItemPop: var1 determines roulette or sphere award --- src/info.c | 3 ++- src/info.h | 1 + src/p_enemy.c | 6 ++++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/info.c b/src/info.c index 2db296b99..062d1fbb2 100644 --- a/src/info.c +++ b/src/info.c @@ -4074,6 +4074,7 @@ state_t states[NUMSTATES] = {SPR_SBOX, 18|FF_FULLBRIGHT|FF_ANIMATE|FF_GLOBALANIM, 4, {NULL}, 1, 1, S_SPHEREBOX11}, // S_SPHEREBOX10 {SPR_SBOX, 20|FF_FULLBRIGHT|FF_ANIMATE|FF_GLOBALANIM, 4, {NULL}, 1, 1, S_SPHEREBOX12}, // S_SPHEREBOX11 {SPR_SBOX, 22|FF_FULLBRIGHT|FF_ANIMATE|FF_GLOBALANIM, 4, {NULL}, 1, 1, S_SPHEREBOX1}, // S_SPHEREBOX12 + {SPR_NULL, 0, 0, {A_ItemPop}, 1, 0, S_NULL}, // S_DEADSPHEREBOX {SPR_RPOP, FF_FULLBRIGHT, 5, {NULL}, 0, 0, S_RANDOMITEMPOP2}, // S_RANDOMITEMPOP1 {SPR_RPOP, FF_FULLBRIGHT|1, 5, {NULL}, 0, 0, S_RANDOMITEMPOP3}, // S_RANDOMITEMPOP2 @@ -23044,7 +23045,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = sfx_None, // painsound S_NULL, // meleestate S_NULL, // missilestate - S_DEADRANDOMITEM, // deathstate + S_DEADSPHEREBOX, // deathstate S_NULL, // xdeathstate sfx_kc2e, // deathsound 60*FRACUNIT, // speed diff --git a/src/info.h b/src/info.h index eab11e86a..dfb0d3c43 100644 --- a/src/info.h +++ b/src/info.h @@ -4467,6 +4467,7 @@ typedef enum state S_SPHEREBOX10, S_SPHEREBOX11, S_SPHEREBOX12, + S_DEADSPHEREBOX, // Random Item Pop S_RANDOMITEMPOP1, diff --git a/src/p_enemy.c b/src/p_enemy.c index 8bc40525e..3017850cf 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -13254,6 +13254,8 @@ void A_ChangeHeight(mobj_t *actor) void A_ItemPop(mobj_t *actor) { + INT32 locvar1 = var1; + mobj_t *remains; mobjtype_t explode; @@ -13308,9 +13310,9 @@ void A_ItemPop(mobj_t *actor) if (actor->info->deathsound) S_StartSound(remains, actor->info->deathsound); - if (gametyperules & GTR_BUMPERS) + if (locvar1 == 1) P_GivePlayerSpheres(actor->target->player, actor->extravalue1); - else + else if (locvar1 == 0) actor->target->player->itemroulette = 1; remains->flags2 &= ~MF2_AMBUSH; From 04c1a9dcb1b3068434bb5a80ed05ebdb76f03448 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Thu, 16 Dec 2021 09:40:14 -0500 Subject: [PATCH 149/156] Brightmaps on walls --- src/Sourcefile | 1 + src/k_brightmap.c | 256 ++++++++++++++++++++++++++++++++++++++++++++++ src/k_brightmap.h | 38 +++++++ src/p_setup.c | 4 + src/r_data.c | 6 ++ src/r_draw.c | 2 + src/r_draw.h | 3 + src/r_draw8.c | 153 ++++++++++++++++++++++++--- src/r_plane.c | 5 + src/r_segs.c | 95 +++++++++++++---- src/r_state.h | 3 + src/r_textures.c | 21 ++++ src/r_textures.h | 1 + src/r_things.c | 50 +++++++-- src/r_things.h | 4 +- 15 files changed, 597 insertions(+), 45 deletions(-) create mode 100644 src/k_brightmap.c create mode 100644 src/k_brightmap.h diff --git a/src/Sourcefile b/src/Sourcefile index 9bc27d4da..e142ebcc1 100644 --- a/src/Sourcefile +++ b/src/Sourcefile @@ -111,3 +111,4 @@ k_botitem.c k_botsearch.c k_grandprix.c k_hud.c +k_brightmap.c diff --git a/src/k_brightmap.c b/src/k_brightmap.c new file mode 100644 index 000000000..b9ef07ab8 --- /dev/null +++ b/src/k_brightmap.c @@ -0,0 +1,256 @@ +// DR. ROBOTNIK'S RING RACERS +//----------------------------------------------------------------------------- +// Copyright (C) 2021 by Sally "TehRealSalt" Cochenour +// Copyright (C) 2021 by Kart Krew +// +// This program is free software distributed under the +// terms of the GNU General Public License, version 2. +// See the 'LICENSE' file for more details. +//----------------------------------------------------------------------------- +/// \file k_brightmap.c +/// \brief Brightmap texture loading. + +#include "k_brightmap.h" + +#include "doomdata.h" +#include "doomdef.h" +#include "doomtype.h" +#include "fastcmp.h" +#include "r_textures.h" +#include "w_wad.h" +#include "z_zone.h" + +static brightmapStorage_t *brightmapStorage = NULL; +static size_t maxBrightmapStorage = 0; + +/*-------------------------------------------------- + static brightmapStorage_t *K_NewBrightmap(void) + + Increases the size of maxBrightmapStorage by 1. + + Input Arguments:- + None + + Return:- + The new brightmap storage struct. +--------------------------------------------------*/ +static brightmapStorage_t *K_NewBrightmap(void) +{ + maxBrightmapStorage++; + brightmapStorage = (brightmapStorage_t *)Z_Realloc(brightmapStorage, sizeof(brightmapStorage_t) * (maxBrightmapStorage + 1), PU_STATIC, NULL); + return &brightmapStorage[ maxBrightmapStorage - 1 ]; +} + +/*-------------------------------------------------- + static brightmapStorage_t *K_GetBrightmapStorageByIndex(size_t checkIndex) + + See header file for description. +--------------------------------------------------*/ +static brightmapStorage_t *K_GetBrightmapStorageByIndex(size_t checkIndex) +{ + if (checkIndex >= maxBrightmapStorage) + { + return NULL; + } + + return &brightmapStorage[checkIndex]; +} + +/*-------------------------------------------------- + static brightmapStorage_t *K_GetBrightmapStorageByTextureName(const char *checkName) + + See header file for description. +--------------------------------------------------*/ +static brightmapStorage_t *K_GetBrightmapStorageByTextureName(const char *checkName) +{ + size_t i; + + if (maxBrightmapStorage == 0) + { + return NULL; + } + + for (i = 0; i < maxBrightmapStorage; i++) + { + brightmapStorage_t *bms = &brightmapStorage[i]; + + if (stricmp(checkName, bms->textureName) == 0) + { + // Name matches. + return bms; + } + } + + return NULL; +} + +/*-------------------------------------------------- + static boolean K_BRIGHTLumpParser(UINT8 *data, size_t size) + + Parses inputted lump data as a BRIGHT lump. + + Input Arguments:- + data - Pointer to lump data. + size - The length of the lump data. + + Return:- + false if any errors occured, otherwise true. +--------------------------------------------------*/ +static boolean K_BRIGHTLumpParser(UINT8 *data, size_t size) +{ + char *tkn = M_GetToken((char *)data); + size_t pos = 0; + + while (tkn && (pos = M_GetTokenPos()) < size) + { + boolean valid = true; + + if (stricmp(tkn, "texture") == 0) + { + Z_Free(tkn); + tkn = M_GetToken(NULL); + pos = M_GetTokenPos(); + + if (tkn && pos < size) + { + brightmapStorage_t *bms = K_GetBrightmapStorageByTextureName(tkn); + + if (bms == NULL) + { + bms = K_NewBrightmap(); + strncpy(bms->textureName, tkn, 9); + } + + Z_Free(tkn); + tkn = M_GetToken(NULL); + pos = M_GetTokenPos(); + + if (tkn && pos < size) + { + strncpy(bms->brightmapName, tkn, 9); + } + else + { + CONS_Alert(CONS_ERROR, "No brightmap for brightmap definition.\n"); + valid = false; + } + } + else + { + CONS_Alert(CONS_ERROR, "No texture for brightmap definition.\n"); + valid = false; + } + } + // todo: SPRITE brightmaps?! + else + { + CONS_Alert(CONS_ERROR, "Unknown keyword '%s' found in BRIGHT lump.\n", tkn); + valid = false; + } + + Z_Free(tkn); + + if (valid == false) + { + return false; + } + + tkn = M_GetToken(NULL); + } + + Z_Free(tkn); + return true; +} + +/*-------------------------------------------------- + void K_InitBrightmaps(void) + + See header file for description. +--------------------------------------------------*/ +void K_InitBrightmaps(void) +{ + INT32 wadNum; + size_t i; + + I_Assert(brightmapStorage == NULL); + maxBrightmapStorage = 0; + + for (wadNum = 0; wadNum < numwadfiles; wadNum++) + { + lumpinfo_t *lump_p = wadfiles[wadNum]->lumpinfo; + UINT16 lumpNum; + + // Find BRIGHT lump in the WAD + lumpNum = W_CheckNumForNamePwad("BRIGHT", wadNum, 0); + + while (lumpNum != INT16_MAX) + { + UINT8 *data; + data = (UINT8 *)W_CacheLumpNumPwad(wadNum, lumpNum, PU_STATIC); + + // If that didn't exist, we have nothing to do here. + if (data == NULL) + { + lumpNum = W_CheckNumForNamePwad("BRIGHT", (UINT16)wadNum, lumpNum + 1); + continue; + } + else + { + size_t size = W_LumpLengthPwad(wadNum, lumpNum); + + size_t nameLength = strlen(wadfiles[wadNum]->filename) + 1 + strlen(lump_p->fullname); // length of file name, '|', and lump name + char *name = malloc(nameLength + 1); + + sprintf(name, "%s|%s", wadfiles[wadNum]->filename, lump_p->fullname); + name[nameLength] = '\0'; + + size = W_LumpLengthPwad(wadNum, lumpNum); + + CONS_Printf(M_GetText("Loading BRIGHT from %s\n"), name); + K_BRIGHTLumpParser(data, size); + + free(name); + } + + lumpNum = W_CheckNumForNamePwad("BRIGHT", (UINT16)wadNum, lumpNum + 1); + } + } + + if (maxBrightmapStorage == 0) + { + // No brightmaps were defined. + return; + } + + for (i = 0; i < maxBrightmapStorage; i++) + { + brightmapStorage_t *bms = K_GetBrightmapStorageByIndex(i); + INT32 texNum, bmNum; + + if (bms == NULL) + { + // Shouldn't happen. + break; + } + + texNum = R_CheckTextureNumForName(bms->textureName); + if (texNum != -1) + { + bmNum = R_CheckTextureNumForName(bms->brightmapName); + if (bmNum == -1) + { + texturebrightmaps[texNum] = 0; + } + else + { + texturebrightmaps[texNum] = bmNum; + } + } + } + + R_ClearTextureNumCache(false); + + // Clear brightmapStorage now that we're done with it. + Z_Free(brightmapStorage); + brightmapStorage = NULL; +} diff --git a/src/k_brightmap.h b/src/k_brightmap.h new file mode 100644 index 000000000..8d33ae5cb --- /dev/null +++ b/src/k_brightmap.h @@ -0,0 +1,38 @@ +// DR. ROBOTNIK'S RING RACERS +//----------------------------------------------------------------------------- +// Copyright (C) 2021 by Sally "TehRealSalt" Cochenour +// Copyright (C) 2021 by Kart Krew +// +// This program is free software distributed under the +// terms of the GNU General Public License, version 2. +// See the 'LICENSE' file for more details. +//----------------------------------------------------------------------------- +/// \file k_brightmap.h +/// \brief Brightmap texture loading. + +#ifndef __K_BRIGHTMAP_H__ +#define __K_BRIGHTMAP_H__ + +#include "doomdata.h" +#include "doomdef.h" +#include "doomtype.h" + +typedef struct brightmapStorage_s +{ + // Brightmap storage struct. + // Stores data for brightmap definitions, + // before putting them into texturebrightmaps. + + char textureName[9]; // The texture's name. + char brightmapName[9]; // The brightmap's name. +} brightmapStorage_t; + +/*-------------------------------------------------- + void K_InitBrightmaps(void); + + Finds all BRIGHT lumps and processes them. +--------------------------------------------------*/ + +void K_InitBrightmaps(void); + +#endif // __K_BRIGHTMAP_H__ diff --git a/src/p_setup.c b/src/p_setup.c index fab5429b8..db9a35a11 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -91,6 +91,7 @@ #include "k_waypoint.h" #include "k_bot.h" #include "k_grandprix.h" +#include "k_brightmap.h" // Replay names have time #if !defined (UNDER_CE) @@ -4457,6 +4458,9 @@ boolean P_AddWadFile(const char *wadfilename) // Reload ANIMDEFS P_InitPicAnims(); + // Reload BRIGHT + K_InitBrightmaps(); + // Flush and reload HUD graphics ST_UnloadGraphics(); HU_LoadGraphics(); diff --git a/src/r_data.c b/src/r_data.c index bb2e508ba..ddeb5e3b5 100644 --- a/src/r_data.c +++ b/src/r_data.c @@ -30,6 +30,9 @@ #include "byteptr.h" #include "dehacked.h" +// DRRR +#include "k_brightmap.h" + // // Graphics. // SRB2 graphics for walls and sprites @@ -1175,6 +1178,9 @@ void R_InitTextureData(void) CONS_Printf("P_InitPicAnims()...\n"); P_InitPicAnims(); + + CONS_Printf("K_InitBrightmaps()...\n"); + K_InitBrightmaps(); } // diff --git a/src/r_draw.c b/src/r_draw.c index 4adfb6663..c3bc2ac3c 100644 --- a/src/r_draw.c +++ b/src/r_draw.c @@ -71,12 +71,14 @@ UINT8 *topleft; // ========================================================================= lighttable_t *dc_colormap; +lighttable_t *dc_fullbright; INT32 dc_x = 0, dc_yl = 0, dc_yh = 0; fixed_t dc_iscale, dc_texturemid; UINT8 dc_hires; // under MSVC boolean is a byte, while on other systems, it a bit, // soo lets make it a byte on all system for the ASM code UINT8 *dc_source; +UINT8 *dc_brightmap; // ----------------------- // translucency stuff here diff --git a/src/r_draw.h b/src/r_draw.h index 646eb5ec8..b5cea0420 100644 --- a/src/r_draw.h +++ b/src/r_draw.h @@ -32,11 +32,13 @@ extern UINT8 *topleft; // ------------------------- extern lighttable_t *dc_colormap; +extern lighttable_t *dc_fullbright; extern INT32 dc_x, dc_yl, dc_yh; extern fixed_t dc_iscale, dc_texturemid; extern UINT8 dc_hires; extern UINT8 *dc_source; // first pixel in a column +extern UINT8 *dc_brightmap; // brightmap texture column, can be NULL // translucency stuff here extern UINT8 *dc_transmap; @@ -167,6 +169,7 @@ void R_DrawViewBorder(void); #endif #define TRANSPARENTPIXEL 255 +#define BRIGHTPIXEL 0 // ----------------- // 8bpp DRAWING CODE diff --git a/src/r_draw8.c b/src/r_draw8.c index af64edbce..1771614db 100644 --- a/src/r_draw8.c +++ b/src/r_draw8.c @@ -57,7 +57,9 @@ void R_DrawColumn_8(void) // This is as fast as it gets. { register const UINT8 *source = dc_source; + register const UINT8 *brightmap = dc_brightmap; register const lighttable_t *colormap = dc_colormap; + register const lighttable_t *fullbright = dc_fullbright; register INT32 heightmask = dc_texheight-1; if (dc_texheight & heightmask) // not a power of 2 -- killough { @@ -75,7 +77,14 @@ void R_DrawColumn_8(void) // Re-map color indices from wall texture column // using a lighting/special effects LUT. // heightmask is the Tutti-Frutti fix - *dest = colormap[source[frac>>FRACBITS]]; + if (brightmap != NULL && brightmap[frac>>FRACBITS] == BRIGHTPIXEL) + { + *dest = fullbright[source[frac>>FRACBITS]]; + } + else + { + *dest = colormap[source[frac>>FRACBITS]]; + } dest += vid.width; // Avoid overflow. @@ -92,15 +101,42 @@ void R_DrawColumn_8(void) { while ((count -= 2) >= 0) // texture height is a power of 2 { - *dest = colormap[source[(frac>>FRACBITS) & heightmask]]; + if (brightmap != NULL && brightmap[frac>>FRACBITS] == BRIGHTPIXEL) + { + *dest = fullbright[source[(frac>>FRACBITS) & heightmask]]; + } + else + { + *dest = colormap[source[(frac>>FRACBITS) & heightmask]]; + } + dest += vid.width; frac += fracstep; - *dest = colormap[source[(frac>>FRACBITS) & heightmask]]; + + if (brightmap != NULL && brightmap[frac>>FRACBITS] == BRIGHTPIXEL) + { + *dest = fullbright[source[(frac>>FRACBITS) & heightmask]]; + } + else + { + *dest = colormap[source[(frac>>FRACBITS) & heightmask]]; + } + dest += vid.width; frac += fracstep; } + if (count & 1) - *dest = colormap[source[(frac>>FRACBITS) & heightmask]]; + { + if (brightmap != NULL && brightmap[frac>>FRACBITS] == BRIGHTPIXEL) + { + *dest = fullbright[source[(frac>>FRACBITS) & heightmask]]; + } + else + { + *dest = colormap[source[(frac>>FRACBITS) & heightmask]]; + } + } } } } @@ -140,7 +176,9 @@ void R_Draw2sMultiPatchColumn_8(void) // This is as fast as it gets. { register const UINT8 *source = dc_source; + register const UINT8 *brightmap = dc_brightmap; register const lighttable_t *colormap = dc_colormap; + register const lighttable_t *fullbright = dc_fullbright; register INT32 heightmask = dc_texheight-1; register UINT8 val; if (dc_texheight & heightmask) // not a power of 2 -- killough @@ -160,9 +198,17 @@ void R_Draw2sMultiPatchColumn_8(void) // using a lighting/special effects LUT. // heightmask is the Tutti-Frutti fix val = source[frac>>FRACBITS]; - if (val != TRANSPARENTPIXEL) - *dest = colormap[val]; + { + if (brightmap != NULL && brightmap[frac>>FRACBITS] == BRIGHTPIXEL) + { + *dest = fullbright[val]; + } + else + { + *dest = colormap[val]; + } + } dest += vid.width; @@ -182,20 +228,51 @@ void R_Draw2sMultiPatchColumn_8(void) { val = source[(frac>>FRACBITS) & heightmask]; if (val != TRANSPARENTPIXEL) - *dest = colormap[val]; + { + if (brightmap != NULL && brightmap[frac>>FRACBITS] == BRIGHTPIXEL) + { + *dest = fullbright[val]; + } + else + { + *dest = colormap[val]; + } + } + dest += vid.width; frac += fracstep; + val = source[(frac>>FRACBITS) & heightmask]; if (val != TRANSPARENTPIXEL) - *dest = colormap[val]; + { + if (brightmap != NULL && brightmap[frac>>FRACBITS] == BRIGHTPIXEL) + { + *dest = fullbright[val]; + } + else + { + *dest = colormap[val]; + } + } + dest += vid.width; frac += fracstep; } + if (count & 1) { val = source[(frac>>FRACBITS) & heightmask]; if (val != TRANSPARENTPIXEL) - *dest = colormap[val]; + { + if (brightmap != NULL && brightmap[frac>>FRACBITS] == BRIGHTPIXEL) + { + *dest = fullbright[val]; + } + else + { + *dest = colormap[val]; + } + } } } } @@ -236,8 +313,10 @@ void R_Draw2sMultiPatchTranslucentColumn_8(void) // This is as fast as it gets. { register const UINT8 *source = dc_source; + register const UINT8 *brightmap = dc_brightmap; register const UINT8 *transmap = dc_transmap; register const lighttable_t *colormap = dc_colormap; + register const lighttable_t *fullbright = dc_fullbright; register INT32 heightmask = dc_texheight-1; register UINT8 val; if (dc_texheight & heightmask) // not a power of 2 -- killough @@ -257,9 +336,17 @@ void R_Draw2sMultiPatchTranslucentColumn_8(void) // using a lighting/special effects LUT. // heightmask is the Tutti-Frutti fix val = source[frac>>FRACBITS]; - if (val != TRANSPARENTPIXEL) - *dest = *(transmap + (colormap[val]<<8) + (*dest)); + { + if (brightmap != NULL && brightmap[frac>>FRACBITS] == BRIGHTPIXEL) + { + *dest = *(transmap + (fullbright[val]<<8) + (*dest)); + } + else + { + *dest = *(transmap + (colormap[val]<<8) + (*dest)); + } + } dest += vid.width; @@ -279,12 +366,33 @@ void R_Draw2sMultiPatchTranslucentColumn_8(void) { val = source[(frac>>FRACBITS) & heightmask]; if (val != TRANSPARENTPIXEL) - *dest = *(transmap + (colormap[val]<<8) + (*dest)); + { + if (brightmap != NULL && brightmap[frac>>FRACBITS] == BRIGHTPIXEL) + { + *dest = *(transmap + (fullbright[val]<<8) + (*dest)); + } + else + { + *dest = *(transmap + (colormap[val]<<8) + (*dest)); + } + } + dest += vid.width; frac += fracstep; + val = source[(frac>>FRACBITS) & heightmask]; if (val != TRANSPARENTPIXEL) - *dest = *(transmap + (colormap[val]<<8) + (*dest)); + { + if (brightmap != NULL && brightmap[frac>>FRACBITS] == BRIGHTPIXEL) + { + *dest = *(transmap + (fullbright[val]<<8) + (*dest)); + } + else + { + *dest = *(transmap + (colormap[val]<<8) + (*dest)); + } + } + dest += vid.width; frac += fracstep; } @@ -292,7 +400,16 @@ void R_Draw2sMultiPatchTranslucentColumn_8(void) { val = source[(frac>>FRACBITS) & heightmask]; if (val != TRANSPARENTPIXEL) - *dest = *(transmap + (colormap[val]<<8) + (*dest)); + { + if (brightmap != NULL && brightmap[frac>>FRACBITS] == BRIGHTPIXEL) + { + *dest = *(transmap + (fullbright[val]<<8) + (*dest)); + } + else + { + *dest = *(transmap + (colormap[val]<<8) + (*dest)); + } + } } } } @@ -2114,8 +2231,12 @@ void R_DrawColumnShadowed_8(void) if (height <= dc_yl) { dc_colormap = dc_lightlist[i].rcolormap; + dc_fullbright = colormaps; if (encoremap) + { dc_colormap += COLORMAP_REMAPOFFSET; + dc_fullbright += COLORMAP_REMAPOFFSET; + } if (solid && dc_yl < bheight) dc_yl = bheight; continue; @@ -2132,8 +2253,12 @@ void R_DrawColumnShadowed_8(void) dc_yl = dc_yh + 1; dc_colormap = dc_lightlist[i].rcolormap; + dc_fullbright = colormaps; if (encoremap) + { dc_colormap += COLORMAP_REMAPOFFSET; + dc_fullbright += COLORMAP_REMAPOFFSET; + } } dc_yh = realyh; if (dc_yl <= realyh) diff --git a/src/r_plane.c b/src/r_plane.c index 8ec7e2b99..58e6ce5ea 100644 --- a/src/r_plane.c +++ b/src/r_plane.c @@ -651,8 +651,12 @@ static void R_DrawSkyPlane(visplane_t *pl) // Because of this hack, sky is not affected // by sector colormaps (INVUL inverse mapping is not implemented in SRB2 so is irrelevant). dc_colormap = colormaps; + dc_fullbright = colormaps; if (encoremap) + { dc_colormap += COLORMAP_REMAPOFFSET; + dc_fullbright += COLORMAP_REMAPOFFSET; + } dc_texturemid = skytexturemid; dc_texheight = textureheight[skytexture] >>FRACBITS; @@ -669,6 +673,7 @@ static void R_DrawSkyPlane(visplane_t *pl) dc_source = R_GetColumn(texturetranslation[skytexture], -angle); // get negative of angle for each column to display sky correct way round! --Monster Iestyn 27/01/18 + dc_brightmap = NULL; colfunc(); } } diff --git a/src/r_segs.c b/src/r_segs.c index 5c9538e34..033bcca73 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -36,6 +36,7 @@ static boolean markceiling; static boolean maskedtexture; static INT32 toptexture, bottomtexture, midtexture; +static INT32 topbrightmap, bottombrightmap, midbrightmap; static INT32 numthicksides, numbackffloors; angle_t rw_normalangle; @@ -83,7 +84,7 @@ static fixed_t *maskedtextureheight = NULL; // multi-patch textures. They are not normally needed as multi-patch // textures don't have holes in it. At least not for now. -static void R_Render2sidedMultiPatchColumn(column_t *column) +static void R_Render2sidedMultiPatchColumn(column_t *column, column_t *brightmap) { INT32 topscreen, bottomscreen; @@ -93,6 +94,8 @@ static void R_Render2sidedMultiPatchColumn(column_t *column) dc_yl = (sprtopscreen+FRACUNIT-1)>>FRACBITS; dc_yh = (bottomscreen-1)>>FRACBITS; + dc_brightmap = NULL; + if (windowtop != INT32_MAX && windowbottom != INT32_MAX) { dc_yl = ((windowtop + FRACUNIT)>>FRACBITS); @@ -110,6 +113,10 @@ static void R_Render2sidedMultiPatchColumn(column_t *column) if (dc_yl <= dc_yh && dc_yh < vid.height && dc_yh > 0) { dc_source = (UINT8 *)column + 3; + if (brightmap != NULL) + { + dc_brightmap = (UINT8 *)brightmap + 3; + } if (colfunc == colfuncs[BASEDRAWFUNC]) (colfuncs[COLDRAWFUNC_TWOSMULTIPATCH])(); @@ -132,12 +139,12 @@ transnum_t R_GetLinedefTransTable(line_t *ldef) void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2) { size_t pindex; - column_t *col; - INT32 lightnum, texnum, i; + column_t *col, *bmCol = NULL; + INT32 lightnum, texnum, bmnum, i; fixed_t height, realbot; lightlist_t *light; r_lightlist_t *rlight; - void (*colfunc_2s)(column_t *); + void (*colfunc_2s)(column_t *, column_t *); line_t *ldef; sector_t *front, *back; INT32 times, repeats; @@ -155,6 +162,7 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2) frontsector = curline->frontsector; backsector = curline->backsector; texnum = R_GetTextureNum(curline->sidedef->midtexture); + bmnum = R_GetTextureBrightmap(texnum); windowbottom = windowtop = sprbotscreen = INT32_MAX; ldef = curline->linedef; @@ -215,6 +223,8 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2) // Texture must be cached before setting colfunc_2s, // otherwise texture[texnum]->holes may be false when it shouldn't be R_CheckTextureCache(texnum); + if (bmnum) { R_CheckTextureCache(bmnum); } + // handle case where multipatch texture is drawn on a 2sided wall, multi-patch textures // are not stored per-column with post info in SRB2 if (textures[texnum]->holes) @@ -400,6 +410,7 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2) // draw the texture col = (column_t *)((UINT8 *)R_GetColumn(texnum, maskedtexturecol[dc_x]) - 3); + if (bmnum) { bmCol = (column_t *)((UINT8 *)R_GetColumn(bmnum, maskedtexturecol[dc_x]) - 3); } for (i = 0; i < dc_numlights; i++) { @@ -431,8 +442,12 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2) if (height <= windowtop) { dc_colormap = rlight->rcolormap; + dc_fullbright = colormaps; if (encoremap && !(ldef->flags & ML_TFERLINE)) + { dc_colormap += COLORMAP_REMAPOFFSET; + dc_fullbright += COLORMAP_REMAPOFFSET; + } continue; } @@ -440,7 +455,7 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2) if (windowbottom >= realbot) { windowbottom = realbot; - colfunc_2s(col); + colfunc_2s(col, bmCol); for (i++; i < dc_numlights; i++) { rlight = &dc_lightlist[i]; @@ -449,15 +464,19 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2) continue; } - colfunc_2s(col); + colfunc_2s(col, bmCol); windowtop = windowbottom + 1; dc_colormap = rlight->rcolormap; + dc_fullbright = colormaps; if (encoremap && !(ldef->flags & ML_TFERLINE)) + { dc_colormap += COLORMAP_REMAPOFFSET; + dc_fullbright += COLORMAP_REMAPOFFSET; + } } windowbottom = realbot; if (windowtop < windowbottom) - colfunc_2s(col); + colfunc_2s(col, bmCol); spryscale += rw_scalestep; continue; @@ -470,8 +489,12 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2) pindex = MAXLIGHTSCALE - 1; dc_colormap = walllights[pindex]; + dc_fullbright = colormaps; if (encoremap && !(ldef->flags & ML_TFERLINE)) + { dc_colormap += COLORMAP_REMAPOFFSET; + dc_fullbright += COLORMAP_REMAPOFFSET; + } if (frontsector->extra_colormap) dc_colormap = frontsector->extra_colormap->colormap + (dc_colormap - colormaps); @@ -481,6 +504,7 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2) // draw the texture col = (column_t *)((UINT8 *)R_GetColumn(texnum, maskedtexturecol[dc_x]) - 3); + if (bmnum) { bmCol = (column_t *)((UINT8 *)R_GetColumn(bmnum, maskedtexturecol[dc_x]) - 3); } #if 0 // Disabling this allows inside edges to render below the planes, for until the clipping is fixed to work right when POs are near the camera. -Red if (curline->dontrenderme && curline->polyseg && (curline->polyseg->flags & POF_RENDERPLANES)) @@ -535,7 +559,7 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2) } else #endif - colfunc_2s(col); + colfunc_2s(col, bmCol); } spryscale += rw_scalestep; } @@ -544,10 +568,10 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2) } // Loop through R_DrawMaskedColumn calls -static void R_DrawRepeatMaskedColumn(column_t *col) +static void R_DrawRepeatMaskedColumn(column_t *col, column_t *bm) { while (sprtopscreen < sprbotscreen) { - R_DrawMaskedColumn(col); + R_DrawMaskedColumn(col, bm); if ((INT64)sprtopscreen + dc_texheight*spryscale > (INT64)INT32_MAX) // prevent overflow sprtopscreen = INT32_MAX; else @@ -555,10 +579,10 @@ static void R_DrawRepeatMaskedColumn(column_t *col) } } -static void R_DrawRepeatFlippedMaskedColumn(column_t *col) +static void R_DrawRepeatFlippedMaskedColumn(column_t *col, column_t *bm) { do { - R_DrawFlippedMaskedColumn(col); + R_DrawFlippedMaskedColumn(col, bm); sprtopscreen += dc_texheight*spryscale; } while (sprtopscreen < sprbotscreen); } @@ -582,9 +606,9 @@ static boolean R_IsFFloorTranslucent(visffloor_t *pfloor) void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) { size_t pindex; - column_t * col; + column_t * col, *bmCol = NULL; INT32 lightnum; - INT32 texnum; + INT32 texnum, bmnum; sector_t tempsec; INT32 templight; INT32 i, p; @@ -605,7 +629,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) fixed_t left_top, left_bottom; // needed here for slope skewing pslope_t *skewslope = NULL; - void (*colfunc_2s) (column_t *); + void (*colfunc_2s) (column_t *, column_t *); // Calculate light table. // Use different light tables @@ -616,6 +640,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) backsector = pfloor->target; frontsector = curline->frontsector == pfloor->target ? curline->backsector : curline->frontsector; texnum = R_GetTextureNum(sides[pfloor->master->sidenum[0]].midtexture); + bmnum = R_GetTextureBrightmap(texnum); colfunc = colfuncs[BASEDRAWFUNC]; @@ -624,6 +649,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) size_t linenum = curline->linedef-backsector->lines[0]; newline = pfloor->master->frontsector->lines[0] + linenum; texnum = R_GetTextureNum(sides[newline->sidenum[0]].midtexture); + bmnum = R_GetTextureBrightmap(texnum); } if (pfloor->flags & FF_TRANSLUCENT) @@ -833,6 +859,8 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) // Texture must be cached before setting colfunc_2s, // otherwise texture[texnum]->holes may be false when it shouldn't be R_CheckTextureCache(texnum); + if (bmnum) { R_CheckTextureCache(bmnum); } + //faB: handle case where multipatch texture is drawn on a 2sided wall, multi-patch textures // are not stored per-column with post info anymore in Doom Legacy if (textures[texnum]->holes) @@ -916,6 +944,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) // Get data for the column col = (column_t *)((UINT8 *)R_GetColumn(texnum,maskedtexturecol[dc_x]) - 3); + if (bmnum) { bmCol = (column_t *)((UINT8 *)R_GetColumn(bmnum, maskedtexturecol[dc_x]) - 3); } // SoM: New code does not rely on R_DrawColumnShadowed_8 which // will (hopefully) put less strain on the stack. @@ -998,8 +1027,12 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) if (lighteffect) { dc_colormap = rlight->rcolormap; + dc_fullbright = colormaps; if (encoremap && !(curline->linedef->flags & ML_TFERLINE)) + { dc_colormap += COLORMAP_REMAPOFFSET; + dc_fullbright += COLORMAP_REMAPOFFSET; + } } if (solid && windowtop < bheight) windowtop = bheight; @@ -1011,7 +1044,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) { windowbottom = sprbotscreen; // draw the texture - colfunc_2s (col); + colfunc_2s (col, bmCol); for (i++; i < dc_numlights; i++) { rlight = &dc_lightlist[i]; @@ -1022,7 +1055,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) continue; } // draw the texture - colfunc_2s (col); + colfunc_2s (col, bmCol); if (solid) windowtop = bheight; else @@ -1030,14 +1063,18 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) if (lighteffect) { dc_colormap = rlight->rcolormap; + dc_fullbright = colormaps; if (encoremap && !(curline->linedef->flags & ML_TFERLINE)) + { dc_colormap += COLORMAP_REMAPOFFSET; + dc_fullbright += COLORMAP_REMAPOFFSET; + } } } windowbottom = sprbotscreen; // draw the texture, if there is any space left if (windowtop < windowbottom) - colfunc_2s (col); + colfunc_2s (col, bmCol); spryscale += rw_scalestep; continue; @@ -1050,9 +1087,13 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) pindex = MAXLIGHTSCALE - 1; dc_colormap = walllights[pindex]; + dc_fullbright = colormaps; if (encoremap && !(curline->linedef->flags & ML_TFERLINE)) + { dc_colormap += COLORMAP_REMAPOFFSET; + dc_fullbright += COLORMAP_REMAPOFFSET; + } if (pfloor->flags & FF_FOG && pfloor->master->frontsector->extra_colormap) dc_colormap = pfloor->master->frontsector->extra_colormap->colormap + (dc_colormap - colormaps); @@ -1060,7 +1101,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) dc_colormap = frontsector->extra_colormap->colormap + (dc_colormap - colormaps); // draw the texture - colfunc_2s (col); + colfunc_2s (col, bmCol); spryscale += rw_scalestep; } } @@ -1311,8 +1352,12 @@ static void R_RenderSegLoop (void) pindex = MAXLIGHTSCALE-1; dc_colormap = walllights[pindex]; + dc_fullbright = colormaps; if (encoremap && !(curline->linedef->flags & ML_TFERLINE)) + { dc_colormap += COLORMAP_REMAPOFFSET; + dc_fullbright += COLORMAP_REMAPOFFSET; + } dc_x = rw_x; dc_iscale = 0xffffffffu / (unsigned)rw_scale; @@ -1366,6 +1411,7 @@ static void R_RenderSegLoop (void) dc_yh = yh; dc_texturemid = rw_midtexturemid; dc_source = R_GetColumn(midtexture,texturecolumn); + dc_brightmap = (midbrightmap ? R_GetColumn(midbrightmap, texturecolumn) : NULL); dc_texheight = textureheight[midtexture]>>FRACBITS; //profile stuff --------------------------------------------------------- @@ -1427,6 +1473,7 @@ static void R_RenderSegLoop (void) dc_yh = mid; dc_texturemid = rw_toptexturemid; dc_source = R_GetColumn(toptexture,texturecolumn); + dc_brightmap = (topbrightmap ? R_GetColumn(topbrightmap, texturecolumn) : NULL); dc_texheight = textureheight[toptexture]>>FRACBITS; colfunc(); ceilingclip[rw_x] = (INT16)mid; @@ -1462,8 +1509,8 @@ static void R_RenderSegLoop (void) dc_yl = mid; dc_yh = yh; dc_texturemid = rw_bottomtexturemid; - dc_source = R_GetColumn(bottomtexture, - texturecolumn); + dc_source = R_GetColumn(bottomtexture,texturecolumn); + dc_brightmap = (bottombrightmap ? R_GetColumn(bottombrightmap, texturecolumn) : NULL); dc_texheight = textureheight[bottomtexture]>>FRACBITS; colfunc(); floorclip[rw_x] = (INT16)mid; @@ -1738,6 +1785,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) worldbottomslope -= viewz; midtexture = toptexture = bottomtexture = maskedtexture = 0; + midbrightmap = topbrightmap = bottombrightmap = 0; ds_p->maskedtexturecol = NULL; ds_p->numthicksides = numthicksides = 0; ds_p->thicksidecol = NULL; @@ -1785,6 +1833,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) fixed_t texheight; // single sided line midtexture = R_GetTextureNum(sidedef->midtexture); + midbrightmap = R_GetTextureBrightmap(midtexture); texheight = textureheight[midtexture]; // a single sided line is terminal, so it must mark ends markfloor = markceiling = true; @@ -2021,11 +2070,14 @@ void R_StoreWallRange(INT32 start, INT32 stop) if (!toptexture) //Second side has no texture, use the first side's instead. toptexture = R_GetTextureNum(sidedef->toptexture); + + topbrightmap = R_GetTextureBrightmap(toptexture); texheight = textureheight[toptexture]; } else { toptexture = R_GetTextureNum(sidedef->toptexture); + topbrightmap = R_GetTextureBrightmap(toptexture); texheight = textureheight[toptexture]; } if (!(linedef->flags & ML_EFFECT1)) { // Ignore slopes for lower/upper textures unless flag is checked @@ -2052,6 +2104,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) { // bottom texture bottomtexture = R_GetTextureNum(sidedef->bottomtexture); + bottombrightmap = R_GetTextureBrightmap(bottomtexture); if (!(linedef->flags & ML_EFFECT1)) { // Ignore slopes for lower/upper textures unless flag is checked if (linedef->flags & ML_DONTPEGBOTTOM) diff --git a/src/r_state.h b/src/r_state.h index 6f9008cc7..dc577448e 100644 --- a/src/r_state.h +++ b/src/r_state.h @@ -54,6 +54,9 @@ extern extracolormap_t *extra_colormaps; // for global animation extern INT32 *texturetranslation; +// for brightmaps +extern INT32 *texturebrightmaps; + // Sprites extern size_t numspritelumps, max_spritelumps; diff --git a/src/r_textures.c b/src/r_textures.c index df7709374..c08feeece 100644 --- a/src/r_textures.c +++ b/src/r_textures.c @@ -55,6 +55,7 @@ INT32 *texturewidth; fixed_t *textureheight; // needed for texture pegging INT32 *texturetranslation; +INT32 *texturebrightmaps; // Painfully simple texture id cacheing to make maps load faster. :3 static struct { @@ -500,6 +501,20 @@ INT32 R_GetTextureNum(INT32 texnum) return texturetranslation[texnum]; } +// +// R_GetTextureBrightmap +// +// Returns the actual texture id that we should use. +// This can either be the texture's brightmap, +// or 0 if not valid. +// +INT32 R_GetTextureBrightmap(INT32 texnum) +{ + if (texnum < 0 || texnum >= numtextures) + return 0; + return texturebrightmaps[texnum]; +} + // // R_CheckTextureCache // @@ -944,6 +959,7 @@ void R_LoadTextures(void) Z_Free(textures[i]); Z_Free(texturecache[i]); } + Z_Free(texturebrightmaps); Z_Free(texturetranslation); Z_Free(textures); } @@ -1044,9 +1060,14 @@ void R_LoadTextures(void) textureheight = (void *)((UINT8 *)textures + ((numtextures * sizeof(void *)) * 4)); // Create translation table for global animation. texturetranslation = Z_Malloc((numtextures + 1) * sizeof(*texturetranslation), PU_STATIC, NULL); + // Create brightmap texture table. + texturebrightmaps = Z_Malloc((numtextures + 1) * sizeof(*texturebrightmaps), PU_STATIC, NULL); for (i = 0; i < numtextures; i++) + { texturetranslation[i] = i; + texturebrightmaps[i] = 0; + } for (i = 0, w = 0; w < numwadfiles; w++) { diff --git a/src/r_textures.h b/src/r_textures.h index 6e0cc168a..dada043a6 100644 --- a/src/r_textures.h +++ b/src/r_textures.h @@ -82,6 +82,7 @@ void R_FlushTextureCache(void); UINT8 *R_GenerateTexture(size_t texnum); UINT8 *R_GenerateTextureAsFlat(size_t texnum); INT32 R_GetTextureNum(INT32 texnum); +INT32 R_GetTextureBrightmap(INT32 texnum); void R_CheckTextureCache(INT32 tex); void R_ClearTextureNumCache(boolean btell); diff --git a/src/r_things.c b/src/r_things.c index eccbe7e23..134c21dae 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -602,7 +602,7 @@ INT16 *mceilingclip; fixed_t spryscale = 0, sprtopscreen = 0, sprbotscreen = 0; fixed_t windowtop = 0, windowbottom = 0; -void R_DrawMaskedColumn(column_t *column) +void R_DrawMaskedColumn(column_t *column, column_t *brightmap) { INT32 topscreen; INT32 bottomscreen; @@ -610,6 +610,7 @@ void R_DrawMaskedColumn(column_t *column) INT32 topdelta, prevdelta = 0; basetexturemid = dc_texturemid; + dc_brightmap = NULL; for (; column->topdelta != 0xff ;) { @@ -645,6 +646,11 @@ void R_DrawMaskedColumn(column_t *column) if (dc_yl <= dc_yh && dc_yh > 0) { dc_source = (UINT8 *)column + 3; + if (brightmap != NULL) + { + dc_brightmap = (UINT8 *)brightmap + 3; + } + dc_texturemid = basetexturemid - (topdelta<length + 4); + if (brightmap != NULL) + { + brightmap = (column_t *)((UINT8 *)brightmap + brightmap->length + 4); + } } dc_texturemid = basetexturemid; @@ -666,7 +676,7 @@ void R_DrawMaskedColumn(column_t *column) INT32 lengthcol; // column->length : for flipped column function pointers and multi-patch on 2sided wall = texture->height -void R_DrawFlippedMaskedColumn(column_t *column) +void R_DrawFlippedMaskedColumn(column_t *column, column_t *brightmap) { INT32 topscreen; INT32 bottomscreen; @@ -674,6 +684,8 @@ void R_DrawFlippedMaskedColumn(column_t *column) INT32 topdelta, prevdelta = -1; UINT8 *d,*s; + dc_brightmap = NULL; + for (; column->topdelta != 0xff ;) { // calculate unclipped screen coordinates @@ -712,6 +724,14 @@ void R_DrawFlippedMaskedColumn(column_t *column) dc_source = ZZ_Alloc(column->length); for (s = (UINT8 *)column+2+column->length, d = dc_source; d < dc_source+column->length; --s) *d++ = *s; + + if (brightmap != NULL) + { + dc_brightmap = ZZ_Alloc(brightmap->length); + for (s = (UINT8 *)brightmap+2+brightmap->length, d = dc_brightmap; d < dc_brightmap+brightmap->length; --s) + *d++ = *s; + } + dc_texturemid = basetexturemid - (topdelta<length + 4); + if (brightmap != NULL) + { + brightmap = (column_t *)((UINT8 *)brightmap + brightmap->length + 4); + } } dc_texturemid = basetexturemid; @@ -779,7 +803,7 @@ UINT8 *R_GetSpriteTranslation(vissprite_t *vis) static void R_DrawVisSprite(vissprite_t *vis) { column_t *column; - void (*localcolfunc)(column_t *); + void (*localcolfunc)(column_t *, column_t *); INT32 texturecolumn; INT32 pwidth; fixed_t frac; @@ -805,6 +829,7 @@ static void R_DrawVisSprite(vissprite_t *vis) colfunc = colfuncs[BASEDRAWFUNC]; // hack: this isn't resetting properly somewhere. dc_colormap = vis->colormap; + dc_fullbright = colormaps; dc_translation = R_GetSpriteTranslation(vis); if (R_SpriteIsFlashing(vis)) // Bosses "flash" @@ -834,8 +859,13 @@ static void R_DrawVisSprite(vissprite_t *vis) if (!dc_colormap) dc_colormap = colormaps; + dc_fullbright = colormaps; + if (encoremap && !vis->mobj->color && !(vis->mobj->flags & MF_DONTENCOREMAP)) - dc_colormap += COLORMAP_REMAPOFFSET; + { + dc_colormap += COLORMAP_REMAPOFFSET; + dc_fullbright += COLORMAP_REMAPOFFSET; + } dc_texturemid = vis->texturemid; dc_texheight = 0; @@ -908,7 +938,7 @@ static void R_DrawVisSprite(vissprite_t *vis) column = (column_t *)((UINT8 *)patch->columns + (patch->columnofs[texturecolumn])); - localcolfunc (column); + localcolfunc (column, NULL); } } else if (vis->cut & SC_SHEAR) @@ -930,7 +960,7 @@ static void R_DrawVisSprite(vissprite_t *vis) #endif sprtopscreen = (centeryfrac - FixedMul(dc_texturemid, spryscale)); - localcolfunc (column); + localcolfunc (column, NULL); } } else @@ -950,7 +980,7 @@ static void R_DrawVisSprite(vissprite_t *vis) #else column = (column_t *)((UINT8 *)patch->columns + (patch->columnofs[frac>>FRACBITS])); #endif - localcolfunc (column); + localcolfunc (column, NULL); } } @@ -989,8 +1019,12 @@ static void R_DrawPrecipitationVisSprite(vissprite_t *vis) } dc_colormap = colormaps; + dc_fullbright = colormaps; if (encoremap) + { dc_colormap += COLORMAP_REMAPOFFSET; + dc_fullbright += COLORMAP_REMAPOFFSET; + } dc_iscale = FixedDiv(FRACUNIT, vis->scale); dc_texturemid = vis->texturemid; @@ -1019,7 +1053,7 @@ static void R_DrawPrecipitationVisSprite(vissprite_t *vis) #else column = (column_t *)((UINT8 *)patch->columns + (patch->columnofs[frac>>FRACBITS])); #endif - R_DrawMaskedColumn(column); + R_DrawMaskedColumn(column, NULL); } colfunc = colfuncs[BASEDRAWFUNC]; diff --git a/src/r_things.h b/src/r_things.h index cbbb0f2d8..7ff1bd4c7 100644 --- a/src/r_things.h +++ b/src/r_things.h @@ -47,8 +47,8 @@ extern fixed_t windowtop; extern fixed_t windowbottom; extern INT32 lengthcol; -void R_DrawMaskedColumn(column_t *column); -void R_DrawFlippedMaskedColumn(column_t *column); +void R_DrawMaskedColumn(column_t *column, column_t *brightmap); +void R_DrawFlippedMaskedColumn(column_t *column, column_t *brightmap); // ---------------- // SPRITE RENDERING From daab86f4611d6d94a08bacdf19d0dc8b63b122ee Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Thu, 16 Dec 2021 11:48:32 -0500 Subject: [PATCH 150/156] Implement brightmaps for span drawers, fix column loop bug --- src/r_draw.c | 2 + src/r_draw.h | 2 + src/r_draw8.c | 994 ++++++++++++++++++++++++++++++------------------- src/r_plane.c | 31 ++ src/r_splats.c | 1 + 5 files changed, 642 insertions(+), 388 deletions(-) diff --git a/src/r_draw.c b/src/r_draw.c index c3bc2ac3c..d9ae3e4a5 100644 --- a/src/r_draw.c +++ b/src/r_draw.c @@ -110,6 +110,7 @@ INT32 dc_numlights = 0, dc_maxlights, dc_texheight; INT32 ds_y, ds_x1, ds_x2; lighttable_t *ds_colormap; +lighttable_t *ds_fullbright; lighttable_t *ds_translation; // Lactozilla: Sprite splat drawer fixed_t ds_xfrac, ds_yfrac, ds_xstep, ds_ystep; @@ -119,6 +120,7 @@ UINT16 ds_flatwidth, ds_flatheight; boolean ds_powersoftwo; UINT8 *ds_source; // points to the start of a flat +UINT8 *ds_brightmap; // start of brightmap flat UINT8 *ds_transmap; // one of the translucency tables // Vectors for Software's tilted slope drawers diff --git a/src/r_draw.h b/src/r_draw.h index b5cea0420..7b44d6185 100644 --- a/src/r_draw.h +++ b/src/r_draw.h @@ -59,6 +59,7 @@ extern INT32 dc_texheight; extern INT32 ds_y, ds_x1, ds_x2; extern lighttable_t *ds_colormap; +extern lighttable_t *ds_fullbright; extern lighttable_t *ds_translation; extern fixed_t ds_xfrac, ds_yfrac, ds_xstep, ds_ystep; @@ -68,6 +69,7 @@ extern UINT16 ds_flatwidth, ds_flatheight; extern boolean ds_powersoftwo; extern UINT8 *ds_source; +extern UINT8 *ds_brightmap; extern UINT8 *ds_transmap; typedef struct { diff --git a/src/r_draw8.c b/src/r_draw8.c index 1771614db..0dd8463f6 100644 --- a/src/r_draw8.c +++ b/src/r_draw8.c @@ -101,7 +101,7 @@ void R_DrawColumn_8(void) { while ((count -= 2) >= 0) // texture height is a power of 2 { - if (brightmap != NULL && brightmap[frac>>FRACBITS] == BRIGHTPIXEL) + if (brightmap != NULL && brightmap[(frac>>FRACBITS) & heightmask] == BRIGHTPIXEL) { *dest = fullbright[source[(frac>>FRACBITS) & heightmask]]; } @@ -113,7 +113,7 @@ void R_DrawColumn_8(void) dest += vid.width; frac += fracstep; - if (brightmap != NULL && brightmap[frac>>FRACBITS] == BRIGHTPIXEL) + if (brightmap != NULL && brightmap[(frac>>FRACBITS) & heightmask] == BRIGHTPIXEL) { *dest = fullbright[source[(frac>>FRACBITS) & heightmask]]; } @@ -128,7 +128,7 @@ void R_DrawColumn_8(void) if (count & 1) { - if (brightmap != NULL && brightmap[frac>>FRACBITS] == BRIGHTPIXEL) + if (brightmap != NULL && brightmap[(frac>>FRACBITS) & heightmask] == BRIGHTPIXEL) { *dest = fullbright[source[(frac>>FRACBITS) & heightmask]]; } @@ -229,7 +229,7 @@ void R_Draw2sMultiPatchColumn_8(void) val = source[(frac>>FRACBITS) & heightmask]; if (val != TRANSPARENTPIXEL) { - if (brightmap != NULL && brightmap[frac>>FRACBITS] == BRIGHTPIXEL) + if (brightmap != NULL && brightmap[(frac>>FRACBITS) & heightmask] == BRIGHTPIXEL) { *dest = fullbright[val]; } @@ -245,7 +245,7 @@ void R_Draw2sMultiPatchColumn_8(void) val = source[(frac>>FRACBITS) & heightmask]; if (val != TRANSPARENTPIXEL) { - if (brightmap != NULL && brightmap[frac>>FRACBITS] == BRIGHTPIXEL) + if (brightmap != NULL && brightmap[(frac>>FRACBITS) & heightmask] == BRIGHTPIXEL) { *dest = fullbright[val]; } @@ -264,7 +264,7 @@ void R_Draw2sMultiPatchColumn_8(void) val = source[(frac>>FRACBITS) & heightmask]; if (val != TRANSPARENTPIXEL) { - if (brightmap != NULL && brightmap[frac>>FRACBITS] == BRIGHTPIXEL) + if (brightmap != NULL && brightmap[(frac>>FRACBITS) & heightmask] == BRIGHTPIXEL) { *dest = fullbright[val]; } @@ -367,7 +367,7 @@ void R_Draw2sMultiPatchTranslucentColumn_8(void) val = source[(frac>>FRACBITS) & heightmask]; if (val != TRANSPARENTPIXEL) { - if (brightmap != NULL && brightmap[frac>>FRACBITS] == BRIGHTPIXEL) + if (brightmap != NULL && brightmap[(frac>>FRACBITS) & heightmask] == BRIGHTPIXEL) { *dest = *(transmap + (fullbright[val]<<8) + (*dest)); } @@ -383,7 +383,7 @@ void R_Draw2sMultiPatchTranslucentColumn_8(void) val = source[(frac>>FRACBITS) & heightmask]; if (val != TRANSPARENTPIXEL) { - if (brightmap != NULL && brightmap[frac>>FRACBITS] == BRIGHTPIXEL) + if (brightmap != NULL && brightmap[(frac>>FRACBITS) & heightmask] == BRIGHTPIXEL) { *dest = *(transmap + (fullbright[val]<<8) + (*dest)); } @@ -401,7 +401,7 @@ void R_Draw2sMultiPatchTranslucentColumn_8(void) val = source[(frac>>FRACBITS) & heightmask]; if (val != TRANSPARENTPIXEL) { - if (brightmap != NULL && brightmap[frac>>FRACBITS] == BRIGHTPIXEL) + if (brightmap != NULL && brightmap[(frac>>FRACBITS) & heightmask] == BRIGHTPIXEL) { *dest = *(transmap + (fullbright[val]<<8) + (*dest)); } @@ -489,8 +489,10 @@ void R_DrawTranslucentColumn_8(void) // This is as fast as it gets. { register const UINT8 *source = dc_source; + register const UINT8 *brightmap = dc_brightmap; register const UINT8 *transmap = dc_transmap; register const lighttable_t *colormap = dc_colormap; + register const lighttable_t *fullbright = dc_fullbright; register INT32 heightmask = dc_texheight - 1; if (dc_texheight & heightmask) { @@ -509,7 +511,14 @@ void R_DrawTranslucentColumn_8(void) // Re-map color indices from wall texture column // using a lighting/special effects LUT. // heightmask is the Tutti-Frutti fix - *dest = *(transmap + (colormap[source[frac>>FRACBITS]]<<8) + (*dest)); + if (brightmap != NULL && brightmap[frac>>FRACBITS] == BRIGHTPIXEL) + { + *dest = *(transmap + (fullbright[source[frac>>FRACBITS]]<<8) + (*dest)); + } + else + { + *dest = *(transmap + (colormap[source[frac>>FRACBITS]]<<8) + (*dest)); + } dest += vid.width; if ((frac += fracstep) >= heightmask) frac -= heightmask; @@ -520,15 +529,39 @@ void R_DrawTranslucentColumn_8(void) { while ((count -= 2) >= 0) // texture height is a power of 2 { - *dest = *(transmap + (colormap[source[(frac>>FRACBITS)&heightmask]]<<8) + (*dest)); + if (brightmap != NULL && brightmap[(frac>>FRACBITS)&heightmask] == BRIGHTPIXEL) + { + *dest = *(transmap + (fullbright[source[(frac>>FRACBITS)&heightmask]]<<8) + (*dest)); + } + else + { + *dest = *(transmap + (colormap[source[(frac>>FRACBITS)&heightmask]]<<8) + (*dest)); + } dest += vid.width; frac += fracstep; - *dest = *(transmap + (colormap[source[(frac>>FRACBITS)&heightmask]]<<8) + (*dest)); + + if (brightmap != NULL && brightmap[(frac>>FRACBITS)&heightmask] == BRIGHTPIXEL) + { + *dest = *(transmap + (fullbright[source[(frac>>FRACBITS)&heightmask]]<<8) + (*dest)); + } + else + { + *dest = *(transmap + (colormap[source[(frac>>FRACBITS)&heightmask]]<<8) + (*dest)); + } dest += vid.width; frac += fracstep; } if (count & 1) - *dest = *(transmap + (colormap[source[(frac>>FRACBITS)&heightmask]]<<8) + (*dest)); + { + if (brightmap != NULL && brightmap[(frac>>FRACBITS)&heightmask] == BRIGHTPIXEL) + { + *dest = *(transmap + (fullbright[source[(frac>>FRACBITS)&heightmask]]<<8) + (*dest)); + } + else + { + *dest = *(transmap + (colormap[source[(frac>>FRACBITS)&heightmask]]<<8) + (*dest)); + } + } } } } @@ -579,7 +612,14 @@ void R_DrawTranslatedTranslucentColumn_8(void) // using a lighting/special effects LUT. // heightmask is the Tutti-Frutti fix - *dest = *(dc_transmap + (dc_colormap[dc_translation[dc_source[frac>>FRACBITS]]]<<8) + (*dest)); + if (dc_brightmap != NULL && dc_brightmap[frac>>FRACBITS] == BRIGHTPIXEL) + { + *dest = *(dc_transmap + (dc_fullbright[dc_translation[dc_source[frac>>FRACBITS]]]<<8) + (*dest)); + } + else + { + *dest = *(dc_transmap + (dc_colormap[dc_translation[dc_source[frac>>FRACBITS]]]<<8) + (*dest)); + } dest += vid.width; if ((frac += fracstep) >= heightmask) @@ -591,15 +631,41 @@ void R_DrawTranslatedTranslucentColumn_8(void) { while ((count -= 2) >= 0) // texture height is a power of 2 { - *dest = *(dc_transmap + (dc_colormap[dc_translation[dc_source[(frac>>FRACBITS)&heightmask]]]<<8) + (*dest)); + if (dc_brightmap != NULL && dc_brightmap[(frac>>FRACBITS)&heightmask] == BRIGHTPIXEL) + { + *dest = *(dc_transmap + (dc_fullbright[dc_translation[dc_source[(frac>>FRACBITS)&heightmask]]]<<8) + (*dest)); + } + else + { + *dest = *(dc_transmap + (dc_colormap[dc_translation[dc_source[(frac>>FRACBITS)&heightmask]]]<<8) + (*dest)); + } + dest += vid.width; frac += fracstep; - *dest = *(dc_transmap + (dc_colormap[dc_translation[dc_source[(frac>>FRACBITS)&heightmask]]]<<8) + (*dest)); + + if (dc_brightmap != NULL && dc_brightmap[(frac>>FRACBITS)&heightmask] == BRIGHTPIXEL) + { + *dest = *(dc_transmap + (dc_fullbright[dc_translation[dc_source[(frac>>FRACBITS)&heightmask]]]<<8) + (*dest)); + } + else + { + *dest = *(dc_transmap + (dc_colormap[dc_translation[dc_source[(frac>>FRACBITS)&heightmask]]]<<8) + (*dest)); + } + dest += vid.width; frac += fracstep; } if (count & 1) - *dest = *(dc_transmap + (dc_colormap[dc_translation[dc_source[(frac>>FRACBITS)&heightmask]]]<<8) + (*dest)); + { + if (dc_brightmap != NULL && dc_brightmap[(frac>>FRACBITS)&heightmask] == BRIGHTPIXEL) + { + *dest = *(dc_transmap + (dc_fullbright[dc_translation[dc_source[(frac>>FRACBITS)&heightmask]]]<<8) + (*dest)); + } + else + { + *dest = *(dc_transmap + (dc_colormap[dc_translation[dc_source[(frac>>FRACBITS)&heightmask]]]<<8) + (*dest)); + } + } } } } @@ -641,7 +707,14 @@ void R_DrawTranslatedColumn_8(void) // used with PLAY sprites. // Thus the "green" ramp of the player 0 sprite // is mapped to gray, red, black/indigo. - *dest = dc_colormap[dc_translation[dc_source[frac>>FRACBITS]]]; + if (dc_brightmap != NULL && dc_brightmap[frac>>FRACBITS] == BRIGHTPIXEL) + { + *dest = dc_fullbright[dc_translation[dc_source[frac>>FRACBITS]]]; + } + else + { + *dest = dc_colormap[dc_translation[dc_source[frac>>FRACBITS]]]; + } dest += vid.width; @@ -656,6 +729,9 @@ void R_DrawTranslatedColumn_8(void) #define SPANSIZE 16 #define INVSPAN 0.0625f +// 4194303 = (2048x2048)-1 (2048x2048 is maximum flat size) +#define MAXFLATBYTES 4194303 + /** \brief The R_DrawSpan_8 function Draws the actual span. */ @@ -664,13 +740,17 @@ void R_DrawSpan_8 (void) fixed_t xposition; fixed_t yposition; fixed_t xstep, ystep; + UINT32 bit; UINT8 *source; + UINT8 *brightmap; UINT8 *colormap; + UINT8 *fullbright; UINT8 *dest; const UINT8 *deststop = screens[0] + vid.rowbytes * vid.height; size_t count = (ds_x2 - ds_x1 + 1); + size_t i; xposition = ds_xfrac; yposition = ds_yfrac; xstep = ds_xstep; ystep = ds_ystep; @@ -686,7 +766,9 @@ void R_DrawSpan_8 (void) xstep <<= nflatshiftup; ystep <<= nflatshiftup; source = ds_source; + brightmap = ds_brightmap; colormap = ds_colormap; + fullbright = ds_fullbright; dest = ylookup[ds_y] + columnofs[ds_x1]; if (dest+8 > deststop) @@ -697,44 +779,37 @@ void R_DrawSpan_8 (void) // SoM: Why didn't I see this earlier? the spot variable is a waste now because we don't // have the uber complicated math to calculate it now, so that was a memory write we didn't // need! - dest[0] = colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]]; - xposition += xstep; - yposition += ystep; - dest[1] = colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]]; - xposition += xstep; - yposition += ystep; - - dest[2] = colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]]; - xposition += xstep; - yposition += ystep; - - dest[3] = colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]]; - xposition += xstep; - yposition += ystep; - - dest[4] = colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]]; - xposition += xstep; - yposition += ystep; - - dest[5] = colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]]; - xposition += xstep; - yposition += ystep; - - dest[6] = colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]]; - xposition += xstep; - yposition += ystep; - - dest[7] = colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]]; - xposition += xstep; - yposition += ystep; + for (i = 0; i < 8; i++) + { + bit = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); + if (brightmap != NULL && brightmap[bit] == BRIGHTPIXEL) + { + dest[i] = fullbright[source[bit]]; + } + else + { + dest[i] = colormap[source[bit]]; + } + xposition += xstep; + yposition += ystep; + } dest += 8; count -= 8; } while (count-- && dest <= deststop) { - *dest++ = colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]]; + bit = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); + if (brightmap != NULL && brightmap[bit] == BRIGHTPIXEL) + { + *dest++ = fullbright[source[bit]]; + } + else + { + *dest++ = colormap[source[bit]]; + } + xposition += xstep; yposition += ystep; } @@ -775,13 +850,16 @@ void R_DrawTiltedSpan_8(void) int i; UINT8 *source; + UINT8 *brightmap; UINT8 *colormap; + UINT8 *fullbright; UINT8 *dest; double startz, startu, startv; double izstep, uzstep, vzstep; double endz, endu, endv; UINT32 stepu, stepv; + UINT32 bit; iz = ds_szp->z + ds_szp->y*(centery-ds_y) + ds_szp->x*(ds_x1-centerx); @@ -801,8 +879,11 @@ void R_DrawTiltedSpan_8(void) vz = ds_svp->z + ds_svp->y*(centery-ds_y) + ds_svp->x*(ds_x1-centerx); dest = ylookup[ds_y] + columnofs[ds_x1]; + source = ds_source; + brightmap = ds_brightmap; //colormap = ds_colormap; + fullbright = ds_fullbright; #if 0 // The "perfect" reference version of this routine. Pretty slow. // Use it only to see how things are supposed to look. @@ -812,10 +893,16 @@ void R_DrawTiltedSpan_8(void) double z = 1.f/iz; u = (INT64)(uz*z) + viewx; v = (INT64)(vz*z) + viewy; - - colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); - - *dest = colormap[source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]]; + bit = ((v >> nflatyshift) & nflatmask) | (u >> nflatxshift); + if (brightmap != NULL && brightmap[bit] == BRIGHTPIXEL) + { + *dest = fullbright[source[bit]]; + } + else + { + colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); + *dest = colormap[source[bit]]; + } dest++; iz += ds_szp->x; uz += ds_sup->x; @@ -848,8 +935,16 @@ void R_DrawTiltedSpan_8(void) for (i = SPANSIZE-1; i >= 0; i--) { - colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); - *dest = colormap[source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]]; + bit = ((v >> nflatyshift) & nflatmask) | (u >> nflatxshift); + if (brightmap != NULL && brightmap[bit] == BRIGHTPIXEL) + { + *dest = fullbright[source[bit]]; + } + else + { + colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); + *dest = colormap[source[bit]]; + } dest++; u += stepu; v += stepv; @@ -864,8 +959,16 @@ void R_DrawTiltedSpan_8(void) { u = (INT64)(startu); v = (INT64)(startv); - colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); - *dest = colormap[source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]]; + bit = ((v >> nflatyshift) & nflatmask) | (u >> nflatxshift); + if (brightmap != NULL && brightmap[bit] == BRIGHTPIXEL) + { + *dest = fullbright[source[bit]]; + } + else + { + colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); + *dest = colormap[source[bit]]; + } } else { @@ -885,8 +988,16 @@ void R_DrawTiltedSpan_8(void) for (; width != 0; width--) { - colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); - *dest = colormap[source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]]; + bit = ((v >> nflatyshift) & nflatmask) | (u >> nflatxshift); + if (brightmap != NULL && brightmap[bit] == BRIGHTPIXEL) + { + *dest = fullbright[source[bit]]; + } + else + { + colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); + *dest = colormap[source[bit]]; + } dest++; u += stepu; v += stepv; @@ -908,13 +1019,16 @@ void R_DrawTiltedTranslucentSpan_8(void) int i; UINT8 *source; + UINT8 *brightmap; UINT8 *colormap; + UINT8 *fullbright; UINT8 *dest; double startz, startu, startv; double izstep, uzstep, vzstep; double endz, endu, endv; UINT32 stepu, stepv; + UINT32 bit; iz = ds_szp->z + ds_szp->y*(centery-ds_y) + ds_szp->x*(ds_x1-centerx); @@ -934,8 +1048,11 @@ void R_DrawTiltedTranslucentSpan_8(void) vz = ds_svp->z + ds_svp->y*(centery-ds_y) + ds_svp->x*(ds_x1-centerx); dest = ylookup[ds_y] + columnofs[ds_x1]; + source = ds_source; + brightmap = ds_brightmap; //colormap = ds_colormap; + fullbright = ds_fullbright; #if 0 // The "perfect" reference version of this routine. Pretty slow. // Use it only to see how things are supposed to look. @@ -946,8 +1063,16 @@ void R_DrawTiltedTranslucentSpan_8(void) u = (INT64)(uz*z) + viewx; v = (INT64)(vz*z) + viewy; - colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); - *dest = *(ds_transmap + (colormap[source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]] << 8) + *dest); + bit = ((v >> nflatyshift) & nflatmask) | (u >> nflatxshift); + if (brightmap != NULL && brightmap[bit] == BRIGHTPIXEL) + { + *dest = *(ds_transmap + (fullbright[source[bit]] << 8) + *dest); + } + else + { + colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); + *dest = *(ds_transmap + (colormap[source[bit]] << 8) + *dest); + } dest++; iz += ds_szp->x; uz += ds_sup->x; @@ -980,8 +1105,16 @@ void R_DrawTiltedTranslucentSpan_8(void) for (i = SPANSIZE-1; i >= 0; i--) { - colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); - *dest = *(ds_transmap + (colormap[source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]] << 8) + *dest); + bit = ((v >> nflatyshift) & nflatmask) | (u >> nflatxshift); + if (brightmap != NULL && brightmap[bit] == BRIGHTPIXEL) + { + *dest = *(ds_transmap + (fullbright[source[bit]] << 8) + *dest); + } + else + { + colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); + *dest = *(ds_transmap + (colormap[source[bit]] << 8) + *dest); + } dest++; u += stepu; v += stepv; @@ -996,8 +1129,16 @@ void R_DrawTiltedTranslucentSpan_8(void) { u = (INT64)(startu); v = (INT64)(startv); - colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); - *dest = *(ds_transmap + (colormap[source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]] << 8) + *dest); + bit = ((v >> nflatyshift) & nflatmask) | (u >> nflatxshift); + if (brightmap != NULL && brightmap[bit] == BRIGHTPIXEL) + { + *dest = *(ds_transmap + (fullbright[source[bit]] << 8) + *dest); + } + else + { + colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); + *dest = *(ds_transmap + (colormap[source[bit]] << 8) + *dest); + } } else { @@ -1017,8 +1158,16 @@ void R_DrawTiltedTranslucentSpan_8(void) for (; width != 0; width--) { - colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); - *dest = *(ds_transmap + (colormap[source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]] << 8) + *dest); + bit = ((v >> nflatyshift) & nflatmask) | (u >> nflatxshift); + if (brightmap != NULL && brightmap[bit] == BRIGHTPIXEL) + { + *dest = *(ds_transmap + (fullbright[source[bit]] << 8) + *dest); + } + else + { + colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); + *dest = *(ds_transmap + (colormap[source[bit]] << 8) + *dest); + } dest++; u += stepu; v += stepv; @@ -1040,7 +1189,9 @@ void R_DrawTiltedTranslucentWaterSpan_8(void) int i; UINT8 *source; + UINT8 *brightmap; UINT8 *colormap; + UINT8 *fullbright; UINT8 *dest; UINT8 *dsrc; @@ -1048,6 +1199,7 @@ void R_DrawTiltedTranslucentWaterSpan_8(void) double izstep, uzstep, vzstep; double endz, endu, endv; UINT32 stepu, stepv; + UINT32 bit; iz = ds_szp->z + ds_szp->y*(centery-ds_y) + ds_szp->x*(ds_x1-centerx); @@ -1069,7 +1221,9 @@ void R_DrawTiltedTranslucentWaterSpan_8(void) dest = ylookup[ds_y] + columnofs[ds_x1]; dsrc = screens[1] + (ds_y+ds_bgofs)*vid.width + ds_x1; source = ds_source; + brightmap = ds_brightmap; //colormap = ds_colormap; + fullbright = ds_fullbright; #if 0 // The "perfect" reference version of this routine. Pretty slow. // Use it only to see how things are supposed to look. @@ -1080,8 +1234,16 @@ void R_DrawTiltedTranslucentWaterSpan_8(void) u = (INT64)(uz*z) + viewx; v = (INT64)(vz*z) + viewy; - colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); - *dest = *(ds_transmap + (colormap[source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]] << 8) + *dsrc++); + bit = ((v >> nflatyshift) & nflatmask) | (u >> nflatxshift); + if (brightmap != NULL && brightmap[bit] == BRIGHTPIXEL) + { + *dest = *(ds_transmap + (fullbright[source[bit]] << 8) + *dsrc++); + } + else + { + colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); + *dest = *(ds_transmap + (colormap[source[bit]] << 8) + *dsrc++); + } dest++; iz += ds_szp->x; uz += ds_sup->x; @@ -1114,8 +1276,16 @@ void R_DrawTiltedTranslucentWaterSpan_8(void) for (i = SPANSIZE-1; i >= 0; i--) { - colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); - *dest = *(ds_transmap + (colormap[source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]] << 8) + *dsrc++); + bit = ((v >> nflatyshift) & nflatmask) | (u >> nflatxshift); + if (brightmap != NULL && brightmap[bit] == BRIGHTPIXEL) + { + *dest = *(ds_transmap + (fullbright[source[bit]] << 8) + *dsrc++); + } + else + { + colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); + *dest = *(ds_transmap + (colormap[source[bit]] << 8) + *dsrc++); + } dest++; u += stepu; v += stepv; @@ -1130,8 +1300,16 @@ void R_DrawTiltedTranslucentWaterSpan_8(void) { u = (INT64)(startu); v = (INT64)(startv); - colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); - *dest = *(ds_transmap + (colormap[source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]] << 8) + *dsrc++); + bit = ((v >> nflatyshift) & nflatmask) | (u >> nflatxshift); + if (brightmap != NULL && brightmap[bit] == BRIGHTPIXEL) + { + *dest = *(ds_transmap + (fullbright[source[bit]] << 8) + *dsrc++); + } + else + { + colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); + *dest = *(ds_transmap + (colormap[source[bit]] << 8) + *dsrc++); + } } else { @@ -1151,8 +1329,16 @@ void R_DrawTiltedTranslucentWaterSpan_8(void) for (; width != 0; width--) { - colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); - *dest = *(ds_transmap + (colormap[source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]] << 8) + *dsrc++); + bit = ((v >> nflatyshift) & nflatmask) | (u >> nflatxshift); + if (brightmap != NULL && brightmap[bit] == BRIGHTPIXEL) + { + *dest = *(ds_transmap + (fullbright[source[bit]] << 8) + *dsrc++); + } + else + { + colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); + *dest = *(ds_transmap + (colormap[source[bit]] << 8) + *dsrc++); + } dest++; u += stepu; v += stepv; @@ -1171,7 +1357,9 @@ void R_DrawTiltedSplat_8(void) int i; UINT8 *source; + UINT8 *brightmap; UINT8 *colormap; + UINT8 *fullbright; UINT8 *dest; UINT8 val; @@ -1180,6 +1368,7 @@ void R_DrawTiltedSplat_8(void) double izstep, uzstep, vzstep; double endz, endu, endv; UINT32 stepu, stepv; + UINT32 bit; iz = ds_szp->z + ds_szp->y*(centery-ds_y) + ds_szp->x*(ds_x1-centerx); @@ -1199,8 +1388,11 @@ void R_DrawTiltedSplat_8(void) vz = ds_svp->z + ds_svp->y*(centery-ds_y) + ds_svp->x*(ds_x1-centerx); dest = ylookup[ds_y] + columnofs[ds_x1]; + source = ds_source; + brightmap = ds_brightmap; //colormap = ds_colormap; + fullbright = ds_fullbright; #if 0 // The "perfect" reference version of this routine. Pretty slow. // Use it only to see how things are supposed to look. @@ -1211,11 +1403,20 @@ void R_DrawTiltedSplat_8(void) u = (INT64)(uz*z) + viewx; v = (INT64)(vz*z) + viewy; - colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); - - val = source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]; + bit = ((v >> nflatyshift) & nflatmask) | (u >> nflatxshift); + val = source[bit]; if (val != TRANSPARENTPIXEL) - *dest = colormap[val]; + { + if (brightmap != NULL && brightmap[bit] == BRIGHTPIXEL) + { + *dest = fullbright[val]; + } + else + { + colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); + *dest = colormap[val]; + } + } dest++; iz += ds_szp->x; @@ -1249,10 +1450,20 @@ void R_DrawTiltedSplat_8(void) for (i = SPANSIZE-1; i >= 0; i--) { - colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); - val = source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]; + bit = ((v >> nflatyshift) & nflatmask) | (u >> nflatxshift); + val = source[bit]; if (val != TRANSPARENTPIXEL) - *dest = colormap[val]; + { + if (brightmap != NULL && brightmap[bit] == BRIGHTPIXEL) + { + *dest = fullbright[val]; + } + else + { + colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); + *dest = colormap[val]; + } + } dest++; u += stepu; v += stepv; @@ -1267,10 +1478,20 @@ void R_DrawTiltedSplat_8(void) { u = (INT64)(startu); v = (INT64)(startv); - colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); - val = source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]; + bit = ((v >> nflatyshift) & nflatmask) | (u >> nflatxshift); + val = source[bit]; if (val != TRANSPARENTPIXEL) - *dest = colormap[val]; + { + if (brightmap != NULL && brightmap[bit] == BRIGHTPIXEL) + { + *dest = fullbright[val]; + } + else + { + colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); + *dest = colormap[val]; + } + } } else { @@ -1290,10 +1511,20 @@ void R_DrawTiltedSplat_8(void) for (; width != 0; width--) { - colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); - val = source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]; + bit = ((v >> nflatyshift) & nflatmask) | (u >> nflatxshift); + val = source[bit]; if (val != TRANSPARENTPIXEL) - *dest = colormap[val]; + { + if (brightmap != NULL && brightmap[bit] == BRIGHTPIXEL) + { + *dest = fullbright[val]; + } + else + { + colormap = planezlight[tiltlighting[ds_x1++]] + (ds_colormap - colormaps); + *dest = colormap[val]; + } + } dest++; u += stepu; v += stepv; @@ -1311,13 +1542,17 @@ void R_DrawSplat_8 (void) fixed_t xposition; fixed_t yposition; fixed_t xstep, ystep; + UINT32 bit; UINT8 *source; + UINT8 *brightmap; UINT8 *colormap; + UINT8 *fullbright; UINT8 *dest; const UINT8 *deststop = screens[0] + vid.rowbytes * vid.height; size_t count = (ds_x2 - ds_x1 + 1); + size_t i; UINT32 val; xposition = ds_xfrac; yposition = ds_yfrac; @@ -1334,7 +1569,9 @@ void R_DrawSplat_8 (void) xstep <<= nflatshiftup; ystep <<= nflatshiftup; source = ds_source; + brightmap = ds_brightmap; colormap = ds_colormap; + fullbright = ds_fullbright; dest = ylookup[ds_y] + columnofs[ds_x1]; while (count >= 8) @@ -1342,80 +1579,44 @@ void R_DrawSplat_8 (void) // SoM: Why didn't I see this earlier? the spot variable is a waste now because we don't // have the uber complicated math to calculate it now, so that was a memory write we didn't // need! - // - // 4194303 = (2048x2048)-1 (2048x2048 is maximum flat size) - val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); - val &= 4194303; - val = source[val]; - if (val != TRANSPARENTPIXEL) - dest[0] = colormap[val]; - xposition += xstep; - yposition += ystep; - - val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); - val &= 4194303; - val = source[val]; - if (val != TRANSPARENTPIXEL) - dest[1] = colormap[val]; - xposition += xstep; - yposition += ystep; - - val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); - val &= 4194303; - val = source[val]; - if (val != TRANSPARENTPIXEL) - dest[2] = colormap[val]; - xposition += xstep; - yposition += ystep; - - val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); - val &= 4194303; - val = source[val]; - if (val != TRANSPARENTPIXEL) - dest[3] = colormap[val]; - xposition += xstep; - yposition += ystep; - - val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); - val &= 4194303; - val = source[val]; - if (val != TRANSPARENTPIXEL) - dest[4] = colormap[val]; - xposition += xstep; - yposition += ystep; - - val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); - val &= 4194303; - val = source[val]; - if (val != TRANSPARENTPIXEL) - dest[5] = colormap[val]; - xposition += xstep; - yposition += ystep; - - val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); - val &= 4194303; - val = source[val]; - if (val != TRANSPARENTPIXEL) - dest[6] = colormap[val]; - xposition += xstep; - yposition += ystep; - - val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); - val &= 4194303; - val = source[val]; - if (val != TRANSPARENTPIXEL) - dest[7] = colormap[val]; - xposition += xstep; - yposition += ystep; + for (i = 0; i < 8; i++) + { + bit = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); + bit &= MAXFLATBYTES; + val = source[bit]; + if (val != TRANSPARENTPIXEL) + { + if (brightmap != NULL && brightmap[bit] == BRIGHTPIXEL) + { + dest[i] = fullbright[val]; + } + else + { + dest[i] = colormap[val]; + } + } + xposition += xstep; + yposition += ystep; + } dest += 8; count -= 8; } while (count-- && dest <= deststop) { - val = source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]; + bit = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); + val = source[bit]; if (val != TRANSPARENTPIXEL) - *dest = colormap[val]; + { + if (brightmap != NULL && brightmap[bit] == BRIGHTPIXEL) + { + *dest = fullbright[val]; + } + else + { + *dest = colormap[val]; + } + } dest++; xposition += xstep; yposition += ystep; @@ -1430,13 +1631,17 @@ void R_DrawTranslucentSplat_8 (void) fixed_t xposition; fixed_t yposition; fixed_t xstep, ystep; + UINT32 bit; UINT8 *source; + UINT8 *brightmap; UINT8 *colormap; + UINT8 *fullbright; UINT8 *dest; const UINT8 *deststop = screens[0] + vid.rowbytes * vid.height; size_t count = (ds_x2 - ds_x1 + 1); + size_t i; UINT32 val; xposition = ds_xfrac; yposition = ds_yfrac; @@ -1453,7 +1658,9 @@ void R_DrawTranslucentSplat_8 (void) xstep <<= nflatshiftup; ystep <<= nflatshiftup; source = ds_source; + brightmap = ds_brightmap; colormap = ds_colormap; + fullbright = ds_fullbright; dest = ylookup[ds_y] + columnofs[ds_x1]; while (count >= 8) @@ -1461,62 +1668,45 @@ void R_DrawTranslucentSplat_8 (void) // SoM: Why didn't I see this earlier? the spot variable is a waste now because we don't // have the uber complicated math to calculate it now, so that was a memory write we didn't // need! - val = source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]; - if (val != TRANSPARENTPIXEL) - dest[0] = *(ds_transmap + (colormap[val] << 8) + dest[0]); - xposition += xstep; - yposition += ystep; - - val = source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]; - if (val != TRANSPARENTPIXEL) - dest[1] = *(ds_transmap + (colormap[val] << 8) + dest[1]); - xposition += xstep; - yposition += ystep; - - val = source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]; - if (val != TRANSPARENTPIXEL) - dest[2] = *(ds_transmap + (colormap[val] << 8) + dest[2]); - xposition += xstep; - yposition += ystep; - - val = source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]; - if (val != TRANSPARENTPIXEL) - dest[3] = *(ds_transmap + (colormap[val] << 8) + dest[3]); - xposition += xstep; - yposition += ystep; - - val = source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]; - if (val != TRANSPARENTPIXEL) - dest[4] = *(ds_transmap + (colormap[val] << 8) + dest[4]); - xposition += xstep; - yposition += ystep; - - val = source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]; - if (val != TRANSPARENTPIXEL) - dest[5] = *(ds_transmap + (colormap[val] << 8) + dest[5]); - xposition += xstep; - yposition += ystep; - - val = source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]; - if (val != TRANSPARENTPIXEL) - dest[6] = *(ds_transmap + (colormap[val] << 8) + dest[6]); - xposition += xstep; - yposition += ystep; - - val = source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]; - if (val != TRANSPARENTPIXEL) - dest[7] = *(ds_transmap + (colormap[val] << 8) + dest[7]); - xposition += xstep; - yposition += ystep; + for (i = 0; i < 8; i++) + { + bit = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); + val = source[bit]; + if (val != TRANSPARENTPIXEL) + { + if (brightmap != NULL && brightmap[bit] == BRIGHTPIXEL) + { + dest[i] = *(ds_transmap + (fullbright[val] << 8) + dest[i]); + } + else + { + dest[i] = *(ds_transmap + (colormap[val] << 8) + dest[i]); + } + + } + xposition += xstep; + yposition += ystep; + } dest += 8; count -= 8; } while (count-- && dest <= deststop) { - val = source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]; + bit = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); + val = source[bit]; if (val != TRANSPARENTPIXEL) - *dest = *(ds_transmap + (colormap[val] << 8) + *dest); + { + if (brightmap != NULL && brightmap[bit] == BRIGHTPIXEL) + { + *dest = *(ds_transmap + (fullbright[val] << 8) + *dest); + } + else + { + *dest = *(ds_transmap + (colormap[val] << 8) + *dest); + } + + } dest++; xposition += xstep; yposition += ystep; @@ -1531,14 +1721,18 @@ void R_DrawFloorSprite_8 (void) fixed_t xposition; fixed_t yposition; fixed_t xstep, ystep; + UINT32 bit; UINT16 *source; + UINT16 *brightmap; UINT8 *colormap; + UINT8 *fullbright; UINT8 *translation; UINT8 *dest; const UINT8 *deststop = screens[0] + vid.rowbytes * vid.height; size_t count = (ds_x2 - ds_x1 + 1); + size_t i; UINT32 val; xposition = ds_xfrac; yposition = ds_yfrac; @@ -1555,7 +1749,9 @@ void R_DrawFloorSprite_8 (void) xstep <<= nflatshiftup; ystep <<= nflatshiftup; source = (UINT16 *)ds_source; + brightmap = (UINT16 *)ds_brightmap; colormap = ds_colormap; + fullbright = ds_fullbright; translation = ds_translation; dest = ylookup[ds_y] + columnofs[ds_x1]; @@ -1564,70 +1760,43 @@ void R_DrawFloorSprite_8 (void) // SoM: Why didn't I see this earlier? the spot variable is a waste now because we don't // have the uber complicated math to calculate it now, so that was a memory write we didn't // need! - val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); - val = source[val]; - if (val & 0xFF00) - dest[0] = colormap[translation[val & 0xFF]]; - xposition += xstep; - yposition += ystep; - - val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); - val = source[val]; - if (val & 0xFF00) - dest[1] = colormap[translation[val & 0xFF]]; - xposition += xstep; - yposition += ystep; - - val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); - val = source[val]; - if (val & 0xFF00) - dest[2] = colormap[translation[val & 0xFF]]; - xposition += xstep; - yposition += ystep; - - val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); - val = source[val]; - if (val & 0xFF00) - dest[3] = colormap[translation[val & 0xFF]]; - xposition += xstep; - yposition += ystep; - - val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); - val = source[val]; - if (val & 0xFF00) - dest[4] = colormap[translation[val & 0xFF]]; - xposition += xstep; - yposition += ystep; - - val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); - val = source[val]; - if (val & 0xFF00) - dest[5] = colormap[translation[val & 0xFF]]; - xposition += xstep; - yposition += ystep; - - val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); - val = source[val]; - if (val & 0xFF00) - dest[6] = colormap[translation[val & 0xFF]]; - xposition += xstep; - yposition += ystep; - - val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); - val = source[val]; - if (val & 0xFF00) - dest[7] = colormap[translation[val & 0xFF]]; - xposition += xstep; - yposition += ystep; + for (i = 0; i < 8; i++) + { + bit = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); + val = source[bit]; + if (val & 0xFF00) + { + if (brightmap != NULL && brightmap[bit] == BRIGHTPIXEL) + { + *dest = fullbright[translation[val & 0xFF]]; + } + else + { + *dest = colormap[translation[val & 0xFF]]; + } + } + xposition += xstep; + yposition += ystep; + } dest += 8; count -= 8; } while (count-- && dest <= deststop) { - val = source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]; + bit = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); + val = source[bit]; if (val & 0xFF00) - *dest = colormap[translation[val & 0xFF]]; + { + if (brightmap != NULL && brightmap[bit] == BRIGHTPIXEL) + { + *dest = fullbright[translation[val & 0xFF]]; + } + else + { + *dest = colormap[translation[val & 0xFF]]; + } + } dest++; xposition += xstep; yposition += ystep; @@ -1642,14 +1811,18 @@ void R_DrawTranslucentFloorSprite_8 (void) fixed_t xposition; fixed_t yposition; fixed_t xstep, ystep; + UINT32 bit; UINT16 *source; + UINT16 *brightmap; UINT8 *colormap; + UINT8 *fullbright; UINT8 *translation; UINT8 *dest; const UINT8 *deststop = screens[0] + vid.rowbytes * vid.height; size_t count = (ds_x2 - ds_x1 + 1); + size_t i; UINT32 val; xposition = ds_xfrac; yposition = ds_yfrac; @@ -1666,7 +1839,9 @@ void R_DrawTranslucentFloorSprite_8 (void) xstep <<= nflatshiftup; ystep <<= nflatshiftup; source = (UINT16 *)ds_source; + brightmap = (UINT16 *)ds_brightmap; colormap = ds_colormap; + fullbright = ds_fullbright; translation = ds_translation; dest = ylookup[ds_y] + columnofs[ds_x1]; @@ -1675,62 +1850,43 @@ void R_DrawTranslucentFloorSprite_8 (void) // SoM: Why didn't I see this earlier? the spot variable is a waste now because we don't // have the uber complicated math to calculate it now, so that was a memory write we didn't // need! - val = source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]; - if (val & 0xFF00) - dest[0] = *(ds_transmap + (colormap[translation[val & 0xFF]] << 8) + dest[0]); - xposition += xstep; - yposition += ystep; - - val = source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]; - if (val & 0xFF00) - dest[1] = *(ds_transmap + (colormap[translation[val & 0xFF]] << 8) + dest[1]); - xposition += xstep; - yposition += ystep; - - val = source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]; - if (val & 0xFF00) - dest[2] = *(ds_transmap + (colormap[translation[val & 0xFF]] << 8) + dest[2]); - xposition += xstep; - yposition += ystep; - - val = source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]; - if (val & 0xFF00) - dest[3] = *(ds_transmap + (colormap[translation[val & 0xFF]] << 8) + dest[3]); - xposition += xstep; - yposition += ystep; - - val = source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]; - if (val & 0xFF00) - dest[4] = *(ds_transmap + (colormap[translation[val & 0xFF]] << 8) + dest[4]); - xposition += xstep; - yposition += ystep; - - val = source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]; - if (val & 0xFF00) - dest[5] = *(ds_transmap + (colormap[translation[val & 0xFF]] << 8) + dest[5]); - xposition += xstep; - yposition += ystep; - - val = source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]; - if (val & 0xFF00) - dest[6] = *(ds_transmap + (colormap[translation[val & 0xFF]] << 8) + dest[6]); - xposition += xstep; - yposition += ystep; - - val = source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]; - if (val & 0xFF00) - dest[7] = *(ds_transmap + (colormap[translation[val & 0xFF]] << 8) + dest[7]); - xposition += xstep; - yposition += ystep; + for (i = 0; i < 8; i++) + { + bit = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); + val = source[bit]; + if (val & 0xFF00) + { + if (brightmap != NULL && brightmap[bit] == BRIGHTPIXEL) + { + dest[i] = *(ds_transmap + (fullbright[translation[val & 0xFF]] << 8) + dest[i]); + } + else + { + dest[i] = *(ds_transmap + (colormap[translation[val & 0xFF]] << 8) + dest[i]); + } + } + xposition += xstep; + yposition += ystep; + } dest += 8; count -= 8; } while (count-- && dest <= deststop) { - val = source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]; + bit = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); + val = source[bit]; if (val & 0xFF00) - *dest = *(ds_transmap + (colormap[translation[val & 0xFF]] << 8) + *dest); + { + if (brightmap != NULL && brightmap[bit] == BRIGHTPIXEL) + { + *dest = *(ds_transmap + (fullbright[translation[val & 0xFF]] << 8) + *dest); + } + else + { + *dest = *(ds_transmap + (colormap[translation[val & 0xFF]] << 8) + *dest); + } + } dest++; xposition += xstep; yposition += ystep; @@ -1749,7 +1905,9 @@ void R_DrawTiltedFloorSprite_8(void) int i; UINT16 *source; + UINT16 *brightmap; UINT8 *colormap; + UINT8 *fullbright; UINT8 *translation; UINT8 *dest; UINT16 val; @@ -1758,6 +1916,7 @@ void R_DrawTiltedFloorSprite_8(void) double izstep, uzstep, vzstep; double endz, endu, endv; UINT32 stepu, stepv; + UINT32 bit; iz = ds_szp->z + ds_szp->y*(centery-ds_y) + ds_szp->x*(ds_x1-centerx); uz = ds_sup->z + ds_sup->y*(centery-ds_y) + ds_sup->x*(ds_x1-centerx); @@ -1765,7 +1924,9 @@ void R_DrawTiltedFloorSprite_8(void) dest = ylookup[ds_y] + columnofs[ds_x1]; source = (UINT16 *)ds_source; + brightmap = (UINT16 *)ds_brightmap; colormap = ds_colormap; + fullbright = ds_fullbright; translation = ds_translation; startz = 1.f/iz; @@ -1794,9 +1955,19 @@ void R_DrawTiltedFloorSprite_8(void) for (i = SPANSIZE-1; i >= 0; i--) { - val = source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]; + bit = ((v >> nflatyshift) & nflatmask) | (u >> nflatxshift); + val = source[bit]; if (val & 0xFF00) - *dest = colormap[translation[val & 0xFF]]; + { + if (brightmap != NULL && brightmap[bit] == BRIGHTPIXEL) + { + *dest = fullbright[translation[val & 0xFF]]; + } + else + { + *dest = colormap[translation[val & 0xFF]]; + } + } dest++; u += stepu; @@ -1812,9 +1983,19 @@ void R_DrawTiltedFloorSprite_8(void) { u = (INT64)(startu); v = (INT64)(startv); - val = source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]; + bit = ((v >> nflatyshift) & nflatmask) | (u >> nflatxshift); + val = source[bit]; if (val & 0xFF00) - *dest = colormap[translation[val & 0xFF]]; + { + if (brightmap != NULL && brightmap[bit] == BRIGHTPIXEL) + { + *dest = fullbright[translation[val & 0xFF]]; + } + else + { + *dest = colormap[translation[val & 0xFF]]; + } + } } else { @@ -1834,9 +2015,19 @@ void R_DrawTiltedFloorSprite_8(void) for (; width != 0; width--) { - val = source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]; + bit = ((v >> nflatyshift) & nflatmask) | (u >> nflatxshift); + val = source[bit]; if (val & 0xFF00) - *dest = colormap[translation[val & 0xFF]]; + { + if (brightmap != NULL && brightmap[bit] == BRIGHTPIXEL) + { + *dest = fullbright[translation[val & 0xFF]]; + } + else + { + *dest = colormap[translation[val & 0xFF]]; + } + } dest++; u += stepu; @@ -1858,7 +2049,9 @@ void R_DrawTiltedTranslucentFloorSprite_8(void) int i; UINT16 *source; + UINT16 *brightmap; UINT8 *colormap; + UINT8 *fullbright; UINT8 *translation; UINT8 *dest; UINT16 val; @@ -1867,6 +2060,7 @@ void R_DrawTiltedTranslucentFloorSprite_8(void) double izstep, uzstep, vzstep; double endz, endu, endv; UINT32 stepu, stepv; + UINT32 bit; iz = ds_szp->z + ds_szp->y*(centery-ds_y) + ds_szp->x*(ds_x1-centerx); uz = ds_sup->z + ds_sup->y*(centery-ds_y) + ds_sup->x*(ds_x1-centerx); @@ -1874,7 +2068,9 @@ void R_DrawTiltedTranslucentFloorSprite_8(void) dest = ylookup[ds_y] + columnofs[ds_x1]; source = (UINT16 *)ds_source; + brightmap = (UINT16 *)ds_brightmap; colormap = ds_colormap; + fullbright = ds_fullbright; translation = ds_translation; startz = 1.f/iz; @@ -1903,9 +2099,19 @@ void R_DrawTiltedTranslucentFloorSprite_8(void) for (i = SPANSIZE-1; i >= 0; i--) { - val = source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]; + bit = ((v >> nflatyshift) & nflatmask) | (u >> nflatxshift); + val = source[bit]; if (val & 0xFF00) - *dest = *(ds_transmap + (colormap[translation[val & 0xFF]] << 8) + *dest); + { + if (brightmap != NULL && brightmap[bit] == BRIGHTPIXEL) + { + *dest = *(ds_transmap + (fullbright[translation[val & 0xFF]] << 8) + *dest); + } + else + { + *dest = *(ds_transmap + (colormap[translation[val & 0xFF]] << 8) + *dest); + } + } dest++; u += stepu; @@ -1921,9 +2127,19 @@ void R_DrawTiltedTranslucentFloorSprite_8(void) { u = (INT64)(startu); v = (INT64)(startv); - val = source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]; + bit = ((v >> nflatyshift) & nflatmask) | (u >> nflatxshift); + val = source[bit]; if (val & 0xFF00) - *dest = *(ds_transmap + (colormap[translation[val & 0xFF]] << 8) + *dest); + { + if (brightmap != NULL && brightmap[bit] == BRIGHTPIXEL) + { + *dest = *(ds_transmap + (fullbright[translation[val & 0xFF]] << 8) + *dest); + } + else + { + *dest = *(ds_transmap + (colormap[translation[val & 0xFF]] << 8) + *dest); + } + } } else { @@ -1943,9 +2159,19 @@ void R_DrawTiltedTranslucentFloorSprite_8(void) for (; width != 0; width--) { - val = source[((v >> nflatyshift) & nflatmask) | (u >> nflatxshift)]; + bit = ((v >> nflatyshift) & nflatmask) | (u >> nflatxshift); + val = source[bit]; if (val & 0xFF00) - *dest = *(ds_transmap + (colormap[translation[val & 0xFF]] << 8) + *dest); + { + if (brightmap != NULL && brightmap[bit] == BRIGHTPIXEL) + { + *dest = *(ds_transmap + (fullbright[translation[val & 0xFF]] << 8) + *dest); + } + else + { + *dest = *(ds_transmap + (colormap[translation[val & 0xFF]] << 8) + *dest); + } + } dest++; u += stepu; @@ -1963,14 +2189,17 @@ void R_DrawTranslucentSpan_8 (void) fixed_t xposition; fixed_t yposition; fixed_t xstep, ystep; + UINT32 bit; UINT8 *source; + UINT8 *brightmap; UINT8 *colormap; + UINT8 *fullbright; UINT8 *dest; const UINT8 *deststop = screens[0] + vid.rowbytes * vid.height; size_t count = (ds_x2 - ds_x1 + 1); - UINT32 val; + size_t i; xposition = ds_xfrac; yposition = ds_yfrac; xstep = ds_xstep; ystep = ds_ystep; @@ -1986,7 +2215,9 @@ void R_DrawTranslucentSpan_8 (void) xstep <<= nflatshiftup; ystep <<= nflatshiftup; source = ds_source; + brightmap = ds_brightmap; colormap = ds_colormap; + fullbright = ds_fullbright; dest = ylookup[ds_y] + columnofs[ds_x1]; while (count >= 8) @@ -1994,45 +2225,35 @@ void R_DrawTranslucentSpan_8 (void) // SoM: Why didn't I see this earlier? the spot variable is a waste now because we don't // have the uber complicated math to calculate it now, so that was a memory write we didn't // need! - dest[0] = *(ds_transmap + (colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]] << 8) + dest[0]); - xposition += xstep; - yposition += ystep; - - dest[1] = *(ds_transmap + (colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]] << 8) + dest[1]); - xposition += xstep; - yposition += ystep; - - dest[2] = *(ds_transmap + (colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]] << 8) + dest[2]); - xposition += xstep; - yposition += ystep; - - dest[3] = *(ds_transmap + (colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]] << 8) + dest[3]); - xposition += xstep; - yposition += ystep; - - dest[4] = *(ds_transmap + (colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]] << 8) + dest[4]); - xposition += xstep; - yposition += ystep; - - dest[5] = *(ds_transmap + (colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]] << 8) + dest[5]); - xposition += xstep; - yposition += ystep; - - dest[6] = *(ds_transmap + (colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]] << 8) + dest[6]); - xposition += xstep; - yposition += ystep; - - dest[7] = *(ds_transmap + (colormap[source[(((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift)]] << 8) + dest[7]); - xposition += xstep; - yposition += ystep; + for (i = 0; i < 8; i++) + { + bit = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); + if (brightmap != NULL && brightmap[bit] == BRIGHTPIXEL) + { + dest[i] = *(ds_transmap + (fullbright[source[bit]] << 8) + dest[i]); + } + else + { + dest[i] = *(ds_transmap + (colormap[source[bit]] << 8) + dest[i]); + } + xposition += xstep; + yposition += ystep; + } dest += 8; count -= 8; } while (count-- && dest <= deststop) { - val = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); - *dest = *(ds_transmap + (colormap[source[val]] << 8) + *dest); + bit = (((UINT32)yposition >> nflatyshift) & nflatmask) | ((UINT32)xposition >> nflatxshift); + if (brightmap != NULL && brightmap[bit] == BRIGHTPIXEL) + { + *dest = *(ds_transmap + (fullbright[source[bit]] << 8) + *dest); + } + else + { + *dest = *(ds_transmap + (colormap[source[bit]] << 8) + *dest); + } dest++; xposition += xstep; yposition += ystep; @@ -2044,13 +2265,17 @@ void R_DrawTranslucentWaterSpan_8(void) UINT32 xposition; UINT32 yposition; UINT32 xstep, ystep; + UINT32 bit; UINT8 *source; + UINT8 *brightmap; UINT8 *colormap; + UINT8 *fullbright; UINT8 *dest; UINT8 *dsrc; size_t count; + size_t i; // SoM: we only need 6 bits for the integer part (0 thru 63) so the rest // can be used for the fraction part. This allows calculation of the memory address in the @@ -2063,7 +2288,9 @@ void R_DrawTranslucentWaterSpan_8(void) xstep = ds_xstep << nflatshiftup; ystep = ds_ystep << nflatshiftup; source = ds_source; + brightmap = ds_brightmap; colormap = ds_colormap; + fullbright = ds_fullbright; dest = ylookup[ds_y] + columnofs[ds_x1]; dsrc = screens[1] + (ds_y+ds_bgofs)*vid.width + ds_x1; count = ds_x2 - ds_x1 + 1; @@ -2073,44 +2300,35 @@ void R_DrawTranslucentWaterSpan_8(void) // SoM: Why didn't I see this earlier? the spot variable is a waste now because we don't // have the uber complicated math to calculate it now, so that was a memory write we didn't // need! - dest[0] = colormap[*(ds_transmap + (source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)] << 8) + *dsrc++)]; - xposition += xstep; - yposition += ystep; - - dest[1] = colormap[*(ds_transmap + (source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)] << 8) + *dsrc++)]; - xposition += xstep; - yposition += ystep; - - dest[2] = colormap[*(ds_transmap + (source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)] << 8) + *dsrc++)]; - xposition += xstep; - yposition += ystep; - - dest[3] = colormap[*(ds_transmap + (source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)] << 8) + *dsrc++)]; - xposition += xstep; - yposition += ystep; - - dest[4] = colormap[*(ds_transmap + (source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)] << 8) + *dsrc++)]; - xposition += xstep; - yposition += ystep; - - dest[5] = colormap[*(ds_transmap + (source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)] << 8) + *dsrc++)]; - xposition += xstep; - yposition += ystep; - - dest[6] = colormap[*(ds_transmap + (source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)] << 8) + *dsrc++)]; - xposition += xstep; - yposition += ystep; - - dest[7] = colormap[*(ds_transmap + (source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)] << 8) + *dsrc++)]; - xposition += xstep; - yposition += ystep; + for (i = 0; i < 8; i++) + { + bit = ((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift); + if (brightmap != NULL && brightmap[bit] == BRIGHTPIXEL) + { + dest[i] = fullbright[*(ds_transmap + (source[bit] << 8) + *dsrc++)]; + } + else + { + dest[i] = colormap[*(ds_transmap + (source[bit] << 8) + *dsrc++)]; + } + xposition += xstep; + yposition += ystep; + } dest += 8; count -= 8; } while (count--) { - *dest++ = colormap[*(ds_transmap + (source[((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift)] << 8) + *dsrc++)]; + bit = ((yposition >> nflatyshift) & nflatmask) | (xposition >> nflatxshift); + if (brightmap != NULL && brightmap[bit] == BRIGHTPIXEL) + { + *dest++ = fullbright[*(ds_transmap + (source[bit] << 8) + *dsrc++)]; + } + else + { + *dest++ = colormap[*(ds_transmap + (source[bit] << 8) + *dsrc++)]; + } xposition += xstep; yposition += ystep; } diff --git a/src/r_plane.c b/src/r_plane.c index 58e6ce5ea..f19de384d 100644 --- a/src/r_plane.c +++ b/src/r_plane.c @@ -235,7 +235,9 @@ void R_MapPlane(INT32 y, INT32 x1, INT32 x2) } if (currentplane->slope) + { ds_colormap = colormaps; + } else { pindex = distance >> LIGHTZSHIFT; @@ -244,8 +246,13 @@ void R_MapPlane(INT32 y, INT32 x1, INT32 x2) ds_colormap = planezlight[pindex]; } + ds_fullbright = colormaps; + if (encoremap && !currentplane->noencore) + { ds_colormap += COLORMAP_REMAPOFFSET; + ds_fullbright += COLORMAP_REMAPOFFSET; + } if (currentplane->extra_colormap) ds_colormap = currentplane->extra_colormap->colormap + (ds_colormap - colormaps); @@ -970,6 +977,30 @@ void R_DrawSinglePlane(visplane_t *pl) R_CheckFlatLength(ds_flatwidth * ds_flatheight); } + ds_brightmap = NULL; + + if (type == LEVELFLAT_TEXTURE) + { + // Get the span's brightmap. + // FLATS not supported, SORRY!! + INT32 texNum = R_GetTextureNum(levelflat->u.texture.num); + INT32 bmNum = R_GetTextureBrightmap(texNum); + + if (bmNum != 0) + { + texture_t *brightmap = textures[bmNum]; + + if (brightmap->flat == NULL) + { + ds_brightmap = R_GenerateTextureAsFlat(bmNum); + } + else + { + ds_brightmap = (UINT8 *)brightmap->flat; + } + } + } + if (!pl->slope // Don't mess with angle on slopes! We'll handle this ourselves later && viewangle != pl->viewangle+pl->plangle) { diff --git a/src/r_splats.c b/src/r_splats.c index 63052049e..39801812f 100644 --- a/src/r_splats.c +++ b/src/r_splats.c @@ -444,6 +444,7 @@ static void R_RasterizeFloorSplat(floorsplat_t *pSplat, vector2_t *verts, visspr } ds_colormap = vis->colormap; + ds_fullbright = colormaps; ds_translation = R_GetSpriteTranslation(vis); if (ds_translation == NULL) ds_translation = colormaps; From 6399cd57e138abc82e61bd2c8554a42cca25d209 Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Thu, 16 Dec 2021 11:52:51 -0500 Subject: [PATCH 151/156] Fix the print's file extension --- src/k_brightmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/k_brightmap.c b/src/k_brightmap.c index b9ef07ab8..f481938f2 100644 --- a/src/k_brightmap.c +++ b/src/k_brightmap.c @@ -177,7 +177,6 @@ void K_InitBrightmaps(void) for (wadNum = 0; wadNum < numwadfiles; wadNum++) { - lumpinfo_t *lump_p = wadfiles[wadNum]->lumpinfo; UINT16 lumpNum; // Find BRIGHT lump in the WAD @@ -196,6 +195,7 @@ void K_InitBrightmaps(void) } else { + lumpinfo_t *lump_p = &wadfiles[wadNum]->lumpinfo[lumpNum]; size_t size = W_LumpLengthPwad(wadNum, lumpNum); size_t nameLength = strlen(wadfiles[wadNum]->filename) + 1 + strlen(lump_p->fullname); // length of file name, '|', and lump name From 603a97938b32b37a89120dcf083be3e1cbaf333c Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Thu, 16 Dec 2021 13:05:37 -0500 Subject: [PATCH 152/156] "Support" ASM functions (By that, I mean it defaults to ASM, but uses the C version when drawing brightmapped stuff. Was this worth the minor performance gain over just making NOASM=1 default? I dunno.) --- src/r_plane.c | 14 ++------- src/r_segs.c | 48 ++++++++++++++++++----------- src/r_splats.c | 5 +-- src/r_things.c | 21 +++++++------ src/screen.c | 82 ++++++++++++++++++++++++++++++++++++++++++-------- src/screen.h | 10 ++++++ 6 files changed, 126 insertions(+), 54 deletions(-) diff --git a/src/r_plane.c b/src/r_plane.c index f19de384d..6276ab7ee 100644 --- a/src/r_plane.c +++ b/src/r_plane.c @@ -648,7 +648,7 @@ static void R_DrawSkyPlane(visplane_t *pl) // Reset column drawer function (note: couldn't we just call walldrawerfunc directly?) // (that is, unless we'll need to switch drawers in future for some reason) - colfunc = colfuncs[BASEDRAWFUNC]; + R_SetColumnFunc(BASEDRAWFUNC, false); // use correct aspect ratio scale dc_iscale = skyscale[viewssnum]; @@ -820,7 +820,7 @@ void R_DrawSinglePlane(visplane_t *pl) } planeripple.active = false; - spanfunc = spanfuncs[BASEDRAWFUNC]; + R_SetSpanFunc(BASEDRAWFUNC, false, false); if (pl->polyobj) { @@ -1116,15 +1116,7 @@ void R_DrawSinglePlane(visplane_t *pl) planezlight = zlight[light]; // Use the correct span drawer depending on the powers-of-twoness - if (!ds_powersoftwo) - { - if (spanfuncs_npo2[spanfunctype]) - spanfunc = spanfuncs_npo2[spanfunctype]; - else - spanfunc = spanfuncs[spanfunctype]; - } - else - spanfunc = spanfuncs[spanfunctype]; + R_SetSpanFunc(spanfunctype, !ds_powersoftwo, ds_brightmap != NULL); // set the maximum value for unsigned pl->top[pl->maxx+1] = 0xffff; diff --git a/src/r_segs.c b/src/r_segs.c index 033bcca73..5a8172615 100644 --- a/src/r_segs.c +++ b/src/r_segs.c @@ -118,9 +118,9 @@ static void R_Render2sidedMultiPatchColumn(column_t *column, column_t *brightmap dc_brightmap = (UINT8 *)brightmap + 3; } - if (colfunc == colfuncs[BASEDRAWFUNC]) + if (R_CheckColumnFunc(BASEDRAWFUNC) == true) (colfuncs[COLDRAWFUNC_TWOSMULTIPATCH])(); - else if (colfunc == colfuncs[COLDRAWFUNC_FUZZY]) + else if (R_CheckColumnFunc(COLDRAWFUNC_FUZZY) == true) (colfuncs[COLDRAWFUNC_TWOSMULTIPATCHTRANS])(); else colfunc(); @@ -196,16 +196,18 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2) if (transtable != NUMTRANSMAPS && (blendmode || transtable)) { dc_transmap = R_GetBlendTable(blendmode, transtable); - colfunc = colfuncs[COLDRAWFUNC_FUZZY]; + R_SetColumnFunc(COLDRAWFUNC_FUZZY, bmnum != 0); } else if (ldef->special == 909) { - colfunc = colfuncs[COLDRAWFUNC_FOG]; + R_SetColumnFunc(COLDRAWFUNC_FOG, bmnum != 0); windowtop = frontsector->ceilingheight; windowbottom = frontsector->floorheight; } else - colfunc = colfuncs[BASEDRAWFUNC]; + { + R_SetColumnFunc(BASEDRAWFUNC, bmnum != 0); + } if (curline->polyseg && curline->polyseg->translucency > 0) { @@ -213,7 +215,7 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2) return; dc_transmap = R_GetTranslucencyTable(curline->polyseg->translucency); - colfunc = colfuncs[COLDRAWFUNC_FUZZY]; + R_SetColumnFunc(COLDRAWFUNC_FUZZY, bmnum != 0); } range = max(ds->x2-ds->x1, 1); @@ -275,7 +277,7 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2) rlight->extra_colormap = *light->extra_colormap; rlight->flags = light->flags; - if ((colfunc != colfuncs[COLDRAWFUNC_FUZZY]) + if ((R_CheckColumnFunc(COLDRAWFUNC_FUZZY) == false) || (rlight->flags & FF_FOG) || (rlight->extra_colormap && (rlight->extra_colormap->flags & CMF_FOG))) lightnum = (rlight->lightlevel >> LIGHTSEGSHIFT); @@ -292,13 +294,13 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2) } else { - if ((colfunc != colfuncs[COLDRAWFUNC_FUZZY]) + if ((R_CheckColumnFunc(COLDRAWFUNC_FUZZY) == false) || (frontsector->extra_colormap && (frontsector->extra_colormap->flags & CMF_FOG))) lightnum = (frontsector->lightlevel >> LIGHTSEGSHIFT); else lightnum = LIGHTLEVELS - 1; - if (colfunc == colfuncs[COLDRAWFUNC_FOG] + if ((R_CheckColumnFunc(COLDRAWFUNC_FOG) == true) || (frontsector->extra_colormap && (frontsector->extra_colormap->flags & CMF_FOG))) ; else @@ -564,7 +566,8 @@ void R_RenderMaskedSegRange(drawseg_t *ds, INT32 x1, INT32 x2) spryscale += rw_scalestep; } } - colfunc = colfuncs[BASEDRAWFUNC]; + + R_SetColumnFunc(BASEDRAWFUNC, false); } // Loop through R_DrawMaskedColumn calls @@ -642,7 +645,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) texnum = R_GetTextureNum(sides[pfloor->master->sidenum[0]].midtexture); bmnum = R_GetTextureBrightmap(texnum); - colfunc = colfuncs[BASEDRAWFUNC]; + R_SetColumnFunc(BASEDRAWFUNC, bmnum != 0); if (pfloor->master->flags & ML_TFERLINE) { @@ -667,10 +670,14 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) } if (fuzzy) - colfunc = colfuncs[COLDRAWFUNC_FUZZY]; + { + R_SetColumnFunc(COLDRAWFUNC_FUZZY, bmnum != 0); + } } else if (pfloor->flags & FF_FOG) - colfunc = colfuncs[COLDRAWFUNC_FOG]; + { + R_SetColumnFunc(COLDRAWFUNC_FOG, bmnum != 0); + } range = max(ds->x2-ds->x1, 1); //SoM: Moved these up here so they are available for my lightlist calculations @@ -778,7 +785,7 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) lightnum = (frontsector->lightlevel >> LIGHTSEGSHIFT); else if (pfloor->flags & FF_FOG) lightnum = (pfloor->master->frontsector->lightlevel >> LIGHTSEGSHIFT); - else if (colfunc == colfuncs[COLDRAWFUNC_FUZZY]) + else if (R_CheckColumnFunc(COLDRAWFUNC_FUZZY) == true) lightnum = LIGHTLEVELS-1; else lightnum = R_FakeFlat(frontsector, &tempsec, &templight, &templight, false) @@ -1105,7 +1112,8 @@ void R_RenderThickSideRange(drawseg_t *ds, INT32 x1, INT32 x2, ffloor_t *pfloor) spryscale += rw_scalestep; } } - colfunc = colfuncs[BASEDRAWFUNC]; + + R_SetColumnFunc(BASEDRAWFUNC, false); #undef CLAMPMAX #undef CLAMPMIN @@ -1395,7 +1403,7 @@ static void R_RenderSegLoop (void) else dc_lightlist[i].rcolormap = xwalllights[pindex]; - colfunc = colfuncs[COLDRAWFUNC_SHADOWED]; + R_SetColumnFunc(COLDRAWFUNC_SHADOWED, false); } } @@ -1414,6 +1422,8 @@ static void R_RenderSegLoop (void) dc_brightmap = (midbrightmap ? R_GetColumn(midbrightmap, texturecolumn) : NULL); dc_texheight = textureheight[midtexture]>>FRACBITS; + R_SetColumnFunc(colfunctype, dc_brightmap != NULL); + //profile stuff --------------------------------------------------------- #ifdef TIMING ProfZeroTimer(); @@ -1475,6 +1485,7 @@ static void R_RenderSegLoop (void) dc_source = R_GetColumn(toptexture,texturecolumn); dc_brightmap = (topbrightmap ? R_GetColumn(topbrightmap, texturecolumn) : NULL); dc_texheight = textureheight[toptexture]>>FRACBITS; + R_SetColumnFunc(colfunctype, dc_brightmap != NULL); colfunc(); ceilingclip[rw_x] = (INT16)mid; } @@ -1512,6 +1523,7 @@ static void R_RenderSegLoop (void) dc_source = R_GetColumn(bottomtexture,texturecolumn); dc_brightmap = (bottombrightmap ? R_GetColumn(bottombrightmap, texturecolumn) : NULL); dc_texheight = textureheight[bottomtexture]>>FRACBITS; + R_SetColumnFunc(colfunctype, dc_brightmap != NULL); colfunc(); floorclip[rw_x] = (INT16)mid; } @@ -1605,7 +1617,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) memset(&segleft, 0x00, sizeof(segleft)); memset(&segright, 0x00, sizeof(segright)); - colfunc = colfuncs[BASEDRAWFUNC]; + R_SetColumnFunc(BASEDRAWFUNC, false); if (ds_p == drawsegs+maxdrawsegs) { @@ -2825,7 +2837,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) rw_bsilheight = &(ds_p->bsilheight); R_RenderSegLoop(); - colfunc = colfuncs[BASEDRAWFUNC]; + R_SetColumnFunc(BASEDRAWFUNC, false); if (portalline) // if curline is a portal, set portalrender for drawseg ds_p->portalpass = portalrender+1; diff --git a/src/r_splats.c b/src/r_splats.c index 39801812f..28acd0ab0 100644 --- a/src/r_splats.c +++ b/src/r_splats.c @@ -469,10 +469,7 @@ static void R_RasterizeFloorSplat(floorsplat_t *pSplat, vector2_t *verts, visspr else ds_transmap = NULL; - if (ds_powersoftwo) - spanfunc = spanfuncs[spanfunctype]; - else - spanfunc = spanfuncs_npo2[spanfunctype]; + R_SetSpanFunc(spanfunctype, !ds_powersoftwo, false); if (maxy >= vid.height) maxy = vid.height-1; diff --git a/src/r_things.c b/src/r_things.c index 134c21dae..8161457d2 100644 --- a/src/r_things.c +++ b/src/r_things.c @@ -610,6 +610,8 @@ void R_DrawMaskedColumn(column_t *column, column_t *brightmap) INT32 topdelta, prevdelta = 0; basetexturemid = dc_texturemid; + + R_SetColumnFunc(colfunctype, brightmap != NULL); dc_brightmap = NULL; for (; column->topdelta != 0xff ;) @@ -684,6 +686,7 @@ void R_DrawFlippedMaskedColumn(column_t *column, column_t *brightmap) INT32 topdelta, prevdelta = -1; UINT8 *d,*s; + R_SetColumnFunc(colfunctype, brightmap != NULL); dc_brightmap = NULL; for (; column->topdelta != 0xff ;) @@ -827,27 +830,27 @@ static void R_DrawVisSprite(vissprite_t *vis) if ((UINT64)overflow_test&0xFFFFFFFF80000000ULL) return; // ditto } - colfunc = colfuncs[BASEDRAWFUNC]; // hack: this isn't resetting properly somewhere. + R_SetColumnFunc(BASEDRAWFUNC, false); // hack: this isn't resetting properly somewhere. dc_colormap = vis->colormap; dc_fullbright = colormaps; dc_translation = R_GetSpriteTranslation(vis); if (R_SpriteIsFlashing(vis)) // Bosses "flash" - colfunc = colfuncs[COLDRAWFUNC_TRANS]; // translate certain pixels to white + R_SetColumnFunc(COLDRAWFUNC_TRANS, false); // translate certain pixels to white else if (vis->mobj->color && vis->transmap) // Color mapping { - colfunc = colfuncs[COLDRAWFUNC_TRANSTRANS]; + R_SetColumnFunc(COLDRAWFUNC_TRANSTRANS, false); dc_transmap = vis->transmap; } else if (vis->transmap) { - colfunc = colfuncs[COLDRAWFUNC_FUZZY]; + R_SetColumnFunc(COLDRAWFUNC_FUZZY, false); dc_transmap = vis->transmap; //Fab : 29-04-98: translucency table } else if (vis->mobj->color) // translate green skin to another color - colfunc = colfuncs[COLDRAWFUNC_TRANS]; + R_SetColumnFunc(COLDRAWFUNC_TRANS, false); else if (vis->mobj->sprite == SPR_PLAY) // Looks like a player, but doesn't have a color? Get rid of green sonic syndrome. - colfunc = colfuncs[COLDRAWFUNC_TRANS]; + R_SetColumnFunc(COLDRAWFUNC_TRANS, false); if (vis->extra_colormap && !(vis->renderflags & RF_NOCOLORMAPS)) { @@ -984,7 +987,7 @@ static void R_DrawVisSprite(vissprite_t *vis) } } - colfunc = colfuncs[BASEDRAWFUNC]; + R_SetColumnFunc(BASEDRAWFUNC, false); dc_hires = 0; vis->x1 = x1; @@ -1014,7 +1017,7 @@ static void R_DrawPrecipitationVisSprite(vissprite_t *vis) if (vis->transmap) { - colfunc = colfuncs[COLDRAWFUNC_FUZZY]; + R_SetColumnFunc(COLDRAWFUNC_FUZZY, false); dc_transmap = vis->transmap; //Fab : 29-04-98: translucency table } @@ -1056,7 +1059,7 @@ static void R_DrawPrecipitationVisSprite(vissprite_t *vis) R_DrawMaskedColumn(column, NULL); } - colfunc = colfuncs[BASEDRAWFUNC]; + R_SetColumnFunc(BASEDRAWFUNC, false); } // diff --git a/src/screen.c b/src/screen.c index ef5fa7769..3cf8e80d3 100644 --- a/src/screen.c +++ b/src/screen.c @@ -49,10 +49,13 @@ // -------------------------------------------- void (*colfunc)(void); void (*colfuncs[COLDRAWFUNC_MAX])(void); +void (*colfuncs_asm[COLDRAWFUNC_MAX])(void); +int colfunctype; void (*spanfunc)(void); void (*spanfuncs[SPANDRAWFUNC_MAX])(void); void (*spanfuncs_npo2[SPANDRAWFUNC_MAX])(void); +void (*spanfuncs_asm[SPANDRAWFUNC_MAX])(void); // ------------------ // global video state @@ -118,9 +121,6 @@ void SCR_SetDrawFuncs(void) colfuncs[BASEDRAWFUNC] = R_DrawColumn_8; spanfuncs[BASEDRAWFUNC] = R_DrawSpan_8; - colfunc = colfuncs[BASEDRAWFUNC]; - spanfunc = spanfuncs[BASEDRAWFUNC]; - colfuncs[COLDRAWFUNC_FUZZY] = R_DrawTranslucentColumn_8; colfuncs[COLDRAWFUNC_TRANS] = R_DrawTranslatedColumn_8; colfuncs[COLDRAWFUNC_SHADE] = R_DrawShadeColumn_8; @@ -165,21 +165,24 @@ void SCR_SetDrawFuncs(void) { if (R_MMX) { - colfuncs[BASEDRAWFUNC] = R_DrawColumn_8_MMX; - //colfuncs[COLDRAWFUNC_SHADE] = R_DrawShadeColumn_8_ASM; - //colfuncs[COLDRAWFUNC_FUZZY] = R_DrawTranslucentColumn_8_ASM; - colfuncs[COLDRAWFUNC_TWOSMULTIPATCH] = R_Draw2sMultiPatchColumn_8_MMX; - spanfuncs[BASEDRAWFUNC] = R_DrawSpan_8_MMX; + colfuncs_asm[BASEDRAWFUNC] = R_DrawColumn_8_MMX; + //colfuncs_asm[COLDRAWFUNC_SHADE] = R_DrawShadeColumn_8_ASM; + //colfuncs_asm[COLDRAWFUNC_FUZZY] = R_DrawTranslucentColumn_8_ASM; + colfuncs_asm[COLDRAWFUNC_TWOSMULTIPATCH] = R_Draw2sMultiPatchColumn_8_MMX; + spanfuncs_asm[BASEDRAWFUNC] = R_DrawSpan_8_MMX; } else { - colfuncs[BASEDRAWFUNC] = R_DrawColumn_8_ASM; - //colfuncs[COLDRAWFUNC_SHADE] = R_DrawShadeColumn_8_ASM; - //colfuncs[COLDRAWFUNC_FUZZY] = R_DrawTranslucentColumn_8_ASM; - colfuncs[COLDRAWFUNC_TWOSMULTIPATCH] = R_Draw2sMultiPatchColumn_8_ASM; + colfuncs_asm[BASEDRAWFUNC] = R_DrawColumn_8_ASM; + //colfuncs_asm[COLDRAWFUNC_SHADE] = R_DrawShadeColumn_8_ASM; + //colfuncs_asm[COLDRAWFUNC_FUZZY] = R_DrawTranslucentColumn_8_ASM; + colfuncs_asm[COLDRAWFUNC_TWOSMULTIPATCH] = R_Draw2sMultiPatchColumn_8_ASM; } } #endif + + R_SetColumnFunc(BASEDRAWFUNC, false); + R_SetSpanFunc(BASEDRAWFUNC, false, false); } /* else if (vid.bpp > 1) { @@ -201,6 +204,61 @@ void SCR_SetDrawFuncs(void) */ } +void R_SetColumnFunc(size_t id, boolean brightmapped) +{ + I_Assert(id < COLDRAWFUNC_MAX); + + colfunctype = id; + + if (colfuncs_asm[id] != NULL && brightmapped == false) + { + colfunc = colfuncs_asm[id]; + } + else + { + colfunc = colfuncs[id]; + } +} + +void R_SetSpanFunc(size_t id, boolean npo2, boolean brightmapped) +{ + I_Assert(id < COLDRAWFUNC_MAX); + + if (spanfuncs_npo2[id] != NULL && npo2 == true) + { + spanfunc = spanfuncs_npo2[id]; + } + else if (spanfuncs_asm[id] != NULL && brightmapped == false) + { + spanfunc = spanfuncs_asm[id]; + } + else + { + spanfunc = spanfuncs[id]; + } +} + +boolean R_CheckColumnFunc(size_t id) +{ + size_t i; + + if (colfunc == NULL) + { + // Shouldn't happen. + return false; + } + + for (i = 0; i < COLDRAWFUNC_MAX; i++) + { + if (colfunc == colfuncs[id] || colfunc == colfuncs_asm[id]) + { + return true; + } + } + + return false; +} + void SCR_SetMode(void) { if (dedicated) diff --git a/src/screen.h b/src/screen.h index 549d59377..86807be76 100644 --- a/src/screen.h +++ b/src/screen.h @@ -135,6 +135,8 @@ enum extern void (*colfunc)(void); extern void (*colfuncs[COLDRAWFUNC_MAX])(void); +extern void (*colfuncs_asm[COLDRAWFUNC_MAX])(void); +extern int colfunctype; enum { @@ -163,6 +165,7 @@ enum extern void (*spanfunc)(void); extern void (*spanfuncs[SPANDRAWFUNC_MAX])(void); extern void (*spanfuncs_npo2[SPANDRAWFUNC_MAX])(void); +extern void (*spanfuncs_asm[SPANDRAWFUNC_MAX])(void); // ----- // CPUID @@ -205,6 +208,13 @@ void SCR_SetMode(void); // Set drawer functions for Software void SCR_SetDrawFuncs(void); +// Set current column / span drawers +void R_SetColumnFunc(size_t id, boolean brightmapped); +void R_SetSpanFunc(size_t id, boolean npo2, boolean brightmapped); + +// Compare current column drawer +boolean R_CheckColumnFunc(size_t id); + // Recalc screen size dependent stuff void SCR_Recalc(void); From 5183d3161c486988a70152d83edf37434da710ee Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Fri, 17 Dec 2021 03:42:59 -0500 Subject: [PATCH 153/156] Simplify span brightmap load --- src/r_plane.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/src/r_plane.c b/src/r_plane.c index 6276ab7ee..ff5698c0b 100644 --- a/src/r_plane.c +++ b/src/r_plane.c @@ -988,16 +988,7 @@ void R_DrawSinglePlane(visplane_t *pl) if (bmNum != 0) { - texture_t *brightmap = textures[bmNum]; - - if (brightmap->flat == NULL) - { - ds_brightmap = R_GenerateTextureAsFlat(bmNum); - } - else - { - ds_brightmap = (UINT8 *)brightmap->flat; - } + ds_brightmap = R_GenerateTextureAsFlat(bmNum); } } From 510c65699b08516761be9ffa742b0f3486ffed7d Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Fri, 17 Dec 2021 04:16:51 -0500 Subject: [PATCH 154/156] Fixed animated span brightmaps being offset `levelflat->u.texture.num` is modified at run-time to do animations, unlike wall textures which use `texturetranslation`. --- src/r_plane.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/r_plane.c b/src/r_plane.c index ff5698c0b..d2f294cdc 100644 --- a/src/r_plane.c +++ b/src/r_plane.c @@ -820,6 +820,7 @@ void R_DrawSinglePlane(visplane_t *pl) } planeripple.active = false; + ds_brightmap = NULL; R_SetSpanFunc(BASEDRAWFUNC, false, false); if (pl->polyobj) @@ -977,18 +978,14 @@ void R_DrawSinglePlane(visplane_t *pl) R_CheckFlatLength(ds_flatwidth * ds_flatheight); } - ds_brightmap = NULL; - if (type == LEVELFLAT_TEXTURE) { // Get the span's brightmap. // FLATS not supported, SORRY!! - INT32 texNum = R_GetTextureNum(levelflat->u.texture.num); - INT32 bmNum = R_GetTextureBrightmap(texNum); - + INT32 bmNum = R_GetTextureBrightmap(levelflat->u.texture.num); if (bmNum != 0) { - ds_brightmap = R_GenerateTextureAsFlat(bmNum); + ds_brightmap = (UINT8 *)R_GenerateTextureAsFlat(bmNum); } } From 4a34eb5e96a4585146b5c7bf32b1217a527b49aa Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Fri, 17 Dec 2021 16:39:09 -0500 Subject: [PATCH 155/156] Disable ASM column / span entirely Causes strange unidentifiable bugs, and testing with tape who has a few framerate issues. perfstats outputted practically the same frames for everyone. Whatever frame drops exist are simply something else and ASM is not helping at all, so decided it's not worth it. Behind a define anyway, if someone decides to fix it anyway. --- src/screen.c | 10 +++++++++- src/screen.h | 6 ++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/screen.c b/src/screen.c index 3cf8e80d3..25dcbb1f7 100644 --- a/src/screen.c +++ b/src/screen.c @@ -49,13 +49,17 @@ // -------------------------------------------- void (*colfunc)(void); void (*colfuncs[COLDRAWFUNC_MAX])(void); +#ifdef USE_COL_SPAN_ASM void (*colfuncs_asm[COLDRAWFUNC_MAX])(void); +#endif int colfunctype; void (*spanfunc)(void); void (*spanfuncs[SPANDRAWFUNC_MAX])(void); void (*spanfuncs_npo2[SPANDRAWFUNC_MAX])(void); +#ifdef USE_COL_SPAN_ASM void (*spanfuncs_asm[SPANDRAWFUNC_MAX])(void); +#endif // ------------------ // global video state @@ -160,7 +164,7 @@ void SCR_SetDrawFuncs(void) spanfuncs_npo2[SPANDRAWFUNC_TILTEDWATER] = R_DrawTiltedTranslucentWaterSpan_NPO2_8; spanfuncs_npo2[SPANDRAWFUNC_FOG] = NULL; // Not needed -#ifdef RUSEASM +#if (defined(RUSEASM) && defined(USE_COL_SPAN_ASM)) if (R_ASM) { if (R_MMX) @@ -210,11 +214,13 @@ void R_SetColumnFunc(size_t id, boolean brightmapped) colfunctype = id; +#ifdef USE_COL_SPAN_ASM if (colfuncs_asm[id] != NULL && brightmapped == false) { colfunc = colfuncs_asm[id]; } else +#endif { colfunc = colfuncs[id]; } @@ -228,10 +234,12 @@ void R_SetSpanFunc(size_t id, boolean npo2, boolean brightmapped) { spanfunc = spanfuncs_npo2[id]; } +#ifdef USE_COL_SPAN_ASM else if (spanfuncs_asm[id] != NULL && brightmapped == false) { spanfunc = spanfuncs_asm[id]; } +#endif else { spanfunc = spanfuncs[id]; diff --git a/src/screen.h b/src/screen.h index 86807be76..66c52dd67 100644 --- a/src/screen.h +++ b/src/screen.h @@ -116,6 +116,8 @@ extern vmode_t specialmodes[NUMSPECIALMODES]; // color mode dependent drawer function pointers // --------------------------------------------- +#define USE_COL_SPAN_ASM 0 + #define BASEDRAWFUNC 0 enum @@ -135,7 +137,9 @@ enum extern void (*colfunc)(void); extern void (*colfuncs[COLDRAWFUNC_MAX])(void); +#ifdef USE_COL_SPAN_ASM extern void (*colfuncs_asm[COLDRAWFUNC_MAX])(void); +#endif extern int colfunctype; enum @@ -165,7 +169,9 @@ enum extern void (*spanfunc)(void); extern void (*spanfuncs[SPANDRAWFUNC_MAX])(void); extern void (*spanfuncs_npo2[SPANDRAWFUNC_MAX])(void); +#ifdef USE_COL_SPAN_ASM extern void (*spanfuncs_asm[SPANDRAWFUNC_MAX])(void); +#endif // ----- // CPUID From 7d2633f5723d152ddc6ee39e01a07341907a397b Mon Sep 17 00:00:00 2001 From: James R Date: Fri, 17 Dec 2021 17:32:19 -0800 Subject: [PATCH 156/156] Correct spherebox dehacked states list --- src/deh_tables.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/deh_tables.c b/src/deh_tables.c index 894157639..e7e211f0c 100644 --- a/src/deh_tables.c +++ b/src/deh_tables.c @@ -3477,7 +3477,19 @@ const char *const STATE_LIST[] = { // array length left dynamic for sanity testi "S_DEADRANDOMITEM", // Sphere Box (for Battle) - "S_SPHEREBOX", + "S_SPHEREBOX1", + "S_SPHEREBOX2", + "S_SPHEREBOX3", + "S_SPHEREBOX4", + "S_SPHEREBOX5", + "S_SPHEREBOX6", + "S_SPHEREBOX7", + "S_SPHEREBOX8", + "S_SPHEREBOX9", + "S_SPHEREBOX10", + "S_SPHEREBOX11", + "S_SPHEREBOX12", + "S_DEADSPHEREBOX", // Random Item Pop "S_RANDOMITEMPOP1",