X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Ftools.c;h=6b8ae64696af23dee2a8be92a643ba4a6bae91e0;hb=8f33ee4940b9c35bf4627b7ef1126d03748da646;hp=932df515bd7080d4cd4c671a4e204930d5eb2210;hpb=2a8b100c02ff1e102b30cb5f0e9345ba531e06c2;p=rocksndiamonds.git diff --git a/src/tools.c b/src/tools.c index 932df515..6b8ae646 100644 --- a/src/tools.c +++ b/src/tools.c @@ -91,8 +91,8 @@ void RedrawPlayfield(boolean force_redraw, int x, int y, int width, int height) if (setup.direct_draw) SetDrawtoField(DRAW_BACKBUFFER); - for(xx=BX1; xx<=BX2; xx++) - for(yy=BY1; yy<=BY2; yy++) + for (xx = BX1; xx <= BX2; xx++) + for (yy = BY1; yy <= BY2; yy++) if (xx >= x1 && xx <= x2 && yy >= y1 && yy <= y2) DrawScreenField(xx, yy); DrawAllPlayers(); @@ -263,8 +263,8 @@ void BackToFront() if (redraw_mask & REDRAW_TILES) { - for(x=0; xuse_murphy_graphic) + { + /* this works only because currently only one player can be "murphy" ... */ + static int last_horizontal_dir = MV_LEFT; + int graphic = el_act_dir2img(EL_SP_MURPHY, player->GfxAction, move_dir); + + if (move_dir == MV_LEFT || move_dir == MV_RIGHT) + last_horizontal_dir = move_dir; + + if (graphic == IMG_SP_MURPHY) /* undefined => use special graphic */ + { + int direction = (player->is_snapping ? move_dir : last_horizontal_dir); + + graphic = el_act_dir2img(EL_SP_MURPHY, player->GfxAction, direction); + } + + return graphic; + } + else + return el_act_dir2img(player->element_nr, player->GfxAction, move_dir); +} + +static boolean equalGraphics(int graphic1, int graphic2) +{ + struct GraphicInfo *g1 = &graphic_info[graphic1]; + struct GraphicInfo *g2 = &graphic_info[graphic2]; + + return (g1->bitmap == g2->bitmap && + g1->src_x == g2->src_x && + g1->src_y == g2->src_y && + g1->anim_frames == g2->anim_frames && + g1->anim_delay == g2->anim_delay && + g1->anim_mode == g2->anim_mode); +} + void DrawAllPlayers() { int i; - for(i=0; iFrame; int frame = 0; if (!player->active || !IN_SCR_FIELD(SCREENX(last_jx), SCREENY(last_jy))) @@ -589,15 +628,12 @@ void DrawPlayer(struct PlayerInfo *player) if (element == EL_EXPLOSION) return; - action = (player->is_pushing ? ACTION_PUSHING : - player->is_digging ? ACTION_DIGGING : - player->is_collecting ? ACTION_COLLECTING : - player->is_moving ? ACTION_MOVING : - player->is_snapping ? ACTION_SNAPPING : ACTION_DEFAULT); - -#if 0 - printf("::: '%s'\n", element_action_info[action].suffix); -#endif + action = (player->is_pushing ? ACTION_PUSHING : + player->is_digging ? ACTION_DIGGING : + player->is_collecting ? ACTION_COLLECTING : + player->is_moving ? ACTION_MOVING : + player->is_snapping ? ACTION_SNAPPING : + player->is_waiting ? player->action_waiting : ACTION_DEFAULT); InitPlayerGfxAnimation(player, action, move_dir); @@ -672,6 +708,17 @@ void DrawPlayer(struct PlayerInfo *player) /* draw player himself */ /* ----------------------------------------------------------------------- */ +#if 1 + + graphic = getPlayerGraphic(player, move_dir); + + /* in the case of changed player action or direction, prevent the current + animation frame from being restarted for identical animations */ + if (player->Frame == 0 && equalGraphics(graphic, last_player_graphic)) + player->Frame = last_player_frame; + +#else + if (player->use_murphy_graphic) { static int last_horizontal_dir = MV_LEFT; @@ -691,6 +738,8 @@ void DrawPlayer(struct PlayerInfo *player) else graphic = el_act_dir2img(player->element_nr, player->GfxAction, move_dir); +#endif + frame = getGraphicAnimationFrame(graphic, player->Frame); if (player->GfxPos) @@ -743,7 +792,11 @@ void DrawPlayer(struct PlayerInfo *player) { int element = MovingOrBlocked2Element(next_jx, next_jy); int graphic = el_act_dir2img(element, ACTION_PUSHING, move_dir); +#if 1 + int frame = getGraphicAnimationFrame(graphic, player->StepFrame); +#else int frame = getGraphicAnimationFrame(graphic, player->Frame); +#endif DrawGraphicShifted(px, py, sxx, syy, graphic, frame, NO_CUTTING, NO_MASKING); @@ -1068,7 +1121,7 @@ void DrawScreenElementExt(int x, int y, int dx, int dy, int element, { SetRandomAnimationValue(lx, ly); - graphic = el_act_dir2img(element, GfxAction[lx][ly], MovDir[lx][ly]); + graphic = el_act_dir2img(element, GfxAction[lx][ly], GfxDir[lx][ly]); frame = getGraphicAnimationFrame(graphic, GfxFrame[lx][ly]); } else /* border element */ @@ -1178,7 +1231,7 @@ static void DrawLevelFieldCrumbledSandExt(int x, int y, int graphic, int frame) getGraphicSource(graphic, frame, &src_bitmap, &src_x, &src_y); - for(i=0; i<4; i++) + for (i = 0; i < 4; i++) { int xx = x + xy[i][0]; int yy = y + xy[i][1]; @@ -1223,7 +1276,7 @@ static void DrawLevelFieldCrumbledSandExt(int x, int y, int graphic, int frame) getGraphicSource(graphic, frame, &src_bitmap, &src_x, &src_y); #endif - for(i=0; i<4; i++) + for (i = 0; i < 4; i++) { int xx = x + xy[i][0]; int yy = y + xy[i][1]; @@ -1312,7 +1365,7 @@ void DrawLevelFieldCrumbledSandNeighbours(int x, int y) }; int i; - for(i=0; i<4; i++) + for (i = 0; i < 4; i++) { int xx = x + xy[i][0]; int yy = y + xy[i][1]; @@ -1560,7 +1613,7 @@ void AnimateEnvelope(int envelope_nr, int anim_mode, int action) int ystep = (ystart < yend || xstep == 0 ? 1 : 0); int x, y; - for (x=xstart, y=ystart; x <= xend && y <= yend; x += xstep, y += ystep) + for (x = xstart, y = ystart; x <= xend && y <= yend; x += xstep, y += ystep) { int xsize = (action == ACTION_CLOSING ? xend - (x - xstart) : x) + 2; int ysize = (action == ACTION_CLOSING ? yend - (y - ystart) : y) + 2; @@ -1574,7 +1627,7 @@ void AnimateEnvelope(int envelope_nr, int anim_mode, int action) SetDrawtoField(DRAW_BACKBUFFER); - for (yy=0; yy < ysize; yy++) for (xx=0; xx < xsize; xx++) + for (yy = 0; yy < ysize; yy++) for (xx = 0; xx < xsize; xx++) DrawEnvelopeBackground(envelope_nr, sx,sy, xx,yy, xsize, ysize, font_nr); DrawTextToTextArea(SX + sx + font_width, SY + sy + font_height, @@ -1661,8 +1714,8 @@ void DrawLevel() SetDrawBackgroundMask(REDRAW_NONE); ClearWindow(); - for(x=BX1; x<=BX2; x++) - for(y=BY1; y<=BY2; y++) + for (x = BX1; x <= BX2; x++) + for (y = BY1; y <= BY2; y++) DrawScreenField(x, y); redraw_mask |= REDRAW_FIELD; @@ -1672,8 +1725,8 @@ void DrawMiniLevel(int size_x, int size_y, int scroll_x, int scroll_y) { int x,y; - for(x=0; x MAX_REQUEST_LINE_FONT1_LEN) + { + max_request_line_len = MAX_REQUEST_LINE_FONT2_LEN; + font_nr = FONT_LEVEL_NUMBER; + + break; + } + } #if 1 SetMouseCursor(CURSOR_DEFAULT); @@ -1951,15 +2022,15 @@ boolean Request(char *text, unsigned int req_state) game_status = GAME_MODE_PSEUDO_DOOR; /* write text for request */ - for(ty=0; ty < MAX_REQUEST_LINES; ty++) + for (ty = 0; ty < MAX_REQUEST_LINES; ty++) { - char text_line[MAX_REQUEST_LINE_LEN + 1]; - int tx, tl, tc; + char text_line[max_request_line_len + 1]; + int tx, tl, tc = 0; if (!*text) break; - for(tl=0,tx=0; tx < MAX_REQUEST_LINE_LEN; tl++,tx++) + for (tl = 0, tx = 0; tx < max_request_line_len; tl++, tx++) { tc = *(text + tx); if (!tc || tc == ' ') @@ -1976,9 +2047,9 @@ boolean Request(char *text, unsigned int req_state) strncpy(text_line, text, tl); text_line[tl] = 0; - DrawText(DX + (DXSIZE - tl * getFontWidth(FONT_TEXT_2)) / 2, - DY + 8 + ty * (getFontHeight(FONT_TEXT_2) + 2), - text_line, FONT_TEXT_2); + DrawText(DX + (DXSIZE - tl * getFontWidth(font_nr)) / 2, + DY + 8 + ty * (getFontHeight(font_nr) + 2), + text_line, font_nr); text += tl + (tc == ' ' ? 1 : 0); } @@ -2033,7 +2104,7 @@ boolean Request(char *text, unsigned int req_state) SetMouseCursor(CURSOR_DEFAULT); #endif - while(result < 0) + while (result < 0) { if (PendingEvent()) { @@ -2288,7 +2359,7 @@ unsigned int MoveDoor(unsigned int door_state) PlaySoundStereo(SND_DOOR_CLOSING, SOUND_MIDDLE); } - for(x = start; x <= end && !(door_1_done && door_2_done); x += stepsize) + for (x = start; x <= end && !(door_1_done && door_2_done); x += stepsize) { Bitmap *bitmap = graphic_info[IMG_GLOBAL_DOOR].bitmap; GC gc = bitmap->stored_clip_gc; @@ -2605,7 +2676,7 @@ void CreateToolButtons() { int i; - for (i=0; i