Adding "indent.sh" to re-indent code; ran it!!!
This commit is contained in:
parent
16336cc854
commit
18f9cad6fe
98 changed files with 5798 additions and 9001 deletions
|
|
@ -49,8 +49,7 @@ char *grass_get_name(magic_api * api, int which);
|
|||
int grass_get_group(magic_api * api, int which);
|
||||
char *grass_get_description(magic_api * api, int which, int mode);
|
||||
void grass_drag(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int ox, int oy, int x, int y,
|
||||
SDL_Rect * update_rect);
|
||||
SDL_Surface * last, int ox, int oy, int x, int y, SDL_Rect * update_rect);
|
||||
void grass_click(magic_api * api, int which, int mode, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int x, int y, SDL_Rect * update_rect);
|
||||
void grass_release(magic_api * api, int which, SDL_Surface * canvas,
|
||||
|
|
@ -59,29 +58,25 @@ void grass_shutdown(magic_api * api);
|
|||
void grass_set_color(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect);
|
||||
int grass_requires_colors(magic_api * api, int which);
|
||||
static void do_grass(void *ptr, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int x, int y);
|
||||
static void do_grass(void *ptr, int which, SDL_Surface * canvas, SDL_Surface * last, int x, int y);
|
||||
static int log2int(int x);
|
||||
void grass_switchin(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
void grass_switchout(magic_api * api, int which, int mode,
|
||||
SDL_Surface * canvas);
|
||||
void grass_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
void grass_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas);
|
||||
int grass_modes(magic_api * api, int which);
|
||||
Uint8 grass_accepted_sizes(magic_api * api, int which, int mode);
|
||||
Uint8 grass_default_size(magic_api * api, int which, int mode);
|
||||
void grass_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size, SDL_Rect * update_rect);
|
||||
void grass_set_size(magic_api * api, int which, int mode, SDL_Surface * canvas, SDL_Surface * last, Uint8 size,
|
||||
SDL_Rect * update_rect);
|
||||
|
||||
// No setup required:
|
||||
int grass_init(magic_api * api, Uint32 disabled_features ATTRIBUTE_UNUSED)
|
||||
{
|
||||
char fname[1024];
|
||||
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/grass.wav",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%ssounds/magic/grass.wav", api->data_directory);
|
||||
grass_snd = Mix_LoadWAV(fname);
|
||||
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/grass_data.png",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/grass_data.png", api->data_directory);
|
||||
img_grass = IMG_Load(fname);
|
||||
|
||||
return (1);
|
||||
|
|
@ -105,43 +100,35 @@ SDL_Surface *grass_get_icon(magic_api * api, int which ATTRIBUTE_UNUSED)
|
|||
{
|
||||
char fname[1024];
|
||||
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/grass.png",
|
||||
api->data_directory);
|
||||
snprintf(fname, sizeof(fname), "%simages/magic/grass.png", api->data_directory);
|
||||
|
||||
return (IMG_Load(fname));
|
||||
}
|
||||
|
||||
// Return our names, localized:
|
||||
char *grass_get_name(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
char *grass_get_name(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return (strdup(gettext_noop("Grass")));
|
||||
}
|
||||
|
||||
// Return our groups:
|
||||
int grass_get_group(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int grass_get_group(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return MAGIC_TYPE_PAINTING;
|
||||
}
|
||||
|
||||
// Return our descriptions, localized:
|
||||
char *grass_get_description(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED,
|
||||
int mode ATTRIBUTE_UNUSED)
|
||||
char *grass_get_description(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return (strdup
|
||||
(gettext_noop
|
||||
("Click and drag to draw grass. Don’t forget the dirt!")));
|
||||
return (strdup(gettext_noop("Click and drag to draw grass. Don’t forget the dirt!")));
|
||||
}
|
||||
|
||||
|
||||
// Affect the canvas on drag:
|
||||
void grass_drag(magic_api * api, int which, SDL_Surface * canvas,
|
||||
SDL_Surface * last, int ox, int oy, int x, int y,
|
||||
SDL_Rect * update_rect)
|
||||
SDL_Surface * last, int ox, int oy, int x, int y, SDL_Rect * update_rect)
|
||||
{
|
||||
api->line((void *) api, which, canvas, last, ox, oy, x, y, 4, do_grass);
|
||||
api->line((void *)api, which, canvas, last, ox, oy, x, y, 4, do_grass);
|
||||
|
||||
if (ox > x)
|
||||
{
|
||||
|
|
@ -168,8 +155,7 @@ void grass_drag(magic_api * api, int which, SDL_Surface * canvas,
|
|||
|
||||
// Affect the canvas on click:
|
||||
void grass_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)
|
||||
{
|
||||
grass_drag(api, which, canvas, last, x, y, x, y, update_rect);
|
||||
}
|
||||
|
|
@ -178,8 +164,7 @@ void grass_release(magic_api * api ATTRIBUTE_UNUSED,
|
|||
int which ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * last ATTRIBUTE_UNUSED,
|
||||
int x ATTRIBUTE_UNUSED, int y ATTRIBUTE_UNUSED,
|
||||
SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
int x ATTRIBUTE_UNUSED, int y ATTRIBUTE_UNUSED, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -191,8 +176,9 @@ void grass_shutdown(magic_api * api ATTRIBUTE_UNUSED)
|
|||
}
|
||||
|
||||
// Record the color from Tux Paint:
|
||||
void grass_set_color(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * last ATTRIBUTE_UNUSED, Uint8 r, Uint8 g, Uint8 b, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
void grass_set_color(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED, SDL_Surface * last ATTRIBUTE_UNUSED, Uint8 r, Uint8 g,
|
||||
Uint8 b, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
{
|
||||
grass_r = r;
|
||||
grass_g = g;
|
||||
|
|
@ -200,15 +186,13 @@ void grass_set_color(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSE
|
|||
}
|
||||
|
||||
// Use colors:
|
||||
int grass_requires_colors(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED)
|
||||
int grass_requires_colors(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void do_grass(void *ptr, int which ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas,
|
||||
SDL_Surface * last ATTRIBUTE_UNUSED, int x, int y)
|
||||
SDL_Surface * canvas, SDL_Surface * last ATTRIBUTE_UNUSED, int x, int y)
|
||||
{
|
||||
magic_api *api = (magic_api *) ptr;
|
||||
int xx, yy;
|
||||
|
|
@ -221,12 +205,10 @@ static void do_grass(void *ptr, int which ATTRIBUTE_UNUSED,
|
|||
|
||||
if (!api->button_down())
|
||||
bucket = 0;
|
||||
bucket += (3.5 + (rand() / (double) RAND_MAX)) * 7.0;
|
||||
bucket += (3.5 + (rand() / (double)RAND_MAX)) * 7.0;
|
||||
while (bucket >= 0)
|
||||
{
|
||||
int rank =
|
||||
log2int(((double) y / canvas->h) *
|
||||
(0.99 + (rand() / (double) RAND_MAX)) * 64);
|
||||
int rank = log2int(((double)y / canvas->h) * (0.99 + (rand() / (double)RAND_MAX)) * 64);
|
||||
int ah = 1 << rank;
|
||||
|
||||
bucket -= ah;
|
||||
|
|
@ -236,12 +218,10 @@ static void do_grass(void *ptr, int which ATTRIBUTE_UNUSED,
|
|||
src.h = ah;
|
||||
|
||||
dest.x = x - 32;
|
||||
dest.y = y - 30 + (int) ((rand() / (double) RAND_MAX) * 30);
|
||||
dest.y = y - 30 + (int)((rand() / (double)RAND_MAX) * 30);
|
||||
|
||||
tmp_red =
|
||||
api->sRGB_to_linear(grass_r) * 2.0 + (rand() / (double) RAND_MAX);
|
||||
tmp_green =
|
||||
api->sRGB_to_linear(grass_g) * 2.0 + (rand() / (double) RAND_MAX);
|
||||
tmp_red = api->sRGB_to_linear(grass_r) * 2.0 + (rand() / (double)RAND_MAX);
|
||||
tmp_green = api->sRGB_to_linear(grass_g) * 2.0 + (rand() / (double)RAND_MAX);
|
||||
tmp_blue = api->sRGB_to_linear(grass_b) * 2.0 + api->sRGB_to_linear(17);
|
||||
|
||||
for (yy = 0; yy < ah; yy++)
|
||||
|
|
@ -250,8 +230,7 @@ static void do_grass(void *ptr, int which ATTRIBUTE_UNUSED,
|
|||
{
|
||||
double rd, gd, bd;
|
||||
|
||||
SDL_GetRGBA(api->getpixel(img_grass, xx + src.x, yy + src.y),
|
||||
img_grass->format, &r, &g, &b, &a);
|
||||
SDL_GetRGBA(api->getpixel(img_grass, xx + src.x, yy + src.y), img_grass->format, &r, &g, &b, &a);
|
||||
|
||||
rd = api->sRGB_to_linear(r) * 8.0 + tmp_red;
|
||||
rd = rd * (a / 255.0) / 11.0;
|
||||
|
|
@ -260,21 +239,13 @@ static void do_grass(void *ptr, int which ATTRIBUTE_UNUSED,
|
|||
bd = api->sRGB_to_linear(b) * 8.0 + tmp_blue;
|
||||
bd = bd * (a / 255.0) / 11.0;
|
||||
|
||||
SDL_GetRGB(api->getpixel(canvas, xx + dest.x, yy + dest.y),
|
||||
canvas->format, &r, &g, &b);
|
||||
SDL_GetRGB(api->getpixel(canvas, xx + dest.x, yy + dest.y), canvas->format, &r, &g, &b);
|
||||
|
||||
r =
|
||||
api->linear_to_sRGB(api->sRGB_to_linear(r) * (1.0 - a / 255.0) +
|
||||
rd);
|
||||
g =
|
||||
api->linear_to_sRGB(api->sRGB_to_linear(g) * (1.0 - a / 255.0) +
|
||||
gd);
|
||||
b =
|
||||
api->linear_to_sRGB(api->sRGB_to_linear(b) * (1.0 - a / 255.0) +
|
||||
bd);
|
||||
r = api->linear_to_sRGB(api->sRGB_to_linear(r) * (1.0 - a / 255.0) + rd);
|
||||
g = api->linear_to_sRGB(api->sRGB_to_linear(g) * (1.0 - a / 255.0) + gd);
|
||||
b = api->linear_to_sRGB(api->sRGB_to_linear(b) * (1.0 - a / 255.0) + bd);
|
||||
|
||||
api->putpixel(canvas, xx + dest.x, yy + dest.y,
|
||||
SDL_MapRGB(canvas->format, r, g, b));
|
||||
api->putpixel(canvas, xx + dest.x, yy + dest.y, SDL_MapRGB(canvas->format, r, g, b));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -297,14 +268,12 @@ static int log2int(int x)
|
|||
}
|
||||
|
||||
void grass_switchin(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
void grass_switchout(magic_api * api ATTRIBUTE_UNUSED,
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
@ -325,6 +294,8 @@ Uint8 grass_default_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_U
|
|||
return 0;
|
||||
}
|
||||
|
||||
void grass_set_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED, SDL_Surface * canvas ATTRIBUTE_UNUSED, SDL_Surface * last ATTRIBUTE_UNUSED, Uint8 size ATTRIBUTE_UNUSED, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
void grass_set_size(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSED, int mode ATTRIBUTE_UNUSED,
|
||||
SDL_Surface * canvas ATTRIBUTE_UNUSED, SDL_Surface * last ATTRIBUTE_UNUSED,
|
||||
Uint8 size ATTRIBUTE_UNUSED, SDL_Rect * update_rect ATTRIBUTE_UNUSED)
|
||||
{
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue