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

0007818: Fix "explode" for blowVehicle, add it for client #213

Closed
wants to merge 19 commits into from
Closed
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
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: 6 additions & 0 deletions Client/game_sa/CVehicleSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ void CVehicleSA::Init(void)

this->internalID = pGame->GetPools()->GetVehicleRef((DWORD*)this->GetVehicleInterface());

m_bExplode = true;
m_bIsDerailable = true;
m_ucAlpha = 255;
m_vecGravity = CVector(0.0f, 0.0f, -1.0f);
Expand Down Expand Up @@ -1660,6 +1661,11 @@ bool CVehicleSA::IsFadingOut(void)
return vehicle->m_nVehicleFlags.bFadeOut;
}

void CVehicleSA::SetWillExplode(bool bExplode)
{
m_bExplode = bExplode;
}

unsigned char CVehicleSA::GetNumberGettingIn(void)
{
return GetVehicleInterface()->m_nNumGettingIn;
Expand Down
4 changes: 4 additions & 0 deletions Client/game_sa/CVehicleSA.h
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,7 @@ class CVehicleSA : public virtual CVehicle, public virtual CPhysicalSA
unsigned char m_ucVariant;
unsigned char m_ucVariant2;
unsigned char m_ucVariantCount;
bool m_bExplode;
qaisjp marked this conversation as resolved.
Show resolved Hide resolved

public:
CVehicleSA();
Expand Down Expand Up @@ -648,6 +649,9 @@ class CVehicleSA : public virtual CVehicle, public virtual CPhysicalSA
void FadeOut(bool bFadeOut);
bool IsFadingOut();

void SetWillExplode(bool bExplode);
bool GetWillExplode(void) { return m_bExplode; };

void SetWinchType(eWinchType winchType);
void PickupEntityWithWinch(CEntity* pEntity);
void ReleasePickedUpEntityWithWinch();
Expand Down
4 changes: 3 additions & 1 deletion Client/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1514,12 +1514,14 @@ int CLuaVehicleDefs::FixVehicle(lua_State* luaVM)
int CLuaVehicleDefs::BlowVehicle(lua_State* luaVM)
{
CClientEntity* pEntity = NULL;
bool bExplode = true;
CScriptArgReader argStream(luaVM);
argStream.ReadUserData(pEntity);
argStream.ReadBool(bExplode);

if (!argStream.HasErrors())
{
if (CStaticFunctionDefinitions::BlowVehicle(*pEntity))
if (CStaticFunctionDefinitions::BlowVehicle(*pEntity, bExplode))
{
lua_pushboolean(luaVM, true);
return 1;
Expand Down
11 changes: 8 additions & 3 deletions Client/mods/deathmatch/logic/rpc/CVehicleRPCs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,19 @@ void CVehicleRPCs::BlowVehicle(CClientEntity* pSource, NetBitStreamInterface& bi
{
// Read out the vehicle id
unsigned char ucTimeContext;
if (bitStream.Read(ucTimeContext))
bool bExplode;
if (bitStream.Read(ucTimeContext) && bitStream.ReadBit(bExplode))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To confirm, this bit was already being sent from the server, right?

{
// Grab the vehicle
CClientVehicle* pVehicle = m_pVehicleManager->Get(pSource->GetID());
if (pVehicle)
{
// Blow it and change the time context
pVehicle->Blow(true);
// Send the event when there is no "real" explosion
if (!bExplode) {
CLuaArguments Arguments;
pVehicle->CallEvent("onClientVehicleExplode", Arguments, true);
}
CStaticFunctionDefinitions::BlowVehicle(*pVehicle, bExplode);
pVehicle->SetSyncTimeContext(ucTimeContext);
}
}
Expand Down
10 changes: 8 additions & 2 deletions Client/multiplayer_sa/CMultiplayerSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2641,7 +2641,10 @@ bool CallExplosionHandler(void)

case ENTITY_TYPE_VEHICLE:
{
pExplosionCreator = pGameInterface->GetPools()->GetVehicle((DWORD*)pInterface);
CVehicle* pVehicle = pGameInterface->GetPools()->GetVehicle((DWORD*)pInterface);
if (!pVehicle->GetWillExplode())
return false;
pExplosionCreator = pVehicle;
break;
}

Expand All @@ -2666,7 +2669,10 @@ bool CallExplosionHandler(void)

case ENTITY_TYPE_VEHICLE:
{
pExplodingEntity = dynamic_cast<CEntity*>(pGameInterface->GetPools()->GetVehicle((DWORD*)pExplodingEntityInterface));
CVehicle* pVehicle = pGameInterface->GetPools()->GetVehicle((DWORD*)pExplodingEntityInterface);
if (!pVehicle->GetWillExplode())
return false;
pExplodingEntity = dynamic_cast<CEntity*>(pVehicle);
break;
}

Expand Down
2 changes: 2 additions & 0 deletions Client/sdk/game/CVehicle.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,8 @@ class CVehicle : public virtual CPhysical

virtual void BlowUp(CEntity* pCreator, unsigned long ulUnknown) = 0;
virtual void BlowUpCutSceneNoExtras(unsigned long ulUnknown1, unsigned long ulUnknown2, unsigned long ulUnknown3, unsigned long ulUnknown4) = 0;
virtual void SetWillExplode(bool bExplode) = 0;
virtual bool GetWillExplode() = 0;

virtual CDamageManager* GetDamageManager() = 0;
virtual void FadeOut(bool bFadeOut) = 0;
Expand Down
5 changes: 4 additions & 1 deletion Server/mods/deathmatch/logic/CGame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2558,17 +2558,20 @@ void CGame::Packet_ExplosionSync(CExplosionSyncPacket& Packet)
if (pVehicle->GetIsBlown() == false)
{
pVehicle->SetIsBlown(true);
pVehicle->SetExplodeBroadcasted(true);

// Call the onVehicleExplode event
CLuaArguments Arguments;
pVehicle->CallEvent("onVehicleExplode", Arguments);
// Update our engine State
pVehicle->SetEngineOn(false);
}
else
else if (pVehicle->IsExplodeBroadcasted())
{
bBroadcast = false;
}
else
pVehicle->SetExplodeBroadcasted(true);
}
}
break;
Expand Down
9 changes: 8 additions & 1 deletion Server/mods/deathmatch/logic/CVehicle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ CVehicle::CVehicle(CVehicleManager* pVehicleManager, CElement* pParent, CXMLNode
m_bRespawnEnabled = false;
m_ulBlowRespawnInterval = 10000;
m_ulIdleRespawnInterval = 60000;
m_bExplodeBroadcasted = true;

m_bEngineOn = false;
for (unsigned int i = 0; i < 6; ++i)
Expand Down Expand Up @@ -699,6 +700,7 @@ void CVehicle::SpawnAt(const CVector& vecPosition, const CVector& vecRotation)
{
SetHealth(GetRespawnHealth());
SetIsBlown(false);
SetExplodeBroadcasted(true);
qaisjp marked this conversation as resolved.
Show resolved Hide resolved
StopIdleTimer();
ResetDoorsWheelsPanelsLights();
SetLandingGearDown(true);
Expand Down Expand Up @@ -865,6 +867,11 @@ bool CVehicle::IsBlowTimerFinished(void)
return GetIsBlown() && CTickCount::Now() > m_llBlowTime + CTickCount((long long)m_ulBlowRespawnInterval);
}

void CVehicle::SetExplodeBroadcasted(bool bExplodeBroadcasted)
{
m_bExplodeBroadcasted = bExplodeBroadcasted;
}

void CVehicle::StopIdleTimer(void)
{
m_llIdleTime = CTickCount(0LL);
Expand Down Expand Up @@ -945,4 +952,4 @@ void CVehicle::SetRespawnEnabled(bool bEnabled)

m_bRespawnEnabled = bEnabled;
}
}
}
3 changes: 3 additions & 0 deletions Server/mods/deathmatch/logic/CVehicle.h
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,8 @@ class CVehicle : public CElement
void SetIsBlown(bool bBlown);
bool GetIsBlown(void);
bool IsBlowTimerFinished(void);
void SetExplodeBroadcasted(bool bExplodeBroadcasted);
bool IsExplodeBroadcasted(void) { return m_bExplodeBroadcasted; };
void StopIdleTimer(void);
void RestartIdleTimer(void);
bool IsIdleTimerRunning(void);
Expand All @@ -364,6 +366,7 @@ class CVehicle : public CElement
float m_fLastSyncedHealthHealth;
CTickCount m_llBlowTime;
CTickCount m_llIdleTime;
bool m_bExplodeBroadcasted;

unsigned char m_ucMaxPassengersOverride;

Expand Down