Start replay loading
This commit is contained in:
parent
71aa8156e9
commit
17a371fdca
4 changed files with 169 additions and 16 deletions
36
racing.h
36
racing.h
|
@ -47,8 +47,6 @@ typedef int32_t LCR_GameUnit; ///< abstract game unit
|
|||
#include "map.h"
|
||||
#include "tinyphysicsengine.h"
|
||||
|
||||
// TODO: move some of this to constants?
|
||||
|
||||
#define LCR_GRAVITY (LCR_PHYSICS_UNIT / 160)
|
||||
#define LCR_FAN_FORCE 3
|
||||
#define LCR_FAN_FORCE_DECREASE 6
|
||||
|
@ -174,8 +172,8 @@ void LCR_replayOutputStr(void (*printChar)(char))
|
|||
|
||||
for (int i = 0; i < 8; ++i)
|
||||
{
|
||||
printChar(_LCR_hexDigit(hash % 16));
|
||||
hash /= 16;
|
||||
printChar(_LCR_hexDigit((hash >> 28) % 16));
|
||||
hash <<= 4;
|
||||
}
|
||||
|
||||
printChar(' ');
|
||||
|
@ -204,15 +202,24 @@ void LCR_replayOutputStr(void (*printChar)(char))
|
|||
|
||||
/**
|
||||
Reads replay from string using provided function that returns next character
|
||||
in the string. Returns 1 on success, else 0.
|
||||
in the string. The mapHash and nameHash pointers are optional: if non-zero,
|
||||
they will be filled with the map hash and name hash. Returns 1 on success,
|
||||
else 0.
|
||||
*/
|
||||
int LCR_replayLoadFromStr(char (*nextChar)(void))
|
||||
int LCR_replayLoadFromStr(char (*nextChar)(void),
|
||||
uint32_t *mapHash, uint16_t *nameHash)
|
||||
{
|
||||
char c = ' ';
|
||||
|
||||
LCR_replay.eventCount = 0;
|
||||
LCR_replay.achievedTime = 0;
|
||||
|
||||
if (nameHash)
|
||||
*nameHash = _LCR_simpleStrHash(nextChar,';');
|
||||
else
|
||||
_LCR_simpleStrHash(nextChar,';');
|
||||
|
||||
/*
|
||||
do // map name
|
||||
{
|
||||
c = nextChar();
|
||||
|
@ -220,10 +227,27 @@ int LCR_replayLoadFromStr(char (*nextChar)(void))
|
|||
if (c == 0)
|
||||
return 0;
|
||||
} while (c != ';');
|
||||
*/
|
||||
|
||||
if (mapHash)
|
||||
*mapHash = 0;
|
||||
|
||||
for (int i = 0; i < 8; ++i) // hash
|
||||
{
|
||||
c = nextChar();
|
||||
|
||||
if (_LCR_hexDigitVal(c) < 0)
|
||||
return 0;
|
||||
|
||||
if (mapHash)
|
||||
*mapHash = ((*mapHash) << 4) | _LCR_hexDigitVal(c);
|
||||
}
|
||||
|
||||
/*
|
||||
for (int i = 0; i < 8; ++i) // hash
|
||||
if (_LCR_hexDigitVal(nextChar()) < 0)
|
||||
return 0;
|
||||
*/
|
||||
|
||||
nextChar();
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue