Merge branch 'dev' into coop

This commit is contained in:
MysterD 2023-04-30 17:59:54 -07:00
commit 03d2590b3d
5 changed files with 10 additions and 239 deletions

View file

@ -532,7 +532,7 @@ SRC_DIRS := src src/engine src/game src/audio src/bass_audio src/menu src/buffer
BIN_DIRS := bin bin/$(VERSION)
# PC files
SRC_DIRS += src/pc src/pc/gfx src/pc/audio src/pc/controller src/pc/fs src/pc/fs/packtypes src/pc/mods src/pc/network src/pc/network/packets src/pc/network/socket src/pc/network/coopnet src/pc/utils src/pc/utils/miniz src/pc/djui src/pc/lua src/pc/lua/utils
SRC_DIRS += src/pc src/pc/gfx src/pc/audio src/pc/controller src/pc/fs src/pc/fs/packtypes src/pc/mods src/dev src/pc/network src/pc/network/packets src/pc/network/socket src/pc/network/coopnet src/pc/utils src/pc/utils/miniz src/pc/djui src/pc/lua src/pc/lua/utils
ifeq ($(DISCORD_SDK),1)
SRC_DIRS += src/pc/discord

View file

@ -9,7 +9,9 @@
#include "pc/debuglog.h"
#include "pc/lua/utils/smlua_level_utils.h"
#include "level_table.h"
#ifdef DEVELOPMENT
#include "dev/chat.h"
#endif
extern bool gIsModerator;
static enum ChatConfirmCommand sConfirming = CCC_NONE;
@ -214,99 +216,7 @@ bool exec_chat_command(char* command) {
return true;
}
#if defined(DEVELOPMENT)
if (gNetworkSystem == &gNetworkSystemSocket && str_starts_with("/warp ", command)) {
static const struct { const char *name; s32 num; } sLevelNumByName[] = {
#undef STUB_LEVEL
#undef DEFINE_LEVEL
#define STUB_LEVEL(...)
#define DEFINE_LEVEL(_0, levelnum, _2, levelname, ...) { #levelname, levelnum },
#include "levels/level_defines.h"
#undef STUB_LEVEL
#undef DEFINE_LEVEL
};
// Params
char *paramLevel = command + 6;
if (*paramLevel == 0 || *paramLevel == ' ') {
djui_chat_message_create("Missing parameters: [LEVEL] [AREA] [ACT]");
return true;
}
char *paramArea = strchr(paramLevel, ' ');
if (paramArea++ == NULL || *paramArea == 0 || *paramArea == ' ') {
djui_chat_message_create("Missing parameters: [AREA] [ACT]");
return true;
}
char *paramAct = strchr(paramArea, ' ');
if (paramAct++ == NULL || *paramAct == 0 || *paramAct == ' ') {
djui_chat_message_create("Missing parameters: [ACT]");
return true;
}
*(paramArea - 1) = 0;
*(paramAct - 1) = 0;
// Level
s32 level = -1;
if (sscanf(paramLevel, "%d", &level) <= 0) {
for (s32 i = 0; i != (s32) (sizeof(sLevelNumByName) / sizeof(sLevelNumByName[0])); ++i) {
if (strstr(paramLevel, sLevelNumByName[i].name) == paramLevel) {
level = sLevelNumByName[i].num;
break;
}
}
if (level == -1) {
struct CustomLevelInfo* info = smlua_level_util_get_info_from_short_name(paramLevel);
if (info != NULL) {
level = info->levelNum;
}
}
if (level == -1) {
char message[256];
snprintf(message, 256, "Invalid [LEVEL] parameter: %s", paramLevel);
djui_chat_message_create(message);
return true;
}
}
// Area
s32 area = -1;
if (sscanf(paramArea, "%d", &area) <= 0) {
char message[256];
snprintf(message, 256, "Invalid [AREA] parameter: %s", paramArea);
djui_chat_message_create(message);
return true;
}
// Act
s32 act = -1;
if (sscanf(paramAct, "%d", &act) <= 0) {
char message[256];
snprintf(message, 256, "Invalid [ACT] parameter: %s", paramAct);
djui_chat_message_create(message);
return true;
}
// Warp
if (!dynos_warp_to_level(level, area, act)) {
char message[256];
snprintf(message, 256, "Unable to warp to: %s %s %s", paramLevel, paramArea, paramAct);
djui_chat_message_create(message);
return true;
}
// OK
char message[256];
snprintf(message, 256, "Warping to: %s %s %s...", paramLevel, paramArea, paramAct);
djui_chat_message_create(message);
return true;
}
if (str_starts_with("/lua ", command)) {
smlua_exec_str(&command[5]);
return true;
}
if (str_starts_with("/luaf ", command)) {
smlua_exec_file(&command[6]);
if (exec_dev_chat_command(command)) {
return true;
}
#endif
@ -323,9 +233,7 @@ void display_chat_commands(void) {
djui_chat_message_create(DLANG(CHAT, MOD_DESC));
}
#if defined(DEVELOPMENT)
djui_chat_message_create("/warp [LEVEL] [AREA] [ACT] - Level can be either a numeric value or a shorthand name");
djui_chat_message_create("/lua [LUA] - Execute Lua code from a string");
djui_chat_message_create("/luaf [FILENAME] - Execute Lua code from a file");
dev_display_chat_commands();
#endif
if (sConfirming != CCC_NONE) { djui_chat_message_create("/confirm"); }
smlua_display_chat_commands();

View file

@ -7,7 +7,10 @@
#include "../configfile.h"
#include "controller_keyboard.h"
#include "controller_keyboard_debug.h"
#ifdef DEVELOPMENT
#include "dev/controller_keyboard_debug.h"
#endif
#include "pc/gfx/gfx_window_manager_api.h"
#include "pc/pc_main.h"

View file

@ -1,131 +0,0 @@
#include "controller_keyboard_debug.h"
#include "game/level_update.h"
#include "game/camera.h"
#include "pc/network/network.h"
#include "game/mario.h"
#include "sm64.h"
#include "object_fields.h"
#include "object_constants.h"
#include "src/game/object_helpers.h"
#include "behavior_data.h"
#include "behavior_table.h"
#ifdef DEVELOPMENT
#include "pc/lua/smlua.h"
#include "pc/network/socket/socket.h"
static bool sHoldingAlt = false;
static bool sHoldingShift = false;
bool gDebugToggle = false;
#define SCANCODE_0 0x0B
#define SCANCODE_1 0x02
#define SCANCODE_2 0x03
#define SCANCODE_3 0x04
#define SCANCODE_4 0x05
#define SCANCODE_5 0x06
#define SCANCODE_6 0x07
#define SCANCODE_7 0x08
#define SCANCODE_8 0x09
#define SCANCODE_9 0x0A
#define SCANCODE_F5 0x3f
#define SCANCODE_ALT 0x38
#define SCANCODE_SHIFT 0x2A
extern void print_sync_object_table(void);
static void debug_breakpoint_here(void) {
// create easy breakpoint position for debugging
}
extern bool dynos_warp_to_level(s32 aLevel, s32 aArea, s32 aAct);
static void debug_warp_level1() {
// warp to credits
//set_mario_action(&gMarioStates[0], ACT_JUMBO_STAR_CUTSCENE, 0);
//return;
dynos_warp_to_level(LEVEL_BOB, 1, 1);
}
static void debug_warp_level2() {
extern f64 gGameSpeed;
gGameSpeed = MAX(gGameSpeed - 0.1f, 0.1f);
printf("GAME SPEED: %f\n", gGameSpeed);
//dynos_warp_to_level(gCurrLevelNum, gCurrAreaIndex^3, 1);
}
static void debug_warp_level3() {
extern f64 gGameSpeed;
gGameSpeed = MIN(gGameSpeed + 0.1f, 10.0f);
printf("GAME SPEED: %f\n", gGameSpeed);
//dynos_warp_to_level(LEVEL_CASTLE_GROUNDS, 1, 1);
}
static void debug_grand_star(void) {
set_mario_action(&gMarioStates[0], ACT_JUMBO_STAR_CUTSCENE, 0);
}
static void debug_warp_to(void) {
gMarioStates[0].pos[0] = gMarioStates[1].pos[0];
gMarioStates[0].pos[1] = gMarioStates[1].pos[1];
gMarioStates[0].pos[2] = gMarioStates[1].pos[2];
gMarioStates[0].marioObj->oRoom = gMarioStates[1].marioObj->oRoom;
}
static void debug_suicide(void) {
gMarioStates[0].hurtCounter = 31;
}
static void debug_reload_lua(void) {
smlua_shutdown();
smlua_init();
}
static void debug_spawn_object(void) {
for (int i = 0; i < 1; i++) {
struct Object* box = spawn_object(gMarioStates[0].marioObj, MODEL_BREAKABLE_BOX_SMALL, bhvBreakableBoxSmall);
if (box == NULL) { return; }
//box->oPosX += (random_float() - 0.5f) * 1000.0f;
//box->oPosZ += (random_float() - 0.5f) * 1000.0f;
if (!sync_object_set_id(box)) {
box->activeFlags = ACTIVE_FLAG_DEACTIVATED;
return;
}
struct Object* spawn_objects[] = { box };
u32 models[] = { MODEL_BREAKABLE_BOX_SMALL };
network_send_spawn_objects(spawn_objects, models, 1);
}
}
void debug_keyboard_on_key_down(int scancode) {
if (gNetworkSystem == &gNetworkSystemSocket) {
switch (scancode & 0xFF) {
case SCANCODE_ALT: sHoldingAlt = true; break;
case SCANCODE_SHIFT: sHoldingShift = true; break;
case SCANCODE_3: debug_breakpoint_here(); break;
case SCANCODE_1: if (sHoldingAlt) { debug_warp_level1(); } break;
case SCANCODE_2: if (sHoldingAlt) { debug_warp_level2(); } break;
case SCANCODE_4: if (sHoldingAlt) { debug_warp_level3(); } break;
case SCANCODE_5: if (sHoldingAlt) { print_sync_object_table(); } break;
case SCANCODE_6: if (sHoldingAlt) { gDebugToggle = !gDebugToggle; } break;
case SCANCODE_8: if (sHoldingAlt) { debug_spawn_object(); } break;
case SCANCODE_9: if (sHoldingAlt) { debug_warp_to(); } break;
case SCANCODE_0: if (sHoldingAlt) { debug_suicide(); } break;
case SCANCODE_F5: debug_reload_lua(); break;
}
}
}
void debug_keyboard_on_key_up(int scancode) {
if (gNetworkSystem == &gNetworkSystemSocket) {
switch (scancode & 0xFF) {
case SCANCODE_ALT: sHoldingAlt = false; break;
case SCANCODE_SHIFT: sHoldingShift = false; break;
}
}
}
#endif

View file

@ -1,9 +0,0 @@
#ifndef CONTROLLER_KEYBOARD_DEBUG_H
#define CONTROLLER_KEYBOARD_DEBUG_H
#ifdef DEVELOPMENT
void debug_keyboard_on_key_down(int scancode);
void debug_keyboard_on_key_up(int scancode);
#endif
#endif