Comply with ansi C and clean up.
This commit is contained in:
+17
-12
@@ -41,12 +41,13 @@ GetTileValueUnchecked(struct tile_map *TileMap,
|
||||
struct tile_chunk *TileChunk,
|
||||
unsigned int TileX, unsigned int TileY)
|
||||
{
|
||||
unsigned int TileChunkValue;
|
||||
|
||||
ASSERT(TileChunk);
|
||||
ASSERT(TileX < TileMap->ChunkDim);
|
||||
ASSERT(TileY < TileMap->ChunkDim);
|
||||
|
||||
unsigned int TileChunkValue =
|
||||
TileChunk->Tiles[TileY * TileMap->ChunkDim + TileX];
|
||||
TileChunkValue = TileChunk->Tiles[TileY * TileMap->ChunkDim + TileX];
|
||||
return TileChunkValue;
|
||||
}
|
||||
|
||||
@@ -140,9 +141,10 @@ static void SetTileValue(struct memory_arena *Arena,
|
||||
ASSERT(TileChunk);
|
||||
if(!TileChunk->Tiles) {
|
||||
unsigned int TileCount = TileMap->ChunkDim*TileMap->ChunkDim;
|
||||
unsigned int TileIndex;
|
||||
|
||||
TileChunk->Tiles = PUSH_ARRAY(Arena, TileCount, unsigned int);
|
||||
for(unsigned int TileIndex = 0;
|
||||
for(TileIndex = 0;
|
||||
TileIndex < TileCount;
|
||||
TileIndex++)
|
||||
{
|
||||
@@ -154,15 +156,13 @@ static void SetTileValue(struct memory_arena *Arena,
|
||||
ChunkPos.RelTileY, TileValue);
|
||||
}
|
||||
|
||||
//
|
||||
// TODO: Do these belong more in a "positioning" or "geometry" file?
|
||||
//
|
||||
/* TODO: Do these belong more in a "positioning" or "geometry" file? */
|
||||
|
||||
static void CannonicalizeCoord(struct tile_map *TileMap, unsigned int *Tile,
|
||||
float *TileRel)
|
||||
{
|
||||
// NOTE: The world is assumed to be toroidal topology. If you step off
|
||||
// one end, you come back on the other.
|
||||
/* NOTE: The world is assumed to be toroidal topology. If you step off
|
||||
* one end, you come back on the other.*/
|
||||
int Offset = RoundFloatToInt(*TileRel / TileMap->TileSideInMeters);
|
||||
*Tile += Offset;
|
||||
*TileRel -= (float)Offset * TileMap->TileSideInMeters;
|
||||
@@ -198,15 +198,20 @@ SubtractInFloat(struct tile_map *TileMap,
|
||||
{
|
||||
struct tile_map_difference Result;
|
||||
|
||||
struct v2 dTileXY = { ((float)A->AbsTileX - (float)B->AbsTileX),
|
||||
((float)A->AbsTileY - (float)B->AbsTileY) };
|
||||
float dTileZ = (float)A->AbsTileZ - (float)B->AbsTileZ;
|
||||
struct v2 dTileXY;
|
||||
|
||||
float dTileZ;
|
||||
|
||||
dTileXY.X = (float)A->AbsTileX - (float)B->AbsTileX;
|
||||
dTileXY.Y = (float)A->AbsTileY - (float)B->AbsTileY;
|
||||
|
||||
dTileZ = (float)A->AbsTileZ - (float)B->AbsTileZ;
|
||||
|
||||
Result.dXY = V2Add(V2Multiply(TileMap->TileSideInMeters,
|
||||
dTileXY),
|
||||
V2Subtract(A->Offset, B->Offset));
|
||||
|
||||
// TODO: Incomplete . . .
|
||||
/* TODO: Incomplete . . . */
|
||||
Result.dZ = TileMap->TileSideInMeters*dTileZ;
|
||||
|
||||
return Result;
|
||||
|
||||
Reference in New Issue
Block a user