chore: Move static Player functions and internal linkage to manager class (#1412)

* Moving and organizing Player code

- Move code to CharacterComponent
- Remove extraneous interfaces
- Simplify some code greatly
- Change some types to return and take in const ref (only structs larger than 8 bytes benefit from this change.)
- Update code to use CharacterComponent for sending to zone instead of Player*.

* Moving and organizing Player code

- Move code to CharacterComponent
- Remove extraneous interfaces
- Simplify some code greatly
- Change some types to return and take in const ref (only structs larger than 8 bytes benefit from this change.)
- Update code to use CharacterComponent for sending to zone instead of Player*.
- Remove static storage container (static containers can be destroyed before exit/terminate handler executes)

* remove player cast

* Remove extra includes

* Add a player manager

Used for the static Player functions.  Further removes stuff from the Player class/file.
This commit is contained in:
David Markowitz
2024-01-13 01:40:56 -08:00
committed by GitHub
parent 0bc12141c3
commit a62f6d63c6
12 changed files with 129 additions and 86 deletions

View File

@@ -78,6 +78,7 @@
#include "StringifiedEnum.h"
#include "Server.h"
#include "PositionUpdate.h"
#include "PlayerManager.h"
namespace Game {
Logger* logger = nullptr;
@@ -798,7 +799,7 @@ void HandlePacket(Packet* packet) {
auto* entity = Game::entityManager->GetEntity(c->GetObjectID());
if (!entity) {
entity = Player::GetPlayer(packet->systemAddress);
entity = PlayerManager::GetPlayer(packet->systemAddress);
}
if (entity) {
@@ -1205,7 +1206,7 @@ void HandlePacket(Packet* packet) {
return;
}
auto* entity = Player::GetPlayer(packet->systemAddress);
auto* entity = PlayerManager::GetPlayer(packet->systemAddress);
if (entity == nullptr) {
LOG("Unable to get player to parse chat moderation request");
@@ -1365,7 +1366,7 @@ void WorldShutdownProcess(uint32_t zoneId) {
for (auto i = 0; i < Game::server->GetReplicaManager()->GetParticipantCount(); ++i) {
const auto& player = Game::server->GetReplicaManager()->GetParticipantAtIndex(i);
auto* entity = Player::GetPlayer(player);
auto* entity = PlayerManager::GetPlayer(player);
LOG("Saving data!");
if (entity != nullptr && entity->GetCharacter() != nullptr) {
auto* skillComponent = entity->GetComponent<SkillComponent>();