reginaldofilhog
Member
I noticed that my server isn't saving the town_id correctly. It changes the town_id and the coordinate. The coordinate is correct, but the town_id isn't. For example, I go to Thais, town_id 3, and it's set in the database as town_id 2. The map is correct, the towns table is correct, and on save, I have this.
Does anyone know what might be happening? I'm using TFS 1.5 7.72!
Thanks
Does anyone know what might be happening? I'm using TFS 1.5 7.72!
Thanks
C++:
//First, an UPDATE query to write the player itself.
std::ostringstream query;
query << "UPDATE `players` SET ";
query << "`level` = " << player->level << ',';
query << "`group_id` = " << player->group->id << ',';
query << "`vocation` = " << player->getVocationId() << ',';
query << "`health` = " << player->health << ',';
query << "`healthmax` = " << player->healthMax << ',';
query << "`experience` = " << player->experience << ',';
query << "`lookbody` = " << static_cast<uint32_t>(player->defaultOutfit.lookBody) << ',';
query << "`lookfeet` = " << static_cast<uint32_t>(player->defaultOutfit.lookFeet) << ',';
query << "`lookhead` = " << static_cast<uint32_t>(player->defaultOutfit.lookHead) << ',';
query << "`looklegs` = " << static_cast<uint32_t>(player->defaultOutfit.lookLegs) << ',';
query << "`looktype` = " << player->defaultOutfit.lookType << ',';
query << "`lookaddons` = " << static_cast<uint32_t>(player->defaultOutfit.lookAddons) << ',';
query << "`maglevel` = " << player->magLevel << ',';
query << "`mana` = " << player->mana << ',';
query << "`manamax` = " << player->manaMax << ',';
query << "`manaspent` = " << player->manaSpent << ',';
query << "`soul` = " << static_cast<uint16_t>(player->soul) << ',';
query << "`town_id` = " << player->town->getID() << ',';
const Position& loginPosition = player->getLoginPosition();
query << "`posx` = " << loginPosition.getX() << ',';
query << "`posy` = " << loginPosition.getY() << ',';
query << "`posz` = " << loginPosition.getZ() << ',';
query << "`cap` = " << (player->capacity / 100) << ',';
query << "`sex` = " << static_cast<uint16_t>(player->sex) << ',';
if (player->lastLoginSaved != 0) {
query << "`lastlogin` = " << player->lastLoginSaved << ',';
}
if (player->lastIP != 0) {
query << "`lastip` = " << player->lastIP << ',';
}
query << "`conditions` = " << db.escapeBlob(conditions, conditionsSize) << ',';
if (g_game.getWorldType() != WORLD_TYPE_PVP_ENFORCED) {
int64_t skullTime = 0;
if (player->skullTicks > 0) {
skullTime = time(nullptr) + player->skullTicks;
}
query << "`skulltime` = " << skullTime << ',';
Skulls_t skull = SKULL_NONE;
if (player->skull == SKULL_RED) {
skull = SKULL_RED;
} else if (player->skull == SKULL_BLACK) {
skull = SKULL_BLACK;
}
query << "`skull` = " << static_cast<int64_t>(skull) << ',';
}
query << "`lastlogout` = " << player->getLastLogout() << ',';
query << "`balance` = " << player->bankBalance << ',';
query << "`offlinetraining_time` = " << player->getOfflineTrainingTime() / 1000 << ',';
query << "`offlinetraining_skill` = " << player->getOfflineTrainingSkill() << ',';
query << "`stamina` = " << player->getStaminaMinutes() << ',';
query << "`skill_fist` = " << player->skills[SKILL_FIST].level << ',';
query << "`skill_fist_tries` = " << player->skills[SKILL_FIST].tries << ',';
query << "`skill_club` = " << player->skills[SKILL_CLUB].level << ',';
query << "`skill_club_tries` = " << player->skills[SKILL_CLUB].tries << ',';
query << "`skill_sword` = " << player->skills[SKILL_SWORD].level << ',';
query << "`skill_sword_tries` = " << player->skills[SKILL_SWORD].tries << ',';
query << "`skill_axe` = " << player->skills[SKILL_AXE].level << ',';
query << "`skill_axe_tries` = " << player->skills[SKILL_AX].tries << ',';
query << "`skill_dist` = " << player->skills[SKILL_DISTANCE].level << ',';
query << "`skill_dist_tries` = " << player->skills[SKILL_DISTANCE].tries << ',';
query << "`skill_shielding` = " << player->skills[SKILL_SHIELD].level << ',';
query << "`skill_shielding_tries` = " << player->skills[SKILL_SHIELD].tries << ',';
query << "`skill_fishing` = " << player->skills[SKILL_FISHING].level << ',';
query << "`skill_fishing_tries` = " << player->skills[SKILL_FISHING].tries << ',';
query << "`direction` = " << static_cast<uint16_t> (player->getDirection()) << ',';
if (!player->isOffline()) {
query << "`onlinetime` = `onlinetime` + " << (time(nullptr) - player->lastLoginSaved) << ',';
}
query << "`blessings` = " << player->blessings.to_ulong();
query << " WHERE `id` = " << player->getGUID();