Skip to content

Commit

Permalink
Merge branch 'main' into fix_creature_attacked
Browse files Browse the repository at this point in the history
  • Loading branch information
dudantas authored Nov 11, 2023
2 parents 1c89bca + 483b32b commit e758b7a
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 13 deletions.
2 changes: 1 addition & 1 deletion data-otservbr-global/monster/humans/nomad_blue.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ monster.events = {
"NomadDeath",
}

monster.raceId = 777
monster.raceId = 776
monster.Bestiary = {
class = "Human",
race = BESTY_RACE_HUMAN,
Expand Down
2 changes: 1 addition & 1 deletion data-otservbr-global/monster/humans/nomad_female.lua
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ monster.events = {
"NomadDeath",
}

monster.raceId = 776
monster.raceId = 777
monster.Bestiary = {
class = "Human",
race = BESTY_RACE_HUMAN,
Expand Down
4 changes: 2 additions & 2 deletions src/creatures/creature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@ void Creature::onDeath() {
bool mostDamageUnjustified = false;
std::shared_ptr<Creature> lastHitCreature = g_game().getCreatureByID(lastHitCreatureId);
std::shared_ptr<Creature> lastHitCreatureMaster;
if (lastHitCreature) {
if (lastHitCreature && !getMonster()) {
lastHitUnjustified = lastHitCreature->onKilledCreature(static_self_cast<Creature>(), true);
lastHitCreatureMaster = lastHitCreature->getMaster();
} else {
Expand Down Expand Up @@ -679,7 +679,7 @@ void Creature::onDeath() {
it.first->onGainExperience(it.second, getCreature());
}

if (mostDamageCreature && mostDamageCreature != lastHitCreature && mostDamageCreature != lastHitCreatureMaster) {
if (mostDamageCreature && (mostDamageCreature != lastHitCreature || getMonster()) && mostDamageCreature != lastHitCreatureMaster) {
auto mostDamageCreatureMaster = mostDamageCreature->getMaster();
if (lastHitCreature != mostDamageCreatureMaster && (lastHitCreatureMaster == nullptr || mostDamageCreatureMaster != lastHitCreatureMaster)) {
mostDamageUnjustified = mostDamageCreature->onKilledCreature(static_self_cast<Creature>(), false);
Expand Down
16 changes: 10 additions & 6 deletions src/io/iologindata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,22 +83,22 @@ void IOLoginData::updateOnlineStatus(uint32_t guid, bool login) {
Database::getInstance().executeQuery(query.str());
}

// The boolean "disable" will desactivate the loading of information that is not relevant to the preload, for example, forge, bosstiary, etc. None of this we need to access if the player is offline
bool IOLoginData::loadPlayerById(std::shared_ptr<Player> player, uint32_t id, bool disable /* = true*/) {
// The boolean "disableIrrelevantInfo" will desactivate the loading of information that is not relevant to the preload, for example, forge, bosstiary, etc. None of this we need to access if the player is offline
bool IOLoginData::loadPlayerById(std::shared_ptr<Player> player, uint32_t id, bool disableIrrelevantInfo /* = true*/) {
Database &db = Database::getInstance();
std::ostringstream query;
query << "SELECT * FROM `players` WHERE `id` = " << id;
return loadPlayer(player, db.storeQuery(query.str()), disable);
return loadPlayer(player, db.storeQuery(query.str()), disableIrrelevantInfo);
}

bool IOLoginData::loadPlayerByName(std::shared_ptr<Player> player, const std::string &name, bool disable /* = true*/) {
bool IOLoginData::loadPlayerByName(std::shared_ptr<Player> player, const std::string &name, bool disableIrrelevantInfo /* = true*/) {
Database &db = Database::getInstance();
std::ostringstream query;
query << "SELECT * FROM `players` WHERE `name` = " << db.escapeString(name);
return loadPlayer(player, db.storeQuery(query.str()), disable);
return loadPlayer(player, db.storeQuery(query.str()), disableIrrelevantInfo);
}

bool IOLoginData::loadPlayer(std::shared_ptr<Player> player, DBResult_ptr result, bool disable /* = false*/) {
bool IOLoginData::loadPlayer(std::shared_ptr<Player> player, DBResult_ptr result, bool disableIrrelevantInfo /* = false*/) {
if (!result || !player) {
std::string nullptrType = !result ? "Result" : "Player";
g_logger().warn("[{}] - {} is nullptr", __FUNCTION__, nullptrType);
Expand Down Expand Up @@ -166,6 +166,10 @@ bool IOLoginData::loadPlayer(std::shared_ptr<Player> player, DBResult_ptr result
// Load task hunting class
IOLoginDataLoad::loadPlayerTaskHuntingClass(player, result);

if (disableIrrelevantInfo) {
return true;
}

// load forge history
IOLoginDataLoad::loadPlayerForgeHistory(player, result);

Expand Down
6 changes: 3 additions & 3 deletions src/io/iologindata.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ class IOLoginData {
static bool gameWorldAuthentication(const std::string &accountDescriptor, const std::string &sessionOrPassword, std::string &characterName, uint32_t &accountId, bool oldProcotol);
static account::AccountType getAccountType(uint32_t accountId);
static void updateOnlineStatus(uint32_t guid, bool login);
static bool loadPlayerById(std::shared_ptr<Player> player, uint32_t id, bool disable = true);
static bool loadPlayerByName(std::shared_ptr<Player> player, const std::string &name, bool disable = true);
static bool loadPlayer(std::shared_ptr<Player> player, DBResult_ptr result, bool disable = true);
static bool loadPlayerById(std::shared_ptr<Player> player, uint32_t id, bool disableIrrelevantInfo = true);
static bool loadPlayerByName(std::shared_ptr<Player> player, const std::string &name, bool disableIrrelevantInfo = true);
static bool loadPlayer(std::shared_ptr<Player> player, DBResult_ptr result, bool disableIrrelevantInfo = false);
static bool savePlayer(std::shared_ptr<Player> player);
static uint32_t getGuidByName(const std::string &name);
static bool getGuidByNameEx(uint32_t &guid, bool &specialVip, std::string &name);
Expand Down

0 comments on commit e758b7a

Please sign in to comment.