From 5415674034032b28bfcf36b291e1be4236e58d8d Mon Sep 17 00:00:00 2001 From: James R Date: Wed, 4 Oct 2023 20:17:31 -0700 Subject: [PATCH 1/3] debugfinishline: highlight deathpits and instakill planes --- src/cvars.cpp | 2 +- src/r_bsp.cpp | 56 ++++++++++++++++++++++++++----- src/r_draw.c | 1 + src/r_draw.h | 3 +- src/r_plane.cpp | 87 +++++++++++++++++++++++++++++++++++++++---------- src/r_plane.h | 6 +++- src/r_portal.c | 2 +- src/r_segs.cpp | 15 ++++++--- src/screen.c | 21 ++++++++++-- src/screen.h | 1 + 10 files changed, 156 insertions(+), 38 deletions(-) diff --git a/src/cvars.cpp b/src/cvars.cpp index 5e56394ef..4aa73492f 100644 --- a/src/cvars.cpp +++ b/src/cvars.cpp @@ -834,7 +834,7 @@ consvar_t cv_kartdebugnodes = ServerCheat("debugnodes", "Off").on_off().descript consvar_t cv_1pswap = PlayerCheat("1pswap", "1").min_max(1, MAXSPLITSCREENPLAYERS).description("Let P1's Profile control a different splitscreen player"); -consvar_t cv_debugfinishline = PlayerCheat("debugfinishline", "Off").on_off().description("Highlight finish lines and respawn lines with high contrast colors"); +consvar_t cv_debugfinishline = PlayerCheat("debugfinishline", "Off").on_off().description("Highlight finish lines, respawn lines, death pits and instakill planes with high contrast colors"); consvar_t cv_debugrank = PlayerCheat("debugrank", "Off").description("Show GP rank state on the HUD; optionally force a rank grade").values({ {0, "Off"}, diff --git a/src/r_bsp.cpp b/src/r_bsp.cpp index f4e11bad4..577012133 100644 --- a/src/r_bsp.cpp +++ b/src/r_bsp.cpp @@ -15,6 +15,7 @@ #include +#include "command.h" #include "doomdef.h" #include "g_game.h" #include "r_local.h" @@ -30,6 +31,8 @@ #include "k_terrain.h" +extern "C" consvar_t cv_debugfinishline; + seg_t *curline; side_t *sidedef; line_t *linedef; @@ -404,7 +407,8 @@ boolean R_IsEmptyLine(seg_t *line, sector_t *front, sector_t *back) // Consider colormaps && back->extra_colormap == front->extra_colormap && ((!front->ffloors && !back->ffloors) - || Tag_Compare(&front->tags, &back->tags))); + || Tag_Compare(&front->tags, &back->tags)) + && (!cv_debugfinishline.value || back->damagetype == front->damagetype)); } boolean R_IsDebugLine(seg_t *line) @@ -963,6 +967,11 @@ static void R_Subsector(size_t num) ceilingcolormap = *frontsector->lightlist[light].extra_colormap; } + auto sector_damage = [](sector_t* s) { return static_cast(s->damagetype); }; + + auto floor_damage = [&](sector_t* s) { return s->flags & MSF_FLIPSPECIAL_FLOOR ? sector_damage(s) : SD_NONE; }; + auto ceiling_damage = [&](sector_t* s) { return s->flags & MSF_FLIPSPECIAL_CEILING ? sector_damage(s) : SD_NONE; }; + sub->sector->extra_colormap = frontsector->extra_colormap; if (P_GetSectorFloorZAt(frontsector, viewx, viewy) < viewz @@ -975,7 +984,7 @@ static void R_Subsector(size_t num) floorcolormap, NULL, NULL, frontsector->f_slope, R_NoEncore(frontsector, &levelflats[frontsector->floorpic], false), R_IsRipplePlane(frontsector, NULL, false), - false, frontsector + false, frontsector, floor_damage(frontsector) ); } else @@ -991,7 +1000,7 @@ static void R_Subsector(size_t num) ceilingcolormap, NULL, NULL, frontsector->c_slope, R_NoEncore(frontsector, &levelflats[frontsector->ceilingpic], true), R_IsRipplePlane(frontsector, NULL, true), - true, frontsector + true, frontsector, ceiling_damage(frontsector) ); } else @@ -1005,9 +1014,20 @@ static void R_Subsector(size_t num) { fixed_t heightcheck, planecenterz; + auto fof_damage = [&](auto& f) + { + sector_t* s = rover->master->frontsector; + return rover->fofflags & FOF_BLOCKPLAYER ? f(s) : sector_damage(s); + }; + + auto fof_top_damage = [&] { return fof_damage(floor_damage); }; + auto fof_bottom_damage = [&] { return fof_damage(ceiling_damage); }; + for (rover = frontsector->ffloors; rover && numffloors < MAXFFLOORS; rover = rover->next) { - if (!(rover->fofflags & FOF_EXISTS) || !(rover->fofflags & FOF_RENDERPLANES)) + bool visible = rover->fofflags & FOF_RENDERPLANES; + + if (!(rover->fofflags & FOF_EXISTS) || (!cv_debugfinishline.value && !visible)) continue; if (frontsector->cullheight) @@ -1030,6 +1050,14 @@ static void R_Subsector(size_t num) && ((viewz < heightcheck && (rover->fofflags & FOF_BOTHPLANES || !(rover->fofflags & FOF_INVERTPLANES))) || (viewz > heightcheck && (rover->fofflags & FOF_BOTHPLANES || rover->fofflags & FOF_INVERTPLANES)))) { + sectordamage_t damage = fof_bottom_damage(); + + if (!damage && !visible) + { + rover->norender = leveltime; // Tell R_StoreWallRange to skip this + continue; + } + light = R_GetPlaneLight(frontsector, planecenterz, viewz < heightcheck); @@ -1039,7 +1067,7 @@ static void R_Subsector(size_t num) *rover->bottomyoffs, *rover->bottomangle, *frontsector->lightlist[light].extra_colormap, rover, NULL, *rover->b_slope, R_NoEncore(rover->master->frontsector, &levelflats[*rover->bottompic], true), R_IsRipplePlane(rover->master->frontsector, rover, true), - true, frontsector + true, frontsector, damage ); ffloor[numffloors].slope = *rover->b_slope; @@ -1065,6 +1093,14 @@ static void R_Subsector(size_t num) && ((viewz > heightcheck && (rover->fofflags & FOF_BOTHPLANES || !(rover->fofflags & FOF_INVERTPLANES))) || (viewz < heightcheck && (rover->fofflags & FOF_BOTHPLANES || rover->fofflags & FOF_INVERTPLANES)))) { + sectordamage_t damage = fof_top_damage(); + + if (!damage && !visible) + { + rover->norender = leveltime; // Tell R_StoreWallRange to skip this + continue; + } + light = R_GetPlaneLight(frontsector, planecenterz, viewz < heightcheck); ffloor[numffloors].plane = R_FindPlane( @@ -1073,7 +1109,7 @@ static void R_Subsector(size_t num) *frontsector->lightlist[light].extra_colormap, rover, NULL, *rover->t_slope, R_NoEncore(rover->master->frontsector, &levelflats[*rover->toppic], false), R_IsRipplePlane(rover->master->frontsector, rover, false), - false, frontsector + false, frontsector, damage ); ffloor[numffloors].slope = *rover->t_slope; @@ -1095,6 +1131,10 @@ static void R_Subsector(size_t num) polyobj_t *po = sub->polyList; sector_t *polysec; + auto poly_damage = [&](auto& f) { return polysec->flags & POF_SOLID ? f(polysec) : sector_damage(polysec); }; + auto poly_top_damage = [&] { return poly_damage(floor_damage); }; + auto poly_bottom_damage = [&] { return poly_damage(ceiling_damage); }; + while (po) { if (numffloors >= MAXFFLOORS) @@ -1123,7 +1163,7 @@ static void R_Subsector(size_t num) NULL, // will ffloors be slopable eventually? R_NoEncore(polysec, &levelflats[polysec->floorpic], false), false, /* TODO: wet polyobjects? */ - true, frontsector + true, frontsector, poly_bottom_damage() ); ffloor[numffloors].height = polysec->floorheight; @@ -1152,7 +1192,7 @@ static void R_Subsector(size_t num) NULL, // will ffloors be slopable eventually? R_NoEncore(polysec, &levelflats[polysec->ceilingpic], true), false, /* TODO: wet polyobjects? */ - false, frontsector + false, frontsector, poly_top_damage() ); ffloor[numffloors].polyobj = po; diff --git a/src/r_draw.c b/src/r_draw.c index 42f3473df..c335755f2 100644 --- a/src/r_draw.c +++ b/src/r_draw.c @@ -117,6 +117,7 @@ INT32 ds_y, ds_x1, ds_x2; lighttable_t *ds_colormap; lighttable_t *ds_fullbright; lighttable_t *ds_translation; // Lactozilla: Sprite splat drawer +lighttable_t *ds_flatlighting; fixed_t ds_xfrac, ds_yfrac, ds_xstep, ds_ystep; INT32 ds_waterofs, ds_bgofs; diff --git a/src/r_draw.h b/src/r_draw.h index c14747eed..62073a2fe 100644 --- a/src/r_draw.h +++ b/src/r_draw.h @@ -69,6 +69,7 @@ extern INT32 ds_y, ds_x1, ds_x2; extern lighttable_t *ds_colormap; extern lighttable_t *ds_fullbright; extern lighttable_t *ds_translation; +extern lighttable_t *ds_flatlighting; extern fixed_t ds_xfrac, ds_yfrac, ds_xstep, ds_ystep; extern INT32 ds_waterofs, ds_bgofs; @@ -80,8 +81,6 @@ extern UINT8 *ds_source; extern UINT8 *ds_brightmap; extern UINT8 *ds_transmap; -extern UINT8 ds_flatcolor; - struct floatv3_t { float x, y, z; }; diff --git a/src/r_plane.cpp b/src/r_plane.cpp index 1df08da37..1ddcd4b21 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -15,6 +15,7 @@ #include +#include "command.h" #include "doomdef.h" #include "console.h" #include "g_game.h" @@ -34,6 +35,8 @@ #include "z_zone.h" #include "p_tick.h" +extern "C" consvar_t cv_debugfinishline; + // // opening // @@ -212,21 +215,29 @@ static void R_MapPlane(INT32 y, INT32 x1, INT32 x2) ds_bgofs = -y; } - pindex = distance >> LIGHTZSHIFT; - if (pindex >= MAXLIGHTZ) - pindex = MAXLIGHTZ - 1; - ds_colormap = planezlight[pindex]; - - if (!debugrender_highlight) + if (ds_flatlighting) { - if (currentplane->extra_colormap) - ds_colormap = currentplane->extra_colormap->colormap + (ds_colormap - colormaps); + ds_colormap = ds_flatlighting; + } + else + { + pindex = distance >> LIGHTZSHIFT; + if (pindex >= MAXLIGHTZ) + pindex = MAXLIGHTZ - 1; - ds_fullbright = colormaps; - if (encoremap && !currentplane->noencore) + ds_colormap = planezlight[pindex]; + + if (!debugrender_highlight) { - ds_colormap += COLORMAP_REMAPOFFSET; - ds_fullbright += COLORMAP_REMAPOFFSET; + if (currentplane->extra_colormap) + ds_colormap = currentplane->extra_colormap->colormap + (ds_colormap - colormaps); + + ds_fullbright = colormaps; + if (encoremap && !currentplane->noencore) + { + ds_colormap += COLORMAP_REMAPOFFSET; + ds_fullbright += COLORMAP_REMAPOFFSET; + } } } @@ -363,11 +374,17 @@ static visplane_t *new_visplane(unsigned hash) visplane_t *R_FindPlane(fixed_t height, INT32 picnum, INT32 lightlevel, fixed_t xoff, fixed_t yoff, angle_t plangle, extracolormap_t *planecolormap, ffloor_t *pfloor, polyobj_t *polyobj, pslope_t *slope, boolean noencore, - boolean ripple, boolean reverseLight, const sector_t *lighting_sector) + boolean ripple, boolean reverseLight, const sector_t *lighting_sector, + sectordamage_t damage) { visplane_t *check; unsigned hash; + if (!cv_debugfinishline.value) + { + damage = SD_NONE; + } + if (!slope) // Don't mess with this right now if a slope is involved { if (plangle != 0) @@ -446,7 +463,8 @@ visplane_t *R_FindPlane(fixed_t height, INT32 picnum, INT32 lightlevel, && check->plangle == plangle && check->slope == slope && check->noencore == noencore - && check->ripple == ripple) + && check->ripple == ripple + && check->damage == damage) { return check; } @@ -477,6 +495,7 @@ visplane_t *R_FindPlane(fixed_t height, INT32 picnum, INT32 lightlevel, check->slope = slope; check->noencore = noencore; check->ripple = ripple; + check->damage = damage; memset(check->top, 0xff, sizeof (check->top)); memset(check->bottom, 0x00, sizeof (check->bottom)); @@ -555,6 +574,7 @@ visplane_t *R_CheckPlane(visplane_t *pl, INT32 start, INT32 stop) new_pl->slope = pl->slope; new_pl->noencore = pl->noencore; new_pl->ripple = pl->ripple; + new_pl->damage = pl->damage; pl = new_pl; pl->minx = start; pl->maxx = stop; @@ -865,6 +885,7 @@ void R_DrawSinglePlane(visplane_t *pl) INT32 type, spanfunctype = BASEDRAWFUNC; debugrender_highlight_t debug = debugrender_highlight_t::SW_HI_PLANES; void (*mapfunc)(INT32, INT32, INT32) = R_MapPlane; + bool highlight = R_PlaneIsHighlighted(pl); if (!(pl->minx <= pl->maxx)) return; @@ -874,7 +895,22 @@ void R_DrawSinglePlane(visplane_t *pl) // sky flat if (pl->picnum == skyflatnum) { - R_DrawSkyPlane(pl); + if (highlight) + { + r8_flatcolor = 35; // red + dc_lightmap = colormaps; + + for (dc_x = pl->minx; dc_x <= pl->maxx; ++dc_x) + { + dc_yl = pl->top[dc_x]; + dc_yh = pl->bottom[dc_x]; + R_DrawColumn_Flat_8(); + } + } + else + { + R_DrawSkyPlane(pl); + } return; } @@ -927,6 +963,7 @@ void R_DrawSinglePlane(visplane_t *pl) // Hacked up support for alpha value in software mode Tails 09-24-2002 // ...unhacked by toaster 04-01-2021 + if (!highlight) { INT32 trans = (10*((256+12) - pl->ffloor->alpha))/255; if (trans >= 10) @@ -1121,11 +1158,20 @@ void R_DrawSinglePlane(visplane_t *pl) planezlight = zlight[light]; } + if (highlight && R_SetSpanFuncFlat(BASEDRAWFUNC)) + { + r8_flatcolor = 35; // red + ds_flatlighting = colormaps; + } + else + { + R_CheckDebugHighlight(debug); - R_CheckDebugHighlight(debug); + // Use the correct span drawer depending on the powers-of-twoness + R_SetSpanFunc(spanfunctype, !ds_powersoftwo, ds_brightmap != NULL); - // Use the correct span drawer depending on the powers-of-twoness - R_SetSpanFunc(spanfunctype, !ds_powersoftwo, ds_brightmap != NULL); + ds_flatlighting = NULL; + } // set the maximum value for unsigned pl->top[pl->maxx+1] = 0xffff; @@ -1228,3 +1274,8 @@ void R_PlaneBounds(visplane_t *plane) plane->high = hi; plane->low = low; } + +boolean R_PlaneIsHighlighted(const visplane_t *pl) +{ + return pl->damage == SD_DEATHPIT || pl->damage == SD_INSTAKILL; +} diff --git a/src/r_plane.h b/src/r_plane.h index 2a77dcfea..2d2f5b04e 100644 --- a/src/r_plane.h +++ b/src/r_plane.h @@ -20,6 +20,7 @@ extern "C" { #include "screen.h" // needs MAXVIDWIDTH/MAXVIDHEIGHT #include "r_data.h" +#include "r_defs.h" #include "r_textures.h" #include "p_polyobj.h" @@ -60,6 +61,7 @@ struct visplane_t boolean noencore; boolean ripple; + sectordamage_t damage; }; extern visplane_t *visplanes[MAXVISPLANES]; @@ -88,7 +90,7 @@ void R_ClearFFloorClips (void); void R_DrawPlanes(void); visplane_t *R_FindPlane(fixed_t height, INT32 picnum, INT32 lightlevel, fixed_t xoff, fixed_t yoff, angle_t plangle, extracolormap_t *planecolormap, ffloor_t *ffloor, polyobj_t *polyobj, pslope_t *slope, boolean noencore, - boolean ripple, boolean reverseLight, const sector_t *lighting_sector); + boolean ripple, boolean reverseLight, const sector_t *lighting_sector, sectordamage_t damage); visplane_t *R_CheckPlane(visplane_t *pl, INT32 start, INT32 stop); void R_ExpandPlane(visplane_t *pl, INT32 start, INT32 stop); void R_PlaneBounds(visplane_t *plane); @@ -108,6 +110,8 @@ void R_CalculateSlopeVectors(void); // Sets the slope vector pointers for the current tilted span. void R_SetTiltedSpan(INT32 span); +boolean R_PlaneIsHighlighted(const visplane_t *pl); + struct visffloor_t { visplane_t *plane; diff --git a/src/r_portal.c b/src/r_portal.c index 86c727e1e..b7dd855e8 100644 --- a/src/r_portal.c +++ b/src/r_portal.c @@ -300,7 +300,7 @@ void Portal_AddSkyboxPortals (const player_t *player) { for (pl = visplanes[i]; pl; pl = pl->next) { - if (pl->picnum == skyflatnum) + if (pl->picnum == skyflatnum && !pl->damage) { Portal_AddSkybox(player, pl); diff --git a/src/r_segs.cpp b/src/r_segs.cpp index 6c79e5543..9e0a27042 100644 --- a/src/r_segs.cpp +++ b/src/r_segs.cpp @@ -13,6 +13,7 @@ #include +#include "command.h" #include "doomdef.h" #include "r_local.h" #include "r_sky.h" @@ -30,6 +31,8 @@ #include "taglist.h" #include "r_draw.h" +extern "C" consvar_t cv_debugfinishline; + #define HEIGHTBITS 12 #define HEIGHTUNIT (1<extra_colormap != backsector->extra_colormap || (frontsector->ffloors != backsector->ffloors && !Tag_Compare(&frontsector->tags, &backsector->tags)) // Portals block traversal behind them - || g_portal) + || g_portal + // Highlighting death pits + || (cv_debugfinishline.value && frontsector->damagetype != backsector->damagetype)) { markfloor = true; } @@ -2147,7 +2152,9 @@ void R_StoreWallRange(INT32 start, INT32 stop) || frontsector->extra_colormap != backsector->extra_colormap || (frontsector->ffloors != backsector->ffloors && !Tag_Compare(&frontsector->tags, &backsector->tags)) // Portals block traversal behind them - || g_portal) + || g_portal + // Highlighting death pits + || (cv_debugfinishline.value && frontsector->damagetype != backsector->damagetype)) { markceiling = true; } @@ -2713,7 +2720,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) { for (rover = backsector->ffloors; rover && i < MAXFFLOORS; rover = rover->next) { - if (!(rover->fofflags & FOF_EXISTS) || !(rover->fofflags & FOF_RENDERPLANES)) + if (!(rover->fofflags & FOF_EXISTS) || (!cv_debugfinishline.value && !(rover->fofflags & FOF_RENDERPLANES))) continue; if (rover->norender == leveltime) continue; @@ -2770,7 +2777,7 @@ void R_StoreWallRange(INT32 start, INT32 stop) { for (rover = frontsector->ffloors; rover && i < MAXFFLOORS; rover = rover->next) { - if (!(rover->fofflags & FOF_EXISTS) || !(rover->fofflags & FOF_RENDERPLANES)) + if (!(rover->fofflags & FOF_EXISTS) || (!cv_debugfinishline.value && !(rover->fofflags & FOF_RENDERPLANES))) continue; if (rover->norender == leveltime) continue; diff --git a/src/screen.c b/src/screen.c index 0e4bbb109..bc4c51c78 100644 --- a/src/screen.c +++ b/src/screen.c @@ -238,11 +238,12 @@ void R_SetSpanFunc(size_t id, boolean npo2, boolean brightmapped) { I_Assert(id < SPANDRAWFUNC_MAX); - if (spanfuncs_flat[id] != NULL && debugrender_highlight != 0) + if (debugrender_highlight != 0 && R_SetSpanFuncFlat(id)) { - spanfunc = spanfuncs_flat[id]; + return; } - else if (spanfuncs_npo2[id] != NULL && npo2 == true) + + if (spanfuncs_npo2[id] != NULL && npo2 == true) { spanfunc = spanfuncs_npo2[id]; } @@ -258,6 +259,20 @@ void R_SetSpanFunc(size_t id, boolean npo2, boolean brightmapped) } } +boolean R_SetSpanFuncFlat(size_t id) +{ + I_Assert(id < SPANDRAWFUNC_MAX); + + if (spanfuncs_flat[id] == NULL) + { + return false; + } + + spanfunc = spanfuncs_flat[id]; + + return true; +} + boolean R_CheckColumnFunc(size_t id) { size_t i; diff --git a/src/screen.h b/src/screen.h index e9cfc7d59..f80a41c7d 100644 --- a/src/screen.h +++ b/src/screen.h @@ -227,6 +227,7 @@ void SCR_SetDrawFuncs(void); // Set current column / span drawers void R_SetColumnFunc(size_t id, boolean brightmapped); void R_SetSpanFunc(size_t id, boolean npo2, boolean brightmapped); +boolean R_SetSpanFuncFlat(size_t id); // flat color // Compare current column drawer boolean R_CheckColumnFunc(size_t id); From adb3eb74630c38dad80e819e18a87ba91800ea48 Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 7 Oct 2023 14:36:20 -0700 Subject: [PATCH 2/3] ACS_Execute, ACS_ExecuteAlways: handle map stringargs --- src/acs/interface.cpp | 85 ++++++++++++++++++++++++++++++++++++------- src/acs/interface.h | 14 ++++--- src/p_spec.c | 20 +--------- 3 files changed, 82 insertions(+), 37 deletions(-) diff --git a/src/acs/interface.cpp b/src/acs/interface.cpp index 4c14a8e2e..8b56b6ebe 100644 --- a/src/acs/interface.cpp +++ b/src/acs/interface.cpp @@ -11,11 +11,14 @@ /// \file interface.cpp /// \brief Action Code Script: Interface for the rest of SRB2's game logic +#include #include #include #include #include +#include + #include "acsvm.hpp" #include "interface.h" @@ -347,31 +350,63 @@ void ACS_Tick(void) } /*-------------------------------------------------- - boolean ACS_Execute(const char *name, const INT32 *args, size_t numArgs, activator_t *activator) + static std::vector ACS_MixArgs(tcb::span args, tcb::span stringArgs) - See header file for description. + Convert strings to ACS arguments and position them + correctly among integer arguments. + + Input Arguments:- + args: Integer arguments. + stringArgs: C string arguments. + + Return:- + Final argument vector. --------------------------------------------------*/ -boolean ACS_Execute(const char *name, const INT32 *args, size_t numArgs, activator_t *activator) +static std::vector ACS_MixArgs(tcb::span args, tcb::span stringArgs) { - Environment *env = &ACSEnv; + std::vector argV; + size_t first = std::min(args.size(), stringArgs.size()); - ACSVM::GlobalScope *const global = env->getGlobalScope(0); - ACSVM::HubScope *const hub = global->getHubScope(0); - ACSVM::MapScope *const map = hub->getMapScope(0); - ACSVM::ScopeID scope{global->id, hub->id, map->id}; + auto new_string = [env = &ACSEnv](const char* str) -> ACSVM::Word { return ~env->getString(str, strlen(str))->idx; }; - ThreadInfo info{activator}; + for (size_t i = 0; i < first; ++i) + { + // args[i] must be 0. + // + // If ACS_Execute is called from ACS, stringargs[i] + // will always be set, because there is no + // differentiation between integers and strings on + // arguments passed to a function. In this case, + // string arguments already exist in the ACS string + // table beforehand (and set in args[i]), so no + // conversion is required here. + // + // If ACS_Execute is called from a map line special, + // args[i] may be left unset (0), while stringArgs[i] + // is set. In this case, conversion to ACS string + // table is necessary. + argV.push_back(!args[i] && stringArgs[i] ? new_string(stringArgs[i]) : args[i]); + } - ACSVM::String *script = env->getString(name, strlen(name)); - return map->scriptStart(script, scope, {reinterpret_cast(args), numArgs, &info}); + for (size_t i = first; i < args.size(); ++i) + { + argV.push_back(args[i]); + } + + for (size_t i = first; i < stringArgs.size(); ++i) + { + argV.push_back(new_string(stringArgs[i] ? stringArgs[i] : "")); + } + + return argV; } /*-------------------------------------------------- - boolean ACS_ExecuteAlways(const char *name, const INT32 *args, size_t numArgs, activator_t *activator) + boolean ACS_Execute(const char *name, const INT32 *args, size_t numArgs, const char *const *stringArgs, size_t numStringArgs, activator_t *activator) See header file for description. --------------------------------------------------*/ -boolean ACS_ExecuteAlways(const char *name, const INT32 *args, size_t numArgs, activator_t *activator) +boolean ACS_Execute(const char *name, const INT32 *args, size_t numArgs, const char *const *stringArgs, size_t numStringArgs, activator_t *activator) { Environment *env = &ACSEnv; @@ -383,7 +418,29 @@ boolean ACS_ExecuteAlways(const char *name, const INT32 *args, size_t numArgs, a ThreadInfo info{activator}; ACSVM::String *script = env->getString(name, strlen(name)); - return map->scriptStartForced(script, scope, {reinterpret_cast(args), numArgs, &info}); + std::vector argV = ACS_MixArgs(tcb::span {args, numArgs}, tcb::span {stringArgs, numStringArgs}); + return map->scriptStart(script, scope, {argV.data(), argV.size(), &info}); +} + +/*-------------------------------------------------- + boolean ACS_ExecuteAlways(const char *name, const INT32 *args, size_t numArgs, const char *const *stringArgs, size_t numStringArgs, activator_t *activator) + + See header file for description. +--------------------------------------------------*/ +boolean ACS_ExecuteAlways(const char *name, const INT32 *args, size_t numArgs, const char *const *stringArgs, size_t numStringArgs, activator_t *activator) +{ + Environment *env = &ACSEnv; + + ACSVM::GlobalScope *const global = env->getGlobalScope(0); + ACSVM::HubScope *const hub = global->getHubScope(0); + ACSVM::MapScope *const map = hub->getMapScope(0); + ACSVM::ScopeID scope{global->id, hub->id, map->id}; + + ThreadInfo info{activator}; + + ACSVM::String *script = env->getString(name, strlen(name)); + std::vector argV = ACS_MixArgs(tcb::span {args, numArgs}, tcb::span {stringArgs, numStringArgs}); + return map->scriptStartForced(script, scope, {argV.data(), argV.size(), &info}); } /*-------------------------------------------------- diff --git a/src/acs/interface.h b/src/acs/interface.h index 5e9c9ba9f..32ba78b90 100644 --- a/src/acs/interface.h +++ b/src/acs/interface.h @@ -201,7 +201,7 @@ void ACS_Tick(void); /*-------------------------------------------------- - boolean ACS_Execute(const char *name, const INT32 *args, size_t numArgs, activator_t *activator); + boolean ACS_Execute(const INT32 *args, size_t numArgs, const char *const *stringArgs, size_t numStringArgs, activator_t *activator); Runs an ACS script by its string name. Only one instance of the script will run at @@ -213,6 +213,8 @@ void ACS_Tick(void); Strings should be transformed into ACSVM string IDs. numArgs: Number of input arguments. + stringArgs: Array of input string arguments. + numStringArgs: Number of input string arguments. activator: Container for information on what activated this script. @@ -220,11 +222,11 @@ void ACS_Tick(void); true if we were able to run the script, otherwise false. --------------------------------------------------*/ -boolean ACS_Execute(const char *name, const INT32 *args, size_t numArgs, activator_t *activator); +boolean ACS_Execute(const char *name, const INT32 *args, size_t numArgs, const char *const *stringArgs, size_t numStringArgs, activator_t *activator); /*-------------------------------------------------- - boolean ACS_ExecuteAlways(const char *name, const INT32 *args, size_t numArgs, activator_t *activator); + boolean ACS_ExecuteAlways(const INT32 *args, size_t numArgs, const char *const *stringArgs, size_t numStringArgs, activator_t *activator) Runs an ACS script by its string name. If the script is already running, this method @@ -237,6 +239,8 @@ boolean ACS_Execute(const char *name, const INT32 *args, size_t numArgs, activat Strings should be transformed into ACSVM string IDs. numArgs: Number of input arguments. + stringArgs: Array of input string arguments. + numStringArgs: Number of input string arguments. activator: Container for information on what activated this script. @@ -244,11 +248,11 @@ boolean ACS_Execute(const char *name, const INT32 *args, size_t numArgs, activat true if we were able to run the script, otherwise false. --------------------------------------------------*/ -boolean ACS_ExecuteAlways(const char *name, const INT32 *args, size_t numArgs, activator_t *activator); +boolean ACS_ExecuteAlways(const char *name, const INT32 *args, size_t numArgs, const char *const *stringArgs, size_t numStringArgs, activator_t *activator); /*-------------------------------------------------- - INT32 ACS_ExecuteResult(const char *name, const INT32 *args, size_t numArgs, activator_t *activator); + INT32 ACS_ExecuteResult(const char *name, const INT32 *args, size_t numArgs, activator_t *activator) Runs an ACS script by its string name. Will return the scripts special result diff --git a/src/p_spec.c b/src/p_spec.c index 599ee327f..49fa5f441 100644 --- a/src/p_spec.c +++ b/src/p_spec.c @@ -4307,40 +4307,24 @@ boolean P_ProcessSpecial(activator_t *activator, INT16 special, INT32 *args, cha case 475: // ACS_Execute { - INT32 newArgs[NUM_SCRIPT_ARGS-1] = {0}; - INT32 i; - if (!stringargs[0]) { CONS_Debug(DBG_GAMELOGIC, "Special type 475: No script name given\n"); return false; } - for (i = 1; i < NUM_SCRIPT_ARGS; i++) - { - newArgs[i - 1] = args[i]; - } - - ACS_Execute(stringargs[0], newArgs, NUM_SCRIPT_ARGS-1, activator); + ACS_Execute(stringargs[0], &args[1], NUM_SCRIPT_ARGS - 1, (const char* const*)&stringargs[1], NUM_SCRIPT_STRINGARGS - 1, activator); } break; case 476: // ACS_ExecuteAlways { - INT32 newArgs[NUM_SCRIPT_ARGS-1] = {0}; - INT32 i; - if (!stringargs[0]) { CONS_Debug(DBG_GAMELOGIC, "Special type 475: No script name given\n"); return false; } - for (i = 1; i < NUM_SCRIPT_ARGS; i++) - { - newArgs[i - 1] = args[i]; - } - - ACS_ExecuteAlways(stringargs[0], newArgs, NUM_SCRIPT_ARGS-1, activator); + ACS_ExecuteAlways(stringargs[0], &args[1], NUM_SCRIPT_ARGS - 1, (const char* const*)&stringargs[1], NUM_SCRIPT_STRINGARGS - 1, activator); } break; case 477: // ACS_Suspend From 91ce31c11dbb491416d1100e29bd61cd819bf10a Mon Sep 17 00:00:00 2001 From: James R Date: Sat, 7 Oct 2023 21:37:15 -0700 Subject: [PATCH 3/3] MT_SUNBEAMPALM_STEM: adjust radius for new sprite --- src/info.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/info.c b/src/info.c index cad341f2c..61e08600f 100644 --- a/src/info.c +++ b/src/info.c @@ -29446,7 +29446,7 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] = S_NULL, // xdeathstate sfx_None, // deathsound 0, // speed - 90<