Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor events: Extracted into tfs::events namespace #4831

Merged
2 commits merged into from
Nov 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions src/combat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

extern Game g_game;
extern Weapons* g_weapons;
extern Events* g_events;

std::vector<Tile*> getList(const MatrixArea& area, const Position& targetPos, const Direction dir)
{
Expand Down Expand Up @@ -261,7 +260,7 @@ ReturnValue Combat::canDoCombat(Creature* caster, Tile* tile, bool aggressive)
return RETURNVALUE_ACTIONNOTPERMITTEDINPROTECTIONZONE;
}

return g_events->eventCreatureOnAreaCombat(caster, tile, aggressive);
return tfs::events::creature::onAreaCombat(caster, tile, aggressive);
}

bool Combat::isInPvpZone(const Creature* attacker, const Creature* target)
Expand Down Expand Up @@ -290,7 +289,7 @@ bool Combat::isProtected(const Player* attacker, const Player* target)
ReturnValue Combat::canDoCombat(Creature* attacker, Creature* target)
{
if (!attacker) {
return g_events->eventCreatureOnTargetCombat(attacker, target);
return tfs::events::creature::onTargetCombat(attacker, target);
}

if (const Player* targetPlayer = target->getPlayer()) {
Expand Down Expand Up @@ -369,7 +368,7 @@ ReturnValue Combat::canDoCombat(Creature* attacker, Creature* target)
}
}
}
return g_events->eventCreatureOnTargetCombat(attacker, target);
return tfs::events::creature::onTargetCombat(attacker, target);
}

void Combat::setPlayerCombatValues(formulaType_t formulaType, double mina, double minb, double maxa, double maxb)
Expand Down
5 changes: 2 additions & 3 deletions src/creature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ double Creature::speedC = -4795.01;

extern Game g_game;
extern CreatureEvents* g_creatureEvents;
extern Events* g_events;

Creature::Creature() { onIdleStatus(); }

Expand Down Expand Up @@ -410,7 +409,7 @@ void Creature::onCreatureMove(Creature* creature, const Tile* newTile, const Pos
}

if (newTile->getZone() != oldTile->getZone()) {
g_events->eventCreatureOnChangeZone(this, oldTile->getZone(), newTile->getZone());
tfs::events::creature::onChangeZone(this, oldTile->getZone(), newTile->getZone());
onChangeZone(getZone());
}
}
Expand Down Expand Up @@ -1433,7 +1432,7 @@ void Creature::setStorageValue(uint32_t key, std::optional<int32_t> value, bool
} else {
storageMap.erase(key);
}
g_events->eventCreatureOnUpdateStorage(this, key, oldValue, value, isSpawn);
tfs::events::creature::onUpdateStorage(this, key, oldValue, value, isSpawn);
}

std::optional<int32_t> Creature::getStorageValue(uint32_t key) const
Expand Down
Loading
Loading