mirror of
https://github.com/ErikasKontenis/SabrehavenServer.git
synced 2025-12-17 23:27:11 +01:00
done with most important files comparison
This commit is contained in:
228
src/game.cpp
228
src/game.cpp
@@ -232,7 +232,7 @@ Thing* Game::internalGetThing(Player* player, const Position& pos, int32_t index
|
||||
}
|
||||
|
||||
case STACKPOS_USETARGET: {
|
||||
thing = tile->getTopCreature();
|
||||
thing = tile->getTopVisibleCreature(player);
|
||||
if (!thing) {
|
||||
thing = tile->getUseItem(index);
|
||||
}
|
||||
@@ -280,9 +280,10 @@ Thing* Game::internalGetThing(Player* player, const Position& pos, int32_t index
|
||||
}
|
||||
|
||||
int32_t subType;
|
||||
if (it.isFluidContainer()) {
|
||||
subType = static_cast<FluidTypes_t>(index);
|
||||
} else {
|
||||
if (it.isFluidContainer() && index < static_cast<int32_t>(sizeof(reverseFluidMap) / sizeof(uint8_t))) {
|
||||
subType = reverseFluidMap[index];
|
||||
}
|
||||
else {
|
||||
subType = -1;
|
||||
}
|
||||
|
||||
@@ -501,15 +502,15 @@ bool Game::placeCreature(Creature* creature, const Position& pos, bool extendedP
|
||||
return false;
|
||||
}
|
||||
|
||||
SpectatorVec list;
|
||||
map.getSpectators(list, creature->getPosition(), true);
|
||||
for (Creature* spectator : list) {
|
||||
SpectatorVec spectators;
|
||||
map.getSpectators(spectators, creature->getPosition(), true);
|
||||
for (Creature* spectator : spectators) {
|
||||
if (Player* tmpPlayer = spectator->getPlayer()) {
|
||||
tmpPlayer->sendCreatureAppear(creature, creature->getPosition(), true);
|
||||
}
|
||||
}
|
||||
|
||||
for (Creature* spectator : list) {
|
||||
for (Creature* spectator : spectators) {
|
||||
spectator->onCreatureAppear(creature, true);
|
||||
}
|
||||
|
||||
@@ -530,9 +531,9 @@ bool Game::removeCreature(Creature* creature, bool isLogout/* = true*/)
|
||||
|
||||
std::vector<int32_t> oldStackPosVector;
|
||||
|
||||
SpectatorVec list;
|
||||
map.getSpectators(list, tile->getPosition(), true);
|
||||
for (Creature* spectator : list) {
|
||||
SpectatorVec spectators;
|
||||
map.getSpectators(spectators, tile->getPosition(), true);
|
||||
for (Creature* spectator : spectators) {
|
||||
if (Player* player = spectator->getPlayer()) {
|
||||
oldStackPosVector.push_back(player->canSeeCreature(creature) ? tile->getStackposOfCreature(player, creature) : -1);
|
||||
}
|
||||
@@ -544,14 +545,14 @@ bool Game::removeCreature(Creature* creature, bool isLogout/* = true*/)
|
||||
|
||||
//send to client
|
||||
size_t i = 0;
|
||||
for (Creature* spectator : list) {
|
||||
for (Creature* spectator : spectators) {
|
||||
if (Player* player = spectator->getPlayer()) {
|
||||
player->sendRemoveTileThing(tilePosition, oldStackPosVector[i++]);
|
||||
}
|
||||
}
|
||||
|
||||
//event method
|
||||
for (Creature* spectator : list) {
|
||||
for (Creature* spectator : spectators) {
|
||||
spectator->onRemoveCreature(creature, isLogout);
|
||||
}
|
||||
|
||||
@@ -564,7 +565,7 @@ bool Game::removeCreature(Creature* creature, bool isLogout/* = true*/)
|
||||
removeCreatureCheck(creature);
|
||||
|
||||
for (Creature* summon : creature->summons) {
|
||||
summon->setLossSkill(false);
|
||||
summon->setSkillLoss(false);
|
||||
removeCreature(summon);
|
||||
}
|
||||
return true;
|
||||
@@ -1823,6 +1824,11 @@ void Game::playerOpenPrivateChannel(uint32_t playerId, std::string& receiver)
|
||||
return;
|
||||
}
|
||||
|
||||
if (player->getName() == receiver) {
|
||||
player->sendCancelMessage("You cannot set up a private message channel with yourself.");
|
||||
return;
|
||||
}
|
||||
|
||||
player->sendOpenPrivateChannel(receiver);
|
||||
}
|
||||
|
||||
@@ -2450,10 +2456,10 @@ void Game::playerAcceptTrade(uint32_t playerId)
|
||||
player->setTradeState(TRADE_ACCEPT);
|
||||
|
||||
if (tradePartner->getTradeState() == TRADE_ACCEPT) {
|
||||
Item* tradeItem1 = player->tradeItem;
|
||||
Item* tradeItem2 = tradePartner->tradeItem;
|
||||
Item* playerTradeItem = player->tradeItem;
|
||||
Item* partnerTradeItem = tradePartner->tradeItem;
|
||||
|
||||
if (!g_events->eventPlayerOnTradeAccept(player, tradePartner, tradeItem1, tradeItem2)) {
|
||||
if (!g_events->eventPlayerOnTradeAccept(player, tradePartner, playerTradeItem, partnerTradeItem)) {
|
||||
internalCloseTrade(player);
|
||||
return;
|
||||
}
|
||||
@@ -2461,13 +2467,13 @@ void Game::playerAcceptTrade(uint32_t playerId)
|
||||
player->setTradeState(TRADE_TRANSFER);
|
||||
tradePartner->setTradeState(TRADE_TRANSFER);
|
||||
|
||||
auto it = tradeItems.find(tradeItem1);
|
||||
auto it = tradeItems.find(playerTradeItem);
|
||||
if (it != tradeItems.end()) {
|
||||
ReleaseItem(it->first);
|
||||
tradeItems.erase(it);
|
||||
}
|
||||
|
||||
it = tradeItems.find(tradeItem2);
|
||||
it = tradeItems.find(partnerTradeItem);
|
||||
if (it != tradeItems.end()) {
|
||||
ReleaseItem(it->first);
|
||||
tradeItems.erase(it);
|
||||
@@ -2475,24 +2481,24 @@ void Game::playerAcceptTrade(uint32_t playerId)
|
||||
|
||||
bool isSuccess = false;
|
||||
|
||||
ReturnValue ret1 = internalAddItem(tradePartner, tradeItem1, INDEX_WHEREEVER, 0, true);
|
||||
ReturnValue ret2 = internalAddItem(player, tradeItem2, INDEX_WHEREEVER, 0, true);
|
||||
if (ret1 == RETURNVALUE_NOERROR && ret2 == RETURNVALUE_NOERROR) {
|
||||
ret1 = internalRemoveItem(tradeItem1, tradeItem1->getItemCount(), true);
|
||||
ret2 = internalRemoveItem(tradeItem2, tradeItem2->getItemCount(), true);
|
||||
if (ret1 == RETURNVALUE_NOERROR && ret2 == RETURNVALUE_NOERROR) {
|
||||
Cylinder* cylinder1 = tradeItem1->getParent();
|
||||
Cylinder* cylinder2 = tradeItem2->getParent();
|
||||
ReturnValue tradePartnerRet = internalAddItem(tradePartner, playerTradeItem, INDEX_WHEREEVER, 0, true);
|
||||
ReturnValue playerRet = internalAddItem(player, partnerTradeItem, INDEX_WHEREEVER, 0, true);
|
||||
if (tradePartnerRet == RETURNVALUE_NOERROR && playerRet == RETURNVALUE_NOERROR) {
|
||||
tradePartnerRet = internalRemoveItem(playerTradeItem, playerTradeItem->getItemCount(), true);
|
||||
playerRet = internalRemoveItem(partnerTradeItem, partnerTradeItem->getItemCount(), true);
|
||||
if (tradePartnerRet == RETURNVALUE_NOERROR && playerRet == RETURNVALUE_NOERROR) {
|
||||
Cylinder* cylinder1 = playerTradeItem->getParent();
|
||||
Cylinder* cylinder2 = partnerTradeItem->getParent();
|
||||
|
||||
uint32_t count1 = tradeItem1->getItemCount();
|
||||
uint32_t count2 = tradeItem2->getItemCount();
|
||||
uint32_t count1 = playerTradeItem->getItemCount();
|
||||
uint32_t count2 = partnerTradeItem->getItemCount();
|
||||
|
||||
ret1 = internalMoveItem(cylinder1, tradePartner, INDEX_WHEREEVER, tradeItem1, count1, nullptr, FLAG_IGNOREAUTOSTACK, nullptr, tradeItem2);
|
||||
if (ret1 == RETURNVALUE_NOERROR) {
|
||||
internalMoveItem(cylinder2, player, INDEX_WHEREEVER, tradeItem2, count2, nullptr, FLAG_IGNOREAUTOSTACK);
|
||||
tradePartnerRet = internalMoveItem(cylinder1, tradePartner, INDEX_WHEREEVER, playerTradeItem, count1, nullptr, FLAG_IGNOREAUTOSTACK, nullptr, partnerTradeItem);
|
||||
if (tradePartnerRet == RETURNVALUE_NOERROR) {
|
||||
internalMoveItem(cylinder2, player, INDEX_WHEREEVER, partnerTradeItem, count2, nullptr, FLAG_IGNOREAUTOSTACK);
|
||||
|
||||
tradeItem1->onTradeEvent(ON_TRADE_TRANSFER, tradePartner);
|
||||
tradeItem2->onTradeEvent(ON_TRADE_TRANSFER, player);
|
||||
playerTradeItem->onTradeEvent(ON_TRADE_TRANSFER, tradePartner);
|
||||
partnerTradeItem->onTradeEvent(ON_TRADE_TRANSFER, player);
|
||||
|
||||
isSuccess = true;
|
||||
}
|
||||
@@ -2503,13 +2509,13 @@ void Game::playerAcceptTrade(uint32_t playerId)
|
||||
std::string errorDescription;
|
||||
|
||||
if (tradePartner->tradeItem) {
|
||||
errorDescription = getTradeErrorDescription(ret1, tradeItem1);
|
||||
errorDescription = getTradeErrorDescription(tradePartnerRet, playerTradeItem);
|
||||
tradePartner->sendTextMessage(MESSAGE_EVENT_ADVANCE, errorDescription);
|
||||
tradePartner->tradeItem->onTradeEvent(ON_TRADE_CANCEL, tradePartner);
|
||||
}
|
||||
|
||||
if (player->tradeItem) {
|
||||
errorDescription = getTradeErrorDescription(ret2, tradeItem2);
|
||||
errorDescription = getTradeErrorDescription(playerRet, partnerTradeItem);
|
||||
player->sendTextMessage(MESSAGE_EVENT_ADVANCE, errorDescription);
|
||||
player->tradeItem->onTradeEvent(ON_TRADE_CANCEL, player);
|
||||
}
|
||||
@@ -3004,13 +3010,13 @@ bool Game::playerSaySpell(Player* player, SpeakClasses type, const std::string&
|
||||
|
||||
void Game::playerWhisper(Player* player, const std::string& text)
|
||||
{
|
||||
SpectatorVec list;
|
||||
map.getSpectators(list, player->getPosition(), false, false,
|
||||
SpectatorVec spectators;
|
||||
map.getSpectators(spectators, player->getPosition(), false, false,
|
||||
Map::maxClientViewportX, Map::maxClientViewportX,
|
||||
Map::maxClientViewportY, Map::maxClientViewportY);
|
||||
|
||||
//send to client
|
||||
for (Creature* spectator : list) {
|
||||
for (Creature* spectator : spectators) {
|
||||
if (Player* spectatorPlayer = spectator->getPlayer()) {
|
||||
if (!Position::areInRange<1, 1>(player->getPosition(), spectatorPlayer->getPosition())) {
|
||||
spectatorPlayer->sendCreatureSay(player, TALKTYPE_WHISPER, "pspsps");
|
||||
@@ -3021,7 +3027,7 @@ void Game::playerWhisper(Player* player, const std::string& text)
|
||||
}
|
||||
|
||||
//event method
|
||||
for (Creature* spectator : list) {
|
||||
for (Creature* spectator : spectators) {
|
||||
spectator->onCreatureSay(player, TALKTYPE_WHISPER, text);
|
||||
}
|
||||
}
|
||||
@@ -3094,16 +3100,16 @@ bool Game::internalCreatureTurn(Creature* creature, Direction dir)
|
||||
creature->setDirection(dir);
|
||||
|
||||
//send to client
|
||||
SpectatorVec list;
|
||||
map.getSpectators(list, creature->getPosition(), true, true);
|
||||
for (Creature* spectator : list) {
|
||||
SpectatorVec spectators;
|
||||
map.getSpectators(spectators, creature->getPosition(), true, true);
|
||||
for (Creature* spectator : spectators) {
|
||||
spectator->getPlayer()->sendCreatureTurn(creature);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Game::internalCreatureSay(Creature* creature, SpeakClasses type, const std::string& text,
|
||||
bool ghostMode, SpectatorVec* listPtr/* = nullptr*/, const Position* pos/* = nullptr*/)
|
||||
bool ghostMode, SpectatorVec* spectatorsPtr/* = nullptr*/, const Position* pos/* = nullptr*/)
|
||||
{
|
||||
if (text.empty()) {
|
||||
return false;
|
||||
@@ -3113,26 +3119,26 @@ bool Game::internalCreatureSay(Creature* creature, SpeakClasses type, const std:
|
||||
pos = &creature->getPosition();
|
||||
}
|
||||
|
||||
SpectatorVec list;
|
||||
SpectatorVec spectators;
|
||||
|
||||
if (!listPtr || listPtr->empty()) {
|
||||
if (!spectatorsPtr || spectatorsPtr->empty()) {
|
||||
// This somewhat complex construct ensures that the cached SpectatorVec
|
||||
// is used if available and if it can be used, else a local vector is
|
||||
// used (hopefully the compiler will optimize away the construction of
|
||||
// the temporary when it's not used).
|
||||
if (type != TALKTYPE_YELL && type != TALKTYPE_MONSTER_YELL) {
|
||||
map.getSpectators(list, *pos, false, false,
|
||||
map.getSpectators(spectators, *pos, false, false,
|
||||
Map::maxClientViewportX, Map::maxClientViewportX,
|
||||
Map::maxClientViewportY, Map::maxClientViewportY);
|
||||
} else {
|
||||
map.getSpectators(list, *pos, true, false, 30, 30, 30, 30);
|
||||
map.getSpectators(spectators, *pos, true, false, 30, 30, 30, 30);
|
||||
}
|
||||
} else {
|
||||
list = (*listPtr);
|
||||
spectators = (*spectatorsPtr);
|
||||
}
|
||||
|
||||
//send to client
|
||||
for (Creature* spectator : list) {
|
||||
for (Creature* spectator : spectators) {
|
||||
if (Player* tmpPlayer = spectator->getPlayer()) {
|
||||
if (!ghostMode || tmpPlayer->canSeeCreature(creature)) {
|
||||
tmpPlayer->sendCreatureSay(creature, type, text, pos);
|
||||
@@ -3141,7 +3147,7 @@ bool Game::internalCreatureSay(Creature* creature, SpeakClasses type, const std:
|
||||
}
|
||||
|
||||
//event method
|
||||
for (Creature* spectator : list) {
|
||||
for (Creature* spectator : spectators) {
|
||||
spectator->onCreatureSay(creature, type, text);
|
||||
}
|
||||
return true;
|
||||
@@ -3225,9 +3231,9 @@ void Game::changeSpeed(Creature* creature, int32_t varSpeedDelta)
|
||||
creature->setSpeed(varSpeedDelta);
|
||||
|
||||
//send to clients
|
||||
SpectatorVec list;
|
||||
map.getSpectators(list, creature->getPosition(), false, true);
|
||||
for (Creature* spectator : list) {
|
||||
SpectatorVec spectators;
|
||||
map.getSpectators(spectators, creature->getPosition(), false, true);
|
||||
for (Creature* spectator : spectators) {
|
||||
spectator->getPlayer()->sendChangeSpeed(creature, creature->getStepSpeed());
|
||||
}
|
||||
}
|
||||
@@ -3245,9 +3251,9 @@ void Game::internalCreatureChangeOutfit(Creature* creature, const Outfit_t& outf
|
||||
}
|
||||
|
||||
//send to clients
|
||||
SpectatorVec list;
|
||||
map.getSpectators(list, creature->getPosition(), true, true);
|
||||
for (Creature* spectator : list) {
|
||||
SpectatorVec spectators;
|
||||
map.getSpectators(spectators, creature->getPosition(), true, true);
|
||||
for (Creature* spectator : spectators) {
|
||||
spectator->getPlayer()->sendCreatureChangeOutfit(creature, outfit);
|
||||
}
|
||||
}
|
||||
@@ -3255,9 +3261,9 @@ void Game::internalCreatureChangeOutfit(Creature* creature, const Outfit_t& outf
|
||||
void Game::internalCreatureChangeVisible(Creature* creature, bool visible)
|
||||
{
|
||||
//send to clients
|
||||
SpectatorVec list;
|
||||
map.getSpectators(list, creature->getPosition(), true, true);
|
||||
for (Creature* spectator : list) {
|
||||
SpectatorVec spectators;
|
||||
map.getSpectators(spectators, creature->getPosition(), true, true);
|
||||
for (Creature* spectator : spectators) {
|
||||
spectator->getPlayer()->sendCreatureChangeVisible(creature, visible);
|
||||
}
|
||||
}
|
||||
@@ -3265,9 +3271,9 @@ void Game::internalCreatureChangeVisible(Creature* creature, bool visible)
|
||||
void Game::changeLight(const Creature* creature)
|
||||
{
|
||||
//send to clients
|
||||
SpectatorVec list;
|
||||
map.getSpectators(list, creature->getPosition(), true, true);
|
||||
for (Creature* spectator : list) {
|
||||
SpectatorVec spectators;
|
||||
map.getSpectators(spectators, creature->getPosition(), true, true);
|
||||
for (Creature* spectator : spectators) {
|
||||
spectator->getPlayer()->sendCreatureLight(creature);
|
||||
}
|
||||
}
|
||||
@@ -3464,7 +3470,7 @@ bool Game::combatChangeHealth(Creature* attacker, Creature* target, CombatDamage
|
||||
return true;
|
||||
}
|
||||
Player* targetPlayer = target->getPlayer();
|
||||
SpectatorVec list;
|
||||
SpectatorVec spectators;
|
||||
if (target->hasCondition(CONDITION_MANASHIELD) && damage.type != COMBAT_UNDEFINEDDAMAGE) {
|
||||
int32_t manaDamage = std::min<int32_t>(targetPlayer->getMana(), healthChange);
|
||||
if (manaDamage != 0) {
|
||||
@@ -3482,8 +3488,8 @@ bool Game::combatChangeHealth(Creature* attacker, Creature* target, CombatDamage
|
||||
}
|
||||
}
|
||||
targetPlayer->drainMana(attacker, manaDamage);
|
||||
map.getSpectators(list, targetPos, true, true);
|
||||
addMagicEffect(list, targetPos, CONST_ME_LOSEENERGY);
|
||||
map.getSpectators(spectators, targetPos, true, true);
|
||||
addMagicEffect(spectators, targetPos, CONST_ME_LOSEENERGY);
|
||||
|
||||
std::string damageString = std::to_string(manaDamage);
|
||||
|
||||
@@ -3501,7 +3507,7 @@ bool Game::combatChangeHealth(Creature* attacker, Creature* target, CombatDamage
|
||||
targetPlayer->sendTextMessage(MESSAGE_EVENT_DEFAULT, ss.str());
|
||||
}
|
||||
|
||||
for (Creature* spectator : list) {
|
||||
for (Creature* spectator : spectators) {
|
||||
Player* tmpPlayer = spectator->getPlayer();
|
||||
tmpPlayer->sendAnimatedText(targetPos, TEXTCOLOR_BLUE, damageString);
|
||||
}
|
||||
@@ -3528,8 +3534,8 @@ bool Game::combatChangeHealth(Creature* attacker, Creature* target, CombatDamage
|
||||
return true;
|
||||
}
|
||||
|
||||
if (list.empty()) {
|
||||
map.getSpectators(list, targetPos, true, true);
|
||||
if (spectators.empty()) {
|
||||
map.getSpectators(spectators, targetPos, true, true);
|
||||
}
|
||||
|
||||
TextColor_t color = TEXTCOLOR_NONE;
|
||||
@@ -3537,7 +3543,7 @@ bool Game::combatChangeHealth(Creature* attacker, Creature* target, CombatDamage
|
||||
if (damage.value) {
|
||||
combatGetTypeInfo(damage.type, target, color, hitEffect);
|
||||
if (hitEffect != CONST_ME_NONE) {
|
||||
addMagicEffect(list, targetPos, hitEffect);
|
||||
addMagicEffect(spectators, targetPos, hitEffect);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3558,7 +3564,7 @@ bool Game::combatChangeHealth(Creature* attacker, Creature* target, CombatDamage
|
||||
}
|
||||
|
||||
std::string realDamageStr = std::to_string(realDamage);
|
||||
for (Creature* spectator : list) {
|
||||
for (Creature* spectator : spectators) {
|
||||
Player* tmpPlayer = spectator->getPlayer();
|
||||
tmpPlayer->sendAnimatedText(targetPos, color, realDamageStr);
|
||||
}
|
||||
@@ -3573,7 +3579,7 @@ bool Game::combatChangeHealth(Creature* attacker, Creature* target, CombatDamage
|
||||
}
|
||||
|
||||
target->drainHealth(attacker, realDamage);
|
||||
addCreatureHealth(list, target);
|
||||
addCreatureHealth(spectators, target);
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -3642,8 +3648,8 @@ bool Game::combatChangeMana(Creature* attacker, Creature* target, CombatDamage&
|
||||
|
||||
std::string damageString = std::to_string(manaLoss);
|
||||
|
||||
SpectatorVec list;
|
||||
map.getSpectators(list, targetPos, false, true);
|
||||
SpectatorVec spectators;
|
||||
map.getSpectators(spectators, targetPos, false, true);
|
||||
if (targetPlayer) {
|
||||
std::stringstream ss;
|
||||
if (!attacker) {
|
||||
@@ -3658,7 +3664,7 @@ bool Game::combatChangeMana(Creature* attacker, Creature* target, CombatDamage&
|
||||
targetPlayer->sendTextMessage(MESSAGE_EVENT_DEFAULT, ss.str());
|
||||
}
|
||||
|
||||
for (Creature* spectator : list) {
|
||||
for (Creature* spectator : spectators) {
|
||||
Player* tmpPlayer = spectator->getPlayer();
|
||||
tmpPlayer->sendAnimatedText(targetPos, TEXTCOLOR_BLUE, damageString);
|
||||
}
|
||||
@@ -3669,14 +3675,14 @@ bool Game::combatChangeMana(Creature* attacker, Creature* target, CombatDamage&
|
||||
|
||||
void Game::addCreatureHealth(const Creature* target)
|
||||
{
|
||||
SpectatorVec list;
|
||||
map.getSpectators(list, target->getPosition(), true, true);
|
||||
addCreatureHealth(list, target);
|
||||
SpectatorVec spectators;
|
||||
map.getSpectators(spectators, target->getPosition(), true, true);
|
||||
addCreatureHealth(spectators, target);
|
||||
}
|
||||
|
||||
void Game::addCreatureHealth(const SpectatorVec& list, const Creature* target)
|
||||
void Game::addCreatureHealth(const SpectatorVec& spectators, const Creature* target)
|
||||
{
|
||||
for (Creature* spectator : list) {
|
||||
for (Creature* spectator : spectators) {
|
||||
if (Player* tmpPlayer = spectator->getPlayer()) {
|
||||
tmpPlayer->sendCreatureHealth(target);
|
||||
}
|
||||
@@ -3685,14 +3691,14 @@ void Game::addCreatureHealth(const SpectatorVec& list, const Creature* target)
|
||||
|
||||
void Game::addMagicEffect(const Position& pos, uint8_t effect)
|
||||
{
|
||||
SpectatorVec list;
|
||||
map.getSpectators(list, pos, true, true);
|
||||
addMagicEffect(list, pos, effect);
|
||||
SpectatorVec spectators;
|
||||
map.getSpectators(spectators, pos, true, true);
|
||||
addMagicEffect(spectators, pos, effect);
|
||||
}
|
||||
|
||||
void Game::addMagicEffect(const SpectatorVec& list, const Position& pos, uint8_t effect)
|
||||
void Game::addMagicEffect(const SpectatorVec& spectators, const Position& pos, uint8_t effect)
|
||||
{
|
||||
for (Creature* spectator : list) {
|
||||
for (Creature* spectator : spectators) {
|
||||
if (Player* tmpPlayer = spectator->getPlayer()) {
|
||||
tmpPlayer->sendMagicEffect(pos, effect);
|
||||
}
|
||||
@@ -3701,15 +3707,15 @@ void Game::addMagicEffect(const SpectatorVec& list, const Position& pos, uint8_t
|
||||
|
||||
void Game::addDistanceEffect(const Position& fromPos, const Position& toPos, uint8_t effect)
|
||||
{
|
||||
SpectatorVec list;
|
||||
map.getSpectators(list, fromPos, false, true);
|
||||
map.getSpectators(list, toPos, false, true);
|
||||
addDistanceEffect(list, fromPos, toPos, effect);
|
||||
SpectatorVec spectators;
|
||||
map.getSpectators(spectators, fromPos, false, true);
|
||||
map.getSpectators(spectators, toPos, false, true);
|
||||
addDistanceEffect(spectators, fromPos, toPos, effect);
|
||||
}
|
||||
|
||||
void Game::addDistanceEffect(const SpectatorVec& list, const Position& fromPos, const Position& toPos, uint8_t effect)
|
||||
void Game::addDistanceEffect(const SpectatorVec& spectators, const Position& fromPos, const Position& toPos, uint8_t effect)
|
||||
{
|
||||
for (Creature* spectator : list) {
|
||||
for (Creature* spectator : spectators) {
|
||||
if (Player* tmpPlayer = spectator->getPlayer()) {
|
||||
tmpPlayer->sendDistanceShoot(fromPos, toPos, effect);
|
||||
}
|
||||
@@ -3718,14 +3724,14 @@ void Game::addDistanceEffect(const SpectatorVec& list, const Position& fromPos,
|
||||
|
||||
void Game::addAnimatedText(const Position& pos, uint8_t color, const std::string& text)
|
||||
{
|
||||
SpectatorVec list;
|
||||
map.getSpectators(list, pos, false, true);
|
||||
addAnimatedText(list, pos, color, text);
|
||||
SpectatorVec spectators;
|
||||
map.getSpectators(spectators, pos, false, true);
|
||||
addAnimatedText(spectators, pos, color, text);
|
||||
}
|
||||
|
||||
void Game::addAnimatedText(const SpectatorVec& list, const Position& pos, uint8_t color, const std::string& text)
|
||||
void Game::addAnimatedText(const SpectatorVec& spectators, const Position& pos, uint8_t color, const std::string& text)
|
||||
{
|
||||
for (Creature* spectator : list) {
|
||||
for (Creature* spectator : spectators) {
|
||||
if (Player* tmpPlayer = spectator->getPlayer()) {
|
||||
tmpPlayer->sendAnimatedText(pos, color, text);
|
||||
}
|
||||
@@ -3734,10 +3740,10 @@ void Game::addAnimatedText(const SpectatorVec& list, const Position& pos, uint8_
|
||||
|
||||
void Game::addMonsterSayText(const Position& pos, const std::string& text)
|
||||
{
|
||||
SpectatorVec list;
|
||||
map.getSpectators(list, pos, false, true);
|
||||
SpectatorVec spectators;
|
||||
map.getSpectators(spectators, pos, false, true);
|
||||
|
||||
for (Creature* spectator : list) {
|
||||
for (Creature* spectator : spectators) {
|
||||
if (Player* tmpPlayer = spectator->getPlayer()) {
|
||||
tmpPlayer->sendCreatureSay(tmpPlayer, TALKTYPE_MONSTER_SAY, text, &pos);
|
||||
}
|
||||
@@ -3867,8 +3873,7 @@ void Game::checkLight()
|
||||
}
|
||||
|
||||
if (lightChange) {
|
||||
LightInfo lightInfo;
|
||||
getWorldLightInfo(lightInfo);
|
||||
LightInfo lightInfo = getWorldLightInfo();
|
||||
|
||||
for (const auto& it : players) {
|
||||
it.second->sendWorldLight(lightInfo);
|
||||
@@ -3876,10 +3881,9 @@ void Game::checkLight()
|
||||
}
|
||||
}
|
||||
|
||||
void Game::getWorldLightInfo(LightInfo& lightInfo) const
|
||||
LightInfo Game::getWorldLightInfo() const
|
||||
{
|
||||
lightInfo.level = lightLevel;
|
||||
lightInfo.color = 0xD7;
|
||||
return { lightLevel, 0xD7 };
|
||||
}
|
||||
|
||||
void Game::shutdown()
|
||||
@@ -3952,18 +3956,18 @@ void Game::updateCreatureSkull(const Creature* creature)
|
||||
return;
|
||||
}
|
||||
|
||||
SpectatorVec list;
|
||||
map.getSpectators(list, creature->getPosition(), true, true);
|
||||
for (Creature* spectator : list) {
|
||||
SpectatorVec spectators;
|
||||
map.getSpectators(spectators, creature->getPosition(), true, true);
|
||||
for (Creature* spectator : spectators) {
|
||||
spectator->getPlayer()->sendCreatureSkull(creature);
|
||||
}
|
||||
}
|
||||
|
||||
void Game::updatePlayerShield(Player* player)
|
||||
{
|
||||
SpectatorVec list;
|
||||
map.getSpectators(list, player->getPosition(), true, true);
|
||||
for (Creature* spectator : list) {
|
||||
SpectatorVec spectators;
|
||||
map.getSpectators(spectators, player->getPosition(), true, true);
|
||||
for (Creature* spectator : spectators) {
|
||||
spectator->getPlayer()->sendCreatureShield(player);
|
||||
}
|
||||
}
|
||||
@@ -4137,6 +4141,10 @@ bool Game::loadExperienceStages()
|
||||
|
||||
void Game::playerInviteToParty(uint32_t playerId, uint32_t invitedId)
|
||||
{
|
||||
if (playerId == invitedId) {
|
||||
return;
|
||||
}
|
||||
|
||||
Player* player = getPlayerByID(playerId);
|
||||
if (!player) {
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user