Re-ran indent on all .c & .h source code files
Like so --
find . -name "*.c" -or -name "*.h" -exec indent -nbfda -npcs -npsl -bli0 --no-tabs {} \;
The `indent` invocation differs from the last one noted in
CHANGES.txt (from 2006!?), in that I've added "--no-tabs",
to ensure indents are all space-based.
This commit is contained in:
parent
09f332367f
commit
cc05925d9e
99 changed files with 31659 additions and 27102 deletions
|
|
@ -60,18 +60,23 @@ char *reflection_get_name(magic_api * api, int which);
|
|||
int reflection_get_group(magic_api * api, int which);
|
||||
char *reflection_get_description(magic_api * api, int which, int mode);
|
||||
void reflection_drag(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int ox, int oy, int x, int y, SDL_Rect * update_rect);
|
||||
void do_reflection(magic_api * api, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int x, int y, SDL_Rect * update_rect, int show_origin);
|
||||
SDL_Surface * last, int ox, int oy, int x, int y,
|
||||
SDL_Rect * update_rect);
|
||||
void do_reflection(magic_api * api, SDL_Surface * canvas, SDL_Surface * last,
|
||||
int x, int y, SDL_Rect * update_rect, int show_origin);
|
||||
void reflection_click(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas, SDL_Surface * last, int x, int y, SDL_Rect * update_rect);
|
||||
void reflection_release(magic_api * api, int which,
|
||||
SDL_Surface * canvas, SDL_Surface * last, int x, int y, SDL_Rect * update_rect);
|
||||
SDL_Surface * canvas, SDL_Surface * last, int x, int y,
|
||||
SDL_Rect * update_rect);
|
||||
void reflection_release(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int x, int y,
|
||||
SDL_Rect * update_rect);
|
||||
void reflection_shutdown(magic_api * api);
|
||||
void reflection_set_color(magic_api * api, Uint8 r, Uint8 g, Uint8 b);
|
||||
int reflection_requires_colors(magic_api * api, int which);
|
||||
void reflection_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
void reflection_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
void reflection_switchin(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
void reflection_switchout(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
int reflection_modes(magic_api * api, int which);
|
||||
|
||||
|
||||
|
|
@ -80,7 +85,8 @@ int reflection_init(magic_api * api)
|
|||
{
|
||||
char fname[1024];
|
||||
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/reflection.ogg", api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/reflection.ogg",
|
||||
api->data_directory);
|
||||
reflection_snd = Mix_LoadWAV(fname);
|
||||
|
||||
return (1);
|
||||
|
|
@ -105,30 +111,38 @@ SDL_Surface *reflection_get_icon(magic_api * api, int which ATTRIBUTE_UNUSED)
|
|||
return (IMG_Load(fname));
|
||||
}
|
||||
|
||||
char *reflection_get_name(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
char *reflection_get_name(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return (strdup(gettext_noop("Reflection")));
|
||||
}
|
||||
|
||||
int reflection_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
int reflection_get_group(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return MAGIC_TYPE_PICTURE_WARPS;
|
||||
}
|
||||
|
||||
char *reflection_get_description(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED)
|
||||
char *reflection_get_description(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED,
|
||||
int mode ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return (strdup(gettext_noop("Click and drag the mouse around to add a reflection to your picture.")));
|
||||
return (strdup
|
||||
(gettext_noop
|
||||
("Click and drag the mouse around to add a reflection to your picture.")));
|
||||
}
|
||||
|
||||
void reflection_drag(magic_api * api, int which ATTRIBUTE_UNUSED, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int ox ATTRIBUTE_UNUSED, int oy ATTRIBUTE_UNUSED, int x, int y,
|
||||
SDL_Rect * update_rect)
|
||||
void reflection_drag(magic_api * api, int which ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas, SDL_Surface * last,
|
||||
int ox ATTRIBUTE_UNUSED, int oy ATTRIBUTE_UNUSED, int x,
|
||||
int y, SDL_Rect * update_rect)
|
||||
{
|
||||
do_reflection(api, canvas, last, x, y, update_rect, 1);
|
||||
}
|
||||
|
||||
void do_reflection(magic_api * api, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int x, int y, SDL_Rect * update_rect, int show_origin)
|
||||
SDL_Surface * last, int x, int y, SDL_Rect * update_rect,
|
||||
int show_origin)
|
||||
{
|
||||
float scale;
|
||||
int xx, yy;
|
||||
|
|
@ -149,29 +163,29 @@ void do_reflection(magic_api * api, SDL_Surface * canvas,
|
|||
|
||||
/* Determine what direction to go */
|
||||
if (abs(x - reflection_x1) < 32)
|
||||
{
|
||||
/* +/-32 pixels of wiggle room before we switch from vertical to horizontal */
|
||||
if (y > reflection_y1)
|
||||
reflection_side = REFLECTION_SIDE_BOTTOM;
|
||||
else
|
||||
reflection_side = REFLECTION_SIDE_TOP;
|
||||
}
|
||||
{
|
||||
/* +/-32 pixels of wiggle room before we switch from vertical to horizontal */
|
||||
if (y > reflection_y1)
|
||||
reflection_side = REFLECTION_SIDE_BOTTOM;
|
||||
else
|
||||
reflection_side = REFLECTION_SIDE_TOP;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (x < reflection_x1)
|
||||
reflection_side = REFLECTION_SIDE_LEFT;
|
||||
else
|
||||
reflection_side = REFLECTION_SIDE_RIGHT;
|
||||
}
|
||||
{
|
||||
if (x < reflection_x1)
|
||||
reflection_side = REFLECTION_SIDE_LEFT;
|
||||
else
|
||||
reflection_side = REFLECTION_SIDE_RIGHT;
|
||||
}
|
||||
|
||||
/* If we've changed direction, reset the canvas back
|
||||
to the snapshot before proceeding */
|
||||
if (reflection_side != reflection_side_old)
|
||||
{
|
||||
SDL_BlitSurface(last, NULL, canvas, NULL);
|
||||
reflection_side_old = reflection_side;
|
||||
update_all = 1;
|
||||
}
|
||||
{
|
||||
SDL_BlitSurface(last, NULL, canvas, NULL);
|
||||
reflection_side_old = reflection_side;
|
||||
update_all = 1;
|
||||
}
|
||||
|
||||
|
||||
/* Note: This isn't very good, and I basically
|
||||
|
|
@ -179,173 +193,179 @@ void do_reflection(magic_api * api, SDL_Surface * canvas,
|
|||
well enough. There's a ton of room for improvement!
|
||||
-bjk 2021.11.05 */
|
||||
if (reflection_side == REFLECTION_SIDE_BOTTOM)
|
||||
{
|
||||
/* Starting from `reflection_y1` and moving down,
|
||||
we'll copy from `reflection_y1` and moving up */
|
||||
|
||||
scale = (float) reflection_y1 / (float) y;
|
||||
|
||||
for (yy = reflection_y1; yy < canvas->h; yy++)
|
||||
{
|
||||
/* Starting from `reflection_y1` and moving down,
|
||||
we'll copy from `reflection_y1` and moving up */
|
||||
dest.x = 0;
|
||||
dest.y = yy;
|
||||
dest.w = canvas->w;
|
||||
dest.h = 1;
|
||||
|
||||
scale = (float) reflection_y1 / (float) y;
|
||||
src.x = 0;
|
||||
src.y = (reflection_y1 * scale) + ((y - yy) * scale);
|
||||
src.w = canvas->w;
|
||||
src.h = 1;
|
||||
|
||||
for (yy = reflection_y1; yy < canvas->h; yy++)
|
||||
{
|
||||
dest.x = 0;
|
||||
dest.y = yy;
|
||||
dest.w = canvas->w;
|
||||
dest.h = 1;
|
||||
if (src.y < 0)
|
||||
{
|
||||
src.y = yy;
|
||||
}
|
||||
|
||||
src.x = 0;
|
||||
src.y = (reflection_y1 * scale) + ((y - yy) * scale);
|
||||
src.w = canvas->w;
|
||||
src.h = 1;
|
||||
|
||||
if (src.y < 0)
|
||||
{
|
||||
src.y = yy;
|
||||
}
|
||||
|
||||
SDL_BlitSurface(last, &src, canvas, &dest);
|
||||
}
|
||||
|
||||
update_rect->x = 0;
|
||||
update_rect->y = reflection_y1;
|
||||
update_rect->w = canvas->w;
|
||||
update_rect->h = canvas->h - reflection_y1 + 1;
|
||||
SDL_BlitSurface(last, &src, canvas, &dest);
|
||||
}
|
||||
|
||||
update_rect->x = 0;
|
||||
update_rect->y = reflection_y1;
|
||||
update_rect->w = canvas->w;
|
||||
update_rect->h = canvas->h - reflection_y1 + 1;
|
||||
}
|
||||
else if (reflection_side == REFLECTION_SIDE_TOP)
|
||||
{
|
||||
/* Starting from `reflection_y1` and moving up,
|
||||
we'll copy from `reflection_y1` and moving down */
|
||||
|
||||
scale = ((float) reflection_y1 / (float) y);
|
||||
|
||||
for (yy = reflection_y1; yy >= 0; yy--)
|
||||
{
|
||||
/* Starting from `reflection_y1` and moving up,
|
||||
we'll copy from `reflection_y1` and moving down */
|
||||
dest.x = 0;
|
||||
dest.y = yy;
|
||||
dest.w = canvas->w;
|
||||
dest.h = 1;
|
||||
|
||||
scale = ((float) reflection_y1 / (float) y);
|
||||
src.x = 0;
|
||||
src.y = (reflection_y1 / scale) + (y * scale) - (yy / scale);
|
||||
src.w = canvas->w;
|
||||
src.h = 1;
|
||||
|
||||
for (yy = reflection_y1; yy >= 0; yy--)
|
||||
{
|
||||
dest.x = 0;
|
||||
dest.y = yy;
|
||||
dest.w = canvas->w;
|
||||
dest.h = 1;
|
||||
if (src.y >= canvas->h)
|
||||
{
|
||||
src.y = yy;
|
||||
}
|
||||
|
||||
src.x = 0;
|
||||
src.y = (reflection_y1 / scale) + (y * scale) - (yy / scale);
|
||||
src.w = canvas->w;
|
||||
src.h = 1;
|
||||
|
||||
if (src.y >= canvas->h)
|
||||
{
|
||||
src.y = yy;
|
||||
}
|
||||
|
||||
SDL_BlitSurface(last, &src, canvas, &dest);
|
||||
}
|
||||
|
||||
update_rect->x = 0;
|
||||
update_rect->y = 0;
|
||||
update_rect->w = canvas->w;
|
||||
update_rect->h = reflection_y1;
|
||||
SDL_BlitSurface(last, &src, canvas, &dest);
|
||||
}
|
||||
|
||||
update_rect->x = 0;
|
||||
update_rect->y = 0;
|
||||
update_rect->w = canvas->w;
|
||||
update_rect->h = reflection_y1;
|
||||
}
|
||||
else if (reflection_side == REFLECTION_SIDE_RIGHT)
|
||||
{
|
||||
/* Starting from `reflection_x1` and moving right,
|
||||
we'll copy from `reflection_x1` and moving left */
|
||||
|
||||
scale = (float) reflection_x1 / (float) x;
|
||||
|
||||
for (xx = reflection_x1; xx < canvas->w; xx++)
|
||||
{
|
||||
/* Starting from `reflection_x1` and moving right,
|
||||
we'll copy from `reflection_x1` and moving left */
|
||||
dest.x = xx;
|
||||
dest.y = 0;
|
||||
dest.w = 1;
|
||||
dest.h = canvas->h;
|
||||
|
||||
scale = (float) reflection_x1 / (float) x;
|
||||
src.x = (reflection_x1 * scale) + ((x - xx) * scale);
|
||||
src.y = 0;
|
||||
src.w = 1;
|
||||
src.h = canvas->h;
|
||||
|
||||
for (xx = reflection_x1; xx < canvas->w; xx++)
|
||||
{
|
||||
dest.x = xx;
|
||||
dest.y = 0;
|
||||
dest.w = 1;
|
||||
dest.h = canvas->h;
|
||||
if (src.x < 0)
|
||||
{
|
||||
src.x = xx;
|
||||
}
|
||||
|
||||
src.x = (reflection_x1 * scale) + ((x - xx) * scale);
|
||||
src.y = 0;
|
||||
src.w = 1;
|
||||
src.h = canvas->h;
|
||||
|
||||
if (src.x < 0)
|
||||
{
|
||||
src.x = xx;
|
||||
}
|
||||
|
||||
SDL_BlitSurface(last, &src, canvas, &dest);
|
||||
}
|
||||
|
||||
update_rect->x = reflection_x1;
|
||||
update_rect->y = 0;
|
||||
update_rect->w = canvas->w - reflection_x1 + 1;
|
||||
update_rect->h = canvas->h;
|
||||
SDL_BlitSurface(last, &src, canvas, &dest);
|
||||
}
|
||||
|
||||
update_rect->x = reflection_x1;
|
||||
update_rect->y = 0;
|
||||
update_rect->w = canvas->w - reflection_x1 + 1;
|
||||
update_rect->h = canvas->h;
|
||||
}
|
||||
else if (reflection_side == REFLECTION_SIDE_LEFT)
|
||||
{
|
||||
/* Starting from `reflection_x1` and left up,
|
||||
we'll copy from `reflection_x1` and right down */
|
||||
|
||||
scale = (float) reflection_x1 / (float) x;
|
||||
|
||||
for (xx = reflection_x1; xx >= 0; xx--)
|
||||
{
|
||||
/* Starting from `reflection_x1` and left up,
|
||||
we'll copy from `reflection_x1` and right down */
|
||||
dest.x = xx;
|
||||
dest.y = 0;
|
||||
dest.w = 1;
|
||||
dest.h = canvas->h;
|
||||
|
||||
scale = (float) reflection_x1 / (float) x;
|
||||
src.x = (reflection_x1 / scale) + (x * scale) - (xx / scale);
|
||||
src.y = 0;
|
||||
src.w = 1;
|
||||
src.h = canvas->h;
|
||||
|
||||
for (xx = reflection_x1; xx >= 0; xx--)
|
||||
{
|
||||
dest.x = xx;
|
||||
dest.y = 0;
|
||||
dest.w = 1;
|
||||
dest.h = canvas->h;
|
||||
if (src.x >= canvas->w)
|
||||
{
|
||||
src.x = xx;
|
||||
}
|
||||
|
||||
src.x = (reflection_x1 / scale) + (x * scale) - (xx / scale);
|
||||
src.y = 0;
|
||||
src.w = 1;
|
||||
src.h = canvas->h;
|
||||
|
||||
if (src.x >= canvas->w)
|
||||
{
|
||||
src.x = xx;
|
||||
}
|
||||
|
||||
SDL_BlitSurface(last, &src, canvas, &dest);
|
||||
}
|
||||
|
||||
update_rect->x = 0;
|
||||
update_rect->y = 0;
|
||||
update_rect->w = reflection_x1;
|
||||
update_rect->h = canvas->h;
|
||||
SDL_BlitSurface(last, &src, canvas, &dest);
|
||||
}
|
||||
|
||||
update_rect->x = 0;
|
||||
update_rect->y = 0;
|
||||
update_rect->w = reflection_x1;
|
||||
update_rect->h = canvas->h;
|
||||
}
|
||||
|
||||
/* TODO: Support reflecting at arbitrary angles!
|
||||
(a la linear gradient fill tool) */
|
||||
|
||||
if (update_all)
|
||||
{
|
||||
update_rect->x = 0;
|
||||
update_rect->y = 0;
|
||||
update_rect->w = canvas->w;
|
||||
update_rect->h = canvas->h;
|
||||
}
|
||||
{
|
||||
update_rect->x = 0;
|
||||
update_rect->y = 0;
|
||||
update_rect->w = canvas->w;
|
||||
update_rect->h = canvas->h;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (yy = reflection_y1 - REFLECTION_XOR_SIZE;
|
||||
yy < reflection_y1 + REFLECTION_XOR_SIZE; yy++)
|
||||
{
|
||||
for (yy = reflection_y1 - REFLECTION_XOR_SIZE; yy < reflection_y1 + REFLECTION_XOR_SIZE; yy++)
|
||||
{
|
||||
if (show_origin)
|
||||
api->xorpixel(canvas, reflection_x1, yy);
|
||||
else
|
||||
api->putpixel(canvas, reflection_x1, yy, api->getpixel(last, reflection_x1, yy));
|
||||
}
|
||||
|
||||
for (xx = reflection_x1 - REFLECTION_XOR_SIZE; xx < reflection_x1 + REFLECTION_XOR_SIZE; xx++)
|
||||
{
|
||||
if (show_origin)
|
||||
api->xorpixel(canvas, xx, reflection_y1);
|
||||
else
|
||||
api->putpixel(canvas, xx, reflection_y1, api->getpixel(last, xx, reflection_y1));
|
||||
}
|
||||
|
||||
update_rect->x -= REFLECTION_XOR_SIZE;
|
||||
update_rect->w += (REFLECTION_XOR_SIZE * 2);
|
||||
update_rect->y -= REFLECTION_XOR_SIZE;
|
||||
update_rect->h += (REFLECTION_XOR_SIZE * 2);
|
||||
if (show_origin)
|
||||
api->xorpixel(canvas, reflection_x1, yy);
|
||||
else
|
||||
api->putpixel(canvas, reflection_x1, yy,
|
||||
api->getpixel(last, reflection_x1, yy));
|
||||
}
|
||||
|
||||
api->playsound(reflection_snd, (x * 255) / canvas->w, (y * 255) / canvas->h);
|
||||
for (xx = reflection_x1 - REFLECTION_XOR_SIZE;
|
||||
xx < reflection_x1 + REFLECTION_XOR_SIZE; xx++)
|
||||
{
|
||||
if (show_origin)
|
||||
api->xorpixel(canvas, xx, reflection_y1);
|
||||
else
|
||||
api->putpixel(canvas, xx, reflection_y1,
|
||||
api->getpixel(last, xx, reflection_y1));
|
||||
}
|
||||
|
||||
update_rect->x -= REFLECTION_XOR_SIZE;
|
||||
update_rect->w += (REFLECTION_XOR_SIZE * 2);
|
||||
update_rect->y -= REFLECTION_XOR_SIZE;
|
||||
update_rect->h += (REFLECTION_XOR_SIZE * 2);
|
||||
}
|
||||
|
||||
api->playsound(reflection_snd, (x * 255) / canvas->w,
|
||||
(y * 255) / canvas->h);
|
||||
}
|
||||
|
||||
void reflection_click(magic_api * api, int which, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas, SDL_Surface * last, int x, int y, SDL_Rect * update_rect)
|
||||
SDL_Surface * canvas, SDL_Surface * last, int x, int y,
|
||||
SDL_Rect * update_rect)
|
||||
{
|
||||
if (x <= 0)
|
||||
x = 1;
|
||||
|
|
@ -365,8 +385,8 @@ void reflection_click(magic_api * api, int which, int mode ATTRIBUTE_UNUSED,
|
|||
}
|
||||
|
||||
void reflection_release(magic_api * api, int which ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas, SDL_Surface * last,
|
||||
int x, int y, SDL_Rect * update_rect)
|
||||
SDL_Surface * canvas, SDL_Surface * last,
|
||||
int x, int y, SDL_Rect * update_rect)
|
||||
{
|
||||
do_reflection(api, canvas, last, x, y, update_rect, 0);
|
||||
}
|
||||
|
|
@ -377,29 +397,35 @@ void reflection_shutdown(magic_api * api ATTRIBUTE_UNUSED)
|
|||
Mix_FreeChunk(reflection_snd);
|
||||
}
|
||||
|
||||
void reflection_set_color(magic_api * api ATTRIBUTE_UNUSED, Uint8 r ATTRIBUTE_UNUSED, Uint8 g ATTRIBUTE_UNUSED,
|
||||
Uint8 b ATTRIBUTE_UNUSED)
|
||||
void reflection_set_color(magic_api * api ATTRIBUTE_UNUSED,
|
||||
Uint8 r ATTRIBUTE_UNUSED, Uint8 g ATTRIBUTE_UNUSED,
|
||||
Uint8 b ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
int reflection_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
int reflection_requires_colors(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void reflection_switchin(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas)
|
||||
void reflection_switchin(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED,
|
||||
int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas)
|
||||
{
|
||||
reflection_x1 = canvas->w / 2;
|
||||
reflection_y1 = canvas->h / 2;
|
||||
}
|
||||
|
||||
void reflection_switchout(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
void reflection_switchout(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED,
|
||||
int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
int reflection_modes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
int reflection_modes(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return MODE_PAINT;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue