From: Holger Schemel Date: Thu, 14 Mar 2002 14:40:46 +0000 (+0100) Subject: rnd-20020314-3-src X-Git-Tag: 2.0.1^2~9 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=df8111be2dc97172f30c7162eca4641d027e2aa4;p=rocksndiamonds.git rnd-20020314-3-src --- diff --git a/src/events.c b/src/events.c index 365d7962..79ffdd4a 100644 --- a/src/events.c +++ b/src/events.c @@ -19,6 +19,7 @@ #include "tools.h" #include "game.h" #include "editor.h" +#include "files.h" #include "tape.h" #include "joystick.h" #include "network.h" @@ -565,6 +566,12 @@ void HandleKey(Key key, int key_status) HandleChooseLevel(0,0, 0,SCR_FIELDY, MB_MENU_MARK); break; +#ifdef DEBUG + case KSYM_t: + DumpTape(&tape); + break; +#endif + default: break; } diff --git a/src/files.c b/src/files.c index 773b0e72..3f50b5e9 100644 --- a/src/files.c +++ b/src/files.c @@ -1312,6 +1312,14 @@ static void setTapeInfoToDefaults() /* at least one (default: the first) player participates in every tape */ tape.num_participating_players = 1; + + tape.level_nr = level_nr; + tape.counter = 0; + tape.changed = FALSE; + + tape.recording = FALSE; + tape.playing = FALSE; + tape.pausing = FALSE; } void OLD_LoadTape(int level_nr) @@ -1553,14 +1561,6 @@ static int LoadTape_HEAD(struct TapeInfo *tape, FILE *file, int chunk_size) } } - tape->level_nr = level_nr; - tape->counter = 0; - tape->changed = FALSE; - - tape->recording = FALSE; - tape->playing = FALSE; - tape->pausing = FALSE; - return chunk_size; } @@ -1576,10 +1576,6 @@ static int LoadTape_BODY(struct TapeInfo *tape, FILE *file, int chunk_size) return chunk_size_expected; } -#if DEBUG - printf("\nTAPE OF LEVEL %d\n", level_nr); -#endif - for(i=0; ilength; i++) { if (i >= MAX_TAPELEN) @@ -1591,30 +1587,10 @@ static int LoadTape_BODY(struct TapeInfo *tape, FILE *file, int chunk_size) 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 (tape->file_version == FILE_VERSION_1_0) { /* eliminate possible diagonal moves in old tapes */ @@ -1929,6 +1905,49 @@ void SaveTape(int level_nr) Request("tape saved !", REQ_CONFIRM); } +void DumpTape(struct TapeInfo *tape) +{ + int i, j; + + if (TAPE_IS_EMPTY(*tape)) + { + Error(ERR_WARN, "no tape available for level %d", tape->level_nr); + return; + } + + printf("\n"); + printf("-------------------------------------------------------------------------------\n"); + printf("TAPE OF LEVEL %d\n", tape->level_nr); + printf("-------------------------------------------------------------------------------\n"); + + for(i=0; ilength; i++) + { + if (i >= MAX_TAPELEN) + break; + + for(j=0; jplayer_participates[j]) + { + int action = tape->pos[i].action[j]; + + printf("%d:%02x ", j, action); + printf("[%c%c%c%c|%c%c] - ", + (action & JOY_LEFT ? '<' : ' '), + (action & JOY_RIGHT ? '>' : ' '), + (action & JOY_UP ? '^' : ' '), + (action & JOY_DOWN ? 'v' : ' '), + (action & JOY_BUTTON_1 ? '1' : ' '), + (action & JOY_BUTTON_2 ? '2' : ' ')); + } + } + + printf("(%03d)\n", tape->pos[i].delay); + } + + printf("-------------------------------------------------------------------------------\n"); +} + void LoadScore(int level_nr) { int i; diff --git a/src/files.h b/src/files.h index 53000668..bd593b5a 100644 --- a/src/files.h +++ b/src/files.h @@ -21,6 +21,7 @@ void SaveLevel(int); void LoadTape(int); void SaveTape(int); +void DumpTape(struct TapeInfo *); void LoadScore(int); void SaveScore(int); diff --git a/src/game.c b/src/game.c index 50ffaf16..423fc4c8 100644 --- a/src/game.c +++ b/src/game.c @@ -942,12 +942,12 @@ void GameWon() if (TimeLeft) { - if (setup.sound_loops) + if (!tape.playing && setup.sound_loops) PlaySoundExt(SND_SIRR, PSND_MAX_VOLUME, PSND_MAX_RIGHT, PSND_LOOP); while(TimeLeft > 0) { - if (!setup.sound_loops) + if (!tape.playing && !setup.sound_loops) PlaySoundStereo(SND_SIRR, PSND_MAX_RIGHT); if (TimeLeft > 0 && !(TimeLeft % 10)) RaiseScore(level.score[SC_ZEITBONUS]); @@ -957,20 +957,22 @@ void GameWon() TimeLeft--; DrawText(DX_TIME, DY_TIME, int2str(TimeLeft, 3), FS_SMALL, FC_YELLOW); BackToFront(); - Delay(10); + + if (!tape.playing) + Delay(10); } - if (setup.sound_loops) + if (!tape.playing && setup.sound_loops) StopSound(SND_SIRR); } else if (level.time == 0) /* level without time limit */ { - if (setup.sound_loops) + if (!tape.playing && setup.sound_loops) PlaySoundExt(SND_SIRR, PSND_MAX_VOLUME, PSND_MAX_RIGHT, PSND_LOOP); while(TimePlayed < 999) { - if (!setup.sound_loops) + if (!tape.playing && !setup.sound_loops) PlaySoundStereo(SND_SIRR, PSND_MAX_RIGHT); if (TimePlayed < 999 && !(TimePlayed % 10)) RaiseScore(level.score[SC_ZEITBONUS]); @@ -980,10 +982,12 @@ void GameWon() TimePlayed++; DrawText(DX_TIME, DY_TIME, int2str(TimePlayed, 3), FS_SMALL, FC_YELLOW); BackToFront(); - Delay(10); + + if (!tape.playing) + Delay(10); } - if (setup.sound_loops) + if (!tape.playing && setup.sound_loops) StopSound(SND_SIRR); } @@ -4207,7 +4211,9 @@ static void PlayerActions(struct PlayerInfo *player, byte player_action) { static byte stored_player_action[MAX_PLAYERS]; static int num_stored_actions = 0; +#if 0 static boolean save_tape_entry = FALSE; +#endif boolean moved = FALSE, snapped = FALSE, bombed = FALSE; int left = player_action & JOY_LEFT; int right = player_action & JOY_RIGHT; @@ -4247,9 +4253,7 @@ static void PlayerActions(struct PlayerInfo *player, byte player_action) 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 */