mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2026-02-20 04:21:52 +00:00
No longer dynamically allocate roulette list
Done with the issues trying to sync this memory over the wire, so now it's just a long static array...
This commit is contained in:
parent
59ee8177d7
commit
c184567361
3 changed files with 78 additions and 12 deletions
|
|
@ -331,13 +331,23 @@ struct skybox_t {
|
|||
};
|
||||
|
||||
// player_t struct for item roulette variables
|
||||
|
||||
// Doing this the right way is causing problems.
|
||||
// so FINE, it's a static length now.
|
||||
#define ITEM_LIST_SIZE (NUMKARTRESULTS * 20)
|
||||
|
||||
struct itemroulette_t
|
||||
{
|
||||
boolean active;
|
||||
|
||||
#ifdef ITEM_LIST_SIZE
|
||||
size_t itemListLen;
|
||||
SINT8 itemList[ITEM_LIST_SIZE];
|
||||
#else
|
||||
size_t itemListCap;
|
||||
size_t itemListLen;
|
||||
SINT8 *itemList;
|
||||
#endif
|
||||
|
||||
UINT8 useOdds;
|
||||
size_t index;
|
||||
|
|
|
|||
|
|
@ -724,6 +724,7 @@ boolean K_ForcedSPB(player_t *const player)
|
|||
|
||||
static void K_InitRoulette(itemroulette_t *const roulette)
|
||||
{
|
||||
#ifndef ITEM_LIST_SIZE
|
||||
if (roulette->itemList == NULL)
|
||||
{
|
||||
roulette->itemListCap = 8;
|
||||
|
|
@ -732,7 +733,13 @@ static void K_InitRoulette(itemroulette_t *const roulette)
|
|||
PU_STATIC,
|
||||
&roulette->itemList
|
||||
);
|
||||
|
||||
if (roulette->itemList == NULL)
|
||||
{
|
||||
I_Error("Not enough memory for item roulette list\n");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
roulette->itemListLen = 0;
|
||||
roulette->index = 0;
|
||||
|
|
@ -747,6 +754,13 @@ static void K_InitRoulette(itemroulette_t *const roulette)
|
|||
|
||||
static void K_PushToRouletteItemList(itemroulette_t *const roulette, kartitems_t item)
|
||||
{
|
||||
#ifdef ITEM_LIST_SIZE
|
||||
if (roulette->itemListLen >= ITEM_LIST_SIZE)
|
||||
{
|
||||
I_Error("Out of space for item reel! Go and make ITEM_LIST_SIZE bigger I guess?\n");
|
||||
return;
|
||||
}
|
||||
#else
|
||||
I_Assert(roulette->itemList != NULL);
|
||||
|
||||
if (roulette->itemListLen >= roulette->itemListCap)
|
||||
|
|
@ -758,7 +772,13 @@ static void K_PushToRouletteItemList(itemroulette_t *const roulette, kartitems_t
|
|||
PU_STATIC,
|
||||
&roulette->itemList
|
||||
);
|
||||
|
||||
if (roulette->itemList == NULL)
|
||||
{
|
||||
I_Error("Not enough memory for item roulette list\n");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
roulette->itemList[ roulette->itemListLen ] = item;
|
||||
roulette->itemListLen++;
|
||||
|
|
@ -1008,7 +1028,11 @@ void K_KartItemRoulette(player_t *const player, ticcmd_t *const cmd)
|
|||
return;
|
||||
}
|
||||
|
||||
if (roulette->itemList == NULL || roulette->itemListLen == 0)
|
||||
if (roulette->itemListLen == 0
|
||||
#ifndef ITEM_LIST_SIZE
|
||||
|| roulette->itemList == NULL
|
||||
#endif
|
||||
)
|
||||
{
|
||||
// Invalid roulette setup.
|
||||
// Escape before we run into issues.
|
||||
|
|
|
|||
|
|
@ -96,7 +96,7 @@ static void P_NetArchivePlayers(void)
|
|||
{
|
||||
INT32 i, j;
|
||||
UINT16 flags;
|
||||
// size_t q;
|
||||
size_t q;
|
||||
|
||||
WRITEUINT32(save_p, ARCHIVEBLOCK_PLAYERS);
|
||||
|
||||
|
|
@ -410,19 +410,39 @@ static void P_NetArchivePlayers(void)
|
|||
|
||||
// itemroulette_t
|
||||
WRITEUINT8(save_p, players[i].itemRoulette.active);
|
||||
WRITEUINT32(save_p, players[i].itemRoulette.itemListCap);
|
||||
|
||||
#ifdef ITEM_LIST_SIZE
|
||||
WRITEUINT32(save_p, players[i].itemRoulette.itemListLen);
|
||||
for (j = 0; j < (signed)players[i].itemRoulette.itemListLen; j++)
|
||||
|
||||
for (q = 0; q < ITEM_LIST_SIZE; q++)
|
||||
{
|
||||
if (players[i].itemRoulette.itemList == NULL)
|
||||
if (q >= players[i].itemRoulette.itemListLen)
|
||||
{
|
||||
WRITESINT8(save_p, KITEM_NONE);
|
||||
}
|
||||
else
|
||||
{
|
||||
WRITESINT8(save_p, players[i].itemRoulette.itemList[j]);
|
||||
WRITESINT8(save_p, players[i].itemRoulette.itemList[q]);
|
||||
}
|
||||
}
|
||||
#else
|
||||
if (players[i].itemRoulette.itemList == NULL)
|
||||
{
|
||||
WRITEUINT32(save_p, 0);
|
||||
WRITEUINT32(save_p, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
WRITEUINT32(save_p, players[i].itemRoulette.itemListCap);
|
||||
WRITEUINT32(save_p, players[i].itemRoulette.itemListLen);
|
||||
|
||||
for (q = 0; q < players[i].itemRoulette.itemListLen; q++)
|
||||
{
|
||||
WRITESINT8(save_p, players[i].itemRoulette.itemList[q]);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
WRITEUINT8(save_p, players[i].itemRoulette.useOdds);
|
||||
WRITEUINT32(save_p, players[i].itemRoulette.index);
|
||||
WRITEUINT8(save_p, players[i].itemRoulette.sound);
|
||||
|
|
@ -437,6 +457,7 @@ static void P_NetUnArchivePlayers(void)
|
|||
{
|
||||
INT32 i, j;
|
||||
UINT16 flags;
|
||||
size_t q;
|
||||
|
||||
if (READUINT32(save_p) != ARCHIVEBLOCK_PLAYERS)
|
||||
I_Error("Bad $$$.sav at archive block Players");
|
||||
|
|
@ -732,6 +753,15 @@ static void P_NetUnArchivePlayers(void)
|
|||
|
||||
// itemroulette_t
|
||||
players[i].itemRoulette.active = (boolean)READUINT8(save_p);
|
||||
|
||||
#ifdef ITEM_LIST_SIZE
|
||||
players[i].itemRoulette.itemListLen = (size_t)READUINT32(save_p);
|
||||
|
||||
for (q = 0; q < ITEM_LIST_SIZE; q++)
|
||||
{
|
||||
players[i].itemRoulette.itemList[q] = READSINT8(save_p);
|
||||
}
|
||||
#else
|
||||
players[i].itemRoulette.itemListCap = (size_t)READUINT32(save_p);
|
||||
players[i].itemRoulette.itemListLen = (size_t)READUINT32(save_p);
|
||||
|
||||
|
|
@ -754,16 +784,18 @@ static void P_NetUnArchivePlayers(void)
|
|||
&players[i].itemRoulette.itemList
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
for (j = 0; j < (signed)players[i].itemRoulette.itemListLen; j++)
|
||||
{
|
||||
SINT8 item = READSINT8(save_p);
|
||||
if (players[i].itemRoulette.itemList != NULL)
|
||||
if (players[i].itemRoulette.itemList == NULL)
|
||||
{
|
||||
players[i].itemRoulette.itemList[j] = item;
|
||||
I_Error("Not enough memory for item roulette list\n");
|
||||
}
|
||||
|
||||
for (q = 0; q < players[i].itemRoulette.itemListLen; q++)
|
||||
{
|
||||
players[i].itemRoulette.itemList[q] = READSINT8(save_p);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
players[i].itemRoulette.useOdds = READUINT8(save_p);
|
||||
players[i].itemRoulette.index = (size_t)READUINT32(save_p);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue