Updated the aliases and switched from u64 to size_t in the for loops
This commit is contained in:
1 parent
e1806bafc2
commit
b95cff5f0c
5 files changed
+16
-12
No files matched your search
+6
-5
@@ -9,6 +9,7 @@
|
||||
#include "constants.h"
|
||||
#include "reusable_ids.h"
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@@ -51,7 +52,7 @@ u64 hash_path(const char *path) {
|
||||
|
||||
u64 i = 0;
|
||||
|
||||
for (u64 j = 0; path[j]; ++j) {
|
||||
for (size_t j = 0; path[j]; ++j) {
|
||||
i += (u64)path[j] * HASH_PRIME_01 % MAX_ASSET_COUNT;
|
||||
}
|
||||
|
||||
@@ -72,7 +73,7 @@ void insert_id_node(IDNodeList *node_list, AssetID id) {
|
||||
}
|
||||
|
||||
IDNode *last_node = node_list->start_node;
|
||||
for (u64 i = 1; i < node_list->node_count; ++i) {
|
||||
for (size_t i = 1; i < node_list->node_count; ++i) {
|
||||
last_node = last_node->next;
|
||||
}
|
||||
|
||||
@@ -98,7 +99,7 @@ void remove_id_node(IDNodeList *node_list, AssetID id) {
|
||||
IDNode *node = NULL;
|
||||
IDNode *prev = NULL;
|
||||
IDNode *current = node_list->start_node;
|
||||
for (u64 i = 0; i < node_list->node_count; ++i) {
|
||||
for (size_t i = 0; i < node_list->node_count; ++i) {
|
||||
if (current->id == id) {
|
||||
node = current;
|
||||
break;
|
||||
@@ -138,7 +139,7 @@ AssetID get_asset_id_from_id_node(AssetManager *am, IDNodeList *node_list,
|
||||
}
|
||||
|
||||
IDNode *id_node = node_list->start_node;
|
||||
for (u64 i = 0; i < node_list->node_count; ++i) {
|
||||
for (size_t i = 0; i < node_list->node_count; ++i) {
|
||||
if (!id_node) {
|
||||
break;
|
||||
}
|
||||
@@ -379,7 +380,7 @@ void destroy_asset_manager(AssetManager **am) {
|
||||
// TODO (Abdelrahman): Figure out if there is a better way to remove all of
|
||||
// the existing assets without having to loop for the maximum number of
|
||||
// assets allowed.
|
||||
for (u64 i = 0; i < MAX_ASSET_COUNT; ++i) {
|
||||
for (size_t i = 0; i < MAX_ASSET_COUNT; ++i) {
|
||||
if (!(*am)->assets[i].path) {
|
||||
continue;
|
||||
}
|
||||
|
||||
+5
-4
@@ -22,6 +22,7 @@
|
||||
#include "engine_build_config.h"
|
||||
#include "reusable_ids.h"
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
@@ -467,7 +468,7 @@ void pause_all_instances_of_audio_asset(AssetID id) {
|
||||
|
||||
u64 channel_count = Mix_AllocateChannels(-1);
|
||||
|
||||
for (u64 i = 0; i < channel_count; ++i) {
|
||||
for (size_t i = 0; i < channel_count; ++i) {
|
||||
if (chunk == Mix_GetChunk(i)) {
|
||||
Mix_Pause(i);
|
||||
}
|
||||
@@ -486,7 +487,7 @@ void resume_all_instances_of_audio_asset(AssetID id) {
|
||||
|
||||
u64 channel_count = Mix_AllocateChannels(-1);
|
||||
|
||||
for (u64 i = 0; i < channel_count; ++i) {
|
||||
for (size_t i = 0; i < channel_count; ++i) {
|
||||
if (chunk == Mix_GetChunk(i)) {
|
||||
Mix_Resume(i);
|
||||
}
|
||||
@@ -505,7 +506,7 @@ void stop_all_instances_of_audio_asset(AssetID id) {
|
||||
|
||||
u64 channel_count = Mix_AllocateChannels(-1);
|
||||
|
||||
for (u64 i = 0; i < channel_count; ++i) {
|
||||
for (size_t i = 0; i < channel_count; ++i) {
|
||||
if (chunk == Mix_GetChunk(i)) {
|
||||
Mix_HaltChannel(i);
|
||||
}
|
||||
@@ -524,7 +525,7 @@ void fade_out_all_instances_of_audio_asset(AssetID id, u32 fade_length_in_ms) {
|
||||
|
||||
u64 channel_count = Mix_AllocateChannels(-1);
|
||||
|
||||
for (u64 i = 0; i < channel_count; ++i) {
|
||||
for (size_t i = 0; i < channel_count; ++i) {
|
||||
if (chunk == Mix_GetChunk(i)) {
|
||||
Mix_FadeOutChannel(i, fade_length_in_ms);
|
||||
}
|
||||
|
||||
+2
-2
@@ -46,7 +46,7 @@ bool object_exists(ObjectStore *os, void *object) {
|
||||
// This is a crude implementation for checking that an object has already
|
||||
// been added.
|
||||
// TODO (Abdelrahman): Figure out if there is a better way of doing this
|
||||
for (u64 i = 0; i < MAX_OBJ_COUNT; ++i) {
|
||||
for (size_t i = 0; i < MAX_OBJ_COUNT; ++i) {
|
||||
if (object == os->object_ptrs[i]) {
|
||||
return true;
|
||||
}
|
||||
@@ -150,7 +150,7 @@ void destroy_object_store(ObjectStore **os) {
|
||||
// TODO (Abdelrahman): Figure out if there is a better way to remove all of
|
||||
// the existing objects without having to loop for the maximum number of
|
||||
// objects allowed.
|
||||
for (u64 i = 0; i < MAX_OBJ_COUNT; ++i) {
|
||||
for (size_t i = 0; i < MAX_OBJ_COUNT; ++i) {
|
||||
(*os)->object_ptrs[i] = NULL;
|
||||
(*os)->event_handlers[i] = NULL;
|
||||
(*os)->update_funcs[i] = NULL;
|
||||
|
||||
+2
-1
@@ -1,10 +1,11 @@
|
||||
#include "reusable_ids.h"
|
||||
#include "aliases.h"
|
||||
#include <stddef.h>
|
||||
|
||||
i32 reuse_id(i32 *ids, u64 count) {
|
||||
i32 id = ids[0];
|
||||
|
||||
for (u64 i = 0; i < count; ++i) {
|
||||
for (size_t i = 0; i < count; ++i) {
|
||||
// Remove the first id and make sure the remaining ones are packed
|
||||
ids[i] = ids[i + 1];
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user