]> git.lizzy.rs Git - dragonfireclient.git/commitdiff
[CSM] Remove `on_connect` callback (#6941)
authorred-001 <red-001@outlook.ie>
Sun, 21 Jan 2018 17:27:27 +0000 (17:27 +0000)
committerLoïc Blot <nerzhul@users.noreply.github.com>
Sun, 21 Jan 2018 17:27:27 +0000 (18:27 +0100)
Fixes #6939

builtin/client/register.lua
clientmods/preview/init.lua
doc/client_lua_api.txt
src/client.cpp
src/script/cpp_api/s_client.cpp
src/script/cpp_api/s_client.h

index 2da37ad5fa5e284b1c8f307aad120024c451b072..95565523636bad5b5176508edecfed1a2e7f69b9 100644 (file)
@@ -60,7 +60,6 @@ end
 
 core.registered_globalsteps, core.register_globalstep = make_registration()
 core.registered_on_shutdown, core.register_on_shutdown = make_registration()
-core.registered_on_connect, core.register_on_connect = make_registration()
 core.registered_on_receiving_chat_message, core.register_on_receiving_chat_message = make_registration()
 core.registered_on_sending_chat_message, core.register_on_sending_chat_message = make_registration()
 core.registered_on_death, core.register_on_death = make_registration()
index a384fd6bf6a9047daf74f279efb1918ce4a104a3..223577876bea404022f33346c502c74724a7715f 100644 (file)
@@ -7,21 +7,19 @@ dofile("preview:example.lua")
 core.register_on_shutdown(function()
        print("[PREVIEW] shutdown client")
 end)
-local id = 0
-core.register_on_connect(function()
-       print("[PREVIEW] Player connection completed")
-       local server_info = core.get_server_info()
-       print("Server version: " .. server_info.protocol_version)
-       print("Server ip: " .. server_info.ip)
-       print("Server address: " .. server_info.address)
-       print("Server port: " .. server_info.port)
-       mod_channel = core.mod_channel_join("experimental_preview")
-
-       core.after(4, function()
-               if mod_channel:is_writeable() then
-                       mod_channel:send_all("preview talk to experimental")
-               end
-       end)
+local id = nil
+
+local server_info = core.get_server_info()
+print("Server version: " .. server_info.protocol_version)
+print("Server ip: " .. server_info.ip)
+print("Server address: " .. server_info.address)
+print("Server port: " .. server_info.port)
+mod_channel = core.mod_channel_join("experimental_preview")
+
+core.after(4, function()
+       if mod_channel:is_writeable() then
+               mod_channel:send_all("preview talk to experimental")
+       end
 end)
 
 core.after(1, function()
index 566b862557d43231a21e812268ed2c6ae50257a2..31142cae2bb6f9b17e6adfb98f1a5ff84dcb5da5 100644 (file)
@@ -651,8 +651,6 @@ Call these functions only at load time!
     * **Warning**: If the client terminates abnormally (i.e. crashes), the registered
       callbacks **will likely not be run**. Data should be saved at
       semi-frequent intervals as well as on server shutdown.
-* `minetest.register_on_connect(func())`
-    * Called at the end of client connection (when player is loaded onto map)
 * `minetest.register_on_receiving_chat_message(func(message))`
     * Called always when a client receive a message
     * Return `true` to mark the message as handled, which means that it will not be shown to chat
@@ -784,8 +782,6 @@ Call these functions only at load time!
     * Client joins channel `channel_name`, and creates it, if necessary. You
       should listen from incoming messages with `minetest.register_on_modchannel_message`
       call to receive incoming messages. Warning, this function is asynchronous.
-    * You should use a minetest.register_on_connect(function() ... end) to perform
-      a successful channel join on client startup.
 
 ### Particles
 * `minetest.add_particle(particle definition)`
@@ -935,18 +931,7 @@ Please do not try to access the reference until the camera is initialized, other
     * Returns aspect ratio of screen
 
 ### LocalPlayer
-An interface to retrieve information about the player. The player is
-not accessible until the client is fully done loading and therefore
-not at module init time.
-
-To get the localplayer handle correctly, use `on_connect()` as follows:
-
-```lua
-local localplayer
-minetest.register_on_connect(function()
-        localplayer = minetest.localplayer
-end)
-```
+An interface to retrieve information about the player.
 
 Methods:
 
index 90f1c4e013ff92207f5906fe78ec756124dbee21..6416f771542528689f6c4bf5dc348a2d68983766 100644 (file)
@@ -1698,7 +1698,6 @@ void Client::afterContentReceived()
 
        if (g_settings->getBool("enable_client_modding")) {
                m_script->on_client_ready(m_env.getLocalPlayer());
-               m_script->on_connect();
        }
 
        text = wgettext("Done!");
index c6f7a8e191ca7c8859ad0f45c5c6255fb4ea97d8..457dabfa7ccdc5778d77bf011092db004710f185 100644 (file)
@@ -36,17 +36,6 @@ void ScriptApiClient::on_shutdown()
        runCallbacks(0, RUN_CALLBACKS_MODE_FIRST);
 }
 
-void ScriptApiClient::on_connect()
-{
-       SCRIPTAPI_PRECHECKHEADER
-
-       // get registered connect hooks
-       lua_getglobal(L, "core");
-       lua_getfield(L, -1, "registered_on_connect");
-       // Call callback
-       runCallbacks(0, RUN_CALLBACKS_MODE_FIRST);
-}
-
 bool ScriptApiClient::on_sending_message(const std::string &message)
 {
        SCRIPTAPI_PRECHECKHEADER
index 717fbb4cc5bc93a926eb1283cb0e6322a066dc38..402b44e337d8355fb9ddec907f1b59f96cdbb46f 100644 (file)
@@ -40,8 +40,6 @@ class ScriptApiClient : virtual public ScriptApiBase
        // Calls on_shutdown handlers
        void on_shutdown();
 
-       void on_connect();
-
        // Chat message handlers
        bool on_sending_message(const std::string &message);
        bool on_receiving_message(const std::string &message);