Add quit block

This commit is contained in:
Miloslav Ciz 2025-02-03 18:57:53 +01:00
parent 7f00b5aa5f
commit 2a84afa981
4 changed files with 85 additions and 86 deletions

View file

@ -6,14 +6,6 @@
- replay stretching works - replay stretching works
- replay with input not occuring for more that LCR_SETTING_GHOST_STEP - replay with input not occuring for more that LCR_SETTING_GHOST_STEP
- replay validation - replay validation
- add argc/argv to gameInit? could be used to quickly start maps, verify
replays etc. Options:
-sN: sound (0/1)
-mN: music (0/1)
-cN: set camera
-M: load last map in resource files (good for making maps)
-R: load last replay in resource files (good for making TASes)
-P: load and play against last replay in resource files
- maybe each map could have a target time embedded: when beaten, the map would - maybe each map could have a target time embedded: when beaten, the map would
be marked as such be marked as such
- player name (modifiable via resource file) - player name (modifiable via resource file)
@ -33,6 +25,14 @@
=========== HANDLED ============== =========== HANDLED ==============
- allow stopping car rotation in air like in Trackmania - allow stopping car rotation in air like in Trackmania
- add argc/argv to gameInit? could be used to quickly start maps, verify
replays etc. Options:
-sN: sound (0/1)
-mN: music (0/1)
-cN: set camera
-M: load last map in resource files (good for making maps)
-R: load last replay in resource files (good for making TASes)
-P: load and play against last replay in resource files
- bug: background horizon position depends on resolution! fix - bug: background horizon position depends on resolution! fix
- option to disable crash sounds (and so code that detects crashes) - option to disable crash sounds (and so code that detects crashes)
- drawing dithered transparent objects fills z-buffer in the transparent parts - drawing dithered transparent objects fills z-buffer in the transparent parts

138
game.h
View file

@ -798,6 +798,75 @@ void LCR_gameLoadMainMenuItems(void)
LCR_game.menu.itemCount = 4; LCR_game.menu.itemCount = 4;
} }
/**
Loads up to LCR_RESOURCE_ITEM_CHUNK items of given type, starting at given
index (among items of the same type). This will also load the menu item names.
*/
void LCR_gameLoadDataFileChunk(unsigned int startIndex, char magicNumber)
{
char c;
unsigned char state = 0;
LCR_gameEraseMenuItemNames();
LCR_game.dataFile.firstItemIndex = startIndex;
LCR_game.dataFile.itemsTotal = 0;
LCR_gameRewindDataFile();
/* 3 iterations: in first we seek to the start index, in second we load the
names, in third we just read the rest to get the total count. */
for (int i = 0; i < 3; ++i)
{
while (1)
{
if (i == 0 && !startIndex)
break;
c = LCR_gameGetNextDataFileChar();
if (c == 0)
return;
if (state == 0) // second magic char
{
state = 255;
if (c == magicNumber)
{
LCR_game.dataFile.itemsTotal++;
if (i == 0)
startIndex--;
else if (i == 1)
state = 1;
}
}
else if (i == 1 && state != 255)
{
if (c == LCR_RESOURCE_FILE_SEPARATOR ||
c == LCR_RESOURCE_FILE_SEPARATOR2 ||
state >= 1 + LCR_MENU_STRING_SIZE - 1)
{
state = 255;
LCR_game.menu.itemCount++;
if (LCR_game.menu.itemCount >= LCR_RESOURCE_ITEM_CHUNK)
break;
}
else
LCR_game.menu.itemNames[LCR_game.menu.itemCount][state - 1] = c;
state++;
}
if (c == LCR_RESOURCE_FILE_SEPARATOR)
state = 0;
}
}
}
void LCR_gameInit(int argc, const char **argv) void LCR_gameInit(int argc, const char **argv)
{ {
LCR_LOG0("initializing"); LCR_LOG0("initializing");
@ -871,75 +940,6 @@ void LCR_gameInit(int argc, const char **argv)
} }
} }
/**
Loads up to LCR_RESOURCE_ITEM_CHUNK items of given type, starting at given
index (among items of the same type). This will also load the menu item names.
*/
void LCR_gameLoadDataFileChunk(unsigned int startIndex, char magicNumber)
{
char c;
unsigned char state = 0;
LCR_gameEraseMenuItemNames();
LCR_game.dataFile.firstItemIndex = startIndex;
LCR_game.dataFile.itemsTotal = 0;
LCR_gameRewindDataFile();
/* 3 iterations: in first we seek to the start index, in second we load the
names, in third we just read the rest to get the total count. */
for (int i = 0; i < 3; ++i)
{
while (1)
{
if (i == 0 && !startIndex)
break;
c = LCR_gameGetNextDataFileChar();
if (c == 0)
return;
if (state == 0) // second magic char
{
state = 255;
if (c == magicNumber)
{
LCR_game.dataFile.itemsTotal++;
if (i == 0)
startIndex--;
else if (i == 1)
state = 1;
}
}
else if (i == 1 && state != 255)
{
if (c == LCR_RESOURCE_FILE_SEPARATOR ||
c == LCR_RESOURCE_FILE_SEPARATOR2 ||
state >= 1 + LCR_MENU_STRING_SIZE - 1)
{
state = 255;
LCR_game.menu.itemCount++;
if (LCR_game.menu.itemCount >= LCR_RESOURCE_ITEM_CHUNK)
break;
}
else
LCR_game.menu.itemNames[LCR_game.menu.itemCount][state - 1] = c;
state++;
}
if (c == LCR_RESOURCE_FILE_SEPARATOR)
state = 0;
}
}
}
/** /**
Assumes maps are loaded in menu items, checks (in the resource file) which Assumes maps are loaded in menu items, checks (in the resource file) which
ones have been marked as beaten and marks corresponding menu items as such. ones have been marked as beaten and marks corresponding menu items as such.

5
map.h
View file

@ -129,6 +129,8 @@
but makes a hollow one */ but makes a hollow one */
#define LCR_BLOCK_START '*' ///< specifies start block position #define LCR_BLOCK_START '*' ///< specifies start block position
#define LCR_BLOCK_QUIT 'e' /**< special block, ends reading the
map (useful when creating maps) */
/* /*
TODO: TODO:
- bigger structures like a loop, sloped road etc? - bigger structures like a loop, sloped road etc?
@ -436,6 +438,9 @@ uint8_t LCR_mapLoadFromStr(char (*getNextCharFunc)(void), const char *name)
uint8_t mat = 0; uint8_t mat = 0;
int coords[3]; int coords[3];
if (block == LCR_BLOCK_QUIT)
break;
for (int i = 0; i < 3; ++i) for (int i = 0; i < 3; ++i)
{ {
c = getNextCharFunc(); c = getNextCharFunc();

View file

@ -10,17 +10,19 @@
*/ */
#ifndef LCR_SETTING_RESOLUTION_X #ifndef LCR_SETTING_RESOLUTION_X
/** Horizontal rendering resolution in pixels. */
#define LCR_SETTING_RESOLUTION_X 1024 #define LCR_SETTING_RESOLUTION_X 1024
#endif #endif
#ifndef LCR_SETTING_RESOLUTION_Y #ifndef LCR_SETTING_RESOLUTION_Y
/** Vertical rendering resolution in pixels. */
#define LCR_SETTING_RESOLUTION_Y 768 #define LCR_SETTING_RESOLUTION_Y 768
#endif #endif
#ifndef LCR_SETTING_RESOLUTION_SUBDIVIDE #ifndef LCR_SETTING_RESOLUTION_SUBDIVIDE
/** Subdivides the whole game resolution by this amount by making each pixel /** Subdivides the whole game resolution by this amount by making each pixel
this number of times bigger. */ this number of times bigger. */
#define LCR_SETTING_RESOLUTION_SUBDIVIDE 2 #define LCR_SETTING_RESOLUTION_SUBDIVIDE 1
#endif #endif
#ifndef LCR_SETTING_FPS #ifndef LCR_SETTING_FPS
@ -39,14 +41,6 @@
#define LCR_SETTING_FREE_CAMERA_TURN_SPEED 180 #define LCR_SETTING_FREE_CAMERA_TURN_SPEED 180
#endif #endif
#ifndef LCR_SETTING_SKY_ROLL_MULTIPLIER_V
#define LCR_SETTING_SKY_ROLL_MULTIPLIER_V 8
#endif
#ifndef LCR_SETTING_SKY_ROLL_MULTIPLIER_H
#define LCR_SETTING_SKY_ROLL_MULTIPLIER_H 4
#endif
#ifndef LCR_SETTING_MAX_MAP_VERTICES #ifndef LCR_SETTING_MAX_MAP_VERTICES
/** Maximum number of vertices for 3D rendering. Lower number will decrease /** Maximum number of vertices for 3D rendering. Lower number will decrease
RAM usage but will prevent larger maps from being loaded. */ RAM usage but will prevent larger maps from being loaded. */