From 9f8fbb1a7733a5769e4fd743a8cf879e5c881ee0 Mon Sep 17 00:00:00 2001 From: Kp Date: Sun, 20 Dec 2020 20:39:07 +0000 Subject: [PATCH] Remove newdemo_strip_frames The sole user is based on newdemo_do2, which is being retired. This feature was only available in developer builds. --- common/main/newdemo.h | 1 - similar/main/gamecntl.cpp | 27 ------------------ similar/main/newdemo.cpp | 60 --------------------------------------- 3 files changed, 88 deletions(-) diff --git a/common/main/newdemo.h b/common/main/newdemo.h index ad6f2242b..e0833c463 100644 --- a/common/main/newdemo.h +++ b/common/main/newdemo.h @@ -163,6 +163,5 @@ extern int newdemo_get_percent_done(); extern void newdemo_record_link_sound_to_object3( int soundno, objnum_t objnum, fix max_volume, fix max_distance, int loop_start, int loop_end ); int newdemo_count_demos(); -void newdemo_strip_frames(char *, int); #endif diff --git a/similar/main/gamecntl.cpp b/similar/main/gamecntl.cpp index 2d55b437e..8ba888d7b 100644 --- a/similar/main/gamecntl.cpp +++ b/similar/main/gamecntl.cpp @@ -620,33 +620,6 @@ static window_event_result HandleDemoKey(int key) Newdemo_do_interpolate = !Newdemo_do_interpolate; HUD_init_message(HM_DEFAULT, "Demo playback interpolation %s", Newdemo_do_interpolate?"ON":"OFF"); break; - case KEY_DEBUGGED + KEY_K: { - int how_many, c; - char filename[FILENAME_LEN], num[16]; - std::array m{{ - nm_item_text("output file name"), - nm_item_input(filename), - }}; - filename[0] = '\0'; - c = newmenu_do2(menu_title{nullptr}, menu_subtitle{nullptr}, m, unused_newmenu_subfunction, unused_newmenu_userdata); - if (c == -2) - break; - strcat(filename, DEMO_EXT); - num[0] = '\0'; - m = {{ - nm_item_text("strip how many bytes"), - nm_item_input(num), - }}; - c = newmenu_do2(menu_title{nullptr}, menu_subtitle{nullptr}, m, unused_newmenu_subfunction, unused_newmenu_userdata); - if (c == -2) - break; - how_many = atoi(num); - if (how_many <= 0) - break; - newdemo_strip_frames(filename, how_many); - - break; - } #endif default: diff --git a/similar/main/newdemo.cpp b/similar/main/newdemo.cpp index 5995e6d77..6eeb09128 100644 --- a/similar/main/newdemo.cpp +++ b/similar/main/newdemo.cpp @@ -4355,66 +4355,6 @@ read_error: return nd_playback_v_at_eof; } -#ifndef NDEBUG - -#define BUF_SIZE 16384 - -void newdemo_strip_frames(char *outname, int bytes_to_strip) -{ - char *buf; - int read_elems, bytes_back; - int trailer_start, loc1, loc2, stop_loc, bytes_to_read; - short last_frame_length; - - const auto &&outfp = PHYSFSX_openWriteBuffered(outname); - if (!outfp) { - nm_messagebox_str(menu_title{nullptr}, nm_messagebox_tie(TXT_OK), menu_subtitle{"Can't open output file"}); - newdemo_stop_playback(); - return; - } - MALLOC(buf, char, BUF_SIZE); - if (buf == NULL) { - nm_messagebox_str(menu_title{nullptr}, nm_messagebox_tie(TXT_OK), menu_subtitle{"Can't malloc output buffer"}); - newdemo_stop_playback(); - return; - } - newdemo_goto_end(0); - trailer_start = PHYSFS_tell(infile); - PHYSFS_seek(infile, PHYSFS_tell(infile) + 11); - bytes_back = 0; - while (bytes_back < bytes_to_strip) { - loc1 = PHYSFS_tell(infile); - newdemo_back_frames(1); - loc2 = PHYSFS_tell(infile); - bytes_back += (loc1 - loc2); - } - PHYSFS_seek(infile, PHYSFS_tell(infile) - 10); - nd_read_short(&last_frame_length); - PHYSFS_seek(infile, PHYSFS_tell(infile) - 3); - stop_loc = PHYSFS_tell(infile); - PHYSFS_seek(infile, 0); - while (stop_loc > 0) { - if (stop_loc < BUF_SIZE) - bytes_to_read = stop_loc; - else - bytes_to_read = BUF_SIZE; - read_elems = PHYSFS_read(infile, buf, 1, bytes_to_read); - PHYSFS_write(outfp, buf, 1, read_elems); - stop_loc -= read_elems; - } - stop_loc = PHYSFS_tell(outfp); - PHYSFS_seek(infile, trailer_start); - while ((read_elems = PHYSFS_read(infile, buf, 1, BUF_SIZE)) != 0) - PHYSFS_write(outfp, buf, 1, read_elems); - PHYSFS_seek(outfp, stop_loc); - PHYSFS_seek(outfp, PHYSFS_tell(infile) + 1); - PHYSFS_write(outfp, &last_frame_length, 2, 1); - newdemo_stop_playback(); - -} - -#endif - #if defined(DXX_BUILD_DESCENT_II) static void nd_render_extras (ubyte which,const object &obj) {