idk
Some checks failed
Build Dusk / run-tests (push) Successful in 1m57s
Build Dusk / build-linux (push) Successful in 2m9s
Build Dusk / build-psp (push) Failing after 1m39s

This commit is contained in:
2026-01-26 22:54:05 -06:00
parent d1b03c4cb3
commit 81b08b2eba
19 changed files with 179 additions and 276 deletions

View File

@@ -9,14 +9,14 @@
#include "assert/assert.h"
#include "util/string.h"
inputaction_t inputActionGetByName(const char_t *name) {
assertNotNull(name, "name must not be NULL");
// inputaction_t inputActionGetByName(const char_t *name) {
// assertNotNull(name, "name must not be NULL");
for(inputaction_t i = 0; i < INPUT_ACTION_COUNT; i++) {
if(INPUT_ACTION_NAMES[i] == NULL) continue;
if(stringCompareInsensitive(INPUT_ACTION_NAMES[i], name) != 0) continue;
return i;
}
// for(inputaction_t i = 0; i < INPUT_ACTION_COUNT; i++) {
// if(INPUT_ACTION_IDS[i] == NULL) continue;
// if(stringCompareInsensitive(INPUT_ACTION_IDS[i], name) != 0) continue;
// return i;
// }
return INPUT_ACTION_COUNT;
}
// return INPUT_ACTION_COUNT;
// }

View File

@@ -12,7 +12,7 @@
#error "Input CSV has not been generated. Run dusk_input_csv in CMake."
#endif
#include "input/inputactiontype.h"
#include "input/inputactionname.h"
// #include "input/inputactionname.h"
typedef struct {
inputaction_t action;
@@ -31,4 +31,4 @@ typedef struct {
* @param name The name of the input action.
* @return The input action, or INPUT_ACTION_COUNT if not found.
*/
inputaction_t inputActionGetByName(const char_t *name);
// inputaction_t inputActionGetByName(const char_t *name);

View File

@@ -6,7 +6,6 @@
# Sources
target_sources(${DUSK_LIBRARY_TARGET_NAME}
PUBLIC
item.c
inventory.c
backpack.c
)

View File

@@ -6,7 +6,7 @@
*/
#pragma once
#include "item.h"
#include "item/item.h"
#define ITEM_STACK_QUANTITY_MAX UINT8_MAX

View File

@@ -1,29 +0,0 @@
/**
* Copyright (c) 2026 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#include "item.h"
const item_t ITEMS[] = {
[ITEM_ID_NULL] = {
.type = ITEM_TYPE_NULL
},
// Potion
[ITEM_ID_POTION] = {
.type = ITEM_TYPE_MEDICINE
},
// Potato
[ITEM_ID_POTATO] = {
.type = ITEM_TYPE_FOOD
},
// Apple
[ITEM_ID_APPLE] = {
.type = ITEM_TYPE_FOOD
}
};

View File

@@ -1,24 +0,0 @@
/**
* Copyright (c) 2026 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#pragma once
#ifndef ITEM_CSV_GENERATED
#error "Item CSV has not been generated. Ensure dusk_item_csv is run in CMake."
#endif
#include "item/itemtype.h"
#include "item/itemid.h"
#include "item/itemname.h"
// test.
typedef struct {
const char_t *name;
const itemtype_t type;
} item_t;
extern const item_t ITEMS[];

View File

@@ -50,9 +50,9 @@ void moduleInput(scriptcontext_t *context) {
// Set input information
for(inputaction_t act = INPUT_ACTION_NULL + 1; act < INPUT_ACTION_COUNT; act++) {
const char_t *actName = INPUT_ACTION_NAMES[act];
assertStrLenMax(actName, 64, "Input action name too long for buffer");
snprintf(buffer, sizeof(buffer), "INPUT_ACTION_%s = %d\n", actName, act);
const char_t *actId = INPUT_ACTION_IDS[act];
assertStrLenMax(actId, 64, "Input action name too long for buffer");
snprintf(buffer, sizeof(buffer), "INPUT_ACTION_%s = %d\n", actId, act);
scriptContextExec(context, buffer);
}

View File

@@ -243,7 +243,7 @@ void moduleItem(scriptcontext_t *context) {
// Set item information
for(itemid_t itemId = ITEM_ID_NULL + 1; itemId < ITEM_ID_COUNT; itemId++) {
const char_t *itemName = ITEM_NAMES[itemId];
const char_t *itemName = ITEMS[itemId].name;
assertStrLenMax(itemName, 64, "Item name too long for buffer");
snprintf(buffer, sizeof(buffer), "ITEM_ID_%s = %d\n", itemName, itemId);
scriptContextExec(context, buffer);