From: Holger Schemel Date: Mon, 28 Sep 1998 16:30:50 +0000 (+0200) Subject: rnd-19980928-4 X-Git-Tag: 1.2.0^2~73 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=cfe0b06c84dc509e45c616c21ca1d5ef71f2304f;p=rocksndiamonds.git rnd-19980928-4 --- diff --git a/src/events.c b/src/events.c index 771efb28..ff86409e 100644 --- a/src/events.c +++ b/src/events.c @@ -273,7 +273,7 @@ void HandleButton(int mx, int my, int button) int sx = (mx - SX) / TILEX; int sy = (my - SY) / TILEY; - if (IN_SCR_FIELD(sx,sy)) + if (IN_VIS_FIELD(sx,sy)) { int x = LEVELX(sx); int y = LEVELY(sy); @@ -728,7 +728,12 @@ void HandleJoystick() { int joystick = Joystick(); int keyboard = key_joystick_mapping; + + /* int joy = (tape.playing ? TapePlayAction() : (joystick | keyboard)); + */ + + int joy = (joystick | keyboard); int left = joy & JOY_LEFT; int right = joy & JOY_RIGHT; int up = joy & JOY_UP; diff --git a/src/files.c b/src/files.c index e3ad459f..284ed51f 100644 --- a/src/files.c +++ b/src/files.c @@ -220,6 +220,7 @@ void LoadLevelTape(int level_nr) char filename[MAX_FILENAME]; char cookie[MAX_FILENAME]; FILE *file; + BOOL levelrec_10 = FALSE; #ifndef MSDOS sprintf(filename,"%s/%s/%d.tape", @@ -233,7 +234,9 @@ void LoadLevelTape(int level_nr) { fgets(cookie,LEVELREC_COOKIE_LEN,file); fgetc(file); - if (strcmp(cookie,LEVELREC_COOKIE)) /* ungültiges Format? */ + if (!strcmp(cookie,LEVELREC_COOKIE_10)) /* old 1.0 tape format */ + levelrec_10 = TRUE; + else if (strcmp(cookie,LEVELREC_COOKIE)) /* unknown tape format */ { fprintf(stderr,"%s: wrong format of level recording file '%s'!\n", progname,filename); @@ -262,10 +265,23 @@ void LoadLevelTape(int level_nr) for(i=0;i=MAX_TAPELEN) + int j; + + if (i >= MAX_TAPELEN) break; - tape.pos[i].joystickdata = fgetc(file); - tape.pos[i].delay = fgetc(file); + + for(j=0; j0) + { + tape.pos[i].joystickdata[j] = MV_NO_MOVING; + continue; + } + tape.pos[i].joystickdata[j] = fgetc(file); + } + + tape.pos[i].delay = fgetc(file); + if (feof(file)) break; } @@ -571,7 +587,11 @@ void SaveLevelTape(int level_nr) for(i=0;ijx, jy = player->jy; int left = player_action & JOY_LEFT; @@ -2721,6 +2723,9 @@ void PlayerActions(struct PlayerInfo *player, int player_action) int dx = (left ? -1 : right ? 1 : 0); int dy = (up ? -1 : down ? 1 : 0); + stored_player_action[player->nr] = 0; + num_stored_actions++; + if (!player->active || player->gone) return; @@ -2741,7 +2746,15 @@ void PlayerActions(struct PlayerInfo *player, int player_action) { if (bombed && !moved) player_action &= JOY_BUTTON; - TapeRecordAction(player_action); + + stored_player_action[player->nr] = player_action; + + /* this allows cycled sequences of PlayerActions() */ + if (num_stored_actions >= MAX_PLAYERS) + { + TapeRecordAction(stored_player_action); + num_stored_actions = 0; + } } else if (tape.playing && snapped) SnapField(player, 0,0); /* stop snapping */ @@ -2757,7 +2770,8 @@ void PlayerActions(struct PlayerInfo *player, int player_action) if (tape.playing && !tape.pausing && !player_action && tape.counter < tape.length) { - int next_joy = tape.pos[tape.counter].joystickdata & (JOY_LEFT|JOY_RIGHT); + int next_joy = + tape.pos[tape.counter].joystickdata[player->nr] & (JOY_LEFT|JOY_RIGHT); if (next_joy == JOY_LEFT || next_joy == JOY_RIGHT) { @@ -2785,6 +2799,7 @@ void GameActions(int player_action) long action_delay_value; int sieb_x = 0, sieb_y = 0; int i, x,y, element; + int *recorded_player_action; if (game_status != PLAYING) return; @@ -2800,16 +2815,25 @@ void GameActions(int player_action) /* main game synchronization point */ WaitUntilDelayReached(&action_delay, action_delay_value); + if (tape.playing) + recorded_player_action = TapePlayAction(); + else + recorded_player_action = NULL; + for(i=0; i=255) + if (tape.pos[tape.counter].delay >= 255) { - tape.pos[tape.counter].joystickdata = 0; + for(i=0; i=tape.length) { TapeStop(); - return(0); + return(NULL); } if (tape.delay_played == tape.pos[tape.counter].delay) { tape.delay_played = 0; tape.counter++; - return(tape.pos[tape.counter-1].joystickdata); + + for(i=0; i