mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-02-24 19:59:57 +00:00
fix: imaginite on racing minigames and add null checks (#1958)
This commit is contained in:
@@ -325,9 +325,8 @@ bool ActivityComponent::CheckCost(Entity* player) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool ActivityComponent::TakeCost(Entity* player) const {
|
bool ActivityComponent::TakeCost(Entity* player) const {
|
||||||
|
|
||||||
auto* inventoryComponent = player->GetComponent<InventoryComponent>();
|
auto* inventoryComponent = player->GetComponent<InventoryComponent>();
|
||||||
return CheckCost(player) && inventoryComponent->RemoveItem(m_ActivityInfo.optionalCostLOT, m_ActivityInfo.optionalCostCount, eInventoryType::ALL);
|
return CheckCost(player) && inventoryComponent && inventoryComponent->RemoveItem(m_ActivityInfo.optionalCostLOT, m_ActivityInfo.optionalCostCount, eInventoryType::ALL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActivityComponent::PlayerReady(Entity* player, bool bReady) {
|
void ActivityComponent::PlayerReady(Entity* player, bool bReady) {
|
||||||
|
|||||||
@@ -33,7 +33,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
RacingControlComponent::RacingControlComponent(Entity* parent, const int32_t componentID)
|
RacingControlComponent::RacingControlComponent(Entity* parent, const int32_t componentID)
|
||||||
: Component(parent, componentID) {
|
: ActivityComponent(parent, componentID) {
|
||||||
m_PathName = u"MainPath";
|
m_PathName = u"MainPath";
|
||||||
m_NumberOfLaps = 3;
|
m_NumberOfLaps = 3;
|
||||||
m_RemainingLaps = m_NumberOfLaps;
|
m_RemainingLaps = m_NumberOfLaps;
|
||||||
@@ -70,7 +70,7 @@ void RacingControlComponent::OnPlayerLoaded(Entity* player) {
|
|||||||
auto* vehicle = inventoryComponent->FindItemByLot(8092);
|
auto* vehicle = inventoryComponent->FindItemByLot(8092);
|
||||||
|
|
||||||
// If the race has already started, send the player back to the main world.
|
// If the race has already started, send the player back to the main world.
|
||||||
if (m_Loaded || !vehicle) {
|
if (m_Loaded || !vehicle || !TakeCost(player)) {
|
||||||
auto* characterComponent = player->GetComponent<CharacterComponent>();
|
auto* characterComponent = player->GetComponent<CharacterComponent>();
|
||||||
if (characterComponent) characterComponent->SendToZone(m_MainWorld);
|
if (characterComponent) characterComponent->SendToZone(m_MainWorld);
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
#include "BitStream.h"
|
#include "BitStream.h"
|
||||||
#include "Entity.h"
|
#include "Entity.h"
|
||||||
#include "Component.h"
|
#include "ActivityComponent.h"
|
||||||
#include "eReplicaComponentType.h"
|
#include "eReplicaComponentType.h"
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
|
|
||||||
@@ -104,7 +104,7 @@ struct RacingPlayerInfo {
|
|||||||
/**
|
/**
|
||||||
* Component that's attached to a manager entity in each race zone that loads player vehicles, keep scores, etc.
|
* Component that's attached to a manager entity in each race zone that loads player vehicles, keep scores, etc.
|
||||||
*/
|
*/
|
||||||
class RacingControlComponent final : public Component {
|
class RacingControlComponent final : public ActivityComponent {
|
||||||
public:
|
public:
|
||||||
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::RACING_CONTROL;
|
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::RACING_CONTROL;
|
||||||
|
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
#include "Logger.h"
|
#include "Logger.h"
|
||||||
#include "Loot.h"
|
#include "Loot.h"
|
||||||
#include "ShootingGalleryComponent.h"
|
#include "ShootingGalleryComponent.h"
|
||||||
|
#include "RacingControlComponent.h"
|
||||||
|
|
||||||
bool ActivityManager::IsPlayerInActivity(Entity* self, LWOOBJID playerID) {
|
bool ActivityManager::IsPlayerInActivity(Entity* self, LWOOBJID playerID) {
|
||||||
const auto* sac = self->GetComponent<ScriptedActivityComponent>();
|
const auto* sac = self->GetComponent<ScriptedActivityComponent>();
|
||||||
@@ -99,6 +100,8 @@ bool ActivityManager::TakeActivityCost(const Entity* self, const LWOOBJID player
|
|||||||
activityComponent = self->GetComponent<ShootingGalleryComponent>();
|
activityComponent = self->GetComponent<ShootingGalleryComponent>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!activityComponent) return false;
|
||||||
|
|
||||||
auto* player = Game::entityManager->GetEntity(playerID);
|
auto* player = Game::entityManager->GetEntity(playerID);
|
||||||
if (player == nullptr)
|
if (player == nullptr)
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
Reference in New Issue
Block a user