projects
/
supertux.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
e51ba8f
)
Small cleanup of Sector::get_nearest_player
author
Mathnerd314
<man.is.allan@gmail.com>
Thu, 4 Mar 2010 02:39:19 +0000
(
02:39
+0000)
committer
Mathnerd314
<man.is.allan@gmail.com>
Thu, 4 Mar 2010 02:39:19 +0000
(
02:39
+0000)
SVN-Revision: 6537
src/supertux/sector.cpp
patch
|
blob
|
history
diff --git
a/src/supertux/sector.cpp
b/src/supertux/sector.cpp
index
e57058f
..
273c1d4
100644
(file)
--- a/
src/supertux/sector.cpp
+++ b/
src/supertux/sector.cpp
@@
-1893,13
+1893,11
@@
Sector::get_gravity() const
return gravity;
}
return gravity;
}
-Player
*
+Player*
Sector::get_nearest_player (const Vector& pos)
{
Sector::get_nearest_player (const Vector& pos)
{
- Player *nearest_player;
- float nearest_dist;
-
- nearest_player = NULL;
+ Player *nearest_player = NULL;
+ float nearest_dist = std::numeric_limits<float>::max();
std::vector<Player*> players = Sector::current()->get_players();
for (std::vector<Player*>::iterator playerIter = players.begin();
std::vector<Player*> players = Sector::current()->get_players();
for (std::vector<Player*>::iterator playerIter = players.begin();
@@
-1907,20
+1905,18
@@
Sector::get_nearest_player (const Vector& pos)
++playerIter)
{
Player *this_player = *playerIter;
++playerIter)
{
Player *this_player = *playerIter;
- float this_dist;
-
if (this_player->is_dying() || this_player->is_dead())
continue;
if (this_player->is_dying() || this_player->is_dead())
continue;
-
this_dist = this_player->get_bbox ().distance
(pos);
+
float this_dist = this_player->get_bbox ().distance
(pos);
- if (
(nearest_player == NULL) || (nearest_dist > this_dist)
) {
+ if (
this_dist < nearest_dist
) {
nearest_player = this_player;
nearest_dist = this_dist;
}
}
nearest_player = this_player;
nearest_dist = this_dist;
}
}
- return
(nearest_player)
;
+ return
nearest_player
;
} /* Player *get_nearest_player */
std::vector<MovingObject*>
} /* Player *get_nearest_player */
std::vector<MovingObject*>