Add map target time

This commit is contained in:
Miloslav Ciz 2025-01-15 21:29:38 +01:00
parent ea57ecd470
commit 9d2c6108b1
3 changed files with 60 additions and 35 deletions

22
map.h
View file

@ -13,10 +13,12 @@
The TEXT format serves for editing maps in human readable format, it more or
less corresponds to the binary storage format (below) with some exceptions.
It has the following structure:
- Number specifying environment (0, 1, 2, ...)
- A series of block strings. Blocks may be separated by characters that
aren't ':' (comments may be added this way). Block format
is following:
- Target time as a decimal number of milliseconds.
- Non-decimal character.
- Number of environment (0, 1, 2, ...)
- A series of block strings. Blocks may be preceded/followed by characters
that aren't ':' (comments may be added this way). Block format is
following:
:BXYZMT
@ -153,6 +155,7 @@ struct
uint8_t checkpointCount;
uint32_t hash; ///< Hash of the processed binary map.
uint32_t targetTime;
char name[LCR_MAP_NAME_MAX_LEN + 1];
} LCR_currentMap;
@ -398,11 +401,22 @@ uint8_t LCR_mapLoadFromStr(char (*getNextCharFunc)(void), const char *name)
for (int i = 0; i < 4; ++i)
LCR_currentMap.startPos[i] = 0;
LCR_currentMap.targetTime = 0;
LCR_currentMap.checkpointCount = 0;
LCR_currentMap.blockCount = 0;
LCR_currentMap.environment = 0;
LCR_currentMap.hash = 0;
while (1) // read target time
{
c = getNextCharFunc();
if (c >= '0' && c <= '9')
LCR_currentMap.targetTime = LCR_currentMap.targetTime * 10 + c - '0';
else
break;
}
c = getNextCharFunc();
if (c < '0' || c > '3')