mirror of
https://github.com/coop-deluxe/sm64coopdx.git
synced 2024-12-22 16:30:23 +00:00
Fixed crash in save set flag packet
This commit is contained in:
parent
6d7d79a4aa
commit
988c75d621
2 changed files with 13 additions and 1 deletions
|
@ -2,6 +2,7 @@
|
|||
#include "../network.h"
|
||||
#include "game/save_file.h"
|
||||
#include "buffers/buffers.h"
|
||||
#include "pc/debuglog.h"
|
||||
|
||||
void network_send_save_set_flag(s32 fileIndex, s32 courseIndex, u8 courseStars, u32 flags) {
|
||||
struct Packet p = { 0 };
|
||||
|
@ -23,6 +24,16 @@ void network_receive_save_set_flag(struct Packet* p) {
|
|||
packet_read(p, &courseStars, sizeof(u8));
|
||||
packet_read(p, &flags, sizeof(u32));
|
||||
|
||||
if (fileIndex >= NUM_SAVE_FILES) {
|
||||
LOG_ERROR("Invalid fileIndex: %d", fileIndex);
|
||||
return;
|
||||
}
|
||||
|
||||
if (courseIndex >= COURSE_COUNT) {
|
||||
LOG_ERROR("Invalid courseIndex: %d", courseIndex);
|
||||
return;
|
||||
}
|
||||
|
||||
gSaveBuffer.files[fileIndex][0].courseStars[courseIndex] |= courseStars;
|
||||
gSaveBuffer.files[fileIndex][0].flags |= flags;
|
||||
gSaveFileModified = TRUE;
|
||||
|
|
|
@ -113,7 +113,8 @@ void network_receive_spawn_objects(struct Packet* p) {
|
|||
parentObj = gMarioStates[0].marioObj;
|
||||
} else {
|
||||
// sanity check parent id
|
||||
if (i == 0 && data.parentId >= MAX_SYNC_OBJECTS) {
|
||||
u32 maxSyncObjects = MAX_SYNC_OBJECTS;
|
||||
if (i == 0 && data.parentId >= maxSyncObjects) {
|
||||
LOG_ERROR("Invalid spawn object parentId: %u", data.parentId);
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue