WiiUPluginLoader
WiiUPluginLoader copied to clipboard
Override socket_lib_init/finish
Hi. 🙂
My brother was using Minecraft: Wii U Edition to build a 3D model for a school project, and to show evidence of his actions, I tried to use the streaming plugin to record the project, but noticed that several seconds after starting Minecraft, the streaming plugin would stop sending data.
We're using an outdated version of Minecraft, and so when it is loaded, it tries to connect to Nintendo Network, and fails because it is outdated. I found that this results in socket_lib_finish()
being called, which makes sense for Minecraft, but the side effect is that this nukes the sockets for WUPS' logger and the streaming plugin. Nothing crashes, but this results in the streaming plugin and logging not working until I return to HBL and start WUPS again.
This PR prevents that from occurring by overriding socket_lib_init()
and socket_lib_finish()
such that both the running program and loaded plugins cannot de/reinitialize the socket library. socket_lib_init()
is called once when the WUPS loader starts. The sockets are initialised, and then cannot be shut down again until wups_using_sockets
is set to true
which only occurs once the program has started exiting.
This ensures that the sockets are kept alive until WUPS no longer needs them, allowing plugins such as the streaming plugin to continue sending information over the network. It also doesn't interfere with Minecraft's ability to attempt to connect to Nintendo Network. (it still spits out the error about being outdated, which means that Minecraft was in fact successfully communicating with Nintendo Network)