Skip to content

Commit

Permalink
fixes and removed commented code.
Browse files Browse the repository at this point in the history
  • Loading branch information
elsongabriel committed Apr 16, 2024
1 parent c547af9 commit 16e4777
Show file tree
Hide file tree
Showing 12 changed files with 20 additions and 352 deletions.
3 changes: 1 addition & 2 deletions src/canary_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -374,10 +374,9 @@ void CanaryServer::loadModules() {
modulesLoadHelper((g_npcs().load(false, true)), "npc");

g_game().loadBoostedCreature();
// TODO: g_game().initializeCyclopedia();
// TODO: verify g_game().initializeGameWorldHighscores();
g_ioBosstiary().loadBoostedBoss();
g_ioprey().initializeTaskHuntOptions();
g_game().getCyclopediaStatistics();
}

void CanaryServer::modulesLoadHelper(bool loaded, std::string moduleName) {
Expand Down
4 changes: 2 additions & 2 deletions src/creatures/players/cyclopedia/player_badge.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ class PlayerBadge {
public:
explicit PlayerBadge(Player &player);

bool hasBadge(uint8_t id) const;
[[nodiscard]] bool hasBadge(uint8_t id) const;
bool add(uint8_t id, uint32_t timestamp = 0);
std::vector<std::pair<Badge, uint32_t>> getUnlockedBadges() const;
[[nodiscard]] std::vector<std::pair<Badge, uint32_t>> getUnlockedBadges() const;
void loadUnlockedBadges();
const std::shared_ptr<KV> &getUnlockedKV();

Expand Down
4 changes: 4 additions & 0 deletions src/creatures/players/cyclopedia/player_cyclopedia.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@
PlayerCyclopedia::PlayerCyclopedia(Player &player) :
m_player(player) { }

void PlayerCyclopedia::loadSummaryData() {
// todo create player summary
}

void PlayerCyclopedia::addXpBoostsObtained(uint16_t amount) {
m_storeXpBoosts += amount;
}
Expand Down
7 changes: 4 additions & 3 deletions src/creatures/players/cyclopedia/player_cyclopedia.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,10 @@ class PlayerCyclopedia {
public:
explicit PlayerCyclopedia(Player &player);

Summary loadSummary() {
Summary getSummary() {
return Summary(m_storeXpBoosts, m_dailyRewardCollections, m_hirelings, m_preyCards, m_charms, m_goshnar, m_drome, m_loginStreak, m_taskHuntingPoints, m_mapAreaDiscoveredPercentage, m_hirelingOutfits, m_hirelingJobs, m_blessings);
}
void loadSummaryData();

void addXpBoostsObtained(uint16_t amount);
void addRewardCollectionObtained(uint16_t amount);
Expand All @@ -56,9 +57,9 @@ class PlayerCyclopedia {
void addBlessingsObtained(Blessings_t id, uint16_t amount);
// void addHouseItemsObtained(uint16_t itemId, uint32_t amount);

std::vector<RecentDeathEntry> getDeathHistory() const;
[[nodiscard]] std::vector<RecentDeathEntry> getDeathHistory() const;
void insertDeathOnHistory(std::string cause, uint32_t timestamp);
std::vector<RecentPvPKillEntry> getPvpKillsHistory() const;
[[nodiscard]] std::vector<RecentPvPKillEntry> getPvpKillsHistory() const;
void insertPvpKillOnHistory(std::string cause, uint32_t timestamp, uint8_t status);

private:
Expand Down
1 change: 1 addition & 0 deletions src/creatures/players/cyclopedia/player_title.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ namespace std {
class PlayerTitle {
public:
explicit PlayerTitle(Player &player);

[[nodiscard]] bool isTitleUnlocked(uint8_t id) const;
bool add(uint8_t id, uint32_t timestamp = 0);
[[nodiscard]] std::vector<std::pair<Title, uint32_t>> getUnlockedTitles() const;
Expand Down
11 changes: 4 additions & 7 deletions src/game/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8221,13 +8221,10 @@ void Game::kickPlayer(uint32_t playerId, bool displayEffect) {

void Game::playerFriendSystemAction(std::shared_ptr<Player> player, uint8_t type, uint8_t titleId) {
uint32_t playerGUID = player->getGUID();
g_logger().info("ProtocolGame::parseFriendSystemAction 3");
if (type == 0x0E) {
g_logger().info("ProtocolGame::parseFriendSystemAction 4");
player->title()->setCurrentTitle(titleId);
player->sendCyclopediaCharacterBaseInformation();
player->sendCyclopediaCharacterTitles();
// player->sendCyclopediaCharacterTitles(player->title()->getUnlockedTitles());
return;
}
}
Expand Down Expand Up @@ -10624,9 +10621,10 @@ std::map<uint16_t, Achievement> Game::getAchievements() {
return m_achievements;
}

// void Game::initializeCyclopedia() {
//
// }
void Game::getCyclopediaStatistics() {
g_logger().info("Loaded {} badges from Badge System", m_badges.size());
g_logger().info("Loaded {} titles from Title system", m_titles.size());
}

Badge Game::getBadgeByIdOrName(uint8_t id, const std::string &name /*= ""*/) {
if (id == 0 && name.empty()) {
Expand All @@ -10649,7 +10647,6 @@ Title Game::getTitleByIdOrName(uint8_t id, const std::string &name /*= ""*/) {
if (id == 0 && name.empty()) {
return {};
}
g_logger().info("title searched: id {}, name {}", id, name);
auto it = std::find_if(m_titles.begin(), m_titles.end(), [id, name](const Title &t) {
return id != 0 ? t.m_id == id : t.m_maleName == name;
});
Expand Down
2 changes: 1 addition & 1 deletion src/game/game.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class Game {

void forceRemoveCondition(uint32_t creatureId, ConditionType_t type, ConditionId_t conditionId);

// void initializeCyclopedia();
void getCyclopediaStatistics();

/**
* Load the main map
Expand Down
1 change: 1 addition & 0 deletions src/io/functions/iologindata_load_player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -891,6 +891,7 @@ void IOLoginDataLoad::loadPlayerInitializeSystem(std::shared_ptr<Player> player)
player->achiev()->loadUnlockedAchievements();
player->badge()->loadUnlockedBadges();
player->title()->loadUnlockedTitles();
player->cyclopedia()->loadSummaryData();

player->initializePrey();
player->initializeTaskHunting();
Expand Down
92 changes: 0 additions & 92 deletions src/lua/functions/core/game/game_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -907,95 +907,3 @@ int GameFunctions::luaGameGetAchievements(lua_State* L) {
}
return 1;
}

// int GameFunctions::luaGameGetAllMounts(lua_State *L) {
// // Game.getMounts()
// const auto &mounts = g_game().mounts.getMounts();
// int index = 0;
// lua_createtable(L, mounts.size(), 0);
// for (const auto &mount: mounts) {
// lua_createtable(L, 0, 6);
// setField(L, "id", mount->id);
// setField(L, "clientId", mount->clientId);
// setField(L, "name", mount->name);
// setField(L, "speed", mount->speed);
// setField(L, "premium", mount->premium);
// setField(L, "type", mount->type);
// lua_rawseti(L, -2, ++index);
// }
// return 1;
// }
//
// int GameFunctions::luaGameGetAllOutfits(lua_State *L) {
// // Game.getOutfits(sex)
// int index = 0;
// const auto &outfits = Outfits::getInstance().getOutfits(static_cast<PlayerSex_t>(getNumber<uint8_t>(L, 1, 1)));
// lua_createtable(L, outfits.size(), 0);
// for (const auto &outfit: outfits) {
// lua_createtable(L, 0, 5);
// setField(L, "lookType", outfit->lookType);
// setField(L, "name", outfit->name);
// setField(L, "unlocked", outfit->unlocked);
// setField(L, "premium", outfit->premium);
// setField(L, "from", outfit->from);
// lua_rawseti(L, -2, ++index);
// }
// return 1;
// }

// int GameFunctions::luaGameGetHighscoresLeaderId(lua_State* L) {
// // Game.getHighscoresLeaderId(skill)
// const auto highscoreVector = g_game().getHighscoreByCategory(static_cast<HighscoreCategories_t>(getNumber<uint16_t>(L, 1, 0)));
// if (highscoreVector.size() != 0) {
// lua_pushnumber(L, highscoreVector.front().id);
// } else {
// lua_pushnumber(L, 0);
// }
//
// return 1;
// }

// int GameFunctions::luaGameGetBestiaryRaceAmount(lua_State *L) {
// // Game.getBestiaryRaceAmount(race)
// uint16_t entries = 0;
// auto race = static_cast<BestiaryType_t>(getNumber<uint16_t>(L, 1, 0));
// for (const auto &mType_it: g_game().getBestiaryList()) {
// if (std::shared_ptr<MonsterType> mType = g_monsters().getMonsterType(mType_it.second);
// mType && mType->info.bestiaryRace == race) {
// entries++;
// }
// }
//
// lua_pushnumber(L, entries);
// return 1;
// }

// int GameFunctions::luaGameRegisterBadge(lua_State* L) {
// // Game.registerBadge(id, name, amount)
// if (lua_gettop(L) < 2) {
// reportErrorFunc("Badge can only be registered with all params.");
// lua_pushnil(L);
// } else {
// g_game().registerBadge(getNumber<uint8_t>(L, 1), getString(L, 2), getNumber<uint8_t>(L, 3));
// pushBoolean(L, true);
// }
// return 1;
// }
//
// int GameFunctions::luaGameRegisterTitle(lua_State* L) {
// // Game.registerTitle(id, maleName, femaleName, type, description, permanent)
// if (lua_gettop(L) < 5) {
// reportErrorFunc("Title can only be registered with all params.");
// lua_pushnil(L);
// } else {
// uint16_t id = getNumber<uint16_t>(L, 1);
// std::string maleName = getString(L, 2);
// std::string femaleName = getString(L, 3);
// std::string type = getString(L, 4);
// std::string description = getString(L, 5);
// bool permanent = getBoolean(L, 6);
// g_game().registerTitle(id, maleName, femaleName, type, description, permanent);
// pushBoolean(L, true);
// }
// return 1;
// }
Loading

0 comments on commit 16e4777

Please sign in to comment.