Fixed a bunch of messy over 80 char lines
This commit is contained in:
+1
-1
@@ -1,6 +1,6 @@
|
||||
module = {
|
||||
render() {
|
||||
Text.draw(10, 10, "Hello World");
|
||||
Text.draw(0, 0, "Hello World");
|
||||
SpriteBatch.flush();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -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--;
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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,7 +29,7 @@ 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 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).
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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 };
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
)
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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
|
||||
);
|
||||
@@ -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;
|
||||
@@ -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;
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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];
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
|
||||
@@ -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]);
|
||||
|
||||
@@ -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));
|
||||
|
||||
@@ -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 };
|
||||
|
||||
@@ -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 };
|
||||
|
||||
@@ -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 };
|
||||
|
||||
@@ -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 };
|
||||
|
||||
@@ -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 };
|
||||
|
||||
@@ -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]);
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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]);
|
||||
|
||||
@@ -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]);
|
||||
|
||||
@@ -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]);
|
||||
|
||||
@@ -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];
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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)) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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';
|
||||
}
|
||||
|
||||
@@ -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
|
||||
*/
|
||||
|
||||
@@ -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
|
||||
);
|
||||
|
||||
@@ -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()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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)
|
||||
@@ -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)
|
||||
@@ -1,5 +0,0 @@
|
||||
# Copyright (c) 2026 Dominic Masters
|
||||
#
|
||||
# This software is released under the MIT License.
|
||||
# https://opensource.org/licenses/MIT
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
# Copyright (c) 2026 Dominic Masters
|
||||
#
|
||||
# This software is released under the MIT License.
|
||||
# https://opensource.org/licenses/MIT
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
@@ -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);
|
||||
@@ -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
|
||||
|
||||
@@ -91,10 +91,10 @@
|
||||
<section class="panel-section" id="info-section" hidden>
|
||||
<div class="section-label">Info</div>
|
||||
<table class="info-table">
|
||||
<tr><td>File</td><td id="info-filename">—</td></tr>
|
||||
<tr><td>Input</td><td id="info-input-size">—</td></tr>
|
||||
<tr><td>Output</td><td id="info-output-size">—</td></tr>
|
||||
<tr><td>DTF</td><td id="info-dtf-size">—</td></tr>
|
||||
<tr><td>File</td><td id="info-filename">N/A</td></tr>
|
||||
<tr><td>Input</td><td id="info-input-size">N/A</td></tr>
|
||||
<tr><td>Output</td><td id="info-output-size">N/A</td></tr>
|
||||
<tr><td>DTF</td><td id="info-dtf-size">N/A</td></tr>
|
||||
</table>
|
||||
</section>
|
||||
|
||||
|
||||
@@ -85,10 +85,10 @@
|
||||
<section class="panel-section" id="info-section" hidden>
|
||||
<div class="section-label">Info</div>
|
||||
<table class="info-table">
|
||||
<tr><td>File</td><td id="info-filename">—</td></tr>
|
||||
<tr><td>Size</td><td id="info-size">—</td></tr>
|
||||
<tr><td>Format</td><td id="info-format">—</td></tr>
|
||||
<tr><td>DTF</td><td id="info-dtf-size">—</td></tr>
|
||||
<tr><td>File</td><td id="info-filename">N/A</td></tr>
|
||||
<tr><td>Size</td><td id="info-size">N/A</td></tr>
|
||||
<tr><td>Format</td><td id="info-format">N/A</td></tr>
|
||||
<tr><td>DTF</td><td id="info-dtf-size">N/A</td></tr>
|
||||
</table>
|
||||
</section>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user