Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: use more zoneTable options #1273

Merged
merged 2 commits into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions dDatabase/Tables/CDZoneTableTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ void CDZoneTableTable::LoadValuesFromDatabase() {
entry.smashableMaxDistance = tableData.getFloatField("smashableMaxDistance", -1.0f);
UNUSED(entry.mixerProgram = tableData.getStringField("mixerProgram", ""));
UNUSED(entry.clientPhysicsFramerate = tableData.getStringField("clientPhysicsFramerate", ""));
UNUSED(entry.serverPhysicsFramerate = tableData.getStringField("serverPhysicsFramerate", ""));
entry.serverPhysicsFramerate = tableData.getStringField("serverPhysicsFramerate", "");
entry.zoneControlTemplate = tableData.getIntField("zoneControlTemplate", -1);
entry.widthInChunks = tableData.getIntField("widthInChunks", -1);
entry.heightInChunks = tableData.getIntField("heightInChunks", -1);
Expand All @@ -40,10 +40,10 @@ void CDZoneTableTable::LoadValuesFromDatabase() {
entry.fZoneWeight = tableData.getFloatField("fZoneWeight", -1.0f);
UNUSED(entry.thumbnail = tableData.getStringField("thumbnail", ""));
entry.PlayerLoseCoinsOnDeath = tableData.getIntField("PlayerLoseCoinsOnDeath", -1) == 1 ? true : false;
UNUSED(entry.disableSaveLoc = tableData.getIntField("disableSaveLoc", -1) == 1 ? true : false);
entry.disableSaveLoc = tableData.getIntField("disableSaveLoc", -1) == 1 ? true : false;
entry.teamRadius = tableData.getFloatField("teamRadius", -1.0f);
UNUSED(entry.gate_version = tableData.getStringField("gate_version", ""));
UNUSED(entry.mountsAllowed = tableData.getIntField("mountsAllowed", -1) == 1 ? true : false);
entry.mountsAllowed = tableData.getIntField("mountsAllowed", -1) == 1 ? true : false;

this->m_Entries.insert(std::make_pair(entry.zoneID, entry));
tableData.nextRow();
Expand Down
6 changes: 3 additions & 3 deletions dDatabase/Tables/CDZoneTableTable.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ struct CDZoneTable {
float smashableMaxDistance; //!< The maximum smashable distance?
UNUSED(std::string mixerProgram); //!< ???
UNUSED(std::string clientPhysicsFramerate); //!< The client physics framerate
UNUSED(std::string serverPhysicsFramerate); //!< The server physics framerate
std::string serverPhysicsFramerate; //!< The server physics framerate
unsigned int zoneControlTemplate; //!< The Zone Control template
unsigned int widthInChunks; //!< The width of the world in chunks
unsigned int heightInChunks; //!< The height of the world in chunks
Expand All @@ -27,10 +27,10 @@ struct CDZoneTable {
float fZoneWeight; //!< ???
UNUSED(std::string thumbnail); //!< The thumbnail of the world
bool PlayerLoseCoinsOnDeath; //!< Whether or not the user loses coins on death
UNUSED(bool disableSaveLoc); //!< Disables the saving location?
bool disableSaveLoc; //!< Disables the saving location?
float teamRadius; //!< ???
UNUSED(std::string gate_version); //!< The gate version
UNUSED(bool mountsAllowed); //!< Whether or not mounts are allowed
bool mountsAllowed; //!< Whether or not mounts are allowed
};

class CDZoneTableTable : public CDTable<CDZoneTableTable> {
Expand Down
2 changes: 1 addition & 1 deletion dGame/Character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ void Character::SaveXMLToDatabase() {

auto zoneInfo = Game::zoneManager->GetZone()->GetZoneID();
// lzid garbage, binary concat of zoneID, zoneInstance and zoneClone
if (zoneInfo.GetMapID() != 0 && zoneInfo.GetCloneID() == 0) {
if (zoneInfo.GetMapID() != 0 && zoneInfo.GetCloneID() == 0 && !Game::zoneManager->GetDisableSaveLocation()) {
uint64_t lzidConcat = zoneInfo.GetCloneID();
lzidConcat = (lzidConcat << 16) | uint16_t(zoneInfo.GetInstanceID());
lzidConcat = (lzidConcat << 16) | uint16_t(zoneInfo.GetMapID());
Expand Down
2 changes: 1 addition & 1 deletion dGame/dComponents/ControllablePhysicsComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ void ControllablePhysicsComponent::UpdateXml(tinyxml2::XMLDocument* doc) {

auto zoneInfo = Game::zoneManager->GetZone()->GetZoneID();

if (zoneInfo.GetMapID() != 0 && zoneInfo.GetCloneID() == 0) {
if (zoneInfo.GetMapID() != 0 && zoneInfo.GetCloneID() == 0 && !Game::zoneManager->GetDisableSaveLocation()) {
character->SetAttribute("lzx", m_Position.x);
character->SetAttribute("lzy", m_Position.y);
character->SetAttribute("lzz", m_Position.z);
Expand Down
21 changes: 15 additions & 6 deletions dGame/dInventory/Item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
#include "eObjectBits.h"
#include "eReplicaComponentType.h"
#include "eUseItemResponse.h"
#include "dZoneManager.h"
#include "ChatPackets.h"

#include "CDBrickIDTableTable.h"
#include "CDObjectSkillsTable.h"
Expand Down Expand Up @@ -292,12 +294,19 @@ void Item::UseNonEquip(Item* item) {

const auto type = static_cast<eItemType>(info->itemType);
if (type == eItemType::MOUNT) {
playerInventoryComponent->HandlePossession(this);
// TODO Check if mounts are allowed to be spawned
} else if (type == eItemType::PET_INVENTORY_ITEM && subKey != LWOOBJID_EMPTY) {
const auto& databasePet = playerInventoryComponent->GetDatabasePet(subKey);
if (databasePet.lot != LOT_NULL) {
playerInventoryComponent->SpawnPet(this);
if (Game::zoneManager->GetMountsAllowed()){
playerInventoryComponent->HandlePossession(this);
} else {
ChatPackets::SendSystemMessage(playerEntity->GetSystemAddress(), u"Mounts are not allowed in this zone");
}
} else if (type == eItemType::PET_INVENTORY_ITEM && subKey != LWOOBJID_EMPTY ) {
if (Game::zoneManager->GetPetsAllowed()){
const auto& databasePet = playerInventoryComponent->GetDatabasePet(subKey);
if (databasePet.lot != LOT_NULL) {
playerInventoryComponent->SpawnPet(this);
}
} else {
ChatPackets::SendSystemMessage(playerEntity->GetSystemAddress(), u"Pets are not allowed in this zone");
}
// This precondition response is taken care of in SpawnPet().
} else {
Expand Down
26 changes: 23 additions & 3 deletions dWorldServer/PerformanceManager.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "PerformanceManager.h"

#include "CDZoneTableTable.h"
#include "CDClientManager.h"
#include "UserManager.h"

#define SOCIAL { lowFrameDelta }
Expand Down Expand Up @@ -68,11 +69,30 @@ std::map<LWOMAPID, PerformanceProfile> PerformanceManager::m_Profiles = {
};

void PerformanceManager::SelectProfile(LWOMAPID mapID) {
const auto pair = m_Profiles.find(mapID);
// Try to get it from zoneTable
CDZoneTableTable* zoneTable = CDClientManager::Instance().GetTable<CDZoneTableTable>();
if (zoneTable) {
const CDZoneTable* zone = zoneTable->Query(mapID);
if (zone) {
if (zone->serverPhysicsFramerate == "high"){
m_CurrentProfile = { highFrameDelta };
return;
}
if (zone->serverPhysicsFramerate == "medium"){
m_CurrentProfile = { mediumFrameDelta };
return;
}
if (zone->serverPhysicsFramerate == "low"){
m_CurrentProfile = { lowFrameDelta };
return;
}
}
}

// Fall back to hardcoded list and defaults
const auto pair = m_Profiles.find(mapID);
if (pair == m_Profiles.end()) {
m_CurrentProfile = m_DefaultProfile;

return;
}

Expand Down
3 changes: 3 additions & 0 deletions dZoneManager/dZoneManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ void dZoneManager::Initialize(const LWOZONEID& zoneID) {
Game::entityManager->SetGhostDistanceMax(max + min);
Game::entityManager->SetGhostDistanceMin(max);
m_PlayerLoseCoinsOnDeath = zone->PlayerLoseCoinsOnDeath;
m_DisableSaveLocation = zone->disableSaveLoc;
m_MountsAllowed = zone->mountsAllowed;
m_PetsAllowed = zone->petsAllowed;
}
}

Expand Down
8 changes: 7 additions & 1 deletion dZoneManager/dZoneManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ class dZoneManager {
void Update(float deltaTime);
Entity* GetZoneControlObject() { return m_ZoneControlObject; }
bool GetPlayerLoseCoinOnDeath() { return m_PlayerLoseCoinsOnDeath; }
bool GetDisableSaveLocation() { return m_DisableSaveLocation; }
bool GetMountsAllowed() { return m_MountsAllowed; }
bool GetPetsAllowed() { return m_PetsAllowed; }
uint32_t GetUniqueMissionIdStartingValue();
bool CheckIfAccessibleZone(LWOMAPID zoneID);

Expand All @@ -58,7 +61,10 @@ class dZoneManager {

Zone* m_pZone = nullptr;
LWOZONEID m_ZoneID;
bool m_PlayerLoseCoinsOnDeath; //Do players drop coins in this zone when smashed
bool m_PlayerLoseCoinsOnDeath = false;
bool m_DisableSaveLocation = false;
bool m_MountsAllowed = true;
bool m_PetsAllowed = true;
std::map<LWOOBJID, Spawner*> m_Spawners;
WorldConfig* m_WorldConfig = nullptr;

Expand Down
Loading