-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Fixed server starting with errored entities (1.7.1.0) #2165
base: 1.7.0.0
Are you sure you want to change the base?
Conversation
Streamlined sorting into a single enumeration pass
Those entities we are throwing away might be important and we can't just delete them like it's nothing. |
That's actually a very good point, and I was too preoccupied with making sure the entire save doesn't get discarded and thinking about it as a stopgap fix while waiting for the Living Large version that I didn't consider that it could be say... a player, a cyclops, or an immediately critical vehicle in deep water getting deleted, and implementing a location fix for it would be far better. Want me to look into making a fix for that immediately? I'm not sure how fast I'd get it done around work and other IRL obligations, but it shouldn't be too difficult, especially if it's just correcting the data during the loading process. (I'm going to at least look into it a bit right now) As a side note I'm not exactly sure what causes the NaN location entities to come into existence, I'd assume it's something like a failed spawn or something, but I'm far from certain on that. In the case of the server I'm part of it was a random Stalker. |
…d on other entities in parent, which is generally a cell.
I realized that the parent data is usually still present, and location can be approximated from that. Also flagging previous comments as resolved as the index based access has to be where it is now with current design, and a foreach statement wouldn't work as the for loop now backsteps one after fixing things. EDIT: I also thought wrong, it could still be put in the try/catch, just not changed to a foreach. If people would prefer the index accessor to be put inside the try/catch feel free to say something. |
Do we want to add a choice for the user in saying a non debug mode? I am just thinking that the normal users will at this point go to the help channel and start saying it doesn't work, I think we should come up with a default and then let advanced users fix it themselves, what do you think? |
Hmm, maybe? |
With that in mind, I'd just have a message at the beginning saying |
You sure? The NaN error is very rare, and when it occurs the new warning tells you what kind of entity it happened on. If you ever get the error on more than one or two entities max there's probably something far more significant wrong with your save. Also for the default, I currently have it put it back in the parent it was already part of, the parent most likely being a cell or other type of container (I can't think of anything else it even could be, the one I've seen being an entity with no type that contains several fish entities). |
Generally it'd happen to players which were launched into space because of some Subnautica wrong collision, but it can probably happen to any entity, for which the best fix would simply to put them back into the world. When you say it's pretty rare of an error, what do you mean ? What other entity errors are you talking about ? If you spawn an entity in it's original cell while messing up the positions, there are good chances that they'll just end up being under the ground. I even think no computation is better than any computation around other entities' positions |
Sorry that this took so long, work got in my way for several days straight. Anyways, first of all getting launched into space should never cause the NaN error. Positional data is handled as a float, meaning that no matter how far they go it should only result in floating point rounding errors. The only circumstances I can think of that would ever result in a NaN are dividing the values by zero, or it never getting initialized or serialized properly in the first place. As for saying it's a pretty rare error, this is specifically the error mentioned in #2097 and also happened to the server I'm part of, but does not seem to occur to many people and not very often. When it does occur though it's a pretty severe bug. Here is the relevant world data for my server: MP.zip As for the location setting back to an estimated position based on surrounding entities in parent, I created a test set of 100 theoretical repositions and manually visited each of them precisely in-game, which I recorded in test footage here: https://youtu.be/D-Jkua4cfG8?si=vSqnkAClfveR-md4 The biggest thing that concerns me about putting things back in the center of the world is... well, let's just say I have this image of this bug happening to a Leviathan, and it getting dropped right on top of the escape pod. Alternatively, this somehow happening to a vehicle during world save, loading back in, and finding out your vehicle is now all the way back up in the shallows while you're somewhere like the lost river. Lastly the slight chance of an object getting permanently stuck up in the air that isn't supposed to be seems almost as bad as ending up under the ground to me, although creatures would be more likely to find their way back to water than they would be to swim the correct direction to exit the ground, even if they're right next to it. (Although let's be honest, creatures clipping into surfaces is already something that happens quite a bit in Subnautica) Comparatively, centering it in the parent does have a fairly high chance of ending up in the ground, but if there are other entities in the parent they'll be physics bound as well, meaning if they all cluster to a specific side or avoid a specific part of the area, then there's probably an obstacle there, and centering it on sibling positions will nudge it the correct direction to not end up in the ground most of the time. Also if it were something like a plant (which I don't think this bug really happens to but it's good to be sure) it'll generally put it back into the plant cluster around the right spot. If the above tests still produce too many bad results in your opinion, I will try to implement an emulated OutOfBoundsWarp, I'm not the one in charge here after all and will defer to your judgement on the subject, I just genuinely think putting them back roughly where they belong is the better option. |
The issue of the NaN numbers in positions is an issue with Nitrox's calculations regarding object transformations... its a bug that I myself struggle to wrap my brain around due to lack of enough math education regarding that particular topic. |
Do you know offhand where in the code the bugged transformation calculations take place? I'll also take a look at that. |
This is the class that handles transformations in Nitrox, it could be data that is fed to it improperly or it could originate here. |
spawning in Nitrox where the data originates from is here fyi |
Perhaps targeting the main branch of Nitrox would be better for this particular issue? The reason is that Nitrox is getting ready to release a new version soon(TM), and the team doesn't plan on releasing any more patches for the 1.7 version. Releasing another patch on 1.7 for one fix could give the impression that progress has stalled. Plus, the team wants to prioritize getting Nitrox in top shape for its upcoming release, while also sinking any final regressions that surfaced after the Subnautica Living Large update. |
Fair enough, I just had no idea exactly how long it'd be until the 2.0 version of Nitrox came out, and the bug seemed severe enough to warrant a hotfix. (Being completely unable to load the server's world is… notable to say the least) |
@uGuardian Indeed we're not going to release another 1.7 version. Though help is always good to take and that would be a pleasure if you're willing to get this sorted out for 1.8. Eve, though we've reworked a lot of thing for 1.8, issue is still the same. The current fix you gave looks like a help tool rather than a proper fix. What comes to my mind is to prevent such entities to be serialized into the save file with weird values like NaN or Infinite, before anything else. Rather than dealing with the issue when you're loading the server |
Yup, that'd be preferable, although it's always good to have error checking in the loader. |
Fixed server starting with errored entities, most notably the issue where occasionally an entity will have a NaN location, causing the entire save file to be unloadable.
Refactored sorting into a single enumeration pass, in part to allow easy insertion of the try-catch.
I've noticed several people having this issue occasionally on the current version, and this is intended to be a small patch to allow the current public version to not occasionally end up losing entire saves due to "corrupted" data when the user has no idea of how to find or fix it.