summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2006-09-26 11:42:03 +0000
committerharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2006-09-26 11:42:03 +0000
commit592c6a235e81c40fd67cddaa429326d2397979a9 (patch)
tree80d525ad032fcca95345d42b68f2f621b1aeb668
parente8c6cd983a488b452fa1b8355c38c5fa92e626a3 (diff)
downloadcrawl-ref-592c6a235e81c40fd67cddaa429326d2397979a9.tar.gz
crawl-ref-592c6a235e81c40fd67cddaa429326d2397979a9.zip
Killed a lot of libunix.cc which is no longer necessary with the new
command dispatch mechanism. Cleaned up all remaining variable shadowing warnings. Added -Wshadow and -pedantic to CFLAGS. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/branches/stone_soup@135 c06c8d41-db1a-0410-9941-cceddc491573
-rw-r--r--crawl-ref/source/Kills.cc14
-rw-r--r--crawl-ref/source/invent.cc9
-rw-r--r--crawl-ref/source/libunix.cc187
-rw-r--r--crawl-ref/source/libunix.h2
-rw-r--r--crawl-ref/source/makefile.lnx1
-rw-r--r--crawl-ref/source/menu.h3
-rw-r--r--crawl-ref/source/ouch.cc2
-rw-r--r--crawl-ref/source/stash.cc10
-rw-r--r--crawl-ref/source/travel.cc14
9 files changed, 27 insertions, 215 deletions
diff --git a/crawl-ref/source/Kills.cc b/crawl-ref/source/Kills.cc
index 66f3157c04..0dfe4376c1 100644
--- a/crawl-ref/source/Kills.cc
+++ b/crawl-ref/source/Kills.cc
@@ -242,10 +242,10 @@ void Kills::merge(const Kills &k)
i != k.kills.end(); ++i)
{
const kill_monster_desc &kmd = i->first;
- kill_def &k = kills[kmd];
+ kill_def &ki = kills[kmd];
const kill_def &ko = i->second;
bool uniq = mons_is_unique(kmd.monnum);
- k.merge(ko, uniq);
+ ki.merge(ko, uniq);
}
}
@@ -369,8 +369,8 @@ void Kills::save(FILE *file) const
// How many kill records do we have?
writeLong(file, kills.size());
- kill_map::const_iterator iter = kills.begin();
- for ( ; iter != kills.end(); ++iter)
+ for ( kill_map::const_iterator iter = kills.begin();
+ iter != kills.end(); ++iter)
{
iter->first.save(file);
iter->second.save(file);
@@ -379,7 +379,7 @@ void Kills::save(FILE *file) const
// How many ghosts do we have?
writeShort(file, ghosts.size());
for (ghost_vec::const_iterator iter = ghosts.begin();
- iter != ghosts.end(); ++iter)
+ iter != ghosts.end(); ++iter)
{
iter->save(file);
}
@@ -409,8 +409,8 @@ void Kills::load(FILE *file)
void Kills::record_ghost_kill(const struct monsters *mon)
{
- kill_ghost ghost(mon);
- ghosts.push_back(ghost);
+ kill_ghost ghostk(mon);
+ ghosts.push_back(ghostk);
}
kill_def::kill_def(const struct monsters *mon) : kills(0), exp(0)
diff --git a/crawl-ref/source/invent.cc b/crawl-ref/source/invent.cc
index 5a3780ab22..c77c14e098 100644
--- a/crawl-ref/source/invent.cc
+++ b/crawl-ref/source/invent.cc
@@ -204,7 +204,7 @@ public:
class InvMenu : public Menu
{
public:
- InvMenu(int flags = MF_MULTISELECT) : Menu(flags) { }
+ InvMenu(int mflags = MF_MULTISELECT) : Menu(mflags) { }
protected:
bool process_key(int key);
};
@@ -690,7 +690,7 @@ std::vector<SelItem> prompt_invent_items(
redraw_screen();
mesclr( true );
- for (int i = 0, count = items.size(); i < count; ++i)
+ for (unsigned int i = 0; i < items.size(); ++i)
items[i].slot = letter_to_index( items[i].slot );
return items;
}
@@ -736,8 +736,7 @@ std::vector<SelItem> prompt_invent_items(
return items;
}
-/*** HP CHANGE ***/
-int digit_to_index( char digit, int type, operation_types oper ) {
+static int digit_to_index( char digit, operation_types oper ) {
int i;
unsigned int j;
@@ -898,7 +897,7 @@ int prompt_invent_item( const char *prompt, int type_expect,
else if ( count == NULL && isdigit( keyin ) )
{
/* scan for our item */
- int res = digit_to_index( keyin, type_expect, oper );
+ int res = digit_to_index( keyin, oper );
if ( res != -1 ) {
ret = res;
if ( check_warning_inscriptions( you.inv[ret], oper ) )
diff --git a/crawl-ref/source/libunix.cc b/crawl-ref/source/libunix.cc
index 76d4025670..2cde84e7ca 100644
--- a/crawl-ref/source/libunix.cc
+++ b/crawl-ref/source/libunix.cc
@@ -69,9 +69,6 @@ int character_set = CHARACTER_SET;
short FG_COL = WHITE;
short BG_COL = BLACK;
-// a lookup table to convert keypresses to command enums
-static int key_to_command_table[KEY_MAX];
-
static unsigned int convert_to_curses_attr( int chattr )
{
switch (chattr & CHATTR_ATTRMASK)
@@ -206,188 +203,6 @@ int getch_ck() {
}
}
-void init_key_to_command()
-{
- int i;
-
- // initialize to "do nothing"
- for (i = 0; i < KEY_MAX; i++)
- {
- key_to_command_table[i] = CMD_NO_CMD;
- }
-
- // lower case
- key_to_command_table[(int) 'a'] = CMD_USE_ABILITY;
- key_to_command_table[(int) 'b'] = CMD_MOVE_DOWN_LEFT;
- key_to_command_table[(int) 'c'] = CMD_CLOSE_DOOR;
- key_to_command_table[(int) 'd'] = CMD_DROP;
- key_to_command_table[(int) 'e'] = CMD_EAT;
- key_to_command_table[(int) 'f'] = CMD_FIRE;
- key_to_command_table[(int) 'g'] = CMD_PICKUP;
- key_to_command_table[(int) 'h'] = CMD_MOVE_LEFT;
- key_to_command_table[(int) 'i'] = CMD_DISPLAY_INVENTORY;
- key_to_command_table[(int) 'j'] = CMD_MOVE_DOWN;
- key_to_command_table[(int) 'k'] = CMD_MOVE_UP;
- key_to_command_table[(int) 'l'] = CMD_MOVE_RIGHT;
- key_to_command_table[(int) 'm'] = CMD_DISPLAY_SKILLS;
- key_to_command_table[(int) 'n'] = CMD_MOVE_DOWN_RIGHT;
- key_to_command_table[(int) 'o'] = CMD_OPEN_DOOR;
- key_to_command_table[(int) 'p'] = CMD_PRAY;
- key_to_command_table[(int) 'q'] = CMD_QUAFF;
- key_to_command_table[(int) 'r'] = CMD_READ;
- key_to_command_table[(int) 's'] = CMD_SEARCH;
- key_to_command_table[(int) 't'] = CMD_THROW;
- key_to_command_table[(int) 'u'] = CMD_MOVE_UP_RIGHT;
- key_to_command_table[(int) 'v'] = CMD_EXAMINE_OBJECT;
- key_to_command_table[(int) 'w'] = CMD_WIELD_WEAPON;
- key_to_command_table[(int) 'x'] = CMD_LOOK_AROUND;
- key_to_command_table[(int) 'y'] = CMD_MOVE_UP_LEFT;
- key_to_command_table[(int) 'z'] = CMD_ZAP_WAND;
-
- // upper case
- key_to_command_table[(int) 'A'] = CMD_DISPLAY_MUTATIONS;
- key_to_command_table[(int) 'B'] = CMD_RUN_DOWN_LEFT;
- key_to_command_table[(int) 'C'] = CMD_EXPERIENCE_CHECK;
- key_to_command_table[(int) 'D'] = CMD_BUTCHER;
- key_to_command_table[(int) 'E'] = CMD_EVOKE;
- key_to_command_table[(int) 'F'] = CMD_NO_CMD;
- key_to_command_table[(int) 'G'] = CMD_NO_CMD;
- key_to_command_table[(int) 'H'] = CMD_RUN_LEFT;
- key_to_command_table[(int) 'I'] = CMD_OBSOLETE_INVOKE;
- key_to_command_table[(int) 'J'] = CMD_RUN_DOWN;
- key_to_command_table[(int) 'K'] = CMD_RUN_UP;
- key_to_command_table[(int) 'L'] = CMD_RUN_RIGHT;
- key_to_command_table[(int) 'M'] = CMD_MEMORISE_SPELL;
- key_to_command_table[(int) 'N'] = CMD_RUN_DOWN_RIGHT;
- key_to_command_table[(int) 'O'] = CMD_DISPLAY_OVERMAP;
- key_to_command_table[(int) 'P'] = CMD_WEAR_JEWELLERY;
- key_to_command_table[(int) 'Q'] = CMD_QUIT;
- key_to_command_table[(int) 'R'] = CMD_REMOVE_JEWELLERY;
- key_to_command_table[(int) 'S'] = CMD_SAVE_GAME;
- key_to_command_table[(int) 'T'] = CMD_REMOVE_ARMOUR;
- key_to_command_table[(int) 'U'] = CMD_RUN_UP_RIGHT;
- key_to_command_table[(int) 'V'] = CMD_GET_VERSION;
- key_to_command_table[(int) 'W'] = CMD_WEAR_ARMOUR;
- key_to_command_table[(int) 'X'] = CMD_DISPLAY_MAP;
- key_to_command_table[(int) 'Y'] = CMD_RUN_UP_LEFT;
- key_to_command_table[(int) 'Z'] = CMD_CAST_SPELL;
-
- // control
- key_to_command_table[ (int) CONTROL('A') ] = CMD_TOGGLE_AUTOPICKUP;
- key_to_command_table[ (int) CONTROL('B') ] = CMD_OPEN_DOOR_DOWN_LEFT;
- key_to_command_table[ (int) CONTROL('C') ] = CMD_CLEAR_MAP;
-
-#ifdef ALLOW_DESTROY_ITEM_COMMAND
- key_to_command_table[ (int) CONTROL('D') ] = CMD_DESTROY_ITEM;
-#else
- key_to_command_table[ (int) CONTROL('D') ] = CMD_NO_CMD;
-#endif
-
- key_to_command_table[ (int) CONTROL('E') ] = CMD_FORGET_STASH;
- key_to_command_table[ (int) CONTROL('F') ] = CMD_SEARCH_STASHES;
- key_to_command_table[ (int) CONTROL('G') ] = CMD_INTERLEVEL_TRAVEL;
- key_to_command_table[ (int) CONTROL('H') ] = CMD_OPEN_DOOR_LEFT;
- key_to_command_table[ (int) CONTROL('I') ] = CMD_NO_CMD;
- key_to_command_table[ (int) CONTROL('J') ] = CMD_OPEN_DOOR_DOWN;
- key_to_command_table[ (int) CONTROL('K') ] = CMD_OPEN_DOOR_UP;
- key_to_command_table[ (int) CONTROL('L') ] = CMD_OPEN_DOOR_RIGHT;
- key_to_command_table[ (int) CONTROL('M') ] = CMD_NO_CMD;
- key_to_command_table[ (int) CONTROL('N') ] = CMD_OPEN_DOOR_DOWN_RIGHT;
- key_to_command_table[ (int) CONTROL('O') ] = CMD_EXPLORE;
- key_to_command_table[ (int) CONTROL('P') ] = CMD_REPLAY_MESSAGES;
- key_to_command_table[ (int) CONTROL('Q') ] = CMD_NO_CMD;
- key_to_command_table[ (int) CONTROL('R') ] = CMD_REDRAW_SCREEN;
- key_to_command_table[ (int) CONTROL('S') ] = CMD_MARK_STASH;
- key_to_command_table[ (int) CONTROL('T') ] = CMD_NO_CMD;
- key_to_command_table[ (int) CONTROL('U') ] = CMD_OPEN_DOOR_UP_LEFT;
- key_to_command_table[ (int) CONTROL('V') ] = CMD_TOGGLE_AUTOPRAYER;
- key_to_command_table[ (int) CONTROL('W') ] = CMD_FIX_WAYPOINT;
- key_to_command_table[ (int) CONTROL('X') ] = CMD_SAVE_GAME_NOW;
- key_to_command_table[ (int) CONTROL('Y') ] = CMD_OPEN_DOOR_UP_RIGHT;
- key_to_command_table[ (int) CONTROL('Z') ] = CMD_SUSPEND_GAME;
-
- // other printables
- key_to_command_table[(int) '.'] = CMD_MOVE_NOWHERE;
- key_to_command_table[(int) '<'] = CMD_GO_UPSTAIRS;
- key_to_command_table[(int) '>'] = CMD_GO_DOWNSTAIRS;
- key_to_command_table[(int) '@'] = CMD_DISPLAY_CHARACTER_STATUS;
- key_to_command_table[(int) ','] = CMD_PICKUP;
- key_to_command_table[(int) ':'] = CMD_MAKE_NOTE;
- key_to_command_table[(int) ';'] = CMD_INSPECT_FLOOR;
- key_to_command_table[(int) '!'] = CMD_SHOUT;
- key_to_command_table[(int) '^'] = CMD_DISPLAY_RELIGION;
- key_to_command_table[(int) '#'] = CMD_CHARACTER_DUMP;
- key_to_command_table[(int) '='] = CMD_ADJUST_INVENTORY;
- key_to_command_table[(int) '?'] = CMD_DISPLAY_COMMANDS;
- key_to_command_table[(int) '`'] = CMD_MACRO_ADD;
- key_to_command_table[(int) '~'] = CMD_MACRO_SAVE;
- key_to_command_table[(int) '&'] = CMD_WIZARD;
- key_to_command_table[(int) '"'] = CMD_LIST_JEWELLERY;
-
-
- // I'm making this both, because I'm tried of changing it
- // back to '[' (the character that represents armour on the map) -- bwr
- key_to_command_table[(int) '['] = CMD_LIST_ARMOUR;
- key_to_command_table[(int) ']'] = CMD_LIST_ARMOUR;
-
- // This one also ended up backwards this time, so it's also going on
- // both now -- should be ')'... the same character that's used to
- // represent weapons.
- key_to_command_table[(int) ')'] = CMD_LIST_WEAPONS;
- key_to_command_table[(int) '('] = CMD_LIST_WEAPONS;
-
- key_to_command_table[(int) '\\'] = CMD_DISPLAY_KNOWN_OBJECTS;
- key_to_command_table[(int) '\''] = CMD_WEAPON_SWAP;
-
- // digits
- key_to_command_table[(int) '0'] = CMD_NO_CMD;
- key_to_command_table[(int) '1'] = CMD_MOVE_DOWN_LEFT;
- key_to_command_table[(int) '2'] = CMD_MOVE_DOWN;
- key_to_command_table[(int) '3'] = CMD_MOVE_DOWN_RIGHT;
- key_to_command_table[(int) '4'] = CMD_MOVE_LEFT;
- key_to_command_table[(int) '5'] = CMD_REST;
- key_to_command_table[(int) '6'] = CMD_MOVE_RIGHT;
- key_to_command_table[(int) '7'] = CMD_MOVE_UP_LEFT;
- key_to_command_table[(int) '8'] = CMD_MOVE_UP;
- key_to_command_table[(int) '9'] = CMD_MOVE_UP_RIGHT;
-
- // keypad
- key_to_command_table[KEY_A1] = CMD_MOVE_UP_LEFT;
- key_to_command_table[KEY_A3] = CMD_MOVE_UP_RIGHT;
- key_to_command_table[KEY_C1] = CMD_MOVE_DOWN_LEFT;
- key_to_command_table[KEY_C3] = CMD_MOVE_DOWN_RIGHT;
-
- key_to_command_table[KEY_HOME] = CMD_MOVE_UP_LEFT;
- key_to_command_table[KEY_PPAGE] = CMD_MOVE_UP_RIGHT;
- key_to_command_table[KEY_END] = CMD_MOVE_DOWN_LEFT;
- key_to_command_table[KEY_NPAGE] = CMD_MOVE_DOWN_RIGHT;
-
- key_to_command_table[KEY_B2] = CMD_REST;
-
- key_to_command_table[KEY_UP] = CMD_MOVE_UP;
- key_to_command_table[KEY_DOWN] = CMD_MOVE_DOWN;
- key_to_command_table[KEY_LEFT] = CMD_MOVE_LEFT;
- key_to_command_table[KEY_RIGHT] = CMD_MOVE_RIGHT;
-
-
- // other odd things
- // key_to_command_table[ 263 ] = CMD_OPEN_DOOR_LEFT; // backspace
-
- // these are invalid keys, but to help kludge running
- // pass them through unmolested
- key_to_command_table[128] = 128;
- key_to_command_table[(int) '*'] = '*';
-}
-
-int key_to_command(int keyin)
-{
- bool is_userfunction(int key);
-
- if (is_userfunction(keyin))
- return keyin;
- return (key_to_command_table[keyin]);
-}
-
void unixcurses_startup( void )
{
termio_init();
@@ -424,8 +239,6 @@ void unixcurses_startup( void )
start_color();
setup_colour_pairs();
- init_key_to_command();
-
#ifndef SOLARIS
// These can cause some display problems under Solaris
scrollok(stdscr, TRUE);
diff --git a/crawl-ref/source/libunix.h b/crawl-ref/source/libunix.h
index c416733666..9cb2dd3604 100644
--- a/crawl-ref/source/libunix.h
+++ b/crawl-ref/source/libunix.h
@@ -17,7 +17,6 @@ int cprintf(const char *format,...);
int gotoxy(int x, int y);
int itoa(int value, char *strptr, int radix);
int kbhit(void);
-int key_to_command(int);
int putch(unsigned char chr);
int stricmp(const char *str1, const char *str2);
int translate_keypad(int keyin);
@@ -32,7 +31,6 @@ void get_input_line_from_curses( char *const buff, int len );
void _setcursortype(int curstype);
void delay(unsigned long time);
-void init_key_to_command();
void unixcurses_shutdown(void);
void unixcurses_startup(void);
void textbackground(int bg);
diff --git a/crawl-ref/source/makefile.lnx b/crawl-ref/source/makefile.lnx
index 8b8b8994fd..2a306320a9 100644
--- a/crawl-ref/source/makefile.lnx
+++ b/crawl-ref/source/makefile.lnx
@@ -18,6 +18,7 @@ COPY = cp
OS_TYPE = LINUX
CFLAGS = -Wall -Wwrite-strings -fsigned-char \
+ -Wshadow -pedantic \
-g -D$(OS_TYPE) $(EXTRA_FLAGS)
MCHMOD = 2755
diff --git a/crawl-ref/source/menu.h b/crawl-ref/source/menu.h
index 4552851bb4..a788b92ebc 100644
--- a/crawl-ref/source/menu.h
+++ b/crawl-ref/source/menu.h
@@ -33,7 +33,8 @@ struct menu_letter
return *this;
}
- menu_letter operator ++ (int postfix)
+ // dummy postfix argument unnamed to stop gcc from complaining
+ menu_letter operator ++ (int)
{
menu_letter copy = *this;
this->operator++();
diff --git a/crawl-ref/source/ouch.cc b/crawl-ref/source/ouch.cc
index 7161aee1da..0fdd6d7f9d 100644
--- a/crawl-ref/source/ouch.cc
+++ b/crawl-ref/source/ouch.cc
@@ -976,7 +976,7 @@ void end_game( struct scorefile_entry &se )
const int num_suffixes = sizeof(suffixes) / sizeof(const char*);
- for ( int i = 0; i < num_suffixes; ++i ) {
+ for ( i = 0; i < num_suffixes; ++i ) {
std::string tmpname = basename + suffixes[i];
unlink( tmpname.c_str() );
}
diff --git a/crawl-ref/source/stash.cc b/crawl-ref/source/stash.cc
index ae512cd019..567982800b 100644
--- a/crawl-ref/source/stash.cc
+++ b/crawl-ref/source/stash.cc
@@ -713,12 +713,12 @@ bool ShopInfo::matches_search(const std::string &prefix,
for (unsigned i = 0; i < items.size(); ++i)
{
- std::string name = shop_item_name(items[i]);
+ std::string sname = shop_item_name(items[i]);
std::string ann = stash_annotate_item(
LUA_SEARCH_ANNOTATE, &items[i].item, true);
bool thismatch = false;
- if (search.matches(prefix + " " + ann + name))
+ if (search.matches(prefix + " " + ann + sname))
thismatch = true;
else
{
@@ -730,7 +730,7 @@ bool ShopInfo::matches_search(const std::string &prefix,
if (thismatch)
{
if (!res.count++)
- res.match = name;
+ res.match = sname;
res.matches++;
}
}
@@ -1038,11 +1038,11 @@ void LevelStashes::write(std::ostream &os, bool identify) const
{
const Stash &s = stashes.begin()->second;
int refx = s.getX(), refy = s.getY();
- std::string level_name = short_level_name();
+ std::string levname = short_level_name();
for (c_stashes::const_iterator iter = stashes.begin();
iter != stashes.end(); iter++)
{
- iter->second.write(os, refx, refy, level_name, identify);
+ iter->second.write(os, refx, refy, levname, identify);
}
}
os << std::endl;
diff --git a/crawl-ref/source/travel.cc b/crawl-ref/source/travel.cc
index ece94608ba..5a594fcaa8 100644
--- a/crawl-ref/source/travel.cc
+++ b/crawl-ref/source/travel.cc
@@ -752,10 +752,10 @@ void start_running(void)
*/
command_type travel()
{
- char x,y;
- char *move_x = &x;
- char *move_y = &y;
- x = y = 0;
+ char holdx, holdy;
+ char *move_x = &holdx;
+ char *move_y = &holdy;
+ holdx = holdy = 0;
command_type result = CMD_NO_CMD;
@@ -1486,14 +1486,14 @@ static std::vector<unsigned char> get_known_branches()
BRANCH_HALL_OF_ZOT
};
- std::vector<unsigned char> branches;
+ std::vector<unsigned char> result;
for (unsigned i = 0; i < sizeof list_order / sizeof(*list_order); ++i)
{
if (is_known_branch(list_order[i]))
- branches.push_back(list_order[i]);
+ result.push_back(list_order[i]);
}
- return branches;
+ return result;
}
static int prompt_travel_branch()