Getting ready to modify AMS and ECS

This commit is contained in:
Dennis Eichhorn 2025-01-02 21:13:11 +01:00
parent 73dfa96c6a
commit 2521f5f2e4
13 changed files with 300 additions and 133 deletions

View File

@ -10,6 +10,7 @@
#ifndef TOS_ANIMATION_H #ifndef TOS_ANIMATION_H
#define TOS_ANIMATION_H #define TOS_ANIMATION_H
#include "../stdlib/Types.h"
#include "../utils/MathUtils.h" #include "../utils/MathUtils.h"
#include "AnimationEaseType.h" #include "AnimationEaseType.h"
@ -26,6 +27,9 @@ f32 smoothstep(f32 t) {
f32 anim_ease(f32 t, AnimationEaseType type) { f32 anim_ease(f32 t, AnimationEaseType type) {
switch(type) { switch(type) {
case ANIMATION_EASE_DISCRETE: {
return anim_discrete(t);
};
case ANIMATION_EASE_IN_SINE: { case ANIMATION_EASE_IN_SINE: {
return anim_ease_in_sine(t); return anim_ease_in_sine(t);
}; };
@ -121,6 +125,11 @@ f32 anim_ease(f32 t, AnimationEaseType type) {
} }
} }
inline
f32 anim_discrete(f32 t) {
return t >= 1.0f ? 1.0f : 0.0f;
}
inline inline
f32 anim_ease_linear(f32 t) { f32 anim_ease_linear(f32 t) {
return t; return t;
@ -217,7 +226,8 @@ f32 anim_ease_in_out_quint(f32 t) {
inline inline
f32 anim_ease_in_expo(f32 t) { f32 anim_ease_in_expo(f32 t) {
return t == 0 return t == 0
? 0 : pow(2, 10 * t - 10); ? 0
: pow(2, 10 * t - 10);
} }
inline inline
@ -240,19 +250,19 @@ f32 anim_ease_in_out_expo(f32 t) {
inline inline
f32 anim_ease_in_circ(f32 t) { f32 anim_ease_in_circ(f32 t) {
return 1 - sqrt(1 - pow(t, 2)); return 1 - sqrtf(1 - pow(t, 2));
} }
inline inline
f32 anim_ease_out_circ(f32 t) { f32 anim_ease_out_circ(f32 t) {
return sqrt(1 - pow(t - 1, 2)); return sqrtf(1 - pow(t - 1, 2));
} }
inline inline
f32 anim_ease_in_out_circ(f32 t) { f32 anim_ease_in_out_circ(f32 t) {
return t < 0.5 return t < 0.5
? (1 - sqrt(1 - pow(2 * t, 2))) / 2 ? (1 - sqrtf(1 - pow(2 * t, 2))) / 2
: (sqrt(1 - pow(-2 * t + 2, 2)) + 1) / 2; : (sqrtf(1 - pow(-2 * t + 2, 2)) + 1) / 2;
} }
inline inline

View File

@ -10,8 +10,11 @@
#ifndef TOS_ANIMATION_EASE_TYPE_H #ifndef TOS_ANIMATION_EASE_TYPE_H
#define TOS_ANIMATION_EASE_TYPE_H #define TOS_ANIMATION_EASE_TYPE_H
enum AnimationEaseType { #include "../stdlib/Types.h"
enum AnimationEaseType : byte {
ANIMATION_LINEAR, ANIMATION_LINEAR,
ANIMATION_EASE_DISCRETE,
ANIMATION_EASE_IN_SINE, ANIMATION_EASE_IN_SINE,
ANIMATION_EASE_OUT_SINE, ANIMATION_EASE_OUT_SINE,
ANIMATION_EASE_IN_OUT_SINE, ANIMATION_EASE_IN_OUT_SINE,

View File

@ -35,6 +35,14 @@ struct AssetManagementSystem {
// The indices of asset_memory and asset_data_memory are always linked // The indices of asset_memory and asset_data_memory are always linked
// @question Wouldn't it make much more sense to have a general AMS for this data
// In that case we would only need one AMS which holds the Asset information. All others would only need the data_memory
// We could probably dramatically simplify the AMS that holds the actual data. We might only need the ChunkMemory?
// @question Even further, why would we want to split stats and DATA at all? we are talking about assets which most likely don't fit into a single L1 cache line
// BUT they may fit in L2 or L3 and therefore require less pointer chasing
// Sure collecting data is faster with split memory (ram/vram usage)
// General asset memory // General asset memory
// Fixed chunk size of sizeof(Asset) // Fixed chunk size of sizeof(Asset)
ChunkMemory asset_memory; ChunkMemory asset_memory;

78
entity/AnimationEntity.h Normal file
View File

@ -0,0 +1,78 @@
/**
* Jingga
*
* @copyright Jingga
* @license OMS License 2.0
* @version 1.0.0
* @link https://jingga.app
*/
#ifndef TOS_ANIMATION_ENTITY_H
#define TOS_ANIMATION_ENTITY_H
#include "../stdlib/Types.h"
#include "../animation/AnimationEaseType.h"
#include "../animation/Animation.h"
#include "../utils/BitUtils.h"
#include "EntityComponentSystem.h"
struct AnimationEntity {
AnimationEaseType type;
uint32 start_time;
uint32 last_time;
f32 interval;
f32 progress;
byte state_last;
byte state;
// @question Do we want another flag that indicates if the entity got handled by the main loop?
// this way we could do the animation process in a thread and only overwrite the state_last whenever the flag is true
// However, we would have to implement locking or atomics which might be really bad depending on how we use this data
};
void update_animation_entity(AnimationEntity* anim, uint32 time, uint32 delay)
{
anim->state_last = anim->state;
switch (anim->type) {
case ANIMATION_EASE_DISCRETE: {
anim->progress = anim_discrete((f32) (time - anim->start_time + delay) / (f32) anim->interval);
anim->state = (int32) ((f32) anim->state - anim->progress);
} break;
default: {}
}
}
void update_animation_entities(EntityComponentSystem* ecs, uint32 time, uint32 delay)
{
int32 chunk_bytes = (ecs->entity_data_memory.size + 63) / 64;
// @performance It might make sense to iterate by int16 or even int32 instead of byte. Needs profiling
for (int32 i = 0; i < chunk_bytes; ++i) {
// @question Do we want this to be the first case. It probably depends on how often a byte is realistically empty
if (!ecs->entity_data_memory.free[i]) {
continue;
} else if (ecs->entity_data_memory.free[i] == 256) {
// @performance If we go larger than 8bit in the outer loop we also have to adjust it here
// AND maybe we would want to do sub checks then for 8bit again
for (int32 j = 0; j < 8; ++j) {
AnimationEntity* anim = (AnimationEntity *) chunk_get_element(&ecs->entity_data_memory, i * 8 + j);
update_animation_entity(anim, time, delay);
}
continue;
}
// @performance If we go larger than 8bit in the outer loop we also have to adjust it here
// AND maybe we would want to do sub checks then for 8bit again
for (int32 j = 0; j < 8; ++j) {
if (!IS_BIT_SET_L2R(ecs->entity_data_memory.free[i], j, 1)) {
continue;
}
AnimationEntity* anim = (AnimationEntity *) chunk_get_element(&ecs->entity_data_memory, i * 8 + j);
update_animation_entity(anim, time, delay);
}
}
}
#endif

View File

@ -22,20 +22,29 @@ struct Entity {
EntityType type; EntityType type;
uint64 last_access;
// Variable used for thread safety
bool is_loaded;
// Describes if the asset can be removed/garbage collected IF necessary
// This however only happens if space is needed
bool can_garbage_collect_ram;
bool can_garbage_collect_vram;
// Counts the references to this entity // Counts the references to this entity
// e.g. textures // e.g. textures
int reference_count; int16 reference_count;
Entity* next;
Entity* prev;
// A entity can reference up to N other entities // A entity can reference up to N other entities
// This allows us to quickly update the other entities // This allows us to quickly update the other entities
// Example: A player pulls N mobs // Example: A player pulls N mobs
// @bug This means there are hard limits on how many mobs can be pulled by a player // @bug This means there are hard limits on how many mobs can be pulled by a player
// @question should this be an entity id?
Entity* references[50]; Entity* references[50];
uint64 free_references; // bits show which is free uint64 free_references; // bits show which is free
// @question should this be an entity id?
Entity* schema; // This entity represents the schema for this entity (most likely stored in a separate ecs) Entity* schema; // This entity represents the schema for this entity (most likely stored in a separate ecs)
// Actual memory address and specific entity data // Actual memory address and specific entity data
@ -50,28 +59,35 @@ struct EntitySchema {
// Could be 0 if there is no official id // Could be 0 if there is no official id
uint64 official_id; uint64 official_id;
char name[MAX_ENTITY_NAME_LENGTH];
EntityType type; EntityType type;
// Counts the references to this entity // Counts the references to this entity
// e.g. textures // e.g. textures
int reference_count; int16 reference_count;
// Describes how much ram/vram the asset uses // Describes how much ram/vram the asset uses
// E.g. vram_size = 0 but ram_size > 0 means that it never uses any gpu memory // E.g. vram_size = 0 but ram_size > 0 means that it never uses any gpu memory
uint64 ram_size; uint64 ram_size;
uint64 vram_size; uint64 vram_size;
uint64 last_access;
// Usually 1 but in some cases an ECS may hold entities of variable chunk length // Usually 1 but in some cases an ECS may hold entities of variable chunk length
// For textures for example a 128x128 is of size 1 but 256x256 is of size 4 // For textures for example a 128x128 is of size 1 but 256x256 is of size 4
uint32 size; uint32 size;
// Variable used for thread safety
bool is_loaded;
// Describes if the memory is currently available in ram/vram // Describes if the memory is currently available in ram/vram
// E.g. a entity might be uploaded to the gpu and no longer held in ram (or the other way around) // E.g. a entity might be uploaded to the gpu and no longer held in ram (or the other way around)
bool is_ram; bool is_ram;
bool is_vram; bool is_vram;
// Describes if the asset can be removed/garbage collected IF necessary
// This however only happens if space is needed
bool can_garbage_collect_ram;
bool can_garbage_collect_vram;
EntitySchema* next; EntitySchema* next;
EntitySchema* prev; EntitySchema* prev;
@ -79,7 +95,8 @@ struct EntitySchema {
// This allows us to quickly update the other entities // This allows us to quickly update the other entities
// Example: A player pulls N mobs // Example: A player pulls N mobs
// @bug This means there are hard limits on how many mobs can be pulled by a player // @bug This means there are hard limits on how many mobs can be pulled by a player
Entity* references[50]; // @question should this be an entity id?
EntitySchema* references[50];
uint64 free_references; // bits show which is free uint64 free_references; // bits show which is free
// Actual memory address and specific schema data // Actual memory address and specific schema data

View File

@ -21,22 +21,37 @@ struct EntityComponentSystem {
// @question is this even necessary or could we integrate this directly into the system here? // @question is this even necessary or could we integrate this directly into the system here?
HashMap hash_map; HashMap hash_map;
uint64 ram_size;
uint64 vram_size;
uint64 entity_count;
int32 overhead;
// @question Do we want this, I would assume this should be almost always true in the final game
bool has_changed;
// The indices of entity_memory and entity_data_memory are always linked // The indices of entity_memory and entity_data_memory are always linked
// @question Consider to reset entity_memory->last_pos to 0 before adding a new element
// This allows us to make the chunk memory more continuous which is better for iteration later on
// However, adding elements would now be slower. Needs profiling
// General entity memory // General entity memory
ChunkMemory entity_memory; ChunkMemory entity_memory;
// Actual entity data // Actual entity data
ChunkMemory entity_data_memory; ChunkMemory entity_data_memory;
Entity* first;
Entity* last;
}; };
struct EntitySchemaSystem { struct EntitySchemaSystem {
// @question is this even necessary or could we integrate this directly into the system here? // @question is this even necessary or could we integrate this directly into the system here?
HashMap hash_map; HashMap hash_map;
uint64 ram_size;
uint64 vram_size;
uint64 entity_count;
int32 overhead;
bool has_changed;
// The indices of entity_memory and entity_data_memory are always linked // The indices of entity_memory and entity_data_memory are always linked
// General entity memory // General entity memory

View File

@ -118,6 +118,8 @@ void vertex_rect_create(
*index = idx; *index = idx;
} }
// @todo also allow background -> we can benefit from reduced vertex count
// All we have to do is add 3 more vertices (= inside vertices)
inline inline
void vertex_rect_border_create( void vertex_rect_border_create(
Vertex3DTextureColorIndex* __restrict vertices, uint32* __restrict index, f32 zindex, Vertex3DTextureColorIndex* __restrict vertices, uint32* __restrict index, f32 zindex,

View File

@ -15,6 +15,14 @@
#include "ControllerInput.h" #include "ControllerInput.h"
#include "InputConnectionType.h" #include "InputConnectionType.h"
#define INPUT_MOUSE_BUTTON_1 1
#define INPUT_MOUSE_BUTTON_2 2
#define INPUT_MOUSE_BUTTON_3 3
#define INPUT_MOUSE_BUTTON_4 4
#define INPUT_MOUSE_BUTTON_5 5
#define INPUT_MOUSE_BUTTON_WHEEL 6
#define INPUT_MOUSE_BUTTON_HWHEEL 7
// How many concurrent mouse/secondary input device presses to we recognize // How many concurrent mouse/secondary input device presses to we recognize
#define MAX_MOUSE_PRESSES 3 #define MAX_MOUSE_PRESSES 3
@ -28,7 +36,7 @@
#define MIN_INPUT_DEVICES 2 #define MIN_INPUT_DEVICES 2
// How often can a key be asigned to a different hotkey // How often can a key be assigned to a different hotkey
#define MAX_KEY_TO_HOTKEY 5 #define MAX_KEY_TO_HOTKEY 5
#define MEX_KEY_LENGTH ((MAX_MOUSE_KEYS + MAX_KEYBOARD_KEYS + MAX_CONTROLLER_KEYS) * MAX_KEY_TO_HOTKEY) #define MEX_KEY_LENGTH ((MAX_MOUSE_KEYS + MAX_KEYBOARD_KEYS + MAX_CONTROLLER_KEYS) * MAX_KEY_TO_HOTKEY)
@ -38,12 +46,15 @@
// These values are used as bit flags to hint32 if a "key" is a keyboard/primary or mouse/secondary input // These values are used as bit flags to hint32 if a "key" is a keyboard/primary or mouse/secondary input
// When adding a keybind the "key" can only be uint8 but we expand it to an int and set the first bit accordingly // When adding a keybind the "key" can only be uint8 but we expand it to an int and set the first bit accordingly
#define INPUT_MOUSE_PREFIX 0 #define INPUT_MOUSE_PREFIX 0
#define INPUT_KEYBOARD_PREFIX 8192 #define INPUT_KEYBOARD_PREFIX 1 << 13
#define INPUT_CONTROLLER_PREFIX 16384 #define INPUT_CONTROLLER_PREFIX 1 << 14
#define INPUT_TYPE_MOUSE_KEYBOARD 0x01 enum InputType {
#define INPUT_TYPE_CONTROLLER 0x02 INPUT_TYPE_NONE = 0,
#define INPUT_TYPE_OTHER 0x03 INPUT_TYPE_MOUSE_KEYBOARD = 1 << 0,
INPUT_TYPE_CONTROLLER = 1 << 2,
INPUT_TYPE_OTHER = 1 << 3,
};
#define MIN_CONTROLLER_DEVICES 4 #define MIN_CONTROLLER_DEVICES 4

View File

@ -173,10 +173,8 @@ void chunk_reserve_index(ChunkMemory* buf, int64 index, int64 elements = 1, bool
int64 chunk_reserve(ChunkMemory* buf, uint64 elements = 1, bool zeroed = false) int64 chunk_reserve(ChunkMemory* buf, uint64 elements = 1, bool zeroed = false)
{ {
int64 free_index = (buf->last_pos + 1) / 64; int64 free_index = (buf->last_pos + 1) / 64;
int32 bit_index; int32 bit_index = buf->last_pos - free_index * 64;
int64 free_element = -1; int64 free_element = -1;
int64 mask;
int32 i = 0; int32 i = 0;
int64 max_bytes = (buf->count + 7) / 64; int64 max_bytes = (buf->count + 7) / 64;
@ -195,7 +193,7 @@ int64 chunk_reserve(ChunkMemory* buf, uint64 elements = 1, bool zeroed = false)
} }
// @performance There is some redundancy happening down below, we should ++free_index in certain conditions? // @performance There is some redundancy happening down below, we should ++free_index in certain conditions?
for (bit_index = 0; bit_index < 64; ++bit_index) { for (; bit_index < 64; ++bit_index) {
int32 consecutive_free_bits = 0; int32 consecutive_free_bits = 0;
// Check if there are 'elements' consecutive free bits // Check if there are 'elements' consecutive free bits
@ -209,7 +207,7 @@ int64 chunk_reserve(ChunkMemory* buf, uint64 elements = 1, bool zeroed = false)
uint64 current_free_index = free_index + (bit_index + j) / 64; uint64 current_free_index = free_index + (bit_index + j) / 64;
int32 current_bit_index = (bit_index + j) % 64; int32 current_bit_index = (bit_index + j) % 64;
mask = 1LL << current_bit_index; int64 mask = 1LL << current_bit_index;
if ((buf->free[current_free_index] & mask) == 0) { if ((buf->free[current_free_index] & mask) == 0) {
++consecutive_free_bits; ++consecutive_free_bits;
} else { } else {
@ -231,6 +229,8 @@ int64 chunk_reserve(ChunkMemory* buf, uint64 elements = 1, bool zeroed = false)
} }
} }
bit_index = 0;
++i; ++i;
++free_index; ++free_index;
} }

View File

@ -1,104 +1,128 @@
#ifndef TOS_MODELS_SETTING_TYPES_H #ifndef TOS_MODELS_SETTING_TYPES_H
#define TOS_MODELS_SETTING_TYPES_H #define TOS_MODELS_SETTING_TYPES_H
#define SETTING_TYPE_GPU_CUSTOM 0x0 enum SettingGpuDetail {
#define SETTING_TYPE_GPU_VLOW 0x1 SETTING_TYPE_GPU_CUSTOM,
#define SETTING_TYPE_GPU_LOW 0x2 SETTING_TYPE_GPU_VLOW,
#define SETTING_TYPE_GPU_MEDIUM 0x3 SETTING_TYPE_GPU_LOW,
#define SETTING_TYPE_GPU_HIGH 0x4 SETTING_TYPE_GPU_MEDIUM,
#define SETTING_TYPE_GPU_VHIGH 0x5 SETTING_TYPE_GPU_HIGH,
#define SETTING_TYPE_GPU_ULTRA 0x6 SETTING_TYPE_GPU_VHIGH,
#define SETTING_TYPE_GPU_NEXTGEN 0x7 SETTING_TYPE_GPU_ULTRA,
SETTING_TYPE_GPU_NEXTGEN
};
#define SETTING_TYPE_PERSPECTIVE_FIRST 0x00 enum SettingPlayerPerspective {
#define SETTING_TYPE_PERSPECTIVE_THIRD 0x01 SETTING_TYPE_PERSPECTIVE_FIRST,
#define SETTING_TYPE_PERSPECTIVE_ISOMETRIC 0x02 SETTING_TYPE_PERSPECTIVE_THIRD,
SETTING_TYPE_PERSPECTIVE_ISOMETRIC
};
#define SETTING_TYPE_SYNC_V 0x1 enum SettingVSync {
#define SETTING_TYPE_SYNC_ADAPTIVE 0x2 SETTING_TYPE_SYNC_NONE,
#define SETTING_TYPE_SYNC_FAST 0x3 SETTING_TYPE_SYNC_V,
SETTING_TYPE_SYNC_ADAPTIVE,
SETTING_TYPE_SYNC_FAST
};
#define SETTING_TYPE_ASPEC_RATIO_4x3 0x00 enum SettingAspectRatio {
#define SETTING_TYPE_ASPEC_RATIO_16x9 0x01 SETTING_TYPE_ASPEC_RATIO_4x3,
#define SETTING_TYPE_ASPEC_RATIO_16x10 0x02 SETTING_TYPE_ASPEC_RATIO_16x9,
#define SETTING_TYPE_ASPEC_RATIO_21x9 0x03 SETTING_TYPE_ASPEC_RATIO_16x10,
SETTING_TYPE_ASPEC_RATIO_21x9
};
#define SETTING_TYPE_SCREEN_RESOLUTION_800x600 0x00 enum SettingScreenResolution {
#define SETTING_TYPE_SCREEN_RESOLUTION_1024x768 0x01 SETTING_TYPE_SCREEN_RESOLUTION_800x600,
#define SETTING_TYPE_SCREEN_RESOLUTION_1280x720 0x02 SETTING_TYPE_SCREEN_RESOLUTION_1024x768,
#define SETTING_TYPE_SCREEN_RESOLUTION_1280x800 0x03 SETTING_TYPE_SCREEN_RESOLUTION_1280x720,
#define SETTING_TYPE_SCREEN_RESOLUTION_1280x1024 0x04 SETTING_TYPE_SCREEN_RESOLUTION_1280x800,
#define SETTING_TYPE_SCREEN_RESOLUTION_1360x768 0x05 SETTING_TYPE_SCREEN_RESOLUTION_1280x1024,
#define SETTING_TYPE_SCREEN_RESOLUTION_1366x768 0x06 SETTING_TYPE_SCREEN_RESOLUTION_1360x768,
#define SETTING_TYPE_SCREEN_RESOLUTION_1440x900 0x07 SETTING_TYPE_SCREEN_RESOLUTION_1366x768,
#define SETTING_TYPE_SCREEN_RESOLUTION_1536x864 0x08 SETTING_TYPE_SCREEN_RESOLUTION_1440x900,
#define SETTING_TYPE_SCREEN_RESOLUTION_1600x900 0x09 SETTING_TYPE_SCREEN_RESOLUTION_1536x864,
#define SETTING_TYPE_SCREEN_RESOLUTION_1600x1200 0x0A SETTING_TYPE_SCREEN_RESOLUTION_1600x900,
#define SETTING_TYPE_SCREEN_RESOLUTION_1680x1050 0x0B SETTING_TYPE_SCREEN_RESOLUTION_1600x1200,
#define SETTING_TYPE_SCREEN_RESOLUTION_1920x1080 0x0C SETTING_TYPE_SCREEN_RESOLUTION_1680x1050,
#define SETTING_TYPE_SCREEN_RESOLUTION_1920x1200 0x0D SETTING_TYPE_SCREEN_RESOLUTION_1920x1080,
#define SETTING_TYPE_SCREEN_RESOLUTION_2048x1152 0x0E SETTING_TYPE_SCREEN_RESOLUTION_1920x1200,
#define SETTING_TYPE_SCREEN_RESOLUTION_2048x1536 0x0F SETTING_TYPE_SCREEN_RESOLUTION_2048x1152,
#define SETTING_TYPE_SCREEN_RESOLUTION_2560x1080 0x10 SETTING_TYPE_SCREEN_RESOLUTION_2048x1536,
#define SETTING_TYPE_SCREEN_RESOLUTION_2560x1440 0x11 SETTING_TYPE_SCREEN_RESOLUTION_2560x1080,
#define SETTING_TYPE_SCREEN_RESOLUTION_2560x1600 0x12 SETTING_TYPE_SCREEN_RESOLUTION_2560x1440,
#define SETTING_TYPE_SCREEN_RESOLUTION_3440x1440 0x13 SETTING_TYPE_SCREEN_RESOLUTION_2560x1600,
#define SETTING_TYPE_SCREEN_RESOLUTION_3840x2160 0x14 SETTING_TYPE_SCREEN_RESOLUTION_3440x1440,
SETTING_TYPE_SCREEN_RESOLUTION_3840x2160
};
#define SETTING_TYPE_WINDOW_CHAT 0x01 enum SettingWindows {
#define SETTING_TYPE_WINDOW_MAP 0x02 SETTING_TYPE_WINDOW_NONE,
#define SETTING_TYPE_WINDOW_RANKING 0x03 SETTING_TYPE_WINDOW_CHAT,
#define SETTING_TYPE_WINDOW_SHOP 0x04 SETTING_TYPE_WINDOW_MAP,
#define SETTING_TYPE_WINDOW_STATS 0x05 SETTING_TYPE_WINDOW_RANKING,
#define SETTING_TYPE_WINDOW_GROUPS 0x06 SETTING_TYPE_WINDOW_SHOP,
#define SETTING_TYPE_WINDOW_PET 0x07 // Pet "tamagochi" window SETTING_TYPE_WINDOW_STATS,
SETTING_TYPE_WINDOW_GROUPS,
SETTING_TYPE_WINDOW_PET // Pet "tamagochi" window
};
#define SETTING_TYPE_WINDOW_MODE_FULLSCREEN 0x00 enum SettingWindowMode {
#define SETTING_TYPE_WINDOW_MODE_WINDOWED_FULLSCREEN 0x01 SETTING_TYPE_WINDOW_MODE_FULLSCREEN,
#define SETTING_TYPE_WINDOW_MODE_WINDOWED 0x02 SETTING_TYPE_WINDOW_MODE_WINDOWED_FULLSCREEN,
SETTING_TYPE_WINDOW_MODE_WINDOWED
};
#define SETTING_TYPE_DISABLED 0x00 #define SETTING_TYPE_DISABLED 0x00
#define SETTING_TYPE_UNLIMITED 0x00 #define SETTING_TYPE_UNLIMITED 0x00
#define SETTING_DEBUG_VISIBILITY_WIREFRAME 1 enum SettingDebugVisibility {
#define SETTING_DEBUG_VISIBILITY_DEBUG 2 SETTING_DEBUG_VISIBILITY_WIREFRAME = 1 << 0,
#define SETTING_DEBUG_VISIBILITY_3D 2048 SETTING_DEBUG_VISIBILITY_DEBUG = 1 << 1,
#define SETTING_DEBUG_VISIBILITY_NORMALS 4096 SETTING_DEBUG_VISIBILITY_3D = 1 << 2,
SETTING_DEBUG_VISIBILITY_NORMALS = 1 << 3
};
#define SETTING_UI_VISIBILITY_FPS 1 enum SettingUiVisibility {
#define SETTING_UI_VISIBILITY_APM 2 SETTING_UI_VISIBILITY_FPS = 1 << 0,
#define SETTING_UI_VISIBILITY_NET_GRAPH 4 SETTING_UI_VISIBILITY_APM = 1 << 1,
#define SETTING_UI_VISIBILITY___ 8 SETTING_UI_VISIBILITY_NET_GRAPH = 1 << 2,
#define SETTING_UI_VISIBILITY_HOTKEYS 16 SETTING_UI_VISIBILITY_CONSOLE = 1 << 3,
#define SETTING_UI_VISIBILITY_XP_BAR 32 SETTING_UI_VISIBILITY_HOTKEYS = 1 << 4,
#define SETTING_UI_VISIBILITY_COOLDOWN_TIMER 64 SETTING_UI_VISIBILITY_XP_BAR = 1 << 5,
#define SETTING_UI_VISIBILITY_MINIMAP 128 SETTING_UI_VISIBILITY_COOLDOWN_TIMER = 1 << 6,
#define SETTING_UI_VISIBILITY_CHAT 256 SETTING_UI_VISIBILITY_MINIMAP = 1 << 7,
#define SETTING_UI_VISIBILITY_CLOCK 512 SETTING_UI_VISIBILITY_CHAT = 1 << 8,
#define SETTING_UI_VISIBILITY_SUBTITLES 1024 SETTING_UI_VISIBILITY_CLOCK = 1 << 9,
#define SETTING_UI_VISIBILITY_BAR 2048 SETTING_UI_VISIBILITY_SUBTITLES = 1 << 10,
#define SETTING_UI_VISIBILITY_HEALTH 4096 SETTING_UI_VISIBILITY_BAR = 1 << 11,
#define SETTING_UI_VISIBILITY_RESOURCE 8192 SETTING_UI_VISIBILITY_HEALTH = 1 << 12,
#define SETTING_UI_VISIBILITY_INFO 8192 // = e.g. quest info SETTING_UI_VISIBILITY_RESOURCE = 1 << 13,
SETTING_UI_VISIBILITY_INFO = 1 << 14 // = e.g. quest info
};
#define SETTING_GAME_VISIBILITY_BAR_SELF 1 enum SettingGameVisibility {
#define SETTING_GAME_VISIBILITY_BAR_PLAYER 2 SETTING_GAME_VISIBILITY_BAR_SELF = 1 << 0,
#define SETTING_GAME_VISIBILITY_BAR_OTHER 4 SETTING_GAME_VISIBILITY_BAR_PLAYER = 1 << 1,
#define SETTING_GAME_VISIBILITY_BAR_NUMBERS 8 SETTING_GAME_VISIBILITY_BAR_OTHER = 1 << 2,
#define SETTING_GAME_VISIBILITY_BUFFS_SELF 16 SETTING_GAME_VISIBILITY_BAR_NUMBERS = 1 << 3,
#define SETTING_GAME_VISIBILITY_BUFFS_PLAYER 32 SETTING_GAME_VISIBILITY_BUFFS_SELF = 1 << 4,
#define SETTING_GAME_VISIBILITY_BUFFS_OTHER 64 SETTING_GAME_VISIBILITY_BUFFS_PLAYER = 1 << 5,
#define SETTING_GAME_VISIBILITY_NAME_SELF 128 SETTING_GAME_VISIBILITY_BUFFS_OTHER = 1 << 6,
#define SETTING_GAME_VISIBILITY_NAME_PLAYER 256 SETTING_GAME_VISIBILITY_NAME_SELF = 1 << 7,
#define SETTING_GAME_VISIBILITY_NAME_OTHER 512 SETTING_GAME_VISIBILITY_NAME_PLAYER = 1 << 8,
#define SETTING_GAME_VISIBILITY_TITLE_SELF 1024 SETTING_GAME_VISIBILITY_NAME_OTHER = 1 << 9,
#define SETTING_GAME_VISIBILITY_TITLE_PLAYER 2048 SETTING_GAME_VISIBILITY_TITLE_SELF = 1 << 10,
#define SETTING_GAME_VISIBILITY_TITLE_OTHER 4096 SETTING_GAME_VISIBILITY_TITLE_PLAYER = 1 << 11,
#define SETTING_GAME_VISIBILITY_DMG_NUMBERS 8192 SETTING_GAME_VISIBILITY_TITLE_OTHER = 1 << 12,
#define SETTING_GAME_VISIBILITY_XP_NUMBERS 16384 SETTING_GAME_VISIBILITY_DMG_NUMBERS = 1 << 13,
#define SETTING_GAME_VISIBILITY_EFFECTS 32768 SETTING_GAME_VISIBILITY_XP_NUMBERS = 1 << 14,
SETTING_GAME_VISIBILITY_EFFECTS = 1 << 15
};
#define SETTING_INPUT_DEVICE_TYPE_MOUSE_KEYBOARD 1 enum InputDeviceType {
#define SETTING_INPUT_DEVICE_TYPE_CONTROLLER 2 SETTING_INPUT_DEVICE_TYPE_MOUSE_KEYBOARD,
SETTING_INPUT_DEVICE_TYPE_CONTROLLER,
};
#endif #endif

View File

@ -293,8 +293,8 @@ void file_read(FileHandle fp, FileBody* file, uint64 offset = 0, uint64 length =
{ {
LARGE_INTEGER size; LARGE_INTEGER size;
if (!GetFileSizeEx(fp, &size)) { if (!GetFileSizeEx(fp, &size)) {
CloseHandle(fp);
file->content = NULL; file->content = NULL;
ASSERT_SIMPLE(false);
return; return;
} }
@ -304,7 +304,7 @@ void file_read(FileHandle fp, FileBody* file, uint64 offset = 0, uint64 length =
if (offset >= file_size) { if (offset >= file_size) {
file->size = 0; file->size = 0;
file->content = NULL; file->content = NULL;
CloseHandle(fp); ASSERT_SIMPLE(false);
return; return;
} }
@ -320,16 +320,16 @@ void file_read(FileHandle fp, FileBody* file, uint64 offset = 0, uint64 length =
LARGE_INTEGER li; LARGE_INTEGER li;
li.QuadPart = offset; li.QuadPart = offset;
if (SetFilePointerEx(fp, li, NULL, FILE_BEGIN) == 0) { if (SetFilePointerEx(fp, li, NULL, FILE_BEGIN) == 0) {
CloseHandle(fp);
file->content = NULL; file->content = NULL;
ASSERT_SIMPLE(false);
return; return;
} }
DWORD bytes; DWORD bytes;
if (!ReadFile(fp, file->content, (uint32) read_length, &bytes, NULL)) { if (!ReadFile(fp, file->content, (uint32) read_length, &bytes, NULL)) {
CloseHandle(fp);
file->content = NULL; file->content = NULL;
ASSERT_SIMPLE(false);
return; return;
} }
@ -554,8 +554,8 @@ bool file_read_async(
) { ) {
LARGE_INTEGER size; LARGE_INTEGER size;
if (!GetFileSizeEx(fp, &size)) { if (!GetFileSizeEx(fp, &size)) {
CloseHandle(fp);
file->content = NULL; file->content = NULL;
ASSERT_SIMPLE(false);
return false; return false;
} }
@ -565,7 +565,7 @@ bool file_read_async(
if (offset >= file_size) { if (offset >= file_size) {
file->size = 0; file->size = 0;
file->content = NULL; file->content = NULL;
CloseHandle(fp); ASSERT_SIMPLE(false);
return false; return false;
} }
@ -579,7 +579,7 @@ bool file_read_async(
} }
if (!file->content) { if (!file->content) {
CloseHandle(fp); ASSERT_SIMPLE(false);
return false; return false;
} }
@ -594,10 +594,9 @@ bool file_read_async(
if (!ReadFile(fp, file->content, (DWORD) read_length, &bytes_read, &file->ov)) { if (!ReadFile(fp, file->content, (DWORD) read_length, &bytes_read, &file->ov)) {
DWORD error = GetLastError(); DWORD error = GetLastError();
if (error != ERROR_IO_PENDING) { if (error != ERROR_IO_PENDING) {
CloseHandle(fp);
free(file->content); free(file->content);
file->content = NULL; file->content = NULL;
CloseHandle(&file->ov.hEvent); ASSERT_SIMPLE(false);
return false; return false;
} }
@ -733,13 +732,14 @@ inline bool
file_append(FileHandle fp, const char* file) file_append(FileHandle fp, const char* file)
{ {
if (fp == INVALID_HANDLE_VALUE) { if (fp == INVALID_HANDLE_VALUE) {
ASSERT_SIMPLE(false);
return false; return false;
} }
DWORD written; DWORD written;
DWORD length = (DWORD) strlen(file); DWORD length = (DWORD) strlen(file);
if (!WriteFile(fp, file, length, &written, NULL)) { if (!WriteFile(fp, file, length, &written, NULL)) {
CloseHandle(fp); ASSERT_SIMPLE(false);
return false; return false;
} }
@ -752,12 +752,13 @@ inline bool
file_append(FileHandle fp, const char* file, size_t length) file_append(FileHandle fp, const char* file, size_t length)
{ {
if (fp == INVALID_HANDLE_VALUE) { if (fp == INVALID_HANDLE_VALUE) {
ASSERT_SIMPLE(false);
return false; return false;
} }
DWORD written; DWORD written;
if (!WriteFile(fp, file, (uint32) length, &written, NULL)) { if (!WriteFile(fp, file, (uint32) length, &written, NULL)) {
CloseHandle(fp); ASSERT_SIMPLE(false);
return false; return false;
} }

View File

@ -20,14 +20,6 @@
#include "../../../memory/RingMemory.h" #include "../../../memory/RingMemory.h"
#include <winDNS.h> #include <winDNS.h>
#define INPUT_MOUSE_BUTTON_1 1
#define INPUT_MOUSE_BUTTON_2 2
#define INPUT_MOUSE_BUTTON_3 3
#define INPUT_MOUSE_BUTTON_4 4
#define INPUT_MOUSE_BUTTON_5 5
#define INPUT_MOUSE_BUTTON_WHEEL 6
#define INPUT_MOUSE_BUTTON_HWHEEL 7
// IMPORTANT: // IMPORTANT:
// Even if it is nowhere documented (at least not to our knowledge) the GetRawInputDeviceInfoA, GetRawInputBuffer functions required // Even if it is nowhere documented (at least not to our knowledge) the GetRawInputDeviceInfoA, GetRawInputBuffer functions required
// aligned memory. So far we only figured out that 4 bytes works, maybe this needs to be 8 in the future?! // aligned memory. So far we only figured out that 4 bytes works, maybe this needs to be 8 in the future?!

View File

@ -26,6 +26,12 @@
#define UNREACHABLE() __builtin_unreachable() #define UNREACHABLE() __builtin_unreachable()
#endif #endif
#if _WIN32
#define EXPORT_LIB extern "C" __declspec(dllexport)
#elif __linux__
#define EXPORT_LIB extern "C" __attribute__((visibility("default")))
#endif
#define ARRAY_COUNT(a) (sizeof(a) / sizeof((a)[0])) #define ARRAY_COUNT(a) (sizeof(a) / sizeof((a)[0]))
typedef int8_t int8; typedef int8_t int8;