Skip to content

Commit

Permalink
Fix compile warnings with -Wall
Browse files Browse the repository at this point in the history
  • Loading branch information
cxong committed Jan 12, 2013
1 parent 7f9f4d9 commit ff78f23
Show file tree
Hide file tree
Showing 22 changed files with 341 additions and 173 deletions.
14 changes: 14 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
cmake_minimum_required(VERSION 2.6)
project(cdogs-sdl)

#There are lots of scripts with cmake
#for finding external libraries.
#see /usr/local/share/cmake-2.6/Modules/Find*.cmake for more examples
find_package(sdl-dev REQUIRED)
find_package(sdl-mixer)

set(CF_OPTIMISE "-02")
set(CF_ARCH "")
set(CF_DEBUG "-w") #-ggdb -Wall, -pg
set(CMAKE_C_FLAGS "-g -Wall")
add_subdirectory(w01-cpp)
8 changes: 4 additions & 4 deletions src/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -165,17 +165,15 @@ endif

### Debugging

CF_DEBUG:=-Wall
ifeq ($(DEBUG), 1)
DEFS += -DCDOGS_DEBUG
CF_DEBUG += -ggdb -Wall
CF_DEBUG += -ggdb

ifeq ($(DEBUG_PROFILE), 1)
CF_DEBUG += -pg
LDFLAGS += -pg
endif
else
# suppress warnings
CF_DEBUG += -w
endif


Expand Down Expand Up @@ -205,6 +203,8 @@ CDOGSED_OBJS = \

.PHONY: clean install info tidy help

all: $(CDOGS) $(CDOGSED)

help:
@echo "C-Dogs SDL Build System..."
@echo
Expand Down
3 changes: 3 additions & 0 deletions src/actors.c
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,9 @@ void DrawCharacter(int x, int y, TActor * actor)
pic2 = body;
pic3 = head;
break;
default:
// should never get here
return;
}

if (transparent) {
Expand Down
2 changes: 1 addition & 1 deletion src/automap.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ static void DisplaySummary()
{
int i, y, x, x2;
char sScore[20];
unsigned char *scr = GetDstScreen();
//unsigned char *scr = GetDstScreen();
unsigned char color;

y = SCREEN_HEIGHT - 5 - TextHeight(); // 10 pixels from bottom
Expand Down
49 changes: 22 additions & 27 deletions src/blit.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,68 +118,63 @@ void *GetDstScreen(void)
return r_screen;
}

#define PixelIndex(x, y, w, h) (y * w + x)
#define PixelIndex(x, y, w) (y * w + x)

#ifdef _MSC_VER
#define inline __inline
#endif

static inline
void Scale8(char unsigned *d, const unsigned char *s, const int w, const int h, const int sf)
static INLINE
void Scale8(char unsigned *d, const unsigned char *s, const int w, const int h,
const int sf)
{
int sx;
int sy;
int f = sf;

int dx, dy, dw, dh;
int dx, dy, dw;
char p;

if (f > 4) f = 4; /* max 4x for the moment */

dw = w * f;
dh = h * f;

for (sy = 0; sy < h; sy++) {
dy = f * sy;
for (sx = 0; sx < w; sx++) {
p = s[PixelIndex(sx, sy, w, h)];
p = s[PixelIndex(sx, sy, w)];
dx = f * sx;

switch (f) {
case 4:
/* right side */
d[PixelIndex((dx + 3), (dy + 1), dw, dh)] = p;
d[PixelIndex((dx + 3), (dy + 2), dw, dh)] = p;
d[PixelIndex((dx + 3), dy, dw, dh)] = p;
d[PixelIndex((dx + 3), (dy + 1), dw)] = p;
d[PixelIndex((dx + 3), (dy + 2), dw)] = p;
d[PixelIndex((dx + 3), dy, dw)] = p;

/* bottom row */
d[PixelIndex(dx, (dy + 3), dw, dh)] = p;
d[PixelIndex((dx + 1), (dy + 3), dw, dh)] = p;
d[PixelIndex((dx + 2), (dy + 3), dw, dh)] = p;
d[PixelIndex(dx, (dy + 3), dw)] = p;
d[PixelIndex((dx + 1), (dy + 3), dw)] = p;
d[PixelIndex((dx + 2), (dy + 3), dw)] = p;

/* bottom right */
d[PixelIndex((dx + 3), (dy + 3), dw, dh)] = p;
d[PixelIndex((dx + 3), (dy + 3), dw)] = p;

case 3:
/* right side */
d[PixelIndex((dx + 2), (dy + 1), dw, dh)] = p;
d[PixelIndex((dx + 2), dy, dw, dh)] = p;
d[PixelIndex((dx + 2), (dy + 1), dw)] = p;
d[PixelIndex((dx + 2), dy, dw)] = p;

/* bottom row */
d[PixelIndex(dx, (dy + 2), dw, dh)] = p;
d[PixelIndex((dx + 1), (dy + 2), dw, dh)] = p;
d[PixelIndex(dx, (dy + 2), dw)] = p;
d[PixelIndex((dx + 1), (dy + 2), dw)] = p;

/* bottom right */
d[PixelIndex((dx + 2), (dy + 2), dw, dh)] = p;

d[PixelIndex((dx + 2), (dy + 2), dw)] = p;

case 2:
d[PixelIndex((dx + 1), dy, dw, dh)] = p;
d[PixelIndex((dx + 1), (dy + 1), dw, dh)] = p;
d[PixelIndex(dx, (dy + 1), dw, dh)] = p;
d[PixelIndex((dx + 1), dy, dw)] = p;
d[PixelIndex((dx + 1), (dy + 1), dw)] = p;
d[PixelIndex(dx, (dy + 1), dw)] = p;

default:
d[PixelIndex(dx, dy, dw, dh)] = p;
d[PixelIndex(dx, dy, dw)] = p;
}
}
}
Expand Down
17 changes: 11 additions & 6 deletions src/cdogs.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,17 +93,22 @@ void DrawObjectiveInfo(int index, int x, int y, struct Mission *mission)
pic = cGeneralPics[i];
break;
case OBJECTIVE_INVESTIGATE:
pic.dx = pic.dy = 0;
pic.picIndex = -1;
return;
default:
i = gMission.objectives[i].pickupItem;
pic = cGeneralPics[i];
break;
}
if (pic.picIndex >= 0) {
if (table)
DrawTTPic(x + pic.dx, y + pic.dy, gPics[pic.picIndex],
table, NULL);
else
DrawTPic(x + pic.dx, y + pic.dy, gPics[pic.picIndex],
NULL);
}
if (table)
DrawTTPic(x + pic.dx, y + pic.dy, gPics[pic.picIndex],
table, NULL);
else
DrawTPic(x + pic.dx, y + pic.dy, gPics[pic.picIndex],
NULL);
}

int MissionDescription(int y, const char *description)
Expand Down
30 changes: 18 additions & 12 deletions src/cdogsed.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#include "objs.h"
#include "actors.h"
#include "grafx.h"
#include "keyboard.h"
#include "pics.h"
#include "text.h"
#include "gamedata.h"
Expand Down Expand Up @@ -269,19 +270,19 @@ void DisplayText(int x, int y, const char *text, int hilite, int editable)
TextGoto(x, y);
if (editable) {
if (hilite)
TextCharWithTable('\020', tableFlamed);
TextCharWithTable('\020', &tableFlamed);
else
TextChar('\020');
}

if (hilite && !editable)
TextStringWithTable(text, tableFlamed);
TextStringWithTable(text, &tableFlamed);
else
TextString(text);

if (editable) {
if (hilite)
TextCharWithTable('\021', tableFlamed);
TextCharWithTable('\021', &tableFlamed);
else
TextChar('\021');
}
Expand All @@ -301,7 +302,7 @@ void DrawObjectiveInfo(int index, int y, int xc)
i = characterDesc[currentMission->baddieCount +
CHARACTER_OTHERS].facePic;
table =
characterDesc[currentMission->baddieCount +
&characterDesc[currentMission->baddieCount +
CHARACTER_OTHERS].table;
pic.picIndex = cHeadPic[i][DIRECTION_DOWN][STATE_IDLE];
pic.dx = cHeadOffset[i][DIRECTION_DOWN].dx;
Expand All @@ -310,7 +311,7 @@ void DrawObjectiveInfo(int index, int y, int xc)
case OBJECTIVE_RESCUE:
typeText = "Rescue";
i = characterDesc[CHARACTER_PRISONER].facePic;
table = characterDesc[CHARACTER_PRISONER].table;
table = &characterDesc[CHARACTER_PRISONER].table;
pic.picIndex = cHeadPic[i][DIRECTION_DOWN][STATE_IDLE];
pic.dx = cHeadOffset[i][DIRECTION_DOWN].dx;
pic.dy = cHeadOffset[i][DIRECTION_DOWN].dy;
Expand All @@ -327,17 +328,19 @@ void DrawObjectiveInfo(int index, int y, int xc)
break;
case OBJECTIVE_INVESTIGATE:
typeText = "Explore";
pic.dx = pic.dy = 0;
pic.picIndex = -1;
break;
default:
typeText = "???";
i = gMission.objectives[i].pickupItem;
i = gMission.objectives[index].pickupItem;
pic = cGeneralPics[i];
break;
}

DisplayText(20, y, typeText, xc == XC_TYPE, 0);

if (currentMission->objectives[index].type !=
OBJECTIVE_INVESTIGATE) {
if (pic.picIndex >= 0) {
if (table)
DrawTTPic(60 + pic.dx, y + 8 + pic.dy,
gPics[pic.picIndex], table, NULL);
Expand Down Expand Up @@ -374,7 +377,7 @@ int MissionDescription(int y, const char *description, int hilite)

TextGoto(20 - TextCharWidth('\020'), y);
if (hilite)
TextCharWithTable('\020', tableFlamed);
TextCharWithTable('\020', &tableFlamed);
else
TextChar('\020');

Expand Down Expand Up @@ -415,7 +418,7 @@ int MissionDescription(int y, const char *description, int hilite)
}

if (hilite)
TextCharWithTable('\021', tableFlamed);
TextCharWithTable('\021', &tableFlamed);
else
TextChar('\021');

Expand Down Expand Up @@ -485,7 +488,7 @@ void DisplayMapItem(int x, int y, TMapObject * mo, int density, int hilite)
{
char s[10];

TOffsetPic *pic = &cGeneralPics[mo->pic];
const TOffsetPic *pic = &cGeneralPics[mo->pic];
DrawTPic(x + pic->dx, y + pic->dy, gPics[pic->picIndex], NULL);

if (hilite) {
Expand Down Expand Up @@ -899,6 +902,9 @@ static int Change(int yc, int xc, int d, int *mission)
limit =
campaign.characterCount - 1;
break;
default:
// should never get here
return 0;
}
currentMission->objectives[yc -
YC_OBJECTIVES].
Expand Down Expand Up @@ -1207,7 +1213,7 @@ static void Save(int asCode)
{
char filename[128];
// char drive[_MAX_DRIVE];
char dir[96];
// char dir[96];
char name[32];
// char ext[_MAX_EXT];
char c;
Expand Down
9 changes: 5 additions & 4 deletions src/charsed.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include "actors.h"
#include "defs.h"
#include "grafx.h"
#include "keyboard.h"
#include "pics.h"
#include "text.h"
#include "mission.h"
Expand Down Expand Up @@ -196,7 +197,7 @@ static void DisplayCharacter(int x, int y, const TBadGuy * data,
static void DisplayText(int x, int y, const char *text, int hilite)
{
if (hilite)
TextStringWithTableAt(x, y, text, tableFlamed);
TextStringWithTableAt(x, y, text, &tableFlamed);
else
TextStringAt(x, y, text);
}
Expand All @@ -205,14 +206,14 @@ void DisplayFlag(int x, int y, const char *s, int on, int hilite)
{
TextGoto(x, y);
if (hilite) {
TextStringWithTable(s, tableFlamed);
TextCharWithTable(':', tableFlamed);
TextStringWithTable(s, &tableFlamed);
TextCharWithTable(':', &tableFlamed);
} else {
TextString(s);
TextChar(':');
}
if (on)
TextStringWithTable("On", tablePurple);
TextStringWithTable("On", &tablePurple);
else
TextString("Off");
}
Expand Down
Loading

0 comments on commit ff78f23

Please sign in to comment.