From: Holger Schemel Date: Thu, 14 Mar 2002 00:51:59 +0000 (+0100) Subject: rnd-20020314-1-src X-Git-Tag: 2.0.1^2~11 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=dfe534c10c9825cafd54961c60fc81a56691dc55;p=rocksndiamonds.git rnd-20020314-1-src --- diff --git a/src/files.c b/src/files.c index 8ccb2466..ce7ff2d9 100644 --- a/src/files.c +++ b/src/files.c @@ -35,7 +35,7 @@ /* file identifier strings */ #define LEVEL_COOKIE "ROCKSNDIAMONDS_LEVEL_FILE_VERSION_2.0" #define SCORE_COOKIE "ROCKSNDIAMONDS_SCORE_FILE_VERSION_1.2" -#define TAPE_COOKIE "ROCKSNDIAMONDS_TAPE_FILE_VERSION_1.2" +#define TAPE_COOKIE "ROCKSNDIAMONDS_TAPE_FILE_VERSION_2.0" #define SETUP_COOKIE "ROCKSNDIAMONDS_SETUP_FILE_VERSION_1.2" #define LEVELSETUP_COOKIE "ROCKSNDIAMONDS_LEVELSETUP_FILE_VERSION_1.2" #define LEVELINFO_COOKIE "ROCKSNDIAMONDS_LEVELINFO_FILE_VERSION_1.2" @@ -44,6 +44,7 @@ #define LEVEL_COOKIE_12 "ROCKSNDIAMONDS_LEVEL_FILE_VERSION_1.2" #define LEVEL_COOKIE_14 "ROCKSNDIAMONDS_LEVEL_FILE_VERSION_1.4" #define TAPE_COOKIE_10 "ROCKSNDIAMONDS_LEVELREC_FILE_VERSION_1.0" +#define TAPE_COOKIE_12 "ROCKSNDIAMONDS_TAPE_FILE_VERSION_1.2" /* file names and filename extensions */ #if !defined(PLATFORM_MSDOS) @@ -1410,6 +1411,10 @@ void LoadTape(int level_nr) } } +#if DEBUG + printf("\nTAPE OF LEVEL %d\n", level_nr); +#endif + for(i=0; i= MAX_TAPELEN) @@ -1421,10 +1426,30 @@ void LoadTape(int level_nr) if (tape.player_participates[j]) tape.pos[i].action[j] = fgetc(file); + +#if DEBUG + { + int x = tape.pos[i].action[j]; + + printf("%d:%02x ", j, x); + printf("[%c%c%c%c|%c%c] - ", + (x & JOY_LEFT ? '<' : ' '), + (x & JOY_RIGHT ? '>' : ' '), + (x & JOY_UP ? '^' : ' '), + (x & JOY_DOWN ? 'v' : ' '), + (x & JOY_BUTTON_1 ? '1' : ' '), + (x & JOY_BUTTON_2 ? '2' : ' ')); + } +#endif + } tape.pos[i].delay = fgetc(file); +#if DEBUG + printf("[%03d]\n", tape.pos[i].delay); +#endif + if (file_version == FILE_VERSION_1_0) { /* eliminate possible diagonal moves in old tapes */ @@ -1452,6 +1477,23 @@ void LoadTape(int level_nr) tape.length += num_moves; } } + else if (file_version < FILE_VERSION_2_0) + { + if (tape.pos[i].delay > 1) + { + /* action part */ + tape.pos[i + 1] = tape.pos[i]; + tape.pos[i + 1].delay = 1; + + /* delay part */ + for(j=0; jjx, jy = player->jy; int left = player_action & JOY_LEFT; int right = player_action & JOY_RIGHT; int up = player_action & JOY_UP; @@ -4221,7 +4226,9 @@ static void PlayerActions(struct PlayerInfo *player, byte player_action) if (player_action) { +#if 0 save_tape_entry = TRUE; +#endif player->frame_reset_delay = 0; if (button1) @@ -4233,15 +4240,22 @@ static void PlayerActions(struct PlayerInfo *player, byte player_action) moved = MoveFigure(player, dx, dy); } +#if 0 if (tape.recording && (moved || snapped || bombed)) { if (bombed && !moved) player_action &= JOY_BUTTON; stored_player_action[player->index_nr] = player_action; +#if 1 + save_tape_entry = TRUE; +#endif } else if (tape.playing && snapped) SnapField(player, 0, 0); /* stop snapping */ +#else + stored_player_action[player->index_nr] = player_action; +#endif } else { @@ -4274,16 +4288,26 @@ static void PlayerActions(struct PlayerInfo *player, byte player_action) player->Frame = 0; } +#if 0 if (tape.recording && num_stored_actions >= MAX_PLAYERS && save_tape_entry) { TapeRecordAction(stored_player_action); num_stored_actions = 0; save_tape_entry = FALSE; } +#else + if (tape.recording && num_stored_actions >= MAX_PLAYERS) + { + TapeRecordAction(stored_player_action); + num_stored_actions = 0; + } +#endif +#if 0 if (tape.playing && !tape.pausing && !player_action && tape.counter < tape.length) { + int jx = player->jx, jy = player->jy; int next_joy = tape.pos[tape.counter].action[player->index_nr] & (JOY_LEFT|JOY_RIGHT); @@ -4307,6 +4331,7 @@ static void PlayerActions(struct PlayerInfo *player, byte player_action) } } } +#endif } void GameActions() @@ -4909,9 +4934,15 @@ boolean MoveFigure(struct PlayerInfo *player, int dx, int dy) if (!player->active || (!dx && !dy)) return FALSE; +#if 0 if (!FrameReached(&player->move_delay, player->move_delay_value) && !tape.playing) return FALSE; +#else + if (!FrameReached(&player->move_delay, player->move_delay_value) && + !(tape.playing && tape.file_version < FILE_VERSION_2_0)) + return FALSE; +#endif /* remove the last programmed player action */ player->programmed_action = 0; @@ -5761,9 +5792,16 @@ int DigField(struct PlayerInfo *player, if (player->push_delay == 0) player->push_delay = FrameCounter; +#if 0 if (!FrameReached(&player->push_delay, player->push_delay_value) && !tape.playing && element != EL_SPRING) return MF_NO_ACTION; +#else + if (!FrameReached(&player->push_delay, player->push_delay_value) && + !(tape.playing && tape.file_version < FILE_VERSION_2_0) && + element != EL_SPRING) + return MF_NO_ACTION; +#endif RemoveField(x, y); Feld[x+dx][y+dy] = element; @@ -5996,9 +6034,16 @@ int DigField(struct PlayerInfo *player, if (player->push_delay == 0) player->push_delay = FrameCounter; +#if 0 if (!FrameReached(&player->push_delay, player->push_delay_value) && !tape.playing && element != EL_BALLOON) return MF_NO_ACTION; +#else + if (!FrameReached(&player->push_delay, player->push_delay_value) && + !(tape.playing && tape.file_version < FILE_VERSION_2_0) && + element != EL_BALLOON) + return MF_NO_ACTION; +#endif if (IS_SB_ELEMENT(element)) { diff --git a/src/main.h b/src/main.h index 803f0a0e..72524c39 100644 --- a/src/main.h +++ b/src/main.h @@ -278,7 +278,7 @@ struct PlayerInfo int index_nr, client_nr, element_nr; byte action; /* action from local input device */ - byte effective_action; /* action aknowledged from network server + byte effective_action; /* action acknowledged from network server or summarized over all configured input devices when in single player mode */ byte programmed_action; /* action forced by game itself (like moving diff --git a/src/tape.c b/src/tape.c index 8771fedd..44bbc57b 100644 --- a/src/tape.c +++ b/src/tape.c @@ -18,6 +18,7 @@ #include "tools.h" #include "files.h" #include "network.h" +#include "cartoons.h" /* tape button identifiers */ #define TAPE_CTRL_ID_EJECT 0 @@ -315,13 +316,17 @@ void TapeStartRecording() void TapeStopRecording() { +#if 0 int i; +#endif if (!tape.recording) return; +#if 0 for(i=0; i= MAX_TAPELEN-1) + { + TapeStopRecording(); + return; + } + + if (tape.pos[tape.counter].delay > 0) /* already stored action */ + { + boolean changed_events = FALSE; + + for(i=0; i= 255) + { + tape.counter++; + tape.pos[tape.counter].delay = 0; + } + else + tape.pos[tape.counter].delay++; + } + + if (tape.pos[tape.counter].delay == 0) /* store new action */ + { + for(i=0; i tape.length_seconds - TAPE_PAUSE_SECONDS_BEFORE_DEATH) + { + TapeTogglePause(); + return NULL; + } + } + + if (tape.counter >= tape.length) + { + TapeStop(); + return NULL; + } + + for(i=0; i= tape.pos[tape.counter].delay) + { + tape.counter++; + tape.delay_played = 0; + } + + return action; +} +#endif + +#if 0 boolean TapePlayDelay() { if (!tape.playing || tape.pausing) @@ -494,6 +599,14 @@ boolean TapePlayDelay() return(FALSE); } +#else + +boolean TapePlayDelay() +{ + return TRUE|FALSE; /* ...it doesn't matter at all */ +} +#endif + void TapeStop() { TapeStopRecording(); @@ -675,6 +788,7 @@ static void HandleTapeButtons(struct GadgetInfo *gi) #endif { game_status = PLAYING; + StopAnimation(); InitGame(); } } @@ -703,6 +817,7 @@ static void HandleTapeButtons(struct GadgetInfo *gi) TapeStartPlaying(); game_status = PLAYING; + StopAnimation(); InitGame(); } else if (tape.playing)