Fix replay and ghost

This commit is contained in:
Miloslav Ciz 2025-01-31 15:55:01 +01:00
parent 2ff43a0d1a
commit 1f0d3587f6
4 changed files with 39 additions and 30 deletions

View file

@ -71,7 +71,7 @@ static const char *LCR_internalDataFile =
":;p0w0L :f5130" // bugs
":of0s0 :fd110" // small labyrinth
":>f0s0 :fd110" // small labyrinth
":oc0p0 :fd110"
":=f0s0 :f11d0"
":=c0p0 :f11d0"

41
game.h
View file

@ -1013,14 +1013,14 @@ void LCR_gameDraw3DView(void)
LCR_rendererSetCarTransform(carTransform,carTransform + 3);
if (LCR_game.ghost.active)
{
LCR_rendererSetGhostVisibility(1);
LCR_gameGhostGetTransform(LCR_racing.tick,carTransform,carTransform + 3);
LCR_rendererSetGhostTransform(carTransform,carTransform + 3);
}
else
LCR_rendererSetGhostVisibility(0);
if (LCR_game.ghost.active)
{
LCR_rendererSetGhostVisibility(1);
LCR_gameGhostGetTransform(LCR_racing.tick,carTransform,carTransform + 3);
LCR_rendererSetGhostTransform(carTransform,carTransform + 3);
}
else
LCR_rendererSetGhostVisibility(0);
if (LCR_game.cameraMode != LCR_CAMERA_MODE_FREE &&
LCR_game.state != LCR_GAME_STATE_RUN_FINISHED)
@ -1054,7 +1054,8 @@ else
LCR_rendererDrawText(str,
(LCR_EFFECTIVE_RESOLUTION_X - LCR_rendererComputeTextWidth(str,8)) / 2,
LCR_EFFECTIVE_RESOLUTION_Y / 2,0x0707,8);
LCR_EFFECTIVE_RESOLUTION_Y / 2
,0x0707,8);
break;
default:
@ -1069,18 +1070,23 @@ else
str[2] = '0' + val % 10;
str[3] = 0;
LCR_rendererDrawText(str,
LCR_EFFECTIVE_RESOLUTION_X -
LCR_rendererDrawText(str,LCR_EFFECTIVE_RESOLUTION_X -
LCR_rendererComputeTextWidth(str,2) - 20,
LCR_EFFECTIVE_RESOLUTION_Y -
LCR_rendererComputeTextHeight(2) - 20,0,2);
LCR_EFFECTIVE_RESOLUTION_Y - LCR_rendererComputeTextHeight(2) - 20,0,2);
LCR_gameTimeToStr(LCR_game.runTimeMS,str);
LCR_rendererDrawText(str,20,LCR_EFFECTIVE_RESOLUTION_Y -
LCR_rendererComputeTextHeight(2) - 45,0,2);
if (LCR_game.state != LCR_GAME_STATE_RUN_FINISHED)
LCR_rendererDrawText(str,20,LCR_EFFECTIVE_RESOLUTION_Y -
LCR_rendererComputeTextHeight(2) - 45,0,2);
else
LCR_rendererDrawText(str,((LCR_EFFECTIVE_RESOLUTION_X -
LCR_rendererComputeTextWidth(str,4)) / 2),
LCR_EFFECTIVE_RESOLUTION_Y / 2,
LCR_game.runTimeMS <= LCR_currentMap.targetTime * LCR_RACING_TICK_MS ?
0x0700 : 0x4208,4);
LCR_gameTimeToStr(LCR_currentMap.targetTime,str);
LCR_gameTimeToStr(LCR_currentMap.targetTime * LCR_RACING_TICK_MS,str);
LCR_rendererDrawText(str,20,LCR_EFFECTIVE_RESOLUTION_Y -
LCR_rendererComputeTextHeight(2) - 20,0x4208,2);
@ -1333,7 +1339,10 @@ uint8_t LCR_gameStep(uint32_t time)
LCR_rendererLoadMap();
if (LCR_game.menu.selectedTab == 3)
{
_LCR_gamePrepareGhost();
LCR_currentMap.targetTime = LCR_racing.replay.achievedTime;
}
LCR_gameResetRun(
LCR_game.menu.selectedTab == 2,

View file

@ -20,12 +20,12 @@
- Replay text format: first there is the name of the map terminated by ';',
then hexadecimal hash of the map follows (exactly 8 characters), then
blank character follows, then achieved time as a series of decimal digits
expressing the number of milliseconds, then the replay data, i.e. the series
of 16 bit words in hexadecimal, each preceded by ':'. The events (but
nothing else) may otherwise be preceeded or followed by other characters
(possible comments). All hexadecimal letters must be lowercase. The word
00000000 may optinally be used to terminate the replay, the rest of the
string will be ignored.
expressing the physics frame at which the run finished, then the replay
data, i.e. the series of 16 bit words in hexadecimal, each preceded by ':'.
The events (but nothing else) may otherwise be preceeded or followed by
other characters (possible comments). All hexadecimal letters must be
lowercase. The word 00000000 may optinally be used to terminate the replay,
the rest of the string will be ignored.
*/
typedef int32_t LCR_GameUnit; ///< abstract game unit
@ -123,7 +123,7 @@ struct
// for playing
uint16_t currentEvent;
uint16_t currentFrame;
uint32_t achievedTime;
uint32_t achievedTime; ///< Time achieved in physics frames.
} replay;
} LCR_racing;
@ -186,12 +186,12 @@ void LCR_replayOutputStr(void (*printChar)(char))
printChar(' ');
// 8 decimal digits are enough to record 24 hours
// 7 decimal digits are enough to record 24 hours
#define PUTD(order) \
printChar('0' + (LCR_racing.replay.achievedTime / order) % 10);
PUTD(10000000) PUTD(1000000) PUTD(100000) PUTD(10000)
PUTD(1000000) PUTD(100000) PUTD(10000)
PUTD(1000) PUTD(100) PUTD(10) PUTD(1)
#undef PUTD

View file

@ -15,7 +15,7 @@
where it is looking. This is to save resources, we don't draw the far away
chunks or those behind the camera.
- Extremely simple LOD of far away chunks is implemented: we keep an 8x8x8
bit map of where there is empty space and where there is "something", then
bit array of where there is empty space and where there is "something", then
for far away areas with "something" we just draw some 2D rectangles.
*/
@ -67,8 +67,8 @@ struct
{
S3L_Scene scene; ///< Whole 3D scene.
S3L_Model3D mapModel; ///< Whole map model.
S3L_Model3D *carModel; ///< Shortcut pointer to the car model in scene.
S3L_Model3D *ghostModel; ///< Shortcut pointer to the ghost model in scene.
S3L_Model3D *carModel; ///< Shortcut ptr to the car model in the scene.
S3L_Model3D *ghostModel; ///< Shortcut ptr to the ghost model in the scene.
/**
The scene model array.
@ -1951,7 +1951,7 @@ void LCR_rendererDraw3D(void)
{
carGhostVisibility <<= 1;
if (LCR_renderer.carModel->config.visible)
if (m->config.visible)
{
carGhostVisibility |= 1;