Init roulette before prehook can bail, IDIOT

This commit is contained in:
Antonio Martinez 2025-07-10 04:48:19 -04:00
parent 4ed4989f3b
commit 23912a7c63

View file

@ -1164,19 +1164,40 @@ static boolean K_TimingPermitsItem(kartitems_t item, const itemroulette_t *roule
void K_FillItemRoulette(player_t *const player, itemroulette_t *const roulette, boolean ringbox) void K_FillItemRoulette(player_t *const player, itemroulette_t *const roulette, boolean ringbox)
{ {
K_InitRoulette(roulette);
if (player != NULL)
{
roulette->baseDist = K_UndoMapScaling(player->distancetofinish);
if (player->pflags & PF_AUTOROULETTE)
roulette->autoroulette = true;
K_CalculateRouletteSpeed(roulette);
}
CONS_Printf("HC: prehook\n");
// Lua may want to intercept reelbuilder entirely. // Lua may want to intercept reelbuilder entirely.
LUA_HookPreFillItemRoulette(player, roulette); LUA_HookPreFillItemRoulette(player, roulette);
CONS_Printf("HC: bail\n");
// If prehook did something, no need to continue. // If prehook did something, no need to continue.
if (roulette->itemList.len != 0) { if (roulette->itemList.len != 0) {
return; return;
} }
CONS_Printf("HC: fill\n");
K_FillItemRouletteData(player, roulette, ringbox, false); K_FillItemRouletteData(player, roulette, ringbox, false);
CONS_Printf("HC: posthook\n");
// Lua can modify the final result. // Lua can modify the final result.
LUA_HookFillItemRoulette(player, roulette); LUA_HookFillItemRoulette(player, roulette);
CONS_Printf("HC: out\n");
// If somehow there's no items, add sad. // If somehow there's no items, add sad.
if (roulette->itemList.len == 0) { if (roulette->itemList.len == 0) {
K_AddItemToReel(player, roulette, KITEM_SAD); K_AddItemToReel(player, roulette, KITEM_SAD);
@ -1199,18 +1220,6 @@ void K_FillItemRouletteData(player_t *player, itemroulette_t *const roulette, bo
size_t i, j; size_t i, j;
K_InitRoulette(roulette);
if (player != NULL)
{
roulette->baseDist = K_UndoMapScaling(player->distancetofinish);
if (player->pflags & PF_AUTOROULETTE)
roulette->autoroulette = true;
K_CalculateRouletteSpeed(roulette);
}
if (ringbox == true) if (ringbox == true)
{ {
// If this is being invoked by a Ring Box, it should literally never produce items. // If this is being invoked by a Ring Box, it should literally never produce items.