mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2025-01-03 14:11:10 +00:00
Add new networked water level functions
This commit is contained in:
parent
2d314c539c
commit
e6880a5fee
13 changed files with 227 additions and 116 deletions
|
@ -894,7 +894,7 @@ def process_function(fname, line):
|
|||
|
||||
line = line.replace('UNUSED', '')
|
||||
|
||||
match = re.search('[a-zA-Z0-9_]+\(', line)
|
||||
match = re.search(r'[a-zA-Z0-9_]+\(', line)
|
||||
function['type'] = normalize_type(line[0:match.span()[0]])
|
||||
function['identifier'] = match.group()[0:-1]
|
||||
|
||||
|
@ -911,7 +911,7 @@ def process_function(fname, line):
|
|||
param['type'] = normalize_type(param_str)
|
||||
param['identifier'] = 'arg%d' % param_index
|
||||
else:
|
||||
match = re.search('[a-zA-Z0-9_\[\]]+$', param_str)
|
||||
match = re.search(r'[a-zA-Z0-9_\[\]]+$', param_str)
|
||||
if match == None:
|
||||
return None
|
||||
param['type'] = normalize_type(param_str[0:match.span()[0]])
|
||||
|
|
|
@ -8611,12 +8611,25 @@ function djui_hud_set_render_behind_hud(enable)
|
|||
-- ...
|
||||
end
|
||||
|
||||
--- @param index integer
|
||||
--- @return number
|
||||
function get_environment_region(index)
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @param localIndex integer
|
||||
--- @return string
|
||||
function network_discord_id_from_local_index(localIndex)
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @param index integer
|
||||
--- @param value integer
|
||||
--- @return nil
|
||||
function set_environment_region(index, value)
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @param levelNum integer
|
||||
--- @return boolean
|
||||
function level_is_vanilla_level(levelNum)
|
||||
|
@ -8980,12 +8993,6 @@ function get_envfx()
|
|||
-- ...
|
||||
end
|
||||
|
||||
--- @param index integer
|
||||
--- @return number
|
||||
function get_environment_region(index)
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @param index integer
|
||||
--- @return integer
|
||||
function get_fog_color(index)
|
||||
|
@ -9097,6 +9104,12 @@ function get_vertex_color(index)
|
|||
-- ...
|
||||
end
|
||||
|
||||
--- @param index integer
|
||||
--- @return integer
|
||||
function get_water_level(index)
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @return integer
|
||||
function hud_get_flash()
|
||||
-- ...
|
||||
|
@ -9205,13 +9218,6 @@ function save_file_set_using_backup_slot(usingBackupSlot)
|
|||
-- ...
|
||||
end
|
||||
|
||||
--- @param index integer
|
||||
--- @param value integer
|
||||
--- @return nil
|
||||
function set_environment_region(index, value)
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @param index integer
|
||||
--- @param value integer
|
||||
--- @return nil
|
||||
|
@ -9312,6 +9318,14 @@ function set_vertex_color(index, value)
|
|||
-- ...
|
||||
end
|
||||
|
||||
--- @param index integer
|
||||
--- @param height integer
|
||||
--- @param sync boolean
|
||||
--- @return nil
|
||||
function set_water_level(index, height, sync)
|
||||
-- ...
|
||||
end
|
||||
|
||||
--- @param title string
|
||||
--- @return nil
|
||||
function set_window_title(title)
|
||||
|
|
|
@ -4858,7 +4858,7 @@
|
|||
- `integer`
|
||||
|
||||
### C Prototype
|
||||
`s32 lvl_set_current_level(UNUSED s16 arg0, s32 levelNum);`
|
||||
`s32 lvl_set_current_level(UNUSED s16 arg0, s16 levelNum);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
|
|
|
@ -1353,26 +1353,6 @@
|
|||
|
||||
<br />
|
||||
|
||||
## [get_environment_region](#get_environment_region)
|
||||
|
||||
### Lua Example
|
||||
`local numberValue = get_environment_region(index)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| index | `integer` |
|
||||
|
||||
### Returns
|
||||
- `number`
|
||||
|
||||
### C Prototype
|
||||
`f32 get_environment_region(u8 index);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [get_fog_color](#get_fog_color)
|
||||
|
||||
### Lua Example
|
||||
|
@ -1752,6 +1732,26 @@
|
|||
|
||||
<br />
|
||||
|
||||
## [get_water_level](#get_water_level)
|
||||
|
||||
### Lua Example
|
||||
`local integerValue = get_water_level(index)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| index | `integer` |
|
||||
|
||||
### Returns
|
||||
- `integer`
|
||||
|
||||
### C Prototype
|
||||
`s16 get_water_level(u8 index);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [hud_get_flash](#hud_get_flash)
|
||||
|
||||
### Lua Example
|
||||
|
@ -2076,27 +2076,6 @@
|
|||
|
||||
<br />
|
||||
|
||||
## [set_environment_region](#set_environment_region)
|
||||
|
||||
### Lua Example
|
||||
`set_environment_region(index, value)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| index | `integer` |
|
||||
| value | `integer` |
|
||||
|
||||
### Returns
|
||||
- None
|
||||
|
||||
### C Prototype
|
||||
`void set_environment_region(u8 index, s32 value);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [set_fog_color](#set_fog_color)
|
||||
|
||||
### Lua Example
|
||||
|
@ -2421,6 +2400,28 @@
|
|||
|
||||
<br />
|
||||
|
||||
## [set_water_level](#set_water_level)
|
||||
|
||||
### Lua Example
|
||||
`set_water_level(index, height, sync)`
|
||||
|
||||
### Parameters
|
||||
| Field | Type |
|
||||
| ----- | ---- |
|
||||
| index | `integer` |
|
||||
| height | `integer` |
|
||||
| sync | `boolean` |
|
||||
|
||||
### Returns
|
||||
- None
|
||||
|
||||
### C Prototype
|
||||
`void set_water_level(u8 index, s16 height, bool sync);`
|
||||
|
||||
[:arrow_up_small:](#)
|
||||
|
||||
<br />
|
||||
|
||||
## [set_window_title](#set_window_title)
|
||||
|
||||
### Lua Example
|
||||
|
|
|
@ -1668,7 +1668,6 @@
|
|||
- [get_dialog_id](functions-5.md#get_dialog_id)
|
||||
- [get_dialog_response](functions-5.md#get_dialog_response)
|
||||
- [get_envfx](functions-5.md#get_envfx)
|
||||
- [get_environment_region](functions-5.md#get_environment_region)
|
||||
- [get_fog_color](functions-5.md#get_fog_color)
|
||||
- [get_fog_intensity](functions-5.md#get_fog_intensity)
|
||||
- [get_global_timer](functions-5.md#get_global_timer)
|
||||
|
@ -1689,6 +1688,7 @@
|
|||
- [get_time](functions-5.md#get_time)
|
||||
- [get_ttc_speed_setting](functions-5.md#get_ttc_speed_setting)
|
||||
- [get_vertex_color](functions-5.md#get_vertex_color)
|
||||
- [get_water_level](functions-5.md#get_water_level)
|
||||
- [hud_get_flash](functions-5.md#hud_get_flash)
|
||||
- [hud_get_value](functions-5.md#hud_get_value)
|
||||
- [hud_hide](functions-5.md#hud_hide)
|
||||
|
@ -1705,7 +1705,6 @@
|
|||
- [reset_window_title](functions-5.md#reset_window_title)
|
||||
- [save_file_get_using_backup_slot](functions-5.md#save_file_get_using_backup_slot)
|
||||
- [save_file_set_using_backup_slot](functions-5.md#save_file_set_using_backup_slot)
|
||||
- [set_environment_region](functions-5.md#set_environment_region)
|
||||
- [set_fog_color](functions-5.md#set_fog_color)
|
||||
- [set_fog_intensity](functions-5.md#set_fog_intensity)
|
||||
- [set_got_file_coin_hi_score](functions-5.md#set_got_file_coin_hi_score)
|
||||
|
@ -1722,6 +1721,7 @@
|
|||
- [set_save_file_modified](functions-5.md#set_save_file_modified)
|
||||
- [set_ttc_speed_setting](functions-5.md#set_ttc_speed_setting)
|
||||
- [set_vertex_color](functions-5.md#set_vertex_color)
|
||||
- [set_water_level](functions-5.md#set_water_level)
|
||||
- [set_window_title](functions-5.md#set_window_title)
|
||||
|
||||
<br />
|
||||
|
|
|
@ -14636,7 +14636,7 @@ int smlua_func_lvl_set_current_level(lua_State* L) {
|
|||
|
||||
s16 arg0 = smlua_to_integer(L, 1);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "lvl_set_current_level"); return 0; }
|
||||
s32 levelNum = smlua_to_integer(L, 2);
|
||||
s16 levelNum = smlua_to_integer(L, 2);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "lvl_set_current_level"); return 0; }
|
||||
|
||||
lua_pushinteger(L, lvl_set_current_level(arg0, levelNum));
|
||||
|
@ -28451,6 +28451,23 @@ int smlua_func_djui_hud_set_render_behind_hud(lua_State* L) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_get_environment_region(lua_State* L) {
|
||||
if (L == NULL) { return 0; }
|
||||
|
||||
int top = lua_gettop(L);
|
||||
if (top != 1) {
|
||||
LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "get_environment_region", 1, top);
|
||||
return 0;
|
||||
}
|
||||
|
||||
u8 index = smlua_to_integer(L, 1);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "get_environment_region"); return 0; }
|
||||
|
||||
lua_pushnumber(L, get_environment_region(index));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_network_discord_id_from_local_index(lua_State* L) {
|
||||
if (L == NULL) { return 0; }
|
||||
|
||||
|
@ -28468,6 +28485,25 @@ int smlua_func_network_discord_id_from_local_index(lua_State* L) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_set_environment_region(lua_State* L) {
|
||||
if (L == NULL) { return 0; }
|
||||
|
||||
int top = lua_gettop(L);
|
||||
if (top != 2) {
|
||||
LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "set_environment_region", 2, top);
|
||||
return 0;
|
||||
}
|
||||
|
||||
u8 index = smlua_to_integer(L, 1);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "set_environment_region"); return 0; }
|
||||
s32 value = smlua_to_integer(L, 2);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "set_environment_region"); return 0; }
|
||||
|
||||
set_environment_region(index, value);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/////////////////////////
|
||||
// smlua_level_utils.h //
|
||||
/////////////////////////
|
||||
|
@ -29511,23 +29547,6 @@ int smlua_func_get_envfx(UNUSED lua_State* L) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_get_environment_region(lua_State* L) {
|
||||
if (L == NULL) { return 0; }
|
||||
|
||||
int top = lua_gettop(L);
|
||||
if (top != 1) {
|
||||
LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "get_environment_region", 1, top);
|
||||
return 0;
|
||||
}
|
||||
|
||||
u8 index = smlua_to_integer(L, 1);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "get_environment_region"); return 0; }
|
||||
|
||||
lua_pushnumber(L, get_environment_region(index));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_get_fog_color(lua_State* L) {
|
||||
if (L == NULL) { return 0; }
|
||||
|
||||
|
@ -29850,6 +29869,23 @@ int smlua_func_get_vertex_color(lua_State* L) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_get_water_level(lua_State* L) {
|
||||
if (L == NULL) { return 0; }
|
||||
|
||||
int top = lua_gettop(L);
|
||||
if (top != 1) {
|
||||
LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "get_water_level", 1, top);
|
||||
return 0;
|
||||
}
|
||||
|
||||
u8 index = smlua_to_integer(L, 1);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "get_water_level"); return 0; }
|
||||
|
||||
lua_pushinteger(L, get_water_level(index));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_hud_get_flash(UNUSED lua_State* L) {
|
||||
if (L == NULL) { return 0; }
|
||||
|
||||
|
@ -30146,25 +30182,6 @@ int smlua_func_save_file_set_using_backup_slot(lua_State* L) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_set_environment_region(lua_State* L) {
|
||||
if (L == NULL) { return 0; }
|
||||
|
||||
int top = lua_gettop(L);
|
||||
if (top != 2) {
|
||||
LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "set_environment_region", 2, top);
|
||||
return 0;
|
||||
}
|
||||
|
||||
u8 index = smlua_to_integer(L, 1);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "set_environment_region"); return 0; }
|
||||
s32 value = smlua_to_integer(L, 2);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "set_environment_region"); return 0; }
|
||||
|
||||
set_environment_region(index, value);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_set_fog_color(lua_State* L) {
|
||||
if (L == NULL) { return 0; }
|
||||
|
||||
|
@ -30445,6 +30462,27 @@ int smlua_func_set_vertex_color(lua_State* L) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_set_water_level(lua_State* L) {
|
||||
if (L == NULL) { return 0; }
|
||||
|
||||
int top = lua_gettop(L);
|
||||
if (top != 3) {
|
||||
LOG_LUA_LINE("Improper param count for '%s': Expected %u, Received %u", "set_water_level", 3, top);
|
||||
return 0;
|
||||
}
|
||||
|
||||
u8 index = smlua_to_integer(L, 1);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 1, "set_water_level"); return 0; }
|
||||
s16 height = smlua_to_integer(L, 2);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 2, "set_water_level"); return 0; }
|
||||
bool sync = smlua_to_boolean(L, 3);
|
||||
if (!gSmLuaConvertSuccess) { LOG_LUA("Failed to convert parameter %u for function '%s'", 3, "set_water_level"); return 0; }
|
||||
|
||||
set_water_level(index, height, sync);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int smlua_func_set_window_title(lua_State* L) {
|
||||
if (L == NULL) { return 0; }
|
||||
|
||||
|
@ -33622,7 +33660,9 @@ void smlua_bind_functions_autogen(void) {
|
|||
smlua_bind_function(L, "audio_stream_set_speed", smlua_func_audio_stream_set_speed);
|
||||
smlua_bind_function(L, "audio_stream_set_tempo", smlua_func_audio_stream_set_tempo);
|
||||
smlua_bind_function(L, "djui_hud_set_render_behind_hud", smlua_func_djui_hud_set_render_behind_hud);
|
||||
smlua_bind_function(L, "get_environment_region", smlua_func_get_environment_region);
|
||||
smlua_bind_function(L, "network_discord_id_from_local_index", smlua_func_network_discord_id_from_local_index);
|
||||
smlua_bind_function(L, "set_environment_region", smlua_func_set_environment_region);
|
||||
|
||||
// smlua_level_utils.h
|
||||
smlua_bind_function(L, "level_is_vanilla_level", smlua_func_level_is_vanilla_level);
|
||||
|
@ -33690,7 +33730,6 @@ void smlua_bind_functions_autogen(void) {
|
|||
smlua_bind_function(L, "get_dialog_id", smlua_func_get_dialog_id);
|
||||
smlua_bind_function(L, "get_dialog_response", smlua_func_get_dialog_response);
|
||||
smlua_bind_function(L, "get_envfx", smlua_func_get_envfx);
|
||||
smlua_bind_function(L, "get_environment_region", smlua_func_get_environment_region);
|
||||
smlua_bind_function(L, "get_fog_color", smlua_func_get_fog_color);
|
||||
smlua_bind_function(L, "get_fog_intensity", smlua_func_get_fog_intensity);
|
||||
smlua_bind_function(L, "get_global_timer", smlua_func_get_global_timer);
|
||||
|
@ -33711,6 +33750,7 @@ void smlua_bind_functions_autogen(void) {
|
|||
smlua_bind_function(L, "get_time", smlua_func_get_time);
|
||||
smlua_bind_function(L, "get_ttc_speed_setting", smlua_func_get_ttc_speed_setting);
|
||||
smlua_bind_function(L, "get_vertex_color", smlua_func_get_vertex_color);
|
||||
smlua_bind_function(L, "get_water_level", smlua_func_get_water_level);
|
||||
smlua_bind_function(L, "hud_get_flash", smlua_func_hud_get_flash);
|
||||
smlua_bind_function(L, "hud_get_value", smlua_func_hud_get_value);
|
||||
smlua_bind_function(L, "hud_hide", smlua_func_hud_hide);
|
||||
|
@ -33727,7 +33767,6 @@ void smlua_bind_functions_autogen(void) {
|
|||
smlua_bind_function(L, "reset_window_title", smlua_func_reset_window_title);
|
||||
smlua_bind_function(L, "save_file_get_using_backup_slot", smlua_func_save_file_get_using_backup_slot);
|
||||
smlua_bind_function(L, "save_file_set_using_backup_slot", smlua_func_save_file_set_using_backup_slot);
|
||||
smlua_bind_function(L, "set_environment_region", smlua_func_set_environment_region);
|
||||
smlua_bind_function(L, "set_fog_color", smlua_func_set_fog_color);
|
||||
smlua_bind_function(L, "set_fog_intensity", smlua_func_set_fog_intensity);
|
||||
smlua_bind_function(L, "set_got_file_coin_hi_score", smlua_func_set_got_file_coin_hi_score);
|
||||
|
@ -33744,6 +33783,7 @@ void smlua_bind_functions_autogen(void) {
|
|||
smlua_bind_function(L, "set_save_file_modified", smlua_func_set_save_file_modified);
|
||||
smlua_bind_function(L, "set_ttc_speed_setting", smlua_func_set_ttc_speed_setting);
|
||||
smlua_bind_function(L, "set_vertex_color", smlua_func_set_vertex_color);
|
||||
smlua_bind_function(L, "set_water_level", smlua_func_set_water_level);
|
||||
smlua_bind_function(L, "set_window_title", smlua_func_set_window_title);
|
||||
|
||||
// smlua_model_utils.h
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
#include "pc/discord/discord.h"
|
||||
#endif
|
||||
#include "pc/lua/smlua.h"
|
||||
#include "game/hardcoded.h"
|
||||
#include "game/object_list_processor.h"
|
||||
|
||||
char* network_discord_id_from_local_index(UNUSED u8 localIndex) {
|
||||
#ifdef DISCORD_SDK
|
||||
|
@ -34,3 +36,18 @@ void audio_stream_set_tempo(UNUSED struct ModAudio* audio, UNUSED f32 tempo) {
|
|||
|
||||
void audio_stream_set_speed(UNUSED struct ModAudio* audio, UNUSED f32 initial_freq, UNUSED f32 speed, UNUSED bool pitch) {
|
||||
}
|
||||
|
||||
f32 get_environment_region(u8 index) {
|
||||
s32 idx = 6 * index;
|
||||
if (gEnvironmentRegions != NULL && index > 0 && index <= gEnvironmentRegions[0] && gEnvironmentRegionsLength > idx) {
|
||||
return gEnvironmentRegions[idx];
|
||||
}
|
||||
return gLevelValues.floorLowerLimit;
|
||||
}
|
||||
|
||||
void set_environment_region(u8 index, s32 value) {
|
||||
s32 idx = 6 * index;
|
||||
if (gEnvironmentRegions != NULL && index > 0 && index <= gEnvironmentRegions[0] && gEnvironmentRegionsLength > idx) {
|
||||
gEnvironmentRegions[idx] = value;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,3 +7,6 @@ struct ModAudio* audio_stream_load_url(const char* url);
|
|||
f32 audio_stream_get_tempo(struct ModAudio* audio);
|
||||
void audio_stream_set_tempo(struct ModAudio* audio, f32 tempo);
|
||||
void audio_stream_set_speed(struct ModAudio* audio, f32 initial_freq, f32 speed, bool pitch);
|
||||
|
||||
f32 get_environment_region(u8 index);
|
||||
void set_environment_region(u8 index, s32 value);
|
||||
|
|
|
@ -472,18 +472,26 @@ void movtexqc_register(const char* name, s16 level, s16 area, s16 type) {
|
|||
|
||||
///
|
||||
|
||||
f32 get_environment_region(u8 index) {
|
||||
s32 idx = 6 * index;
|
||||
if (gEnvironmentRegions != NULL && index > 0 && index <= gEnvironmentRegions[0] && gEnvironmentRegionsLength > idx) {
|
||||
return gEnvironmentRegions[idx];
|
||||
s16 get_water_level(u8 index) {
|
||||
u8 id = 6 * (index + 1);
|
||||
if (gEnvironmentRegions && index < gEnvironmentRegions[0] && gEnvironmentRegionsLength > id) {
|
||||
return gEnvironmentRegions[id];
|
||||
}
|
||||
return gLevelValues.floorLowerLimit;
|
||||
}
|
||||
|
||||
void set_environment_region(u8 index, s32 value) {
|
||||
s32 idx = 6 * index;
|
||||
if (gEnvironmentRegions != NULL && index > 0 && index <= gEnvironmentRegions[0] && gEnvironmentRegionsLength > idx) {
|
||||
gEnvironmentRegions[idx] = value;
|
||||
void set_water_level(u8 index, s16 height, bool sync) {
|
||||
if (sync && (!gNetworkPlayerLocal || !gNetworkPlayerLocal->currAreaSyncValid)) { return; }
|
||||
|
||||
u8 id = 6 * (index + 1);
|
||||
if (gEnvironmentRegions && index < gEnvironmentRegions[0] && gEnvironmentRegionsLength > id) {
|
||||
if (gEnvironmentRegions[id] == height) {
|
||||
return;
|
||||
}
|
||||
if (sync) {
|
||||
network_send_change_water_level(id, height);
|
||||
}
|
||||
gEnvironmentRegions[id] = height;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -623,6 +631,12 @@ u32 get_global_timer(void) {
|
|||
|
||||
///
|
||||
|
||||
s32 get_dialog_response() {
|
||||
return gDialogResponse;
|
||||
}
|
||||
|
||||
///
|
||||
|
||||
void set_window_title(const char* title) {
|
||||
WAPI.set_window_title(title);
|
||||
}
|
||||
|
@ -648,9 +662,3 @@ const char* get_os_name(void) {
|
|||
return "Unknown";
|
||||
#endif
|
||||
}
|
||||
|
||||
///
|
||||
|
||||
s32 get_dialog_response() {
|
||||
return gDialogResponse;
|
||||
}
|
||||
|
|
|
@ -117,8 +117,8 @@ bool save_file_get_using_backup_slot(void);
|
|||
void save_file_set_using_backup_slot(bool usingBackupSlot);
|
||||
|
||||
void movtexqc_register(const char* name, s16 level, s16 area, s16 type);
|
||||
f32 get_environment_region(u8 index);
|
||||
void set_environment_region(u8 index, s32 value);
|
||||
s16 get_water_level(u8 index);
|
||||
void set_water_level(u8 index, s16 height, bool sync);
|
||||
|
||||
void set_override_fov(f32 fov);
|
||||
void set_override_near(f32 near);
|
||||
|
@ -156,11 +156,11 @@ void set_override_envfx(s32 envfx);
|
|||
|
||||
u32 get_global_timer(void);
|
||||
|
||||
s32 get_dialog_response();
|
||||
|
||||
void set_window_title(const char* title);
|
||||
void reset_window_title(void);
|
||||
|
||||
const char* get_os_name(void);
|
||||
|
||||
s32 get_dialog_response();
|
||||
|
||||
#endif
|
||||
|
|
|
@ -117,6 +117,7 @@ void packet_process(struct Packet* p) {
|
|||
case PACKET_LEVEL_MACRO: network_receive_level_macro(p); break;
|
||||
case PACKET_LEVEL_AREA_INFORM: network_receive_level_area_inform(p); break;
|
||||
case PACKET_LEVEL_RESPAWN_INFO: network_receive_level_respawn_info(p); break;
|
||||
case PACKET_CHANGE_WATER_LEVEL: network_receive_change_water_level(p); break;
|
||||
|
||||
case PACKET_PLAYER_SETTINGS: network_receive_player_settings(p); break;
|
||||
|
||||
|
|
|
@ -53,6 +53,7 @@ enum PacketType {
|
|||
PACKET_LEVEL_MACRO,
|
||||
PACKET_LEVEL_AREA_INFORM,
|
||||
PACKET_LEVEL_RESPAWN_INFO,
|
||||
PACKET_CHANGE_WATER_LEVEL,
|
||||
|
||||
PACKET_PLAYER_SETTINGS,
|
||||
|
||||
|
@ -332,6 +333,10 @@ void network_receive_level_area_inform(struct Packet* p);
|
|||
void network_send_level_respawn_info(struct Object* o, u8 respawnInfoBits);
|
||||
void network_receive_level_respawn_info(struct Packet* p);
|
||||
|
||||
// packet_change_water_level.c
|
||||
void network_send_change_water_level(u8 index, s16 height);
|
||||
void network_receive_change_water_level(struct Packet* p);
|
||||
|
||||
// packet_debug_sync.c
|
||||
void network_send_debug_sync(void);
|
||||
void network_receive_debug_sync(struct Packet* p);
|
||||
|
|
22
src/pc/network/packets/packet_change_water_level.c
Normal file
22
src/pc/network/packets/packet_change_water_level.c
Normal file
|
@ -0,0 +1,22 @@
|
|||
#include "../network.h"
|
||||
#include "game/object_list_processor.h"
|
||||
|
||||
void network_send_change_water_level(u8 index, s16 height) {
|
||||
struct Packet p = { 0 };
|
||||
packet_init(&p, PACKET_CHANGE_WATER_LEVEL, true, PLMT_AREA);
|
||||
packet_write(&p, &index, sizeof(u8));
|
||||
packet_write(&p, &height, sizeof(s16));
|
||||
|
||||
network_send(&p);
|
||||
}
|
||||
|
||||
void network_receive_change_water_level(struct Packet* p) {
|
||||
u8 index;
|
||||
s16 height;
|
||||
packet_read(p, &index, sizeof(u8));
|
||||
packet_read(p, &height, sizeof(s16));
|
||||
|
||||
if (gEnvironmentRegions && index % 6 == 0 && gEnvironmentRegionsLength > index) {
|
||||
gEnvironmentRegions[index] = height;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue