mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2025-10-30 08:01:01 +00:00
Fixed cannons, possible fix to star unlocks
This commit is contained in:
parent
59eef70183
commit
ad3ee677c6
5 changed files with 35 additions and 34 deletions
|
|
@ -1,29 +1,21 @@
|
|||
// cannon.c.inc
|
||||
|
||||
void bhv_cannon_closed_init(void) {
|
||||
struct Object *cannon;
|
||||
|
||||
static void bhv_cannon_closed_init_non_spawn(void) {
|
||||
if (save_file_is_cannon_unlocked() == 1) {
|
||||
if (!gNetworkAreaLoaded || get_network_player_smallest_global() == gNetworkPlayerLocal) {
|
||||
// If the cannon is open, spawn a cannon and despawn the object.
|
||||
cannon = spawn_object(o, MODEL_CANNON_BASE, bhvCannon);
|
||||
cannon->parentObj = cannon;
|
||||
cannon->oBehParams2ndByte = o->oBehParams2ndByte;
|
||||
cannon->oPosX = o->oHomeX;
|
||||
cannon->oPosY = o->oHomeY;
|
||||
cannon->oPosZ = o->oHomeZ;
|
||||
if (gNetworkAreaLoaded) {
|
||||
network_set_sync_id(cannon);
|
||||
struct Object* spawn_objects[] = { cannon };
|
||||
u32 models[] = { MODEL_CANNON_BASE };
|
||||
network_send_spawn_objects(spawn_objects, models, 1);
|
||||
}
|
||||
}
|
||||
o->oAction = CANNON_TRAP_DOOR_ACT_OPEN;
|
||||
o->activeFlags = ACTIVE_FLAG_DEACTIVATED;
|
||||
}
|
||||
}
|
||||
|
||||
void bhv_cannon_closed_init(void) {
|
||||
struct Object* cannon = spawn_object(o, MODEL_CANNON_BASE, bhvCannon);
|
||||
cannon->parentObj = cannon;
|
||||
cannon->oBehParams2ndByte = o->oBehParams2ndByte;
|
||||
cannon->oPosX = o->oHomeX;
|
||||
cannon->oPosY = o->oHomeY;
|
||||
cannon->oPosZ = o->oHomeZ;
|
||||
bhv_cannon_closed_init_non_spawn();
|
||||
}
|
||||
|
||||
void cannon_door_act_opening(void) {
|
||||
if (o->oTimer == 0)
|
||||
cur_obj_play_sound_2(SOUND_GENERAL_CANNON_UP);
|
||||
|
|
@ -34,7 +26,7 @@ void cannon_door_act_opening(void) {
|
|||
o->oVelX = 0;
|
||||
} else {
|
||||
if (o->oTimer == 80) {
|
||||
bhv_cannon_closed_init();
|
||||
bhv_cannon_closed_init_non_spawn();
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -605,7 +605,7 @@ s32 save_file_get_total_star_count(s32 fileIndex, s32 minCourse, s32 maxCourse)
|
|||
void save_file_set_flags(u32 flags) {
|
||||
gSaveBuffer.files[gCurrSaveFileNum - 1][0].flags |= (flags | SAVE_FLAG_FILE_EXISTS);
|
||||
gSaveFileModified = TRUE;
|
||||
network_send_save_set_flag(flags);
|
||||
network_send_save_set_flag(gCurrSaveFileNum - 1, 0, 0, (flags | SAVE_FLAG_FILE_EXISTS));
|
||||
}
|
||||
|
||||
void save_file_clear_flags(u32 flags) {
|
||||
|
|
@ -644,8 +644,10 @@ u32 save_file_get_star_flags(s32 fileIndex, s32 courseIndex) {
|
|||
void save_file_set_star_flags(s32 fileIndex, s32 courseIndex, u32 starFlags) {
|
||||
if (courseIndex == -1) {
|
||||
gSaveBuffer.files[fileIndex][0].flags |= starFlags << 24;
|
||||
network_send_save_set_flag(fileIndex, courseIndex, 0, ((starFlags << 24) | SAVE_FLAG_FILE_EXISTS));
|
||||
} else {
|
||||
gSaveBuffer.files[fileIndex][0].courseStars[courseIndex] |= starFlags;
|
||||
network_send_save_set_flag(fileIndex, courseIndex, starFlags, SAVE_FLAG_FILE_EXISTS);
|
||||
}
|
||||
|
||||
gSaveBuffer.files[fileIndex][0].flags |= SAVE_FLAG_FILE_EXISTS;
|
||||
|
|
@ -670,6 +672,7 @@ void save_file_set_cannon_unlocked(void) {
|
|||
gSaveBuffer.files[gCurrSaveFileNum - 1][0].courseStars[gCurrCourseNum] |= 0x80;
|
||||
gSaveBuffer.files[gCurrSaveFileNum - 1][0].flags |= SAVE_FLAG_FILE_EXISTS;
|
||||
gSaveFileModified = TRUE;
|
||||
network_send_save_set_flag(gCurrSaveFileNum - 1, gCurrCourseNum, 0x80, SAVE_FLAG_FILE_EXISTS);
|
||||
}
|
||||
|
||||
void save_file_set_cap_pos(s16 x, s16 y, s16 z) {
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
#ifdef DEBUG
|
||||
|
||||
static u8 warpToLevel = LEVEL_BBH;
|
||||
static u8 warpToLevel = LEVEL_BOB;
|
||||
static u8 warpToArea = 29;
|
||||
// warpToArea: 26 = basement
|
||||
// warpToArea: 27 = upstairs
|
||||
|
|
|
|||
|
|
@ -189,7 +189,7 @@ void network_send_save_file(s32 fileIndex);
|
|||
void network_receive_save_file(struct Packet* p);
|
||||
|
||||
// packet_save_set_flag.c
|
||||
void network_send_save_set_flag(u32 flags);
|
||||
void network_send_save_set_flag(s32 fileIndex, s32 courseIndex, u8 courseStars, u32 flags);
|
||||
void network_receive_save_set_flag(struct Packet* p);
|
||||
|
||||
// packet_network_players.c
|
||||
|
|
|
|||
|
|
@ -1,23 +1,29 @@
|
|||
#include <stdio.h>
|
||||
#include "../network.h"
|
||||
#include "game/save_file.h"
|
||||
#include "buffers/buffers.h"
|
||||
|
||||
static bool sIgnoreSendSaveSetFlag = false;
|
||||
|
||||
void network_send_save_set_flag(u32 flags) {
|
||||
// prevent replying to the packet we just received
|
||||
if (sIgnoreSendSaveSetFlag) { return; }
|
||||
|
||||
void network_send_save_set_flag(s32 fileIndex, s32 courseIndex, u8 courseStars, u32 flags) {
|
||||
struct Packet p;
|
||||
packet_init(&p, PACKET_SAVE_SET_FLAG, true, false);
|
||||
packet_write(&p, &flags, sizeof(u32));
|
||||
packet_write(&p, &fileIndex, sizeof(s32));
|
||||
packet_write(&p, &courseIndex, sizeof(s32));
|
||||
packet_write(&p, &courseStars, sizeof(u8));
|
||||
packet_write(&p, &flags, sizeof(u32));
|
||||
network_send(&p);
|
||||
}
|
||||
|
||||
void network_receive_save_set_flag(struct Packet* p) {
|
||||
s32 fileIndex;
|
||||
s32 courseIndex;
|
||||
u8 courseStars;
|
||||
u32 flags;
|
||||
packet_read(p, &flags, sizeof(u32));
|
||||
sIgnoreSendSaveSetFlag = true;
|
||||
save_file_set_flags(flags);
|
||||
sIgnoreSendSaveSetFlag = false;
|
||||
packet_read(p, &fileIndex, sizeof(s32));
|
||||
packet_read(p, &courseIndex, sizeof(s32));
|
||||
packet_read(p, &courseStars, sizeof(u8));
|
||||
packet_read(p, &flags, sizeof(u32));
|
||||
|
||||
gSaveBuffer.files[fileIndex][0].courseStars[courseIndex] |= courseStars;
|
||||
gSaveBuffer.files[fileIndex][0].flags |= flags;
|
||||
gSaveFileModified = TRUE;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue