mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2024-11-25 13:35:12 +00:00
Fade out players when they leave/disconnect
This commit is contained in:
parent
ab9056bb68
commit
00da6b48f5
3 changed files with 22 additions and 6 deletions
|
@ -381,6 +381,7 @@ struct MarioState
|
||||||
|
|
||||||
/*????*/ Vec3f nonInstantWarpPos;
|
/*????*/ Vec3f nonInstantWarpPos;
|
||||||
/*????*/ struct Character* character;
|
/*????*/ struct Character* character;
|
||||||
|
/*????*/ u8 wasNetworkVisible;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define PLAY_MODE_NORMAL 0
|
#define PLAY_MODE_NORMAL 0
|
||||||
|
|
|
@ -1782,7 +1782,7 @@ void mario_update_hitbox_and_cap_model(struct MarioState *m) {
|
||||||
}
|
}
|
||||||
|
|
||||||
struct NetworkPlayer* np = &gNetworkPlayers[gMarioState->playerIndex];
|
struct NetworkPlayer* np = &gNetworkPlayers[gMarioState->playerIndex];
|
||||||
u8 teleportFade = (m->flags & MARIO_TELEPORTING) || (np->type != NPT_LOCAL && np->connected && np->fadeOpacity < 32);
|
u8 teleportFade = (m->flags & MARIO_TELEPORTING) || (np->type != NPT_LOCAL && np->fadeOpacity < 32);
|
||||||
if (teleportFade && (m->fadeWarpOpacity != 0xFF)) {
|
if (teleportFade && (m->fadeWarpOpacity != 0xFF)) {
|
||||||
bodyState->modelState &= ~0xFF;
|
bodyState->modelState &= ~0xFF;
|
||||||
bodyState->modelState |= (0x100 | m->fadeWarpOpacity);
|
bodyState->modelState |= (0x100 | m->fadeWarpOpacity);
|
||||||
|
@ -1874,17 +1874,25 @@ s32 execute_mario_action(UNUSED struct Object *o) {
|
||||||
|| np->currLevelNum != gNetworkPlayerLocal->currLevelNum
|
|| np->currLevelNum != gNetworkPlayerLocal->currLevelNum
|
||||||
|| np->currAreaIndex != gNetworkPlayerLocal->currAreaIndex);
|
|| np->currAreaIndex != gNetworkPlayerLocal->currAreaIndex);
|
||||||
|
|
||||||
if (!np->connected || levelAreaMismatch || !gNetworkAreaLoaded) {
|
bool fadedOut = gNetworkAreaLoaded && (levelAreaMismatch && gMarioState->wasNetworkVisible && np->fadeOpacity == 0);
|
||||||
|
bool wasNeverVisible = gNetworkAreaLoaded && !gMarioState->wasNetworkVisible;
|
||||||
|
|
||||||
|
if (!gNetworkAreaLoaded || fadedOut || wasNeverVisible) {
|
||||||
gMarioState->marioObj->header.gfx.node.flags |= GRAPH_RENDER_INVISIBLE;
|
gMarioState->marioObj->header.gfx.node.flags |= GRAPH_RENDER_INVISIBLE;
|
||||||
gMarioState->marioObj->oIntangibleTimer = -1;
|
gMarioState->marioObj->oIntangibleTimer = -1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (np->fadeOpacity < 32) {
|
if (levelAreaMismatch && gMarioState->wasNetworkVisible) {
|
||||||
if (!(gMarioState->flags & MARIO_TELEPORTING)) {
|
if (np->fadeOpacity <= 2) {
|
||||||
np->fadeOpacity += 2;
|
np->fadeOpacity = 0;
|
||||||
gMarioState->fadeWarpOpacity = np->fadeOpacity << 3;
|
} else {
|
||||||
|
np->fadeOpacity -= 2;
|
||||||
}
|
}
|
||||||
|
gMarioState->fadeWarpOpacity = np->fadeOpacity << 3;
|
||||||
|
} else if (np->fadeOpacity < 32) {
|
||||||
|
np->fadeOpacity += 2;
|
||||||
|
gMarioState->fadeWarpOpacity = np->fadeOpacity << 3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2134,6 +2142,8 @@ static void init_single_mario(struct MarioState* m) {
|
||||||
// force all other players to be invisible by default
|
// force all other players to be invisible by default
|
||||||
if (playerIndex != 0) {
|
if (playerIndex != 0) {
|
||||||
m->marioObj->header.gfx.node.flags |= GRAPH_RENDER_INVISIBLE;
|
m->marioObj->header.gfx.node.flags |= GRAPH_RENDER_INVISIBLE;
|
||||||
|
m->wasNetworkVisible = false;
|
||||||
|
gNetworkPlayers[playerIndex].fadeOpacity = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// set mario/luigi model
|
// set mario/luigi model
|
||||||
|
|
|
@ -343,6 +343,11 @@ void network_receive_player(struct Packet* p) {
|
||||||
if (m->action != oldData.action) {
|
if (m->action != oldData.action) {
|
||||||
m->actionTimer = 0;
|
m->actionTimer = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// mark this player as visible
|
||||||
|
if (gNetworkAreaLoaded) {
|
||||||
|
m->wasNetworkVisible = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void network_update_player(void) {
|
void network_update_player(void) {
|
||||||
|
|
Loading…
Reference in a new issue