Translated using Weblate (Japanese)
[oweals/minetest.git] / src / nodetimer.cpp
index d1043fa51341815ec950406c80a33da3debe708b..a5b48a5afa07a44af744915f95bb29182ba227a4 100644 (file)
@@ -1,6 +1,6 @@
 /*
 Minetest
-Copyright (C) 2010-2012 celeron55, Perttu Ahola <celeron55@gmail.com>
+Copyright (C) 2010-2013 celeron55, Perttu Ahola <celeron55@gmail.com>
 
 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU Lesser General Public License as published by
@@ -19,6 +19,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 
 #include "nodetimer.h"
 #include "log.h"
+#include "serialization.h"
 #include "util/serialize.h"
 #include "constants.h" // MAP_BLOCKSIZE
 
@@ -46,7 +47,7 @@ void NodeTimerList::serialize(std::ostream &os, u8 map_format_version) const
 {
        if(map_format_version == 24){
                // Version 0 is a placeholder for "nothing to see here; go away."
-               if(m_data.size() == 0){
+               if(m_data.empty()){
                        writeU8(os, 0); // version
                        return;
                }
@@ -61,7 +62,7 @@ void NodeTimerList::serialize(std::ostream &os, u8 map_format_version) const
 
        for(std::map<v3s16, NodeTimer>::const_iterator
                        i = m_data.begin();
-                       i != m_data.end(); i++){
+                       i != m_data.end(); ++i){
                v3s16 p = i->first;
                NodeTimer t = i->second;
 
@@ -95,12 +96,12 @@ void NodeTimerList::deSerialize(std::istream &is, u8 map_format_version)
        {
                u16 p16 = readU16(is);
 
-               v3s16 p(0,0,0);
-               p.Z += p16 / MAP_BLOCKSIZE / MAP_BLOCKSIZE;
-               p16 -= p.Z * MAP_BLOCKSIZE * MAP_BLOCKSIZE;
-               p.Y += p16 / MAP_BLOCKSIZE;
-               p16 -= p.Y * MAP_BLOCKSIZE;
-               p.X += p16;
+               v3s16 p;
+               p.Z = p16 / MAP_BLOCKSIZE / MAP_BLOCKSIZE;
+               p16 &= MAP_BLOCKSIZE * MAP_BLOCKSIZE - 1;
+               p.Y = p16 / MAP_BLOCKSIZE;
+               p16 &= MAP_BLOCKSIZE - 1;
+               p.X = p16;
 
                NodeTimer t;
                t.deSerialize(is);
@@ -133,7 +134,7 @@ std::map<v3s16, NodeTimer> NodeTimerList::step(float dtime)
        // Increment timers
        for(std::map<v3s16, NodeTimer>::iterator
                        i = m_data.begin();
-                       i != m_data.end(); i++){
+                       i != m_data.end(); ++i){
                v3s16 p = i->first;
                NodeTimer t = i->second;
                t.elapsed += dtime;
@@ -145,7 +146,7 @@ std::map<v3s16, NodeTimer> NodeTimerList::step(float dtime)
        // Delete elapsed timers
        for(std::map<v3s16, NodeTimer>::const_iterator
                        i = elapsed_timers.begin();
-                       i != elapsed_timers.end(); i++){
+                       i != elapsed_timers.end(); ++i){
                v3s16 p = i->first;
                m_data.erase(p);
        }