Allow host to own objects when no one else is connected

This commit is contained in:
MysterD 2021-08-03 23:26:51 -07:00
parent f8c5fb0725
commit e17cba85f3
4 changed files with 7 additions and 4 deletions

View file

@ -269,7 +269,7 @@ void network_update(void) {
gNetworkAreaTimer = (clock_elapsed_ticks() - gNetworkAreaTimerClock); gNetworkAreaTimer = (clock_elapsed_ticks() - gNetworkAreaTimerClock);
// send out update packets // send out update packets
if (gNetworkType != NT_NONE && network_player_any_connected()) { if (gNetworkType != NT_NONE) {
network_player_update(); network_player_update();
if (sCurrPlayMode == PLAY_MODE_NORMAL || sCurrPlayMode == PLAY_MODE_PAUSED) { if (sCurrPlayMode == PLAY_MODE_NORMAL || sCurrPlayMode == PLAY_MODE_PAUSED) {
network_update_player(); network_update_player();

View file

@ -112,7 +112,7 @@ struct NetworkPlayer* get_network_player_smallest_global(void) {
} }
void network_player_update(void) { void network_player_update(void) {
if (!network_player_any_connected()) { return; }
//#ifndef DEVELOPMENT //#ifndef DEVELOPMENT
if (gNetworkType == NT_SERVER) { if (gNetworkType == NT_SERVER) {
for (int i = 1; i < MAX_PLAYERS; i++) { for (int i = 1; i < MAX_PLAYERS; i++) {

View file

@ -58,7 +58,7 @@ static bool should_own_object(struct SyncObject* so) {
} }
if (so->o->oHeldState == HELD_HELD && so->o->heldByPlayerIndex == 0) { return true; } if (so->o->oHeldState == HELD_HELD && so->o->heldByPlayerIndex == 0) { return true; }
for (int i = 0; i < MAX_PLAYERS; i++) { for (int i = 0; i < MAX_PLAYERS; i++) {
if (!is_player_active(&gMarioStates[i])) { continue; } if (i != 0 && !is_player_active(&gMarioStates[i])) { continue; }
if (player_distance(&gMarioStates[0], so->o) > player_distance(&gMarioStates[i], so->o)) { return false; } if (player_distance(&gMarioStates[0], so->o) > player_distance(&gMarioStates[i], so->o)) { return false; }
} }
if (so->o->oHeldState == HELD_HELD && so->o->heldByPlayerIndex != 0) { return false; } if (so->o->oHeldState == HELD_HELD && so->o->heldByPlayerIndex != 0) { return false; }
@ -570,7 +570,9 @@ void network_update_objects(void) {
if (timeSinceUpdate < updateRate) { continue; } if (timeSinceUpdate < updateRate) { continue; }
// update! // update!
network_send_object(gSyncObjects[i].o); if (network_player_any_connected()) {
network_send_object(gSyncObjects[i].o);
}
} }
} }

View file

@ -338,5 +338,6 @@ void network_receive_player(struct Packet* p) {
} }
void network_update_player(void) { void network_update_player(void) {
if (!network_player_any_connected()) { return; }
network_send_player(0); network_send_player(0);
} }