summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitlab-ci.yml66
-rwxr-xr-xconfigure.ac1
-rw-r--r--po/POTFILES.in9
-rwxr-xr-xpo/POTgen.sh4
-rw-r--r--src/CMakeLists.txt4
-rw-r--r--src/Makefile.am4
-rw-r--r--src/actormanager.cpp161
-rw-r--r--src/actormanager.h14
-rw-r--r--src/being/actorsprite.cpp43
-rw-r--r--src/gui/onlineplayer.h2
-rw-r--r--src/gui/windows/buydialog.cpp30
-rw-r--r--src/gui/windows/buydialog.h2
-rw-r--r--src/net/eathena/adminrecv.cpp12
-rw-r--r--src/net/eathena/adminrecv.h1
-rw-r--r--src/net/eathena/network.cpp1
-rw-r--r--src/net/eathena/packetsin.inc2
-rw-r--r--src/net/tmwa/adminrecv.cpp (renamed from src/net/ea/adminrecv.cpp)8
-rw-r--r--src/net/tmwa/adminrecv.h (renamed from src/net/ea/adminrecv.h)10
-rw-r--r--src/net/tmwa/network.cpp2
-rw-r--r--src/net/tmwa/packetsin.inc2
-rw-r--r--src/utils/checkutils.h9
-rwxr-xr-xtools/ci/jobs/cpplint.sh17
22 files changed, 182 insertions, 222 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index d3be39d84..7f73ecab0 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -74,8 +74,6 @@ variables:
libxml2-dev libcurl4-gnutls-dev libpng-dev
libsdl-gfx1.2-dev libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl-net1.2-dev libsdl-ttf2.0-dev
gdb valgrind netcat-openbsd procps
- tags:
- - docker
# Disabled: drop 1386 support
.gcc-8-i386:
@@ -92,8 +90,6 @@ variables:
libxml2-dev libcurl4-gnutls-dev libpng-dev
libsdl-gfx1.2-dev libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl-net1.2-dev libsdl-ttf2.0-dev
gdb valgrind netcat-openbsd procps
- tags:
- - docker
# Do we really need to test such bleeding edge?
# It's mostly a waste of CI time and it should be made allow-fail, perhaps?
@@ -112,8 +108,6 @@ variables:
libxml2-dev libcurl4-gnutls-dev libpng-dev
libsdl2-gfx-dev libsdl2-image-dev libsdl2-mixer-dev libsdl2-net-dev libsdl2-ttf-dev
git gdb valgrind netcat-openbsd procps
- tags:
- - docker
# Disabled: drop 1386 support
@@ -132,8 +126,6 @@ variables:
libxml2-dev libcurl4-gnutls-dev libpng-dev
libsdl-gfx1.2-dev libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl-net1.2-dev libsdl-ttf2.0-dev
gdb valgrind netcat-openbsd procps
- tags:
- - docker
# TODO: Clang 3.9 is down but we don't have a newer Clang to test?
.clang-3.9:
@@ -151,8 +143,6 @@ variables:
libxml2-dev libcurl4-gnutls-dev libpng-dev
libsdl-gfx1.2-dev libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl-net1.2-dev libsdl-ttf2.0-dev
gdb valgrind netcat-openbsd procps
- tags:
- - docker
.gcc-7:
stage: prebuild
@@ -169,8 +159,6 @@ variables:
libxml2-dev libcurl4-gnutls-dev libpng-dev
libsdl-gfx1.2-dev libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl-net1.2-dev libsdl-ttf2.0-dev
gdb valgrind netcat-openbsd procps
- tags:
- - docker
gcc-8:
stage: prebuild
@@ -189,8 +177,6 @@ gcc-8:
libxml2-dev libcurl4-gnutls-dev libpng-dev
libsdl-gfx1.2-dev libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl-net1.2-dev libsdl-ttf2.0-dev
gdb valgrind netcat-openbsd procps
- tags:
- - docker
.gcc-7_default:
stage: prebuild
@@ -211,8 +197,6 @@ gcc-8:
libxml2-dev libcurl4-gnutls-dev libpng-dev
libsdl-gfx1.2-dev libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl-net1.2-dev libsdl-ttf2.0-dev
gdb valgrind netcat-openbsd procps
- tags:
- - docker
gcc-10_default:
stage: prebuild
@@ -233,8 +217,6 @@ gcc-10_default:
libxml2-dev libcurl4-gnutls-dev libpng-dev
libsdl-gfx1.2-dev libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl-net1.2-dev libsdl-ttf2.0-dev
gdb valgrind netcat-openbsd procps
- tags:
- - docker
# This and the next job do not work any more:
# access denied pulling the specified image
@@ -250,8 +232,6 @@ gcc-10_default:
variables:
PACKAGES: bash
CROSS: i686-w64-mingw32.shared
- tags:
- - docker
.mxe_gcc6_shared_64:
only:
@@ -265,8 +245,6 @@ gcc-10_default:
variables:
PACKAGES: bash
CROSS: x86_64-w64-mingw32.shared
- tags:
- - docker
docker-windows-builder:
stage: prebuild
@@ -296,8 +274,6 @@ gcc-5_sdl2:
libxml2-dev libcurl4-gnutls-dev libpng-dev
libsdl2-gfx-dev libsdl2-image-dev libsdl2-mixer-dev libsdl2-net-dev libsdl2-ttf-dev
gdb valgrind netcat-openbsd procps
- tags:
- - docker
# TODO: make this only run once-in-a-while (e.g. before release?)
.gcc-10_game_only:
@@ -314,8 +290,6 @@ gcc-5_sdl2:
libxml2-dev libcurl4-gnutls-dev libpng-dev
libsdl-gfx1.2-dev libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl-net1.2-dev libsdl-ttf2.0-dev
gdb valgrind netcat-openbsd procps
- tags:
- - docker
# TODO: make this only run once-in-a-while (e.g. before release?)
.gcc-10_dyecmd_only:
@@ -331,8 +305,6 @@ gcc-5_sdl2:
make autoconf automake autopoint gettext
libxml2-dev libcurl4-gnutls-dev libpng-dev
libsdl-gfx1.2-dev libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl-net1.2-dev libsdl-ttf2.0-dev
- tags:
- - docker
gcc-8_unittestsbin:
stage: prebuild
@@ -348,12 +320,12 @@ gcc-8_unittestsbin:
make autoconf automake autopoint gettext
libxml2-dev libcurl4-gnutls-dev libpng-dev
libsdl-gfx1.2-dev libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl-net1.2-dev libsdl-ttf2.0-dev
- tags:
- - docker
linters:
stage: lint
+ tags:
+ - lightweight
image: debian:bullseye
script:
- ./tools/ci/jobs/mplint.sh src po data
@@ -366,8 +338,6 @@ linters:
variables:
MPLINT_PACKAGE_URL: "$CI_API_V4_URL/projects/mana%2Fmplint/jobs/artifacts/master/download?job=package_debian10_buster"
PACKAGES: git grep imagemagick pngcheck python2 python3 unzip wget
- tags:
- - docker
gcc-5_h_all:
@@ -388,8 +358,6 @@ gcc-5_h_all:
make autoconf automake autopoint gettext
libxml2-dev libcurl4-gnutls-dev libpng-dev
libsdl-gfx1.2-dev libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl-net1.2-dev libsdl-ttf2.0-dev
- tags:
- - docker
# Disabled: drop 1386 support
.gcc-5_h_all_i386:
@@ -408,8 +376,6 @@ gcc-5_h_all:
make autoconf automake autopoint gettext
libxml2-dev libcurl4-gnutls-dev libpng-dev
libsdl-gfx1.2-dev libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl-net1.2-dev libsdl-ttf2.0-dev
- tags:
- - docker
# Coverage support is broken
.gcov_gcc7:
@@ -436,8 +402,6 @@ gcc-5_h_all:
coverage_report:
coverage_format: cobertura
path: coverage/gcc-7.xml
- tags:
- - docker
doxygen:
stage: build
@@ -454,11 +418,11 @@ doxygen:
paths:
- doxygen
expire_in: 2 days
- tags:
- - docker
pages:
stage: deploy
+ tags:
+ - lightweight
image: debian:buster
script:
- mkdir -p public
@@ -508,8 +472,6 @@ triggers:
ASAN_OPTIONS: "detect_leaks=0"
runenvz: /usr/local/spm/bin/${LIBNAME}_${LIBVERSION}/runzlib_master.sh
runenvx: /usr/local/spm/bin/${LIBNAME}_${LIBVERSION}/runlibxml2_master.sh
- tags:
- - docker
# disabled due gitlab bug
.gcc-10_SDL_default_sanitize2_test:
@@ -534,8 +496,6 @@ triggers:
ASAN_OPTIONS: "detect_leaks=0"
runenvz: /usr/local/spm/bin/${LIBNAME}_${LIBVERSION}/runzlib_master.sh
runenvx: /usr/local/spm/bin/${LIBNAME}_${LIBVERSION}/runlibxml2_master.sh
- tags:
- - docker
# disabled due gitlab bug
.gcc-10_SDL_SDL-1.2_sanitize_test:
@@ -558,8 +518,6 @@ triggers:
wget unzip
runenvz: /usr/local/spm/bin/${LIBNAME}_${LIBVERSION}/runzlib_master.sh
runenvx: /usr/local/spm/bin/${LIBNAME}_${LIBVERSION}/runlibxml2_master.sh
- tags:
- - docker
# disabled due gitlab bug
.gcc-10_SDL_default_sanitize_test:
@@ -580,8 +538,6 @@ triggers:
wget unzip
runenvz: /usr/local/spm/bin/${LIBNAME}_${LIBVERSION}/runzlib_master.sh
runenvx: /usr/local/spm/bin/${LIBNAME}_${LIBVERSION}/runlibxml2_master.sh
- tags:
- - docker
# disabled due gitlab bug
@@ -607,8 +563,6 @@ triggers:
runenvz: /usr/local/spm/bin/${LIBNAME}_${LIBVERSION}/runzlib_v1.2.5.sh
runenvx: /usr/local/spm/bin/${LIBNAME}_${LIBVERSION}/runlibxml2_v2.9.1.sh
POST_CXXFLAGS: "-Wno-undef"
- tags:
- - docker
# disabled due gitlab bug
.gcc-10_SDL_default_old_sanitize_test:
@@ -631,8 +585,6 @@ triggers:
runenvz: /usr/local/spm/bin/${LIBNAME}_${LIBVERSION}/runzlib_v1.2.5.sh
runenvx: /usr/local/spm/bin/${LIBNAME}_${LIBVERSION}/runlibxml2_v2.9.1.sh
POST_CXXFLAGS: "-Wno-undef"
- tags:
- - docker
# error compilation. cant find SDL.
.gcc-10_zlib_ng_develop:
@@ -652,8 +604,6 @@ triggers:
libxml2-dev libcurl4-gnutls-dev libpng-dev
libsdl-gfx1.2-dev libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl-net1.2-dev libsdl-ttf2.0-dev
wget unzip gdb valgrind netcat-openbsd procps
- tags:
- - docker
# disabled due gitlab bug
.gcc-10_SDL_SDL-1.2_sanitize:
@@ -676,8 +626,6 @@ triggers:
wget unzip
runenvz: /usr/local/spm/bin/${LIBNAME}_${LIBVERSION}/runzlib_master.sh
runenvx: /usr/local/spm/bin/${LIBNAME}_${LIBVERSION}/runlibxml2_master.sh
- tags:
- - docker
# disabled due gitlab bug
.gcc-10_SDL_default_sanitize:
@@ -698,8 +646,6 @@ triggers:
wget unzip
runenvz: /usr/local/spm/bin/${LIBNAME}_${LIBVERSION}/runzlib_master.sh
runenvx: /usr/local/spm/bin/${LIBNAME}_${LIBVERSION}/runlibxml2_master.sh
- tags:
- - docker
# disabled due gitlab bug
@@ -725,8 +671,6 @@ triggers:
runenvz: /usr/local/spm/bin/${LIBNAME}_${LIBVERSION}/runzlib_v1.2.5.sh
runenvx: /usr/local/spm/bin/${LIBNAME}_${LIBVERSION}/runlibxml2_v2.9.1.sh
POST_CXXFLAGS: "-Wno-undef"
- tags:
- - docker
# disabled due gitlab bug
.gcc-10_SDL_default_old_sanitize:
@@ -749,5 +693,3 @@ triggers:
runenvz: /usr/local/spm/bin/${LIBNAME}_${LIBVERSION}/runzlib_v1.2.5.sh
runenvx: /usr/local/spm/bin/${LIBNAME}_${LIBVERSION}/runlibxml2_v2.9.1.sh
POST_CXXFLAGS: "-Wno-undef"
- tags:
- - docker
diff --git a/configure.ac b/configure.ac
index dc041d8c9..1d25ae8e1 100755
--- a/configure.ac
+++ b/configure.ac
@@ -954,6 +954,7 @@ echo "Build with OpenGL: $with_opengl"
echo
echo "LIBS: $LIBS"
echo "CPPFLAGS: $CPPFLAGS"
+echo "CXXFLAGS: $CXXFLAGS"
echo
echo "configure complete, now type \"make\""
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 5bcdeb29e..0d4765054 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -140,8 +140,6 @@ src/input/pages/other.cpp
src/input/pages/outfits.cpp
src/input/pages/shortcuts.cpp
src/input/pages/windows.cpp
-src/localconsts.h
-src/logger.h
src/net/ea/charserverrecv.cpp
src/net/ea/chatrecv.cpp
src/net/ea/gamerecv.cpp
@@ -155,11 +153,9 @@ src/net/eathena/generalhandler.cpp
src/net/eathena/generalrecv.cpp
src/net/eathena/guildrecv.cpp
src/net/eathena/inventoryrecv.cpp
-src/net/eathena/itemflags.h
src/net/eathena/loginrecv.cpp
src/net/eathena/mail2recv.cpp
src/net/eathena/mailrecv.cpp
-src/net/eathena/maptypeproperty2.h
src/net/eathena/playerrecv.cpp
src/net/eathena/skillrecv.cpp
src/net/eathena/vendingrecv.cpp
@@ -203,12 +199,7 @@ src/resources/modinfo.cpp
src/resources/notifications.h
src/resources/skill/skillinfo.cpp
src/resources/skill/skilltypelist.h
-src/unittests/catch.hpp
-src/unittests/doctest.h
-src/unittests/endian.cc
src/unittests/gui/windowmanager.cc
src/utils/booleanoptions.h
src/utils/gettext.h
src/utils/stringutils.cpp
-src/utils/stringutils.h
-src/utils/xml/libxml.cpp
diff --git a/po/POTgen.sh b/po/POTgen.sh
index a2b1ad31c..12890f41f 100755
--- a/po/POTgen.sh
+++ b/po/POTgen.sh
@@ -16,9 +16,9 @@ printf "# Generated by %s, do not edit manually\n" "$0" > po/POTFILES.in
# See WARNING in manpage of GNU Coreutils sort:
# LC_COLLATE override is required to preserve the order of files
-# across platforms. But it can be override by LC_ALL.
+# across platforms. But it can be overriden by LC_ALL.
# But, LC_ALL should never be set in a sane environment.
-grep "_(" src \
+grep "[^_]_(" src \
--binary-files=without-match \
--files-with-matches \
--recursive \
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 9f5a22e0f..6195f9260 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -2010,8 +2010,6 @@ SET(DYE_CMD_SRCS
)
SET(SRCS_EVOL
- net/ea/adminrecv.cpp
- net/ea/adminrecv.h
net/ea/adminhandler.cpp
net/ea/adminhandler.h
net/ea/beingrecv.cpp
@@ -2082,6 +2080,8 @@ SET(SRCS_TMWA
gui/windows/shopselldialog.h
net/tmwa/adminhandler.cpp
net/tmwa/adminhandler.h
+ net/tmwa/adminrecv.cpp
+ net/tmwa/adminrecv.h
net/tmwa/achievementhandler.cpp
net/tmwa/achievementhandler.h
net/tmwa/attendancehandler.cpp
diff --git a/src/Makefile.am b/src/Makefile.am
index f11d310e4..394a7bd45 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1639,8 +1639,6 @@ SRC = ${BASE_SRC} \
net/protocoloutdefine.h \
net/protocoloutinclude.h \
net/protocoloutupdate.h \
- net/ea/adminrecv.cpp \
- net/ea/adminrecv.h \
net/ea/adminhandler.cpp \
net/ea/adminhandler.h \
net/ea/beingrecv.cpp \
@@ -1728,6 +1726,8 @@ SRC += \
gui/windows/shopselldialog.h \
net/tmwa/adminhandler.cpp \
net/tmwa/adminhandler.h \
+ net/tmwa/adminrecv.cpp \
+ net/tmwa/adminrecv.h \
net/tmwa/achievementhandler.cpp \
net/tmwa/achievementhandler.h \
net/tmwa/attendancehandler.cpp \
diff --git a/src/actormanager.cpp b/src/actormanager.cpp
index 80dc6e25d..e33798bab 100644
--- a/src/actormanager.cpp
+++ b/src/actormanager.cpp
@@ -1130,7 +1130,7 @@ Being *ActorManager::findNearestLivingBeing(const Being *const aroundBeing,
}
Being *ActorManager::findNearestLivingBeing(const Being *const aroundBeing,
- int maxDist,
+ const int maxDist,
const ActorTypeT &type,
const int x, const int y,
const Being *const excluded,
@@ -1155,7 +1155,7 @@ Being *ActorManager::findNearestLivingBeing(const Being *const aroundBeing,
specialDistance = true;
}
- maxDist = maxDist * maxDist;
+ const int maxDistSq = maxDist * maxDist;
const bool cycleSelect = allowSort == AllowSort_true
&& ((mCyclePlayers && type == ActorType::Player)
@@ -1288,9 +1288,9 @@ Being *ActorManager::findNearestLivingBeing(const Being *const aroundBeing,
return *i;
}
- int dist = 0;
- int index = defaultPriorityIndex;
Being *closestBeing = nullptr;
+ int closestDistSq = maxDistSq + 1;
+ int closestPriority = defaultPriorityIndex;
FOR_EACH (ActorSprites::iterator, i, mActors)
{
@@ -1305,96 +1305,77 @@ Being *ActorManager::findNearestLivingBeing(const Being *const aroundBeing,
}
Being *const being = static_cast<Being*>(*i);
- if (filtered)
- {
- if (ignoreAttackMobs.find(being->getName())
- != ignoreAttackMobs.end())
- {
- continue;
- }
- if (ignoreDefault && attackMobs.find(being->getName())
- == attackMobs.end() && priorityMobs.find(being->getName())
- == priorityMobs.end())
- {
- continue;
- }
- }
-
if ((being->getInfo() != nullptr)
&& !(being->getInfo()->isTargetSelection() || modActive))
{
continue;
}
- const bool valid = validateBeing(aroundBeing, being,
- type, excluded, 50);
- int d = being->getDistance();
- if (being->getType() != ActorType::Monster
- || !mTargetOnlyReachable)
- { // if distance not calculated, use old distance
- const int dx = being->getTileX() - x;
- const int dy = being->getTileY() - y;
- d = dx*dx + dy*dy;
- }
-
- if (!valid)
+ // Cheap bounding box check, first, before engaging the pathfinder
+ // (in validateBeing call). Target is _at minimum_ distSq away
+ const int dx = being->getTileX() - x;
+ const int dy = being->getTileY() - y;
+ int distSq = dx*dx + dy*dy;
+ if (distSq > maxDistSq)
continue;
- if (specialDistance && being->getDistance() <= 2
- && being->getType() == type)
+ // Check if target is too close
+ if (specialDistance
+ && (distSq <= 2*2)
+ && (being->getType() == type))
{
continue;
}
-// logger->log("being name:" + being->getName());
-// logger->log("index:" + toString(index));
-// logger->log("d:" + toString(d));
-
- if (!filtered && (d <= dist || (closestBeing == nullptr)))
- {
- dist = d;
- closestBeing = being;
- }
- else if (filtered)
+ int priority = defaultPriorityIndex;
+ if (filtered)
{
- int w2 = defaultPriorityIndex;
- if (closestBeing != nullptr)
+ // Skip ignored
+ if (ignoreAttackMobs.find(being->getName()) !=
+ ignoreAttackMobs.end())
{
- const StringIntMapCIter it2 = priorityMobsMap.find(
- being->getName());
- if (it2 != priorityMobsMap.end())
- w2 = (*it2).second;
-
- if (w2 < index)
- {
- dist = d;
- closestBeing = being;
- index = w2;
- continue;
- }
- if (w2 == index && d <= dist)
- {
- dist = d;
- closestBeing = being;
- index = w2;
- continue;
- }
+ continue;
}
- if (closestBeing == nullptr)
+ const StringIntMapCIter prioIter
+ = priorityMobsMap.find(being->getName());
+
+ if (prioIter != priorityMobsMap.end())
+ priority = prioIter->second;
+
+ // if (default) is in ignore list, then only attack
+ // those in priority or general attack list.
+ if (ignoreDefault
+ && attackMobs.find(being->getName()) == attackMobs.end()
+ && prioIter == priorityMobsMap.end())
{
- dist = d;
- closestBeing = being;
- const StringIntMapCIter it1 = priorityMobsMap.find(
- being->getName());
- if (it1 != priorityMobsMap.end())
- index = (*it1).second;
- else
- index = defaultPriorityIndex;
+ continue;
}
}
+
+ if (!validateBeing(aroundBeing, being, type, excluded, 50))
+ continue;
+
+ // see validateBeing for when real distance is valid
+ if (mTargetOnlyReachable && being->getType() == ActorType::Monster)
+ {
+ const int d = being->getDistance();
+ distSq = d*d;
+ }
+
+ //logger->log("being prio:%3d, dist^2:%3d, name: '%s'",
+ // priority, distSq, being->getName().c_str());
+
+ // without filtering, priority and closestPriority are always the same
+ if ((priority == closestPriority && distSq < closestDistSq) ||
+ (priority < closestPriority && distSq <= maxDistSq))
+ {
+ closestDistSq = distSq;
+ closestBeing = being;
+ closestPriority = priority;
+ }
}
- return (maxDist >= dist) ? closestBeing : nullptr;
+ return closestBeing;
}
bool ActorManager::validateBeing(const Being *const aroundBeing,
@@ -1405,12 +1386,32 @@ bool ActorManager::validateBeing(const Being *const aroundBeing,
{
if (localPlayer == nullptr)
return false;
- return (being != nullptr) && ((being->getType() == type
- || type == ActorType::Unknown) && (being->isAlive()
- || (mTargetDeadPlayers && type == ActorType::Player))
- && being != aroundBeing) && being != excluded
- && (type != ActorType::Monster || !mTargetOnlyReachable
- || localPlayer->isReachable(being, maxCost));
+
+ if (being == nullptr)
+ return false;
+
+ if (being == aroundBeing)
+ return false;
+
+ if (being == excluded)
+ return false;
+
+ // If specific being type is given, it must match.
+ if (!(being->getType() == type || type == ActorType::Unknown))
+ return false;
+
+ if (!being->isAlive())
+ if (!mTargetDeadPlayers || type != ActorType::Player)
+ return false;
+
+ // Why are we ignoring real reachability checks for non-monsters?
+ if (type != ActorType::Monster)
+ return true;
+
+ if (!mTargetOnlyReachable)
+ return true;
+
+ return localPlayer->isReachable(being, maxCost);
}
#ifdef TMWA_SUPPORT
diff --git a/src/actormanager.h b/src/actormanager.h
index 43b9341b9..15841f61d 100644
--- a/src/actormanager.h
+++ b/src/actormanager.h
@@ -393,6 +393,20 @@ class ActorManager final : public ConfigListener
#ifndef UNITTESTS
protected:
#endif // UNITTESTS
+ /*
+ * General checks if a being is valid for selection.
+ * Additionally, localPlayer is checked to exist
+ *
+ * @param aroundBeing being must not equal this one
+ * @param being being under scrutiny. Nullptr check performed
+ * it must be alive unless a player and
+ * mTargetDeadPlayers is true.
+ * @param type pass ActorType::Unknown if no matching desired
+ * @param exluded being must not equal this one
+ * @param maxCost allowed max pathfinder distance, if applicable
+ * (only if being is a monster and
+ * mTargetOnlyReachable is true)
+ */
bool validateBeing(const Being *const aroundBeing,
Being *const being,
const ActorTypeT &type,
diff --git a/src/being/actorsprite.cpp b/src/being/actorsprite.cpp
index 3beb5b9d2..25a118f88 100644
--- a/src/being/actorsprite.cpp
+++ b/src/being/actorsprite.cpp
@@ -124,9 +124,7 @@ void ActorSprite::logic()
if (effect != nullptr &&
effect->mIsPersistent)
{
- updateStatusEffect(*it,
- Enable_true,
- IsStart_false);
+ updateStatusEffect(*it, Enable_true, IsStart_false);
}
}
}
@@ -228,9 +226,7 @@ static void applyEffectByOption(ActorSprite *const actor,
const Enable enable = (opt & option) != 0 ? Enable_true : Enable_false;
option |= opt;
option ^= opt;
- actor->setStatusEffect(id,
- enable,
- IsStart_false);
+ actor->setStatusEffect(id, enable, IsStart_false);
}
if (option != 0U &&
config.getBoolValue("unimplimentedLog"))
@@ -240,8 +236,8 @@ static void applyEffectByOption(ActorSprite *const actor,
"Left value: %u",
name,
option);
- logger->log(str);
- DebugMessageListener::distributeEvent(str);
+ logger->log(str);
+ DebugMessageListener::distributeEvent(str);
}
}
@@ -256,16 +252,12 @@ static void applyEffectByOption1(ActorSprite *const actor,
const int32_t id = (*it).second;
if (opt == option)
{
- actor->setStatusEffect(id,
- Enable_true,
- IsStart_false);
+ actor->setStatusEffect(id, Enable_true, IsStart_false);
option = 0U;
}
else
{
- actor->setStatusEffect(id,
- Enable_false,
- IsStart_false);
+ actor->setStatusEffect(id, Enable_false, IsStart_false);
}
}
if (option != 0 &&
@@ -276,8 +268,8 @@ static void applyEffectByOption1(ActorSprite *const actor,
"Left value: %u",
name,
option);
- logger->log(str);
- DebugMessageListener::distributeEvent(str);
+ logger->log(str);
+ DebugMessageListener::distributeEvent(str);
}
}
@@ -318,8 +310,9 @@ void ActorSprite::updateStatusEffect(const int32_t index,
const Enable newStatus,
const IsStart start)
{
- StatusEffect *const effect = StatusEffectDB::getStatusEffect(
- index, newStatus);
+ StatusEffect *const effect
+ = StatusEffectDB::getStatusEffect(index, newStatus);
+
if (effect == nullptr)
return;
if (effect->mIsPoison && getType() == ActorType::Player)
@@ -385,9 +378,10 @@ void ActorSprite::setupSpriteDisplay(const SpriteDisplay &display,
{
if (display.image.empty())
{
- addSprite(AnimatedSprite::delayedLoad(pathJoin(
- paths.getStringValue("sprites"),
- paths.getStringValue("spriteErrorFile")),
+ addSprite(AnimatedSprite::delayedLoad(
+ pathJoin(
+ paths.getStringValue("sprites"),
+ paths.getStringValue("spriteErrorFile")),
0));
}
else
@@ -524,10 +518,9 @@ std::string ActorSprite::getStatusEffectsString() const
{
FOR_EACH (std::set<int32_t>::const_iterator, it, mStatusEffects)
{
- const StatusEffect *const effect =
- StatusEffectDB::getStatusEffect(
- *it,
- Enable_true);
+ const StatusEffect *const effect
+ = StatusEffectDB::getStatusEffect(*it, Enable_true);
+
if (effect == nullptr)
continue;
if (!effectsStr.empty())
diff --git a/src/gui/onlineplayer.h b/src/gui/onlineplayer.h
index 64ab76abd..b38960c56 100644
--- a/src/gui/onlineplayer.h
+++ b/src/gui/onlineplayer.h
@@ -54,7 +54,7 @@ class OnlinePlayer final
const std::string getNick() const noexcept2 A_WARN_UNUSED
{ return mNick; }
- unsigned char getStaus() const noexcept2 A_WARN_UNUSED
+ unsigned char getStatus() const noexcept2 A_WARN_UNUSED
{ return mStatus; }
void setIsGM(const bool b)
diff --git a/src/gui/windows/buydialog.cpp b/src/gui/windows/buydialog.cpp
index f30fb92e4..038ddb3ac 100644
--- a/src/gui/windows/buydialog.cpp
+++ b/src/gui/windows/buydialog.cpp
@@ -226,6 +226,7 @@ BuyDialog::BuyDialog() :
mMoney(0),
mAmountItems(0),
mMaxItems(0),
+ mTotalPurchaseWeight(0),
mAdvanced(false)
{
init();
@@ -248,6 +249,7 @@ BuyDialog::BuyDialog(const BeingId npcId,
mMoney(0),
mAmountItems(0),
mMaxItems(0),
+ mTotalPurchaseWeight(0),
mAdvanced(Net::getNetworkType() != ServerType::TMWATHENA)
{
init();
@@ -272,6 +274,7 @@ BuyDialog::BuyDialog(const std::string &nick,
mMoney(0),
mAmountItems(0),
mMaxItems(0),
+ mTotalPurchaseWeight(0),
mAdvanced(false)
{
init();
@@ -296,6 +299,7 @@ BuyDialog::BuyDialog(const Being *const being,
mMoney(0),
mAmountItems(0),
mMaxItems(0),
+ mTotalPurchaseWeight(0),
mAdvanced(true)
{
init();
@@ -338,8 +342,8 @@ void BuyDialog::init()
"%d / %d", mAmountItems, mMaxItems));
mQuantityLabel->setAlignment(Graphics::CENTER);
mMoneyLabel = new Label(this, strprintf(
- // TRANSLATORS: buy dialog label
- _("Price: %s / Total: %s"), "", ""));
+ // TRANSLATORS: buy dialog label, price, remaining money & free weight
+ _("Price: %s, Remaining: %s & %s"), "", "", ""));
mAmountField = new IntTextField(this, 1, 1, 123, Enable_true, 0);
mAmountField->setActionEventId("amount");
@@ -473,6 +477,7 @@ void BuyDialog::reset()
mShopItemList->setSelected(-1);
mSlider->setValue(0);
+ mTotalPurchaseWeight = 0;
setMoney(0);
}
@@ -637,6 +642,8 @@ void BuyDialog::action(const ActionEvent &event)
else if (mNpcId == fromInt(Vending, BeingId))
{
item->increaseUsedQuantity(mAmountItems);
+ const int itemWeight = item->getInfo().getWeight();
+ mTotalPurchaseWeight += mAmountItems * itemWeight;
item->update();
if (mConfirmButton != nullptr)
mConfirmButton->setEnabled(true);
@@ -650,6 +657,8 @@ void BuyDialog::action(const ActionEvent &event)
if (mAdvanced)
{
item->increaseUsedQuantity(mAmountItems);
+ const int itemWeight = item->getInfo().getWeight();
+ mTotalPurchaseWeight += mAmountItems * itemWeight;
item->update();
if (mConfirmButton != nullptr)
mConfirmButton->setEnabled(true);
@@ -745,6 +754,10 @@ void BuyDialog::updateButtonsAndLabels()
{
const int selectedItem = mShopItemList->getSelected();
int price = 0;
+ int freeWeight
+ = PlayerInfo::getAttribute(Attributes::MAX_WEIGHT)
+ - PlayerInfo::getAttribute(Attributes::TOTAL_WEIGHT)
+ - mTotalPurchaseWeight;
if (selectedItem > -1)
{
@@ -765,10 +778,7 @@ void BuyDialog::updateButtonsAndLabels()
const int itemWeight = item->getInfo().getWeight();
if (itemWeight != 0)
{
- const int myFreeWeight
- = PlayerInfo::getAttribute(Attributes::MAX_WEIGHT)
- - PlayerInfo::getAttribute(Attributes::TOTAL_WEIGHT);
- const int canCarry = myFreeWeight / itemWeight;
+ const int canCarry = freeWeight / itemWeight;
mMaxItems = std::min(mMaxItems, canCarry);
}
@@ -786,6 +796,7 @@ void BuyDialog::updateButtonsAndLabels()
if (mAmountItems > mMaxItems)
mAmountItems = mMaxItems;
+ freeWeight -= mAmountItems * itemWeight;
price = mAmountItems * itemPrice;
}
}
@@ -802,10 +813,11 @@ void BuyDialog::updateButtonsAndLabels()
mAmountField->setEnabled(mAmountItems > 0);
mQuantityLabel->setCaption(strprintf("%d / %d", mAmountItems, mMaxItems));
- // TRANSLATORS: buy dialog label
- mMoneyLabel->setCaption(strprintf(_("Price: %s / Total: %s"),
+ // TRANSLATORS: buy dialog label, price, remaining money & free weight
+ mMoneyLabel->setCaption(strprintf(_("Price: %s, Remaining: %s & %s"),
UnitsDb::formatCurrency(mCurrency, price).c_str(),
- UnitsDb::formatCurrency(mCurrency, mMoney - price).c_str()));
+ UnitsDb::formatCurrency(mCurrency, mMoney - price).c_str(),
+ UnitsDb::formatWeight(freeWeight).c_str()));
}
void BuyDialog::setVisible(Visible visible)
diff --git a/src/gui/windows/buydialog.h b/src/gui/windows/buydialog.h
index 4535e1201..969734aec 100644
--- a/src/gui/windows/buydialog.h
+++ b/src/gui/windows/buydialog.h
@@ -202,6 +202,8 @@ class BuyDialog final : public Window,
int mMoney;
int mAmountItems;
int mMaxItems;
+ // combined weight of all items added to shopping list
+ int mTotalPurchaseWeight;
bool mAdvanced;
};
diff --git a/src/net/eathena/adminrecv.cpp b/src/net/eathena/adminrecv.cpp
index 19895924d..fc9cb606b 100644
--- a/src/net/eathena/adminrecv.cpp
+++ b/src/net/eathena/adminrecv.cpp
@@ -19,8 +19,12 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+
#include "net/eathena/adminrecv.h"
+#include "enums/resources/notifytypes.h"
+#include "notifymanager.h"
+
#include "logger.h"
#include "net/messagein.h"
@@ -79,4 +83,12 @@ void AdminRecv::processAccountStats(Net::MessageIn &msg)
msg.readInt16("zero");
}
+void AdminRecv::processKickAck(Net::MessageIn &msg)
+{
+ if (msg.readInt8("flag") == 0)
+ NotifyManager::notify(NotifyTypes::KICK_FAIL);
+ else
+ NotifyManager::notify(NotifyTypes::KICK_SUCCEED);
+}
+
} // namespace EAthena
diff --git a/src/net/eathena/adminrecv.h b/src/net/eathena/adminrecv.h
index 1dc2b13b5..6a660b18a 100644
--- a/src/net/eathena/adminrecv.h
+++ b/src/net/eathena/adminrecv.h
@@ -32,6 +32,7 @@ namespace EAthena
namespace AdminRecv
{
void processAdminGetLoginAck(Net::MessageIn &msg);
+ void processKickAck(Net::MessageIn &msg);
void processSetTileType(Net::MessageIn &msg);
void processAccountStats(Net::MessageIn &msg);
} // namespace AdminRecv
diff --git a/src/net/eathena/network.cpp b/src/net/eathena/network.cpp
index 94290cb3f..f52402c9d 100644
--- a/src/net/eathena/network.cpp
+++ b/src/net/eathena/network.cpp
@@ -25,7 +25,6 @@
#include "net/packetinfo.h"
-#include "net/ea/adminrecv.h"
#include "net/ea/beingrecv.h"
#include "net/ea/buysellrecv.h"
#include "net/ea/charserverrecv.h"
diff --git a/src/net/eathena/packetsin.inc b/src/net/eathena/packetsin.inc
index 2a8e26264..b93e9d09d 100644
--- a/src/net/eathena/packetsin.inc
+++ b/src/net/eathena/packetsin.inc
@@ -94,7 +94,7 @@ packet(SMSG_MAP_NOT_FOUND, 0x0840, -1, &GeneralRecv::processMap
// map server, unknown versions
packet(SMSG_ADMIN_GET_LOGIN_ACK, 0x01e0, 30, &AdminRecv::processAdminGetLoginAck, 0);
-packet(SMSG_ADMIN_KICK_ACK, 0x00cd, 3, &Ea::AdminRecv::processKickAck, 0);
+packet(SMSG_ADMIN_KICK_ACK, 0x00cd, 3, &AdminRecv::processKickAck, 0);
packet(SMSG_ADMIN_SET_TILE_TYPE, 0x0192, 24, &AdminRecv::processSetTileType, 0);
packet(SMSG_BATTLE_BEGINS, 0x08df, 50, &BattleGroundRecv::processBattleBegins, 0);
packet(SMSG_BATTLE_JOINED, 0x08d9, 30, &BattleGroundRecv::processBattleJoined, 0);
diff --git a/src/net/ea/adminrecv.cpp b/src/net/tmwa/adminrecv.cpp
index efc55762f..58ee1b175 100644
--- a/src/net/ea/adminrecv.cpp
+++ b/src/net/tmwa/adminrecv.cpp
@@ -21,7 +21,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "net/ea/adminrecv.h"
+#include "net/tmwa/adminrecv.h"
#include "notifymanager.h"
@@ -31,15 +31,15 @@
#include "debug.h"
-namespace Ea
+namespace TmwAthena
{
void AdminRecv::processKickAck(Net::MessageIn &msg)
{
- if (msg.readInt32("flag") == 0)
+ if (msg.readInt32("account id") == 0)
NotifyManager::notify(NotifyTypes::KICK_FAIL);
else
NotifyManager::notify(NotifyTypes::KICK_SUCCEED);
}
-} // namespace Ea
+} // namespace TmwAthena
diff --git a/src/net/ea/adminrecv.h b/src/net/tmwa/adminrecv.h
index 41f8121d3..616e786e1 100644
--- a/src/net/ea/adminrecv.h
+++ b/src/net/tmwa/adminrecv.h
@@ -21,8 +21,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#ifndef NET_EA_ADMINRECV_H
-#define NET_EA_ADMINRECV_H
+#ifndef NET_TMWA_ADMINRECV_H
+#define NET_TMWA_ADMINRECV_H
#include "localconsts.h"
@@ -31,12 +31,12 @@ namespace Net
class MessageIn;
} // namespace Net
-namespace Ea
+namespace TmwAthena
{
namespace AdminRecv
{
void processKickAck(Net::MessageIn &msg);
} // namespace AdminRecv
-} // namespace Ea
+} // namespace TmwAthena
-#endif // NET_EA_ADMINRECV_H
+#endif // NET_TMWA_ADMINRECV_H
diff --git a/src/net/tmwa/network.cpp b/src/net/tmwa/network.cpp
index 0fec580a6..f070e1cf3 100644
--- a/src/net/tmwa/network.cpp
+++ b/src/net/tmwa/network.cpp
@@ -27,7 +27,6 @@
#include "net/packetinfo.h"
-#include "net/ea/adminrecv.h"
#include "net/ea/beingrecv.h"
#include "net/ea/buysellrecv.h"
#include "net/ea/charserverrecv.h"
@@ -43,6 +42,7 @@
#include "net/ea/skillrecv.h"
#include "net/ea/traderecv.h"
+#include "net/tmwa/adminrecv.h"
#include "net/tmwa/beingrecv.h"
#include "net/tmwa/buysellrecv.h"
#include "net/tmwa/charserverrecv.h"
diff --git a/src/net/tmwa/packetsin.inc b/src/net/tmwa/packetsin.inc
index dbfdbd494..47f87c768 100644
--- a/src/net/tmwa/packetsin.inc
+++ b/src/net/tmwa/packetsin.inc
@@ -21,7 +21,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-packet(SMSG_ADMIN_KICK_ACK, 0x00cd, 6, &Ea::AdminRecv::processKickAck, 0);
+packet(SMSG_ADMIN_KICK_ACK, 0x00cd, 6, &AdminRecv::processKickAck, 0);
packet(SMSG_BEING_ACTION, 0x008a, 29, &Ea::BeingRecv::processBeingAction, 0);
packet(SMSG_BEING_CHANGE_DIRECTION, 0x009c, 9, &BeingRecv::processBeingChangeDirection, 0);
packet(SMSG_BEING_CHANGE_LOOKS, 0x00c3, 8, &BeingRecv::processBeingChangeLook, 0);
diff --git a/src/utils/checkutils.h b/src/utils/checkutils.h
index 0d20673b8..5ef46110d 100644
--- a/src/utils/checkutils.h
+++ b/src/utils/checkutils.h
@@ -38,8 +38,7 @@ LOGGER_H
#define reportAlwaysReal(...) \
{ \
logger->log("Assert:"); \
- logger->assertLog( \
- __VA_ARGS__); \
+ logger->assertLog(__VA_ARGS__); \
reportLogStack(__FILE__, __LINE__, __func__); \
}
@@ -152,8 +151,7 @@ LOGGER_H
#define failAlways(...) \
{ \
logger->log("Assert:"); \
- logger->assertLog( \
- __VA_ARGS__); \
+ logger->assertLog(__VA_ARGS__); \
reportLogStack(__FILE__, __LINE__, __func__); \
throw new std::exception(); \
}
@@ -178,8 +176,7 @@ void reportStack();
#define reportAlwaysReal(...) \
{ \
logger->log("Error:"); \
- logger->log( \
- __VA_ARGS__); \
+ logger->log(__VA_ARGS__); \
}
#define returnFalseVReal(val) \
diff --git a/tools/ci/jobs/cpplint.sh b/tools/ci/jobs/cpplint.sh
index d9ccf92c8..b8331ff29 100755
--- a/tools/ci/jobs/cpplint.sh
+++ b/tools/ci/jobs/cpplint.sh
@@ -50,21 +50,16 @@ args+=("--filter=\
# Cannot find a good way to handle execution errors
# (such cpplint.py demanding a version of Python that does not exist)
# So use || true here and assume any other problems will be exposed
-# by the grep below.
+# by the grep below. Addendum: no more grep. YMMV.
find src \
-type f \
\( -name "*.cc" \
- -o -name "*.cpp"\
- -o -name "*.h" \
- -o -name "*.hpp" \
- \) -exec ./cpplint.py --verbose=5 "${args[@]}" {} \+ 2>"$ERRFILE_UNFILTERED" \
- || true
+ -o \( -name "*.cpp" -a \! -path src/debug/nvwa/debug_new.cpp \) \
+ -o \( -name "*.h" -a \! -path src/unittests/doctest.h \) \
+ -o \( -name "*.hpp" -a \! -path src/unittests/catch.hpp \) \
+ \) -exec ./cpplint.py --verbose=5 "${args[@]}" {} \+ 2>"$ERRFILE"
+ #|| true
-# If grep does not find any messages, it exits non-zero. Therefore, use ||true
-grep -v -e "^src/debug/nvwa/debug_new.cpp" \
- -e "^src/unittests/doctest.h" \
- -e "^src/unittests/catch.hpp" \
- < "$ERRFILE_UNFILTERED" > "$ERRFILE" || true
run_check_warnings