gfx.c/h: consistent indentation

This commit is contained in:
wdlkmpx 2021-01-14 21:03:50 +08:00
parent c1989eec10
commit efce62f435
2 changed files with 375 additions and 358 deletions

View File

@ -45,15 +45,18 @@ gint xy_to_cell_number(gint x, gint y) {
return find_node_of_x_y(x, y, rules_get_width());
}
gint get_jump_phase(gint x, gint y) {
if(!_animation_in_progress || xy_to_cell_number(x, y) != _jumping_ball)
if (!_animation_in_progress || xy_to_cell_number(x, y) != _jumping_ball) {
return 0;
}
return _phase;
}
void set_jump_phase(gint p) {
if(!_animation_in_progress)
if (!_animation_in_progress) {
return;
}
_phase = p;
}
@ -72,7 +75,8 @@ void update_rectangle(gint x, gint y, gint w, gint h) {
_pixmap, x, y, x, y, w, h);
}
void draw_ball_no_update(gint ballcolor, gint x, gint y, gint jumpnum, gint destroynum) {
void draw_ball_no_update(gint ballcolor, gint x, gint y, gint jumpnum, gint destroynum)
{
GtkWidget *widget = mw_get_da();
GdkGC *gc = widget->style->fg_gc[gtk_widget_get_state(widget)];
gint cxs = gtkbTheme->emptycell.xsize;
@ -158,14 +162,16 @@ void draw_board(void) {
}
gint inc_with_limit(gint val, gint lim) {
if(val < lim)
if (val < lim) {
return val + 1;
}
return lim;
}
gint dec_with_limit(gint val, gint lim) {
if(val > lim)
if (val > lim) {
return val - 1;
}
return lim;
}
@ -194,15 +200,17 @@ void stop_jumping_animation(void) {
}
}
void move_pointer_to(gint x, gint y) {
void move_pointer_to(gint x, gint y)
{
gint i, jp, dp, xc = _pointer_x, yc = _pointer_y;
if(x >= rules_get_width() || y >= rules_get_height() || x < 0 || y < 0)
if (x >= rules_get_width() || y >= rules_get_height() || x < 0 || y < 0) {
/* "boundary check" */
return;
if(_pointer_x == x && _pointer_y == y)
}
if (_pointer_x == x && _pointer_y == y) {
return;
}
_pointer_x = x;
_pointer_y = y;
for (i = 0; i < 2; i++) {
@ -219,17 +227,21 @@ void move_pointer_to(gint x, gint y) {
void move_pointer(Direction dir) {
gint xn = _pointer_x, yn = _pointer_y;
if(dir == DIR_LEFT || dir == DIR_UP_LEFT || dir == DIR_DOWN_LEFT)
if (dir == DIR_LEFT || dir == DIR_UP_LEFT || dir == DIR_DOWN_LEFT) {
xn = dec_with_limit(_pointer_x, 0);
if(dir == DIR_RIGHT || dir == DIR_UP_RIGHT || dir == DIR_DOWN_RIGHT)
}
if (dir == DIR_RIGHT || dir == DIR_UP_RIGHT || dir == DIR_DOWN_RIGHT) {
xn = inc_with_limit(_pointer_x, rules_get_width() - 1);
if(dir == DIR_UP || dir == DIR_UP_LEFT || dir == DIR_UP_RIGHT)
}
if (dir == DIR_UP || dir == DIR_UP_LEFT || dir == DIR_UP_RIGHT) {
yn = dec_with_limit(_pointer_y, 0);
if(dir == DIR_DOWN || dir == DIR_DOWN_LEFT || dir == DIR_DOWN_RIGHT)
}
if (dir == DIR_DOWN || dir == DIR_DOWN_LEFT || dir == DIR_DOWN_RIGHT) {
yn = inc_with_limit(_pointer_y, rules_get_height() - 1);
if(xn == _pointer_x && yn == _pointer_y)
}
if (xn == _pointer_x && yn == _pointer_y) {
return;
}
move_pointer_to(xn, yn);
}
@ -308,7 +320,8 @@ void reinit_board(gint *newboard, gint *newnext, gint score, gint oldnext) {
void remake_board(gint numoldchilds, gboolean isnextvalid) {
gint cxs, cys, i;
if(numoldchilds && numoldchilds != rules_get_next()) {
if (numoldchilds && numoldchilds != rules_get_next())
{
if (_small_balls) {
for (i = 0; i < numoldchilds; i++) {
gtk_widget_destroy(_small_balls[i]);
@ -364,7 +377,8 @@ gint expose_event(GtkWidget *widget, GdkEventExpose *event) {
return FALSE;
}
void find_pawnum_and_direction(gint pawx, gint pawy, gint x, gint y, gint *pawnum, gint *direction) {
void find_pawnum_and_direction(gint pawx, gint pawy, gint x, gint y, gint *pawnum, gint *direction)
{
if (pawy < y) {
*pawnum = 2;
if (*direction == 1) *pawnum = 6;
@ -413,7 +427,8 @@ gboolean have_path(gint source_ball, gint target_ball) {
return 1;
}
void move_ball(gint source_ball, gint target_ball) {
void move_ball(gint source_ball, gint target_ball)
{
gint nodes[rules_get_width() * rules_get_height()];
gint path[rules_get_width() * rules_get_height()];
gint pawx = -1, pawy = -1;
@ -439,9 +454,11 @@ void move_ball(gint source_ball, gint target_ball) {
phase = 0;
draw_ball(0, x, y, 0, 0);
if(pref_get_show_path()) {
if (pref_get_show_path())
{
lock_actions(1);
for(k = path[0] - 1; k; k--) {
for (k = path[0] - 1; k; k--)
{
gettimeofday(&tvs, NULL);
find_x_y_of_the_node(&i, &j, path[k], rules_get_width(), rules_get_height());
if (k == path[0] - 1) {