mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2024-11-21 19:45:10 +00:00
fixes and other improvements (#309)
* HOOK_JOINED_GAME * expose VERSION_TEXT, and two more adjusments * show if a constant type is a string with autogen * fix another blunder by that guy * should use an or operator here * fix frame limiter stuff
This commit is contained in:
parent
751dfe61c7
commit
7e46ce4a21
15 changed files with 36 additions and 12 deletions
2
Makefile
2
Makefile
|
@ -102,7 +102,7 @@ EXTRA_CFLAGS ?=
|
||||||
EXTRA_CPP_FLAGS ?=
|
EXTRA_CPP_FLAGS ?=
|
||||||
EXTRA_CFLAGS += -Wno-format-security -Wno-trigraphs
|
EXTRA_CFLAGS += -Wno-format-security -Wno-trigraphs
|
||||||
|
|
||||||
dev:; @$(MAKE) DEBUG=1 DEVELOPMENT=1
|
dev:; @$(MAKE) DEVELOPMENT=1
|
||||||
|
|
||||||
# COMPILER - selects the C compiler to use
|
# COMPILER - selects the C compiler to use
|
||||||
# gcc - uses the GNU C Compiler
|
# gcc - uses the GNU C Compiler
|
||||||
|
|
|
@ -162,7 +162,7 @@ def process_define(filename, line):
|
||||||
if p.startswith('0x'):
|
if p.startswith('0x'):
|
||||||
continue
|
continue
|
||||||
p = re.sub(r'0x[a-fA-F0-9]+', '', p)
|
p = re.sub(r'0x[a-fA-F0-9]+', '', p)
|
||||||
if re.search('[a-z]', p) != None:
|
if re.search('[a-z]', p) != None and 'VERSION_TEXT' not in line:
|
||||||
if 'gCurrentObject' not in line:
|
if 'gCurrentObject' not in line:
|
||||||
print('UNRECOGNIZED DEFINE: ' + line)
|
print('UNRECOGNIZED DEFINE: ' + line)
|
||||||
return None
|
return None
|
||||||
|
@ -327,7 +327,10 @@ def def_constant(processed_constant):
|
||||||
return s
|
return s
|
||||||
|
|
||||||
for c in [processed_constant]:
|
for c in [processed_constant]:
|
||||||
s += '\n--- @type integer\n'
|
if "'" in c[1]:
|
||||||
|
s += '\n--- @type string\n'
|
||||||
|
else:
|
||||||
|
s += '\n--- @type integer\n'
|
||||||
s += '%s = %s\n' % (c[0], c[1])
|
s += '%s = %s\n' % (c[0], c[1])
|
||||||
|
|
||||||
return s
|
return s
|
||||||
|
|
|
@ -8209,7 +8209,10 @@ HOOK_CHARACTER_SOUND = 29
|
||||||
HOOK_BEFORE_SET_MARIO_ACTION = 30
|
HOOK_BEFORE_SET_MARIO_ACTION = 30
|
||||||
|
|
||||||
--- @type LuaHookedEventType
|
--- @type LuaHookedEventType
|
||||||
HOOK_MAX = 31
|
HOOK_JOINED_GAME = 31
|
||||||
|
|
||||||
|
--- @type LuaHookedEventType
|
||||||
|
HOOK_MAX = 32
|
||||||
|
|
||||||
--- @class HudDisplayFlags
|
--- @class HudDisplayFlags
|
||||||
|
|
||||||
|
@ -11484,3 +11487,6 @@ MINOR_VERSION_NUMBER = 0
|
||||||
|
|
||||||
--- @type integer
|
--- @type integer
|
||||||
VERSION_NUMBER = 32
|
VERSION_NUMBER = 32
|
||||||
|
|
||||||
|
--- @type string
|
||||||
|
VERSION_TEXT = 'beta'
|
||||||
|
|
|
@ -2927,7 +2927,8 @@
|
||||||
| HOOK_OBJECT_SET_MODEL | 28 |
|
| HOOK_OBJECT_SET_MODEL | 28 |
|
||||||
| HOOK_CHARACTER_SOUND | 29 |
|
| HOOK_CHARACTER_SOUND | 29 |
|
||||||
| HOOK_BEFORE_SET_MARIO_ACTION | 30 |
|
| HOOK_BEFORE_SET_MARIO_ACTION | 30 |
|
||||||
| HOOK_MAX | 31 |
|
| HOOK_JOINED_GAME | 31 |
|
||||||
|
| HOOK_MAX | 32 |
|
||||||
|
|
||||||
[:arrow_up_small:](#)
|
[:arrow_up_small:](#)
|
||||||
|
|
||||||
|
@ -4072,6 +4073,7 @@
|
||||||
- MAX_VERSION_LENGTH
|
- MAX_VERSION_LENGTH
|
||||||
- MINOR_VERSION_NUMBER
|
- MINOR_VERSION_NUMBER
|
||||||
- VERSION_NUMBER
|
- VERSION_NUMBER
|
||||||
|
- VERSION_TEXT
|
||||||
|
|
||||||
[:arrow_up_small:](#)
|
[:arrow_up_small:](#)
|
||||||
|
|
||||||
|
|
|
@ -116,6 +116,8 @@ The lua functions sent to `hook_event()` will be automatically called by SM64 wh
|
||||||
| HOOK_ON_CHAT_MESSAGE | Called when a chat message gets sent. Return `false` to prevent the message from being sent. | [MarioState](structs.md#MarioState) messageSender, `string` messageSent |
|
| HOOK_ON_CHAT_MESSAGE | Called when a chat message gets sent. Return `false` to prevent the message from being sent. | [MarioState](structs.md#MarioState) messageSender, `string` messageSent |
|
||||||
| HOOK_OBJECT_SET_MODEL | Called when a behavior changes models. Also runs when a behavior spawns. | [Object](structs.md#Object) obj, `integer` modelID |
|
| HOOK_OBJECT_SET_MODEL | Called when a behavior changes models. Also runs when a behavior spawns. | [Object](structs.md#Object) obj, `integer` modelID |
|
||||||
| HOOK_CHARACTER_SOUND | Called when mario retrieves a character sound to play, return a character sound or `0` to override it. | [MarioState](structs.md#MarioState) mario, [enum CharacterSound](constants.md#enum-CharacterSound) characterSound |
|
| HOOK_CHARACTER_SOUND | Called when mario retrieves a character sound to play, return a character sound or `0` to override it. | [MarioState](structs.md#MarioState) mario, [enum CharacterSound](constants.md#enum-CharacterSound) characterSound |
|
||||||
|
| HOOK_BEFORE_SET_MARIO_ACTION | Called before Mario's action changes. Return an action to change the incoming action or `1` to cancel the action change. | `integer` incomingAction |
|
||||||
|
| HOOK_JOINED_GAME | Called when the local player finishes the join process (if the player isn't the host) | None |
|
||||||
| HOOK_BEFORE_SET_MARIO_ACTION | Called before Mario's action changes. Return an action to change the incoming action or `1` to cancel the action change. | [MarioState](structs.md#MarioState) mario, `integer` incomingAction |
|
| HOOK_BEFORE_SET_MARIO_ACTION | Called before Mario's action changes. Return an action to change the incoming action or `1` to cancel the action change. | [MarioState](structs.md#MarioState) mario, `integer` incomingAction |
|
||||||
|
|
||||||
### Parameters
|
### Parameters
|
||||||
|
|
|
@ -410,7 +410,6 @@ void save_file_erase_current_backup_save(void) {
|
||||||
save_file_reload(FALSE);
|
save_file_reload(FALSE);
|
||||||
|
|
||||||
save_file_do_save(gCurrSaveFileNum-1, TRUE);
|
save_file_do_save(gCurrSaveFileNum-1, TRUE);
|
||||||
network_send_save_file(gCurrSaveFileNum-1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -811,7 +811,7 @@ static struct LuaObjectField sMarioBodyStateFields[LUA_MARIO_BODY_STATE_FIELD_CO
|
||||||
{ "wingFlutter", LVT_S8, offsetof(struct MarioBodyState, wingFlutter), false, LOT_NONE },
|
{ "wingFlutter", LVT_S8, offsetof(struct MarioBodyState, wingFlutter), false, LOT_NONE },
|
||||||
};
|
};
|
||||||
|
|
||||||
#define LUA_MARIO_STATE_FIELD_COUNT 76
|
#define LUA_MARIO_STATE_FIELD_COUNT 77
|
||||||
static struct LuaObjectField sMarioStateFields[LUA_MARIO_STATE_FIELD_COUNT] = {
|
static struct LuaObjectField sMarioStateFields[LUA_MARIO_STATE_FIELD_COUNT] = {
|
||||||
{ "action", LVT_U32, offsetof(struct MarioState, action), false, LOT_NONE },
|
{ "action", LVT_U32, offsetof(struct MarioState, action), false, LOT_NONE },
|
||||||
{ "actionArg", LVT_U32, offsetof(struct MarioState, actionArg), false, LOT_NONE },
|
{ "actionArg", LVT_U32, offsetof(struct MarioState, actionArg), false, LOT_NONE },
|
||||||
|
|
|
@ -2939,7 +2939,8 @@ char gSmluaConstants[] = ""
|
||||||
"HOOK_OBJECT_SET_MODEL = 28\n"
|
"HOOK_OBJECT_SET_MODEL = 28\n"
|
||||||
"HOOK_CHARACTER_SOUND = 29\n"
|
"HOOK_CHARACTER_SOUND = 29\n"
|
||||||
"HOOK_BEFORE_SET_MARIO_ACTION = 30\n"
|
"HOOK_BEFORE_SET_MARIO_ACTION = 30\n"
|
||||||
"HOOK_MAX = 31\n"
|
"HOOK_JOINED_GAME = 31\n"
|
||||||
|
"HOOK_MAX = 32\n"
|
||||||
"ACTION_HOOK_EVERY_FRAME = 0\n"
|
"ACTION_HOOK_EVERY_FRAME = 0\n"
|
||||||
"ACTION_HOOK_GRAVITY = 1\n"
|
"ACTION_HOOK_GRAVITY = 1\n"
|
||||||
"ACTION_HOOK_MAX = 2\n"
|
"ACTION_HOOK_MAX = 2\n"
|
||||||
|
@ -4028,6 +4029,7 @@ char gSmluaConstants[] = ""
|
||||||
"COOP_OBJ_FLAG_NETWORK = (1 << 0)\n"
|
"COOP_OBJ_FLAG_NETWORK = (1 << 0)\n"
|
||||||
"COOP_OBJ_FLAG_LUA = (1 << 1)\n"
|
"COOP_OBJ_FLAG_LUA = (1 << 1)\n"
|
||||||
"COOP_OBJ_FLAG_NON_SYNC = (1 << 2)\n"
|
"COOP_OBJ_FLAG_NON_SYNC = (1 << 2)\n"
|
||||||
|
"VERSION_TEXT = 'beta'\n"
|
||||||
"VERSION_NUMBER = 32\n"
|
"VERSION_NUMBER = 32\n"
|
||||||
"MINOR_VERSION_NUMBER = 0\n"
|
"MINOR_VERSION_NUMBER = 0\n"
|
||||||
"MAX_VERSION_LENGTH = 10\n"
|
"MAX_VERSION_LENGTH = 10\n"
|
||||||
|
|
|
@ -42,6 +42,7 @@ enum LuaHookedEventType {
|
||||||
HOOK_OBJECT_SET_MODEL,
|
HOOK_OBJECT_SET_MODEL,
|
||||||
HOOK_CHARACTER_SOUND,
|
HOOK_CHARACTER_SOUND,
|
||||||
HOOK_BEFORE_SET_MARIO_ACTION,
|
HOOK_BEFORE_SET_MARIO_ACTION,
|
||||||
|
HOOK_JOINED_GAME,
|
||||||
HOOK_MAX,
|
HOOK_MAX,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -77,6 +78,7 @@ static const char* LuaHookedEventTypeName[] = {
|
||||||
"HOOK_OBJECT_SET_MODEL",
|
"HOOK_OBJECT_SET_MODEL",
|
||||||
"HOOK_CHARACTER_SOUND",
|
"HOOK_CHARACTER_SOUND",
|
||||||
"HOOK_BEFORE_SET_MARIO_ACTION",
|
"HOOK_BEFORE_SET_MARIO_ACTION",
|
||||||
|
"HOOK_JOINED_GAME",
|
||||||
"HOOK_MAX"
|
"HOOK_MAX"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,6 @@ static void on_activity_join_callback(UNUSED void* data, enum EDiscordResult res
|
||||||
DISCORD_REQUIRE(result);
|
DISCORD_REQUIRE(result);
|
||||||
if (gNetworkType != NT_NONE) {
|
if (gNetworkType != NT_NONE) {
|
||||||
LOGFILE_ERROR(LFT_DISCORD, "Joined lobby when already connected somewhere!");
|
LOGFILE_ERROR(LFT_DISCORD, "Joined lobby when already connected somewhere!");
|
||||||
exit(0);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
network_init(NT_CLIENT);
|
network_init(NT_CLIENT);
|
||||||
|
|
|
@ -38,6 +38,9 @@ void network_send_join_request(void) {
|
||||||
|
|
||||||
struct Packet p = { 0 };
|
struct Packet p = { 0 };
|
||||||
packet_init(&p, PACKET_JOIN_REQUEST, true, PLMT_NONE);
|
packet_init(&p, PACKET_JOIN_REQUEST, true, PLMT_NONE);
|
||||||
|
char version[MAX_VERSION_LENGTH] = { 0 };
|
||||||
|
snprintf(version, MAX_VERSION_LENGTH, "%s", get_version());
|
||||||
|
packet_write(&p, &version, sizeof(u8) * MAX_VERSION_LENGTH);
|
||||||
|
|
||||||
packet_write(&p, &configPlayerModel, sizeof(u8));
|
packet_write(&p, &configPlayerModel, sizeof(u8));
|
||||||
packet_write(&p, &configPlayerPalette, sizeof(struct PlayerPalette));
|
packet_write(&p, &configPlayerPalette, sizeof(struct PlayerPalette));
|
||||||
|
@ -52,6 +55,8 @@ void network_receive_join_request(struct Packet* p) {
|
||||||
LOG_INFO("received join request");
|
LOG_INFO("received join request");
|
||||||
|
|
||||||
if (p->dataLength > 5) {
|
if (p->dataLength > 5) {
|
||||||
|
char version[MAX_VERSION_LENGTH] = { 0 };
|
||||||
|
packet_read(p, &version, sizeof(u8) * MAX_VERSION_LENGTH);
|
||||||
packet_read(p, &sJoinRequestPlayerModel, sizeof(u8));
|
packet_read(p, &sJoinRequestPlayerModel, sizeof(u8));
|
||||||
packet_read(p, &sJoinRequestPlayerPalette, sizeof(struct PlayerPalette));
|
packet_read(p, &sJoinRequestPlayerPalette, sizeof(struct PlayerPalette));
|
||||||
packet_read(p, &sJoinRequestPlayerName, sizeof(u8) * MAX_PLAYER_STRING);
|
packet_read(p, &sJoinRequestPlayerName, sizeof(u8) * MAX_PLAYER_STRING);
|
||||||
|
@ -241,7 +246,8 @@ void network_receive_join(struct Packet* p) {
|
||||||
network_send_network_players_request();
|
network_send_network_players_request();
|
||||||
network_send_lua_sync_table_request();
|
network_send_lua_sync_table_request();
|
||||||
|
|
||||||
|
gCurrentlyJoining = false;
|
||||||
|
smlua_call_event_hooks(HOOK_JOINED_GAME);
|
||||||
extern s16 gChangeLevel;
|
extern s16 gChangeLevel;
|
||||||
gChangeLevel = gLevelValues.entryLevel;
|
gChangeLevel = gLevelValues.entryLevel;
|
||||||
gCurrentlyJoining = false;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,9 @@ void network_send_mod_list_request(void) {
|
||||||
|
|
||||||
struct Packet p = { 0 };
|
struct Packet p = { 0 };
|
||||||
packet_init(&p, PACKET_MOD_LIST_REQUEST, true, PLMT_NONE);
|
packet_init(&p, PACKET_MOD_LIST_REQUEST, true, PLMT_NONE);
|
||||||
|
char version[MAX_VERSION_LENGTH] = { 0 };
|
||||||
|
snprintf(version, MAX_VERSION_LENGTH, "%s", get_version());
|
||||||
|
packet_write(&p, &version, sizeof(u8) * MAX_VERSION_LENGTH);
|
||||||
|
|
||||||
network_send_to((gNetworkPlayerServer != NULL) ? gNetworkPlayerServer->localIndex : 0, &p);
|
network_send_to((gNetworkPlayerServer != NULL) ? gNetworkPlayerServer->localIndex : 0, &p);
|
||||||
LOG_INFO("sending mod list request");
|
LOG_INFO("sending mod list request");
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
|
||||||
static char sVersionString[MAX_VERSION_LENGTH] = { 0 };
|
static char sVersionString[MAX_VERSION_LENGTH] = { 0 };
|
||||||
#define VERSION_TEXT "beta"
|
|
||||||
|
|
||||||
char* get_version(void) {
|
char* get_version(void) {
|
||||||
snprintf(sVersionString, MAX_VERSION_LENGTH, "%s %d.%d", VERSION_TEXT, VERSION_NUMBER, MINOR_VERSION_NUMBER);
|
snprintf(sVersionString, MAX_VERSION_LENGTH, "%s %d.%d", VERSION_TEXT, VERSION_NUMBER, MINOR_VERSION_NUMBER);
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#ifndef VERSION_H
|
#ifndef VERSION_H
|
||||||
#define VERSION_H
|
#define VERSION_H
|
||||||
|
|
||||||
|
#define VERSION_TEXT 'beta'
|
||||||
#define VERSION_NUMBER 32
|
#define VERSION_NUMBER 32
|
||||||
#define MINOR_VERSION_NUMBER 0
|
#define MINOR_VERSION_NUMBER 0
|
||||||
|
|
||||||
|
|
|
@ -174,7 +174,7 @@ void produce_interpolation_frames_and_delay(void) {
|
||||||
gfx_start_frame();
|
gfx_start_frame();
|
||||||
f32 delta = MIN((curTime - sFrameTimeStart) / (sFrameTargetTime - sFrameTimeStart), 1);
|
f32 delta = MIN((curTime - sFrameTimeStart) / (sFrameTargetTime - sFrameTimeStart), 1);
|
||||||
gRenderingDelta = delta;
|
gRenderingDelta = delta;
|
||||||
if (!gSkipInterpolationTitleScreen && configFrameLimit > 30) { patch_interpolations(delta); }
|
if (!gSkipInterpolationTitleScreen && (configFrameLimit > 30 || configUncappedFramerate)) { patch_interpolations(delta); }
|
||||||
send_display_list(gGfxSPTask);
|
send_display_list(gGfxSPTask);
|
||||||
gfx_end_frame();
|
gfx_end_frame();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue