[Server] Place getters and setters in consistent order

new-script-api
David Cernat 7 years ago
parent 947b3f76be
commit 010a80ceca

@ -15,10 +15,10 @@ void Object::Init(LuaState &lua)
"refId", sol::property(&BaseObject::getRefId, &BaseObject::setRefId), "refId", sol::property(&BaseObject::getRefId, &BaseObject::setRefId),
"refNum", sol::property(&BaseObject::getRefNum, &BaseObject::setRefNum), "refNum", sol::property(&BaseObject::getRefNum, &BaseObject::setRefNum),
"mpNum", sol::property(&BaseObject::getMpNum, &BaseObject::setMpNum), "mpNum", sol::property(&BaseObject::getMpNum, &BaseObject::setMpNum),
"setPosition", &Object::setPosition,
"getPosition", &Object::getPosition, "getPosition", &Object::getPosition,
"setRotation", &Object::setRotation, "setPosition", &Object::setPosition,
"getRotation", &Object::getRotation, "getRotation", &Object::getRotation,
"setRotation", &Object::setRotation,
"count", sol::property(&Object::getCount, &Object::setCount), "count", sol::property(&Object::getCount, &Object::setCount),
"goldValue", sol::property(&Object::getGoldValue, &Object::setGoldValue), "goldValue", sol::property(&Object::getGoldValue, &Object::setGoldValue),
"scale", sol::property(&Object::getScale, &Object::setScale), "scale", sol::property(&Object::getScale, &Object::setScale),

@ -28,7 +28,6 @@ void Player::Init(LuaState &lua)
"getCell", &NetActor::getCell, "getCell", &NetActor::getCell,
"getInventory", &NetActor::getInventory, "getInventory", &NetActor::getInventory,
"getPreviousCellPos", &Player::getPreviousCellPos, "getPreviousCellPos", &Player::getPreviousCellPos,
"kick", &Player::kick, "kick", &Player::kick,
@ -219,19 +218,14 @@ void Player::setId(unsigned short id)
this->id = id; this->id = id;
} }
void Player::setHandshake()
{
handshakeState = true;
}
bool Player::isHandshaked() bool Player::isHandshaked()
{ {
return handshakeState; return handshakeState;
} }
void Player::setLoadState(int state) void Player::setHandshake()
{ {
loadState = state; handshakeState = true;
} }
int Player::getLoadState() int Player::getLoadState()
@ -239,50 +233,55 @@ int Player::getLoadState()
return loadState; return loadState;
} }
void Player::setLoadState(int state)
{
loadState = state;
}
CellController::TContainer *Player::getCells() CellController::TContainer *Player::getCells()
{ {
return &cells; return &cells;
} }
void Player::sendToLoaded(mwmp::PlayerPacket *myPacket) void Player::forEachLoaded(std::function<void(Player *pl, Player *other)> func)
{ {
std::list <Player*> plList; std::list <Player*> plList;
for (auto cell : cells) for (auto &&cell : cells)
for (auto pl : *cell) {
for (auto &&pl : *cell)
{
if (pl != nullptr && !pl->npc.mName.empty())
plList.push_back(pl); plList.push_back(pl);
}
}
plList.sort(); plList.sort();
plList.unique(); plList.unique();
for (auto pl : plList) for (auto &&pl : plList)
{ {
if (pl == this) continue; if (pl == this) continue;
myPacket->setPlayer(this); func(this, pl);
myPacket->Send(pl->guid);
} }
} }
void Player::forEachLoaded(std::function<void(Player *pl, Player *other)> func) void Player::sendToLoaded(mwmp::PlayerPacket *myPacket)
{ {
std::list <Player*> plList; std::list <Player*> plList;
for (auto &&cell : cells) for (auto cell : cells)
{ for (auto pl : *cell)
for (auto &&pl : *cell)
{
if (pl != nullptr && !pl->npc.mName.empty())
plList.push_back(pl); plList.push_back(pl);
}
}
plList.sort(); plList.sort();
plList.unique(); plList.unique();
for (auto &&pl : plList) for (auto pl : plList)
{ {
if (pl == this) continue; if (pl == this) continue;
func(this, pl); myPacket->setPlayer(this);
myPacket->Send(pl->guid);
} }
} }
@ -318,15 +317,15 @@ int Player::getAvgPing()
return mwmp::Networking::get().getAvgPing(guid); return mwmp::Networking::get().getAvgPing(guid);
} }
void Player::setName(const std::string &name) std::string Player::getName()
{ {
npc.mName = name; return npc.mName;
baseInfoChanged = true;
} }
std::string Player::getName() void Player::setName(const std::string &name)
{ {
return npc.mName; npc.mName = name;
baseInfoChanged = true;
} }
void Player::setCharGenStages(int currentStage, int endStage) void Player::setCharGenStages(int currentStage, int endStage)
@ -352,15 +351,20 @@ void Player::message(const std::string &message, bool toAll)
packet->Send(true); packet->Send(true);
} }
int Player::getLevel() const
{
return creatureStats.mLevel;
}
void Player::setLevel(int level) void Player::setLevel(int level)
{ {
creatureStats.mLevel = level; creatureStats.mLevel = level;
levelChanged = true; levelChanged = true;
} }
int Player::getLevel() const int Player::getGender() const
{ {
return creatureStats.mLevel; return npc.isMale();
} }
void Player::setGender(int gender) void Player::setGender(int gender)
@ -369,9 +373,9 @@ void Player::setGender(int gender)
baseInfoChanged = true; baseInfoChanged = true;
} }
int Player::getGender() const std::string Player::getRace() const
{ {
return npc.isMale(); return npc.mRace;
} }
void Player::setRace(const std::string &race) void Player::setRace(const std::string &race)
@ -382,9 +386,9 @@ void Player::setRace(const std::string &race)
baseInfoChanged = true; baseInfoChanged = true;
} }
std::string Player::getRace() const std::string Player::getHead() const
{ {
return npc.mRace; return npc.mHead;
} }
void Player::setHead(const std::string &head) void Player::setHead(const std::string &head)
@ -393,9 +397,9 @@ void Player::setHead(const std::string &head)
baseInfoChanged = true; baseInfoChanged = true;
} }
std::string Player::getHead() const std::string Player::getHair() const
{ {
return npc.mHead; return npc.mHair;
} }
void Player::setHair(const std::string &hair) void Player::setHair(const std::string &hair)
@ -404,11 +408,6 @@ void Player::setHair(const std::string &hair)
baseInfoChanged = true; baseInfoChanged = true;
} }
std::string Player::getHair() const
{
return npc.mHair;
}
std::string Player::getBirthsign() const std::string Player::getBirthsign() const
{ {
return birthsign; return birthsign;
@ -434,15 +433,20 @@ void Player::setBounty(int bounty)
packet->Send(true); packet->Send(true);
} }
int Player::getLevelProgress() const
{
return npcStats.mLevelProgress;
}
void Player::setLevelProgress(int progress) void Player::setLevelProgress(int progress)
{ {
npcStats.mLevelProgress = progress; npcStats.mLevelProgress = progress;
skillsChanged = true; skillsChanged = true;
} }
int Player::getLevelProgress() const std::string Player::getCreatureModel() const
{ {
return npcStats.mLevelProgress; return creatureModel;
} }
void Player::setCreatureModel(const std::string &model) void Player::setCreatureModel(const std::string &model)
@ -451,11 +455,6 @@ void Player::setCreatureModel(const std::string &model)
baseInfoChanged = true; baseInfoChanged = true;
} }
std::string Player::getCreatureModel() const
{
return creatureModel;
}
void Player::creatureName(bool useName) void Player::creatureName(bool useName)
{ {
useCreatureName = useName; useCreatureName = useName;
@ -591,6 +590,11 @@ void Player::jail(int jailDays, bool ignoreJailTeleportation, bool ignoreJailSki
packet->Send(false); packet->Send(false);
} }
bool Player::getWerewolfState() const
{
return isWerewolf;
}
void Player::setWerewolfState(bool state) void Player::setWerewolfState(bool state)
{ {
isWerewolf = state; isWerewolf = state;
@ -601,11 +605,6 @@ void Player::setWerewolfState(bool state)
packet->Send(true); packet->Send(true);
} }
bool Player::getWerewolfState() const
{
return isWerewolf;
}
size_t Player::cellStateSize() const size_t Player::cellStateSize() const
{ {
return cellStateChanges.cellStates.size(); return cellStateChanges.cellStates.size();

@ -59,8 +59,8 @@ public:
bool isHandshaked(); bool isHandshaked();
void setHandshake(); void setHandshake();
void setLoadState(int state);
int getLoadState(); int getLoadState();
void setLoadState(int state);
virtual ~Player(); virtual ~Player();
@ -78,27 +78,27 @@ public:
int getAvgPing(); int getAvgPing();
void setName(const std::string &name);
std::string getName(); std::string getName();
void setName(const std::string &name);
void setCharGenStages(int currentStage, int endStage); void setCharGenStages(int currentStage, int endStage);
void message(const std::string &message, bool toAll = false); void message(const std::string &message, bool toAll = false);
void setGender(int gender);
int getGender() const; int getGender() const;
void setRace(const std::string &race); void setGender(int gender);
std::string getRace() const; std::string getRace() const;
void setHead(const std::string &head); void setRace(const std::string &race);
std::string getHead() const; std::string getHead() const;
void setHair(const std::string &hair); void setHead(const std::string &head);
std::string getHair() const; std::string getHair() const;
void setHair(const std::string &hair);
std::string getBirthsign() const; std::string getBirthsign() const;
void setBirthsign(const std::string &sign); void setBirthsign(const std::string &sign);
int getBounty() const; int getBounty() const;
void setBounty(int bounty); void setBounty(int bounty);
void setLevel(int level);
int getLevel() const; int getLevel() const;
void setLevelProgress(int progress); void setLevel(int level);
int getLevelProgress() const; int getLevelProgress() const;
void setLevelProgress(int progress);
/** /**
* \brief Send a PlayerResurrect packet about a player. * \brief Send a PlayerResurrect packet about a player.
@ -130,12 +130,11 @@ public:
void jail(int jailDays, bool ignoreJailTeleportation, bool ignoreJailSkillIncreases, void jail(int jailDays, bool ignoreJailTeleportation, bool ignoreJailSkillIncreases,
const std::string &jailProgressText, const std::string &jailEndText); const std::string &jailProgressText, const std::string &jailEndText);
void setWerewolfState(bool state);
bool getWerewolfState() const; bool getWerewolfState() const;
void setWerewolfState(bool state);
void setCreatureModel(const std::string &model);
std::string getCreatureModel() const; std::string getCreatureModel() const;
void setCreatureModel(const std::string &model);
void creatureName(bool useName); void creatureName(bool useName);
bool isCreatureName() const; bool isCreatureName() const;

Loading…
Cancel
Save