mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2025-10-30 08:01:01 +00:00
Added more things to the language system
This commit is contained in:
parent
fe8c510ee4
commit
30e802179b
13 changed files with 196 additions and 95 deletions
|
|
@ -1,3 +1,45 @@
|
||||||
|
[NOTIF]
|
||||||
|
CONNECTED = "@ connected"
|
||||||
|
DISCONNECTED = "@ disconnected"
|
||||||
|
LEFT_THIS_LEVEL = "@ left this level"
|
||||||
|
ENTERED_THIS_LEVEL = "@ entered this level"
|
||||||
|
ENTERED = "@ entered\n#"
|
||||||
|
SERVER_CLOSED = "\\#ffa0a0\\Disconnected:\\#dcdcdc\\ server closed"
|
||||||
|
DISCORD_ERROR = "Discord threw an error.\nTo fix, try: \n1. Close the game.\n2. Restart Discord.\n3. Start the game."
|
||||||
|
DISCORD_DETECT = "\\#ffa0a0\\Error:\\#c8c8c8\\ Could not detect Discord.\n\\#a0a0a0\\Try closing the game, restarting Discord, and opening the game again."
|
||||||
|
DISCONNECT_FULL = "\\#ffa0a0\\Disconnected:\\#c8c8c8\\ The party is full."
|
||||||
|
DISCONNECT_KICK = "\\#ffa0a0\\Disconnected:\\#c8c8c8\\ The server kicked you."
|
||||||
|
DISCONNECT_BAN = "\\#ffa0a0\\Disconnected:\\#c8c8c8\\ The server banned you."
|
||||||
|
DISCONNECT_REJOIN = "\\#ffa0a0\\Disconnected:\\#c8c8c8\\ Rejoining..."
|
||||||
|
DISCONNECT_CLOSED = "\\#ffa0a0\\Disconnected:\\#c8c8c8\\ Host has closed the connection."
|
||||||
|
DISCONNECT_BIG_MOD = "Server had too large of a mod.\nQuitting."
|
||||||
|
DIED = "@ died"
|
||||||
|
DEBUG_FLY = "@ entered the debug free fly state"
|
||||||
|
|
||||||
|
[CHAT]
|
||||||
|
KICKING = "Kicking '@'!"
|
||||||
|
BANNING = "Banning '@'!"
|
||||||
|
SERVER_ONLY = "Only the server can use this command."
|
||||||
|
PERM_BANNING = "Permanently banning '@'!"
|
||||||
|
ADD_MODERATOR = "Adding '@' as a Moderator!"
|
||||||
|
PLAYERS = "Players"
|
||||||
|
NO_PERMS = "You do not have permission to use this command."
|
||||||
|
PLAYER_NOT_FOUND = "Could not find player."
|
||||||
|
SELF_KICK = "You can not kick yourself."
|
||||||
|
SELF_BAN = "You can not ban yourself."
|
||||||
|
SELF_MOD = "You can not make yourself a moderator."
|
||||||
|
KICK_CONFIRM = "Are you sure you want to kick '@'?\nType '\\#a0ffa0\\/confirm\\#fff982\\' to kick."
|
||||||
|
BAN_CONFIRM = "Are you sure you want to ban '@'?\nType '\\#a0ffa0\\/confirm\\#fff982\\' to ban."
|
||||||
|
PERM_BAN_CONFIRM = "Are you sure you want to permanently ban '@'?\nType '\\#a0ffa0\\/confirm\\#fff982\\' to ban."
|
||||||
|
MOD_CONFIRM = "Are you sure you want to make '@' a moderator?\nType '\\#a0ffa0\\/confirm\\#fff982\\'."
|
||||||
|
PLAYERS_DESC = "/players - List all players and their IDs"
|
||||||
|
KICK_DESC = "/kick [NAME|ID] - Kick this player from the current game"
|
||||||
|
BAN_DESC = "/ban [NAME|ID] - Ban this player from the current game"
|
||||||
|
PERM_BAN_DESC = "/permban [NAME|ID] - Ban this player from any game you host"
|
||||||
|
MOD_DESC = "/moderator [NAME|ID] - Make this player able to use commands like /kick, /ban, /permban on any game you host"
|
||||||
|
UNRECOGNIZED = "Unrecognized chat command."
|
||||||
|
MOD_GRANTED = "\\#fff982\\You are now a Moderator."
|
||||||
|
|
||||||
[MENU]
|
[MENU]
|
||||||
BACK = "Back"
|
BACK = "Back"
|
||||||
CANCEL = "Cancel"
|
CANCEL = "Cancel"
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,45 @@
|
||||||
|
[NOTIF]
|
||||||
|
CONNECTED = "@ conectado"
|
||||||
|
DISCONNECTED = "@ desconectado"
|
||||||
|
LEFT_THIS_LEVEL = "@ salió de este nivel"
|
||||||
|
ENTERED_THIS_LEVEL = "@ entró en este nivel"
|
||||||
|
ENTERED = "@ ingresado\n#"
|
||||||
|
SERVER_CLOSED = "\\#ffa0a0\\Desconectado:\\#dcdcdc\\ servidor cerrado"
|
||||||
|
DISCORD_ERROR = "Discord lanzó un error.\nPara solucionarlo, intente: \n1. Cierre el juego.\n2. Reinicie Discord.\n3. Inicie el juego".
|
||||||
|
DISCORD_DETECT = "\\#ffa0a0\\Error:\\#c8c8c8\\ No se pudo detectar Discord.\n\\#a0a0a0\\Intente cerrar el juego, reiniciar Discord y volver a abrir el juego".
|
||||||
|
DISCONNECT_FULL = "\\#ffa0a0\\Desconectado:\\#c8c8c8\\ La fiesta está llena."
|
||||||
|
DISCONNECT_KICK = "\\#ffa0a0\\Desconectado:\\#c8c8c8\\ El servidor te expulsó".
|
||||||
|
DISCONNECT_BAN = "\\#ffa0a0\\Desconectado:\\#c8c8c8\\ El servidor te prohibió."
|
||||||
|
DISCONNECT_REJOIN = "\\#ffa0a0\\Desconectado:\\#c8c8c8\\ Reuniéndose..."
|
||||||
|
DISCONNECT_CLOSED = "\\#ffa0a0\\Desconectado:\\#c8c8c8\\ Host ha cerrado la conexión".
|
||||||
|
DISCONNECT_BIG_MOD = "El servidor tenía un mod demasiado grande.\nSaliendo".
|
||||||
|
DIED = "@ murió"
|
||||||
|
DEBUG_FLY = "@ entró en el estado de vuelo libre de depuración"
|
||||||
|
|
||||||
|
[CHAT]
|
||||||
|
KICKING = "¡Patadas a '@'!"
|
||||||
|
BANNING = "¡Prohibición de '@'!"
|
||||||
|
SERVER_ONLY = "Solo el servidor puede usar este comando".
|
||||||
|
PERM_BANNING = "¡Prohibición permanente de '@'!"
|
||||||
|
ADD_MODERATOR = "¡Añadiendo '@' como moderador!"
|
||||||
|
PLAYERS = "Jugadores"
|
||||||
|
NO_PERMS = "No tiene permiso para usar este comando".
|
||||||
|
PLAYER_NOT_FOUND = "No se pudo encontrar el jugador".
|
||||||
|
SELF_KICK = "No puedes patearte a ti mismo".
|
||||||
|
SELF_BAN = "No puedes banearte a ti mismo".
|
||||||
|
SELF_MOD = "No puedes convertirte en moderador".
|
||||||
|
KICK_CONFIRM = "¿Estás seguro de que quieres patear a '@'?\nEscribe '\\#a0ffa0\\/confirm\\#fff982\\' para patear."
|
||||||
|
BAN_CONFIRM = "¿Está seguro de que desea prohibir a '@'?\nEscriba '\\#a0ffa0\\/confirm\\#fff982\\' para prohibir".
|
||||||
|
PERM_BAN_CONFIRM = "¿Está seguro de que desea prohibir permanentemente a '@'?\nEscriba '\\#a0ffa0\\/confirm\\#fff982\\' para prohibir".
|
||||||
|
MOD_CONFIRM = "¿Está seguro de que desea convertir a '@' en moderador?\nEscriba '\\#a0ffa0\\/confirm\\#fff982\\'".
|
||||||
|
PLAYERS_DESC = "/players - Lista de todos los jugadores y sus ID"
|
||||||
|
KICK_DESC = "/kick [NOMBRE|ID] - Expulsa a este jugador del juego actual"
|
||||||
|
BAN_DESC = "/ban [NOMBRE|ID] - Prohibir a este jugador del juego actual"
|
||||||
|
PERM_BAN_DESC = "/permban [NOMBRE|ID] - Bloquea a este jugador de cualquier juego que organices"
|
||||||
|
MOD_DESC = "/moderator [NOMBRE|ID] - Haz que este jugador pueda usar comandos como /kick, /ban, /permban en cualquier juego que organices"
|
||||||
|
UNRECOGNIZED = "Comando de chat no reconocido".
|
||||||
|
MOD_GRANTED = "\\#fff982\\Ahora eres moderador".
|
||||||
|
|
||||||
[MENU]
|
[MENU]
|
||||||
BACK = "Atrás"
|
BACK = "Atrás"
|
||||||
CANCEL = "Cancelar"
|
CANCEL = "Cancelar"
|
||||||
|
|
@ -97,7 +139,7 @@ HOST = "Anfitrión"
|
||||||
|
|
||||||
[HOST_MODS]
|
[HOST_MODS]
|
||||||
ROMHACKS = "ROMHACKS"
|
ROMHACKS = "ROMHACKS"
|
||||||
MODS = "MODIFICACIONES"
|
MODS = "MODS"
|
||||||
|
|
||||||
[HOST_SAVE]
|
[HOST_SAVE]
|
||||||
SAVE_TITLE = "AHORRAR"
|
SAVE_TITLE = "AHORRAR"
|
||||||
|
|
@ -177,7 +219,7 @@ MENU_OPTIONS = "Opciones de menú"
|
||||||
DEBUG = "Depurar"
|
DEBUG = "Depurar"
|
||||||
|
|
||||||
[MODLIST]
|
[MODLIST]
|
||||||
MODS = "MODIFICACIONES"
|
MODS = "MODS"
|
||||||
|
|
||||||
[OPTIONS]
|
[OPTIONS]
|
||||||
OPTIONS = "OPCIONES"
|
OPTIONS = "OPCIONES"
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
#include "pc/network/network.h"
|
#include "pc/network/network.h"
|
||||||
#include "pc/network/socket/socket.h"
|
#include "pc/network/socket/socket.h"
|
||||||
#include "pc/lua/smlua_hooks.h"
|
#include "pc/lua/smlua_hooks.h"
|
||||||
|
#include "pc/djui/djui_language.h"
|
||||||
#include "pc/djui/djui_chat_message.h"
|
#include "pc/djui/djui_chat_message.h"
|
||||||
#include "chat_commands.h"
|
#include "chat_commands.h"
|
||||||
#include "pc/network/ban_list.h"
|
#include "pc/network/ban_list.h"
|
||||||
|
|
@ -41,6 +42,16 @@ static bool str_starts_with(const char* pre, char* str) {
|
||||||
return strncmp(pre, str, strlen(pre)) == 0;
|
return strncmp(pre, str, strlen(pre)) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void chat_construct_player_message(struct NetworkPlayer* np, char* msg) {
|
||||||
|
char built[256] = { 0 };
|
||||||
|
snprintf(built, 256, "\\#fff982\\");
|
||||||
|
|
||||||
|
char player[128] = { 0 };
|
||||||
|
snprintf(player, 128, "%s%s\\#fff982\\", network_get_player_text_color_string(np->localIndex), np->name);
|
||||||
|
djui_language_replace(msg, &built[9], 256 - 9, '@', player);
|
||||||
|
djui_chat_message_create(built);
|
||||||
|
}
|
||||||
|
|
||||||
bool exec_chat_command(char* command) {
|
bool exec_chat_command(char* command) {
|
||||||
enum ChatConfirmCommand ccc = sConfirming;
|
enum ChatConfirmCommand ccc = sConfirming;
|
||||||
sConfirming = CCC_NONE;
|
sConfirming = CCC_NONE;
|
||||||
|
|
@ -50,9 +61,7 @@ bool exec_chat_command(char* command) {
|
||||||
if (ccc == CCC_KICK) {
|
if (ccc == CCC_KICK) {
|
||||||
struct NetworkPlayer* np = &gNetworkPlayers[sConfirmPlayerIndex];
|
struct NetworkPlayer* np = &gNetworkPlayers[sConfirmPlayerIndex];
|
||||||
if (!np->connected) { return true; }
|
if (!np->connected) { return true; }
|
||||||
char message[256] = { 0 };
|
chat_construct_player_message(np, DLANG(CHAT, KICKING));
|
||||||
snprintf(message, 256, "\\#fff982\\Kicking '%s%s\\#fff982\\'!", network_get_player_text_color_string(np->localIndex), np->name);
|
|
||||||
djui_chat_message_create(message);
|
|
||||||
if (gNetworkType == NT_SERVER) {
|
if (gNetworkType == NT_SERVER) {
|
||||||
network_send_kick(np->localIndex, EKT_KICKED);
|
network_send_kick(np->localIndex, EKT_KICKED);
|
||||||
network_player_disconnected(np->localIndex);
|
network_player_disconnected(np->localIndex);
|
||||||
|
|
@ -66,9 +75,7 @@ bool exec_chat_command(char* command) {
|
||||||
if (ccc == CCC_BAN) {
|
if (ccc == CCC_BAN) {
|
||||||
struct NetworkPlayer* np = &gNetworkPlayers[sConfirmPlayerIndex];
|
struct NetworkPlayer* np = &gNetworkPlayers[sConfirmPlayerIndex];
|
||||||
if (!np->connected) { return true; }
|
if (!np->connected) { return true; }
|
||||||
char message[256] = { 0 };
|
chat_construct_player_message(np, DLANG(CHAT, BANNING));
|
||||||
snprintf(message, 256, "\\#fff982\\Banning '%s%s\\#fff982\\'!", network_get_player_text_color_string(np->localIndex), np->name);
|
|
||||||
djui_chat_message_create(message);
|
|
||||||
if (gNetworkType == NT_SERVER) {
|
if (gNetworkType == NT_SERVER) {
|
||||||
network_send_kick(np->localIndex, EKT_BANNED);
|
network_send_kick(np->localIndex, EKT_BANNED);
|
||||||
ban_list_add(gNetworkSystem->get_id_str(np->localIndex), false);
|
ban_list_add(gNetworkSystem->get_id_str(np->localIndex), false);
|
||||||
|
|
@ -82,9 +89,7 @@ bool exec_chat_command(char* command) {
|
||||||
if (gNetworkType == NT_SERVER && ccc == CCC_PERMBAN) {
|
if (gNetworkType == NT_SERVER && ccc == CCC_PERMBAN) {
|
||||||
struct NetworkPlayer* np = &gNetworkPlayers[sConfirmPlayerIndex];
|
struct NetworkPlayer* np = &gNetworkPlayers[sConfirmPlayerIndex];
|
||||||
if (!np->connected) { return true; }
|
if (!np->connected) { return true; }
|
||||||
char message[256] = { 0 };
|
chat_construct_player_message(np, DLANG(CHAT, PERM_BANNING));
|
||||||
snprintf(message, 256, "\\#fff982\\Permanently banning '%s%s\\#fff982\\'!", network_get_player_text_color_string(np->localIndex), np->name);
|
|
||||||
djui_chat_message_create(message);
|
|
||||||
network_send_kick(np->localIndex, EKT_BANNED);
|
network_send_kick(np->localIndex, EKT_BANNED);
|
||||||
ban_list_add(gNetworkSystem->get_id_str(np->localIndex), true);
|
ban_list_add(gNetworkSystem->get_id_str(np->localIndex), true);
|
||||||
network_player_disconnected(np->localIndex);
|
network_player_disconnected(np->localIndex);
|
||||||
|
|
@ -93,9 +98,7 @@ bool exec_chat_command(char* command) {
|
||||||
if (gNetworkType == NT_SERVER && ccc == CCC_MODERATOR) {
|
if (gNetworkType == NT_SERVER && ccc == CCC_MODERATOR) {
|
||||||
struct NetworkPlayer* np = &gNetworkPlayers[sConfirmPlayerIndex];
|
struct NetworkPlayer* np = &gNetworkPlayers[sConfirmPlayerIndex];
|
||||||
if (!np->connected) { return true; }
|
if (!np->connected) { return true; }
|
||||||
char message[256] = { 0 };
|
chat_construct_player_message(np, DLANG(CHAT, ADD_MODERATOR));
|
||||||
snprintf(message, 256, "\\#fff982\\Adding '%s%s\\#fff982\\' as a Moderator!", network_get_player_text_color_string(np->localIndex), np->name);
|
|
||||||
djui_chat_message_create(message);
|
|
||||||
network_send_moderator(np->localIndex);
|
network_send_moderator(np->localIndex);
|
||||||
moderator_list_add(gNetworkSystem->get_id_str(np->localIndex), true);
|
moderator_list_add(gNetworkSystem->get_id_str(np->localIndex), true);
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -104,7 +107,7 @@ bool exec_chat_command(char* command) {
|
||||||
|
|
||||||
if (strcmp("/players", command) == 0) {
|
if (strcmp("/players", command) == 0) {
|
||||||
char line[128] = { 0 };
|
char line[128] = { 0 };
|
||||||
strncat(line, "\\#fff982\\Players:\n", 127);
|
snprintf(line, 127, "\\#fff982\\%s:\n", DLANG(CHAT, PLAYERS));
|
||||||
djui_chat_message_create(line);
|
djui_chat_message_create(line);
|
||||||
for (s32 i = 0; i < MAX_PLAYERS; i++) {
|
for (s32 i = 0; i < MAX_PLAYERS; i++) {
|
||||||
struct NetworkPlayer* np = &gNetworkPlayers[i];
|
struct NetworkPlayer* np = &gNetworkPlayers[i];
|
||||||
|
|
@ -121,25 +124,21 @@ bool exec_chat_command(char* command) {
|
||||||
|
|
||||||
if (str_starts_with("/kick ", command)) {
|
if (str_starts_with("/kick ", command)) {
|
||||||
if (gNetworkType != NT_SERVER && !gIsModerator) {
|
if (gNetworkType != NT_SERVER && !gIsModerator) {
|
||||||
djui_chat_message_create("You do not have permission to use this command.");
|
djui_chat_message_create(DLANG(CHAT, NO_PERMS));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct NetworkPlayer* np = chat_get_network_player(&command[6]);
|
struct NetworkPlayer* np = chat_get_network_player(&command[6]);
|
||||||
if (np == NULL) {
|
if (np == NULL) {
|
||||||
djui_chat_message_create("Could not find player.");
|
djui_chat_message_create(DLANG(CHAT, PLAYER_NOT_FOUND));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (np->localIndex == 0) {
|
if (np->localIndex == 0) {
|
||||||
djui_chat_message_create("Can not kick yourself.");
|
djui_chat_message_create(DLANG(CHAT, SELF_KICK));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
chat_construct_player_message(np, DLANG(CHAT, KICK_CONFIRM));
|
||||||
char message[256] = { 0 };
|
|
||||||
snprintf(message, 256, "\\#fff982\\Are you sure you want to kick '%s%s\\#fff982\\'?\nType '\\#a0ffa0\\/confirm\\#fff982\\' to kick.", network_get_player_text_color_string(np->localIndex), np->name);
|
|
||||||
djui_chat_message_create(message);
|
|
||||||
|
|
||||||
sConfirming = CCC_KICK;
|
sConfirming = CCC_KICK;
|
||||||
sConfirmPlayerIndex = np->localIndex;
|
sConfirmPlayerIndex = np->localIndex;
|
||||||
|
|
||||||
|
|
@ -148,25 +147,21 @@ bool exec_chat_command(char* command) {
|
||||||
|
|
||||||
if (str_starts_with("/ban ", command)) {
|
if (str_starts_with("/ban ", command)) {
|
||||||
if (gNetworkType != NT_SERVER && !gIsModerator) {
|
if (gNetworkType != NT_SERVER && !gIsModerator) {
|
||||||
djui_chat_message_create("You do not have permission to use this command.");
|
djui_chat_message_create(DLANG(CHAT, NO_PERMS));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct NetworkPlayer* np = chat_get_network_player(&command[5]);
|
struct NetworkPlayer* np = chat_get_network_player(&command[5]);
|
||||||
if (np == NULL) {
|
if (np == NULL) {
|
||||||
djui_chat_message_create("Could not find player.");
|
djui_chat_message_create(DLANG(CHAT, PLAYER_NOT_FOUND));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (np->localIndex == 0) {
|
if (np->localIndex == 0) {
|
||||||
djui_chat_message_create("Can not ban yourself.");
|
djui_chat_message_create(DLANG(CHAT, SELF_BAN));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
chat_construct_player_message(np, DLANG(CHAT, BAN_CONFIRM));
|
||||||
char message[256] = { 0 };
|
|
||||||
snprintf(message, 256, "\\#fff982\\Are you sure you want to ban '%s%s\\#fff982\\'?\nType '\\#a0ffa0\\/confirm\\#fff982\\' to ban.", network_get_player_text_color_string(np->localIndex), np->name);
|
|
||||||
djui_chat_message_create(message);
|
|
||||||
|
|
||||||
sConfirming = CCC_BAN;
|
sConfirming = CCC_BAN;
|
||||||
sConfirmPlayerIndex = np->localIndex;
|
sConfirmPlayerIndex = np->localIndex;
|
||||||
|
|
||||||
|
|
@ -175,25 +170,21 @@ bool exec_chat_command(char* command) {
|
||||||
|
|
||||||
if (str_starts_with("/permban ", command)) {
|
if (str_starts_with("/permban ", command)) {
|
||||||
if (gNetworkType != NT_SERVER && !gIsModerator) {
|
if (gNetworkType != NT_SERVER && !gIsModerator) {
|
||||||
djui_chat_message_create("You do not have permission to use this command.");
|
djui_chat_message_create(DLANG(CHAT, NO_PERMS));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct NetworkPlayer* np = chat_get_network_player(&command[9]);
|
struct NetworkPlayer* np = chat_get_network_player(&command[9]);
|
||||||
if (np == NULL) {
|
if (np == NULL) {
|
||||||
djui_chat_message_create("Could not find player.");
|
djui_chat_message_create(DLANG(CHAT, PLAYER_NOT_FOUND));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (np->localIndex == 0) {
|
if (np->localIndex == 0) {
|
||||||
djui_chat_message_create("Can not permanently ban yourself.");
|
djui_chat_message_create(DLANG(CHAT, SELF_BAN));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
chat_construct_player_message(np, DLANG(CHAT, PERM_BAN_CONFIRM));
|
||||||
char message[256] = { 0 };
|
|
||||||
snprintf(message, 256, "\\#fff982\\Are you sure you want to permanently ban '%s%s\\#fff982\\'?\nType '\\#a0ffa0\\/confirm\\#fff982\\' to permanently ban.", network_get_player_text_color_string(np->localIndex), np->name);
|
|
||||||
djui_chat_message_create(message);
|
|
||||||
|
|
||||||
sConfirming = CCC_PERMBAN;
|
sConfirming = CCC_PERMBAN;
|
||||||
sConfirmPlayerIndex = np->localIndex;
|
sConfirmPlayerIndex = np->localIndex;
|
||||||
|
|
||||||
|
|
@ -202,25 +193,21 @@ bool exec_chat_command(char* command) {
|
||||||
|
|
||||||
if (str_starts_with("/moderator ", command)) {
|
if (str_starts_with("/moderator ", command)) {
|
||||||
if (gNetworkType != NT_SERVER) {
|
if (gNetworkType != NT_SERVER) {
|
||||||
djui_chat_message_create("Only the server can use this command.");
|
djui_chat_message_create(DLANG(CHAT, SERVER_ONLY));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct NetworkPlayer* np = chat_get_network_player(&command[11]);
|
struct NetworkPlayer* np = chat_get_network_player(&command[11]);
|
||||||
if (np == NULL) {
|
if (np == NULL) {
|
||||||
djui_chat_message_create("Could not find player.");
|
djui_chat_message_create(DLANG(CHAT, PLAYER_NOT_FOUND));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (np->localIndex == 0) {
|
if (np->localIndex == 0) {
|
||||||
djui_chat_message_create("Can not make yourself a moderator.");
|
djui_chat_message_create(DLANG(CHAT, SELF_MOD));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
chat_construct_player_message(np, DLANG(CHAT, MOD_CONFIRM));
|
||||||
char message[256] = { 0 };
|
|
||||||
snprintf(message, 256, "\\#fff982\\Are you sure you want to make '%s%s\\#fff982\\' a moderator?\nType '\\#a0ffa0\\/confirm\\#fff982\\' to moderate.", network_get_player_text_color_string(np->localIndex), np->name);
|
|
||||||
djui_chat_message_create(message);
|
|
||||||
|
|
||||||
sConfirming = CCC_MODERATOR;
|
sConfirming = CCC_MODERATOR;
|
||||||
sConfirmPlayerIndex = np->localIndex;
|
sConfirmPlayerIndex = np->localIndex;
|
||||||
|
|
||||||
|
|
@ -328,12 +315,12 @@ bool exec_chat_command(char* command) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void display_chat_commands(void) {
|
void display_chat_commands(void) {
|
||||||
djui_chat_message_create("/players - List all players and their IDs");
|
djui_chat_message_create(DLANG(CHAT, PLAYERS_DESC));
|
||||||
if (gNetworkType == NT_SERVER || gIsModerator) {
|
if (gNetworkType == NT_SERVER || gIsModerator) {
|
||||||
djui_chat_message_create("/kick [NAME|ID] - Kick this player from the current game");
|
djui_chat_message_create(DLANG(CHAT, KICK_DESC));
|
||||||
djui_chat_message_create("/ban [NAME|ID] - Ban this player from the current game");
|
djui_chat_message_create(DLANG(CHAT, BAN_DESC));
|
||||||
djui_chat_message_create("/permban [NAME|ID] - Ban this player from any game you host");
|
djui_chat_message_create(DLANG(CHAT, PERM_BAN_DESC));
|
||||||
djui_chat_message_create("/moderator [NAME|ID] - Make this player able to use commands like /kick, /ban, /permban on any game you host");
|
djui_chat_message_create(DLANG(CHAT, MOD_DESC));
|
||||||
}
|
}
|
||||||
#if defined(DEVELOPMENT)
|
#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("/warp [LEVEL] [AREA] [ACT] - Level can be either a numeric value or a shorthand name");
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ static void djui_chat_box_input_enter(struct DjuiInputbox* chatInput) {
|
||||||
if (strlen(chatInput->buffer) != 0) {
|
if (strlen(chatInput->buffer) != 0) {
|
||||||
if (chatInput->buffer[0] == '/') {
|
if (chatInput->buffer[0] == '/') {
|
||||||
if (!exec_chat_command(chatInput->buffer)) {
|
if (!exec_chat_command(chatInput->buffer)) {
|
||||||
djui_chat_message_create("Unrecognized chat command.");
|
djui_chat_message_create(DLANG(CHAT, UNRECOGNIZED));
|
||||||
display_chat_commands();
|
display_chat_commands();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -16,4 +16,38 @@ char* djui_language_get(const char *section, const char *key) {
|
||||||
char* value = (char*)ini_get(sLang, section, key);
|
char* value = (char*)ini_get(sLang, section, key);
|
||||||
if (!value) { return "???"; }
|
if (!value) { return "???"; }
|
||||||
return value;
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
void djui_language_replace(char* src, char* dst, int size, char key, char* value) {
|
||||||
|
char tmpChar[10] = { 0 };
|
||||||
|
char* c = src;
|
||||||
|
char* o = dst;
|
||||||
|
while (*c != '\0') {
|
||||||
|
if (*c == key) {
|
||||||
|
snprintf(o, size - (o - dst), "%s", value);
|
||||||
|
} else {
|
||||||
|
djui_unicode_get_char(c, tmpChar);
|
||||||
|
snprintf(o, size - (o - dst), "%s", tmpChar);
|
||||||
|
}
|
||||||
|
o = &dst[strlen(dst)];
|
||||||
|
c = djui_unicode_next_char(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void djui_language_replace2(char* src, char* dst, int size, char key1, char* value1, char key2, char* value2) {
|
||||||
|
char tmpChar[10] = { 0 };
|
||||||
|
char* c = src;
|
||||||
|
char* o = dst;
|
||||||
|
while (*c != '\0') {
|
||||||
|
if (*c == key1) {
|
||||||
|
snprintf(o, size - (o - dst), "%s", value1);
|
||||||
|
} else if (*c == key2) {
|
||||||
|
snprintf(o, size - (o - dst), "%s", value2);
|
||||||
|
} else {
|
||||||
|
djui_unicode_get_char(c, tmpChar);
|
||||||
|
snprintf(o, size - (o - dst), "%s", tmpChar);
|
||||||
|
}
|
||||||
|
o = &dst[strlen(dst)];
|
||||||
|
c = djui_unicode_next_char(c);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -3,3 +3,5 @@
|
||||||
|
|
||||||
void djui_language_init(char* filename);
|
void djui_language_init(char* filename);
|
||||||
char* djui_language_get(const char *section, const char *key);
|
char* djui_language_get(const char *section, const char *key);
|
||||||
|
void djui_language_replace(char* src, char* dst, int size, char key, char* value);
|
||||||
|
void djui_language_replace2(char* src, char* dst, int size, char key1, char* value1, char key2, char* value2);
|
||||||
|
|
|
||||||
|
|
@ -30,7 +30,7 @@ static void discord_sdk_log_callback(UNUSED void* hook_data, enum EDiscordLogLev
|
||||||
|
|
||||||
void discord_fatal_message(int rc) { // Discord usually does this because of loss of connection to Discord
|
void discord_fatal_message(int rc) { // Discord usually does this because of loss of connection to Discord
|
||||||
char errorMessage[132] = { 0 };
|
char errorMessage[132] = { 0 };
|
||||||
snprintf(errorMessage, 132, "Discord threw an error.\nTo fix, try: \n1. Close the game.\n2. Restart Discord.\n3. Start the game.\nRC: %d", rc);
|
snprintf(errorMessage, 132, "%s\nRC: %d", DLANG(NOTIF, DISCORD_ERROR), rc);
|
||||||
djui_popup_create(errorMessage, 6);
|
djui_popup_create(errorMessage, 6);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -142,7 +142,7 @@ static bool ns_discord_initialize(enum NetworkType networkType) {
|
||||||
DISCORD_REQUIRE(rc);
|
DISCORD_REQUIRE(rc);
|
||||||
} else if (rc) {
|
} else if (rc) {
|
||||||
LOGFILE_ERROR(LFT_DISCORD, "DiscordCreate failed: %d", rc);
|
LOGFILE_ERROR(LFT_DISCORD, "DiscordCreate failed: %d", rc);
|
||||||
djui_popup_create("\\#ffa0a0\\Error:\\#c8c8c8\\ Could not detect Discord.\n\\#a0a0a0\\Try closing the game, restarting Discord, and opening the game again.", 3);
|
djui_popup_create(DLANG(NOTIF, DISCORD_DETECT), 3);
|
||||||
gDiscordFailed = true;
|
gDiscordFailed = true;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -300,10 +300,7 @@ u8 network_player_connected(enum NetworkPlayerType type, u8 globalIndex, u8 mode
|
||||||
|
|
||||||
// display connected popup
|
// display connected popup
|
||||||
if (!gCurrentlyJoining && type != NPT_SERVER && (gNetworkType != NT_SERVER || type != NPT_LOCAL)) {
|
if (!gCurrentlyJoining && type != NPT_SERVER && (gNetworkType != NT_SERVER || type != NPT_LOCAL)) {
|
||||||
char *playerColorString = network_get_player_text_color_string(np->localIndex);
|
construct_player_popup(np, DLANG(NOTIF, CONNECTED), NULL);
|
||||||
char popupMsg[128] = { 0 };
|
|
||||||
snprintf(popupMsg, 128, "%s%s\\#dcdcdc\\ connected", playerColorString, np->name);
|
|
||||||
djui_popup_create(popupMsg, 1);
|
|
||||||
}
|
}
|
||||||
LOG_INFO("player connected, local %d, global %d", localIndex, np->globalIndex);
|
LOG_INFO("player connected, local %d, global %d", localIndex, np->globalIndex);
|
||||||
|
|
||||||
|
|
@ -350,10 +347,7 @@ u8 network_player_disconnected(u8 globalIndex) {
|
||||||
LOG_INFO("player disconnected, local %d, global %d", i, globalIndex);
|
LOG_INFO("player disconnected, local %d, global %d", i, globalIndex);
|
||||||
|
|
||||||
// display popup
|
// display popup
|
||||||
char *playerColorString = network_get_player_text_color_string(np->localIndex);
|
construct_player_popup(np, DLANG(NOTIF, DISCONNECTED), NULL);
|
||||||
char popupMsg[128] = { 0 };
|
|
||||||
snprintf(popupMsg, 128, "%s%s\\#dcdcdc\\ disconnected", playerColorString, np->name);
|
|
||||||
djui_popup_create(popupMsg, 1);
|
|
||||||
|
|
||||||
packet_ordered_clear(globalIndex);
|
packet_ordered_clear(globalIndex);
|
||||||
|
|
||||||
|
|
@ -366,6 +360,20 @@ u8 network_player_disconnected(u8 globalIndex) {
|
||||||
return UNKNOWN_GLOBAL_INDEX;
|
return UNKNOWN_GLOBAL_INDEX;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void construct_player_popup(struct NetworkPlayer* np, char* msg, const char* level) {
|
||||||
|
char built[256] = { 0 };
|
||||||
|
snprintf(built, 256, "\\#dcdcdc\\");
|
||||||
|
|
||||||
|
char player[128] = { 0 };
|
||||||
|
snprintf(player, 128, "%s%s\\#dcdcdc\\", network_get_player_text_color_string(np->localIndex), np->name);
|
||||||
|
if (level) {
|
||||||
|
djui_language_replace2(msg, &built[9], 256 - 9, '@', player, '#', (char*)level);
|
||||||
|
} else {
|
||||||
|
djui_language_replace(msg, &built[9], 256 - 9, '@', player);
|
||||||
|
}
|
||||||
|
djui_popup_create(built, 1);
|
||||||
|
}
|
||||||
|
|
||||||
void network_player_update_course_level(struct NetworkPlayer* np, s16 courseNum, s16 actNum, s16 levelNum, s16 areaIndex) {
|
void network_player_update_course_level(struct NetworkPlayer* np, s16 courseNum, s16 actNum, s16 levelNum, s16 areaIndex) {
|
||||||
// prevent sync valid packets from corrupting areaIndex
|
// prevent sync valid packets from corrupting areaIndex
|
||||||
if (areaIndex == -1) {
|
if (areaIndex == -1) {
|
||||||
|
|
@ -374,23 +382,16 @@ void network_player_update_course_level(struct NetworkPlayer* np, s16 courseNum,
|
||||||
|
|
||||||
// display popup
|
// display popup
|
||||||
bool inCredits = (np->currActNum == 99);
|
bool inCredits = (np->currActNum == 99);
|
||||||
|
|
||||||
if (np->currCourseNum != courseNum && np->localIndex != 0 && !inCredits) {
|
if (np->currCourseNum != courseNum && np->localIndex != 0 && !inCredits) {
|
||||||
char *playerColorString = network_get_player_text_color_string(np->localIndex);
|
|
||||||
char popupMsg[128] = { 0 };
|
|
||||||
bool matchingLocal = (np->currCourseNum == gNetworkPlayerLocal->currCourseNum) && (np->currActNum == gNetworkPlayerLocal->currActNum);
|
bool matchingLocal = (np->currCourseNum == gNetworkPlayerLocal->currCourseNum) && (np->currActNum == gNetworkPlayerLocal->currActNum);
|
||||||
|
|
||||||
if (matchingLocal && gNetworkPlayerLocal->currCourseNum != 0) {
|
if (matchingLocal && gNetworkPlayerLocal->currCourseNum != 0) {
|
||||||
snprintf(popupMsg, 128, "%s%s\\#dcdcdc\\ left this level", playerColorString, np->name);
|
construct_player_popup(np, DLANG(NOTIF, LEFT_THIS_LEVEL), NULL);
|
||||||
} else if (matchingLocal && gNetworkPlayerLocal->currCourseNum != 0) {
|
} else if (matchingLocal && gNetworkPlayerLocal->currCourseNum != 0) {
|
||||||
snprintf(popupMsg, 128, "%s%s\\#dcdcdc\\ entered this level", playerColorString, np->name);
|
construct_player_popup(np, DLANG(NOTIF, ENTERED_THIS_LEVEL), NULL);
|
||||||
} else {
|
} else {
|
||||||
snprintf(popupMsg, 128, "%s%s\\#dcdcdc\\ entered\n%s", playerColorString, np->name, get_level_name(courseNum, levelNum, areaIndex));
|
construct_player_popup(np, DLANG(NOTIF, ENTERED), get_level_name(courseNum, levelNum, areaIndex));
|
||||||
}
|
|
||||||
|
|
||||||
// display popup
|
|
||||||
if (configDisablePopups == 0) {
|
|
||||||
djui_popup_create(popupMsg, 1);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -446,6 +447,6 @@ void network_player_shutdown(bool popup) {
|
||||||
gNetworkSystem->clear_id(i);
|
gNetworkSystem->clear_id(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (popup) { djui_popup_create("\\#ffa0a0\\Disconnected:\\#dcdcdc\\ server closed", 1); }
|
if (popup) { djui_popup_create(DLANG(NOTIF, SERVER_CLOSED), 1); }
|
||||||
LOG_INFO("cleared all network players");
|
LOG_INFO("cleared all network players");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -83,6 +83,7 @@ void network_player_update(void);
|
||||||
|
|
||||||
u8 network_player_connected(enum NetworkPlayerType type, u8 globalIndex, u8 modelIndex, const struct PlayerPalette* playerPalette, char* name);
|
u8 network_player_connected(enum NetworkPlayerType type, u8 globalIndex, u8 modelIndex, const struct PlayerPalette* playerPalette, char* name);
|
||||||
u8 network_player_disconnected(u8 globalIndex);
|
u8 network_player_disconnected(u8 globalIndex);
|
||||||
|
void construct_player_popup(struct NetworkPlayer* np, char* msg, const char* level);
|
||||||
|
|
||||||
void network_player_update_course_level(struct NetworkPlayer* np, s16 courseNum, s16 actNum, s16 levelNum, s16 areaIndex);
|
void network_player_update_course_level(struct NetworkPlayer* np, s16 courseNum, s16 actNum, s16 levelNum, s16 areaIndex);
|
||||||
void network_player_shutdown(bool popup);
|
void network_player_shutdown(bool popup);
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include "../network.h"
|
#include "../network.h"
|
||||||
|
#include "pc/djui/djui_language.h"
|
||||||
#include "pc/djui/djui_chat_message.h"
|
#include "pc/djui/djui_chat_message.h"
|
||||||
#include "pc/network/ban_list.h"
|
#include "pc/network/ban_list.h"
|
||||||
#include "pc/network/moderator_list.h"
|
#include "pc/network/moderator_list.h"
|
||||||
|
|
@ -64,5 +65,5 @@ void network_recieve_moderator(struct Packet *p) {
|
||||||
}
|
}
|
||||||
|
|
||||||
gIsModerator = true;
|
gIsModerator = true;
|
||||||
djui_chat_message_create("\\#fff982\\You are now a Moderator.");
|
djui_chat_message_create(DLANG(CHAT, MOD_GRANTED));
|
||||||
}
|
}
|
||||||
|
|
@ -31,11 +31,11 @@ void network_receive_kick(struct Packet* p) {
|
||||||
enum KickReasonType kickReason = kickReasonType;
|
enum KickReasonType kickReason = kickReasonType;
|
||||||
|
|
||||||
switch (kickReason) {
|
switch (kickReason) {
|
||||||
case EKT_FULL_PARTY: djui_popup_create("\\#ffa0a0\\Disconnected:\\#c8c8c8\\ The party is full.", 1); break;
|
case EKT_FULL_PARTY: djui_popup_create(DLANG(NOTIF, DISCONNECT_FULL), 1); break;
|
||||||
case EKT_KICKED: djui_popup_create("\\#ffa0a0\\Disconnected:\\#c8c8c8\\ The server kicked you.", 1); break;
|
case EKT_KICKED: djui_popup_create(DLANG(NOTIF, DISCONNECT_KICK), 1); break;
|
||||||
case EKT_BANNED: djui_popup_create("\\#ffa0a0\\Disconnected:\\#c8c8c8\\ The server banned you.", 1); break;
|
case EKT_BANNED: djui_popup_create(DLANG(NOTIF, DISCONNECT_BAN), 1); break;
|
||||||
case EKT_REJOIN: djui_popup_create("\\#ffa0a0\\Disconnected:\\#c8c8c8\\ Rejoining...", 1); break;
|
case EKT_REJOIN: djui_popup_create(DLANG(NOTIF, DISCONNECT_REJOIN), 1); break;
|
||||||
default: djui_popup_create("\\#ffa0a0\\Disconnected:\\#c8c8c8\\ Host has closed the connection.", 1); break;
|
default: djui_popup_create(DLANG(NOTIF, DISCONNECT_CLOSED), 1); break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (kickReason == EKT_REJOIN) {
|
if (kickReason == EKT_REJOIN) {
|
||||||
|
|
|
||||||
|
|
@ -236,7 +236,7 @@ void network_receive_mod_list_entry(struct Packet* p) {
|
||||||
|
|
||||||
// sanity check mod size
|
// sanity check mod size
|
||||||
if (mod->size >= MAX_MOD_SIZE) {
|
if (mod->size >= MAX_MOD_SIZE) {
|
||||||
djui_popup_create("Server had too large of a mod.\nQuitting.", 4);
|
djui_popup_create(DLANG(NOTIF, DISCONNECT_BIG_MOD), 4);
|
||||||
network_shutdown(false, false, false);
|
network_shutdown(false, false, false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@
|
||||||
#include "game/mario_misc.h"
|
#include "game/mario_misc.h"
|
||||||
#include "pc/configfile.h"
|
#include "pc/configfile.h"
|
||||||
#include "pc/djui/djui.h"
|
#include "pc/djui/djui.h"
|
||||||
|
#include "pc/djui/djui_language.h"
|
||||||
#include "pc/debuglog.h"
|
#include "pc/debuglog.h"
|
||||||
|
|
||||||
#pragma pack(1)
|
#pragma pack(1)
|
||||||
|
|
@ -362,13 +363,7 @@ void network_receive_player(struct Packet* p) {
|
||||||
|
|
||||||
// inform of player death
|
// inform of player death
|
||||||
if (oldData.action != ACT_BUBBLED && data.action == ACT_BUBBLED) {
|
if (oldData.action != ACT_BUBBLED && data.action == ACT_BUBBLED) {
|
||||||
// display popup
|
construct_player_popup(np, DLANG(NOTIF, DIED), NULL);
|
||||||
char* playerColorString = network_get_player_text_color_string(np->localIndex);
|
|
||||||
char popupMsg[128] = { 0 };
|
|
||||||
snprintf(popupMsg, 128, "%s%s\\#dcdcdc\\ died", playerColorString, np->name);
|
|
||||||
if (configDisablePopups == 0) {
|
|
||||||
djui_popup_create(popupMsg, 1);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// action changed, reset timer
|
// action changed, reset timer
|
||||||
|
|
@ -395,11 +390,7 @@ void network_receive_player(struct Packet* p) {
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if (m->action == ACT_DEBUG_FREE_MOVE && oldData.action != ACT_DEBUG_FREE_MOVE) {
|
if (m->action == ACT_DEBUG_FREE_MOVE && oldData.action != ACT_DEBUG_FREE_MOVE) {
|
||||||
char *playerColorString = network_get_player_text_color_string(np->localIndex);
|
construct_player_popup(np, DLANG(NOTIF, DEBUG_FLY), NULL);
|
||||||
char message[256];
|
|
||||||
snprintf(message, 256, "%s%s\\#dcdcdc\\ entered the debug free fly state", playerColorString, np->name);
|
|
||||||
djui_popup_create(message, 1);
|
|
||||||
LOG_INFO("%s entered the debug free fly state", np->name);
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue