Remove the C-authoring shorthand for declaring cutscenes
CUTSCENE(...)/CUTSCENE_REFERENCE/CUTSCENE_CUTSCENE/CUTSCENE_INSERT existed to build a cutscene_t and its item array directly in C; real cutscenes are now authored exclusively as .jsonc files parsed via cutsceneParseDoc, so these are dead weight in production. Deletes the demo scene that still used them (testcutscene.h, wired to NPC #3) along with its now-dead include in npc.c. test_cutscenesystem.c - the only other user, building cutscenes in-memory for tests - now writes the equivalent struct literals directly, matching the convention already used by test_battle.c/test_entityinteract.c. Co-Authored-By: Claude Sonnet 5 <[email protected]>
This commit is contained in:
@@ -15,64 +15,6 @@ typedef struct cutscene_s {
|
||||
cutscenepause_t pause;
|
||||
} cutscene_t;
|
||||
|
||||
/**
|
||||
* Declares a standalone, named cutscene_t (and its backing item array) -
|
||||
* the entry point for a C-authored cutscene.
|
||||
*
|
||||
* @param NAME Suffix for the generated CUTSCENE_##NAME cutscene/items
|
||||
* statics.
|
||||
* @param PAUSE_TYPE Suffix of the CUTSCENE_PAUSE_* flag(s) to apply
|
||||
* while this cutscene runs (e.g. NONE, ALL).
|
||||
* @param ... The cutscene's cutsceneitem_t entries, in order.
|
||||
*/
|
||||
#define CUTSCENE(NAME, PAUSE_TYPE, ...) \
|
||||
static const cutsceneitem_t CUTSCENE_##NAME##_ITEMS[] = { __VA_ARGS__ }; \
|
||||
static const cutscene_t CUTSCENE_##NAME = { \
|
||||
.items = CUTSCENE_##NAME##_ITEMS, \
|
||||
.itemCount = sizeof(CUTSCENE_##NAME##_ITEMS) / sizeof(cutsceneitem_t), \
|
||||
.pause = CUTSCENE_PAUSE_##PAUSE_TYPE, \
|
||||
};
|
||||
|
||||
/**
|
||||
* References a CUTSCENE(NAME, ...)-declared cutscene by name.
|
||||
*
|
||||
* @param CUTSCENE The cutscene's NAME, as passed to CUTSCENE(...).
|
||||
*/
|
||||
#define CUTSCENE_REFERENCE(CUTSCENE) \
|
||||
&CUTSCENE_##CUTSCENE
|
||||
|
||||
/**
|
||||
* Hands control over to another CUTSCENE(NAME, ...)-declared cutscene.
|
||||
* Has no dedicated item header of its own - cutscenecutsceneref_t is
|
||||
* defined inline in cutsceneitem.h, tightly bound to the asset/loader
|
||||
* system, so this shorthand stays here too.
|
||||
*
|
||||
* @param CUTSCENE The referenced cutscene's NAME, as passed to
|
||||
* CUTSCENE(...).
|
||||
*/
|
||||
#define CUTSCENE_CUTSCENE(CUTSCENE) \
|
||||
{ \
|
||||
.type = CUTSCENE_ITEM_TYPE_CUTSCENE, \
|
||||
.cutsceneRef = { .cutscene = CUTSCENE_REFERENCE(CUTSCENE), .name = NULL } \
|
||||
}
|
||||
|
||||
/**
|
||||
* Splices another CUTSCENE(NAME, ...)-declared cutscene's items into this
|
||||
* one in place, resuming right after this item once the referenced
|
||||
* cutscene's items run out - unlike CUTSCENE_CUTSCENE (a one-way jump that
|
||||
* never returns). Has no dedicated item header of its own, same rationale
|
||||
* as CUTSCENE_CUTSCENE - cutsceneInsertStart/Update/Load are defined
|
||||
* inline in cutsceneitem.h/.c, tightly bound to the asset/loader system.
|
||||
*
|
||||
* @param CUTSCENE The referenced cutscene's NAME, as passed to
|
||||
* CUTSCENE(...).
|
||||
*/
|
||||
#define CUTSCENE_INSERT(CUTSCENE) \
|
||||
{ \
|
||||
.type = CUTSCENE_ITEM_TYPE_INSERT, \
|
||||
.insert = { .cutscene = CUTSCENE_REFERENCE(CUTSCENE), .name = NULL } \
|
||||
}
|
||||
|
||||
/**
|
||||
* Parses one cutscene item object into item. Every field/enum name is
|
||||
* validated as real (untrusted, authored) file content - failures are
|
||||
|
||||
@@ -34,9 +34,8 @@ typedef struct entity_s entity_t;
|
||||
// into this fixed, static buffer via cutsceneParseDoc (see cutscene.h),
|
||||
// once the raw JSON itself has been read+parsed via the generic
|
||||
// ASSET_LOADER_TYPE_JSON asset loader. Bump this if a real cutscene ever
|
||||
// needs more; C-authored cutscenes (the CUTSCENE(...) macro) don't use
|
||||
// this at all - they're compiled directly into their own static const
|
||||
// arrays.
|
||||
// needs more; C-authored cutscenes (used only by tests) don't use this
|
||||
// at all - they're compiled directly into their own static const arrays.
|
||||
#define CUTSCENE_LOADED_ITEMS_MAX 128
|
||||
|
||||
extern cutsceneitem_t CUTSCENE_LOADED_ITEMS[CUTSCENE_LOADED_ITEMS_MAX];
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2025 Dominic Masters
|
||||
*
|
||||
* This software is released under the MIT License.
|
||||
* https://opensource.org/licenses/MIT
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
#include "rpg/cutscene/cutscene.h"
|
||||
#include "rpg/cutscene/cutscenesystem.h"
|
||||
|
||||
CUTSCENE(TEST_ONE, DEFAULT,
|
||||
CUTSCENE_TEXT("Test One."),
|
||||
);
|
||||
|
||||
CUTSCENE(TEST_TWO, DEFAULT,
|
||||
CUTSCENE_TEXT("Test Two."),
|
||||
CUTSCENE_ENTITY_ADD(ENTITY_TYPE_NPC, 4, 4, 0),
|
||||
CUTSCENE_TEXT_MINI("Hello!", 4, 4, 0, 3.0f),
|
||||
CUTSCENE_EMOJI(
|
||||
CUTSCENE_ENTITY_LAST_CREATED, UI_EMOJI_EXCLAMATION_MARK, 2.0f
|
||||
),
|
||||
CUTSCENE_ENTITY_WALK_TO(CUTSCENE_ENTITY_LAST_CREATED, 8, 2, 0),
|
||||
// CUTSCENE_CONCURRENT(
|
||||
// CUTSCENE_ENTITY_WALK_TO(CUTSCENE_ENTITY_INTERACT, 4, 4, 0),
|
||||
// CUTSCENE_ENTITY_WALK_TO(CUTSCENE_ENTITY_INTERACTED, 8, 2, 0),
|
||||
// ),
|
||||
// CUTSCENE_ITEM_GIVE(ITEM_ID_POTATO, 3),
|
||||
// CUTSCENE_ENTITY_REMOVE(CUTSCENE_ENTITY_INTERACT),
|
||||
CUTSCENE_TEXT("Done."),
|
||||
);
|
||||
@@ -7,7 +7,6 @@
|
||||
|
||||
#pragma once
|
||||
#include "entityglobaldefs.h"
|
||||
#include "rpg/cutscene/scene/testcutscene.h"
|
||||
#include "rpg/cutscene/item/cutsceneitem.h"
|
||||
|
||||
ENTITY_GLOBAL_CALLBACK(3) {
|
||||
@@ -16,9 +15,6 @@ ENTITY_GLOBAL_CALLBACK(3) {
|
||||
npcPathAddNode(&create->entity->data.npc, (worldpos_t){ 10, 10, 1 });
|
||||
npcPathAddNode(&create->entity->data.npc, (worldpos_t){ 4, 4, 0 });
|
||||
npcPathAddNode(&create->entity->data.npc, (worldpos_t){ 10, 10, 1 });
|
||||
|
||||
create->entity->interact.type = ENTITY_INTERACT_CUTSCENE;
|
||||
create->entity->interact.data.cutscene = CUTSCENE_REFERENCE(TEST_TWO);
|
||||
}
|
||||
|
||||
ENTITY_GLOBAL_CALLBACK(4) {
|
||||
|
||||
@@ -29,10 +29,10 @@ typedef enum {
|
||||
* Per-type data for an entity's interact component.
|
||||
*/
|
||||
typedef union {
|
||||
// A compile-time cutscene_t* (e.g. CUTSCENE_REFERENCE(...)) - safe to
|
||||
// hold onto indefinitely, since C-authored cutscenes are compiled
|
||||
// directly into their own static const arrays, never the shared
|
||||
// CUTSCENE_LOADED_ITEMS buffer (see cutscenesystem.h).
|
||||
// A compile-time cutscene_t* (a C-authored, test-only cutscene) - safe
|
||||
// to hold onto indefinitely, since it's compiled directly into its own
|
||||
// static const arrays, never the shared CUTSCENE_LOADED_ITEMS buffer
|
||||
// (see cutscenesystem.h).
|
||||
const cutscene_t *cutscene;
|
||||
// A bare cutscene name (as passed to cutsceneCutsceneResolve), resolved
|
||||
// lazily at interact time rather than once up front - only one
|
||||
|
||||
@@ -9,8 +9,6 @@
|
||||
#include "assert/assert.h"
|
||||
#include "rpg/cutscene/cutscenesystem.h"
|
||||
|
||||
#include "rpg/cutscene/scene/testcutscene.h"
|
||||
|
||||
const npcmovecallback_t NPC_MOVE_CALLBACKS[NPC_MOVE_TYPE_COUNT] = {
|
||||
[NPC_MOVE_TYPE_NULL] = { 0 },
|
||||
|
||||
|
||||
Reference in New Issue
Block a user