format codebase

This commit is contained in:
aronwk-aaron
2022-07-28 08:39:57 -05:00
parent 4f7aa11067
commit 19e77a38d8
881 changed files with 34700 additions and 38689 deletions

View File

@@ -17,8 +17,7 @@
std::vector<Player*> Player::m_Players = {};
Player::Player(const LWOOBJID& objectID, const EntityInfo info, User* user, Entity* parentEntity) : Entity(objectID, info, parentEntity)
{
Player::Player(const LWOOBJID& objectID, const EntityInfo info, User* user, Entity* parentEntity) : Entity(objectID, info, parentEntity) {
m_ParentUser = user;
m_Character = m_ParentUser->GetLastUsedChar();
m_ParentUser->SetLoggedInChar(objectID);
@@ -38,58 +37,48 @@ Player::Player(const LWOOBJID& objectID, const EntityInfo info, User* user, Enti
const auto& iter = std::find(m_Players.begin(), m_Players.end(), this);
if (iter != m_Players.end())
{
if (iter != m_Players.end()) {
return;
}
m_Players.push_back(this);
}
User* Player::GetParentUser() const
{
User* Player::GetParentUser() const {
return m_ParentUser;
}
SystemAddress Player::GetSystemAddress() const
{
SystemAddress Player::GetSystemAddress() const {
return m_SystemAddress;
}
void Player::SetSystemAddress(const SystemAddress& value)
{
void Player::SetSystemAddress(const SystemAddress& value) {
m_SystemAddress = value;
}
void Player::SetRespawnPos(const NiPoint3 position)
{
void Player::SetRespawnPos(const NiPoint3 position) {
m_respawnPos = position;
m_Character->SetRespawnPoint(dZoneManager::Instance()->GetZone()->GetWorldID(), position);
}
void Player::SetRespawnRot(const NiQuaternion rotation)
{
void Player::SetRespawnRot(const NiQuaternion rotation) {
m_respawnRot = rotation;
}
NiPoint3 Player::GetRespawnPosition() const
{
NiPoint3 Player::GetRespawnPosition() const {
return m_respawnPos;
}
NiQuaternion Player::GetRespawnRotation() const
{
NiQuaternion Player::GetRespawnRotation() const {
return m_respawnRot;
}
void Player::SendMail(const LWOOBJID sender, const std::string& senderName, const std::string& subject, const std::string& body, LOT attachment, uint16_t attachmentCount) const
{
void Player::SendMail(const LWOOBJID sender, const std::string& senderName, const std::string& subject, const std::string& body, LOT attachment, uint16_t attachmentCount) const {
Mail::SendMail(sender, senderName, this, subject, body, attachment, attachmentCount);
}
void Player::SendToZone(LWOMAPID zoneId, LWOCLONEID cloneId)
{
void Player::SendToZone(LWOMAPID zoneId, LWOCLONEID cloneId) {
const auto objid = GetObjectID();
ZoneInstanceManager::Instance()->RequestZoneTransfer(Game::server, zoneId, cloneId, false, [objid](bool mythranShift, uint32_t zoneID, uint32_t zoneInstance, uint32_t zoneClone, std::string serverIP, uint16_t serverPort) {
@@ -118,41 +107,34 @@ void Player::SendToZone(LWOMAPID zoneId, LWOCLONEID cloneId)
EntityManager::Instance()->DestructEntity(entity);
return;
});
});
}
void Player::AddLimboConstruction(LWOOBJID objectId)
{
void Player::AddLimboConstruction(LWOOBJID objectId) {
const auto& iter = std::find(m_LimboConstructions.begin(), m_LimboConstructions.end(), objectId);
if (iter != m_LimboConstructions.end())
{
if (iter != m_LimboConstructions.end()) {
return;
}
m_LimboConstructions.push_back(objectId);
}
void Player::RemoveLimboConstruction(LWOOBJID objectId)
{
void Player::RemoveLimboConstruction(LWOOBJID objectId) {
const auto& iter = std::find(m_LimboConstructions.begin(), m_LimboConstructions.end(), objectId);
if (iter == m_LimboConstructions.end())
{
if (iter == m_LimboConstructions.end()) {
return;
}
m_LimboConstructions.erase(iter);
}
void Player::ConstructLimboEntities()
{
for (const auto objectId : m_LimboConstructions)
{
void Player::ConstructLimboEntities() {
for (const auto objectId : m_LimboConstructions) {
auto* entity = EntityManager::Instance()->GetEntity(objectId);
if (entity == nullptr)
{
if (entity == nullptr) {
continue;
}
@@ -162,52 +144,41 @@ void Player::ConstructLimboEntities()
m_LimboConstructions.clear();
}
std::map<LWOOBJID, Loot::Info>& Player::GetDroppedLoot()
{
std::map<LWOOBJID, Loot::Info>& Player::GetDroppedLoot() {
return m_DroppedLoot;
}
const NiPoint3& Player::GetGhostReferencePoint() const
{
const NiPoint3& Player::GetGhostReferencePoint() const {
return m_GhostOverride ? m_GhostOverridePoint : m_GhostReferencePoint;
}
const NiPoint3& Player::GetOriginGhostReferencePoint() const
{
const NiPoint3& Player::GetOriginGhostReferencePoint() const {
return m_GhostReferencePoint;
}
void Player::SetGhostReferencePoint(const NiPoint3& value)
{
void Player::SetGhostReferencePoint(const NiPoint3& value) {
m_GhostReferencePoint = value;
}
void Player::SetGhostOverridePoint(const NiPoint3& value)
{
void Player::SetGhostOverridePoint(const NiPoint3& value) {
m_GhostOverridePoint = value;
}
const NiPoint3& Player::GetGhostOverridePoint() const
{
const NiPoint3& Player::GetGhostOverridePoint() const {
return m_GhostOverridePoint;
}
void Player::SetGhostOverride(bool value)
{
void Player::SetGhostOverride(bool value) {
m_GhostOverride = value;
}
bool Player::GetGhostOverride() const
{
bool Player::GetGhostOverride() const {
return m_GhostOverride;
}
void Player::ObserveEntity(int32_t id)
{
for (int32_t i = 0; i < m_ObservedEntitiesUsed; i++)
{
if (m_ObservedEntities[i] == 0 || m_ObservedEntities[i] == id)
{
void Player::ObserveEntity(int32_t id) {
for (int32_t i = 0; i < m_ObservedEntitiesUsed; i++) {
if (m_ObservedEntities[i] == 0 || m_ObservedEntities[i] == id) {
m_ObservedEntities[i] = id;
return;
@@ -216,8 +187,7 @@ void Player::ObserveEntity(int32_t id)
const auto index = m_ObservedEntitiesUsed++;
if (m_ObservedEntitiesUsed > m_ObservedEntitiesLength)
{
if (m_ObservedEntitiesUsed > m_ObservedEntitiesLength) {
m_ObservedEntities.resize(m_ObservedEntitiesLength + m_ObservedEntitiesLength);
m_ObservedEntitiesLength = m_ObservedEntitiesLength + m_ObservedEntitiesLength;
@@ -226,12 +196,9 @@ void Player::ObserveEntity(int32_t id)
m_ObservedEntities[index] = id;
}
bool Player::IsObserved(int32_t id)
{
for (int32_t i = 0; i < m_ObservedEntitiesUsed; i++)
{
if (m_ObservedEntities[i] == id)
{
bool Player::IsObserved(int32_t id) {
for (int32_t i = 0; i < m_ObservedEntitiesUsed; i++) {
if (m_ObservedEntities[i] == id) {
return true;
}
}
@@ -239,34 +206,27 @@ bool Player::IsObserved(int32_t id)
return false;
}
void Player::GhostEntity(int32_t id)
{
for (int32_t i = 0; i < m_ObservedEntitiesUsed; i++)
{
if (m_ObservedEntities[i] == id)
{
void Player::GhostEntity(int32_t id) {
for (int32_t i = 0; i < m_ObservedEntitiesUsed; i++) {
if (m_ObservedEntities[i] == id) {
m_ObservedEntities[i] = 0;
}
}
}
Player* Player::GetPlayer(const SystemAddress& sysAddr)
{
Player* Player::GetPlayer(const SystemAddress& sysAddr) {
auto* entity = UserManager::Instance()->GetUser(sysAddr)->GetLastUsedChar()->GetEntity();
return static_cast<Player*>(entity);
}
Player* Player::GetPlayer(const std::string& name)
{
Player* Player::GetPlayer(const std::string& name) {
const auto characters = EntityManager::Instance()->GetEntitiesByComponent(COMPONENT_TYPE_CHARACTER);
for (auto* character : characters)
{
for (auto* character : characters) {
if (!character->IsPlayer()) continue;
if (character->GetCharacter()->GetName() == name)
{
if (character->GetCharacter()->GetName() == name) {
return static_cast<Player*>(character);
}
}
@@ -274,12 +234,9 @@ Player* Player::GetPlayer(const std::string& name)
return nullptr;
}
Player* Player::GetPlayer(LWOOBJID playerID)
{
for (auto* player : m_Players)
{
if (player->GetObjectID() == playerID)
{
Player* Player::GetPlayer(LWOOBJID playerID) {
for (auto* player : m_Players) {
if (player->GetObjectID() == playerID) {
return player;
}
}
@@ -287,8 +244,7 @@ Player* Player::GetPlayer(LWOOBJID playerID)
return nullptr;
}
const std::vector<Player*>& Player::GetAllPlayers()
{
const std::vector<Player*>& Player::GetAllPlayers() {
return m_Players;
}
@@ -300,23 +256,19 @@ void Player::SetDroppedCoins(uint64_t value) {
m_DroppedCoins = value;
}
Player::~Player()
{
Player::~Player() {
Game::logger->Log("Player", "Deleted player");
for (int32_t i = 0; i < m_ObservedEntitiesUsed; i++)
{
for (int32_t i = 0; i < m_ObservedEntitiesUsed; i++) {
const auto id = m_ObservedEntities[i];
if (id == 0)
{
if (id == 0) {
continue;
}
auto* entity = EntityManager::Instance()->GetGhostCandidate(id);
if (entity != nullptr)
{
if (entity != nullptr) {
entity->SetObservers(entity->GetObservers() - 1);
}
}
@@ -325,25 +277,24 @@ Player::~Player()
const auto& iter = std::find(m_Players.begin(), m_Players.end(), this);
if (iter == m_Players.end())
{
if (iter == m_Players.end()) {
return;
}
if (IsPlayer()) {
Entity* zoneControl = EntityManager::Instance()->GetZoneControlEntity();
for (CppScripts::Script* script : CppScripts::GetEntityScripts(zoneControl)) {
script->OnPlayerExit(zoneControl, this);
}
Entity* zoneControl = EntityManager::Instance()->GetZoneControlEntity();
for (CppScripts::Script* script : CppScripts::GetEntityScripts(zoneControl)) {
script->OnPlayerExit(zoneControl, this);
}
std::vector<Entity*> scriptedActs = EntityManager::Instance()->GetEntitiesByComponent(COMPONENT_TYPE_SCRIPTED_ACTIVITY);
for (Entity* scriptEntity : scriptedActs) {
if (scriptEntity->GetObjectID() != zoneControl->GetObjectID()) { // Don't want to trigger twice on instance worlds
for (CppScripts::Script* script : CppScripts::GetEntityScripts(scriptEntity)) {
script->OnPlayerExit(scriptEntity, this);
}
}
}
std::vector<Entity*> scriptedActs = EntityManager::Instance()->GetEntitiesByComponent(COMPONENT_TYPE_SCRIPTED_ACTIVITY);
for (Entity* scriptEntity : scriptedActs) {
if (scriptEntity->GetObjectID() != zoneControl->GetObjectID()) { // Don't want to trigger twice on instance worlds
for (CppScripts::Script* script : CppScripts::GetEntityScripts(scriptEntity)) {
script->OnPlayerExit(scriptEntity, this);
}
}
}
}
m_Players.erase(iter);