Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/targets.cc')
-rw-r--r--src/client/targets.cc85
1 files changed, 50 insertions, 35 deletions
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);