mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2024-11-25 21:45:12 +00:00
Added getter for network area timer
This commit is contained in:
parent
1b99e22848
commit
3641d5404e
5 changed files with 41 additions and 22 deletions
|
@ -619,6 +619,7 @@
|
||||||
|
|
||||||
- smlua_misc_utils.h
|
- smlua_misc_utils.h
|
||||||
- [collision_find_surface_on_ray](#collision_find_surface_on_ray)
|
- [collision_find_surface_on_ray](#collision_find_surface_on_ray)
|
||||||
|
- [get_network_area_timer](#get_network_area_timer)
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
|
@ -11422,6 +11423,24 @@ The `reliable` field will ensure that the packet arrives, but should be used spa
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
|
## [get_network_area_timer](#get_network_area_timer)
|
||||||
|
|
||||||
|
### Lua Example
|
||||||
|
`local integerValue = get_network_area_timer()`
|
||||||
|
|
||||||
|
### Parameters
|
||||||
|
- None
|
||||||
|
|
||||||
|
### Returns
|
||||||
|
- `integer`
|
||||||
|
|
||||||
|
### C Prototype
|
||||||
|
`u32 get_network_area_timer(void);`
|
||||||
|
|
||||||
|
[:arrow_up_small:](#)
|
||||||
|
|
||||||
|
<br />
|
||||||
|
|
||||||
---
|
---
|
||||||
# functions from smlua_obj_utils.h
|
# functions from smlua_obj_utils.h
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,6 @@ ballActionValues = {
|
||||||
|
|
||||||
gBallTouchedLocal = false
|
gBallTouchedLocal = false
|
||||||
gCachedBalls = {}
|
gCachedBalls = {}
|
||||||
gInitializeBalls = {}
|
|
||||||
|
|
||||||
-----------
|
-----------
|
||||||
-- utils --
|
-- utils --
|
||||||
|
@ -128,8 +127,8 @@ function spawn_or_move_ball(x, y, z)
|
||||||
obj.oVelZ = 0
|
obj.oVelZ = 0
|
||||||
|
|
||||||
obj.oGlobalOwner = my_global_index()
|
obj.oGlobalOwner = my_global_index()
|
||||||
obj.oHitTime = obj.areaTimer
|
obj.oHitTime = get_network_area_timer()
|
||||||
obj.oNetworkTime = obj.areaTimer
|
obj.oNetworkTime = get_network_area_timer()
|
||||||
network_send_object(obj, false)
|
network_send_object(obj, false)
|
||||||
|
|
||||||
return obj
|
return obj
|
||||||
|
@ -615,13 +614,13 @@ function bhv_ball_loop(obj)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- send out object if we touched it
|
-- send out object if we touched it
|
||||||
local updateRateSend = (obj.oGlobalOwner == my_global_index() and (obj.areaTimer - obj.oNetworkTime) > 5)
|
local updateRateSend = (obj.oGlobalOwner == my_global_index() and (get_network_area_timer() - obj.oNetworkTime) > 5)
|
||||||
if gBallTouchedLocal or updateRateSend then
|
if gBallTouchedLocal or updateRateSend then
|
||||||
if gBallTouchedLocal then
|
if gBallTouchedLocal then
|
||||||
obj.oGlobalOwner = my_global_index()
|
obj.oGlobalOwner = my_global_index()
|
||||||
obj.oHitTime = obj.areaTimer
|
obj.oHitTime = get_network_area_timer()
|
||||||
end
|
end
|
||||||
obj.oNetworkTime = obj.areaTimer
|
obj.oNetworkTime = get_network_area_timer()
|
||||||
network_send_object(obj, false)
|
network_send_object(obj, false)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -647,18 +646,6 @@ function bhv_ball_loop(obj)
|
||||||
cb.oVelZ = obj.oVelZ
|
cb.oVelZ = obj.oVelZ
|
||||||
end
|
end
|
||||||
|
|
||||||
function ball_update()
|
|
||||||
-- hack: we have to set the area timer outside of the behavior or bad things happen
|
|
||||||
for i, obj in ipairs(gInitializeBalls) do
|
|
||||||
if obj ~= nil then
|
|
||||||
obj.areaTimerDuration = 0
|
|
||||||
obj.areaTimerType = AREA_TIMER_TYPE_MAXIMUM
|
|
||||||
obj.areaTimer = 0
|
|
||||||
end
|
|
||||||
gInitializeBalls[i] = nil
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
id_bhvBall = hook_behavior(nil, OBJ_LIST_DEFAULT, true, bhv_ball_init, bhv_ball_loop)
|
id_bhvBall = hook_behavior(nil, OBJ_LIST_DEFAULT, true, bhv_ball_init, bhv_ball_loop)
|
||||||
|
|
||||||
----------------------------------------------------------------------------------------------------------------
|
----------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -828,8 +815,8 @@ function gamemode_wait()
|
||||||
-- claim the ball
|
-- claim the ball
|
||||||
if sSoccerBall.oGlobalOwner ~= my_global_index() then
|
if sSoccerBall.oGlobalOwner ~= my_global_index() then
|
||||||
sSoccerBall.oGlobalOwner = my_global_index()
|
sSoccerBall.oGlobalOwner = my_global_index()
|
||||||
sSoccerBall.oHitTime = sSoccerBall.areaTimer
|
sSoccerBall.oHitTime = get_network_area_timer()
|
||||||
sSoccerBall.oNetworkTime = sSoccerBall.areaTimer
|
sSoccerBall.oNetworkTime = get_network_area_timer()
|
||||||
network_send_object(sSoccerBall, false)
|
network_send_object(sSoccerBall, false)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1284,8 +1271,6 @@ function update()
|
||||||
local m = gMarioStates[0]
|
local m = gMarioStates[0]
|
||||||
local np = gNetworkPlayers[m.playerIndex]
|
local np = gNetworkPlayers[m.playerIndex]
|
||||||
|
|
||||||
ball_update()
|
|
||||||
|
|
||||||
if np.currAreaSyncValid then
|
if np.currAreaSyncValid then
|
||||||
gamemode_update()
|
gamemode_update()
|
||||||
end
|
end
|
||||||
|
|
|
@ -7289,6 +7289,15 @@ int smlua_func_collision_find_surface_on_ray(lua_State* L) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int smlua_func_get_network_area_timer(UNUSED lua_State* L) {
|
||||||
|
if(!smlua_functions_valid_param_count(L, 0)) { return 0; }
|
||||||
|
|
||||||
|
|
||||||
|
lua_pushinteger(L, get_network_area_timer());
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
///////////////////////
|
///////////////////////
|
||||||
// smlua_obj_utils.h //
|
// smlua_obj_utils.h //
|
||||||
///////////////////////
|
///////////////////////
|
||||||
|
@ -8520,6 +8529,7 @@ void smlua_bind_functions_autogen(void) {
|
||||||
|
|
||||||
// smlua_misc_utils.h
|
// smlua_misc_utils.h
|
||||||
smlua_bind_function(L, "collision_find_surface_on_ray", smlua_func_collision_find_surface_on_ray);
|
smlua_bind_function(L, "collision_find_surface_on_ray", smlua_func_collision_find_surface_on_ray);
|
||||||
|
smlua_bind_function(L, "get_network_area_timer", smlua_func_get_network_area_timer);
|
||||||
|
|
||||||
// smlua_obj_utils.h
|
// smlua_obj_utils.h
|
||||||
smlua_bind_function(L, "obj_get_first", smlua_func_obj_get_first);
|
smlua_bind_function(L, "obj_get_first", smlua_func_obj_get_first);
|
||||||
|
|
|
@ -12,3 +12,7 @@ struct RayIntersectionInfo* collision_find_surface_on_ray(f32 startX, f32 startY
|
||||||
find_surface_on_ray(orig, end, &info.surface, info.hitPos);
|
find_surface_on_ray(orig, end, &info.surface, info.hitPos);
|
||||||
return &info;
|
return &info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
u32 get_network_area_timer(void) {
|
||||||
|
return gNetworkAreaTimer;
|
||||||
|
}
|
|
@ -7,5 +7,6 @@ struct RayIntersectionInfo {
|
||||||
};
|
};
|
||||||
|
|
||||||
struct RayIntersectionInfo* collision_find_surface_on_ray(f32 startX, f32 startY, f32 startZ, f32 endX, f32 endY, f32 endZ);
|
struct RayIntersectionInfo* collision_find_surface_on_ray(f32 startX, f32 startY, f32 startZ, f32 endX, f32 endY, f32 endZ);
|
||||||
|
u32 get_network_area_timer(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue