mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2026-03-02 09:21:29 +00:00
Add LapsPerSection property to map headers, fixes finish line distance in hybrid section-circuit maps
- It is possible to have a circuit map separated into sections, where there are multiple "laps" before making a full loop - Normally the lap count is used to multiply the finish line distance, but it fails for these maps - The LapsPerSection property fixes the calculation by specifying how many laps make up a full loop - Default = 1 lap (most maps)
This commit is contained in:
parent
0d4f42cf80
commit
9f982a574e
5 changed files with 9 additions and 2 deletions
|
|
@ -1299,6 +1299,8 @@ void readlevelheader(MYFILE *f, char * name)
|
|||
mapheaderinfo[num]->encorepal = (UINT16)i;
|
||||
else if (fastcmp(word, "NUMLAPS"))
|
||||
mapheaderinfo[num]->numlaps = (UINT8)i;
|
||||
else if (fastcmp(word, "LAPSPERSECTION"))
|
||||
mapheaderinfo[num]->lapspersection = max((UINT8)i, 1u);
|
||||
else if (fastcmp(word, "SKYBOXSCALE"))
|
||||
mapheaderinfo[num]->skybox_scalex = mapheaderinfo[num]->skybox_scaley = mapheaderinfo[num]->skybox_scalez = (INT16)i;
|
||||
else if (fastcmp(word, "SKYBOXSCALEX"))
|
||||
|
|
|
|||
|
|
@ -509,6 +509,7 @@ struct mapheader_t
|
|||
UINT16 levelflags; ///< LF_flags: merged booleans into one UINT16 for space, see below
|
||||
UINT32 typeoflevel; ///< Combination of typeoflevel flags.
|
||||
UINT8 numlaps; ///< Number of laps in circuit mode, unless overridden.
|
||||
UINT8 lapspersection; ///< Number of laps per section in hybrid section-circuit maps.
|
||||
fixed_t gravity; ///< Map-wide gravity.
|
||||
char relevantskin[SKINNAMESIZE+1]; ///< Skin to use for tutorial (if not provided, uses Eggman.)
|
||||
|
||||
|
|
|
|||
|
|
@ -9891,9 +9891,10 @@ static void K_UpdateDistanceFromFinishLine(player_t *const player)
|
|||
// correct we need to add to it the length of the entire circuit multiplied by the number of laps
|
||||
// left after this one. This will give us the total distance to the finish line, and allow item
|
||||
// distance calculation to work easily
|
||||
if ((mapheaderinfo[gamemap - 1]->levelflags & LF_SECTIONRACE) == 0U)
|
||||
const mapheader_t *mapheader = mapheaderinfo[gamemap - 1];
|
||||
if ((mapheader->levelflags & LF_SECTIONRACE) == 0U)
|
||||
{
|
||||
const UINT8 numfulllapsleft = ((UINT8)numlaps - player->laps);
|
||||
const UINT8 numfulllapsleft = ((UINT8)numlaps - player->laps) / mapheader->lapspersection;
|
||||
player->distancetofinish += numfulllapsleft * K_GetCircuitLength();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2535,6 +2535,8 @@ static int mapheaderinfo_get(lua_State *L)
|
|||
lua_pushinteger(L, header->palette);
|
||||
else if (fastcmp(field,"numlaps"))
|
||||
lua_pushinteger(L, header->numlaps);
|
||||
else if (fastcmp(field,"lapspersection"))
|
||||
lua_pushinteger(L, header->lapspersection);
|
||||
else if (fastcmp(field,"levelselect"))
|
||||
lua_pushinteger(L, header->levelselect);
|
||||
else if (fastcmp(field,"levelflags"))
|
||||
|
|
|
|||
|
|
@ -458,6 +458,7 @@ static void P_ClearSingleMapHeaderInfo(INT16 num)
|
|||
mapheaderinfo[num]->palette = UINT16_MAX;
|
||||
mapheaderinfo[num]->encorepal = UINT16_MAX;
|
||||
mapheaderinfo[num]->numlaps = NUMLAPS_DEFAULT;
|
||||
mapheaderinfo[num]->lapspersection = 1;
|
||||
mapheaderinfo[num]->levelselect = 0;
|
||||
mapheaderinfo[num]->levelflags = 0;
|
||||
mapheaderinfo[num]->menuflags = 0;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue