Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2008-09-27 17:16:15 +0000
committerStijn Buys <ingar@osirion.org>2008-09-27 17:16:15 +0000
commitca0c1d3e6f8b5fa4eb2e0a86fcf47b12fb600786 (patch)
tree5d72e330f11350065806e83cc8712693241b9aad /src/client
parent29984680d6e0e52efec489497b1796e056164442 (diff)
mission targets, texture unloading, private messages
Diffstat (limited to 'src/client')
-rw-r--r--src/client/client.cc55
-rw-r--r--src/client/client.h5
-rw-r--r--src/client/targets.cc4
-rw-r--r--src/client/view.cc58
-rw-r--r--src/client/view.h5
5 files changed, 95 insertions, 32 deletions
diff --git a/src/client/client.cc b/src/client/client.cc
index 7ba61d6..a8d4ca8 100644
--- a/src/client/client.cc
+++ b/src/client/client.cc
@@ -19,6 +19,8 @@
#include "client/input.h"
#include "client/view.h"
#include "core/core.h"
+#include "core/zone.h"
+#include "render/render.h"
namespace client
{
@@ -181,6 +183,8 @@ void Client::shutdown()
{
con_print << "^BShutting down client..." << std::endl;
+ if (connected()) disconnect();
+
core::Func::remove("r_restart");
core::Func::remove("snd_restart");
@@ -210,34 +214,49 @@ void Client::notify_remove_sound(size_t source)
audio::Sources::remove(source);
}
-void Client::notify_message(std::string const & message)
+void Client::notify_message(core::Message::Channel const channel, std::string const message)
{
- con_print << message << std::endl;
+
+ switch(channel) {
+
+ case core::Message::Info: // Info message
+ break;
+
+ case core::Message::Local: // Chat message in the local zone
+ break;
+
+ case core::Message::RCon: // RCon message
+ break;
+
+ case core::Message::Public: // Public chat message
+ audio::play("com/chat");
+ break;
+
+ case core::Message::Private: // Private chat message
+ audio::play("com/priv");
+ break;
+
+ default:
+ break;
+ }
+
+ con_print << message << std::endl;
console()->notify(message);
}
void Client::notify_zoneclear(core::Zone *zone)
{
- // FIXME unload zone textures
- /*
if (!zone)
return;
- for (core::Zone::Content::iterator it = zone->content().begin(); it != zone->content.end(); i++) {
- core:: Entity *entity = (*it);
-
- if (entity->type() == core::Entity::Globe) {
- core::EntityGlobe *globe = static_cast<core::EntityGlobe *>(entity);
- if (globe->render_texture)
- render::Textures::unload(render_texture);
-
- }
+ view::clear_zone(zone);
+}
- if (zone->sky_texture()) {
- render::Textures::unload(zone->sky_texture());
- zone->set_sky_texture(0);
- }
- */
+void Client::notify_disconnect()
+{
+ // FIXME unload sounds
+
+ render::unload();
}
} // namespace client
diff --git a/src/client/client.h b/src/client/client.h
index 664bbb4..6da5c5f 100644
--- a/src/client/client.h
+++ b/src/client/client.h
@@ -32,13 +32,16 @@ public:
virtual void notify_sound(const char * name);
/// text notifications from the core
- virtual void notify_message(std::string const & message);
+ virtual void notify_message(core::Message::Channel const channel, std::string const message);
/// remove sound source notification
virtual void notify_remove_sound(size_t source);
/// clear zone notification
virtual void notify_zoneclear(core::Zone *zone);
+
+ /// disconnect notification
+ virtual void notify_disconnect();
};
diff --git a/src/client/targets.cc b/src/client/targets.cc
index a18392f..4764245 100644
--- a/src/client/targets.cc
+++ b/src/client/targets.cc
@@ -42,7 +42,9 @@ bool is_legal_target(core::Entity *entity)
{
if (entity->serverside()) {
return false;
- } else if (entity->id() == core::localcontrol()->id()) {
+ } else if (entity == core::localplayer()->mission_target()) {
+ return true;
+ } else if (entity == core::localcontrol()) {
return false;
} else if (entity->state()->distance() < 0.001f) {
return false;
diff --git a/src/client/view.cc b/src/client/view.cc
index 8cf1af9..bbf9088 100644
--- a/src/client/view.cc
+++ b/src/client/view.cc
@@ -18,13 +18,8 @@
#include "client/input.h"
#include "client/targets.h"
#include "client/video.h"
-#include "render/draw.h"
#include "render/render.h"
-#include "render/textures.h"
-#include "render/camera.h"
#include "core/core.h"
-#include "core/stats.h"
-#include "core/zone.h"
#include "math/mathlib.h"
#include "sys/sys.h"
@@ -38,6 +33,7 @@ core::Cvar *draw_keypress = 0;
core::Cvar *ui_pointercolor = 0;
core::Cvar *ui_pointerhovercolor =0;
+
namespace view
{
@@ -50,6 +46,8 @@ float net_counter_time[net_counter_size];
size_t net_counter_traffic[net_counter_size];
size_t net_counter_index;
+core::Zone *current_zone = 0;
+
void init()
{
draw_stats = core::Cvar::get("draw_stats", "0", core::Cvar::Archive);
@@ -84,6 +82,26 @@ void shutdown()
targets::shutdown();
}
+void clear_zone(core::Zone *zone)
+{
+ for (core::Zone::Content::iterator it = zone->content().begin(); it != zone->content().end(); it++) {
+ core:: Entity *entity = (*it);
+
+ if (entity->type() == core::Entity::Globe) {
+ core::EntityGlobe *globe = static_cast<core::EntityGlobe *>(entity);
+ if (globe->render_texture) {
+ render::Textures::unload(globe->render_texture);
+ globe->render_texture = 0;
+ }
+ }
+ }
+
+ if (zone->sky_texture()) {
+ render::Textures::unload(zone->sky_texture());
+ zone->set_sky_texture(0);
+ }
+}
+
void draw_loader()
{
using namespace render;
@@ -219,10 +237,12 @@ void draw_entity_offscreen_target(core::Entity *entity, bool is_active_target)
glVertex3f(cx, cy-r+2, 0);
render::gl::end();
- if (entity->type() == core::Entity::Controlable) {
- render::gl::color(0, 1, 0, 1);
+ if (entity == core::localplayer()->mission_target()) {
+ render::gl::color(1, 0.5f, 1, 1); // FIXME mission color
+ } else if (entity->type() == core::Entity::Controlable) {
+ render::gl::color(0, 1, 0, 1); // FIXME allegiance color
} else {
- render::gl::color(1, 1, 1, 1);
+ render::gl::color(1, 1, 1, 1); // FIXME neutral color
}
render::gl::begin(render::gl::LineLoop);
@@ -279,11 +299,14 @@ void draw_entity_target(core::Entity *entity, bool is_active_target)
glVertex3f(cx, cy-r+2, 0);
render::gl::end();
- if (entity->type() == core::Entity::Controlable) {
- render::gl::color(0, 1, 0, 1);
+ if (entity == core::localplayer()->mission_target()) {
+ render::gl::color(1, 0.5f, 1, 1); // FIXME mission color
+ } else if (entity->type() == core::Entity::Controlable) {
+ render::gl::color(0, 1, 0, 1); // FIXME allegiance color
} else {
- render::gl::color(1, 1, 1, 1);
+ render::gl::color(1, 1, 1, 1); // FIXME neutral color
}
+
// outer square0
render::gl::begin(render::gl::LineLoop);
glVertex3f(cx+r, cy, 0);
@@ -391,7 +414,9 @@ void draw_status()
core::Entity *entity = (*it);
if (targets::is_legal_target(entity)) {
- if (entity == targets::current()) {
+ if (entity == core::localplayer()->mission_target()) {
+ draw_entity_target(entity, true);
+ } else if (entity == targets::current()) {
draw_entity_target(entity, true);
} else if (entity->type() == core::Entity::Controlable) {
draw_entity_target(entity, false);
@@ -716,11 +741,20 @@ void frame(float seconds)
render::Stats::clear();
if (core::application()->connected() && core::game()->serverframetime()) {
+
+ if (core::localplayer()->zone() != current_zone) {
+ if (current_zone)
+ clear_zone(current_zone);
+ current_zone = core::localplayer()->zone();
+ }
+
render::draw(seconds); // draw the world
targets::draw(); // validate current target, render sound
if (targets::current()) // draw target docks etc
draw_entity_world_target(targets::current());
+ } else {
+ current_zone = 0;
}
// switch to orthographic projection to draw the GUI
diff --git a/src/client/view.h b/src/client/view.h
index d9e44ab..1f81597 100644
--- a/src/client/view.h
+++ b/src/client/view.h
@@ -6,6 +6,8 @@
#ifndef __INCLUDED_CLIENT_VIEW_H__
#define __INCLUDED_CLIENT_VIEW_H__
+#include "core/zone.h"
+
namespace client
{
@@ -24,6 +26,9 @@ namespace view
/// reset OpenGL state
void reset();
+ /// clear client-side assets of a zone
+ void clear_zone(core::Zone *zone);
+
} // namespace view
} // namespace client