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
Conversation
…entVehicleExplode" if there will be no "explosion"
@@ -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)) |
There was a problem hiding this comment.
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?
|
||
// Call onClientVehicleExplode | ||
// Bonus: This way "onClientVehicleExplode will only get called for serversided vehicles. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we expect clientsided vehicles to trigger onClientVehicleExplode
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would expect it !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is the current way, only wanted to comment that.
Currently onClientVehicleExplode will only get triggered when the server sends the explosion.
You can try it on the current build.
This PR doesn't add onClientVehicleExplode for clientside vehicles (also doesn't remove it, cause the event was never triggered for them).
This looks really good - well done! |
if (pInterface->nType == ENTITY_TYPE_VEHICLE) { | ||
CVehicle* pVehicle = pGameInterface->GetPools()->GetVehicle((DWORD*)pInterface)->pEntity; | ||
if (!pVehicle->GetWillExplode()) | ||
return false; | ||
} | ||
pExplosionCreator = pGameInterface->GetPools()->GetEntity((DWORD*)pInterface); | ||
} | ||
|
||
if (pExplodingEntityInterface) | ||
{ | ||
if (pExplodingEntityInterface->nType == ENTITY_TYPE_VEHICLE) | ||
{ | ||
CVehicle* pVehicle = pGameInterface->GetPools()->GetVehicle((DWORD*)pExplodingEntityInterface)->pEntity; | ||
if (!pVehicle->GetWillExplode()) | ||
return false; | ||
} | ||
pExplodingEntity = pGameInterface->GetPools()->GetEntity((DWORD*)pExplodingEntityInterface); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@saml1er please can you check that I've merged this correctly? the author previously had this which conflicted with your entity pool refactor
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's okay, but you don't need to get the entity again from pools class. GetPools()->GetVehicle()
can also return nullptr if the interface pointer is corrupt, so we have to check it.
CEntity* pExplodingEntity = pGameInterface->GetPools()->GetEntity((DWORD*)pExplodingEntityInterface);
if (pExplodingEntity && pExplodingEntityInterface->nType == ENTITY_TYPE_VEHICLE) {
CVehicle* pVehicle = reinterpret_cast<CVehicle*>(pExplodingEntity);
if (!pVehicle->GetWillExplode())
return false;
}
Not tested the master merge, but it compiles. Looking at the code, it seems that this PR only stops the blow event from being broadcasted twice, but the game still wants to broadcast it twice. But why does the game try to broadcast it twice? |
This is the default game behavior. It looks like a bug. It happens sometimes. I can reproduce it in single-player. |
…owVehicle_explode
Updated to latest master. Is this good for merge? |
I think we need to address this comment: #213 (comment) |
Is it a blocker? |
Thanks for the pull request. Unfortunately this has since been superseded by #1997. If you wish to implement a silent vehicle blowup, feel free to submit a new pull request with the new refactored version as base. |
Bugtracker:
https://bugs.mtasa.com/view.php?id=7817
Content of PR:
Previously:
Worked the whole night for it :/
Tested it, but it could be possible that I forgot to test a scenario.
Fixes #455