mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2025-08-09 20:24:16 +00:00
Merge branch 'main' into cdclient-rework
This commit is contained in:
59
dGame/CMakeLists.txt
Normal file
59
dGame/CMakeLists.txt
Normal file
@@ -0,0 +1,59 @@
|
||||
set(DGAME_SOURCES "Character.cpp"
|
||||
"Entity.cpp"
|
||||
"EntityManager.cpp"
|
||||
"LeaderboardManager.cpp"
|
||||
"Player.cpp"
|
||||
"TeamManager.cpp"
|
||||
"TradingManager.cpp"
|
||||
"User.cpp"
|
||||
"UserManager.cpp")
|
||||
|
||||
add_subdirectory(dBehaviors)
|
||||
|
||||
foreach(file ${DGAME_DBEHAVIORS_SOURCES})
|
||||
set(DGAME_SOURCES ${DGAME_SOURCES} "dBehaviors/${file}")
|
||||
endforeach()
|
||||
|
||||
add_subdirectory(dComponents)
|
||||
|
||||
foreach(file ${DGAME_DCOMPONENTS_SOURCES})
|
||||
set(DGAME_SOURCES ${DGAME_SOURCES} "dComponents/${file}")
|
||||
endforeach()
|
||||
|
||||
add_subdirectory(dEntity)
|
||||
|
||||
foreach(file ${DGAME_DENTITY_SOURCES})
|
||||
set(DGAME_SOURCES ${DGAME_SOURCES} "dEntity/${file}")
|
||||
endforeach()
|
||||
|
||||
add_subdirectory(dGameMessages)
|
||||
|
||||
foreach(file ${DGAME_DGAMEMESSAGES_SOURCES})
|
||||
set(DGAME_SOURCES ${DGAME_SOURCES} "dGameMessages/${file}")
|
||||
endforeach()
|
||||
|
||||
add_subdirectory(dInventory)
|
||||
|
||||
foreach(file ${DGAME_DINVENTORY_SOURCES})
|
||||
set(DGAME_SOURCES ${DGAME_SOURCES} "dInventory/${file}")
|
||||
endforeach()
|
||||
|
||||
add_subdirectory(dMission)
|
||||
|
||||
foreach(file ${DGAME_DMISSION_SOURCES})
|
||||
set(DGAME_SOURCES ${DGAME_SOURCES} "dMission/${file}")
|
||||
endforeach()
|
||||
|
||||
add_subdirectory(dUtilities)
|
||||
|
||||
foreach(file ${DGAME_DUTILITIES_SOURCES})
|
||||
set(DGAME_SOURCES ${DGAME_SOURCES} "dUtilities/${file}")
|
||||
endforeach()
|
||||
|
||||
foreach(file ${DSCRIPT_SOURCES})
|
||||
set(DGAME_SOURCES ${DGAME_SOURCES} "${PROJECT_SOURCE_DIR}/dScripts/${file}")
|
||||
endforeach()
|
||||
|
||||
add_library(dGame STATIC ${DGAME_SOURCES})
|
||||
|
||||
target_link_libraries(dGame dDatabase)
|
@@ -109,6 +109,11 @@ Entity::~Entity() {
|
||||
|
||||
m_Components.erase(pair.first);
|
||||
}
|
||||
|
||||
for (auto child : m_ChildEntities) {
|
||||
if (child) child->RemoveParent();
|
||||
}
|
||||
|
||||
if (m_ParentEntity) {
|
||||
m_ParentEntity->RemoveChild(this);
|
||||
}
|
||||
@@ -1201,17 +1206,21 @@ void Entity::UpdateXMLDoc(tinyxml2::XMLDocument* doc) {
|
||||
}
|
||||
|
||||
void Entity::Update(const float deltaTime) {
|
||||
for (int i = 0; i < m_Timers.size(); i++) {
|
||||
m_Timers[i]->Update(deltaTime);
|
||||
if (m_Timers[i]->GetTime() <= 0) {
|
||||
const auto timerName = m_Timers[i]->GetName();
|
||||
uint32_t timerPosition;
|
||||
timerPosition = 0;
|
||||
while (timerPosition < m_Timers.size()) {
|
||||
m_Timers[timerPosition]->Update(deltaTime);
|
||||
if (m_Timers[timerPosition]->GetTime() <= 0) {
|
||||
const auto timerName = m_Timers[timerPosition]->GetName();
|
||||
|
||||
delete m_Timers[i];
|
||||
m_Timers.erase(m_Timers.begin() + i);
|
||||
delete m_Timers[timerPosition];
|
||||
m_Timers.erase(m_Timers.begin() + timerPosition);
|
||||
|
||||
for (CppScripts::Script* script : CppScripts::GetEntityScripts(this)) {
|
||||
script->OnTimerDone(this, timerName);
|
||||
}
|
||||
} else {
|
||||
timerPosition++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1223,6 +1232,14 @@ void Entity::Update(const float deltaTime) {
|
||||
m_CallbackTimers.erase(m_CallbackTimers.begin() + i);
|
||||
}
|
||||
}
|
||||
|
||||
// Add pending timers to the list of timers so they start next tick.
|
||||
if (m_PendingTimers.size() > 0) {
|
||||
for (auto namedTimer : m_PendingTimers) {
|
||||
m_Timers.push_back(namedTimer);
|
||||
}
|
||||
m_PendingTimers.clear();
|
||||
}
|
||||
|
||||
if (IsSleeping())
|
||||
{
|
||||
@@ -1650,18 +1667,24 @@ void Entity::AddChild(Entity* child) {
|
||||
|
||||
void Entity::RemoveChild(Entity* child) {
|
||||
if (!child) return;
|
||||
for (auto entity = m_ChildEntities.begin(); entity != m_ChildEntities.end(); entity++) {
|
||||
if (*entity && (*entity)->GetObjectID() == child->GetObjectID()) {
|
||||
uint32_t entityPosition = 0;
|
||||
while (entityPosition < m_ChildEntities.size()) {
|
||||
if (!m_ChildEntities[entityPosition] || (m_ChildEntities[entityPosition])->GetObjectID() == child->GetObjectID()) {
|
||||
m_IsParentChildDirty = true;
|
||||
m_ChildEntities.erase(entity);
|
||||
return;
|
||||
m_ChildEntities.erase(m_ChildEntities.begin() + entityPosition);
|
||||
} else {
|
||||
entityPosition++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Entity::RemoveParent() {
|
||||
this->m_ParentEntity = nullptr;
|
||||
}
|
||||
|
||||
void Entity::AddTimer(std::string name, float time) {
|
||||
EntityTimer* timer = new EntityTimer(name, time);
|
||||
m_Timers.push_back(timer);
|
||||
m_PendingTimers.push_back(timer);
|
||||
}
|
||||
|
||||
void Entity::AddCallbackTimer(float time, std::function<void()> callback) {
|
||||
|
@@ -144,6 +144,7 @@ public:
|
||||
|
||||
void AddChild(Entity* child);
|
||||
void RemoveChild(Entity* child);
|
||||
void RemoveParent();
|
||||
void AddTimer(std::string name, float time);
|
||||
void AddCallbackTimer(float time, std::function<void()> callback);
|
||||
bool HasTimer(const std::string& name);
|
||||
@@ -309,6 +310,7 @@ protected:
|
||||
|
||||
std::unordered_map<int32_t, Component*> m_Components; //The int is the ID of the component
|
||||
std::vector<EntityTimer*> m_Timers;
|
||||
std::vector<EntityTimer*> m_PendingTimers;
|
||||
std::vector<EntityCallbackTimer*> m_CallbackTimers;
|
||||
|
||||
bool m_ShouldDestroyAfterUpdate = false;
|
||||
|
@@ -401,7 +401,7 @@ void EntityManager::ConstructEntity(Entity* entity, const SystemAddress& sysAddr
|
||||
Game::server->Send(&stream, sysAddr, false);
|
||||
}
|
||||
|
||||
PacketUtils::SavePacket("[24]_"+std::to_string(entity->GetObjectID()) + "_" + std::to_string(m_SerializationCounter) + ".bin", (char*)stream.GetData(), stream.GetNumberOfBytesUsed());
|
||||
// PacketUtils::SavePacket("[24]_"+std::to_string(entity->GetObjectID()) + "_" + std::to_string(m_SerializationCounter) + ".bin", (char*)stream.GetData(), stream.GetNumberOfBytesUsed());
|
||||
|
||||
if (entity->IsPlayer())
|
||||
{
|
||||
|
@@ -369,10 +369,8 @@ void UserManager::DeleteCharacter(const SystemAddress& sysAddr, Packet* packet)
|
||||
}
|
||||
|
||||
LWOOBJID objectID = PacketUtils::ReadPacketS64(8, packet);
|
||||
objectID = GeneralUtils::ClearBit(objectID, OBJECT_BIT_CHARACTER);
|
||||
objectID = GeneralUtils::ClearBit(objectID, OBJECT_BIT_PERSISTENT);
|
||||
|
||||
uint32_t charID = static_cast<uint32_t>(objectID);
|
||||
uint32_t charID = static_cast<uint32_t>(objectID);
|
||||
|
||||
Game::logger->Log("UserManager", "Received char delete req for ID: %llu (%u)\n", objectID, charID);
|
||||
|
||||
//Check if this user has this character:
|
||||
@@ -402,10 +400,14 @@ void UserManager::DeleteCharacter(const SystemAddress& sysAddr, Packet* packet)
|
||||
}
|
||||
{
|
||||
sql::PreparedStatement* stmt = Database::CreatePreppedStmt("DELETE FROM friends WHERE player_id=? OR friend_id=?;");
|
||||
stmt->setUInt64(1, charID);
|
||||
stmt->setUInt64(2, charID);
|
||||
stmt->setUInt(1, charID);
|
||||
stmt->setUInt(2, charID);
|
||||
stmt->execute();
|
||||
delete stmt;
|
||||
CBITSTREAM;
|
||||
PacketUtils::WriteHeader(bitStream, CHAT_INTERNAL, MSG_CHAT_INTERNAL_PLAYER_REMOVED_NOTIFICATION);
|
||||
bitStream.Write(objectID);
|
||||
Game::chatServer->Send(&bitStream, SYSTEM_PRIORITY, RELIABLE, 0, Game::chatSysAddr, false);
|
||||
}
|
||||
{
|
||||
sql::PreparedStatement* stmt = Database::CreatePreppedStmt("DELETE FROM leaderboard WHERE character_id=?;");
|
||||
|
@@ -409,7 +409,7 @@ Behavior::Behavior(const uint32_t behaviorId)
|
||||
{
|
||||
auto behaviorTemplateTable = CDClientManager::Instance()->GetTable<CDBehaviorTemplateTable>("BehaviorTemplate");
|
||||
|
||||
CDBehaviorTemplate templateInDatabase;
|
||||
CDBehaviorTemplate templateInDatabase{};
|
||||
|
||||
if (behaviorTemplateTable) {
|
||||
auto templateEntry = behaviorTemplateTable->GetByBehaviorID(behaviorId);
|
||||
@@ -445,7 +445,7 @@ Behavior::Behavior(const uint32_t behaviorId)
|
||||
|
||||
this->m_effectId = templateInDatabase.effectID;
|
||||
|
||||
this->m_effectHandle = templateInDatabase.effectHandle != "" ? new std::string(templateInDatabase.effectHandle) : nullptr;
|
||||
this->m_effectHandle = *templateInDatabase.effectHandle != "" ? new std::string(*templateInDatabase.effectHandle) : nullptr;
|
||||
}
|
||||
|
||||
|
||||
|
51
dGame/dBehaviors/CMakeLists.txt
Normal file
51
dGame/dBehaviors/CMakeLists.txt
Normal file
@@ -0,0 +1,51 @@
|
||||
set(DGAME_DBEHAVIORS_SOURCES "AirMovementBehavior.cpp"
|
||||
"AndBehavior.cpp"
|
||||
"ApplyBuffBehavior.cpp"
|
||||
"AreaOfEffectBehavior.cpp"
|
||||
"AttackDelayBehavior.cpp"
|
||||
"BasicAttackBehavior.cpp"
|
||||
"Behavior.cpp"
|
||||
"BehaviorBranchContext.cpp"
|
||||
"BehaviorContext.cpp"
|
||||
"BehaviorTemplates.cpp"
|
||||
"BlockBehavior.cpp"
|
||||
"BuffBehavior.cpp"
|
||||
"CarBoostBehavior.cpp"
|
||||
"ChainBehavior.cpp"
|
||||
"ChangeOrientationBehavior.cpp"
|
||||
"ChargeUpBehavior.cpp"
|
||||
"ClearTargetBehavior.cpp"
|
||||
"DamageAbsorptionBehavior.cpp"
|
||||
"DamageReductionBehavior.cpp"
|
||||
"DurationBehavior.cpp"
|
||||
"EmptyBehavior.cpp"
|
||||
"EndBehavior.cpp"
|
||||
"ForceMovementBehavior.cpp"
|
||||
"HealBehavior.cpp"
|
||||
"ImaginationBehavior.cpp"
|
||||
"ImmunityBehavior.cpp"
|
||||
"InterruptBehavior.cpp"
|
||||
"JetPackBehavior.cpp"
|
||||
"KnockbackBehavior.cpp"
|
||||
"LootBuffBehavior.cpp"
|
||||
"MovementSwitchBehavior.cpp"
|
||||
"NpcCombatSkillBehavior.cpp"
|
||||
"OverTimeBehavior.cpp"
|
||||
"PlayEffectBehavior.cpp"
|
||||
"ProjectileAttackBehavior.cpp"
|
||||
"PullToPointBehavior.cpp"
|
||||
"RepairBehavior.cpp"
|
||||
"SkillCastFailedBehavior.cpp"
|
||||
"SkillEventBehavior.cpp"
|
||||
"SpawnBehavior.cpp"
|
||||
"SpawnQuickbuildBehavior.cpp"
|
||||
"SpeedBehavior.cpp"
|
||||
"StartBehavior.cpp"
|
||||
"StunBehavior.cpp"
|
||||
"SwitchBehavior.cpp"
|
||||
"SwitchMultipleBehavior.cpp"
|
||||
"TacArcBehavior.cpp"
|
||||
"TargetCasterBehavior.cpp"
|
||||
"TauntBehavior.cpp"
|
||||
"VentureVisionBehavior.cpp"
|
||||
"VerifyBehavior.cpp" PARENT_SCOPE)
|
40
dGame/dComponents/CMakeLists.txt
Normal file
40
dGame/dComponents/CMakeLists.txt
Normal file
@@ -0,0 +1,40 @@
|
||||
set(DGAME_DCOMPONENTS_SOURCES "BaseCombatAIComponent.cpp"
|
||||
"BouncerComponent.cpp"
|
||||
"BuffComponent.cpp"
|
||||
"BuildBorderComponent.cpp"
|
||||
"CharacterComponent.cpp"
|
||||
"Component.cpp"
|
||||
"ControllablePhysicsComponent.cpp"
|
||||
"DestroyableComponent.cpp"
|
||||
"InventoryComponent.cpp"
|
||||
"LUPExhibitComponent.cpp"
|
||||
"MissionComponent.cpp"
|
||||
"MissionOfferComponent.cpp"
|
||||
"ModelComponent.cpp"
|
||||
"ModuleAssemblyComponent.cpp"
|
||||
"MovementAIComponent.cpp"
|
||||
"MovingPlatformComponent.cpp"
|
||||
"PetComponent.cpp"
|
||||
"PhantomPhysicsComponent.cpp"
|
||||
"PossessableComponent.cpp"
|
||||
"PossessorComponent.cpp"
|
||||
"PropertyComponent.cpp"
|
||||
"PropertyEntranceComponent.cpp"
|
||||
"PropertyManagementComponent.cpp"
|
||||
"PropertyVendorComponent.cpp"
|
||||
"ProximityMonitorComponent.cpp"
|
||||
"RacingControlComponent.cpp"
|
||||
"RailActivatorComponent.cpp"
|
||||
"RebuildComponent.cpp"
|
||||
"RenderComponent.cpp"
|
||||
"RigidbodyPhantomPhysicsComponent.cpp"
|
||||
"RocketLaunchLupComponent.cpp"
|
||||
"RocketLaunchpadControlComponent.cpp"
|
||||
"ScriptedActivityComponent.cpp"
|
||||
"ShootingGalleryComponent.cpp"
|
||||
"SimplePhysicsComponent.cpp"
|
||||
"SkillComponent.cpp"
|
||||
"SoundTriggerComponent.cpp"
|
||||
"SwitchComponent.cpp"
|
||||
"VehiclePhysicsComponent.cpp"
|
||||
"VendorComponent.cpp" PARENT_SCOPE)
|
@@ -179,6 +179,18 @@ public:
|
||||
*/
|
||||
void SetLastRocketItemID(LWOOBJID lastRocketItemID) { m_LastRocketItemID = lastRocketItemID; }
|
||||
|
||||
/**
|
||||
* Gets the object ID of the mount item that is being used
|
||||
* @return the object ID of the mount item that is being used
|
||||
*/
|
||||
LWOOBJID GetMountItemID() const { return m_MountItemID; }
|
||||
|
||||
/**
|
||||
* Sets the object ID of the mount item that is being used
|
||||
* @param m_MountItemID the object ID of the mount item that is being used
|
||||
*/
|
||||
void SetMountItemID(LWOOBJID mountItemID) { m_MountItemID = mountItemID; }
|
||||
|
||||
/**
|
||||
* Gives the player rewards for the last level that they leveled up from
|
||||
*/
|
||||
@@ -579,6 +591,11 @@ private:
|
||||
* ID of the last rocket used
|
||||
*/
|
||||
LWOOBJID m_LastRocketItemID = LWOOBJID_EMPTY;
|
||||
|
||||
/**
|
||||
* Mount Item ID
|
||||
*/
|
||||
LWOOBJID m_MountItemID = LWOOBJID_EMPTY;
|
||||
};
|
||||
|
||||
#endif // CHARACTERCOMPONENT_H
|
||||
|
@@ -25,6 +25,7 @@
|
||||
#include "PropertyManagementComponent.h"
|
||||
#include "DestroyableComponent.h"
|
||||
#include "dConfig.h"
|
||||
#include "eItemType.h"
|
||||
|
||||
InventoryComponent::InventoryComponent(Entity* parent, tinyxml2::XMLDocument* document) : Component(parent)
|
||||
{
|
||||
@@ -1024,13 +1025,13 @@ void InventoryComponent::EquipItem(Item* item, const bool skipChecks)
|
||||
return;
|
||||
}
|
||||
|
||||
if (type == ITEM_TYPE_LOOT_MODEL || type == ITEM_TYPE_VEHICLE)
|
||||
if (type == eItemType::ITEM_TYPE_LOOT_MODEL || type == eItemType::ITEM_TYPE_VEHICLE)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (type != ITEM_TYPE_LOOT_MODEL && type != ITEM_TYPE_MODEL)
|
||||
if (type != eItemType::ITEM_TYPE_LOOT_MODEL && type != eItemType::ITEM_TYPE_MODEL)
|
||||
{
|
||||
if (!item->GetBound() && !item->GetPreconditionExpression()->Check(m_Parent))
|
||||
{
|
||||
@@ -1411,15 +1412,15 @@ void InventoryComponent::RemoveDatabasePet(LWOOBJID id)
|
||||
BehaviorSlot InventoryComponent::FindBehaviorSlot(const eItemType type)
|
||||
{
|
||||
switch (type) {
|
||||
case ITEM_TYPE_HAT:
|
||||
case eItemType::ITEM_TYPE_HAT:
|
||||
return BehaviorSlot::Head;
|
||||
case ITEM_TYPE_NECK:
|
||||
case eItemType::ITEM_TYPE_NECK:
|
||||
return BehaviorSlot::Neck;
|
||||
case ITEM_TYPE_LEFT_HAND:
|
||||
case eItemType::ITEM_TYPE_LEFT_HAND:
|
||||
return BehaviorSlot::Offhand;
|
||||
case ITEM_TYPE_RIGHT_HAND:
|
||||
case eItemType::ITEM_TYPE_RIGHT_HAND:
|
||||
return BehaviorSlot::Primary;
|
||||
case ITEM_TYPE_CONSUMABLE:
|
||||
case eItemType::ITEM_TYPE_CONSUMABLE:
|
||||
return BehaviorSlot::Consumable;
|
||||
default:
|
||||
return BehaviorSlot::Invalid;
|
||||
|
@@ -1,4 +1,4 @@
|
||||
#pragma once
|
||||
#pragma once
|
||||
|
||||
#ifndef INVENTORYCOMPONENT_H
|
||||
#define INVENTORYCOMPONENT_H
|
||||
@@ -25,6 +25,8 @@ class ItemSet;
|
||||
|
||||
typedef std::map<std::string, EquippedItem> EquipmentMap;
|
||||
|
||||
enum class eItemType : int32_t;
|
||||
|
||||
/**
|
||||
* Handles the inventory of entity, including the items they possess and have equipped. An entity can have inventories
|
||||
* of different types, each type representing a different group of items, see `eInventoryType` for a list of
|
||||
|
@@ -1,10 +1,13 @@
|
||||
#include "PossessableComponent.h"
|
||||
#include "PossessorComponent.h"
|
||||
#include "EntityManager.h"
|
||||
#include "Inventory.h"
|
||||
#include "Item.h"
|
||||
|
||||
PossessableComponent::PossessableComponent(Entity* parent, uint32_t componentId) : Component(parent){
|
||||
m_Possessor = LWOOBJID_EMPTY;
|
||||
CDItemComponent item = Inventory::FindItemComponent(m_Parent->GetLOT());
|
||||
m_AnimationFlag = static_cast<eAnimationFlags>(item.animationFlag);
|
||||
|
||||
// Get the possession Type from the CDClient
|
||||
auto query = CDClientDatabase::CreatePreppedStmt("SELECT possessionType, depossessOnHit FROM PossessableComponent WHERE id = ?;");
|
||||
|
@@ -54,6 +54,18 @@ class PossessableComponent : public Component {
|
||||
*/
|
||||
void ForceDepossess() { m_ImmediatelyDepossess = true; m_DirtyPossessable = true;};
|
||||
|
||||
/**
|
||||
* Set if the parent entity was spawned from an item
|
||||
* @param value if the parent entity was spawned from an item
|
||||
*/
|
||||
void SetItemSpawned(bool value) { m_ItemSpawned = value;};
|
||||
|
||||
/**
|
||||
* Returns if the parent entity was spawned from an item
|
||||
* @return if the parent entity was spawned from an item
|
||||
*/
|
||||
LWOOBJID GetItemSpawned() const { return m_ItemSpawned; };
|
||||
|
||||
/**
|
||||
* Handles an OnUsed event by some other entity, if said entity has a Possessor it becomes the possessor
|
||||
* of this entity
|
||||
@@ -95,4 +107,9 @@ class PossessableComponent : public Component {
|
||||
*/
|
||||
bool m_ImmediatelyDepossess = false;
|
||||
|
||||
/**
|
||||
* @brief Whether the parent entity was spawned from an item
|
||||
*
|
||||
*/
|
||||
bool m_ItemSpawned = false;
|
||||
};
|
||||
|
@@ -36,6 +36,18 @@ class PossessorComponent : public Component {
|
||||
*/
|
||||
LWOOBJID GetPossessable() const { return m_Possessable; }
|
||||
|
||||
/**
|
||||
* Sets if we are busy mounting or dismounting
|
||||
* @param value if we are busy mounting or dismounting
|
||||
*/
|
||||
void SetIsBusy(bool value) { m_IsBusy = value; }
|
||||
|
||||
/**
|
||||
* Returns if we are busy mounting or dismounting
|
||||
* @return if we are busy mounting or dismounting
|
||||
*/
|
||||
bool GetIsBusy() const { return m_IsBusy; }
|
||||
|
||||
/**
|
||||
* Sets the possesible type that's currently used, merely used by the shooting gallery if it's 0
|
||||
* @param value the possesible type to set
|
||||
@@ -60,4 +72,10 @@ class PossessorComponent : public Component {
|
||||
*
|
||||
*/
|
||||
bool m_DirtyPossesor = false;
|
||||
|
||||
/**
|
||||
* @brief if the possessor is busy mounting or dismounting
|
||||
*
|
||||
*/
|
||||
bool m_IsBusy = false;
|
||||
};
|
||||
|
@@ -102,7 +102,7 @@ PropertySelectQueryProperty PropertyEntranceComponent::SetPropertyValues(Propert
|
||||
return property;
|
||||
}
|
||||
|
||||
std::string PropertyEntranceComponent::BuildQuery(Entity* entity, int32_t sortMethod, std::string customQuery, bool wantLimits) {
|
||||
std::string PropertyEntranceComponent::BuildQuery(Entity* entity, int32_t sortMethod, Character* character, std::string customQuery, bool wantLimits) {
|
||||
std::string base;
|
||||
if (customQuery == "") {
|
||||
base = baseQueryForProperties;
|
||||
@@ -115,15 +115,13 @@ std::string PropertyEntranceComponent::BuildQuery(Entity* entity, int32_t sortMe
|
||||
|
||||
auto friendsListQuery = Database::CreatePreppedStmt("SELECT * FROM (SELECT CASE WHEN player_id = ? THEN friend_id WHEN friend_id = ? THEN player_id END AS requested_player FROM friends ) AS fr WHERE requested_player IS NOT NULL ORDER BY requested_player DESC;");
|
||||
|
||||
friendsListQuery->setInt64(1, entity->GetObjectID());
|
||||
friendsListQuery->setInt64(2, entity->GetObjectID());
|
||||
friendsListQuery->setUInt(1, character->GetID());
|
||||
friendsListQuery->setUInt(2, character->GetID());
|
||||
|
||||
auto friendsListQueryResult = friendsListQuery->executeQuery();
|
||||
|
||||
while (friendsListQueryResult->next()) {
|
||||
auto playerIDToConvert = friendsListQueryResult->getInt64(1);
|
||||
playerIDToConvert = GeneralUtils::ClearBit(playerIDToConvert, OBJECT_BIT_CHARACTER);
|
||||
playerIDToConvert = GeneralUtils::ClearBit(playerIDToConvert, OBJECT_BIT_PERSISTENT);
|
||||
auto playerIDToConvert = friendsListQueryResult->getInt(1);
|
||||
friendsList = friendsList + std::to_string(playerIDToConvert) + ",";
|
||||
}
|
||||
// Replace trailing comma with the closing parenthesis.
|
||||
@@ -193,7 +191,7 @@ void PropertyEntranceComponent::OnPropertyEntranceSync(Entity* entity, bool incl
|
||||
|
||||
entries.push_back(playerEntry);
|
||||
|
||||
const auto query = BuildQuery(entity, sortMethod);
|
||||
const auto query = BuildQuery(entity, sortMethod, character);
|
||||
|
||||
auto propertyLookup = Database::CreatePreppedStmt(query);
|
||||
|
||||
@@ -262,17 +260,17 @@ void PropertyEntranceComponent::OnPropertyEntranceSync(Entity* entity, bool incl
|
||||
// Query to get friend and best friend fields
|
||||
auto friendCheck = Database::CreatePreppedStmt("SELECT best_friend FROM friends WHERE (player_id = ? AND friend_id = ?) OR (player_id = ? AND friend_id = ?)");
|
||||
|
||||
friendCheck->setInt64(1, entity->GetObjectID());
|
||||
friendCheck->setInt64(2, ownerObjId);
|
||||
friendCheck->setInt64(3, ownerObjId);
|
||||
friendCheck->setInt64(4, entity->GetObjectID());
|
||||
friendCheck->setUInt(1, character->GetID());
|
||||
friendCheck->setUInt(2, ownerObjId);
|
||||
friendCheck->setUInt(3, ownerObjId);
|
||||
friendCheck->setUInt(4, character->GetID());
|
||||
|
||||
auto friendResult = friendCheck->executeQuery();
|
||||
|
||||
// If we got a result than the two players are friends.
|
||||
if (friendResult->next()) {
|
||||
isFriend = true;
|
||||
if (friendResult->getInt(1) == 2) {
|
||||
if (friendResult->getInt(1) == 3) {
|
||||
isBestFriend = true;
|
||||
}
|
||||
}
|
||||
@@ -326,7 +324,7 @@ void PropertyEntranceComponent::OnPropertyEntranceSync(Entity* entity, bool incl
|
||||
// Query here is to figure out whether or not to display the button to go to the next page or not.
|
||||
int32_t numberOfProperties = 0;
|
||||
|
||||
auto buttonQuery = BuildQuery(entity, sortMethod, "SELECT COUNT(*) FROM properties as p JOIN charinfo as ci ON ci.prop_clone_id = p.clone_id where p.zone_id = ? AND (p.description LIKE ? OR p.name LIKE ? OR ci.name LIKE ?) AND p.privacy_option >= ? ", false);
|
||||
auto buttonQuery = BuildQuery(entity, sortMethod, character, "SELECT COUNT(*) FROM properties as p JOIN charinfo as ci ON ci.prop_clone_id = p.clone_id where p.zone_id = ? AND (p.description LIKE ? OR p.name LIKE ? OR ci.name LIKE ?) AND p.privacy_option >= ? ", false);
|
||||
auto propertiesLeft = Database::CreatePreppedStmt(buttonQuery);
|
||||
|
||||
propertiesLeft->setUInt(1, this->m_MapID);
|
||||
|
@@ -60,7 +60,7 @@ class PropertyEntranceComponent : public Component {
|
||||
|
||||
PropertySelectQueryProperty SetPropertyValues(PropertySelectQueryProperty property, LWOCLONEID cloneId = LWOCLONEID_INVALID, std::string ownerName = "", std::string propertyName = "", std::string propertyDescription = "", float reputation = 0, bool isBFF = false, bool isFriend = false, bool isModeratorApproved = false, bool isAlt = false, bool isOwned = false, uint32_t privacyOption = 0, uint32_t timeLastUpdated = 0, float performanceCost = 0.0f);
|
||||
|
||||
std::string BuildQuery(Entity* entity, int32_t sortMethod, std::string customQuery = "", bool wantLimits = true);
|
||||
std::string BuildQuery(Entity* entity, int32_t sortMethod, Character* character, std::string customQuery = "", bool wantLimits = true);
|
||||
|
||||
private:
|
||||
/**
|
||||
|
2
dGame/dEntity/CMakeLists.txt
Normal file
2
dGame/dEntity/CMakeLists.txt
Normal file
@@ -0,0 +1,2 @@
|
||||
set(DGAME_DENTITY_SOURCES "EntityCallbackTimer.cpp"
|
||||
"EntityTimer.cpp" PARENT_SCOPE)
|
4
dGame/dGameMessages/CMakeLists.txt
Normal file
4
dGame/dGameMessages/CMakeLists.txt
Normal file
@@ -0,0 +1,4 @@
|
||||
set(DGAME_DGAMEMESSAGES_SOURCES "GameMessageHandler.cpp"
|
||||
"GameMessages.cpp"
|
||||
"PropertyDataMessage.cpp"
|
||||
"PropertySelectQueryProperty.cpp" PARENT_SCOPE)
|
File diff suppressed because it is too large
Load Diff
@@ -328,6 +328,34 @@ namespace GameMessages {
|
||||
|
||||
void SendDisplayChatBubble(LWOOBJID objectId, const std::u16string& text, const SystemAddress& sysAddr);
|
||||
|
||||
// Mounts
|
||||
/**
|
||||
* @brief Set the Inventory LWOOBJID of the mount
|
||||
*
|
||||
* @param entity The entity that is mounting
|
||||
* @param sysAddr the system address to send game message responses to
|
||||
* @param objectID LWOOBJID of the item in inventory that is being used
|
||||
*/
|
||||
void SendSetMountInventoryID(Entity* entity, const LWOOBJID& objectID, const SystemAddress& sysAddr);
|
||||
|
||||
/**
|
||||
* @brief Handle client dismounting mount
|
||||
*
|
||||
* @param inStream Raknet BitStream of incoming data
|
||||
* @param entity The Entity that is dismounting
|
||||
* @param sysAddr the system address to send game message responses to
|
||||
*/
|
||||
void HandleDismountComplete(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr);
|
||||
|
||||
/**
|
||||
* @brief Handle acknowledging that the client possessed something
|
||||
*
|
||||
* @param inStream Raknet BitStream of incoming data
|
||||
* @param entity The Entity that is possessing
|
||||
* @param sysAddr the system address to send game message responses to
|
||||
*/
|
||||
void HandleAcknowledgePossession(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr);
|
||||
|
||||
//Racing:
|
||||
void HandleModuleAssemblyQueryData(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr);
|
||||
|
||||
@@ -337,8 +365,6 @@ namespace GameMessages {
|
||||
|
||||
void HandleRacingClientReady(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr);
|
||||
|
||||
void HandleAcknowledgePossession(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr);
|
||||
|
||||
void HandleRequestDie(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr);
|
||||
|
||||
void HandleVehicleNotifyServerAddPassiveBoostAction(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr);
|
||||
|
5
dGame/dInventory/CMakeLists.txt
Normal file
5
dGame/dInventory/CMakeLists.txt
Normal file
@@ -0,0 +1,5 @@
|
||||
set(DGAME_DINVENTORY_SOURCES "EquippedItem.cpp"
|
||||
"Inventory.cpp"
|
||||
"Item.cpp"
|
||||
"ItemSet.cpp"
|
||||
"ItemSetPassiveAbility.cpp" PARENT_SCOPE)
|
@@ -1,7 +1,8 @@
|
||||
#include "Inventory.h"
|
||||
#include "Inventory.h"
|
||||
#include "GameMessages.h"
|
||||
#include "Game.h"
|
||||
#include "Item.h"
|
||||
#include "eItemType.h"
|
||||
|
||||
std::vector<LOT> Inventory::m_GameMasterRestrictedItems = {
|
||||
1727, // GM Only - JetPack
|
||||
@@ -274,40 +275,41 @@ eInventoryType Inventory::FindInventoryTypeForLot(const LOT lot)
|
||||
const auto itemType = static_cast<eItemType>(itemComponent.itemType);
|
||||
|
||||
switch (itemType) {
|
||||
case ITEM_TYPE_BRICK:
|
||||
case eItemType::ITEM_TYPE_BRICK:
|
||||
return BRICKS;
|
||||
|
||||
case ITEM_TYPE_BEHAVIOR:
|
||||
case eItemType::ITEM_TYPE_BEHAVIOR:
|
||||
return BEHAVIORS;
|
||||
|
||||
case ITEM_TYPE_PROPERTY:
|
||||
case eItemType::ITEM_TYPE_PROPERTY:
|
||||
return PROPERTY_DEEDS;
|
||||
|
||||
case ITEM_TYPE_MODEL:
|
||||
case ITEM_TYPE_VEHICLE:
|
||||
case ITEM_TYPE_LOOT_MODEL:
|
||||
case eItemType::ITEM_TYPE_MODEL:
|
||||
case eItemType::ITEM_TYPE_VEHICLE:
|
||||
case eItemType::ITEM_TYPE_LOOT_MODEL:
|
||||
case eItemType::ITEM_TYPE_MOUNT:
|
||||
return MODELS;
|
||||
|
||||
case ITEM_TYPE_HAT:
|
||||
case ITEM_TYPE_HAIR:
|
||||
case ITEM_TYPE_NECK:
|
||||
case ITEM_TYPE_LEFT_HAND:
|
||||
case ITEM_TYPE_RIGHT_HAND:
|
||||
case ITEM_TYPE_LEGS:
|
||||
case ITEM_TYPE_LEFT_TRINKET:
|
||||
case ITEM_TYPE_RIGHT_TRINKET:
|
||||
case ITEM_TYPE_COLLECTIBLE:
|
||||
case ITEM_TYPE_CONSUMABLE:
|
||||
case ITEM_TYPE_CHEST:
|
||||
case ITEM_TYPE_EGG:
|
||||
case ITEM_TYPE_PET_FOOD:
|
||||
case ITEM_TYPE_PET_INVENTORY_ITEM:
|
||||
case ITEM_TYPE_PACKAGE:
|
||||
case ITEM_TYPE_CURRENCY:
|
||||
case eItemType::ITEM_TYPE_HAT:
|
||||
case eItemType::ITEM_TYPE_HAIR:
|
||||
case eItemType::ITEM_TYPE_NECK:
|
||||
case eItemType::ITEM_TYPE_LEFT_HAND:
|
||||
case eItemType::ITEM_TYPE_RIGHT_HAND:
|
||||
case eItemType::ITEM_TYPE_LEGS:
|
||||
case eItemType::ITEM_TYPE_LEFT_TRINKET:
|
||||
case eItemType::ITEM_TYPE_RIGHT_TRINKET:
|
||||
case eItemType::ITEM_TYPE_COLLECTIBLE:
|
||||
case eItemType::ITEM_TYPE_CONSUMABLE:
|
||||
case eItemType::ITEM_TYPE_CHEST:
|
||||
case eItemType::ITEM_TYPE_EGG:
|
||||
case eItemType::ITEM_TYPE_PET_FOOD:
|
||||
case eItemType::ITEM_TYPE_PET_INVENTORY_ITEM:
|
||||
case eItemType::ITEM_TYPE_PACKAGE:
|
||||
case eItemType::ITEM_TYPE_CURRENCY:
|
||||
return ITEMS;
|
||||
|
||||
case ITEM_TYPE_QUEST_OBJECT:
|
||||
case ITEM_TYPE_UNKNOWN:
|
||||
case eItemType::ITEM_TYPE_QUEST_OBJECT:
|
||||
case eItemType::ITEM_TYPE_UNKNOWN:
|
||||
default:
|
||||
return HIDDEN;
|
||||
}
|
||||
|
3
dGame/dMission/CMakeLists.txt
Normal file
3
dGame/dMission/CMakeLists.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
set(DGAME_DMISSION_SOURCES "Mission.cpp"
|
||||
"MissionPrerequisites.cpp"
|
||||
"MissionTask.cpp" PARENT_SCOPE)
|
9
dGame/dUtilities/CMakeLists.txt
Normal file
9
dGame/dUtilities/CMakeLists.txt
Normal file
@@ -0,0 +1,9 @@
|
||||
set(DGAME_DUTILITIES_SOURCES "BrickDatabase.cpp"
|
||||
"dLocale.cpp"
|
||||
"GameConfig.cpp"
|
||||
"GUID.cpp"
|
||||
"Loot.cpp"
|
||||
"Mail.cpp"
|
||||
"Preconditions.cpp"
|
||||
"SlashCommandHandler.cpp"
|
||||
"VanityUtilities.cpp" PARENT_SCOPE)
|
@@ -2017,11 +2017,15 @@ void SlashCommandHandler::SendAnnouncement(const std::string& title, const std::
|
||||
CBITSTREAM;
|
||||
PacketUtils::WriteHeader(bitStream, CHAT_INTERNAL, MSG_CHAT_INTERNAL_ANNOUNCEMENT);
|
||||
|
||||
RakNet::RakString rsTitle(title.c_str());
|
||||
RakNet::RakString rsMsg(message.c_str());
|
||||
bitStream.Write<uint32_t>(title.size());
|
||||
for (auto character : title) {
|
||||
bitStream.Write<char>(character);
|
||||
}
|
||||
|
||||
bitStream.Write(rsTitle);
|
||||
bitStream.Write(rsMsg);
|
||||
bitStream.Write<uint32_t>(message.size());
|
||||
for (auto character : message) {
|
||||
bitStream.Write<char>(character);
|
||||
}
|
||||
|
||||
Game::chatServer->Send(&bitStream, SYSTEM_PRIORITY, RELIABLE, 0, Game::chatSysAddr, false);
|
||||
}
|
||||
|
Reference in New Issue
Block a user