diff --git a/assets/ui/test.js b/assets/ui/test.js index 4499a130..e202801c 100644 --- a/assets/ui/test.js +++ b/assets/ui/test.js @@ -1,6 +1,6 @@ module = { render() { - Text.draw(10, 10, "Hello World"); + Text.draw(0, 0, "Hello World"); SpriteBatch.flush(); } }; diff --git a/src/dusk/asset/assetfile.c b/src/dusk/asset/assetfile.c index 8ae31c5e..8617ddbc 100644 --- a/src/dusk/asset/assetfile.c +++ b/src/dusk/asset/assetfile.c @@ -146,7 +146,9 @@ size_t assetFileLineReaderUnreadBytes(const assetfilelinereader_t *reader) { return reader->bufferEnd - reader->bufferStart; } -const uint8_t *assetFileLineReaderUnreadPtr(const assetfilelinereader_t *reader) { +const uint8_t *assetFileLineReaderUnreadPtr( + const assetfilelinereader_t *reader +) { assertNotNull(reader, "Reader cannot be NULL."); assertNotNull(reader->readBuffer, "Read buffer cannot be NULL."); return reader->readBuffer + reader->bufferStart; @@ -177,11 +179,16 @@ static errorret_t assetFileLineReaderAppend( static void assetFileLineReaderTerminate(assetfilelinereader_t *reader) { assertNotNull(reader, "Reader cannot be NULL."); assertNotNull(reader->outBuffer, "Out buffer cannot be NULL."); - assertTrue(reader->lineLength < reader->outBufferSize, "Line length exceeds out buffer."); + assertTrue( + reader->lineLength < reader->outBufferSize, + "Line length exceeds out buffer." + ); reader->outBuffer[reader->lineLength] = '\0'; } -static ssize_t assetFileLineReaderFindNewline(const assetfilelinereader_t *reader) { +static ssize_t assetFileLineReaderFindNewline( + const assetfilelinereader_t *reader +) { size_t i; assertNotNull(reader, "Reader cannot be NULL."); @@ -276,7 +283,7 @@ errorret_t assetFileLineReaderNext(assetfilelinereader_t *reader) { reader->lineLength = 0; - for(;;) { + for(;) { ssize_t newlineIndex = assetFileLineReaderFindNewline(reader); if(newlineIndex >= 0) { @@ -284,7 +291,10 @@ errorret_t assetFileLineReaderNext(assetfilelinereader_t *reader) { errorret_t ret; /* strip CR in CRLF */ - if(chunkLength > 0 && reader->readBuffer[(size_t)newlineIndex - 1] == '\r') { + if( + chunkLength > 0 && + reader->readBuffer[(size_t)newlineIndex - 1] == '\r' + ) { chunkLength--; } diff --git a/src/dusk/asset/loader/locale/assetlocaleloader.c b/src/dusk/asset/loader/locale/assetlocaleloader.c index eb0b6b1e..c3413404 100644 --- a/src/dusk/asset/loader/locale/assetlocaleloader.c +++ b/src/dusk/asset/loader/locale/assetlocaleloader.c @@ -152,7 +152,7 @@ errorret_t assetLocaleParseHeader( if(pluralIndex >= localeFile->pluralStateCount - 1) { errorThrow( - "Too many plural conditions. Expected %d conditional clauses for nplurals=%d.", + "Too many plural conditions. Expected %d clauses for nplurals=%d.", localeFile->pluralStateCount - 1, localeFile->pluralStateCount ); diff --git a/src/dusk/display/mesh/capsule.c b/src/dusk/display/mesh/capsule.c index f5952131..920cae33 100644 --- a/src/dusk/display/mesh/capsule.c +++ b/src/dusk/display/mesh/capsule.c @@ -119,8 +119,12 @@ void capsuleBuffer( { const float_t yTop = cy + halfHeight; const float_t yBot = cy - halfHeight; - const float_t vTop = 1.0f - (float_t)capRings / (float_t)(2 * capRings + 1); - const float_t vBot = 1.0f - (float_t)(capRings + 1) / (float_t)(2 * capRings + 1); + const float_t vTop = ( + 1.0f - (float_t)capRings / (float_t)(2 * capRings + 1) + ); + const float_t vBot = ( + 1.0f - (float_t)(capRings + 1) / (float_t)(2 * capRings + 1) + ); for(int32_t j = 0; j < sectors; j++) { const float_t t1 = (float_t)j * sectorStep; @@ -152,8 +156,12 @@ void capsuleBuffer( const float_t lxz1 = radius * cosf(phi1); const float_t lxz2 = radius * cosf(phi2); - const float_t v1 = 1.0f - (float_t)(capRings + 1 + i) / (float_t)(2 * capRings + 1); - const float_t v2 = 1.0f - (float_t)(capRings + 1 + i + 1) / (float_t)(2 * capRings + 1); + const float_t v1 = ( + 1.0f - (float_t)(capRings + 1 + i) / (float_t)(2 * capRings + 1) + ); + const float_t v2 = ( + 1.0f - (float_t)(capRings + 1 + i + 1) / (float_t)(2 * capRings + 1) + ); for(int32_t j = 0; j < sectors; j++) { const float_t t1 = (float_t)j * sectorStep; diff --git a/src/dusk/display/mesh/cube.h b/src/dusk/display/mesh/cube.h index 6aa4f015..2826f6f0 100644 --- a/src/dusk/display/mesh/cube.h +++ b/src/dusk/display/mesh/cube.h @@ -28,7 +28,7 @@ errorret_t cubeInit(); * Buffers a 3D axis-aligned cube into the provided vertex array. * Writes CUBE_VERTEX_COUNT vertices (6 faces x 6 vertices, CCW winding). * - * @param vertices The vertex array to buffer into (must hold CUBE_VERTEX_COUNT). + * @param vertices The vertex array to buffer into. * @param min The minimum XYZ corner of the cube. * @param max The maximum XYZ corner of the cube. * @param color The color applied to all vertices. diff --git a/src/dusk/display/mesh/mesh.c b/src/dusk/display/mesh/mesh.c index 5306aaa5..03d0f3c7 100644 --- a/src/dusk/display/mesh/mesh.c +++ b/src/dusk/display/mesh/mesh.c @@ -34,10 +34,14 @@ errorret_t meshFlush( #ifdef meshFlushPlatform assertNotNull(mesh, "Mesh cannot be NULL"); assertTrue(vertexOffset >= 0, "Vertex offset must be non-negative."); - assertTrue(vertexCount == -1 || vertexCount > 0, "Vertex count incorrect."); + assertTrue( + vertexCount == -1 || vertexCount > 0, "Vertex count incorrect." + ); int32_t vertCount = meshGetVertexCount(mesh); - assertTrue(vertexOffset < (vertCount - 1), "Need at least one vert to draw"); + assertTrue( + vertexOffset < (vertCount - 1), "Need at least one vert to draw" + ); int32_t drawCount = vertexCount; if(vertexCount == -1) { diff --git a/src/dusk/display/mesh/triprism.h b/src/dusk/display/mesh/triprism.h index 1230be32..d674199d 100644 --- a/src/dusk/display/mesh/triprism.h +++ b/src/dusk/display/mesh/triprism.h @@ -9,12 +9,6 @@ #include "display/mesh/mesh.h" #include "display/color.h" -/** - * Vertex layout: - * 2 triangular end-caps (3 verts each) = 6 - * 3 rectangular side faces (6 verts each) = 18 - * Total = 24 - */ #define TRIPRISM_VERTEX_COUNT 24 #define TRIPRISM_PRIMITIVE_TYPE MESH_PRIMITIVE_TYPE_TRIANGLES @@ -35,13 +29,13 @@ errorret_t triPrismInit(); * the prism is extruded along the Z axis between minZ and maxZ. * Writes TRIPRISM_VERTEX_COUNT (24) vertices (CCW winding). * - * @param vertices Vertex array to write into (must hold TRIPRISM_VERTEX_COUNT). - * @param x0,y0 First triangle vertex (XY). - * @param x1,y1 Second triangle vertex (XY). - * @param x2,y2 Third triangle vertex (XY). - * @param minZ Near Z extent of the prism. - * @param maxZ Far Z extent of the prism. - * @param color Color applied to all vertices. + * @param vertices Vertex array to write into. + * @param x0,y0 First triangle vertex (XY). + * @param x1,y1 Second triangle vertex (XY). + * @param x2,y2 Third triangle vertex (XY). + * @param minZ Near Z extent of the prism. + * @param maxZ Far Z extent of the prism. + * @param color Color applied to all vertices. */ void triPrismBuffer( meshvertex_t *vertices, diff --git a/src/dusk/entity/component.c b/src/dusk/entity/component.c index 1538c371..6eea637a 100644 --- a/src/dusk/entity/component.c +++ b/src/dusk/entity/component.c @@ -101,7 +101,7 @@ entityid_t componentGetEntitiesWithComponent( "Component ID OOB in entitiesWithComponent lookup" ); assertTrue( - componentGetIndex(i, used) < ENTITY_COUNT_MAX * ENTITY_COMPONENT_COUNT_MAX, + componentGetIndex(i,used) < ENTITY_COUNT_MAX*ENTITY_COMPONENT_COUNT_MAX, "Component index OOB in entitiesWithComponent lookup" ); assertTrue( diff --git a/src/dusk/entity/component/display/entitycamera.c b/src/dusk/entity/component/display/entitycamera.c index a58ac7aa..a21e5b48 100644 --- a/src/dusk/entity/component/display/entitycamera.c +++ b/src/dusk/entity/component/display/entitycamera.c @@ -73,7 +73,8 @@ entityid_t entityCameraGetCurrent(void) { void entityCameraGetForward(const entityid_t entityId, vec2 out) { componentid_t posComp = entityGetComponent(entityId, COMPONENT_TYPE_POSITION); entityposition_t *pos = entityPositionGet(entityId, posComp); - // View matrix column layout: M[col][row], forward = {-M[0][2], -M[1][2], -M[2][2]} + // View matrix column layout: M[col][row], + // forward = {-M[0][2], -M[1][2], -M[2][2]} float_t fx = -pos->transform[0][2]; float_t fz = -pos->transform[2][2]; float_t len = sqrtf(fx * fx + fz * fz); diff --git a/src/dusk/entity/component/display/entitycamera.h b/src/dusk/entity/component/display/entitycamera.h index 29726c00..be8c510d 100644 --- a/src/dusk/entity/component/display/entitycamera.h +++ b/src/dusk/entity/component/display/entitycamera.h @@ -55,7 +55,8 @@ void entityCameraGetProjection( ); /** - * Returns the entity ID of the first active camera, or ENTITY_COUNT_MAX if none. + * Returns the entity ID of the first active camera, or ENTITY_COUNT_MAX if + * none are active. */ entityid_t entityCameraGetCurrent(void); diff --git a/src/dusk/entity/component/display/entitymesh.c b/src/dusk/entity/component/display/entitymesh.c index fa5f2882..8f173735 100644 --- a/src/dusk/entity/component/display/entitymesh.c +++ b/src/dusk/entity/component/display/entitymesh.c @@ -72,7 +72,9 @@ errorret_t entityMeshGeneratePlane( ); entityMeshDispose(entityId, componentId); - comp->ownedVertices = memoryAllocate(PLANE_VERTEX_COUNT * sizeof(meshvertex_t)); + comp->ownedVertices = memoryAllocate( + PLANE_VERTEX_COUNT * sizeof(meshvertex_t) + ); assertNotNull(comp->ownedVertices, "Failed to allocate plane vertices"); vec3 min = { -width * 0.5f, 0.0f, -height * 0.5f }; @@ -114,7 +116,9 @@ errorret_t entityMeshGenerateCapsule( ); entityMeshDispose(entityId, componentId); - comp->ownedVertices = memoryAllocate(CAPSULE_VERTEX_COUNT * sizeof(meshvertex_t)); + comp->ownedVertices = memoryAllocate( + CAPSULE_VERTEX_COUNT * sizeof(meshvertex_t) + ); assertNotNull(comp->ownedVertices, "Failed to allocate capsule vertices"); vec3 center = { 0.0f, 0.0f, 0.0f }; diff --git a/src/dusk/entity/component/display/entitymesh.h b/src/dusk/entity/component/display/entitymesh.h index 10fb8b5f..1f058d04 100644 --- a/src/dusk/entity/component/display/entitymesh.h +++ b/src/dusk/entity/component/display/entitymesh.h @@ -44,7 +44,7 @@ mesh_t * entityMeshGetMesh( * * @param entityId The entity ID. * @param componentId The component ID. - * @param mesh A pointer to the mesh to associate with the entity mesh component. + * @param mesh A pointer to the mesh to associate. */ void entityMeshSetMesh( const entityid_t entityId, diff --git a/src/dusk/error/error.c b/src/dusk/error/error.c index f1c6c902..cde67a0f 100644 --- a/src/dusk/error/error.c +++ b/src/dusk/error/error.c @@ -83,7 +83,9 @@ errorret_t errorChainImpl( assertNotNull(retval.state->message, "Message cannot be NULL"); // Create a new line string. - int32_t newLineLen = snprintf(NULL, 0, ERROR_LINE_FORMAT, file, line, function); + int32_t newLineLen = snprintf( + NULL, 0, ERROR_LINE_FORMAT, file, line, function + ); assertTrue(newLineLen >= 0, "Line formatting failed"); char_t *newLine = (char_t *)memoryAllocate(newLineLen + 1); snprintf(newLine, newLineLen + 1, ERROR_LINE_FORMAT, file, line, function); diff --git a/src/dusk/item/CMakeLists.txt b/src/dusk/item/CMakeLists.txt deleted file mode 100644 index 025c5447..00000000 --- a/src/dusk/item/CMakeLists.txt +++ /dev/null @@ -1,10 +0,0 @@ -# Copyright (c) 2026 Dominic Masters -# -# This software is released under the MIT License. -# https://opensource.org/licenses/MIT - -# Sources -target_sources(${DUSK_LIBRARY_TARGET_NAME} - PUBLIC - inventory.c -) \ No newline at end of file diff --git a/src/dusk/item/inventory.c b/src/dusk/item/inventory.c deleted file mode 100644 index 41d6d3eb..00000000 --- a/src/dusk/item/inventory.c +++ /dev/null @@ -1,207 +0,0 @@ -/** - * Copyright (c) 2026 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#include "inventory.h" -#include "assert/assert.h" - -void inventoryInit( - inventory_t *inventory, - itemstack_t *inventoryItems, - const uint32_t inventorySize -) { - assertNotNull(inventory, "Inventory must not be null"); - assertNotNull(inventoryItems, "Inventory items must not be null"); - assertTrue(inventorySize > 0, "Inventory size must be greater than zero"); - - inventory->inventoryItems = inventoryItems; - inventory->inventorySize = inventorySize; - inventoryClear(inventory); -} - -uint8_t inventoryItemAdd( - inventory_t *inventory, - const itemtype_t type, - const uint8_t count -) { - assertNotNull(inventory, "Inventory must not be null"); - assertFalse(type == ITEM_TYPE_NULL, "Cannot add null item type"); - assertTrue(count > 0, "Count must be greater than zero"); - - uint8_t remaining = count; - - // Fill existing stacks of matching type first - for(uint32_t i = 0; i < inventory->inventorySize && remaining > 0; i++) { - itemstack_t *stack = &inventory->inventoryItems[i]; - if(stack->type != type) continue; - if(stack->count >= ITEM_STACK_COUNT_MAX) continue; - - uint8_t space = ITEM_STACK_COUNT_MAX - stack->count; - uint8_t toAdd = remaining < space ? remaining : space; - stack->count += toAdd; - remaining -= toAdd; - } - - // Fill empty slots with new stacks - for(uint32_t i = 0; i < inventory->inventorySize && remaining > 0; i++) { - itemstack_t *stack = &inventory->inventoryItems[i]; - if(stack->type != ITEM_TYPE_NULL) continue; - - uint8_t toAdd = remaining < ITEM_STACK_COUNT_MAX ? remaining : ITEM_STACK_COUNT_MAX; - stack->type = type; - stack->count = toAdd; - remaining -= toAdd; - } - - return count - remaining; -} - -uint8_t inventoryItemRemove( - inventory_t *inventory, - const itemtype_t type, - const uint8_t count -) { - assertNotNull(inventory, "Inventory must not be null"); - assertFalse(type == ITEM_TYPE_NULL, "Cannot remove null item type"); - assertTrue(count > 0, "Count must be greater than zero"); - - uint8_t remaining = count; - - for(uint32_t i = 0; i < inventory->inventorySize && remaining > 0; i++) { - itemstack_t *stack = &inventory->inventoryItems[i]; - if(stack->type != type) continue; - - uint8_t toRemove = remaining < stack->count ? remaining : stack->count; - stack->count -= toRemove; - remaining -= toRemove; - - if(stack->count == 0) stack->type = ITEM_TYPE_NULL; - } - - return count - remaining; -} - -uint8_t inventoryItemCount( - const inventory_t *inventory, - const itemtype_t type -) { - assertNotNull(inventory, "Inventory must not be null"); - - uint8_t total = 0; - for(uint32_t i = 0; i < inventory->inventorySize; i++) { - if(inventory->inventoryItems[i].type == type) { - total += inventory->inventoryItems[i].count; - } - } - return total; -} - -uint32_t inventoryStackCount(const inventory_t *inventory) { - assertNotNull(inventory, "Inventory must not be null"); - - uint32_t count = 0; - for(uint32_t i = 0; i < inventory->inventorySize; i++) { - if(inventory->inventoryItems[i].type != ITEM_TYPE_NULL) count++; - } - return count; -} - -size_t inventoryItemCountAll(const inventory_t *inventory) { - assertNotNull(inventory, "Inventory must not be null"); - - size_t total = 0; - for(uint32_t i = 0; i < inventory->inventorySize; i++) { - if(inventory->inventoryItems[i].type != ITEM_TYPE_NULL) { - total += inventory->inventoryItems[i].count; - } - } - return total; -} - -void inventoryItemSet( - inventory_t *inventory, - const itemtype_t type, - const uint8_t count -) { - assertNotNull(inventory, "Inventory must not be null"); - assertFalse(type == ITEM_TYPE_NULL, "Cannot set null item type"); - - // Find existing stack of this type - for(uint32_t i = 0; i < inventory->inventorySize; i++) { - if(inventory->inventoryItems[i].type != type) continue; - inventory->inventoryItems[i].count = count; - if(count == 0) inventory->inventoryItems[i].type = ITEM_TYPE_NULL; - return; - } - - // Find empty slot - for(uint32_t i = 0; i < inventory->inventorySize; i++) { - if(inventory->inventoryItems[i].type != ITEM_TYPE_NULL) continue; - inventory->inventoryItems[i].type = type; - inventory->inventoryItems[i].count = count; - return; - } - - assertUnreachable("Inventory is full, cannot set item"); -} - -void inventoryClear(inventory_t *inventory) { - assertNotNull(inventory, "Inventory must not be null"); - - for(uint32_t i = 0; i < inventory->inventorySize; i++) { - inventory->inventoryItems[i].type = ITEM_TYPE_NULL; - inventory->inventoryItems[i].count = 0; - } -} - -bool_t inventoryIsFull(const inventory_t *inventory) { - assertNotNull(inventory, "Inventory must not be null"); - - for(uint32_t i = 0; i < inventory->inventorySize; i++) { - itemstack_t *stack = &inventory->inventoryItems[i]; - if(stack->type == ITEM_TYPE_NULL) return false; - if(stack->count < ITEM_STACK_COUNT_MAX) return false; - } - return true; -} - -bool_t inventoryIsEmpty(const inventory_t *inventory) { - assertNotNull(inventory, "Inventory must not be null"); - - for(uint32_t i = 0; i < inventory->inventorySize; i++) { - if(inventory->inventoryItems[i].type != ITEM_TYPE_NULL) return false; - } - return true; -} - -bool_t inventoryItemHas( - const inventory_t *inventory, - const itemtype_t type, - const uint8_t count -) { - assertNotNull(inventory, "Inventory must not be null"); - return inventoryItemCount(inventory, type) >= count; -} - -bool_t inventoryItemCanAdd( - const inventory_t *inventory, - const itemtype_t type, - const uint8_t count -) { - assertNotNull(inventory, "Inventory must not be null"); - assertFalse(type == ITEM_TYPE_NULL, "Cannot check null item type"); - - uint32_t space = 0; - for(uint32_t i = 0; i < inventory->inventorySize; i++) { - itemstack_t *stack = &inventory->inventoryItems[i]; - if(stack->type == type) { - space += ITEM_STACK_COUNT_MAX - stack->count; - } else if(stack->type == ITEM_TYPE_NULL) { - space += ITEM_STACK_COUNT_MAX; - } - } - return space >= count; -} diff --git a/src/dusk/item/inventory.h b/src/dusk/item/inventory.h deleted file mode 100644 index a79ee9bc..00000000 --- a/src/dusk/item/inventory.h +++ /dev/null @@ -1,148 +0,0 @@ -/** - * Copyright (c) 2025 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#pragma once -#include "itemstack.h" - -typedef struct { - itemstack_t *inventoryItems; - uint32_t inventorySize; -} inventory_t; - -/** - * Initializes an inventory with the given item stack array and size. - * - * @param inventory The inventory to initialize. - * @param inventoryItems The array of item stacks to use for the inventory. - * @param inventorySize The size of the inventory (number of item stacks). - */ -void inventoryInit( - inventory_t *inventory, - itemstack_t *inventoryItems, - const uint32_t inventorySize -); - -/** - * Adds items to the inventory, stacking them if possible. - * - * @param inventory The inventory to add items to. - * @param type The type of item to add. - * @param count The number of items to add. - * @return The number of items that were successfully added to the inventory. - */ -uint8_t inventoryItemAdd( - inventory_t *inventory, - const itemtype_t type, - const uint8_t count -); - -/** - * Removes items from the inventory, unstacking them if necessary. - * - * @param inventory The inventory to remove items from. - * @param type The type of item to remove. - * @param count The number of items to remove. - * @return The number of items that were successfully removed from the inventory. - */ -uint8_t inventoryItemRemove( - inventory_t *inventory, - const itemtype_t type, - const uint8_t count -); - -/** - * Get count of items of a type in the inventory. - * - * @param inventory The inventory to count items in. - * @param type The type of item to count. - * @return The number of items of the given type in the inventory. - */ -uint8_t inventoryItemCount( - const inventory_t *inventory, - const itemtype_t type -); - -/** - * Get count of STACKS in the inventory. - * - * @param inventory The inventory to count stacks in. - * @return The number of stacks in the inventory. - */ -uint32_t inventoryStackCount(const inventory_t *inventory); - -/** - * Get count of ITEMS in the inventory. - * - * @param inventory The inventory to count items in. - * @return The number of items in the inventory. - */ -size_t inventoryItemCountAll(const inventory_t *inventory); - -/** - * Sets the item stack at the given index in the inventory. - * - * @param inventory The inventory to set the item stack in. - * @param index The index of the item stack to set. - * @param type The type of item to set in the stack. - * @param count The number of items to set in the stack. - */ -void inventoryItemSet( - inventory_t *inventory, - const itemtype_t type, - const uint8_t count -); - -/** - * Clears all item stacks in the inventory. - * - * @param inventory The inventory to clear. - */ -void inventoryClear(inventory_t *inventory); - -/** - * Checks if the inventory is full. - * - * @param inventory The inventory to check. - * @return true if the inventory is full, false otherwise. - */ -bool_t inventoryIsFull(const inventory_t *inventory); - -/** - * Checks if the inventory is empty. - * - * @param inventory The inventory to check. - * @return true if the inventory is empty, false otherwise. - */ -bool_t inventoryIsEmpty(const inventory_t *inventory); - -/** - * Checks if the inventory has at least a certain number of items of a type. - * - * @param inventory The inventory to check. - * @param type The type of item to check for. - * @param count Count of item to check for. - * @return True if contained, false otherwise. - */ -bool_t inventoryItemHas( - const inventory_t *inventory, - const itemtype_t type, - const uint8_t count -); - -/** - * Checks if the inventory can add a certain number of items of a given type. - * - * @param inventory The inventory to check. - * @param type The type of item to check for. - * @param count Count of item to check for. - * @return True if can add, false otherwise. - */ -bool_t inventoryItemCanAdd( - const inventory_t *inventory, - const itemtype_t type, - const uint8_t count -); \ No newline at end of file diff --git a/src/dusk/item/itemstack.h b/src/dusk/item/itemstack.h deleted file mode 100644 index e298b0bb..00000000 --- a/src/dusk/item/itemstack.h +++ /dev/null @@ -1,16 +0,0 @@ -/** - * Copyright (c) 2026 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#pragma once -#include "itemtype.h" - -#define ITEM_STACK_COUNT_MAX 99 - -typedef struct { - itemtype_t type; - uint8_t count; -} itemstack_t; \ No newline at end of file diff --git a/src/dusk/item/itemtype.h b/src/dusk/item/itemtype.h deleted file mode 100644 index 580b3ecc..00000000 --- a/src/dusk/item/itemtype.h +++ /dev/null @@ -1,17 +0,0 @@ -/** - * Copyright (c) 2026 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#pragma once -#include "dusk.h" - -typedef enum { - ITEM_TYPE_NULL = 0, - - ITEM_TYPE_POTION, - - ITEM_TYPE_COUNT -} itemtype_t; \ No newline at end of file diff --git a/src/dusk/network/networkinfo.h b/src/dusk/network/networkinfo.h index 06c33c9a..8558c234 100644 --- a/src/dusk/network/networkinfo.h +++ b/src/dusk/network/networkinfo.h @@ -25,17 +25,11 @@ typedef enum { typedef struct { uint8_t ip[NETWORK_INFO_IPV4_OCTET_COUNT]; - // uint8_t subnet[NETWORK_INFO_IPV4_OCTET_COUNT]; - // uint8_t gateway[NETWORK_INFO_IPV4_OCTET_COUNT]; - // uint8_t dns[NETWORK_INFO_IPV4_OCTET_COUNT][NETWORK_INFO_IPV4_DNS_COUNT_MAX]; } networkinfoipv4_t; #ifdef DUSK_NETWORK_IPV6 typedef struct { uint8_t ip[NETWORK_INFO_IPV6_OCTET_COUNT]; - // uint8_t subnet[NETWORK_INFO_IPV6_OCTET_COUNT]; - // uint8_t gateway[NETWORK_INFO_IPV6_OCTET_COUNT]; - // uint8_t dns[NETWORK_INFO_IPV6_OCTET_COUNT][NETWORK_INFO_IPV6_DNS_COUNT_MAX]; } networkinfoipv6_t; #endif diff --git a/src/dusk/physics/physicsworld.c b/src/dusk/physics/physicsworld.c index 7efbbc4c..02e24ec7 100644 --- a/src/dusk/physics/physicsworld.c +++ b/src/dusk/physics/physicsworld.c @@ -45,7 +45,7 @@ void physicsWorldStep(const float_t dt) { } /* Phase 1: integrate dynamic bodies (gravity + velocity → position). - * Writes directly to pos->position — matrix rebuilt at end. */ + * Writes directly to pos->position, matrix rebuilt at end. */ for(entityid_t i = 0; i < physCount; i++) { if(!positions[i]) continue; entityphysics_t *phys = physBodies[i]; diff --git a/src/dusk/script/module/console/moduleconsole.h b/src/dusk/script/module/console/moduleconsole.h index 31a3555c..53c801e3 100644 --- a/src/dusk/script/module/console/moduleconsole.h +++ b/src/dusk/script/module/console/moduleconsole.h @@ -43,7 +43,7 @@ moduleBaseFunction(moduleConsoleGetVisible) { } moduleBaseFunction(moduleConsoleSetVisible) { - if(argc < 1) return moduleBaseThrow("Expected at least 1 argument");; + if(argc < 1) return moduleBaseThrow("Expected at least 1 argument"); if(!jerry_value_is_boolean(args[0])) { return moduleBaseThrow("Console.visible: expected boolean"); } diff --git a/src/dusk/script/module/display/modulecolor.h b/src/dusk/script/module/display/modulecolor.h index d22a913d..a92673ab 100644 --- a/src/dusk/script/module/display/modulecolor.h +++ b/src/dusk/script/module/display/modulecolor.h @@ -42,7 +42,11 @@ moduleBaseFunction(moduleColorGetA) { } moduleBaseFunction(moduleColorSetR) { - if(argc < 1) return moduleBaseThrow("Expected at least 1 argument");; moduleBaseRequireNumber(0); + if(argc < 1) { + return moduleBaseThrow("Expected at least 1 argument"); + } + moduleBaseRequireNumber(0); + color_t *c = moduleColorGet(callInfo); if(!c) return jerry_undefined(); c->r = (colorchannel8_t)jerry_value_as_number(args[0]); @@ -50,7 +54,11 @@ moduleBaseFunction(moduleColorSetR) { } moduleBaseFunction(moduleColorSetG) { - if(argc < 1) return moduleBaseThrow("Expected at least 1 argument");; moduleBaseRequireNumber(0); + if(argc < 1) { + return moduleBaseThrow("Expected at least 1 argument"); + } + moduleBaseRequireNumber(0); + color_t *c = moduleColorGet(callInfo); if(!c) return jerry_undefined(); c->g = (colorchannel8_t)jerry_value_as_number(args[0]); @@ -58,7 +66,11 @@ moduleBaseFunction(moduleColorSetG) { } moduleBaseFunction(moduleColorSetB) { - if(argc < 1) return moduleBaseThrow("Expected at least 1 argument");; moduleBaseRequireNumber(0); + if(argc < 1) { + return moduleBaseThrow("Expected at least 1 argument"); + } + moduleBaseRequireNumber(0); + color_t *c = moduleColorGet(callInfo); if(!c) return jerry_undefined(); c->b = (colorchannel8_t)jerry_value_as_number(args[0]); @@ -66,7 +78,11 @@ moduleBaseFunction(moduleColorSetB) { } moduleBaseFunction(moduleColorSetA) { - if(argc < 1) return moduleBaseThrow("Expected at least 1 argument");; moduleBaseRequireNumber(0); + if(argc < 1) { + return moduleBaseThrow("Expected at least 1 argument"); + } + moduleBaseRequireNumber(0); + color_t *c = moduleColorGet(callInfo); if(!c) return jerry_undefined(); c->a = (colorchannel8_t)jerry_value_as_number(args[0]); diff --git a/src/dusk/script/module/display/moduletext.h b/src/dusk/script/module/display/moduletext.h index a1a4903e..d5e4552b 100644 --- a/src/dusk/script/module/display/moduletext.h +++ b/src/dusk/script/module/display/moduletext.h @@ -17,7 +17,9 @@ moduleBaseFunction(moduleTextDraw) { if(argc < 3) return moduleBaseThrow("expected at least 3 arguments"); moduleBaseRequireNumber(0); moduleBaseRequireNumber(1); - if(!jerry_value_is_string(args[2])) return moduleBaseThrow("text must be a string"); + if(!jerry_value_is_string(args[2])) { + return moduleBaseThrow("text must be a string"); + } float_t x = (float_t)jerry_value_as_number(args[0]); float_t y = (float_t)jerry_value_as_number(args[1]); @@ -44,7 +46,9 @@ moduleBaseFunction(moduleTextDraw) { moduleBaseFunction(moduleTextMeasure) { if(argc < 1) return moduleBaseThrow("expected at least 1 argument"); - if(!jerry_value_is_string(args[0])) return moduleBaseThrow("text must be a string"); + if(!jerry_value_is_string(args[0])) { + return moduleBaseThrow("text must be a string"); + } char_t text[1024]; moduleBaseToString(args[0], text, sizeof(text)); diff --git a/src/dusk/script/module/entity/component/moduleentitycamera.h b/src/dusk/script/module/entity/component/moduleentitycamera.h index 87d54cc1..e32af40e 100644 --- a/src/dusk/script/module/entity/component/moduleentitycamera.h +++ b/src/dusk/script/module/entity/component/moduleentitycamera.h @@ -188,7 +188,9 @@ moduleBaseFunction(moduleEntityCameraSetProjectionType) { } moduleBaseFunction(moduleEntityCameraAdd) { - if(argc < 1) return moduleBaseThrow("Expected at least 1 argument");; moduleBaseRequireNumber(0); + if(argc < 1) return moduleBaseThrow("Expected at least 1 argument"); + moduleBaseRequireNumber(0); + entityid_t id = (entityid_t)jerry_value_as_number(args[0]); componentid_t comp = entityAddComponent(id, COMPONENT_TYPE_CAMERA); componenthandle_t h = { .eid = id, .cid = comp }; diff --git a/src/dusk/script/module/entity/component/moduleentitymaterial.h b/src/dusk/script/module/entity/component/moduleentitymaterial.h index da507559..87135ef7 100644 --- a/src/dusk/script/module/entity/component/moduleentitymaterial.h +++ b/src/dusk/script/module/entity/component/moduleentitymaterial.h @@ -28,7 +28,7 @@ static entitymaterial_t * moduleEntityMaterialGet( } moduleBaseFunction(moduleEntityMaterialSetColor) { - if(argc < 1) return moduleBaseThrow("Expected at least 1 argument");; + if(argc < 1) return moduleBaseThrow("Expected at least 1 argument"); if(!jerry_value_is_object(args[0])) { return moduleBaseThrow("expected color object"); } @@ -68,7 +68,11 @@ moduleBaseFunction(moduleEntityMaterialSetColor) { } moduleBaseFunction(moduleEntityMaterialAdd) { - if(argc < 1) return moduleBaseThrow("Expected at least 1 argument");; moduleBaseRequireNumber(0); + if(argc < 1) { + return moduleBaseThrow("Expected at least 1 argument"); + } + moduleBaseRequireNumber(0); + entityid_t id = (entityid_t)jerry_value_as_number(args[0]); componentid_t comp = entityAddComponent(id, COMPONENT_TYPE_MATERIAL); componenthandle_t h = { .eid = id, .cid = comp }; diff --git a/src/dusk/script/module/entity/component/moduleentitymesh.h b/src/dusk/script/module/entity/component/moduleentitymesh.h index 702cd77a..a9eda630 100644 --- a/src/dusk/script/module/entity/component/moduleentitymesh.h +++ b/src/dusk/script/module/entity/component/moduleentitymesh.h @@ -25,7 +25,11 @@ static entitymesh_t * moduleEntityMeshGet( } moduleBaseFunction(moduleEntityMeshAdd) { - if(argc < 1) return moduleBaseThrow("Expected at least 1 argument");; moduleBaseRequireNumber(0); + if(argc < 1) { + return moduleBaseThrow("Expected at least 1 argument"); + } + moduleBaseRequireNumber(0); + entityid_t id = (entityid_t)jerry_value_as_number(args[0]); componentid_t comp = entityAddComponent(id, COMPONENT_TYPE_MESH); componenthandle_t h = { .eid = id, .cid = comp }; diff --git a/src/dusk/script/module/entity/component/moduleentityphysics.h b/src/dusk/script/module/entity/component/moduleentityphysics.h index 614b99b0..f7dd37de 100644 --- a/src/dusk/script/module/entity/component/moduleentityphysics.h +++ b/src/dusk/script/module/entity/component/moduleentityphysics.h @@ -32,7 +32,7 @@ moduleBaseFunction(moduleEntityPhysicsGetVelocity) { } moduleBaseFunction(moduleEntityPhysicsSetVelocity) { - if(argc < 1) return moduleBaseThrow("Expected at least 1 argument");; + if(argc < 1) return moduleBaseThrow("Expected at least 1 argument"); entityphysics_t *phys = moduleEntityPhysicsGet(callInfo); if(!phys) return jerry_undefined(); vec3 v; @@ -56,7 +56,11 @@ moduleBaseFunction(moduleEntityPhysicsGetBodyType) { } moduleBaseFunction(moduleEntityPhysicsSetBodyType) { - if(argc < 1) return moduleBaseThrow("Expected at least 1 argument");; moduleBaseRequireNumber(0); + if(argc < 1) { + return moduleBaseThrow("Expected at least 1 argument"); + } + moduleBaseRequireNumber(0); + entityphysics_t *phys = moduleEntityPhysicsGet(callInfo); if(!phys) return jerry_undefined(); phys->type = (physicsbodytype_t)(int32_t)jerry_value_as_number(args[0]); @@ -64,7 +68,7 @@ moduleBaseFunction(moduleEntityPhysicsSetBodyType) { } moduleBaseFunction(moduleEntityPhysicsApplyImpulse) { - if(argc < 1) return moduleBaseThrow("Expected at least 1 argument");; + if(argc < 1) return moduleBaseThrow("Expected at least 1 argument"); entityphysics_t *phys = moduleEntityPhysicsGet(callInfo); if(!phys) return jerry_undefined(); if(phys->type == PHYSICS_BODY_STATIC) return jerry_undefined(); @@ -77,7 +81,7 @@ moduleBaseFunction(moduleEntityPhysicsApplyImpulse) { } moduleBaseFunction(moduleEntityPhysicsSetShapeCube) { - if(argc < 1) return moduleBaseThrow("Expected at least 1 argument");; + if(argc < 1) return moduleBaseThrow("Expected at least 1 argument"); entityphysics_t *phys = moduleEntityPhysicsGet(callInfo); if(!phys) return jerry_undefined(); vec3 half; @@ -90,7 +94,11 @@ moduleBaseFunction(moduleEntityPhysicsSetShapeCube) { } moduleBaseFunction(moduleEntityPhysicsSetShapeSphere) { - if(argc < 1) return moduleBaseThrow("Expected at least 1 argument");; moduleBaseRequireNumber(0); + if(argc < 1) { + return moduleBaseThrow("Expected at least 1 argument"); + } + moduleBaseRequireNumber(0); + entityphysics_t *phys = moduleEntityPhysicsGet(callInfo); if(!phys) return jerry_undefined(); phys->shape.type = PHYSICS_SHAPE_SPHERE; @@ -99,7 +107,7 @@ moduleBaseFunction(moduleEntityPhysicsSetShapeSphere) { } moduleBaseFunction(moduleEntityPhysicsSetShapeCapsule) { - if(argc < 2) return moduleBaseThrow("Expected at least 2 arguments");; + if(argc < 2) return moduleBaseThrow("Expected at least 2 arguments"); moduleBaseRequireNumber(0); moduleBaseRequireNumber(1); entityphysics_t *phys = moduleEntityPhysicsGet(callInfo); if(!phys) return jerry_undefined(); @@ -111,7 +119,11 @@ moduleBaseFunction(moduleEntityPhysicsSetShapeCapsule) { } moduleBaseFunction(moduleEntityPhysicsSetShapePlane) { - if(argc < 2) return moduleBaseThrow("Expected at least 2 arguments");; moduleBaseRequireNumber(1); + if(argc < 2) { + return moduleBaseThrow("Expected at least 2 arguments"); + } + moduleBaseRequireNumber(1); + entityphysics_t *phys = moduleEntityPhysicsGet(callInfo); if(!phys) return jerry_undefined(); vec3 normal; @@ -125,7 +137,11 @@ moduleBaseFunction(moduleEntityPhysicsSetShapePlane) { } moduleBaseFunction(moduleEntityPhysicsAdd) { - if(argc < 1) return moduleBaseThrow("Expected at least 1 argument");; moduleBaseRequireNumber(0); + if(argc < 1) { + return moduleBaseThrow("Expected at least 1 argument"); + } + moduleBaseRequireNumber(0); + entityid_t id = (entityid_t)jerry_value_as_number(args[0]); componentid_t comp = entityAddComponent(id, COMPONENT_TYPE_PHYSICS); componenthandle_t h = { .eid = id, .cid = comp }; diff --git a/src/dusk/script/module/entity/component/moduleentityposition.h b/src/dusk/script/module/entity/component/moduleentityposition.h index 05063141..e1df4e6f 100644 --- a/src/dusk/script/module/entity/component/moduleentityposition.h +++ b/src/dusk/script/module/entity/component/moduleentityposition.h @@ -12,7 +12,6 @@ #include "entity/entity.h" #include "entity/component/display/entityposition.h" -// Shared component handle struct — defined once, used by all component modules. #ifndef COMPONENT_HANDLE_DEFINED #define COMPONENT_HANDLE_DEFINED typedef struct { @@ -42,7 +41,7 @@ moduleBaseFunction(moduleEntityPositionGetPosition) { } moduleBaseFunction(moduleEntityPositionSetPosition) { - if(argc < 1) return moduleBaseThrow("Expected at least 1 argument");; + if(argc < 1) return moduleBaseThrow("Expected at least 1 argument"); entityposition_t *pos = moduleEntityPositionGet(callInfo); if(!pos) return jerry_undefined(); vec3 v; @@ -63,7 +62,7 @@ moduleBaseFunction(moduleEntityPositionGetRotation) { } moduleBaseFunction(moduleEntityPositionSetRotation) { - if(argc < 1) return moduleBaseThrow("Expected at least 1 argument");; + if(argc < 1) return moduleBaseThrow("Expected at least 1 argument"); entityposition_t *pos = moduleEntityPositionGet(callInfo); if(!pos) return jerry_undefined(); vec3 v; @@ -84,7 +83,7 @@ moduleBaseFunction(moduleEntityPositionGetScale) { } moduleBaseFunction(moduleEntityPositionSetScale) { - if(argc < 1) return moduleBaseThrow("Expected at least 1 argument");; + if(argc < 1) return moduleBaseThrow("Expected at least 1 argument"); entityposition_t *pos = moduleEntityPositionGet(callInfo); if(!pos) return jerry_undefined(); vec3 v; @@ -97,7 +96,7 @@ moduleBaseFunction(moduleEntityPositionSetScale) { } moduleBaseFunction(moduleEntityPositionLookAt) { - if(argc < 1) return moduleBaseThrow("Expected at least 1 argument");; + if(argc < 1) return moduleBaseThrow("Expected at least 1 argument"); entityposition_t *pos = moduleEntityPositionGet(callInfo); if(!pos) return jerry_undefined(); vec3 target; @@ -114,7 +113,11 @@ moduleBaseFunction(moduleEntityPositionLookAt) { } moduleBaseFunction(moduleEntityPositionAdd) { - if(argc < 1) return moduleBaseThrow("Expected at least 1 argument");; moduleBaseRequireNumber(0); + if(argc < 1) { + return moduleBaseThrow("Expected at least 1 argument"); + } + moduleBaseRequireNumber(0); + entityid_t id = (entityid_t)jerry_value_as_number(args[0]); componentid_t comp = entityAddComponent(id, COMPONENT_TYPE_POSITION); componenthandle_t h = { .eid = id, .cid = comp }; diff --git a/src/dusk/script/module/input/moduleinput.h b/src/dusk/script/module/input/moduleinput.h index 107d5c0b..cb9a28a5 100644 --- a/src/dusk/script/module/input/moduleinput.h +++ b/src/dusk/script/module/input/moduleinput.h @@ -15,7 +15,7 @@ static scriptproto_t MODULE_INPUT_PROTO; // Static Methods moduleBaseFunction(moduleInputBind) { - if(argc < 2) return moduleBaseThrow("Expected at least 2 arguments");; + if(argc < 2) return moduleBaseThrow("Expected at least 2 arguments"); moduleBaseRequireString(0); moduleBaseRequireNumber(1); @@ -40,7 +40,11 @@ moduleBaseFunction(moduleInputBind) { } moduleBaseFunction(moduleInputIsDown) { - if(argc < 1) return moduleBaseThrow("Expected at least 1 argument");; moduleBaseRequireNumber(0); + if(argc < 1) { + return moduleBaseThrow("Expected at least 1 argument"); + } + moduleBaseRequireNumber(0); + const inputaction_t action = (inputaction_t)jerry_value_as_number(args[0]); if(action <= INPUT_ACTION_NULL || action >= INPUT_ACTION_COUNT) { return moduleBaseThrow("Input.isDown: invalid action"); @@ -49,7 +53,11 @@ moduleBaseFunction(moduleInputIsDown) { } moduleBaseFunction(moduleInputPressed) { - if(argc < 1) return moduleBaseThrow("Expected at least 1 argument");; moduleBaseRequireNumber(0); + if(argc < 1) { + return moduleBaseThrow("Expected at least 1 argument"); + } + moduleBaseRequireNumber(0); + const inputaction_t action = (inputaction_t)jerry_value_as_number(args[0]); if(action <= INPUT_ACTION_NULL || action >= INPUT_ACTION_COUNT) { return moduleBaseThrow("Input.pressed: invalid action"); @@ -58,7 +66,11 @@ moduleBaseFunction(moduleInputPressed) { } moduleBaseFunction(moduleInputReleased) { - if(argc < 1) return moduleBaseThrow("Expected at least 1 argument");; moduleBaseRequireNumber(0); + if(argc < 1) { + return moduleBaseThrow("Expected at least 1 argument"); + } + moduleBaseRequireNumber(0); + const inputaction_t action = (inputaction_t)jerry_value_as_number(args[0]); if(action <= INPUT_ACTION_NULL || action >= INPUT_ACTION_COUNT) { return moduleBaseThrow("Input.released: invalid action"); @@ -67,7 +79,11 @@ moduleBaseFunction(moduleInputReleased) { } moduleBaseFunction(moduleInputGetValue) { - if(argc < 1) return moduleBaseThrow("Expected at least 1 argument");; moduleBaseRequireNumber(0); + if(argc < 1) { + return moduleBaseThrow("Expected at least 1 argument"); + } + moduleBaseRequireNumber(0); + const inputaction_t action = (inputaction_t)jerry_value_as_number(args[0]); if(action <= INPUT_ACTION_NULL || action >= INPUT_ACTION_COUNT) { return moduleBaseThrow("Input.getValue: invalid action"); @@ -76,7 +92,7 @@ moduleBaseFunction(moduleInputGetValue) { } moduleBaseFunction(moduleInputAxis) { - if(argc < 2) return moduleBaseThrow("Expected at least 2 arguments");; + if(argc < 2) return moduleBaseThrow("Expected at least 2 arguments"); moduleBaseRequireNumber(0); moduleBaseRequireNumber(1); const inputaction_t neg = (inputaction_t)jerry_value_as_number(args[0]); const inputaction_t pos = (inputaction_t)jerry_value_as_number(args[1]); @@ -90,7 +106,7 @@ moduleBaseFunction(moduleInputAxis) { } moduleBaseFunction(moduleInputAxis2D) { - if(argc < 4) return moduleBaseThrow("Expected at least 4 arguments");; + if(argc < 4) return moduleBaseThrow("Expected at least 4 arguments"); moduleBaseRequireNumber(0); moduleBaseRequireNumber(1); moduleBaseRequireNumber(2); moduleBaseRequireNumber(3); const inputaction_t negX = (inputaction_t)jerry_value_as_number(args[0]); diff --git a/src/dusk/script/module/math/modulemat4.h b/src/dusk/script/module/math/modulemat4.h index 49d81427..c138a0b3 100644 --- a/src/dusk/script/module/math/modulemat4.h +++ b/src/dusk/script/module/math/modulemat4.h @@ -28,7 +28,7 @@ moduleBaseFunction(moduleMatConstructor) { } moduleBaseFunction(moduleMatMul) { - if(argc < 1) return moduleBaseThrow("Expected at least 1 argument");; + if(argc < 1) return moduleBaseThrow("Expected at least 1 argument"); float_t (*a)[4] = (float_t (*)[4])moduleMatGet(callInfo); if(!a) return moduleBaseThrow("Mat4.mul: invalid this"); float_t (*b)[4] = (float_t (*)[4])scriptProtoGetValue( @@ -63,7 +63,7 @@ moduleBaseFunction(moduleMatDeterminant) { } moduleBaseFunction(moduleMatMulVec3) { - if(argc < 1) return moduleBaseThrow("Expected at least 1 argument");; + if(argc < 1) return moduleBaseThrow("Expected at least 1 argument"); float_t (*m)[4] = (float_t (*)[4])moduleMatGet(callInfo); if(!m) return moduleBaseThrow("Mat4.mulVec3: invalid this"); vec3 vin; @@ -78,7 +78,7 @@ moduleBaseFunction(moduleMatMulVec3) { } moduleBaseFunction(moduleMatMulVec4) { - if(argc < 1) return moduleBaseThrow("Expected at least 1 argument");; + if(argc < 1) return moduleBaseThrow("Expected at least 1 argument"); float_t (*m)[4] = (float_t (*)[4])moduleMatGet(callInfo); if(!m) return moduleBaseThrow("Mat4.mulVec4: invalid this"); vec4 vin; @@ -91,7 +91,7 @@ moduleBaseFunction(moduleMatMulVec4) { } moduleBaseFunction(moduleMatTranslate) { - if(argc < 1) return moduleBaseThrow("Expected at least 1 argument");; + if(argc < 1) return moduleBaseThrow("Expected at least 1 argument"); float_t (*m)[4] = (float_t (*)[4])moduleMatGet(callInfo); if(!m) return moduleBaseThrow("Mat4.translate: invalid this"); vec3 tv; @@ -105,7 +105,7 @@ moduleBaseFunction(moduleMatTranslate) { } moduleBaseFunction(moduleMatScale) { - if(argc < 1) return moduleBaseThrow("Expected at least 1 argument");; + if(argc < 1) return moduleBaseThrow("Expected at least 1 argument"); float_t (*m)[4] = (float_t (*)[4])moduleMatGet(callInfo); if(!m) return moduleBaseThrow("Mat4.scale: invalid this"); vec3 sv; @@ -125,7 +125,7 @@ moduleBaseFunction(moduleMatStaticIdentity) { } moduleBaseFunction(moduleMatStaticPerspective) { - if(argc < 4) return moduleBaseThrow("Expected at least 4 arguments");; + if(argc < 4) return moduleBaseThrow("Expected at least 4 arguments"); moduleBaseRequireNumber(0); moduleBaseRequireNumber(1); moduleBaseRequireNumber(2); moduleBaseRequireNumber(3); mat4 r; @@ -140,7 +140,7 @@ moduleBaseFunction(moduleMatStaticPerspective) { } moduleBaseFunction(moduleMatStaticLookAt) { - if(argc < 3) return moduleBaseThrow("Expected at least 3 arguments");; + if(argc < 3) return moduleBaseThrow("Expected at least 3 arguments"); vec3 eye, center, up; if(!moduleVec3Check(args[0], eye)) { return moduleBaseThrow("Mat4.lookAt: eye must be a Vec3"); diff --git a/src/dusk/script/module/math/modulevec2.h b/src/dusk/script/module/math/modulevec2.h index 13d2f4ec..46da014b 100644 --- a/src/dusk/script/module/math/modulevec2.h +++ b/src/dusk/script/module/math/modulevec2.h @@ -55,7 +55,7 @@ moduleBaseFunction(moduleVec2SetY) { } moduleBaseFunction(moduleVec2Dot) { - if(argc < 1) return moduleBaseThrow("Expected at least 1 argument");; + if(argc < 1) return moduleBaseThrow("Expected at least 1 argument"); float_t *a = moduleVec2Get(callInfo); if(!a) return moduleBaseThrow("Vec2.dot: invalid this"); float_t *b = moduleVec2From(args[0]); @@ -92,7 +92,7 @@ moduleBaseFunction(moduleVec2Negate) { } moduleBaseFunction(moduleVec2Add) { - if(argc < 1) return moduleBaseThrow("Expected at least 1 argument");; + if(argc < 1) return moduleBaseThrow("Expected at least 1 argument"); float_t *a = moduleVec2Get(callInfo); if(!a) return moduleBaseThrow("Vec2.add: invalid this"); float_t *b = moduleVec2From(args[0]); @@ -103,7 +103,7 @@ moduleBaseFunction(moduleVec2Add) { } moduleBaseFunction(moduleVec2Sub) { - if(argc < 1) return moduleBaseThrow("Expected at least 1 argument");; + if(argc < 1) return moduleBaseThrow("Expected at least 1 argument"); float_t *a = moduleVec2Get(callInfo); if(!a) return moduleBaseThrow("Vec2.sub: invalid this"); float_t *b = moduleVec2From(args[0]); @@ -114,7 +114,11 @@ moduleBaseFunction(moduleVec2Sub) { } moduleBaseFunction(moduleVec2Scale) { - if(argc < 1) return moduleBaseThrow("Expected at least 1 argument");; moduleBaseRequireNumber(0); + if(argc < 1) { + return moduleBaseThrow("Expected at least 1 argument"); + } + moduleBaseRequireNumber(0); + float_t *v = moduleVec2Get(callInfo); if(!v) return moduleBaseThrow("Vec2.scale: invalid this"); vec2 r; @@ -123,7 +127,11 @@ moduleBaseFunction(moduleVec2Scale) { } moduleBaseFunction(moduleVec2Lerp) { - if(argc < 2) return moduleBaseThrow("Expected at least 2 arguments");; moduleBaseRequireNumber(1); + if(argc < 2) { + return moduleBaseThrow("Expected at least 2 arguments"); + } + moduleBaseRequireNumber(1); + float_t *a = moduleVec2Get(callInfo); if(!a) return moduleBaseThrow("Vec2.lerp: invalid this"); float_t *b = moduleVec2From(args[0]); @@ -134,7 +142,7 @@ moduleBaseFunction(moduleVec2Lerp) { } moduleBaseFunction(moduleVec2Distance) { - if(argc < 1) return moduleBaseThrow("Expected at least 1 argument");; + if(argc < 1) return moduleBaseThrow("Expected at least 1 argument"); float_t *a = moduleVec2Get(callInfo); if(!a) return moduleBaseThrow("Vec2.distance: invalid this"); float_t *b = moduleVec2From(args[0]); @@ -176,14 +184,14 @@ static void moduleVec2(void) { scriptProtoDefineToString(&MODULE_VEC2_PROTO, moduleVec2ToString); - scriptProtoDefineFunc(&MODULE_VEC2_PROTO, "dot", moduleVec2Dot); - scriptProtoDefineFunc(&MODULE_VEC2_PROTO, "length", moduleVec2Length); - scriptProtoDefineFunc(&MODULE_VEC2_PROTO, "lengthSq", moduleVec2LengthSq); + scriptProtoDefineFunc(&MODULE_VEC2_PROTO, "dot", moduleVec2Dot); + scriptProtoDefineFunc(&MODULE_VEC2_PROTO, "length", moduleVec2Length); + scriptProtoDefineFunc(&MODULE_VEC2_PROTO, "lengthSq", moduleVec2LengthSq); scriptProtoDefineFunc(&MODULE_VEC2_PROTO, "normalize", moduleVec2Normalize); - scriptProtoDefineFunc(&MODULE_VEC2_PROTO, "negate", moduleVec2Negate); - scriptProtoDefineFunc(&MODULE_VEC2_PROTO, "add", moduleVec2Add); - scriptProtoDefineFunc(&MODULE_VEC2_PROTO, "sub", moduleVec2Sub); - scriptProtoDefineFunc(&MODULE_VEC2_PROTO, "scale", moduleVec2Scale); - scriptProtoDefineFunc(&MODULE_VEC2_PROTO, "lerp", moduleVec2Lerp); - scriptProtoDefineFunc(&MODULE_VEC2_PROTO, "distance", moduleVec2Distance); + scriptProtoDefineFunc(&MODULE_VEC2_PROTO, "negate", moduleVec2Negate); + scriptProtoDefineFunc(&MODULE_VEC2_PROTO, "add", moduleVec2Add); + scriptProtoDefineFunc(&MODULE_VEC2_PROTO, "sub", moduleVec2Sub); + scriptProtoDefineFunc(&MODULE_VEC2_PROTO, "scale", moduleVec2Scale); + scriptProtoDefineFunc(&MODULE_VEC2_PROTO, "lerp", moduleVec2Lerp); + scriptProtoDefineFunc(&MODULE_VEC2_PROTO, "distance", moduleVec2Distance); } diff --git a/src/dusk/script/module/math/modulevec3.h b/src/dusk/script/module/math/modulevec3.h index 8bccc9f0..ec4af698 100644 --- a/src/dusk/script/module/math/modulevec3.h +++ b/src/dusk/script/module/math/modulevec3.h @@ -67,7 +67,7 @@ moduleBaseFunction(moduleVec3SetZ) { } moduleBaseFunction(moduleVec3Dot) { - if(argc < 1) return moduleBaseThrow("Expected at least 1 argument");; + if(argc < 1) return moduleBaseThrow("Expected at least 1 argument"); float_t *a = moduleVec3Get(callInfo); if(!a) return moduleBaseThrow("Vec3.dot: invalid this"); float_t *b = moduleVec3From(args[0]); @@ -76,7 +76,7 @@ moduleBaseFunction(moduleVec3Dot) { } moduleBaseFunction(moduleVec3Cross) { - if(argc < 1) return moduleBaseThrow("Expected at least 1 argument");; + if(argc < 1) return moduleBaseThrow("Expected at least 1 argument"); float_t *a = moduleVec3Get(callInfo); if(!a) return moduleBaseThrow("Vec3.cross: invalid this"); float_t *b = moduleVec3From(args[0]); @@ -115,7 +115,7 @@ moduleBaseFunction(moduleVec3Negate) { } moduleBaseFunction(moduleVec3Add) { - if(argc < 1) return moduleBaseThrow("Expected at least 1 argument");; + if(argc < 1) return moduleBaseThrow("Expected at least 1 argument"); float_t *a = moduleVec3Get(callInfo); if(!a) return moduleBaseThrow("Vec3.add: invalid this"); float_t *b = moduleVec3From(args[0]); @@ -126,7 +126,7 @@ moduleBaseFunction(moduleVec3Add) { } moduleBaseFunction(moduleVec3Sub) { - if(argc < 1) return moduleBaseThrow("Expected at least 1 argument");; + if(argc < 1) return moduleBaseThrow("Expected at least 1 argument"); float_t *a = moduleVec3Get(callInfo); if(!a) return moduleBaseThrow("Vec3.sub: invalid this"); float_t *b = moduleVec3From(args[0]); @@ -137,7 +137,11 @@ moduleBaseFunction(moduleVec3Sub) { } moduleBaseFunction(moduleVec3Scale) { - if(argc < 1) return moduleBaseThrow("Expected at least 1 argument");; moduleBaseRequireNumber(0); + if(argc < 1) { + return moduleBaseThrow("Expected at least 1 argument"); + } + moduleBaseRequireNumber(0); + float_t *v = moduleVec3Get(callInfo); if(!v) return moduleBaseThrow("Vec3.scale: invalid this"); vec3 r; @@ -146,7 +150,11 @@ moduleBaseFunction(moduleVec3Scale) { } moduleBaseFunction(moduleVec3Lerp) { - if(argc < 2) return moduleBaseThrow("Expected at least 2 arguments");; moduleBaseRequireNumber(1); + if(argc < 2) { + return moduleBaseThrow("Expected at least 2 arguments"); + } + moduleBaseRequireNumber(1); + float_t *a = moduleVec3Get(callInfo); if(!a) return moduleBaseThrow("Vec3.lerp: invalid this"); float_t *b = moduleVec3From(args[0]); @@ -157,7 +165,7 @@ moduleBaseFunction(moduleVec3Lerp) { } moduleBaseFunction(moduleVec3Distance) { - if(argc < 1) return moduleBaseThrow("Expected at least 1 argument");; + if(argc < 1) return moduleBaseThrow("Expected at least 1 argument"); float_t *a = moduleVec3Get(callInfo); if(!a) return moduleBaseThrow("Vec3.distance: invalid this"); float_t *b = moduleVec3From(args[0]); diff --git a/src/dusk/script/module/math/modulevec4.h b/src/dusk/script/module/math/modulevec4.h index 48ce003b..79274431 100644 --- a/src/dusk/script/module/math/modulevec4.h +++ b/src/dusk/script/module/math/modulevec4.h @@ -121,7 +121,7 @@ moduleBaseFunction(moduleVec4SetV1) { } moduleBaseFunction(moduleVec4Dot) { - if(argc < 1) return moduleBaseThrow("Expected at least 1 argument");; + if(argc < 1) return moduleBaseThrow("Expected at least 1 argument"); float_t *a = moduleVec4Get(callInfo); if(!a) return moduleBaseThrow("Vec4.dot: invalid this"); float_t *b = moduleVec4From(args[0]); @@ -158,7 +158,7 @@ moduleBaseFunction(moduleVec4Negate) { } moduleBaseFunction(moduleVec4Add) { - if(argc < 1) return moduleBaseThrow("Expected at least 1 argument");; + if(argc < 1) return moduleBaseThrow("Expected at least 1 argument"); float_t *a = moduleVec4Get(callInfo); if(!a) return moduleBaseThrow("Vec4.add: invalid this"); float_t *b = moduleVec4From(args[0]); @@ -169,7 +169,7 @@ moduleBaseFunction(moduleVec4Add) { } moduleBaseFunction(moduleVec4Sub) { - if(argc < 1) return moduleBaseThrow("Expected at least 1 argument");; + if(argc < 1) return moduleBaseThrow("Expected at least 1 argument"); float_t *a = moduleVec4Get(callInfo); if(!a) return moduleBaseThrow("Vec4.sub: invalid this"); float_t *b = moduleVec4From(args[0]); @@ -180,7 +180,11 @@ moduleBaseFunction(moduleVec4Sub) { } moduleBaseFunction(moduleVec4Scale) { - if(argc < 1) return moduleBaseThrow("Expected at least 1 argument");; moduleBaseRequireNumber(0); + if(argc < 1) { + return moduleBaseThrow("Expected at least 1 argument"); + } + moduleBaseRequireNumber(0); + float_t *v = moduleVec4Get(callInfo); if(!v) return moduleBaseThrow("Vec4.scale: invalid this"); vec4 r; @@ -189,7 +193,11 @@ moduleBaseFunction(moduleVec4Scale) { } moduleBaseFunction(moduleVec4Lerp) { - if(argc < 2) return moduleBaseThrow("Expected at least 2 arguments");; moduleBaseRequireNumber(1); + if(argc < 2) { + return moduleBaseThrow("Expected at least 2 arguments"); + } + moduleBaseRequireNumber(1); + float_t *a = moduleVec4Get(callInfo); if(!a) return moduleBaseThrow("Vec4.lerp: invalid this"); float_t *b = moduleVec4From(args[0]); @@ -256,13 +264,13 @@ static void moduleVec4(void) { scriptProtoDefineToString(&MODULE_VEC4_PROTO, moduleVec4ToString); - scriptProtoDefineFunc(&MODULE_VEC4_PROTO, "dot", moduleVec4Dot); - scriptProtoDefineFunc(&MODULE_VEC4_PROTO, "length", moduleVec4Length); - scriptProtoDefineFunc(&MODULE_VEC4_PROTO, "lengthSq", moduleVec4LengthSq); + scriptProtoDefineFunc(&MODULE_VEC4_PROTO, "dot", moduleVec4Dot); + scriptProtoDefineFunc(&MODULE_VEC4_PROTO, "length", moduleVec4Length); + scriptProtoDefineFunc(&MODULE_VEC4_PROTO, "lengthSq", moduleVec4LengthSq); scriptProtoDefineFunc(&MODULE_VEC4_PROTO, "normalize", moduleVec4Normalize); - scriptProtoDefineFunc(&MODULE_VEC4_PROTO, "negate", moduleVec4Negate); - scriptProtoDefineFunc(&MODULE_VEC4_PROTO, "add", moduleVec4Add); - scriptProtoDefineFunc(&MODULE_VEC4_PROTO, "sub", moduleVec4Sub); - scriptProtoDefineFunc(&MODULE_VEC4_PROTO, "scale", moduleVec4Scale); - scriptProtoDefineFunc(&MODULE_VEC4_PROTO, "lerp", moduleVec4Lerp); + scriptProtoDefineFunc(&MODULE_VEC4_PROTO, "negate", moduleVec4Negate); + scriptProtoDefineFunc(&MODULE_VEC4_PROTO, "add", moduleVec4Add); + scriptProtoDefineFunc(&MODULE_VEC4_PROTO, "sub", moduleVec4Sub); + scriptProtoDefineFunc(&MODULE_VEC4_PROTO, "scale", moduleVec4Scale); + scriptProtoDefineFunc(&MODULE_VEC4_PROTO, "lerp", moduleVec4Lerp); } diff --git a/src/dusk/script/module/scene/modulescene.h b/src/dusk/script/module/scene/modulescene.h index 29e68fa8..255ee16f 100644 --- a/src/dusk/script/module/scene/modulescene.h +++ b/src/dusk/script/module/scene/modulescene.h @@ -25,7 +25,7 @@ moduleBaseFunction(moduleSceneDefaultConstructor) { } moduleBaseFunction(moduleSceneSet) { - if(argc < 1) return moduleBaseThrow("Expected at least 1 argument");; + if(argc < 1) return moduleBaseThrow("Expected at least 1 argument"); moduleBaseRequireString(0); char_t name[ASSET_FILE_PATH_MAX]; diff --git a/src/dusk/script/scriptproto.c b/src/dusk/script/scriptproto.c index 3fc2067d..2db8c824 100644 --- a/src/dusk/script/scriptproto.c +++ b/src/dusk/script/scriptproto.c @@ -78,7 +78,9 @@ void scriptProtoDefineProp( } jerry_value_t key = jerry_string_sz(name); - jerry_value_t result = jerry_object_define_own_prop(proto->prototype, key, &desc); + jerry_value_t result = jerry_object_define_own_prop( + proto->prototype, key, &desc + ); jerry_value_free(result); jerry_value_free(key); jerry_value_free(desc.getter); @@ -111,7 +113,9 @@ void scriptProtoDefineStaticProp( assertStrLenMin(name, 1, "Property name must not be empty"); assertNotNull(getter, "Getter must not be null"); - jerry_value_t target = proto->constructor ? proto->constructor : proto->prototype; + jerry_value_t target = ( + proto->constructor ? proto->constructor : proto->prototype + ); jerry_property_descriptor_t desc; memoryZero(&desc, sizeof(desc)); @@ -145,7 +149,9 @@ void scriptProtoDefineStaticFunc( assertStrLenMin(name, 1, "Method name must not be empty"); assertNotNull(fn, "Function handler must not be null"); - jerry_value_t target = proto->constructor ? proto->constructor : proto->prototype; + jerry_value_t target = ( + proto->constructor ? proto->constructor : proto->prototype + ); jerry_value_t key = jerry_string_sz(name); jerry_value_t func = jerry_function_external(fn); jerry_object_set(target, key, func); diff --git a/src/dusk/ui/uielement.c b/src/dusk/ui/uielement.c index 33cba7f9..a31d3ddd 100644 --- a/src/dusk/ui/uielement.c +++ b/src/dusk/ui/uielement.c @@ -37,7 +37,9 @@ errorret_t uiElementDraw(const uielement_t *element) { case UI_ELEMENT_TYPE_SCRIPT: { jerry_value_t renderKey = jerry_string_sz("render"); - jerry_value_t renderFn = jerry_object_get(element->script.module, renderKey); + jerry_value_t renderFn = jerry_object_get( + element->script.module, renderKey + ); jerry_value_free(renderKey); if(!jerry_value_is_function(renderFn)) { diff --git a/src/dusk/util/string.c b/src/dusk/util/string.c index a6b26bae..8321546f 100644 --- a/src/dusk/util/string.c +++ b/src/dusk/util/string.c @@ -163,7 +163,12 @@ bool_t stringToI16(const char_t *str, int16_t *out) { char_t *endptr; errno = 0; long int result = strtol(str, &endptr, 10); - if(errno != 0 || *endptr != '\0' || result < INT16_MIN || result > INT16_MAX) { + if( + errno != 0 || + *endptr != '\0' || + result < INT16_MIN || + result > INT16_MAX + ) { return false; } *out = (int16_t)result; diff --git a/src/duskdolphin/display/shader/shaderdolphin.c b/src/duskdolphin/display/shader/shaderdolphin.c index 802a9d13..cc381b02 100644 --- a/src/duskdolphin/display/shader/shaderdolphin.c +++ b/src/duskdolphin/display/shader/shaderdolphin.c @@ -146,7 +146,12 @@ errorret_t shaderSetTextureDolphin( GX_TEXMAP0, GX_COLOR0A0 ); - GX_SetBlendMode(GX_BM_BLEND, GX_BL_SRCALPHA, GX_BL_INVSRCALPHA, GX_LO_CLEAR); + GX_SetBlendMode( + GX_BM_BLEND, + GX_BL_SRCALPHA, + GX_BL_INVSRCALPHA, + GX_LO_CLEAR + ); GX_SetAlphaCompare(GX_ALWAYS, 0, GX_AOP_AND, GX_ALWAYS, 0); break; @@ -226,7 +231,9 @@ errorret_t shaderUpdateMVPDolphin() { // Set Model/View Matrix if(mvDirt) { - glm_mat4_mul(SHADER_BOUND->view, SHADER_BOUND->model, SHADER_BOUND->modelView); + glm_mat4_mul( + SHADER_BOUND->view, SHADER_BOUND->model, SHADER_BOUND->modelView + ); shaderMat4ToMtx(SHADER_BOUND->modelView, SHADER_BOUND->dolphinModelView); GX_LoadPosMtxImm(SHADER_BOUND->dolphinModelView, GX_PNMTX0); } diff --git a/src/duskgl/display/framebuffer/framebuffergl.c b/src/duskgl/display/framebuffer/framebuffergl.c index 43f70068..95eecfa3 100644 --- a/src/duskgl/display/framebuffer/framebuffergl.c +++ b/src/duskgl/display/framebuffer/framebuffergl.c @@ -107,9 +107,9 @@ void frameBufferGLClear(const uint8_t flags, const color_t color) { assertTrue(width > 0 && height > 0, "W/H must be greater than 0"); memoryZero(fb, sizeof(framebuffer_t)); - textureInit(&fb->texture, width, height, TEXTURE_FORMAT_RGBA,(texturedata_t){ - .rgbaColors = NULL - }); + textureInit(&fb->texture, width, height, TEXTURE_FORMAT_RGBA, + (texturedata_t){ .rgbaColors = NULL } + ); errorChain(errorGLCheck()); glGenFramebuffersEXT(1, &fb->id); diff --git a/src/dusklinux/asset/assetlinux.c b/src/dusklinux/asset/assetlinux.c index 30b3ae3c..5315f070 100644 --- a/src/dusklinux/asset/assetlinux.c +++ b/src/dusklinux/asset/assetlinux.c @@ -61,7 +61,7 @@ errorret_t assetInitLinux(void) { // Ensure combined length does not exceed ASSET_FILE_PATH_MAX size_t syslen = strlen(ASSET.platform.systemPath); size_t slashlen = 1; // for '/' - size_t max_temp = ASSET_FILE_PATH_MAX - syslen - slashlen - 1; // -1 for null terminator + size_t max_temp = ASSET_FILE_PATH_MAX - syslen - slashlen - 1; if(strlen(temp) > max_temp) { temp[max_temp] = '\0'; } diff --git a/src/dusklinux/network/networklinux.h b/src/dusklinux/network/networklinux.h index 3b70bc6a..d81501bd 100644 --- a/src/dusklinux/network/networklinux.h +++ b/src/dusklinux/network/networklinux.h @@ -33,7 +33,7 @@ errorret_t networkLinuxInit(); errorret_t networkLinuxUpdate(); /** - * Returns true — Linux uses the OS network stack which is always available. + * Returns true, Linux uses the OS network stack which is always available. * * @return true */ diff --git a/src/duskpsp/asset/assetpbp.c b/src/duskpsp/asset/assetpbp.c index e97237d9..46ebedd1 100644 --- a/src/duskpsp/asset/assetpbp.c +++ b/src/duskpsp/asset/assetpbp.c @@ -73,7 +73,9 @@ errorret_t assetInitPBP(const char_t *pbpPath) { errorThrow("Failed to seek to PSAR offset in PBP file: %s", pbpPath); } - zip_uint64_t zipPsarOffset = (zip_uint64_t)ASSET.platform.pbpHeader.psarOffset; + zip_uint64_t zipPsarOffset = (zip_uint64_t)( + ASSET.platform.pbpHeader.psarOffset + ); zip_int64_t zipPsarSize = (zip_int64_t)( pbpSize - ASSET.platform.pbpHeader.psarOffset ); diff --git a/src/duskpsp/network/networkpsp.c b/src/duskpsp/network/networkpsp.c index 73c12b80..19e0fd9d 100644 --- a/src/duskpsp/network/networkpsp.c +++ b/src/duskpsp/network/networkpsp.c @@ -116,7 +116,9 @@ errorret_t networkPSPUpdate() { break; default: - errorThrow("Unknown PSP Netconf dialog status: %d", sceUtilityNetconfGetStatus()); + errorThrow( + "Unknown PSP Netconf dialog status: %d", sceUtilityNetconfGetStatus() + ); } } diff --git a/src/duskpsp/network/networkpsp.h b/src/duskpsp/network/networkpsp.h index fc3a400f..e8b50889 100644 --- a/src/duskpsp/network/networkpsp.h +++ b/src/duskpsp/network/networkpsp.h @@ -84,7 +84,7 @@ void networkPSPRequestConnection( ); /** - * Requests the PSP to disconnect from the network (Shows the Wi-Fi disconnecting). + * Requests the PSP to disconnect from the network. * * @param onComplete Callback when disconnection is complete. * @param user User data to pass to the callback. diff --git a/src/duskrpg/script/CMakeLists.txt b/src/duskrpg/script/CMakeLists.txt deleted file mode 100644 index 26438bbd..00000000 --- a/src/duskrpg/script/CMakeLists.txt +++ /dev/null @@ -1,7 +0,0 @@ -# Copyright (c) 2026 Dominic Masters -# -# This software is released under the MIT License. -# https://opensource.org/licenses/MIT - -# Subdirs -add_subdirectory(module) \ No newline at end of file diff --git a/src/duskrpg/script/module/CMakeLists.txt b/src/duskrpg/script/module/CMakeLists.txt deleted file mode 100644 index 1c70c1d9..00000000 --- a/src/duskrpg/script/module/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -# Copyright (c) 2026 Dominic Masters -# -# This software is released under the MIT License. -# https://opensource.org/licenses/MIT - -# Subdirectories -add_subdirectory(item) -add_subdirectory(story) \ No newline at end of file diff --git a/src/duskrpg/script/module/item/CMakeLists.txt b/src/duskrpg/script/module/item/CMakeLists.txt deleted file mode 100644 index 84f36e34..00000000 --- a/src/duskrpg/script/module/item/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -# Copyright (c) 2026 Dominic Masters -# -# This software is released under the MIT License. -# https://opensource.org/licenses/MIT - diff --git a/src/duskrpg/script/module/item/moduleitem.h b/src/duskrpg/script/module/item/moduleitem.h deleted file mode 100644 index 8a6a396d..00000000 --- a/src/duskrpg/script/module/item/moduleitem.h +++ /dev/null @@ -1,200 +0,0 @@ -/** - * Copyright (c) 2026 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#pragma once -#include "script/module/modulebase.h" -#include "item/inventory.h" -#include "item/backpack.h" -#include "assert/assert.h" - -JS_FUNC(moduleInventoryItemExists) { - if(!jerry_value_is_object(args_p[0])) { - return JS_THROW("inventoryItemExists: Expected inventory pointer as first argument"); - } - - if(!jerry_value_is_number(args_p[1])) { - return JS_THROW("inventoryItemExists: Expected item ID as second argument"); - } - - inventory_t *inventory = (inventory_t *)jsUnwrapPointer(args_p[0]); - itemid_t item = (itemid_t)jerry_value_as_number(args_p[1]); - - assertNotNull(inventory, "Inventory pointer cannot be NULL."); - - if(item == ITEM_ID_NULL) { - return JS_THROW("inventoryItemExists: Item ID cannot be ITEM_ID_NULL"); - } - - bool_t hasItem = inventoryItemExists(inventory, item); - return jerry_boolean(hasItem); -} - -JS_FUNC(moduleInventorySet) { - if(!jerry_value_is_object(args_p[0])) { - return JS_THROW("inventorySet: Expected inventory pointer as first argument"); - } - - if(!jerry_value_is_number(args_p[1])) { - return JS_THROW("inventorySet: Expected item ID as second argument"); - } - - if(!jerry_value_is_number(args_p[2])) { - return JS_THROW("inventorySet: Expected quantity as third argument"); - } - - inventory_t *inventory = (inventory_t *)jsUnwrapPointer(args_p[0]); - itemid_t item = (itemid_t)jerry_value_as_number(args_p[1]); - uint8_t quantity = (uint8_t)jerry_value_as_number(args_p[2]); - - assertNotNull(inventory, "Inventory pointer cannot be NULL."); - inventorySet(inventory, item, quantity); - return jerry_undefined(); -} - -JS_FUNC(moduleInventoryAdd) { - if(!jerry_value_is_object(args_p[0])) { - return JS_THROW("inventoryAdd: Expected inventory pointer as first argument"); - } - - if(!jerry_value_is_number(args_p[1])) { - return JS_THROW("inventoryAdd: Expected item ID as second argument"); - } - - if(!jerry_value_is_number(args_p[2])) { - return JS_THROW("inventoryAdd: Expected quantity as third argument"); - } - - inventory_t *inventory = (inventory_t *)jsUnwrapPointer(args_p[0]); - itemid_t item = (itemid_t)jerry_value_as_number(args_p[1]); - uint8_t quantity = (uint8_t)jerry_value_as_number(args_p[2]); - - assertNotNull(inventory, "Inventory pointer cannot be NULL."); - inventoryAdd(inventory, item, quantity); - return jerry_undefined(); -} - -JS_FUNC(moduleInventoryRemove) { - if(!jerry_value_is_object(args_p[0])) { - return JS_THROW("inventoryRemove: Expected inventory pointer as first argument"); - } - - if(!jerry_value_is_number(args_p[1])) { - return JS_THROW("inventoryRemove: Expected item ID as second argument"); - } - - inventory_t *inventory = (inventory_t *)jsUnwrapPointer(args_p[0]); - itemid_t item = (itemid_t)jerry_value_as_number(args_p[1]); - assertNotNull(inventory, "Inventory pointer cannot be NULL."); - - if(args_count >= 3) { - if(!jerry_value_is_number(args_p[2])) { - return JS_THROW("inventoryRemove: Expected quantity as third argument"); - } - uint8_t amount = (uint8_t)jerry_value_as_number(args_p[2]); - uint8_t currentQuantity = inventoryGetCount(inventory, item); - if(amount >= currentQuantity) { - inventoryRemove(inventory, item); - return jerry_undefined(); - } - inventorySet(inventory, item, currentQuantity - amount); - return jerry_undefined(); - } - - inventoryRemove(inventory, item); - return jerry_undefined(); -} - -JS_FUNC(moduleInventoryGetCount) { - if(!jerry_value_is_object(args_p[0])) { - return JS_THROW("inventoryGetCount: Expected inventory pointer as first argument"); - } - - if(!jerry_value_is_number(args_p[1])) { - return JS_THROW("inventoryGetCount: Expected item ID as second argument"); - } - - inventory_t *inventory = (inventory_t *)jsUnwrapPointer(args_p[0]); - itemid_t item = (itemid_t)jerry_value_as_number(args_p[1]); - - assertNotNull(inventory, "Inventory pointer cannot be NULL."); - - uint8_t count = inventoryGetCount(inventory, item); - return jerry_number(count); -} - -JS_FUNC(moduleInventoryIsFull) { - if(!jerry_value_is_object(args_p[0])) { - return JS_THROW("inventoryIsFull: Expected inventory pointer as first argument"); - } - - inventory_t *inventory = (inventory_t *)jsUnwrapPointer(args_p[0]); - - assertNotNull(inventory, "Inventory pointer cannot be NULL."); - - bool_t isFull = inventoryIsFull(inventory); - return jerry_boolean(isFull); -} - -JS_FUNC(moduleInventoryItemFull) { - if(!jerry_value_is_object(args_p[0])) { - return JS_THROW("inventoryItemFull: Expected inventory pointer as first argument"); - } - - if(!jerry_value_is_number(args_p[1])) { - return JS_THROW("inventoryItemFull: Expected item ID as second argument"); - } - - inventory_t *inventory = (inventory_t *)jsUnwrapPointer(args_p[0]); - itemid_t item = (itemid_t)jerry_value_as_number(args_p[1]); - - assertNotNull(inventory, "Inventory pointer cannot be NULL."); - - bool_t isFull = inventoryItemFull(inventory, item); - return jerry_boolean(isFull); -} - -JS_FUNC(moduleInventorySort) { - if(!jerry_value_is_object(args_p[0])) { - return JS_THROW("inventorySort: Expected inventory pointer as first argument"); - } - - if(!jerry_value_is_number(args_p[1])) { - return JS_THROW("inventorySort: Expected sort type as second argument"); - } - - bool_t reverse = false; - if(args_count >= 3) { - if(!jerry_value_is_boolean(args_p[2])) { - return JS_THROW("inventorySort: Expected reverse flag as third argument"); - } - reverse = (bool_t)jerry_value_is_true(args_p[2]); - } - - inventory_t *inventory = (inventory_t *)jsUnwrapPointer(args_p[0]); - inventorysort_t sortBy = (inventorysort_t)jerry_value_as_number(args_p[1]); - - assertNotNull(inventory, "Inventory pointer cannot be NULL."); - inventorySort(inventory, sortBy, reverse); - return jerry_undefined(); -} - -static void moduleItem(void) { - moduleBaseEval(ITEM_SCRIPT); - - jerry_value_t backpack = jsWrapPointer(&BACKPACK); - jsSetValue("BACKPACK", backpack); - jerry_value_free(backpack); - - jsRegister("inventoryItemExists", moduleInventoryItemExists); - jsRegister("inventoryAdd", moduleInventoryAdd); - jsRegister("inventorySet", moduleInventorySet); - jsRegister("inventoryRemove", moduleInventoryRemove); - jsRegister("inventoryGetCount", moduleInventoryGetCount); - jsRegister("inventoryIsFull", moduleInventoryIsFull); - jsRegister("inventoryItemFull", moduleInventoryItemFull); - jsRegister("inventorySort", moduleInventorySort); -} diff --git a/src/duskrpg/script/module/story/CMakeLists.txt b/src/duskrpg/script/module/story/CMakeLists.txt deleted file mode 100644 index 84f36e34..00000000 --- a/src/duskrpg/script/module/story/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -# Copyright (c) 2026 Dominic Masters -# -# This software is released under the MIT License. -# https://opensource.org/licenses/MIT - diff --git a/src/duskrpg/script/module/story/modulestoryflag.h b/src/duskrpg/script/module/story/modulestoryflag.h deleted file mode 100644 index 3dbefcac..00000000 --- a/src/duskrpg/script/module/story/modulestoryflag.h +++ /dev/null @@ -1,63 +0,0 @@ -/** - * Copyright (c) 2025 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#pragma once -#include "script/module/modulebase.h" -#include "assert/assert.h" -#include "story/storyflag.h" - -JS_FUNC(moduleStoryFlagGet) { - JS_REQUIRE_ARGS(1); - JS_REQUIRE_NUMBER(0); - storyflag_t flag = (storyflag_t)jerry_value_as_number(args_p[0]); - if(flag <= STORY_FLAG_NULL || flag >= STORY_FLAG_COUNT) { - return JS_THROW("storyFlagGet: invalid flag ID"); - } - return jerry_number((double)storyFlagGet(flag)); -} - -JS_FUNC(moduleStoryFlagSet) { - JS_REQUIRE_ARGS(2); - JS_REQUIRE_NUMBER(0); - JS_REQUIRE_NUMBER(1); - storyflag_t flag = (storyflag_t)jerry_value_as_number(args_p[0]); - if(flag <= STORY_FLAG_NULL || flag >= STORY_FLAG_COUNT) { - return JS_THROW("storyFlagSet: invalid flag ID"); - } - storyflagvalue_t value = (storyflagvalue_t)jerry_value_as_number(args_p[1]); - storyFlagSet(flag, value); - return jerry_undefined(); -} - -JS_FUNC(moduleStoryFlagIncrement) { - JS_REQUIRE_ARGS(1); - JS_REQUIRE_NUMBER(0); - storyflag_t flag = (storyflag_t)jerry_value_as_number(args_p[0]); - if(flag <= STORY_FLAG_NULL || flag >= STORY_FLAG_COUNT) { - return JS_THROW("storyFlagIncrement: invalid flag ID"); - } - storyFlagSet(flag, storyFlagGet(flag) + 1); - return jerry_undefined(); -} - -JS_FUNC(moduleStoryFlagDecrement) { - JS_REQUIRE_ARGS(1); - JS_REQUIRE_NUMBER(0); - storyflag_t flag = (storyflag_t)jerry_value_as_number(args_p[0]); - if(flag <= STORY_FLAG_NULL || flag >= STORY_FLAG_COUNT) { - return JS_THROW("storyFlagDecrement: invalid flag ID"); - } - storyFlagSet(flag, storyFlagGet(flag) - 1); - return jerry_undefined(); -} - -static void moduleStoryFlag(void) { - jsRegister("storyFlagGet", moduleStoryFlagGet); - jsRegister("storyFlagSet", moduleStoryFlagSet); - jsRegister("storyFlagIncrement", moduleStoryFlagIncrement); - jsRegister("storyFlagDecrement", moduleStoryFlagDecrement); -} diff --git a/src/duskrpg/script/scriptgame.h b/src/duskrpg/script/scriptgame.h deleted file mode 100644 index 16094648..00000000 --- a/src/duskrpg/script/scriptgame.h +++ /dev/null @@ -1,14 +0,0 @@ -/** - * Copyright (c) 2026 Dominic Masters - * - * This software is released under the MIT License. - * https://opensource.org/licenses/MIT - */ - -#pragma once -#include "script/module/item/moduleitem.h" -#include "script/module/story/modulestoryflag.h" - -#define SCRIPT_GAME_INIT(L) \ - moduleItem(L); \ - moduleStoryFlag(L); \ No newline at end of file diff --git a/src/dusksdl2/display/displaysdl2.c b/src/dusksdl2/display/displaysdl2.c index e5d4586a..5eccdf42 100644 --- a/src/dusksdl2/display/displaysdl2.c +++ b/src/dusksdl2/display/displaysdl2.c @@ -23,9 +23,10 @@ errorret_t displaySDL2Init(void) { SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); #ifdef DUSK_OPENGL_LEGACY - // SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_COMPATIBILITY); #else - SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE); + SDL_GL_SetAttribute( + SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE + ); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3); SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3); #endif diff --git a/tools/editor/texture-padder/index.html b/tools/editor/texture-padder/index.html index aa9e7f33..ae4357ec 100644 --- a/tools/editor/texture-padder/index.html +++ b/tools/editor/texture-padder/index.html @@ -91,10 +91,10 @@ diff --git a/tools/editor/texture/index.html b/tools/editor/texture/index.html index 32b6e051..edf52130 100644 --- a/tools/editor/texture/index.html +++ b/tools/editor/texture/index.html @@ -85,10 +85,10 @@