From: Holger Schemel Date: Tue, 21 Apr 2020 15:57:41 +0000 (+0200) Subject: prepared code to support more tape actions than players X-Git-Tag: 4.2.0.0~45 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=216bac7a443561781916af1b643d14a15007db42;p=rocksndiamonds.git prepared code to support more tape actions than players --- diff --git a/src/files.c b/src/files.c index 54835e28..981411f0 100644 --- a/src/files.c +++ b/src/files.c @@ -3986,7 +3986,7 @@ static void CopyNativeTape_SP_to_RND(struct LevelInfo *level) int demo_repeat = (demo->data[i] & 0xf0) >> 4; int tape_action = map_key_SP_to_RND(demo_action); int tape_repeat = demo_repeat + 1; - byte action[MAX_PLAYERS] = { tape_action, 0, 0, 0 }; + byte action[MAX_TAPE_ACTIONS] = { tape_action }; boolean success = 0; int j; diff --git a/src/game.c b/src/game.c index 5d9e473b..e4373903 100644 --- a/src/game.c +++ b/src/game.c @@ -11374,7 +11374,7 @@ static void GameActionsExt(void) unsigned int game_frame_delay_value; byte *recorded_player_action; byte summarized_player_action = 0; - byte tape_action[MAX_PLAYERS]; + byte tape_action[MAX_TAPE_ACTIONS] = { 0 }; int i; // detect endless loops, caused by custom element programming diff --git a/src/tape.c b/src/tape.c index bf24b531..61c0ec6e 100644 --- a/src/tape.c +++ b/src/tape.c @@ -660,7 +660,7 @@ void TapeStopRecording(void) MapTapeEjectButton(); } -boolean TapeAddAction(byte action[MAX_PLAYERS]) +boolean TapeAddAction(byte action[MAX_TAPE_ACTIONS]) { int i; @@ -668,7 +668,7 @@ boolean TapeAddAction(byte action[MAX_PLAYERS]) { boolean changed_events = FALSE; - for (i = 0; i < MAX_PLAYERS; i++) + for (i = 0; i < MAX_TAPE_ACTIONS; i++) if (tape.pos[tape.counter].action[i] != action[i]) changed_events = TRUE; @@ -686,7 +686,7 @@ boolean TapeAddAction(byte action[MAX_PLAYERS]) if (tape.pos[tape.counter].delay == 0) // store new action { - for (i = 0; i < MAX_PLAYERS; i++) + for (i = 0; i < MAX_TAPE_ACTIONS; i++) tape.pos[tape.counter].action[i] = action[i]; tape.pos[tape.counter].delay++; @@ -695,15 +695,15 @@ boolean TapeAddAction(byte action[MAX_PLAYERS]) return TRUE; } -void TapeRecordAction(byte action_raw[MAX_PLAYERS]) +void TapeRecordAction(byte action_raw[MAX_TAPE_ACTIONS]) { - byte action[MAX_PLAYERS]; + byte action[MAX_TAPE_ACTIONS]; int i; if (!tape.recording) // (record action even when tape is paused) return; - for (i = 0; i < MAX_PLAYERS; i++) + for (i = 0; i < MAX_TAPE_ACTIONS; i++) action[i] = action_raw[i]; if (!tape.use_mouse && tape.set_centered_player) @@ -825,7 +825,7 @@ byte *TapePlayAction(void) int update_delay = FRAMES_PER_SECOND / 2; boolean update_video_display = (FrameCounter % update_delay == 0); boolean update_draw_label_on = ((FrameCounter / update_delay) % 2 == 1); - static byte action[MAX_PLAYERS]; + static byte action[MAX_TAPE_ACTIONS]; int i; if (!tape.playing || tape.pausing) @@ -874,12 +874,12 @@ byte *TapePlayAction(void) DrawVideoDisplaySymbol(state); } - for (i = 0; i < MAX_PLAYERS; i++) + for (i = 0; i < MAX_TAPE_ACTIONS; i++) action[i] = tape.pos[tape.counter].action[i]; #if DEBUG_TAPE_WHEN_PLAYING printf("%05d", FrameCounter); - for (i = 0; i < MAX_PLAYERS; i++) + for (i = 0; i < MAX_TAPE_ACTIONS; i++) printf(" %08x", action[i]); printf("\n"); #endif diff --git a/src/tape.h b/src/tape.h index 40ddd094..c20fab41 100644 --- a/src/tape.h +++ b/src/tape.h @@ -27,6 +27,8 @@ #define TAPE_ACTION_BUTTON 2 #define TAPE_ACTION_UNUSED 3 +#define MAX_TAPE_ACTIONS 4 + // some positions in the video tape control window #define VIDEO_DISPLAY1_XPOS 5 #define VIDEO_DISPLAY1_YPOS 5 @@ -194,7 +196,7 @@ struct TapeInfo struct { - byte action[MAX_PLAYERS]; + byte action[MAX_TAPE_ACTIONS]; byte delay; } pos[MAX_TAPE_LEN];