Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 9 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,15 @@ namespace segfault::renderer {
namespace segfault::application {
// application code
}

namespace segfault::ai {
// game ai code
}

namespace segfault::scene {
// scene code
}

```

### Import Style
Expand Down
22 changes: 22 additions & 0 deletions src/examples/hello_world/hello_world.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
/*-----------------------------------------------------------------------------------------------
The MIT License (MIT)

Copyright (c) 2015-2026 Segfault by Kim Kulling

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-----------------------------------------------------------------------------------------------*/
Comment on lines +1 to +22

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

Copyright notice in source files does not match the canonical LICENSE file.

The copyright notice should match what is specified in the LICENSE file as the copyright holder. This file (and all others with MIT headers) uses "Copyright (c) 2015-2026 Segfault by Kim Kulling", but the repository's LICENSE file specifies "Copyright (c) 2025 Kim Kulling".

These discrepancies create ambiguity about the correct copyright holder and years:

  • Year range: LICENSE says 2025; headers say 2015-2026
  • Attribution: LICENSE says "Kim Kulling"; headers say "Segfault by Kim Kulling"

The MIT license requires that "The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software", which means copyright notices must be consistent across the LICENSE file and source files for compliance.

This issue affects all 8 files receiving MIT headers in this PR. Update all headers to match the canonical LICENSE file: Copyright (c) 2025 Kim Kulling.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/examples/hello_world/hello_world.cpp` around lines 1 - 22, Update the
copyright notice line in the MIT license header comment to match the canonical
LICENSE file. Replace the line reading "Copyright (c) 2015-2026 Segfault by Kim
Kulling" with "Copyright (c) 2025 Kim Kulling". This change needs to be applied
to all 8 files that have MIT headers in this PR, including hello_world.cpp, to
ensure consistency and proper license compliance.

#include "core/segfault.h"
#include "application/app.h"

Expand Down
13 changes: 10 additions & 3 deletions src/runtime/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,23 @@ SET(segfault_renderer_src
renderer/vulkantypes.h
)

SET(segfault_ai_src
ai/behavior_tree.h
ai/behavior_tree.cpp
)

SET(segfault_application_src
application/app.h
application/app.cpp
)

SOURCE_GROUP(core FILES ${segfault_core_src} )
SOURCE_GROUP(application FILES ${segfault_application_src} )
SOURCE_GROUP(renderer FILES ${segfault_renderer_src} )
source_group(ai FILES ${segfault_ai_src} )
source_group(core FILES ${segfault_core_src} )
source_group(application FILES ${segfault_application_src} )
source_group(renderer FILES ${segfault_renderer_src} )

ADD_LIBRARY(segfault_runtime SHARED
${segfault_ai_src}
${segfault_core_src}
${segfault_renderer_src}
${segfault_application_src}
Expand Down
69 changes: 69 additions & 0 deletions src/runtime/ai/behavior_tree.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*-----------------------------------------------------------------------------------------------
The MIT License (MIT)

Copyright (c) 2015-2026 Segfault by Kim Kulling

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-----------------------------------------------------------------------------------------------*/
#include "behavior_tree.h"
#include "core/filearchive.h"

#include <nlohmann/json.hpp>

using json = ::nlohmann::json;

namespace segfault::ai {

using namespace segfault::core;

BehaviorTree::BehaviorTree() {

Check failure on line 34 in src/runtime/ai/behavior_tree.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use "=default" instead of the default implementation of this special member functions.

See more on https://sonarcloud.io/project/issues?id=kimkulling_Segfault&issues=AZ72Al5NY1I2F-bSCi7T&open=AZ72Al5NY1I2F-bSCi7T&pullRequest=13
// Constructor implementation (if needed)
}

BehaviorTree::~BehaviorTree() {

Check failure on line 38 in src/runtime/ai/behavior_tree.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Use "=default" instead of the default implementation of this special member functions.

See more on https://sonarcloud.io/project/issues?id=kimkulling_Segfault&issues=AZ72Al5NY1I2F-bSCi7U&open=AZ72Al5NY1I2F-bSCi7U&pullRequest=13
// Destructor implementation (if needed)
}

bool BehaviorTree::init(const char* configFile) {

Check warning on line 42 in src/runtime/ai/behavior_tree.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

This function should be declared "const".

See more on https://sonarcloud.io/project/issues?id=kimkulling_Segfault&issues=AZ72Al5NY1I2F-bSCi7V&open=AZ72Al5NY1I2F-bSCi7V&pullRequest=13
if (configFile == nullptr) {
return false;
}

FileArchive archive(configFile, "r", true, false);
if (!archive.isValid()) {
return false;
}

// Read the entire file into a string
size_t size = archive.getSize();
std::string content(size, '\0');
archive.read(reinterpret_cast<uint8_t*>(&content[0]), size);
json Doc{ json::parse(content) };

Comment thread
kimkulling marked this conversation as resolved.
return true;
}

void BehaviorTree::update() {
if (mRootNode == nullptr) {
return;
}

mRootNode->tick();
}
Comment thread
kimkulling marked this conversation as resolved.

} // namespace segfault::ai
119 changes: 119 additions & 0 deletions src/runtime/ai/behavior_tree.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
/*-----------------------------------------------------------------------------------------------
The MIT License (MIT)

Copyright (c) 2015-2026 Segfault by Kim Kulling

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-----------------------------------------------------------------------------------------------*/
#pragma once

#include "core/segfault.h"

namespace segfault::ai {
Comment thread
kimkulling marked this conversation as resolved.
enum class NodeStatus {
IDLE = 0,
RUNNING = 1,
SUCCESS = 2,
FAILURE = 3,
SKIPPED = 4,
};

//---------------------------------------------------------------------------------------------
/// @class BehaviorTreeNode
/// @brief The BehaviorTreeNode class represents a single node in a behavior tree, which is a
/// hierarchical structure used to model the decision-making process of an AI agent. Each node
/// can represent an action, condition, or control flow, allowing for complex behaviors to be
/// defined in a modular and reusable way.
//---------------------------------------------------------------------------------------------
class BehaviorTreeNode {
public:
// No copying
BehaviorTreeNode(const BehaviorTreeNode& rhs) = delete;
BehaviorTreeNode& operator = (const BehaviorTreeNode& rhs) = delete;

BehaviorTreeNode() = default;
virtual ~BehaviorTreeNode() = default;

/// @brief Pure virtual function to be implemented by derived classes
virtual NodeStatus tick() = 0;
};

class LeafNode : public BehaviorTreeNode {
public:
NodeStatus tick() override {
// Implementation of the leaf node's behavior
return NodeStatus::IDLE;
}
};

class SequenceNode : public BehaviorTreeNode {
public:
NodeStatus tick() override {
// Implementation of the sequence node's behavior
return NodeStatus::IDLE;
}
};

class ConditionNode : public LeafNode {
public:
NodeStatus tick() override {
// Implementation of the condition node's behavior
return NodeStatus::IDLE;
}
};

class ActionNode : public LeafNode {
public:
NodeStatus tick() override {
// Implementation of the action node's behavior
return NodeStatus::IDLE;
}
};

//---------------------------------------------------------------------------------------------
/// @class BehaviorTree
/// @brief The BehaviorTree class represents a behavior tree, which is a hierarchical structure
/// used to model the decision-making process of an AI agent. It consists of nodes that
/// represent actions, conditions, and control flow, allowing for complex behaviors to be
/// defined in a modular and reusable way.
//---------------------------------------------------------------------------------------------
class SEGFAULT_EXPORT BehaviorTree final {
public:
// No copying
BehaviorTree(const BehaviorTree& rhs) = delete;
BehaviorTree& operator = (const BehaviorTree& rhs) = delete;

/// @brief The class constructor.
BehaviorTree();

/// @brief The class destructor.
~BehaviorTree();

/// @brief Initializes the behavior tree with the specified parameters.
/// @param[ in ] configFile The path to the configuration file that defines the behavior tree structure.
/// @return True if initialization was successful, false otherwise.
bool init(const char* configFile);

/// @brief Updates the behavior tree, processing the nodes and executing actions as needed.
void update();

private:
BehaviorTreeNode* mRootNode{ nullptr };
};

} // namespace segfault::ai
22 changes: 22 additions & 0 deletions src/runtime/application/app.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
/*-----------------------------------------------------------------------------------------------
The MIT License (MIT)

Copyright (c) 2015-2026 Segfault by Kim Kulling

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-----------------------------------------------------------------------------------------------*/
#include "application/app.h"
#include "core/segfault.h"
#include <SDL.h>
Expand Down
22 changes: 22 additions & 0 deletions src/runtime/application/app.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
/*-----------------------------------------------------------------------------------------------
The MIT License (MIT)

Copyright (c) 2015-2026 Segfault by Kim Kulling

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-----------------------------------------------------------------------------------------------*/
#pragma once

#include "core/segfault.h"
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/core/argumentparser.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*-----------------------------------------------------------------------------------------------
The MIT License (MIT)

Copyright (c) 2015-2025 OSRE ( Open Source Render Engine ) by Kim Kulling
Copyright (c) 2015-2026 Segfault by Kim Kulling

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/core/argumentparser.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*-----------------------------------------------------------------------------------------------
The MIT License (MIT)

Copyright (c) 2015-2025 OSRE ( Open Source Render Engine ) by Kim Kulling
Copyright (c) 2015-2026 Segfault by Kim Kulling

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
Expand Down
Loading
Loading