mirror of
https://github.com/ErikasKontenis/SabrehavenServer.git
synced 2025-04-30 01:29:21 +02:00
done with most important files comparison
This commit is contained in:
parent
447b858551
commit
37d8a76f06
@ -1,6 +1,7 @@
|
|||||||
-- Combat settings
|
-- Combat settings
|
||||||
-- NOTE: valid values for worldType are: "pvp", "no-pvp" and "pvp-enforced"
|
-- NOTE: valid values for worldType are: "pvp", "no-pvp" and "pvp-enforced"
|
||||||
worldType = "pvp"
|
worldType = "pvp"
|
||||||
|
hotkeyAimbotEnabled = true
|
||||||
protectionLevel = 1
|
protectionLevel = 1
|
||||||
pzLocked = 60000
|
pzLocked = 60000
|
||||||
removeChargesFromRunes = true
|
removeChargesFromRunes = true
|
||||||
@ -65,7 +66,7 @@ mysqlSock = ""
|
|||||||
|
|
||||||
-- Misc.
|
-- Misc.
|
||||||
allowChangeOutfit = true
|
allowChangeOutfit = true
|
||||||
freePremium = false
|
freePremium = true
|
||||||
kickIdlePlayerAfterMinutes = 15
|
kickIdlePlayerAfterMinutes = 15
|
||||||
maxMessageBuffer = 4
|
maxMessageBuffer = 4
|
||||||
showMonsterLoot = false
|
showMonsterLoot = false
|
||||||
|
@ -30,6 +30,7 @@ SET time_zone = "+00:00";
|
|||||||
|
|
||||||
CREATE TABLE `accounts` (
|
CREATE TABLE `accounts` (
|
||||||
`id` int(11) NOT NULL,
|
`id` int(11) NOT NULL,
|
||||||
|
`name` int(11) NOT NULL,
|
||||||
`password` char(40) NOT NULL,
|
`password` char(40) NOT NULL,
|
||||||
`type` int(11) NOT NULL DEFAULT '1',
|
`type` int(11) NOT NULL DEFAULT '1',
|
||||||
`premdays` int(11) NOT NULL DEFAULT '0',
|
`premdays` int(11) NOT NULL DEFAULT '0',
|
||||||
@ -40,8 +41,8 @@ CREATE TABLE `accounts` (
|
|||||||
-- Dumping data for table `accounts`
|
-- Dumping data for table `accounts`
|
||||||
--
|
--
|
||||||
|
|
||||||
INSERT INTO `accounts` (`id`, `password`, `type`, `premdays`, `lastday`) VALUES
|
INSERT INTO `accounts` (`id`, `name`, `password`, `type`, `premdays`, `lastday`) VALUES
|
||||||
(1234567, '41da8bef22aaef9d7c5821fa0f0de7cccc4dda4d', 5, 497, 1547320555);
|
(1, 1234567, '41da8bef22aaef9d7c5821fa0f0de7cccc4dda4d', 5, 497, 1547320555);
|
||||||
|
|
||||||
-- --------------------------------------------------------
|
-- --------------------------------------------------------
|
||||||
|
|
||||||
@ -7638,7 +7639,8 @@ INSERT INTO `tile_store` (`house_id`, `data`) VALUES
|
|||||||
-- Indexes for table `accounts`
|
-- Indexes for table `accounts`
|
||||||
--
|
--
|
||||||
ALTER TABLE `accounts`
|
ALTER TABLE `accounts`
|
||||||
ADD PRIMARY KEY (`id`);
|
ADD PRIMARY KEY (`id`)
|
||||||
|
ADD UNIQUE KEY `name` (`name`);
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Indexes for table `account_bans`
|
-- Indexes for table `account_bans`
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
|
|
||||||
struct Account {
|
struct Account {
|
||||||
std::vector<std::string> characters;
|
std::vector<std::string> characters;
|
||||||
|
uint32_t name;
|
||||||
time_t lastDay = 0;
|
time_t lastDay = 0;
|
||||||
uint32_t id = 0;
|
uint32_t id = 0;
|
||||||
uint16_t premiumDays = 0;
|
uint16_t premiumDays = 0;
|
||||||
|
@ -1235,12 +1235,11 @@ bool ConditionLight::executeCondition(Creature* creature, int32_t interval)
|
|||||||
|
|
||||||
if (internalLightTicks >= lightChangeInterval) {
|
if (internalLightTicks >= lightChangeInterval) {
|
||||||
internalLightTicks = 0;
|
internalLightTicks = 0;
|
||||||
LightInfo creatureLight;
|
LightInfo lightInfo = creature->getCreatureLight();
|
||||||
creature->getCreatureLight(creatureLight);
|
|
||||||
|
|
||||||
if (creatureLight.level > 0) {
|
if (lightInfo.level > 0) {
|
||||||
--creatureLight.level;
|
--lightInfo.level;
|
||||||
creature->setCreatureLight(creatureLight);
|
creature->setCreatureLight(lightInfo);
|
||||||
g_game.changeLight(creature);
|
g_game.changeLight(creature);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
13
src/const.h
13
src/const.h
@ -129,6 +129,19 @@ enum FluidTypes_t : uint8_t
|
|||||||
FLUID_FRUITJUICE,
|
FLUID_FRUITJUICE,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const uint8_t reverseFluidMap[] = {
|
||||||
|
FLUID_NONE,
|
||||||
|
FLUID_WATER,
|
||||||
|
FLUID_MANAFLUID,
|
||||||
|
FLUID_BEER,
|
||||||
|
FLUID_NONE,
|
||||||
|
FLUID_LIFEFLUID,
|
||||||
|
FLUID_SLIME,
|
||||||
|
FLUID_NONE,
|
||||||
|
FLUID_LEMONADE,
|
||||||
|
FLUID_MILK,
|
||||||
|
};
|
||||||
|
|
||||||
enum FluidColor_t : uint8_t
|
enum FluidColor_t : uint8_t
|
||||||
{
|
{
|
||||||
FLUID_COLOR_NONE = 0,
|
FLUID_COLOR_NONE = 0,
|
||||||
|
@ -1085,7 +1085,7 @@ void Creature::onGainExperience(uint64_t gainExp, Creature* target)
|
|||||||
void Creature::addSummon(Creature* creature)
|
void Creature::addSummon(Creature* creature)
|
||||||
{
|
{
|
||||||
creature->setDropLoot(false);
|
creature->setDropLoot(false);
|
||||||
creature->setLossSkill(false);
|
creature->setSkillLoss(false);
|
||||||
creature->setMaster(this);
|
creature->setMaster(this);
|
||||||
creature->incrementReferenceCounter();
|
creature->incrementReferenceCounter();
|
||||||
summons.push_back(creature);
|
summons.push_back(creature);
|
||||||
@ -1096,7 +1096,7 @@ void Creature::removeSummon(Creature* creature)
|
|||||||
auto cit = std::find(summons.begin(), summons.end(), creature);
|
auto cit = std::find(summons.begin(), summons.end(), creature);
|
||||||
if (cit != summons.end()) {
|
if (cit != summons.end()) {
|
||||||
creature->setDropLoot(true);
|
creature->setDropLoot(true);
|
||||||
creature->setLossSkill(true);
|
creature->setSkillLoss(true);
|
||||||
creature->setMaster(nullptr);
|
creature->setMaster(nullptr);
|
||||||
creature->decrementReferenceCounter();
|
creature->decrementReferenceCounter();
|
||||||
summons.erase(cit);
|
summons.erase(cit);
|
||||||
@ -1364,9 +1364,9 @@ int64_t Creature::getEventStepTicks(bool onlyDelay) const
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Creature::getCreatureLight(LightInfo& light) const
|
LightInfo Creature::getCreatureLight() const
|
||||||
{
|
{
|
||||||
light = internalLight;
|
return internalLight;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Creature::setNormalCreatureLight()
|
void Creature::setNormalCreatureLight()
|
||||||
|
@ -355,7 +355,7 @@ class Creature : virtual public Thing
|
|||||||
virtual void onAttackedCreatureChangeZone(ZoneType_t zone);
|
virtual void onAttackedCreatureChangeZone(ZoneType_t zone);
|
||||||
virtual void onIdleStatus();
|
virtual void onIdleStatus();
|
||||||
|
|
||||||
virtual void getCreatureLight(LightInfo& light) const;
|
virtual LightInfo getCreatureLight() const;
|
||||||
virtual void setNormalCreatureLight();
|
virtual void setNormalCreatureLight();
|
||||||
void setCreatureLight(LightInfo light) {
|
void setCreatureLight(LightInfo light) {
|
||||||
internalLight = light;
|
internalLight = light;
|
||||||
@ -395,7 +395,7 @@ class Creature : virtual public Thing
|
|||||||
void setDropLoot(bool lootDrop) {
|
void setDropLoot(bool lootDrop) {
|
||||||
this->lootDrop = lootDrop;
|
this->lootDrop = lootDrop;
|
||||||
}
|
}
|
||||||
void setLossSkill(bool skillLoss) {
|
void setSkillLoss(bool skillLoss) {
|
||||||
this->skillLoss = skillLoss;
|
this->skillLoss = skillLoss;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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: {
|
case STACKPOS_USETARGET: {
|
||||||
thing = tile->getTopCreature();
|
thing = tile->getTopVisibleCreature(player);
|
||||||
if (!thing) {
|
if (!thing) {
|
||||||
thing = tile->getUseItem(index);
|
thing = tile->getUseItem(index);
|
||||||
}
|
}
|
||||||
@ -280,9 +280,10 @@ Thing* Game::internalGetThing(Player* player, const Position& pos, int32_t index
|
|||||||
}
|
}
|
||||||
|
|
||||||
int32_t subType;
|
int32_t subType;
|
||||||
if (it.isFluidContainer()) {
|
if (it.isFluidContainer() && index < static_cast<int32_t>(sizeof(reverseFluidMap) / sizeof(uint8_t))) {
|
||||||
subType = static_cast<FluidTypes_t>(index);
|
subType = reverseFluidMap[index];
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
subType = -1;
|
subType = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -501,15 +502,15 @@ bool Game::placeCreature(Creature* creature, const Position& pos, bool extendedP
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
SpectatorVec list;
|
SpectatorVec spectators;
|
||||||
map.getSpectators(list, creature->getPosition(), true);
|
map.getSpectators(spectators, creature->getPosition(), true);
|
||||||
for (Creature* spectator : list) {
|
for (Creature* spectator : spectators) {
|
||||||
if (Player* tmpPlayer = spectator->getPlayer()) {
|
if (Player* tmpPlayer = spectator->getPlayer()) {
|
||||||
tmpPlayer->sendCreatureAppear(creature, creature->getPosition(), true);
|
tmpPlayer->sendCreatureAppear(creature, creature->getPosition(), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Creature* spectator : list) {
|
for (Creature* spectator : spectators) {
|
||||||
spectator->onCreatureAppear(creature, true);
|
spectator->onCreatureAppear(creature, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -530,9 +531,9 @@ bool Game::removeCreature(Creature* creature, bool isLogout/* = true*/)
|
|||||||
|
|
||||||
std::vector<int32_t> oldStackPosVector;
|
std::vector<int32_t> oldStackPosVector;
|
||||||
|
|
||||||
SpectatorVec list;
|
SpectatorVec spectators;
|
||||||
map.getSpectators(list, tile->getPosition(), true);
|
map.getSpectators(spectators, tile->getPosition(), true);
|
||||||
for (Creature* spectator : list) {
|
for (Creature* spectator : spectators) {
|
||||||
if (Player* player = spectator->getPlayer()) {
|
if (Player* player = spectator->getPlayer()) {
|
||||||
oldStackPosVector.push_back(player->canSeeCreature(creature) ? tile->getStackposOfCreature(player, creature) : -1);
|
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
|
//send to client
|
||||||
size_t i = 0;
|
size_t i = 0;
|
||||||
for (Creature* spectator : list) {
|
for (Creature* spectator : spectators) {
|
||||||
if (Player* player = spectator->getPlayer()) {
|
if (Player* player = spectator->getPlayer()) {
|
||||||
player->sendRemoveTileThing(tilePosition, oldStackPosVector[i++]);
|
player->sendRemoveTileThing(tilePosition, oldStackPosVector[i++]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//event method
|
//event method
|
||||||
for (Creature* spectator : list) {
|
for (Creature* spectator : spectators) {
|
||||||
spectator->onRemoveCreature(creature, isLogout);
|
spectator->onRemoveCreature(creature, isLogout);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -564,7 +565,7 @@ bool Game::removeCreature(Creature* creature, bool isLogout/* = true*/)
|
|||||||
removeCreatureCheck(creature);
|
removeCreatureCheck(creature);
|
||||||
|
|
||||||
for (Creature* summon : creature->summons) {
|
for (Creature* summon : creature->summons) {
|
||||||
summon->setLossSkill(false);
|
summon->setSkillLoss(false);
|
||||||
removeCreature(summon);
|
removeCreature(summon);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -1823,6 +1824,11 @@ void Game::playerOpenPrivateChannel(uint32_t playerId, std::string& receiver)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (player->getName() == receiver) {
|
||||||
|
player->sendCancelMessage("You cannot set up a private message channel with yourself.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
player->sendOpenPrivateChannel(receiver);
|
player->sendOpenPrivateChannel(receiver);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2450,10 +2456,10 @@ void Game::playerAcceptTrade(uint32_t playerId)
|
|||||||
player->setTradeState(TRADE_ACCEPT);
|
player->setTradeState(TRADE_ACCEPT);
|
||||||
|
|
||||||
if (tradePartner->getTradeState() == TRADE_ACCEPT) {
|
if (tradePartner->getTradeState() == TRADE_ACCEPT) {
|
||||||
Item* tradeItem1 = player->tradeItem;
|
Item* playerTradeItem = player->tradeItem;
|
||||||
Item* tradeItem2 = tradePartner->tradeItem;
|
Item* partnerTradeItem = tradePartner->tradeItem;
|
||||||
|
|
||||||
if (!g_events->eventPlayerOnTradeAccept(player, tradePartner, tradeItem1, tradeItem2)) {
|
if (!g_events->eventPlayerOnTradeAccept(player, tradePartner, playerTradeItem, partnerTradeItem)) {
|
||||||
internalCloseTrade(player);
|
internalCloseTrade(player);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -2461,13 +2467,13 @@ void Game::playerAcceptTrade(uint32_t playerId)
|
|||||||
player->setTradeState(TRADE_TRANSFER);
|
player->setTradeState(TRADE_TRANSFER);
|
||||||
tradePartner->setTradeState(TRADE_TRANSFER);
|
tradePartner->setTradeState(TRADE_TRANSFER);
|
||||||
|
|
||||||
auto it = tradeItems.find(tradeItem1);
|
auto it = tradeItems.find(playerTradeItem);
|
||||||
if (it != tradeItems.end()) {
|
if (it != tradeItems.end()) {
|
||||||
ReleaseItem(it->first);
|
ReleaseItem(it->first);
|
||||||
tradeItems.erase(it);
|
tradeItems.erase(it);
|
||||||
}
|
}
|
||||||
|
|
||||||
it = tradeItems.find(tradeItem2);
|
it = tradeItems.find(partnerTradeItem);
|
||||||
if (it != tradeItems.end()) {
|
if (it != tradeItems.end()) {
|
||||||
ReleaseItem(it->first);
|
ReleaseItem(it->first);
|
||||||
tradeItems.erase(it);
|
tradeItems.erase(it);
|
||||||
@ -2475,24 +2481,24 @@ void Game::playerAcceptTrade(uint32_t playerId)
|
|||||||
|
|
||||||
bool isSuccess = false;
|
bool isSuccess = false;
|
||||||
|
|
||||||
ReturnValue ret1 = internalAddItem(tradePartner, tradeItem1, INDEX_WHEREEVER, 0, true);
|
ReturnValue tradePartnerRet = internalAddItem(tradePartner, playerTradeItem, INDEX_WHEREEVER, 0, true);
|
||||||
ReturnValue ret2 = internalAddItem(player, tradeItem2, INDEX_WHEREEVER, 0, true);
|
ReturnValue playerRet = internalAddItem(player, partnerTradeItem, INDEX_WHEREEVER, 0, true);
|
||||||
if (ret1 == RETURNVALUE_NOERROR && ret2 == RETURNVALUE_NOERROR) {
|
if (tradePartnerRet == RETURNVALUE_NOERROR && playerRet == RETURNVALUE_NOERROR) {
|
||||||
ret1 = internalRemoveItem(tradeItem1, tradeItem1->getItemCount(), true);
|
tradePartnerRet = internalRemoveItem(playerTradeItem, playerTradeItem->getItemCount(), true);
|
||||||
ret2 = internalRemoveItem(tradeItem2, tradeItem2->getItemCount(), true);
|
playerRet = internalRemoveItem(partnerTradeItem, partnerTradeItem->getItemCount(), true);
|
||||||
if (ret1 == RETURNVALUE_NOERROR && ret2 == RETURNVALUE_NOERROR) {
|
if (tradePartnerRet == RETURNVALUE_NOERROR && playerRet == RETURNVALUE_NOERROR) {
|
||||||
Cylinder* cylinder1 = tradeItem1->getParent();
|
Cylinder* cylinder1 = playerTradeItem->getParent();
|
||||||
Cylinder* cylinder2 = tradeItem2->getParent();
|
Cylinder* cylinder2 = partnerTradeItem->getParent();
|
||||||
|
|
||||||
uint32_t count1 = tradeItem1->getItemCount();
|
uint32_t count1 = playerTradeItem->getItemCount();
|
||||||
uint32_t count2 = tradeItem2->getItemCount();
|
uint32_t count2 = partnerTradeItem->getItemCount();
|
||||||
|
|
||||||
ret1 = internalMoveItem(cylinder1, tradePartner, INDEX_WHEREEVER, tradeItem1, count1, nullptr, FLAG_IGNOREAUTOSTACK, nullptr, tradeItem2);
|
tradePartnerRet = internalMoveItem(cylinder1, tradePartner, INDEX_WHEREEVER, playerTradeItem, count1, nullptr, FLAG_IGNOREAUTOSTACK, nullptr, partnerTradeItem);
|
||||||
if (ret1 == RETURNVALUE_NOERROR) {
|
if (tradePartnerRet == RETURNVALUE_NOERROR) {
|
||||||
internalMoveItem(cylinder2, player, INDEX_WHEREEVER, tradeItem2, count2, nullptr, FLAG_IGNOREAUTOSTACK);
|
internalMoveItem(cylinder2, player, INDEX_WHEREEVER, partnerTradeItem, count2, nullptr, FLAG_IGNOREAUTOSTACK);
|
||||||
|
|
||||||
tradeItem1->onTradeEvent(ON_TRADE_TRANSFER, tradePartner);
|
playerTradeItem->onTradeEvent(ON_TRADE_TRANSFER, tradePartner);
|
||||||
tradeItem2->onTradeEvent(ON_TRADE_TRANSFER, player);
|
partnerTradeItem->onTradeEvent(ON_TRADE_TRANSFER, player);
|
||||||
|
|
||||||
isSuccess = true;
|
isSuccess = true;
|
||||||
}
|
}
|
||||||
@ -2503,13 +2509,13 @@ void Game::playerAcceptTrade(uint32_t playerId)
|
|||||||
std::string errorDescription;
|
std::string errorDescription;
|
||||||
|
|
||||||
if (tradePartner->tradeItem) {
|
if (tradePartner->tradeItem) {
|
||||||
errorDescription = getTradeErrorDescription(ret1, tradeItem1);
|
errorDescription = getTradeErrorDescription(tradePartnerRet, playerTradeItem);
|
||||||
tradePartner->sendTextMessage(MESSAGE_EVENT_ADVANCE, errorDescription);
|
tradePartner->sendTextMessage(MESSAGE_EVENT_ADVANCE, errorDescription);
|
||||||
tradePartner->tradeItem->onTradeEvent(ON_TRADE_CANCEL, tradePartner);
|
tradePartner->tradeItem->onTradeEvent(ON_TRADE_CANCEL, tradePartner);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (player->tradeItem) {
|
if (player->tradeItem) {
|
||||||
errorDescription = getTradeErrorDescription(ret2, tradeItem2);
|
errorDescription = getTradeErrorDescription(playerRet, partnerTradeItem);
|
||||||
player->sendTextMessage(MESSAGE_EVENT_ADVANCE, errorDescription);
|
player->sendTextMessage(MESSAGE_EVENT_ADVANCE, errorDescription);
|
||||||
player->tradeItem->onTradeEvent(ON_TRADE_CANCEL, player);
|
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)
|
void Game::playerWhisper(Player* player, const std::string& text)
|
||||||
{
|
{
|
||||||
SpectatorVec list;
|
SpectatorVec spectators;
|
||||||
map.getSpectators(list, player->getPosition(), false, false,
|
map.getSpectators(spectators, player->getPosition(), false, false,
|
||||||
Map::maxClientViewportX, Map::maxClientViewportX,
|
Map::maxClientViewportX, Map::maxClientViewportX,
|
||||||
Map::maxClientViewportY, Map::maxClientViewportY);
|
Map::maxClientViewportY, Map::maxClientViewportY);
|
||||||
|
|
||||||
//send to client
|
//send to client
|
||||||
for (Creature* spectator : list) {
|
for (Creature* spectator : spectators) {
|
||||||
if (Player* spectatorPlayer = spectator->getPlayer()) {
|
if (Player* spectatorPlayer = spectator->getPlayer()) {
|
||||||
if (!Position::areInRange<1, 1>(player->getPosition(), spectatorPlayer->getPosition())) {
|
if (!Position::areInRange<1, 1>(player->getPosition(), spectatorPlayer->getPosition())) {
|
||||||
spectatorPlayer->sendCreatureSay(player, TALKTYPE_WHISPER, "pspsps");
|
spectatorPlayer->sendCreatureSay(player, TALKTYPE_WHISPER, "pspsps");
|
||||||
@ -3021,7 +3027,7 @@ void Game::playerWhisper(Player* player, const std::string& text)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//event method
|
//event method
|
||||||
for (Creature* spectator : list) {
|
for (Creature* spectator : spectators) {
|
||||||
spectator->onCreatureSay(player, TALKTYPE_WHISPER, text);
|
spectator->onCreatureSay(player, TALKTYPE_WHISPER, text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3094,16 +3100,16 @@ bool Game::internalCreatureTurn(Creature* creature, Direction dir)
|
|||||||
creature->setDirection(dir);
|
creature->setDirection(dir);
|
||||||
|
|
||||||
//send to client
|
//send to client
|
||||||
SpectatorVec list;
|
SpectatorVec spectators;
|
||||||
map.getSpectators(list, creature->getPosition(), true, true);
|
map.getSpectators(spectators, creature->getPosition(), true, true);
|
||||||
for (Creature* spectator : list) {
|
for (Creature* spectator : spectators) {
|
||||||
spectator->getPlayer()->sendCreatureTurn(creature);
|
spectator->getPlayer()->sendCreatureTurn(creature);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Game::internalCreatureSay(Creature* creature, SpeakClasses type, const std::string& text,
|
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()) {
|
if (text.empty()) {
|
||||||
return false;
|
return false;
|
||||||
@ -3113,26 +3119,26 @@ bool Game::internalCreatureSay(Creature* creature, SpeakClasses type, const std:
|
|||||||
pos = &creature->getPosition();
|
pos = &creature->getPosition();
|
||||||
}
|
}
|
||||||
|
|
||||||
SpectatorVec list;
|
SpectatorVec spectators;
|
||||||
|
|
||||||
if (!listPtr || listPtr->empty()) {
|
if (!spectatorsPtr || spectatorsPtr->empty()) {
|
||||||
// This somewhat complex construct ensures that the cached SpectatorVec
|
// This somewhat complex construct ensures that the cached SpectatorVec
|
||||||
// is used if available and if it can be used, else a local vector is
|
// 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
|
// used (hopefully the compiler will optimize away the construction of
|
||||||
// the temporary when it's not used).
|
// the temporary when it's not used).
|
||||||
if (type != TALKTYPE_YELL && type != TALKTYPE_MONSTER_YELL) {
|
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::maxClientViewportX, Map::maxClientViewportX,
|
||||||
Map::maxClientViewportY, Map::maxClientViewportY);
|
Map::maxClientViewportY, Map::maxClientViewportY);
|
||||||
} else {
|
} else {
|
||||||
map.getSpectators(list, *pos, true, false, 30, 30, 30, 30);
|
map.getSpectators(spectators, *pos, true, false, 30, 30, 30, 30);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
list = (*listPtr);
|
spectators = (*spectatorsPtr);
|
||||||
}
|
}
|
||||||
|
|
||||||
//send to client
|
//send to client
|
||||||
for (Creature* spectator : list) {
|
for (Creature* spectator : spectators) {
|
||||||
if (Player* tmpPlayer = spectator->getPlayer()) {
|
if (Player* tmpPlayer = spectator->getPlayer()) {
|
||||||
if (!ghostMode || tmpPlayer->canSeeCreature(creature)) {
|
if (!ghostMode || tmpPlayer->canSeeCreature(creature)) {
|
||||||
tmpPlayer->sendCreatureSay(creature, type, text, pos);
|
tmpPlayer->sendCreatureSay(creature, type, text, pos);
|
||||||
@ -3141,7 +3147,7 @@ bool Game::internalCreatureSay(Creature* creature, SpeakClasses type, const std:
|
|||||||
}
|
}
|
||||||
|
|
||||||
//event method
|
//event method
|
||||||
for (Creature* spectator : list) {
|
for (Creature* spectator : spectators) {
|
||||||
spectator->onCreatureSay(creature, type, text);
|
spectator->onCreatureSay(creature, type, text);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -3225,9 +3231,9 @@ void Game::changeSpeed(Creature* creature, int32_t varSpeedDelta)
|
|||||||
creature->setSpeed(varSpeedDelta);
|
creature->setSpeed(varSpeedDelta);
|
||||||
|
|
||||||
//send to clients
|
//send to clients
|
||||||
SpectatorVec list;
|
SpectatorVec spectators;
|
||||||
map.getSpectators(list, creature->getPosition(), false, true);
|
map.getSpectators(spectators, creature->getPosition(), false, true);
|
||||||
for (Creature* spectator : list) {
|
for (Creature* spectator : spectators) {
|
||||||
spectator->getPlayer()->sendChangeSpeed(creature, creature->getStepSpeed());
|
spectator->getPlayer()->sendChangeSpeed(creature, creature->getStepSpeed());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3245,9 +3251,9 @@ void Game::internalCreatureChangeOutfit(Creature* creature, const Outfit_t& outf
|
|||||||
}
|
}
|
||||||
|
|
||||||
//send to clients
|
//send to clients
|
||||||
SpectatorVec list;
|
SpectatorVec spectators;
|
||||||
map.getSpectators(list, creature->getPosition(), true, true);
|
map.getSpectators(spectators, creature->getPosition(), true, true);
|
||||||
for (Creature* spectator : list) {
|
for (Creature* spectator : spectators) {
|
||||||
spectator->getPlayer()->sendCreatureChangeOutfit(creature, outfit);
|
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)
|
void Game::internalCreatureChangeVisible(Creature* creature, bool visible)
|
||||||
{
|
{
|
||||||
//send to clients
|
//send to clients
|
||||||
SpectatorVec list;
|
SpectatorVec spectators;
|
||||||
map.getSpectators(list, creature->getPosition(), true, true);
|
map.getSpectators(spectators, creature->getPosition(), true, true);
|
||||||
for (Creature* spectator : list) {
|
for (Creature* spectator : spectators) {
|
||||||
spectator->getPlayer()->sendCreatureChangeVisible(creature, visible);
|
spectator->getPlayer()->sendCreatureChangeVisible(creature, visible);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3265,9 +3271,9 @@ void Game::internalCreatureChangeVisible(Creature* creature, bool visible)
|
|||||||
void Game::changeLight(const Creature* creature)
|
void Game::changeLight(const Creature* creature)
|
||||||
{
|
{
|
||||||
//send to clients
|
//send to clients
|
||||||
SpectatorVec list;
|
SpectatorVec spectators;
|
||||||
map.getSpectators(list, creature->getPosition(), true, true);
|
map.getSpectators(spectators, creature->getPosition(), true, true);
|
||||||
for (Creature* spectator : list) {
|
for (Creature* spectator : spectators) {
|
||||||
spectator->getPlayer()->sendCreatureLight(creature);
|
spectator->getPlayer()->sendCreatureLight(creature);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3464,7 +3470,7 @@ bool Game::combatChangeHealth(Creature* attacker, Creature* target, CombatDamage
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Player* targetPlayer = target->getPlayer();
|
Player* targetPlayer = target->getPlayer();
|
||||||
SpectatorVec list;
|
SpectatorVec spectators;
|
||||||
if (target->hasCondition(CONDITION_MANASHIELD) && damage.type != COMBAT_UNDEFINEDDAMAGE) {
|
if (target->hasCondition(CONDITION_MANASHIELD) && damage.type != COMBAT_UNDEFINEDDAMAGE) {
|
||||||
int32_t manaDamage = std::min<int32_t>(targetPlayer->getMana(), healthChange);
|
int32_t manaDamage = std::min<int32_t>(targetPlayer->getMana(), healthChange);
|
||||||
if (manaDamage != 0) {
|
if (manaDamage != 0) {
|
||||||
@ -3482,8 +3488,8 @@ bool Game::combatChangeHealth(Creature* attacker, Creature* target, CombatDamage
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
targetPlayer->drainMana(attacker, manaDamage);
|
targetPlayer->drainMana(attacker, manaDamage);
|
||||||
map.getSpectators(list, targetPos, true, true);
|
map.getSpectators(spectators, targetPos, true, true);
|
||||||
addMagicEffect(list, targetPos, CONST_ME_LOSEENERGY);
|
addMagicEffect(spectators, targetPos, CONST_ME_LOSEENERGY);
|
||||||
|
|
||||||
std::string damageString = std::to_string(manaDamage);
|
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());
|
targetPlayer->sendTextMessage(MESSAGE_EVENT_DEFAULT, ss.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Creature* spectator : list) {
|
for (Creature* spectator : spectators) {
|
||||||
Player* tmpPlayer = spectator->getPlayer();
|
Player* tmpPlayer = spectator->getPlayer();
|
||||||
tmpPlayer->sendAnimatedText(targetPos, TEXTCOLOR_BLUE, damageString);
|
tmpPlayer->sendAnimatedText(targetPos, TEXTCOLOR_BLUE, damageString);
|
||||||
}
|
}
|
||||||
@ -3528,8 +3534,8 @@ bool Game::combatChangeHealth(Creature* attacker, Creature* target, CombatDamage
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (list.empty()) {
|
if (spectators.empty()) {
|
||||||
map.getSpectators(list, targetPos, true, true);
|
map.getSpectators(spectators, targetPos, true, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
TextColor_t color = TEXTCOLOR_NONE;
|
TextColor_t color = TEXTCOLOR_NONE;
|
||||||
@ -3537,7 +3543,7 @@ bool Game::combatChangeHealth(Creature* attacker, Creature* target, CombatDamage
|
|||||||
if (damage.value) {
|
if (damage.value) {
|
||||||
combatGetTypeInfo(damage.type, target, color, hitEffect);
|
combatGetTypeInfo(damage.type, target, color, hitEffect);
|
||||||
if (hitEffect != CONST_ME_NONE) {
|
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);
|
std::string realDamageStr = std::to_string(realDamage);
|
||||||
for (Creature* spectator : list) {
|
for (Creature* spectator : spectators) {
|
||||||
Player* tmpPlayer = spectator->getPlayer();
|
Player* tmpPlayer = spectator->getPlayer();
|
||||||
tmpPlayer->sendAnimatedText(targetPos, color, realDamageStr);
|
tmpPlayer->sendAnimatedText(targetPos, color, realDamageStr);
|
||||||
}
|
}
|
||||||
@ -3573,7 +3579,7 @@ bool Game::combatChangeHealth(Creature* attacker, Creature* target, CombatDamage
|
|||||||
}
|
}
|
||||||
|
|
||||||
target->drainHealth(attacker, realDamage);
|
target->drainHealth(attacker, realDamage);
|
||||||
addCreatureHealth(list, target);
|
addCreatureHealth(spectators, target);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
@ -3642,8 +3648,8 @@ bool Game::combatChangeMana(Creature* attacker, Creature* target, CombatDamage&
|
|||||||
|
|
||||||
std::string damageString = std::to_string(manaLoss);
|
std::string damageString = std::to_string(manaLoss);
|
||||||
|
|
||||||
SpectatorVec list;
|
SpectatorVec spectators;
|
||||||
map.getSpectators(list, targetPos, false, true);
|
map.getSpectators(spectators, targetPos, false, true);
|
||||||
if (targetPlayer) {
|
if (targetPlayer) {
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
if (!attacker) {
|
if (!attacker) {
|
||||||
@ -3658,7 +3664,7 @@ bool Game::combatChangeMana(Creature* attacker, Creature* target, CombatDamage&
|
|||||||
targetPlayer->sendTextMessage(MESSAGE_EVENT_DEFAULT, ss.str());
|
targetPlayer->sendTextMessage(MESSAGE_EVENT_DEFAULT, ss.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Creature* spectator : list) {
|
for (Creature* spectator : spectators) {
|
||||||
Player* tmpPlayer = spectator->getPlayer();
|
Player* tmpPlayer = spectator->getPlayer();
|
||||||
tmpPlayer->sendAnimatedText(targetPos, TEXTCOLOR_BLUE, damageString);
|
tmpPlayer->sendAnimatedText(targetPos, TEXTCOLOR_BLUE, damageString);
|
||||||
}
|
}
|
||||||
@ -3669,14 +3675,14 @@ bool Game::combatChangeMana(Creature* attacker, Creature* target, CombatDamage&
|
|||||||
|
|
||||||
void Game::addCreatureHealth(const Creature* target)
|
void Game::addCreatureHealth(const Creature* target)
|
||||||
{
|
{
|
||||||
SpectatorVec list;
|
SpectatorVec spectators;
|
||||||
map.getSpectators(list, target->getPosition(), true, true);
|
map.getSpectators(spectators, target->getPosition(), true, true);
|
||||||
addCreatureHealth(list, target);
|
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()) {
|
if (Player* tmpPlayer = spectator->getPlayer()) {
|
||||||
tmpPlayer->sendCreatureHealth(target);
|
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)
|
void Game::addMagicEffect(const Position& pos, uint8_t effect)
|
||||||
{
|
{
|
||||||
SpectatorVec list;
|
SpectatorVec spectators;
|
||||||
map.getSpectators(list, pos, true, true);
|
map.getSpectators(spectators, pos, true, true);
|
||||||
addMagicEffect(list, pos, effect);
|
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()) {
|
if (Player* tmpPlayer = spectator->getPlayer()) {
|
||||||
tmpPlayer->sendMagicEffect(pos, effect);
|
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)
|
void Game::addDistanceEffect(const Position& fromPos, const Position& toPos, uint8_t effect)
|
||||||
{
|
{
|
||||||
SpectatorVec list;
|
SpectatorVec spectators;
|
||||||
map.getSpectators(list, fromPos, false, true);
|
map.getSpectators(spectators, fromPos, false, true);
|
||||||
map.getSpectators(list, toPos, false, true);
|
map.getSpectators(spectators, toPos, false, true);
|
||||||
addDistanceEffect(list, fromPos, toPos, effect);
|
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()) {
|
if (Player* tmpPlayer = spectator->getPlayer()) {
|
||||||
tmpPlayer->sendDistanceShoot(fromPos, toPos, effect);
|
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)
|
void Game::addAnimatedText(const Position& pos, uint8_t color, const std::string& text)
|
||||||
{
|
{
|
||||||
SpectatorVec list;
|
SpectatorVec spectators;
|
||||||
map.getSpectators(list, pos, false, true);
|
map.getSpectators(spectators, pos, false, true);
|
||||||
addAnimatedText(list, pos, color, text);
|
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()) {
|
if (Player* tmpPlayer = spectator->getPlayer()) {
|
||||||
tmpPlayer->sendAnimatedText(pos, color, text);
|
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)
|
void Game::addMonsterSayText(const Position& pos, const std::string& text)
|
||||||
{
|
{
|
||||||
SpectatorVec list;
|
SpectatorVec spectators;
|
||||||
map.getSpectators(list, pos, false, true);
|
map.getSpectators(spectators, pos, false, true);
|
||||||
|
|
||||||
for (Creature* spectator : list) {
|
for (Creature* spectator : spectators) {
|
||||||
if (Player* tmpPlayer = spectator->getPlayer()) {
|
if (Player* tmpPlayer = spectator->getPlayer()) {
|
||||||
tmpPlayer->sendCreatureSay(tmpPlayer, TALKTYPE_MONSTER_SAY, text, &pos);
|
tmpPlayer->sendCreatureSay(tmpPlayer, TALKTYPE_MONSTER_SAY, text, &pos);
|
||||||
}
|
}
|
||||||
@ -3867,8 +3873,7 @@ void Game::checkLight()
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (lightChange) {
|
if (lightChange) {
|
||||||
LightInfo lightInfo;
|
LightInfo lightInfo = getWorldLightInfo();
|
||||||
getWorldLightInfo(lightInfo);
|
|
||||||
|
|
||||||
for (const auto& it : players) {
|
for (const auto& it : players) {
|
||||||
it.second->sendWorldLight(lightInfo);
|
it.second->sendWorldLight(lightInfo);
|
||||||
@ -3876,10 +3881,9 @@ void Game::checkLight()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Game::getWorldLightInfo(LightInfo& lightInfo) const
|
LightInfo Game::getWorldLightInfo() const
|
||||||
{
|
{
|
||||||
lightInfo.level = lightLevel;
|
return { lightLevel, 0xD7 };
|
||||||
lightInfo.color = 0xD7;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Game::shutdown()
|
void Game::shutdown()
|
||||||
@ -3952,18 +3956,18 @@ void Game::updateCreatureSkull(const Creature* creature)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SpectatorVec list;
|
SpectatorVec spectators;
|
||||||
map.getSpectators(list, creature->getPosition(), true, true);
|
map.getSpectators(spectators, creature->getPosition(), true, true);
|
||||||
for (Creature* spectator : list) {
|
for (Creature* spectator : spectators) {
|
||||||
spectator->getPlayer()->sendCreatureSkull(creature);
|
spectator->getPlayer()->sendCreatureSkull(creature);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Game::updatePlayerShield(Player* player)
|
void Game::updatePlayerShield(Player* player)
|
||||||
{
|
{
|
||||||
SpectatorVec list;
|
SpectatorVec spectators;
|
||||||
map.getSpectators(list, player->getPosition(), true, true);
|
map.getSpectators(spectators, player->getPosition(), true, true);
|
||||||
for (Creature* spectator : list) {
|
for (Creature* spectator : spectators) {
|
||||||
spectator->getPlayer()->sendCreatureShield(player);
|
spectator->getPlayer()->sendCreatureShield(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -4137,6 +4141,10 @@ bool Game::loadExperienceStages()
|
|||||||
|
|
||||||
void Game::playerInviteToParty(uint32_t playerId, uint32_t invitedId)
|
void Game::playerInviteToParty(uint32_t playerId, uint32_t invitedId)
|
||||||
{
|
{
|
||||||
|
if (playerId == invitedId) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Player* player = getPlayerByID(playerId);
|
Player* player = getPlayerByID(playerId);
|
||||||
if (!player) {
|
if (!player) {
|
||||||
return;
|
return;
|
||||||
|
@ -244,7 +244,7 @@ class Game
|
|||||||
return playersRecord;
|
return playersRecord;
|
||||||
}
|
}
|
||||||
|
|
||||||
void getWorldLightInfo(LightInfo& lightInfo) const;
|
LightInfo getWorldLightInfo() const;
|
||||||
|
|
||||||
ReturnValue internalMoveCreature(Creature* creature, Direction direction, uint32_t flags = 0);
|
ReturnValue internalMoveCreature(Creature* creature, Direction direction, uint32_t flags = 0);
|
||||||
ReturnValue internalMoveCreature(Creature& creature, Tile& toTile, uint32_t flags = 0);
|
ReturnValue internalMoveCreature(Creature& creature, Tile& toTile, uint32_t flags = 0);
|
||||||
@ -322,7 +322,7 @@ class Game
|
|||||||
* \param text The text to say
|
* \param text The text to say
|
||||||
*/
|
*/
|
||||||
bool internalCreatureSay(Creature* creature, SpeakClasses type, const std::string& text,
|
bool 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);
|
||||||
|
|
||||||
void loadPlayersRecord();
|
void loadPlayersRecord();
|
||||||
void checkPlayersRecord();
|
void checkPlayersRecord();
|
||||||
|
@ -31,13 +31,14 @@ Account IOLoginData::loadAccount(uint32_t accno)
|
|||||||
Account account;
|
Account account;
|
||||||
|
|
||||||
std::ostringstream query;
|
std::ostringstream query;
|
||||||
query << "SELECT `id`, `password`, `type`, `premdays`, `lastday` FROM `accounts` WHERE `id` = " << accno;
|
query << "SELECT `id`, `name`, `password`, `type`, `premdays`, `lastday` FROM `accounts` WHERE `id` = " << accno;
|
||||||
DBResult_ptr result = Database::getInstance()->storeQuery(query.str());
|
DBResult_ptr result = Database::getInstance()->storeQuery(query.str());
|
||||||
if (!result) {
|
if (!result) {
|
||||||
return account;
|
return account;
|
||||||
}
|
}
|
||||||
|
|
||||||
account.id = result->getNumber<uint32_t>("id");
|
account.id = result->getNumber<uint32_t>("id");
|
||||||
|
account.name = result->getNumber<uint32_t>("name");
|
||||||
account.accountType = static_cast<AccountType_t>(result->getNumber<int32_t>("type"));
|
account.accountType = static_cast<AccountType_t>(result->getNumber<int32_t>("type"));
|
||||||
account.premiumDays = result->getNumber<uint16_t>("premdays");
|
account.premiumDays = result->getNumber<uint16_t>("premdays");
|
||||||
account.lastDay = result->getNumber<time_t>("lastday");
|
account.lastDay = result->getNumber<time_t>("lastday");
|
||||||
@ -51,12 +52,12 @@ bool IOLoginData::saveAccount(const Account& acc)
|
|||||||
return Database::getInstance()->executeQuery(query.str());
|
return Database::getInstance()->executeQuery(query.str());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IOLoginData::loginserverAuthentication(uint32_t accountNumber, const std::string& password, Account& account)
|
bool IOLoginData::loginserverAuthentication(uint32_t accountName, const std::string& password, Account& account)
|
||||||
{
|
{
|
||||||
Database* db = Database::getInstance();
|
Database* db = Database::getInstance();
|
||||||
|
|
||||||
std::ostringstream query;
|
std::ostringstream query;
|
||||||
query << "SELECT `id`, `password`, `type`, `premdays`, `lastday` FROM `accounts` WHERE `id` = " << accountNumber;
|
query << "SELECT `id`, `name`, `password`, `type`, `premdays`, `lastday` FROM `accounts` WHERE `name` = " << accountName;
|
||||||
DBResult_ptr result = db->storeQuery(query.str());
|
DBResult_ptr result = db->storeQuery(query.str());
|
||||||
if (!result) {
|
if (!result) {
|
||||||
return false;
|
return false;
|
||||||
@ -67,6 +68,7 @@ bool IOLoginData::loginserverAuthentication(uint32_t accountNumber, const std::s
|
|||||||
}
|
}
|
||||||
|
|
||||||
account.id = result->getNumber<uint32_t>("id");
|
account.id = result->getNumber<uint32_t>("id");
|
||||||
|
account.name = result->getNumber<uint32_t>("name");
|
||||||
account.accountType = static_cast<AccountType_t>(result->getNumber<int32_t>("type"));
|
account.accountType = static_cast<AccountType_t>(result->getNumber<int32_t>("type"));
|
||||||
account.premiumDays = result->getNumber<uint16_t>("premdays");
|
account.premiumDays = result->getNumber<uint16_t>("premdays");
|
||||||
account.lastDay = result->getNumber<time_t>("lastday");
|
account.lastDay = result->getNumber<time_t>("lastday");
|
||||||
@ -85,12 +87,12 @@ bool IOLoginData::loginserverAuthentication(uint32_t accountNumber, const std::s
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t IOLoginData::gameworldAuthentication(uint32_t accountNumber, const std::string& password, std::string& characterName)
|
uint32_t IOLoginData::gameworldAuthentication(uint32_t accountName, const std::string& password, std::string& characterName)
|
||||||
{
|
{
|
||||||
Database* db = Database::getInstance();
|
Database* db = Database::getInstance();
|
||||||
|
|
||||||
std::ostringstream query;
|
std::ostringstream query;
|
||||||
query << "SELECT `id`, `password` FROM `accounts` WHERE `id` = " << accountNumber;
|
query << "SELECT `id`, `password` FROM `accounts` WHERE `name` = " << accountName;
|
||||||
DBResult_ptr result = db->storeQuery(query.str());
|
DBResult_ptr result = db->storeQuery(query.str());
|
||||||
if (!result) {
|
if (!result) {
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -32,8 +32,8 @@ class IOLoginData
|
|||||||
static Account loadAccount(uint32_t accno);
|
static Account loadAccount(uint32_t accno);
|
||||||
static bool saveAccount(const Account& acc);
|
static bool saveAccount(const Account& acc);
|
||||||
|
|
||||||
static bool loginserverAuthentication(uint32_t accountNumber, const std::string& password, Account& account);
|
static bool loginserverAuthentication(uint32_t accountName, const std::string& password, Account& account);
|
||||||
static uint32_t gameworldAuthentication(uint32_t accountNumber, const std::string& password, std::string& characterName);
|
static uint32_t gameworldAuthentication(uint32_t accountName, const std::string& password, std::string& characterName);
|
||||||
|
|
||||||
static AccountType_t getAccountType(uint32_t accountId);
|
static AccountType_t getAccountType(uint32_t accountId);
|
||||||
static void setAccountType(uint32_t accountId, AccountType_t accountType);
|
static void setAccountType(uint32_t accountId, AccountType_t accountType);
|
||||||
|
@ -2796,8 +2796,7 @@ int LuaScriptInterface::luaGetWorldTime(lua_State* L)
|
|||||||
int LuaScriptInterface::luaGetWorldLight(lua_State* L)
|
int LuaScriptInterface::luaGetWorldLight(lua_State* L)
|
||||||
{
|
{
|
||||||
//getWorldLight()
|
//getWorldLight()
|
||||||
LightInfo lightInfo;
|
LightInfo lightInfo = g_game.getWorldLightInfo();
|
||||||
g_game.getWorldLightInfo(lightInfo);
|
|
||||||
lua_pushnumber(L, lightInfo.level);
|
lua_pushnumber(L, lightInfo.level);
|
||||||
lua_pushnumber(L, lightInfo.color);
|
lua_pushnumber(L, lightInfo.color);
|
||||||
return 2;
|
return 2;
|
||||||
@ -6481,10 +6480,9 @@ int LuaScriptInterface::luaCreatureGetLight(lua_State* L)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
LightInfo light;
|
LightInfo lightInfo = creature->getCreatureLight();
|
||||||
creature->getCreatureLight(light);
|
lua_pushnumber(L, lightInfo.level);
|
||||||
lua_pushnumber(L, light.level);
|
lua_pushnumber(L, lightInfo.color);
|
||||||
lua_pushnumber(L, light.color);
|
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1768,7 +1768,7 @@ void Player::death(Creature* lastHitCreature)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
setLossSkill(true);
|
setSkillLoss(true);
|
||||||
|
|
||||||
auto it = conditions.begin(), end = conditions.end();
|
auto it = conditions.begin(), end = conditions.end();
|
||||||
while (it != end) {
|
while (it != end) {
|
||||||
@ -2911,13 +2911,12 @@ void Player::stopWalk()
|
|||||||
cancelNextWalk = true;
|
cancelNextWalk = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::getCreatureLight(LightInfo& light) const
|
LightInfo Player::getCreatureLight() const
|
||||||
{
|
{
|
||||||
if (internalLight.level > itemsLight.level) {
|
if (internalLight.level > itemsLight.level) {
|
||||||
light = internalLight;
|
return internalLight;
|
||||||
} else {
|
|
||||||
light = itemsLight;
|
|
||||||
}
|
}
|
||||||
|
return itemsLight;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::updateItemsLight(bool internal /*=false*/)
|
void Player::updateItemsLight(bool internal /*=false*/)
|
||||||
@ -3140,7 +3139,7 @@ bool Player::onKilledCreature(Creature* target, bool lastHit/* = true*/)
|
|||||||
if (Player* targetPlayer = target->getPlayer()) {
|
if (Player* targetPlayer = target->getPlayer()) {
|
||||||
if (targetPlayer && targetPlayer->getZone() == ZONE_PVP) {
|
if (targetPlayer && targetPlayer->getZone() == ZONE_PVP) {
|
||||||
targetPlayer->setDropLoot(false);
|
targetPlayer->setDropLoot(false);
|
||||||
targetPlayer->setLossSkill(false);
|
targetPlayer->setSkillLoss(false);
|
||||||
} else if (!hasFlag(PlayerFlag_NotGainInFight) && !isPartner(targetPlayer)) {
|
} else if (!hasFlag(PlayerFlag_NotGainInFight) && !isPartner(targetPlayer)) {
|
||||||
if (!Combat::isInPvpZone(this, targetPlayer) && hasAttacked(targetPlayer) && !targetPlayer->hasAttacked(this) && targetPlayer != this) {
|
if (!Combat::isInPvpZone(this, targetPlayer) && hasAttacked(targetPlayer) && !targetPlayer->hasAttacked(this) && targetPlayer != this) {
|
||||||
if (targetPlayer->getSkull() == SKULL_NONE && !isInWar(targetPlayer)) {
|
if (targetPlayer->getSkull() == SKULL_NONE && !isInWar(targetPlayer)) {
|
||||||
@ -3392,7 +3391,10 @@ Skulls_t Player::getSkullClient(const Creature* creature) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
const Player* player = creature->getPlayer();
|
const Player* player = creature->getPlayer();
|
||||||
if (player && player->getSkull() == SKULL_NONE) {
|
if (!player || player->getSkull() != SKULL_NONE) {
|
||||||
|
return Creature::getSkullClient(creature);
|
||||||
|
}
|
||||||
|
|
||||||
if (isInWar(player)) {
|
if (isInWar(player)) {
|
||||||
return SKULL_GREEN;
|
return SKULL_GREEN;
|
||||||
}
|
}
|
||||||
@ -3408,10 +3410,10 @@ Skulls_t Player::getSkullClient(const Creature* creature) const
|
|||||||
if (isPartner(player)) {
|
if (isPartner(player)) {
|
||||||
return SKULL_GREEN;
|
return SKULL_GREEN;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return Creature::getSkullClient(creature);
|
return Creature::getSkullClient(creature);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Player::hasAttacked(const Player* attacked) const
|
bool Player::hasAttacked(const Player* attacked) const
|
||||||
{
|
{
|
||||||
if (hasFlag(PlayerFlag_NotGainInFight) || !attacked) {
|
if (hasFlag(PlayerFlag_NotGainInFight) || !attacked) {
|
||||||
@ -3634,7 +3636,7 @@ bool Player::isInviting(const Player* player) const
|
|||||||
|
|
||||||
bool Player::isPartner(const Player* player) const
|
bool Player::isPartner(const Player* player) const
|
||||||
{
|
{
|
||||||
if (!player || !party) {
|
if (!player || !party || player == this) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return party == player->party;
|
return party == player->party;
|
||||||
|
@ -559,7 +559,7 @@ class Player final : public Creature, public Cylinder
|
|||||||
void onIdleStatus() final;
|
void onIdleStatus() final;
|
||||||
void onPlacedCreature() final;
|
void onPlacedCreature() final;
|
||||||
|
|
||||||
void getCreatureLight(LightInfo& light) const final;
|
LightInfo getCreatureLight() const override;
|
||||||
|
|
||||||
Skulls_t getSkull() const final;
|
Skulls_t getSkull() const final;
|
||||||
Skulls_t getSkullClient(const Creature* creature) const final;
|
Skulls_t getSkullClient(const Creature* creature) const final;
|
||||||
|
@ -1594,9 +1594,7 @@ void ProtocolGame::sendAddCreature(const Creature* creature, const Position& pos
|
|||||||
sendSkills();
|
sendSkills();
|
||||||
|
|
||||||
//gameworld light-settings
|
//gameworld light-settings
|
||||||
LightInfo lightInfo;
|
sendWorldLight(g_game.getWorldLightInfo());
|
||||||
g_game.getWorldLightInfo(lightInfo);
|
|
||||||
sendWorldLight(lightInfo);
|
|
||||||
|
|
||||||
//player light level
|
//player light level
|
||||||
sendCreatureLight(creature);
|
sendCreatureLight(creature);
|
||||||
@ -1871,8 +1869,7 @@ void ProtocolGame::AddCreature(NetworkMessage& msg, const Creature* creature, bo
|
|||||||
AddOutfit(msg, outfit);
|
AddOutfit(msg, outfit);
|
||||||
}
|
}
|
||||||
|
|
||||||
LightInfo lightInfo;
|
LightInfo lightInfo = creature->getCreatureLight();
|
||||||
creature->getCreatureLight(lightInfo);
|
|
||||||
msg.addByte(player->isAccessPlayer() ? 0xFF : lightInfo.level);
|
msg.addByte(player->isAccessPlayer() ? 0xFF : lightInfo.level);
|
||||||
msg.addByte(lightInfo.color);
|
msg.addByte(lightInfo.color);
|
||||||
|
|
||||||
@ -1941,8 +1938,7 @@ void ProtocolGame::AddWorldLight(NetworkMessage& msg, const LightInfo& lightInfo
|
|||||||
|
|
||||||
void ProtocolGame::AddCreatureLight(NetworkMessage& msg, const Creature* creature)
|
void ProtocolGame::AddCreatureLight(NetworkMessage& msg, const Creature* creature)
|
||||||
{
|
{
|
||||||
LightInfo lightInfo;
|
LightInfo lightInfo = creature->getCreatureLight();
|
||||||
creature->getCreatureLight(lightInfo);
|
|
||||||
|
|
||||||
msg.addByte(0x8D);
|
msg.addByte(0x8D);
|
||||||
msg.add<uint32_t>(creature->getID());
|
msg.add<uint32_t>(creature->getID());
|
||||||
|
Loading…
x
Reference in New Issue
Block a user