mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2024-11-25 05:25:14 +00:00
Notify players where other players go with a popup
This commit is contained in:
parent
6a447c10f4
commit
777b9287e6
12 changed files with 201 additions and 201 deletions
|
@ -3863,6 +3863,7 @@
|
|||
<ClCompile Include="..\src\game\ingame_menu.c" />
|
||||
<ClCompile Include="..\src\game\interaction.c" />
|
||||
<ClCompile Include="..\src\game\level_geo.c" />
|
||||
<ClCompile Include="..\src\game\level_info.c" />
|
||||
<ClCompile Include="..\src\game\level_update.c" />
|
||||
<ClCompile Include="..\src\game\macro_presets.c" />
|
||||
<ClCompile Include="..\src\game\macro_special_objects.c" />
|
||||
|
@ -3963,6 +3964,7 @@
|
|||
<ClCompile Include="..\src\pc\djui\djui_panel_menu.c" />
|
||||
<ClCompile Include="..\src\pc\djui\djui_panel_pause.c" />
|
||||
<ClCompile Include="..\src\pc\djui\djui_panel_player.c" />
|
||||
<ClCompile Include="..\src\pc\djui\djui_panel_playerlist.c" />
|
||||
<ClCompile Include="..\src\pc\djui\djui_popup.c" />
|
||||
<ClCompile Include="..\src\pc\djui\djui_selectionbox.c" />
|
||||
<ClCompile Include="..\src\pc\djui\djui_cursor.c" />
|
||||
|
@ -4394,6 +4396,7 @@
|
|||
<ClInclude Include="..\include\behavior_table.h" />
|
||||
<ClInclude Include="..\include\luigi_audio_defines.h" />
|
||||
<ClInclude Include="..\src\game\characters.h" />
|
||||
<ClInclude Include="..\src\game\level_info.h" />
|
||||
<ClInclude Include="..\src\game\rng_position.h" />
|
||||
<ClInclude Include="..\src\pc\controller\controller_bind_mapping.h" />
|
||||
<ClInclude Include="..\src\pc\controller\controller_keyboard_debug.h" />
|
||||
|
@ -4416,6 +4419,7 @@
|
|||
<ClInclude Include="..\src\pc\djui\djui_panel_menu.h" />
|
||||
<ClInclude Include="..\src\pc\djui\djui_panel_pause.h" />
|
||||
<ClInclude Include="..\src\pc\djui\djui_panel_player.h" />
|
||||
<ClInclude Include="..\src\pc\djui\djui_panel_playerlist.h" />
|
||||
<ClInclude Include="..\src\pc\djui\djui_popup.h" />
|
||||
<ClInclude Include="..\src\pc\djui\djui_selectionbox.h" />
|
||||
<ClInclude Include="..\src\pc\djui\djui_cursor.h" />
|
||||
|
|
|
@ -15291,6 +15291,12 @@
|
|||
<ClCompile Include="..\src\pc\controller\controller_bind_mapping.c">
|
||||
<Filter>Source Files\src\pc\controller</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\pc\djui\djui_panel_playerlist.c">
|
||||
<Filter>Source Files\src\pc\djui\panel</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\src\game\level_info.c">
|
||||
<Filter>Source Files\src\game</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\actors\common0.h">
|
||||
|
@ -16393,5 +16399,11 @@
|
|||
<ClInclude Include="..\src\pc\controller\controller_bind_mapping.h">
|
||||
<Filter>Source Files\src\pc\controller</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\pc\djui\djui_panel_playerlist.h">
|
||||
<Filter>Source Files\src\pc\djui\panel</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\src\game\level_info.h">
|
||||
<Filter>Source Files\src\game</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
136
src/game/level_info.c
Normal file
136
src/game/level_info.c
Normal file
|
@ -0,0 +1,136 @@
|
|||
#include <stdbool.h>
|
||||
#include <string.h>
|
||||
#include "types.h"
|
||||
#include "level_info.h"
|
||||
#include "game/memory.h"
|
||||
|
||||
extern u8 seg2_course_name_table[];
|
||||
|
||||
static const char charset[0xFF + 1] = {
|
||||
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 7
|
||||
' ', ' ', 'a', 'b', 'c', 'd', 'e', 'f', // 15
|
||||
'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', // 23
|
||||
'o', 'p', 'q', 'r', 's', 't', 'u', 'v', // 31
|
||||
'w', 'x', 'y', 'z', ' ', ' ', ' ', ' ', // 39
|
||||
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 49
|
||||
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 55
|
||||
' ', ' ', ' ', ' ', ' ', ' ', '\'', ' ', // 63
|
||||
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 71
|
||||
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 79
|
||||
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 87
|
||||
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 95
|
||||
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 103
|
||||
' ', ' ', ' ', ' ', ' ', ' ', ' ', ',', // 111
|
||||
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 119
|
||||
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 127
|
||||
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 135
|
||||
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 143
|
||||
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 151
|
||||
' ', ' ', ' ', ' ', ' ', ' ', ' ', '-', // 159
|
||||
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 167
|
||||
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 175
|
||||
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 183
|
||||
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 192
|
||||
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 199
|
||||
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 207
|
||||
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 215
|
||||
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 223
|
||||
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 231
|
||||
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 239
|
||||
' ', ' ', '!', ' ', ' ', ' ', ' ', ' ', // 247
|
||||
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' // 255
|
||||
};
|
||||
|
||||
static void convert_string(const u8* str, char* output) {
|
||||
s32 strPos = 0;
|
||||
bool capitalizeChar = true;
|
||||
|
||||
while (str[strPos] != 0xFF) {
|
||||
if (str[strPos] < 0xFF) {
|
||||
output[strPos] = charset[str[strPos]];
|
||||
|
||||
// if the char is a letter we can capatalize it
|
||||
if (capitalizeChar && 0x0A <= str[strPos] && str[strPos] <= 0x23) {
|
||||
output[strPos] -= ('a' - 'A');
|
||||
capitalizeChar = false;
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
output[strPos] = ' ';
|
||||
}
|
||||
|
||||
// decide if the next character should be capitalized
|
||||
switch (output[strPos]) {
|
||||
case ' ':
|
||||
//if (str[strPos] != 158)
|
||||
//fprintf(stdout, "Unknown Character (%i)\n", str[strPos]); // inform that an unknown char was found
|
||||
case '-':
|
||||
capitalizeChar = true;
|
||||
break;
|
||||
default:
|
||||
capitalizeChar = false;
|
||||
break;
|
||||
}
|
||||
|
||||
strPos++;
|
||||
}
|
||||
|
||||
output[strPos] = '\0';
|
||||
}
|
||||
|
||||
const char* get_level_name(s16 courseNum, s16 levelNum, s16 areaIndex) {
|
||||
static char stage[188];
|
||||
// overrides for castle locations
|
||||
if (courseNum == 0 && levelNum == 16) {
|
||||
strcpy(stage, "Castle Grounds");
|
||||
return stage;
|
||||
}
|
||||
if (courseNum == 0 && levelNum == 6) {
|
||||
if (areaIndex == 1) {
|
||||
strcpy(stage, "Castle Main Floor");
|
||||
return stage;
|
||||
}
|
||||
else if (areaIndex == 2) {
|
||||
strcpy(stage, "Castle Upper Floor");
|
||||
return stage;
|
||||
}
|
||||
else if (areaIndex == 3) {
|
||||
strcpy(stage, "Castle Basement");
|
||||
return stage;
|
||||
}
|
||||
}
|
||||
if (courseNum == 0 && levelNum == 26) {
|
||||
strcpy(stage, "Castle Courtyard");
|
||||
return stage;
|
||||
}
|
||||
|
||||
// If we are in in Course 0 we are in the castle which doesn't have a string
|
||||
if (courseNum) {
|
||||
void** courseNameTbl;
|
||||
|
||||
#ifndef VERSION_EU
|
||||
courseNameTbl = segmented_to_virtual(seg2_course_name_table);
|
||||
#else
|
||||
switch (gInGameLanguage) {
|
||||
case LANGUAGE_ENGLISH:
|
||||
courseNameTbl = segmented_to_virtual(course_name_table_eu_en);
|
||||
break;
|
||||
case LANGUAGE_FRENCH:
|
||||
courseNameTbl = segmented_to_virtual(course_name_table_eu_fr);
|
||||
break;
|
||||
case LANGUAGE_GERMAN:
|
||||
courseNameTbl = segmented_to_virtual(course_name_table_eu_de);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
u8* courseName = segmented_to_virtual(courseNameTbl[courseNum - 1]);
|
||||
|
||||
convert_string(&courseName[3], stage);
|
||||
}
|
||||
else {
|
||||
strcpy(stage, "Peach's Castle");
|
||||
}
|
||||
|
||||
return stage;
|
||||
}
|
8
src/game/level_info.h
Normal file
8
src/game/level_info.h
Normal file
|
@ -0,0 +1,8 @@
|
|||
#ifndef LEVEL_INFO_H
|
||||
#define LEVEL_INFO_H
|
||||
|
||||
#include <PR\ultratypes.h>
|
||||
|
||||
const char* get_level_name(s16 courseNum, s16 levelNum, s16 areaIndex);
|
||||
|
||||
#endif // LEVEL_INFO_H
|
|
@ -1,5 +1,6 @@
|
|||
#include <string.h>
|
||||
|
||||
#include "game/level_info.h"
|
||||
#include "pc/network/network.h"
|
||||
#include "djui.h"
|
||||
#include "djui_panel_playerlist.h"
|
||||
|
@ -14,148 +15,18 @@ static struct DjuiImage* djuiImages[MAX_PLAYERS] = { 0 };
|
|||
static struct DjuiText* djuiTextNames[MAX_PLAYERS] = { 0 };
|
||||
static struct DjuiText* djuiTextLocations[MAX_PLAYERS] = { 0 };
|
||||
|
||||
extern u8 seg2_course_name_table[];
|
||||
extern u8 seg2_act_name_table[];
|
||||
|
||||
static char stage[188];
|
||||
static char act[188];
|
||||
|
||||
static const char charset[0xFF + 1] = {
|
||||
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 7
|
||||
' ', ' ', 'a', 'b', 'c', 'd', 'e', 'f', // 15
|
||||
'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', // 23
|
||||
'o', 'p', 'q', 'r', 's', 't', 'u', 'v', // 31
|
||||
'w', 'x', 'y', 'z', ' ', ' ', ' ', ' ', // 39
|
||||
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 49
|
||||
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 55
|
||||
' ', ' ', ' ', ' ', ' ', ' ', '\'', ' ', // 63
|
||||
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 71
|
||||
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 79
|
||||
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 87
|
||||
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 95
|
||||
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 103
|
||||
' ', ' ', ' ', ' ', ' ', ' ', ' ', ',', // 111
|
||||
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 119
|
||||
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 127
|
||||
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 135
|
||||
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 143
|
||||
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 151
|
||||
' ', ' ', ' ', ' ', ' ', ' ', ' ', '-', // 159
|
||||
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 167
|
||||
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 175
|
||||
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 183
|
||||
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 192
|
||||
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 199
|
||||
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 207
|
||||
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 215
|
||||
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 223
|
||||
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 231
|
||||
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', // 239
|
||||
' ', ' ', '!', ' ', ' ', ' ', ' ', ' ', // 247
|
||||
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ' // 255
|
||||
};
|
||||
|
||||
static void convert_string(const u8* str, char* output) {
|
||||
s32 strPos = 0;
|
||||
bool capitalizeChar = true;
|
||||
|
||||
while (str[strPos] != 0xFF) {
|
||||
if (str[strPos] < 0xFF) {
|
||||
output[strPos] = charset[str[strPos]];
|
||||
|
||||
// if the char is a letter we can capatalize it
|
||||
if (capitalizeChar && 0x0A <= str[strPos] && str[strPos] <= 0x23) {
|
||||
output[strPos] -= ('a' - 'A');
|
||||
capitalizeChar = false;
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
output[strPos] = ' ';
|
||||
}
|
||||
|
||||
// decide if the next character should be capitalized
|
||||
switch (output[strPos]) {
|
||||
case ' ':
|
||||
//if (str[strPos] != 158)
|
||||
//fprintf(stdout, "Unknown Character (%i)\n", str[strPos]); // inform that an unknown char was found
|
||||
case '-':
|
||||
capitalizeChar = true;
|
||||
break;
|
||||
default:
|
||||
capitalizeChar = false;
|
||||
break;
|
||||
}
|
||||
|
||||
strPos++;
|
||||
}
|
||||
|
||||
output[strPos] = '\0';
|
||||
}
|
||||
|
||||
static void set_details(s16 courseNum, s16 levelNum, s16 areaIndex) {
|
||||
// overrides for castle locations
|
||||
if (courseNum == 0 && levelNum == 16) {
|
||||
strcpy(stage, "Castle Grounds");
|
||||
return;
|
||||
}
|
||||
if (courseNum == 0 && levelNum == 6) {
|
||||
if (areaIndex == 1) {
|
||||
strcpy(stage, "Castle Main Floor");
|
||||
return;
|
||||
} else if (areaIndex == 2) {
|
||||
strcpy(stage, "Castle Upper Floor");
|
||||
return;
|
||||
} else if (areaIndex == 3) {
|
||||
strcpy(stage, "Castle Basement");
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (courseNum == 0 && levelNum == 26) {
|
||||
strcpy(stage, "Castle Courtyard");
|
||||
return;
|
||||
}
|
||||
|
||||
// If we are in in Course 0 we are in the castle which doesn't have a string
|
||||
if (courseNum) {
|
||||
void** courseNameTbl;
|
||||
|
||||
#ifndef VERSION_EU
|
||||
courseNameTbl = segmented_to_virtual(seg2_course_name_table);
|
||||
#else
|
||||
switch (gInGameLanguage) {
|
||||
case LANGUAGE_ENGLISH:
|
||||
courseNameTbl = segmented_to_virtual(course_name_table_eu_en);
|
||||
break;
|
||||
case LANGUAGE_FRENCH:
|
||||
courseNameTbl = segmented_to_virtual(course_name_table_eu_fr);
|
||||
break;
|
||||
case LANGUAGE_GERMAN:
|
||||
courseNameTbl = segmented_to_virtual(course_name_table_eu_de);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
u8* courseName = segmented_to_virtual(courseNameTbl[courseNum - 1]);
|
||||
|
||||
convert_string(&courseName[3], stage);
|
||||
} else {
|
||||
strcpy(stage, "Peach's Castle");
|
||||
}
|
||||
}
|
||||
|
||||
static void playerlist_update_row(u8 i, struct NetworkPlayer* np) {
|
||||
u8 charIndex = np->modelIndex;
|
||||
if (charIndex >= CT_MAX) { charIndex = 0; }
|
||||
djuiImages[i]->texture = gCharacters[charIndex].hudHeadTexture;
|
||||
|
||||
set_details(np->currCourseNum, np->currLevelNum, np->currAreaIndex);
|
||||
djui_base_set_visible(&djuiRow[i]->base, np->connected);
|
||||
|
||||
u8* rgb = get_player_color(np->paletteIndex, 0);
|
||||
djui_base_set_color(&djuiTextNames[i]->base, rgb[0], rgb[1], rgb[2], 255);
|
||||
djui_text_set_text(djuiTextNames[i], np->name);
|
||||
|
||||
djui_text_set_text(djuiTextLocations[i], stage);
|
||||
djui_text_set_text(djuiTextLocations[i], get_level_name(np->currCourseNum, np->currLevelNum, np->currAreaIndex));
|
||||
}
|
||||
|
||||
void djui_panel_playerlist_on_render_pre(UNUSED struct DjuiBase* base, UNUSED bool* skipRender) {
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include "pc/debuglog.h"
|
||||
#include "pc/utils/misc.h"
|
||||
#include "game/area.h"
|
||||
#include "game/level_info.h"
|
||||
|
||||
struct NetworkPlayer gNetworkPlayers[MAX_PLAYERS] = { 0 };
|
||||
struct NetworkPlayer* gNetworkPlayerLocal = NULL;
|
||||
|
@ -95,43 +96,9 @@ struct NetworkPlayer* get_network_player_smallest_global(void) {
|
|||
return smallest;
|
||||
}
|
||||
|
||||
static void network_player_update_level_popup(void) {
|
||||
static s16 sCachedCourseNum = 0;
|
||||
static s16 sCachedActStarNum = 0;
|
||||
static s16 sCachedLevelNum = 0;
|
||||
|
||||
bool inBonusCourse = (gCurrCourseNum >= 16);
|
||||
bool allowPopup = (sCachedCourseNum == gCurrCourseNum)
|
||||
&& (sCachedActStarNum == gCurrActStarNum)
|
||||
&& (sCachedLevelNum == gCurrLevelNum)
|
||||
&& (gCurrActStarNum != 99) // suppress popup for credits sequence
|
||||
&& (inBonusCourse || gCurrActStarNum != 0); // suppress popup for star selection
|
||||
|
||||
sCachedCourseNum = gCurrCourseNum;
|
||||
sCachedActStarNum = gCurrActStarNum;
|
||||
sCachedLevelNum = gCurrLevelNum;
|
||||
|
||||
for (int i = 1; i < MAX_PLAYERS; i++) {
|
||||
struct NetworkPlayer* np = &gNetworkPlayers[i];
|
||||
if (!np->connected) { continue; }
|
||||
bool localLevelMatch = (np->currCourseNum == gCurrCourseNum && np->currActNum == gCurrActStarNum && np->currLevelNum == gCurrLevelNum);
|
||||
if (np->localLevelMatch != localLevelMatch) {
|
||||
np->localLevelMatch = localLevelMatch;
|
||||
|
||||
if (!allowPopup) { continue; }
|
||||
u8* rgb = get_player_color(np->paletteIndex, 0);
|
||||
char popupMsg[128] = { 0 };
|
||||
snprintf(popupMsg, 128, "\\#%02x%02x%02x\\%s\\#dcdcdc\\ %s this level.", rgb[0], rgb[1], rgb[2], np->name, localLevelMatch ? "entered" : "left");
|
||||
djui_popup_create(popupMsg, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void network_player_update(void) {
|
||||
if (!network_player_any_connected()) { return; }
|
||||
|
||||
network_player_update_level_popup();
|
||||
|
||||
#ifndef DEVELOPMENT
|
||||
if (gNetworkType == NT_SERVER) {
|
||||
for (int i = 1; i < MAX_PLAYERS; i++) {
|
||||
|
@ -187,10 +154,7 @@ u8 network_player_connected(enum NetworkPlayerType type, u8 globalIndex, u8 mode
|
|||
np->currLevelAreaSeqId = 0;
|
||||
|
||||
extern s16 gCurrCourseNum, gCurrActStarNum, gCurrLevelNum, gCurrAreaIndex;
|
||||
np->currCourseNum = gCurrCourseNum;
|
||||
np->currActNum = gCurrActStarNum;
|
||||
np->currLevelNum = gCurrLevelNum;
|
||||
np->currAreaIndex = gCurrAreaIndex;
|
||||
network_player_update_course_level(np, gCurrCourseNum, gCurrActStarNum, gCurrLevelNum, gCurrAreaIndex);
|
||||
np->currLevelSyncValid = false;
|
||||
np->currAreaSyncValid = false;
|
||||
np->modelIndex = modelIndex;
|
||||
|
@ -236,10 +200,7 @@ u8 network_player_connected(enum NetworkPlayerType type, u8 globalIndex, u8 mode
|
|||
np->connected = true;
|
||||
np->currLevelAreaSeqId = 0;
|
||||
if (gNetworkType == NT_SERVER && !np->currAreaSyncValid) {
|
||||
np->currCourseNum = 0;
|
||||
np->currActNum = 0;
|
||||
np->currLevelNum = 16;
|
||||
np->currAreaIndex = 1;
|
||||
network_player_update_course_level(np, 0, 0, 16, 1);
|
||||
np->currLevelSyncValid = false;
|
||||
np->currAreaSyncValid = false;
|
||||
}
|
||||
|
@ -264,7 +225,7 @@ u8 network_player_connected(enum NetworkPlayerType type, u8 globalIndex, u8 mode
|
|||
// display popup
|
||||
u8* rgb = get_player_color(np->paletteIndex, 0);
|
||||
char popupMsg[128] = { 0 };
|
||||
snprintf(popupMsg, 128, "\\#%02x%02x%02x\\%s\\#dcdcdc\\ connected.", rgb[0], rgb[1], rgb[2], np->name);
|
||||
snprintf(popupMsg, 128, "\\#%02x%02x%02x\\%s\\#dcdcdc\\ connected", rgb[0], rgb[1], rgb[2], np->name);
|
||||
djui_popup_create(popupMsg, 1);
|
||||
}
|
||||
LOG_INFO("player connected, local %d, global %d", i, np->globalIndex);
|
||||
|
@ -311,7 +272,7 @@ u8 network_player_disconnected(u8 globalIndex) {
|
|||
// display popup
|
||||
u8* rgb = get_player_color(np->paletteIndex, 0);
|
||||
char popupMsg[128] = { 0 };
|
||||
snprintf(popupMsg, 128, "\\#%02x%02x%02x\\%s\\#dcdcdc\\ disconnected.", rgb[0], rgb[1], rgb[2], np->name);
|
||||
snprintf(popupMsg, 128, "\\#%02x%02x%02x\\%s\\#dcdcdc\\ disconnected", rgb[0], rgb[1], rgb[2], np->name);
|
||||
djui_popup_create(popupMsg, 1);
|
||||
|
||||
packet_ordered_clear(globalIndex);
|
||||
|
@ -321,6 +282,27 @@ u8 network_player_disconnected(u8 globalIndex) {
|
|||
return UNKNOWN_GLOBAL_INDEX;
|
||||
}
|
||||
|
||||
void network_player_update_course_level(struct NetworkPlayer* np, s16 courseNum, s16 actNum, s16 levelNum, s16 areaIndex) {
|
||||
// display popup
|
||||
if (np->currCourseNum != courseNum && np->localIndex != 0) {
|
||||
u8* rgb = get_player_color(np->paletteIndex, 0);
|
||||
char popupMsg[128] = { 0 };
|
||||
if (np->currCourseNum == gNetworkPlayerLocal->currCourseNum && gNetworkPlayerLocal->currCourseNum != 0) {
|
||||
snprintf(popupMsg, 128, "\\#%02x%02x%02x\\%s\\#dcdcdc\\ left this level", rgb[0], rgb[1], rgb[2], np->name);
|
||||
} else if (courseNum == gNetworkPlayerLocal->currCourseNum && gNetworkPlayerLocal->currCourseNum != 0) {
|
||||
snprintf(popupMsg, 128, "\\#%02x%02x%02x\\%s\\#dcdcdc\\ entered this level", rgb[0], rgb[1], rgb[2], np->name);
|
||||
} else {
|
||||
snprintf(popupMsg, 128, "\\#%02x%02x%02x\\%s\\#dcdcdc\\ entered\n%s", rgb[0], rgb[1], rgb[2], np->name, get_level_name(courseNum, levelNum, areaIndex));
|
||||
}
|
||||
djui_popup_create(popupMsg, 1);
|
||||
}
|
||||
|
||||
np->currCourseNum = courseNum;
|
||||
np->currActNum = actNum;
|
||||
np->currLevelNum = levelNum;
|
||||
np->currAreaIndex = areaIndex;
|
||||
}
|
||||
|
||||
void network_player_shutdown(void) {
|
||||
gNetworkPlayerLocal = NULL;
|
||||
gNetworkPlayerServer = NULL;
|
||||
|
@ -330,6 +312,6 @@ void network_player_shutdown(void) {
|
|||
gNetworkSystem->clear_id(i);
|
||||
}
|
||||
|
||||
djui_popup_create("\\#ffa0a0\\Error:\\#dcdcdc\\ network shutdown.", 1);
|
||||
djui_popup_create("\\#ffa0a0\\Error:\\#dcdcdc\\ network shutdown", 1);
|
||||
LOG_INFO("cleared all network players");
|
||||
}
|
||||
|
|
|
@ -57,6 +57,7 @@ struct NetworkPlayer* get_network_player_smallest_global(void);
|
|||
void network_player_update(void);
|
||||
u8 network_player_connected(enum NetworkPlayerType type, u8 globalIndex, u8 modelIndex, u8 paletteIndex, char* name);
|
||||
u8 network_player_disconnected(u8 globalIndex);
|
||||
void network_player_update_course_level(struct NetworkPlayer* np, s16 courseNum, s16 actNum, s16 levelNum, s16 areaIndex);
|
||||
void network_player_shutdown(void);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -7,10 +7,7 @@
|
|||
|
||||
static void player_changed_area(struct NetworkPlayer* np, s16 courseNum, s16 actNum, s16 levelNum, s16 areaIndex) {
|
||||
// set NetworkPlayer variables
|
||||
np->currCourseNum = courseNum;
|
||||
np->currActNum = actNum;
|
||||
np->currLevelNum = levelNum;
|
||||
np->currAreaIndex = areaIndex;
|
||||
network_player_update_course_level(np, courseNum, actNum, levelNum, areaIndex);
|
||||
np->currAreaSyncValid = false;
|
||||
reservation_area_change(np);
|
||||
|
||||
|
@ -56,10 +53,7 @@ void network_send_change_area(void) {
|
|||
network_send_to(gNetworkPlayerServer->localIndex, &p);
|
||||
|
||||
struct NetworkPlayer* np = gNetworkPlayerLocal;
|
||||
np->currCourseNum = gCurrCourseNum;
|
||||
np->currActNum = gCurrActStarNum;
|
||||
np->currLevelNum = gCurrLevelNum;
|
||||
np->currAreaIndex = gCurrAreaIndex;
|
||||
network_player_update_course_level(np, gCurrCourseNum, gCurrActStarNum, gCurrLevelNum, gCurrAreaIndex);
|
||||
np->currAreaSyncValid = false;
|
||||
|
||||
LOG_INFO("tx change area");
|
||||
|
|
|
@ -7,10 +7,7 @@
|
|||
|
||||
static void player_changed_level(struct NetworkPlayer* np, s16 courseNum, s16 actNum, s16 levelNum, s16 areaIndex) {
|
||||
// set NetworkPlayer variables
|
||||
np->currCourseNum = courseNum;
|
||||
np->currActNum = actNum;
|
||||
np->currLevelNum = levelNum;
|
||||
np->currAreaIndex = areaIndex;
|
||||
network_player_update_course_level(np, courseNum, actNum, levelNum, areaIndex);
|
||||
np->currLevelSyncValid = false;
|
||||
np->currAreaSyncValid = false;
|
||||
reservation_area_change(np);
|
||||
|
@ -62,10 +59,7 @@ void network_send_change_level(void) {
|
|||
network_send_to(gNetworkPlayerServer->localIndex, &p);
|
||||
|
||||
struct NetworkPlayer* np = gNetworkPlayerLocal;
|
||||
np->currCourseNum = gCurrCourseNum;
|
||||
np->currActNum = gCurrActStarNum;
|
||||
np->currLevelNum = gCurrLevelNum;
|
||||
np->currAreaIndex = gCurrAreaIndex;
|
||||
network_player_update_course_level(np, gCurrCourseNum, gCurrActStarNum, gCurrLevelNum, gCurrAreaIndex);
|
||||
np->currAreaSyncValid = false;
|
||||
np->currLevelSyncValid = false;
|
||||
|
||||
|
|
|
@ -4,6 +4,10 @@
|
|||
//#define DISABLE_MODULE_LOG 1
|
||||
#include "pc/debuglog.h"
|
||||
|
||||
#include "pc/djui/djui.h"
|
||||
#include "game/level_info.h"
|
||||
#include "game/mario_misc.h"
|
||||
|
||||
static u16 sLevelAreaInformSeq[MAX_PLAYERS][MAX_PLAYERS] = { 0 };
|
||||
|
||||
void network_send_level_area_inform(struct NetworkPlayer* np) {
|
||||
|
@ -64,10 +68,7 @@ void network_receive_level_area_inform(struct Packet* p) {
|
|||
}
|
||||
sLevelAreaInformSeq[0][globalIndex] = seq;
|
||||
|
||||
np->currCourseNum = courseNum;
|
||||
np->currActNum = actNum;
|
||||
np->currLevelNum = levelNum;
|
||||
np->currAreaIndex = areaIndex;
|
||||
network_player_update_course_level(np, courseNum, actNum, levelNum, areaIndex);
|
||||
np->currLevelSyncValid = levelSyncValid;
|
||||
np->currAreaSyncValid = areaSyncValid;
|
||||
}
|
||||
|
|
|
@ -87,10 +87,7 @@ void network_receive_network_players(struct Packet* p) {
|
|||
struct NetworkPlayer* np = &gNetworkPlayers[localIndex];
|
||||
if (localIndex != 0) {
|
||||
np->currLevelAreaSeqId = levelAreaSeqId;
|
||||
np->currCourseNum = courseNum;
|
||||
np->currActNum = actNum;
|
||||
np->currLevelNum = levelNum;
|
||||
np->currAreaIndex = areaIndex;
|
||||
network_player_update_course_level(np, courseNum, actNum, levelNum, areaIndex);
|
||||
np->currLevelSyncValid = levelSyncValid;
|
||||
np->currAreaSyncValid = areaSyncValid;
|
||||
LOG_INFO("received network player location (%d, %d, %d, %d)", courseNum, actNum, levelNum, areaIndex);
|
||||
|
|
|
@ -341,7 +341,7 @@ void network_receive_player(struct Packet* p) {
|
|||
// display popup
|
||||
u8* rgb = get_player_color(np->paletteIndex, 0);
|
||||
char popupMsg[128] = { 0 };
|
||||
snprintf(popupMsg, 128, "\\#%02x%02x%02x\\%s\\#dcdcdc\\ died.", rgb[0], rgb[1], rgb[2], np->name);
|
||||
snprintf(popupMsg, 128, "\\#%02x%02x%02x\\%s\\#dcdcdc\\ died", rgb[0], rgb[1], rgb[2], np->name);
|
||||
djui_popup_create(popupMsg, 1);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue