Merge branch 'master' into codetriage-badge

This commit is contained in:
Konrad Kuśnierz 2019-01-16 14:13:18 +01:00 committed by GitHub
commit c1369a7c92
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
33 changed files with 371 additions and 65 deletions

2
.gitignore vendored
View File

@ -39,6 +39,8 @@ Thumbs.db
.directory .directory
src/framework/graphics/dx/ src/framework/graphics/dx/
modules/.project/modules.sublime-workspace modules/.project/modules.sublime-workspace
vc14/.vs/
*.dll
################# #################
## Visual Studio ## Visual Studio

31
Dockerfile Normal file
View File

@ -0,0 +1,31 @@
from ubuntu:latest
WORKDIR /app
RUN apt-get update; apt-get install -y \
build-essential \
cmake \
git-core \
libboost-all-dev \
libglew-dev \
liblua5.1-0-dev \
libopenal-dev \
libphysfs-dev \
libssl-dev \
libvorbis-dev \
zlib1g-dev
RUN apt-get install -y \
libncurses5-dev \
mercurial; \
hg clone -r stable-2.0 http://hg.icculus.org/icculus/physfs/; \
cd physfs; \
mkdir build && cd build && cmake .. && make && make install; \
mv /usr/local/lib/libphysfs.a /usr/lib/x86_64-linux-gnu/.
ADD . /app
# Build application
RUN mkdir -p build && cd build && cmake .. && make -j$(grep -c ^process /proc/cpuinfo);
CMD cd build; ./otclient

View File

@ -1,4 +1,4 @@
[![Build Status](https://secure.travis-ci.org/edubart/otclient.svg?branch=master)](http://travis-ci.org/edubart/otclient) [![Join the chat at https://gitter.im/edubart/otclient](https://img.shields.io/badge/GITTER-join%20chat-green.svg)](https://gitter.im/edubart/otclient?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![Open Source Helpers](https://www.codetriage.com/edubart/otclient/badges/users.svg)](https://www.codetriage.com/edubart/otclient) \ [![Build Status](https://secure.travis-ci.org/edubart/otclient.svg?branch=master)](http://travis-ci.org/edubart/otclient) [![Join the chat at https://gitter.im/edubart/otclient](https://img.shields.io/badge/GITTER-join%20chat-green.svg)](https://gitter.im/edubart/otclient?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) [![Open Source Helpers](https://www.codetriage.com/edubart/otclient/badges/users.svg)](https://www.codetriage.com/edubart/otclient)
### What is otclient? ### What is otclient?
@ -36,6 +36,15 @@ In short, if you need to compile OTClient, follow these tutorials:
* [Compiling on Linux](https://github.com/edubart/otclient/wiki/Compiling-on-Linux) * [Compiling on Linux](https://github.com/edubart/otclient/wiki/Compiling-on-Linux)
* [Compiling on OS X](https://github.com/edubart/otclient/wiki/Compiling-on-Mac-OS-X) * [Compiling on OS X](https://github.com/edubart/otclient/wiki/Compiling-on-Mac-OS-X)
### Build and run with Docker
To build and run the client:
```
./build.sh
./run.sh
```
The build step should be run just when something on implementation changes.
### Need help? ### Need help?

3
build.sh Executable file
View File

@ -0,0 +1,3 @@
#!/usr/bin/env bash
docker build -t edubart/otclient .

View File

@ -22,7 +22,7 @@ end
g_resources.addSearchPath(g_resources.getWorkDir() .. "mods", true) g_resources.addSearchPath(g_resources.getWorkDir() .. "mods", true)
-- setup directory for saving configurations -- setup directory for saving configurations
g_resources.setupUserWriteDir(g_app.getCompactName()) g_resources.setupUserWriteDir(('%s/'):format(g_app.getCompactName()))
-- search all packages -- search all packages
g_resources.searchAndAddPackages('/', '.otpkg', true) g_resources.searchAndAddPackages('/', '.otpkg', true)

View File

@ -254,12 +254,21 @@ function CharacterList.create(characters, account, otui)
end end
-- account -- account
if account.premDays > 0 and account.premDays < 65535 then local status = ''
accountStatusLabel:setText(tr("Premium Account (%s) days left", account.premDays)) if account.status == AccountStatus.Frozen then
elseif account.premDays >= 65535 then status = tr(' (Frozen)')
accountStatusLabel:setText(tr("Lifetime Premium Account")) elseif account.status == AccountStatus.Suspended then
status = tr(' (Suspended)')
end
if account.subStatus == SubscriptionStatus.Free then
accountStatusLabel:setText(('%s%s'):format(tr('Free Account'), status))
elseif account.subStatus == SubscriptionStatus.Premium then
if account.premDays == 0 or account.premDays == 65535 then
accountStatusLabel:setText(('%s%s'):format(tr('Gratis Premium Account'), status))
else else
accountStatusLabel:setText(tr('Free Account')) accountStatusLabel:setText(('%s%s'):format(tr('Premium Account (%s) days left', account.premDays), status))
end
end end
if account.premDays > 0 and account.premDays <= 7 then if account.premDays > 0 and account.premDays <= 7 then

View File

@ -26,6 +26,11 @@ local function retranslateKeyComboDesc(keyComboDesc)
if keyComboDesc == nil then if keyComboDesc == nil then
error('Unable to translate key combo \'' .. keyComboDesc .. '\'') error('Unable to translate key combo \'' .. keyComboDesc .. '\'')
end end
if type(keyComboDesc) == 'number' then
keyComboDesc = tostring(keyComboDesc)
end
local keyCombo = {} local keyCombo = {}
for i,currentKeyDesc in ipairs(keyComboDesc:split('+')) do for i,currentKeyDesc in ipairs(keyComboDesc:split('+')) do
for keyCode, keyDesc in pairs(KeyCodeDescs) do for keyCode, keyDesc in pairs(KeyCodeDescs) do

View File

@ -10,13 +10,24 @@ local function moveToolTip(first)
if not first and (not toolTipLabel:isVisible() or toolTipLabel:getOpacity() < 0.1) then return end if not first and (not toolTipLabel:isVisible() or toolTipLabel:getOpacity() < 0.1) then return end
local pos = g_window.getMousePosition() local pos = g_window.getMousePosition()
local windowSize = g_window.getSize()
local labelSize = toolTipLabel:getSize()
pos.x = pos.x + 1
pos.y = pos.y + 1 pos.y = pos.y + 1
local xdif = g_window.getSize().width - (pos.x + toolTipLabel:getWidth())
if xdif < 10 then if windowSize.width - (pos.x + labelSize.width) < 10 then
pos.x = pos.x - toolTipLabel:getWidth() - 3 pos.x = pos.x - labelSize.width - 3
else else
pos.x = pos.x + 10 pos.x = pos.x + 10
end end
if windowSize.height - (pos.y + labelSize.height) < 10 then
pos.y = pos.y - labelSize.height - 3
else
pos.y = pos.y + 10
end
toolTipLabel:setPosition(pos) toolTipLabel:setPosition(pos)
end end

View File

@ -19,13 +19,14 @@ function UIComboBox:clearOptions()
self:clearText() self:clearText()
end end
function UIComboBox:getOption(text) function UIComboBox:isOption(text)
if not self.options then return nil end if not self.options then return false end
for i,v in ipairs(self.options) do for i,v in ipairs(self.options) do
if v.text == text then if v.text == text then
return nil return true
end end
end end
return false
end end
function UIComboBox:setOption(text, dontSignal) function UIComboBox:setOption(text, dontSignal)

View File

@ -3,6 +3,7 @@ UIMiniWindow = extends(UIWindow, "UIMiniWindow")
function UIMiniWindow.create() function UIMiniWindow.create()
local miniwindow = UIMiniWindow.internalCreate() local miniwindow = UIMiniWindow.internalCreate()
miniwindow.UIMiniWindowContainer = true
return miniwindow return miniwindow
end end

View File

@ -83,7 +83,7 @@ function UIMiniWindowContainer:fitAll(noRemoveChild)
end end
function UIMiniWindowContainer:onDrop(widget, mousePos) function UIMiniWindowContainer:onDrop(widget, mousePos)
if widget:getClassName() == 'UIMiniWindow' then if widget.UIMiniWindowContainer then
local oldParent = widget:getParent() local oldParent = widget:getParent()
if oldParent == self then if oldParent == self then
return true return true

View File

@ -385,6 +385,11 @@ function UIMoveableTabBar:selectTab(tab)
tab:setOn(false) tab:setOn(false)
tab.blinking = false tab.blinking = false
if tab.blinkEvent then
removeEvent(tab.blinkEvent)
tab.blinkEvent = nil
end
local parent = tab:getParent() local parent = tab:getParent()
parent:focusChild(tab, MouseFocusReason) parent:focusChild(tab, MouseFocusReason)
updateNavigation(self) updateNavigation(self)

View File

@ -126,8 +126,8 @@ end
function UIScrollBar:onSetup() function UIScrollBar:onSetup()
self.setupDone = true self.setupDone = true
local sliderButton = self:getChildById('sliderButton') local sliderButton = self:getChildById('sliderButton')
g_mouse.bindAutoPress(self:getChildById('decrementButton'), function() self:decrement() end, 300) g_mouse.bindAutoPress(self:getChildById('decrementButton'), function() self:onDecrement() end, 300)
g_mouse.bindAutoPress(self:getChildById('incrementButton'), function() self:increment() end, 300) g_mouse.bindAutoPress(self:getChildById('incrementButton'), function() self:onIncrement() end, 300)
g_mouse.bindPressMove(sliderButton, function(mousePos, mouseMoved) parseSliderPos(self, sliderButton, mousePos, mouseMoved) end) g_mouse.bindPressMove(sliderButton, function(mousePos, mouseMoved) parseSliderPos(self, sliderButton, mousePos, mouseMoved) end)
g_mouse.bindPress(sliderButton, function(mousePos, mouseButton) parseSliderPress(self, sliderButton, mousePos, mouseButton) end) g_mouse.bindPress(sliderButton, function(mousePos, mouseButton) parseSliderPress(self, sliderButton, mousePos, mouseButton) end)
@ -158,6 +158,26 @@ function UIScrollBar:onStyleApply(styleName, styleNode)
end end
end end
function UIScrollBar:onDecrement()
if g_keyboard.isCtrlPressed() then
self:decrement(self.value)
elseif g_keyboard.isShiftPressed() then
self:decrement(10)
else
self:decrement()
end
end
function UIScrollBar:onIncrement()
if g_keyboard.isCtrlPressed() then
self:increment(self.maximum)
elseif g_keyboard.isShiftPressed() then
self:increment(10)
else
self:increment()
end
end
function UIScrollBar:decrement(count) function UIScrollBar:decrement(count)
count = count or self.step count = count or self.step
self:setValue(self.value - count) self:setValue(self.value - count)

View File

@ -52,6 +52,13 @@ SayModes = {
[3] = { speakTypeDesc = 'yell', icon = '/images/game/console/yell' } [3] = { speakTypeDesc = 'yell', icon = '/images/game/console/yell' }
} }
ChannelEventFormats = {
[ChannelEvent.Join] = '%s joined the channel.',
[ChannelEvent.Leave] = '%s left the channel.',
[ChannelEvent.Invite] = '%s has been invited to the channel.',
[ChannelEvent.Exclude] = '%s has been removed from the channel.',
}
MAX_HISTORY = 500 MAX_HISTORY = 500
MAX_LINES = 100 MAX_LINES = 100
HELP_CHANNEL = 9 HELP_CHANNEL = 9
@ -98,7 +105,8 @@ function init()
onRuleViolationCancel = onRuleViolationCancel, onRuleViolationCancel = onRuleViolationCancel,
onRuleViolationLock = onRuleViolationLock, onRuleViolationLock = onRuleViolationLock,
onGameStart = online, onGameStart = online,
onGameEnd = offline onGameEnd = offline,
onChannelEvent = onChannelEvent,
}) })
consolePanel = g_ui.loadUI('console', modules.game_interface.getBottomPanel()) consolePanel = g_ui.loadUI('console', modules.game_interface.getBottomPanel())
@ -240,7 +248,8 @@ function terminate()
onRuleViolationCancel = onRuleViolationCancel, onRuleViolationCancel = onRuleViolationCancel,
onRuleViolationLock = onRuleViolationLock, onRuleViolationLock = onRuleViolationLock,
onGameStart = online, onGameStart = online,
onGameEnd = offline onGameEnd = offline,
onChannelEvent = onChannelEvent,
}) })
if g_game.isOnline() then clear() end if g_game.isOnline() then clear() end
@ -978,7 +987,7 @@ function navigateMessageHistory(step)
end end
function applyMessagePrefixies(name, level, message) function applyMessagePrefixies(name, level, message)
if name then if name and #name > 0 then
if modules.client_options.getOption('showLevelsInConsole') and level > 0 then if modules.client_options.getOption('showLevelsInConsole') and level > 0 then
message = name .. ' [' .. level .. ']: ' .. message message = name .. ' [' .. level .. ']: ' .. message
else else
@ -1437,3 +1446,19 @@ function offline()
end end
clear() clear()
end end
function onChannelEvent(channelId, name, type)
local fmt = ChannelEventFormats[type]
if not fmt then
print(('Unknown channel event type (%d).'):format(type))
return
end
local channel = channels[channelId]
if channel then
local tab = getTab(channel)
if tab then
addTabText(fmt:format(name), SpeakTypesSettings.channelOrange, tab)
end
end
end

View File

@ -120,7 +120,7 @@ function setSkillTooltip(id, value)
widget:setTooltip(value) widget:setTooltip(value)
end end
function setSkillPercent(id, percent, tooltip) function setSkillPercent(id, percent, tooltip, color)
local skill = skillsWindow:recursiveGetChildById(id) local skill = skillsWindow:recursiveGetChildById(id)
local widget = skill:getChildById('percent') local widget = skill:getChildById('percent')
if widget then if widget then
@ -129,6 +129,10 @@ function setSkillPercent(id, percent, tooltip)
if tooltip then if tooltip then
widget:setTooltip(tooltip) widget:setTooltip(tooltip)
end end
if color then
widget:setBackgroundColor(color)
end
end end
end end
@ -333,10 +337,34 @@ function onStaminaChange(localPlayer, stamina)
if minutes < 10 then if minutes < 10 then
minutes = '0' .. minutes minutes = '0' .. minutes
end end
local percent = math.floor(100 * stamina / (42 * 60)) -- max is 42 hours local percent = math.floor(100 * stamina / (42 * 60)) -- max is 42 hours --TODO not in all client versions
setSkillValue('stamina', hours .. ":" .. minutes) setSkillValue('stamina', hours .. ":" .. minutes)
setSkillPercent('stamina', percent, tr('You have %s percent', percent))
--TODO not all client versions have premium time
if stamina > 2400 and g_game.getClientVersion() >= 1038 and localPlayer:isPremium() then
local text = tr("You have %s hours and %s minutes left", hours, minutes) .. '\n' ..
tr("Now you will gain 50%% more experience")
setSkillPercent('stamina', percent, text, 'green')
elseif stamina > 2400 and g_game.getClientVersion() >= 1038 and not localPlayer:isPremium() then
local text = tr("You have %s hours and %s minutes left", hours, minutes) .. '\n' ..
tr("You will not gain 50%% more experience because you aren't premium player, now you receive only 1x experience points")
setSkillPercent('stamina', percent, text, '#89F013')
elseif stamina > 2400 and g_game.getClientVersion() < 1038 then
local text = tr("You have %s hours and %s minutes left", hours, minutes) .. '\n' ..
tr("If you are premium player, you will gain 50%% more experience")
setSkillPercent('stamina', percent, text, 'green')
elseif stamina <= 2400 and stamina > 840 then
setSkillPercent('stamina', percent, tr("You have %s hours and %s minutes left", hours, minutes), 'orange')
elseif stamina <= 840 and stamina > 0 then
local text = tr("You have %s hours and %s minutes left", hours, minutes) .. "\n" ..
tr("You gain only 50%% experience and you don't may gain loot from monsters")
setSkillPercent('stamina', percent, text, 'red')
elseif stamina == 0 then
local text = tr("You have %s hours and %s minutes left", hours, minutes) .. "\n" ..
tr("You don't may receive experience and loot from monsters")
setSkillPercent('stamina', percent, text, 'black')
end
end end
function onOfflineTrainingChange(localPlayer, offlineTrainingTime) function onOfflineTrainingChange(localPlayer, offlineTrainingTime)

View File

@ -8,7 +8,7 @@ TextMessageLabel < UILabel
Panel Panel
anchors.fill: gameMapPanel anchors.fill: gameMapPanel
anchors.bottom: gameBottomPanel.top anchors.bottom: gameMapPanel.bottom
focusable: false focusable: false
Panel Panel

View File

@ -322,4 +322,22 @@ StoreState = {
Timed = 3 Timed = 3
} }
AccountStatus = {
Ok = 0,
Frozen = 1,
Suspended = 2,
}
SubscriptionStatus = {
Free = 0,
Premium = 1,
}
ChannelEvent = {
Join = 0,
Leave = 1,
Invite = 2,
Exclude = 3,
}
-- @} -- @}

View File

@ -240,7 +240,20 @@ function ProtocolLogin:parseCharacterList(msg)
end end
local account = {} local account = {}
if g_game.getProtocolVersion() > 1077 then
account.status = msg:getU8()
account.subStatus = msg:getU8()
account.premDays = msg:getU32()
if account.premDays ~= 0 and account.premDays ~= 65535 then
account.premDays = math.floor((account.premDays - os.time()) / 86400)
end
else
account.status = AccountStatus.Ok
account.premDays = msg:getU16() account.premDays = msg:getU16()
account.subStatus = account.premDays > 0 and SubscriptionStatus.Premium or SubscriptionStatus.Free
end
signalcall(self.onCharacterList, self, characters, account) signalcall(self.onCharacterList, self, characters, account)
end end

View File

@ -72,12 +72,14 @@ end
function UIMinimap:save() function UIMinimap:save()
local settings = { flags={} } local settings = { flags={} }
for _,flag in pairs(self.flags) do for _,flag in pairs(self.flags) do
if not flag.temporary then
table.insert(settings.flags, { table.insert(settings.flags, {
position = flag.pos, position = flag.pos,
icon = flag.icon, icon = flag.icon,
description = flag.description, description = flag.description,
}) })
end end
end
settings.zoom = self:getZoom() settings.zoom = self:getZoom()
g_settings.setNode('Minimap', settings) g_settings.setNode('Minimap', settings)
end end
@ -110,19 +112,25 @@ function UIMinimap:setCrossPosition(pos)
end end
end end
function UIMinimap:addFlag(pos, icon, description) function UIMinimap:addFlag(pos, icon, description, temporary)
if not pos or not icon then return end if not pos or not icon then return end
local flag = self:getFlag(pos, icon, description) local flag = self:getFlag(pos, icon, description)
if flag or not icon then if flag or not icon then
return return
end end
temporary = temporary or false
flag = g_ui.createWidget('MinimapFlag') flag = g_ui.createWidget('MinimapFlag')
self:insertChild(1, flag) self:insertChild(1, flag)
flag.pos = pos flag.pos = pos
flag.description = description flag.description = description
flag.icon = icon flag.icon = icon
flag.temporary = temporary
if type(tonumber(icon)) == 'number' then
flag:setIcon('/images/game/minimap/flag' .. icon) flag:setIcon('/images/game/minimap/flag' .. icon)
else
flag:setIcon(resolvepath(icon, 1))
end
flag:setTooltip(description) flag:setTooltip(description)
flag.onMouseRelease = onFlagMouseRelease flag.onMouseRelease = onFlagMouseRelease
flag.onDestroy = function() table.removevalue(self.flags, flag) end flag.onDestroy = function() table.removevalue(self.flags, flag) end

19
run.sh Executable file
View File

@ -0,0 +1,19 @@
#!/usr/bin/env bash
SE_enforcing=`getenforce` || true
sudo setenforce Permissive || true
# Enable any host to connect on X Org
xhost +
docker run -ti --rm \
-e DISPLAY \
-v /tmp/.X11-unix:/tmp/.X11-unix \
--device /dev/dri \
edubart/otclient
# Enable any host to connect on X Org
xhost -
sudo setenforce $SE_enforcing || true

View File

@ -123,6 +123,24 @@ int Animator::getPhase()
return m_phase; return m_phase;
} }
int Animator::getPhaseAt(ticks_t time)
{
int index = 0;
ticks_t total = 0;
for(const auto &pair: m_phaseDurations) {
total += std::get<1>(pair);
if (time < total) {
return index;
}
++index;
}
return std::min<int>(index, m_animationPhases - 1);
}
int Animator::getStartPhase() int Animator::getStartPhase()
{ {
if(m_startPhase > -1) if(m_startPhase > -1)
@ -197,3 +215,13 @@ void Animator::calculateSynchronous()
} }
m_lastPhaseTicks = ticks; m_lastPhaseTicks = ticks;
} }
ticks_t Animator::getTotalDuration()
{
ticks_t time = 0;
for (const auto &pair: m_phaseDurations) {
time += std::get<1>(pair);
}
return time;
}

View File

@ -50,12 +50,15 @@ public:
void setPhase(int phase); void setPhase(int phase);
int getPhase(); int getPhase();
int getPhaseAt(ticks_t time);
int getStartPhase(); int getStartPhase();
int getAnimationPhases() { return m_animationPhases; } int getAnimationPhases() { return m_animationPhases; }
bool isAsync() { return m_async; } bool isAsync() { return m_async; }
bool isComplete() { return m_isComplete; } bool isComplete() { return m_isComplete; }
ticks_t getTotalDuration();
void resetAnimation(); void resetAnimation();
private: private:

View File

@ -405,7 +405,7 @@ void Creature::updateJump()
int nextT, i = 1; int nextT, i = 1;
do { do {
nextT = stdext::round((-b + std::sqrt(std::max<int>(b*b + 4*a*(roundHeight+diff*i), 0.0)) * diff) / (2*a)); nextT = stdext::round((-b + std::sqrt(std::max<double>(b*b + 4*a*(roundHeight+diff*i), 0.0)) * diff) / (2*a));
++i; ++i;
if(nextT < halfJumpDuration) if(nextT < halfJumpDuration)

View File

@ -22,6 +22,7 @@
#include "effect.h" #include "effect.h"
#include "map.h" #include "map.h"
#include "game.h"
#include <framework/core/eventdispatcher.h> #include <framework/core/eventdispatcher.h>
void Effect::drawEffect(const Point& dest, float scaleFactor, bool animate, int offsetX, int offsetY, LightView *lightView) void Effect::drawEffect(const Point& dest, float scaleFactor, bool animate, int offsetX, int offsetY, LightView *lightView)
@ -30,8 +31,20 @@ void Effect::drawEffect(const Point& dest, float scaleFactor, bool animate, int
return; return;
int animationPhase = 0; int animationPhase = 0;
if(animate) if(animate) {
animationPhase = std::min<int>((int)(m_animationTimer.ticksElapsed() / m_phaseDuration), getAnimationPhases() - 1); if(g_game.getFeature(Otc::GameEnhancedAnimations)) {
// This requires a separate getPhaseAt method as using getPhase would make all magic effects use the same phase regardless of their appearance time
animationPhase = rawGetThingType()->getAnimator()->getPhaseAt(m_animationTimer.ticksElapsed());
} else {
// hack to fix some animation phases duration, currently there is no better solution
int ticks = EFFECT_TICKS_PER_FRAME;
if (m_id == 33) {
ticks <<= 2;
}
animationPhase = std::min<int>((int)(m_animationTimer.ticksElapsed() / ticks), getAnimationPhases() - 1);
}
}
int xPattern = offsetX % getNumPatternX(); int xPattern = offsetX % getNumPatternX();
if(xPattern < 0) if(xPattern < 0)
@ -47,15 +60,24 @@ void Effect::drawEffect(const Point& dest, float scaleFactor, bool animate, int
void Effect::onAppear() void Effect::onAppear()
{ {
m_animationTimer.restart(); m_animationTimer.restart();
m_phaseDuration = EFFECT_TICKS_PER_FRAME;
int duration = 0;
if(g_game.getFeature(Otc::GameEnhancedAnimations)) {
duration = getThingType()->getAnimator()->getTotalDuration();
} else {
duration = EFFECT_TICKS_PER_FRAME;
// hack to fix some animation phases duration, currently there is no better solution // hack to fix some animation phases duration, currently there is no better solution
if(m_id == 33) if(m_id == 33) {
m_phaseDuration <<= 2; duration <<= 2;
}
duration *= getAnimationPhases();
}
// schedule removal // schedule removal
auto self = asEffect(); auto self = asEffect();
g_dispatcher.scheduleEvent([self]() { g_map.removeThing(self); }, m_phaseDuration * getAnimationPhases()); g_dispatcher.scheduleEvent([self]() { g_map.removeThing(self); }, duration);
} }
void Effect::setId(uint32 id) void Effect::setId(uint32 id)

View File

@ -51,7 +51,6 @@ protected:
private: private:
Timer m_animationTimer; Timer m_animationTimer;
uint m_phaseDuration;
uint16 m_id; uint16 m_id;
}; };

View File

@ -1903,9 +1903,11 @@ void ProtocolGame::parseQuestLine(const InputMessagePtr& msg)
void ProtocolGame::parseChannelEvent(const InputMessagePtr& msg) void ProtocolGame::parseChannelEvent(const InputMessagePtr& msg)
{ {
msg->getU16(); // channel id uint16 channelId = msg->getU16();
g_game.formatCreatureName(msg->getString()); // player name std::string name = g_game.formatCreatureName(msg->getString());
msg->getU8(); // event type uint8 type = msg->getU8();
g_lua.callGlobalField("g_game", "onChannelEvent", channelId, name, type);
} }
void ProtocolGame::parseItemInfo(const InputMessagePtr& msg) void ProtocolGame::parseItemInfo(const InputMessagePtr& msg)

View File

@ -33,9 +33,10 @@ class Connection : public LuaObject
typedef std::function<void(const boost::system::error_code&)> ErrorCallback; typedef std::function<void(const boost::system::error_code&)> ErrorCallback;
typedef std::function<void(uint8*, uint16)> RecvCallback; typedef std::function<void(uint8*, uint16)> RecvCallback;
static constexpr int32_t READ_TIMEOUT = 30;
static constexpr int32_t WRITE_TIMEOUT = 30;
enum { enum {
READ_TIMEOUT = 30,
WRITE_TIMEOUT = 30,
SEND_BUFFER_SIZE = 65536, SEND_BUFFER_SIZE = 65536,
RECV_BUFFER_SIZE = 65536 RECV_BUFFER_SIZE = 65536
}; };

View File

@ -79,7 +79,7 @@ void Protocol::send(const OutputMessagePtr& outputMessage)
if(m_checksumEnabled) if(m_checksumEnabled)
outputMessage->writeChecksum(); outputMessage->writeChecksum();
// wirte message size // write message size
outputMessage->writeMessageSize(); outputMessage->writeMessageSize();
// send // send

View File

@ -29,7 +29,19 @@
#include <winsock2.h> #include <winsock2.h>
#include <windows.h> #include <windows.h>
#include <process.h> #include <process.h>
#ifdef _MSC_VER
#pragma warning (push)
#pragma warning (disable:4091) // warning C4091: 'typedef ': ignored on left of '' when no variable is declared
#include <imagehlp.h> #include <imagehlp.h>
#pragma warning (pop)
#else
#include <imagehlp.h>
#endif
const char *getExceptionName(DWORD exceptionCode) const char *getExceptionName(DWORD exceptionCode)
{ {

View File

@ -27,8 +27,8 @@
#define AL_LIBTYPE_STATIC #define AL_LIBTYPE_STATIC
#include <al.h> #include <AL/al.h>
#include <alc.h> #include <AL/alc.h>
class SoundManager; class SoundManager;
class SoundSource; class SoundSource;

View File

@ -45,7 +45,16 @@
#pragma warning(disable:4146) // unary minus operator applied to unsigned type, result still unsigned #pragma warning(disable:4146) // unary minus operator applied to unsigned type, result still unsigned
#pragma warning(disable:4800) // 'A' : forcing value to bool 'true' or 'false' (performance warning) #pragma warning(disable:4800) // 'A' : forcing value to bool 'true' or 'false' (performance warning)
#define BUILD_COMPILER "msvc12" #if _MSC_VER == 1912 || _MSC_VER == 1911 || _MSC_VER == 1910
#define BUILD_COMPILER "Visual Studio 2017"
#elif _MSC_VER == 1900
#define BUILD_COMPILER "Visual Studio 2015"
#elif _MSC_VER == 1800
#define BUILD_COMPILER "Visual Studio 2013"
#else
#define BUILD_COMPILER "Visual Studio"
#endif
#define __PRETTY_FUNCTION__ __FUNCDNAME__ #define __PRETTY_FUNCTION__ __FUNCDNAME__
#else #else
#error "Compiler not supported." #error "Compiler not supported."

View File

@ -23,13 +23,21 @@
#include "demangle.h" #include "demangle.h"
#ifdef _MSC_VER #ifdef _MSC_VER
#include <winsock2.h> #include <winsock2.h>
#include <windows.h> #include <windows.h>
#pragma warning (push)
#pragma warning (disable:4091) // warning C4091: 'typedef ': ignored on left of '' when no variable is declared
#include <dbghelp.h> #include <dbghelp.h>
#pragma warning (pop)
#else #else
#include <cxxabi.h> #include <cxxabi.h>
#include <cstring> #include <cstring>
#include <cstdlib> #include <cstdlib>
#endif #endif
namespace stdext { namespace stdext {

View File

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations"> <ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32"> <ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration> <Configuration>Debug</Configuration>
@ -22,27 +22,28 @@
<Keyword>Win32Proj</Keyword> <Keyword>Win32Proj</Keyword>
<ProjectGuid>{17A8F78F-1FFB-4128-A3B3-59CC6C19D89A}</ProjectGuid> <ProjectGuid>{17A8F78F-1FFB-4128-A3B3-59CC6C19D89A}</ProjectGuid>
<RootNamespace>otclient</RootNamespace> <RootNamespace>otclient</RootNamespace>
<WindowsTargetPlatformVersion>10.0.17134.0</WindowsTargetPlatformVersion>
</PropertyGroup> </PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType> <ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries> <UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset> <PlatformToolset>v141</PlatformToolset>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType> <ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries> <UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset> <PlatformToolset>v141</PlatformToolset>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType> <ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries> <UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset> <PlatformToolset>v141</PlatformToolset>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType> <ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries> <UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset> <PlatformToolset>v141</PlatformToolset>
</PropertyGroup> </PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" /> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings"> <ImportGroup Label="ExtensionSettings">
@ -74,8 +75,11 @@
<PropertyGroup Label="UserMacros" /> <PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);../src;</IncludePath> <IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);../src;</IncludePath>
<SourcePath>$(VC_SourcePath);$(ProjectDir)../src;</SourcePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);../src;</IncludePath>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);../src;</IncludePath> <IncludePath>$(VC_IncludePath);$(WindowsSDK_IncludePath);../src;</IncludePath>
</PropertyGroup> </PropertyGroup>
@ -87,6 +91,7 @@
<PreprocessorDefinitions>$(PREPROCESSOR_DEFS);_SCL_SECURE_NO_WARNINGS;ZLIB_WINAPI;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>$(PREPROCESSOR_DEFS);_SCL_SECURE_NO_WARNINGS;ZLIB_WINAPI;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<Optimization>Disabled</Optimization> <Optimization>Disabled</Optimization>
<EnableEnhancedInstructionSet>AdvancedVectorExtensions</EnableEnhancedInstructionSet>
</ClCompile> </ClCompile>
<Link> <Link>
<TargetMachine>MachineX86</TargetMachine> <TargetMachine>MachineX86</TargetMachine>
@ -97,6 +102,7 @@
<ClCompile> <ClCompile>
<PreprocessorDefinitions>$(PREPROCESSOR_DEFS);_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>$(PREPROCESSOR_DEFS);_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<EnableEnhancedInstructionSet>AdvancedVectorExtensions</EnableEnhancedInstructionSet>
</ClCompile> </ClCompile>
<Link> <Link>
<GenerateDebugInformation>true</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
@ -106,6 +112,10 @@
<ClCompile> <ClCompile>
<PreprocessorDefinitions>$(PREPROCESSOR_DEFS);%(PreprocessorDefinitions)</PreprocessorDefinitions> <PreprocessorDefinitions>$(PREPROCESSOR_DEFS);%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary> <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<EnableEnhancedInstructionSet>AdvancedVectorExtensions</EnableEnhancedInstructionSet>
<Optimization>MaxSpeed</Optimization>
<IntrinsicFunctions>true</IntrinsicFunctions>
<EnableFiberSafeOptimizations>true</EnableFiberSafeOptimizations>
</ClCompile> </ClCompile>
<Link> <Link>
<TargetMachine>MachineX86</TargetMachine> <TargetMachine>MachineX86</TargetMachine>
@ -120,6 +130,10 @@
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary> <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<WarningLevel>Level4</WarningLevel> <WarningLevel>Level4</WarningLevel>
<EnableEnhancedInstructionSet>AdvancedVectorExtensions</EnableEnhancedInstructionSet>
<Optimization>MaxSpeed</Optimization>
<IntrinsicFunctions>true</IntrinsicFunctions>
<EnableFiberSafeOptimizations>true</EnableFiberSafeOptimizations>
</ClCompile> </ClCompile>
<Link> <Link>
<GenerateDebugInformation>true</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>