From 8352c7e90b41512f69c238d93887d451a34a58cb Mon Sep 17 00:00:00 2001 From: Kp Date: Sun, 15 Jul 2012 17:32:21 +0000 Subject: [PATCH 1/5] Mark reactor default countdown times as const --- main/cntrlcen.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main/cntrlcen.c b/main/cntrlcen.c index 3d9954dcf..e78da807b 100644 --- a/main/cntrlcen.c +++ b/main/cntrlcen.c @@ -128,7 +128,7 @@ int Control_center_destroyed = 0; fix Countdown_timer=0; int Countdown_seconds_left=0, Total_countdown_time=0; //in whole seconds -int Alan_pavlish_reactor_times[NDL] = {90, 60, 45, 35, 30}; +static const int Alan_pavlish_reactor_times[NDL] = {90, 60, 45, 35, 30}; // ----------------------------------------------------------------------------- // Called every frame. If control center been destroyed, then actually do something. From b29c4e8120d00c4ce2f19bc2d358213a90d1064d Mon Sep 17 00:00:00 2001 From: Kp Date: Sat, 8 Jun 2013 23:35:21 +0000 Subject: [PATCH 2/5] Mark bitblt.c functions static --- 2d/bitblt.c | 45 +++++++++++++++++++++------------------------ include/grdef.h | 3 --- 2 files changed, 21 insertions(+), 27 deletions(-) diff --git a/2d/bitblt.c b/2d/bitblt.c index f2a277da0..53824da84 100644 --- a/2d/bitblt.c +++ b/2d/bitblt.c @@ -28,22 +28,19 @@ COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED. #include "ogl_init.h" #endif -int gr_bitblt_dest_step_shift = 0; -int gr_bitblt_double = 0; -ubyte *gr_bitblt_fade_table=NULL; +static int gr_bitblt_dest_step_shift = 0; +static int gr_bitblt_double = 0; +static ubyte *gr_bitblt_fade_table=NULL; -void gr_bm_ubitblt00_rle(int w, int h, int dx, int dy, int sx, int sy, grs_bitmap * src, grs_bitmap * dest); -void gr_bm_ubitblt00m_rle(int w, int h, int dx, int dy, int sx, int sy, grs_bitmap * src, grs_bitmap * dest); -void gr_bm_ubitblt0x_rle(int w, int h, int dx, int dy, int sx, int sy, grs_bitmap * src, grs_bitmap * dest, int masked); +static void gr_bm_ubitblt00_rle(int w, int h, int dx, int dy, int sx, int sy, grs_bitmap * src, grs_bitmap * dest); +static void gr_bm_ubitblt00m_rle(int w, int h, int dx, int dy, int sx, int sy, grs_bitmap * src, grs_bitmap * dest); +static void gr_bm_ubitblt0x_rle(int w, int h, int dx, int dy, int sx, int sy, grs_bitmap * src, grs_bitmap * dest, int masked); -void gr_bm_ubitblt01(int w, int h, int dx, int dy, int sx, int sy, grs_bitmap * src, grs_bitmap * dest); -void gr_bm_ubitblt02(int w, int h, int dx, int dy, int sx, int sy, grs_bitmap * src, grs_bitmap * dest); - -void gr_linear_movsd( ubyte * source, ubyte * dest, unsigned int nbytes) { +static void gr_linear_movsd( ubyte * source, ubyte * dest, unsigned int nbytes) { memcpy(dest,source,nbytes); } -void gr_linear_rep_movsdm(ubyte *src, ubyte *dest, int num_pixels) { +static void gr_linear_rep_movsdm(ubyte *src, ubyte *dest, int num_pixels) { register ubyte c; while (num_pixels--) if ((c=*src++)!=255) @@ -51,7 +48,7 @@ void gr_linear_rep_movsdm(ubyte *src, ubyte *dest, int num_pixels) { else dest++; } -void gr_linear_rep_movsdm_faded(ubyte * src, ubyte * dest, int num_pixels, ubyte fade_value ) { +static void gr_linear_rep_movsdm_faded(ubyte * src, ubyte * dest, int num_pixels, ubyte fade_value ) { register ubyte c; while (num_pixels--) if ((c=*src++)!=255) @@ -59,7 +56,7 @@ void gr_linear_rep_movsdm_faded(ubyte * src, ubyte * dest, int num_pixels, ubyte else dest++; } -void gr_linear_rep_movsd_2x(ubyte * source, ubyte * dest, uint nbytes ) { +static void gr_linear_rep_movsd_2x(ubyte * source, ubyte * dest, uint nbytes ) { register ubyte c; while (nbytes--) { if (nbytes&1) @@ -73,7 +70,7 @@ void gr_linear_rep_movsd_2x(ubyte * source, ubyte * dest, uint nbytes ) { } } -void gr_ubitmap00( int x, int y, grs_bitmap *bm ) +static void gr_ubitmap00( int x, int y, grs_bitmap *bm ) { register int y1; int dest_rowsize; @@ -96,7 +93,7 @@ void gr_ubitmap00( int x, int y, grs_bitmap *bm ) } } -void gr_ubitmap00m( int x, int y, grs_bitmap *bm ) +static void gr_ubitmap00m( int x, int y, grs_bitmap *bm ) { register int y1; int dest_rowsize; @@ -124,7 +121,7 @@ void gr_ubitmap00m( int x, int y, grs_bitmap *bm ) } } -void gr_ubitmap012( int x, int y, grs_bitmap *bm ) +static void gr_ubitmap012( int x, int y, grs_bitmap *bm ) { register int x1, y1; unsigned char * src; @@ -139,7 +136,7 @@ void gr_ubitmap012( int x, int y, grs_bitmap *bm ) } } -void gr_ubitmap012m( int x, int y, grs_bitmap *bm ) +static void gr_ubitmap012m( int x, int y, grs_bitmap *bm ) { register int x1, y1; unsigned char * src; @@ -157,7 +154,7 @@ void gr_ubitmap012m( int x, int y, grs_bitmap *bm ) } } -void gr_ubitmapGENERIC(int x, int y, grs_bitmap * bm) +static void gr_ubitmapGENERIC(int x, int y, grs_bitmap * bm) { register int x1, y1; @@ -169,7 +166,7 @@ void gr_ubitmapGENERIC(int x, int y, grs_bitmap * bm) } } -void gr_ubitmapGENERICm(int x, int y, grs_bitmap * bm) +static void gr_ubitmapGENERICm(int x, int y, grs_bitmap * bm) { register int x1, y1; ubyte c; @@ -245,7 +242,7 @@ void gr_ubitmapm( int x, int y, grs_bitmap *bm ) } // From Linear to Linear -void gr_bm_ubitblt00(int w, int h, int dx, int dy, int sx, int sy, grs_bitmap * src, grs_bitmap * dest) +static void gr_bm_ubitblt00(int w, int h, int dx, int dy, int sx, int sy, grs_bitmap * src, grs_bitmap * dest) { unsigned char * dbits; unsigned char * sbits; @@ -276,7 +273,7 @@ void gr_bm_ubitblt00(int w, int h, int dx, int dy, int sx, int sy, grs_bitmap * } // From Linear to Linear Masked -void gr_bm_ubitblt00m(int w, int h, int dx, int dy, int sx, int sy, grs_bitmap * src, grs_bitmap * dest) +static void gr_bm_ubitblt00m(int w, int h, int dx, int dy, int sx, int sy, grs_bitmap * src, grs_bitmap * dest) { unsigned char * dbits; unsigned char * sbits; @@ -473,7 +470,7 @@ void gr_bm_ubitbltm(int w, int h, int dx, int dy, int sx, int sy, grs_bitmap * s } -void gr_bm_ubitblt00_rle(int w, int h, int dx, int dy, int sx, int sy, grs_bitmap * src, grs_bitmap * dest) +static void gr_bm_ubitblt00_rle(int w, int h, int dx, int dy, int sx, int sy, grs_bitmap * src, grs_bitmap * dest) { unsigned char * dbits; unsigned char * sbits; @@ -501,7 +498,7 @@ void gr_bm_ubitblt00_rle(int w, int h, int dx, int dy, int sx, int sy, grs_bitma } } -void gr_bm_ubitblt00m_rle(int w, int h, int dx, int dy, int sx, int sy, grs_bitmap * src, grs_bitmap * dest) +static void gr_bm_ubitblt00m_rle(int w, int h, int dx, int dy, int sx, int sy, grs_bitmap * src, grs_bitmap * dest) { unsigned char * dbits; unsigned char * sbits; @@ -531,7 +528,7 @@ void gr_bm_ubitblt00m_rle(int w, int h, int dx, int dy, int sx, int sy, grs_bitm // in rle.c -void gr_bm_ubitblt0x_rle(int w, int h, int dx, int dy, int sx, int sy, grs_bitmap * src, +static void gr_bm_ubitblt0x_rle(int w, int h, int dx, int dy, int sx, int sy, grs_bitmap * src, grs_bitmap * dest, int masked ) { int i, data_offset; diff --git a/include/grdef.h b/include/grdef.h index 8b882a743..ca4724651 100644 --- a/include/grdef.h +++ b/include/grdef.h @@ -35,9 +35,6 @@ extern unsigned int gr_var_color; extern unsigned int gr_var_bwidth; extern unsigned char * gr_var_bitmap; -void gr_linear_movsd( ubyte * source, ubyte * dest, unsigned int nbytes); -void gr_linear_rep_movsd_2x(ubyte *source, ubyte *dest, unsigned int nbytes); - void gr_linear_line( int x0, int y0, int x1, int y1); extern unsigned int Table8to32[256]; From 105be723f899ff07750396ae982a67da305ef361 Mon Sep 17 00:00:00 2001 From: Kp Date: Sat, 8 Jun 2013 02:58:06 +0000 Subject: [PATCH 3/5] Adjust handling of weapon cycle with superlaser --- main/weapon.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/main/weapon.c b/main/weapon.c index d9c87481e..9497ee93f 100644 --- a/main/weapon.c +++ b/main/weapon.c @@ -221,13 +221,15 @@ void InitWeaponOrdering () void CyclePrimary () { - int cur_order_slot = POrderList(Primary_weapon), desired_weapon = Primary_weapon, loop=0; + int cur_order_slot, desired_weapon = Primary_weapon, loop=0; const int autoselect_order_slot = POrderList(255); - const int use_restricted_autoselect = (cur_order_slot < autoselect_order_slot) && (1 < autoselect_order_slot) && (PlayerCfg.CycleAutoselectOnly); // some remapping for SUPER LASER which is not an actual weapon type at all if (Primary_weapon == LASER_INDEX && Players[Player_num].laser_level > MAX_LASER_LEVEL) cur_order_slot = POrderList(SUPER_LASER_INDEX); + else + cur_order_slot = POrderList(Primary_weapon); + const int use_restricted_autoselect = (cur_order_slot < autoselect_order_slot) && (1 < autoselect_order_slot) && (PlayerCfg.CycleAutoselectOnly); while (loop<(MAX_PRIMARY_WEAPONS+1)) { From 2cece43d4b7042a73b1d44834e888c928ba6a2de Mon Sep 17 00:00:00 2001 From: Kp Date: Sat, 8 Jun 2013 17:43:35 +0000 Subject: [PATCH 4/5] Fix recvfrom prototype mismatches Win32 uses int* instead of unsigned int*. Fortunately, socklen_t is defined to the correct type in both cases, so use socklen_t and let the compiler sort it out. --- main/net_udp.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/main/net_udp.c b/main/net_udp.c index 4d9e9e528..032e42bc8 100644 --- a/main/net_udp.c +++ b/main/net_udp.c @@ -131,7 +131,7 @@ ssize_t dxx_sendto(int sockfd, const void *msg, int len, unsigned int flags, con return rv; } -ssize_t dxx_recvfrom(int sockfd, void *buf, int len, unsigned int flags, struct sockaddr *from, unsigned int *fromlen) +ssize_t dxx_recvfrom(int sockfd, void *buf, int len, unsigned int flags, struct sockaddr *from, socklen_t *fromlen) { ssize_t rv = recvfrom(sockfd, buf, len, flags, from, fromlen); @@ -347,7 +347,8 @@ int udp_general_packet_ready(int socknum) // Gets some text. Returns 0 if nothing on there. int udp_receive_packet(int socknum, ubyte *text, int len, struct _sockaddr *sender_addr) { - unsigned int clen = sizeof (struct _sockaddr), msglen = 0; + socklen_t clen = sizeof (struct _sockaddr); + ssize_t msglen = 0; if (UDP_Socket[socknum] == -1) return -1; From 49b547cb45410b9cdec5ee1f3cd6017fcb42f2e3 Mon Sep 17 00:00:00 2001 From: Kp Date: Sat, 8 Jun 2013 17:38:36 +0000 Subject: [PATCH 5/5] Fix font prototype mismatch in SDL-only case Commit 33bf139002533b2115251e9f391988001dc8fdc3 changed OGL gr_internal_color_string to take a const char, but left SDL gr_internal_color_string with non-const char. --- 2d/font.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/2d/font.c b/2d/font.c index bb3c6ec0d..eaabf54e3 100644 --- a/2d/font.c +++ b/2d/font.c @@ -438,10 +438,10 @@ grs_bitmap char_bm = { 0 //unused }; -int gr_internal_color_string(int x, int y, char *s ) +int gr_internal_color_string(int x, int y, const char *s ) { unsigned char * fp; - char *text_ptr, *next_row, *text_ptr1; + const char *text_ptr, *next_row, *text_ptr1; int width, spacing,letter; int xx,yy;