Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into fix-warning
Browse files Browse the repository at this point in the history
  • Loading branch information
kokekanon committed Dec 18, 2024
2 parents b3a1691 + b8b229e commit 9aa5037
Show file tree
Hide file tree
Showing 284 changed files with 3,300 additions and 3,220 deletions.
10 changes: 10 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,12 @@
/.git/
/.github/
/.idea/
/.vs/
/android/
/build/
/cmake-build*
/vc17/
Dockerfile
*.dll
*.exe
*.pdb
50 changes: 24 additions & 26 deletions modules/client_topmenu/topmenu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ function terminate()
})

topMenu:destroy()
if PingWidget then
if PingWidget and not PingWidget:isDestroyed() then
PingWidget:destroy()
PingWidget = nil
end
Expand All @@ -138,8 +138,23 @@ function online()
showGameButtons()

addEvent(function()
if modules.client_options.getOption('showPing') and
(g_game.getFeature(GameClientPing) or g_game.getFeature(GameExtendedClientPing)) then
local showPing = modules.client_options.getOption('showPing')
local pingFeatureAvailable = g_game.getFeature(GameClientPing) or g_game.getFeature(GameExtendedClientPing)

if not PingWidget then
PingWidget = g_ui.loadUI("pingFps", modules.game_interface.getMapPanel())
MainPingPanel = g_ui.createWidget("testPingPanel", PingWidget:getChildByIndex(1))
MainPingPanel:setId("ping")

pingImg = MainPingPanel:getChildByIndex(1)
pingPanel = MainPingPanel:getChildByIndex(2)

mainFpsPanel = g_ui.createWidget("testPingPanel", PingWidget:getChildByIndex(2))
mainFpsPanel:setId("fps")
fpsPanel2 = mainFpsPanel:getChildByIndex(2)
end

if showPing and pingFeatureAvailable then
pingLabel:show()
if pingPanel then
pingPanel:show()
Expand All @@ -152,29 +167,12 @@ function online()
pingImg:hide()
end
end
if PingWidget then
return
end
PingWidget = g_ui.loadUI("pingFps", modules.game_interface.getMapPanel())
MainPingPanel = g_ui.createWidget("testPingPanel", PingWidget:getChildByIndex(1))
MainPingPanel.setId(MainPingPanel, "ping")
pingImg = MainPingPanel.getChildByIndex(MainPingPanel, 1)
pingPanel = MainPingPanel.getChildByIndex(MainPingPanel, 2)
if modules.client_options.getOption('showPing') then
pingImg:setVisible(true)
pingPanel:setVisible(true)
else
pingImg:setVisible(false)
pingPanel:setVisible(true)
end
mainFpsPanel = g_ui.createWidget("testPingPanel", PingWidget:getChildByIndex(2))
mainFpsPanel.setId(mainFpsPanel, "fps")
fpsPanel2 = mainFpsPanel.getChildByIndex(mainFpsPanel, 2)
if modules.client_options.getOption('showFps') then
fpsPanel2:setVisible(true)
else
fpsPanel2:setVisible(false)
end

pingImg:setVisible(showPing)
pingPanel:setVisible(showPing)

local showFps = modules.client_options.getOption('showFps')
fpsPanel2:setVisible(showFps)
end)
end

Expand Down
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,7 @@ endif()


target_sources(${PROJECT_NAME} PRIVATE ${SOURCE_FILES})
target_link_options(${PROJECT_NAME} PUBLIC -flto=auto)

# *****************************************************************************
# Includes and librarys
Expand Down
6 changes: 3 additions & 3 deletions src/client/animatedtext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
*/

#include "animatedtext.h"
#include <framework/core/eventdispatcher.h>
#include <framework/core/graphicalapplication.h>
#include "game.h"
#include "map.h"
#include "gameconfig.h"
#include "map.h"
#include <framework/core/eventdispatcher.h>
#include <framework/core/graphicalapplication.h>

AnimatedText::AnimatedText()
{
Expand Down
6 changes: 3 additions & 3 deletions src/client/animatedtext.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@
#include <framework/luaengine/luaobject.h>

// @bindclass
class AnimatedText : public LuaObject
class AnimatedText final : public LuaObject
{
public:
AnimatedText();
AnimatedText(const std::string_view text, int color) : AnimatedText() {
AnimatedText(const std::string_view text, const int color) : AnimatedText() {
setText(text);
setColor(color);
}
Expand All @@ -42,7 +42,7 @@ class AnimatedText : public LuaObject

void onAppear();

void setColor(int color) { m_color = Color::from8bit(color); }
void setColor(const int color) { m_color = Color::from8bit(color); }
void setText(const std::string_view text) { m_cachedText.setText(text); }
void setOffset(const Point& offset) { m_offset = offset; }

Expand Down
8 changes: 4 additions & 4 deletions src/client/animator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ void Animator::unserializeAppearance(const appearances::SpriteAnimation& animati
assert(m_startPhase >= -1 && m_startPhase < m_animationPhases);
}

void Animator::unserialize(int animationPhases, const FileStreamPtr& fin)
void Animator::unserialize(const int animationPhases, const FileStreamPtr& fin)
{
m_animationPhases = animationPhases;
m_async = fin->getU8() == 0;
Expand Down Expand Up @@ -77,7 +77,7 @@ void Animator::serialize(const FileStreamPtr& fin) const
}
}

void Animator::setPhase(int phase)
void Animator::setPhase(const int phase)
{
if (m_phase == phase)
return;
Expand Down Expand Up @@ -133,7 +133,7 @@ int Animator::getPhase()
return m_phase;
}

int Animator::getPhaseAt(Timer& timer, float durationFactor) const
int Animator::getPhaseAt(Timer& timer, const float durationFactor) const
{
const ticks_t time = timer.ticksElapsed();

Expand Down Expand Up @@ -195,7 +195,7 @@ int Animator::getLoopPhase()
return m_phase;
}

int Animator::getPhaseDuration(int phase) const
int Animator::getPhaseDuration(const int phase) const
{
assert(phase < static_cast<int>(m_phaseDurations.size()));

Expand Down
36 changes: 19 additions & 17 deletions src/client/attachableobject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@
*/

#include "attachableobject.h"
#include <framework/graphics/particlemanager.h>
#include <framework/graphics/particleeffect.h>
#include <framework/graphics/particlemanager.h>

#include <framework/core/eventdispatcher.h>
#include <framework/ui/uiwidget.h>
#include <framework/core/eventdispatcher.h>
#include <framework/ui/uimanager.h>
#include <framework/ui/uiwidget.h>

#include <algorithm>

#include "client.h"
#include "game.h"
Expand Down Expand Up @@ -55,7 +57,7 @@ void AttachableObject::attachEffect(const AttachedEffectPtr& obj)
++m_ownerHidden;

if (obj->getDuration() > 0) {
g_dispatcher.scheduleEvent([self = std::static_pointer_cast<AttachableObject>(shared_from_this()), effect = obj]() {
g_dispatcher.scheduleEvent([self = std::static_pointer_cast<AttachableObject>(shared_from_this()), effect = obj] {
self->detachEffect(effect);
}, obj->getDuration());
}
Expand Down Expand Up @@ -95,7 +97,7 @@ bool AttachableObject::detachEffectById(uint16_t id)
return true;
}

void AttachableObject::onDetachEffect(const AttachedEffectPtr& effect, bool callEvent)
void AttachableObject::onDetachEffect(const AttachedEffectPtr& effect, const bool callEvent)
{
if (effect->isHidedOwner())
--m_ownerHidden;
Expand All @@ -106,7 +108,7 @@ void AttachableObject::onDetachEffect(const AttachedEffectPtr& effect, bool call
effect->callLuaField("onDetach", attachedObjectToLuaObject());
}

void AttachableObject::clearAttachedEffects(bool ignoreLuaEvent)
void AttachableObject::clearAttachedEffects(const bool ignoreLuaEvent)
{
if (!hasAttachedEffects()) return;
for (const auto& e : m_data->attachedEffects)
Expand All @@ -117,27 +119,27 @@ void AttachableObject::clearAttachedEffects(bool ignoreLuaEvent)
void AttachableObject::clearTemporaryAttachedEffects()
{
if (!hasAttachedEffects()) return;
m_data->attachedEffects.erase(std::remove_if(m_data->attachedEffects.begin(), m_data->attachedEffects.end(),
[this](const AttachedEffectPtr& obj) {
std::erase_if(m_data->attachedEffects,
[this](const AttachedEffectPtr& obj) {
if (!obj->isPermanent()) {
onDetachEffect(obj);
return true;
}
return false;
}), m_data->attachedEffects.end());
});
}

void AttachableObject::clearPermanentAttachedEffects()
{
if (!hasAttachedEffects()) return;
m_data->attachedEffects.erase(std::remove_if(m_data->attachedEffects.begin(), m_data->attachedEffects.end(),
[this](const AttachedEffectPtr& obj) {
std::erase_if(m_data->attachedEffects,
[this](const AttachedEffectPtr& obj) {
if (obj->isPermanent()) {
onDetachEffect(obj);
return true;
}
return false;
}), m_data->attachedEffects.end());
});
}

AttachedEffectPtr AttachableObject::getAttachedEffectById(uint16_t id)
Expand All @@ -152,13 +154,13 @@ AttachedEffectPtr AttachableObject::getAttachedEffectById(uint16_t id)
return *it;
}

void AttachableObject::drawAttachedEffect(const Point& dest, const LightViewPtr& lightView, bool isOnTop)
void AttachableObject::drawAttachedEffect(const Point& dest, const LightViewPtr& lightView, const bool isOnTop)
{
if (!hasAttachedEffects()) return;
for (const auto& effect : m_data->attachedEffects) {
effect->draw(dest, isOnTop, lightView);
if (effect->getLoop() == 0) {
g_dispatcher.addEvent([self = std::static_pointer_cast<AttachableObject>(shared_from_this()), effect]() {
g_dispatcher.addEvent([self = std::static_pointer_cast<AttachableObject>(shared_from_this()), effect] {
self->detachEffect(effect);
});
}
Expand Down Expand Up @@ -228,7 +230,7 @@ void AttachableObject::updateAndAttachParticlesEffects(std::vector<std::string>&
toRemove.reserve(m_data->attachedParticles.size());

for (const auto& effect : m_data->attachedParticles) {
auto findPos = std::find(newElements.begin(), newElements.end(), effect->getEffectType()->getName());
auto findPos = std::ranges::find(newElements, effect->getEffectType()->getName());
if (findPos == newElements.end())
toRemove.emplace_back(effect->getEffectType()->getName());
else
Expand Down Expand Up @@ -262,7 +264,7 @@ void AttachableObject::attachWidget(const UIWidgetPtr& widget) {
getData()->attachedWidgets.emplace_back(widget);
g_map.addAttachedWidgetToObject(widget, std::static_pointer_cast<AttachableObject>(shared_from_this()));
widget->callLuaField("onAttached", asLuaObject());
widget->addOnDestroyCallback("attached-widget-destroy", [this, widget]() {
widget->addOnDestroyCallback("attached-widget-destroy", [this, widget] {
detachWidget(widget);
});
}
Expand Down Expand Up @@ -301,12 +303,12 @@ bool AttachableObject::detachWidget(const UIWidgetPtr widget)
return true;
}

void AttachableObject::clearAttachedWidgets(bool callEvent)
void AttachableObject::clearAttachedWidgets(const bool callEvent)
{
if (!hasAttachedWidgets()) return;

// keep the same behavior as detachWidget
auto oldList = std::move(m_data->attachedWidgets);
const auto oldList = std::move(m_data->attachedWidgets);
m_data->attachedWidgets.clear();

for (const auto& widget : oldList) {
Expand Down
12 changes: 6 additions & 6 deletions src/client/attachableobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class AttachableObject : public LuaObject
{
public:
AttachableObject() = default;
virtual ~AttachableObject();
~AttachableObject() override;

virtual LuaObjectPtr attachedObjectToLuaObject() = 0;
virtual bool isTile() { return false; }
Expand All @@ -45,9 +45,9 @@ class AttachableObject : public LuaObject
bool detachEffect(const AttachedEffectPtr& obj);
AttachedEffectPtr getAttachedEffectById(uint16_t id);

virtual void onStartAttachEffect(const AttachedEffectPtr& /*effect*/) { };
virtual void onDispatcherAttachEffect(const AttachedEffectPtr& /*effect*/) { };
virtual void onStartDetachEffect(const AttachedEffectPtr& /*effect*/) { };
virtual void onStartAttachEffect(const AttachedEffectPtr& /*effect*/) {};
virtual void onDispatcherAttachEffect(const AttachedEffectPtr& /*effect*/) {};
virtual void onStartDetachEffect(const AttachedEffectPtr& /*effect*/) {};

bool isOwnerHidden() { return m_ownerHidden > 0; }

Expand All @@ -67,7 +67,7 @@ class AttachableObject : public LuaObject
void attachWidget(const UIWidgetPtr& widget);
void clearAttachedWidgets(bool callEvent = true);
bool detachWidgetById(const std::string& id);
bool detachWidget(const UIWidgetPtr widget);
bool detachWidget(UIWidgetPtr widget);
UIWidgetPtr getAttachedWidgetById(const std::string& id);

protected:
Expand All @@ -84,7 +84,7 @@ class AttachableObject : public LuaObject
void onDetachEffect(const AttachedEffectPtr& effect, bool callEvent = true);
void drawAttachedParticlesEffect(const Point& dest);

inline auto getData() {
auto getData() {
if (!m_data)
m_data = std::make_shared<Data>();
return m_data;
Expand Down
6 changes: 3 additions & 3 deletions src/client/attachedeffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@
#include "lightview.h"

#include <framework/core/clock.h>
#include <framework/graphics/texturemanager.h>
#include <framework/graphics/animatedtexture.h>
#include <framework/graphics/shadermanager.h>
#include <framework/graphics/texturemanager.h>

AttachedEffectPtr AttachedEffect::create(uint16_t thingId, ThingCategory category) {
AttachedEffectPtr AttachedEffect::create(const uint16_t thingId, const ThingCategory category) {
if (!g_things.isValidDatId(thingId, category)) {
g_logger.error(stdext::format("AttachedEffectManager::getInstance(%d, %d): invalid thing with id or category.", thingId, static_cast<uint8_t>(category)));
return nullptr;
Expand Down Expand Up @@ -71,7 +71,7 @@ int getBounce(const AttachedEffect::Bounce bounce, const ticks_t ticks) {
return minHeight + (height - std::abs(height - static_cast<int>(ticks / (bounce.speed / 100.f)) % static_cast<int>(height * 2)));
}

void AttachedEffect::draw(const Point& dest, bool isOnTop, const LightViewPtr& lightView, const bool drawThing) {
void AttachedEffect::draw(const Point& dest, const bool isOnTop, const LightViewPtr& lightView, const bool drawThing) {
if (m_transform)
return;

Expand Down
Loading

0 comments on commit 9aa5037

Please sign in to comment.