Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #5116 #5122

Merged
merged 1 commit into from
Jul 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/graphics/explosion.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ using namespace irr;

class Vec3;
class SFXBase;

#ifndef SERVER_ONLY
class ParticleEmitter;
#endif

/**
* \ingroup graphics
Expand All @@ -42,7 +45,11 @@ class Explosion : public HitSFX
private:
int m_remaining_ticks;
int m_emission_frames;

#ifndef SERVER_ONLY
ParticleEmitter* m_emitter;
#endif

int m_explosion_ticks;


Expand Down
6 changes: 5 additions & 1 deletion src/graphics/particle_emitter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

#ifndef SERVER_ONLY

#ifndef HEADER_SMOKE_HPP
#define HEADER_SMOKE_HPP

Expand Down Expand Up @@ -100,6 +102,8 @@ class ParticleEmitter : public NoCopy

bool randomizeInitialY() const { return m_randomize_initial_y; }
};
#endif
#endif // HEADER_SMOKE_HPP

#endif // !SERVER_ONLY


2 changes: 1 addition & 1 deletion src/karts/controller/local_player_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@ LocalPlayerController::~LocalPlayerController()
void LocalPlayerController::initParticleEmitter()
{
// Attach Particle System
#ifndef SERVER_ONLY
m_sky_particles_emitter = nullptr;
Track *track = Track::getCurrentTrack();
#ifndef SERVER_ONLY
if (!GUIEngine::isNoGraphics() &&
UserConfigParams::m_particles_effects > 1 &&
track->getSkyParticles() != NULL)
Expand Down
7 changes: 6 additions & 1 deletion src/karts/controller/local_player_controller.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,14 @@
#include <memory>

class AbstractKart;
class ParticleEmitter;
class SFXBase;
class SFXBuffer;
class btTransform;

#ifndef SERVER_ONLY
class ParticleEmitter;
#endif

/** PlayerKart manages control events from the player and moves
* them to the Kart
*
Expand All @@ -46,7 +49,9 @@ class LocalPlayerController : public PlayerController
bool m_has_started;
bool m_is_above_nitro_target;

#ifndef SERVER_ONLY
std::unique_ptr<ParticleEmitter> m_sky_particles_emitter;
#endif

/** The index of the camera attached to the kart for this controller. The
* camera object is managed in the Camera class, so no need to free it. */
Expand Down
7 changes: 7 additions & 0 deletions src/karts/kart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,9 @@ Kart::Kart (const std::string& ident, unsigned int world_kart_id,
m_initial_position = position;
m_race_result = false;
m_wheel_box = NULL;
#ifndef SERVER_ONLY
m_collision_particles = NULL;
#endif
m_controller = NULL;
m_saved_controller = NULL;
m_consumption_per_tick = stk_config->ticks2Time(1) *
Expand Down Expand Up @@ -283,7 +285,9 @@ Kart::~Kart()
m_nitro_sound ->deleteSFX();
if(m_terrain_sound) m_terrain_sound->deleteSFX();
if(m_previous_terrain_sound) m_previous_terrain_sound->deleteSFX();
#ifndef SERVER_ONLY
if(m_collision_particles) delete m_collision_particles;
#endif

if (m_wheel_box) m_wheel_box->remove();

Expand Down Expand Up @@ -3283,7 +3287,10 @@ void Kart::updateGraphics(float dt)
// Update particle effects (creation rate, and emitter size
// depending on speed)
m_kart_gfx->update(dt);

#ifndef SERVER_ONLY
if (m_collision_particles) m_collision_particles->update(dt);
#endif

// --------------------------------------------------------
float nitro_frac = 0;
Expand Down
7 changes: 6 additions & 1 deletion src/karts/kart.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ class ItemState;
class KartGFX;
class KartRewinder;
class MaxSpeed;
class ParticleEmitter;
class ParticleKind;
class SFXBase;
class Shadow;
Expand All @@ -56,6 +55,10 @@ class SlipStream;
class Stars;
class TerrainInfo;

#ifndef SERVER_ONLY
class ParticleEmitter;
#endif

/** The main kart class. All type of karts are of this object, but with
* different controllers. The controllers are what turn a kart into a
* player kart (i.e. the controller handle input), or an AI kart (the
Expand Down Expand Up @@ -155,8 +158,10 @@ class Kart : public AbstractKart
};
std::unique_ptr<btCompoundShape, btCompoundShapeDeleter> m_kart_chassis;

#ifndef SERVER_ONLY
/** For collisions */
ParticleEmitter *m_collision_particles;
#endif

/** The main controller of this object, used for driving. This
* controller is used to run the kart. It will be replaced
Expand Down
8 changes: 5 additions & 3 deletions src/karts/kart_gfx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,10 @@ KartGFX::KartGFX(const AbstractKart *kart, bool is_day)
}
else
{
#ifndef SERVER_ONLY
m_all_emitters.push_back(NULL);
m_all_emitters.push_back(NULL);
#endif
}

} // KartGFX
Expand All @@ -139,13 +141,13 @@ KartGFX::KartGFX(const AbstractKart *kart, bool is_day)
*/
KartGFX::~KartGFX()
{
#ifndef SERVER_ONLY
for(unsigned int i=0; i<KGFX_COUNT; i++)
{
if(m_all_emitters[i])
delete m_all_emitters[i];
} // for i < KGFX_COUNT

#ifndef SERVER_ONLY
if (!GUIEngine::isNoGraphics() && CVS->isGLSL())
{
m_nitro_light->drop();
Expand Down Expand Up @@ -221,8 +223,6 @@ void KartGFX::addEffect(KartGFXType type, const std::string &file_name,
m_skid_kind1 = kind;
else if (type==KGFX_SKID2L || type==KGFX_SKID2R)
m_skid_kind2 = kind;
#else
m_all_emitters.push_back(NULL);
#endif
} // addEffect

Expand Down Expand Up @@ -442,11 +442,13 @@ void KartGFX::update(float dt)
{
m_wheel_toggle = 1 - m_wheel_toggle;

#ifndef SERVER_ONLY
for (unsigned int i = 0; i < m_all_emitters.size(); i++)
{
if (m_all_emitters[i])
m_all_emitters[i]->update(dt);
}
#endif

} // update

Expand Down
7 changes: 6 additions & 1 deletion src/karts/kart_gfx.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,13 @@
#include <string>

class AbstractKart;
class ParticleEmitter;
class ParticleKind;
class Vec3;

#ifndef SERVER_ONLY
class ParticleEmitter;
#endif

namespace irr {
namespace scene {
class ISceneNode;
Expand Down Expand Up @@ -73,8 +76,10 @@ class KartGFX
/** The particle kind for skidding bonus level 2. */
const ParticleKind *m_skid_kind2;

#ifndef SERVER_ONLY
/** Vector of all particle emitters. */
std::vector<ParticleEmitter*> m_all_emitters;
#endif

/** Pointer to the owner of this kart. */
const AbstractKart *m_kart;
Expand Down
1 change: 0 additions & 1 deletion src/tracks/track.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ class ItemManager;
class ModelDefinitionLoader;
class MovingTexture;
class MusicInformation;
class ParticleEmitter;
class ParticleKind;
class PhysicalObject;
class RenderTarget;
Expand Down
10 changes: 8 additions & 2 deletions src/tracks/track_object_presentation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -476,12 +476,12 @@ TrackObjectPresentationMesh::TrackObjectPresentationMesh(
m_node = NULL;
m_is_in_skybox = false;
m_render_info = NULL;
bool animated = (UserConfigParams::m_particles_effects > 1 ||
World::getWorld()->getIdent() == IDENT_CUTSCENE);

m_model_file = model_file;
file_manager->pushTextureSearchPath(StringUtils::getPath(model_file), "");
#ifndef SERVER_ONLY
bool animated = (UserConfigParams::m_particles_effects > 1 ||
World::getWorld()->getIdent() == IDENT_CUTSCENE);
if (file_manager->fileExists(model_file))
{
if (animated)
Expand Down Expand Up @@ -879,7 +879,9 @@ TrackObjectPresentationParticles::TrackObjectPresentationParticles(
m_init_hpr.Z = 0;
}

#ifndef SERVER_ONLY
m_emitter = NULL;
#endif
m_lod_emitter_node = NULL;
std::string path;
xml_node.get("kind", &path);
Expand Down Expand Up @@ -937,6 +939,7 @@ TrackObjectPresentationParticles::TrackObjectPresentationParticles(
// ----------------------------------------------------------------------------
TrackObjectPresentationParticles::~TrackObjectPresentationParticles()
{
#ifndef SERVER_ONLY
if (m_emitter)
{
if (m_lod_emitter_node != NULL)
Expand All @@ -946,15 +949,18 @@ TrackObjectPresentationParticles::~TrackObjectPresentationParticles()
}
delete m_emitter; // this will also delete m_node
}
#endif
} // ~TrackObjectPresentationParticles

// ----------------------------------------------------------------------------
void TrackObjectPresentationParticles::updateGraphics(float dt)
{
#ifndef SERVER_ONLY
if (m_emitter != NULL)
{
m_emitter->update(dt);
}
#endif

if (m_delayed_stop)
{
Expand Down
7 changes: 6 additions & 1 deletion src/tracks/track_object_presentation.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
#include <string>

class SFXBase;
class ParticleEmitter;
class PhysicalObject;
class ThreeDAnimation;
class ModelDefinitionLoader;
Expand All @@ -44,6 +43,10 @@ class STKInstancedSceneNode;
class XMLNode;
class TrackObject;

#ifndef SERVER_ONLY
class ParticleEmitter;
#endif

namespace irr
{
namespace scene { class IAnimatedMesh; class IMesh; class IMeshSceneNode; class ISceneNode; }
Expand Down Expand Up @@ -335,7 +338,9 @@ class TrackObjectPresentationBillboard : public TrackObjectPresentationSceneNode
class TrackObjectPresentationParticles : public TrackObjectPresentationSceneNode
{
private:
#ifndef SERVER_ONLY
ParticleEmitter* m_emitter;
#endif
LODNode* m_lod_emitter_node;
std::string m_trigger_condition;
bool m_delayed_stop;
Expand Down
Loading