johnsamir
Advanced OT User
Hi use tfs 1.5 protocol 8.6
Recently i have added a commit related to tfs perfomance on loading map or something similar, the thing is that, when i want to log in to the game i receive the message error "account or passowrd is not correct
. this is strange since i have already accessed to my char list. this happens when i chose a chracter in order to log in to the game
not sure but the error might be in protocolgame or iologindata files
maybe here? still iologindata
maybe the rror is herE?
tried this too
trying to remove charactername variable from it but did not worked
Hi
@Codinablack how you doing, sorry to tag u nut this occurs after i added your commit related to string_view and others. wonder if you would or could help me to fix if you can please.
any help is welcome.
edit: changed in protocolgame.cpp
to
now i get error message "your character could not be loaded"
now i noticed that i get this error as i try to log in
SOLVED
all changed displayed previuosly also
std::tie(accountId, characterName/tried std::ignore ti not use charactername here*/) = IOLoginData::gameworldAuthentication(ac
LUA:
oid ProtocolLogin::getCharacterList(const std::string& accountName, const std::string& password)
{
Account account;
if (!IOLoginData::loginserverAuthentication(accountName, password, account)) {
disconnectClient("Account name or password is not correct.");
return;
}
auto output = OutputMessagePool::getOutputMessage();
const std::string& motd = g_config.getString(ConfigManager::MOTD);
if (!motd.empty()) {
//Add MOTD
output->addByte(0x14);
output->addString(fmt::format("{:d}\n{:s}", g_game.getMotdNum(), motd));
}
//Add char list
output->addByte(0x64);
uint8_t size = std::min<size_t>(std::numeric_limits<uint8_t>::max(), account.characters.size());
output->addByte(size);
for (uint8_t i = 0; i < size; i++) {
output->addString(account.characters[i]);
output->addString(g_config.getString(ConfigManager::SERVER_NAME));
output->add<uint32_t>(g_config.getNumber(ConfigManager::IP));
output->add<uint16_t>(g_config.getNumber(ConfigManager::GAME_PORT));
}
//Add premium days
if (g_config.getBoolean(ConfigManager::FREE_PREMIUM)) {
output->add<uint16_t>(0xFFFF); //client displays free premium
}
else {
output->add<uint16_t>(std::max<time_t>(0, account.premiumEndsAt - time(nullptr)) / 86400);
}
send(output);
disconnect();
}
Code:
disconnectClient("Account name or password is not correct.");
not sure but the error might be in protocolgame or iologindata files
LUA:
void ProtocolGame::onRecvFirstMessage(NetworkMessage& msg)
{
if (g_game.getGameState() == GAME_STATE_SHUTDOWN) {
disconnect();
return;
}
OperatingSystem_t operatingSystem = static_cast<OperatingSystem_t>(msg.get<uint16_t>());
version = msg.get<uint16_t>();
if (!Protocol::RSA_decrypt(msg)) {
disconnect();
return;
}
xtea::key key;
key[0] = msg.get<uint32_t>();
key[1] = msg.get<uint32_t>();
key[2] = msg.get<uint32_t>();
key[3] = msg.get<uint32_t>();
enableXTEAEncryption();
setXTEAKey(std::move(key));
/*if (operatingSystem >= CLIENTOS_OTCLIENT_LINUX) {
NetworkMessage opcodeMessage;
opcodeMessage.addByte(0x32);
opcodeMessage.addByte(0x00);
opcodeMessage.add<uint16_t>(0x00);
writeToOutputBuffer(opcodeMessage);
}*/
msg.skipBytes(1); // gamemaster flag
//revisar
//<<<<<<< HEAD
auto accountName = msg.getString();
//std::string characterName = msg.getString();
auto password = msg.getString();
//=======
// acc name or email, password, token, timestamp divided by 30
//auto sessionArgs = explodeString(msg.getString(), "\n", 4);
//if (sessionArgs.size() != 4) {
// disconnect();
// return;
//}
//auto accountName = sessionArgs[0];
//auto password = sessionArgs[1];
//std::string_view token = sessionArgs[2];
//int32_t tokenTime = 0;
/*try {
tokenTime = std::stoul(sessionArgs[3].data());
} catch (const std::invalid_argument&) {
disconnectClient("Malformed token packet.");
return;
} catch (const std::out_of_range&) {
disconnectClient("Token time is too long.");
return;
}*/
//>>>>>>> 65c46f9a (Replaces boost fs with std fs, and replaces many copied instances of string with string_view. (#4079))
if (accountName.empty()) {
disconnectClient("You must enter your account name.");
return;
}
auto characterName = msg.getString();
//>>>>>>> 65c46f9a (Replaces boost fs with std fs, and replaces many copied instances of string with string_view. (#4079))
uint32_t timeStamp = msg.get<uint32_t>();
uint8_t randNumber = msg.getByte();
if (challengeTimestamp != timeStamp || challengeRandom != randNumber) {
disconnect();
return;
}
// OTCv8 version detection
uint16_t otcV8StringLength = msg.get<uint16_t>();
if (otcV8StringLength == 5 && msg.getString(5) == "OTCv8") {
otclientV8 = msg.get<uint16_t>(); // 253, 260, 261, ...
}
if (version < CLIENT_VERSION_MIN || version > CLIENT_VERSION_MAX) {
disconnectClient(fmt::format("Only clients with protocol {:s} allowed!", CLIENT_VERSION_STR));
return;
}
if (g_game.getGameState() == GAME_STATE_STARTUP) {
disconnectClient("Gameworld is starting up. Please wait.");
return;
}
if (g_game.getGameState() == GAME_STATE_MAINTAIN) {
disconnectClient("Gameworld is under maintenance. Please re-connect in a while.");
return;
}
BanInfo banInfo;
if (IOBan::isIpBanned(getIP(), banInfo)) {
if (banInfo.reason.empty()) {
banInfo.reason = "(none)";
}
disconnectClient(fmt::format("Your IP has been banned until {:s} by {:s}.\n\nReason specified:\n{:s}", formatDateShort(banInfo.expiresAt), banInfo.bannedBy, banInfo.reason));
return;
}
//<<<<<<< HEAD
//uint32_t accountId = IOLoginData::gameworldAuthentication(accountName, password, characterName);
//=======
uint32_t accountId;
std::tie(accountId, characterName) = IOLoginData::gameworldAuthentication(accountName, password, characterName/*, token, tokenTime*/);
//>>>>>>> 65c46f9a (Replaces boost fs with std fs, and replaces many copied instances of string with string_view. (#4079))
if (accountId == 0) {
disconnectClient("Account name or password is not correct.");
return;
}
//<<<<<<< HEAD
//g_dispatcher.addTask(createTask(std::bind(&ProtocolGame::login, getThis(), characterName, accountId, operatingSystem)));
//=======
addGameTask([=, thisPtr = getThis(), characterName = std::string{ characterName }]() { thisPtr->login(characterName, accountId, operatingSystem); });
//>>>>>>> 65c46f9a (Replaces boost fs with std fs, and replaces many copied instances of string with string_view. (#4079))
}
maybe here? still iologindata
Code:
bool IOLoginData::preloadPlayer(Player* player, const std::string& name)
{
Database& db = Database::getInstance();
DBResult_ptr result = db.storeQuery(fmt::format("SELECT `p`.`id`, `p`.`account_id`, `p`.`group_id`, `a`.`type`, `a`.`premium_ends_at` FROM `players` as `p` JOIN `accounts` as `a` ON `a`.`id` = `p`.`account_id` WHERE `p`.`name` = {:s} AND `p`.`deletion` = 0", db.escapeString(name)));
if (!result) {
return false;
}
player->setGUID(result->getNumber<uint32_t>("id"));
Group* group = g_game.groups.getGroup(result->getNumber<uint16_t>("group_id"));
if (!group) {
std::cout << "[Error - IOLoginData::preloadPlayer] " << player->name << " has Group ID " << result->getNumber<uint16_t>("group_id") << " which doesn't exist." << std::endl;
return false;
}
player->setGroup(group);
player->accountNumber = result->getNumber<uint32_t>("account_id");
player->accountType = static_cast<AccountType_t>(result->getNumber<uint16_t>("type"));
player->premiumEndsAt = result->getNumber<time_t>("premium_ends_at");
return true;
}
Code:
bool IOLoginData::loginserverAuthentication(const std::string& name, const std::string& password, Account& account)
{
Database& db = Database::getInstance();
DBResult_ptr result = db.storeQuery(fmt::format("SELECT `id`, `name`, `password`, `secret`, `type`, `premium_ends_at` FROM `accounts` WHERE `name` = {:s}", db.escapeString(name)));
if (!result) {
return false;
}
if (transformToSHA1(password) != result->getString("password")) {
return false;
}
account.id = result->getNumber<uint32_t>("id");
account.name = result->getString("name");
//account.key = decodeSecret(result->getString("secret"));
account.accountType = static_cast<AccountType_t>(result->getNumber<int32_t>("type"));
account.premiumEndsAt = result->getNumber<time_t>("premium_ends_at");
result = db.storeQuery(fmt::format("SELECT `name` FROM `players` WHERE `account_id` = {:d} AND `deletion` = 0 ORDER BY `name` ASC", account.id));
if (result) {
do {
account.characters.emplace_back(result->getString("name"));
} while (result->next());
}
return true;
}
//<<<<<<< HEAD
//uint32_t IOLoginData::gameworldAuthentication(const std::string& accountName, const std::string& password, std::string& characterName)
//=======
std::pair<uint32_t, std::string_view> IOLoginData::gameworldAuthentication(std::string_view accountName, std::string_view password, std::string_view characterName/*, std::string_view token, uint32_t tokenTime*/)
//>>>>>>> 65c46f9a (Replaces boost fs with std fs, and replaces many copied instances of string with string_view. (#4079))
{
Database& db = Database::getInstance();
DBResult_ptr result = db.storeQuery(fmt::format("SELECT `id`, `password` FROM `accounts` WHERE `name` = {:s}", db.escapeString(accountName)));
if (!result) {
return std::make_pair(0, characterName);
}
//<<<<<<< HEAD
//======= //revisar
/* std::string secret = decodeSecret(result->getString("secret"));
if (!secret.empty()) {
if (token.empty()) {
return std::make_pair(0, characterName);
}
bool tokenValid = token == generateToken(secret, tokenTime) || token == generateToken(secret, tokenTime - 1) || token == generateToken(secret, tokenTime + 1);
if (!tokenValid) {
return std::make_pair(0, characterName);
}
}*/
///>>>>>>> 65c46f9a (Replaces boost fs with std fs, and replaces many copied instances of string with string_view. (#4079))
if (transformToSHA1(password) != result->getString("password")) {
return std::make_pair(0, characterName);
}
uint32_t accountId = result->getNumber<uint32_t>("id");
result = db.storeQuery(fmt::format("SELECT `name` FROM `players` WHERE `name` = {:s} AND `account_id` = {:d} AND `deletion` = 0", db.escapeString(characterName), accountId));
if (!result) {
return std::make_pair(0, characterName);
}
return std::make_pair(accountId, result->getString("name"));
}
LUA:
void ProtocolLogin::onRecvFirstMessage(NetworkMessage& msg)
{
if (g_game.getGameState() == GAME_STATE_SHUTDOWN) {
disconnect();
return;
}
msg.skipBytes(2); // client OS
uint16_t version = msg.get<uint16_t>();
msg.skipBytes(12);
/*
* Skipped bytes:
* 4 bytes: protocolVersion
* 12 bytes: dat, spr, pic signatures (4 bytes each)
* 1 byte: 0
*/
if (version <= 760) {
disconnectClient(fmt::format("Only clients with protocol {:s} allowed!", CLIENT_VERSION_STR));
return;
}
if (!Protocol::RSA_decrypt(msg)) {
disconnect();
return;
}
xtea::key key;
key[0] = msg.get<uint32_t>();
key[1] = msg.get<uint32_t>();
key[2] = msg.get<uint32_t>();
key[3] = msg.get<uint32_t>();
enableXTEAEncryption();
setXTEAKey(std::move(key));
if (version < CLIENT_VERSION_MIN || version > CLIENT_VERSION_MAX) {
disconnectClient(fmt::format("Only clients with protocol {:s} allowed!", CLIENT_VERSION_STR));
return;
}
if (g_game.getGameState() == GAME_STATE_STARTUP) {
disconnectClient("Gameworld is starting up. Please wait.");
return;
}
if (g_game.getGameState() == GAME_STATE_MAINTAIN) {
disconnectClient("Gameworld is under maintenance.\nPlease re-connect in a while.");
return;
}
BanInfo banInfo;
auto connection = getConnection();
if (!connection) {
return;
}
if (IOBan::isIpBanned(connection->getIP(), banInfo)) {
if (banInfo.reason.empty()) {
banInfo.reason = "(none)";
}
disconnectClient(fmt::format("Your IP has been banned until {:s} by {:s}.\n\nReason specified:\n{:s}", formatDateShort(banInfo.expiresAt), banInfo.bannedBy, banInfo.reason));
return;
}
auto accountName = msg.getString();
if (accountName.empty()) {
disconnectClient("Invalid account name.");
return;
}
auto password = msg.getString();
if (password.empty()) {
disconnectClient("Invalid password.");
return;
}
// OTCv8 version detection
uint16_t otclientV8 = 0;
uint16_t otcV8StringLength = msg.get<uint16_t>();
if (otcV8StringLength == 5 && msg.getString(5) == "OTCv8") {
otclientV8 = msg.get<uint16_t>(); // 253, 260, 261, ...
}
//<<<<<<< HEAD
//auto thisPtr = std::static_pointer_cast<ProtocolLogin>(shared_from_this());
//g_dispatcher.addTask(createTask(std::bind(&ProtocolLogin::getCharacterList, thisPtr, accountName, password)));
//=======
//auto authToken = msg.getString();
g_dispatcher.addTask(createTask(
[=, thisPtr = std::static_pointer_cast<ProtocolLogin>(shared_from_this()), accountName = std::string{ accountName }, password = std::string{ password }/*, authToken = std::string{ authToken }*/]() {
thisPtr->getCharacterList(accountName, password/*, authToken, version*/);
}));
//>>>>>>> 65c46f9a (Replaces boost fs with std fs, and replaces many copied instances of string with string_view. (#4079))
}
changed this too cuz of the change from std::string to strd::string_view dont think the problem might be here but i post it anyway
Code:
void ProtocolGame::parseSetOutfit(NetworkMessage& msg)
{
//uint8_t 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();
//msg.get<uint16_t>(); // familiar looktype
newOutfit.lookMount = msg.get<uint16_t>();
newOutfit.lookWings = otclientV8 ? msg.get<uint16_t>() : 0;
newOutfit.lookAura = otclientV8 ? msg.get<uint16_t>() : 0;
//std::string_view shaderName = otclientV8 ? msg.getString() : "";
//std::string_view shaderName = otclientV8 ? msg.getString() : "";
//S//hader* getShaderByName(const std::string_view & name);
//Shader* shader = g_game.shaders.getShaderByName(shaderName);
//newOutfit.lookShader = shader ? shader->id : 0;
//addGameTask([=, playerID = player->getID()]() { g_game.playerChangeOutfit(playerID, newOutfit); });
// std::string_view shaderName = otclientV8 ? msg.getString() : "";
//Shader* shader = g_game.shaders.getShaderByName(shaderName); // Call getShaderByName function
//newOutfit.lookShader = shader ? shader->id : 0;
//addGameTask([=, playerID = player->getID()]() { g_game.playerChangeOutfit(playerID, newOutfit); });
// std::string_view shaderNameView = otclientV8 ? msg.getString() : "";
std::string_view shaderNameView = otclientV8 ? msg.getString() : "";
std::string shaderName(shaderNameView); // Convert std::string_view to std::string
Shader* shader = g_game.shaders.getShaderByName(shaderName);
newOutfit.lookShader = shader ? shader->id : 0;
addGameTask([=, playerID = player->getID()]() { g_game.playerChangeOutfit(playerID, newOutfit); });
// Set outfit window
// Set outfit window
// Set outfit window
// Set outfit window
Code:
std::tie(accountId, characterName) = IOLoginData::gameworldAuthentication(accountName, password, characterName/*, token, tokenTime*/);
tried this too
Code:
//<<<<<<< HEAD
//uint32_t accountId = IOLoginData::gameworldAuthentication(accountName, password, characterName);
//=======
uint32_t accountId;
std::tie(accountId, characterName/*tried std::ignore* ti not use charactername here/) = IOLoginData::gameworldAuthentication(accountName, password, characterName/*, token, tokenTime*/);
//>>>>>>> 65c46f9a (Replaces boost fs with std fs, and replaces many copied instances of string with string_view. (#4079))
if (accountId == 0) {
disconnectClient("Account name or password is not correct.");
return;
}
Code:
std::tie(accountId)
Hi
@Codinablack how you doing, sorry to tag u nut this occurs after i added your commit related to string_view and others. wonder if you would or could help me to fix if you can please.
any help is welcome.
edit: changed in protocolgame.cpp
Code:
auto accountName = msg.getString();
auto password = msg.getString();
auto characterName = msg.getString();
to
Code:
std::string_view accountName = msg.getString();
std::string_view password = msg.getString();
std::string_view characterName = msg.getString();
now i noticed that i get this error as i try to log in
Code:
>> Loaded all modules, server starting up...
>> RPG Server Online!
[Error - mysql_real_query] Query: SELECT `p`.`id`, `p`.`account_id`, `p`.`group_id`, `a`.`type`, `a`.`premium_ends_at` FROM `players` as `p` JOIN `accounts` as `a` ON `a`.`id` = `p`.`account_id` WHERE `p`.`name` = '¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦' AND `p`.`deletion` = 0
Message: Illegal mix of collations (utf8_general_ci,IMPLICIT) and (utf8mb4_general_ci,COERCIBLE) for operation '='
[Error - mysql_store_result] Query: SELECT `p`.`id`, `p`.`account_id`, `p`.`group_id`, `a`.`type`, `a`.`premium_ends_at` FROM `players` as `p` JOIN `accounts` as `a` ON `a`.`id` = `p`.`account_id` WHERE `p`.`name` = '¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦' AND `p`.`deletion` = 0
Message: Illegal mix of collations (utf8_general_ci,IMPLICIT) and (utf8mb4_general_ci,COERCIBLE) for operation '='
[Error - mysql_real_query] Query: SELECT `p`.`id`, `p`.`account_id`, `p`.`group_id`, `a`.`type`, `a`.`premium_ends_at` FROM `players` as `p` JOIN `accounts` as `a` ON `a`.`id` = `p`.`account_id` WHERE `p`.`name` = '¦¦¦¦' AND `p`.`deletion` = 0
Message: Illegal mix of collations (utf8_general_ci,IMPLICIT) and (utf8mb4_general_ci,COERCIBLE) for operation '='
[Error - mysql_store_result] Query: SELECT `p`.`id`, `p`.`account_id`, `p`.`group_id`, `a`.`type`, `a`.`premium_ends_at` FROM `players` as `p` JOIN `accounts` as `a` ON `a`.`id` = `p`.`account_id` WHERE `p`.`name` = '¦¦¦¦' AND `p`.`deletion` = 0
Message: Illegal mix of collations (utf8_general_ci,IMPLICIT) and (utf8mb4_general_ci,COERCIBLE) for operation '='
Post automatically merged:
SOLVED
all changed displayed previuosly also
std::tie(accountId, characterName/tried std::ignore ti not use charactername here*/) = IOLoginData::gameworldAuthentication(ac
LUA:
std::tie(accountId, std::ignore/*tried std::ignore* ti not use charactername here*/) = IOLoginData::gameworldAuthentication(ac
Last edited: