mirror of
https://github.com/HarbourMasters/SpaghettiKart
synced 2026-07-08 06:30:56 -04:00
fix of bowser castle crash (#70)
* fix of bowser castle crash * format multiplayer * Update MultiplayerWindow.cpp * fix crash
This commit is contained in:
@@ -13,13 +13,13 @@ extern "C" {
|
||||
#include "networking/networking.h"
|
||||
#include "actor_types.h"
|
||||
#include "code_800029B0.h"
|
||||
struct Actor gActorList[];
|
||||
extern char *gCourseNames[];
|
||||
extern char *gCupNames[];
|
||||
extern struct Actor gActorList[];
|
||||
extern char* gCourseNames[];
|
||||
extern char* gCupNames[];
|
||||
extern char* D_800E76A8[];
|
||||
extern Network gNetwork;
|
||||
extern Camera cameras[];
|
||||
extern UnkStruct_800DC5EC *D_800DC5EC;
|
||||
extern UnkStruct_800DC5EC* D_800DC5EC;
|
||||
}
|
||||
|
||||
namespace Multiplayer {
|
||||
@@ -42,35 +42,35 @@ void MultiplayerWindow::DrawElement() {
|
||||
|
||||
if (!gNetwork.isConnected) {
|
||||
|
||||
static char username[NETWORK_USERNAME_LENGTH] = "TestUser";
|
||||
static char username[NETWORK_USERNAME_LENGTH] = "TestUser";
|
||||
|
||||
ImGui::Text("Username:");
|
||||
ImGui::InputText("##edit", username, IM_ARRAYSIZE(username));
|
||||
ImGui::Text("Username:");
|
||||
ImGui::InputText("##edit", username, IM_ARRAYSIZE(username));
|
||||
|
||||
static char address[32] = "127.0.0.1:64010";
|
||||
static char addressCopy[32];
|
||||
strncpy(addressCopy, address, sizeof(addressCopy));
|
||||
addressCopy[sizeof(addressCopy) - 1] = '\0'; // Ensure null termination
|
||||
static char address[32] = "127.0.0.1:64010";
|
||||
static char addressCopy[32];
|
||||
strncpy(addressCopy, address, sizeof(addressCopy));
|
||||
addressCopy[sizeof(addressCopy) - 1] = '\0'; // Ensure null termination
|
||||
|
||||
ImGui::Text("Host:");
|
||||
ImGui::InputText("##edit3", addressCopy, IM_ARRAYSIZE(addressCopy));
|
||||
ImGui::Text("Host:");
|
||||
ImGui::InputText("##edit3", addressCopy, IM_ARRAYSIZE(addressCopy));
|
||||
|
||||
if (ImGui::Button("Connect!")) {
|
||||
char* ip = NULL;
|
||||
uint16_t port = 0;
|
||||
if (ImGui::Button("Connect!")) {
|
||||
char* ip = NULL;
|
||||
uint16_t port = 0;
|
||||
|
||||
char* token = strtok(addressCopy, ":");
|
||||
ip = token;
|
||||
char* token = strtok(addressCopy, ":");
|
||||
ip = token;
|
||||
|
||||
token = strtok(NULL, ":");
|
||||
if (token != NULL) {
|
||||
port = (uint16_t)atoi(token);
|
||||
token = strtok(NULL, ":");
|
||||
if (token != NULL) {
|
||||
port = (uint16_t) atoi(token);
|
||||
}
|
||||
|
||||
gNetwork.enabled = true;
|
||||
ConnectToServer(ip, port, username);
|
||||
}
|
||||
|
||||
gNetwork.enabled = true;
|
||||
ConnectToServer(ip, port, username);
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
ImGui::Spacing();
|
||||
@@ -104,7 +104,6 @@ void MultiplayerWindow::DrawElement() {
|
||||
ImGui::Spacing();
|
||||
ImGui::Text("-- %s --", gCupNames[sCup]);
|
||||
|
||||
|
||||
if (ImGui::Button("test", ImVec2(-1, 0))) {
|
||||
// Add disconnect logic here
|
||||
cameras[0].playerId = 2;
|
||||
@@ -112,16 +111,17 @@ void MultiplayerWindow::DrawElement() {
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < NETWORK_MAX_PLAYERS; i++) {
|
||||
ImGui::Text("Slot %d: char: %d, hasAuthority: %d", clients[i].slot, clients[i].character, gPlayers[i].nHasAuthority);
|
||||
ImGui::Text("Slot %d: char: %d, hasAuthority: %d", clients[i].slot, clients[i].character,
|
||||
gPlayers[i].nHasAuthority);
|
||||
}
|
||||
|
||||
|
||||
/* Stick UI to the bottom of the panel */
|
||||
|
||||
float windowHeight = ImGui::GetWindowHeight();
|
||||
|
||||
// Move the cursor to a position relative to the bottom of the window
|
||||
ImGui::SetCursorPosY(windowHeight - ImGui::GetFrameHeightWithSpacing() * 2); // Adjust Y position for two buttons
|
||||
ImGui::SetCursorPosY(windowHeight -
|
||||
ImGui::GetFrameHeightWithSpacing() * 2); // Adjust Y position for two buttons
|
||||
|
||||
char buttonLabel[32];
|
||||
|
||||
@@ -152,4 +152,4 @@ void MultiplayerWindow::DrawElement() {
|
||||
|
||||
void MultiplayerWindow::UpdateElement() {
|
||||
}
|
||||
} // namespace GameInfo
|
||||
} // namespace Multiplayer
|
||||
|
||||
Reference in New Issue
Block a user