bunch of code quality fixes
parent
eccaa14bda
commit
e302d1c865
|
@ -1,6 +1,5 @@
|
|||
build
|
||||
build_rel
|
||||
build_web
|
||||
build_*
|
||||
emsdk
|
||||
deploy_web
|
||||
run_web
|
||||
|
|
|
@ -100,7 +100,7 @@ void game_world_view_cycle_active(int8_t dir) {
|
|||
game_world_view_set_active_by_idx(zpl_max(0, (idx+dir)%zpl_buffer_count(world_viewers)));
|
||||
}
|
||||
void game_world_view_set_active_by_idx(uint16_t idx) {
|
||||
ZPL_ASSERT(idx >= 0 && idx < zpl_buffer_count(world_viewers));
|
||||
ZPL_ASSERT(idx < zpl_buffer_count(world_viewers));
|
||||
game_world_view_set_active(&world_viewers[idx]);
|
||||
}
|
||||
|
||||
|
|
|
@ -66,8 +66,8 @@ ActSpawnMobs(void) {
|
|||
|
||||
for (uint32_t cy=y; cy<y+h; cy+=WORLD_BLOCK_SIZE) {
|
||||
for (uint32_t cx=x; cx<x+w; cx+=WORLD_BLOCK_SIZE) {
|
||||
if (cx < 0 || cx >= world_dim()) continue;
|
||||
if (cy < 0 || cy >= world_dim()) continue;
|
||||
if (cx >= world_dim()) continue;
|
||||
if (cy >= world_dim()) continue;
|
||||
|
||||
if ((cy == y || cy == (y + h-WORLD_BLOCK_SIZE)) ||
|
||||
(cx == x || cx == (x + w-WORLD_BLOCK_SIZE))) {
|
||||
|
|
|
@ -45,7 +45,7 @@ uint16_t craft_get_recipe_id_from_product(asset_id id) {
|
|||
}
|
||||
|
||||
recipe craft_get_recipe_data(uint16_t i) {
|
||||
ZPL_ASSERT(i >= 0 && i < MAX_RECIPES);
|
||||
ZPL_ASSERT(i < MAX_RECIPES);
|
||||
return recipes[i];
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
#define ITEMS_COUNT (sizeof(items)/sizeof(item_desc))
|
||||
|
||||
static inline item_id item_resolve_proxy(item_id id) {
|
||||
ZPL_ASSERT(id >= 0 && id < ITEMS_COUNT);
|
||||
ZPL_ASSERT(id < ITEMS_COUNT);
|
||||
item_usage usage = items[id].usage;
|
||||
if (usage == UKIND_PROXY) {
|
||||
return item_find(items[id].proxy.id);
|
||||
|
@ -164,21 +164,21 @@ void item_despawn(uint64_t id) {
|
|||
}
|
||||
|
||||
uint32_t item_max_quantity(item_id id) {
|
||||
ZPL_ASSERT(id >= 0 && id < ITEMS_COUNT);
|
||||
ZPL_ASSERT(id < ITEMS_COUNT);
|
||||
return items[id].max_quantity;
|
||||
}
|
||||
|
||||
item_usage item_get_usage(item_id id) {
|
||||
ZPL_ASSERT(id >= 0 && id < ITEMS_COUNT);
|
||||
ZPL_ASSERT(id < ITEMS_COUNT);
|
||||
return items[id].usage;
|
||||
}
|
||||
|
||||
bool item_get_place_directional(item_id id) {
|
||||
ZPL_ASSERT(id >= 0 && id < ITEMS_COUNT);
|
||||
ZPL_ASSERT(id < ITEMS_COUNT);
|
||||
return items[id].place.directional;
|
||||
}
|
||||
|
||||
item_desc item_get_desc(item_id id) {
|
||||
ZPL_ASSERT(id >= 0 && id < ITEMS_COUNT);
|
||||
ZPL_ASSERT(id < ITEMS_COUNT);
|
||||
return items[id];
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#include "input.h"
|
||||
#include "raylib.h"
|
||||
|
||||
const static input_map maps[] = {
|
||||
static const input_map maps[] = {
|
||||
{
|
||||
"left",
|
||||
IN_LEFT,
|
||||
|
|
|
@ -28,7 +28,7 @@ void PickItem(ecs_iter_t *it) {
|
|||
uint16_t item_id = item ? item_find(item->kind) : 0;
|
||||
if (!item || (item_id != ASSET_INVALID && (item->kind == drop->kind && item->durability == drop->durability) && item->quantity < item_max_quantity(drop_id))) {
|
||||
if (item) {
|
||||
uint32_t picked_count = zpl_max(0, drop->quantity);
|
||||
uint32_t picked_count = zpl_max(0, (int32_t)drop->quantity);
|
||||
picked_count = zpl_clamp(picked_count, 0, item_max_quantity(drop_id) - item->quantity);
|
||||
item->quantity += picked_count;
|
||||
drop->quantity -= picked_count;
|
||||
|
@ -378,7 +378,7 @@ void HarvestIntoContainers(ecs_iter_t *it) {
|
|||
uint16_t item_id = item ? item_find(item->kind) : 0;
|
||||
if (!item || (item_id != ASSET_INVALID && (item->kind == drop->kind && item->durability == drop->durability) && item->quantity < item_max_quantity(drop_id))) {
|
||||
if (item) {
|
||||
uint32_t picked_count = zpl_max(0, drop->quantity);
|
||||
uint32_t picked_count = zpl_max(0, (int32_t)drop->quantity);
|
||||
picked_count = zpl_clamp(picked_count, 0, item_max_quantity(drop_id) - item->quantity);
|
||||
item->quantity += picked_count;
|
||||
drop->quantity -= picked_count;
|
||||
|
|
|
@ -658,14 +658,14 @@ int64_t world_chunk_from_entity(ecs_entity_t id) {
|
|||
}
|
||||
|
||||
void world_chunk_replace_worldgen_block(int64_t id, uint16_t block_idx, block_id bid) {
|
||||
ZPL_ASSERT(block_idx >= 0 && block_idx < zpl_square(world.chunk_size));
|
||||
ZPL_ASSERT(block_idx < zpl_square(world.chunk_size));
|
||||
ZPL_ASSERT(!(blocks_get_flags(bid) & BLOCK_FLAG_ENTITY));
|
||||
world.block_mapping[id][block_idx] = bid;
|
||||
world_chunk_mark_dirty(world.chunk_mapping[id]);
|
||||
}
|
||||
|
||||
void world_chunk_replace_block(int64_t id, uint16_t block_idx, block_id bid) {
|
||||
ZPL_ASSERT(block_idx >= 0 && block_idx < zpl_square(world.chunk_size));
|
||||
ZPL_ASSERT(block_idx < zpl_square(world.chunk_size));
|
||||
if (blocks_get_flags(bid) & BLOCK_FLAG_ENTITY) {
|
||||
ecs_entity_t e = entity_spawn_id(blocks_get_asset(bid));
|
||||
world_block_lookup l = world_block_from_index(id, block_idx);
|
||||
|
@ -678,7 +678,7 @@ void world_chunk_replace_block(int64_t id, uint16_t block_idx, block_id bid) {
|
|||
}
|
||||
|
||||
bool world_chunk_place_block(int64_t id, uint16_t block_idx, block_id bid) {
|
||||
ZPL_ASSERT(block_idx >= 0 && block_idx < zpl_square(world.chunk_size));
|
||||
ZPL_ASSERT(block_idx < zpl_square(world.chunk_size));
|
||||
if (world.outer_block_mapping[id][block_idx] != 0 && bid != 0) return false;
|
||||
if (blocks_get_flags(bid) & BLOCK_FLAG_ENTITY) {
|
||||
ecs_entity_t e = entity_spawn_id(blocks_get_asset(bid));
|
||||
|
|
|
@ -25,8 +25,8 @@ int worldgen_in_circle(int x, int y, int radius) {
|
|||
static void world_fill_rect(block_id *data, block_id id, uint32_t x, uint32_t y, uint32_t w, uint32_t h, world_block_observer_proc *proc) {
|
||||
for (uint32_t cy=y; cy<y+h; cy++) {
|
||||
for (uint32_t cx=x; cx<x+w; cx++) {
|
||||
if (cx < 0 || cx >= world->dim) continue;
|
||||
if (cy < 0 || cy >= world->dim) continue;
|
||||
if (cx >= world->dim) continue;
|
||||
if (cy >= world->dim) continue;
|
||||
uint32_t i = (cy*world->dim) + cx;
|
||||
|
||||
if (proc) {
|
||||
|
|
|
@ -1094,8 +1094,8 @@ c2TOIResult c2TOI(const void* A, C2_TYPE typeA, const c2x* ax_ptr, c2v vA, const
|
|||
if (!bx_ptr) bx = c2xIdentity();
|
||||
else bx = *bx_ptr;
|
||||
|
||||
c2Proxy pA;
|
||||
c2Proxy pB;
|
||||
c2Proxy pA = { 0 };
|
||||
c2Proxy pB = { 0 };
|
||||
c2MakeProxy(A, typeA, &pA);
|
||||
c2MakeProxy(B, typeB, &pB);
|
||||
|
||||
|
@ -1933,7 +1933,7 @@ void c2AABBtoPolyManifold(c2AABB A, const c2Poly* B, const c2x* bx, c2Manifold*
|
|||
// clip a segment to a plane
|
||||
static int c2Clip(c2v* seg, c2h h)
|
||||
{
|
||||
c2v out[2];
|
||||
c2v out[2] = { 0 };
|
||||
int sp = 0;
|
||||
float d0, d1;
|
||||
if ((d0 = c2Dist(h, seg[0])) < 0) out[sp++] = seg[0];
|
||||
|
|
Loading…
Reference in New Issue