Update readme
This commit is contained in:
parent
aab53fc11a
commit
822375ff7d
6 changed files with 178 additions and 36 deletions
34
racing.h
34
racing.h
|
@ -171,6 +171,7 @@ struct
|
|||
|
||||
uint16_t crashState;
|
||||
|
||||
#if LCR_SETTING_REPLAY_MAX_SIZE != 0
|
||||
struct
|
||||
{
|
||||
uint8_t on; ///< Currently playing replay?
|
||||
|
@ -182,6 +183,7 @@ struct
|
|||
uint16_t currentFrame;
|
||||
uint32_t achievedTime; ///< Time achieved in physics frames.
|
||||
} replay;
|
||||
#endif
|
||||
} LCR_racing;
|
||||
|
||||
uint32_t LCR_timeTicksToMS(uint32_t ticks)
|
||||
|
@ -211,15 +213,19 @@ static inline uint8_t LCR_racingCurrentGroundMaterial(void)
|
|||
void LCR_replayInitRecording(void)
|
||||
{
|
||||
LCR_LOG1("initializing replay recording");
|
||||
#if LCR_SETTING_REPLAY_MAX_SIZE != 0
|
||||
LCR_racing.replay.eventCount = 0;
|
||||
LCR_racing.replay.achievedTime = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
void LCR_replayInitPlaying(void)
|
||||
{
|
||||
LCR_LOG1("initializing replay playing");
|
||||
#if LCR_SETTING_REPLAY_MAX_SIZE != 0
|
||||
LCR_racing.replay.currentEvent = 0;
|
||||
LCR_racing.replay.currentFrame = 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -230,6 +236,7 @@ void LCR_replayOutputStr(void (*printChar)(char))
|
|||
{
|
||||
LCR_LOG1("outputting replay");
|
||||
|
||||
#if LCR_SETTING_REPLAY_MAX_SIZE != 0
|
||||
const char *s = LCR_currentMap.name;
|
||||
|
||||
printChar(LCR_RACING_VERSION1);
|
||||
|
@ -274,6 +281,7 @@ void LCR_replayOutputStr(void (*printChar)(char))
|
|||
}
|
||||
|
||||
printChar('\n');
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -285,6 +293,7 @@ void LCR_replayOutputStr(void (*printChar)(char))
|
|||
int LCR_replayLoadFromStr(char (*nextChar)(void), uint32_t *mapHash,
|
||||
uint16_t *nameHash)
|
||||
{
|
||||
#if LCR_SETTING_REPLAY_MAX_SIZE != 0
|
||||
char c;
|
||||
|
||||
LCR_racing.replay.eventCount = 0;
|
||||
|
@ -367,10 +376,14 @@ int LCR_replayLoadFromStr(char (*nextChar)(void), uint32_t *mapHash,
|
|||
LCR_racing.replay.events[i] = 0;
|
||||
|
||||
return 1;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
int LCR_replayHasFinished(void)
|
||||
{
|
||||
#if LCR_SETTING_REPLAY_MAX_SIZE != 0
|
||||
if (LCR_racing.replay.currentEvent == LCR_racing.replay.eventCount)
|
||||
{
|
||||
uint32_t totalTime = LCR_racing.replay.currentFrame;
|
||||
|
@ -382,6 +395,9 @@ int LCR_replayHasFinished(void)
|
|||
}
|
||||
|
||||
return LCR_racing.replay.currentEvent > LCR_racing.replay.eventCount;
|
||||
#else
|
||||
return 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -390,6 +406,7 @@ int LCR_replayHasFinished(void)
|
|||
*/
|
||||
uint8_t LCR_replayGetNextInput(void)
|
||||
{
|
||||
#if LCR_SETTING_REPLAY_MAX_SIZE != 0
|
||||
if (LCR_replayHasFinished())
|
||||
{
|
||||
LCR_racing.replay.currentFrame++; // has to be here
|
||||
|
@ -407,6 +424,9 @@ uint8_t LCR_replayGetNextInput(void)
|
|||
|
||||
return LCR_racing.replay.currentEvent ?
|
||||
(LCR_racing.replay.events[LCR_racing.replay.currentEvent - 1] & 0x0f) : 0;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -419,6 +439,7 @@ int LCR_replayRecordEvent(uint32_t frame, uint8_t input)
|
|||
{
|
||||
LCR_LOG2("recording replay event");
|
||||
|
||||
#if LCR_SETTING_REPLAY_MAX_SIZE != 0
|
||||
if (LCR_racing.replay.achievedTime)
|
||||
return 1; // already finished
|
||||
|
||||
|
@ -429,7 +450,6 @@ int LCR_replayRecordEvent(uint32_t frame, uint8_t input)
|
|||
return 1;
|
||||
}
|
||||
|
||||
#if LCR_SETTING_REPLAY_MAX_SIZE > 0
|
||||
uint8_t previousInput = 0;
|
||||
uint32_t previousFrame = 0;
|
||||
|
||||
|
@ -985,7 +1005,9 @@ void LCR_racingRestart(uint8_t replay)
|
|||
LCR_racing.tick = 0;
|
||||
LCR_racing.fanForce = 0;
|
||||
|
||||
#if LCR_SETTING_REPLAY_MAX_SIZE > 0
|
||||
LCR_racing.replay.on = replay;
|
||||
#endif
|
||||
|
||||
TPE_bodyActivate(&(LCR_racing.carBody));
|
||||
LCR_racing.wheelCollisions = 0;
|
||||
|
@ -1069,7 +1091,9 @@ void LCR_racingInit(void)
|
|||
TPE_worldInit(&(LCR_racing.physicsWorld),
|
||||
&(LCR_racing.carBody),1,_LCR_racingEnvironmentFunction);
|
||||
|
||||
#if LCR_SETTING_REPLAY_MAX_SIZE > 0
|
||||
LCR_racing.replay.on = 0;
|
||||
#endif
|
||||
LCR_racing.physicsWorld.collisionCallback = _LCR_racingCollisionHandler;
|
||||
}
|
||||
|
||||
|
@ -1221,6 +1245,7 @@ uint32_t LCR_racingStep(unsigned int input)
|
|||
|
||||
LCR_racing.groundMaterial = LCR_BLOCK_MATERIAL_CONCRETE;
|
||||
|
||||
#if LCR_SETTING_REPLAY_MAX_SIZE > 0
|
||||
if (LCR_racing.replay.on)
|
||||
{
|
||||
if (LCR_racing.tick == 0)
|
||||
|
@ -1232,6 +1257,7 @@ uint32_t LCR_racingStep(unsigned int input)
|
|||
input = LCR_replayGetNextInput();
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
if (LCR_racing.tick == 0)
|
||||
LCR_replayInitRecording();
|
||||
|
@ -1641,8 +1667,10 @@ uint32_t LCR_racingStep(unsigned int input)
|
|||
{
|
||||
result |= LCR_RACING_EVENT_FINISHED;
|
||||
|
||||
#if LCR_SETTING_REPLAY_MAX_SIZE > 0
|
||||
if (!LCR_racing.replay.on)
|
||||
LCR_replayRecordEvent(LCR_racing.tick,LCR_REPLAY_EVENT_END);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1692,6 +1720,7 @@ int LCR_replayValidate(void)
|
|||
{
|
||||
LCR_LOG1("validating replay");
|
||||
|
||||
#if LCR_SETTING_REPLAY_MAX_SIZE != 0
|
||||
int result = 0;
|
||||
|
||||
LCR_racingRestart(1);
|
||||
|
@ -1738,6 +1767,9 @@ int LCR_replayValidate(void)
|
|||
LCR_racingRestart(1);
|
||||
|
||||
return result;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif // guard
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue