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:
Bill Kendrick 2022-09-15 00:11:16 -07:00
parent 09f332367f
commit cc05925d9e
99 changed files with 31659 additions and 27102 deletions

View file

@ -64,13 +64,18 @@ typedef struct
float x, y;
} Point2D;
static void tornado_predrag(magic_api * api, SDL_Surface * canvas, SDL_Surface * last, int ox, int oy, int x, int y);
static void tornado_predrag(magic_api * api, SDL_Surface * canvas,
SDL_Surface * last, int ox, int oy, int x, int y);
static void tornado_drawbase(magic_api * api, SDL_Surface * canvas);
static void tornado_drawstalk(magic_api * api, SDL_Surface * canvas, SDL_Surface * last,
int top_x, int top_y, int minx, int maxx, int bottom_x, int bottom_y, int final);
static void tornado_drawtornado(magic_api * api, SDL_Surface * canvas, int x, int y);
static void tornado_drawstalk(magic_api * api, SDL_Surface * canvas,
SDL_Surface * last, int top_x, int top_y,
int minx, int maxx, int bottom_x, int bottom_y,
int final);
static void tornado_drawtornado(magic_api * api, SDL_Surface * canvas, int x,
int y);
static Point2D tornado_PointOnCubicBezier(Point2D * cp, float t);
static void tornado_ComputeBezier(Point2D * cp, int numberOfPoints, Point2D * curve);
static void tornado_ComputeBezier(Point2D * cp, int numberOfPoints,
Point2D * curve);
static void tornado_colorize_cloud(magic_api * api);
static Uint32 tornado_mess(Uint32 pixel, SDL_Surface * canvas);
Uint32 tornado_api_version(void);
@ -88,17 +93,21 @@ char *tornado_get_description(magic_api * api, int which, int mode);
void tornado_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 tornado_click(magic_api * api, int which, int mode,
SDL_Surface * canvas, SDL_Surface * last, int x, int y, SDL_Rect * update_rect);
void tornado_release(magic_api * api, int which,
SDL_Surface * canvas, SDL_Surface * last, int x, int y, SDL_Rect * update_rect);
SDL_Surface * last, int ox, int oy, int x, int y,
SDL_Rect * update_rect);
void tornado_click(magic_api * api, int which, int mode, SDL_Surface * canvas,
SDL_Surface * last, int x, int y, SDL_Rect * update_rect);
void tornado_release(magic_api * api, int which, SDL_Surface * canvas,
SDL_Surface * last, int x, int y,
SDL_Rect * update_rect);
void tornado_shutdown(magic_api * api);
void tornado_set_color(magic_api * api, Uint8 r, Uint8 g, Uint8 b);
int tornado_requires_colors(magic_api * api, int which);
void tornado_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas);
void tornado_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas);
void tornado_switchin(magic_api * api, int which, int mode,
SDL_Surface * canvas);
void tornado_switchout(magic_api * api, int which, int mode,
SDL_Surface * canvas);
int tornado_modes(magic_api * api, int which);
@ -120,13 +129,16 @@ int tornado_init(magic_api * api)
tornado_click_snd = Mix_LoadWAV(fname);
*/
snprintf(fname, sizeof(fname), "%ssounds/magic/tornado_release.ogg", api->data_directory);
snprintf(fname, sizeof(fname), "%ssounds/magic/tornado_release.ogg",
api->data_directory);
tornado_release_snd = Mix_LoadWAV(fname);
snprintf(fname, sizeof(fname), "%simages/magic/tornado_base.png", api->data_directory);
snprintf(fname, sizeof(fname), "%simages/magic/tornado_base.png",
api->data_directory);
tornado_base = IMG_Load(fname);
snprintf(fname, sizeof(fname), "%simages/magic/tornado_cloud.png", api->data_directory);
snprintf(fname, sizeof(fname), "%simages/magic/tornado_cloud.png",
api->data_directory);
tornado_cloud = IMG_Load(fname);
return (1);
@ -143,32 +155,41 @@ SDL_Surface *tornado_get_icon(magic_api * api, int which ATTRIBUTE_UNUSED)
{
char fname[1024];
snprintf(fname, sizeof(fname), "%simages/magic/tornado.png", api->data_directory);
snprintf(fname, sizeof(fname), "%simages/magic/tornado.png",
api->data_directory);
return (IMG_Load(fname));
}
// Return our names, localized:
char *tornado_get_name(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
char *tornado_get_name(magic_api * api ATTRIBUTE_UNUSED,
int which ATTRIBUTE_UNUSED)
{
return (strdup(gettext_noop("Tornado")));
}
// Return our groups:
int tornado_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
int tornado_get_group(magic_api * api ATTRIBUTE_UNUSED,
int which ATTRIBUTE_UNUSED)
{
return MAGIC_TYPE_ARTISTIC;
}
// Return our descriptions, localized:
char *tornado_get_description(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED)
char *tornado_get_description(magic_api * api ATTRIBUTE_UNUSED,
int which ATTRIBUTE_UNUSED,
int mode ATTRIBUTE_UNUSED)
{
return (strdup(gettext_noop("Click and drag to draw a tornado funnel on your picture.")));
return (strdup
(gettext_noop
("Click and drag to draw a tornado funnel on your picture.")));
}
// Affect the canvas on drag:
static void tornado_predrag(magic_api * api ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED,
SDL_Surface * last ATTRIBUTE_UNUSED, int ox, int oy, int x, int y)
static void tornado_predrag(magic_api * api ATTRIBUTE_UNUSED,
SDL_Surface * canvas ATTRIBUTE_UNUSED,
SDL_Surface * last ATTRIBUTE_UNUSED, int ox,
int oy, int x, int y)
{
if (x < tornado_min_x)
tornado_min_x = x;
@ -187,22 +208,23 @@ static void tornado_predrag(magic_api * api ATTRIBUTE_UNUSED, SDL_Surface * canv
// Determine which way to bend first:
//
if (tornado_side_decided == 0)
{
if (x < tornado_bottom_x - 10)
{
if (x < tornado_bottom_x - 10)
{
tornado_side_first = SIDE_LEFT;
tornado_side_decided = 1;
}
else if (x > tornado_bottom_x + 10)
{
tornado_side_first = SIDE_RIGHT;
tornado_side_decided = 1;
}
tornado_side_first = SIDE_LEFT;
tornado_side_decided = 1;
}
else if (x > tornado_bottom_x + 10)
{
tornado_side_first = SIDE_RIGHT;
tornado_side_decided = 1;
}
}
}
void tornado_drag(magic_api * api, int which ATTRIBUTE_UNUSED, SDL_Surface * canvas,
SDL_Surface * last, int ox, int oy, int x, int y, SDL_Rect * update_rect)
void tornado_drag(magic_api * api, int which ATTRIBUTE_UNUSED,
SDL_Surface * canvas, SDL_Surface * last, int ox, int oy,
int x, int y, SDL_Rect * update_rect)
{
tornado_predrag(api, canvas, last, ox, oy, x, y);
@ -215,7 +237,8 @@ void tornado_drag(magic_api * api, int which ATTRIBUTE_UNUSED, SDL_Surface * can
/* Draw the base and the stalk (low-quality) for now: */
tornado_drawstalk(api, canvas, last,
x, y, tornado_min_x, tornado_max_x, tornado_bottom_x, tornado_bottom_y, !(api->button_down()));
x, y, tornado_min_x, tornado_max_x, tornado_bottom_x,
tornado_bottom_y, !(api->button_down()));
tornado_drawbase(api, canvas);
@ -227,7 +250,8 @@ void tornado_drag(magic_api * api, int which ATTRIBUTE_UNUSED, SDL_Surface * can
// Affect the canvas on click:
void tornado_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)
{
tornado_min_x = x;
tornado_max_x = x;
@ -246,7 +270,8 @@ void tornado_click(magic_api * api, int which, int mode ATTRIBUTE_UNUSED,
// Affect the canvas on release:
void tornado_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)
{
/* Don't let tornado be too low compared to base: */
@ -266,7 +291,8 @@ void tornado_release(magic_api * api, int which ATTRIBUTE_UNUSED,
/* Draw high-quality stalk, and tornado: */
tornado_drawstalk(api, canvas, last, x, y, tornado_min_x, tornado_max_x, tornado_bottom_x, tornado_bottom_y, 1);
tornado_drawstalk(api, canvas, last, x, y, tornado_min_x, tornado_max_x,
tornado_bottom_x, tornado_bottom_y, 1);
tornado_drawtornado(api, canvas, x, y);
@ -282,7 +308,8 @@ void tornado_release(magic_api * api, int which ATTRIBUTE_UNUSED,
}
static void tornado_drawtornado(magic_api * api, SDL_Surface * canvas, int x, int y)
static void tornado_drawtornado(magic_api * api, SDL_Surface * canvas, int x,
int y)
{
SDL_Surface *aux_surf;
SDL_Rect dest;
@ -295,7 +322,8 @@ static void tornado_drawtornado(magic_api * api, SDL_Surface * canvas, int x, in
SDL_FreeSurface(aux_surf);
}
static void tornado_drawbase(magic_api * api ATTRIBUTE_UNUSED, SDL_Surface * canvas)
static void tornado_drawbase(magic_api * api ATTRIBUTE_UNUSED,
SDL_Surface * canvas)
{
SDL_Rect dest;
@ -308,16 +336,19 @@ static void tornado_drawbase(magic_api * api ATTRIBUTE_UNUSED, SDL_Surface * can
static Uint32 tornado_mess(Uint32 pixel, SDL_Surface * canvas)
{
Uint8 r, g, b, a;
float f = (float)rand() * 255 / RAND_MAX;
float f = (float) rand() * 255 / RAND_MAX;
SDL_GetRGBA(pixel, canvas->format, &r, &g, &b, &a);
return (SDL_MapRGBA(canvas->format,
(tornado_r + r + (Uint8) f * 2) / 4,
(tornado_g + g + (Uint8) f * 2) / 4, (tornado_b + b + (Uint8) f * 2) / 4, a));
(tornado_g + g + (Uint8) f * 2) / 4,
(tornado_b + b + (Uint8) f * 2) / 4, a));
}
static void tornado_drawstalk(magic_api * api, SDL_Surface * canvas, SDL_Surface * last,
int top_x, int top_y, int minx, int maxx, int bottom_x, int bottom_y, int final)
static void tornado_drawstalk(magic_api * api, SDL_Surface * canvas,
SDL_Surface * last, int top_x, int top_y,
int minx, int maxx, int bottom_x, int bottom_y,
int final)
{
Point2D control_points[4];
Point2D *curve;
@ -335,15 +366,15 @@ static void tornado_drawstalk(magic_api * api, SDL_Surface * canvas, SDL_Surface
control_points[0].y = top_y;
if (tornado_side_first == SIDE_LEFT)
{
control_points[1].x = minx;
control_points[2].x = maxx;
}
{
control_points[1].x = minx;
control_points[2].x = maxx;
}
else
{
control_points[1].x = maxx;
control_points[2].x = minx;
}
{
control_points[1].x = maxx;
control_points[2].x = minx;
}
control_points[1].y = ((bottom_y - top_y) / 3) + top_y;
control_points[2].y = (((bottom_y - top_y) / 3) * 2) + top_y;
@ -367,58 +398,68 @@ static void tornado_drawstalk(magic_api * api, SDL_Surface * canvas, SDL_Surface
/* Draw the curve: */
for (i = 0; i < n_points - 1; i++)
{
if (final == 0)
{
if (final == 0)
{
dest.x = curve[i].x;
dest.y = curve[i].y;
dest.w = 2;
dest.h = 2;
SDL_FillRect(canvas, &dest, SDL_MapRGB(canvas->format, 0, 0, 0));
}
else
{
ii = n_points - i;
/* min 10 pixels then ii^2 / 2000 or 4 * ii^2 / canvas->w,
don't let the top of funnel be wider than the half of canvas */
if (n_points * n_points / 2000 > canvas->w / 4)
ww = 4 * n_points * n_points / canvas->w;
else
ww = 2000;
left = min(curve[i].x, curve[i + 1].x) - 5 - ii * ii / ww;
right = max(curve[i].x, curve[i + 1].x) + 5 + ii * ii / ww;
dest.x = left;
dest.y = curve[i].y;
dest.w = right - left + 1;
dest.h = 2;
}
rotation += 3;
/* The body of the tornado: 3x 1y rotation + some random particles */
for (p = dest.x; p < dest.x + dest.w; p++)
{
if ((float)rand() * 100 / RAND_MAX > 10)
{
api->putpixel(canvas, p, dest.y, api->getpixel(last, dest.x + (p - dest.x + rotation) % dest.w, dest.y));
}
else
{
api->putpixel(canvas, p, dest.y,
tornado_mess(api->getpixel(last, dest.x + (p - dest.x + rotation) % dest.w, dest.y),
canvas));
}
}
/* Some random particles flying around the tornado */
for (p = dest.x - dest.w * 20 / 100; p < dest.x + dest.w + dest.w * 20 / 100; p++)
{
if ((float)rand() * 100 / RAND_MAX < 5 && ((p < dest.x) || (p > dest.w)))
api->putpixel(canvas, p, dest.y,
tornado_mess(api->getpixel(last, dest.x + (p - dest.x + rotation) % dest.w, dest.y), canvas));
}
dest.x = curve[i].x;
dest.y = curve[i].y;
dest.w = 2;
dest.h = 2;
SDL_FillRect(canvas, &dest, SDL_MapRGB(canvas->format, 0, 0, 0));
}
else
{
ii = n_points - i;
/* min 10 pixels then ii^2 / 2000 or 4 * ii^2 / canvas->w,
don't let the top of funnel be wider than the half of canvas */
if (n_points * n_points / 2000 > canvas->w / 4)
ww = 4 * n_points * n_points / canvas->w;
else
ww = 2000;
left = min(curve[i].x, curve[i + 1].x) - 5 - ii * ii / ww;
right = max(curve[i].x, curve[i + 1].x) + 5 + ii * ii / ww;
dest.x = left;
dest.y = curve[i].y;
dest.w = right - left + 1;
dest.h = 2;
}
rotation += 3;
/* The body of the tornado: 3x 1y rotation + some random particles */
for (p = dest.x; p < dest.x + dest.w; p++)
{
if ((float) rand() * 100 / RAND_MAX > 10)
{
api->putpixel(canvas, p, dest.y,
api->getpixel(last,
dest.x + (p - dest.x + rotation) % dest.w,
dest.y));
}
else
{
api->putpixel(canvas, p, dest.y,
tornado_mess(api->getpixel(last,
dest.x + (p - dest.x +
rotation) % dest.w,
dest.y), canvas));
}
}
/* Some random particles flying around the tornado */
for (p = dest.x - dest.w * 20 / 100;
p < dest.x + dest.w + dest.w * 20 / 100; p++)
{
if ((float) rand() * 100 / RAND_MAX < 5
&& ((p < dest.x) || (p > dest.w)))
api->putpixel(canvas, p, dest.y,
tornado_mess(api->getpixel(last,
dest.x + (p - dest.x +
rotation) % dest.w,
dest.y), canvas));
}
}
free(curve);
}
@ -452,7 +493,8 @@ void tornado_set_color(magic_api * api, Uint8 r, Uint8 g, Uint8 b)
}
// Use colors:
int tornado_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
int tornado_requires_colors(magic_api * api ATTRIBUTE_UNUSED,
int which ATTRIBUTE_UNUSED)
{
return 1;
}
@ -507,7 +549,8 @@ static Point2D tornado_PointOnCubicBezier(Point2D * cp, float t)
<sizeof(Point2D) numberOfPoints>
*/
static void tornado_ComputeBezier(Point2D * cp, int numberOfPoints, Point2D * curve)
static void tornado_ComputeBezier(Point2D * cp, int numberOfPoints,
Point2D * curve)
{
float dt;
int i;
@ -530,7 +573,9 @@ static void tornado_colorize_cloud(magic_api * api)
/* Create a surface to render into: */
amask = ~(tornado_cloud->format->Rmask | tornado_cloud->format->Gmask | tornado_cloud->format->Bmask);
amask =
~(tornado_cloud->format->Rmask | tornado_cloud->format->
Gmask | tornado_cloud->format->Bmask);
tornado_cloud_colorized =
SDL_CreateRGBSurface(SDL_SWSURFACE,
@ -538,7 +583,8 @@ static void tornado_colorize_cloud(magic_api * api)
tornado_cloud->h,
tornado_cloud->format->BitsPerPixel,
tornado_cloud->format->Rmask,
tornado_cloud->format->Gmask, tornado_cloud->format->Bmask, amask);
tornado_cloud->format->Gmask,
tornado_cloud->format->Bmask, amask);
/* Render the new cloud: */
@ -546,33 +592,39 @@ static void tornado_colorize_cloud(magic_api * api)
SDL_LockSurface(tornado_cloud_colorized);
for (y = 0; y < tornado_cloud->h; y++)
{
for (x = 0; x < tornado_cloud->w; x++)
{
for (x = 0; x < tornado_cloud->w; x++)
{
SDL_GetRGBA(api->getpixel(tornado_cloud, x, y), tornado_cloud->format, &r, &g, &b, &a);
SDL_GetRGBA(api->getpixel(tornado_cloud, x, y), tornado_cloud->format,
&r, &g, &b, &a);
api->putpixel(tornado_cloud_colorized, x, y,
SDL_MapRGBA(tornado_cloud_colorized->format,
(tornado_r + r * 2) / 3, (tornado_g + g * 2) / 3, (tornado_b + b * 2) / 3, a));
}
api->putpixel(tornado_cloud_colorized, x, y,
SDL_MapRGBA(tornado_cloud_colorized->format,
(tornado_r + r * 2) / 3,
(tornado_g + g * 2) / 3,
(tornado_b + b * 2) / 3, a));
}
}
SDL_UnlockSurface(tornado_cloud_colorized);
SDL_UnlockSurface(tornado_cloud);
}
void tornado_switchin(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
void tornado_switchin(magic_api * api ATTRIBUTE_UNUSED,
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
SDL_Surface * canvas ATTRIBUTE_UNUSED)
{
}
void tornado_switchout(magic_api * api, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
void tornado_switchout(magic_api * api, int which ATTRIBUTE_UNUSED,
int mode ATTRIBUTE_UNUSED,
SDL_Surface * canvas ATTRIBUTE_UNUSED)
{
api->stopsound();
}
int tornado_modes(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
int tornado_modes(magic_api * api ATTRIBUTE_UNUSED,
int which ATTRIBUTE_UNUSED)
{
return (MODE_PAINT_WITH_PREVIEW);
}