Remove Automake cruft and stop game from crashing on start.

Close #149. Close #146
This commit is contained in:
S David 2023-12-06 19:08:14 -05:00
parent 802372fb4a
commit 2936790fd9
33 changed files with 163 additions and 3450 deletions

4
.gitmodules vendored
View File

@ -1,6 +1,2 @@
[submodule "third_party/FakeIt"]
path = third_party/FakeIt
url = https://github.com/eranpeer/FakeIt.git
shallow = true
[submodule "third_party/Catch2"]
shallow = true

View File

@ -37,7 +37,7 @@ project(ElementalEngine
)
IF(NOT CMAKE_BUILD_TYPE)
SET( CMAKE_BUILD_TYPE Debug ... FORCE )
SET( CMAKE_BUILD_TYPE Debug )
ENDIF()
set(CMAKE_CXX_STANDARD 20)

View File

@ -1,60 +0,0 @@
srcdir = @srcdir@
VPATH = @srcdir@
ACLOCAL_AMFLAGS=-I m4
# Variable declarations to be reused and appended with targets
bin_PROGRAMS=
check_PROGRAMS=
noinst_LIBRARIES=
noinst_LTLIBRARIES=
pkglib_LTLIBRARIES=
include_HEADERS=
TESTS=
EXTRA_LIBRARIES=
phony_targets=
warning_flags=
disabled_warnings=
qt5_extra_cxxflags=-fPIC -DPIC
warning_flags+=-Werror -Wall
if HAVE_BUILD_SERVER
disabled_warnings+=-Wno-c++20-extensions
else
warning_flags+=-pedantic
endif
project_include_flags=
project_include_flags+=-I ${srcdir}/src
project_include_flags+=-I ${srcdir}/third_party/cereal/include
project_include_flags+=-I ${srcdir}/third_party/nlohmann_json/include/nlohmann
AM_CFLAGS= ${CFLAGS}
AM_CXXFLAGS= ${CXXFLAGS}
AM_CPPFLAGS= -std=c++20
AM_CFLAGS+=${warning_flags}
AM_CXXFLAGS+= ${warning_flags} ${disabled_warnings}
AM_CPPFLAGS+=$(project_include_flags)
AM_LDFLAGS=
rebuild-qtforms:
$(abs_top_srcdir)/rebuild-qtforms.sh
run: ${bin_PROGRAMS}
@./quartz-warriors
all-am: @top_builddir@/res
#if DEBUG_BUILD
#AM_CXXFLAGS += -ggdb -Og
#endif
include src/Makefile.am
include editorconfig/vim-completion.am
.PHONY: $(phony_targets)
# vim: set ts=4 sts=4 noet foldmethod=marker foldmarker=#region,#endregion :

0
NEWS
View File

View File

@ -1 +0,0 @@
scripts/bootstrap.sh

View File

@ -1,129 +0,0 @@
dnl -*- Autoconf -*-
dnl Process this file with autoconf to produce a configure script.
AC_PREREQ([2.69])
AC_INIT([quartz-warriors], [0.0.3], [])
AC_CONFIG_MACRO_DIR([m4])
AC_CONFIG_SRCDIR([src])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_FILES([Makefile])
AC_CANONICAL_HOST
dnl AM_CONDITIONAL([HAVE_FREEBSD], [ test "${host_os#freebsd}" != "${host_os}" ])
dnl AM_CONDITIONAL([HAVE_LINUX], [ test "${host_os#linux}" != "${host_os}" ])
dnl AM_CONDITIONAL([HAVE_MACOS], [ test "${host_os#darwin}" != "${host_os}" ])
AC_ARG_WITH([ci-config],
[AS_HELP_STRING([--with-ci-config],
[Set this to 'yes' on build servers.
Disables certain warnings on specific OS/Buildserver combinations @<:@default=no@:>@])],
[with_ci_config=$withval],
[with_ci_config=no])
AC_ARG_ENABLE([debug],
[AS_HELP_STRING([--enable-debug],
[Enable debugging symbols @<:@default=no@:>@])],
[enable_debug=$enableval],
[enable_debug=yes])
AM_CONDITIONAL([DEBUG_BUILD], [test "x$enable_debug" = "xyes"])
AM_CONDITIONAL([HAVE_BUILD_SERVER], [ test "x${with_ci_config}" = "xyes" ])
AM_COND_IF([HAVE_BUILD_SERVER],
AC_MSG_NOTICE([CI configuration requested. Disabling pedantic mode & warnings about C++20 extensions])
)
dnl Predefine some shell variables for error messages
err_inplace_build="In-place builds are forbidden
Try:
$ mkdir build && cd build ;
$ ../configure
"
AC_MSG_CHECKING([that this is an out-of-source build])
dnl check to make sure that $srcdir is not '.'
dnl This package cannot be built in-place. Build it like a cmake project
case $srcdir in
.)
AC_MSG_RESULT([no])
AC_MSG_ERROR([$err_inplace_build])
AS_EXIT(255)
;;
*)
AC_MSG_RESULT([yes])
;;
esac
AC_CONFIG_LINKS([${builddir}res:${top_srcdir}res])
AM_INIT_AUTOMAKE([1.15] [foreign subdir-objects dist-xz])
AM_SILENT_RULES([yes])
dnl libtool support
LT_INIT
dnl Add search paths for user-installed libraires and packages
PKG_CONFIG_PATH="${PKG_CONFIG_PATH}:/usr/local/share/pkgconfig"
export PKG_CONFIG_PATH
CPPFLAGS="${CPPFLAGS} -isystem /usr/local/include"
export CPPFLAGS
PKG_PROG_PKG_CONFIG
dnl Set default CXXFLAGS based on the debug option
if test "x$enable_debug" = "xyes"; then
AC_DEFINE([DEBUG_BUILD], [1], [Define if in debug build])
AC_SUBST([CFLAGS], ["-ggdb -O0 -fno-inline-functions"])
AC_SUBST([CXXFLAGS], ["-ggdb -O0 -fno-inline-functions"])
fi
AC_PROG_CC
AC_PROG_CXX
AX_CXX_COMPILE_STDCXX(20, [noext], [mandatory])
AC_CHECK_PROG([_ac_compiledb_detected], [compiledb], [true], [false])
AM_CONDITIONAL([HAVE_COMPILEDB], [test x$_ac_compiledb_detected = xtrue ])
AM_COND_IF([HAVE_COMPILEDB],
AC_MSG_NOTICE([compiledb found! vim-completion make target enabled]),
AC_MSG_WARN([compiledb not found. vim-completion make target disabled])
)
dnl Checks for libraries.
PKG_CHECK_MODULES([SDL2], [sdl2 >= 2 SDL2_image >= 0.29.0 SDL2_gfx >= 1.0.2])
AC_REQUIRE_HEADER([stdint.h])
AC_CHECK_HEADERS([execinfo.h])
dnl Checks for header files.
dnl C++ Header library checks
AC_LANG_PUSH([C++])
BOOST_REQUIRE([1.7.2])
PKG_CHECK_MODULES([CATCH2], [catch2-with-main >= 2.13.7])
PKG_CHECK_MODULES([QT], [Qt5Core >= 5.15 Qt5Widgets Qt5Gui], [
QT_PATH="$(eval $PKG_CONFIG --variable=exec_prefix Qt5Core)"
QT_HOST_PATH="$(eval $PKG_CONFIG --variable=host_bins Qt5Core)"
QT_VERSION="$(eval $PKG_CONFIG --modversion Qt5Gui)"
AC_PATH_PROGS(MOC, [moc-qt5 moc], moc, ["${QT_HOST_PATH}" "${QT_PATH}/bin"])
AC_PATH_PROGS(RCC, [rcc-qt5 rcc], rcc, ["${QT_HOST_PATH}" "${QT_PATH}/bin"])
AC_PATH_PROGS(UIC, [uic-qt5 uic], uic, ["${QT_HOST_PATH}" "${QT_PATH}/bin"])
AC_PATH_PROGS(QMLCACHE, [qmlcachegen-qt5 qmlcachegen], no, ["${QT_HOST_PATH}" "${QT_PATH}/bin"])
])
PKG_CHECK_MODULES([NLOHMANN_JSON], [nlohmann_json >= 3.11.0])
dnl Check if we have a libexecinfo.
dnl On non-glibc systems, using backtrace requires linking to libexecinfo.o
AC_CHECK_LIB([execinfo], [backtrace],
[LIBS="${LIBS} -lexecinfo"; BOOST_FIND_HEADER([boost/stacktrace.hpp])])
AC_CHECK_LIB([pthread], [pthread_create])
AC_LANG_POP
AC_CHECK_FUNCS([backtrace backtrace_symbols])
AC_OUTPUT

View File

@ -1,12 +0,0 @@
#!/bin/sh
CFLAGS="${CFLAGS} -Og -ggdb"
CXXFLAGS=" ${CFLAGS} ${CXXFLAGS}"
CPPFLAGS="${CPPFLAGS} -DQW_DEBUG"
export CC
export CXX
export CFLAGS
export CXXFLAGS
export CPPFLAGS

View File

File diff suppressed because it is too large Load Diff

View File

@ -1,39 +0,0 @@
# =============================================================================
# https://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx_11.html
# =============================================================================
#
# SYNOPSIS
#
# AX_CXX_COMPILE_STDCXX_11([ext|noext], [mandatory|optional])
#
# DESCRIPTION
#
# Check for baseline language coverage in the compiler for the C++11
# standard; if necessary, add switches to CXX and CXXCPP to enable
# support.
#
# This macro is a convenience alias for calling the AX_CXX_COMPILE_STDCXX
# macro with the version set to C++11. The two optional arguments are
# forwarded literally as the second and third argument respectively.
# Please see the documentation for the AX_CXX_COMPILE_STDCXX macro for
# more information. If you want to use this macro, you also need to
# download the ax_cxx_compile_stdcxx.m4 file.
#
# LICENSE
#
# Copyright (c) 2008 Benjamin Kosnik <bkoz@redhat.com>
# Copyright (c) 2012 Zack Weinberg <zackw@panix.com>
# Copyright (c) 2013 Roy Stogner <roystgnr@ices.utexas.edu>
# Copyright (c) 2014, 2015 Google Inc.; contributed by Alexey Sokolov <sokolov@google.com>
# Copyright (c) 2015 Paul Norman <penorman@mac.com>
# Copyright (c) 2015 Moritz Klammler <moritz@klammler.eu>
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved. This file is offered as-is, without any
# warranty.
#serial 18
AX_REQUIRE_DEFINED([AX_CXX_COMPILE_STDCXX])
AC_DEFUN([AX_CXX_COMPILE_STDCXX_11], [AX_CXX_COMPILE_STDCXX([11], [$1], [$2])])

View File

@ -1,34 +0,0 @@
# =============================================================================
# https://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx_14.html
# =============================================================================
#
# SYNOPSIS
#
# AX_CXX_COMPILE_STDCXX_14([ext|noext], [mandatory|optional])
#
# DESCRIPTION
#
# Check for baseline language coverage in the compiler for the C++14
# standard; if necessary, add switches to CXX and CXXCPP to enable
# support.
#
# This macro is a convenience alias for calling the AX_CXX_COMPILE_STDCXX
# macro with the version set to C++14. The two optional arguments are
# forwarded literally as the second and third argument respectively.
# Please see the documentation for the AX_CXX_COMPILE_STDCXX macro for
# more information. If you want to use this macro, you also need to
# download the ax_cxx_compile_stdcxx.m4 file.
#
# LICENSE
#
# Copyright (c) 2015 Moritz Klammler <moritz@klammler.eu>
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved. This file is offered as-is, without any
# warranty.
#serial 5
AX_REQUIRE_DEFINED([AX_CXX_COMPILE_STDCXX])
AC_DEFUN([AX_CXX_COMPILE_STDCXX_14], [AX_CXX_COMPILE_STDCXX([14], [$1], [$2])])

View File

@ -1,35 +0,0 @@
# =============================================================================
# https://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx_17.html
# =============================================================================
#
# SYNOPSIS
#
# AX_CXX_COMPILE_STDCXX_17([ext|noext], [mandatory|optional])
#
# DESCRIPTION
#
# Check for baseline language coverage in the compiler for the C++17
# standard; if necessary, add switches to CXX and CXXCPP to enable
# support.
#
# This macro is a convenience alias for calling the AX_CXX_COMPILE_STDCXX
# macro with the version set to C++17. The two optional arguments are
# forwarded literally as the second and third argument respectively.
# Please see the documentation for the AX_CXX_COMPILE_STDCXX macro for
# more information. If you want to use this macro, you also need to
# download the ax_cxx_compile_stdcxx.m4 file.
#
# LICENSE
#
# Copyright (c) 2015 Moritz Klammler <moritz@klammler.eu>
# Copyright (c) 2016 Krzesimir Nowak <qdlacz@gmail.com>
#
# Copying and distribution of this file, with or without modification, are
# permitted in any medium without royalty provided the copyright notice
# and this notice are preserved. This file is offered as-is, without any
# warranty.
#serial 2
AX_REQUIRE_DEFINED([AX_CXX_COMPILE_STDCXX])
AC_DEFUN([AX_CXX_COMPILE_STDCXX_17], [AX_CXX_COMPILE_STDCXX([17], [$1], [$2])])

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +0,0 @@
AC_DEFUN([AC_REQUIRE_HEADER], [dnl
AC_CHECK_HEADERS([$1], dnl
[], dnl
dnl[AC_DEFINE(AS_TR_CPP([HAVE_$1]), [1])], dnl
[AC_MSG_ERROR([cannot find $1])])
])

View File

@ -1,7 +0,0 @@
#!/usr/bin/false
PATH="/usr/local/opt/qt@5/bin/:${PATH}"
PKG_CONFIG_PATH="/usr/local/opt/qt@5/lib/pkgconfig/:${PKG_CONFIG_PATH}"
export PATH
export PKG_CONFIG_PATH

View File

@ -1,65 +0,0 @@
#!/bin/sh
# Determine the project root no matter if you call this from the symlink or scripts/ directory
PROGRAM="basename ${0}"
if [ -n "`readlink $0`" ]; then
BASE_DIR="`cd "$(dirname "$0")"; pwd`";
else
BASE_DIR="`cd "$(dirname "$0")"; pwd`/..";
BASE_DIR="`readlink -f ${BASE_DIR}`"
fi
cd "${BASE_DIR}"
die()
{
rc=${2:-255}
echo "Error: ${1}"
exit ${rc}
}
cmdecho()
{
need_to_die=1
if [ "${1}" == "--optional" ] || [ "${1}" == "-o" ]; then
echo "optional"
need_to_die=0
shift;
fi
echo "$ ${@}"
if [ ${need_to_die} -ne 0 ]; then
${@} || die "${1} returned error code ${?}"
else
${@}
fi
#return ${?}
}
cmdecho git config -f .gitmodules submodule.third_party/Catch2.shallow true
cmdecho git config -f .gitmodules submodule.third_party/FakeIt.shallow true
cmdecho -o git submodule update --init --recursive
if [ ${?} -ne 0 ]; then
cmdecho rm -rf third_party/Catch2
cmdecho rm -rf third_party/FakeIt
cmdecho git submodule update --init --recursive
fi
if [ "x$1" == "x-f" ] || [ ! -x ./configure ]; then
cmdecho autoreconf -iv
fi
if [ ! -x ./configure ]; then
die "./configure does not exist. Check configure.ac and the autotools!"
fi
cmdecho sh scripts/rebuild-qtforms.sh
cd $OLDPWD

View File

@ -1,66 +0,0 @@
#!/bin/sh
BASE_DIR="$(cd "$(dirname "$0")"; pwd)/..";
BASE_DIR="$(readlink -f ${BASE_DIR})"
UIC_CMD="uic-qt5"
MOC_CMD="mod-qt5"
die() {
echo "An error has occured. Stopping"
return 1
}
cmdecho() {
echo "$@"
$@
}
error() {
echo "$@" >&2
}
detect_qt_tools() {
if [ -x "`which uic`" ] ; then
UIC_CMD="uic"
else
echo "could not detect a binary named 'uic'"
fi
if [ -x "`which moc`" ] ; then
MOC_CMD="moc"
else
echo "could not detect a binary named 'moc'"
fi
}
detect_qt_tools
if [ -z $UIC_CMD ] || [ ! -x $UIC_CMD ] && [ ! -x $(which $UIC_CMD) ];then
error "The selected uic compiler either does not exist, or is not executable"
error
error "Could not build QT forms without uic!"
error "(This is only needed for the game editors.)"
exit 0
fi
if [ -z $MOC_CMD ] || [ ! -x $MOC_CMD ] && [ ! -x $(which $MOC_CMD) ];then
error "The selected moc compiler either does not exist, or is not executable"
error
error "Could not build QT forms without moc!"
error "(This is only needed for the game editors.)"
exit 0
fi
cd ${BASE_DIR}
echo "Searching for *.ui files in source..."
UI_FILES="$(find src -iname '*.ui')"
for uifile in $UI_FILES; do
cmdecho ${UIC_CMD} ${uifile} -o ${uifile}.hpp
done

View File

@ -1,5 +0,0 @@
include src/framework/Makefile.am
include src/tests/Makefile.am
include src/game/Makefile.am
include src/editors/Makefile.am

View File

@ -1,7 +0,0 @@
BUILT_SOURCES= # Needed to include QT .ui.hpp files in the build dependency trees.
editor_common_libs=$(QT_LIBS) $(SDL2_LIBS) $(NLOHMANN_JSON_LIBS)
include src/editors/object-editor/Makefile.am

View File

@ -21,12 +21,13 @@
#include "EntityEditor.hpp"
#include "ui_EntityEditor.h"
#include "src/game/ComponentStore.hpp"
#include "framework/core/components/EntityManager.hpp"
using nlohmann::json;
using QW::GameEngine::ComponentStore;
static ComponentStore* components = nullptr;
using namespace QW::Core::Components;
static EntityManager* components = &(EntityManager::GetInstance());
EntityEditor::EntityEditor(QWidget* parent, const QString& filepath)
: QWidget(parent)
@ -34,10 +35,6 @@ EntityEditor::EntityEditor(QWidget* parent, const QString& filepath)
, available_components(this)
, ui(*(new Ui::EntityEditor()))
{
if (!components) {
components = &(ComponentStore::GetInstance());
}
ui.setupUi(this);
for (auto& type : components->GetRegisteredTypes()) {

View File

@ -1,31 +0,0 @@
pkglib_LTLIBRARIES+=libframework-core.la
noinst_LTLIBRARIES+=libframework-core-test.la
engine_source_files=
engine_source_files+=src/framework/core/Observable.cpp
engine_source_files+=src/framework/core/components/Entity.cpp
engine_source_files+=src/framework/core/components/EntityManager.cpp
engine_source_files+=src/framework/core/components/PlayerBehavior.cpp
engine_source_files+=src/framework/core/components/PositionAttribute.cpp
engine_source_files+=src/framework/core/input/EventDispatcher.cpp
libframework_core_la_SOURCES= $(engine_source_files)
libframework_core_test_la_SOURCES= $(engine_source_files)
libframework_core_la_CXXFLAGS=$(AM_CXXFLAGS)
libframework_core_la_CXXFLAGS+=$(SDL2_CFLAGS)
libframework_core_test_la_CXXFLAGS=$(AM_CXXFLAGS)
libframework_core_test_la_CXXFLAGS+=$(SDL2_CFLAGS)
libframework_core_test_la_CPPFLAGS=$(AM_CPPFLAGS) -DUNIT_TEST=1_
libframework_core_la_LIBADD=${NLOHMANN_JSON_LIBS}
libframework_core_test_la_LIBADD=${NLOHMANN_JSON_LIBS}
include_HEADERS+=${srcdir}/src/framework/framework.hpp
include src/framework/system/Makefile.am

View File

@ -31,8 +31,8 @@ class PhysicalProperties
PhysicalProperties(InstanceId id)
: BaseComponent(id), velocity(), position(nullptr)
{
static auto& components = EntityManager::GetInstance();
position = &(components.GetComponent<PositionAttribute>(id));
static auto& entities = EntityManager::GetInstance();
position = &(entities.GetComponent<PositionAttribute>(id));
}
virtual ~PhysicalProperties() = default;

View File

@ -38,8 +38,7 @@ using nlohmann::json;
using namespace QW::Core;
using error_flag = IBehavior::error_flag;
static GameEngine::ComponentStore& entities =
GameEngine::ComponentStore::GetInstance();
static auto& entities = EntityManager::GetInstance();
PlayerBehavior::PlayerBehavior(InstanceId id)
: IBehavior()
@ -184,7 +183,6 @@ PlayerBehavior::to_json(json& json_object) const
void
PlayerBehavior::from_json(const json& json_object)
{
static auto& entities = GameEngine::ComponentStore::GetInstance();
Metadata metadata = json_object["metadata"].get<Metadata>();
if (metadata != this->component_info) {

View File

@ -1,13 +0,0 @@
pkglib_LTLIBRARIES+=libframework-system.la
libframework_system_la_SOURCES=
libframework_system_la_SOURCES+=src/framework/system/sdl.cpp
libframework_system_la_CXXFLAGS=
libframework_system_la_CXXFLAGS+=$(SDL2_CFLAGS)
libframework_system_la_LIBADD=
libframework_system_la_LIBADD+=$(SDL2_LIBS)

View File

@ -10,8 +10,13 @@
// #include "config.h"
#include "framework/core/types.hpp"
#include "framework/system/platform.hpp"
#if defined(HAVE_EXECINFO_H)
#if defined(__clang__)
#include <cxxabi.h>
#endif
#ifdef HAVE_EXECINFO_H
#include <execinfo.h>
#else
#include <boost/stacktrace.hpp>
@ -20,6 +25,7 @@
#include <iostream>
#include <sstream>
using QW::Core::Platform;
using namespace QW::Core::Types;
#ifdef QW_DEBUG // #region
@ -29,24 +35,105 @@ using namespace QW::Core::Types;
#define debugprint(msg) ;
#endif // #endregion
// Extracts the mangled symbol from a string like <func_name+0x34>
inline std::string
generate_stacktrace()
extract_mangled_symbol(const std::string& input)
{
std::string result;
bool insideAngleBrackets = false;
for (char c : input) {
if (c == '<') {
insideAngleBrackets = true;
continue;
}
if (c == '>') {
insideAngleBrackets = false;
continue;
}
if (c == '+') {
break;
}
if (insideAngleBrackets) {
result += c;
}
};
return result;
}
// There are a lot of C and platform-specific hacks contained within
// I am sorry. 🤡
inline std::string
generate_stacktrace(short framesToRemove = -1)
{
std::stringstream buffer;
#ifdef HAVE_EXECINFO_H
#ifndef BOOST_STACKTRACER
void* callstack[128];
int i, frames = backtrace(callstack, 128);
char** strs = backtrace_symbols(callstack, frames);
for (i = 0; i < frames; ++i) {
buffer << strs[i] << std::endl;
size_t columns_to_print = 0;
// preconfigure column length for certain platforms
if (Platform::FREEBSD) {
columns_to_print = 2;
} else if (Platform::MACOS) {
columns_to_print = 4;
}
free(strs);
#else
if (framesToRemove == frames || framesToRemove < 0) {
framesToRemove = 0;
}
for (i = framesToRemove; i < frames; ++i) {
std::string word;
std::stringstream line_stream(strs[i]);
std::vector<std::string> wordlist;
// Create a list of words for this stack trace line
while (line_stream >> word) {
if (columns_to_print != 0 &&
(word.find('<') != word.npos &&
word.find('>') != word.npos)) {
auto extracted_symbol =
extract_mangled_symbol(word);
word = extracted_symbol;
}
wordlist.push_back(word);
}
// if columns_to_print is still 0, assign it to the list length
// It is only pre-configured for certain platforms, see above
if (!columns_to_print) {
columns_to_print = wordlist.size();
}
// Process the extracted words one at a time and format the
// stack trace string
for (unsigned pos = 0; pos < columns_to_print; ++pos) {
auto word = wordlist[pos];
int status;
char* demangled_symbol = abi::__cxa_demangle(
word.c_str(), nullptr, nullptr, &status
);
if (status == 0) {
buffer << demangled_symbol << '\t';
std::free(demangled_symbol);
} else {
buffer << word << '\t';
}
}
buffer << std::endl;
}
std::free(strs);
#else /*@{*/
buffer << boost::stacktrace::stacktrace() << std::flush;
#endif
#endif /*@}*/
return buffer.str();
}
inline void
print_backtrace()
{
@ -72,4 +159,4 @@ print_cmdline(int argc, const c_string argv[])
}
// clang-format off
// vim: set foldmethod=marker foldmarker=#region,#endregion textwidth=80 ts=8 sts=0 sw=8 noexpandtab ft=cpp.doxygen :
// vim: set foldmethod=marker foldmarker=@{,@} textwidth=80 ts=8 sts=0 sw=8 noexpandtab ft=cpp.doxygen :

View File

@ -0,0 +1,43 @@
/* platform.hpp
* Copyright © 2023 Saul D. Beniquez
* License: Mozilla Public License v. 2.0
*
* This Source Code Form is subject to the terms of the Mozilla Public License,
* v.2.0. If a copy of the MPL was not distributed with this file, You can
* obtain one at https://mozilla.org/MPL/2.0/.
*/
#pragma once
namespace QW::Core {
struct Platform {
#ifdef __linux__
static constexpr bool LINUX = true;
#else
static constexpr bool LINUX = false;
#endif
#ifdef _WIN32
static constexpr bool WINDOWS = true;
#else
static constexpr bool WINDOWS = false;
#endif
#ifdef __APPLE__
static constexpr bool MACOS = true;
#else
static constexpr bool MACOS = false;
#endif
#ifdef __FreeBSD__
static constexpr bool FREEBSD = true;
#else
static constexpr bool FREEBSD = false;
#endif
// I don't own any AIX, Solaris, HP-UX, or pure Darwin systems, sorry :)
};
}
// clang-format off
// vim: set foldmethod=marker foldmarker=#region,#endregion textwidth=80 ts=8 sts=0 sw=8 noexpandtab ft=cpp.doxygen :

View File

@ -23,7 +23,7 @@
using namespace QW::Core::Components;
namespace QW::GameEngine {
class ComponentStore : public EntityManager {
class ComponentStore {
public:
static ComponentStore& GetInstance()
{
@ -32,14 +32,14 @@ class ComponentStore : public EntityManager {
return instance;
}
static void Init()
void Init()
{
auto& instance = GetInstance();
auto& instance = EntityManager::GetInstance();
instance.RegisterPool(instance.positions);
instance.RegisterPool(instance.properties);
instance.RegisterPool(instance.views);
instance.RegisterPool(instance.players);
instance.RegisterPool(this->positions);
instance.RegisterPool(this->properties);
instance.RegisterPool(this->views);
instance.RegisterPool(this->players);
}
ComponentDictionary<PositionAttribute> positions;
@ -48,10 +48,7 @@ class ComponentStore : public EntityManager {
ComponentDictionary<PhysicalProperties> properties;
protected:
ComponentStore()
: EntityManager(), positions(), players(), views(), properties()
{
}
ComponentStore() : positions(), players(), views(), properties() {}
};
}

View File

@ -1,17 +0,0 @@
bin_PROGRAMS+= quartz-warriors
quartz_warriors_SOURCES=
quartz_warriors_SOURCES+=src/game/main.cpp
quartz_warriors_SOURCES+=src/game/QuartzWarriors.cpp
quartz_warriors_CPPFLAGS=
quartz_warriors_CPPFLAGS+= $(AM_CPPFLAGS)
quartz_warriors_CPPFLAGS+= $(project_include_flags)
quartz_warriors_CPPFLAGS+= $(SDL2_CFLAGS)
quartz_warriors_LDADD=
quartz_warriors_LDADD+= libframework-core.la libframework-system.la
quartz_warriors_LDADD+= $(NLOHMANN_JSON_LIBS)
#quartz_warriors_LDADD+= $(SDL2_LIBS) #not needed, libframework-system provides SDL linkage

View File

@ -35,6 +35,7 @@ QuartzWarriors::QuartzWarriors()
, is_running(false)
, ticks(0)
, component_pools(ComponentStore::GetInstance())
, entity_manager(EntityManager::GetInstance())
{
this->renderer = System::Video::new_renderer();
@ -55,13 +56,13 @@ QuartzWarriors::Init(int argc, char* argv[])
// Initialize player 1's data structs
component_pools.views.emplace(playerId, playerId);
component_pools.positions.emplace(playerId, playerId);
component_pools.players.emplace(playerId, playerId);
component_pools.properties.emplace(playerId, playerId);
component_pools.players.emplace(playerId, playerId);
this->is_running = true;
auto& player_behavior =
component_pools.GetComponent<PlayerBehavior>(playerId);
entity_manager.GetComponent<PlayerBehavior>(playerId);
this->event_dispatcher.RegisterObserver(player_behavior);
System::Video::initialize_renderer(this->renderer);
@ -162,14 +163,14 @@ QuartzWarriors::Render()
mutex_lock dataLock(data_mutex);
auto positionList =
component_pools.AsSequential<PositionAttribute>();
entity_manager.AsSequential<PositionAttribute>();
for (auto& position : positionList) {
auto& viewMetadata = position.GetMetadata();
InstanceId id = viewMetadata.instance.id;
RenderedCircle& view =
component_pools.GetComponent<RenderedCircle>(id);
entity_manager.GetComponent<RenderedCircle>(id);
view.Draw(this->renderer, position);
}

View File

@ -54,6 +54,8 @@ class QuartzWarriors : public Core::IGame {
System::Video::rendering_ctx renderer;
QW::GameEngine::ComponentStore& component_pools;
std::mutex data_mutex;
EntityManager& entity_manager;
};
}

View File

@ -1,39 +0,0 @@
# src/tests/Makefile.am
# Copyright © 2022 Saul D. Beniquez
# License: MPL2
check_PROGRAMS+=game-tests
TESTS+=$(check_PROGRAMS)
phony_targets+=tests
tests: $(check_PROGRAMS)
thirdparty_library_includes=-I ${srcdir}/third_party/FakeIt/include
thirdparty_library_includes+=-I ${srcdir}/third_party/FakeIt/config/catch
#test_disabled_warnings=-Wno-deprecated-declarations -Wno-defaulted-function-deleted\
# -Wno-zero-length-array
tests_addl_cppflags=
tests_addl_cppflags+= -I ${srcdir}/src/tests -DUNIT_TEST=1
tests_addl_cxxflags=
tests_addl_cxxflags+= $(CATCH2_CFLAGS) $(SDL2_CFLAGS)
tests_addl_cxxflags+= $(thirdparty_library_includes)
game_tests_CPPFLAGS= $(AM_CPPFLAGS) $(PROJECT_INCLUDE_FLAGS)
game_tests_CPPFLAGS+= $(tests_addl_cppflags)
game_tests_CPPFLAGS+= -DUNIT_TEST=1
game_tests_CXXFLAGS=
game_tests_CXXFLAGS+=${AM_CXXFLAGS}
game_tests_CXXFLAGS+= $(tests_addl_cxxflags)
game_tests_LDADD= libframework-core-test.la
game_tests_LDADD+= $(CATCH2_LIBS) $(SDL2_LIBS) $(NLOHMANN_JSON_LIBS)
game_tests_SOURCES=
game_tests_SOURCES+=src/tests/runtime.tests.cpp
include src/tests/framework/Makefile.am
# vim: ft=automake :

View File

@ -1,14 +0,0 @@
pwd=src/tests/framework
core_sources=
core_sources+=$(pwd)/types/adapters/Sequential.test.cpp
core_sources+=$(pwd)/core/input/EventDispatcher.test.cpp
core_sources+=$(pwd)/core/input/InputMapper.test.cpp
core_sources+=$(pwd)/core/components/Entity.test.cpp
core_sources+=$(pwd)/core/components/EntityManager.test.cpp
core_sources+=$(pwd)/core/components/PositionAttribute.test.cpp
game_tests_SOURCES+=${core_sources}

1
third_party/FakeIt vendored

@ -1 +0,0 @@
Subproject commit 78ca536e6b32f11e2883d474719a447915e40005