X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Ftools.c;h=6b8ae64696af23dee2a8be92a643ba4a6bae91e0;hb=8f33ee4940b9c35bf4627b7ef1126d03748da646;hp=0244e944d3d0f0d9644ef82a989ecd8b4be8cd14;hpb=7373e992fb880976e1dc7c559bcd7a19b8bcfe80;p=rocksndiamonds.git diff --git a/src/tools.c b/src/tools.c index 0244e944..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; xis_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_sleeping ? ACTION_SLEEPING : - player->is_bored ? ACTION_BORING : - player->is_waiting ? ACTION_WAITING : ACTION_DEFAULT); - - if (player->is_sleeping) - { - if (player->num_special_action_sleeping > 0) - { - if (player->anim_delay_counter == 0 && player->post_delay_counter == 0) - { - int special_action = - ACTION_BORING_1 + SimpleRND(player->num_special_action_sleeping); - int special_graphic = - el_act_dir2img(player->element_nr, special_action, move_dir); - - player->anim_delay_counter = - graphic_info[special_graphic].anim_delay_fixed + - SimpleRND(graphic_info[special_graphic].anim_delay_random); - player->post_delay_counter = - graphic_info[special_graphic].post_delay_fixed + - SimpleRND(graphic_info[special_graphic].post_delay_random); - - player->special_action_sleeping = special_action; - } - - if (player->anim_delay_counter > 0) - { - action = player->special_action_sleeping; - player->anim_delay_counter--; - } - else if (player->post_delay_counter > 0) - { - player->post_delay_counter--; - } - } - } - else if (player->is_bored) - { - if (player->num_special_action_bored > 0) - { - if (player->anim_delay_counter == 0 && player->post_delay_counter == 0) - { - int special_action = - ACTION_BORING_1 + SimpleRND(player->num_special_action_bored); - int special_graphic = - el_act_dir2img(player->element_nr, special_action, move_dir); - - player->anim_delay_counter = - graphic_info[special_graphic].anim_delay_fixed + - SimpleRND(graphic_info[special_graphic].anim_delay_random); - player->post_delay_counter = - graphic_info[special_graphic].post_delay_fixed + - SimpleRND(graphic_info[special_graphic].post_delay_random); - - player->special_action_bored = special_action; - } - - if (player->anim_delay_counter > 0) - { - action = player->special_action_bored; - player->anim_delay_counter--; - } - else if (player->post_delay_counter > 0) - { - player->post_delay_counter--; - } - } - } - - return action; -} - static int getPlayerGraphic(struct PlayerInfo *player, int move_dir) { if (player->use_murphy_graphic) @@ -649,7 +570,7 @@ void DrawAllPlayers() { int i; - for(i=0; iis_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_sleeping ? ACTION_SLEEPING : - player->is_bored ? ACTION_BORING : - player->is_waiting ? ACTION_WAITING : ACTION_DEFAULT); - - if (player->is_bored && player->num_special_action_bored > 0) - { - if (player->anim_delay_counter == 0 && player->post_delay_counter == 0) - { - int graphic_waiting; - - action = ACTION_BORING_1 + SimpleRND(player->num_special_action_bored); - special_graphic = el_act_dir2img(EL_SP_MURPHY, action, move_dir); - - player->anim_delay_counter = - graphic_info[special_graphic].anim_delay_fixed + - SimpleRND(graphic_info[special_graphic].anim_delay_random); - player->post_delay_counter = - graphic_info[special_graphic].post_delay_fixed + - SimpleRND(graphic_info[special_graphic].post_delay_random); - player->special_action_bored = action; - } - - if (player->anim_delay_counter > 0) - { - action = player->special_action_bored; - player->anim_delay_counter--; - } - - if (player->post_delay_counter > 0) - { - player->post_delay_counter--; - } - } -#endif - -#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); @@ -1353,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]; @@ -1398,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]; @@ -1487,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]; @@ -1735,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; @@ -1749,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, @@ -1836,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; @@ -1847,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); @@ -2126,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 == ' ') @@ -2151,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); } @@ -2208,7 +2104,7 @@ boolean Request(char *text, unsigned int req_state) SetMouseCursor(CURSOR_DEFAULT); #endif - while(result < 0) + while (result < 0) { if (PendingEvent()) { @@ -2463,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; @@ -2780,7 +2676,7 @@ void CreateToolButtons() { int i; - for (i=0; i