Skip to content

Commit

Permalink
Always convert 4294967295 to 4294967296 when requesting level vertex …
Browse files Browse the repository at this point in the history
…ID from scripts.

#382, #392, #1529
  • Loading branch information
Xottab-DUTY committed Jan 2, 2025
1 parent 9049947 commit 34ef356
Showing 1 changed file with 9 additions and 28 deletions.
37 changes: 9 additions & 28 deletions src/xrGame/level_script.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -577,20 +577,6 @@ int g_get_general_goodwill_between(u16 from, u16 to)
return presonal_goodwill + community_to_obj_goodwill + community_to_community_goodwill;
}

u32 vertex_id(Fvector position)
{
return (ai().level_graph().vertex_id(position));
}

u64 vertex_id_awful(Fvector position)
{
// Original Clear Sky's LuaJIT or luabind converts
// 4294967295 (which is u32(-1)) to 4294967296
// for some reason :(
const u32 id = ai().level_graph().vertex_id(position);
return id == u32(-1) ? id + 1 : id; // reproduce Clear Sky behaviour
}

u32 render_get_dx_level() { return GEnv.Render->get_dx_level(); }
CUISequencer* g_tutorial = NULL;
CUISequencer* g_tutorial2 = NULL;
Expand Down Expand Up @@ -837,20 +823,15 @@ IC static void CLevel_Export(lua_State* luaState)
def("ray_pick", &ray_pick)
];

if (ClearSkyMode)
{
module(luaState, "level")
[
def("vertex_id", &vertex_id_awful)
];
}
else
{
module(luaState, "level")
[
def("vertex_id", &vertex_id)
];
}
module(luaState, "level")
[
def("vertex_id", +[](Fvector position) -> u64
{
// Original luabind converts 4294967295 (which is u32(-1)) to 4294967296
const u32 id = ai().level_graph().vertex_id(position);
return id == u32(-1) ? id + 1 : id; // reproduce original behaviour
})
];

module(luaState, "actor_stats")
[
Expand Down

0 comments on commit 34ef356

Please sign in to comment.