чување ca58f46524a0bf0ee04eb4ea7957e0e1c3a7b999
родитељ da394a98e43e7bca983b16130e399f2ddc7985ae
Аутор: Страхиња Радић <sr@strahinja.org>
Датум: Tue, 25 Aug 2026 17:08:47 +0000
linije.c: Get rid of unnecessary variables
Diffstat:
| M | linije.c | | | 50 | +++++++++++++++++++------------------------------- |
измењених датотека: 1, додавања: 19(+), брисања: 31(-)
diff --git a/linije.c b/linije.c
@@ -1602,8 +1602,6 @@ render_background(struct State* state, SDL_FRect* bg_rect)
const SDL_DisplayMode* mode;
SDL_FRect cell_rect, dest_rect;
SDL_DisplayID display;
- float crx, cry;
- float drx, dry;
int x, y;
assert((state != NULL) && (bg_rect != NULL));
@@ -1640,18 +1638,16 @@ render_background(struct State* state, SDL_FRect* bg_rect)
dest_rect.w = state->cell_scale_factor * CELL_SIZE;
dest_rect.h = state->cell_scale_factor * CELL_SIZE;
- get_sprite_xy(CELL_EMPTY, &crx, &cry);
- cell_rect.x = crx;
- cell_rect.y = cry;
+ get_sprite_xy(CELL_EMPTY, &cell_rect.x, &cell_rect.y);
cell_rect.w = CELL_SIZE;
cell_rect.h = CELL_SIZE;
for (y = 0; y < GRID_HEIGHT; y++)
for (x = 0; x < GRID_WIDTH; x++)
{
grid_coord_to_screen_coord(state, x, y, 0.0f, 0.0f,
- &drx, &dry);
- dest_rect.x = state->cell_scale_factor + drx;
- dest_rect.y = state->cell_scale_factor + dry;
+ &dest_rect.x, &dest_rect.y);
+ dest_rect.x += state->cell_scale_factor;
+ dest_rect.y += state->cell_scale_factor;
SDL_RenderTexture(state->renderer, state->sprites,
&cell_rect, &dest_rect);
}
@@ -1659,9 +1655,10 @@ render_background(struct State* state, SDL_FRect* bg_rect)
/* Draw upper border */
for (x = -1; x < GRID_WIDTH; x++)
{
- grid_coord_to_screen_coord(state, x, -1, 0.0f, 0.0f, &drx, &dry);
- dest_rect.x = state->cell_scale_factor + drx;
- dest_rect.y = state->cell_scale_factor + dry;
+ grid_coord_to_screen_coord(state, x, -1, 0.0f, 0.0f,
+ &dest_rect.x, &dest_rect.y);
+ dest_rect.x += state->cell_scale_factor;
+ dest_rect.y += state->cell_scale_factor;
SDL_RenderTexture(state->renderer, state->sprites, &cell_rect,
&dest_rect);
}
@@ -1669,9 +1666,10 @@ render_background(struct State* state, SDL_FRect* bg_rect)
/* Draw left border */
for (y = 0; y < GRID_WIDTH; y++)
{
- grid_coord_to_screen_coord(state, -1, y, 0.0f, 0.0f, &drx, &dry);
- dest_rect.x = state->cell_scale_factor + drx;
- dest_rect.y = state->cell_scale_factor + dry;
+ grid_coord_to_screen_coord(state, -1, y, 0.0f, 0.0f,
+ &dest_rect.x, &dest_rect.y);
+ dest_rect.x += state->cell_scale_factor;
+ dest_rect.y += state->cell_scale_factor;
SDL_RenderTexture(state->renderer, state->sprites, &cell_rect,
&dest_rect);
}
@@ -1688,8 +1686,6 @@ render_balls(struct State* state, const float startx, const float starty)
struct Cell* c = NULL;
SDL_FRect cell_rect, dest_rect;
float csf;
- float crx, cry;
- float drx, dry;
int x, y;
assert(state != NULL);
@@ -1707,19 +1703,16 @@ render_balls(struct State* state, const float startx, const float starty)
if (c->contents == CELL_EMPTY)
continue;
- get_sprite_xy(c->contents, &crx, &cry);
- cell_rect.x = crx;
- cell_rect.y = cry;
+ get_sprite_xy(c->contents, &cell_rect.x, &cell_rect.y);
if (c->path)
grid_coord_to_screen_coord(state,
state->animation.position.x,
state->animation.position.y, startx + 1,
- starty + 1, &drx, &dry);
+ starty + 1, &dest_rect.x, &dest_rect.y);
else
grid_coord_to_screen_coord(state, x, y,
- startx + 1, starty + 1, &drx, &dry);
- dest_rect.x = drx;
- dest_rect.y = dry;
+ startx + 1, starty + 1, &dest_rect.x,
+ &dest_rect.y);
SDL_RenderTexture(state->renderer, state->sprites,
&cell_rect, &dest_rect);
}
@@ -1822,23 +1815,18 @@ void
render_selection(struct State* state, const float startx, const float starty)
{
SDL_FRect cell_rect, dest_rect;
- float crx, cry;
- float drx, dry;
float csf;
assert(state != NULL);
assert(state->cell_scale_factor != 0.0f);
csf = state->cell_scale_factor;
- get_sprite_xy(CELL_SELECTED, &crx, &cry);
- cell_rect.x = crx;
- cell_rect.y = cry;
+ get_sprite_xy(CELL_SELECTED, &cell_rect.x, &cell_rect.y);
cell_rect.w = CELL_SIZE;
cell_rect.h = CELL_SIZE;
grid_coord_to_screen_coord(state, state->selection_start.x,
- state->selection_start.y, startx + 1, starty + 1, &drx, &dry);
- dest_rect.x = drx;
- dest_rect.y = dry;
+ state->selection_start.y, startx + 1, starty + 1, &dest_rect.x,
+ &dest_rect.y);
dest_rect.w = csf * CELL_SIZE;
dest_rect.h = csf * CELL_SIZE;
SDL_RenderTexture(state->renderer, state->sprites, &cell_rect,