ClientEnvironment::~ClientEnvironment()
{
// delete active objects
- for (UNORDERED_MAP<u16, ClientActiveObject*>::iterator i = m_active_objects.begin();
- i != m_active_objects.end(); ++i) {
+ for (ClientActiveObjectMap::iterator i = m_active_objects.begin();
+ i != m_active_objects.end(); ++i) {
delete i->second;
}
pre_factor = 1.0 + (float)addp/100.0;
}
float speed = pre_factor * speed_diff.getLength();
- if(speed > tolerance)
- {
- f32 damage_f = (speed - tolerance)/BS * post_factor;
- u16 damage = (u16)(damage_f+0.5);
- if(damage != 0){
+ if (speed > tolerance) {
+ f32 damage_f = (speed - tolerance) / BS * post_factor;
+ u8 damage = (u8)MYMIN(damage_f + 0.5, 255);
+ if (damage != 0) {
damageLocalPlayer(damage, true);
MtEvent *e = new SimpleTriggerEvent("PlayerFallingDamage");
m_client->event()->put(e);
g_profiler->avg("CEnv: num of objects", m_active_objects.size());
bool update_lighting = m_active_object_light_update_interval.step(dtime, 0.21);
- for (UNORDERED_MAP<u16, ClientActiveObject*>::iterator i = m_active_objects.begin();
- i != m_active_objects.end(); ++i) {
+ for (ClientActiveObjectMap::iterator i = m_active_objects.begin();
+ i != m_active_objects.end(); ++i) {
ClientActiveObject* obj = i->second;
// Step object
obj->step(dtime, this);
ClientActiveObject* ClientEnvironment::getActiveObject(u16 id)
{
- UNORDERED_MAP<u16, ClientActiveObject*>::iterator n = m_active_objects.find(id);
+ ClientActiveObjectMap::iterator n = m_active_objects.find(id);
if (n == m_active_objects.end())
return NULL;
return n->second;
}
bool isFreeClientActiveObjectId(const u16 id,
- UNORDERED_MAP<u16, ClientActiveObject*> &objects)
+ ClientActiveObjectMap &objects)
{
if(id == 0)
return false;
return objects.find(id) == objects.end();
}
-u16 getFreeClientActiveObjectId(UNORDERED_MAP<u16, ClientActiveObject*> &objects)
+u16 getFreeClientActiveObjectId(ClientActiveObjectMap &objects)
{
//try to reuse id's as late as possible
static u16 last_used_id = 0;
void ClientEnvironment::getActiveObjects(v3f origin, f32 max_d,
std::vector<DistanceSortedActiveObject> &dest)
{
- for (UNORDERED_MAP<u16, ClientActiveObject*>::iterator i = m_active_objects.begin();
- i != m_active_objects.end(); ++i) {
+ for (ClientActiveObjectMap::iterator i = m_active_objects.begin();
+ i != m_active_objects.end(); ++i) {
ClientActiveObject* obj = i->second;
f32 d = (obj->getPosition() - origin).getLength();