Skip to content
This repository has been archived by the owner on May 20, 2023. It is now read-only.

Commit

Permalink
Protocol 12.20 (#1396)
Browse files Browse the repository at this point in the history
You'll need to change accountname to email in your login.php

This PR will only work with client 12.20

Credits to SaiyansKing & R1Ck

Thanks to majesty for login by email

Client 12.20:
https://mega.nz/file/7ip32B5T#uHrJwJWiMu6fLNtNqPHDdMdt2P8BUwmWMnCqYZnjIDg

Login.php to test:
GesiorAAC: https://github.com/opentibiabr/gesioraac-tibia12-login/releases/tag/1.1
MyAAC: https://github.com/opentibiabr/myaac-tibia12-login/releases/tag/1.4
  • Loading branch information
FakeShinoda authored Jul 13, 2020
1 parent 89ed8c6 commit eb7b04a
Show file tree
Hide file tree
Showing 11 changed files with 85 additions and 17 deletions.
1 change: 1 addition & 0 deletions data/modules/scripts/blessings/blessings.lua
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ Blessings.sendBlessDialog = function(player)
if v.type ~= Blessings.Types.PvP or Blessings.Config.HasToF then
msg:addU16(Blessings.BitWiseTable[v.id])
msg:addByte(player:getBlessingCount(v.id))
msg:addByte(0) -- Store Blessings Count
end
end

Expand Down
4 changes: 2 additions & 2 deletions src/definitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ static constexpr auto STATUS_SERVER_NAME = "OTServBR - Global";
static constexpr auto STATUS_SERVER_VERSION = "TFS 1.3";
static constexpr auto STATUS_SERVER_DEVELOPERS = "OTServBR, Mark Samman and The Forgotten Server Developers";

static constexpr auto CLIENT_VERSION = 1200;
static constexpr auto CLIENT_VERSION_STR = "12.00";
static constexpr auto CLIENT_VERSION = 1220;
static constexpr auto CLIENT_VERSION_STR = "12.20";

static constexpr auto AUTHENTICATOR_DIGITS = 6U;
static constexpr auto AUTHENTICATOR_PERIOD = 30U;
Expand Down
9 changes: 9 additions & 0 deletions src/enums.h
Original file line number Diff line number Diff line change
Expand Up @@ -680,4 +680,13 @@ enum Resource_t : uint8_t
RESOURCE_PREY = 0x0A,
};

enum MagicEffectsType_t : uint8_t {
MAGIC_EFFECTS_END_LOOP = 0,//ends magic effect loop
MAGIC_EFFECTS_DELTA = 1,//needs uint8_t delta after type to adjust position
MAGIC_EFFECTS_DELAY = 2,//needs uint16_t delay after type to delay in miliseconds effect display
MAGIC_EFFECTS_CREATE_EFFECT = 3,//needs uint8_t effectid after type
MAGIC_EFFECTS_CREATE_DISTANCEEFFECT = 4,//needs uint8_t and deltaX(int8_t), deltaY(int8_t) after type
MAGIC_EFFECTS_CREATE_DISTANCEEFFECT_REVERSED = 5,//needs uint8_t and deltaX(int8_t), deltaY(int8_t) after type
};

#endif
14 changes: 13 additions & 1 deletion src/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,18 @@ Thing* Game::internalGetThing(Player* player, const Position& pos, int32_t index
break;
}

case STACKPOS_FIND_THING: {
thing = tile->getUseItem(index);
if (!thing) {
thing = tile->getDoorItem();
}

if (!thing) {
thing = tile->getTopDownItem();
}
break;
}

default: {
thing = nullptr;
break;
Expand Down Expand Up @@ -2164,7 +2176,7 @@ void Game::playerUseItem(uint32_t playerId, const Position& pos, uint8_t stackPo
return;
}

Thing* thing = internalGetThing(player, pos, stackPos, spriteId, STACKPOS_USEITEM);
Thing* thing = internalGetThing(player, pos, stackPos, spriteId, STACKPOS_FIND_THING);
if (!thing) {
player->sendCancelMessage(RETURNVALUE_NOTPOSSIBLE);
return;
Expand Down
1 change: 1 addition & 0 deletions src/game.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ enum stackPosType_t {
STACKPOS_TOPDOWN_ITEM,
STACKPOS_USEITEM,
STACKPOS_USETARGET,
STACKPOS_FIND_THING,
};

enum WorldType_t {
Expand Down
4 changes: 2 additions & 2 deletions src/iologindata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,12 @@ bool IOLoginData::LoginServerAuthentication(const std::string& name,
return true;
}

uint32_t IOLoginData::gameworldAuthentication(const std::string& accountName, const std::string& password, std::string& characterName)
uint32_t IOLoginData::gameworldAuthentication(const std::string& email, const std::string& password, std::string& characterName)
{
Database& db = Database::getInstance();

std::ostringstream query;
query << "SELECT `id`, `password` FROM `accounts` WHERE `name` = " << db.escapeString(accountName);
query << "SELECT `id`, `password` FROM `accounts` WHERE `email` = " << db.escapeString(email);
DBResult_ptr result = db.storeQuery(query.str());
if (!result) {
std::cout << "[IOLoginData::gameworldAuthentication] Account not found!" << std::endl;
Expand Down
2 changes: 1 addition & 1 deletion src/player.h
Original file line number Diff line number Diff line change
Expand Up @@ -1609,7 +1609,7 @@ class Player final : public Creature, public Cylinder
tradestate_t tradeState = TRADE_NONE;
fightMode_t fightMode = FIGHTMODE_ATTACK;
account::AccountType accountType =
account::AccountType::ACCOUNT_TYPE_NORMAL;
account::AccountType::ACCOUNT_TYPE_NORMAL;

bool chaseMode = false;
bool secureMode = true;
Expand Down
45 changes: 35 additions & 10 deletions src/protocolgame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -792,16 +792,25 @@ void ProtocolGame::parseSetOutfit(NetworkMessage& msg)
}

if(msg.getBufferPosition() == startBufferPosition) {
uint8_t outfitType = 0;
outfitType = msg.getByte();
Outfit_t newOutfit;
newOutfit.lookType = msg.get<uint16_t>();
newOutfit.lookHead = msg.getByte();
newOutfit.lookBody = msg.getByte();
newOutfit.lookLegs = msg.getByte();
newOutfit.lookFeet = msg.getByte();
newOutfit.lookAddons = msg.getByte();
newOutfit.lookMount = msg.get<uint16_t>();
if (outfitType == 0) {
newOutfit.lookMount = msg.get<uint16_t>();
} else if (outfitType == 1) {
//This value probably has something to do with try outfit variable inside outfit window dialog
//if try outfit is set to 2 it expects uint32_t value after mounted and disable mounts from outfit window dialog
newOutfit.lookMount = 0;
msg.get<uint32_t>();
}
addGameTask(&Game::playerChangeOutfit, player->getID(), newOutfit);
}
}
}

void ProtocolGame::parseToggleMount(NetworkMessage& msg)
Expand Down Expand Up @@ -1716,6 +1725,8 @@ void ProtocolGame::sendContainer(uint8_t cid, const Container* container, bool h

msg.addByte(hasParent ? 0x01 : 0x00);

msg.addByte(0x00); // To-do: Depot Find (boolean)

msg.addByte(container->isUnlocked() ? 0x01 : 0x00); // Drag and drop
msg.addByte(container->hasPagination() ? 0x01 : 0x00); // Pagination

Expand Down Expand Up @@ -1750,6 +1761,7 @@ void ProtocolGame::sendShop(Npc* npc, const ShopInfoList& itemList)
NetworkMessage msg;
msg.addByte(0x7A);
msg.addString(npc->getName());
msg.add<uint16_t>(3031); // TO-DO Coin used

uint16_t itemsToSend = std::min<size_t>(itemList.size(), std::numeric_limits<uint16_t>::max());
msg.add<uint16_t>(itemsToSend);
Expand Down Expand Up @@ -1970,6 +1982,7 @@ void ProtocolGame::sendCoinBalance()

msg.add<uint32_t>(player->coinBalance); //total coins
msg.add<uint32_t>(player->coinBalance); //transferable coins
msg.add<uint32_t>(0); // Tournament Coins

writeToOutputBuffer(msg);
}
Expand Down Expand Up @@ -2569,10 +2582,13 @@ void ProtocolGame::sendPingBack()
void ProtocolGame::sendDistanceShoot(const Position& from, const Position& to, uint8_t type)
{
NetworkMessage msg;
msg.addByte(0x85);
msg.addByte(0x83);
msg.addPosition(from);
msg.addPosition(to);
msg.addByte(MAGIC_EFFECTS_CREATE_DISTANCEEFFECT);
msg.addByte(type);
msg.addByte(static_cast<uint8_t>(static_cast<int8_t>(static_cast<int32_t>(to.x) - static_cast<int32_t>(from.x))));
msg.addByte(static_cast<uint8_t>(static_cast<int8_t>(static_cast<int32_t>(to.y) - static_cast<int32_t>(from.y))));
msg.addByte(MAGIC_EFFECTS_END_LOOP);
writeToOutputBuffer(msg);
}

Expand All @@ -2585,7 +2601,9 @@ void ProtocolGame::sendMagicEffect(const Position& pos, uint8_t type)
NetworkMessage msg;
msg.addByte(0x83);
msg.addPosition(pos);
msg.addByte(MAGIC_EFFECTS_CREATE_EFFECT);
msg.addByte(type);
msg.addByte(MAGIC_EFFECTS_END_LOOP);
writeToOutputBuffer(msg);
}

Expand Down Expand Up @@ -2770,7 +2788,7 @@ void ProtocolGame::sendAddCreature(const Creature* creature, const Position& pos
msg.add<uint16_t>(static_cast<uint16_t>(g_config.getNumber(ConfigManager::STORE_COIN_PACKET)));

msg.addByte(shouldAddExivaRestrictions ? 0x01 : 0x00); // exiva button enabled
// msg.addByte(0x01); // tournament button enabled
msg.addByte(0x00); // tournament button

writeToOutputBuffer(msg);

Expand Down Expand Up @@ -3035,9 +3053,11 @@ void ProtocolGame::sendOutfitWindow()
NetworkMessage msg;
msg.addByte(0xC8);

bool mounted = false;
Outfit_t currentOutfit = player->getDefaultOutfit();
Mount* currentMount = g_game.mounts.getMountByID(player->getCurrentMount());
if (currentMount) {
mounted = (currentOutfit.lookMount == currentMount->clientId);
currentOutfit.lookMount = currentMount->clientId;
}

Expand Down Expand Up @@ -3088,8 +3108,8 @@ void ProtocolGame::sendOutfitWindow()
msg.addByte(0x00);
}

msg.addByte(0x00);
msg.addByte(0x00);
msg.addByte(0x00); //Try outfit
msg.addByte(mounted ? 0x01 : 0x00);

writeToOutputBuffer(msg);
}
Expand Down Expand Up @@ -3444,6 +3464,10 @@ void ProtocolGame::AddCreature(NetworkMessage& msg, const Creature* creature, bo
}
}

if (creatureType == CREATURETYPE_PLAYER) {
msg.addByte(0);
}

msg.addByte(creature->getSpeechBubble());
msg.addByte(0xFF); // MARK_UNMARKED
msg.addByte(0x00); // inspection type
Expand Down Expand Up @@ -3521,10 +3545,9 @@ void ProtocolGame::AddPlayerSkills(NetworkMessage& msg)
msg.add<uint32_t>(player->getBaseCapacity()); // base total capacity
}

void ProtocolGame::AddOutfit(NetworkMessage& msg, const Outfit_t& outfit)
void ProtocolGame::AddOutfit(NetworkMessage& msg, const Outfit_t& outfit, bool addMount/* = true*/)
{
msg.add<uint16_t>(outfit.lookType);

if (outfit.lookType != 0) {
msg.addByte(outfit.lookHead);
msg.addByte(outfit.lookBody);
Expand All @@ -3535,7 +3558,9 @@ void ProtocolGame::AddOutfit(NetworkMessage& msg, const Outfit_t& outfit)
msg.addItemId(outfit.lookTypeEx);
}

msg.add<uint16_t>(outfit.lookMount);
if (addMount) {
msg.add<uint16_t>(outfit.lookMount);
}
}

void ProtocolGame::addImbuementInfo(NetworkMessage& msg, uint32_t imbuid)
Expand Down
2 changes: 1 addition & 1 deletion src/protocolgame.h
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ class ProtocolGame final : public Protocol

void AddCreature(NetworkMessage& msg, const Creature* creature, bool known, uint32_t remove);
void AddPlayerStats(NetworkMessage& msg);
void AddOutfit(NetworkMessage& msg, const Outfit_t& outfit);
void AddOutfit(NetworkMessage& msg, const Outfit_t& outfit, bool addMount = true);
void AddPlayerSkills(NetworkMessage& msg);
void sendBlessStatus();
void sendPremiumTrigger();
Expand Down
19 changes: 19 additions & 0 deletions src/tile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1647,3 +1647,22 @@ Item* Tile::getUseItem(int32_t index) const

return nullptr;
}

Item* Tile::getDoorItem() const
{
const TileItemVector* items = getItemList();
if (!items || items->size() == 0) {
return ground;
}

if (items) {
for (Item* item : *items) {
const ItemType& it = Item::items[item->getID()];
if (it.isDoor()) {
return item;
}
}
}

return nullptr;
}
1 change: 1 addition & 0 deletions src/tile.h
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ class Tile : public Cylinder
}

Item* getUseItem(int32_t index) const;
Item* getDoorItem() const;

Item* getGround() const {
return ground;
Expand Down

0 comments on commit eb7b04a

Please sign in to comment.