Skip to content
This repository has been archived by the owner on Jan 5, 2024. It is now read-only.

Commit

Permalink
Merge branch 'development' into thread-pooling
Browse files Browse the repository at this point in the history
  • Loading branch information
Causeless committed Nov 21, 2023
2 parents 6e5ca8c + d3a53f5 commit 74fb0b5
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 32 deletions.
8 changes: 8 additions & 0 deletions Entities/MOSParticle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,14 @@ namespace RTE {
if (m_pScreenEffect) { SetPostScreenEffectToDraw(); }
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

void MOSParticle::Update() {
MOSprite::Update();

if (m_pScreenEffect) { SetPostScreenEffectToDraw(); }
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

void MOSParticle::Draw(BITMAP *targetBitmap, const Vector &targetPos, DrawMode mode, bool onlyPhysical) const {
Expand Down
5 changes: 5 additions & 0 deletions Entities/MOSParticle.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,11 @@ namespace RTE {
/// <returns>Whether the MOSParticle should immediately halt any travel going on after this sinkage.</returns>
bool OnSink(HitData &hd) override { return false; }

/// <summary>
/// Updates this MOParticle. Supposed to be done every frame.
/// </summary>
void Update() override;

/// <summary>
/// Draws this MOSParticle's current graphical representation to a BITMAP of choice.
/// </summary>
Expand Down
18 changes: 9 additions & 9 deletions Managers/PostProcessMan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,29 +177,29 @@ namespace RTE {

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

void PostProcessMan::AdjustEffectsPosToPlayerScreen(int playerScreen, BITMAP *targetBitmap, const Vector &targetBitmapOffset, std::list<PostEffect> &screenRelativeEffectsList, std::list<Box> &screenRelativeGlowBoxesList) const {
void PostProcessMan::AdjustEffectsPosToPlayerScreen(int playerScreen, BITMAP *targetBitmap, const Vector &targetBitmapOffset, std::list<PostEffect> &screenRelativeEffectsList, std::list<Box> &screenRelativeGlowBoxesList) {
int screenOcclusionOffsetX = g_CameraMan.GetScreenOcclusion(playerScreen).GetFloorIntX();
int screenOcclusionOffsetY = g_CameraMan.GetScreenOcclusion(playerScreen).GetFloorIntY();
int occludedOffsetX = targetBitmap->w + screenOcclusionOffsetX;
int occludedOffsetY = targetBitmap->h + screenOcclusionOffsetY;

// Copy post effects received by client if in network mode
if (g_FrameMan.GetDrawNetworkBackBuffer()) {
g_PostProcessMan.GetNetworkPostEffectsList(0, screenRelativeEffectsList);
GetNetworkPostEffectsList(0, screenRelativeEffectsList);
}

// Adjust for the player screen's position on the final buffer
for (const PostEffect &postEffect : screenRelativeEffectsList) {
// Make sure we won't be adding any effects to a part of the screen that is occluded by menus and such
if (postEffect.m_Pos.GetFloorIntX() > screenOcclusionOffsetX && postEffect.m_Pos.GetFloorIntY() > screenOcclusionOffsetY && postEffect.m_Pos.GetFloorIntX() < occludedOffsetX && postEffect.m_Pos.GetFloorIntY() < occludedOffsetY) {
g_PostProcessMan.GetPostScreenEffectsList()->push_back(PostEffect(postEffect.m_Pos + targetBitmapOffset, postEffect.m_Bitmap, postEffect.m_BitmapHash, postEffect.m_Strength, postEffect.m_Angle));
m_PostSceneEffects.emplace_back(postEffect.m_Pos + targetBitmapOffset, postEffect.m_Bitmap, postEffect.m_BitmapHash, postEffect.m_Strength, postEffect.m_Angle);
}
}
// Adjust glow areas for the player screen's position on the final buffer
for (const Box &glowBox : screenRelativeGlowBoxesList) {
g_PostProcessMan.GetPostScreenGlowBoxesList()->push_back(glowBox);
m_PostScreenGlowBoxes.push_back(glowBox);
// Adjust each added glow area for the player screen's position on the final buffer
g_PostProcessMan.GetPostScreenGlowBoxesList()->back().m_Corner += targetBitmapOffset;
m_PostScreenGlowBoxes.back().m_Corner += targetBitmapOffset;
}
}

Expand All @@ -208,9 +208,6 @@ namespace RTE {
void PostProcessMan::RegisterPostEffect(const Vector &effectPos, BITMAP *effect, size_t hash, int strength, float angle) {
// These effects get applied when there's a drawn frame that followed one or more sim updates.
// They are not only registered on drawn sim updates; flashes and stuff could be missed otherwise if they occur on undrawn sim updates.
if (effect && !effect->extra) {
LazyInitBitmap(effect);
}

if (effect && g_TimerMan.SimUpdatesSinceDrawn() >= 0) {
m_PostSceneEffects.push_back(PostEffect(effectPos, effect, hash, strength, angle));
Expand Down Expand Up @@ -516,7 +513,7 @@ namespace RTE {

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

void PostProcessMan::DrawPostScreenEffects() const {
void PostProcessMan::DrawPostScreenEffects() {
BITMAP *effectBitmap = nullptr;
float effectPosX = 0;
float effectPosY = 0;
Expand All @@ -530,6 +527,9 @@ namespace RTE {

for (const PostEffect &postEffect : m_PostScreenEffects) {
if (postEffect.m_Bitmap) {
if (!postEffect.m_Bitmap->extra) {
LazyInitBitmap(postEffect.m_Bitmap);
}
effectBitmap = postEffect.m_Bitmap;
effectStrength = postEffect.m_Strength / 255.f;
effectPosX = postEffect.m_Pos.m_X;
Expand Down
15 changes: 2 additions & 13 deletions Managers/PostProcessMan.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,16 +95,10 @@ namespace RTE {
/// <param name="targetBitmapOffset">The position of the specified player's draw screen on the backbuffer.</param>
/// <param name="screenRelativeEffectsList">List of the specified player's accumulated post effects for this frame.</param>
/// <param name="screenRelativeGlowBoxesList">List of the specified player's accumulated glow boxes for this frame.</param>
void AdjustEffectsPosToPlayerScreen(int playerScreen, BITMAP *targetBitmap, const Vector &targetBitmapOffset, std::list<PostEffect> &screenRelativeEffectsList, std::list<Box> &screenRelativeGlowBoxesList) const;
void AdjustEffectsPosToPlayerScreen(int playerScreen, BITMAP *targetBitmap, const Vector &targetBitmapOffset, std::list<PostEffect> &screenRelativeEffectsList, std::list<Box> &screenRelativeGlowBoxesList);
#pragma endregion

#pragma region Post Effect Handling
/// <summary>
/// Gets the list of effects to apply at the end of each frame.
/// </summary>
/// <returns>The list of effects to apply at the end of each frame.</returns>
std::list<PostEffect> * GetPostScreenEffectsList() { return &m_PostScreenEffects; }

/// <summary>
/// Registers a post effect to be added at the very last stage of 32bpp rendering by the FrameMan.
/// </summary>
Expand Down Expand Up @@ -136,11 +130,6 @@ namespace RTE {
#pragma endregion

#pragma region Post Pixel Glow Handling
/// <summary>
/// Gets the list of areas that will be processed with glow.
/// </summary>
/// <returns>The list of areas that will be processed with glow.</returns>
std::list<Box> * GetPostScreenGlowBoxesList() { return &m_PostScreenGlowBoxes; }

/// <summary>
/// Registers a specific IntRect to be post-processed and have special pixel colors lit up by glow effects in it.
Expand Down Expand Up @@ -284,7 +273,7 @@ namespace RTE {
/// <summary>
/// Draws all the glow effects registered for this frame. This is called from PostProcess().
/// </summary>
void DrawPostScreenEffects() const;
void DrawPostScreenEffects();
#pragma endregion

/// <summary>
Expand Down
35 changes: 25 additions & 10 deletions Managers/UInputMan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -651,16 +651,7 @@ namespace RTE {
return false;
}
if (IsInMultiplayerMode()) {
if (whichPlayer < Players::PlayerOne || whichPlayer >= Players::MaxPlayerCount) {
for (int player = Players::PlayerOne; player < Players::MaxPlayerCount; player++) {
if (m_NetworkServerChangedMouseButtonState[player][whichButton]) {
return m_NetworkServerChangedMouseButtonState[player][whichButton];
}
}
return m_NetworkServerChangedMouseButtonState[Players::PlayerOne][whichButton];
} else {
return m_NetworkServerChangedMouseButtonState[whichPlayer][whichButton];
}
return GetNetworkMouseButtonState(whichPlayer, whichButton, whichState);
}

switch (whichState) {
Expand All @@ -676,6 +667,30 @@ namespace RTE {
}
}

bool UInputMan::GetNetworkMouseButtonState(int whichPlayer, int whichButton, InputState whichState) const {

if (whichPlayer == Players::NoPlayer || whichPlayer >= Players::MaxPlayerCount) {
for (int player = Players::PlayerOne; player < Players::MaxPlayerCount; ++player) {
if (GetNetworkMouseButtonState(player, whichButton, whichState)) {
return true;
}
}
return false;
}

switch (whichState) {
case InputState::Held:
return m_NetworkServerPreviousMouseButtonState[whichPlayer][whichButton];
case InputState::Pressed:
return m_NetworkServerPreviousMouseButtonState[whichPlayer][whichButton] && m_NetworkServerChangedMouseButtonState[whichPlayer][whichButton];
case InputState::Released:
return !m_NetworkServerPreviousMouseButtonState[whichPlayer][whichButton] && m_NetworkServerChangedMouseButtonState[whichPlayer][whichButton];
default:
RTEAbort("Undefined InputState value passed in. See InputState enumeration.");
return false;
}
}

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

bool UInputMan::GetJoystickButtonState(int whichJoy, int whichButton, InputState whichState) const {
Expand Down
9 changes: 9 additions & 0 deletions Managers/UInputMan.h
Original file line number Diff line number Diff line change
Expand Up @@ -757,6 +757,15 @@ namespace RTE {
/// <returns>Whether the mouse button is in the specified state or not.</returns>
bool GetMouseButtonState(int whichPlayer, int whichButton, InputState whichState) const;

/// <summary>
/// Gets whether a multiplayer mouse button is in the specified state.
/// </summary>
/// <param name="whichPlayer">Which player to check for. See Players enumeration.</param>
/// <param name="whichButton">Which mouse button to check for. See MouseButtons enumeration.</param>
/// <param name="whichState">Which state to check for. See InputState enumeration.</param>
/// <returns>Whether the mouse button is in the specified state or not.</returns>
bool GetNetworkMouseButtonState(int whichPlayer, int whichButton, InputState whichState) const;

/// <summary>
/// Gets whether a joystick button is in the specified state.
/// </summary>
Expand Down

0 comments on commit 74fb0b5

Please sign in to comment.