-
Notifications
You must be signed in to change notification settings - Fork 23
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 dummy implementations of all current API calls to fake player #98
Conversation
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.
looks ok, but probably should be tested with other mods to make sure nothing..... implodes. could try a pr to dreambuilder with this branch so that its ci runs.......
relating to abstracting a mod out for this, rather leave it here so its easier/faster to fix in the context of the engine already has some issues about handling fake players, so would be best off handled there |
Funny, I was just working on that the other day, trying to finish one of the many projects I have :P It's not just Regarding this PR, there is something else to consider: adding all these extra functions significantly increases the time it takes to create a new fake player (which is already quite slow). It would be better to use a metatable, so the functions are only ever created once, which is the method I'm using. |
Another alternative would be to cache them and evict periodically, they don't have internal state or anything 🤔 |
Should you also override core sound functions and add check for fake player or are those already fine with fake player? I think there there was some other similar core functions that can't tolerate fake player instances. Then of course there's few core functions that could be overridden to improve compatibility but in most cases probably better to change mod code instead, for example things like getting player by name and but like said I think in most cases probably better to actually ask others to keep their player instance instead of losing it and getting it again by name. |
so this has been approved, but there's suggestions about possible improvements. should i put all the stateless functions in a metatable, or leave this PR as is in anticipation of Ogel releasing a better solution? should i check that nothing crashes if the fake player is passed as an argument to various API calls? the only things i can see that take a player argument that i could override are |
if you assume |
StackOverflow is right but you have to remember that you still need to commit update submodule hash. They're not talking about automatically pointing to submodule remote branch latest commit but about about automatically updating to remote latest commit, these are different things as former would not need additional actions from you but latter does need commit to update actual submodule commit pointer. In other words it does not follow but instead lets you know what to follow. |
Preferably the first option, because I don't know when I'll have time to finish my solution, and it's better to have some improvement over nothing. |
keep in mind, during testing, that fakeplayer may be used while corresponding real player isn't online. |
whoops, did this a while back but forgot to commit/push it. |
IMO: this could be merged and enhanced (or moved out to a separate mod) later on |
this is an alternate to the proposal in #18.
the incompleteness of the fake player's API causes crashes in unsuspecting mods, making it a huge headache for large servers with large numbers of mods. most recently for the your-land server, this was due to ts_furniture trying to call
get_player_velocity()
. the "expected" solution is to add a check forplayer.is_fake_player
, but i find this to be a terrible solution, as this isn't part of the published minetest API (though luanti-org/luanti#11477). mods that have no dependency or awareness of pipeworks shouldn't be required to conform to the non-standard assumptions it imposes. it's also difficult to get all mods to "fix" their code that way, because a lot are abandoned, and some (e.g. petz) won't add such a check.so, i've created dummy functions for all the API calls currently in ObjectRef. i've added no extra state to the fake player - trying to modify various things is usually just a no-op. the results may not always be what the mod expects but at least the crashes will go away.
one downside of this is that the fake player API will need to be updated whenever the real player API changes.
i've got a snippet that i used to generate the list of API calls that weren't yet implemented, possibly that should be added to help w/ future updates, though i'm at a loss for the best place to put it.
i'm aware that digtron has a similar problem, though i'm less concerned about it. but perhaps instead i should create a fake player mod that pipeworks and digtron could both rely on?