Merge pull request #5122 from kimden/fix5116

Fix #5116
This commit is contained in:
CodingJellyfish 2024-07-01 22:01:12 +08:00 committed by GitHub
commit afbb58ed44
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
11 changed files with 57 additions and 12 deletions

View File

@ -32,7 +32,10 @@ using namespace irr;
class Vec3; class Vec3;
class SFXBase; class SFXBase;
#ifndef SERVER_ONLY
class ParticleEmitter; class ParticleEmitter;
#endif
/** /**
* \ingroup graphics * \ingroup graphics
@ -42,7 +45,11 @@ class Explosion : public HitSFX
private: private:
int m_remaining_ticks; int m_remaining_ticks;
int m_emission_frames; int m_emission_frames;
#ifndef SERVER_ONLY
ParticleEmitter* m_emitter; ParticleEmitter* m_emitter;
#endif
int m_explosion_ticks; int m_explosion_ticks;

View File

@ -16,6 +16,8 @@
// along with this program; if not, write to the Free Software // along with this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef SERVER_ONLY
#ifndef HEADER_SMOKE_HPP #ifndef HEADER_SMOKE_HPP
#define HEADER_SMOKE_HPP #define HEADER_SMOKE_HPP
@ -100,6 +102,8 @@ public:
bool randomizeInitialY() const { return m_randomize_initial_y; } bool randomizeInitialY() const { return m_randomize_initial_y; }
}; };
#endif #endif // HEADER_SMOKE_HPP
#endif // !SERVER_ONLY

View File

@ -107,9 +107,9 @@ LocalPlayerController::~LocalPlayerController()
void LocalPlayerController::initParticleEmitter() void LocalPlayerController::initParticleEmitter()
{ {
// Attach Particle System // Attach Particle System
#ifndef SERVER_ONLY
m_sky_particles_emitter = nullptr; m_sky_particles_emitter = nullptr;
Track *track = Track::getCurrentTrack(); Track *track = Track::getCurrentTrack();
#ifndef SERVER_ONLY
if (!GUIEngine::isNoGraphics() && if (!GUIEngine::isNoGraphics() &&
UserConfigParams::m_particles_effects > 1 && UserConfigParams::m_particles_effects > 1 &&
track->getSkyParticles() != NULL) track->getSkyParticles() != NULL)

View File

@ -25,11 +25,14 @@
#include <memory> #include <memory>
class AbstractKart; class AbstractKart;
class ParticleEmitter;
class SFXBase; class SFXBase;
class SFXBuffer; class SFXBuffer;
class btTransform; class btTransform;
#ifndef SERVER_ONLY
class ParticleEmitter;
#endif
/** PlayerKart manages control events from the player and moves /** PlayerKart manages control events from the player and moves
* them to the Kart * them to the Kart
* *
@ -46,7 +49,9 @@ private:
bool m_has_started; bool m_has_started;
bool m_is_above_nitro_target; bool m_is_above_nitro_target;
#ifndef SERVER_ONLY
std::unique_ptr<ParticleEmitter> m_sky_particles_emitter; std::unique_ptr<ParticleEmitter> m_sky_particles_emitter;
#endif
/** The index of the camera attached to the kart for this controller. The /** 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. */ * camera object is managed in the Camera class, so no need to free it. */

View File

@ -127,7 +127,9 @@ Kart::Kart (const std::string& ident, unsigned int world_kart_id,
m_initial_position = position; m_initial_position = position;
m_race_result = false; m_race_result = false;
m_wheel_box = NULL; m_wheel_box = NULL;
#ifndef SERVER_ONLY
m_collision_particles = NULL; m_collision_particles = NULL;
#endif
m_controller = NULL; m_controller = NULL;
m_saved_controller = NULL; m_saved_controller = NULL;
m_consumption_per_tick = stk_config->ticks2Time(1) * m_consumption_per_tick = stk_config->ticks2Time(1) *
@ -283,7 +285,9 @@ Kart::~Kart()
m_nitro_sound ->deleteSFX(); m_nitro_sound ->deleteSFX();
if(m_terrain_sound) m_terrain_sound->deleteSFX(); if(m_terrain_sound) m_terrain_sound->deleteSFX();
if(m_previous_terrain_sound) m_previous_terrain_sound->deleteSFX(); if(m_previous_terrain_sound) m_previous_terrain_sound->deleteSFX();
#ifndef SERVER_ONLY
if(m_collision_particles) delete m_collision_particles; if(m_collision_particles) delete m_collision_particles;
#endif
if (m_wheel_box) m_wheel_box->remove(); if (m_wheel_box) m_wheel_box->remove();
@ -3283,7 +3287,10 @@ void Kart::updateGraphics(float dt)
// Update particle effects (creation rate, and emitter size // Update particle effects (creation rate, and emitter size
// depending on speed) // depending on speed)
m_kart_gfx->update(dt); m_kart_gfx->update(dt);
#ifndef SERVER_ONLY
if (m_collision_particles) m_collision_particles->update(dt); if (m_collision_particles) m_collision_particles->update(dt);
#endif
// -------------------------------------------------------- // --------------------------------------------------------
float nitro_frac = 0; float nitro_frac = 0;

View File

@ -46,7 +46,6 @@ class ItemState;
class KartGFX; class KartGFX;
class KartRewinder; class KartRewinder;
class MaxSpeed; class MaxSpeed;
class ParticleEmitter;
class ParticleKind; class ParticleKind;
class SFXBase; class SFXBase;
class Shadow; class Shadow;
@ -56,6 +55,10 @@ class SlipStream;
class Stars; class Stars;
class TerrainInfo; class TerrainInfo;
#ifndef SERVER_ONLY
class ParticleEmitter;
#endif
/** The main kart class. All type of karts are of this object, but with /** 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 * different controllers. The controllers are what turn a kart into a
* player kart (i.e. the controller handle input), or an AI kart (the * player kart (i.e. the controller handle input), or an AI kart (the
@ -155,8 +158,10 @@ protected:
}; };
std::unique_ptr<btCompoundShape, btCompoundShapeDeleter> m_kart_chassis; std::unique_ptr<btCompoundShape, btCompoundShapeDeleter> m_kart_chassis;
#ifndef SERVER_ONLY
/** For collisions */ /** For collisions */
ParticleEmitter *m_collision_particles; ParticleEmitter *m_collision_particles;
#endif
/** The main controller of this object, used for driving. This /** The main controller of this object, used for driving. This
* controller is used to run the kart. It will be replaced * controller is used to run the kart. It will be replaced

View File

@ -128,8 +128,10 @@ KartGFX::KartGFX(const AbstractKart *kart, bool is_day)
} }
else else
{ {
#ifndef SERVER_ONLY
m_all_emitters.push_back(NULL); m_all_emitters.push_back(NULL);
m_all_emitters.push_back(NULL); m_all_emitters.push_back(NULL);
#endif
} }
} // KartGFX } // KartGFX
@ -139,13 +141,13 @@ KartGFX::KartGFX(const AbstractKart *kart, bool is_day)
*/ */
KartGFX::~KartGFX() KartGFX::~KartGFX()
{ {
#ifndef SERVER_ONLY
for(unsigned int i=0; i<KGFX_COUNT; i++) for(unsigned int i=0; i<KGFX_COUNT; i++)
{ {
if(m_all_emitters[i]) if(m_all_emitters[i])
delete m_all_emitters[i]; delete m_all_emitters[i];
} // for i < KGFX_COUNT } // for i < KGFX_COUNT
#ifndef SERVER_ONLY
if (!GUIEngine::isNoGraphics() && CVS->isGLSL()) if (!GUIEngine::isNoGraphics() && CVS->isGLSL())
{ {
m_nitro_light->drop(); m_nitro_light->drop();
@ -221,8 +223,6 @@ void KartGFX::addEffect(KartGFXType type, const std::string &file_name,
m_skid_kind1 = kind; m_skid_kind1 = kind;
else if (type==KGFX_SKID2L || type==KGFX_SKID2R) else if (type==KGFX_SKID2L || type==KGFX_SKID2R)
m_skid_kind2 = kind; m_skid_kind2 = kind;
#else
m_all_emitters.push_back(NULL);
#endif #endif
} // addEffect } // addEffect
@ -442,11 +442,13 @@ void KartGFX::update(float dt)
{ {
m_wheel_toggle = 1 - m_wheel_toggle; m_wheel_toggle = 1 - m_wheel_toggle;
#ifndef SERVER_ONLY
for (unsigned int i = 0; i < m_all_emitters.size(); i++) for (unsigned int i = 0; i < m_all_emitters.size(); i++)
{ {
if (m_all_emitters[i]) if (m_all_emitters[i])
m_all_emitters[i]->update(dt); m_all_emitters[i]->update(dt);
} }
#endif
} // update } // update

View File

@ -26,10 +26,13 @@
#include <string> #include <string>
class AbstractKart; class AbstractKart;
class ParticleEmitter;
class ParticleKind; class ParticleKind;
class Vec3; class Vec3;
#ifndef SERVER_ONLY
class ParticleEmitter;
#endif
namespace irr { namespace irr {
namespace scene { namespace scene {
class ISceneNode; class ISceneNode;
@ -73,8 +76,10 @@ private:
/** The particle kind for skidding bonus level 2. */ /** The particle kind for skidding bonus level 2. */
const ParticleKind *m_skid_kind2; const ParticleKind *m_skid_kind2;
#ifndef SERVER_ONLY
/** Vector of all particle emitters. */ /** Vector of all particle emitters. */
std::vector<ParticleEmitter*> m_all_emitters; std::vector<ParticleEmitter*> m_all_emitters;
#endif
/** Pointer to the owner of this kart. */ /** Pointer to the owner of this kart. */
const AbstractKart *m_kart; const AbstractKart *m_kart;

View File

@ -65,7 +65,6 @@ class ItemManager;
class ModelDefinitionLoader; class ModelDefinitionLoader;
class MovingTexture; class MovingTexture;
class MusicInformation; class MusicInformation;
class ParticleEmitter;
class ParticleKind; class ParticleKind;
class PhysicalObject; class PhysicalObject;
class RenderTarget; class RenderTarget;

View File

@ -476,12 +476,12 @@ TrackObjectPresentationMesh::TrackObjectPresentationMesh(
m_node = NULL; m_node = NULL;
m_is_in_skybox = false; m_is_in_skybox = false;
m_render_info = NULL; m_render_info = NULL;
bool animated = (UserConfigParams::m_particles_effects > 1 ||
World::getWorld()->getIdent() == IDENT_CUTSCENE);
m_model_file = model_file; m_model_file = model_file;
file_manager->pushTextureSearchPath(StringUtils::getPath(model_file), ""); file_manager->pushTextureSearchPath(StringUtils::getPath(model_file), "");
#ifndef SERVER_ONLY #ifndef SERVER_ONLY
bool animated = (UserConfigParams::m_particles_effects > 1 ||
World::getWorld()->getIdent() == IDENT_CUTSCENE);
if (file_manager->fileExists(model_file)) if (file_manager->fileExists(model_file))
{ {
if (animated) if (animated)
@ -879,7 +879,9 @@ TrackObjectPresentationParticles::TrackObjectPresentationParticles(
m_init_hpr.Z = 0; m_init_hpr.Z = 0;
} }
#ifndef SERVER_ONLY
m_emitter = NULL; m_emitter = NULL;
#endif
m_lod_emitter_node = NULL; m_lod_emitter_node = NULL;
std::string path; std::string path;
xml_node.get("kind", &path); xml_node.get("kind", &path);
@ -937,6 +939,7 @@ TrackObjectPresentationParticles::TrackObjectPresentationParticles(
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
TrackObjectPresentationParticles::~TrackObjectPresentationParticles() TrackObjectPresentationParticles::~TrackObjectPresentationParticles()
{ {
#ifndef SERVER_ONLY
if (m_emitter) if (m_emitter)
{ {
if (m_lod_emitter_node != NULL) if (m_lod_emitter_node != NULL)
@ -946,15 +949,18 @@ TrackObjectPresentationParticles::~TrackObjectPresentationParticles()
} }
delete m_emitter; // this will also delete m_node delete m_emitter; // this will also delete m_node
} }
#endif
} // ~TrackObjectPresentationParticles } // ~TrackObjectPresentationParticles
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
void TrackObjectPresentationParticles::updateGraphics(float dt) void TrackObjectPresentationParticles::updateGraphics(float dt)
{ {
#ifndef SERVER_ONLY
if (m_emitter != NULL) if (m_emitter != NULL)
{ {
m_emitter->update(dt); m_emitter->update(dt);
} }
#endif
if (m_delayed_stop) if (m_delayed_stop)
{ {

View File

@ -35,7 +35,6 @@
#include <string> #include <string>
class SFXBase; class SFXBase;
class ParticleEmitter;
class PhysicalObject; class PhysicalObject;
class ThreeDAnimation; class ThreeDAnimation;
class ModelDefinitionLoader; class ModelDefinitionLoader;
@ -44,6 +43,10 @@ class STKInstancedSceneNode;
class XMLNode; class XMLNode;
class TrackObject; class TrackObject;
#ifndef SERVER_ONLY
class ParticleEmitter;
#endif
namespace irr namespace irr
{ {
namespace scene { class IAnimatedMesh; class IMesh; class IMeshSceneNode; class ISceneNode; } namespace scene { class IAnimatedMesh; class IMesh; class IMeshSceneNode; class ISceneNode; }
@ -335,7 +338,9 @@ public:
class TrackObjectPresentationParticles : public TrackObjectPresentationSceneNode class TrackObjectPresentationParticles : public TrackObjectPresentationSceneNode
{ {
private: private:
#ifndef SERVER_ONLY
ParticleEmitter* m_emitter; ParticleEmitter* m_emitter;
#endif
LODNode* m_lod_emitter_node; LODNode* m_lod_emitter_node;
std::string m_trigger_condition; std::string m_trigger_condition;
bool m_delayed_stop; bool m_delayed_stop;