Skip to content

Commit aefdfe9

Browse files
committed
more high severity issues fix
1 parent 334a9f2 commit aefdfe9

4 files changed

Lines changed: 17 additions & 18 deletions

File tree

include/tile.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ void TileDestroy(Tile* tilep);
1717

1818

1919
// The name of a tile.
20-
const char* TileGetName(Tile tile);
20+
char* TileGetName(Tile tile);
2121

2222
// The number (MapTiles) that this tile represents.
2323
int TileGetMapTiles(Tile tile);

src/map.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ static bool hashmapstrcmp(void* key1, void* key2) {
4646

4747
// INTERNAL: registers a new tile type in a map. Returns false on error (if tile with that name already exists)
4848
static bool registerTile(Map map, Tile tile, int* tileID) {
49-
char* tileName = (char*) TileGetName(tile);
49+
char* tileName = TileGetName(tile);
5050
if (HashMapContains(map->tileMap, tileName)) { // Duplicate checking
5151
return false;
5252
}

src/player.c

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -193,24 +193,23 @@ void PlayerDraw3D(Player p, int screenWidth, int screenHeight) {
193193
double distaux = sqrt(pow(p->posX-collisionPoint.x, 2) + pow(p->posY-collisionPoint.y, 2));
194194
double distance = (1.5*MapGetTileSize(p->map)*screenHeight) / (distaux*cos(MapRayGetAngleOffsetRad(ray)));
195195

196-
Color drawColor;
197-
if (currentCollision.hitSide == X_AXIS) {
198-
drawColor = (Color) {255, 255, 255, 255};
199-
} else {
200-
drawColor = (Color) {210, 210, 210, 255};
201-
}
196+
Color drawColor = currentCollision.hitSide == X_AXIS ?
197+
(Color) {255, 255, 255, 255}
198+
: (Color) {210, 210, 210, 255};
199+
202200
//DrawRectangle(rayX, (screenHeight/2)-(distance/2), line_width, distance, drawColor);
203201

204202
Vector2 collisionPointGrid = (Vector2) {currentCollision.collisionGridX, currentCollision.collisionGridY};
205203

206204
Texture tex = TileGetTexture(currentCollision.tile);
207-
208-
int ray_percentage; // Percentage of tile that ray hit (not really percentage, just number of tile pixels)
209-
if (currentCollision.hitSide == X_AXIS) {
210-
ray_percentage = (int) (collisionPoint.y) % MapGetTileSize(p->map) + 1;
211-
} else {
212-
ray_percentage = (int) (collisionPoint.x) % MapGetTileSize(p->map) + 1;
213-
}
205+
206+
int coll_point_axis = currentCollision.hitSide == X_AXIS ?
207+
(int) (collisionPoint.y)
208+
: (int) (collisionPoint.x);
209+
210+
// Percentage of tile that ray hit (not really percentage, just number of tile pixels)
211+
int ray_percentage = coll_point_axis % MapGetTileSize(p->map) + 1;
212+
214213
double texture_offset = ((double) (ray_percentage) / (double) (MapGetTileSize(p->map)))*((double) tex.width);
215214
int texture_width = 1;
216215

@@ -219,8 +218,8 @@ void PlayerDraw3D(Player p, int screenWidth, int screenHeight) {
219218
(Rectangle) {rayX, (screenHeight/2)-(distance/2), line_width, distance},
220219
(Vector2) {0, 0}, 0, drawColor);
221220

222-
ListMoveToNext(collisions);
223-
} else if (currentCollision.collisionType == COLLISION_BILLBOARD) {
221+
ListMoveToNext(collisions);
222+
} else if (currentCollision.collisionType == COLLISION_BILLBOARD) {
224223
Billboard bb = currentCollision.billboard;
225224

226225
double distaux = sqrt(pow(p->posX-collisionPoint.x, 2) + pow(p->posY-collisionPoint.y, 2));

src/tile.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ void TileDestroy(Tile* tilep) {
5454
*tilep = NULL;
5555
}
5656

57-
const char* TileGetName(Tile tile) {
57+
char* TileGetName(Tile tile) {
5858
assert(tile != NULL);
5959
return tile->name;
6060
}

0 commit comments

Comments
 (0)