Clean up GCC warnings (2019-08-29 edition)

Updated most parts of the code that were throwing warnings in GCC.
This commit is contained in:
Bill Kendrick 2019-08-30 00:00:18 -07:00
parent 1f2c6c3c4e
commit 7938480174
16 changed files with 110 additions and 141 deletions

View file

@ -1,12 +1,12 @@
/*
alien.c
//
alien, Modifies the colours of the image.
Tux Paint - A simple drawing program for children.
Credits: Andrew Corcoran <akanewbie@gmail.com> inspired by the Alien Map GIMP plugin
Copyright (c) 2002-2007 by Bill Kendrick and others; see AUTHORS.txt
Copyright (c) 2002-2019 by Bill Kendrick and others; see AUTHORS.txt
bill@newbreedsoftware.com
http://www.tuxpaint.org/
@ -25,7 +25,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
(See COPYING.txt)
Last updated: June 6, 2008
Last updated: August 29, 2019
$Id$
*/
@ -168,9 +168,6 @@ static void do_alien_pixel(void *ptr, int which ATTRIBUTE_UNUSED,
// Do the effect for the full image
static void do_alien_full(void *ptr, SDL_Surface * canvas, SDL_Surface * last, int which)
{
magic_api *api = (magic_api *) ptr;
int x, y;
for (y = 0; y < last->h; y++)

View file

@ -4,7 +4,7 @@
Calligraphy Magic Tool Plugin
Tux Paint - A simple drawing program for children.
Copyright (c) 2002-2008 by Bill Kendrick and others; see AUTHORS.txt
Copyright (c) 2002-2019 by Bill Kendrick and others; see AUTHORS.txt
bill@newbreedsoftware.com
http://www.tuxpaint.org/
@ -23,7 +23,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
(See COPYING.txt)
Last updated: July 8, 2008
Last updated: August 29, 2019
$Id$
*/
@ -137,7 +137,6 @@ void calligraphy_drag(magic_api * api, int which ATTRIBUTE_UNUSED, SDL_Surface *
{
Point2D *curve;
int i, n_points, thick, new_thick;
Uint32 colr;
SDL_Rect src, dest;
// if (SDL_GetTicks() < calligraphy_last_time + 5)
@ -184,8 +183,6 @@ void calligraphy_drag(magic_api * api, int which ATTRIBUTE_UNUSED, SDL_Surface *
calligraphy_ComputeBezier(calligraphy_control_points, n_points, curve);
colr = SDL_MapRGB(canvas->format, calligraphy_r, calligraphy_g, calligraphy_b);
new_thick = 40 - min((n_points /* / 2 */ ), 32);
for (i = 0; i < n_points - 1; i++)
@ -218,23 +215,6 @@ void calligraphy_drag(magic_api * api, int which ATTRIBUTE_UNUSED, SDL_Surface *
dest.y = y;
SDL_BlitSurface(calligraphy_colored_brush, &src, canvas, &dest);
/* Old way; using putpixel:
SDL_LockSurface(canvas);
for (j = -(thick / 2); j < (thick / 2) + 1; j++)
{
x = curve[i].x + j;
y = curve[i].y - (j / 2); // 30 degrees
api->putpixel(canvas, x, y, colr);
api->putpixel(canvas, x + 1, y, colr);
api->putpixel(canvas, x, y + 1, colr);
api->putpixel(canvas, x + 1, y + 1, colr);
}
SDL_UnlockSurface(canvas);
*/
}
calligraphy_old_thick = (calligraphy_old_thick + new_thick) / 2;

View file

@ -4,7 +4,7 @@
Emboss Magic Tool Plugin
Tux Paint - A simple drawing program for children.
Copyright (c) 2002-2008 by Bill Kendrick and others; see AUTHORS.txt
Copyright (c) 2002-2019 by Bill Kendrick and others; see AUTHORS.txt
bill@newbreedsoftware.com
http://www.tuxpaint.org/
@ -23,7 +23,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
(See COPYING.txt)
Last updated: July 8, 2008
Last updated: August 29, 2019
$Id$
*/
@ -114,7 +114,7 @@ static void do_emboss(void *ptr, int which ATTRIBUTE_UNUSED, SDL_Surface * canva
magic_api *api = (magic_api *) ptr;
int xx, yy;
Uint8 r1, g1, b1, r2, g2, b2;
int r, g, b;
int r;
float h, s, v;
int avg1, avg2;
@ -139,7 +139,6 @@ static void do_emboss(void *ptr, int which ATTRIBUTE_UNUSED, SDL_Surface * canva
r = 0;
if (r > 255)
r = 255;
g = b = r;
v = (r / 255.0);

View file

@ -1,3 +1,9 @@
/*
* Folds the picture down from the corners.
*
* Last updated: 2019-08-29
*/
//optimized version soon :)
//when "folding" same corner many times it gives strange results. Now it's allowed. Let me know
//if you think it shouldn't be.
@ -138,25 +144,29 @@ void fold_draw(magic_api * api, int which,
right_step_y = (float)(y - left_arm_y) / (float)(left_arm_x - fold_ox);
left_step_x = (float)(x - right_arm_x) / (float)(right_arm_y - fold_oy);
left_step_y = (float)(y - right_arm_y) / (float)(right_arm_y - fold_oy);
left_y = (float)right_arm_y / left_arm_x * (left_arm_x - canvas->w);
right_x = (float)left_arm_x / right_arm_y * (right_arm_y - canvas->h);
for (w = 0; w < canvas->w; w += 0.5)
for (h = 0; h < canvas->h; h += 0.5)
{
dist_x = right_step_x * w + left_step_x * h;
dist_y = right_step_y * w + left_step_y * h;
api->putpixel(canvas, x - dist_x, y - dist_y, api->getpixel(temp, w, h));
}
{
for (h = 0; h < canvas->h; h += 0.5)
{
dist_x = right_step_x * w + left_step_x * h;
dist_y = right_step_y * w + left_step_y * h;
api->putpixel(canvas, x - dist_x, y - dist_y, api->getpixel(temp, w, h));
}
}
// Erasing the triangle.
// The 1 pixel in plus is a workaround for api-line not getting the end in some lines.
if (left_arm_x > canvas->w)
{
left_y = (float)right_arm_y / left_arm_x * (left_arm_x - canvas->w);
for (h = 0; h <= right_arm_y; h++)
api->line((void *)api, which, canvas, snapshot, canvas->w, left_y - h, -1, right_arm_y - h, 1, fold_erase);
}
else if (right_arm_y > canvas->h)
{
right_x = (float)left_arm_x / right_arm_y * (right_arm_y - canvas->h);
for (w = 0; w <= left_arm_x; w++)
api->line((void *)api, which, canvas, snapshot, left_arm_x - w, 0, right_x - w, canvas->h + 1, 1, fold_erase);
}

View file

@ -1,3 +1,9 @@
/*
* Draws fretwork
*
* Last updated: 2019-08-29
*/
#include "tp_magic_api.h"
#include "SDL_image.h"
#include "SDL_mixer.h"
@ -25,7 +31,7 @@
Mix_Chunk *fretwork_snd;
unsigned int img_w, img_h;
unsigned int fretwork_segments_x, fretwork_segments_y; //how many segments do we have?
static int fretwork_math_ceil(int x, int y); //ceil() in cstdlib returns float and is relative slow, so we'll use our one
inline int fretwork_math_ceil(int x, int y); //ceil() in cstdlib returns float and is relative slow, so we'll use our one
static Uint8 *fretwork_status_of_segments; //a place to store an info about bitmap used for selected segment
static char **fretwork_images; //the pathes to all the images needed
static unsigned int fretwork_segment_modified; //which segment was modified this time?
@ -239,7 +245,7 @@ void fretwork_switchout(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UN
// Interactivity functions
static int fretwork_math_ceil(int x, int y)
inline int fretwork_math_ceil(int x, int y)
{
int temp;

View file

@ -8,7 +8,7 @@
Credits: Andrew Corcoran <akanewbie@gmail.com>
Copyright (c) 2002-2009 by Bill Kendrick and others; see AUTHORS.txt
Copyright (c) 2002-2019 by Bill Kendrick and others; see AUTHORS.txt
bill@newbreedsoftware.com
http://www.tuxpaint.org/
@ -27,7 +27,7 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
(See COPYING.txt)
Last updated: May 6, 2009
Last updated: August 29, 2019
$Id$
*/
@ -86,9 +86,11 @@ void perspective_line(void *ptr_to_api, int which, SDL_Surface * canvas, SDL_Sur
/* Unused?
static const int perspective_AMOUNT = 300;
static const int perspective_RADIUS = 16;
static const double perspective_SHARPEN = 1.0;
*/
Uint8 perspective_r, perspective_g, perspective_b;
int corner;
int dash;
@ -396,12 +398,10 @@ void perspective_release(magic_api * api, int which,
}
else
{
int aux_x, aux_y, aux_h, aux_w;
int aux_h, aux_w;
aux_h = canvas->h * canvas->h / new_h;
aux_w = canvas->w * aux_h / canvas->h;
aux_x = canvas->w / 2 - aux_w / 2;
aux_y = canvas->h / 2 - aux_h / 2;
update_rect->x = canvas->w / 2 - aux_w / 2;
update_rect->y = canvas->h / 2 - aux_h / 2;

View file

@ -24,7 +24,7 @@
Mix_Chunk *rails_snd;
unsigned int img_w, img_h;
unsigned int rails_segments_x, rails_segments_y; //how many segments do we have?
static int rails_math_ceil(int x, int y); //ceil() in cstdlib returns float and is relative slow, so we'll use our one
inline int rails_math_ceil(int x, int y); //ceil() in cstdlib returns float and is relative slow, so we'll use our one
static Uint8 *rails_status_of_segments; //a place to store an info about bitmap used for selected segment
static char **rails_images; //the pathes to all the images needed
static unsigned int rails_segment_modified; //which segment was modified this time?
@ -51,7 +51,6 @@ void rails_release(magic_api * api, int which,
void rails_shutdown(magic_api * api);
void rails_switchin(magic_api * api, int which, int mode, SDL_Surface * canvas);
void rails_switchout(magic_api * api, int which, int mode, SDL_Surface * canvas);
static int rails_math_ceil(int x, int y);
inline unsigned int rails_get_segment(int x, int y);
inline void rails_extract_coords_from_segment(unsigned int segment, Sint16 * x, Sint16 * y);
static void rails_flip(void *ptr, SDL_Surface * dest, SDL_Surface * src);
@ -193,7 +192,7 @@ void rails_switchout(magic_api * api ATTRIBUTE_UNUSED, int which ATTRIBUTE_UNUSE
// Interactivity functions
static int rails_math_ceil(int x, int y)
inline int rails_math_ceil(int x, int y)
{
int temp;

View file

@ -1,3 +1,8 @@
/*
* Strings -- draws string art.
*
* Last modified: 2019-08-29
*/
#include "tp_magic_api.h"
#include "SDL_image.h"
#include "SDL_mixer.h"
@ -353,20 +358,9 @@ void string_draw_triangle_preview(magic_api * api, int which,
SDL_Rect * update_rect)
{
int middle_x, middle_y;
int w, h;
scale_coords(&ox, &oy, &x, &y);
w = max(string_ox, x) - min(string_ox, x);
h = max(string_oy, y) - min(string_oy, y);
/*
This is enouth if you move the mouse slowly, but if you move the mouse fast,
there are rests of old previews left around.
update_rect->w=max(max(string_ox,x),max(ox,x))-min(min(string_ox,x),min(ox,x)) +80;
update_rect->h=max(max(string_oy,y),max(oy,y))-min(min(string_oy,y),min(oy,y)) +80;
update_rect->x=min(string_ox,x) -40;
update_rect->y=min(string_oy,y) -40;
*/
update_rect->x = 0;
update_rect->y = 0;
update_rect->w = canvas->w;
@ -387,13 +381,9 @@ void string_draw_angle_preview(magic_api * api, int which,
int ox, __attribute__ ((unused))
int oy, int x, int y, SDL_Rect * update_rect)
{
int w, h;
int middle_x, middle_y;
int dx, dy;
w = max(string_ox, x) - min(string_ox, x);
h = max(string_oy, y) - min(string_oy, y);
update_rect->x = 0;
update_rect->y = 0;
update_rect->w = canvas->w;