Skip to content

Commit

Permalink
[CSM] Remove on_connect callback (#6941)
Browse files Browse the repository at this point in the history
Fixes #6939
  • Loading branch information
red-001 authored and nerzhul committed Jan 21, 2018
1 parent 5dab742 commit 49ff1d2
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 46 deletions.
1 change: 0 additions & 1 deletion builtin/client/register.lua
Expand Up @@ -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()
Expand Down
28 changes: 13 additions & 15 deletions clientmods/preview/init.lua
Expand Up @@ -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()
Expand Down
17 changes: 1 addition & 16 deletions doc/client_lua_api.txt
Expand Up @@ -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
Expand Down Expand Up @@ -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)`
Expand Down Expand Up @@ -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:

Expand Down
1 change: 0 additions & 1 deletion src/client.cpp
Expand Up @@ -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!");
Expand Down
11 changes: 0 additions & 11 deletions src/script/cpp_api/s_client.cpp
Expand Up @@ -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
Expand Down
2 changes: 0 additions & 2 deletions src/script/cpp_api/s_client.h
Expand Up @@ -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);
Expand Down

0 comments on commit 49ff1d2

Please sign in to comment.