diff --git a/sc2/ChangeLog b/sc2/ChangeLog index d5311dc28..3b19270df 100644 --- a/sc2/ChangeLog +++ b/sc2/ChangeLog @@ -1,4 +1,5 @@ Changes towards version 0.7: +- Got rid of many warnings - SvdB - Clean up and some refactoring of the SuperMelee code - SvdB - Fixed concurrent screen fades regression (bug #1079) - Alex - Removed some legacy source code files related to resources - SvdB diff --git a/sc2/src/libs/file/dirs.c b/sc2/src/libs/file/dirs.c index 21939b83d..2663edf70 100644 --- a/sc2/src/libs/file/dirs.c +++ b/sc2/src/libs/file/dirs.c @@ -27,6 +27,7 @@ #include "filintrn.h" #include "libs/compiler.h" #include "libs/memlib.h" +#include "libs/misc.h" #include "libs/log.h" #ifdef HAVE_DRIVE_LETTERS @@ -788,7 +789,7 @@ strrchr2(const char *start, int c, const char *end) { if (end < start) return (char *) NULL; if (*end == c) - return (char *) end; + return (char *) unconst(end); } } diff --git a/sc2/src/libs/graphics/context.h b/sc2/src/libs/graphics/context.h index 1e12dd897..ff759087b 100644 --- a/sc2/src/libs/graphics/context.h +++ b/sc2/src/libs/graphics/context.h @@ -141,6 +141,7 @@ extern GRAPHICS_STATUS _GraphicsStatusFlags; // pValidRect or origin may be NULL BOOLEAN GetContextValidRect (RECT *pValidRect, POINT *origin); +extern void FixContextFontEffect (void); #endif /* _CONTEXT_H */ diff --git a/sc2/src/libs/graphics/font.c b/sc2/src/libs/graphics/font.c index 7e0a1da38..638c814d9 100644 --- a/sc2/src/libs/graphics/font.c +++ b/sc2/src/libs/graphics/font.c @@ -20,7 +20,6 @@ #include "tfb_prim.h" #include "libs/log.h" -extern void FixContextFontEffect (void); static inline TFB_Char *getCharFrame (FONT_DESC *fontPtr, UniChar ch); diff --git a/sc2/src/libs/graphics/gfxload.c b/sc2/src/libs/graphics/gfxload.c index 226f67952..a18b09697 100644 --- a/sc2/src/libs/graphics/gfxload.c +++ b/sc2/src/libs/graphics/gfxload.c @@ -356,9 +356,12 @@ typedef struct BuildCharDesc UniChar index; } BuildCharDesc; -int -compareBCDIndex (const BuildCharDesc *bcd1, const BuildCharDesc *bcd2) +static int +compareBCDIndex (const void *arg1, const void *arg2) { + const BuildCharDesc *bcd1 = (const BuildCharDesc *) arg1; + const BuildCharDesc *bcd2 = (const BuildCharDesc *) arg2; + return (int) bcd1->index - (int) bcd2->index; } @@ -466,8 +469,7 @@ _GetFontData (uio_Stream *fp, DWORD length) #endif // sort on the character index - qsort (bcds, numBCDs, sizeof (BuildCharDesc), - (int (*)(const void *, const void *)) compareBCDIndex); + qsort (bcds, numBCDs, sizeof (BuildCharDesc), compareBCDIndex); fontPtr = AllocFont (0); if (fontPtr == NULL) diff --git a/sc2/src/libs/graphics/sdl/3do_getbody.c b/sc2/src/libs/graphics/sdl/3do_getbody.c index cd2d0d5a9..b1bb5621d 100644 --- a/sc2/src/libs/graphics/sdl/3do_getbody.c +++ b/sc2/src/libs/graphics/sdl/3do_getbody.c @@ -24,7 +24,8 @@ #include "sdl_common.h" #include "primitives.h" - +#if 0 +/* Unused */ void process_rgb_bmp (FRAME FramePtr, Uint32 *rgba, int maxx, int maxy) { int x, y; @@ -45,7 +46,10 @@ void process_rgb_bmp (FRAME FramePtr, Uint32 *rgba, int maxx, int maxy) SDL_UnlockSurface (img); UnlockMutex (tfbImg->mutex); } +#endif +#if 0 +/* Unused */ void fill_frame_rgb (FRAME FramePtr, Uint32 color, int x0, int y0, int x, int y) { @@ -70,8 +74,12 @@ void fill_frame_rgb (FRAME FramePtr, Uint32 color, int x0, int y0, SDL_UnlockSurface (img); UnlockMutex (tfbImg->mutex); } +#endif -void arith_frame_blit (FRAME srcFrame, const RECT *rsrc, FRAME dstFrame, +#if 0 +/* Unused */ +void +arith_frame_blit (FRAME srcFrame, const RECT *rsrc, FRAME dstFrame, const RECT *rdst, int num, int denom) { TFB_Image *srcImg, *dstImg; @@ -120,7 +128,10 @@ void arith_frame_blit (FRAME srcFrame, const RECT *rsrc, FRAME dstFrame, UnlockMutex (srcImg->mutex); UnlockMutex (dstImg->mutex); } +#endif +#if 0 +/* Unused */ // Generate an array of all pixels in FramePtr // The 32bpp pixel format is : // bits 24-31 : red @@ -128,8 +139,8 @@ void arith_frame_blit (FRAME srcFrame, const RECT *rsrc, FRAME dstFrame, // bits 8-15 : blue // bits 0-7 : alpha // The 8bpp pixel format is 1 index per pixel -void getpixelarray (void *map, int Bpp, FRAME FramePtr, - int width, int height) +void +getpixelarray (void *map, int Bpp, FRAME FramePtr, int width, int height) { Uint8 r,g,b,a; Uint32 p, pos, row; @@ -179,8 +190,10 @@ void getpixelarray (void *map, int Bpp, FRAME FramePtr, SDL_UnlockSurface (img); UnlockMutex (tfbImg->mutex); } +#endif - +#if 0 +/* Unused */ // Generate a pixel (in the correct format to be applied to FramePtr) from the // r,g,b,a values supplied Uint32 frame_mapRGBA (FRAME FramePtr,Uint8 r, Uint8 g, Uint8 b, Uint8 a) @@ -188,5 +201,7 @@ Uint32 frame_mapRGBA (FRAME FramePtr,Uint8 r, Uint8 g, Uint8 b, Uint8 a) SDL_Surface *img= (SDL_Surface *)FramePtr->image->NormalImg; return (SDL_MapRGBA (img->format, r, g, b, a)); } +#endif #endif + diff --git a/sc2/src/libs/graphics/sdl/canvas.c b/sc2/src/libs/graphics/sdl/canvas.c index e81df5aba..2fd5bc3f3 100644 --- a/sc2/src/libs/graphics/sdl/canvas.c +++ b/sc2/src/libs/graphics/sdl/canvas.c @@ -56,7 +56,7 @@ TFB_DrawCanvas_GetError (void) return err; } -void +static void checkPrimitiveMode (SDL_Surface *surf, Color *color, DrawMode *mode) { const SDL_PixelFormat *fmt = surf->format; diff --git a/sc2/src/libs/graphics/sdl/primitives.c b/sc2/src/libs/graphics/sdl/primitives.c index 618746141..17edb7da5 100644 --- a/sc2/src/libs/graphics/sdl/primitives.c +++ b/sc2/src/libs/graphics/sdl/primitives.c @@ -25,42 +25,48 @@ // Pixel drawing routines -Uint32 getpixel_8(SDL_Surface *surface, int x, int y) +static Uint32 +getpixel_8(SDL_Surface *surface, int x, int y) { /* Here p is the address to the pixel we want to retrieve */ Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x; return *p; } -void putpixel_8(SDL_Surface *surface, int x, int y, Uint32 pixel) +static void +putpixel_8(SDL_Surface *surface, int x, int y, Uint32 pixel) { /* Here p is the address to the pixel we want to set */ Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * 1; *p = pixel; } -Uint32 getpixel_16(SDL_Surface *surface, int x, int y) +static Uint32 +getpixel_16(SDL_Surface *surface, int x, int y) { /* Here p is the address to the pixel we want to retrieve */ Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * 2; return *(Uint16 *)p; } -void putpixel_16(SDL_Surface *surface, int x, int y, Uint32 pixel) +static void +putpixel_16(SDL_Surface *surface, int x, int y, Uint32 pixel) { /* Here p is the address to the pixel we want to set */ Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * 2; *(Uint16 *)p = pixel; } -Uint32 getpixel_24_be(SDL_Surface *surface, int x, int y) +static Uint32 +getpixel_24_be(SDL_Surface *surface, int x, int y) { /* Here p is the address to the pixel we want to retrieve */ Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * 3; return p[0] << 16 | p[1] << 8 | p[2]; } -void putpixel_24_be(SDL_Surface *surface, int x, int y, Uint32 pixel) +static void +putpixel_24_be(SDL_Surface *surface, int x, int y, Uint32 pixel) { /* Here p is the address to the pixel we want to set */ Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * 3; @@ -69,14 +75,16 @@ void putpixel_24_be(SDL_Surface *surface, int x, int y, Uint32 pixel) p[2] = pixel & 0xff; } -Uint32 getpixel_24_le(SDL_Surface *surface, int x, int y) +static Uint32 +getpixel_24_le(SDL_Surface *surface, int x, int y) { /* Here p is the address to the pixel we want to retrieve */ Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * 3; return p[0] | p[1] << 8 | p[2] << 16; } -void putpixel_24_le(SDL_Surface *surface, int x, int y, Uint32 pixel) +static void +putpixel_24_le(SDL_Surface *surface, int x, int y, Uint32 pixel) { /* Here p is the address to the pixel we want to set */ Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * 3; @@ -85,21 +93,24 @@ void putpixel_24_le(SDL_Surface *surface, int x, int y, Uint32 pixel) p[2] = (pixel >> 16) & 0xff; } -Uint32 getpixel_32(SDL_Surface *surface, int x, int y) +static Uint32 +getpixel_32(SDL_Surface *surface, int x, int y) { /* Here p is the address to the pixel we want to retrieve */ Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * 4; return *(Uint32 *)p; } -void putpixel_32(SDL_Surface *surface, int x, int y, Uint32 pixel) +static void +putpixel_32(SDL_Surface *surface, int x, int y, Uint32 pixel) { /* Here p is the address to the pixel we want to set */ Uint8 *p = (Uint8 *)surface->pixels + y * surface->pitch + x * 4; *(Uint32 *)p = pixel; } -GetPixelFn getpixel_for(SDL_Surface *surface) +GetPixelFn +getpixel_for(SDL_Surface *surface) { int bpp = surface->format->BytesPerPixel; switch (bpp) { @@ -119,7 +130,8 @@ GetPixelFn getpixel_for(SDL_Surface *surface) return NULL; } -PutPixelFn putpixel_for(SDL_Surface *surface) +PutPixelFn +putpixel_for(SDL_Surface *surface) { int bpp = surface->format->BytesPerPixel; switch (bpp) { @@ -139,14 +151,16 @@ PutPixelFn putpixel_for(SDL_Surface *surface) return NULL; } -static void renderpixel_replace(SDL_Surface *surface, int x, int y, - Uint32 pixel, int factor) +static void +renderpixel_replace(SDL_Surface *surface, int x, int y, Uint32 pixel, + int factor) { (void) factor; // ignored putpixel_32(surface, x, y, pixel); } -static inline Uint8 clip_channel(int c) +static inline Uint8 +clip_channel(int c) { if (c < 0) c = 0; @@ -155,7 +169,8 @@ static inline Uint8 clip_channel(int c) return c; } -static inline Uint8 modulated_sum(Uint8 dc, Uint8 sc, int factor) +static inline Uint8 +modulated_sum(Uint8 dc, Uint8 sc, int factor) { // We use >> 8 instead of / 255 because it is faster, but it does // not work 100% correctly. It should be safe because this should @@ -164,7 +179,8 @@ static inline Uint8 modulated_sum(Uint8 dc, Uint8 sc, int factor) return clip_channel(b); } -static inline Uint8 alpha_blend(Uint8 dc, Uint8 sc, int alpha) +static inline Uint8 +alpha_blend(Uint8 dc, Uint8 sc, int alpha) { // We use >> 8 instead of / 255 because it is faster, but it does // not work 100% correctly. It should be safe because this should @@ -183,15 +199,17 @@ static inline Uint8 alpha_blend(Uint8 dc, Uint8 sc, int alpha) } while (0) // Assumes the channels already clipped to 8 bits -static inline Uint32 PACK_PIXEL_32(const SDL_PixelFormat *fmt, +static inline Uint32 +PACK_PIXEL_32(const SDL_PixelFormat *fmt, Uint8 r, Uint8 g, Uint8 b) { return ((Uint32)r << fmt->Rshift) | ((Uint32)g << fmt->Gshift) | ((Uint32)b << fmt->Bshift); } -static void renderpixel_additive(SDL_Surface *surface, int x, int y, - Uint32 pixel, int factor) +static void +renderpixel_additive(SDL_Surface *surface, int x, int y, Uint32 pixel, + int factor) { const SDL_PixelFormat *fmt = surface->format; Uint32 *p; @@ -223,8 +241,9 @@ static void renderpixel_additive(SDL_Surface *surface, int x, int y, *p = PACK_PIXEL_32(fmt, sr, sg, sb); } -static void renderpixel_alpha(SDL_Surface *surface, int x, int y, - Uint32 pixel, int factor) +static void +renderpixel_alpha(SDL_Surface *surface, int x, int y, Uint32 pixel, + int factor) { const SDL_PixelFormat *fmt = surface->format; Uint32 *p; @@ -249,7 +268,8 @@ static void renderpixel_alpha(SDL_Surface *surface, int x, int y, *p = PACK_PIXEL_32(fmt, sr, sg, sb); } -RenderPixelFn renderpixel_for(SDL_Surface *surface, RenderKind kind) +RenderPixelFn +renderpixel_for(SDL_Surface *surface, RenderKind kind) { const SDL_PixelFormat *fmt = surface->format; @@ -278,8 +298,9 @@ RenderPixelFn renderpixel_for(SDL_Surface *surface, RenderKind kind) * Adapted from Paul Heckbert's implementation of Bresenham's algorithm, * 3 Sep 85; taken from Graphics Gems I */ -void line_prim(int x1, int y1, int x2, int y2, Uint32 color, - RenderPixelFn plot, int factor, SDL_Surface *dst) +void +line_prim(int x1, int y1, int x2, int y2, Uint32 color, RenderPixelFn plot, + int factor, SDL_Surface *dst) { int d, x, y, ax, ay, sx, sy, dx, dy; SDL_Rect clip_r; @@ -417,8 +438,9 @@ clip_line (int *lx1, int *ly1, int *lx2, int *ly2, const SDL_Rect *r) } } -void fillrect_prim(SDL_Rect r, Uint32 color, - RenderPixelFn plot, int factor, SDL_Surface *dst) +void +fillrect_prim(SDL_Rect r, Uint32 color, RenderPixelFn plot, int factor, + SDL_Surface *dst) { int x, y; int x1, y1; @@ -440,7 +462,8 @@ void fillrect_prim(SDL_Rect r, Uint32 color, } // clip the rectangle against the clip rectangle -int clip_rect(SDL_Rect *r, const SDL_Rect *clip_r) +int +clip_rect(SDL_Rect *r, const SDL_Rect *clip_r) { // NOTE: the following clipping code is copied in part // from SDL-1.2.4 sources @@ -475,7 +498,8 @@ int clip_rect(SDL_Rect *r, const SDL_Rect *clip_r) return 1; } -void blt_prim(SDL_Surface *src, SDL_Rect src_r, RenderPixelFn plot, int factor, +void +blt_prim(SDL_Surface *src, SDL_Rect src_r, RenderPixelFn plot, int factor, SDL_Surface *dst, SDL_Rect dst_r) { SDL_PixelFormat *srcfmt = src->format; @@ -544,7 +568,8 @@ void blt_prim(SDL_Surface *src, SDL_Rect src_r, RenderPixelFn plot, int factor, } // clip the source and destination rectangles against the clip rectangle -int clip_blt_rects(SDL_Rect *src_r, SDL_Rect *dst_r, const SDL_Rect *clip_r) +int +clip_blt_rects(SDL_Rect *src_r, SDL_Rect *dst_r, const SDL_Rect *clip_r) { // NOTE: the following clipping code is copied in part // from SDL-1.2.4 sources diff --git a/sc2/src/libs/graphics/sdl/pure.h b/sc2/src/libs/graphics/sdl/pure.h index 07f067a48..2538c3f0d 100644 --- a/sc2/src/libs/graphics/sdl/pure.h +++ b/sc2/src/libs/graphics/sdl/pure.h @@ -23,5 +23,6 @@ int TFB_Pure_InitGraphics (int driver, int flags, int width, int height); int TFB_Pure_ConfigureVideo (int driver, int flags, int width, int height, int togglefullscreen); +void Scale_PerfTest (void); #endif diff --git a/sc2/src/libs/graphics/sdl/sdl_common.c b/sc2/src/libs/graphics/sdl/sdl_common.c index 5538b5e54..4b933b288 100644 --- a/sc2/src/libs/graphics/sdl/sdl_common.c +++ b/sc2/src/libs/graphics/sdl/sdl_common.c @@ -338,8 +338,9 @@ TFB_GetScreenCanvas (SCREEN screen) return SDL_Screens[screen]; } -void TFB_BlitSurface (SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst, - SDL_Rect *dstrect, int blend_numer, int blend_denom) +void +TFB_BlitSurface (SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst, + SDL_Rect *dstrect, int blend_numer, int blend_denom) { BOOLEAN has_colorkey; int x, y, x1, y1, x2, y2, dst_x2, dst_y2, nr, ng, nb; @@ -369,7 +370,7 @@ void TFB_BlitSurface (SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst, } // clip the source rectangle to the source surface - if (srcrect) + if (srcrect) { int maxw, maxh; @@ -452,6 +453,7 @@ void TFB_BlitSurface (SDL_Surface *src, SDL_Rect *srcrect, SDL_Surface *dst, else { has_colorkey = FALSE; + colorkey = 0; /* Satisfying compiler */ } src_getpix = getpixel_for (src); diff --git a/sc2/src/libs/input/sdl/vcontrol.c b/sc2/src/libs/input/sdl/vcontrol.c index 1459d7905..302c3ba6c 100644 --- a/sc2/src/libs/input/sdl/vcontrol.c +++ b/sc2/src/libs/input/sdl/vcontrol.c @@ -1076,7 +1076,7 @@ next_token (parse_state *state) } static void -expected_error (parse_state *state, char *expected) +expected_error (parse_state *state, const char *expected) { log_add (log_Warning, "VControl: Expected '%s' on config file line %d", expected, state->linenum); @@ -1084,7 +1084,7 @@ expected_error (parse_state *state, char *expected) } static void -consume (parse_state *state, char *expected) +consume (parse_state *state, const char *expected) { if (strcasecmp (expected, state->token)) { diff --git a/sc2/src/libs/misc.h b/sc2/src/libs/misc.h index dfb98a0bd..a080f064c 100644 --- a/sc2/src/libs/misc.h +++ b/sc2/src/libs/misc.h @@ -41,5 +41,18 @@ static inline void explode (void) #endif } +/* Sometimes you just have to remove a 'const'. + * (for instance, when implementing a function like strchr) + */ +static inline void * +unconst(const void *arg) { + union { + char *c; + const char *cc; + } u; + u.cc = arg; + return u.c; +} + #endif diff --git a/sc2/src/libs/network/socket/socket.h b/sc2/src/libs/network/socket/socket.h index 9a9354440..707d3191a 100644 --- a/sc2/src/libs/network/socket/socket.h +++ b/sc2/src/libs/network/socket/socket.h @@ -84,6 +84,8 @@ ssize_t Socket_recv(Socket *sock, void *buf, size_t len, int flags); int Socket_setNonBlocking(Socket *sock); int Socket_setReuseAddr(Socket *sock); +int Socket_setNodelay(Socket *sock); +int Socket_setTOS(Socket *sock, int tos); int Socket_setInteractive(Socket *sock); int Socket_setInlineOOB(Socket *sock); int Socket_setKeepAlive(Socket *sock); diff --git a/sc2/src/libs/network/socket/socket_bsd.c b/sc2/src/libs/network/socket/socket_bsd.c index 780865db9..54d5d58ba 100644 --- a/sc2/src/libs/network/socket/socket_bsd.c +++ b/sc2/src/libs/network/socket/socket_bsd.c @@ -40,12 +40,12 @@ #include -Socket * +static Socket * Socket_alloc(void) { return malloc(sizeof (Socket)); } -void +static void Socket_free(Socket *sock) { free(sock); } diff --git a/sc2/src/libs/reslib.h b/sc2/src/libs/reslib.h index 4966affa1..39b67b174 100644 --- a/sc2/src/libs/reslib.h +++ b/sc2/src/libs/reslib.h @@ -64,7 +64,7 @@ void UninitResourceSystem (void); BOOLEAN InstallResTypeVectors (const char *res_type, ResourceLoadFun *loadFun, ResourceFreeFun *freeFun, ResourceStringFun *stringFun); void *res_GetResource (RESOURCE res); void *res_DetachResource (RESOURCE res); -BOOLEAN FreeResource (RESOURCE res); +void res_FreeResource (RESOURCE res); COUNT CountResourceTypes (void); DWORD res_GetIntResource (RESOURCE res); BOOLEAN res_GetBooleanResource (RESOURCE res); diff --git a/sc2/src/libs/sound/stream.c b/sc2/src/libs/sound/stream.c index 8fe0be2da..c9f7e800a 100644 --- a/sc2/src/libs/sound/stream.c +++ b/sc2/src/libs/sound/stream.c @@ -578,7 +578,7 @@ StreamDecoderTaskFunc (void *data) return 0; } -inline sint32 +static inline sint32 readSoundSample (void *ptr, int sample_size) { if (sample_size == sizeof (uint8)) diff --git a/sc2/src/libs/sound/trackplayer.c b/sc2/src/libs/sound/trackplayer.c index 4e8d2d7b3..11417117a 100644 --- a/sc2/src/libs/sound/trackplayer.c +++ b/sc2/src/libs/sound/trackplayer.c @@ -314,8 +314,8 @@ GetTimeStamps (UNICODE *TimeStamps, sint32 *time_stamps) } #define TEXT_SPEED 80 -// Returns number of parsed pages -int +// Returns number of parsed pages +static int SplitSubPages (UNICODE *text, UNICODE *pages[], sint32 timestamp[], int size) { int lead_ellips = 0; diff --git a/sc2/src/libs/strings/unicode.c b/sc2/src/libs/strings/unicode.c index d273caa5d..17505078f 100644 --- a/sc2/src/libs/strings/unicode.c +++ b/sc2/src/libs/strings/unicode.c @@ -24,6 +24,7 @@ #include #include #include "libs/log.h" +#include "libs/misc.h" // Resynchronise (skip everything starting with 0x10xxxxxx): @@ -176,7 +177,7 @@ getLineFromString(const unsigned char *start, const unsigned char **end, if (*ptr == '\0') { *end = ptr; *startNext = ptr; - return (unsigned char *) start; + return (unsigned char *) unconst(start); } lastPtr = ptr; ch = getCharFromString(&ptr); @@ -191,7 +192,7 @@ getLineFromString(const unsigned char *start, const unsigned char **end, if (*ptr == '\0'){ // LF at the end of the string. *startNext = ptr; - return (unsigned char *) start; + return (unsigned char *) unconst(start); } ch = getCharFromString(&ptr); if (ch == '\0') { @@ -205,11 +206,11 @@ getLineFromString(const unsigned char *start, const unsigned char **end, // LF *startNext = *end; } - return (unsigned char *) start; + return (unsigned char *) unconst(start); } else if (ch == '\r') { *end = lastPtr; *startNext = ptr; - return (unsigned char *) start; + return (unsigned char *) unconst(start); } // else: a normal character } } @@ -271,7 +272,7 @@ utf8StringCopy (unsigned char *dst, size_t size, const unsigned char *src) if (size == 0) return 0; - strncpy ((char *) dst, (char *) src, size); + strncpy ((char *) dst, (const char *) src, size); dst[size - 1] = '\0'; return dst; @@ -319,7 +320,7 @@ utf8StringCompare (const unsigned char *str1, const unsigned char *str2) return 0; #else // this will do for now - return strcmp ((char *) str1, (char *) str2); + return strcmp ((const char *) str1, (const char *) str2); #endif } @@ -332,9 +333,9 @@ skipUTF8Chars(const unsigned char *ptr, size_t num) { oldPtr = ptr; ch = getCharFromString(&ptr); if (ch == '\0') - return (unsigned char *) oldPtr; + return (unsigned char *) unconst(oldPtr); } - return (unsigned char *) ptr; + return (unsigned char *) unconst(ptr); } // Decodes a UTF-8 string (start) into a unicode character string (wstr) diff --git a/sc2/src/libs/uio/io.h b/sc2/src/libs/uio/io.h index 5bd8ea186..8e8ce663c 100644 --- a/sc2/src/libs/uio/io.h +++ b/sc2/src/libs/uio/io.h @@ -102,6 +102,9 @@ int uio_close(uio_Handle *handle); int uio_rename(uio_DirHandle *oldDir, const char *oldPath, uio_DirHandle *newDir, const char *newPath); +// Test permissions on a file or directory. +int uio_access(uio_DirHandle *dir, const char *path, int mode); + // Fstat a file descriptor int uio_fstat(uio_Handle *handle, struct stat *statBuf); diff --git a/sc2/src/uqm/cnctdlg.c b/sc2/src/uqm/cnctdlg.c index 7d623d18a..5ff1cc3e9 100644 --- a/sc2/src/uqm/cnctdlg.c +++ b/sc2/src/uqm/cnctdlg.c @@ -172,7 +172,7 @@ MCD_DrawSlider (WIDGET *_self, int x, int y) SetContextForeGroundColor (oldtext); } -void +static void MCD_DrawTextEntry (WIDGET *_self, int x, int y) { WIDGET_TEXTENTRY *self = (WIDGET_TEXTENTRY *)_self; diff --git a/sc2/src/uqm/comm/starbas/starbas.c b/sc2/src/uqm/comm/starbas/starbas.c index 89959b3a7..860896cc2 100644 --- a/sc2/src/uqm/comm/starbas/starbas.c +++ b/sc2/src/uqm/comm/starbas/starbas.c @@ -227,10 +227,10 @@ static void NeedInfo (RESPONSE_REF R); static void TellHistory (RESPONSE_REF R); static void AlienRaces (RESPONSE_REF R); -static BYTE stack0, - stack1, - stack2, - stack3; +static BYTE stack0; +static BYTE stack1; +static BYTE stack2; +static BYTE stack3; static void AllianceInfo (RESPONSE_REF R) @@ -492,7 +492,9 @@ TellHistory (RESPONSE_REF R) if (PLAYER_SAID (R, history)) { NPCPhrase (WHICH_HISTORY); - stack0 = stack1 = stack2 = 0; + stack0 = 0; + stack1 = 0; + stack2 = 0; } else if (PLAYER_SAID (R, enough_aliens)) { @@ -518,7 +520,7 @@ TellHistory (RESPONSE_REF R) case 0: pstack[0] = alien_races; break; - case 1: + default: pstack[0] = 0; break; } @@ -527,7 +529,7 @@ TellHistory (RESPONSE_REF R) case 0: pstack[1] = the_war; break; - case 1: + default: pstack[1] = 0; break; } @@ -536,7 +538,7 @@ TellHistory (RESPONSE_REF R) case 0: pstack[2] = ancient_history; break; - case 1: + default: pstack[2] = 0; break; } @@ -782,7 +784,10 @@ TellMission (RESPONSE_REF R) if (PLAYER_SAID (R, our_mission)) { NPCPhrase (WHICH_MISSION); - stack0 = stack1 = stack2 = stack3 = 0; + stack0 = 0; + stack1 = 0; + stack2 = 0; + stack3 = 0; } else if (PLAYER_SAID (R, where_get_minerals)) { @@ -881,7 +886,10 @@ TellStarBase (RESPONSE_REF R) if (PLAYER_SAID (R, starbase_functions)) { NPCPhrase (WHICH_FUNCTION); - stack0 = stack1 = stack2 = stack3 = 0; + stack0 = 0; + stack1 = 0; + stack2 = 0; + stack3 = 0; } else if (PLAYER_SAID (R, tell_me_about_fuel0)) { diff --git a/sc2/src/uqm/gameinp.c b/sc2/src/uqm/gameinp.c index d17128234..cd2745599 100644 --- a/sc2/src/uqm/gameinp.c +++ b/sc2/src/uqm/gameinp.c @@ -318,7 +318,7 @@ FlushInput (void) _clear_menu_state (); } -MENU_SOUND_FLAGS +static MENU_SOUND_FLAGS MenuKeysToSoundFlags (const CONTROLLER_INPUT_STATE *state) { MENU_SOUND_FLAGS soundFlags; diff --git a/sc2/src/uqm/gendef.c b/sc2/src/uqm/gendef.c index 2e39f590e..6980222b9 100644 --- a/sc2/src/uqm/gendef.c +++ b/sc2/src/uqm/gendef.c @@ -16,6 +16,7 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "gendef.h" #include "encount.h" #include "planets/generate.h" diff --git a/sc2/src/uqm/init.c b/sc2/src/uqm/init.c index 932b319b2..46fabc17d 100644 --- a/sc2/src/uqm/init.c +++ b/sc2/src/uqm/init.c @@ -156,7 +156,7 @@ UninitSpace (void) } } -HSTARSHIP +static HSTARSHIP BuildSIS (void) { HSTARSHIP hStarShip; diff --git a/sc2/src/uqm/intro.c b/sc2/src/uqm/intro.c index 7ba8a0b43..3f90f6bc9 100644 --- a/sc2/src/uqm/intro.c +++ b/sc2/src/uqm/intro.c @@ -282,7 +282,7 @@ Present_DrawMovieFrame (PRESENTATION_INPUT_STATE* pPIS) UnlockMutex (GraphicsLock); } -BOOLEAN +static BOOLEAN ShowPresentationFile (const char *name) { STRING pres = CaptureStringTable (LoadStringTableFile (contentDir, name)); diff --git a/sc2/src/uqm/planets/planets.h b/sc2/src/uqm/planets/planets.h index bca259754..7041f114d 100644 --- a/sc2/src/uqm/planets/planets.h +++ b/sc2/src/uqm/planets/planets.h @@ -199,7 +199,7 @@ struct solarsys_state BYTE max_ship_speed; STRING XlatRef; - void *XlatPtr; + const void *XlatPtr; COLORMAP OrbitalCMap; SYSTEM_INFO SysInfo; diff --git a/sc2/src/uqm/planets/plangen.c b/sc2/src/uqm/planets/plangen.c index 481fbc50a..ca5dbb50c 100644 --- a/sc2/src/uqm/planets/plangen.c +++ b/sc2/src/uqm/planets/plangen.c @@ -105,12 +105,13 @@ RenderTopography (FRAME DstFrame, SBYTE *pTopoData, int w, int h) COUNT i; BYTE AlgoType; SIZE base, d; + const XLAT_DESC *xlatDesc; POINT pt; const PlanetFrame *PlanDataPtr; PRIMITIVE BatchArray[NUM_BATCH_POINTS]; PRIMITIVE *pBatch; SBYTE *pSrc; - BYTE *xlat_tab; + const BYTE *xlat_tab; BYTE *cbase; POINT oldOrigin; RECT ClipRect; @@ -132,7 +133,8 @@ RenderTopography (FRAME DstFrame, SBYTE *pTopoData, int w, int h) ]; AlgoType = PLANALGO (PlanDataPtr->Type); base = PlanDataPtr->base_elevation; - xlat_tab = (BYTE*)((XLAT_DESC*)pSolarSysState->XlatPtr)->xlat_tab; + xlatDesc = (const XLAT_DESC *) pSolarSysState->XlatPtr; + xlat_tab = (const BYTE *) xlatDesc->xlat_tab; cbase = GetColorMapAddress (pSolarSysState->OrbitalCMap); i = NUM_BATCH_POINTS; diff --git a/sc2/src/uqm/planets/roster.c b/sc2/src/uqm/planets/roster.c index 2d8a4c844..cd289e4b2 100644 --- a/sc2/src/uqm/planets/roster.c +++ b/sc2/src/uqm/planets/roster.c @@ -375,8 +375,8 @@ DoModifyRoster (MENU_STATE *pMS) static int compShipPos (const void *ptr1, const void *ptr2) { - POINT *pt1 = (POINT *) ptr1; - POINT *pt2 = (POINT *) ptr2; + const POINT *pt1 = (const POINT *) ptr1; + const POINT *pt2 = (const POINT *) ptr2; // Ships on the left in the lower half if (pt1->x < pt2->x) diff --git a/sc2/src/uqm/sis.c b/sc2/src/uqm/sis.c index 410010e84..0f7b6d130 100644 --- a/sc2/src/uqm/sis.c +++ b/sc2/src/uqm/sis.c @@ -1274,7 +1274,7 @@ GetCPodCapacity (POINT *ppt) //////////////////////////////////////////////////////////////////////////// // Get the total amount of minerals aboard the SIS. -COUNT +static COUNT GetElementMass (void) { return GLOBAL_SIS (TotalElementMass); @@ -1379,7 +1379,7 @@ GetSBayCapacity (POINT *ppt) //////////////////////////////////////////////////////////////////////////// // Get the total amount of fuel aboard the SIS. -DWORD +static DWORD GetFuelTotal (void) { return GLOBAL_SIS (FuelOnBoard); diff --git a/sc2/src/uqm/sis.h b/sc2/src/uqm/sis.h index 962337d3c..b717b5b6d 100644 --- a/sc2/src/uqm/sis.h +++ b/sc2/src/uqm/sis.h @@ -231,9 +231,11 @@ extern COUNT GetModuleCrewCapacity (BYTE moduleType); extern COUNT GetCrewPodCapacity (void); extern COUNT GetCPodCapacity (POINT *ppt); +extern COUNT GetModuleStorageCapacity (BYTE moduleType); extern COUNT GetStorageBayCapacity (void); extern COUNT GetSBayCapacity (POINT *ppt); +extern DWORD GetModuleFuelCapacity (BYTE moduleType); extern DWORD GetFuelTankCapacity (void); extern DWORD GetFTankCapacity (POINT *ppt); diff --git a/sc2/src/uqm/supermelee/melee.c b/sc2/src/uqm/supermelee/melee.c index 5f517c6f5..db7d1d687 100644 --- a/sc2/src/uqm/supermelee/melee.c +++ b/sc2/src/uqm/supermelee/melee.c @@ -1923,7 +1923,7 @@ DoMelee (MELEE_STATE *pMS) return TRUE; } -int +static int LoadMeleeConfig (MELEE_STATE *pMS) { uio_Stream *stream; @@ -1968,7 +1968,7 @@ err: return -1; } -int +static int WriteMeleeConfig (MELEE_STATE *pMS) { uio_Stream *stream; @@ -2125,7 +2125,7 @@ connectedFeedback (NetConnection *conn) { PlayMenuSound (MENU_SOUND_INVOKED); } -const char * +static const char * abortReasonString (NetplayAbortReason reason) { switch (reason) @@ -2160,7 +2160,7 @@ abortFeedback (NetConnection *conn, NetplayAbortReason reason) connectionFeedback (conn, msg, true); } -const char * +static const char * resetReasonString (NetplayResetReason reason) { switch (reason)