This commit is contained in:
Tulioh
2015-04-19 12:22:16 -03:00
386 changed files with 2616 additions and 921 deletions

View File

@@ -24,6 +24,8 @@ set(client_SOURCES ${client_SOURCES}
# core
${CMAKE_CURRENT_LIST_DIR}/animatedtext.cpp
${CMAKE_CURRENT_LIST_DIR}/animatedtext.h
${CMAKE_CURRENT_LIST_DIR}/animator.h
${CMAKE_CURRENT_LIST_DIR}/animator.cpp
${CMAKE_CURRENT_LIST_DIR}/container.cpp
${CMAKE_CURRENT_LIST_DIR}/container.h
${CMAKE_CURRENT_LIST_DIR}/creature.cpp

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 OTClient <https://github.com/edubart/otclient>
* Copyright (c) 2010-2015 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 OTClient <https://github.com/edubart/otclient>
* Copyright (c) 2010-2015 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

199
src/client/animator.cpp Normal file
View File

@@ -0,0 +1,199 @@
/*
* Copyright (c) 2010-2015 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include "declarations.h"
#include "animator.h"
#include <framework/core/clock.h>
#include <framework/core/filestream.h>
Animator::Animator()
{
m_animationPhases = 0;
m_startPhase = 0;
m_loopCount = 0;
m_async = false;
m_currentDuration = 0;
m_currentDirection = AnimDirForward;
m_currentLoop = 0;
m_lastPhaseTicks = 0;
m_isComplete = false;
m_phase = 0;
}
void Animator::unserialize(int animationPhases, const FileStreamPtr& fin)
{
m_animationPhases = animationPhases;
m_async = fin->getU8() == 0;
m_loopCount = fin->get32();
m_startPhase = fin->get8();
for(int i = 0; i < m_animationPhases; ++i) {
int minimum = fin->getU32();
int maximum = fin->getU32();
m_phaseDurations.push_back(std::make_tuple(minimum, maximum));
}
m_phase = getStartPhase();
assert(m_animationPhases == (int)m_phaseDurations.size());
assert(m_startPhase >= -1 && m_startPhase < m_animationPhases);
}
void Animator::serialize(const FileStreamPtr& fin)
{
fin->addU8(m_async ? 0 : 1);
fin->add32(m_loopCount);
fin->add8(m_startPhase);
for(std::tuple<int, int> phase : m_phaseDurations) {
fin->addU32(std::get<0>(phase));
fin->addU32(std::get<1>(phase));
}
}
void Animator::setPhase(int phase)
{
if(m_phase == phase) return;
if(m_async) {
if(phase == AnimPhaseAsync)
m_phase = 0;
else if(phase == AnimPhaseRandom)
m_phase = (int)stdext::random_range(0, (long)m_animationPhases);
else if(phase >= 0 && phase < m_animationPhases)
m_phase = phase;
else
m_phase = getStartPhase();
m_isComplete = false;
m_lastPhaseTicks = g_clock.millis();
m_currentDuration = getPhaseDuration(phase);
m_currentLoop = 0;
} else
calculateSynchronous();
}
int Animator::getPhase()
{
ticks_t ticks = g_clock.millis();
if(ticks != m_lastPhaseTicks && !m_isComplete) {
int elapsedTicks = (int)(ticks - m_lastPhaseTicks);
if(elapsedTicks >= m_currentDuration) {
int phase = 0;
if(m_loopCount < 0)
phase = getPingPongPhase();
else
phase = getLoopPhase();
if(m_phase != phase) {
int duration = getPhaseDuration(phase) - (elapsedTicks - m_currentDuration);
if(duration < 0 && !m_async) {
calculateSynchronous();
} else {
m_phase = phase;
m_currentDuration = std::max<int>(0, duration);
}
} else
m_isComplete = true;
} else
m_currentDuration -= elapsedTicks;
m_lastPhaseTicks = ticks;
}
return m_phase;
}
int Animator::getStartPhase()
{
if(m_startPhase > -1)
return m_startPhase;
return (int)stdext::random_range(0, (long)m_animationPhases);
}
void Animator::resetAnimation()
{
m_isComplete = false;
m_currentDirection = AnimDirForward;
m_currentLoop = 0;
setPhase(AnimPhaseAutomatic);
}
int Animator::getPingPongPhase()
{
int count = m_currentDirection == AnimDirForward ? 1 : -1;
int nextPhase = m_phase + count;
if(nextPhase < 0 || nextPhase >= m_animationPhases) {
m_currentDirection = m_currentDirection == AnimDirForward ? AnimDirBackward : AnimDirForward;
count *= -1;
}
return m_phase + count;
}
int Animator::getLoopPhase()
{
int nextPhase = m_phase + 1;
if(nextPhase < m_animationPhases)
return nextPhase;
if(m_loopCount == 0)
return 0;
if(m_currentLoop < (m_loopCount - 1)) {
m_currentLoop++;
return 0;
}
return m_phase;
}
int Animator::getPhaseDuration(int phase)
{
assert(phase < (int)m_phaseDurations.size());
std::tuple<int, int> data = m_phaseDurations.at(phase);
int min = std::get<0>(data);
int max = std::get<1>(data);
if(min == max) return min;
return (int)stdext::random_range((long)min, (long)max);
}
void Animator::calculateSynchronous()
{
int totalDuration = 0;
for(int i = 0; i < m_animationPhases; i++)
totalDuration += getPhaseDuration(i);
ticks_t ticks = g_clock.millis();
int elapsedTicks = (int)(ticks % totalDuration);
int totalTime = 0;
for(int i = 0; i < m_animationPhases; i++) {
int duration = getPhaseDuration(i);
if(elapsedTicks >= totalTime && elapsedTicks < totalTime + duration) {
m_phase = i;
m_currentDuration = duration - (elapsedTicks - totalTime);
break;
}
totalTime += duration;
}
m_lastPhaseTicks = ticks;
}

83
src/client/animator.h Normal file
View File

@@ -0,0 +1,83 @@
/*
* Copyright (c) 2010-2015 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef ANIMATOR_H
#define ANIMATOR_H
#include "declarations.h"
#include <framework/core/declarations.h>
enum AnimationPhase : int16
{
AnimPhaseAutomatic = -1,
AnimPhaseRandom = 254,
AnimPhaseAsync = 255,
};
enum AnimationDirection : uint8
{
AnimDirForward = 0,
AnimDirBackward = 1
};
class Animator : public stdext::shared_object
{
public:
Animator();
void unserialize(int animationPhases, const FileStreamPtr& fin);
void serialize(const FileStreamPtr& fin);
void setPhase(int phase);
int getPhase();
int getStartPhase();
int getAnimationPhases() { return m_animationPhases; }
bool isAsync() { return m_async; }
bool isComplete() { return m_isComplete; }
void resetAnimation();
private:
int getPingPongPhase();
int getLoopPhase();
int getPhaseDuration(int phase);
void calculateSynchronous();
int m_animationPhases;
int m_startPhase;
int m_loopCount;
bool m_async;
std::vector< std::tuple<int, int> > m_phaseDurations;
int m_currentDuration;
AnimationDirection m_currentDirection;
int m_currentLoop;
ticks_t m_lastPhaseTicks;
bool m_isComplete;
int m_phase;
};
#endif

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 OTClient <https://github.com/edubart/otclient>
* Copyright (c) 2010-2015 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 OTClient <https://github.com/edubart/otclient>
* Copyright (c) 2010-2015 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 OTClient <https://github.com/edubart/otclient>
* Copyright (c) 2010-2015 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -328,7 +328,9 @@ namespace Otc
MessageRVRChannel = 46,
MessageRVRAnswer = 47,
MessageRVRContinue = 48,
LastMessage = 49,
MessageGameHighlight = 49,
MessageNpcFromStartBlock = 50,
LastMessage = 51,
MessageInvalid = 255
};
@@ -390,6 +392,17 @@ namespace Otc
GamePremiumExpiration = 57,
GameBrowseField = 58,
GameEnhancedAnimations = 59,
GameOGLInformation = 60,
GameMessageSizeCheck = 61,
GamePreviewState = 62,
GameLoginPacketEncryption = 63,
GameClientVersion = 64,
GameContentRevision = 65,
GameExperienceBonus = 66,
GameAuthenticator = 67,
GameUnjustifiedPoints = 68,
GameSessionKey = 69,
GameDeathType = 70,
LastGameFeature = 101
};
@@ -445,10 +458,19 @@ namespace Otc
LastSpeedFormula
};
enum AnimationPhase {
PhaseAutomatic = 0,
PhaseRandom = 254,
PhaseAsync = 255
enum Blessings {
BlessingNone = 0,
BlessingAdventurer = 1,
BlessingSpiritualShielding = 1 << 1,
BlessingEmbraceOfTibia = 1 << 2,
BlessingFireOfSuns = 1 << 3,
BlessingWisdomOfSolitude = 1 << 4,
BlessingSparkOfPhoenix = 1 << 5
};
enum DeathType {
DeathRegular = 0,
DeathBlessed = 1
};
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 OTClient <https://github.com/edubart/otclient>
* Copyright (c) 2010-2015 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 OTClient <https://github.com/edubart/otclient>
* Copyright (c) 2010-2015 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 OTClient <https://github.com/edubart/otclient>
* Copyright (c) 2010-2015 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -696,6 +696,16 @@ void Creature::setSpeed(uint16 speed)
callLuaField("onSpeedChange", m_speed, oldSpeed);
}
void Creature::setBaseSpeed(double baseSpeed)
{
if(m_baseSpeed != baseSpeed) {
double oldBaseSpeed = m_baseSpeed;
m_baseSpeed = baseSpeed;
callLuaField("onBaseSpeedChange", baseSpeed, oldBaseSpeed);
}
}
void Creature::setSkull(uint8 skull)
{
m_skull = skull;

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 OTClient <https://github.com/edubart/otclient>
* Copyright (c) 2010-2015 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -58,6 +58,7 @@ public:
void setOutfitColor(const Color& color, int duration);
void setLight(const Light& light) { m_light = light; }
void setSpeed(uint16 speed);
void setBaseSpeed(double baseSpeed);
void setSkull(uint8 skull);
void setShield(uint8 shield);
void setEmblem(uint8 emblem);
@@ -82,6 +83,7 @@ public:
Outfit getOutfit() { return m_outfit; }
Light getLight() { return m_light; }
uint16 getSpeed() { return m_speed; }
double getBaseSpeed() { return m_baseSpeed; }
uint8 getSkull() { return m_skull; }
uint8 getShield() { return m_shield; }
uint8 getEmblem() { return m_emblem; }
@@ -147,6 +149,7 @@ protected:
Outfit m_outfit;
Light m_light;
int m_speed;
double m_baseSpeed;
uint8 m_skull;
uint8 m_shield;
uint8 m_emblem;

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 OTClient <https://github.com/edubart/otclient>
* Copyright (c) 2010-2015 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 OTClient <https://github.com/edubart/otclient>
* Copyright (c) 2010-2015 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 OTClient <https://github.com/edubart/otclient>
* Copyright (c) 2010-2015 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -45,6 +45,7 @@ class Effect;
class Missile;
class AnimatedText;
class StaticText;
class Animator;
class ThingType;
class ItemType;
class House;
@@ -68,6 +69,7 @@ typedef stdext::shared_object_ptr<Effect> EffectPtr;
typedef stdext::shared_object_ptr<Missile> MissilePtr;
typedef stdext::shared_object_ptr<AnimatedText> AnimatedTextPtr;
typedef stdext::shared_object_ptr<StaticText> StaticTextPtr;
typedef stdext::shared_object_ptr<Animator> AnimatorPtr;
typedef stdext::shared_object_ptr<ThingType> ThingTypePtr;
typedef stdext::shared_object_ptr<ItemType> ItemTypePtr;
typedef stdext::shared_object_ptr<House> HousePtr;

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 OTClient <https://github.com/edubart/otclient>
* Copyright (c) 2010-2015 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 OTClient <https://github.com/edubart/otclient>
* Copyright (c) 2010-2015 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 OTClient <https://github.com/edubart/otclient>
* Copyright (c) 2010-2015 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -84,6 +84,7 @@ void Game::resetGameStates()
m_localPlayer = nullptr;
m_pingSent = 0;
m_pingReceived = 0;
m_unjustifiedPoints = UnjustifiedPoints();
for(auto& it : m_containers) {
const ContainerPtr& container = it.second;
@@ -155,6 +156,11 @@ void Game::processLoginWait(const std::string& message, int time)
g_lua.callGlobalField("g_game", "onLoginWait", message, time);
}
void Game::processLoginToken(bool unknown)
{
g_lua.callGlobalField("g_game", "onLoginToken", unknown);
}
void Game::processLogin()
{
g_lua.callGlobalField("g_game", "onLogin");
@@ -222,12 +228,12 @@ void Game::processGameEnd()
g_map.cleanDynamicThings();
}
void Game::processDeath(int penality)
void Game::processDeath(int deathType, int penality)
{
m_dead = true;
m_localPlayer->stopWalk();
g_lua.callGlobalField("g_game", "onDeath", penality);
g_lua.callGlobalField("g_game", "onDeath", deathType, penality);
}
void Game::processGMActions(const std::vector<uint8>& actions)
@@ -308,9 +314,6 @@ void Game::processCloseContainer(int containerId)
{
ContainerPtr container = getContainer(containerId);
if(!container) {
/* happens if you close and restart client with container opened
* g_logger.traceError("container not found");
*/
return;
}
@@ -322,7 +325,6 @@ void Game::processContainerAddItem(int containerId, const ItemPtr& item, int slo
{
ContainerPtr container = getContainer(containerId);
if(!container) {
g_logger.traceError("container not found");
return;
}
@@ -333,7 +335,6 @@ void Game::processContainerUpdateItem(int containerId, int slot, const ItemPtr&
{
ContainerPtr container = getContainer(containerId);
if(!container) {
g_logger.traceError("container not found");
return;
}
@@ -344,7 +345,6 @@ void Game::processContainerRemoveItem(int containerId, int slot, const ItemPtr&
{
ContainerPtr container = getContainer(containerId);
if(!container) {
g_logger.traceError("container not found");
return;
}
@@ -528,7 +528,7 @@ void Game::processWalkCancel(Otc::Direction direction)
m_localPlayer->cancelWalk(direction);
}
void Game::loginWorld(const std::string& account, const std::string& password, const std::string& worldName, const std::string& worldHost, int worldPort, const std::string& characterName)
void Game::loginWorld(const std::string& account, const std::string& password, const std::string& worldName, const std::string& worldHost, int worldPort, const std::string& characterName, const std::string& authenticatorToken, const std::string& sessionKey)
{
if(m_protocolGame || isOnline())
stdext::throw_exception("Unable to login into a world while already online or logging.");
@@ -543,7 +543,7 @@ void Game::loginWorld(const std::string& account, const std::string& password, c
m_localPlayer->setName(characterName);
m_protocolGame = ProtocolGamePtr(new ProtocolGame);
m_protocolGame->login(account, password, worldHost, (uint16)worldPort, characterName);
m_protocolGame->login(account, password, worldHost, (uint16)worldPort, characterName, authenticatorToken, sessionKey);
m_characterName = characterName;
m_worldName = worldName;
}
@@ -854,7 +854,7 @@ void Game::useWith(const ItemPtr& item, const ThingPtr& toThing)
Position pos = item->getPosition();
if(!pos.isValid()) // virtual item
pos = Position(0xFFFF, 0, 0); // means that is a item in inventory
pos = Position(0xFFFF, 0, 0); // means that is an item in inventory
m_protocolGame->sendUseItemWith(pos, item->getId(), item->getStackPos(), toThing->getPosition(), toThing->getId(), toThing->getStackPos());
}
@@ -1204,6 +1204,31 @@ void Game::setPVPMode(Otc::PVPModes pvpMode)
g_lua.callGlobalField("g_game", "onPVPModeChange", pvpMode);
}
void Game::setUnjustifiedPoints(UnjustifiedPoints unjustifiedPoints)
{
if(!canPerformGameAction())
return;
if(!getFeature(Otc::GameUnjustifiedPoints))
return;
if(m_unjustifiedPoints == unjustifiedPoints)
return;
m_unjustifiedPoints = unjustifiedPoints;
g_lua.callGlobalField("g_game", "onUnjustifiedPointsChange", unjustifiedPoints);
}
void Game::setOpenPvpSituations(int openPvpSituations)
{
if(!canPerformGameAction())
return;
if(m_openPvpSituations == openPvpSituations)
return;
m_openPvpSituations = openPvpSituations;
g_lua.callGlobalField("g_game", "onOpenPvpSituationsChange", openPvpSituations);
}
void Game::inspectNpcTrade(const ItemPtr& item)
{
if(!canPerformGameAction() || !item)
@@ -1425,7 +1450,7 @@ void Game::setProtocolVersion(int version)
if(isOnline())
stdext::throw_exception("Unable to change protocol version while online");
if(version != 0 && (version < 740 || version > 1051))
if(version != 0 && (version < 740 || version > 1076))
stdext::throw_exception(stdext::format("Protocol version %d not supported", version));
m_protocolVersion = version;
@@ -1443,7 +1468,7 @@ void Game::setClientVersion(int version)
if(isOnline())
stdext::throw_exception("Unable to change client version while online");
if(version != 0 && (version < 740 || version > 1051))
if(version != 0 && (version < 740 || version > 1076))
stdext::throw_exception(stdext::format("Client version %d not supported", version));
m_features.reset();
@@ -1452,6 +1477,7 @@ void Game::setClientVersion(int version)
if(version >= 770) {
enableFeature(Otc::GameLooktypeU16);
enableFeature(Otc::GameMessageStatements);
enableFeature(Otc::GameLoginPacketEncryption);
}
if(version >= 780) {
@@ -1475,6 +1501,7 @@ void Game::setClientVersion(int version)
if(version >= 841) {
enableFeature(Otc::GameChallengeOnLogin);
enableFeature(Otc::GameMessageSizeCheck);
}
if(version >= 854) {
@@ -1523,6 +1550,11 @@ void Game::setClientVersion(int version)
enableFeature(Otc::GameAdditionalVipInfo);
}
if(version >= 980) {
enableFeature(Otc::GamePreviewState);
enableFeature(Otc::GameClientVersion);
}
if(version >= 981) {
enableFeature(Otc::GameLoginPending);
enableFeature(Otc::GameNewSpeedLaw);
@@ -1538,7 +1570,7 @@ void Game::setClientVersion(int version)
enableFeature(Otc::GamePVPMode);
}
if (version >= 1035) {
if(version >= 1035) {
enableFeature(Otc::GameDoubleSkills);
enableFeature(Otc::GameBaseSkillU16);
}
@@ -1556,6 +1588,34 @@ void Game::setClientVersion(int version)
enableFeature(Otc::GameEnhancedAnimations);
}
if(version >= 1053) {
enableFeature(Otc::GameUnjustifiedPoints);
}
if(version >= 1054) {
enableFeature(Otc::GameExperienceBonus);
}
if(version >= 1055) {
enableFeature(Otc::GameDeathType);
}
if(version >= 1061) {
enableFeature(Otc::GameOGLInformation);
}
if(version >= 1071) {
enableFeature(Otc::GameContentRevision);
}
if(version >= 1072) {
enableFeature(Otc::GameAuthenticator);
}
if(version >= 1074) {
enableFeature(Otc::GameSessionKey);
}
m_clientVersion = version;
g_lua.callGlobalField("g_game", "onClientVersionChange", version);

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 OTClient <https://github.com/edubart/otclient>
* Copyright (c) 2010-2015 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -36,6 +36,25 @@
#include <bitset>
struct UnjustifiedPoints {
bool operator==(const UnjustifiedPoints& other) {
return killsDay == other.killsDay &&
killsDayRemaining == other.killsDayRemaining &&
killsWeek == other.killsWeek &&
killsWeekRemaining == other.killsWeekRemaining &&
killsMonth == other.killsMonth &&
killsMonthRemaining == other.killsMonthRemaining &&
skullTime == other.skullTime;
}
uint8 killsDay;
uint8 killsDayRemaining;
uint8 killsWeek;
uint8 killsWeekRemaining;
uint8 killsMonth;
uint8 killsMonthRemaining;
uint8 skullTime;
};
typedef std::tuple<std::string, uint, std::string, int, bool> Vip;
//@bindsingleton g_game
@@ -60,13 +79,14 @@ protected:
void processLoginError(const std::string& error);
void processLoginAdvice(const std::string& message);
void processLoginWait(const std::string& message, int time);
void processLoginToken(bool unknown);
void processLogin();
void processPendingGame();
void processEnterGame();
void processGameStart();
void processGameEnd();
void processDeath(int penality);
void processDeath(int deathType, int penality);
void processGMActions(const std::vector<uint8>& actions);
void processInventoryChange(int slot, const ItemPtr& item);
@@ -139,7 +159,7 @@ protected:
public:
// login related
void loginWorld(const std::string& account, const std::string& password, const std::string& worldName, const std::string& worldHost, int worldPort, const std::string& characterName);
void loginWorld(const std::string& account, const std::string& password, const std::string& worldName, const std::string& worldHost, int worldPort, const std::string& characterName, const std::string& authenticatorToken, const std::string& sessionKey);
void cancelLogin();
void forceLogout();
void safeLogout();
@@ -218,6 +238,12 @@ public:
bool isSafeFight() { return m_safeFight; }
Otc::PVPModes getPVPMode() { return m_pvpMode; }
// pvp related
void setUnjustifiedPoints(UnjustifiedPoints unjustifiedPoints);
UnjustifiedPoints getUnjustifiedPoints() { return m_unjustifiedPoints; };
void setOpenPvpSituations(int openPvpSitations);
int getOpenPvpSituations() { return m_openPvpSituations; }
// npc trade related
void inspectNpcTrade(const ItemPtr& item);
void buyItem(const ItemPtr& item, int amount, bool ignoreCapacity, bool buyWithBackpack);
@@ -304,6 +330,8 @@ public:
int getServerBeat() { return m_serverBeat; }
void setCanReportBugs(bool enable) { m_canReportBugs = enable; }
bool canReportBugs() { return m_canReportBugs; }
void setExpertPvpMode(bool enable) { m_expertPvpMode = enable; }
bool getExpertPvpMode() { return m_expertPvpMode; }
LocalPlayerPtr getLocalPlayer() { return m_localPlayer; }
ProtocolGamePtr getProtocolGame() { return m_protocolGame; }
std::string getCharacterName() { return m_characterName; }
@@ -333,6 +361,7 @@ private:
bool m_online;
bool m_denyBotCall;
bool m_dead;
bool m_expertPvpMode;
int m_serverBeat;
ticks_t m_ping;
uint m_pingSent;
@@ -345,6 +374,8 @@ private:
Otc::ChaseModes m_chaseMode;
Otc::PVPModes m_pvpMode;
Otc::Direction m_lastWalkDir;
UnjustifiedPoints m_unjustifiedPoints;
int m_openPvpSituations;
bool m_safeFight;
bool m_canReportBugs;
std::vector<uint8> m_gmActions;

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 OTClient <https://github.com/edubart/otclient>
* Copyright (c) 2010-2015 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 OTClient <https://github.com/edubart/otclient>
* Copyright (c) 2010-2015 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 OTClient <https://github.com/edubart/otclient>
* Copyright (c) 2010-2015 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 OTClient <https://github.com/edubart/otclient>
* Copyright (c) 2010-2015 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -382,6 +382,9 @@ int Item::calculateAnimationPhase(bool animate)
{
if(getAnimationPhases() > 1) {
if(animate) {
if(getAnimator() != nullptr)
return getAnimator()->getPhase();
if(m_async)
return (g_clock.millis() % (Otc::ITEM_TICKS_PER_FRAME * getAnimationPhases())) / Otc::ITEM_TICKS_PER_FRAME;
else {

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 OTClient <https://github.com/edubart/otclient>
* Copyright (c) 2010-2015 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 OTClient <https://github.com/edubart/otclient>
* Copyright (c) 2010-2015 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 OTClient <https://github.com/edubart/otclient>
* Copyright (c) 2010-2015 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 OTClient <https://github.com/edubart/otclient>
* Copyright (c) 2010-2015 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 OTClient <https://github.com/edubart/otclient>
* Copyright (c) 2010-2015 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 OTClient <https://github.com/edubart/otclient>
* Copyright (c) 2010-2015 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -31,6 +31,7 @@ LocalPlayer::LocalPlayer()
{
m_states = 0;
m_vocation = 0;
m_blessings = Otc::BlessingNone;
m_walkLockExpiration = 0;
m_skillsLevel.fill(-1);
@@ -506,16 +507,6 @@ void LocalPlayer::setPremium(bool premium)
}
}
void LocalPlayer::setBaseSpeed(double baseSpeed)
{
if(m_baseSpeed != baseSpeed) {
double oldBaseSpeed = m_baseSpeed;
m_baseSpeed = baseSpeed;
callLuaField("onBaseSpeedChange", baseSpeed, oldBaseSpeed);
}
}
void LocalPlayer::setRegenerationTime(double regenerationTime)
{
if(m_regenerationTime != regenerationTime) {
@@ -546,6 +537,16 @@ void LocalPlayer::setSpells(const std::vector<int>& spells)
}
}
void LocalPlayer::setBlessings(int blessings)
{
if(blessings != m_blessings) {
int oldBlessings = m_blessings;
m_blessings = blessings;
callLuaField("onBlessingsChange", blessings, oldBlessings);
}
}
bool LocalPlayer::hasSight(const Position& pos)
{
return m_position.isInRange(pos, g_map.getAwareRange().left - 1, g_map.getAwareRange().top - 1);

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 OTClient <https://github.com/edubart/otclient>
* Copyright (c) 2010-2015 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -59,10 +59,10 @@ public:
void setInventoryItem(Otc::InventorySlot inventory, const ItemPtr& item);
void setVocation(int vocation);
void setPremium(bool premium);
void setBaseSpeed(double baseSpeed);
void setRegenerationTime(double regenerationTime);
void setOfflineTrainingTime(double offlineTrainingTime);
void setSpells(const std::vector<int>& spells);
void setBlessings(int blessings);
int getStates() { return m_states; }
int getSkillLevel(Otc::Skill skill) { return m_skillsLevel[skill]; }
@@ -83,11 +83,11 @@ public:
double getBaseMagicLevel() { return m_baseMagicLevel; }
double getSoul() { return m_soul; }
double getStamina() { return m_stamina; }
double getBaseSpeed() { return m_baseSpeed; }
double getRegenerationTime() { return m_regenerationTime; }
double getOfflineTrainingTime() { return m_offlineTrainingTime; }
std::vector<int> getSpells() { return m_spells; }
ItemPtr getInventoryItem(Otc::InventorySlot inventory) { return m_inventoryItems[inventory]; }
int getBlessings() { return m_blessings; }
bool hasSight(const Position& pos);
bool isKnown() { return m_known; }
@@ -144,6 +144,7 @@ private:
int m_states;
int m_vocation;
int m_blessings;
double m_health;
double m_maxHealth;
@@ -159,7 +160,6 @@ private:
double m_baseMagicLevel;
double m_soul;
double m_stamina;
double m_baseSpeed;
double m_regenerationTime;
double m_offlineTrainingTime;
};

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 OTClient <https://github.com/edubart/otclient>
* Copyright (c) 2010-2015 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -63,6 +63,7 @@ void Client::registerLuaFunctions()
g_lua.bindSingletonFunction("g_things", "isDatLoaded", &ThingTypeManager::isDatLoaded, &g_things);
g_lua.bindSingletonFunction("g_things", "isOtbLoaded", &ThingTypeManager::isOtbLoaded, &g_things);
g_lua.bindSingletonFunction("g_things", "getDatSignature", &ThingTypeManager::getDatSignature, &g_things);
g_lua.bindSingletonFunction("g_things", "getContentRevision", &ThingTypeManager::getContentRevision, &g_things);
g_lua.bindSingletonFunction("g_things", "getThingType", &ThingTypeManager::getThingType, &g_things);
g_lua.bindSingletonFunction("g_things", "getItemType", &ThingTypeManager::getItemType, &g_things);
g_lua.bindSingletonFunction("g_things", "getThingTypes", &ThingTypeManager::getThingTypes, &g_things);
@@ -237,6 +238,8 @@ void Client::registerLuaFunctions()
g_lua.bindSingletonFunction("g_game", "getChaseMode", &Game::getChaseMode, &g_game);
g_lua.bindSingletonFunction("g_game", "getFightMode", &Game::getFightMode, &g_game);
g_lua.bindSingletonFunction("g_game", "getPVPMode", &Game::getPVPMode, &g_game);
g_lua.bindSingletonFunction("g_game", "getUnjustifiedPoints", &Game::getUnjustifiedPoints, &g_game);
g_lua.bindSingletonFunction("g_game", "getOpenPvpSituations", &Game::getOpenPvpSituations, &g_game);
g_lua.bindSingletonFunction("g_game", "isSafeFight", &Game::isSafeFight, &g_game);
g_lua.bindSingletonFunction("g_game", "inspectNpcTrade", &Game::inspectNpcTrade, &g_game);
g_lua.bindSingletonFunction("g_game", "buyItem", &Game::buyItem, &g_game);
@@ -439,6 +442,7 @@ void Client::registerLuaFunctions()
g_lua.bindClassMemberFunction<Creature>("getName", &Creature::getName);
g_lua.bindClassMemberFunction<Creature>("getHealthPercent", &Creature::getHealthPercent);
g_lua.bindClassMemberFunction<Creature>("getSpeed", &Creature::getSpeed);
g_lua.bindClassMemberFunction<Creature>("getBaseSpeed", &Creature::getBaseSpeed);
g_lua.bindClassMemberFunction<Creature>("getSkull", &Creature::getSkull);
g_lua.bindClassMemberFunction<Creature>("getShield", &Creature::getShield);
g_lua.bindClassMemberFunction<Creature>("getEmblem", &Creature::getEmblem);
@@ -625,11 +629,11 @@ void Client::registerLuaFunctions()
g_lua.bindClassMemberFunction<LocalPlayer>("getStamina", &LocalPlayer::getStamina);
g_lua.bindClassMemberFunction<LocalPlayer>("getOfflineTrainingTime", &LocalPlayer::getOfflineTrainingTime);
g_lua.bindClassMemberFunction<LocalPlayer>("getRegenerationTime", &LocalPlayer::getRegenerationTime);
g_lua.bindClassMemberFunction<LocalPlayer>("getBaseSpeed", &LocalPlayer::getBaseSpeed);
g_lua.bindClassMemberFunction<LocalPlayer>("getBaseMagicLevel", &LocalPlayer::getBaseMagicLevel);
g_lua.bindClassMemberFunction<LocalPlayer>("getTotalCapacity", &LocalPlayer::getTotalCapacity);
g_lua.bindClassMemberFunction<LocalPlayer>("getInventoryItem", &LocalPlayer::getInventoryItem);
g_lua.bindClassMemberFunction<LocalPlayer>("getVocation", &LocalPlayer::getVocation);
g_lua.bindClassMemberFunction<LocalPlayer>("getBlessings", &LocalPlayer::getBlessings);
g_lua.bindClassMemberFunction<LocalPlayer>("isPremium", &LocalPlayer::isPremium);
g_lua.bindClassMemberFunction<LocalPlayer>("isKnown", &LocalPlayer::isKnown);
g_lua.bindClassMemberFunction<LocalPlayer>("isPreWalking", &LocalPlayer::isPreWalking);

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 OTClient <https://github.com/edubart/otclient>
* Copyright (c) 2010-2015 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -165,3 +165,45 @@ bool luavalue_cast(int index, Light& light)
}
return false;
}
int push_luavalue(const UnjustifiedPoints& unjustifiedPoints)
{
g_lua.createTable(0, 7);
g_lua.pushInteger(unjustifiedPoints.killsDay);
g_lua.setField("killsDay");
g_lua.pushInteger(unjustifiedPoints.killsDayRemaining);
g_lua.setField("killsDayRemaining");
g_lua.pushInteger(unjustifiedPoints.killsWeek);
g_lua.setField("killsWeek");
g_lua.pushInteger(unjustifiedPoints.killsWeekRemaining);
g_lua.setField("killsWeekRemaining");
g_lua.pushInteger(unjustifiedPoints.killsMonth);
g_lua.setField("killsMonth");
g_lua.pushInteger(unjustifiedPoints.killsMonthRemaining);
g_lua.setField("killsMonthRemaining");
g_lua.pushInteger(unjustifiedPoints.skullTime);
g_lua.setField("skullTime");
return 1;
}
bool luavalue_cast(int index, UnjustifiedPoints& unjustifiedPoints)
{
if(g_lua.isTable(index)) {
g_lua.getField("killsDay", index);
unjustifiedPoints.killsDay = g_lua.popInteger();
g_lua.getField("killsDayRemaining", index);
unjustifiedPoints.killsDayRemaining = g_lua.popInteger();
g_lua.getField("killsWeek", index);
unjustifiedPoints.killsWeek = g_lua.popInteger();
g_lua.getField("killsWeekRemaining", index);
unjustifiedPoints.killsWeekRemaining = g_lua.popInteger();
g_lua.getField("killsMonth", index);
unjustifiedPoints.killsMonth = g_lua.popInteger();
g_lua.getField("killsMonthRemaining", index);
unjustifiedPoints.killsMonthRemaining = g_lua.popInteger();
g_lua.getField("skullTime", index);
unjustifiedPoints.skullTime = g_lua.popInteger();
return true;
}
return false;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 OTClient <https://github.com/edubart/otclient>
* Copyright (c) 2010-2015 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -44,4 +44,8 @@ bool luavalue_cast(int index, MarketData& data);
int push_luavalue(const Light& light);
bool luavalue_cast(int index, Light& light);
// unjustified points
int push_luavalue(const UnjustifiedPoints& unjustifiedPoints);
bool luavalue_cast(int index, UnjustifiedPoints& unjustifiedPoints);
#endif

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 OTClient <https://github.com/edubart/otclient>
* Copyright (c) 2010-2015 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 OTClient <https://github.com/edubart/otclient>
* Copyright (c) 2010-2015 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 OTClient <https://github.com/edubart/otclient>
* Copyright (c) 2010-2015 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 OTClient <https://github.com/edubart/otclient>
* Copyright (c) 2010-2015 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 OTClient <https://github.com/edubart/otclient>
* Copyright (c) 2010-2015 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 OTClient <https://github.com/edubart/otclient>
* Copyright (c) 2010-2015 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 OTClient <https://github.com/edubart/otclient>
* Copyright (c) 2010-2015 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 OTClient <https://github.com/edubart/otclient>
* Copyright (c) 2010-2015 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 OTClient <https://github.com/edubart/otclient>
* Copyright (c) 2010-2015 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 OTClient <https://github.com/edubart/otclient>
* Copyright (c) 2010-2015 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 OTClient <https://github.com/edubart/otclient>
* Copyright (c) 2010-2015 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 OTClient <https://github.com/edubart/otclient>
* Copyright (c) 2010-2015 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 OTClient <https://github.com/edubart/otclient>
* Copyright (c) 2010-2015 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 OTClient <https://github.com/edubart/otclient>
* Copyright (c) 2010-2015 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 OTClient <https://github.com/edubart/otclient>
* Copyright (c) 2010-2015 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -28,7 +28,52 @@ std::map<uint8, uint8> messageModesMap;
void buildMessageModesMap(int version) {
messageModesMap.clear();
if(version >= 1036) {
if(version >= 1055) { // might be 1054
messageModesMap[Otc::MessageNone] = 0;
messageModesMap[Otc::MessageSay] = 1;
messageModesMap[Otc::MessageWhisper] = 2;
messageModesMap[Otc::MessageYell] = 3;
messageModesMap[Otc::MessagePrivateFrom] = 4;
messageModesMap[Otc::MessagePrivateTo] = 5;
messageModesMap[Otc::MessageChannelManagement] = 6;
messageModesMap[Otc::MessageChannel] = 7;
messageModesMap[Otc::MessageChannelHighlight] = 8;
messageModesMap[Otc::MessageSpell] = 9;
messageModesMap[Otc::MessageNpcFromStartBlock] = 10;
messageModesMap[Otc::MessageNpcFrom] = 11;
messageModesMap[Otc::MessageNpcTo] = 12;
messageModesMap[Otc::MessageGamemasterBroadcast] = 13;
messageModesMap[Otc::MessageGamemasterChannel] = 14;
messageModesMap[Otc::MessageGamemasterPrivateFrom] = 15;
messageModesMap[Otc::MessageGamemasterPrivateTo] = 16;
messageModesMap[Otc::MessageLogin] = 17;
messageModesMap[Otc::MessageWarning] = 18; // Admin
messageModesMap[Otc::MessageGame] = 19;
messageModesMap[Otc::MessageGameHighlight] = 20;
messageModesMap[Otc::MessageFailure] = 21;
messageModesMap[Otc::MessageLook] = 22;
messageModesMap[Otc::MessageDamageDealed] = 23;
messageModesMap[Otc::MessageDamageReceived] = 24;
messageModesMap[Otc::MessageHeal] = 25;
messageModesMap[Otc::MessageExp] = 26;
messageModesMap[Otc::MessageDamageOthers] = 27;
messageModesMap[Otc::MessageHealOthers] = 28;
messageModesMap[Otc::MessageExpOthers] = 29;
messageModesMap[Otc::MessageStatus] = 30;
messageModesMap[Otc::MessageLoot] = 31;
messageModesMap[Otc::MessageTradeNpc] = 32;
messageModesMap[Otc::MessageGuild] = 33;
messageModesMap[Otc::MessagePartyManagement] = 34;
messageModesMap[Otc::MessageParty] = 35;
messageModesMap[Otc::MessageBarkLow] = 36;
messageModesMap[Otc::MessageBarkLoud] = 37;
messageModesMap[Otc::MessageReport] = 38;
messageModesMap[Otc::MessageHotkeyUse] = 39;
messageModesMap[Otc::MessageTutorialHint] = 40;
messageModesMap[Otc::MessageThankyou] = 41;
messageModesMap[Otc::MessageMarket] = 42;
} else if(version >= 1036) {
for(int i = Otc::MessageNone; i <= Otc::MessageBeyondLast; ++i) {
if(i >= Otc::MessageNpcTo)
messageModesMap[i] = i + 1;

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 OTClient <https://github.com/edubart/otclient>
* Copyright (c) 2010-2015 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -50,6 +50,7 @@ namespace Proto {
GameServerLoginAdvice = 21,
GameServerLoginWait = 22,
GameServerLoginSuccess = 23,
GameServerLoginToken = 24,
GameServerPingBack = 29,
GameServerPing = 30,
GameServerChallenge = 31,
@@ -107,6 +108,8 @@ namespace Proto {
GameServerCreatureType = 149,
GameServerEditText = 150,
GameServerEditList = 151,
GameServerBlessings = 156,
GameServerPreset = 157,
GameServerPremiumTrigger = 158, // 1038
GameServerPlayerDataBasic = 159, // 950
GameServerPlayerData = 160,
@@ -130,6 +133,8 @@ namespace Proto {
GameServerTextMessage = 180,
GameServerCancelWalk = 181,
GameServerWalkWait = 182,
GameServerUnjustifiedStats = 183,
GameServerPvpSituations = 184,
GameServerFloorChangeUp = 190,
GameServerFloorChangeDown = 191,
GameServerChooseOutfit = 200,

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 OTClient <https://github.com/edubart/otclient>
* Copyright (c) 2010-2015 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -26,10 +26,12 @@
#include "item.h"
#include "localplayer.h"
void ProtocolGame::login(const std::string& accountName, const std::string& accountPassword, const std::string& host, uint16 port, const std::string& characterName)
void ProtocolGame::login(const std::string& accountName, const std::string& accountPassword, const std::string& host, uint16 port, const std::string& characterName, const std::string& authenticatorToken, const std::string& sessionKey)
{
m_accountName = accountName;
m_accountPassword = accountPassword;
m_authenticatorToken = authenticatorToken;
m_sessionKey = sessionKey;
m_characterName = characterName;
connect(host, port);
@@ -56,7 +58,7 @@ void ProtocolGame::onRecv(const InputMessagePtr& inputMessage)
if(m_firstRecv) {
m_firstRecv = false;
if(g_game.getClientVersion() >= 841) { // not sure since which version this is, but it seems to be after 8.40
if(g_game.getFeature(Otc::GameMessageSizeCheck)) {
int size = inputMessage->getU16();
if(size != inputMessage->getUnreadSize()) {
g_logger.traceError("invalid message size");

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 OTClient <https://github.com/edubart/otclient>
* Copyright (c) 2010-2015 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -31,7 +31,7 @@
class ProtocolGame : public Protocol
{
public:
void login(const std::string& accountName, const std::string& accountPassword, const std::string& host, uint16 port, const std::string& characterName);
void login(const std::string& accountName, const std::string& accountPassword, const std::string& host, uint16 port, const std::string& characterName, const std::string& authenticatorToken, const std::string& sessionKey);
void send(const OutputMessagePtr& outputMessage);
void sendExtendedOpcode(uint8 opcode, const std::string& buffer);
@@ -128,6 +128,10 @@ public:
void addPosition(const OutputMessagePtr& msg, const Position& position);
private:
void parseBlessings(const InputMessagePtr& msg);
void parseUnjustifiedStats(const InputMessagePtr& msg);
void parsePvpSituations(const InputMessagePtr& msg);
void parsePreset(const InputMessagePtr& msg);
void parseCreatureType(const InputMessagePtr& msg);
void parsePlayerHelpers(const InputMessagePtr& msg);
void parseMessage(const InputMessagePtr& msg);
@@ -139,6 +143,7 @@ private:
void parseLoginError(const InputMessagePtr& msg);
void parseLoginAdvice(const InputMessagePtr& msg);
void parseLoginWait(const InputMessagePtr& msg);
void parseLoginToken(const InputMessagePtr& msg);
void parsePing(const InputMessagePtr& msg);
void parsePingBack(const InputMessagePtr& msg);
void parseChallenge(const InputMessagePtr& msg);
@@ -242,6 +247,8 @@ private:
stdext::boolean<true> m_firstRecv;
std::string m_accountName;
std::string m_accountPassword;
std::string m_authenticatorToken;
std::string m_sessionKey;
std::string m_characterName;
LocalPlayerPtr m_localPlayer;
};

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 OTClient <https://github.com/edubart/otclient>
* Copyright (c) 2010-2015 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -79,6 +79,9 @@ void ProtocolGame::parseMessage(const InputMessagePtr& msg)
case Proto::GameServerLoginWait:
parseLoginWait(msg);
break;
case Proto::GameServerLoginToken:
parseLoginToken(msg);
break;
case Proto::GameServerPing:
case Proto::GameServerPingBack:
if((opcode == Proto::GameServerPing && g_game.getFeature(Otc::GameClientPing)) ||
@@ -340,6 +343,19 @@ void ProtocolGame::parseMessage(const InputMessagePtr& msg)
case Proto::GameServerCreatureType:
parseCreatureType(msg);
break;
// PROTOCOL>=1055
case Proto::GameServerBlessings:
parseBlessings(msg);
break;
case Proto::GameServerUnjustifiedStats:
parseUnjustifiedStats(msg);
break;
case Proto::GameServerPvpSituations:
parsePvpSituations(msg);
break;
case Proto::GameServerPreset:
parsePreset(msg);
break;
// otclient ONLY
case Proto::GameServerExtendedOpcode:
parseExtendedOpcode(msg);
@@ -372,6 +388,14 @@ void ProtocolGame::parseLogin(const InputMessagePtr& msg)
}
bool canReportBugs = msg->getU8();
if(g_game.getClientVersion() >= 1054)
msg->getU8(); // can change pvp frame option
if(g_game.getClientVersion() >= 1058) {
int expertModeEnabled = msg->getU8();
g_game.setExpertPvpMode(expertModeEnabled);
}
m_localPlayer->setId(playerId);
g_game.setServerBeat(serverBeat);
g_game.setCanReportBugs(canReportBugs);
@@ -396,6 +420,38 @@ void ProtocolGame::parseEnterGame(const InputMessagePtr& msg)
}
}
void ProtocolGame::parseBlessings(const InputMessagePtr& msg)
{
uint16 blessings = msg->getU16();
m_localPlayer->setBlessings(blessings);
}
void ProtocolGame::parsePreset(const InputMessagePtr& msg)
{
uint16 preset = msg->getU32();
}
void ProtocolGame::parseUnjustifiedStats(const InputMessagePtr& msg)
{
UnjustifiedPoints unjustifiedPoints;
unjustifiedPoints.killsDay = msg->getU8();
unjustifiedPoints.killsDayRemaining = msg->getU8();
unjustifiedPoints.killsWeek = msg->getU8();
unjustifiedPoints.killsWeekRemaining = msg->getU8();
unjustifiedPoints.killsMonth = msg->getU8();
unjustifiedPoints.killsMonthRemaining = msg->getU8();
unjustifiedPoints.skullTime = msg->getU8();
g_game.setUnjustifiedPoints(unjustifiedPoints);
}
void ProtocolGame::parsePvpSituations(const InputMessagePtr& msg)
{
uint8 openPvpSituations = msg->getU8();
g_game.setOpenPvpSituations(openPvpSituations);
}
void ProtocolGame::parsePlayerHelpers(const InputMessagePtr& msg)
{
uint id = msg->getU32();
@@ -454,6 +510,12 @@ void ProtocolGame::parseLoginWait(const InputMessagePtr& msg)
g_game.processLoginWait(message, time);
}
void ProtocolGame::parseLoginToken(const InputMessagePtr& msg)
{
bool unknown = (msg->getU8() == 0);
g_game.processLoginToken(unknown);
}
void ProtocolGame::parsePing(const InputMessagePtr& msg)
{
g_game.processPing();
@@ -468,15 +530,22 @@ void ProtocolGame::parseChallenge(const InputMessagePtr& msg)
{
uint timestamp = msg->getU32();
uint8 random = msg->getU8();
sendLoginPacket(timestamp, random);
}
void ProtocolGame::parseDeath(const InputMessagePtr& msg)
{
int penality = 100;
if(g_game.getFeature(Otc::GamePenalityOnDeath))
int deathType = Otc::DeathRegular;
if(g_game.getFeature(Otc::GameDeathType))
deathType = msg->getU8();
if(g_game.getFeature(Otc::GamePenalityOnDeath) && deathType == Otc::DeathRegular)
penality = msg->getU8();
g_game.processDeath(penality);
g_game.processDeath(deathType, penality);
}
void ProtocolGame::parseMapDescription(const InputMessagePtr& msg)
@@ -941,11 +1010,19 @@ void ProtocolGame::parseCreatureOutfit(const InputMessagePtr& msg)
void ProtocolGame::parseCreatureSpeed(const InputMessagePtr& msg)
{
uint id = msg->getU32();
int baseSpeed = -1;
if(g_game.getClientVersion() >= 1059)
baseSpeed = msg->getU16();
int speed = msg->getU16();
CreaturePtr creature = g_map.getCreatureById(id);
if(creature)
if(creature) {
creature->setSpeed(speed);
if(baseSpeed != -1)
creature->setBaseSpeed(baseSpeed);
}
// some servers has a bug in get spectators and sends unknown creatures updates
// so this code is disabled
@@ -1038,7 +1115,7 @@ void ProtocolGame::parsePlayerInfo(const InputMessagePtr& msg)
bool premium = msg->getU8(); // premium
int vocation = msg->getU8(); // vocation
if(g_game.getFeature(Otc::GamePremiumExpiration))
int premiumEx = msg->getU32(); // premium expiration
int premiumEx = msg->getU32(); // premium expiration used for premium advertisement
int spellCount = msg->getU16();
std::vector<int> spells;
@@ -1081,6 +1158,10 @@ void ProtocolGame::parsePlayerStats(const InputMessagePtr& msg)
double level = msg->getU16();
double levelPercent = msg->getU8();
if(g_game.getFeature(Otc::GameExperienceBonus))
double experienceBonus = msg->getDouble();
double mana;
double maxMana;
@@ -1145,7 +1226,7 @@ void ProtocolGame::parsePlayerSkills(const InputMessagePtr& msg)
int baseLevel;
if(g_game.getFeature(Otc::GameSkillsBase))
if (g_game.getFeature(Otc::GameBaseSkillU16))
if(g_game.getFeature(Otc::GameBaseSkillU16))
baseLevel = msg->getU16();
else
baseLevel = msg->getU8();
@@ -1242,6 +1323,7 @@ void ProtocolGame::parseTalk(const InputMessagePtr& msg)
case Otc::MessageBarkLow:
case Otc::MessageBarkLoud:
case Otc::MessageSpell:
case Otc::MessageNpcFromStartBlock:
pos = getPosition(msg);
break;
case Otc::MessageChannel:
@@ -1699,7 +1781,7 @@ void ProtocolGame::parseChangeMapAwareRange(const InputMessagePtr& msg)
void ProtocolGame::parseCreaturesMark(const InputMessagePtr& msg)
{
int len;
if (g_game.getClientVersion() >= 1035) {
if(g_game.getClientVersion() >= 1035) {
len = 1;
} else {
len = msg->getU8();

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 OTClient <https://github.com/edubart/otclient>
* Copyright (c) 2010-2015 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -56,17 +56,20 @@ void ProtocolGame::sendLoginPacket(uint challengeTimestamp, uint8 challengeRando
msg->addU16(g_game.getOs());
msg->addU16(g_game.getProtocolVersion());
if(g_game.getClientVersion() >= 980) {
if(g_game.getFeature(Otc::GameClientVersion))
msg->addU32(g_game.getClientVersion());
msg->addU8(0); // preview state
}
if(g_game.getFeature(Otc::GameContentRevision))
msg->addU16(g_things.getContentRevision());
if(g_game.getFeature(Otc::GamePreviewState))
msg->addU8(0);
int offset = msg->getMessageSize();
// first RSA byte must be 0
msg->addU8(0);
msg->addU8(0); // first RSA byte must be 0
if(g_game.getClientVersion() >= 770)
{
if(g_game.getFeature(Otc::GameLoginPacketEncryption)) {
// xtea key
generateXteaKey();
msg->addU32(m_xteaKey[0]);
@@ -76,13 +79,21 @@ void ProtocolGame::sendLoginPacket(uint challengeTimestamp, uint8 challengeRando
msg->addU8(0); // is gm set?
}
if(g_game.getFeature(Otc::GameAccountNames))
msg->addString(m_accountName);
else
msg->addU32(stdext::from_string<uint32>(m_accountName));
if(g_game.getFeature(Otc::GameSessionKey)) {
msg->addString(m_sessionKey);
msg->addString(m_characterName);
} else {
if(g_game.getFeature(Otc::GameAccountNames))
msg->addString(m_accountName);
else
msg->addU32(stdext::from_string<uint32>(m_accountName));
msg->addString(m_characterName);
msg->addString(m_accountPassword);
msg->addString(m_characterName);
msg->addString(m_accountPassword);
if(g_game.getFeature(Otc::GameAuthenticator))
msg->addString(m_authenticatorToken);
}
if(g_game.getFeature(Otc::GameChallengeOnLogin)) {
msg->addU32(challengeTimestamp);
@@ -99,7 +110,7 @@ void ProtocolGame::sendLoginPacket(uint challengeTimestamp, uint8 challengeRando
msg->addPaddingBytes(paddingBytes);
// encrypt with RSA
if(g_game.getClientVersion() >= 770)
if(g_game.getFeature(Otc::GameLoginPacketEncryption))
msg->encryptRsa();
if(g_game.getFeature(Otc::GameProtocolChecksum))
@@ -107,7 +118,7 @@ void ProtocolGame::sendLoginPacket(uint challengeTimestamp, uint8 challengeRando
send(msg);
if(g_game.getClientVersion() >= 770)
if(g_game.getFeature(Otc::GameLoginPacketEncryption))
enableXteaEncryption();
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 OTClient <https://github.com/edubart/otclient>
* Copyright (c) 2010-2015 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 OTClient <https://github.com/edubart/otclient>
* Copyright (c) 2010-2015 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 OTClient <https://github.com/edubart/otclient>
* Copyright (c) 2010-2015 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 OTClient <https://github.com/edubart/otclient>
* Copyright (c) 2010-2015 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 OTClient <https://github.com/edubart/otclient>
* Copyright (c) 2010-2015 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 OTClient <https://github.com/edubart/otclient>
* Copyright (c) 2010-2015 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 OTClient <https://github.com/edubart/otclient>
* Copyright (c) 2010-2015 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 OTClient <https://github.com/edubart/otclient>
* Copyright (c) 2010-2015 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -74,7 +74,7 @@ public:
int getNumPatternY() { return rawGetThingType()->getNumPatternY(); }
int getNumPatternZ() { return rawGetThingType()->getNumPatternZ(); }
int getAnimationPhases() { return rawGetThingType()->getAnimationPhases(); }
Animation getAnimation() { return rawGetThingType()->getAnimation(); }
AnimatorPtr getAnimator() { return rawGetThingType()->getAnimator(); }
int getGroundSpeed() { return rawGetThingType()->getGroundSpeed(); }
int getMaxTextLength() { return rawGetThingType()->getMaxTextLength(); }
Light getLight() { return rawGetThingType()->getLight(); }

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 OTClient <https://github.com/edubart/otclient>
* Copyright (c) 2010-2015 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -39,6 +39,7 @@ ThingType::ThingType()
m_null = true;
m_exactSize = 0;
m_realSize = 0;
m_animator = nullptr;
m_numPatternX = m_numPatternY = m_numPatternZ = 0;
m_animationPhases = 0;
m_layers = 0;
@@ -58,7 +59,7 @@ void ThingType::serialize(const FileStreamPtr& fin)
attr = ThingAttrWritable;
else if(attr >= ThingAttrWritable)
attr += 1;
} else if(g_game.getClientVersion() >= 1010) {
} else if(g_game.getClientVersion() >= 1000) {
if(attr == ThingAttrNoMoveAnimation)
attr = 16;
else if(attr >= ThingAttrPickupable)
@@ -117,15 +118,8 @@ void ThingType::serialize(const FileStreamPtr& fin)
fin->addU8(m_animationPhases);
if(g_game.getFeature(Otc::GameEnhancedAnimations)) {
if(m_animationPhases > 1) {
fin->addU8(m_animation.async ? 0 : 1);
fin->add32(m_animation.loopCount);
fin->addU8(m_animation.startIndex);
for(std::tuple<int, int> frame : m_animation.frames) {
fin->addU32(std::get<0>(frame));
fin->addU32(std::get<1>(frame));
}
if(m_animationPhases > 1 && m_animator != nullptr) {
m_animator->serialize(fin);
}
}
@@ -153,7 +147,7 @@ void ThingType::unserialize(uint16 clientId, ThingCategory category, const FileS
break;
}
if(g_game.getClientVersion() >= 1010) {
if(g_game.getClientVersion() >= 1000) {
/* In 10.10+ all attributes from 16 and up were
* incremented by 1 to make space for 16 as
* "No Movement Animation" flag.
@@ -274,51 +268,50 @@ void ThingType::unserialize(uint16 clientId, ThingCategory category, const FileS
stdext::throw_exception(stdext::format("corrupt data (id: %d, category: %d, count: %d, lastAttr: %d)",
m_id, m_category, count, attr));
uint8 width = fin->getU8();
uint8 height = fin->getU8();
m_size = Size(width, height);
if(width > 1 || height > 1) {
m_realSize = fin->getU8();
m_exactSize = std::min<int>(m_realSize, std::max<int>(width * 32, height * 32));
}
else
m_exactSize = 32;
uint8 groupCount = 1;
if(category == ThingCategoryCreature && g_game.getClientVersion() >= 1057)
groupCount = fin->getU8();
m_layers = fin->getU8();
m_numPatternX = fin->getU8();
m_numPatternY = fin->getU8();
if(g_game.getClientVersion() >= 755)
m_numPatternZ = fin->getU8();
else
m_numPatternZ = 1;
m_animationPhases = fin->getU8();
if(g_game.getFeature(Otc::GameEnhancedAnimations)) {
if(m_animationPhases > 1) {
m_animation.async = fin->getU8() == 0;
m_animation.loopCount = fin->get32();
m_animation.startIndex = fin->getU8();
for(int i = 0; i < m_animationPhases; i++) {
int minDuration = fin->getU32();
int maxDuration = fin->getU32();
m_animation.frames.push_back(std::make_tuple(minDuration, maxDuration));
}
for(int i = 0; i < groupCount; ++i) {
uint8 frameGroup = FrameGroupDefault;
if(category == ThingCategoryCreature && g_game.getClientVersion() >= 1057) {
frameGroup = fin->getU8();
}
uint8 width = fin->getU8();
uint8 height = fin->getU8();
m_size = Size(width, height);
if(width > 1 || height > 1) {
m_realSize = fin->getU8();
m_exactSize = std::min<int>(m_realSize, std::max<int>(width * 32, height * 32));
}
else
m_exactSize = 32;
m_layers = fin->getU8();
m_numPatternX = fin->getU8();
m_numPatternY = fin->getU8();
if(g_game.getClientVersion() >= 755)
m_numPatternZ = fin->getU8();
else
m_numPatternZ = 1;
m_animationPhases = fin->getU8();
if(m_animationPhases > 1 && g_game.getFeature(Otc::GameEnhancedAnimations)) {
m_animator = AnimatorPtr(new Animator);
m_animator->unserialize(m_animationPhases, fin);
}
int totalSprites = m_size.area() * m_layers * m_numPatternX * m_numPatternY * m_numPatternZ * m_animationPhases;
if(totalSprites > 4096)
stdext::throw_exception("a thing type has more than 4096 sprites");
m_spritesIndex.resize(totalSprites);
for(int i = 0; i < totalSprites; i++)
m_spritesIndex[i] = g_game.getFeature(Otc::GameSpritesU32) ? fin->getU32() : fin->getU16();
}
int totalSprites = m_size.area() * m_layers * m_numPatternX * m_numPatternY * m_numPatternZ * m_animationPhases;
// if(totalSprites == 0)
// stdext::throw_exception("a thing type has no sprites");
if(totalSprites > 4096)
stdext::throw_exception("a thing type has more than 4096 sprites");
m_spritesIndex.resize(totalSprites);
for(int i = 0; i < totalSprites; i++)
m_spritesIndex[i] = g_game.getFeature(Otc::GameSpritesU32) ? fin->getU32() : fin->getU16();
m_textures.resize(m_animationPhases);
m_texturesFramesRects.resize(m_animationPhases);
m_texturesFramesOriginRects.resize(m_animationPhases);

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 OTClient <https://github.com/edubart/otclient>
* Copyright (c) 2010-2015 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -24,6 +24,7 @@
#define THINGTYPE_H
#include "declarations.h"
#include "animator.h"
#include <framework/core/declarations.h>
#include <framework/otml/declarations.h>
@@ -32,6 +33,12 @@
#include <framework/luaengine/luaobject.h>
#include <framework/net/server.h>
enum FrameGroup : uint8 {
FrameGroupIdle = 0,
FrameGroupMoving,
FrameGroupDefault = FrameGroupIdle
};
enum ThingCategory : uint8 {
ThingCategoryItem = 0,
ThingCategoryCreature,
@@ -110,21 +117,6 @@ struct Light {
uint8 color;
};
struct Animation {
Animation() { startIndex = 0; loopCount = 0; async = false; }
int startIndex;
int loopCount;
bool async;
std::vector<std::tuple<int, int> > frames;
float duration(uint8 frame) {
assert(frames.size() <= frame);
std::tuple<int, int> data = frames.at(frame);
return stdext::random_range((long)std::get<0>(data), (long)std::get<1>(data));
}
};
class ThingType : public LuaObject
{
public:
@@ -153,7 +145,7 @@ public:
int getNumPatternY() { return m_numPatternY; }
int getNumPatternZ() { return m_numPatternZ; }
int getAnimationPhases() { return m_animationPhases; }
Animation getAnimation() { return m_animation; }
AnimatorPtr getAnimator() { return m_animator; }
Point getDisplacement() { return m_displacement; }
int getDisplacementX() { return getDisplacement().x; }
int getDisplacementY() { return getDisplacement().y; }
@@ -220,7 +212,7 @@ private:
Size m_size;
Point m_displacement;
Animation m_animation;
AnimatorPtr m_animator;
int m_animationPhases;
int m_exactSize;
int m_realSize;

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 OTClient <https://github.com/edubart/otclient>
* Copyright (c) 2010-2015 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -42,6 +42,7 @@ void ThingTypeManager::init()
m_nullThingType = ThingTypePtr(new ThingType);
m_nullItemType = ItemTypePtr(new ItemType);
m_datSignature = 0;
m_contentRevision = 0;
m_otbMinorVersion = 0;
m_otbMajorVersion = 0;
m_datLoaded = false;
@@ -100,12 +101,14 @@ bool ThingTypeManager::loadDat(std::string file)
{
m_datLoaded = false;
m_datSignature = 0;
m_contentRevision = 0;
try {
file = g_resources.guessFilePath(file, "dat");
FileStreamPtr fin = g_resources.openFile(file);
m_datSignature = fin->getU32();
m_contentRevision = static_cast<uint16_t>(m_datSignature);
for(int category = 0; category < ThingLastCategory; ++category) {
int count = fin->getU16() + 1;

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 OTClient <https://github.com/edubart/otclient>
* Copyright (c) 2010-2015 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -66,6 +66,7 @@ public:
uint32 getDatSignature() { return m_datSignature; }
uint32 getOtbMajorVersion() { return m_otbMajorVersion; }
uint32 getOtbMinorVersion() { return m_otbMinorVersion; }
uint16 getContentRevision() { return m_contentRevision; }
bool isDatLoaded() { return m_datLoaded; }
bool isXmlLoaded() { return m_xmlLoaded; }
@@ -89,6 +90,7 @@ private:
uint32 m_otbMinorVersion;
uint32 m_otbMajorVersion;
uint32 m_datSignature;
uint16 m_contentRevision;
};
extern ThingTypeManager g_things;

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 OTClient <https://github.com/edubart/otclient>
* Copyright (c) 2010-2015 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -485,7 +485,7 @@ ThingPtr Tile::getTopMultiUseThing()
for(uint i = 0; i < m_things.size(); ++i) {
ThingPtr thing = m_things[i];
if(!thing->isGround() && !thing->isGroundBorder() && !thing->isOnBottom() && !thing->isOnTop()) {
if(!thing->isGround() && !thing->isOnBottom() && !thing->isOnTop()) {
if(i > 0 && thing->isSplash())
return m_things[i-1];
return thing;
@@ -494,7 +494,7 @@ ThingPtr Tile::getTopMultiUseThing()
for(uint i = 0; i < m_things.size(); ++i) {
ThingPtr thing = m_things[i];
if(!thing->isGround() && !thing->isGroundBorder() && !thing->isOnTop())
if(!thing->isGround() && !thing->isOnTop())
return thing;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 OTClient <https://github.com/edubart/otclient>
* Copyright (c) 2010-2015 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 OTClient <https://github.com/edubart/otclient>
* Copyright (c) 2010-2015 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 OTClient <https://github.com/edubart/otclient>
* Copyright (c) 2010-2015 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 OTClient <https://github.com/edubart/otclient>
* Copyright (c) 2010-2015 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 OTClient <https://github.com/edubart/otclient>
* Copyright (c) 2010-2015 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 OTClient <https://github.com/edubart/otclient>
* Copyright (c) 2010-2015 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 OTClient <https://github.com/edubart/otclient>
* Copyright (c) 2010-2015 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 OTClient <https://github.com/edubart/otclient>
* Copyright (c) 2010-2015 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 OTClient <https://github.com/edubart/otclient>
* Copyright (c) 2010-2015 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 OTClient <https://github.com/edubart/otclient>
* Copyright (c) 2010-2015 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 OTClient <https://github.com/edubart/otclient>
* Copyright (c) 2010-2015 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 OTClient <https://github.com/edubart/otclient>
* Copyright (c) 2010-2015 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 OTClient <https://github.com/edubart/otclient>
* Copyright (c) 2010-2015 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 OTClient <https://github.com/edubart/otclient>
* Copyright (c) 2010-2015 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 OTClient <https://github.com/edubart/otclient>
* Copyright (c) 2010-2015 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 OTClient <https://github.com/edubart/otclient>
* Copyright (c) 2010-2015 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 OTClient <https://github.com/edubart/otclient>
* Copyright (c) 2010-2015 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 OTClient <https://github.com/edubart/otclient>
* Copyright (c) 2010-2015 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 OTClient <https://github.com/edubart/otclient>
* Copyright (c) 2010-2015 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 OTClient <https://github.com/edubart/otclient>
* Copyright (c) 2010-2015 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 OTClient <https://github.com/edubart/otclient>
* Copyright (c) 2010-2015 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 OTClient <https://github.com/edubart/otclient>
* Copyright (c) 2010-2015 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 OTClient <https://github.com/edubart/otclient>
* Copyright (c) 2010-2015 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 OTClient <https://github.com/edubart/otclient>
* Copyright (c) 2010-2015 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 OTClient <https://github.com/edubart/otclient>
* Copyright (c) 2010-2015 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 OTClient <https://github.com/edubart/otclient>
* Copyright (c) 2010-2015 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 OTClient <https://github.com/edubart/otclient>
* Copyright (c) 2010-2015 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 OTClient <https://github.com/edubart/otclient>
* Copyright (c) 2010-2015 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 OTClient <https://github.com/edubart/otclient>
* Copyright (c) 2010-2015 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 OTClient <https://github.com/edubart/otclient>
* Copyright (c) 2010-2015 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 OTClient <https://github.com/edubart/otclient>
* Copyright (c) 2010-2015 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 OTClient <https://github.com/edubart/otclient>
* Copyright (c) 2010-2015 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 OTClient <https://github.com/edubart/otclient>
* Copyright (c) 2010-2015 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2010-2014 OTClient <https://github.com/edubart/otclient>
* Copyright (c) 2010-2015 OTClient <https://github.com/edubart/otclient>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal

Some files were not shown because too many files have changed in this diff Show More