Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
f791b36
Small config changes to build without STL and Unreal
willvale Nov 7, 2025
8645d01
Fix optional::emplace(), which wasn't marking the newly-constructed
willvale Nov 8, 2025
00509f5
Verify sized types
willvale Nov 10, 2025
5ee26cd
Merge branch 'JBenda:master' into master
willvale Nov 10, 2025
65fdeba
Merge pull request #1 from willvale/master
willvale Nov 14, 2025
fce4b1e
Structural optimisations
willvale Nov 15, 2025
9359507
Closer to working, added original jump back for comparisons.
willvale Nov 15, 2025
45471cf
Optimise/fix jump to visit all nested knots when we change path.
willvale Nov 16, 2025
7ce4729
Use ~0 to delimit containers.
willvale Nov 17, 2025
461a652
Use explicit types in compiled data
willvale Nov 17, 2025
2f2c308
Write container data during compilation.
willvale Nov 18, 2025
7baa748
Move read_list_flag out of header and make header private to story.
willvale Nov 18, 2025
6a44a0a
Allow manual workflow dispatch.
willvale Nov 19, 2025
3958835
Allow manual dispatch of build workflow.
willvale Nov 19, 2025
b4f47e0
Fix traits for ubuntu?
willvale Nov 19, 2025
4c56a70
Fix definitions for line_type-based APIs.
willvale Nov 19, 2025
23ffa04
For real this time
willvale Nov 19, 2025
b2ea4e1
Merge branch 'master' into optimisation
willvale Nov 19, 2025
30e05b6
Fix warning - store command flags as integral.
willvale Nov 19, 2025
4d926c6
Remove profiling code.
willvale Nov 19, 2025
4f33a1e
Fix non-deref of empty container.
willvale Nov 19, 2025
3bf0ca0
inkcpp_test fixes
willvale Nov 20, 2025
eb68bad
Fix remaining unit test
willvale Nov 20, 2025
afe3e1e
Fix UTF-8 test
willvale Nov 21, 2025
88dc8d0
Rework jump slightly and fix tests.
willvale Nov 21, 2025
5f3a179
Fix restrictive numeric casts/assignments.
willvale Nov 21, 2025
adefe3e
Clangformat fixes.
willvale Nov 21, 2025
97e7f4b
Merge branch 'JBenda:master' into master
willvale Nov 21, 2025
48bac0f
Fix knot visit counts
willvale Nov 21, 2025
01a04c2
Merge branch 'fix-casts' into optimisation
willvale Nov 22, 2025
3f7f6f2
build(Options) Add NO_EH and NO_RTTI as cmake options.
JBenda Nov 28, 2025
7106179
Fix a variety of cast problems
willvale Dec 14, 2025
c180251
Merge branch 'JBenda:master' into fix-casts
willvale Dec 14, 2025
be2b6f7
Clangformat fixes
willvale Dec 14, 2025
918ebc3
Merge latest from fix_casts (and implicitly upstream)
willvale Dec 14, 2025
75c247a
Merge branch 'master' of https://github.com/willvale/inkcpp
willvale Dec 18, 2025
c540ff7
Merge branch 'JBenda:master' into master
willvale Dec 19, 2025
ecb7077
Merge branch 'master' into optimisation
willvale Dec 20, 2025
e1ca8ba
Emit list metadata in separate section and remove duplicate parsing.
willvale Dec 21, 2025
9d653ae
Don't keep trying to terminate a stream which failed.
willvale Dec 23, 2025
31885d4
Run Clangformat on affected files.
willvale Dec 23, 2025
46569c3
Missed one.
willvale Dec 23, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 27 additions & 33 deletions inkcpp/container_operations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,40 +13,34 @@

#include <iostream>

namespace ink::runtime::internal {
namespace ink::runtime::internal
{

void operation<Command::READ_COUNT_VAR, value_type::divert, void>::operator()(
basic_eval_stack& stack, value* vals)
{
container_t id;
bool success = _story.get_container_id(
_story.instructions() + vals[0].get<value_type::divert>(),
id);
inkAssert(success, "failed to find container to read visit count!");
stack.push(value{}.set<value_type::int32>(
static_cast<int32_t>(_visit_counts.visits( id )
)));
}

void operation<Command::TURNS, value_type::divert, void>::operator()(
basic_eval_stack& stack, value* vals)
{
container_t id;
bool success = _story.get_container_id(
_story.instructions() + vals[0].get<value_type::divert>(),
id);
inkAssert(success, "failed to find container to read turn count!");
stack.push(value{}.set<value_type::int32>(
static_cast<int32_t>(_visit_counts.turns(id)
)));
}
void operation<Command::READ_COUNT_VAR, value_type::divert, void>::operator()(
basic_eval_stack& stack, value* vals
)
{
container_t id;
bool success = _story.find_container_id(vals[0].get<value_type::divert>(), id);
inkAssert(success, "failed to find container to read visit count!");
stack.push(value{}.set<value_type::int32>(static_cast<int32_t>(_visit_counts.visits(id))));
}

void operation<Command::CHOICE_COUNT, value_type::none, void>::operator()
(basic_eval_stack& stack, value* vals)
{
stack.push(value{}.set<value_type::int32>(static_cast<int32_t>(
_runner.num_choices()
)));
}
void operation<Command::TURNS, value_type::divert, void>::operator()(
basic_eval_stack& stack, value* vals
)
{
container_t id;
bool success = _story.find_container_id(vals[0].get<value_type::divert>(), id);
inkAssert(success, "failed to find container to read turn count!");
stack.push(value{}.set<value_type::int32>(static_cast<int32_t>(_visit_counts.turns(id))));
}

void operation<Command::CHOICE_COUNT, value_type::none, void>::operator()(
basic_eval_stack& stack, value* vals
)
{
stack.push(value{}.set<value_type::int32>(static_cast<int32_t>(_runner.num_choices())));
}

} // namespace ink::runtime::internal
11 changes: 4 additions & 7 deletions inkcpp/globals_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ globals_impl::globals_impl(const story_impl* story)
, _visit_counts_backup()
, _owner(story)
, _runners_start(nullptr)
, _lists(story->list_meta(), story->get_header())
, _lists(story->list_meta())
, _globals_initialized(false)
{
_visit_counts.resize(_num_containers);
Expand All @@ -46,13 +46,10 @@ globals_impl::globals_impl(const story_impl* story)
}
}

void globals_impl::visit(uint32_t container_id, bool entering_at_start)
void globals_impl::visit(uint32_t container_id)
{
if ((! (_owner->container_flag(container_id) & CommandFlag::CONTAINER_MARKER_ONLY_FIRST))
|| entering_at_start) {
_visit_counts[container_id].visits += 1;
_visit_counts[container_id].turns = 0;
}
_visit_counts[container_id].visits += 1;
_visit_counts[container_id].turns = 0;
}

uint32_t globals_impl::visits(uint32_t container_id) const
Expand Down
3 changes: 1 addition & 2 deletions inkcpp/globals_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ class globals_impl final

public:
// Records a visit to a container
/// @param start_cmd iff the visit was initiatet through a MARKER_START_CONTAINER
void visit(uint32_t container_id, bool entering_at_start);
void visit(uint32_t container_id);

// Checks the number of visits to a container
uint32_t visits(uint32_t container_id) const;
Expand Down
49 changes: 19 additions & 30 deletions inkcpp/header.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,38 +7,27 @@
#include "header.h"
#include "version.h"

namespace ink::internal {
namespace ink::internal
{

header header::parse_header(const char *data)
{
header res;
const char* ptr = data;
res.endien = *reinterpret_cast<const header::endian_types*>(ptr);
ptr += sizeof(header::endian_types);

using v_t = decltype(header::ink_version_number);
using vcpp_t = decltype(header::ink_bin_version_number);

if (res.endien == header::endian_types::same) {
res.ink_version_number =
*reinterpret_cast<const v_t*>(ptr);
ptr += sizeof(v_t);
res.ink_bin_version_number =
*reinterpret_cast<const vcpp_t*>(ptr);
bool header::verify() const
{
if (endian() == endian_types::none) {
inkFail("Header magic number was wrong!");
return false;
}

} else if (res.endien == header::endian_types::differ) {
res.ink_version_number =
swap_bytes(*reinterpret_cast<const v_t*>(ptr));
ptr += sizeof(v_t);
res.ink_bin_version_number =
swap_bytes(*reinterpret_cast<const vcpp_t*>(ptr));
} else {
inkFail("Failed to parse endian encoding!");
}
if (endian() == endian_types::differ) {
inkFail("Can't load content with different endian-ness!");
return false;
}

if (res.ink_bin_version_number != InkBinVersion) {
inkFail("InkCpp-version mismatch: file was compiled with different InkCpp-version!");
}
return res;
if (ink_bin_version_number != InkBinVersion) {
inkFail("InkCpp-version mismatch: file was compiled with different InkCpp-version!");
return false;
}

return true;
}

} // namespace ink::internal
4 changes: 2 additions & 2 deletions inkcpp/list_table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ void list_table::copy_lists(const data_t* src, data_t* dst)
}
}

list_table::list_table(const char* data, const ink::internal::header& header)
list_table::list_table(const char* data)
: _valid{false}
{
if (data == nullptr) {
Expand All @@ -41,7 +41,7 @@ list_table::list_table(const char* data, const ink::internal::header& header)
list_flag flag;
const char* ptr = data;
int start = 0;
while ((flag = header.read_list_flag(ptr)) != null_flag) {
while ((flag = read_list_flag(ptr)) != null_flag) {
// start of new list
if (_list_end.size() == flag.list_id) {
start = _list_end.size() == 0 ? 0 : _list_end.back();
Expand Down
2 changes: 1 addition & 1 deletion inkcpp/list_table.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class list_table : public snapshot_interface
list& add_inplace(list& lh, list_flag rh);

// parse binary list meta data
list_table(const char* data, const ink::internal::header&);
list_table(const char* data);

explicit list_table()
: _entrySize{0}
Expand Down
Loading
Loading