mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2026-04-21 17:41:48 +00:00
Fix crashes & off-by-one errors
This commit is contained in:
parent
de1f67b72a
commit
1115486689
5 changed files with 32 additions and 18 deletions
10
src/k_hud.c
10
src/k_hud.c
|
|
@ -3015,7 +3015,7 @@ static void K_drawKartMinimapIcon(fixed_t objx, fixed_t objy, INT32 hudx, INT32
|
|||
|
||||
static void K_drawKartMinimap(void)
|
||||
{
|
||||
INT32 lumpnum = LUMPERROR;
|
||||
lumpnum_t lumpnum = LUMPERROR;
|
||||
patch_t *AutomapPic;
|
||||
INT32 i = 0;
|
||||
INT32 x, y;
|
||||
|
|
@ -3042,10 +3042,12 @@ static void K_drawKartMinimap(void)
|
|||
lumpnum = W_CheckNumForLongName(mapheaderinfo[gamemap-1]->minimapLump);
|
||||
}
|
||||
|
||||
if (lumpnum != -1)
|
||||
AutomapPic = W_CachePatchNum(lumpnum, PU_HUDGFX);
|
||||
else
|
||||
if (lumpnum == LUMPERROR)
|
||||
{
|
||||
return; // no pic, just get outta here
|
||||
}
|
||||
|
||||
AutomapPic = W_CachePatchNum(lumpnum, PU_HUDGFX);
|
||||
|
||||
x = MINI_X - (AutomapPic->width/2);
|
||||
y = MINI_Y - (AutomapPic->height/2);
|
||||
|
|
|
|||
|
|
@ -644,6 +644,7 @@ static int libd_drawStretched(lua_State *L)
|
|||
}
|
||||
|
||||
// KART: draw patch on minimap from x, y coordinates on the map
|
||||
// Sal: Let's please just merge the relevant info into the actual function, and have Lua call that...
|
||||
static int libd_drawOnMinimap(lua_State *L)
|
||||
{
|
||||
fixed_t x, y, scale; // coordinates of the object
|
||||
|
|
@ -652,7 +653,7 @@ static int libd_drawOnMinimap(lua_State *L)
|
|||
boolean centered; // the patch is centered and doesn't need readjusting on x/y coordinates.
|
||||
|
||||
// variables used to replicate k_kart's mmap drawer:
|
||||
INT32 lumpnum = LUMPERROR;
|
||||
lumpnum_t lumpnum = LUMPERROR;
|
||||
patch_t *AutomapPic;
|
||||
INT32 mx, my;
|
||||
INT32 splitflags, minimaptrans;
|
||||
|
|
@ -743,10 +744,12 @@ static int libd_drawOnMinimap(lua_State *L)
|
|||
lumpnum = W_CheckNumForLongName(mapheaderinfo[gamemap-1]->minimapLump);
|
||||
}
|
||||
|
||||
if (lumpnum != -1)
|
||||
AutomapPic = W_CachePatchNum(lumpnum, PU_HUDGFX);
|
||||
else
|
||||
if (lumpnum == LUMPERROR)
|
||||
{
|
||||
return 0; // no pic, just get outta here
|
||||
}
|
||||
|
||||
AutomapPic = W_CachePatchNum(lumpnum, PU_HUDGFX);
|
||||
|
||||
mx = MM_X - (AutomapPic->width/2);
|
||||
my = MM_Y - (AutomapPic->height/2);
|
||||
|
|
|
|||
21
src/m_menu.c
21
src/m_menu.c
|
|
@ -5527,9 +5527,9 @@ static void DrawReplayHutReplayInfo(void)
|
|||
// A 160x100 image of the level as entry MAPxxP
|
||||
//CONS_Printf("%d %s\n", demolist[dir_on[menudepthleft]].map, G_BuildMapName(demolist[dir_on[menudepthleft]].map));
|
||||
|
||||
if (mapheaderinfo[demolist[dir_on[menudepthleft]].map])
|
||||
if (mapheaderinfo[demolist[dir_on[menudepthleft]].map - 1])
|
||||
{
|
||||
lumpnum = W_CheckNumForLongName(mapheaderinfo[demolist[dir_on[menudepthleft]].map]->thumbnailLump);
|
||||
lumpnum = W_CheckNumForLongName(mapheaderinfo[demolist[dir_on[menudepthleft]].map - 1]->thumbnailLump);
|
||||
}
|
||||
|
||||
if (lumpnum != LUMPERROR)
|
||||
|
|
@ -8882,16 +8882,17 @@ static void M_StartServer(INT32 choice)
|
|||
|
||||
static void M_DrawLevelSelectOnly(boolean leftfade, boolean rightfade)
|
||||
{
|
||||
lumpnum_t lumpnum = LUMPERROR;
|
||||
lumpnum_t lumpnum;
|
||||
patch_t *PictureOfLevel;
|
||||
INT32 x, y, w, i, oldval, trans, dupadjust = ((vid.width/vid.dupx) - BASEVIDWIDTH)>>1;
|
||||
|
||||
// A 160x100 image of the level as entry MAPxxP
|
||||
if (cv_nextmap.value)
|
||||
{
|
||||
if (mapheaderinfo[cv_nextmap.value])
|
||||
lumpnum = LUMPERROR;
|
||||
if (mapheaderinfo[cv_nextmap.value-1])
|
||||
{
|
||||
lumpnum = W_CheckNumForLongName(mapheaderinfo[cv_nextmap.value]->thumbnailLump);
|
||||
lumpnum = W_CheckNumForLongName(mapheaderinfo[cv_nextmap.value-1]->thumbnailLump);
|
||||
}
|
||||
|
||||
if (lumpnum != LUMPERROR)
|
||||
|
|
@ -8959,9 +8960,10 @@ static void M_DrawLevelSelectOnly(boolean leftfade, boolean rightfade)
|
|||
// A 160x100 image of the level as entry MAPxxP
|
||||
if (i+1)
|
||||
{
|
||||
if (mapheaderinfo[i+1])
|
||||
lumpnum = LUMPERROR;
|
||||
if (mapheaderinfo[i])
|
||||
{
|
||||
lumpnum = W_CheckNumForLongName(mapheaderinfo[i+1]->thumbnailLump);
|
||||
lumpnum = W_CheckNumForLongName(mapheaderinfo[i]->thumbnailLump);
|
||||
}
|
||||
|
||||
if (lumpnum != LUMPERROR)
|
||||
|
|
@ -9001,9 +9003,10 @@ static void M_DrawLevelSelectOnly(boolean leftfade, boolean rightfade)
|
|||
// A 160x100 image of the level as entry MAPxxP
|
||||
if (i+1)
|
||||
{
|
||||
if (mapheaderinfo[i+1])
|
||||
lumpnum = LUMPERROR;
|
||||
if (mapheaderinfo[i])
|
||||
{
|
||||
lumpnum = W_CheckNumForLongName(mapheaderinfo[i+1]->thumbnailLump);
|
||||
lumpnum = W_CheckNumForLongName(mapheaderinfo[i]->thumbnailLump);
|
||||
}
|
||||
|
||||
if (lumpnum != LUMPERROR)
|
||||
|
|
|
|||
|
|
@ -1135,6 +1135,9 @@ lumpnum_t W_CheckNumForName(const char *name)
|
|||
INT32 i;
|
||||
lumpnum_t check = INT16_MAX;
|
||||
|
||||
if (name == NULL)
|
||||
return LUMPERROR;
|
||||
|
||||
if (!*name) // some doofus gave us an empty string?
|
||||
return LUMPERROR;
|
||||
|
||||
|
|
@ -1182,6 +1185,9 @@ lumpnum_t W_CheckNumForLongName(const char *name)
|
|||
INT32 i;
|
||||
lumpnum_t check = INT16_MAX;
|
||||
|
||||
if (name == NULL)
|
||||
return LUMPERROR;
|
||||
|
||||
if (!*name) // some doofus gave us an empty string?
|
||||
return LUMPERROR;
|
||||
|
||||
|
|
|
|||
|
|
@ -1790,7 +1790,7 @@ void Y_StartVote(void)
|
|||
// set up the pic
|
||||
if (mapheaderinfo[votelevels[i][0]+1])
|
||||
{
|
||||
lumpnum = W_CheckNumForLongName(mapheaderinfo[votelevels[i][0]+1]->thumbnailLump);
|
||||
lumpnum = W_CheckNumForLongName(mapheaderinfo[votelevels[i][0]]->thumbnailLump);
|
||||
}
|
||||
|
||||
if (lumpnum != LUMPERROR)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue