From 0dc21106e5ae47bc274e02c0f46ee34a264a042b Mon Sep 17 00:00:00 2001 From: Sally Coolatta Date: Sat, 15 Aug 2020 07:47:18 -0400 Subject: [PATCH] Lua stuff is done --- src/d_clisrv.c | 1 + src/d_main.c | 14 +- src/d_netcmd.c | 7 +- src/dehacked.c | 9 +- src/f_finale.c | 4 +- src/f_finale.h | 33 -- src/f_wipe.c | 65 ++++ src/g_demo.c | 4 +- src/g_game.c | 4 +- src/g_splitscreen.c | 1 + src/hardware/hw_draw.c | 2 +- src/hardware/hw_main.c | 10 +- src/hu_stuff.c | 1 + src/info.c | 4 +- src/info.h | 3 - src/lua_baselib.c | 180 +-------- src/lua_hook.h | 4 +- src/lua_hooklib.c | 70 ++-- src/lua_hudlib.c | 147 -------- src/lua_playerlib.c | 8 - src/lua_script.c | 832 ++++++++--------------------------------- src/lua_script.h | 9 +- src/m_cond.c | 1 - src/m_menu.c | 225 ++++------- src/p_enemy.c | 40 -- src/p_local.h | 12 - src/p_saveg.c | 4 +- src/p_setup.c | 6 - src/p_spec.c | 2 +- src/s_sound.c | 1 + src/sdl/i_threads.c | 2 +- 31 files changed, 360 insertions(+), 1345 deletions(-) diff --git a/src/d_clisrv.c b/src/d_clisrv.c index 29b320219..3946fe386 100644 --- a/src/d_clisrv.c +++ b/src/d_clisrv.c @@ -52,6 +52,7 @@ #include "k_pwrlv.h" #include "k_bot.h" #include "k_grandprix.h" +#include "doomstat.h" #ifndef NONET // cl loading screen diff --git a/src/d_main.c b/src/d_main.c index 8423a6b6c..83a03a4bf 100644 --- a/src/d_main.c +++ b/src/d_main.c @@ -70,6 +70,7 @@ // SRB2Kart #include "k_grandprix.h" +#include "doomstat.h" #ifdef CMAKECONFIG #include "config.h" @@ -336,17 +337,11 @@ static void D_Display(void) if (rendermode != render_none) { // Fade to black first - if ((wipegamestate == (gamestate_t)FORCEWIPE || - (wipegamestate != (gamestate_t)FORCEWIPEOFF - && !(gamestate == GS_LEVEL || (gamestate == GS_TITLESCREEN && titlemapinaction))) - ) // fades to black on its own timing, always + if (!(gamestate == GS_LEVEL || (gamestate == GS_TITLESCREEN && titlemapinaction)) // fades to black on its own timing, always && wipetypepre != UINT8_MAX) { F_WipeStartScreen(); - // Check for Mega Genesis fade - wipestyleflags = WSF_FADEOUT; - if (wipegamestate == (gamestate_t)FORCEWIPE) - F_WipeColorFill(31); + F_WipeColorFill(31); F_WipeEndScreen(); F_RunWipe(wipetypepre, gamestate != GS_TIMEATTACK, "FADEMAP0", false, false); } @@ -460,9 +455,6 @@ static void D_Display(void) } // STUPID race condition... - if (wipegamestate == GS_INTRO && gamestate == GS_TITLESCREEN) - wipegamestate = FORCEWIPEOFF; - else { wipegamestate = gamestate; diff --git a/src/d_netcmd.c b/src/d_netcmd.c index 3015decad..a77483cf7 100644 --- a/src/d_netcmd.c +++ b/src/d_netcmd.c @@ -56,6 +56,7 @@ #include "k_color.h" #include "k_respawn.h" #include "k_grandprix.h" +#include "doomstat.h" #ifdef NETGAME_DEVMODE #define CV_RESTRICT CV_NETVAR @@ -310,7 +311,7 @@ INT32 cv_debug; consvar_t cv_usemouse = {"use_mouse", "Off", CV_SAVE|CV_CALL,usemouse_cons_t, I_StartupMouse, 0, NULL, NULL, 0, 0, NULL}; consvar_t cv_usejoystick[MAXSPLITSCREENPLAYERS] = { - {"use_gamepad", "1", CV_SAVE|CV_CALL, usejoystick_cons_t, I_InitJoystick, 0, NULL, NULL, 0, 0, NULL}, + {"use_gamepad", "1", CV_SAVE|CV_CALL, usejoystick_cons_t, I_InitJoystick1, 0, NULL, NULL, 0, 0, NULL}, {"use_gamepad2", "2", CV_SAVE|CV_CALL, usejoystick_cons_t, I_InitJoystick2, 0, NULL, NULL, 0, 0, NULL}, {"use_joystick3", "3", CV_SAVE|CV_CALL, usejoystick_cons_t, I_InitJoystick3, 0, NULL, NULL, 0, 0, NULL}, {"use_joystick4", "4", CV_SAVE|CV_CALL, usejoystick_cons_t, I_InitJoystick4, 0, NULL, NULL, 0, 0, NULL} @@ -4865,7 +4866,7 @@ static void Command_Archivetest_f(void) // test archive CONS_Printf("LUA_Archive...\n"); - LUA_Archive(); + LUA_Archive(save_p); WRITEUINT8(save_p, 0x7F); wrote = (UINT32)(save_p-buf); @@ -4876,7 +4877,7 @@ static void Command_Archivetest_f(void) // test unarchive save_p = buf; CONS_Printf("LUA_UnArchive...\n"); - LUA_UnArchive(); + LUA_UnArchive(save_p); i = READUINT8(save_p); if (i != 0x7F || wrote != (UINT32)(save_p-buf)) CONS_Printf("Savegame corrupted. (write %u, read %u)\n", wrote, (UINT32)(save_p-buf)); diff --git a/src/dehacked.c b/src/dehacked.c index 92d548ea5..5870b0bca 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -21,7 +21,6 @@ #include "w_wad.h" #include "m_menu.h" #include "m_misc.h" -#include "filesrch.h" // for refreshdirmenu #include "f_finale.h" #include "y_inter.h" #include "dehacked.h" @@ -38,7 +37,6 @@ #include "lua_script.h" #include "lua_hook.h" #include "d_clisrv.h" -#include "r_things.h" // for followers #include "m_cond.h" @@ -48,6 +46,10 @@ #include "hardware/hw_light.h" #endif +// SRB2Kart +#include "filesrch.h" // for refreshdirmenu +#include "r_skins.h" // for followers + // Free slot names // The crazy word-reading stuff uses these. static char *FREE_STATES[NUMSTATEFREESLOTS]; @@ -3137,7 +3139,6 @@ static actionpointer_t actionpointers[] = {{A_Scream}, "A_SCREAM"}, {{A_BossDeath}, "A_BOSSDEATH"}, {{A_CustomPower}, "A_CUSTOMPOWER"}, - {{A_GiveWeapon}, "A_GIVEWEAPON"}, {{A_RingBox}, "A_RINGBOX"}, {{A_Invincibility}, "A_INVINCIBILITY"}, {{A_SuperSneakers}, "A_SUPERSNEAKERS"}, @@ -3147,7 +3148,6 @@ static actionpointer_t actionpointers[] = {{A_BubbleRise}, "A_BUBBLERISE"}, {{A_BubbleCheck}, "A_BUBBLECHECK"}, {{A_AwardScore}, "A_AWARDSCORE"}, - {{A_ExtraLife}, "A_EXTRALIFE"}, {{A_GiveShield}, "A_GIVESHIELD"}, {{A_GravityBox}, "A_GRAVITYBOX"}, {{A_ScoreRise}, "A_SCORERISE"}, @@ -3179,7 +3179,6 @@ static actionpointer_t actionpointers[] = {{A_RingExplode}, "A_RINGEXPLODE"}, {{A_OldRingExplode}, "A_OLDRINGEXPLODE"}, {{A_MixUp}, "A_MIXUP"}, - {{A_RecyclePowers}, "A_RECYCLEPOWERS"}, {{A_Boss1Chase}, "A_BOSS1CHASE"}, {{A_FocusTarget}, "A_FOCUSTARGET"}, {{A_Boss2Chase}, "A_BOSS2CHASE"}, diff --git a/src/f_finale.c b/src/f_finale.c index 215c07989..04459c23a 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -382,9 +382,8 @@ void F_IntroDrawer(void) { if (rendermode != render_none) { - wipestyleflags = WSF_FADEOUT; F_WipeStartScreen(); - F_TryColormapFade(31); + F_WipeColorFill(31); F_WipeEndScreen(); F_RunWipe(99, true, "FADEMAP0", false, false); } @@ -430,7 +429,6 @@ void F_IntroDrawer(void) F_WipeStartScreen(); wipegamestate = -1; - wipestyleflags = WSF_CROSSFADE; animtimer = stoptimer = 0; } diff --git a/src/f_finale.h b/src/f_finale.h index ac0147de9..e82b1a97d 100644 --- a/src/f_finale.h +++ b/src/f_finale.h @@ -140,43 +140,10 @@ void F_MenuPresTicker(boolean run); // // WIPE // -// HACK for menu fading while titlemapinaction; skips the level check -#define FORCEWIPE -3 -#define FORCEWIPEOFF -2 extern boolean WipeInAction; extern boolean WipeStageTitle; -typedef enum -{ - WIPESTYLE_NORMAL, - WIPESTYLE_COLORMAP -} wipestyle_t; -extern wipestyle_t wipestyle; - -typedef enum -{ - WSF_FADEOUT = 1, - WSF_FADEIN = 1<<1, - WSF_TOWHITE = 1<<2, - WSF_CROSSFADE = 1<<3, -} wipestyleflags_t; -extern wipestyleflags_t wipestyleflags; - -// Even my function names are borderline -boolean F_ShouldColormapFade(void); -boolean F_TryColormapFade(UINT8 wipecolor); -#ifndef NOWIPE -void F_DecideWipeStyle(void); -#endif - -#define FADECOLORMAPDIV 8 -#define FADECOLORMAPROWS (256/FADECOLORMAPDIV) - -#define FADEREDFACTOR 15 -#define FADEGREENFACTOR 15 -#define FADEBLUEFACTOR 10 - extern INT32 lastwipetic; // Don't know where else to place this constant diff --git a/src/f_wipe.c b/src/f_wipe.c index 530536377..6d8da96e0 100644 --- a/src/f_wipe.c +++ b/src/f_wipe.c @@ -31,6 +31,9 @@ #include "m_misc.h" // movie mode #include "d_clisrv.h" // So the network state can be updated during the wipe +#include "g_game.h" +#include "st_stuff.h" + #ifdef HWRENDER #include "hardware/hw_main.h" #endif @@ -82,6 +85,7 @@ UINT8 wipedefs[NUMWIPEDEFS] = { //-------------------------------------------------------------------------- boolean WipeInAction = false; +boolean WipeStageTitle = false; INT32 lastwipetic = 0; #ifndef NOWIPE @@ -401,6 +405,18 @@ static void F_DoEncoreWiggle(UINT8 time) } } +/** Draw the stage title. + */ +void F_WipeStageTitle(void) +{ + // draw level title + if ((WipeStageTitle) && G_IsTitleCardAvailable()) + { + ST_runTitleCard(); + ST_drawWipeTitleCard(); + } +} + /** After setting up the screens you want to wipe, * calling this will do a 'typical' wipe. */ @@ -505,3 +521,52 @@ void F_RunWipe(UINT8 wipetype, boolean drawMenu, const char *colormap, boolean r } #endif } + +/** Returns tic length of wipe + * One lump equals one tic + */ +tic_t F_GetWipeLength(UINT8 wipetype) +{ +#ifdef NOWIPE + (void)wipetype; + return 0; +#else + static char lumpname[10] = "FADEmmss"; + lumpnum_t lumpnum; + UINT8 wipeframe; + + if (wipetype > 99) + return 0; + + for (wipeframe = 0; wipeframe < 100; wipeframe++) + { + sprintf(&lumpname[4], "%.2hu%.2hu", (UINT16)wipetype, (UINT16)wipeframe); + + lumpnum = W_CheckNumForName(lumpname); + if (lumpnum == LUMPERROR) + return --wipeframe; + } + return --wipeframe; +#endif +} + +/** Does the specified wipe exist? + */ +boolean F_WipeExists(UINT8 wipetype) +{ +#ifdef NOWIPE + (void)wipetype; + return false; +#else + static char lumpname[10] = "FADEmm00"; + lumpnum_t lumpnum; + + if (wipetype > 99) + return false; + + sprintf(&lumpname[4], "%.2hu00", (UINT16)wipetype); + + lumpnum = W_CheckNumForName(lumpname); + return !(lumpnum == LUMPERROR); +#endif +} diff --git a/src/g_demo.c b/src/g_demo.c index 22f7c735f..2c455e71d 100644 --- a/src/g_demo.c +++ b/src/g_demo.c @@ -2040,7 +2040,7 @@ void G_BeginRecording(void) WRITEUINT8(demo_p, 0xFF); // Denote the end of the player listing // player lua vars, always saved even if empty - LUA_ArchiveDemo(); + LUA_Archive(demo_p); WRITEUINT32(demo_p,P_GetInitSeed()); @@ -3006,7 +3006,7 @@ void G_DoPlayDemo(char *defdemoname) LUA_ClearState(); // No modeattacking check, DF_LUAVARS won't be present here. - LUA_UnArchiveDemo(); + LUA_UnArchive(demo_p); } splitscreen = 0; diff --git a/src/g_game.c b/src/g_game.c index b5b102672..f38c3ebc8 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -56,7 +56,7 @@ #include "k_color.h" #include "k_respawn.h" #include "k_grandprix.h" - +#include "doomstat.h" gameaction_t gameaction; gamestate_t gamestate = GS_NULL; @@ -1334,8 +1334,6 @@ void G_PreLevelTitleCard(void) if (takescreenshot) // Only take screenshots after drawing. M_DoScreenShot(); } - if (!cv_showhud.value) - wipestyleflags = WSF_CROSSFADE; #endif } diff --git a/src/g_splitscreen.c b/src/g_splitscreen.c index ffc548147..0354c0d10 100644 --- a/src/g_splitscreen.c +++ b/src/g_splitscreen.c @@ -13,6 +13,7 @@ #include "g_game.h" #include "p_local.h" #include "r_local.h" +#include "doomstat.h" INT32 splitscreen_original_party_size[MAXPLAYERS]; INT32 splitscreen_original_party[MAXPLAYERS][MAXSPLITSCREENPLAYERS]; diff --git a/src/hardware/hw_draw.c b/src/hardware/hw_draw.c index 8ac1bc4c3..0fe237e24 100644 --- a/src/hardware/hw_draw.c +++ b/src/hardware/hw_draw.c @@ -214,7 +214,7 @@ void HWR_DrawStretchyFixedPatch(GLPatch_t *gpatch, fixed_t x, fixed_t y, fixed_t } } - if (pscale != FRACUNIT || (splitscreen && option & V_SPLITSCREEN)) + if (pscale != FRACUNIT || (r_splitscreen && option & V_SPLITSCREEN)) { fwidth = (float)SHORT(gpatch->width) * fscalew * dupx; fheight = (float)SHORT(gpatch->height) * fscaleh * dupy; diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index b13fcdbac..a0cd07025 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -5441,7 +5441,7 @@ static void HWR_DrawSkyBackground(player_t *player) dometransform.rollangle = FIXED_TO_FLOAT(rol); dometransform.roll = true; } - dometransform.splitscreen = splitscreen; + dometransform.splitscreen = r_splitscreen; HWR_GetTexture(texturetranslation[skytexture]); @@ -5673,7 +5673,7 @@ void HWR_RenderSkyboxView(INT32 viewnumber, player_t *player) gl_centery = gl_basecentery; gl_viewwindowy = gl_baseviewwindowy; gl_windowcentery = gl_basewindowcentery; - if (splitscreen && viewnumber == 1) + if (r_splitscreen && viewnumber == 1) { gl_viewwindowy += (vid.height/2); gl_windowcentery += (vid.height/2); @@ -5729,7 +5729,7 @@ void HWR_RenderSkyboxView(INT32 viewnumber, player_t *player) HWR_DrawSkyBackground(player); //Hurdler: it doesn't work in splitscreen mode - drawsky = splitscreen; + drawsky = r_splitscreen; HWR_ClearSprites(); @@ -5934,7 +5934,7 @@ void HWR_RenderPlayerView(INT32 viewnumber, player_t *player) atransform.rollangle = FIXED_TO_FLOAT(rol); atransform.roll = true; } - atransform.splitscreen = splitscreen; + atransform.splitscreen = r_splitscreen; gl_fovlud = (float)(1.0l/tan((double)(fpov*M_PIl/360l))); @@ -5945,7 +5945,7 @@ void HWR_RenderPlayerView(INT32 viewnumber, player_t *player) HWR_DrawSkyBackground(player); //Hurdler: it doesn't work in splitscreen mode - drawsky = splitscreen; + drawsky = r_splitscreen; HWR_ClearSprites(); diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 8e40609f5..48a952485 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -51,6 +51,7 @@ #include "lua_hud.h" #include "lua_hook.h" +// SRB2Kart #include "s_sound.h" // song credits #include "k_kart.h" #include "k_color.h" diff --git a/src/info.c b/src/info.c index a39105f1d..f6a9512b8 100644 --- a/src/info.c +++ b/src/info.c @@ -1859,7 +1859,7 @@ state_t states[NUMSTATES] = {SPR_TVIV, 2, 18, {A_Invincibility}, 0, 0, S_NULL}, // S_INVULN_ICON2 {SPR_TV1U, FF_ANIMATE|2, 18, {NULL}, 3, 4, S_1UP_ICON2}, // S_1UP_ICON1 - {SPR_TV1U, 2, 18, {A_ExtraLife}, 0, 0, S_NULL}, // S_1UP_ICON2 + {SPR_TV1U, 2, 18, {NULL}, 0, 0, S_NULL}, // S_1UP_ICON2 {SPR_TVEG, FF_ANIMATE|2, 18, {NULL}, 3, 4, S_EGGMAN_ICON2}, // S_EGGMAN_ICON1 {SPR_TVEG, 2, 18, {A_EggmanBox}, 0, 0, S_NULL}, // S_EGGMAN_ICON2 @@ -1871,7 +1871,7 @@ state_t states[NUMSTATES] = {SPR_TVGV, 2, 18, {A_GravityBox}, 0, 0, S_NULL}, // S_GRAVITY_ICON2 {SPR_TVRC, FF_ANIMATE|2, 18, {NULL}, 3, 4, S_RECYCLER_ICON2}, // S_RECYCLER_ICON1 - {SPR_TVRC, 2, 18, {A_RecyclePowers}, 0, 0, S_NULL}, // S_RECYCLER_ICON2 + {SPR_TVRC, 2, 18, {NULL}, 0, 0, S_NULL}, // S_RECYCLER_ICON2 {SPR_TV1K, FF_ANIMATE|2, 18, {NULL}, 3, 4, S_SCORE1K_ICON2}, // S_SCORE1K_ICON1 {SPR_TV1K, 2, 18, {A_AwardScore}, 0, 0, S_NULL}, // S_SCORE1K_ICON2 diff --git a/src/info.h b/src/info.h index 2e7a855a4..86540b73d 100644 --- a/src/info.h +++ b/src/info.h @@ -39,7 +39,6 @@ void A_FaceTracer(); void A_Scream(); void A_BossDeath(); void A_CustomPower(); // Use this for a custom power -void A_GiveWeapon(); // Gives the player weapon(s) void A_RingBox(); // Obtained Ring Box Tails void A_Invincibility(); // Obtained Invincibility Box void A_SuperSneakers(); // Obtained Super Sneakers Box @@ -49,7 +48,6 @@ void A_FanBubbleSpawn(); void A_BubbleRise(); // Bubbles float to surface void A_BubbleCheck(); // Don't draw if not underwater void A_AwardScore(); -void A_ExtraLife(); // Extra Life void A_GiveShield(); // Obtained Shield void A_GravityBox(); void A_ScoreRise(); // Rise the score logo @@ -82,7 +80,6 @@ void A_SmokeTrailer(); void A_RingExplode(); void A_OldRingExplode(); void A_MixUp(); -void A_RecyclePowers(); void A_BossScream(); void A_Boss2TakeDamage(); void A_GoopSplat(); diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 5146365c1..b26787c00 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -33,6 +33,9 @@ #include "d_netcmd.h" // IsPlayerAdmin #include "m_menu.h" // Player Setup menu color stuff +// SRB2Kart +#include "p_spec.h" // P_StartQuake + #include "lua_script.h" #include "lua_libs.h" #include "lua_hud.h" // hud_running errors @@ -1265,19 +1268,6 @@ static int lib_pGivePlayerLives(lua_State *L) return 0; } -static int lib_pGiveCoopLives(lua_State *L) -{ - player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); - INT32 numlives = (INT32)luaL_checkinteger(L, 2); - boolean sound = (boolean)lua_opttrueboolean(L, 3); - NOHUD - INLEVEL - if (!player) - return LUA_ErrInvalid(L, "player_t"); - P_GiveCoopLives(player, numlives, sound); - return 0; -} - static int lib_pResetScore(lua_State *L) { player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); @@ -1289,39 +1279,6 @@ static int lib_pResetScore(lua_State *L) return 0; } -static int lib_pDoJumpShield(lua_State *L) -{ - player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); - NOHUD - INLEVEL - if (!player) - return LUA_ErrInvalid(L, "player_t"); - P_DoJumpShield(player); - return 0; -} - -static int lib_pDoBubbleBounce(lua_State *L) -{ - player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); - NOHUD - INLEVEL - if (!player) - return LUA_ErrInvalid(L, "player_t"); - P_DoBubbleBounce(player); - return 0; -} - -static int lib_pBlackOw(lua_State *L) -{ - player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); - NOHUD - INLEVEL - if (!player) - return LUA_ErrInvalid(L, "player_t"); - P_BlackOw(player); - return 0; -} - static int lib_pElementalFire(lua_State *L) { player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); @@ -1358,17 +1315,6 @@ static int lib_pMovePlayer(lua_State *L) return 0; } -static int lib_pDoPlayerFinish(lua_State *L) -{ - player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); - NOHUD - INLEVEL - if (!player) - return LUA_ErrInvalid(L, "player_t"); - P_DoPlayerFinish(player); - return 0; -} - static int lib_pDoPlayerExit(lua_State *L) { player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); @@ -1445,19 +1391,6 @@ static int lib_pNukeEnemies(lua_State *L) return 0; } -static int lib_pEarthquake(lua_State *L) -{ - mobj_t *inflictor = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); - mobj_t *source = *((mobj_t **)luaL_checkudata(L, 2, META_MOBJ)); - fixed_t radius = luaL_checkfixed(L, 3); - NOHUD - INLEVEL - if (!inflictor || !source) - return LUA_ErrInvalid(L, "mobj_t"); - P_Earthquake(inflictor, source, radius); - return 0; -} - static int lib_pSwitchShield(lua_State *L) { player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); @@ -1690,18 +1623,6 @@ static int lib_pPlayerRingBurst(lua_State *L) return 0; } -static int lib_pPlayerFlagBurst(lua_State *L) -{ - player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); - boolean toss = lua_optboolean(L, 2); - NOHUD - INLEVEL - if (!player) - return LUA_ErrInvalid(L, "player_t"); - P_PlayerFlagBurst(player, toss); - return 0; -} - static int lib_pPlayRinglossSound(lua_State *L) { mobj_t *source = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); @@ -1786,28 +1707,6 @@ static int lib_pCanPickupItem(lua_State *L) return 1; } -static int lib_pDoNightsScore(lua_State *L) -{ - player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); - NOHUD - INLEVEL - if (!player) - return LUA_ErrInvalid(L, "player_t"); - P_DoNightsScore(player); - return 0; -} - -static int lib_pDoMatchSuper(lua_State *L) -{ - player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); - NOHUD - INLEVEL - if (!player) - return LUA_ErrInvalid(L, "player_t"); - P_DoMatchSuper(player); - return 0; -} - // P_SPEC //////////// @@ -1840,18 +1739,6 @@ static int lib_pSetMobjStateNF(lua_State *L) return 1; } -static int lib_pDoSuperTransformation(lua_State *L) -{ - player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); - boolean giverings = lua_optboolean(L, 2); - NOHUD - INLEVEL - if (!player) - return LUA_ErrInvalid(L, "player_t"); - P_DoSuperTransformation(player, giverings); - return 0; -} - static int lib_pExplodeMissile(lua_State *L) { mobj_t *mo = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); @@ -1871,9 +1758,9 @@ static int lib_pMobjTouchingSectorSpecial(lua_State *L) boolean touchground = lua_optboolean(L, 4); //HUDSAFE INLEVEL - if (!player) - return LUA_ErrInvalid(L, "player_t"); - LUA_PushUserdata(L, P_PlayerTouchingSectorSpecial(player, section, number), META_SECTOR); + if (!mo) + return LUA_ErrInvalid(L, "mobj_t"); + LUA_PushUserdata(L, P_MobjTouchingSectorSpecial(mo, section, number, touchground), META_SECTOR); return 1; } @@ -2678,35 +2565,6 @@ static int lib_sMusicName(lua_State *L) return 1; } -static int lib_sMusicInfo(lua_State *L) -{ - player_t *player = NULL; - NOHUD - if (!lua_isnone(L, 1) && lua_isuserdata(L, 1)) - { - player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); - if (!player) - return LUA_ErrInvalid(L, "player_t"); - } - if (!player || P_IsLocalPlayer(player)) - { - char mname[7]; - UINT16 mflags; - boolean looping; - if (S_MusicInfo(mname, &mflags, &looping)) - { - lua_pushstring(L, mname); - lua_pushinteger(L, mflags); - lua_pushboolean(L, looping); - } - else - lua_pushboolean(L, false); - } - else - lua_pushnil(L); - return 1; -} - static int lib_sMusicExists(lua_State *L) { boolean checkMIDI = lua_opttrueboolean(L, 2); @@ -2761,6 +2619,12 @@ static int lib_sSetMusicLoopPoint(lua_State *L) return 1; } +static int lib_sGetMusicLoopPoint(lua_State *L) +{ + lua_pushinteger(L, S_GetMusicLoopPoint()); + return 1; +} + static int lib_sGetMusicLength(lua_State *L) { lua_pushinteger(L, S_GetMusicLength()); @@ -3536,14 +3400,6 @@ static int lib_kLossSound(lua_State *L) // Note: Pain, Death and Victory are already exposed. -static int lib_kGetKartColorByName(lua_State *L) -{ - const char *name = luaL_checkstring(L, 1); - //HUDSAFE - lua_pushinteger(L, K_GetKartColorByName(name)); - return 1; -} - static int lib_kIsPlayerLosing(lua_State *L) { player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); @@ -4041,22 +3897,16 @@ static luaL_Reg lib[] = { {"P_SpawnGhostMobj",lib_pSpawnGhostMobj}, {"P_GivePlayerRings",lib_pGivePlayerRings}, {"P_GivePlayerLives",lib_pGivePlayerLives}, - {"P_GiveCoopLives",lib_pGiveCoopLives}, {"P_ResetScore",lib_pResetScore}, - {"P_DoJumpShield",lib_pDoJumpShield}, - {"P_DoBubbleBounce",lib_pDoBubbleBounce}, - {"P_BlackOw",lib_pBlackOw}, {"P_ElementalFire",lib_pElementalFire}, {"P_SpawnSkidDust", lib_pSpawnSkidDust}, {"P_MovePlayer",lib_pMovePlayer}, - {"P_DoPlayerFinish",lib_pDoPlayerFinish}, {"P_DoPlayerExit",lib_pDoPlayerExit}, {"P_InstaThrust",lib_pInstaThrust}, {"P_ReturnThrustX",lib_pReturnThrustX}, {"P_ReturnThrustY",lib_pReturnThrustY}, {"P_LookForEnemies",lib_pLookForEnemies}, {"P_NukeEnemies",lib_pNukeEnemies}, - {"P_Earthquake",lib_pEarthquake}, {"P_SwitchShield",lib_pSwitchShield}, // p_map @@ -4077,19 +3927,15 @@ static luaL_Reg lib[] = { {"P_DamageMobj",lib_pDamageMobj}, {"P_KillMobj",lib_pKillMobj}, {"P_PlayerRingBurst",lib_pPlayerRingBurst}, - {"P_PlayerFlagBurst",lib_pPlayerFlagBurst}, {"P_PlayRinglossSound",lib_pPlayRinglossSound}, {"P_PlayDeathSound",lib_pPlayDeathSound}, {"P_PlayVictorySound",lib_pPlayVictorySound}, {"P_PlayLivesJingle",lib_pPlayLivesJingle}, {"P_CanPickupItem",lib_pCanPickupItem}, - {"P_DoNightsScore",lib_pDoNightsScore}, - {"P_DoMatchSuper",lib_pDoMatchSuper}, // p_spec {"P_Thrust",lib_pThrust}, {"P_SetMobjStateNF",lib_pSetMobjStateNF}, - {"P_DoSuperTransformation",lib_pDoSuperTransformation}, {"P_ExplodeMissile",lib_pExplodeMissile}, {"P_MobjTouchingSectorSpecial",lib_pMobjTouchingSectorSpecial}, {"P_FindLowestFloorSurrounding",lib_pFindLowestFloorSurrounding}, @@ -4148,7 +3994,6 @@ static luaL_Reg lib[] = { {"S_MusicPlaying",lib_sMusicPlaying}, {"S_MusicPaused",lib_sMusicPaused}, {"S_MusicName",lib_sMusicName}, - {"S_MusicInfo",lib_sMusicInfo}, {"S_MusicExists",lib_sMusicExists}, {"S_GetMusicLength",lib_sGetMusicLength}, {"S_SetMusicLoopPoint",lib_sSetMusicLoopPoint}, @@ -4199,7 +4044,6 @@ static luaL_Reg lib[] = { {"K_PlayLossSound", lib_kLossSound}, {"K_PlayPainSound", lib_kPainSound}, {"K_PlayHitEmSound", lib_kHitEmSound}, - {"K_GetKartColorByName",lib_kGetKartColorByName}, {"K_IsPlayerLosing",lib_kIsPlayerLosing}, {"K_IsPlayerWanted",lib_kIsPlayerWanted}, {"K_KartBouncing",lib_kKartBouncing}, diff --git a/src/lua_hook.h b/src/lua_hook.h index 07511c8f2..306686100 100644 --- a/src/lua_hook.h +++ b/src/lua_hook.h @@ -109,9 +109,9 @@ boolean LUAh_BotAI(mobj_t *sonic, mobj_t *tails, ticcmd_t *cmd); // Hook for B_B boolean LUAh_BotRespawn(mobj_t *sonic, mobj_t *tails); // Hook for B_CheckRespawn boolean LUAh_LinedefExecute(line_t *line, mobj_t *mo, sector_t *sector); // Hook for linedef executors boolean LUAh_PlayerMsg(int source, int target, int flags, char *msg, int mute); // Hook for chat messages -boolean LUAh_HurtMsg(player_t *player, mobj_t *inflictor, mobj_t *source); // Hook for hurt messages +boolean LUAh_HurtMsg(player_t *player, mobj_t *inflictor, mobj_t *source, UINT8 damagetype); // Hook for hurt messages #define LUAh_PlayerSpawn(player) LUAh_PlayerHook(player, hook_PlayerSpawn) // Hook for G_SpawnPlayer -void LUAh_PlayerQuit(player_t *plr, int reason); // Hook for player quitting +void LUAh_PlayerQuit(player_t *plr, kickreason_t reason); // Hook for player quitting boolean LUAh_MusicChange(const char *oldname, char *newname, UINT16 *mflags, boolean *looping, UINT32 *position, UINT32 *prefadems, UINT32 *fadeinms); // Hook for music changes diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index 940446031..85a109ee0 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -527,49 +527,6 @@ void LUAh_PostThinkFrame(void) lua_pop(gL, 1); // Pop error handler } -// Hook for Y_Ticker -void LUAh_IntermissionThinker(void) -{ - hook_p hookp; - if (!gL || !(hooksAvailable[hook_IntermissionThinker/8] & (1<<(hook_IntermissionThinker%8)))) - return; - - for (hookp = roothook; hookp; hookp = hookp->next) - if (hookp->type == hook_IntermissionThinker) - { - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); - if (lua_pcall(gL, 0, 0, 0)) { - if (!hookp->error || cv_debug & DBG_LUA) - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); - hookp->error = true; - } - } -} - -// Hook for Y_VoteTicker -void LUAh_VoteThinker(void) -{ - hook_p hookp; - if (!gL || !(hooksAvailable[hook_VoteThinker/8] & (1<<(hook_VoteThinker%8)))) - return; - - for (hookp = roothook; hookp; hookp = hookp->next) - if (hookp->type == hook_VoteThinker) - { - lua_pushfstring(gL, FMT_HOOKID, hookp->id); - lua_gettable(gL, LUA_REGISTRYINDEX); - if (lua_pcall(gL, 0, 0, 0)) { - if (!hookp->error || cv_debug & DBG_LUA) - CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); - lua_pop(gL, 1); - hookp->error = true; - } - } -} - - // Hook for mobj collisions UINT8 LUAh_MobjCollideHook(mobj_t *thing1, mobj_t *thing2, enum hook which) { @@ -1384,10 +1341,10 @@ boolean LUAh_PlayerMsg(int source, int target, int flags, char *msg, int mute) hooked = true; lua_pop(gL, 1); } - - lua_settop(gL, 0); - return hooked; } + + lua_settop(gL, 0); + return hooked; } // Hook for hurt messages @@ -2218,6 +2175,27 @@ boolean LUAh_PlayerExplode(player_t *player, mobj_t *inflictor, mobj_t *source) return hooked; } +// Hook for Y_VoteTicker +void LUAh_VoteThinker(void) +{ + hook_p hookp; + if (!gL || !(hooksAvailable[hook_VoteThinker/8] & (1<<(hook_VoteThinker%8)))) + return; + + for (hookp = roothook; hookp; hookp = hookp->next) + if (hookp->type == hook_VoteThinker) + { + lua_pushfstring(gL, FMT_HOOKID, hookp->id); + lua_gettable(gL, LUA_REGISTRYINDEX); + if (lua_pcall(gL, 0, 0, 0)) { + if (!hookp->error || cv_debug & DBG_LUA) + CONS_Alert(CONS_WARNING,"%s\n",lua_tostring(gL, -1)); + lua_pop(gL, 1); + hookp->error = true; + } + } +} + // Hook for game quitting void LUAh_GameQuit(void) { diff --git a/src/lua_hudlib.c b/src/lua_hudlib.c index f83d11ee9..cacb1b411 100644 --- a/src/lua_hudlib.c +++ b/src/lua_hudlib.c @@ -114,25 +114,10 @@ enum align { align_left = 0, align_center, align_right, - align_fixed, - align_fixedcenter, - align_fixedright, align_small, - align_smallfixed, - align_smallfixedcenter, - align_smallfixedright, align_smallcenter, align_smallright, - align_smallthin, - align_smallthincenter, - align_smallthinright, - align_smallthinfixed, - align_smallthinfixedcenter, - align_smallthinfixedright, align_thin, - align_thinfixed, - align_thinfixedcenter, - align_thinfixedright, align_thincenter, align_thinright }; @@ -140,25 +125,10 @@ static const char *const align_opt[] = { "left", "center", "right", - "fixed", - "fixed-center", - "fixed-right", "small", - "small-fixed", - "small-fixed-center", - "small-fixed-right", "small-center", "small-right", - "small-thin", - "small-thin-center", - "small-thin-right", - "small-thin-fixed", - "small-thin-fixed-center", - "small-thin-fixed-right", "thin", - "thin-fixed", - "thin-fixed-center", - "thin-fixed-right", "thin-center", "thin-right", NULL}; @@ -1029,52 +999,16 @@ static int libd_drawString(lua_State *L) case align_right: V_DrawRightAlignedString(x, y, flags, str); break; - case align_fixed: - V_DrawStringAtFixed(x, y, flags, str); - break; - case align_fixedcenter: - V_DrawCenteredStringAtFixed(x, y, flags, str); - break; - case align_fixedright: - V_DrawRightAlignedStringAtFixed(x, y, flags, str); - break; // hu_font, 0.5x scale case align_small: V_DrawSmallString(x, y, flags, str); break; - case align_smallfixed: - V_DrawSmallStringAtFixed(x, y, flags, str); - break; - case align_smallfixedcenter: - V_DrawCenteredSmallStringAtFixed(x, y, flags, str); - break; - case align_smallfixedright: - V_DrawRightAlignedSmallStringAtFixed(x, y, flags, str); - break; case align_smallcenter: V_DrawCenteredSmallString(x, y, flags, str); break; case align_smallright: V_DrawRightAlignedSmallString(x, y, flags, str); break; - case align_smallthin: - V_DrawSmallThinString(x, y, flags, str); - break; - case align_smallthincenter: - V_DrawCenteredSmallThinString(x, y, flags, str); - break; - case align_smallthinright: - V_DrawRightAlignedSmallThinString(x, y, flags, str); - break; - case align_smallthinfixed: - V_DrawSmallThinStringAtFixed(x, y, flags, str); - break; - case align_smallthinfixedcenter: - V_DrawCenteredSmallThinStringAtFixed(x, y, flags, str); - break; - case align_smallthinfixedright: - V_DrawRightAlignedSmallThinStringAtFixed(x, y, flags, str); - break; // tny_font case align_thin: V_DrawThinString(x, y, flags, str); @@ -1085,81 +1019,10 @@ static int libd_drawString(lua_State *L) case align_thinright: V_DrawRightAlignedThinString(x, y, flags, str); break; - case align_thinfixed: - V_DrawThinStringAtFixed(x, y, flags, str); - break; - case align_thinfixedcenter: - V_DrawCenteredThinStringAtFixed(x, y, flags, str); - break; - case align_thinfixedright: - V_DrawRightAlignedThinStringAtFixed(x, y, flags, str); - break; } return 0; } -static int libd_drawNameTag(lua_State *L) -{ - INT32 x; - INT32 y; - const char *str; - INT32 flags; - UINT16 basecolor; - UINT16 outlinecolor; - UINT8 *basecolormap = NULL; - UINT8 *outlinecolormap = NULL; - - HUDONLY - - x = luaL_checkinteger(L, 1); - y = luaL_checkinteger(L, 2); - str = luaL_checkstring(L, 3); - flags = luaL_optinteger(L, 4, 0); - basecolor = luaL_optinteger(L, 5, SKINCOLOR_BLUE); - outlinecolor = luaL_optinteger(L, 6, SKINCOLOR_ORANGE); - if (basecolor != SKINCOLOR_NONE) - basecolormap = R_GetTranslationColormap(TC_DEFAULT, basecolor, GTC_CACHE); - if (outlinecolor != SKINCOLOR_NONE) - outlinecolormap = R_GetTranslationColormap(TC_DEFAULT, outlinecolor, GTC_CACHE); - - flags &= ~V_PARAMMASK; // Don't let crashes happen. - V_DrawNameTag(x, y, flags, FRACUNIT, basecolormap, outlinecolormap, str); - return 0; -} - -static int libd_drawScaledNameTag(lua_State *L) -{ - fixed_t x; - fixed_t y; - const char *str; - INT32 flags; - fixed_t scale; - UINT16 basecolor; - UINT16 outlinecolor; - UINT8 *basecolormap = NULL; - UINT8 *outlinecolormap = NULL; - - HUDONLY - - x = luaL_checkfixed(L, 1); - y = luaL_checkfixed(L, 2); - str = luaL_checkstring(L, 3); - flags = luaL_optinteger(L, 4, 0); - scale = luaL_optinteger(L, 5, FRACUNIT); - if (scale < 0) - return luaL_error(L, "negative scale"); - basecolor = luaL_optinteger(L, 6, SKINCOLOR_BLUE); - outlinecolor = luaL_optinteger(L, 7, SKINCOLOR_ORANGE); - if (basecolor != SKINCOLOR_NONE) - basecolormap = R_GetTranslationColormap(TC_DEFAULT, basecolor, GTC_CACHE); - if (outlinecolor != SKINCOLOR_NONE) - outlinecolormap = R_GetTranslationColormap(TC_DEFAULT, outlinecolor, GTC_CACHE); - - flags &= ~V_PARAMMASK; // Don't let crashes happen. - V_DrawNameTag(FixedInt(x), FixedInt(y), flags, scale, basecolormap, outlinecolormap, str); - return 0; -} - static int libd_drawKartString(lua_State *L) { fixed_t x = luaL_checkinteger(L, 1); @@ -1196,13 +1059,6 @@ static int libd_stringWidth(lua_State *L) return 1; } -static int libd_nameTagWidth(lua_State *L) -{ - HUDONLY - lua_pushinteger(L, V_NameTagWidth(luaL_checkstring(L, 1))); - return 1; -} - static int libd_getColormap(lua_State *L) { INT32 skinnum = TC_DEFAULT; @@ -1368,12 +1224,9 @@ static luaL_Reg lib_draw[] = { {"drawFill", libd_drawFill}, {"fadeScreen", libd_fadeScreen}, {"drawString", libd_drawString}, - {"drawNameTag", libd_drawNameTag}, - {"drawScaledNameTag", libd_drawScaledNameTag}, {"drawKartString", libd_drawKartString}, // misc {"stringWidth", libd_stringWidth}, - {"nameTagWidth", libd_nameTagWidth}, // m_random {"RandomFixed",libd_RandomFixed}, {"RandomByte",libd_RandomByte}, diff --git a/src/lua_playerlib.c b/src/lua_playerlib.c index 3d6d58788..c0e5c4030 100644 --- a/src/lua_playerlib.c +++ b/src/lua_playerlib.c @@ -229,10 +229,6 @@ static int player_get(lua_State *L) lua_pushinteger(L, plr->skincolor); else if (fastcmp(field,"score")) lua_pushinteger(L, plr->score); - else if (fastcmp(field,"dashspeed")) - lua_pushfixed(L, plr->dashspeed); - else if (fastcmp(field,"dashtime")) - lua_pushinteger(L, plr->dashtime); // SRB2kart else if (fastcmp(field,"kartspeed")) lua_pushinteger(L, plr->kartspeed); @@ -500,10 +496,6 @@ static int player_set(lua_State *L) } else if (fastcmp(field,"score")) plr->score = (UINT32)luaL_checkinteger(L, 3); - else if (fastcmp(field,"dashspeed")) - plr->dashspeed = luaL_checkfixed(L, 3); - else if (fastcmp(field,"dashtime")) - plr->dashtime = (INT32)luaL_checkinteger(L, 3); // SRB2kart else if (fastcmp(field,"kartstuff")) return NOSET; diff --git a/src/lua_script.c b/src/lua_script.c index f8c233a54..b7d776b1e 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -280,20 +280,17 @@ int LUA_PushGlobals(lua_State *L, const char *word) } else if (fastcmp(word,"leveltime")) { lua_pushinteger(L, leveltime); return 1; - } else if (fastcmp(word,"sstimer")) { - lua_pushinteger(L, sstimer); - return 1; } else if (fastcmp(word,"curWeather")) { lua_pushinteger(L, curWeather); return 1; } else if (fastcmp(word,"globalweather")) { lua_pushinteger(L, globalweather); return 1; - } else if (fastcmp(word,"levelskynum")) { - lua_pushinteger(L, levelskynum); + } else if (fastcmp(word,"levelskytexture")) { + lua_pushstring(L, levelskytexture); return 1; - } else if (fastcmp(word,"globallevelskynum")) { - lua_pushinteger(L, globallevelskynum); + } else if (fastcmp(word,"globallevelskytexture")) { + lua_pushstring(L, globallevelskytexture); return 1; } else if (fastcmp(word,"mapmusname")) { lua_pushstring(L, mapmusname); @@ -310,16 +307,6 @@ int LUA_PushGlobals(lua_State *L, const char *word) return 0; LUA_PushUserdata(L, &players[consoleplayer], META_PLAYER); return 1; - } else if (fastcmp(word,"displayplayer")) { // player visible on screen (aka display player 1) - if (displayplayers[0] < 0 || !playeringame[displayplayers[0]]) - return 0; - LUA_PushUserdata(L, &players[displayplayers[0]], META_PLAYER); - return 1; - } else if (fastcmp(word,"secondarydisplayplayer")) { // local/display player 2, for splitscreen - if (splitscreen < 1 || displayplayers[1] < 0 || !playeringame[displayplayers[1]]) - return 0; - LUA_PushUserdata(L, &players[displayplayers[1]], META_PLAYER); - return 1; } else if (fastcmp(word,"isserver")) { lua_pushboolean(L, server); return 1; @@ -332,9 +319,6 @@ int LUA_PushGlobals(lua_State *L, const char *word) return 0; LUA_PushUserdata(L, &players[serverplayer], META_PLAYER); return 1; - } else if (fastcmp(word,"emeralds")) { - lua_pushinteger(L, emeralds); - return 1; } else if (fastcmp(word,"gravity")) { lua_pushinteger(L, gravity); return 1; @@ -355,7 +339,7 @@ int LUA_PushGlobals(lua_State *L, const char *word) } // See the above. -int LUA_CheckGlobals(lua_State *L, const char *word) +int LUA_WriteGlobals(lua_State *L, const char *word) { if (fastcmp(word, "redscore")) redscore = (UINT32)luaL_checkinteger(L, 2); @@ -395,7 +379,7 @@ static int setglobals(lua_State *L) return 0; } - if (LUA_CheckGlobals(L, csname)) + if (LUA_WriteGlobals(L, csname)) return 0; Z_Free(name); @@ -879,7 +863,7 @@ static UINT8 GetUserdataArchType(int index) return ARCH_NULL; } -static UINT8 ArchiveValue(int TABLESINDEX, int myindex) +static UINT8 ArchiveValue(UINT8 *p, int TABLESINDEX, int myindex) { if (myindex < 0) myindex = lua_gettop(gL)+1+myindex; @@ -887,34 +871,34 @@ static UINT8 ArchiveValue(int TABLESINDEX, int myindex) { case LUA_TNONE: case LUA_TNIL: - WRITEUINT8(save_p, ARCH_NULL); + WRITEUINT8(p, ARCH_NULL); break; // This might be a problem. D: case LUA_TLIGHTUSERDATA: case LUA_TTHREAD: case LUA_TFUNCTION: - WRITEUINT8(save_p, ARCH_NULL); + WRITEUINT8(p, ARCH_NULL); return 2; case LUA_TBOOLEAN: - WRITEUINT8(save_p, lua_toboolean(gL, myindex) ? ARCH_TRUE : ARCH_FALSE); + WRITEUINT8(p, lua_toboolean(gL, myindex) ? ARCH_TRUE : ARCH_FALSE); break; case LUA_TNUMBER: { lua_Integer number = lua_tointeger(gL, myindex); if (number >= INT8_MIN && number <= INT8_MAX) { - WRITEUINT8(save_p, ARCH_INT8); - WRITESINT8(save_p, number); + WRITEUINT8(p, ARCH_INT8); + WRITESINT8(p, number); } else if (number >= INT16_MIN && number <= INT16_MAX) { - WRITEUINT8(save_p, ARCH_INT16); - WRITEINT16(save_p, number); + WRITEUINT8(p, ARCH_INT16); + WRITEINT16(p, number); } else { - WRITEUINT8(save_p, ARCH_INT32); - WRITEFIXED(save_p, number); + WRITEUINT8(p, ARCH_INT32); + WRITEFIXED(p, number); } break; } @@ -932,16 +916,16 @@ static UINT8 ArchiveValue(int TABLESINDEX, int myindex) // -- Monster Iestyn 05/08/18 if (len < 255) { - WRITEUINT8(save_p, ARCH_SMALLSTRING); - WRITEUINT8(save_p, len); // save size of string + WRITEUINT8(p, ARCH_SMALLSTRING); + WRITEUINT8(p, len); // save size of string } else { - WRITEUINT8(save_p, ARCH_LARGESTRING); - WRITEUINT32(save_p, len); // save size of string + WRITEUINT8(p, ARCH_LARGESTRING); + WRITEUINT32(p, len); // save size of string } while (i < len) - WRITECHAR(save_p, s[i++]); // write chars individually, including the embedded zeros + WRITECHAR(p, s[i++]); // write chars individually, including the embedded zeros break; } case LUA_TTABLE: @@ -963,8 +947,8 @@ static UINT8 ArchiveValue(int TABLESINDEX, int myindex) if (!found) t++; - WRITEUINT8(save_p, ARCH_TABLE); - WRITEUINT16(save_p, t); + WRITEUINT8(p, ARCH_TABLE); + WRITEUINT16(p, t); if (!found) { @@ -980,25 +964,25 @@ static UINT8 ArchiveValue(int TABLESINDEX, int myindex) case ARCH_MOBJINFO: { mobjinfo_t *info = *((mobjinfo_t **)lua_touserdata(gL, myindex)); - WRITEUINT8(save_p, ARCH_MOBJINFO); - WRITEUINT16(save_p, info - mobjinfo); + WRITEUINT8(p, ARCH_MOBJINFO); + WRITEUINT16(p, info - mobjinfo); break; } case ARCH_STATE: { state_t *state = *((state_t **)lua_touserdata(gL, myindex)); - WRITEUINT8(save_p, ARCH_STATE); - WRITEUINT16(save_p, state - states); + WRITEUINT8(p, ARCH_STATE); + WRITEUINT16(p, state - states); break; } case ARCH_MOBJ: { mobj_t *mobj = *((mobj_t **)lua_touserdata(gL, myindex)); if (!mobj) - WRITEUINT8(save_p, ARCH_NULL); + WRITEUINT8(p, ARCH_NULL); else { - WRITEUINT8(save_p, ARCH_MOBJ); - WRITEUINT32(save_p, mobj->mobjnum); + WRITEUINT8(p, ARCH_MOBJ); + WRITEUINT32(p, mobj->mobjnum); } break; } @@ -1006,10 +990,10 @@ static UINT8 ArchiveValue(int TABLESINDEX, int myindex) { player_t *player = *((player_t **)lua_touserdata(gL, myindex)); if (!player) - WRITEUINT8(save_p, ARCH_NULL); + WRITEUINT8(p, ARCH_NULL); else { - WRITEUINT8(save_p, ARCH_PLAYER); - WRITEUINT8(save_p, player - players); + WRITEUINT8(p, ARCH_PLAYER); + WRITEUINT8(p, player - players); } break; } @@ -1017,10 +1001,10 @@ static UINT8 ArchiveValue(int TABLESINDEX, int myindex) { mapthing_t *mapthing = *((mapthing_t **)lua_touserdata(gL, myindex)); if (!mapthing) - WRITEUINT8(save_p, ARCH_NULL); + WRITEUINT8(p, ARCH_NULL); else { - WRITEUINT8(save_p, ARCH_MAPTHING); - WRITEUINT16(save_p, mapthing - mapthings); + WRITEUINT8(p, ARCH_MAPTHING); + WRITEUINT16(p, mapthing - mapthings); } break; } @@ -1028,10 +1012,10 @@ static UINT8 ArchiveValue(int TABLESINDEX, int myindex) { vertex_t *vertex = *((vertex_t **)lua_touserdata(gL, myindex)); if (!vertex) - WRITEUINT8(save_p, ARCH_NULL); + WRITEUINT8(p, ARCH_NULL); else { - WRITEUINT8(save_p, ARCH_VERTEX); - WRITEUINT16(save_p, vertex - vertexes); + WRITEUINT8(p, ARCH_VERTEX); + WRITEUINT16(p, vertex - vertexes); } break; } @@ -1039,10 +1023,10 @@ static UINT8 ArchiveValue(int TABLESINDEX, int myindex) { line_t *line = *((line_t **)lua_touserdata(gL, myindex)); if (!line) - WRITEUINT8(save_p, ARCH_NULL); + WRITEUINT8(p, ARCH_NULL); else { - WRITEUINT8(save_p, ARCH_LINE); - WRITEUINT16(save_p, line - lines); + WRITEUINT8(p, ARCH_LINE); + WRITEUINT16(p, line - lines); } break; } @@ -1050,10 +1034,10 @@ static UINT8 ArchiveValue(int TABLESINDEX, int myindex) { side_t *side = *((side_t **)lua_touserdata(gL, myindex)); if (!side) - WRITEUINT8(save_p, ARCH_NULL); + WRITEUINT8(p, ARCH_NULL); else { - WRITEUINT8(save_p, ARCH_SIDE); - WRITEUINT16(save_p, side - sides); + WRITEUINT8(p, ARCH_SIDE); + WRITEUINT16(p, side - sides); } break; } @@ -1061,10 +1045,10 @@ static UINT8 ArchiveValue(int TABLESINDEX, int myindex) { subsector_t *subsector = *((subsector_t **)lua_touserdata(gL, myindex)); if (!subsector) - WRITEUINT8(save_p, ARCH_NULL); + WRITEUINT8(p, ARCH_NULL); else { - WRITEUINT8(save_p, ARCH_SUBSECTOR); - WRITEUINT16(save_p, subsector - subsectors); + WRITEUINT8(p, ARCH_SUBSECTOR); + WRITEUINT16(p, subsector - subsectors); } break; } @@ -1072,10 +1056,10 @@ static UINT8 ArchiveValue(int TABLESINDEX, int myindex) { sector_t *sector = *((sector_t **)lua_touserdata(gL, myindex)); if (!sector) - WRITEUINT8(save_p, ARCH_NULL); + WRITEUINT8(p, ARCH_NULL); else { - WRITEUINT8(save_p, ARCH_SECTOR); - WRITEUINT16(save_p, sector - sectors); + WRITEUINT8(p, ARCH_SECTOR); + WRITEUINT16(p, sector - sectors); } break; } @@ -1084,10 +1068,10 @@ static UINT8 ArchiveValue(int TABLESINDEX, int myindex) { seg_t *seg = *((seg_t **)lua_touserdata(gL, myindex)); if (!seg) - WRITEUINT8(save_p, ARCH_NULL); + WRITEUINT8(p, ARCH_NULL); else { - WRITEUINT8(save_p, ARCH_SEG); - WRITEUINT16(save_p, seg - segs); + WRITEUINT8(p, ARCH_SEG); + WRITEUINT16(p, seg - segs); } break; } @@ -1095,10 +1079,10 @@ static UINT8 ArchiveValue(int TABLESINDEX, int myindex) { node_t *node = *((node_t **)lua_touserdata(gL, myindex)); if (!node) - WRITEUINT8(save_p, ARCH_NULL); + WRITEUINT8(p, ARCH_NULL); else { - WRITEUINT8(save_p, ARCH_NODE); - WRITEUINT16(save_p, node - nodes); + WRITEUINT8(p, ARCH_NODE); + WRITEUINT16(p, node - nodes); } break; } @@ -1107,16 +1091,16 @@ static UINT8 ArchiveValue(int TABLESINDEX, int myindex) { ffloor_t *rover = *((ffloor_t **)lua_touserdata(gL, myindex)); if (!rover) - WRITEUINT8(save_p, ARCH_NULL); + WRITEUINT8(p, ARCH_NULL); else { UINT16 i = P_GetFFloorID(rover); if (i == UINT16_MAX) // invalid ID - WRITEUINT8(save_p, ARCH_NULL); + WRITEUINT8(p, ARCH_NULL); else { - WRITEUINT8(save_p, ARCH_FFLOOR); - WRITEUINT16(save_p, rover->target - sectors); - WRITEUINT16(save_p, i); + WRITEUINT8(p, ARCH_FFLOOR); + WRITEUINT16(p, rover->target - sectors); + WRITEUINT16(p, i); } } break; @@ -1125,10 +1109,10 @@ static UINT8 ArchiveValue(int TABLESINDEX, int myindex) { pslope_t *slope = *((pslope_t **)lua_touserdata(gL, myindex)); if (!slope) - WRITEUINT8(save_p, ARCH_NULL); + WRITEUINT8(p, ARCH_NULL); else { - WRITEUINT8(save_p, ARCH_SLOPE); - WRITEUINT16(save_p, slope->id); + WRITEUINT8(p, ARCH_SLOPE); + WRITEUINT16(p, slope->id); } break; } @@ -1136,10 +1120,10 @@ static UINT8 ArchiveValue(int TABLESINDEX, int myindex) { mapheader_t *header = *((mapheader_t **)lua_touserdata(gL, myindex)); if (!header) - WRITEUINT8(save_p, ARCH_NULL); + WRITEUINT8(p, ARCH_NULL); else { - WRITEUINT8(save_p, ARCH_MAPHEADER); - WRITEUINT16(save_p, header - *mapheaderinfo); + WRITEUINT8(p, ARCH_MAPHEADER); + WRITEUINT16(p, header - *mapheaderinfo); } break; } @@ -1147,12 +1131,12 @@ static UINT8 ArchiveValue(int TABLESINDEX, int myindex) case ARCH_SKINCOLOR: { skincolor_t *info = *((skincolor_t **)lua_touserdata(gL, myindex)); - WRITEUINT8(save_p, ARCH_SKINCOLOR); - WRITEUINT16(save_p, info - skincolors); + WRITEUINT8(p, ARCH_SKINCOLOR); + WRITEUINT16(p, info - skincolors); break; } default: - WRITEUINT8(save_p, ARCH_NULL); + WRITEUINT8(p, ARCH_NULL); return 2; } break; @@ -1160,226 +1144,14 @@ static UINT8 ArchiveValue(int TABLESINDEX, int myindex) return 0; } -// because of how this function works it has to be pasted allll over again just to save to demo_p since it returns an uint8 to begin with -static UINT8 ArchiveValueDemo(int TABLESINDEX, int myindex) -{ - if (myindex < 0) - myindex = lua_gettop(gL)+1+myindex; - switch (lua_type(gL, myindex)) - { - case LUA_TNONE: - case LUA_TNIL: - WRITEUINT8(demo_p, ARCH_NULL); - break; - // This might be a problem. D: - case LUA_TLIGHTUSERDATA: - case LUA_TTHREAD: - case LUA_TFUNCTION: - WRITEUINT8(demo_p, ARCH_NULL); - return 2; - case LUA_TBOOLEAN: - WRITEUINT8(demo_p, ARCH_BOOLEAN); - WRITEUINT8(demo_p, lua_toboolean(gL, myindex)); - break; - case LUA_TNUMBER: - { - lua_Integer number = lua_tointeger(gL, myindex); - WRITEUINT8(demo_p, ARCH_SIGNED); - WRITEFIXED(demo_p, number); - break; - } - case LUA_TSTRING: - { - UINT16 len = (UINT16)lua_objlen(gL, myindex); // get length of string, including embedded zeros - const char *s = lua_tostring(gL, myindex); - UINT16 i = 0; - WRITEUINT8(demo_p, ARCH_STRING); - // if you're wondering why we're writing a string to demo_p this way, - // it turns out that Lua can have embedded zeros ('\0') in the strings, - // so we can't use WRITESTRING as that cuts off when it finds a '\0'. - // Saving the size of the string also allows us to get the size of the string on the other end, - // fixing the awful crashes previously encountered for reading strings longer than 1024 - // (yes I know that's kind of a stupid thing to care about, but it'd be evil to trim or ignore them?) - // -- Monster Iestyn 05/08/18 - WRITEUINT16(demo_p, len); // save size of string - while (i < len) - WRITECHAR(demo_p, s[i++]); // write chars individually, including the embedded zeros - break; - } - case LUA_TTABLE: - { - boolean found = false; - INT32 i; - UINT16 t = (UINT16)lua_objlen(gL, TABLESINDEX); - - for (i = 1; i <= t && !found; i++) - { - lua_rawgeti(gL, TABLESINDEX, i); - if (lua_rawequal(gL, myindex, -1)) - { - t = i; - found = true; - } - lua_pop(gL, 1); - } - if (!found) - t++; - - WRITEUINT8(demo_p, ARCH_TABLE); - WRITEUINT16(demo_p, t); - - if (!found) - { - lua_pushvalue(gL, myindex); - lua_rawseti(gL, TABLESINDEX, t); - return 1; - } - break; - } - case LUA_TUSERDATA: - switch (GetUserdataArchType(myindex)) - { - case ARCH_MOBJINFO: - { - mobjinfo_t *info = *((mobjinfo_t **)lua_touserdata(gL, myindex)); - WRITEUINT8(demo_p, ARCH_MOBJINFO); - WRITEUINT16(demo_p, info - mobjinfo); - break; - } - case ARCH_STATE: - { - state_t *state = *((state_t **)lua_touserdata(gL, myindex)); - WRITEUINT8(demo_p, ARCH_STATE); - WRITEUINT16(demo_p, state - states); - break; - } - case ARCH_MOBJ: - { - mobj_t *mobj = *((mobj_t **)lua_touserdata(gL, myindex)); - if (!mobj) - WRITEUINT8(demo_p, ARCH_NULL); - else { - WRITEUINT8(demo_p, ARCH_MOBJ); - WRITEUINT32(demo_p, mobj->mobjnum); - } - break; - } - case ARCH_PLAYER: - { - player_t *player = *((player_t **)lua_touserdata(gL, myindex)); - if (!player) - WRITEUINT8(demo_p, ARCH_NULL); - else { - WRITEUINT8(demo_p, ARCH_PLAYER); - WRITEUINT8(demo_p, player - players); - } - break; - } - case ARCH_MAPTHING: - { - mapthing_t *mapthing = *((mapthing_t **)lua_touserdata(gL, myindex)); - if (!mapthing) - WRITEUINT8(demo_p, ARCH_NULL); - else { - WRITEUINT8(demo_p, ARCH_MAPTHING); - WRITEUINT16(demo_p, mapthing - mapthings); - } - break; - } - case ARCH_VERTEX: - { - vertex_t *vertex = *((vertex_t **)lua_touserdata(gL, myindex)); - if (!vertex) - WRITEUINT8(demo_p, ARCH_NULL); - else { - WRITEUINT8(demo_p, ARCH_VERTEX); - WRITEUINT16(demo_p, vertex - vertexes); - } - break; - } - case ARCH_LINE: - { - line_t *line = *((line_t **)lua_touserdata(gL, myindex)); - if (!line) - WRITEUINT8(demo_p, ARCH_NULL); - else { - WRITEUINT8(demo_p, ARCH_LINE); - WRITEUINT16(demo_p, line - lines); - } - break; - } - case ARCH_SIDE: - { - side_t *side = *((side_t **)lua_touserdata(gL, myindex)); - if (!side) - WRITEUINT8(demo_p, ARCH_NULL); - else { - WRITEUINT8(demo_p, ARCH_SIDE); - WRITEUINT16(demo_p, side - sides); - } - break; - } - case ARCH_SUBSECTOR: - { - subsector_t *subsector = *((subsector_t **)lua_touserdata(gL, myindex)); - if (!subsector) - WRITEUINT8(demo_p, ARCH_NULL); - else { - WRITEUINT8(demo_p, ARCH_SUBSECTOR); - WRITEUINT16(demo_p, subsector - subsectors); - } - break; - } - case ARCH_SECTOR: - { - sector_t *sector = *((sector_t **)lua_touserdata(gL, myindex)); - if (!sector) - WRITEUINT8(demo_p, ARCH_NULL); - else { - WRITEUINT8(demo_p, ARCH_SECTOR); - WRITEUINT16(demo_p, sector - sectors); - } - break; - } - case ARCH_SLOPE: - { - pslope_t *slope = *((pslope_t **)lua_touserdata(gL, myindex)); - if (!slope) - WRITEUINT8(demo_p, ARCH_NULL); - else { - WRITEUINT8(demo_p, ARCH_SLOPE); - WRITEUINT16(demo_p, slope->id); - } - break; - } - case ARCH_MAPHEADER: - { - mapheader_t *header = *((mapheader_t **)lua_touserdata(gL, myindex)); - if (!header) - WRITEUINT8(demo_p, ARCH_NULL); - else { - WRITEUINT8(demo_p, ARCH_MAPHEADER); - WRITEUINT16(demo_p, header - *mapheaderinfo); - } - break; - } - default: - WRITEUINT8(demo_p, ARCH_NULL); - return 2; - } - break; - } - return 0; -} - -static void ArchiveExtVars(void *pointer, const char *ptype) +static void ArchiveExtVars(UINT8 *p, void *pointer, const char *ptype) { int TABLESINDEX; UINT16 i; if (!gL) { if (fastcmp(ptype,"player")) // players must always be included, even if no vars - WRITEUINT16(save_p, 0); + WRITEUINT16(p, 0); return; } @@ -1395,7 +1167,7 @@ static void ArchiveExtVars(void *pointer, const char *ptype) { // no extra values table lua_pop(gL, 1); if (fastcmp(ptype,"player")) // players must always be included, even if no vars - WRITEUINT16(save_p, 0); + WRITEUINT16(p, 0); return; } @@ -1407,77 +1179,20 @@ static void ArchiveExtVars(void *pointer, const char *ptype) if (i == 0) { if (fastcmp(ptype,"player")) // always include players even if they have no extra variables - WRITEUINT16(save_p, 0); + WRITEUINT16(p, 0); lua_pop(gL, 1); return; } if (fastcmp(ptype,"mobj")) // mobjs must write their mobjnum as a header - WRITEUINT32(save_p, ((mobj_t *)pointer)->mobjnum); - WRITEUINT16(save_p, i); + WRITEUINT32(p, ((mobj_t *)pointer)->mobjnum); + WRITEUINT16(p, i); lua_pushnil(gL); while (lua_next(gL, -2)) { I_Assert(lua_type(gL, -2) == LUA_TSTRING); - WRITESTRING(save_p, lua_tostring(gL, -2)); - if (ArchiveValue(TABLESINDEX, -1) == 2) - CONS_Alert(CONS_ERROR, "Type of value for %s entry '%s' (%s) could not be archived!\n", ptype, lua_tostring(gL, -2), luaL_typename(gL, -1)); - lua_pop(gL, 1); - } - - lua_pop(gL, 1); -} - -// simplified for demos -static void ArchiveExtVarsDemo(void *pointer, const char *ptype) -{ - int TABLESINDEX; - UINT16 i; - - if (!gL) { - if (fastcmp(ptype,"player")) // players must always be included, even if no vars - WRITEUINT16(demo_p, 0); - return; - } - - TABLESINDEX = lua_gettop(gL); - - lua_getfield(gL, LUA_REGISTRYINDEX, LREG_EXTVARS); - I_Assert(lua_istable(gL, -1)); - lua_pushlightuserdata(gL, pointer); - lua_rawget(gL, -2); - lua_remove(gL, -2); // pop LREG_EXTVARS - - if (!lua_istable(gL, -1)) - { // no extra values table - lua_pop(gL, 1); - if (fastcmp(ptype,"player")) // players must always be included, even if no vars - WRITEUINT16(demo_p, 0); - return; - } - - lua_pushnil(gL); - for (i = 0; lua_next(gL, -2); i++) - lua_pop(gL, 1); - - // skip anything that has an empty table and isn't a player. - if (i == 0) - { - if (fastcmp(ptype,"player")) // always include players even if they have no extra variables - WRITEUINT16(demo_p, 0); - lua_pop(gL, 1); - return; - } - - if (fastcmp(ptype,"mobj")) // mobjs must write their mobjnum as a header - WRITEUINT32(demo_p, ((mobj_t *)pointer)->mobjnum); - WRITEUINT16(demo_p, i); - lua_pushnil(gL); - while (lua_next(gL, -2)) - { - I_Assert(lua_type(gL, -2) == LUA_TSTRING); - WRITESTRING(demo_p, lua_tostring(gL, -2)); - if (ArchiveValueDemo(TABLESINDEX, -1) == 2) + WRITESTRING(p, lua_tostring(gL, -2)); + if (ArchiveValue(p, TABLESINDEX, -1) == 2) CONS_Alert(CONS_ERROR, "Type of value for %s entry '%s' (%s) could not be archived!\n", ptype, lua_tostring(gL, -2), luaL_typename(gL, -1)); lua_pop(gL, 1); } @@ -1490,11 +1205,11 @@ static int NetArchive(lua_State *L) int TABLESINDEX = lua_upvalueindex(1); int i, n = lua_gettop(L); for (i = 1; i <= n; i++) - ArchiveValue(TABLESINDEX, i); + ArchiveValue(save_p, TABLESINDEX, i); return n; } -static void ArchiveTables(void) +static void ArchiveTables(UINT8 *p) { int TABLESINDEX; UINT16 i, n; @@ -1513,7 +1228,7 @@ static void ArchiveTables(void) while (lua_next(gL, -2)) { // Write key - e = ArchiveValue(TABLESINDEX, -2); // key should be either a number or a string, ArchiveValue can handle this. + e = ArchiveValue(p, TABLESINDEX, -2); // key should be either a number or a string, ArchiveValue can handle this. if (e == 2) // invalid key type (function, thread, lightuserdata, or anything we don't recognise) { lua_pushvalue(gL, -2); @@ -1521,7 +1236,7 @@ static void ArchiveTables(void) lua_pop(gL, 1); } // Write value - e = ArchiveValue(TABLESINDEX, -1); + e = ArchiveValue(p, TABLESINDEX, -1); if (e == 1) n++; // the table contained a new table we'll have to archive. :( else if (e == 2) // invalid value type @@ -1534,57 +1249,13 @@ static void ArchiveTables(void) lua_pop(gL, 1); } lua_pop(gL, 1); - WRITEUINT8(save_p, ARCH_TEND); + WRITEUINT8(p, ARCH_TEND); } } -static void ArchiveTablesDemo(void) +static UINT8 UnArchiveValue(UINT8 *p, int TABLESINDEX) { - int TABLESINDEX; - UINT16 i, n; - UINT8 e; - - if (!gL) - return; - - TABLESINDEX = lua_gettop(gL); - - n = (UINT16)lua_objlen(gL, TABLESINDEX); - for (i = 1; i <= n; i++) - { - lua_rawgeti(gL, TABLESINDEX, i); - lua_pushnil(gL); - while (lua_next(gL, -2)) - { - // Write key - e = ArchiveValueDemo(TABLESINDEX, -2); // key should be either a number or a string, ArchiveValue can handle this. - if (e == 2) // invalid key type (function, thread, lightuserdata, or anything we don't recognise) - { - lua_pushvalue(gL, -2); - CONS_Alert(CONS_ERROR, "Index '%s' (%s) of table %d could not be archived!\n", lua_tostring(gL, -1), luaL_typename(gL, -1), i); - lua_pop(gL, 1); - } - // Write value - e = ArchiveValueDemo(TABLESINDEX, -1); - if (e == 1) - n++; // the table contained a new table we'll have to archive. :( - else if (e == 2) // invalid value type - { - lua_pushvalue(gL, -2); - CONS_Alert(CONS_ERROR, "Type of value for table %d entry '%s' (%s) could not be archived!\n", i, lua_tostring(gL, -1), luaL_typename(gL, -1)); - lua_pop(gL, 1); - } - - lua_pop(gL, 1); - } - lua_pop(gL, 1); - WRITEUINT8(demo_p, ARCH_TEND); - } -} - -static UINT8 UnArchiveValue(int TABLESINDEX) -{ - UINT8 type = READUINT8(save_p); + UINT8 type = READUINT8(p); switch (type) { case ARCH_NULL: @@ -1597,13 +1268,13 @@ static UINT8 UnArchiveValue(int TABLESINDEX) lua_pushboolean(gL, false); break; case ARCH_INT8: - lua_pushinteger(gL, READSINT8(save_p)); + lua_pushinteger(gL, READSINT8(p)); break; case ARCH_INT16: - lua_pushinteger(gL, READINT16(save_p)); + lua_pushinteger(gL, READINT16(p)); break; case ARCH_INT32: - lua_pushinteger(gL, READFIXED(save_p)); + lua_pushinteger(gL, READFIXED(p)); break; case ARCH_SMALLSTRING: case ARCH_LARGESTRING: @@ -1617,20 +1288,20 @@ static UINT8 UnArchiveValue(int TABLESINDEX) // (i.e. we can't use READSTRING either) // -- Monster Iestyn 05/08/18 if (type == ARCH_SMALLSTRING) - len = READUINT8(save_p); // length of string, including embedded zeros + len = READUINT8(p); // length of string, including embedded zeros else - len = READUINT32(save_p); // length of string, including embedded zeros + len = READUINT32(p); // length of string, including embedded zeros value = malloc(len); // make temp buffer of size len // now read the actual string while (i < len) - value[i++] = READCHAR(save_p); // read chars individually, including the embedded zeros + value[i++] = READCHAR(p); // read chars individually, including the embedded zeros lua_pushlstring(gL, value, len); // push the string (note: this function supports embedded zeros) free(value); // free the buffer break; } case ARCH_TABLE: { - UINT16 tid = READUINT16(save_p); + UINT16 tid = READUINT16(p); lua_rawgeti(gL, TABLESINDEX, tid); if (lua_isnil(gL, -1)) { @@ -1643,60 +1314,60 @@ static UINT8 UnArchiveValue(int TABLESINDEX) break; } case ARCH_MOBJINFO: - LUA_PushUserdata(gL, &mobjinfo[READUINT16(save_p)], META_MOBJINFO); + LUA_PushUserdata(gL, &mobjinfo[READUINT16(p)], META_MOBJINFO); break; case ARCH_STATE: - LUA_PushUserdata(gL, &states[READUINT16(save_p)], META_STATE); + LUA_PushUserdata(gL, &states[READUINT16(p)], META_STATE); break; case ARCH_MOBJ: - LUA_PushUserdata(gL, P_FindNewPosition(READUINT32(save_p)), META_MOBJ); + LUA_PushUserdata(gL, P_FindNewPosition(READUINT32(p)), META_MOBJ); break; case ARCH_PLAYER: - LUA_PushUserdata(gL, &players[READUINT8(save_p)], META_PLAYER); + LUA_PushUserdata(gL, &players[READUINT8(p)], META_PLAYER); break; case ARCH_MAPTHING: - LUA_PushUserdata(gL, &mapthings[READUINT16(save_p)], META_MAPTHING); + LUA_PushUserdata(gL, &mapthings[READUINT16(p)], META_MAPTHING); break; case ARCH_VERTEX: - LUA_PushUserdata(gL, &vertexes[READUINT16(save_p)], META_VERTEX); + LUA_PushUserdata(gL, &vertexes[READUINT16(p)], META_VERTEX); break; case ARCH_LINE: - LUA_PushUserdata(gL, &lines[READUINT16(save_p)], META_LINE); + LUA_PushUserdata(gL, &lines[READUINT16(p)], META_LINE); break; case ARCH_SIDE: - LUA_PushUserdata(gL, &sides[READUINT16(save_p)], META_SIDE); + LUA_PushUserdata(gL, &sides[READUINT16(p)], META_SIDE); break; case ARCH_SUBSECTOR: - LUA_PushUserdata(gL, &subsectors[READUINT16(save_p)], META_SUBSECTOR); + LUA_PushUserdata(gL, &subsectors[READUINT16(p)], META_SUBSECTOR); break; case ARCH_SECTOR: - LUA_PushUserdata(gL, §ors[READUINT16(save_p)], META_SECTOR); + LUA_PushUserdata(gL, §ors[READUINT16(p)], META_SECTOR); break; #ifdef HAVE_LUA_SEGS case ARCH_SEG: - LUA_PushUserdata(gL, &segs[READUINT16(save_p)], META_SEG); + LUA_PushUserdata(gL, &segs[READUINT16(p)], META_SEG); break; case ARCH_NODE: - LUA_PushUserdata(gL, &nodes[READUINT16(save_p)], META_NODE); + LUA_PushUserdata(gL, &nodes[READUINT16(p)], META_NODE); break; #endif case ARCH_FFLOOR: { - sector_t *sector = §ors[READUINT16(save_p)]; - UINT16 id = READUINT16(save_p); + sector_t *sector = §ors[READUINT16(p)]; + UINT16 id = READUINT16(p); ffloor_t *rover = P_GetFFloorByID(sector, id); if (rover) LUA_PushUserdata(gL, rover, META_FFLOOR); break; } case ARCH_SLOPE: - LUA_PushUserdata(gL, P_SlopeById(READUINT16(save_p)), META_SLOPE); + LUA_PushUserdata(gL, P_SlopeById(READUINT16(p)), META_SLOPE); break; case ARCH_MAPHEADER: - LUA_PushUserdata(gL, mapheaderinfo[READUINT16(save_p)], META_MAPHEADER); + LUA_PushUserdata(gL, mapheaderinfo[READUINT16(p)], META_MAPHEADER); break; case ARCH_SKINCOLOR: - LUA_PushUserdata(gL, &skincolors[READUINT16(save_p)], META_SKINCOLOR); + LUA_PushUserdata(gL, &skincolors[READUINT16(p)], META_SKINCOLOR); break; case ARCH_TEND: return 1; @@ -1704,111 +1375,10 @@ static UINT8 UnArchiveValue(int TABLESINDEX) return 0; } - -// Unarchives from demo_p: -// Return values: -// 0: Normal -// 1: Read table key -// 2: Read table value -// 3: Don't use setfield - -static UINT8 UnArchiveValueDemo(int TABLESINDEX, char field[1024]) -{ - UINT8 type = READUINT8(demo_p); - switch (type) - { - case ARCH_NULL: - lua_pushnil(gL); - break; - case ARCH_BOOLEAN: - lua_pushboolean(gL, READUINT8(demo_p)); - break; - case ARCH_SIGNED: - lua_pushinteger(gL, READFIXED(demo_p)); - break; - case ARCH_STRING: - { - UINT16 len = READUINT16(demo_p); // length of string, including embedded zeros - char *value; - UINT16 i = 0; - // See my comments in the ArchiveValue function; - // it's much the same for reading strings as writing them! - // (i.e. we can't use READSTRING either) - // -- Monster Iestyn 05/08/18 - value = malloc(len); // make temp buffer of size len - // now read the actual string - while (i < len) - value[i++] = READCHAR(demo_p); // read chars individually, including the embedded zeros - lua_pushlstring(gL, value, len); // push the string (note: this function supports embedded zeros) - free(value); // free the buffer - break; - } - case ARCH_TABLE: - { - UINT16 tid = READUINT16(demo_p); - lua_rawgeti(gL, TABLESINDEX, tid); - if (lua_isnil(gL, -1)) - { - lua_pop(gL, 1); - lua_newtable(gL); - lua_pushvalue(gL, -1); - lua_rawseti(gL, TABLESINDEX, tid); - return 2; - } - break; - } - case ARCH_MOBJINFO: - LUA_PushUserdata(gL, &mobjinfo[READUINT16(demo_p)], META_MOBJINFO); - break; - case ARCH_STATE: - LUA_PushUserdata(gL, &states[READUINT16(demo_p)], META_STATE); - break; - case ARCH_MOBJ: - demo_p += sizeof(UINT32); // Skip this data, we can't read a mobj here, it'd point to garbage and crash the game. - if (field) - CONS_Alert(CONS_WARNING,"Cannot read mobj_t stored in player variable \'%s\'. Desyncs may occur.\n", field); - else - CONS_Alert(CONS_WARNING,"Couldn't read mobj_t\n"); - - return 3; // Don't set the field - - case ARCH_PLAYER: - LUA_PushUserdata(gL, &players[READUINT8(demo_p)], META_PLAYER); - break; - case ARCH_MAPTHING: - LUA_PushUserdata(gL, &mapthings[READUINT16(demo_p)], META_MAPTHING); - break; - case ARCH_VERTEX: - LUA_PushUserdata(gL, &vertexes[READUINT16(demo_p)], META_VERTEX); - break; - case ARCH_LINE: - LUA_PushUserdata(gL, &lines[READUINT16(demo_p)], META_LINE); - break; - case ARCH_SIDE: - LUA_PushUserdata(gL, &sides[READUINT16(demo_p)], META_SIDE); - break; - case ARCH_SUBSECTOR: - LUA_PushUserdata(gL, &subsectors[READUINT16(demo_p)], META_SUBSECTOR); - break; - case ARCH_SECTOR: - LUA_PushUserdata(gL, §ors[READUINT16(demo_p)], META_SECTOR); - break; - case ARCH_SLOPE: - LUA_PushUserdata(gL, P_SlopeById(READUINT16(demo_p)), META_SLOPE); - break; - case ARCH_MAPHEADER: - LUA_PushUserdata(gL, mapheaderinfo[READUINT16(demo_p)], META_MAPHEADER); - break; - case ARCH_TEND: - return 1; - } - return 0; -} - -static void UnArchiveExtVars(void *pointer) +static void UnArchiveExtVars(UINT8 *p, void *pointer) { int TABLESINDEX; - UINT16 field_count = READUINT16(save_p); + UINT16 field_count = READUINT16(p); UINT16 i; char field[1024]; @@ -1821,8 +1391,8 @@ static void UnArchiveExtVars(void *pointer) for (i = 0; i < field_count; i++) { - READSTRING(save_p, field); - UnArchiveValue(TABLESINDEX); + READSTRING(p, field); + UnArchiveValue(p, TABLESINDEX); lua_setfield(gL, -2, field); } @@ -1834,45 +1404,16 @@ static void UnArchiveExtVars(void *pointer) lua_pop(gL, 2); // pop LREG_EXTVARS and pointer's subtable } -static void UnArchiveExtVarsDemo(void *pointer) -{ - int TABLESINDEX; - UINT16 field_count = READUINT16(demo_p); - UINT16 i; - char field[1024]; - - if (field_count == 0) - return; - I_Assert(gL != NULL); - - TABLESINDEX = lua_gettop(gL); - lua_createtable(gL, 0, field_count); // pointer's ext vars subtable - - for (i = 0; i < field_count; i++) - { - READSTRING(demo_p, field); - if (UnArchiveValueDemo(TABLESINDEX, field) != 3) // This will return 3 if we shouldn't set this field. - lua_setfield(gL, -2, field); - } - - lua_getfield(gL, LUA_REGISTRYINDEX, LREG_EXTVARS); - I_Assert(lua_istable(gL, -1)); - lua_pushlightuserdata(gL, pointer); - lua_pushvalue(gL, -3); // pointer's ext vars subtable - lua_rawset(gL, -3); - lua_pop(gL, 2); // pop LREG_EXTVARS and pointer's subtable -} - static int NetUnArchive(lua_State *L) { int TABLESINDEX = lua_upvalueindex(1); int i, n = lua_gettop(L); for (i = 1; i <= n; i++) - UnArchiveValue(TABLESINDEX); + UnArchiveValue(save_p, TABLESINDEX); return n; } -static void UnArchiveTables(void) +static void UnArchiveTables(UINT8 *p) { int TABLESINDEX; UINT16 i, n; @@ -1888,41 +1429,9 @@ static void UnArchiveTables(void) lua_rawgeti(gL, TABLESINDEX, i); while (true) { - if (UnArchiveValue(TABLESINDEX) == 1) // read key + if (UnArchiveValue(p, TABLESINDEX) == 1) // read key break; - if (UnArchiveValue(TABLESINDEX) == 2) // read value - n++; - if (lua_isnil(gL, -2)) // if key is nil (if a function etc was accidentally saved) - { - CONS_Alert(CONS_ERROR, "A nil key in table %d was found! (Invalid key type or corrupted save?)\n", i); - lua_pop(gL, 2); // pop key and value instead of setting them in the table, to prevent Lua panic errors - } - else - lua_rawset(gL, -3); - } - lua_pop(gL, 1); - } -} - -static void UnArchiveTablesDemo(void) -{ - int TABLESINDEX; - UINT16 i, n; - - if (!gL) - return; - - TABLESINDEX = lua_gettop(gL); - - n = (UINT16)lua_objlen(gL, TABLESINDEX); - for (i = 1; i <= n; i++) - { - lua_rawgeti(gL, TABLESINDEX, i); - while (true) - { - if (UnArchiveValueDemo(TABLESINDEX, NULL) == 1) // read key - break; - if (UnArchiveValueDemo(TABLESINDEX, NULL) == 2) // read value + if (UnArchiveValue(p, TABLESINDEX) == 2) // read value n++; if (lua_isnil(gL, -2)) // if key is nil (if a function etc was accidentally saved) { @@ -1944,7 +1453,7 @@ void LUA_Step(void) lua_gc(gL, LUA_GCSTEP, 1); } -void LUA_Archive(void) +void LUA_Archive(UINT8 *p) { INT32 i; thinker_t *th; @@ -1957,32 +1466,36 @@ void LUA_Archive(void) if (!playeringame[i] && i > 0) // NEVER skip player 0, this is for dedi servs. continue; // all players in game will be archived, even if they just add a 0. - ArchiveExtVars(&players[i], "player"); + ArchiveExtVars(p, &players[i], "player"); } - if (gamestate == GS_LEVEL) + if (p == save_p) { - for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next) + if (gamestate == GS_LEVEL) { - if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) - continue; + for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next) + { + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; - // archive function will determine when to skip mobjs, - // and write mobjnum in otherwise. - ArchiveExtVars(th, "mobj"); + // archive function will determine when to skip mobjs, + // and write mobjnum in otherwise. + ArchiveExtVars(p, th, "mobj"); + } } - } - - WRITEUINT32(save_p, UINT32_MAX); // end of mobjs marker, replaces mobjnum. + + WRITEUINT32(p, UINT32_MAX); // end of mobjs marker, replaces mobjnum. - LUAh_NetArchiveHook(NetArchive); // call the NetArchive hook in archive mode - ArchiveTables(); + LUAh_NetArchiveHook(NetArchive); // call the NetArchive hook in archive mode + } + + ArchiveTables(p); if (gL) lua_pop(gL, 1); // pop tables } -void LUA_UnArchive(void) +void LUA_UnArchive(UINT8 *p) { UINT32 mobjnum; INT32 i; @@ -1995,66 +1508,27 @@ void LUA_UnArchive(void) { if (!playeringame[i] && i > 0) // same here, this is to synch dediservs properly. continue; - UnArchiveExtVars(&players[i]); + UnArchiveExtVars(p, &players[i]); } - do { - mobjnum = READUINT32(save_p); // read a mobjnum - for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next) - { - if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) - continue; - if (((mobj_t *)th)->mobjnum != mobjnum) // find matching mobj - continue; - UnArchiveExtVars(th); // apply variables - } - } while(mobjnum != UINT32_MAX); // repeat until end of mobjs marker. - - LUAh_NetArchiveHook(NetUnArchive); // call the NetArchive hook in unarchive mode - UnArchiveTables(); - - if (gL) - lua_pop(gL, 1); // pop tables -} - -// simplified versions of LUA_Archive for demos -void LUA_ArchiveDemo(void) -{ - INT32 i; - - if (gL) - lua_newtable(gL); // tables to be archived. - - for (i = 0; i < MAXPLAYERS; i++) + if (p == save_p) { - if (!playeringame[i] && i > 0) // NEVER skip player 0, this is for dedi servs. - continue; - // all players in game will be archived, even if they just add a 0. - ArchiveExtVarsDemo(&players[i], "player"); + do { + mobjnum = READUINT32(p); // read a mobjnum + for (th = thlist[THINK_MOBJ].next; th != &thlist[THINK_MOBJ]; th = th->next) + { + if (th->function.acp1 == (actionf_p1)P_RemoveThinkerDelayed) + continue; + if (((mobj_t *)th)->mobjnum != mobjnum) // find matching mobj + continue; + UnArchiveExtVars(p, th); // apply variables + } + } while(mobjnum != UINT32_MAX); // repeat until end of mobjs marker. + + LUAh_NetArchiveHook(NetUnArchive); // call the NetArchive hook in unarchive mode } - ArchiveTablesDemo(); - - if (gL) - lua_pop(gL, 1); // pop tables -} - -// this time make sure we read from demo_p -void LUA_UnArchiveDemo(void) -{ - INT32 i; - - if (gL) - lua_newtable(gL); // tables to be read - - for (i = 0; i < MAXPLAYERS; i++) - { - if (!playeringame[i] && i > 0) // same here, this is to synch dediservs properly. - continue; - UnArchiveExtVarsDemo(&players[i]); - } - - UnArchiveTablesDemo(); + UnArchiveTables(p); if (gL) lua_pop(gL, 1); // pop tables diff --git a/src/lua_script.h b/src/lua_script.h index 2b7423d0f..2ba54453e 100644 --- a/src/lua_script.h +++ b/src/lua_script.h @@ -54,14 +54,11 @@ void LUA_InvalidateLevel(void); void LUA_InvalidateMapthings(void); void LUA_InvalidatePlayer(player_t *player); void LUA_Step(void); -void LUA_Archive(void); -void LUA_UnArchive(void); - -void LUA_ArchiveDemo(void); -void LUA_UnArchiveDemo(void); +void LUA_Archive(UINT8 *p); +void LUA_UnArchive(UINT8 *p); int LUA_PushGlobals(lua_State *L, const char *word); -int LUA_CheckGlobals(lua_State *L, const char *word); +int LUA_WriteGlobals(lua_State *L, const char *word); void Got_Luacmd(UINT8 **cp, INT32 playernum); // lua_consolelib.c void LUA_CVarChanged(const char *name); // lua_consolelib.c diff --git a/src/m_cond.c b/src/m_cond.c index c72444818..c6d699643 100644 --- a/src/m_cond.c +++ b/src/m_cond.c @@ -20,7 +20,6 @@ #include "g_game.h" // record info #include "r_skins.h" // numskins #include "r_draw.h" // R_GetColorByName -#include "k_color.h" // K_GetKartColorByName #include "k_pwrlv.h" // Map triggers for linedef executors diff --git a/src/m_menu.c b/src/m_menu.c index 1fb5d3a58..31766bec5 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -2337,6 +2337,64 @@ void Moviemode_option_Onchange(void) // current menudef menu_t *currentMenu = &MainDef; +// ========================================================================= +// MENU PRESENTATION PARAMETER HANDLING (BACKGROUNDS) +// ========================================================================= + +// menu IDs are equal to current/prevMenu in most cases, except MN_SPECIAL when we don't want to operate on Message, Pause, etc. +UINT32 prevMenuId = 0; +UINT32 activeMenuId = 0; + +menupres_t menupres[NUMMENUTYPES]; + +void M_InitMenuPresTables(void) +{ + INT32 i; + + // Called in d_main before SOC can get to the tables + // Set menupres defaults + for (i = 0; i < NUMMENUTYPES; i++) + { + // so-called "undefined" + menupres[i].fadestrength = -1; + menupres[i].hidetitlepics = -1; // inherits global hidetitlepics + menupres[i].ttmode = TTMODE_NONE; + menupres[i].ttscale = UINT8_MAX; + menupres[i].ttname[0] = 0; + menupres[i].ttx = INT16_MAX; + menupres[i].tty = INT16_MAX; + menupres[i].ttloop = INT16_MAX; + menupres[i].tttics = UINT16_MAX; + menupres[i].enterwipe = -1; + menupres[i].exitwipe = -1; + menupres[i].bgcolor = -1; + menupres[i].titlescrollxspeed = INT32_MAX; + menupres[i].titlescrollyspeed = INT32_MAX; + menupres[i].bghide = true; + // default true + menupres[i].enterbubble = true; + menupres[i].exitbubble = true; + + if (i != MN_MAIN) + { + menupres[i].muslooping = true; + } + if (i == MN_SP_TIMEATTACK) + strncpy(menupres[i].musname, "_recat", 7); + else if (i == MN_SP_NIGHTSATTACK) + strncpy(menupres[i].musname, "_nitat", 7); + else if (i == MN_SP_MARATHON) + strncpy(menupres[i].musname, "spec8", 6); + else if (i == MN_SP_PLAYER || i == MN_SR_PLAYER) + strncpy(menupres[i].musname, "_chsel", 7); + else if (i == MN_SR_SOUNDTEST) + { + *menupres[i].musname = '\0'; + menupres[i].musstop = true; + } + } +} + // ========================================================================= // BASIC MENU HANDLING // ========================================================================= @@ -3313,6 +3371,7 @@ void M_ClearMenus(boolean callexitmenufunc) if (currentMenu == &MessageDef) // Oh sod off! currentMenu = &MainDef; // Not like it matters menuactive = false; + hidetitlemap = false; } // @@ -3372,6 +3431,14 @@ void M_SetupNextMenu(menu_t *menudef) } } } + + hidetitlemap = false; +} + +// Guess I'll put this here, idk +boolean M_MouseNeeded(void) +{ + return false; } // @@ -5309,6 +5376,7 @@ void M_ReplayHut(INT32 choice) menuactive = true; M_SetupNextMenu(&MISC_ReplayHutDef); G_SetGamestate(GS_TIMEATTACK); + titlemapinaction = TITLEMAP_OFF; // Nope don't give us HOMs please demo.rewinding = false; CL_ClearRewinds(); @@ -7921,6 +7989,7 @@ static void M_TimeAttack(INT32 choice) M_SetupNextMenu(&SP_TimeAttackDef); G_SetGamestate(GS_TIMEATTACK); + titlemapinaction = TITLEMAP_OFF; // Nope don't give us HOMs please if (cv_nextmap.value) Nextmap_OnChange(); @@ -7953,6 +8022,7 @@ static void M_BreakTheCapsules(INT32 choice) M_SetupNextMenu(&SP_TimeAttackDef); G_SetGamestate(GS_TIMEATTACK); + titlemapinaction = TITLEMAP_OFF; // Nope don't give us HOMs please if (cv_nextmap.value) Nextmap_OnChange(); @@ -7971,161 +8041,6 @@ static boolean M_QuitTimeAttackMenu(void) return true; } -// Drawing function for Nights Attack -/*void M_DrawNightsAttackMenu(void) -{ - patch_t *PictureOfLevel; - lumpnum_t lumpnum; - char beststr[40]; - - S_ChangeMusicInternal("racent", true); // Eww, but needed for when user hits escape during demo playback - - V_DrawPatchFill(W_CachePatchName("SRB2BACK", PU_CACHE)); - - // draw menu (everything else goes on top of it) - M_DrawGenericMenu(); - - // A 160x100 image of the level as entry MAPxxP - lumpnum = W_CheckNumForName(va("%sP", G_BuildMapName(cv_nextmap.value))); - - if (lumpnum != LUMPERROR) - PictureOfLevel = W_CachePatchNum(lumpnum, PU_CACHE); - else - PictureOfLevel = W_CachePatchName("BLANKLVL", PU_CACHE); - - V_DrawSmallScaledPatch(90, 28, 0, PictureOfLevel); - - // Level record list - if (cv_nextmap.value) - { - emblem_t *em; - INT32 yHeight; - - UINT8 bestoverall = G_GetBestNightsGrade(cv_nextmap.value, 0); - UINT8 bestgrade = G_GetBestNightsGrade(cv_nextmap.value, cv_dummymares.value); - UINT32 bestscore = G_GetBestNightsScore(cv_nextmap.value, cv_dummymares.value); - tic_t besttime = G_GetBestNightsTime(cv_nextmap.value, cv_dummymares.value); - - if (P_HasGrades(cv_nextmap.value, 0)) - V_DrawScaledPatch(200, 28 + 8, 0, ngradeletters[bestoverall]); - - if (currentMenu == &SP_NightsAttackDef) - { - if (P_HasGrades(cv_nextmap.value, cv_dummymares.value)) - { - V_DrawString(160-88, 112, highlightflags, "BEST GRADE:"); - V_DrawSmallScaledPatch(160 + 86 - (ngradeletters[bestgrade]->width/2), - 112 + 8 - (ngradeletters[bestgrade]->height/2), - 0, ngradeletters[bestgrade]); - } - - if (!bestscore) - sprintf(beststr, "(none)"); - else - sprintf(beststr, "%u", bestscore); - - V_DrawString(160 - 88, 122, highlightflags, "BEST SCORE:"); - V_DrawRightAlignedString(160 + 88, 122, V_ALLOWLOWERCASE, beststr); - - if (besttime == UINT32_MAX) - sprintf(beststr, "(none)"); - else - sprintf(beststr, "%i:%02i.%02i", G_TicsToMinutes(besttime, true), - G_TicsToSeconds(besttime), - G_TicsToCentiseconds(besttime)); - - V_DrawString(160-88, 132, highlightflags, "BEST TIME:"); - V_DrawRightAlignedString(160+88, 132, V_ALLOWLOWERCASE, beststr); - - if (cv_dummymares.value == 0) { - // Draw record emblems. - em = M_GetLevelEmblems(cv_nextmap.value); - while (em) - { - switch (em->type) - { - case ET_NGRADE: yHeight = 112; break; - case ET_NTIME: yHeight = 132; break; - default: - goto skipThisOne; - } - - if (em->collected) - V_DrawSmallMappedPatch(160+88, yHeight, 0, W_CachePatchName(M_GetEmblemPatch(em, false), PU_CACHE), - R_GetTranslationColormap(TC_DEFAULT, M_GetEmblemColor(em), GTC_MENUCACHE)); - else - V_DrawSmallScaledPatch(160+88, yHeight, 0, W_CachePatchName("NEEDIT", PU_CACHE)); - - skipThisOne: - em = M_GetLevelEmblems(-1); - } - } - } - // ALWAYS DRAW level name even when not on this menu! - else - { - consvar_t *ncv; - INT32 x = SP_NightsAttackDef.x; - INT32 y = SP_NightsAttackDef.y; - - ncv = (consvar_t *)SP_NightsAttackMenu[0].itemaction; - V_DrawString(x, y + SP_NightsAttackMenu[0].alphaKey, V_TRANSLUCENT, SP_NightsAttackMenu[0].text); - V_DrawString(BASEVIDWIDTH - x - V_StringWidth(ncv->string, 0), - y + SP_NightsAttackMenu[0].alphaKey, highlightflags|V_TRANSLUCENT, ncv->string); - } - } -}*/ - -// Going to Nights Attack menu... -/*static void M_BreakTheCapsules(INT32 choice) -{ - (void)choice; - - memset(skins_cons_t, 0, sizeof (skins_cons_t)); - - levellistmode = LLM_BREAKTHECAPSULES; // Don't be dependent on cv_newgametype - - if (M_CountLevelsToShowInList() == 0) - { - M_StartMessage(M_GetText("No NiGHTS-attackable levels found.\n"),NULL,MM_NOTHING); - return; - } - - // This is really just to make sure Sonic is the played character, just in case - M_PatchSkinNameTable(); - - M_PrepareLevelSelect(); - M_SetupNextMenu(&SP_NightsAttackDef); - Nextmap_OnChange(); - - itemOn = nastart; // "Start" is selected. - - G_SetGamestate(GS_TIMEATTACK); - S_ChangeMusicInternal("racent", true); -}*/ - -// Player has selected the "START" from the nights attack screen -/*static void M_ChooseNightsAttack(INT32 choice) -{ - char nameofdemo[256]; - (void)choice; - emeralds = 0; - M_ClearMenus(true); - modeattacking = ATTACKING_CAPSULES; - - I_mkdir(va("%s"PATHSEP"replay", srb2home), 0755); - I_mkdir(va("%s"PATHSEP"replay"PATHSEP"%s", srb2home, timeattackfolder), 0755); - - snprintf(nameofdemo, sizeof nameofdemo, "replay"PATHSEP"%s"PATHSEP"%s-last", timeattackfolder, G_BuildMapName(cv_nextmap.value)); - - if (!cv_autorecord.value) - remove(va("%s"PATHSEP"%s.lmp", srb2home, nameofdemo)); - else - G_RecordDemo(nameofdemo); - - G_DeferedInitNew(false, G_BuildMapName(cv_nextmap.value), 0, 0, false); -}*/ - // Player has selected the "START" from the time attack screen static void M_ChooseTimeAttack(INT32 choice) { diff --git a/src/p_enemy.c b/src/p_enemy.c index e96189293..9b3ca13ca 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -106,12 +106,10 @@ void A_Pain(mobj_t *actor); void A_Explode(mobj_t *actor); void A_BossDeath(mobj_t *actor); void A_CustomPower(mobj_t *actor); -void A_GiveWeapon(mobj_t *actor); void A_RingBox(mobj_t *actor); void A_Invincibility(mobj_t *actor); void A_SuperSneakers(mobj_t *actor); void A_AwardScore(mobj_t *actor); -void A_ExtraLife(mobj_t *actor); void A_GiveShield(mobj_t *actor); void A_GravityBox(mobj_t *actor); void A_ScoreRise(mobj_t *actor); @@ -148,7 +146,6 @@ void A_CrawlaCommanderThink(mobj_t *actor); void A_RingExplode(mobj_t *actor); void A_OldRingExplode(mobj_t *actor); void A_MixUp(mobj_t *actor); -void A_RecyclePowers(mobj_t *actor); void A_Boss2TakeDamage(mobj_t *actor); void A_Boss7Chase(mobj_t *actor); void A_GoopSplat(mobj_t *actor); @@ -3878,43 +3875,6 @@ void A_AwardScore(mobj_t *actor) S_StartSound(player->mo, actor->info->seesound); } -// Function: A_ExtraLife -// -// Description: Awards the player an extra life. -// -// var1 = unused -// var2 = unused -// -void A_ExtraLife(mobj_t *actor) -{ - player_t *player; - - if (LUA_CallAction("A_ExtraLife", actor)) - return; - - if (!actor->target || !actor->target->player) - { - CONS_Debug(DBG_GAMELOGIC, "Powerup has no target.\n"); - return; - } - - player = actor->target->player; - - if (actor->type == MT_1UP_ICON && actor->tracer) - { - // We're using the overlay, so use the overlay 1up sprite (no text) - actor->sprite = SPR_TV1P; - } - - if (ultimatemode) //I don't THINK so! - { - S_StartSound(player->mo, sfx_lose); - return; - } - - P_GiveCoopLives(player, 1, true); -} - // Function: A_GiveShield // // Description: Awards the player a specified shield. diff --git a/src/p_local.h b/src/p_local.h index 2e95e89e5..5aa552926 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -175,7 +175,6 @@ mobj_t *P_SpawnGhostMobj(mobj_t *mobj); void P_GivePlayerRings(player_t *player, INT32 num_rings); void P_GivePlayerSpheres(player_t *player, INT32 num_spheres); void P_GivePlayerLives(player_t *player, INT32 numlives); -void P_GiveCoopLives(player_t *player, INT32 numlives, boolean sound); UINT8 P_GetNextEmerald(void); void P_GiveEmerald(boolean spawnObj); void P_GiveFinishFlags(player_t *player); @@ -186,18 +185,12 @@ void P_ResetScore(player_t *player); #endif boolean P_AutoPause(void); -void P_DoJumpShield(player_t *player); -void P_DoBubbleBounce(player_t *player); -void P_DoAbilityBounce(player_t *player, boolean changemomz); -void P_TwinSpinRejuvenate(player_t *player, mobjtype_t type); -void P_BlackOw(player_t *player); void P_ElementalFire(player_t *player, boolean cropcircle); void P_SpawnSkidDust(player_t *player, fixed_t radius, boolean sound); void P_MovePlayer(player_t *player); void P_PlayerThink(player_t *player); void P_PlayerAfterThink(player_t *player); -void P_DoPlayerFinish(player_t *player); void P_DoPlayerExit(player_t *player); void P_DoTimeOver(player_t *player); @@ -502,15 +495,11 @@ void P_PlayerRingBurst(player_t *player, INT32 num_rings); /// \todo better fit void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck); void P_TouchStarPost(mobj_t *starpost, player_t *player, boolean snaptopost); -void P_PlayerFlagBurst(player_t *player, boolean toss); void P_CheckTimeLimit(void); void P_CheckPointLimit(void); -//void P_CheckSurvivors(void); boolean P_CheckRacers(void); boolean P_CanPickupItem(player_t *player, UINT8 weapon); -void P_DoNightsScore(player_t *player); -void P_DoMatchSuper(player_t *player); // // P_SPEC @@ -531,7 +520,6 @@ boolean P_Teleport(mobj_t *thing, fixed_t x, fixed_t y, fixed_t z, angle_t angle boolean P_SetMobjStateNF(mobj_t *mobj, statenum_t state); boolean P_CheckMissileSpawn(mobj_t *th); void P_Thrust(mobj_t *mo, angle_t angle, fixed_t move); -void P_DoSuperTransformation(player_t *player, boolean giverings); void P_ExplodeMissile(mobj_t *mo); void P_CheckGravity(mobj_t *mo, boolean affect); diff --git a/src/p_saveg.c b/src/p_saveg.c index dbd29ac74..2c9a573b9 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -4372,7 +4372,7 @@ void P_SaveNetGame(void) P_NetArchiveTubeWaypoints(); P_NetArchiveWaypoints(); } - LUA_Archive(); + LUA_Archive(save_p); P_ArchiveLuabanksAndConsistency(); } @@ -4416,7 +4416,7 @@ boolean P_LoadNetGame(void) P_RelinkPointers(); P_FinishMobjs(); } - LUA_UnArchive(); + LUA_UnArchive(save_p); // This is stupid and hacky, but maybe it'll work! P_SetRandSeed(P_GetInitSeed()); diff --git a/src/p_setup.c b/src/p_setup.c index 38c95588e..9b8b06f7d 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -3805,10 +3805,6 @@ boolean P_LoadLevel(boolean fromnetsave) // will be set by player think. players[consoleplayer].viewz = 1; - // Cancel all d_main.c fadeouts (keep fade in though). - wipegamestate = FORCEWIPEOFF; - wipestyleflags = 0; - // Encore mode fade to pink to white // This is handled BEFORE sounds are stopped. if (encoremode && !prevencoremode && !demo.rewinding) @@ -3874,8 +3870,6 @@ boolean P_LoadLevel(boolean fromnetsave) if (G_GetModeAttackRetryFlag()) { - if (modeattacking) - wipestyleflags |= (WSF_FADEOUT|WSF_TOWHITE); G_ClearModeAttackRetryFlag(); } diff --git a/src/p_spec.c b/src/p_spec.c index 3d8dfbdec..ff13d3654 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -4728,7 +4728,7 @@ DoneSection2: { INT32 lineindex; - P_DoPlayerFinish(player); + P_DoPlayerExit(player); P_SetupSignExit(player); // important: use sector->tag on next line instead of player->mo->subsector->tag diff --git a/src/s_sound.c b/src/s_sound.c index a9d5c751a..abefd3c9a 100644 --- a/src/s_sound.c +++ b/src/s_sound.c @@ -1654,6 +1654,7 @@ enum }; musicdef_t *musicdefstart = NULL; +struct cursongcredit cursongcredit; // Currently displayed song credit info // // search for music definition in wad diff --git a/src/sdl/i_threads.c b/src/sdl/i_threads.c index 078f4e0f4..3b1c20b9a 100644 --- a/src/sdl/i_threads.c +++ b/src/sdl/i_threads.c @@ -1,4 +1,4 @@ -// SONIC ROBO BLAST 2 KART +// SONIC ROBO BLAST 2 //----------------------------------------------------------------------------- // Copyright (C) 2020 by James R. //