diff options
author | Stijn Buys <ingar@osirion.org> | 2008-07-28 19:37:31 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2008-07-28 19:37:31 +0000 |
commit | d389a31f9816b55d8c7685ec24b9ab814252d693 (patch) | |
tree | 9b2577692e543fa6c59fcda508f92c3eb839ac7a /src/client | |
parent | 17408276791033e8122819185abf3bcb01740105 (diff) |
zone support
Diffstat (limited to 'src/client')
-rw-r--r-- | src/client/input.cc | 4 | ||||
-rw-r--r-- | src/client/keyboard.cc | 2 | ||||
-rw-r--r-- | src/client/targets.cc | 85 | ||||
-rw-r--r-- | src/client/view.cc | 13 |
4 files changed, 64 insertions, 40 deletions
diff --git a/src/client/input.cc b/src/client/input.cc index 6306fc8..d26c3ba 100644 --- a/src/client/input.cc +++ b/src/client/input.cc @@ -4,6 +4,7 @@ the terms and conditions of the GNU General Public License version 2 */ +#include "auxiliary/functions.h" #include "audio/audio.h" #include "core/core.h" #include "client/client.h" @@ -128,6 +129,7 @@ void func_list_keys(std::string const &args) std::stringstream argstr(args); std::string keyname; if (argstr >> keyname) { + aux::lowercase(keyname); keyboard->list_bind(keyname); } else { keyboard->list_keys(); @@ -143,6 +145,7 @@ void func_list_binds(std::string const &args) std::stringstream argstr(args); std::string keyname; if (argstr >> keyname) { + aux::lowercase(keyname); keyboard->list_bind(keyname); } else { keyboard->list_binds(); @@ -158,6 +161,7 @@ void func_bind(std::string const &args) std::stringstream argstr(args); std::string keyname; if (argstr >> keyname) { + aux::lowercase(keyname); if (args.size() > keyname.size()+1) { keyboard->bind(keyname, args.substr(keyname.size()+1)); } else { diff --git a/src/client/keyboard.cc b/src/client/keyboard.cc index d8b14b3..5870e06 100644 --- a/src/client/keyboard.cc +++ b/src/client/keyboard.cc @@ -329,7 +329,7 @@ Key *Keyboard::find(unsigned int keysym) void Keyboard::bind(std::string const &name, const std::string str) { - Key *key = find(aux::lowercase(name)); + Key *key = find(name); if (key) { key->assign(Key::None, str.c_str()); } else { diff --git a/src/client/targets.cc b/src/client/targets.cc index a39943f..666ea6a 100644 --- a/src/client/targets.cc +++ b/src/client/targets.cc @@ -67,8 +67,14 @@ void select_target(core::Entity *entity) void select_target(unsigned int id) { - // FIXME validate - core::Entity * entity = core::Entity::find(id); + if (!core::localcontrol()) + return; + core::Zone *zone = core::localcontrol()->zone(); + if (!zone) + return; + + core::Entity *entity = zone->find_entity(id); + if (entity) select_target(entity); } @@ -77,45 +83,49 @@ void func_target_next(std::string const &args) { if (!core::localcontrol()) return; + core::Zone *zone = core::localcontrol()->zone(); + if (!zone) + return; - if (!core::Entity::registry.size()) { + if (!zone->content().size()) { current_target = 0; current_target_id = 0; return; } - std::map<unsigned int, core::Entity *>::iterator it = core::Entity::registry.begin(); + core::Zone::Content::iterator it = zone->content().begin(); if (!current_target_id) { // first entity - it = core::Entity::registry.begin(); - while (!is_legal_target((*it).second) && it != core::Entity::registry.end()) + it = zone->content().begin(); + while (!is_legal_target((*it)) && it != zone->content().end()) it++; } else { // current entity - it = core::Entity::registry.find(current_target_id); + while (it != zone->content().end() && ((*it)->id() != current_target_id)) + ++it; // next legal entity - if (it != core::Entity::registry.end()) + if (it != zone->content().end()) it++; - if (it == core::Entity::registry.end()) { - it = core::Entity::registry.begin(); + if (it == zone->content().end()) { + it = zone->content().begin(); } - while (!is_legal_target((*it).second)) { + while (!is_legal_target((*it))) { it++; - if (it == core::Entity::registry.end()) - it = core::Entity::registry.begin(); + if (it == zone->content().end()) + it = zone->content().begin(); - if ((*it).first == current_target_id) { - current_target = (*it).second; + if ((*it)->id() == current_target_id) { + current_target = (*it); return; } } } - if (it != core::Entity::registry.end()) { - select_target((*it).second); + if (it != zone->content().end()) { + select_target((*it)); } else { current_target = 0; current_target_id = 0; @@ -127,45 +137,47 @@ void func_target_prev(std::string const &args) { if (!core::localcontrol()) return; + core::Zone *zone = core::localcontrol()->zone(); + if (!zone) + return; - if (!core::Entity::registry.size()) { + if (!zone->content().size()) { current_target = 0; current_target_id = 0; return; } - std::map<unsigned int, core::Entity *>::reverse_iterator rit = core::Entity::registry.rbegin(); + core::Zone::Content::reverse_iterator rit = zone->content().rbegin(); if (!current_target_id) { // last entity - rit = core::Entity::registry.rbegin(); - while (!is_legal_target((*rit).second) && rit != core::Entity::registry.rend()) + rit = zone->content().rbegin(); + while (!is_legal_target((*rit)) && rit != zone->content().rend()) rit++; } else { // current entity - while (rit != core::Entity::registry.rend() && ((*rit).first != current_target_id)) + while (rit != zone->content().rend() && ((*rit)->id() != current_target_id)) ++rit; // previous legal entity - if (rit != core::Entity::registry.rend()) + if (rit != zone->content().rend()) ++rit; - if (rit == core::Entity::registry.rend()) { - rit = core::Entity::registry.rbegin(); + if (rit == zone->content().rend()) { + rit = zone->content().rbegin(); } - while (!is_legal_target((*rit).second)) { + while (!is_legal_target((*rit))) { ++rit; - if (rit == core::Entity::registry.rend()) - rit = core::Entity::registry.rbegin(); + if (rit == zone->content().rend()) + rit = zone->content().rbegin(); - if ((*rit).first == current_target_id) { - current_target = (*rit).second; + if ((*rit)->id() == current_target_id) { + current_target = (*rit); return; } } } - if (rit != core::Entity::registry.rend()) { - select_target((*rit).second); - + if (rit != zone->content().rend()) { + select_target((*rit)); } else { current_target = 0; current_target_id = 0; @@ -260,6 +272,9 @@ void render_entity_sound(core::Entity *entity) // render client targets void frame() { + core::Zone *zone = core::localplayer()->zone(); + if (!zone) + return; /* Notes http://en.wikipedia.org/wiki/Line-plane_intersection @@ -283,8 +298,8 @@ void frame() cursor -= render::Camera::axis().up() * y; math::Vector3f center = render::Camera::eye() + (render::Camera::axis().forward() * (render::Camera::frustum_front() +0.01f)); - for (core::Entity::Registry::iterator it=core::Entity::registry.begin(); it != core::Entity::registry.end(); it++) { - core::Entity *entity = (*it).second; + for (core::Zone::Content::iterator it=zone->content().begin(); it != zone->content().end(); it++) { + core::Entity *entity = (*it); // render entity sound render_entity_sound(entity); diff --git a/src/client/view.cc b/src/client/view.cc index eda5cf8..75c4989 100644 --- a/src/client/view.cc +++ b/src/client/view.cc @@ -92,15 +92,13 @@ void draw_status() { using namespace render; - // print the status in the upper left corner std::stringstream status; - if (core::game()) { int minutes = (int) floorf(core::game()->clientframetime() / 60.0f); int seconds = (int) floorf( core::game()->clientframetime() - (float) minutes* 60.0f); status << "^Ntime ^B" << std::setfill(' ') << std::setw(3) << minutes << ":" << std::setfill('0') << std::setw(2) << seconds; - Text::draw(video::width-Text::fontwidth()*11-4, 4+Text::fontheight(), status); + Text::draw(video::width-Text::fontwidth()*11-4, 4, status); } // print stats if desired @@ -113,7 +111,8 @@ void draw_status() } stats << "^Ntx ^B"<< std::setw(5) << (core::Stats::network_bytes_sent >> 10) << "\n"; stats << "^Nrx ^B"<< std::setw(5) << (core::Stats::network_bytes_received >> 10) << "\n"; - Text::draw(video::width-Text::fontwidth()*11-4, 4 + Text::fontheight()*3, stats); + + Text::draw(video::width-Text::fontwidth()*11-4, 4 + Text::fontheight()*2, stats); } // draw a basic HUD @@ -136,6 +135,10 @@ void draw_status() Text::draw(4, video::height - Text::fontheight()*2 -4, location); } + if (core::localplayer()->zone()) { + Text::draw(video::width - 4-Text::fontwidth()*24, video::height - Text::fontheight()*3 -4, core::localplayer()->zone()->name()); + } + core::Entity *entity = targets::current(); if (entity) { std::stringstream target; @@ -345,6 +348,8 @@ void frame(float seconds) // Clear the color and depth buffers. gl::clear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + render::Stats::clear(); + if (core::application()->connected() && core::game()->serverframetime()) { render::draw(seconds); // draw the world targets::frame(); |