From b72b70a4233776bdaa6a683c89af2becefd53bd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= Date: Mon, 2 Mar 2020 15:27:42 +0100 Subject: [PATCH] Add future gcc default -fno-common and fix code Global var declarations needs to be in .c files to avoid having them in several .o files. So they need to be declared as extern in .h files if needed. This was already the case for other vars. Related to issue #36 --- Makefile | 2 +- globals.pre | 2 +- main.c | 2 ++ network.c | 4 ++++ network.h | 2 +- 5 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 51f7542..077cc52 100644 --- Makefile +++ Makefile @@ -6,7 +6,7 @@ DATADIR ?= $(PREFIX)/share GAMEDATADIR ?= $(DATADIR) EXE ?= -CFLAGS ?= -Wall -O2 -ffast-math -funroll-loops +CFLAGS ?= -Wall -O2 -ffast-math -funroll-loops -fno-common SDL_CFLAGS = `sdl2-config --cflags` DEFINES = -Dstricmp=strcasecmp -Dstrnicmp=strncasecmp -DNDEBUG -DUSE_SDL -DUSE_NET -DZLIB_SUPPORT -DBZLIB_SUPPORT INCLUDES = -I. diff --git a/globals.pre b/globals.pre index 0d4a738..781c8eb 100644 --- globals.pre +++ globals.pre @@ -267,7 +267,7 @@ extern gob_t number_gobs; /* main.c */ -int endscore_reached; +extern int endscore_reached; void steer_players(void); void position_player(int player_num); diff --git a/main.c b/main.c index d03e5f0..87b4e95 100644 --- main.c +++ main.c @@ -67,6 +67,8 @@ char cur_pal[768]; int ai[JNB_MAX_PLAYERS]; +int endscore_reached = 0; + unsigned int ban_map[17][22] = { {1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, {1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 1, 0, 0, 0}, diff --git a/network.c b/network.c index 07227e7..b4a1e4e 100644 --- network.c +++ network.c @@ -32,6 +32,10 @@ int is_server = 1; int is_net = 0; int server_said_bye = 0; +#ifdef USE_NET +NetInfo net_info[JNB_MAX_PLAYERS]; +#endif + void processMovePacket(NetPacket *pkt) { int playerid = pkt->arg; diff --git a/network.h b/network.h index 3058630..f591480 100644 --- network.h +++ network.h @@ -74,7 +74,7 @@ typedef struct SDLNet_SocketSet socketset; } NetInfo; -NetInfo net_info[JNB_MAX_PLAYERS]; +extern NetInfo net_info[JNB_MAX_PLAYERS]; void bufToPacket(const char *buf, NetPacket *pkt); -- GitLab