-
-
Notifications
You must be signed in to change notification settings - Fork 376
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
onShipHit event can cause crashes #887
Comments
I know this one well. An example scenario where this occurs is when two ships are firing. The first one is destroyed, but some of his lasers or missiles are still floating and hit the other one. onShipHit then fires with a null attacker. The way I want to fix this in the long term is to keep dead ships hanging around in some kind of "dead" state until there's nothing else referencing them. Once all the lasers, missiles and whatever else that have the ship listed as their owner are gone, the ship can be cleaned up. This is easier to do now we have the refcounting smart pointer but is still some effort. |
In these instances, no attacking ships were destroyed. The test cases (for "assist" kills) involved undefended, unarmed, static targets, attacked by specially spawned adders with pulse lasers. On one occasion, the only attacker was me, and I certainly hadn't been damaged or destroyed. |
…e testing to see if it's the player. onShipHit remains unconnected pending pioneerspacesim#887
I'm currently tinkering with getting crime into Lua, at least some parts of it, and I think this bug needs to be resolved if it isn't already. Once this is resolved, StatsTracking can track assisted kills as well. Anyone feeling up for the challenge? |
GrievanceThis bug continues to halt code using Lua, since anything referencing an attacker upon a ship being destroyed will trigger this bug. How to reproduce
Error messageYesterday @johnbartholomew asked for some error messages/bt, since it's in lua there's not much of backtrace, but here are two different error messages:
or:
|
if attacker and attacker:exists() and attacker:IsPlayer() then -- NOT Crash! / NO BUG ;) |
The problem is not onShipHit event. |
So the fix is that
and it will all work fine then? |
right |
I'm not convinved. Feels like a hacky workaround of the actual problem described by @robn. |
I agree this is a workaround, but since it is likely to take quite a lot of effort/time to implement a better fix, I think we should do this anyway. There may be other scripts that need this fix too, but I guess we can wait for people to report errors. |
I don't really care :) it's been open for more than 2 years without a fix, and there are always problems associated with keeping around "dead" objects so you can clean them up later - like references that they hold to other things and the references that they then hold to other things. This just stops the crash happening which is sometimes the best solution. It's simple, the bug goes away, and it doesn't introduce large amounts of complexity with the unknown future bugs that come with it. and @johnbartholomew beat me to the post! :P |
Code like this (first line is line 23):
can cause errors like this:
I've seen this happen when I have fired a missile at a ship, and when an AI ship has been shooting with a laser at another AI ship.
The text was updated successfully, but these errors were encountered: