Skip to content

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Sat727 committed Feb 19, 2024
1 parent 6a5fb44 commit e4fdac3
Show file tree
Hide file tree
Showing 232 changed files with 449,269 additions and 0 deletions.
142 changes: 142 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
list(APPEND GAME_SOURCES
"${CMAKE_CURRENT_SOURCE_DIR}/main.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/init.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/collision.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/light.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/maps.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/cursors.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/draw.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/opengl.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/objects.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/list.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/files.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/items.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/paths.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/charclass.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/net.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/game.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/stat.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/acttorch.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/actplayer.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/actmonster.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/actitem.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/acthudweapon.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/actgold.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/actgib.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/actgeneral.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/actdoor.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/actladder.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/input.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/item_usage_funcs.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/entity.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/messages.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/actflame.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/actcampfire.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/actfountain.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/actsink.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/monster_rat.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/monster_goblin.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/monster_slime.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/monster_human.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/monster_scorpion.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/monster_succubus.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/monster_troll.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/monster_shopkeeper.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/monster_skeleton.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/monster_minotaur.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/monster_ghoul.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/monster_demon.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/monster_spider.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/monster_lich.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/monster_imp.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/monster_gnome.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/monster_devil.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/monster_automaton.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/monster_cockatrice.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/monster_crystalgolem.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/monster_goatman.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/monster_incubus.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/monster_insectoid.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/monster_kobold.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/monster_lichfire.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/monster_lichice.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/monster_scarab.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/monster_sentrybot.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/monster_shadow.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/monster_vampire.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/shops.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/mechanisms.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/actgate.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/actchest.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/actsprite.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/menu.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/savepng.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/actarrow.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/actarrowtrap.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/actboulder.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/actheadstone.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/actthrown.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/actbeartrap.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/actspeartrap.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/actwallbuster.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/book.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/init_game.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/prng.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/scores.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/steam.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/hash.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/player.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/entity_shared.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/stat_shared.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/item_tool.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/actsummontrap.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/actpowercrystal.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/monster_shared.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/actpedestal.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/actteleporter.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/actmagictrap.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/steam_shared.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/mod_tools.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/json.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/eos.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/mod_tools.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/lobbies.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/shader.cpp"
)

list(APPEND EDITOR_SOURCES
"${CMAKE_CURRENT_SOURCE_DIR}/main.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/init.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/light.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/buttons.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/cursors.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/draw.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/opengl.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/objects.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/entity_editor.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/input.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/list.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/hash.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/files.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/editor.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/entity_shared.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/stat_editor.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/stat_shared.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/items_editor.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/steam_shared.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/json.cpp"
#"${CMAKE_CURRENT_SOURCE_DIR}/eos.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/eos_editor.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/mod_tools.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/prng.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/shader.cpp"
)

add_subdirectory(magic)
add_subdirectory(interface)
add_subdirectory(ui)
add_subdirectory(engine)
add_subdirectory(imgui)

set(GAME_SOURCES ${GAME_SOURCES} PARENT_SCOPE)
set(EDITOR_SOURCES ${EDITOR_SOURCES} PARENT_SCOPE)
66 changes: 66 additions & 0 deletions src/Config.hpp.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@

#if @Windows@
#define WINDOWS
#endif

#if @Apple@
#define APPLE
#endif

#if @Linux@
#define LINUX
#endif

#if @Bsd@
#define BSD
#endif

#if @Haiku@
#define HAIKU
#endif

#if @STEAMWORKS_ENABLED@
#define STEAMWORKS
#endif

#ifndef EDITOR
#if @EOS_ENABLED@
#define USE_EOS
#define BUILD_ENV_PR "@BUILD_ENV_PR@"
#define BUILD_ENV_SA "@BUILD_ENV_SA@"
#define BUILD_ENV_DE "@BUILD_ENV_DE@"
#define BUILD_ENV_CC "@BUILD_ENV_CC@"
#define BUILD_ENV_CS "@BUILD_ENV_CS@"
#define BUILD_ENV_GSE "@BUILD_ENV_GSE@"
#endif
#endif

#if @IMGUI@
#define USE_IMGUI
#endif

#if @FMOD@
#define USE_FMOD
#endif

#if @OPENAL@
#define USE_OPENAL
#endif

#if @TREMOR@
#define USE_TREMOR
#endif

#if @PANDORA@
#define PANDORA
#endif

#if @NOT_DWORD_DEFINED@
/*
* https://msdn.microsoft.com/en-us/library/cc230318.aspx
* A DWORD is a 32-bit unsigned integer (range: 0 through 4294967295 decimal). Because a DWORD is unsigned, its first bit (Most Significant Bit (MSB)) is not reserved for signing.
* This type is declared as follows:
* typedef unsigned long DWORD, *PDWORD, *LPDWORD;
*/
typedef unsigned long DWORD;
#endif
32 changes: 32 additions & 0 deletions src/Directory.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#pragma once

#include <dirent.h>
#include "main.hpp"

class Directory {
public:
Directory(const char* name) :
path(name)
{
//TODO: Use datadir. rom:/ needs to get prepended...
DIR* dir;
struct dirent* ent;
if ((dir = opendir(name)) == NULL)
{
printlog("failed to open directory '%s'", name);
return;
}
while ((ent = readdir(dir)) != NULL)
{
std::string entry(ent->d_name);
if (ent->d_name[0] != '.')
{
list.emplace_back(ent->d_name);
}
}
closedir(dir);
std::sort(list.begin(), list.end());
}
std::vector<std::string> list;
const char* path;
};
92 changes: 92 additions & 0 deletions src/UnicodeDecoder.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
#pragma once

/* Copyright (c) 2008-2009 Bjoern Hoehrmann <[email protected]>
* See http://bjoern.hoehrmann.de/utf-8/decoder/dfa/ for details.
* 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.
*
* ValidateUTF8String() is based on https://stackoverflow.com/a/22135005/8552466
*/

#include <array>
#include <cstdint>

namespace UTFD
{

constexpr uint32_t UTF8_ACCEPT { 0 };
constexpr uint32_t UTF8_REJECT { 1 };

static constexpr std::array<uint8_t, 400> UTF8_DECODER
{
// The first part of the table maps bytes to character classes that
// to reduce the size of the transition table and create bitmasks.
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,
7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7, 7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,7,
8,8,2,2,2,2,2,2,2,2,2,2,2,2,2,2, 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,
10,3,3,3,3,3,3,3,3,3,3,3,3,4,3,3, 11,6,6,6,5,8,8,8,8,8,8,8,8,8,8,8,

// The second part is a transition table that maps a combination
// of a state of the automaton and a character class to a state.
0,12,24,36,60,96,84,12,12,12,48,72, 12,12,12,12,12,12,12,12,12,12,12,12,
12, 0,12,12,12,12,12, 0,12, 0,12,12, 12,24,12,12,12,12,12,24,12,24,12,12,
12,12,12,12,12,12,12,24,12,12,12,12, 12,24,12,12,12,12,12,12,12,24,12,12,
12,12,12,12,12,12,12,36,12,36,12,12, 12,36,12,12,12,12,12,36,12,36,12,12,
12,36,12,12,12,12,12,12,12,12,12,12,
};

inline uint32_t DecodeUTF8(uint32_t* const codep, const uint32_t byte)
{
if ( byte > UTF8_DECODER.size() )
{
return UTF8_REJECT;
}

const uint32_t type = UTF8_DECODER[byte];
uint32_t state = UTF8_ACCEPT;

*codep = (state != UTF8_ACCEPT) ? (byte & 0x3fu) | (*codep << 6) : (0xff >> type) & (byte);
state = UTF8_DECODER[256 + state + type];

return state;
}

// Returns 0 (UTF8_ACCEPT) if valid UTF8, 1 (UTF8_REJECT) if invalid, or greater than 1 if more processing is required (two byte character)
inline uint32_t ValidateUTF8String(char* const str, const size_t length)
{
uint32_t state = UTF8_ACCEPT;

for ( size_t charIndex = 0; charIndex < length; charIndex++ )
{
const uint32_t type = UTF8_DECODER[static_cast<uint8_t>(str[charIndex])];
state = UTF8_DECODER[256 + state + type];

if ( state == UTF8_REJECT )
{
break;
}
}

return state;
}

// Returns 0 (UTF8_ACCEPT) if valid UTF8, 1 (UTF8_REJECT) if invalid, or greater than 1 if more processing is required (two byte character)
inline uint32_t ValidateUTF8Character(const char c)
{
return UTF8_DECODER[256 + UTF8_ACCEPT + UTF8_DECODER[static_cast<uint8_t>(c)]];
}

}

Loading

0 comments on commit e4fdac3

Please sign in to comment.