mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2026-04-27 12:31:54 +00:00
Refactor in preperation for scaling feature
Return a `minigen_t` struct with explicit width and height instead of extending the UINT8 buffer by 2 to provide that information in a very datatype-limited way.
This commit is contained in:
parent
da639fe65f
commit
ea7e29f279
4 changed files with 23 additions and 15 deletions
17
src/am_map.c
17
src/am_map.c
|
|
@ -1353,13 +1353,16 @@ void AM_Drawer(void)
|
||||||
if (!followplayer) AM_drawCrosshair(XHAIRCOLORS);
|
if (!followplayer) AM_drawCrosshair(XHAIRCOLORS);
|
||||||
}
|
}
|
||||||
|
|
||||||
UINT8 *AM_MinimapGenerate(INT32 wh)
|
minigen_t *AM_MinimapGenerate(INT32 wh)
|
||||||
{
|
{
|
||||||
UINT8 *buf = NULL;
|
static minigen_t ret = {0};
|
||||||
|
|
||||||
if (automapactive)
|
if (automapactive)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
ret.w = ret.h = 0;
|
||||||
|
ret.buf = NULL;
|
||||||
|
|
||||||
am_minigen = true;
|
am_minigen = true;
|
||||||
|
|
||||||
AM_drawFline = AM_drawFline_soft; // yes, even in GL
|
AM_drawFline = AM_drawFline_soft; // yes, even in GL
|
||||||
|
|
@ -1396,9 +1399,9 @@ UINT8 *AM_MinimapGenerate(INT32 wh)
|
||||||
old_m_w = m_w;
|
old_m_w = m_w;
|
||||||
old_m_h = m_h;
|
old_m_h = m_h;
|
||||||
|
|
||||||
buf = malloc(2 + (f_w*f_h));
|
ret.w = f_w;
|
||||||
|
ret.h = f_h;
|
||||||
am_buf = buf+2;
|
am_buf = ret.buf = malloc((f_w*f_h));
|
||||||
|
|
||||||
//AM_clearFB(BACKGROUND);
|
//AM_clearFB(BACKGROUND);
|
||||||
memset(am_buf, 0xff, (f_w*f_h));
|
memset(am_buf, 0xff, (f_w*f_h));
|
||||||
|
|
@ -1411,7 +1414,5 @@ UINT8 *AM_MinimapGenerate(INT32 wh)
|
||||||
|
|
||||||
am_minigen = false;
|
am_minigen = false;
|
||||||
|
|
||||||
buf[0] = (UINT8)f_w;
|
return &ret;
|
||||||
buf[1] = (UINT8)f_h;
|
|
||||||
return buf;
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -48,8 +48,14 @@ void AM_Start(void);
|
||||||
// Called to force the automap to quit if the level is completed while it is up.
|
// Called to force the automap to quit if the level is completed while it is up.
|
||||||
void AM_Stop(void);
|
void AM_Stop(void);
|
||||||
|
|
||||||
|
struct minigen_t
|
||||||
|
{
|
||||||
|
INT32 w, h;
|
||||||
|
UINT8 *buf;
|
||||||
|
};
|
||||||
|
|
||||||
// Minimap generation
|
// Minimap generation
|
||||||
UINT8 *AM_MinimapGenerate(INT32 wh);
|
minigen_t *AM_MinimapGenerate(INT32 wh);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
} // extern "C"
|
} // extern "C"
|
||||||
|
|
|
||||||
12
src/m_misc.c
12
src/m_misc.c
|
|
@ -1754,7 +1754,7 @@ void M_MinimapGenerate(void)
|
||||||
#ifdef USE_PNG
|
#ifdef USE_PNG
|
||||||
char *filepath = va(pandf, srb2home, "MINIMAP.png");
|
char *filepath = va(pandf, srb2home, "MINIMAP.png");
|
||||||
boolean ret = false;
|
boolean ret = false;
|
||||||
UINT8 *linear = NULL;
|
minigen_t *minigen = NULL;
|
||||||
INT32 wh = 100;
|
INT32 wh = 100;
|
||||||
|
|
||||||
if (gamestate != GS_LEVEL)
|
if (gamestate != GS_LEVEL)
|
||||||
|
|
@ -1763,17 +1763,17 @@ void M_MinimapGenerate(void)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
linear = AM_MinimapGenerate(wh);
|
minigen = AM_MinimapGenerate(wh);
|
||||||
|
|
||||||
if (linear == NULL)
|
if (minigen == NULL || minigen->buf == NULL)
|
||||||
goto failure;
|
goto failure;
|
||||||
|
|
||||||
M_CreateScreenShotPalette();
|
M_CreateScreenShotPalette();
|
||||||
ret = M_SavePNG(filepath, linear+2, linear[0], linear[1], screenshot_palette);
|
ret = M_SavePNG(filepath, minigen->buf, minigen->w, minigen->h, screenshot_palette);
|
||||||
|
|
||||||
failure:
|
failure:
|
||||||
if (linear != NULL)
|
if (minigen->buf != NULL)
|
||||||
free(linear);
|
free(minigen->buf);
|
||||||
|
|
||||||
if (ret)
|
if (ret)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -26,6 +26,7 @@ extern "C" {
|
||||||
// am_map.h
|
// am_map.h
|
||||||
TYPEDEF (fpoint_t);
|
TYPEDEF (fpoint_t);
|
||||||
TYPEDEF (fline_t);
|
TYPEDEF (fline_t);
|
||||||
|
TYPEDEF (minigen_t);
|
||||||
|
|
||||||
// command.h
|
// command.h
|
||||||
TYPEDEF (vsbuf_t);
|
TYPEDEF (vsbuf_t);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue