Merge branch 'master' of https://git.do.srb2.org/KartKrew/Kart into hwr2-twodee

This commit is contained in:
toaster 2023-03-01 18:10:44 +00:00
commit 35ae8f01f4
16 changed files with 226 additions and 42 deletions

View file

@ -559,10 +559,7 @@ bool CallFunc_EndPrint(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Wo
(void)argC;
if (ACS_ActivatorIsLocal(thread) == true)
{
HU_SetCEchoDuration(5);
HU_DoCEcho(thread->printBuf.data());
}
HU_DoTitlecardCEcho(thread->printBuf.data());
thread->printBuf.drop();
return false;
@ -931,13 +928,11 @@ bool CallFunc_EndPrintBold(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM
(void)argV;
(void)argC;
HU_SetCEchoDuration(5);
HU_DoCEcho(thread->printBuf.data());
HU_DoTitlecardCEcho(thread->printBuf.data());
thread->printBuf.drop();
return false;
}
/*--------------------------------------------------
bool CallFunc_PlayerTeam(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word argC)

View file

@ -1179,10 +1179,19 @@ void G_BuildTiccmd(ticcmd_t *cmd, INT32 realtics, UINT8 ssplayer)
K_ToggleDirector(false);
}
if (player->spectator == true)
{
// duplication of fire
if (G_PlayerInputDown(forplayer, gc_item, 0))
{
cmd->buttons |= BT_ATTACK;
}
if (M_MenuButtonPressed(forplayer, MBT_R))
{
K_ToggleDirector(true);
}
}
goto aftercmdinput;
}
@ -3097,6 +3106,7 @@ void G_ExitLevel(void)
// Remove CEcho text on round end.
HU_ClearCEcho();
HU_ClearTitlecardCEcho();
// Don't save demos immediately here! Let standings write first
}
@ -4076,6 +4086,7 @@ void G_AfterIntermission(void)
gamecomplete = 1;
HU_ClearCEcho();
HU_ClearTitlecardCEcho();
if (demo.playback)
{

View file

@ -161,6 +161,11 @@ static tic_t cechotimer = 0;
static tic_t cechoduration = 5*TICRATE;
static INT32 cechoflags = 0;
static char tcechotext[1024]; // buffer for the titlecard text
static tic_t tcechotimer = 0; // goes up by 1 each frame this is active
static tic_t tcechoduration = 0; // Set automatically
static tic_t resynch_ticker = 0;
static huddrawlist_h luahuddrawlist_scores;
@ -1034,6 +1039,13 @@ void HU_Ticker(void)
if (cechotimer)
cechotimer--;
if (tcechotimer)
{
tcechotimer++;
if (tcechotimer > tcechoduration)
tcechotimer = 0;
}
if (gamestate != GS_LEVEL)
{
return;
@ -1996,6 +2008,66 @@ static void HU_DrawCEcho(void)
}
}
static void HU_DrawTitlecardCEcho(void)
{
if (tcechotimer)
{
INT32 i = 0;
INT32 y = (BASEVIDHEIGHT/2)-16;
INT32 pnumlines = 0;
INT32 timeroffset = 0;
char *line;
char *echoptr;
char temp[1024];
for (i = 0; tcechotext[i] != '\0'; ++i)
if (tcechotext[i] == '\\')
pnumlines++;
y -= (pnumlines-1)*16;
// Prevent crashing because I'm sick of this
if (y < 0)
{
CONS_Alert(CONS_WARNING, "CEcho contained too many lines, not displaying\n");
cechotimer = 0;
return;
}
strcpy(temp, tcechotext);
echoptr = &temp[0];
while (*echoptr != '\0')
{
INT32 w;
INT32 timer = (INT32)(tcechotimer - timeroffset);
if (timer <= 0)
return; // we don't care.
line = strchr(echoptr, '\\');
if (line == NULL)
break;
*line = '\0';
w = V_TitleCardStringWidth(echoptr);
V_DrawTitleCardString(BASEVIDWIDTH/2 -w/2, y, echoptr, 0, false, timer, TICRATE*4);
y += 32;
// offset the timer for the next line.
timeroffset += strlen(echoptr);
// set the ptr to the \0 we made and advance it because we don't want an empty string.
echoptr = line;
echoptr++;
}
}
}
//
// demo info stuff
//
@ -2137,6 +2209,9 @@ drawontop:
if (cechotimer)
HU_DrawCEcho();
if (tcechotimer)
HU_DrawTitlecardCEcho();
}
//======================================================================
@ -2590,3 +2665,22 @@ void HU_DoCEcho(const char *msg)
cechotext[sizeof(cechotext) - 1] = '\0';
cechotimer = cechoduration;
}
// Simply set the timer to 0 to clear it.
// No need to bother clearing the buffer or anything.
void HU_ClearTitlecardCEcho(void)
{
tcechotimer = 0;
}
// Similar but for titlecard CEcho and also way less convoluted because I have no clue whatever the fuck they were trying above.
void HU_DoTitlecardCEcho(const char *msg)
{
I_OutputMsg("%s\n", msg); // print to log
strncpy(tcechotext, msg, sizeof(tcechotext));
strncat(tcechotext, "\\", sizeof(tcechotext) - strlen(tcechotext) - 1);
tcechotext[sizeof(tcechotext) - 1] = '\0';
tcechotimer = 1;
tcechoduration = TICRATE*6 + strlen(tcechotext);
}

View file

@ -154,6 +154,10 @@ void HU_SetCEchoDuration(INT32 seconds);
void HU_SetCEchoFlags(INT32 flags);
void HU_DoCEcho(const char *msg);
// Titlecard CECHO shite
void HU_DoTitlecardCEcho(const char *msg);
void HU_ClearTitlecardCEcho(void);
// Demo playback info
extern UINT32 hu_demotime;
extern UINT32 hu_demolap;

View file

@ -110,16 +110,16 @@ static boolean K_CanSwitchDirector(void)
return false;
}
if (!directorinfo.active)
{
return false;
}
return true;
}
static void K_DirectorSwitch(INT32 player, boolean force)
{
if (!directorinfo.active)
{
return;
}
if (P_IsDisplayPlayer(&players[player]))
{
return;

View file

@ -4639,16 +4639,26 @@ K_drawMiniPing (void)
}
}
static void K_DrawDirectorButton(INT32 idx, const char *label, patch_t *kp[2])
static void K_DrawDirectorButton(INT32 idx, const char *label, patch_t *kp[2], INT32 textflags)
{
const INT32 flags = V_SNAPTORIGHT | V_SLIDEIN;
const INT32 textflags = flags | V_6WIDTHSPACE | V_ALLOWLOWERCASE;
INT32 flags = V_SNAPTORIGHT | V_SLIDEIN | V_SPLITSCREEN;
const UINT8 anim_duration = 16;
const UINT8 anim = (leveltime % (anim_duration * 2)) < anim_duration;
const INT32 x = BASEVIDWIDTH - 60;
const INT32 y = BASEVIDHEIGHT - 70 + (idx * 16);
INT32 x = (BASEVIDWIDTH/2) - 10;
INT32 y = (idx * 16);
if (r_splitscreen <= 1)
{
x = BASEVIDWIDTH - 60;
if (r_splitscreen == 0)
{
y += BASEVIDHEIGHT - 78;
}
}
textflags |= (flags | V_6WIDTHSPACE | V_ALLOWLOWERCASE);
V_DrawScaledPatch(x, y - 4, flags, kp[anim]);
V_DrawRightAlignedThinString(x - 2, y, textflags, label);
@ -4656,14 +4666,48 @@ static void K_DrawDirectorButton(INT32 idx, const char *label, patch_t *kp[2])
static void K_drawDirectorHUD(void)
{
const INT32 p = (splitscreen_partied[consoleplayer] ? splitscreen_party[consoleplayer] : g_localplayers)[R_GetViewNumber()];
const char *itemtxt = "Join";
UINT8 offs = 0;
UINT8 numingame = 0;
UINT8 i;
if (!LUA_HudEnabled(hud_textspectator))
{
return;
}
K_DrawDirectorButton(0, "Next Player", kp_button_a[0]);
K_DrawDirectorButton(1, "Prev Player", kp_button_x[0]);
K_DrawDirectorButton(2, "Director", kp_button_r);
for (i = 0; i < MAXPLAYERS; i++)
if (playeringame[i] && !players[i].spectator)
numingame++;
if (numingame > 1 && r_splitscreen == 0) // simplifies things a lot
{
K_DrawDirectorButton(1, "Next Player", kp_button_a[0], 0);
K_DrawDirectorButton(2, "Prev Player", kp_button_x[0], 0);
offs = 2;
}
if (p == -1 || !playeringame[p] || players[p].spectator == false)
{
return;
}
K_DrawDirectorButton(offs + 1, "Director", kp_button_r,
(directorinfo.active ? V_YELLOWMAP : 0));
if (players[p].flashing)
itemtxt = ". . .";
else if (players[p].pflags & PF_WANTSTOJOIN)
itemtxt = "Cancel Join";
if (cv_maxplayers.value)
{
itemtxt = va("%s [%d/%d]", itemtxt, numingame, cv_maxplayers.value);
}
K_DrawDirectorButton(0, itemtxt, kp_button_l, 0);
}
static void K_drawDistributionDebugger(void)
@ -4984,7 +5028,7 @@ void K_drawKartHUD(void)
K_drawMiniPing();
}
if (displayplayers[viewnum] != g_localplayers[viewnum])
if (displayplayers[viewnum] != g_localplayers[viewnum] && !demo.playback)
{
K_drawDirectorHUD();
}

View file

@ -10099,7 +10099,7 @@ void K_UnsetItemOut(player_t *player)
void K_MoveKartPlayer(player_t *player, boolean onground)
{
ticcmd_t *cmd = &player->cmd;
boolean ATTACK_IS_DOWN = ((cmd->buttons & BT_ATTACK) && !(player->oldcmd.buttons & BT_ATTACK));
boolean ATTACK_IS_DOWN = ((cmd->buttons & BT_ATTACK) && !(player->oldcmd.buttons & BT_ATTACK) && (player->respawn.state == RESPAWNST_NONE));
boolean HOLDING_ITEM = (player->pflags & (PF_ITEMOUT|PF_EGGMANOUT));
boolean NO_HYUDORO = (player->stealingtimer == 0);

View file

@ -344,7 +344,10 @@ static void K_MovePlayerToRespawnPoint(player_t *player)
player->mo->momx = player->mo->momy = player->mo->momz = 0;
player->flashing = 2;
// 3 because this timer counts down afterward, in
// P_PlayerThink. flashing must be > 1 after it has
// counted down in order to flicker the player sprite.
player->flashing = 3;
//player->nocontrol = max(2, player->nocontrol);
if (leveltime % 8 == 0 && !mapreset)
@ -813,6 +816,7 @@ void K_RespawnChecker(player_t *player)
return;
case RESPAWNST_DROP:
player->mo->momx = player->mo->momy = 0;
player->flashing = 3;
if (player->respawn.timer > 0)
{
player->mo->momz = 0;

View file

@ -35,6 +35,7 @@
#include "k_menu.h" // Player Setup menu color stuff
#include "p_spec.h" // P_StartQuake
#include "i_system.h" // I_GetPreciseTime, I_GetPrecisePrecision
#include "hu_stuff.h" // for the cecho
#include "lua_script.h"
#include "lua_libs.h"
@ -3879,6 +3880,14 @@ static int lib_getTimeMicros(lua_State *L)
return 1;
}
static int lib_startTitlecardCecho(lua_State *L)
{
const char *str = luaL_checkstring(L, 1);
HU_DoTitlecardCEcho(str);
return 1;
}
static luaL_Reg lib[] = {
{"print", lib_print},
{"chatprint", lib_chatprint},
@ -4161,6 +4170,9 @@ static luaL_Reg lib[] = {
{"K_UpdateBossHealthBar", lib_kUpdateBossHealthBar},
{"K_DeclareWeakspot", lib_kDeclareWeakspot},
// hu_stuff technically?
{"HU_DoTitlecardCEcho", lib_startTitlecardCecho},
{NULL, NULL}
};

View file

@ -1911,6 +1911,12 @@ static boolean P_KillPlayer(player_t *player, mobj_t *inflictor, mobj_t *source,
{
(void)source;
if (player->respawn.state != RESPAWNST_NONE)
{
K_DoInstashield(player);
return false;
}
if (!player->exiting && specialstageinfo.valid == true)
{
player->pflags |= PF_NOCONTEST;

View file

@ -9743,14 +9743,6 @@ 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;
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))
P_SetTarget(&mobj->target, NULL);
@ -13734,6 +13726,18 @@ void P_SpawnItemPattern(mapthing_t *mthing)
}
}
void P_SpawnItemLine(mapthing_t *mt1, mapthing_t *mt2)
{
const mobjtype_t type = P_GetMobjtype(mt1->type);
const fixed_t diameter = 2 * FixedMul(mobjinfo[type].radius, mapobjectscale);
const fixed_t dx = (mt2->x - mt1->x) * FRACUNIT;
const fixed_t dy = (mt2->y - mt1->y) * FRACUNIT;
const fixed_t dist = FixedHypot(dx, dy);
const angle_t angle = R_PointToAngle2(0, 0, dx, dy);
P_SpawnSingularItemRow(mt1, type, (dist / diameter) + 1, diameter, 0, AngleFixed(angle) / FRACUNIT);
}
//
// P_CheckMissileSpawn
// Moves the missile forward a bit and possibly explodes it right there.

View file

@ -530,6 +530,7 @@ fixed_t P_GetMapThingSpawnHeight(const mobjtype_t mobjtype, const mapthing_t* mt
mobj_t *P_SpawnMapThing(mapthing_t *mthing);
void P_SpawnHoop(mapthing_t *mthing);
void P_SpawnItemPattern(mapthing_t *mthing);
void P_SpawnItemLine(mapthing_t *mt1, mapthing_t *mt2);
void P_SpawnHoopOfSomething(fixed_t x, fixed_t y, fixed_t z, fixed_t radius, INT32 number, mobjtype_t type, angle_t rotangle);
void P_SpawnPrecipitation(void);
void P_SpawnParaloop(fixed_t x, fixed_t y, fixed_t z, fixed_t radius, INT32 number, mobjtype_t type, statenum_t nstate, angle_t rotangle, boolean spawncenter);

View file

@ -700,10 +700,13 @@ static void P_SpawnMapThings(boolean spawnemblems)
for (i = 0, mt = mapthings; i < nummapthings; i++, mt++)
{
if (mt->type == 1700 // MT_AXIS
|| mt->type == 1701 // MT_AXISTRANSFER
|| mt->type == 1702) // MT_AXISTRANSFERLINE
switch (mt->type)
{
case 1700: // MT_AXIS
case 1701: // MT_AXISTRANSFER
case 1702: // MT_AXISTRANSFERLINE
continue; // These were already spawned
}
if (mt->type == mobjinfo[MT_BATTLECAPSULE].doomednum)
continue; // This will spawn later
@ -5952,6 +5955,7 @@ static void P_ConvertBinaryLinedefTypes(void)
lines[i].args[1] |= TMBOT_FORCEDIR;
lines[i].args[2] = sides[lines[i].sidenum[0]].textureoffset / FRACUNIT;
break;
default:
break;
}
@ -7519,6 +7523,7 @@ boolean P_LoadLevel(boolean fromnetsave, boolean reloadinggamestate)
// Clear CECHO messages
HU_ClearCEcho();
HU_ClearTitlecardCEcho();
if (mapheaderinfo[gamemap-1]->runsoc[0] != '#')
P_RunSOC(mapheaderinfo[gamemap-1]->runsoc);

View file

@ -167,7 +167,7 @@ angle_t FixedAngle(fixed_t fa)
return AngleAdj(cfa, cwf, ra);
}
INT32 AngleDelta(angle_t a1, angle_t a2)
angle_t AngleDelta(angle_t a1, angle_t a2)
{
angle_t delta = a1 - a2;

View file

@ -27,7 +27,7 @@ extern "C" {
#define FINEANGLES 8192
#define FINEMASK (FINEANGLES - 1)
#define ANGLETOFINESHIFT 19 // 0x100000000 to 0x2000
#define FINEANGLE_C(x) ((FixedAngle((x)*FRACUNIT)>>ANGLETOFINESHIFT) & FINEMASK) // ((x*(ANGLE_45/45))>>ANGLETOFINESHIFT) & FINEMASK
#define ANGLETOFINE(x) (((x)>>ANGLETOFINESHIFT) & FINEMASK)
// Effective size is 10240.
extern fixed_t finesine[5*FINEANGLES/4];
@ -110,7 +110,7 @@ FUNCMATH angle_t FixedAngle(fixed_t fa);
// and with a factor, with +factor for (fa/factor) and -factor for (fa*factor)
FUNCMATH angle_t FixedAngleC(fixed_t fa, fixed_t factor);
// difference between two angle_t
FUNCMATH INT32 AngleDelta(angle_t a1, angle_t a2);
FUNCMATH angle_t AngleDelta(angle_t a1, angle_t a2);
FUNCMATH INT32 AngleDeltaSigned(angle_t a1, angle_t a2);
FUNCMATH float AngleToFloat(angle_t x);
FUNCMATH angle_t FloatToAngle(float f);
@ -136,6 +136,10 @@ void FM_Rotate(matrix_t *dest, angle_t angle, fixed_t x, fixed_t y, fixed_t z);
#define FINECOSINE(n) (finecosine[n]>>(FINE_FRACBITS-FRACBITS))
#define FINETANGENT(n) (finetangent[n]>>(FINE_FRACBITS-FRACBITS))
// FSIN(ANGLE_90) = FRACUNIT
#define FSIN(n) FINESINE(ANGLETOFINE(n))
#define FCOS(n) FINECOSINE(ANGLETOFINE(n))
#ifdef __cplusplus
} // extern "C"
#endif