Use chars for block types
This commit is contained in:
parent
21cedabf85
commit
afcdb99574
1 changed files with 32 additions and 68 deletions
100
map.h
100
map.h
|
@ -29,8 +29,7 @@
|
||||||
#BXYZMT
|
#BXYZMT
|
||||||
|
|
||||||
where:
|
where:
|
||||||
- B is block type (for list of characters see the _LCR_mapCharToBlockType
|
- B is block type
|
||||||
function).
|
|
||||||
- X, Y and Z are block coordinates, each one a single character. The
|
- X, Y and Z are block coordinates, each one a single character. The
|
||||||
following are characters signifying numbers 0 to 63:
|
following are characters signifying numbers 0 to 63:
|
||||||
0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$@
|
0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ$@
|
||||||
|
@ -48,9 +47,8 @@
|
||||||
The internal BINARY map format is made from the text string. It can't contain
|
The internal BINARY map format is made from the text string. It can't contain
|
||||||
special blocks and blocks are ordered by their coordinate number (for fast
|
special blocks and blocks are ordered by their coordinate number (for fast
|
||||||
lookup). The format consists of blocks, each of format:
|
lookup). The format consists of blocks, each of format:
|
||||||
- 1 byte type: says the type of block. Special blocks are defined in code,
|
- 1 byte type: says the type of block, is the same value as B in the text
|
||||||
they have histest bit set to 1, but they only serve internal purposes and
|
format.
|
||||||
can't end up in the final map.
|
|
||||||
- 3 bytes: A, B, C, such that:
|
- 3 bytes: A, B, C, such that:
|
||||||
- A, B and lowest 2 bits of C form the block coordinate number (A being
|
- A, B and lowest 2 bits of C form the block coordinate number (A being
|
||||||
the lowest part etc.)
|
the lowest part etc.)
|
||||||
|
@ -88,41 +86,38 @@
|
||||||
#define LCR_BLOCK_MATERIAL_ICE 0x03
|
#define LCR_BLOCK_MATERIAL_ICE 0x03
|
||||||
|
|
||||||
// normal blocks:
|
// normal blocks:
|
||||||
#define LCR_BLOCK_FULL 0x00 ///< completely filled block
|
#define LCR_BLOCK_FULL '=' ///< completely filled block
|
||||||
#define LCR_BLOCK_BOTTOM 0x01 ///< filled bottom half
|
#define LCR_BLOCK_BOTTOM '-' ///< filled bottom half
|
||||||
#define LCR_BLOCK_LEFT 0x02 ///< filled left half
|
#define LCR_BLOCK_LEFT ';' ///< filled left half
|
||||||
#define LCR_BLOCK_BOTTOM_LEFT 0x03 ///< filled bottom left quarter
|
#define LCR_BLOCK_BOTTOM_LEFT ',' ///< filled bottom left quarter
|
||||||
#define LCR_BLOCK_BOTTOM_LEFT_FRONT 0x04 ///< filled bottom left front eigth
|
#define LCR_BLOCK_BOTTOM_LEFT_FRONT '.' ///< filled bottom left front eigth
|
||||||
#define LCR_BLOCK_RAMP 0x05 ///< plain ramp
|
#define LCR_BLOCK_RAMP '^' ///< plain ramp
|
||||||
#define LCR_BLOCK_RAMP_34 0x06 ///< plain ramp, 3/4 size
|
#define LCR_BLOCK_RAMP_34 '/' ///< plain ramp, 3/4 size
|
||||||
#define LCR_BLOCK_RAMP_12 0x07 ///< plain ramp, 1/2 size
|
#define LCR_BLOCK_RAMP_12 '<' ///< plain ramp, 1/2 size
|
||||||
#define LCR_BLOCK_RAMP_14 0x08 ///< plain ramp, 1/4 size
|
#define LCR_BLOCK_RAMP_14 '_' ///< plain ramp, 1/4 size
|
||||||
#define LCR_BLOCK_RAMP_CURVED_PLAT 0x09 ///< curved ramp with top platgform
|
#define LCR_BLOCK_RAMP_CURVED_PLAT ']' ///< curved ramp with top platgform
|
||||||
#define LCR_BLOCK_RAMP_CURVED 0x0a ///< curv. ramp without top platf.
|
#define LCR_BLOCK_RAMP_CURVED ')' ///< curv. ramp without top platf.
|
||||||
#define LCR_BLOCK_RAMP_CURVED_WALL 0x0b ///< curved ramp plus small wall
|
#define LCR_BLOCK_RAMP_CURVED_WALL '}' ///< curved ramp plus small wall
|
||||||
#define LCR_BLOCK_RAMP_STEEP 0x0c ///< extremely steep ramp
|
#define LCR_BLOCK_RAMP_STEEP '|' ///< extremely steep ramp
|
||||||
#define LCR_BLOCK_CORNER 0x0d ///< diagonal corner
|
#define LCR_BLOCK_CORNER 'A' ///< diagonal corner
|
||||||
#define LCR_BLOCK_CORNER_12 0x0e ///< diagonal corner (1/2 wide)
|
#define LCR_BLOCK_CORNER_12 '\\' ///< diagonal corner (1/2 wide)
|
||||||
#define LCR_BLOCK_HILL 0x0f ///< curved "hill"
|
#define LCR_BLOCK_HILL '(' ///< curved "hill"
|
||||||
#define LCR_BLOCK_FULL_ACCEL 0x20
|
#define LCR_BLOCK_FULL_ACCEL '>'
|
||||||
#define LCR_BLOCK_FULL_FAN 0x30
|
#define LCR_BLOCK_FULL_FAN 'o'
|
||||||
#define LCR_BLOCK_CHECKPOINT_0 0x40 ///< checkpoint, not taken
|
#define LCR_BLOCK_CHECKPOINT_0 '+' ///< checkpoint, not taken
|
||||||
#define LCR_BLOCK_CHECKPOINT_1 0x41 ///< checkpoint, taken
|
#define LCR_BLOCK_CHECKPOINT_1 '\'' ///< checkpoint, taken
|
||||||
|
|
||||||
|
#define LCR_BLOCK_FINISH '!' ///< finish
|
||||||
|
|
||||||
|
|
||||||
#define LCR_BLOCK_FINISH 0x42 ///< finish
|
|
||||||
|
|
||||||
// special blocks:
|
// special blocks:
|
||||||
#define LCR_BLOCK_NONE 0x80 ///< no block, e.g to make holes
|
#define LCR_BLOCK_NONE 'x' ///< no block, e.g to make holes
|
||||||
|
|
||||||
#define LCR_BLOCK_CUBOID_FILL 0x81 /**< makes a cuboid from the
|
#define LCR_BLOCK_CUBOID_FILL 'f' /**< makes a cuboid from the
|
||||||
previously specified block, the
|
previously specified block, the
|
||||||
size is given by block coords */
|
size is given by block coords */
|
||||||
#define LCR_BLOCK_CUBOID_HOLLOW 0x82 /**< same as cuboid special block,
|
#define LCR_BLOCK_CUBOID_HOLLOW 'h' /**< same as cuboid special block,
|
||||||
but makes a hollow one */
|
but makes a hollow one */
|
||||||
#define LCR_BLOCK_START 0x83 ///< specifies start block position
|
#define LCR_BLOCK_START '*' ///< specifies start block position
|
||||||
|
|
||||||
/*
|
/*
|
||||||
TODO:
|
TODO:
|
||||||
|
@ -131,6 +126,7 @@
|
||||||
- curved out corner?
|
- curved out corner?
|
||||||
- curved "hill"
|
- curved "hill"
|
||||||
- bumpy road
|
- bumpy road
|
||||||
|
- bigger structures like a loop, sloped road etc?
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define LCR_MAP_BLOCK_CACHE_SIZE (8 * 2) /// do not change
|
#define LCR_MAP_BLOCK_CACHE_SIZE (8 * 2) /// do not change
|
||||||
|
@ -327,40 +323,6 @@ void LCR_mapReset(void)
|
||||||
LCR_currentMap.blocks[i * LCR_BLOCK_SIZE] = LCR_BLOCK_CHECKPOINT_0;
|
LCR_currentMap.blocks[i * LCR_BLOCK_SIZE] = LCR_BLOCK_CHECKPOINT_0;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t _LCR_mapCharToBlockType(char c)
|
|
||||||
{
|
|
||||||
switch (c)
|
|
||||||
{
|
|
||||||
case '=': return LCR_BLOCK_FULL; break;
|
|
||||||
case '-': return LCR_BLOCK_BOTTOM; break;
|
|
||||||
case ';': return LCR_BLOCK_LEFT; break;
|
|
||||||
case ',': return LCR_BLOCK_BOTTOM_LEFT; break;
|
|
||||||
case '.': return LCR_BLOCK_BOTTOM_LEFT_FRONT; break;
|
|
||||||
case '^': return LCR_BLOCK_RAMP; break;
|
|
||||||
case '/': return LCR_BLOCK_RAMP_34; break;
|
|
||||||
case '<': return LCR_BLOCK_RAMP_12; break;
|
|
||||||
case '_': return LCR_BLOCK_RAMP_14; break;
|
|
||||||
case ']': return LCR_BLOCK_RAMP_CURVED_PLAT; break;
|
|
||||||
case ')': return LCR_BLOCK_RAMP_CURVED; break;
|
|
||||||
case '}': return LCR_BLOCK_RAMP_CURVED_WALL; break;
|
|
||||||
case '|': return LCR_BLOCK_RAMP_STEEP; break;
|
|
||||||
case 'A': return LCR_BLOCK_CORNER; break;
|
|
||||||
case '\\': return LCR_BLOCK_CORNER_12; break;
|
|
||||||
case '(': return LCR_BLOCK_HILL; break;
|
|
||||||
case '>': return LCR_BLOCK_FULL_ACCEL; break;
|
|
||||||
case 'o': return LCR_BLOCK_FULL_FAN; break;
|
|
||||||
case '+': return LCR_BLOCK_CHECKPOINT_0; break;
|
|
||||||
case '!': return LCR_BLOCK_FINISH; break;
|
|
||||||
case 'x': return LCR_BLOCK_NONE; break;
|
|
||||||
case 'f': return LCR_BLOCK_CUBOID_FILL; break;
|
|
||||||
case 'h': return LCR_BLOCK_CUBOID_HOLLOW; break;
|
|
||||||
case '*': return LCR_BLOCK_START; break;
|
|
||||||
default:
|
|
||||||
LCR_LOG1("unknown block char");
|
|
||||||
return LCR_BLOCK_NONE; break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int _LCR_mapCharToCoord(char c)
|
int _LCR_mapCharToCoord(char c)
|
||||||
{
|
{
|
||||||
if (c >= '0' && c <= '9')
|
if (c >= '0' && c <= '9')
|
||||||
|
@ -444,7 +406,7 @@ uint8_t LCR_mapLoadFromStr(const char *mapStr)
|
||||||
{
|
{
|
||||||
mapStr++;
|
mapStr++;
|
||||||
|
|
||||||
uint8_t block = _LCR_mapCharToBlockType(*mapStr);
|
uint8_t block = *mapStr;
|
||||||
uint8_t trans = 0;
|
uint8_t trans = 0;
|
||||||
uint8_t mat = 0;
|
uint8_t mat = 0;
|
||||||
int coords[3];
|
int coords[3];
|
||||||
|
@ -556,6 +518,8 @@ uint8_t LCR_mapLoadFromStr(const char *mapStr)
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: check for invalid blocks?
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue