Add map hash
This commit is contained in:
parent
33daa484e9
commit
c259e35348
4 changed files with 28 additions and 6 deletions
1
TODO.txt
1
TODO.txt
|
@ -1,5 +1,6 @@
|
||||||
=========== GENERAL ==============
|
=========== GENERAL ==============
|
||||||
|
|
||||||
|
- the horizon on background seems too low? maybe add setting to shift it a bit?
|
||||||
- add argc/argv to gameInit? could be used to quickly start maps, verify
|
- add argc/argv to gameInit? could be used to quickly start maps, verify
|
||||||
replays etc.
|
replays etc.
|
||||||
- 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
|
||||||
|
|
6
assets.h
6
assets.h
|
@ -40,16 +40,16 @@ static const char *LCR_texts[] =
|
||||||
|
|
||||||
static const char *LCR_internalResourceFile =
|
static const char *LCR_internalResourceFile =
|
||||||
"Mtestmap;"
|
"Mtestmap;"
|
||||||
"0 :*H1k0J"
|
"1 :*H1k0"
|
||||||
|
|
||||||
":=s0s0 :fd190" // big concrete
|
":=s0s0 :fd190" // big concrete
|
||||||
|
|
||||||
":+v0n0"
|
|
||||||
":+w0o0"
|
":+w0o0"
|
||||||
|
":+v0n0"
|
||||||
":!x0n0"
|
":!x0n0"
|
||||||
|
|
||||||
":=s0B0 :fd910" // concrete wall
|
|
||||||
":^s1A0 :fk110" // ramps before wall
|
":^s1A0 :fk110" // ramps before wall
|
||||||
|
":=s0B0 :fd910" // concrete wall
|
||||||
|
|
||||||
":nu0j1 :ly0j1 :AA0j1 "
|
":nu0j1 :ly0j1 :AA0j1 "
|
||||||
|
|
||||||
|
|
25
map.h
25
map.h
|
@ -151,7 +151,8 @@ struct
|
||||||
|
|
||||||
uint8_t environment;
|
uint8_t environment;
|
||||||
uint8_t checkpointCount;
|
uint8_t checkpointCount;
|
||||||
// TODO: name, desc? possibly as a single '\n' separated string?
|
|
||||||
|
uint32_t hash; ///< Hash of the processed binary map.
|
||||||
} LCR_currentMap;
|
} LCR_currentMap;
|
||||||
|
|
||||||
void LCR_makeMapBlock(uint8_t type, uint8_t x, uint8_t y, uint8_t z,
|
void LCR_makeMapBlock(uint8_t type, uint8_t x, uint8_t y, uint8_t z,
|
||||||
|
@ -353,6 +354,25 @@ int _LCR_mapCharToCoord(char c)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _LCR_mapComputeHash(void)
|
||||||
|
{
|
||||||
|
LCR_LOG1("computing map hash");
|
||||||
|
|
||||||
|
const uint8_t *data = LCR_currentMap.startPos;
|
||||||
|
|
||||||
|
LCR_currentMap.hash = 11 + LCR_currentMap.environment;
|
||||||
|
|
||||||
|
for (int i = 0; i < LCR_currentMap.blockCount * LCR_BLOCK_SIZE + 4; ++i)
|
||||||
|
{
|
||||||
|
LCR_currentMap.hash = LCR_currentMap.hash * 101 + *data;
|
||||||
|
data = i != 3 ? data + 1 : LCR_currentMap.blocks;
|
||||||
|
}
|
||||||
|
|
||||||
|
LCR_currentMap.hash *= 251;
|
||||||
|
LCR_currentMap.hash = ((LCR_currentMap.hash << 19) |
|
||||||
|
(LCR_currentMap.hash >> 13)) * 113;
|
||||||
|
}
|
||||||
|
|
||||||
uint8_t LCR_mapLoadFromStr(char (*getNextCharFunc)(void))
|
uint8_t LCR_mapLoadFromStr(char (*getNextCharFunc)(void))
|
||||||
{
|
{
|
||||||
LCR_LOG0("loading map string");
|
LCR_LOG0("loading map string");
|
||||||
|
@ -368,6 +388,7 @@ uint8_t LCR_mapLoadFromStr(char (*getNextCharFunc)(void))
|
||||||
LCR_currentMap.checkpointCount = 0;
|
LCR_currentMap.checkpointCount = 0;
|
||||||
LCR_currentMap.blockCount = 0;
|
LCR_currentMap.blockCount = 0;
|
||||||
LCR_currentMap.environment = 0;
|
LCR_currentMap.environment = 0;
|
||||||
|
LCR_currentMap.hash = 0;
|
||||||
|
|
||||||
c = getNextCharFunc();
|
c = getNextCharFunc();
|
||||||
|
|
||||||
|
@ -495,6 +516,8 @@ uint8_t LCR_mapLoadFromStr(char (*getNextCharFunc)(void))
|
||||||
for (int i = 0; i < LCR_MAP_BLOCK_CACHE_SIZE; ++i)
|
for (int i = 0; i < LCR_MAP_BLOCK_CACHE_SIZE; ++i)
|
||||||
_LCR_mapBlockCache[i] = 0xffffffff;
|
_LCR_mapBlockCache[i] = 0xffffffff;
|
||||||
|
|
||||||
|
_LCR_mapComputeHash();
|
||||||
|
|
||||||
LCR_LOG2("map loaded")
|
LCR_LOG2("map loaded")
|
||||||
|
|
||||||
LCR_mapReset();
|
LCR_mapReset();
|
||||||
|
|
2
racing.h
2
racing.h
|
@ -45,11 +45,9 @@ typedef int32_t LCR_GameUnit; ///< abstract game unit
|
||||||
#define LCR_CAR_DRIFT_THRESHOLD_1 (LCR_GAME_UNIT / 4)
|
#define LCR_CAR_DRIFT_THRESHOLD_1 (LCR_GAME_UNIT / 4)
|
||||||
#define LCR_CAR_DRIFT_THRESHOLD_0 (LCR_GAME_UNIT / 200)
|
#define LCR_CAR_DRIFT_THRESHOLD_0 (LCR_GAME_UNIT / 200)
|
||||||
|
|
||||||
|
|
||||||
#define LCR_CAR_CRASH_SPEED_DIFF 25
|
#define LCR_CAR_CRASH_SPEED_DIFF 25
|
||||||
#define LCR_CAR_CRASH_SPEED_THRESHOLD 70
|
#define LCR_CAR_CRASH_SPEED_THRESHOLD 70
|
||||||
|
|
||||||
|
|
||||||
// multipliers (in 8ths) of friction and acceleration on concrete:
|
// multipliers (in 8ths) of friction and acceleration on concrete:
|
||||||
#define LCR_CAR_GRASS_FACTOR 5
|
#define LCR_CAR_GRASS_FACTOR 5
|
||||||
#define LCR_CAR_DIRT_FACTOR 3
|
#define LCR_CAR_DIRT_FACTOR 3
|
||||||
|
|
Loading…
Reference in a new issue