mirror of
https://github.com/Karaka-Management/cOMS.git
synced 2026-01-10 19:08:39 +00:00
Getting ready to modify AMS and ECS
This commit is contained in:
parent
73dfa96c6a
commit
2521f5f2e4
|
|
@ -10,6 +10,7 @@
|
|||
#ifndef TOS_ANIMATION_H
|
||||
#define TOS_ANIMATION_H
|
||||
|
||||
#include "../stdlib/Types.h"
|
||||
#include "../utils/MathUtils.h"
|
||||
|
||||
#include "AnimationEaseType.h"
|
||||
|
|
@ -26,6 +27,9 @@ f32 smoothstep(f32 t) {
|
|||
|
||||
f32 anim_ease(f32 t, AnimationEaseType type) {
|
||||
switch(type) {
|
||||
case ANIMATION_EASE_DISCRETE: {
|
||||
return anim_discrete(t);
|
||||
};
|
||||
case ANIMATION_EASE_IN_SINE: {
|
||||
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
|
||||
f32 anim_ease_linear(f32 t) {
|
||||
return t;
|
||||
|
|
@ -217,7 +226,8 @@ f32 anim_ease_in_out_quint(f32 t) {
|
|||
inline
|
||||
f32 anim_ease_in_expo(f32 t) {
|
||||
return t == 0
|
||||
? 0 : pow(2, 10 * t - 10);
|
||||
? 0
|
||||
: pow(2, 10 * t - 10);
|
||||
}
|
||||
|
||||
inline
|
||||
|
|
@ -240,19 +250,19 @@ f32 anim_ease_in_out_expo(f32 t) {
|
|||
|
||||
inline
|
||||
f32 anim_ease_in_circ(f32 t) {
|
||||
return 1 - sqrt(1 - pow(t, 2));
|
||||
return 1 - sqrtf(1 - pow(t, 2));
|
||||
}
|
||||
|
||||
inline
|
||||
f32 anim_ease_out_circ(f32 t) {
|
||||
return sqrt(1 - pow(t - 1, 2));
|
||||
return sqrtf(1 - pow(t - 1, 2));
|
||||
}
|
||||
|
||||
inline
|
||||
f32 anim_ease_in_out_circ(f32 t) {
|
||||
return t < 0.5
|
||||
? (1 - sqrt(1 - pow(2 * t, 2))) / 2
|
||||
: (sqrt(1 - pow(-2 * t + 2, 2)) + 1) / 2;
|
||||
? (1 - sqrtf(1 - pow(2 * t, 2))) / 2
|
||||
: (sqrtf(1 - pow(-2 * t + 2, 2)) + 1) / 2;
|
||||
}
|
||||
|
||||
inline
|
||||
|
|
|
|||
|
|
@ -10,8 +10,11 @@
|
|||
#ifndef TOS_ANIMATION_EASE_TYPE_H
|
||||
#define TOS_ANIMATION_EASE_TYPE_H
|
||||
|
||||
enum AnimationEaseType {
|
||||
#include "../stdlib/Types.h"
|
||||
|
||||
enum AnimationEaseType : byte {
|
||||
ANIMATION_LINEAR,
|
||||
ANIMATION_EASE_DISCRETE,
|
||||
ANIMATION_EASE_IN_SINE,
|
||||
ANIMATION_EASE_OUT_SINE,
|
||||
ANIMATION_EASE_IN_OUT_SINE,
|
||||
|
|
|
|||
|
|
@ -35,6 +35,14 @@ struct AssetManagementSystem {
|
|||
|
||||
// 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
|
||||
// Fixed chunk size of sizeof(Asset)
|
||||
ChunkMemory asset_memory;
|
||||
|
|
|
|||
78
entity/AnimationEntity.h
Normal file
78
entity/AnimationEntity.h
Normal 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
|
||||
|
|
@ -22,20 +22,29 @@ struct Entity {
|
|||
|
||||
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
|
||||
// e.g. textures
|
||||
int reference_count;
|
||||
|
||||
Entity* next;
|
||||
Entity* prev;
|
||||
int16 reference_count;
|
||||
|
||||
// A entity can reference up to N other entities
|
||||
// This allows us to quickly update the other entities
|
||||
// Example: A player pulls N mobs
|
||||
// @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];
|
||||
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)
|
||||
|
||||
// Actual memory address and specific entity data
|
||||
|
|
@ -50,28 +59,35 @@ struct EntitySchema {
|
|||
// Could be 0 if there is no official id
|
||||
uint64 official_id;
|
||||
|
||||
char name[MAX_ENTITY_NAME_LENGTH];
|
||||
|
||||
EntityType type;
|
||||
|
||||
// Counts the references to this entity
|
||||
// e.g. textures
|
||||
int reference_count;
|
||||
int16 reference_count;
|
||||
|
||||
// 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
|
||||
uint64 ram_size;
|
||||
uint64 vram_size;
|
||||
uint64 last_access;
|
||||
|
||||
// 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
|
||||
uint32 size;
|
||||
|
||||
// Variable used for thread safety
|
||||
bool is_loaded;
|
||||
|
||||
// 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)
|
||||
bool is_ram;
|
||||
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* prev;
|
||||
|
||||
|
|
@ -79,7 +95,8 @@ struct EntitySchema {
|
|||
// This allows us to quickly update the other entities
|
||||
// Example: A player pulls N mobs
|
||||
// @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
|
||||
|
||||
// Actual memory address and specific schema data
|
||||
|
|
|
|||
|
|
@ -21,22 +21,37 @@ struct EntityComponentSystem {
|
|||
// @question is this even necessary or could we integrate this directly into the system here?
|
||||
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
|
||||
|
||||
// @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
|
||||
ChunkMemory entity_memory;
|
||||
|
||||
// Actual entity data
|
||||
ChunkMemory entity_data_memory;
|
||||
|
||||
Entity* first;
|
||||
Entity* last;
|
||||
};
|
||||
|
||||
struct EntitySchemaSystem {
|
||||
// @question is this even necessary or could we integrate this directly into the system here?
|
||||
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
|
||||
|
||||
// General entity memory
|
||||
|
|
|
|||
|
|
@ -118,6 +118,8 @@ void vertex_rect_create(
|
|||
*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
|
||||
void vertex_rect_border_create(
|
||||
Vertex3DTextureColorIndex* __restrict vertices, uint32* __restrict index, f32 zindex,
|
||||
|
|
|
|||
|
|
@ -15,6 +15,14 @@
|
|||
#include "ControllerInput.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
|
||||
#define MAX_MOUSE_PRESSES 3
|
||||
|
||||
|
|
@ -28,7 +36,7 @@
|
|||
|
||||
#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 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
|
||||
// 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_KEYBOARD_PREFIX 8192
|
||||
#define INPUT_CONTROLLER_PREFIX 16384
|
||||
#define INPUT_KEYBOARD_PREFIX 1 << 13
|
||||
#define INPUT_CONTROLLER_PREFIX 1 << 14
|
||||
|
||||
#define INPUT_TYPE_MOUSE_KEYBOARD 0x01
|
||||
#define INPUT_TYPE_CONTROLLER 0x02
|
||||
#define INPUT_TYPE_OTHER 0x03
|
||||
enum InputType {
|
||||
INPUT_TYPE_NONE = 0,
|
||||
INPUT_TYPE_MOUSE_KEYBOARD = 1 << 0,
|
||||
INPUT_TYPE_CONTROLLER = 1 << 2,
|
||||
INPUT_TYPE_OTHER = 1 << 3,
|
||||
};
|
||||
|
||||
#define MIN_CONTROLLER_DEVICES 4
|
||||
|
||||
|
|
|
|||
|
|
@ -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 free_index = (buf->last_pos + 1) / 64;
|
||||
int32 bit_index;
|
||||
|
||||
int32 bit_index = buf->last_pos - free_index * 64;
|
||||
int64 free_element = -1;
|
||||
int64 mask;
|
||||
|
||||
int32 i = 0;
|
||||
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?
|
||||
for (bit_index = 0; bit_index < 64; ++bit_index) {
|
||||
for (; bit_index < 64; ++bit_index) {
|
||||
int32 consecutive_free_bits = 0;
|
||||
|
||||
// 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;
|
||||
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) {
|
||||
++consecutive_free_bits;
|
||||
} else {
|
||||
|
|
@ -231,6 +229,8 @@ int64 chunk_reserve(ChunkMemory* buf, uint64 elements = 1, bool zeroed = false)
|
|||
}
|
||||
}
|
||||
|
||||
bit_index = 0;
|
||||
|
||||
++i;
|
||||
++free_index;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,104 +1,128 @@
|
|||
#ifndef TOS_MODELS_SETTING_TYPES_H
|
||||
#define TOS_MODELS_SETTING_TYPES_H
|
||||
|
||||
#define SETTING_TYPE_GPU_CUSTOM 0x0
|
||||
#define SETTING_TYPE_GPU_VLOW 0x1
|
||||
#define SETTING_TYPE_GPU_LOW 0x2
|
||||
#define SETTING_TYPE_GPU_MEDIUM 0x3
|
||||
#define SETTING_TYPE_GPU_HIGH 0x4
|
||||
#define SETTING_TYPE_GPU_VHIGH 0x5
|
||||
#define SETTING_TYPE_GPU_ULTRA 0x6
|
||||
#define SETTING_TYPE_GPU_NEXTGEN 0x7
|
||||
enum SettingGpuDetail {
|
||||
SETTING_TYPE_GPU_CUSTOM,
|
||||
SETTING_TYPE_GPU_VLOW,
|
||||
SETTING_TYPE_GPU_LOW,
|
||||
SETTING_TYPE_GPU_MEDIUM,
|
||||
SETTING_TYPE_GPU_HIGH,
|
||||
SETTING_TYPE_GPU_VHIGH,
|
||||
SETTING_TYPE_GPU_ULTRA,
|
||||
SETTING_TYPE_GPU_NEXTGEN
|
||||
};
|
||||
|
||||
#define SETTING_TYPE_PERSPECTIVE_FIRST 0x00
|
||||
#define SETTING_TYPE_PERSPECTIVE_THIRD 0x01
|
||||
#define SETTING_TYPE_PERSPECTIVE_ISOMETRIC 0x02
|
||||
enum SettingPlayerPerspective {
|
||||
SETTING_TYPE_PERSPECTIVE_FIRST,
|
||||
SETTING_TYPE_PERSPECTIVE_THIRD,
|
||||
SETTING_TYPE_PERSPECTIVE_ISOMETRIC
|
||||
};
|
||||
|
||||
#define SETTING_TYPE_SYNC_V 0x1
|
||||
#define SETTING_TYPE_SYNC_ADAPTIVE 0x2
|
||||
#define SETTING_TYPE_SYNC_FAST 0x3
|
||||
enum SettingVSync {
|
||||
SETTING_TYPE_SYNC_NONE,
|
||||
SETTING_TYPE_SYNC_V,
|
||||
SETTING_TYPE_SYNC_ADAPTIVE,
|
||||
SETTING_TYPE_SYNC_FAST
|
||||
};
|
||||
|
||||
#define SETTING_TYPE_ASPEC_RATIO_4x3 0x00
|
||||
#define SETTING_TYPE_ASPEC_RATIO_16x9 0x01
|
||||
#define SETTING_TYPE_ASPEC_RATIO_16x10 0x02
|
||||
#define SETTING_TYPE_ASPEC_RATIO_21x9 0x03
|
||||
enum SettingAspectRatio {
|
||||
SETTING_TYPE_ASPEC_RATIO_4x3,
|
||||
SETTING_TYPE_ASPEC_RATIO_16x9,
|
||||
SETTING_TYPE_ASPEC_RATIO_16x10,
|
||||
SETTING_TYPE_ASPEC_RATIO_21x9
|
||||
};
|
||||
|
||||
#define SETTING_TYPE_SCREEN_RESOLUTION_800x600 0x00
|
||||
#define SETTING_TYPE_SCREEN_RESOLUTION_1024x768 0x01
|
||||
#define SETTING_TYPE_SCREEN_RESOLUTION_1280x720 0x02
|
||||
#define SETTING_TYPE_SCREEN_RESOLUTION_1280x800 0x03
|
||||
#define SETTING_TYPE_SCREEN_RESOLUTION_1280x1024 0x04
|
||||
#define SETTING_TYPE_SCREEN_RESOLUTION_1360x768 0x05
|
||||
#define SETTING_TYPE_SCREEN_RESOLUTION_1366x768 0x06
|
||||
#define SETTING_TYPE_SCREEN_RESOLUTION_1440x900 0x07
|
||||
#define SETTING_TYPE_SCREEN_RESOLUTION_1536x864 0x08
|
||||
#define SETTING_TYPE_SCREEN_RESOLUTION_1600x900 0x09
|
||||
#define SETTING_TYPE_SCREEN_RESOLUTION_1600x1200 0x0A
|
||||
#define SETTING_TYPE_SCREEN_RESOLUTION_1680x1050 0x0B
|
||||
#define SETTING_TYPE_SCREEN_RESOLUTION_1920x1080 0x0C
|
||||
#define SETTING_TYPE_SCREEN_RESOLUTION_1920x1200 0x0D
|
||||
#define SETTING_TYPE_SCREEN_RESOLUTION_2048x1152 0x0E
|
||||
#define SETTING_TYPE_SCREEN_RESOLUTION_2048x1536 0x0F
|
||||
#define SETTING_TYPE_SCREEN_RESOLUTION_2560x1080 0x10
|
||||
#define SETTING_TYPE_SCREEN_RESOLUTION_2560x1440 0x11
|
||||
#define SETTING_TYPE_SCREEN_RESOLUTION_2560x1600 0x12
|
||||
#define SETTING_TYPE_SCREEN_RESOLUTION_3440x1440 0x13
|
||||
#define SETTING_TYPE_SCREEN_RESOLUTION_3840x2160 0x14
|
||||
enum SettingScreenResolution {
|
||||
SETTING_TYPE_SCREEN_RESOLUTION_800x600,
|
||||
SETTING_TYPE_SCREEN_RESOLUTION_1024x768,
|
||||
SETTING_TYPE_SCREEN_RESOLUTION_1280x720,
|
||||
SETTING_TYPE_SCREEN_RESOLUTION_1280x800,
|
||||
SETTING_TYPE_SCREEN_RESOLUTION_1280x1024,
|
||||
SETTING_TYPE_SCREEN_RESOLUTION_1360x768,
|
||||
SETTING_TYPE_SCREEN_RESOLUTION_1366x768,
|
||||
SETTING_TYPE_SCREEN_RESOLUTION_1440x900,
|
||||
SETTING_TYPE_SCREEN_RESOLUTION_1536x864,
|
||||
SETTING_TYPE_SCREEN_RESOLUTION_1600x900,
|
||||
SETTING_TYPE_SCREEN_RESOLUTION_1600x1200,
|
||||
SETTING_TYPE_SCREEN_RESOLUTION_1680x1050,
|
||||
SETTING_TYPE_SCREEN_RESOLUTION_1920x1080,
|
||||
SETTING_TYPE_SCREEN_RESOLUTION_1920x1200,
|
||||
SETTING_TYPE_SCREEN_RESOLUTION_2048x1152,
|
||||
SETTING_TYPE_SCREEN_RESOLUTION_2048x1536,
|
||||
SETTING_TYPE_SCREEN_RESOLUTION_2560x1080,
|
||||
SETTING_TYPE_SCREEN_RESOLUTION_2560x1440,
|
||||
SETTING_TYPE_SCREEN_RESOLUTION_2560x1600,
|
||||
SETTING_TYPE_SCREEN_RESOLUTION_3440x1440,
|
||||
SETTING_TYPE_SCREEN_RESOLUTION_3840x2160
|
||||
};
|
||||
|
||||
#define SETTING_TYPE_WINDOW_CHAT 0x01
|
||||
#define SETTING_TYPE_WINDOW_MAP 0x02
|
||||
#define SETTING_TYPE_WINDOW_RANKING 0x03
|
||||
#define SETTING_TYPE_WINDOW_SHOP 0x04
|
||||
#define SETTING_TYPE_WINDOW_STATS 0x05
|
||||
#define SETTING_TYPE_WINDOW_GROUPS 0x06
|
||||
#define SETTING_TYPE_WINDOW_PET 0x07 // Pet "tamagochi" window
|
||||
enum SettingWindows {
|
||||
SETTING_TYPE_WINDOW_NONE,
|
||||
SETTING_TYPE_WINDOW_CHAT,
|
||||
SETTING_TYPE_WINDOW_MAP,
|
||||
SETTING_TYPE_WINDOW_RANKING,
|
||||
SETTING_TYPE_WINDOW_SHOP,
|
||||
SETTING_TYPE_WINDOW_STATS,
|
||||
SETTING_TYPE_WINDOW_GROUPS,
|
||||
SETTING_TYPE_WINDOW_PET // Pet "tamagochi" window
|
||||
};
|
||||
|
||||
#define SETTING_TYPE_WINDOW_MODE_FULLSCREEN 0x00
|
||||
#define SETTING_TYPE_WINDOW_MODE_WINDOWED_FULLSCREEN 0x01
|
||||
#define SETTING_TYPE_WINDOW_MODE_WINDOWED 0x02
|
||||
enum SettingWindowMode {
|
||||
SETTING_TYPE_WINDOW_MODE_FULLSCREEN,
|
||||
SETTING_TYPE_WINDOW_MODE_WINDOWED_FULLSCREEN,
|
||||
SETTING_TYPE_WINDOW_MODE_WINDOWED
|
||||
};
|
||||
|
||||
#define SETTING_TYPE_DISABLED 0x00
|
||||
#define SETTING_TYPE_UNLIMITED 0x00
|
||||
|
||||
#define SETTING_DEBUG_VISIBILITY_WIREFRAME 1
|
||||
#define SETTING_DEBUG_VISIBILITY_DEBUG 2
|
||||
#define SETTING_DEBUG_VISIBILITY_3D 2048
|
||||
#define SETTING_DEBUG_VISIBILITY_NORMALS 4096
|
||||
enum SettingDebugVisibility {
|
||||
SETTING_DEBUG_VISIBILITY_WIREFRAME = 1 << 0,
|
||||
SETTING_DEBUG_VISIBILITY_DEBUG = 1 << 1,
|
||||
SETTING_DEBUG_VISIBILITY_3D = 1 << 2,
|
||||
SETTING_DEBUG_VISIBILITY_NORMALS = 1 << 3
|
||||
};
|
||||
|
||||
#define SETTING_UI_VISIBILITY_FPS 1
|
||||
#define SETTING_UI_VISIBILITY_APM 2
|
||||
#define SETTING_UI_VISIBILITY_NET_GRAPH 4
|
||||
#define SETTING_UI_VISIBILITY___ 8
|
||||
#define SETTING_UI_VISIBILITY_HOTKEYS 16
|
||||
#define SETTING_UI_VISIBILITY_XP_BAR 32
|
||||
#define SETTING_UI_VISIBILITY_COOLDOWN_TIMER 64
|
||||
#define SETTING_UI_VISIBILITY_MINIMAP 128
|
||||
#define SETTING_UI_VISIBILITY_CHAT 256
|
||||
#define SETTING_UI_VISIBILITY_CLOCK 512
|
||||
#define SETTING_UI_VISIBILITY_SUBTITLES 1024
|
||||
#define SETTING_UI_VISIBILITY_BAR 2048
|
||||
#define SETTING_UI_VISIBILITY_HEALTH 4096
|
||||
#define SETTING_UI_VISIBILITY_RESOURCE 8192
|
||||
#define SETTING_UI_VISIBILITY_INFO 8192 // = e.g. quest info
|
||||
enum SettingUiVisibility {
|
||||
SETTING_UI_VISIBILITY_FPS = 1 << 0,
|
||||
SETTING_UI_VISIBILITY_APM = 1 << 1,
|
||||
SETTING_UI_VISIBILITY_NET_GRAPH = 1 << 2,
|
||||
SETTING_UI_VISIBILITY_CONSOLE = 1 << 3,
|
||||
SETTING_UI_VISIBILITY_HOTKEYS = 1 << 4,
|
||||
SETTING_UI_VISIBILITY_XP_BAR = 1 << 5,
|
||||
SETTING_UI_VISIBILITY_COOLDOWN_TIMER = 1 << 6,
|
||||
SETTING_UI_VISIBILITY_MINIMAP = 1 << 7,
|
||||
SETTING_UI_VISIBILITY_CHAT = 1 << 8,
|
||||
SETTING_UI_VISIBILITY_CLOCK = 1 << 9,
|
||||
SETTING_UI_VISIBILITY_SUBTITLES = 1 << 10,
|
||||
SETTING_UI_VISIBILITY_BAR = 1 << 11,
|
||||
SETTING_UI_VISIBILITY_HEALTH = 1 << 12,
|
||||
SETTING_UI_VISIBILITY_RESOURCE = 1 << 13,
|
||||
SETTING_UI_VISIBILITY_INFO = 1 << 14 // = e.g. quest info
|
||||
};
|
||||
|
||||
#define SETTING_GAME_VISIBILITY_BAR_SELF 1
|
||||
#define SETTING_GAME_VISIBILITY_BAR_PLAYER 2
|
||||
#define SETTING_GAME_VISIBILITY_BAR_OTHER 4
|
||||
#define SETTING_GAME_VISIBILITY_BAR_NUMBERS 8
|
||||
#define SETTING_GAME_VISIBILITY_BUFFS_SELF 16
|
||||
#define SETTING_GAME_VISIBILITY_BUFFS_PLAYER 32
|
||||
#define SETTING_GAME_VISIBILITY_BUFFS_OTHER 64
|
||||
#define SETTING_GAME_VISIBILITY_NAME_SELF 128
|
||||
#define SETTING_GAME_VISIBILITY_NAME_PLAYER 256
|
||||
#define SETTING_GAME_VISIBILITY_NAME_OTHER 512
|
||||
#define SETTING_GAME_VISIBILITY_TITLE_SELF 1024
|
||||
#define SETTING_GAME_VISIBILITY_TITLE_PLAYER 2048
|
||||
#define SETTING_GAME_VISIBILITY_TITLE_OTHER 4096
|
||||
#define SETTING_GAME_VISIBILITY_DMG_NUMBERS 8192
|
||||
#define SETTING_GAME_VISIBILITY_XP_NUMBERS 16384
|
||||
#define SETTING_GAME_VISIBILITY_EFFECTS 32768
|
||||
enum SettingGameVisibility {
|
||||
SETTING_GAME_VISIBILITY_BAR_SELF = 1 << 0,
|
||||
SETTING_GAME_VISIBILITY_BAR_PLAYER = 1 << 1,
|
||||
SETTING_GAME_VISIBILITY_BAR_OTHER = 1 << 2,
|
||||
SETTING_GAME_VISIBILITY_BAR_NUMBERS = 1 << 3,
|
||||
SETTING_GAME_VISIBILITY_BUFFS_SELF = 1 << 4,
|
||||
SETTING_GAME_VISIBILITY_BUFFS_PLAYER = 1 << 5,
|
||||
SETTING_GAME_VISIBILITY_BUFFS_OTHER = 1 << 6,
|
||||
SETTING_GAME_VISIBILITY_NAME_SELF = 1 << 7,
|
||||
SETTING_GAME_VISIBILITY_NAME_PLAYER = 1 << 8,
|
||||
SETTING_GAME_VISIBILITY_NAME_OTHER = 1 << 9,
|
||||
SETTING_GAME_VISIBILITY_TITLE_SELF = 1 << 10,
|
||||
SETTING_GAME_VISIBILITY_TITLE_PLAYER = 1 << 11,
|
||||
SETTING_GAME_VISIBILITY_TITLE_OTHER = 1 << 12,
|
||||
SETTING_GAME_VISIBILITY_DMG_NUMBERS = 1 << 13,
|
||||
SETTING_GAME_VISIBILITY_XP_NUMBERS = 1 << 14,
|
||||
SETTING_GAME_VISIBILITY_EFFECTS = 1 << 15
|
||||
};
|
||||
|
||||
#define SETTING_INPUT_DEVICE_TYPE_MOUSE_KEYBOARD 1
|
||||
#define SETTING_INPUT_DEVICE_TYPE_CONTROLLER 2
|
||||
enum InputDeviceType {
|
||||
SETTING_INPUT_DEVICE_TYPE_MOUSE_KEYBOARD,
|
||||
SETTING_INPUT_DEVICE_TYPE_CONTROLLER,
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
@ -293,8 +293,8 @@ void file_read(FileHandle fp, FileBody* file, uint64 offset = 0, uint64 length =
|
|||
{
|
||||
LARGE_INTEGER size;
|
||||
if (!GetFileSizeEx(fp, &size)) {
|
||||
CloseHandle(fp);
|
||||
file->content = NULL;
|
||||
ASSERT_SIMPLE(false);
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
@ -304,7 +304,7 @@ void file_read(FileHandle fp, FileBody* file, uint64 offset = 0, uint64 length =
|
|||
if (offset >= file_size) {
|
||||
file->size = 0;
|
||||
file->content = NULL;
|
||||
CloseHandle(fp);
|
||||
ASSERT_SIMPLE(false);
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
@ -320,16 +320,16 @@ void file_read(FileHandle fp, FileBody* file, uint64 offset = 0, uint64 length =
|
|||
LARGE_INTEGER li;
|
||||
li.QuadPart = offset;
|
||||
if (SetFilePointerEx(fp, li, NULL, FILE_BEGIN) == 0) {
|
||||
CloseHandle(fp);
|
||||
file->content = NULL;
|
||||
ASSERT_SIMPLE(false);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
DWORD bytes;
|
||||
if (!ReadFile(fp, file->content, (uint32) read_length, &bytes, NULL)) {
|
||||
CloseHandle(fp);
|
||||
file->content = NULL;
|
||||
ASSERT_SIMPLE(false);
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
@ -554,8 +554,8 @@ bool file_read_async(
|
|||
) {
|
||||
LARGE_INTEGER size;
|
||||
if (!GetFileSizeEx(fp, &size)) {
|
||||
CloseHandle(fp);
|
||||
file->content = NULL;
|
||||
ASSERT_SIMPLE(false);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
@ -565,7 +565,7 @@ bool file_read_async(
|
|||
if (offset >= file_size) {
|
||||
file->size = 0;
|
||||
file->content = NULL;
|
||||
CloseHandle(fp);
|
||||
ASSERT_SIMPLE(false);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
@ -579,7 +579,7 @@ bool file_read_async(
|
|||
}
|
||||
|
||||
if (!file->content) {
|
||||
CloseHandle(fp);
|
||||
ASSERT_SIMPLE(false);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
@ -594,10 +594,9 @@ bool file_read_async(
|
|||
if (!ReadFile(fp, file->content, (DWORD) read_length, &bytes_read, &file->ov)) {
|
||||
DWORD error = GetLastError();
|
||||
if (error != ERROR_IO_PENDING) {
|
||||
CloseHandle(fp);
|
||||
free(file->content);
|
||||
file->content = NULL;
|
||||
CloseHandle(&file->ov.hEvent);
|
||||
ASSERT_SIMPLE(false);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
@ -733,13 +732,14 @@ inline bool
|
|||
file_append(FileHandle fp, const char* file)
|
||||
{
|
||||
if (fp == INVALID_HANDLE_VALUE) {
|
||||
ASSERT_SIMPLE(false);
|
||||
return false;
|
||||
}
|
||||
|
||||
DWORD written;
|
||||
DWORD length = (DWORD) strlen(file);
|
||||
if (!WriteFile(fp, file, length, &written, NULL)) {
|
||||
CloseHandle(fp);
|
||||
ASSERT_SIMPLE(false);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -752,12 +752,13 @@ inline bool
|
|||
file_append(FileHandle fp, const char* file, size_t length)
|
||||
{
|
||||
if (fp == INVALID_HANDLE_VALUE) {
|
||||
ASSERT_SIMPLE(false);
|
||||
return false;
|
||||
}
|
||||
|
||||
DWORD written;
|
||||
if (!WriteFile(fp, file, (uint32) length, &written, NULL)) {
|
||||
CloseHandle(fp);
|
||||
ASSERT_SIMPLE(false);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -20,14 +20,6 @@
|
|||
#include "../../../memory/RingMemory.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:
|
||||
// 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?!
|
||||
|
|
|
|||
|
|
@ -26,6 +26,12 @@
|
|||
#define UNREACHABLE() __builtin_unreachable()
|
||||
#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]))
|
||||
|
||||
typedef int8_t int8;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user