Skip to content

Commit 772944d

Browse files
red-001nerzhul
authored andcommittedMay 20, 2017
Fix CSM crash (#5779)
Caused by dc5bc6c and them made worse by 5ebf8f9
1 parent 7e18506 commit 772944d

File tree

4 files changed

+13
-7
lines changed

4 files changed

+13
-7
lines changed
 

Diff for: ‎doc/client_lua_api.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ For helper functions see "Vector helpers".
202202
### pointed_thing
203203
* `{type="nothing"}`
204204
* `{type="node", under=pos, above=pos}`
205-
* `{type="object", ref=ObjectRef}`
205+
* `{type="object", id=ObjectID}`
206206

207207
Flag Specifier Format
208208
---------------------

Diff for: ‎src/script/common/c_content.cpp

+9-3
Original file line numberDiff line numberDiff line change
@@ -1441,7 +1441,7 @@ void read_json_value(lua_State *L, Json::Value &root, int index, u8 recursion)
14411441
lua_pop(L, 1); // Pop value
14421442
}
14431443

1444-
void push_pointed_thing(lua_State *L, const PointedThing &pointed)
1444+
void push_pointed_thing(lua_State *L, const PointedThing &pointed, bool csm)
14451445
{
14461446
lua_newtable(L);
14471447
if (pointed.type == POINTEDTHING_NODE) {
@@ -1454,8 +1454,14 @@ void push_pointed_thing(lua_State *L, const PointedThing &pointed)
14541454
} else if (pointed.type == POINTEDTHING_OBJECT) {
14551455
lua_pushstring(L, "object");
14561456
lua_setfield(L, -2, "type");
1457-
push_objectRef(L, pointed.object_id);
1458-
lua_setfield(L, -2, "ref");
1457+
1458+
if (csm) {
1459+
lua_pushinteger(L, pointed.object_id);
1460+
lua_setfield(L, -2, "id");
1461+
} else {
1462+
push_objectRef(L, pointed.object_id);
1463+
lua_setfield(L, -2, "ref");
1464+
}
14591465
} else {
14601466
lua_pushstring(L, "nothing");
14611467
lua_setfield(L, -2, "type");

Diff for: ‎src/script/common/c_content.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ bool push_json_value (lua_State *L,
164164
void read_json_value (lua_State *L, Json::Value &root,
165165
int index, u8 recursion = 0);
166166

167-
void push_pointed_thing (lua_State *L, const PointedThing &pointed);
167+
void push_pointed_thing (lua_State *L, const PointedThing &pointed, bool csm = false);
168168

169169
void push_objectRef (lua_State *L, const u16 id);
170170

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ bool ScriptApiClient::on_placenode(const PointedThing &pointed, const ItemDefini
199199
lua_getfield(L, -1, "registered_on_placenode");
200200

201201
// Push data
202-
push_pointed_thing(L, pointed);
202+
push_pointed_thing(L, pointed, true);
203203
push_item_definition(L, item);
204204

205205
// Call functions
@@ -217,7 +217,7 @@ bool ScriptApiClient::on_item_use(const ItemStack &item, const PointedThing &poi
217217

218218
// Push data
219219
LuaItemStack::create(L, item);
220-
push_pointed_thing(L, pointed);
220+
push_pointed_thing(L, pointed, true);
221221

222222
// Call functions
223223
runCallbacks(2, RUN_CALLBACKS_MODE_OR);

0 commit comments

Comments
 (0)
Please sign in to comment.