Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiler warning resolutions #126

Merged
merged 6 commits into from
Mar 1, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions Makefile.Windows
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
# WARNINGS will spam hundreds of warnings, mostly safe, if turned on
# DEBUG is best turned on if you plan to debug in gdb -- please do!
# PROFILE is for use with gprof or a similar program -- don't bother generally
#WARNINGS = -Wall -Wextra -Wno-switch -Wno-sign-compare -Wno-missing-braces -Wno-unused-parameter -Wno-char-subscripts

WARNINGS = -Wall -Wextra
DEBUG = -g
#PROFILE = -pg
OTHERS = -O3
Expand Down Expand Up @@ -49,4 +50,4 @@ $(ODIR)/%.o: %.cpp
clean:
rm -f $(TARGET) $(ODIR)/*.o

-include $(SOURCES:%.cpp=$(DEPDIR)/%.P)
-include $(SOURCES:%.cpp=$(DEPDIR)/%.P)
6 changes: 6 additions & 0 deletions action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,9 @@ std::string action_ident(action_id act)
return "debug_mode";
case ACTION_NULL:
return "null";

default:
break;
}
return "unknown";
}
Expand Down Expand Up @@ -389,6 +392,9 @@ std::string action_name(action_id act)
return "Toggle Debug Messages";
case ACTION_NULL:
return "No Action";

default:
break;
}
return "Someone forgot to name an action.";
}
3 changes: 3 additions & 0 deletions addiction.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,9 @@ void addict_effect(game *g, addiction &add)
g->u.stim -= 3;
}
break;

default:
break;
}
}

Expand Down
57 changes: 28 additions & 29 deletions artifact.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ void game::process_artifact(item *it, player *p, bool wielded)
it_artifact_tool* tool = dynamic_cast<it_artifact_tool*>(it->type);
effects = tool->effects_carried;
if (wielded) {
for (int i = 0; i < tool->effects_wielded.size(); i++)
for (unsigned int i = 0; i < tool->effects_wielded.size(); i++)
effects.push_back(tool->effects_wielded[i]);
}
// Recharge it if necessary
Expand Down Expand Up @@ -448,11 +448,16 @@ void game::process_artifact(item *it, player *p, bool wielded)
it->charges++;
}
break;

// Unused enums added for completeness.
case ARTC_NULL:
case NUM_ARTCS:
break;
}
}
}

for (int i = 0; i < effects.size(); i++) {
for (unsigned int i = 0; i < effects.size(); i++) {
switch (effects[i]) {
case AEP_STR_UP:
p->str_cur += 4;
Expand All @@ -472,25 +477,12 @@ void game::process_artifact(item *it, player *p, bool wielded)
p->per_cur += 2;
p->int_cur += 2;
break;
case AEP_SPEED_UP: // Handled in player::current_speed()
break;

case AEP_IODINE:
if (p->radiation > 0)
p->radiation--;
break;

case AEP_SMOKE:
if (one_in(10)) {
int x = p->posx + rng(-1, 1), y = p->posy + rng(-1, 1);
if (m.add_field(this, x, y, fd_smoke, rng(1, 3)))
add_msg("The %s emits some smoke.", it->tname().c_str());
}
break;

case AEP_SNAKES:
break; // Handled in player::hit()

case AEP_EXTINGUISH:
for (int x = p->posx - 1; x <= p->posx + 1; x++) {
for (int y = p->posy - 1; y <= p->posy + 1; y++) {
Expand All @@ -514,6 +506,14 @@ void game::process_artifact(item *it, player *p, bool wielded)
p->thirst++;
break;

case AEP_SMOKE:
if (one_in(10)) {
int x = p->posx + rng(-1, 1), y = p->posy + rng(-1, 1);
if (m.add_field(this, x, y, fd_smoke, rng(1, 3)))
add_msg("The %s emits some smoke.", it->tname().c_str());
}
break;

case AEP_EVIL:
if (one_in(150)) { // Once every 15 minutes, on average
p->add_disease(DI_EVIL, 300, this);
Expand All @@ -523,14 +523,6 @@ void game::process_artifact(item *it, player *p, bool wielded)
}
break;

case AEP_SCHIZO:
break; // Handled in player::suffer()

case AEP_RADIOACTIVE:
if (one_in(4))
p->radiation++;
break;

case AEP_STR_DOWN:
p->str_cur -= 3;
break;
Expand All @@ -554,16 +546,22 @@ void game::process_artifact(item *it, player *p, bool wielded)
p->int_cur -= 2;
break;

case AEP_SPEED_DOWN:
break; // Handled in player::current_speed()
case AEP_RADIOACTIVE:
if (one_in(4))
p->radiation++;
break;


default:
break;
}
}
}

void game::add_artifact_messages(std::vector<art_effect_passive> effects)
{
int net_str = 0, net_dex = 0, net_per = 0, net_int = 0, net_speed = 0;
for (int i = 0; i < effects.size(); i++) {
for (unsigned int i = 0; i < effects.size(); i++) {
switch (effects[i]) {
case AEP_STR_UP: net_str += 4; break;
case AEP_DEX_UP: net_dex += 4; break;
Expand All @@ -585,9 +583,6 @@ void game::add_artifact_messages(std::vector<art_effect_passive> effects)
case AEP_SPEED_UP: net_speed += 20; break;
case AEP_SPEED_DOWN: net_speed -= 20; break;

case AEP_IODINE:
break; // No message

case AEP_SNAKES:
add_msg("Your skin feels slithery.");
break;
Expand Down Expand Up @@ -659,6 +654,10 @@ void game::add_artifact_messages(std::vector<art_effect_passive> effects)
case AEP_BAD_WEATHER:
add_msg("You feel storms coming.");
break;

// Unused enums added for completeness.
default:
break;
}
}

Expand Down
17 changes: 10 additions & 7 deletions bionics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ void player::activate_bionic(int b, game *g)
std::vector<std::string> good;
std::vector<std::string> bad;
WINDOW* w;
int dirx, diry, t, l, index;
int dirx, diry, t, index;
unsigned int l;
item tmp_item;

switch (bio.id) {

case bio_painkiller:
pkill += 6;
pain -= 2;
Expand Down Expand Up @@ -134,7 +134,7 @@ void player::activate_bionic(int b, game *g)
if (good.size() == 0 && bad.size() == 0)
mvwprintz(w, 1, 1, c_white, "No effects.");
else {
for (int line = 1; line < 39 && line <= good.size() + bad.size(); line++) {
for (unsigned int line = 1; line < 39 && line <= good.size() + bad.size(); line++) {
if (line <= bad.size())
mvwprintz(w, line, 1, c_red, bad[line - 1].c_str());
else
Expand Down Expand Up @@ -268,7 +268,7 @@ void player::activate_bionic(int b, game *g)
break;

case bio_water_extractor:
for (int i = 0; i < g->m.i_at(posx, posy).size(); i++) {
for (unsigned int i = 0; i < g->m.i_at(posx, posy).size(); i++) {
item tmp = g->m.i_at(posx, posy)[i];
if (tmp.type->id == itm_corpse && query_yn("Extract water from the %s",
tmp.tname().c_str())) {
Expand Down Expand Up @@ -306,7 +306,7 @@ void player::activate_bionic(int b, game *g)
traj = line_to(i, j, posx, posy, 0);
}
traj.insert(traj.begin(), point(i, j));
for (int k = 0; k < g->m.i_at(i, j).size(); k++) {
for (unsigned int k = 0; k < g->m.i_at(i, j).size(); k++) {
if (g->m.i_at(i, j)[k].made_of(IRON) || g->m.i_at(i, j)[k].made_of(STEEL)){
tmp_item = g->m.i_at(i, j)[k];
g->m.i_rem(i, j, k);
Expand Down Expand Up @@ -353,6 +353,9 @@ void player::activate_bionic(int b, game *g)
g->add_msg("You can't unlock that %s.", g->m.tername(dirx, diry).c_str());
break;

// Unused enums added for completeness.
default:
break;
}
}

Expand Down Expand Up @@ -383,7 +386,7 @@ bool player::install_bionics(game *g, it_bionic* type)
mvwputch(w, 21, i, c_ltgray, LINE_OXOX);
}
// Init the list of bionics
for (int i = 1; i < type->options.size(); i++) {
for (unsigned int i = 1; i < type->options.size(); i++) {
bionic_id id = type->options[i];
mvwprintz(w, i + 2, 0, (has_bionic(id) ? c_ltred : c_ltblue),
bionics[id].name.c_str());
Expand Down Expand Up @@ -453,7 +456,7 @@ charge mechanism, which must be installed from another CBM.", BATTERY_AMOUNT);
return false;
}

int selection = 0;
unsigned selection = 0;
char ch;

do {
Expand Down
19 changes: 10 additions & 9 deletions catacurse.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,12 +262,12 @@ WINDOW *initscr(void)
lastchar=-1;
inputdelay=-1;
std::string typeface;
char * typeface_c;
char * typeface_c = NULL;
std::ifstream fin;
fin.open("data\\FONTDATA");
if (!fin.is_open()){
MessageBox(WindowHandle, "Failed to open FONTDATA, loading defaults.",
NULL, NULL);
NULL, 0);
fontheight=16;
fontwidth=8;
} else {
Expand All @@ -278,7 +278,7 @@ fin.open("data\\FONTDATA");
fin >> fontheight;
if ((fontwidth <= 4) || (fontheight <=4)){
MessageBox(WindowHandle, "Invalid font size specified!",
NULL, NULL);
NULL, 0);
fontheight=16;
fontwidth=8;
}
Expand Down Expand Up @@ -314,7 +314,7 @@ fin.open("data\\FONTDATA");

} else {
MessageBox(WindowHandle, "Failed to load default font, using FixedSys.",
NULL, NULL);
NULL, 0);
font = CreateFont(fontheight, fontwidth, 0, 0, FW_NORMAL, FALSE, FALSE, FALSE,
ANSI_CHARSET, OUT_DEFAULT_PRECIS,CLIP_DEFAULT_PRECIS,
PROOF_QUALITY, FF_MODERN, "FixedSys"); //Create our font
Expand All @@ -324,7 +324,8 @@ fin.open("data\\FONTDATA");
SelectObject(backbuffer, font);//Load our font into the DC
// WindowCount=0;

delete typeface_c;
if (typeface_c != NULL) delete typeface_c;

mainwin = newwin((OPTIONS[OPT_VIEWPORT_Y] * 2 + 1),(55 + (OPTIONS[OPT_VIEWPORT_Y] * 2 + 1)),0,0);
return mainwin; //create the 'stdscr' window and return its ref
};
Expand Down Expand Up @@ -679,7 +680,7 @@ int start_color(void)
return SetDIBColorTable(backbuffer, 0, 16, windowsPalette);
};

int keypad(WINDOW *faux, bool bf)
int keypad(WINDOW */*faux*/, bool /*bf*/)
{
return 1;
};
Expand All @@ -692,11 +693,11 @@ int cbreak(void)
{
return 1;
};
int keypad(int faux, bool bf)
int keypad(int /*faux*/, bool /*bf*/)
{
return 1;
};
int curs_set(int visibility)
int curs_set(int /*visibility*/)
{
return 1;
};
Expand All @@ -717,7 +718,7 @@ int wattron(WINDOW *win, int attrs)
if (isBlink) win->BG += 8;
return 1;
};
int wattroff(WINDOW *win, int attrs)
int wattroff(WINDOW *win, int /*attrs*/)
{
win->FG=8; //reset to white
win->BG=0; //reset to black
Expand Down
Loading