From ae65ef53fc8b70ebee3b43bb06ecd091aaae2a26 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Thu, 17 Jul 2008 14:19:18 +0000 Subject: engine sounds --- src/core/application.cc | 6 ++++++ src/core/application.h | 3 +++ src/core/clientstate.cc | 18 +++++++++++++++++- src/core/clientstate.h | 5 +++++ 4 files changed, 31 insertions(+), 1 deletion(-) (limited to 'src/core') diff --git a/src/core/application.cc b/src/core/application.cc index f8c563c..f92a0fe 100644 --- a/src/core/application.cc +++ b/src/core/application.cc @@ -411,6 +411,12 @@ void Application::notify_sound(const char *name) // Dedicated servers don't need sounds } +void Application::notify_remove_sound(size_t source) +{ + // the default implementation does nothing. + // Dedicated servers don't need sounds +} + void Application::notify_message(std::string const & message) { con_print << message << std::endl; diff --git a/src/core/application.h b/src/core/application.h index aad3ac9..8f69720 100644 --- a/src/core/application.h +++ b/src/core/application.h @@ -64,6 +64,9 @@ public: /// text notifications from the core to the application virtual void notify_message(std::string const & message); + /// remove sound source notification + virtual void notify_remove_sound(size_t source); + /*----- static --------------------------------------------------- */ /// a pointer to the current application instance diff --git a/src/core/clientstate.cc b/src/core/clientstate.cc index cc9c79e..503a71f 100644 --- a/src/core/clientstate.cc +++ b/src/core/clientstate.cc @@ -5,6 +5,7 @@ */ #include "core/clientstate.h" +#include "core/application.h" namespace core { @@ -14,6 +15,8 @@ ClientState::ClientState() state_detailvisible = false; state_targetable = false; + state_enginesound = 0; + for (size_t i = 0; i < 3; i++) state_screenlocation[i] = 0; @@ -25,11 +28,24 @@ ClientState::ClientState(Entity *entity) state_visible = false; state_detailvisible = false; state_fuzz = math::randomf(); + + state_enginesound = 0; + assign(entity); } ClientState::~ClientState() -{} +{ + clearsound(); +} + +void ClientState::clearsound() +{ + if (state_enginesound) { + application()->notify_remove_sound(state_enginesound); + state_enginesound = 0; + } +} void ClientState::assign(Entity * entity) { diff --git a/src/core/clientstate.h b/src/core/clientstate.h index 6cd283d..87dd1d7 100644 --- a/src/core/clientstate.h +++ b/src/core/clientstate.h @@ -49,6 +49,9 @@ public: /// assign the content of an entity void assign(Entity *entity); + /// clear attached sounds + void clearsound(); + math::Vector3f state_location; math::Axis state_axis; @@ -62,6 +65,8 @@ public: bool state_targetable; float state_fuzz; + + size_t state_enginesound; }; } -- cgit v1.2.3