diff options
-rw-r--r-- | CHANGELOG.md | 9 | ||||
-rw-r--r-- | README.md | 2 | ||||
-rw-r--r-- | bowshock/CMakeLists.txt | 3 | ||||
-rw-r--r-- | bowshock/include/bow/logic.hxx | 113 | ||||
-rw-r--r-- | bowshock/source/client/PlayerData/decode_save.cxx | 2 | ||||
-rw-r--r-- | bowshock/source/logic/Canister/constructor.cxx | 2 | ||||
-rw-r--r-- | bowshock/source/logic/Ship/constructor.cxx | 2 | ||||
-rw-r--r-- | bowshock/source/logic/Ship/net_mass.cxx | 2 | ||||
-rw-r--r-- | bowshock/source/logic/Star/constructor.cxx | 2 | ||||
-rw-r--r-- | bowshock/source/logic/Station/constructor.cxx | 2 | ||||
-rw-r--r-- | bowshock/source/logic/World/constructor.cxx | 2 | ||||
-rw-r--r-- | bowshock/source/logic/hull_mass.cxx | 18 | ||||
-rw-r--r-- | bowshock/source/logic/ware_density.cxx | 9 | ||||
-rw-r--r-- | bowshock/source/logic/ware_mass.cxx | 9 | ||||
-rw-r--r-- | bowshock/source/server/ServerInstance/generate_system.cxx | 4 |
15 files changed, 108 insertions, 73 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index baf164b..f6f5810 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # 0.C.0 +*0.C.0-E* + +* Update readme +* Add function for getting the hull mass of a ship type +* Update commenting +* Don't define object-kind type types inside their appropriate class +* Rename ware_mass to ware_density +* Add ship type 'canis' + *0.C.0-D* * Update readme @@ -50,7 +50,7 @@ build/bowshock/bowshock --skip ## SHADER VALIDATION -The shaders at bowshock/shader may be validated using the Python script `validateShaders.py`. If the shaders contain errors, and these are not fixed before installation, the program will fail to compile them during run‐time. +The shaders at `bowshock/shader`` may be validated using the Python script `validateShaders.py`. If the shaders contain errors, and these are not fixed before installation, the program will fail to compile them during run‐time. # INSTALLATION diff --git a/bowshock/CMakeLists.txt b/bowshock/CMakeLists.txt index 9826336..6553dc3 100644 --- a/bowshock/CMakeLists.txt +++ b/bowshock/CMakeLists.txt @@ -53,6 +53,7 @@ add_executable( "source/logic/Canister/constructor.cxx" "source/logic/Canister/object_type_string.cxx" + "source/logic/hull_mass.cxx" "source/logic/Object/object_type_string.cxx" "source/logic/Ship/constructor.cxx" "source/logic/Ship/net_mass.cxx" @@ -61,7 +62,7 @@ add_executable( "source/logic/Star/object_type_string.cxx" "source/logic/Station/constructor.cxx" "source/logic/Station/object_type_string.cxx" - "source/logic/ware_mass.cxx" + "source/logic/ware_density.cxx" "source/logic/World/constructor.cxx" "source/logic/World/object_type_string.cxx" diff --git a/bowshock/include/bow/logic.hxx b/bowshock/include/bow/logic.hxx index ba9c6a1..bd6a36c 100644 --- a/bowshock/include/bow/logic.hxx +++ b/bowshock/include/bow/logic.hxx @@ -9,6 +9,11 @@ #include <type_traits> namespace bow { + // Each of the three main measures (distance, mass, + // and time) have their own modifier. These + // modifiers are used to change the "fundamental" + // units used. + constexpr double DISTANCE_MODIFIER = 0x1.16A5D2D360000000p037; // 1 astronomical unit constexpr double MASS_MODIFIER = 0x1.91930A5E75F0C192p100; // 1 solar mass constexpr double TIME_MODIFIER = 0x1.0000000000000000p012; // 1 second @@ -134,23 +139,25 @@ namespace bow { [[nodiscard]] virtual auto object_type_string() const noexcept -> ::std::string; }; + enum struct ShipType: ::std::uint8_t { + Aquila, + Canis, + Cassiopeia, + Centaurus, + Corvus, + Cursor, + Eridanus, + Falco, + Lyra, + Taurus, + Ursa, + Vipera, + }; + constexpr ::std::uint8_t MAXIMUM_SHIP_IDENTIFIER = static_cast<::std::uint8_t>(bow::ShipType::Vipera); + class Ship final: public ::bow::Object { public: - enum struct Type: ::std::uint8_t { - Aquila, - Cassiopeia, - Centaurus, - Corvus, - Cursor, - Eridanus, - Falco, - Lyra, - Taurus, - Ursa, - Vipera, - }; - - ::bow::Ship::Type type; + ::bow::ShipType type; Ship() noexcept; @@ -158,67 +165,67 @@ namespace bow { [[nodiscard]] auto net_mass() noexcept -> double; }; - constexpr ::std::uint8_t MAXIMUM_SHIP_IDENTIFIER = static_cast<::std::uint8_t>(bow::Ship::Type::Vipera); + + enum struct StarType: ::std::uint8_t { + A, // Main sequence + B, // Main sequence + C, // Carbon + F, // Main sequence + G, // Main sequence + K, // Main sequence + L, // Brown dwarf + M, // Main sequence + N, // Neutron star + O, // Main sequence + S, // Carbon + T, // Brown dwarf + W, // Worm hole + X, // Black hole + Y, // Brown dwarf + Z, // White hole + }; class Star final: public ::bow::Object { public: - enum struct Type: ::std::uint8_t { - A, // Main sequence - B, // Main sequence - C, // Carbon - F, // Main sequence - G, // Main sequence - K, // Main sequence - L, // Brown dwarf - M, // Main sequence - N, // Neutron star - O, // Main sequence - S, // Carbon - T, // Brown dwarf - W, // Worm hole - X, // Black hole - Y, // Brown dwarf - Z, // White hole - }; - - ::bow::Star::Type type; + ::bow::StarType type; Star() noexcept; [[nodiscard]] virtual auto object_type_string() const noexcept -> ::std::string; }; + enum struct StationType: ::std::uint8_t { + Globus, + Orbis, + }; + class Station final: public ::bow::Object { public: - enum struct Type: ::std::uint8_t { - Globus, - Orbis, - }; - - ::bow::Station::Type type; + ::bow::StationType type; Station() noexcept; [[nodiscard]] virtual auto object_type_string() const noexcept -> ::std::string; }; + enum struct WorldType: ::std::uint8_t { + AmmoniumWorld, + GasGiant, + IceWorld, + LavaWorld, + RockyWorld, + WaterWorld, + }; + class World final: public ::bow::Object { public: - enum struct Type: ::std::uint8_t { - AmmoniumWorld, - GasGiant, - IceWorld, - LavaWorld, - RockyWorld, - WaterWorld, - }; - - ::bow::World::Type type; + ::bow::WorldType type; World() noexcept; [[nodiscard]] virtual auto object_type_string() const noexcept -> ::std::string; }; - [[nodiscard]] auto ware_mass(::bow::Ware const ware) noexcept -> double; + [[nodiscard]] auto hull_mass( ::bow::ShipType ship) noexcept -> double; + [[nodiscard]] auto ware_density(::bow::Ware ware) noexcept -> double; } diff --git a/bowshock/source/client/PlayerData/decode_save.cxx b/bowshock/source/client/PlayerData/decode_save.cxx index 626fce3..a4f57ef 100644 --- a/bowshock/source/client/PlayerData/decode_save.cxx +++ b/bowshock/source/client/PlayerData/decode_save.cxx @@ -66,7 +66,7 @@ auto bow::PlayerData::decode_save(::bow::PlayerData & buffer, ::std::array<::std buffer.time = data.time, buffer.system_identifier = data.system_identifier, - buffer.ship.type = static_cast<::bow::Ship::Type>(data.ship_type), + buffer.ship.type = static_cast<::bow::ShipType>(data.ship_type), buffer.ship.position.x = data.ship_position_x, buffer.ship.position.y = data.ship_position_y, buffer.ship.position.z = data.ship_position_z, diff --git a/bowshock/source/logic/Canister/constructor.cxx b/bowshock/source/logic/Canister/constructor.cxx index 0067623..cc40917 100644 --- a/bowshock/source/logic/Canister/constructor.cxx +++ b/bowshock/source/logic/Canister/constructor.cxx @@ -20,5 +20,5 @@ bow::Canister::Canister() noexcept { this->mass = 0x0p0; this->content = ::bow::Ware::Biowaste; - this->mass = ::bow::ware_mass(this->content) * 0x1p0; + this->mass = ::bow::ware_density(this->content) * 0x1p0; } diff --git a/bowshock/source/logic/Ship/constructor.cxx b/bowshock/source/logic/Ship/constructor.cxx index 50d46a7..8c1532e 100644 --- a/bowshock/source/logic/Ship/constructor.cxx +++ b/bowshock/source/logic/Ship/constructor.cxx @@ -18,7 +18,7 @@ bow::Ship::Ship() noexcept { this->rotational_velocity.y = 0x0p0; this->rotational_velocity.z = 0x0p0; this->mass = 0x0p0; - this->type = ::bow::Ship::Type::Aquila; + this->type = ::bow::ShipType::Aquila; this->mass = this->net_mass(); } diff --git a/bowshock/source/logic/Ship/net_mass.cxx b/bowshock/source/logic/Ship/net_mass.cxx index bfe941d..352117c 100644 --- a/bowshock/source/logic/Ship/net_mass.cxx +++ b/bowshock/source/logic/Ship/net_mass.cxx @@ -3,7 +3,7 @@ #include <bow/logic.hxx> auto bow::Ship::net_mass() noexcept -> double { - double mass = 0x1p0 / ::bow::MASS_MODIFIER; + double mass = ::bow::hull_mass(this->type); return mass; } diff --git a/bowshock/source/logic/Star/constructor.cxx b/bowshock/source/logic/Star/constructor.cxx index 8db89f2..799fb38 100644 --- a/bowshock/source/logic/Star/constructor.cxx +++ b/bowshock/source/logic/Star/constructor.cxx @@ -18,5 +18,5 @@ bow::Star::Star() noexcept { this->rotational_velocity.y = 0x0p0; this->rotational_velocity.z = 0x0p0; this->mass = 0x1p0; - this->type = ::bow::Star::Type::G; + this->type = ::bow::StarType::G; } diff --git a/bowshock/source/logic/Station/constructor.cxx b/bowshock/source/logic/Station/constructor.cxx index df6eecf..e2fd4a4 100644 --- a/bowshock/source/logic/Station/constructor.cxx +++ b/bowshock/source/logic/Station/constructor.cxx @@ -18,5 +18,5 @@ bow::Station::Station() noexcept { this->rotational_velocity.y = 0x0p0; this->rotational_velocity.z = 0x0p0; this->mass = 0x0p0; - this->type = ::bow::Station::Type::Orbis; + this->type = ::bow::StationType::Orbis; } diff --git a/bowshock/source/logic/World/constructor.cxx b/bowshock/source/logic/World/constructor.cxx index 57d1cd1..e7ec793 100644 --- a/bowshock/source/logic/World/constructor.cxx +++ b/bowshock/source/logic/World/constructor.cxx @@ -18,5 +18,5 @@ bow::World::World() noexcept { this->rotational_velocity.y = 0x0p0; this->rotational_velocity.z = 0x0p0; this->mass = 0x1p0; - this->type = ::bow::World::Type::RockyWorld; + this->type = ::bow::WorldType::RockyWorld; } diff --git a/bowshock/source/logic/hull_mass.cxx b/bowshock/source/logic/hull_mass.cxx new file mode 100644 index 0000000..56938f4 --- /dev/null +++ b/bowshock/source/logic/hull_mass.cxx @@ -0,0 +1,18 @@ +// Copyright 2022-2023 Gabriel Bjørnager Jensen. + +#include <bow/logic.hxx> + +auto bow::hull_mass(::bow::ShipType const ship) noexcept -> double { + using ::bow::ShipType; + + double mass = 0x0p0; + + switch (ship) { + default: + mass = 0x1p0; + case ShipType::Aquila: + mass = 0x100p0; + } + + return mass / ::bow::MASS_MODIFIER; +} diff --git a/bowshock/source/logic/ware_density.cxx b/bowshock/source/logic/ware_density.cxx new file mode 100644 index 0000000..97690a0 --- /dev/null +++ b/bowshock/source/logic/ware_density.cxx @@ -0,0 +1,9 @@ +// Copyright 2022-2023 Gabriel Bjørnager Jensen. + +#include <bow/logic.hxx> + +auto bow::ware_density([[maybe_unused]] ::bow::Ware const ware) noexcept -> double { + double mass = 0x1p0; + + return mass / ::bow::MASS_MODIFIER; +} diff --git a/bowshock/source/logic/ware_mass.cxx b/bowshock/source/logic/ware_mass.cxx deleted file mode 100644 index 58afc2d..0000000 --- a/bowshock/source/logic/ware_mass.cxx +++ /dev/null @@ -1,9 +0,0 @@ -// Copyright 2022-2023 Gabriel Bjørnager Jensen. - -#include <bow/logic.hxx> - -auto bow::ware_mass([[maybe_unused]] ::bow::Ware const ware) noexcept -> double { - double mass = 0x1p0 / ::bow::MASS_MODIFIER; - - return mass; -} diff --git a/bowshock/source/server/ServerInstance/generate_system.cxx b/bowshock/source/server/ServerInstance/generate_system.cxx index 9b97300..b8ca6cf 100644 --- a/bowshock/source/server/ServerInstance/generate_system.cxx +++ b/bowshock/source/server/ServerInstance/generate_system.cxx @@ -20,7 +20,7 @@ auto bow::ServerInstance::generate_system(::bow::ObjectRoot& system, ::std::uint auto star = ::bow::Star(); star.mass = 0x1p0, - star.type = ::bow::Star::Type::G; + star.type = ::bow::StarType::G; return star; }()); @@ -32,7 +32,7 @@ auto bow::ServerInstance::generate_system(::bow::ObjectRoot& system, ::std::uint world.positional_velocity.x = 0x1.B2D06FF3p-23 * ::bow::TIME_MODIFIER; world.rotational_velocity.z = 0x1.31DB66BBp-15; world.mass = 0x1.931AFC649369998Fp-19, - world.type = ::bow::World::Type::RockyWorld; + world.type = ::bow::WorldType::RockyWorld; return world; }()); |