Skip to content

Commit

Permalink
Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
deathkiller committed Jan 2, 2025
1 parent da98f95 commit 8de25b9
Show file tree
Hide file tree
Showing 101 changed files with 314 additions and 223 deletions.
4 changes: 2 additions & 2 deletions Sources/Jazz2.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@
<ClInclude Include="Jazz2\Rendering\CombineRenderer.h" />
<ClInclude Include="Jazz2\Rendering\LightingRenderer.h" />
<ClInclude Include="Jazz2\Rendering\PlayerViewport.h" />
<ClInclude Include="Jazz2\Rendering\UpscaleRenderPass.h" />
<ClInclude Include="Main.h" />
<ClInclude Include="Jazz2\Actors\ActorBase.h" />
<ClInclude Include="Jazz2\Actors\Collectibles\CarrotCollectible.h" />
Expand Down Expand Up @@ -520,7 +521,6 @@
<ClInclude Include="Jazz2\UI\Menu\StartGameOptionsSection.h" />
<ClInclude Include="Jazz2\UI\Menu\TouchControlsOptionsSection.h" />
<ClInclude Include="Jazz2\UI\RgbLights.h" />
<ClInclude Include="Jazz2\UI\UpscaleRenderPass.h" />
<ClInclude Include="Jazz2\WarpFlags.h" />
<ClInclude Include="Jazz2\WeaponType.h" />
<ClInclude Include="Jazz2\WeatherType.h" />
Expand Down Expand Up @@ -856,6 +856,7 @@
<ClCompile Include="Jazz2\Rendering\CombineRenderer.cpp" />
<ClCompile Include="Jazz2\Rendering\LightingRenderer.cpp" />
<ClCompile Include="Jazz2\Rendering\PlayerViewport.cpp" />
<ClCompile Include="Jazz2\Rendering\UpscaleRenderPass.cpp" />
<ClCompile Include="Jazz2\Resources.cpp" />
<ClCompile Include="Jazz2\RumbleProcessor.cpp" />
<ClCompile Include="Jazz2\Scripting\JJ2PlusDefinitions.cpp" />
Expand Down Expand Up @@ -908,7 +909,6 @@
<ClCompile Include="Jazz2\UI\Menu\StartGameOptionsSection.cpp" />
<ClCompile Include="Jazz2\UI\Menu\TouchControlsOptionsSection.cpp" />
<ClCompile Include="Jazz2\UI\RgbLights.cpp" />
<ClCompile Include="Jazz2\UI\UpscaleRenderPass.cpp" />
<ClCompile Include="nCine\AppConfiguration.cpp" />
<ClCompile Include="nCine\Application.cpp" />
<ClCompile Include="nCine\Audio\ALAudioDevice.cpp" />
Expand Down
12 changes: 6 additions & 6 deletions Sources/Jazz2.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -948,9 +948,6 @@
<ClInclude Include="Jazz2\UI\Menu\MainMenu.h">
<Filter>Header Files\Jazz2\UI\Menu</Filter>
</ClInclude>
<ClInclude Include="Jazz2\UI\UpscaleRenderPass.h">
<Filter>Header Files\Jazz2\UI</Filter>
</ClInclude>
<ClInclude Include="Jazz2\UI\Menu\MenuSection.h">
<Filter>Header Files\Jazz2\UI\Menu</Filter>
</ClInclude>
Expand Down Expand Up @@ -1569,6 +1566,9 @@
<ClInclude Include="Jazz2\Rendering\BlurRenderPass.h">
<Filter>Header Files\Jazz2\Rendering</Filter>
</ClInclude>
<ClInclude Include="Jazz2\Rendering\UpscaleRenderPass.h">
<Filter>Header Files\Jazz2\Rendering</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="Main.cpp">
Expand Down Expand Up @@ -2114,9 +2114,6 @@
<ClCompile Include="Jazz2\UI\Menu\MainMenu.cpp">
<Filter>Source Files\Jazz2\UI\Menu</Filter>
</ClCompile>
<ClCompile Include="Jazz2\UI\UpscaleRenderPass.cpp">
<Filter>Source Files\Jazz2\UI</Filter>
</ClCompile>
<ClCompile Include="Jazz2\UI\Menu\BeginSection.cpp">
<Filter>Source Files\Jazz2\UI\Menu</Filter>
</ClCompile>
Expand Down Expand Up @@ -2573,6 +2570,9 @@
<ClCompile Include="Jazz2\Rendering\PlayerViewport.cpp">
<Filter>Source Files\Jazz2\Rendering</Filter>
</ClCompile>
<ClCompile Include="Jazz2\Rendering\UpscaleRenderPass.cpp">
<Filter>Source Files\Jazz2\Rendering</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="Resources.rc">
Expand Down
2 changes: 1 addition & 1 deletion Sources/Jazz2/Actors/Collectibles/CollectibleBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ namespace Jazz2::Actors::Collectibles

if ((details.State & ActorState::Illuminated) == ActorState::Illuminated) {
_illuminateLights.reserve(IlluminateLightCount);
for (int i = 0; i < IlluminateLightCount; i++) {
for (std::int32_t i = 0; i < IlluminateLightCount; i++) {
auto& light = _illuminateLights.emplace_back();
light.Intensity = Random().NextFloat(0.22f, 0.42f);
light.Distance = Random().NextFloat(4.0f, 36.0f);
Expand Down
2 changes: 2 additions & 0 deletions Sources/Jazz2/Compatibility/AnimSetMapping.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@ namespace Jazz2::Compatibility
Menu
};

/** @brief Maps indices from original data file to organized entries */
class AnimSetMapping
{
public:
static constexpr char Discard[] = ":discard";

/** @brief Mapped entry */
struct Entry {
String Category;
String Name;
Expand Down
1 change: 1 addition & 0 deletions Sources/Jazz2/Compatibility/EventConverter.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ namespace Jazz2::Compatibility
constexpr std::int32_t JJ2ParamUInt = 2;
constexpr std::int32_t JJ2ParamInt = 3;

/** @brief Maps original events to extended event descriptions */
class EventConverter
{
public:
Expand Down
6 changes: 5 additions & 1 deletion Sources/Jazz2/Compatibility/JJ2Anims.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ using namespace nCine;

namespace Jazz2::Compatibility
{
class JJ2Anims // .j2a
/** @brief Parses original `.j2a` animation files */
class JJ2Anims
{
public:
static constexpr std::uint16_t CacheVersion = 22;
Expand All @@ -29,6 +30,8 @@ namespace Jazz2::Compatibility
private:
static constexpr int32_t AddBorder = 2;

#ifndef DOXYGEN_GENERATING_OUTPUT
// Doxygen 1.12.0 outputs also private structs/unions even if it shouldn't
struct AnimFrameSection {
std::int16_t SizeX, SizeY;
std::int16_t ColdspotX, ColdspotY;
Expand Down Expand Up @@ -64,6 +67,7 @@ namespace Jazz2::Compatibility
std::unique_ptr<std::uint8_t[]> Data;
std::uint16_t Multiplier;
};
#endif

JJ2Anims();

Expand Down
1 change: 1 addition & 0 deletions Sources/Jazz2/Compatibility/JJ2Block.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ using namespace Death::IO;

namespace Jazz2::Compatibility
{
/** @brief Processes compressed or uncompressed blocks from original files */
class JJ2Block
{
public:
Expand Down
6 changes: 4 additions & 2 deletions Sources/Jazz2/Compatibility/JJ2Data.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ using namespace Death::IO;

namespace Jazz2::Compatibility
{
class JJ2Data // .j2d
/** @brief Parses original `.j2d` data files */
class JJ2Data
{
public:
/** @brief Item from a `.j2d` data file */
struct Item {
String Filename;
std::unique_ptr<uint8_t[]> Blob;
Expand All @@ -26,7 +28,7 @@ namespace Jazz2::Compatibility

SmallVector<Item, 0> Items;

JJ2Data() { }
JJ2Data() {}

bool Open(const StringView path, bool strictParser);

Expand Down
3 changes: 2 additions & 1 deletion Sources/Jazz2/Compatibility/JJ2Episode.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ using namespace Death::Containers;

namespace Jazz2::Compatibility
{
class JJ2Episode // .j2e / .j2pe
/** @brief Parses original `.j2e`/`.j2pe` episode files */
class JJ2Episode
{
public:
std::int32_t Position;
Expand Down
4 changes: 2 additions & 2 deletions Sources/Jazz2/Compatibility/JJ2Level.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -436,11 +436,11 @@ namespace Jazz2::Compatibility
JJ2Level extraLayersFile;
if (extraLayersFile.Open(extraLayersPath, strictParser)) {
for (std::int32_t j = 0; j < 8 && (i + j) < layerCount; j++) {
_layers.emplace_back(std::move(extraLayersFile._layers[j]));
_layers.push_back(std::move(extraLayersFile._layers[j]));
}
} else {
for (std::int32_t j = 0; j < 8 && (i + j) < layerCount; j++) {
_layers.emplace_back(LayerSection{});
_layers.emplace_back();
}
}
}
Expand Down
6 changes: 5 additions & 1 deletion Sources/Jazz2/Compatibility/JJ2Level.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ namespace Jazz2::Compatibility
{
class JJ2Episode;

class JJ2Level // .j2l
/** @brief Parses original `.j2l` level files */
class JJ2Level
{
friend class JJ2Episode;

Expand Down Expand Up @@ -79,6 +80,8 @@ namespace Jazz2::Compatibility
SpeedMultipliers
};

#ifndef DOXYGEN_GENERATING_OUTPUT
// Doxygen 1.12.0 outputs also private structs/unions even if it shouldn't
struct LayerSection {
std::uint32_t Flags;
std::uint8_t Type; // Ignored
Expand Down Expand Up @@ -132,6 +135,7 @@ namespace Jazz2::Compatibility
std::uint8_t FrameCount;
std::uint16_t Frames[64];
};
#endif

JJ2Version _version;

Expand Down
2 changes: 1 addition & 1 deletion Sources/Jazz2/Compatibility/JJ2Strings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ namespace Jazz2::Compatibility
s->Read(levelName, 8);
levelName[8] = '\0';

LevelEntry& levelEntry = LevelTexts.emplace_back(String(levelName));
LevelEntry& levelEntry = LevelTexts.emplace_back(levelName);
StringUtils::lowercaseInPlace(levelEntry.Name);

/*uint8_t unknown =*/ s->ReadValue<std::uint8_t>();
Expand Down
4 changes: 3 additions & 1 deletion Sources/Jazz2/Compatibility/JJ2Strings.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,11 @@ using namespace Death::Containers;

namespace Jazz2::Compatibility
{
class JJ2Strings // .j2s
/** @brief Parses original `.j2s` localization files */
class JJ2Strings
{
public:
/** @brief Texts for specific level */
struct LevelEntry
{
String Name;
Expand Down
6 changes: 5 additions & 1 deletion Sources/Jazz2/Compatibility/JJ2Tileset.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ using namespace Death::Containers;

namespace Jazz2::Compatibility
{
class JJ2Tileset // .j2t
/** @brief Parses original `.j2t` tileset files */
class JJ2Tileset
{
public:
static constexpr std::int32_t BlockSize = 32;
Expand All @@ -29,6 +30,8 @@ namespace Jazz2::Compatibility
}

private:
#ifndef DOXYGEN_GENERATING_OUTPUT
// Doxygen 1.12.0 outputs also private structs/unions even if it shouldn't
struct TilesetTileSection {
bool Opaque;
std::uint32_t ImageDataOffset;
Expand All @@ -39,6 +42,7 @@ namespace Jazz2::Compatibility
//std::uint8_t Mask[BlockSize * BlockSize];
std::uint8_t Mask[BlockSize * BlockSize / 8];
};
#endif

static constexpr std::int32_t PaletteSize = 256;

Expand Down
4 changes: 2 additions & 2 deletions Sources/Jazz2/ContentResolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -631,12 +631,12 @@ namespace Jazz2
auto it = _cachedSounds.find(assetPathNormalized);
if (it != _cachedSounds.end()) {
it->second->Flags |= GenericSoundResourceFlags::Referenced;
sound.Buffers.emplace_back(it->second.get());
sound.Buffers.push_back(it->second.get());
} else {
auto s = OpenContentFile(fs::CombinePath("Animations"_s, assetPathNormalized));
auto res = _cachedSounds.emplace(assetPathNormalized, std::make_unique<GenericSoundResource>(std::move(s), assetPathNormalized));
res.first->second->Flags |= GenericSoundResourceFlags::Referenced;
sound.Buffers.emplace_back(res.first->second.get());
sound.Buffers.push_back(res.first->second.get());
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/Jazz2/IResumable.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ using namespace Death::IO;

namespace Jazz2
{
/** @brief Base interface of a resumable objects */
/** @brief Base interface of a resumable object */
class IResumable
{
public:
Expand Down
6 changes: 3 additions & 3 deletions Sources/Jazz2/LevelHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -771,7 +771,7 @@ namespace Jazz2
actor->CollisionProxyID = _collisions.CreateProxy(actor->AABB, actor.get());
}

_actors.emplace_back(actor);
_actors.push_back(std::move(actor));
}

std::shared_ptr<AudioBufferPlayer> LevelHandler::PlaySfx(Actors::ActorBase* self, const StringView identifier, AudioBuffer* buffer, const Vector3f& pos, bool sourceRelative, float gain, float pitch)
Expand Down Expand Up @@ -1587,7 +1587,7 @@ namespace Jazz2
}

if (!found) {
playerZones.emplace_back(cullingRect);
playerZones.push_back(std::move(cullingRect));
}
}

Expand Down Expand Up @@ -1742,7 +1742,7 @@ namespace Jazz2

void LevelHandler::AssignViewport(Actors::Player* player)
{
_assignedViewports.emplace_back(std::make_unique<Rendering::PlayerViewport>(this, player));
_assignedViewports.push_back(std::make_unique<Rendering::PlayerViewport>(this, player));

#if defined(WITH_AUDIO)
for (auto& current : _playingSounds) {
Expand Down
4 changes: 2 additions & 2 deletions Sources/Jazz2/LevelHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
#include "Tiles/ITileMapOwner.h"
#include "Tiles/TileMap.h"
#include "Collisions/DynamicTreeBroadPhase.h"
#include "Rendering/UpscaleRenderPass.h"
#include "UI/ControlScheme.h"
#include "UI/UpscaleRenderPass.h"
#include "UI/Menu/InGameMenu.h"

#include "../nCine/Graphics/Shader.h"
Expand Down Expand Up @@ -189,7 +189,7 @@ namespace Jazz2
Shader* _combineShader;
Shader* _combineWithWaterShader;

UI::UpscaleRenderPassWithClipping _upscalePass;
Rendering::UpscaleRenderPassWithClipping _upscalePass;

std::unique_ptr<SceneNode> _rootNode;
std::unique_ptr<Texture> _noiseTexture;
Expand Down
2 changes: 1 addition & 1 deletion Sources/Jazz2/LightEmitter.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ using namespace nCine;

namespace Jazz2
{
/** @brief Light emitter */
/** @brief Allows objects to emit light */
struct LightEmitter
{
Vector2f Pos;
Expand Down
1 change: 1 addition & 0 deletions Sources/Jazz2/Multiplayer/ConnectionResult.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

namespace Jazz2::Multiplayer
{
/** @brief Describes a connection result of @ref INetworkHandler::OnPeerConnected() */
struct ConnectionResult
{
Reason FailureReason;
Expand Down
5 changes: 5 additions & 0 deletions Sources/Jazz2/Multiplayer/INetworkHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ using namespace Death::Containers;

namespace Jazz2::Multiplayer
{
/**
@brief Interface to handle network requests on a server
@experimental
*/
class INetworkHandler
{
public:
Expand Down
4 changes: 2 additions & 2 deletions Sources/Jazz2/Multiplayer/MultiLevelHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1150,7 +1150,7 @@ namespace Jazz2::Multiplayer
// Cache all possible multiplayer spawn points (if it's not coop level)
_multiplayerSpawnPoints.clear();
_eventMap->ForEachEvent(EventType::LevelStartMultiplayer, [this](const Events::EventMap::EventTile& event, std::int32_t x, std::int32_t y) {
_multiplayerSpawnPoints.emplace_back(MultiplayerSpawnPoint { Vector2f(x * Tiles::TileSet::DefaultTileSize, y * Tiles::TileSet::DefaultTileSize - 8), event.EventParams[0] });
_multiplayerSpawnPoints.emplace_back(Vector2f(x * Tiles::TileSet::DefaultTileSize, y * Tiles::TileSet::DefaultTileSize - 8), event.EventParams[0]);
return true;
});
} else {
Expand Down Expand Up @@ -2254,7 +2254,7 @@ namespace Jazz2::Multiplayer
std::int32_t splitIdx = (playerCount + 1) / 2;
SmallVector<std::int32_t, 0> teamIds(playerCount);
for (std::int32_t i = 0; i < playerCount; i++) {
teamIds.emplace_back(i);
teamIds.push_back(i);
}
Random().Shuffle(arrayView(teamIds));

Expand Down
3 changes: 3 additions & 0 deletions Sources/Jazz2/Multiplayer/MultiLevelHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,9 @@ namespace Jazz2::Multiplayer
struct MultiplayerSpawnPoint {
Vector2f Pos;
std::uint8_t Team;

MultiplayerSpawnPoint(Vector2f pos, std::uint8_t team)
: Pos(pos), Team(team) {}
};
#endif

Expand Down
1 change: 1 addition & 0 deletions Sources/Jazz2/Multiplayer/MultiplayerGameMode.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Jazz2::Multiplayer
{
/** @brief Multiplayer game mode */
enum class MultiplayerGameMode
{
Unknown = 0,
Expand Down
Loading

0 comments on commit 8de25b9

Please sign in to comment.