Skip to content

Commit

Permalink
Merge branch 'main' into stable
Browse files Browse the repository at this point in the history
  • Loading branch information
afwbkbc committed Oct 6, 2024
2 parents 1af2367 + 45d4fff commit 96ab706
Show file tree
Hide file tree
Showing 414 changed files with 6,776 additions and 4,780 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ _deps
/src/tmp/last_commit.h
/debug.log
/build
/build_release
*.depend
*.layout
/out
Expand Down
49 changes: 43 additions & 6 deletions src/config/Config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include "util/FS.h"
#include "util/random/Random.h"

#include "game/settings/Settings.h"
#include "game/backend/settings/Settings.h"

namespace config {

Expand Down Expand Up @@ -87,6 +87,26 @@ Config::Config( const int argc, const char* argv[] )
m_smac_path = value;
}
);
m_parser->AddRule(
"smactype", "SMAC_TYPE", "Specify type of SMAC installation: gog, loki, pp (default: autodetect)", AH( this ) {
const std::unordered_map< std::string, smac_type_t > values = {
{ "gog", ST_GOG },
{ "loki", ST_LOKI },
{ "pp", ST_PP },
};
const auto& it = values.find( value );
if ( it != values.end() ) {
m_smac_type = it->second;
}
else {
std::string errmsg = "Invalid --smactype value specified! Possible choices:";
for ( const auto& it : values ) {
errmsg += " " + it.first;
}
Error( errmsg );
}
}
);
m_parser->AddRule(
"version", "Show version of GLSMAC", AH() {
std::cout
Expand Down Expand Up @@ -188,7 +208,7 @@ Config::Config( const int argc, const char* argv[] )
}
);
const auto f_add_map_parameter_option =
[ this, s_quickstart_argument_missing ]( const std::string& name, const std::vector< std::string >& values, const std::string& desc, debug_flag_t flag, game::settings::map_config_value_t* out_param )
[ this, s_quickstart_argument_missing ]( const std::string& name, const std::vector< std::string >& values, const std::string& desc, debug_flag_t flag, game::backend::settings::map_config_value_t* out_param )
-> void {
ASSERT( values.size() == 3, "values size mismatch" );
m_parser->AddRule(
Expand Down Expand Up @@ -245,6 +265,15 @@ Config::Config( const int argc, const char* argv[] )
}, "cloud cover",
DF_QUICKSTART_MAP_CLOUDS, &m_quickstart_map_clouds
);
m_parser->AddRule(
"quickstart-faction", "FACTION", "Play as specific faction", AH( this, s_quickstart_argument_missing ) {
if ( !HasDebugFlag( DF_QUICKSTART ) ) {
Error( s_quickstart_argument_missing );
}
m_quickstart_faction = value;
m_debug_flags |= DF_QUICKSTART_FACTION;
}
);
m_parser->AddRule(
"quiet", "Do not output debug logs to console", AH( this ) {
m_debug_flags |= DF_QUIET;
Expand Down Expand Up @@ -330,6 +359,10 @@ const std::vector< std::string > Config::GetPossibleSMACPaths() const {
return result;
}

const smac_type_t Config::GetSMACType() const {
return m_smac_type;
}

const bool Config::HasLaunchFlag( launch_flag_t flag ) const {
return m_launch_flags & flag;
}
Expand Down Expand Up @@ -360,22 +393,26 @@ const types::Vec2< size_t >& Config::GetQuickstartMapSize() const {
return m_quickstart_mapsize;
}

const game::settings::map_config_value_t Config::GetQuickstartMapOcean() const {
const game::backend::settings::map_config_value_t Config::GetQuickstartMapOcean() const {
return m_quickstart_map_ocean;
}

const game::settings::map_config_value_t Config::GetQuickstartMapErosive() const {
const game::backend::settings::map_config_value_t Config::GetQuickstartMapErosive() const {
return m_quickstart_map_erosive;
}

const game::settings::map_config_value_t Config::GetQuickstartMapLifeforms() const {
const game::backend::settings::map_config_value_t Config::GetQuickstartMapLifeforms() const {
return m_quickstart_map_lifeforms;
}

const game::settings::map_config_value_t Config::GetQuickstartMapClouds() const {
const game::backend::settings::map_config_value_t Config::GetQuickstartMapClouds() const {
return m_quickstart_map_clouds;
}

const std::string& Config::GetQuickstartFaction() const {
return m_quickstart_faction;
}

const std::string& Config::GetGSETestsScript() const {
return m_gse_tests_script;
}
Expand Down
39 changes: 23 additions & 16 deletions src/config/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
#include "common/Module.h"

#include "util/random/Types.h"
#include "game/settings/Types.h"
#include "game/backend/settings/Types.h"
#include "types/Vec2.h"

#include "Types.h"

namespace util {
class ArgParser;
}
Expand Down Expand Up @@ -45,21 +47,23 @@ CLASS( Config, common::Module )
DF_QUICKSTART_MAP_EROSIVE = 1 << 9,
DF_QUICKSTART_MAP_LIFEFORMS = 1 << 10,
DF_QUICKSTART_MAP_CLOUDS = 1 << 11,
DF_QUIET = 1 << 12,
DF_GSE_ONLY = 1 << 13,
DF_GSE_TESTS = 1 << 14,
DF_GSE_TESTS_SCRIPT = 1 << 15,
DF_GSE_PROMPT_JS = 1 << 16,
DF_NOPINGS = 1 << 17,
DF_QUICKSTART_FACTION = 1 << 12,
DF_QUIET = 1 << 13,
DF_GSE_ONLY = 1 << 14,
DF_GSE_TESTS = 1 << 15,
DF_GSE_TESTS_SCRIPT = 1 << 16,
DF_GSE_PROMPT_JS = 1 << 17,
DF_NOPINGS = 1 << 18,
};
#endif

const std::string GetEnv( const std::string& var ) const;

const std::string& GetPrefix() const;
const std::string& GetDataPath() const;
const std::vector< std::string > GetPossibleSMACPaths() const;

const smac_type_t GetSMACType() const;

#ifdef DEBUG

const std::string GetDebugPath() const; // to store debug stuff like dumps
Expand All @@ -75,10 +79,11 @@ CLASS( Config, common::Module )
const std::string& GetQuickstartMapDump() const;
const std::string& GetQuickstartMapFile() const;
const types::Vec2< size_t >& GetQuickstartMapSize() const;
const game::settings::map_config_value_t GetQuickstartMapOcean() const;
const game::settings::map_config_value_t GetQuickstartMapErosive() const;
const game::settings::map_config_value_t GetQuickstartMapLifeforms() const;
const game::settings::map_config_value_t GetQuickstartMapClouds() const;
const game::backend::settings::map_config_value_t GetQuickstartMapOcean() const;
const game::backend::settings::map_config_value_t GetQuickstartMapErosive() const;
const game::backend::settings::map_config_value_t GetQuickstartMapLifeforms() const;
const game::backend::settings::map_config_value_t GetQuickstartMapClouds() const;
const std::string& GetQuickstartFaction() const;
const std::string& GetGSETestsScript() const;

#endif
Expand All @@ -102,6 +107,7 @@ CLASS( Config, common::Module )
std::string m_prefix;
std::string m_data_path;
std::string m_smac_path;
smac_type_t m_smac_type = ST_AUTO;

uint8_t m_launch_flags = LF_NONE;
types::Vec2< size_t > m_window_size = {};
Expand All @@ -113,10 +119,11 @@ CLASS( Config, common::Module )
std::string m_quickstart_mapdump = "";
std::string m_quickstart_mapfile = "";
types::Vec2< size_t > m_quickstart_mapsize = {};
game::settings::map_config_value_t m_quickstart_map_ocean = game::settings::MAP_CONFIG_OCEAN_MEDIUM;
game::settings::map_config_value_t m_quickstart_map_erosive = game::settings::MAP_CONFIG_EROSIVE_AVERAGE;
game::settings::map_config_value_t m_quickstart_map_lifeforms = game::settings::MAP_CONFIG_LIFEFORMS_AVERAGE;
game::settings::map_config_value_t m_quickstart_map_clouds = game::settings::MAP_CONFIG_CLOUDS_AVERAGE;
game::backend::settings::map_config_value_t m_quickstart_map_ocean = game::backend::settings::MAP_CONFIG_OCEAN_MEDIUM;
game::backend::settings::map_config_value_t m_quickstart_map_erosive = game::backend::settings::MAP_CONFIG_EROSIVE_AVERAGE;
game::backend::settings::map_config_value_t m_quickstart_map_lifeforms = game::backend::settings::MAP_CONFIG_LIFEFORMS_AVERAGE;
game::backend::settings::map_config_value_t m_quickstart_map_clouds = game::backend::settings::MAP_CONFIG_CLOUDS_AVERAGE;
std::string m_quickstart_faction = "";

std::string m_gse_tests_script = "";

Expand Down
14 changes: 14 additions & 0 deletions src/config/Types.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#pragma once

namespace config {

enum smac_type_t : uint8_t {

ST_AUTO,
ST_GOG,
ST_LOKI,
ST_PP,

};

}
6 changes: 3 additions & 3 deletions src/engine/Engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include "audio/Audio.h"
#include "network/Network.h"
#include "ui/UI.h"
#include "game/Game.h"
#include "game/backend/Game.h"

// TODO: move to config
const size_t g_max_fps = 500;
Expand All @@ -41,7 +41,7 @@ Engine::Engine(
audio::Audio* audio,
network::Network* network,
ui::UI* ui,
game::Game* game
game::backend::Game* game
)
:
m_config( config )
Expand Down Expand Up @@ -80,7 +80,7 @@ Engine::Engine(
if ( !m_config->HasDebugFlag( config::Config::DF_GSE_ONLY ) )
#endif
{
m_resource_manager->Init( m_config->GetPossibleSMACPaths() );
m_resource_manager->Init( m_config->GetPossibleSMACPaths(), m_config->GetSMACType() );
t_main->AddModule( m_resource_manager );
}
t_main->AddModule( m_input );
Expand Down
8 changes: 4 additions & 4 deletions src/engine/Engine.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ namespace network {
class Network;
}

namespace game {
namespace game::backend {
class Game;
}

Expand Down Expand Up @@ -91,7 +91,7 @@ CLASS( Engine, common::Class );
audio::Audio* audio,
network::Network* network,
ui::UI* ui,
game::Game* game
game::backend::Game* game
);

~Engine();
Expand All @@ -111,7 +111,7 @@ CLASS( Engine, common::Class );
network::Network* GetNetwork() const { return m_network; }
scheduler::Scheduler* GetScheduler() const { return m_scheduler; }
ui::UI* GetUI() const { return m_ui; }
game::Game* GetGame() const { return m_game; }
game::backend::Game* GetGame() const { return m_game; }

protected:

Expand All @@ -133,7 +133,7 @@ CLASS( Engine, common::Class );
audio::Audio* m_audio = nullptr;
network::Network* m_network = nullptr;
ui::UI* m_ui = nullptr;
game::Game* m_game = nullptr;
game::backend::Game* m_game = nullptr;

};

Expand Down
20 changes: 2 additions & 18 deletions src/game/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,25 +1,9 @@
SUBDIR( map )
SUBDIR( map_editor )
SUBDIR( rules )
SUBDIR( settings )
SUBDIR( slot )
SUBDIR( connection )
SUBDIR( animation )
SUBDIR( unit )
SUBDIR( base )
SUBDIR( bindings )
SUBDIR( event )
SUBDIR( turn )
SUBDIR( backend )
SUBDIR( frontend )

SET( SRC ${SRC}

${PWD}/Game.cpp
${PWD}/State.cpp
${PWD}/Account.cpp
${PWD}/Player.cpp
${PWD}/FrontendRequest.cpp
${PWD}/BackendRequest.cpp
${PWD}/MapObject.cpp
${PWD}/TileLock.cpp

PARENT_SCOPE )
23 changes: 12 additions & 11 deletions src/game/FrontendRequest.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,20 @@
#include <vector>
#include <string>

#include "unit/Types.h"
#include "game/turn/Types.h"
#include "backend/unit/Types.h"
#include "backend/turn/Types.h"

namespace game {

namespace backend {
namespace map::tile {
class Tile;
class TileState;
}

namespace rules {
class Faction;
}
}

class FrontendRequest {
public:
Expand Down Expand Up @@ -45,15 +46,15 @@ class FrontendRequest {

const request_type_t type = FR_NONE;

typedef std::vector< const game::rules::Faction* > faction_defines_t;
typedef std::vector< const backend::rules::Faction* > faction_defines_t;

struct slot_define_t {
size_t slot_index;
std::string faction_id;
};
typedef std::vector< slot_define_t > slot_defines_t;

typedef std::vector< std::pair< map::tile::Tile*, map::tile::TileState* > > tile_updates_t;
typedef std::vector< std::pair< backend::map::tile::Tile*, backend::map::tile::TileState* > > tile_updates_t;

union {
struct {
Expand All @@ -70,7 +71,7 @@ class FrontendRequest {
const tile_updates_t* tile_updates;
} update_tiles;
struct {
turn::turn_status_t status;
backend::turn::turn_status_t status;
} turn_status;
struct {
size_t turn_id;
Expand Down Expand Up @@ -109,18 +110,18 @@ class FrontendRequest {
float y;
float z;
} render_coords;
unit::movement_t movement;
unit::morale_t morale;
backend::unit::movement_t movement;
backend::unit::morale_t morale;
const std::string* morale_string;
unit::health_t health;
backend::unit::health_t health;
} unit_spawn;
struct {
size_t unit_id;
} unit_despawn;
struct {
size_t unit_id;
unit::movement_t movement;
unit::health_t health;
backend::unit::movement_t movement;
backend::unit::health_t health;
struct {
size_t x;
size_t y;
Expand Down
2 changes: 2 additions & 0 deletions src/game/Account.cpp → src/game/backend/Account.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include "util/UUID.h"

namespace game {
namespace backend {

Account::Account() {
if ( util::FS::FileExists( GetPath() ) ) {
Expand Down Expand Up @@ -130,3 +131,4 @@ void Account::Load() {
}

}
}
Loading

0 comments on commit 96ab706

Please sign in to comment.