-
-
Notifications
You must be signed in to change notification settings - Fork 438
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
Add onExplosion event #3130
Add onExplosion event #3130
Conversation
for (auto iter = m_pPlayerManager->IterBegin(); iter != m_pPlayerManager->IterEnd(); ++iter) | ||
{ | ||
CPlayer* player = *iter; | ||
|
||
CVector cameraPosition; | ||
player->GetCamera()->GetPosition(cameraPosition); | ||
|
||
// Is this players camera close enough to send? | ||
if (IsPointNearPoint3D(explosionPosition, cameraPosition, MAX_EXPLOSION_SYNC_DISTANCE)) | ||
{ | ||
sendList.push_back(player); | ||
} | ||
} |
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 suggest extract method here
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.
Is that logic reused somewhere?
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 improve readability and self-documenting.
Wouldn't this cause a desync for the player causing the explosion if cancelled (since it will have already happened on the source client)? |
The client waits for the server packet to actually create the explosion. |
2c33c27
to
f6f63d0
Compare
Well, this was too quick, I wanted to add the event to createExplosion function on serverside. I forgot to mention this. |
Also, the origin element was not done right: it uses the closest player to an explosion, which is not the expected value in this event. |
This pull request adds the
onExplosion
event to the server-side and it can be cancelled. The event callback receives the absolute coordinates of the explosion, the explosion type, and the explosion origin (like a vehicle), if there is one.I haven't tested this event in a two-or-more player scenario yet, but it worked locally for me.