parent
05436e135a
commit
52f81c53f9
|
@ -11,21 +11,21 @@ end
|
|||
|
||||
function UIMiniWindowContainer:onDrop(widget, mousePos)
|
||||
if widget:getClassName() == 'UIMiniWindow' then
|
||||
local oldParent = widget:getParent()
|
||||
if oldParent == self then
|
||||
return true
|
||||
end
|
||||
|
||||
if oldParent then
|
||||
oldParent:removeChild(widget)
|
||||
local oldParent = widget:getParent()
|
||||
if oldParent == self then
|
||||
return true
|
||||
end
|
||||
|
||||
if widget.movedWidget then
|
||||
local index = self:getChildIndex(widget.movedWidget)
|
||||
self:insertChild(index + widget.movedIndex, widget)
|
||||
else
|
||||
self:addChild(widget)
|
||||
end
|
||||
if oldParent then
|
||||
oldParent:removeChild(widget)
|
||||
end
|
||||
|
||||
if widget.movedWidget then
|
||||
local index = self:getChildIndex(widget.movedWidget)
|
||||
self:insertChild(index + widget.movedIndex, widget)
|
||||
else
|
||||
self:addChild(widget)
|
||||
end
|
||||
|
||||
return true
|
||||
end
|
||||
|
@ -47,7 +47,7 @@ end
|
|||
function UIMiniWindowContainer:scheduleInsert(widget, index)
|
||||
if index - 1 > self:getChildCount() then
|
||||
if self.scheduledWidgets[index] then
|
||||
warning('replacing scheduled widget id ' .. widget:getId())
|
||||
pwarning('replacing scheduled widget id ' .. widget:getId())
|
||||
end
|
||||
self.scheduledWidgets[index] = widget
|
||||
else
|
||||
|
|
|
@ -32,7 +32,6 @@ function UIItem:onDrop(widget, mousePos)
|
|||
if itemPos.x == toPos.x and itemPos.y == toPos.y and itemPos.z == toPos.z then return false end
|
||||
|
||||
if item:getCount() > 1 then
|
||||
g_game.look(item)
|
||||
modules.game_interface.moveStackableItem(item, toPos)
|
||||
else
|
||||
g_game.move(item, toPos, 1)
|
||||
|
|
|
@ -380,6 +380,11 @@ function onOpenNpcTrade(items)
|
|||
addEvent(show) -- player goods has not been parsed yet
|
||||
end
|
||||
|
||||
function closeNpcTrade()
|
||||
g_game.closeNpcTrade()
|
||||
hide()
|
||||
end
|
||||
|
||||
function onCloseNpcTrade()
|
||||
hide()
|
||||
end
|
||||
|
|
|
@ -33,7 +33,7 @@ MainWindow
|
|||
id: npcWindow
|
||||
!text: tr('NPC Trade')
|
||||
size: 550 515
|
||||
@onEscape: g_game.closeNpcTrade()
|
||||
@onEscape: modules.game_npctrade.closeNpcTrade()
|
||||
|
||||
TabButton
|
||||
id: buyTab
|
||||
|
@ -264,4 +264,4 @@ MainWindow
|
|||
width: 64
|
||||
anchors.right: parent.right
|
||||
anchors.bottom: parent.bottom
|
||||
@onClick: g_game.closeNpcTrade()
|
||||
@onClick: modules.game_npctrade.closeNpcTrade()
|
||||
|
|
|
@ -150,6 +150,7 @@ function destroy()
|
|||
currentColorBox = nil
|
||||
currentClotheButtonBox = nil
|
||||
colorBoxes = {}
|
||||
addons = nil
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -12,4 +12,4 @@ MiniWindow
|
|||
MiniWindowContents
|
||||
layout: verticalBox
|
||||
anchors.fill: parent
|
||||
@onMousePress: onVipListMousePress()
|
||||
&onMousePress: modules.game_viplist.onVipListMousePress
|
||||
|
|
|
@ -158,6 +158,11 @@ void Game::processPing()
|
|||
g_lua.callGlobalField("g_game", "onPing");
|
||||
}
|
||||
|
||||
void Game::processPingBack(int elapsed)
|
||||
{
|
||||
g_lua.callGlobalField("g_game", "onPingBack", elapsed);
|
||||
}
|
||||
|
||||
void Game::processTextMessage(Otc::MessageMode mode, const std::string& text)
|
||||
{
|
||||
g_lua.callGlobalField("g_game", "onTextMessage", mode, text);
|
||||
|
@ -1073,6 +1078,16 @@ void Game::mount(bool mount)
|
|||
m_mounted = mount;
|
||||
}
|
||||
|
||||
void Game::ping()
|
||||
{
|
||||
if(!m_protocolGame || !m_protocolGame->isConnected())
|
||||
return;
|
||||
|
||||
m_denyBotCall = false;
|
||||
m_protocolGame->sendPing();
|
||||
m_denyBotCall = true;
|
||||
}
|
||||
|
||||
bool Game::checkBotProtection()
|
||||
{
|
||||
#ifdef BOT_PROTECTION
|
||||
|
|
|
@ -51,6 +51,7 @@ protected:
|
|||
void processConnectionError(const boost::system::error_code& error);
|
||||
void processDisconnect();
|
||||
void processPing();
|
||||
void processPingBack(int elapsed);
|
||||
|
||||
void processLoginError(const std::string& error);
|
||||
void processLoginAdvice(const std::string& message);
|
||||
|
@ -232,7 +233,7 @@ public:
|
|||
// 910 only
|
||||
//void requestItemInfo();
|
||||
//void reportRuleViolation2();
|
||||
// TODO: market related
|
||||
void ping();
|
||||
|
||||
// dynamic support for game features
|
||||
void enableFeature(Otc::GameFeature feature) { m_features.set(feature, true); }
|
||||
|
|
|
@ -37,6 +37,7 @@ LocalPlayer::LocalPlayer()
|
|||
|
||||
m_states = 0;
|
||||
m_vocation = 0;
|
||||
m_walkLockInterval = 0;
|
||||
|
||||
m_skillsLevel.fill(-1);
|
||||
m_skillsLevelPercent.fill(-1);
|
||||
|
@ -55,7 +56,7 @@ LocalPlayer::LocalPlayer()
|
|||
m_stamina = -1;
|
||||
}
|
||||
|
||||
void LocalPlayer::lockWalk()
|
||||
void LocalPlayer::lockWalk(int millis)
|
||||
{
|
||||
// prevents double locks
|
||||
if(m_walkLocked)
|
||||
|
@ -63,6 +64,7 @@ void LocalPlayer::lockWalk()
|
|||
|
||||
m_walkLocked = true;
|
||||
m_walkLockTimer.restart();
|
||||
m_walkLockInterval = millis;
|
||||
}
|
||||
|
||||
bool LocalPlayer::canWalk(Otc::Direction direction)
|
||||
|
@ -79,7 +81,7 @@ bool LocalPlayer::canWalk(Otc::Direction direction)
|
|||
return false;
|
||||
|
||||
// cannot walk while locked
|
||||
if(m_walkLocked && m_walkLockTimer.ticksElapsed() <= WALK_LOCK_INTERVAL)
|
||||
if(m_walkLocked && m_walkLockTimer.ticksElapsed() <= m_walkLockInterval)
|
||||
return false;
|
||||
else
|
||||
m_walkLocked = false;
|
||||
|
|
|
@ -29,7 +29,6 @@
|
|||
class LocalPlayer : public Player
|
||||
{
|
||||
enum {
|
||||
WALK_LOCK_INTERVAL = 250,
|
||||
PREWALK_TIMEOUT = 1000
|
||||
};
|
||||
|
||||
|
@ -37,7 +36,7 @@ public:
|
|||
LocalPlayer();
|
||||
|
||||
void unlockWalk() { m_walkLocked = false; }
|
||||
void lockWalk();
|
||||
void lockWalk(int millis = 250);
|
||||
bool canWalk(Otc::Direction direction);
|
||||
|
||||
void setStates(int states);
|
||||
|
@ -112,6 +111,7 @@ private:
|
|||
bool m_known;
|
||||
int m_states;
|
||||
int m_vocation;
|
||||
int m_walkLockInterval;
|
||||
|
||||
double m_health;
|
||||
double m_maxHealth;
|
||||
|
|
|
@ -164,6 +164,7 @@ void OTClient::registerLuaFunctions()
|
|||
g_lua.bindSingletonFunction("g_game", "inspectNpcTrade", &Game::inspectNpcTrade, &g_game);
|
||||
g_lua.bindSingletonFunction("g_game", "buyItem", &Game::buyItem, &g_game);
|
||||
g_lua.bindSingletonFunction("g_game", "sellItem", &Game::sellItem, &g_game);
|
||||
g_lua.bindSingletonFunction("g_game", "ping", &Game::ping, &g_game);
|
||||
g_lua.bindSingletonFunction("g_game", "closeNpcTrade", &Game::closeNpcTrade, &g_game);
|
||||
g_lua.bindSingletonFunction("g_game", "requestTrade", &Game::requestTrade, &g_game);
|
||||
g_lua.bindSingletonFunction("g_game", "inspectTrade", &Game::inspectTrade, &g_game);
|
||||
|
@ -249,6 +250,8 @@ void OTClient::registerLuaFunctions()
|
|||
g_lua.bindClassMemberFunction<Thing>("getStackPriority", &Thing::getStackPriority);
|
||||
g_lua.bindClassMemberFunction<Thing>("getAnimationPhases", &Thing::getAnimationPhases);
|
||||
g_lua.bindClassMemberFunction<Thing>("isItem", &Thing::isItem);
|
||||
g_lua.bindClassMemberFunction<Thing>("isMonster", &Thing::isMonster);
|
||||
g_lua.bindClassMemberFunction<Thing>("isNpc", &Thing::isNpc);
|
||||
g_lua.bindClassMemberFunction<Thing>("isCreature", &Thing::isCreature);
|
||||
g_lua.bindClassMemberFunction<Thing>("isEffect", &Thing::isEffect);
|
||||
g_lua.bindClassMemberFunction<Thing>("isMissile", &Thing::isMissile);
|
||||
|
|
|
@ -219,6 +219,7 @@ private:
|
|||
std::string m_accountName;
|
||||
std::string m_accountPassword;
|
||||
std::string m_characterName;
|
||||
Timer m_pingTimer;
|
||||
LocalPlayerPtr m_localPlayer;
|
||||
};
|
||||
|
||||
|
|
|
@ -378,7 +378,7 @@ void ProtocolGame::parsePing(const InputMessagePtr& msg)
|
|||
|
||||
void ProtocolGame::parsePingBack(const InputMessagePtr& msg)
|
||||
{
|
||||
// nothing to do
|
||||
g_game.processPingBack(m_pingTimer.ticksElapsed());
|
||||
}
|
||||
|
||||
void ProtocolGame::parseChallange(const InputMessagePtr& msg)
|
||||
|
@ -928,7 +928,7 @@ void ProtocolGame::parsePlayerCancelAttack(const InputMessagePtr& msg)
|
|||
|
||||
void ProtocolGame::parseSpellCooldown(const InputMessagePtr& msg)
|
||||
{
|
||||
msg->getU16(); // spell id
|
||||
msg->getU8(); // spell id
|
||||
msg->getU32(); // cooldown
|
||||
}
|
||||
|
||||
|
@ -1083,16 +1083,26 @@ void ProtocolGame::parseTextMessage(const InputMessagePtr& msg)
|
|||
case Otc::MessageDamageReceived:
|
||||
case Otc::MessageDamageOthers: {
|
||||
Position pos = getPosition(msg);
|
||||
uint value = msg->getU32();
|
||||
int color = msg->getU8();
|
||||
msg->getU32(); // ??
|
||||
msg->getU8(); // ??
|
||||
uint value[2];
|
||||
int color[2];
|
||||
|
||||
// physical damage
|
||||
value[0] = msg->getU32();
|
||||
color[0] = msg->getU8();
|
||||
|
||||
// magic damage
|
||||
value[1] = msg->getU32();
|
||||
color[1] = msg->getU8();
|
||||
text = msg->getString();
|
||||
|
||||
AnimatedTextPtr animatedText = AnimatedTextPtr(new AnimatedText);
|
||||
animatedText->setColor(color);
|
||||
animatedText->setText(stdext::to_string(value));
|
||||
g_map.addThing(animatedText, pos);
|
||||
for(int i=0;i<2;++i) {
|
||||
if(value[i] == 0)
|
||||
continue;
|
||||
AnimatedTextPtr animatedText = AnimatedTextPtr(new AnimatedText);
|
||||
animatedText->setColor(color[i]);
|
||||
animatedText->setText(stdext::to_string(value[i]));
|
||||
g_map.addThing(animatedText, pos);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case Otc::MessageHeal:
|
||||
|
@ -1130,8 +1140,8 @@ void ProtocolGame::parseCancelWalk(const InputMessagePtr& msg)
|
|||
|
||||
void ProtocolGame::parseWalkWait(const InputMessagePtr& msg)
|
||||
{
|
||||
//TODO: implement walk wait time
|
||||
msg->getU16(); // time
|
||||
int millis = msg->getU16();
|
||||
m_localPlayer->lockWalk(millis);
|
||||
}
|
||||
|
||||
void ProtocolGame::parseFloorChangeUp(const InputMessagePtr& msg)
|
||||
|
|
|
@ -109,6 +109,7 @@ void ProtocolGame::sendPing()
|
|||
{
|
||||
OutputMessagePtr msg(new OutputMessage);
|
||||
msg->addU8(Proto::ClientPing);
|
||||
m_pingTimer.restart();
|
||||
Protocol::send(msg);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue