diff --git a/src/client/particles.cpp b/src/client/particles.cpp index c6891f8ef..472ac0321 100644 --- a/src/client/particles.cpp +++ b/src/client/particles.cpp @@ -270,6 +270,7 @@ ParticleSpawner::ParticleSpawner( } size_t max_particles = 0; // maximum number of particles likely to be visible at any given time + assert(p.time >= 0); if (p.time != 0) { auto maxGenerations = p.time / std::min(p.exptime.start.min, p.exptime.end.min); max_particles = p.amount / maxGenerations; diff --git a/src/network/clientpackethandler.cpp b/src/network/clientpackethandler.cpp index 9f987ccea..fbd7bdd9e 100644 --- a/src/network/clientpackethandler.cpp +++ b/src/network/clientpackethandler.cpp @@ -4,6 +4,7 @@ #include "client/client.h" +#include "exceptions.h" #include "irr_v2d.h" #include "util/base64.h" #include "client/camera.h" @@ -1007,6 +1008,8 @@ void Client::handleCommand_AddParticleSpawner(NetworkPacket* pkt) p.amount = readU16(is); p.time = readF32(is); + if (p.time < 0) + throw SerializationError("particle spawner time < 0"); bool missing_end_values = false; if (m_proto_ver >= 42) { diff --git a/src/script/lua_api/l_particles.cpp b/src/script/lua_api/l_particles.cpp index 80c3f27c2..efcf3725e 100644 --- a/src/script/lua_api/l_particles.cpp +++ b/src/script/lua_api/l_particles.cpp @@ -3,6 +3,7 @@ // Copyright (C) 2013 celeron55, Perttu Ahola #include "lua_api/l_particles.h" +#include "common/c_types.h" #include "lua_api/l_object.h" #include "lua_api/l_internal.h" #include "lua_api/l_particleparams.h" @@ -280,6 +281,9 @@ int ModApiParticles::l_add_particlespawner(lua_State *L) p.node_tile = getintfield_default(L, 1, "node_tile", p.node_tile); } + if (p.time < 0) + throw LuaError("particle spawner 'time' must be >= 0"); + u32 id = getServer(L)->addParticleSpawner(p, attached, playername); lua_pushnumber(L, id);