Skip to content

Commit 49ff1d2

Browse files
red-001nerzhul
authored andcommittedJan 21, 2018
[CSM] Remove on_connect callback (#6941)
Fixes #6939
1 parent 5dab742 commit 49ff1d2

File tree

6 files changed

+14
-46
lines changed

6 files changed

+14
-46
lines changed
 

Diff for: ‎builtin/client/register.lua

-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ end
6060

6161
core.registered_globalsteps, core.register_globalstep = make_registration()
6262
core.registered_on_shutdown, core.register_on_shutdown = make_registration()
63-
core.registered_on_connect, core.register_on_connect = make_registration()
6463
core.registered_on_receiving_chat_message, core.register_on_receiving_chat_message = make_registration()
6564
core.registered_on_sending_chat_message, core.register_on_sending_chat_message = make_registration()
6665
core.registered_on_death, core.register_on_death = make_registration()

Diff for: ‎clientmods/preview/init.lua

+13-15
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,19 @@ dofile("preview:example.lua")
77
core.register_on_shutdown(function()
88
print("[PREVIEW] shutdown client")
99
end)
10-
local id = 0
11-
core.register_on_connect(function()
12-
print("[PREVIEW] Player connection completed")
13-
local server_info = core.get_server_info()
14-
print("Server version: " .. server_info.protocol_version)
15-
print("Server ip: " .. server_info.ip)
16-
print("Server address: " .. server_info.address)
17-
print("Server port: " .. server_info.port)
18-
mod_channel = core.mod_channel_join("experimental_preview")
19-
20-
core.after(4, function()
21-
if mod_channel:is_writeable() then
22-
mod_channel:send_all("preview talk to experimental")
23-
end
24-
end)
10+
local id = nil
11+
12+
local server_info = core.get_server_info()
13+
print("Server version: " .. server_info.protocol_version)
14+
print("Server ip: " .. server_info.ip)
15+
print("Server address: " .. server_info.address)
16+
print("Server port: " .. server_info.port)
17+
mod_channel = core.mod_channel_join("experimental_preview")
18+
19+
core.after(4, function()
20+
if mod_channel:is_writeable() then
21+
mod_channel:send_all("preview talk to experimental")
22+
end
2523
end)
2624

2725
core.after(1, function()

Diff for: ‎doc/client_lua_api.txt

+1-16
Original file line numberDiff line numberDiff line change
@@ -651,8 +651,6 @@ Call these functions only at load time!
651651
* **Warning**: If the client terminates abnormally (i.e. crashes), the registered
652652
callbacks **will likely not be run**. Data should be saved at
653653
semi-frequent intervals as well as on server shutdown.
654-
* `minetest.register_on_connect(func())`
655-
* Called at the end of client connection (when player is loaded onto map)
656654
* `minetest.register_on_receiving_chat_message(func(message))`
657655
* Called always when a client receive a message
658656
* 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!
784782
* Client joins channel `channel_name`, and creates it, if necessary. You
785783
should listen from incoming messages with `minetest.register_on_modchannel_message`
786784
call to receive incoming messages. Warning, this function is asynchronous.
787-
* You should use a minetest.register_on_connect(function() ... end) to perform
788-
a successful channel join on client startup.
789785

790786
### Particles
791787
* `minetest.add_particle(particle definition)`
@@ -935,18 +931,7 @@ Please do not try to access the reference until the camera is initialized, other
935931
* Returns aspect ratio of screen
936932

937933
### LocalPlayer
938-
An interface to retrieve information about the player. The player is
939-
not accessible until the client is fully done loading and therefore
940-
not at module init time.
941-
942-
To get the localplayer handle correctly, use `on_connect()` as follows:
943-
944-
```lua
945-
local localplayer
946-
minetest.register_on_connect(function()
947-
localplayer = minetest.localplayer
948-
end)
949-
```
934+
An interface to retrieve information about the player.
950935

951936
Methods:
952937

Diff for: ‎src/client.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -1698,7 +1698,6 @@ void Client::afterContentReceived()
16981698

16991699
if (g_settings->getBool("enable_client_modding")) {
17001700
m_script->on_client_ready(m_env.getLocalPlayer());
1701-
m_script->on_connect();
17021701
}
17031702

17041703
text = wgettext("Done!");

Diff for: ‎src/script/cpp_api/s_client.cpp

-11
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,6 @@ void ScriptApiClient::on_shutdown()
3636
runCallbacks(0, RUN_CALLBACKS_MODE_FIRST);
3737
}
3838

39-
void ScriptApiClient::on_connect()
40-
{
41-
SCRIPTAPI_PRECHECKHEADER
42-
43-
// get registered connect hooks
44-
lua_getglobal(L, "core");
45-
lua_getfield(L, -1, "registered_on_connect");
46-
// Call callback
47-
runCallbacks(0, RUN_CALLBACKS_MODE_FIRST);
48-
}
49-
5039
bool ScriptApiClient::on_sending_message(const std::string &message)
5140
{
5241
SCRIPTAPI_PRECHECKHEADER

Diff for: ‎src/script/cpp_api/s_client.h

-2
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,6 @@ class ScriptApiClient : virtual public ScriptApiBase
4040
// Calls on_shutdown handlers
4141
void on_shutdown();
4242

43-
void on_connect();
44-
4543
// Chat message handlers
4644
bool on_sending_message(const std::string &message);
4745
bool on_receiving_message(const std::string &message);

0 commit comments

Comments
 (0)
Please sign in to comment.