From 6fe4dd5d96f0ac4efcb52ac348d08bab8de555e4 Mon Sep 17 00:00:00 2001 From: zicodxx Date: Wed, 20 Apr 2011 01:47:12 +0200 Subject: [PATCH] Resolved termination issue when reading and comparing callsigns fro Coop savestates; Added scores sending after Coop savestate loading as unrestored players will send them when loading new level --- CHANGELOG.txt | 9 +++++++++ main/multi.c | 1 + main/state.c | 30 ++++++++++++------------------ 3 files changed, 22 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 981a63a14..57bdd963f 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,9 +1,18 @@ D1X-Rebirth Changelog +20110420 +-------- +main/multi.c, main/state.c: Resolved termination issue when reading and comparing callsigns fro Coop savestates; Added scores sending after Coop savestate loading as unrestored players will send them when loading new level + 20110418 -------- arch/sdl/digi_mixer_music.c, arch/sdl/jukebox.c, main/config.c, main/menu.c, main/songs.c, main/songs.h: Fix broken m3u playlist support (in jukebox_play() path resolving); point to default descent.m3u playlist for Mac OS X (will be included in bundle); better error reporting in mix_play_file(); only make relative Jukebox path in the menu absolute after browsing it - relative paths are more flexible; allow select_file_recursive() to figure out PhysicsFS relative paths passed to it; stop the music if Jukebox is chosen and unavailable (used to just keep playing the last song) +20110416 +-------- +main/gamecntl.c, main/gauges.c: Due to controls rewrite was not possible anymore to send multiplayer messages while being dead - added specific exception to allow this; Rewrote show_HUD_names to only show names, indicators or typing string for enemy players when they are not cloaked +misc/hmp.c: Check for hmp before pausing/resuming it + 20110414 -------- main/kmatrix.c: Fixing km struct being used after it's being freed by closing the window in EVENT_WINDOW_DRAW diff --git a/main/multi.c b/main/multi.c index e413a6e17..89dd45447 100644 --- a/main/multi.c +++ b/main/multi.c @@ -3588,6 +3588,7 @@ void multi_restore_game(ubyte slot, uint id) } pnum = state_restore_all_sub( filename ); + multi_send_score(); // send my restored scores. I sent 0 when I loaded the level anyways... } void multi_do_msgsend_state(char *buf) diff --git a/main/state.c b/main/state.c index d47ee8dde..aa20568ec 100644 --- a/main/state.c +++ b/main/state.c @@ -561,7 +561,7 @@ int state_get_savegame_filename(char * fname, char * dsc, char * caption, int bl char filename[NUM_SAVES][PATH_MAX]; char desc[NUM_SAVES][DESC_LENGTH + 16]; grs_bitmap *sc_bmp[NUM_SAVES]; - char id[5], dummy_callsign[CALLSIGN_LEN]; + char id[5], dummy_callsign[CALLSIGN_LEN+1]; int valid; nsaves=0; @@ -581,7 +581,7 @@ int state_get_savegame_filename(char * fname, char * dsc, char * caption, int bl if (Game_mode & GM_MULTI_COOP) { dummy_state_game_id = PHYSFSX_readSXE32(fp, 0); - PHYSFS_read(fp, &dummy_callsign, sizeof(char)*CALLSIGN_LEN, 1); + PHYSFS_read(fp, &dummy_callsign, sizeof(char)*CALLSIGN_LEN+1, 1); } if ((version >= STATE_COMPATIBLE_VERSION) || (SWAPINT(version) >= STATE_COMPATIBLE_VERSION)) { // Read description @@ -841,7 +841,7 @@ int state_save_all_sub(char *filename, char *desc) if (Game_mode & GM_MULTI_COOP) { PHYSFS_write(fp, &state_game_id, sizeof(uint), 1); - PHYSFS_write(fp, &Players[Player_num].callsign, sizeof(char)*CALLSIGN_LEN, 1); + PHYSFS_write(fp, &Players[Player_num].callsign, sizeof(char)*CALLSIGN_LEN+1, 1); } //Save description @@ -1048,13 +1048,7 @@ int state_save_all_sub(char *filename, char *desc) PHYSFS_write(fp, &Netgame.numplayers, sizeof(ubyte), 1); PHYSFS_write(fp, &Netgame.max_numplayers, sizeof(ubyte), 1); PHYSFS_write(fp, &Netgame.numconnected, sizeof(ubyte), 1); - for (i = 0; i < MAX_PLAYERS; i++) - PHYSFS_write(fp, &Netgame.killed[i], sizeof(short), 1); PHYSFS_write(fp, &Netgame.level_time, sizeof(int), 1); - for (i = 0; i < MAX_PLAYERS; i++) - PHYSFS_write(fp, &Netgame.player_score[i], sizeof(int), 1); - for (i = 0; i < MAX_PLAYERS; i++) - PHYSFS_write(fp, &Netgame.player_flags[i], sizeof(ubyte), 1); } PHYSFS_close(fp); @@ -1150,9 +1144,9 @@ int state_restore_all_sub(char *filename) // Read Coop state_game_id. Oh the redundancy... we have this one later on but Coop games want to read this before loading a state so for easy access we have this here if (Game_mode & GM_MULTI_COOP) { - char saved_callsign[CALLSIGN_LEN]; + char saved_callsign[CALLSIGN_LEN+1]; state_game_id = PHYSFSX_readSXE32(fp, swap); - PHYSFS_read(fp, &saved_callsign, sizeof(char)*CALLSIGN_LEN, 1); + PHYSFS_read(fp, &saved_callsign, sizeof(char)*CALLSIGN_LEN+1, 1); if (strcmp(saved_callsign, Players[Player_num].callsign)) // check the callsign of the palyer who saved this state. It MUST match. If we transferred this savegame from pilot A to pilot B, others won't be able to restore us. So bail out here if this is the case. { PHYSFS_close(fp); @@ -1435,13 +1429,13 @@ RetryObjectLoading: PHYSFS_read(fp, &Netgame.max_numplayers, sizeof(ubyte), 1); MaxNumNetPlayers = Netgame.max_numplayers; PHYSFS_read(fp, &Netgame.numconnected, sizeof(ubyte), 1); - for (i = 0; i < MAX_PLAYERS; i++) - Netgame.killed[coop_player_slot_remap[i]] = PHYSFSX_readSXE16(fp, swap); Netgame.level_time = PHYSFSX_readSXE32(fp, swap); for (i = 0; i < MAX_PLAYERS; i++) - Netgame.player_score[coop_player_slot_remap[i]] = PHYSFSX_readSXE32(fp, swap); - for (i = 0; i < MAX_PLAYERS; i++) - PHYSFS_read(fp, &Netgame.player_flags[coop_player_slot_remap[i]], sizeof(ubyte), 1); + { + Netgame.killed[i] = Players[i].net_killed_total; + Netgame.player_score[i] = Players[i].score; + Netgame.player_flags[i] = Players[i].flags; + } for (i = 0; i < MAX_PLAYERS; i++) // Disconnect connected players not available in this Savegame if (!coop_player_got[i] && Players[i].connected == CONNECT_PLAYING) multi_disconnect_player(i); @@ -1463,7 +1457,7 @@ int state_get_game_id(char *filename) int version; PHYSFS_file *fp; int swap = 0; // if file is not endian native, have to swap all shorts and ints - char id[5], saved_callsign[CALLSIGN_LEN]; + char id[5], saved_callsign[CALLSIGN_LEN+1]; #ifndef NDEBUG if (GameArg.SysUsePlayersDir && strncmp(filename, "Players/", 8)) @@ -1499,7 +1493,7 @@ int state_get_game_id(char *filename) // Read Coop state_game_id to validate the savegame we are about to load matches the others state_game_id = PHYSFSX_readSXE32(fp, swap); - PHYSFS_read(fp, &saved_callsign, sizeof(char)*CALLSIGN_LEN, 1); + PHYSFS_read(fp, &saved_callsign, sizeof(char)*CALLSIGN_LEN+1, 1); if (strcmp(saved_callsign, Players[Player_num].callsign)) // check the callsign of the palyer who saved this state. It MUST match. If we transferred this savegame from pilot A to pilot B, others won't be able to restore us. So bail out here if this is the case. return 0;