Make onPlayerWeaponFire cancellable (consistency with onWeaponFire)
Maintainer thường phản hồi trong vòng 3 ngày
Chưa có ai nhận issue này.
- #5115 của @QueryOfficial — đã đóng, không merge
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Tính năng
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Ít trao đổi
- Lĩnh vực
- backend, distributed-systems, networking
Hướng nghiên cứu
Start in Server/mods/deathmatch/logic/CGame.cpp at CGame::Packet_Bulletsync and compare the onWeaponFire path with onPlayerWeaponFire. Read CSimPlayerManager::HandleBulletSync and CNetAPI::ReadBulletsync to understand the sim-sync relay and client application. Done means cancellation suppresses the relay for every observer while preserving the fast path when no handler is attached, with relevant sync and event tests passing.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Is your feature request related to a problem? Please describe.
cancelEvent() inside onPlayerWeaponFire does nothing. A script can observe a bullet-sync shot server-side, but cannot stop it. Two things are in the way.
1. The return value is discarded. In CGame::Packet_Bulletsync:
player->CallEvent("onPlayerWeaponFire", args);
RelayNearbyPacket(packet);
CElement::CallEvent already returns !WasEventCancelled(). The custom-weapon path 26 lines below uses it (if (!weapon->CallEvent("onWeaponFire", args)) return;), so onWeaponFire is cancellable and onPlayerWeaponFire is not.
2. Sim sync relays the packet before Lua runs. CSimPlayerManager::HandleBulletSync broadcasts on the sync thread, and threadnet defaults to on. So just honouring the return value would cancel the shot only for observers sim sync did not cover — a zone-dependent partial cancel, which would be worse than today.
This is not cosmetic: receiving clients apply the shot and its damage from the relayed packet (CNetAPI::ReadBulletsync). Scripts validating a shot server-side today have to let it through and undo the damage afterwards, which players can see. onClientPlayerWeaponFire is not a substitute, since a server cannot rely on a client-side cancel.
Describe the solution you'd like
Make cancelEvent() in onPlayerWeaponFire suppress the relay for every observer, matching onWeaponFire.
That means bullets must not take the sim-sync fast path while a cancel is still possible. Proposal, and the part I would like feedback on: keep the fast path as the default, and bypass it for bullet sync only while a Lua handler for onPlayerWeaponFire is attached. Servers not using the event keep today's latency; servers using it pay one main-thread hop. There is precedent for gating work on handler presence (CMapEventManager::HasEvents()), though it is per-element and would need extending.
I am happy to write the PR — raising this first because it changes sync behaviour and I would rather agree on the approach up front.
Describe alternatives you've considered
- Honour the return value only, leaving sim sync alone — smallest diff, but gives the partial cancel described above.
- Drop the sim-sync fast path for bullets entirely — consistent, but costs latency on every server.
- An explicit config/scripting toggle instead of inferring from handler presence — more predictable, more config surface.
Additional context
Verified on master (c3f1957a4007aefa8b2114028b298105a5e17934) with a local server and client build.
#852 asks for the same capability on the client-side event. I know #4989, #5115, #5116 and #4682 are open against this area; this request is about the scripting API contract rather than bullet-sync validation, and I am happy to rebase on top of them.
Security Policy
- I have read and understood the Security Policy and this issue is not about a cheat or security vulnerability.
- Ngôn ngữ chính
- C++
- Star
- 1.9k
- Fork
- 588
- Merge trung bình
- 4 ngày 9 phút
- Pull request đã merge (30 ngày)
- 11
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của multitheftauto/mtasa-blue
-
engineSetModelFlag, engineGetModelFlag, engineSetModelFlags and engineResetModelFlag return errorĐang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
multitheftauto/mtasa-blue#3186 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 3 ngày
-
bindKey shouldn't be able to bind function multiple timesCó thể đã có người làm @iManGaaX đã nhận 11 ngày trước. Đang mởbug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
multitheftauto/mtasa-blue#2629 · 1 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 3 ngày
-
Protocol Error 67Đang mởbug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
multitheftauto/mtasa-blue#5553 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
bug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
multitheftauto/mtasa-blue#5552 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
Crash every time disconnectingĐang mởbug
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 43/100
multitheftauto/mtasa-blue#5550 · 1 reaction ·
Maintainer thường phản hồi trong vòng 3 ngày
Tất cả issue của multitheftauto/mtasa-blue
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 69/100
-
area:qmc bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 69/100
Maintainer thường phản hồi trong vòng 3 ngày
-
bug good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
ASGC-Game-Jam/asgc-gamejam-2026#563 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
area/ysql kind/bug priority/medium status/awaiting-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
yugabyte/yugabyte-db#37523 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Let agents name their jobsĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100