summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-07-26 18:55:44 +0300
committerAndrei Karas <akaras@inbox.ru>2015-07-26 18:55:44 +0300
commit8c3d197dbdfc00969f30309ee7bf52656b33ed1b (patch)
tree1ae60266bcd76a6399921ad9a0d5a9f6af9ae1de /src
parentb29f6896196376a6b3c2abf60de766811264af75 (diff)
downloadmv-8c3d197dbdfc00969f30309ee7bf52656b33ed1b.tar.gz
mv-8c3d197dbdfc00969f30309ee7bf52656b33ed1b.tar.bz2
mv-8c3d197dbdfc00969f30309ee7bf52656b33ed1b.tar.xz
mv-8c3d197dbdfc00969f30309ee7bf52656b33ed1b.zip
Fix code style.
Diffstat (limited to 'src')
-rw-r--r--src/actormanager.h3
-rw-r--r--src/gui/viewport.cpp3
-rw-r--r--src/utils/mathutils.h152
-rw-r--r--src/utils/xml.cpp6
4 files changed, 108 insertions, 56 deletions
diff --git a/src/actormanager.h b/src/actormanager.h
index a29e2ae11..02b060935 100644
--- a/src/actormanager.h
+++ b/src/actormanager.h
@@ -185,7 +185,8 @@ class ActorManager final: public ConfigListener
* Finds most damaged player, non-enemy and alive
* \param maxTileDist maximal distance.
*/
- Being *findMostDamagedPlayer(const int maxTileDist) const A_WARN_UNUSED;
+ Being *findMostDamagedPlayer(const int maxTileDist)
+ const A_WARN_UNUSED;
/**
* Heal all players in distance.
diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp
index ca301d8e8..e70165648 100644
--- a/src/gui/viewport.cpp
+++ b/src/gui/viewport.cpp
@@ -688,7 +688,8 @@ void Viewport::walkByMouse(const MouseEvent &event)
if (!mMap->getWalk(destX, f))
continue;
- const int offset = mMap->getHeightOffset(destX, f) * 16;
+ const int offset = mMap->getHeightOffset(
+ destX, f) * 16;
const int pixelF = f * 32;
const int diff = abs(clickY + offset - pixelF);
if (diff < newDiffY)
diff --git a/src/utils/mathutils.h b/src/utils/mathutils.h
index 37de98b54..36889306d 100644
--- a/src/utils/mathutils.h
+++ b/src/utils/mathutils.h
@@ -66,56 +66,106 @@ static constexpr const uint16_t crc_table[256] =
static constexpr const uint8_t square_roots[1000] =
{
- 0, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4, 4, 4, 4,
- 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 6, 6,
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
- 7, 7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
- 8, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
- 10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,10,
- 10,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,11,
- 11,11,11,11,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,12,
- 12,12,12,12,12,12,12,12,12,13,13,13,13,13,13,13,13,13,13,13,
- 13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,13,14,14,14,14,
- 14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,14,
- 14,14,14,14,14,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,
- 15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,16,16,16,16,
- 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,
- 16,16,16,16,16,16,16,16,16,17,17,17,17,17,17,17,17,17,17,17,
- 17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,
- 17,17,17,17,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,
- 18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,18,
- 18,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,
- 19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,19,
- 20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,
- 20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,20,
- 20,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,
- 21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,21,
- 21,21,21,21,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,
- 22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,22,
- 22,22,22,22,22,22,22,22,22,23,23,23,23,23,23,23,23,23,23,23,
- 23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,
- 23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,23,24,24,24,24,
- 24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,
- 24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,24,
- 24,24,24,24,24,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
- 25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
- 25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,26,
- 26,26,26,26,26,26,26,26,26,27,27,27,27,27,27,27,27,27,27,27,
- 27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,
- 27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,27,
- 27,27,27,27,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,
- 28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,
- 28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,
- 28,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,
- 29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,
- 29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,29,
- 30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,
- 30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,
- 30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,
- 30,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,
- 31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31,31
+ 0, 1, 1, 1, 2, 2, 2, 2, 2, 3,
+ 3, 3, 3, 3, 3, 3, 4, 4, 4, 4,
+ 4, 4, 4, 4, 4, 5, 5, 5, 5, 5,
+ 5, 5, 5, 5, 5, 5, 6, 6, 6, 6,
+ 6, 6, 6, 6, 6, 6, 6, 6, 6, 7,
+ 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
+ 7, 7, 7, 7, 8, 8, 8, 8, 8, 8,
+ 8, 8, 8, 8, 8, 8, 8, 8, 8, 8,
+ 8, 9, 9, 9, 9, 9, 9, 9, 9, 9,
+ 9, 9, 9, 9, 9, 9, 9, 9, 9, 9,
+ 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
+ 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
+ 10, 11, 11, 11, 11, 11, 11, 11, 11, 11,
+ 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
+ 11, 11, 11, 11, 12, 12, 12, 12, 12, 12,
+ 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,
+ 12, 12, 12, 12, 12, 12, 12, 12, 12, 13,
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
+ 13, 13, 13, 13, 13, 13, 14, 14, 14, 14,
+ 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
+ 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,
+ 14, 14, 14, 14, 14, 15, 15, 15, 15, 15,
+ 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
+ 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
+ 15, 15, 15, 15, 15, 15, 16, 16, 16, 16,
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 17,
+ 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
+ 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
+ 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,
+ 17, 17, 17, 17, 18, 18, 18, 18, 18, 18,
+ 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
+ 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
+ 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,
+ 18, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+ 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+ 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+ 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
+ 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
+ 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
+ 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
+ 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,
+ 20, 21, 21, 21, 21, 21, 21, 21, 21, 21,
+ 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
+ 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
+ 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
+ 21, 21, 21, 21, 22, 22, 22, 22, 22, 22,
+ 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
+ 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
+ 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,
+ 22, 22, 22, 22, 22, 22, 22, 22, 22, 23,
+ 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
+ 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
+ 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
+ 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
+ 23, 23, 23, 23, 23, 23, 24, 24, 24, 24,
+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
+ 24, 24, 24, 24, 24, 25, 25, 25, 25, 25,
+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
+ 25, 25, 25, 25, 25, 25, 26, 26, 26, 26,
+ 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
+ 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
+ 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
+ 26, 26, 26, 26, 26, 26, 26, 26, 26, 26,
+ 26, 26, 26, 26, 26, 26, 26, 26, 26, 27,
+ 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
+ 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
+ 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
+ 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
+ 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
+ 27, 27, 27, 27, 28, 28, 28, 28, 28, 28,
+ 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
+ 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
+ 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
+ 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
+ 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
+ 28, 29, 29, 29, 29, 29, 29, 29, 29, 29,
+ 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
+ 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
+ 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
+ 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
+ 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
+ 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,
+ 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,
+ 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,
+ 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,
+ 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,
+ 30, 30, 30, 30, 30, 30, 30, 30, 30, 30,
+ 30, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+ 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+ 31, 31, 31, 31, 31, 31, 31, 31, 31, 31,
+ 31, 31, 31, 31, 31, 31, 31, 31, 31, 31
};
inline uint16_t getCrc16(const std::string &str) A_WARN_UNUSED;
@@ -190,7 +240,7 @@ constexpr2 inline int fastSqrtInt(const unsigned int n)
{
if (n < 1000)
return static_cast<int>(square_roots[n]);
- return sqrt(n);
+ return static_cast<int>(sqrt(n));
}
#endif // UTILS_MATHUTILS_H
diff --git a/src/utils/xml.cpp b/src/utils/xml.cpp
index e9b2260bf..16888fae4 100644
--- a/src/utils/xml.cpp
+++ b/src/utils/xml.cpp
@@ -49,14 +49,14 @@ static void xmlErrorLogger(void *ctx A_UNUSED, const char *msg A_UNUSED, ...)
static void xmlErrorLogger(void *ctx A_UNUSED, const char *msg, ...)
{
+ if (!msg)
+ return;
+
size_t size = 1024;
const size_t msgSize = strlen(msg);
if (msgSize * 3 > size)
size = msgSize * 3;
- if (!msg)
- return;
-
char* buf = new char[size + 1];
va_list ap;