From 583ec3285c41e9d253c4aaabd2af4dadac75f3a7 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sun, 23 Nov 2008 12:34:07 +0000 Subject: clean module consturction/destruction --- src/client/client.cc | 17 ++++++++++++----- src/client/soundext.cc | 8 ++++++-- src/client/targets.cc | 14 ++++++++------ 3 files changed, 26 insertions(+), 13 deletions(-) (limited to 'src/client') diff --git a/src/client/client.cc b/src/client/client.cc index 061f29b..650813c 100644 --- a/src/client/client.cc +++ b/src/client/client.cc @@ -17,6 +17,7 @@ #include "client/input.h" #include "client/view.h" #include "core/core.h" +#include "core/loader.h" #include "core/zone.h" #include "render/render.h" #include "ui/ui.h" @@ -167,15 +168,21 @@ void Client::run() void Client::frame(unsigned long timestamp) { + input::frame(); + core::Application::frame(timestamp); - if (!core::application()->connected()) { + if (!connected()) { + std::string module_label(core::Loader::label()); + // load the intro if nothing is running - if (core::application()->load("intro")) { - core::application()->connect(""); + if (load("intro")) { + connect(""); + if (module_label.size()) + load(module_label); } // show the console if everything fails - if (!core::application()->connected() && !ui::console()->visible()) { + if (!connected() && !ui::console()->visible()) { ui::console()->toggle(); } } else if (!ui::root()->active()) { @@ -207,7 +214,7 @@ void Client::frame(unsigned long timestamp) } video::frame((float)(timestamp - previous_timestamp) / 1000.0f); - input::frame(); + previous_timestamp = timestamp; } diff --git a/src/client/soundext.cc b/src/client/soundext.cc index 421575d..9b15597 100644 --- a/src/client/soundext.cc +++ b/src/client/soundext.cc @@ -134,11 +134,15 @@ void SoundExt::frame(float elapsed) } + float x = entity->radius(); + if (entity->model()) + x = entity->model()->maxbbox().x; + audio::update_source(state_engineloopsource, - entity->location() - entity->axis().forward() * entity->model()->maxbbox().x , entity->axis().forward() * speed, pitch, gain); + entity->location() - entity->axis().forward() * x , entity->axis().forward() * speed, pitch, gain); audio::update_source(state_engineeventsource, - entity->location() - entity->axis().forward() * entity->model()->maxbbox().x , entity->axis().forward() * speed); + entity->location() - entity->axis().forward() * x , entity->axis().forward() * speed); } diff --git a/src/client/targets.cc b/src/client/targets.cc index 3ccea8a..c544e73 100644 --- a/src/client/targets.cc +++ b/src/client/targets.cc @@ -45,6 +45,8 @@ bool is_legal_target(core::Entity *entity) { if (entity->serverside()) { return false; + } else if (!ext_render(entity)) { + return false; } else if (entity == core::localplayer()->mission_target()) { return true; } else if (entity == core::localcontrol()) { @@ -307,17 +309,17 @@ void render_entity_sound(core::Entity *entity) return; } - if (!ext_render(entity) || !ext_render(entity)->visible()) { + if (!ext_render(entity) || (ext_render(entity) && !ext_render(entity)->visible())) { if (ext_sound(entity)) delete ext_sound(entity); return; - } + } else { + if (!ext_sound(entity)) { + new SoundExt(entity); + } - if (!ext_sound(entity)) { - new SoundExt(entity); + ext_sound(entity)->frame(0.0f); } - - entity->extension((size_t) core::Extension::Sound)->frame(0.0f); } -- cgit v1.2.3