From cc137f4b229d1763c3ad71fe56605b8611a1067c Mon Sep 17 00:00:00 2001 From: j-p-e-g Date: Tue, 15 Apr 2008 15:26:57 +0000 Subject: Another code cleanup. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@4244 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/acr.cc | 2 +- crawl-ref/source/chardump.cc | 41 ++++---- crawl-ref/source/database.cc | 54 +++++------ crawl-ref/source/debug.cc | 2 +- crawl-ref/source/effects.cc | 2 +- crawl-ref/source/files.cc | 10 +- crawl-ref/source/format.cc | 34 ++++--- crawl-ref/source/guic-win.cc | 24 ++--- crawl-ref/source/guic-x11.cc | 51 +++++----- crawl-ref/source/guic.cc | 78 ++++++++------- crawl-ref/source/invent.cc | 46 +++++---- crawl-ref/source/item_use.cc | 4 +- crawl-ref/source/itemname.cc | 70 +++++++------- crawl-ref/source/items.cc | 7 +- crawl-ref/source/libw32c.cc | 6 +- crawl-ref/source/libwt.cc | 202 ++++++++++++++++++++------------------ crawl-ref/source/libx11.cc | 39 ++++---- crawl-ref/source/luadgn.cc | 18 ++-- crawl-ref/source/macro.cc | 49 ++++++---- crawl-ref/source/menu.cc | 77 ++++++++------- crawl-ref/source/message.cc | 2 +- crawl-ref/source/monplace.cc | 7 +- crawl-ref/source/monstuff.cc | 10 +- crawl-ref/source/mt19937ar.cc | 54 ++++++----- crawl-ref/source/ouch.cc | 3 +- crawl-ref/source/output.cc | 19 ++-- crawl-ref/source/player.cc | 12 ++- crawl-ref/source/quiver.cc | 55 +++++------ crawl-ref/source/randart.cc | 72 +++++++------- crawl-ref/source/religion.cc | 4 +- crawl-ref/source/spells3.cc | 20 ++-- crawl-ref/source/stash.cc | 140 +++++++++++++++------------ crawl-ref/source/tags.cc | 9 +- crawl-ref/source/tile1.cc | 130 ++++++++++++------------- crawl-ref/source/tile2.cc | 28 +++--- crawl-ref/source/travel.cc | 220 +++++++++++++++++++++--------------------- crawl-ref/source/view.cc | 8 +- 37 files changed, 841 insertions(+), 768 deletions(-) diff --git a/crawl-ref/source/acr.cc b/crawl-ref/source/acr.cc index d4931d6431..9233f47165 100644 --- a/crawl-ref/source/acr.cc +++ b/crawl-ref/source/acr.cc @@ -2629,7 +2629,7 @@ static void _decrement_durations() switch (temp_effect) { case SPWPN_VORPAL: - if (get_vorpal_type(you.inv[you.equip[EQ_WEAPON]])==DVORP_SLICING) + if (get_vorpal_type(you.inv[you.equip[EQ_WEAPON]]) == DVORP_SLICING) msg += " seems blunter."; else msg += " feels lighter."; diff --git a/crawl-ref/source/chardump.cc b/crawl-ref/source/chardump.cc index cc2f9f5671..02647c1a94 100644 --- a/crawl-ref/source/chardump.cc +++ b/crawl-ref/source/chardump.cc @@ -172,7 +172,7 @@ bool dump_char(const std::string &fname, bool show_prices, bool full_id, text.reserve(100 * 80); dump_params par(text, "", show_prices, full_id, se); - + for (int i = 0, size = Options.dump_order.size(); i < size; ++i) { par.section = Options.dump_order[i]; @@ -203,7 +203,7 @@ static void sdump_stats(dump_params &par) static void sdump_burden(dump_params &par) { std::string verb = par.se? "were" : "are"; - + switch (you.burden_state) { case BS_OVERLOADED: @@ -223,7 +223,7 @@ static void sdump_hunger(dump_params &par) par.text += "You were "; else par.text += "You are "; - + par.text += hunger_level(); par.text += ".\n\n"; } @@ -367,7 +367,7 @@ static std::string sdump_turns_place_info(PlaceInfo place_info, float a, b, c, d, e, f; unsigned int non_interlevel = place_info.turns_total - place_info.turns_interlevel; - unsigned int global_non_interlevel = + unsigned int global_non_interlevel = gi.turns_total - gi.turns_interlevel; @@ -561,7 +561,8 @@ static void sdump_notes(dump_params &par) text += "\nNotes\nTurn | Place | Note\n"; text += "--------------------------------------------------------------\n"; - for ( unsigned i = 0; i < note_list.size(); ++i ) { + for ( unsigned i = 0; i < note_list.size(); ++i ) + { text += note_list[i].describe(); text += "\n"; } @@ -575,7 +576,7 @@ static void sdump_notes(dump_params &par) //--------------------------------------------------------------- static void sdump_location(dump_params &par) { - if (you.your_level == -1 + if (you.your_level == -1 && you.where_are_you == BRANCH_MAIN_DUNGEON && you.level_type == LEVEL_DUNGEON) { @@ -694,7 +695,7 @@ static void sdump_inventory(dump_params &par) if (is_valid_item( you.inv[i] )) { // adds up number of each class in invent. - inv_class2[you.inv[i].base_type]++; + inv_class2[you.inv[i].base_type]++; inv_count++; } } @@ -748,7 +749,7 @@ static void sdump_inventory(dump_params &par) { text += " ("; - itoa( ival = item_value( you.inv[j], true ), + itoa( ival = item_value( you.inv[j], true ), tmp_quant, 10 ); text += tmp_quant; @@ -763,7 +764,7 @@ static void sdump_inventory(dump_params &par) if (is_dumpable_artefact( you.inv[j], false )) { - text2 = get_item_description( you.inv[j], + text2 = get_item_description( you.inv[j], false, true ); @@ -810,7 +811,7 @@ static void sdump_skills(dump_params &par) if (you.skills[i] > 0) { text += ( (you.skills[i] == 27) ? " * " : - (you.practise_skill[i]) ? " + " + (you.practise_skill[i]) ? " + " : " - " ); text += "Level "; @@ -876,13 +877,13 @@ static void sdump_spells(dump_params &par) int spell_levels = player_spell_levels(); std::string verb = par.se? "had" : "have"; - + if (spell_levels == 1) text += "You " + verb + " one spell level left."; else if (spell_levels == 0) { verb = par.se? "couldn't" : "cannot"; - + text += "You " + verb + " memorise any spells."; } else @@ -901,7 +902,7 @@ static void sdump_spells(dump_params &par) if (!you.spell_no) { verb = par.se? "didn't" : "don't"; - + text += "You " + verb + " know any spells.\n\n"; } else @@ -927,8 +928,8 @@ static void sdump_spells(dump_params &par) if ( spell_line.length() > 24 ) spell_line = spell_line.substr(0, 24); - - for (int i = spell_line.length(); i < 26; i++) + + for (int i = spell_line.length(); i < 26; i++) spell_line += ' '; bool already = false; @@ -1082,7 +1083,7 @@ static void sdump_hiscore(dump_params &par) { if (!par.se) return; - + std::string hiscore = hiscores_format_single_long( *(par.se), true ); trim_string(hiscore); par.text += hiscore; @@ -1157,7 +1158,7 @@ void dump_map(FILE *fp) if ( j < min_y ) min_y = j; } - + for ( int y = min_y; y <= max_y; ++y ) { for ( int x = min_x; x <= max_x; ++x ) @@ -1178,7 +1179,7 @@ void dump_map(const char* fname) dump_map(fp); - fclose(fp); + fclose(fp); } static bool write_dump( @@ -1214,7 +1215,7 @@ static bool write_dump( } else mprf("Error opening file '%s'", file_name.c_str()); - + return (succeeded); } @@ -1256,7 +1257,7 @@ void resists_screen() clrscr(); cgotoxy(1,1); textcolor(LIGHTGREY); - + formatted_scroller scr; scr.set_tag("resists"); for ( unsigned i = 0; i < vfs.size(); ++i ) diff --git a/crawl-ref/source/database.cc b/crawl-ref/source/database.cc index 8783f0d88b..8417b6e689 100644 --- a/crawl-ref/source/database.cc +++ b/crawl-ref/source/database.cc @@ -38,7 +38,7 @@ class TextDB DBM* get() { return _db; } // Make it easier to migrate from raw DBM* to TextDB - operator bool() const { return _db!=0; } + operator bool() const { return _db != 0; } operator DBM*() const { return _db; } private: @@ -66,26 +66,26 @@ static TextDB AllDBs[] = "descript/gods.txt", "descript/branches.txt", NULL), - + TextDB( "db/randart", "database/randname.txt", "database/rand_wpn.txt", // mostly weapons "database/rand_arm.txt", // mostly armour "database/rand_all.txt", // jewellery and general NULL), - + TextDB( "db/speak", "database/monspeak.txt", // monster speech "database/wpnnoise.txt", // noisy weapon speech "database/insult.txt", // imp/demon taunts "database/godspeak.txt", // god speech NULL), - + TextDB( "db/shout", "database/shout.txt", "database/insult.txt", // imp/demon taunts, again NULL), - + TextDB( "db/help", "database/help.txt", NULL), @@ -110,10 +110,10 @@ TextDB::TextDB(const char* db_name, ...) while (true) { const char* input_file = va_arg(args, const char *); - + if (input_file == 0) break; - + ASSERT( strstr(input_file, ".txt") != 0 ); // probably forgot the terminating 0 _input_files.push_back(input_file); } @@ -124,10 +124,10 @@ void TextDB::init() { if (_needs_update()) _regenerate_db(); - + const std::string full_db_path = get_savedir_path(_db_name); _db = dbm_open(full_db_path.c_str(), O_RDONLY, 0660); - + if (_db == NULL) end(1, true, "Failed to open DB: %s", full_db_path.c_str()); } @@ -144,7 +144,7 @@ void TextDB::shutdown() bool TextDB::_needs_update() const { std::string full_db_path = get_savedir_path(std::string(_db_name) + ".db"); - for (unsigned int i=0; i<_input_files.size(); i++) + for (unsigned int i = 0; i < _input_files.size(); i++) { std::string full_input_path = datafile_path(_input_files[i], true); if (is_newer(full_input_path, full_db_path)) @@ -167,7 +167,7 @@ void TextDB::_regenerate_db() file_lock lock(db_path + ".lk", "wb"); unlink( full_db_path.c_str() ); - for (unsigned int i=0; i<_input_files.size(); i++) + for (unsigned int i = 0; i < _input_files.size(); i++) { std::string full_input_path = datafile_path(_input_files[i], true); _store_text_db(full_input_path, db_path); @@ -182,13 +182,13 @@ void TextDB::_regenerate_db() void databaseSystemInit() { - for (unsigned int i=0; i < ARRAYSIZE(AllDBs); i++) + for (unsigned int i = 0; i < ARRAYSIZE(AllDBs); i++) AllDBs[i].init(); } void databaseSystemShutdown() { - for (unsigned int i=0; i < ARRAYSIZE(AllDBs); i++) + for (unsigned int i = 0; i < ARRAYSIZE(AllDBs); i++) AllDBs[i].shutdown(); } @@ -202,12 +202,12 @@ datum database_fetch(DBM *database, const std::string &key) result.dptr = NULL; result.dsize = 0; datum dbKey; - + dbKey.dptr = (DPTR_COERCE) key.c_str(); - dbKey.dsize = key.length(); - + dbKey.dsize = key.length(); + result = dbm_fetch(database, dbKey); - + return result; } @@ -400,7 +400,7 @@ static std::string _chooseStrByWeight(std::string entry, int fixed_weight = -1) // blank lines. while (i < size && lines[i] == "") i++; - + if (i == size) break; @@ -437,7 +437,7 @@ static std::string _chooseStrByWeight(std::string entry, int fixed_weight = -1) choice = fixed_weight % total_weight; else choice = random2(total_weight); - + for (int i = 0, size = parts.size(); i < size; i++) if (choice < weights[i]) return(parts[i]); @@ -483,7 +483,7 @@ static void _call_recursive_replacement(std::string &str, DBM *database, const std::string &suffix, int &num_replacements, int recursion_depth = 0); - + std::string getWeightedSpeechString(const std::string &key, const std::string &suffix, const int weight) @@ -494,7 +494,7 @@ std::string getWeightedSpeechString(const std::string &key, std::string result = _getWeightedString(SpeakDB, key, suffix, weight); if (result.empty()) return ""; - + int num_replacements = 0; _call_recursive_replacement(result, SpeakDB, suffix, num_replacements); return (result); @@ -514,10 +514,10 @@ static std::string _getRandomizedStr(DBM *database, const std::string &key, } std::string str = _getWeightedString(database, key, suffix); - + _call_recursive_replacement(str, database, suffix, num_replacements, recursion_depth); - + return str; } @@ -576,15 +576,15 @@ static std::string _query_database(DBM *db, std::string key, // in and got the case wrong.) lowercase(key); } - + // Query the DB. datum result = database_fetch(db, key); - + std::string str((const char *)result.dptr, result.dsize); if (run_lua) _execute_embedded_lua(str); - + return (str); } @@ -656,7 +656,7 @@ std::string getRandNameString(const std::string &itemtype, { if (!RandartDB) return (""); - + int num_replacements = 0; return _getRandomizedStr(RandartDB, itemtype, suffix, diff --git a/crawl-ref/source/debug.cc b/crawl-ref/source/debug.cc index 944bc743b8..75c5944b4f 100644 --- a/crawl-ref/source/debug.cc +++ b/crawl-ref/source/debug.cc @@ -1932,7 +1932,7 @@ static void debug_rap_stats(FILE *ostat) for (int j = 0; j < RAP_NUM_PROPERTIES; j++) { const int val = proprt[j]; - if(val) + if (val) { num_props++; all_props[j]++; diff --git a/crawl-ref/source/effects.cc b/crawl-ref/source/effects.cc index 15d362ba3d..dfb511fa63 100644 --- a/crawl-ref/source/effects.cc +++ b/crawl-ref/source/effects.cc @@ -2852,7 +2852,7 @@ static void _maybe_restart_fountain_flow(const int x, const int y, // chance of cleaning adjacent squares for (int i = -1; i <= 1; i++) - for (int j =-1; j <= 1; j++) + for (int j = -1; j <= 1; j++) { if (is_bloodcovered(x+i,y+j) && one_chance_in(5)) diff --git a/crawl-ref/source/files.cc b/crawl-ref/source/files.cc index 020fd0a31c..7b7211adce 100644 --- a/crawl-ref/source/files.cc +++ b/crawl-ref/source/files.cc @@ -1306,8 +1306,10 @@ void save_game(bool leave_game, const char *farewellmsg) snprintf( cmd_buff, sizeof(cmd_buff), SAVE_PACKAGE_CMD, basename.c_str(), basename.c_str() ); - if (system( cmd_buff ) != 0) { - cprintf( EOL "Warning: Zip command (SAVE_PACKAGE_CMD) returned non-zero value!" EOL ); + if (system( cmd_buff ) != 0) + { + cprintf( EOL "Warning: Zip command (SAVE_PACKAGE_CMD) returned" + "non-zero value!" EOL ); } DO_CHMOD_PRIVATE ( (basename + PACKAGE_SUFFIX).c_str() ); #endif @@ -1627,11 +1629,9 @@ static void restore_tagged_file( FILE *restoreFile, int fileType, } // go through and init missing tags - for (int i=0; i tags. -// +// formatted_string formatted_string::parse_block( const std::string &s, bool eot_ends_format, @@ -75,7 +75,7 @@ formatted_string formatted_string::parse_block( if (eot_ends_format) { - if (colour_stack.back() != colour_stack.front()) + if (colour_stack.back() != colour_stack.front()) fs.textcolor(colour_stack.front()); } @@ -96,7 +96,7 @@ formatted_string formatted_string::parse_string( parse_string1(s, fs, colour_stack, process); if (eot_ends_format) { - if (colour_stack.back() != colour_stack.front()) + if (colour_stack.back() != colour_stack.front()) fs.textcolor(colour_stack.front()); } return fs; @@ -119,7 +119,7 @@ void formatted_string::parse_string_to_multiple( formatted_string& fs = out.back(); fs.textcolor(colour_stack.back()); parse_string1(lines[i], fs, colour_stack, NULL); - if (colour_stack.back() != colour_stack.front()) + if (colour_stack.back() != colour_stack.front()) fs.textcolor(colour_stack.front()); } } @@ -138,7 +138,7 @@ void formatted_string::parse_string1( std::string currs; bool masked = false; - + for (tag = 0; tag < length; ++tag) { bool revert_colour = false; @@ -203,7 +203,7 @@ void formatted_string::parse_string1( else if (process && !process(tagtext.substr(1))) masked = true; - tag += tagtext.length() + 1; + tag += tagtext.length() + 1; continue; } @@ -229,7 +229,7 @@ void formatted_string::parse_string1( // fs.cprintf("%d%d", colour_stack.size(), colour_stack.back()); fs.textcolor(colour_stack.back()); - + tag += tagtext.length() + 1; } if (currs.length()) @@ -324,11 +324,11 @@ inline void cap(int &i, int max) std::string formatted_string::tostring(int s, int e) const { std::string st; - + int size = ops.size(); - cap(s, size); + cap(s, size); cap(e, size); - + for (int i = s; i <= e && i < size; ++i) { if (ops[i] == FSOP_TEXT) @@ -348,13 +348,13 @@ std::string formatted_string::to_colour_string() const // gotta double up those '<' chars ... size_t start = st.size(); st += ops[i].text; - + while (true) { const size_t left_angle = st.find('<', start); if (left_angle == std::string::npos) break; - + st.insert(left_angle, "<"); start = left_angle + 2; } @@ -366,7 +366,7 @@ std::string formatted_string::to_colour_string() const st += ">"; } } - + return st; } @@ -378,7 +378,7 @@ void formatted_string::display(int s, int e) const cap(s, size); cap(e, size); - + for (int i = s; i <= e && i < size; ++i) ops[i].display(); } @@ -414,7 +414,7 @@ formatted_string formatted_string::substr(size_t start, size_t substr_length) co // Find the first string to copy unsigned int i; - for (i=0; i start) break; else start -= op.text.length(); + } } if (i == ops.size()) @@ -488,7 +490,7 @@ void formatted_string::textcolor(int color) { if (!ops.empty() && ops[ ops.size() - 1 ].type == FSOP_COLOUR) ops.erase( ops.end() - 1 ); - + ops.push_back(color); } diff --git a/crawl-ref/source/guic-win.cc b/crawl-ref/source/guic-win.cc index 834e4eda44..7d1894dffc 100644 --- a/crawl-ref/source/guic-win.cc +++ b/crawl-ref/source/guic-win.cc @@ -40,10 +40,10 @@ bool GuicInit(HINSTANCE h, int nCmd) hInst = h; nCmdShow = nCmd; - for (i=0; i< MAX_TERM_COL; i++) + for (i = 0; i < MAX_TERM_COL; i++) { int *c = (int *)&term_colors[i]; - term_pix[i] =PALETTERGB( c[0], c[1], c[2] ); + term_pix[i] = PALETTERGB( c[0], c[1], c[2] ); } return true; } @@ -409,8 +409,8 @@ void TextRegionClass::draw_cursor(int x, int y) ReleaseDC(win->hWnd, hdc); } -void TextRegionClass::erase_cursor(){ - +void TextRegionClass::erase_cursor() +{ int x0 = cursor_x; int y0 = cursor_y; int adrs = y0 * mx + x0; @@ -481,8 +481,8 @@ void TextRegionClass::clear() for (i = 0; i < mx*my; i++) { - cbuf[i] =' '; - abuf[i] =0; + cbuf[i] = ' '; + abuf[i] = 0; } RegionClass::clear(); } @@ -498,8 +498,10 @@ BOOL WinClass::create(const char *name) //game_state = STAT_NORMAL; - if ( GetSystemMetrics(SM_CYSCREEN) < (oy + wy) ) oy =0; - if ( GetSystemMetrics(SM_CXSCREEN) < (ox + wx) ) ox =0; + if ( GetSystemMetrics(SM_CYSCREEN) < (oy + wy) ) + oy = 0; + if ( GetSystemMetrics(SM_CXSCREEN) < (ox + wx) ) + ox = 0; AdjustWindowRectEx(&rc, (WS_OVERLAPPED | WS_SYSMENU | WS_MINIMIZEBOX @@ -824,7 +826,7 @@ void ImgCopyH(img_type src, int sx, int sy, int wx, int wy, int x, y; BYTE pix; - if(copy) + if (copy) { for (x = 0; x < wx; x++) for (y = 0; y < wy; y++) @@ -861,7 +863,7 @@ void ImgCopyMasked(img_type src, int sx, int sy, int wx, int wy, for (x = 0; x < wx; x++) { pix = *( dib_ref_pixel(src, sx+x, sy+y) ); - if (mask[count]==0 && pix != pix_transparent) + if (mask[count] == 0 && pix != pix_transparent) *( dib_ref_pixel(dest, dx+x, dy+y) ) = pix; count++; } @@ -880,7 +882,7 @@ void ImgCopyMaskedH(img_type src, int sx, int sy, int wx, int wy, pix = *( dib_ref_pixel(src, sx+x, sy+y) ); if (pix == pix_rimcolor) pix = pix_magenta; - if (mask[count]==0 && pix != pix_transparent) + if (mask[count] == 0 && pix != pix_transparent) *( dib_ref_pixel(dest, dx+x, dy+y) ) = pix; count++; } diff --git a/crawl-ref/source/guic-x11.cc b/crawl-ref/source/guic-x11.cc index c2b989a0e1..a1eedf0629 100644 --- a/crawl-ref/source/guic-x11.cc +++ b/crawl-ref/source/guic-x11.cc @@ -75,7 +75,8 @@ void MapRegionClass::SysInit(int x, int y, int o_x, int o_y) void MapRegionClass::SysDeinit() {} -void RegionClass::init_font(const char *name){ +void RegionClass::init_font(const char *name) +{ /*** Large part of this routine was copied from Hengband ***/ int ascent, descent, width; @@ -90,7 +91,7 @@ void RegionClass::init_font(const char *name){ descent = font->descent; int i; - for (i=0;ifid); fx = dx = width; @@ -172,7 +173,8 @@ void TextRegionClass::draw_string(int x, int y, unsigned char *buf, void TextRegionClass::draw_cursor(int x, int y) { - if(!flag)return; + if (!flag) + return; XDrawString(display, win->win, term_gc[0x0f], x*dx+ox, y*dy+asc+oy, "_", 1); @@ -189,7 +191,8 @@ void TextRegionClass::erase_cursor() int adrs = y0 * mx + x0; int col = abuf[adrs]; int x1 = x0;; - if(!flag)return; + if (!flag) + return; XFillRectangle(display, w->win, term_gc[col>>4], x1*dx + ox, y0*dy +oy, dx*width, dy); @@ -221,10 +224,8 @@ void MapRegionClass::clear() { int i; - for (i=0; i=0); - ASSERT(y>=0); - ASSERT(x<(img->width)); - ASSERT(y<(img->height)); + ASSERT(x >= 0); + ASSERT(y >= 0); + ASSERT(x < img->width); + ASSERT(y < img->height); - return (pix_transparent == XGetPixel(img, x, y)) ? true:false; + return (pix_transparent == XGetPixel(img, x, y)) ? true : false; } void ImgSetTransparentPix(img_type img) @@ -396,12 +397,14 @@ void ImgDestroy(img_type img) img_type ImgCreateSimple(int wx, int wy) { - if (wx ==0 || wy == 0) return NULL; + if (wx == 0 || wy == 0) + return NULL; + char *buf = (char *)malloc(x11_byte_per_pixel_ximage()* wx * wy); - img_type res= XCreateImage(display, DefaultVisual(display, screen), - DefaultDepth(display, screen), - ZPixmap, 0, buf, wx, wy, 8, 0); + img_type res = XCreateImage(display, DefaultVisual(display, screen), + DefaultDepth(display, screen), + ZPixmap, 0, buf, wx, wy, 8, 0); return(res); } @@ -633,7 +636,7 @@ void ImgCopyMasked(img_type src, int sx, int sy, int wx, int wy, for (x = 0; x < wx; x++) { //X11 specific - if(p_src[x] != pix_transparent && mask[count] == 0) + if (p_src[x] != pix_transparent && mask[count] == 0) p_dest[x] = p_src[x]; count++; } @@ -690,7 +693,7 @@ void ImgCopyMaskedH(img_type src, int sx, int sy, int wx, int wy, //X11 specific if (p_src[x] == pix_rimcolor) p_dest[x] = pix_hilite; - else if(p_src[x] != pix_transparent && mask[count] == 0) + else if (p_src[x] != pix_transparent && mask[count] == 0) p_dest[x] = p_src[x]; count++; diff --git a/crawl-ref/source/guic.cc b/crawl-ref/source/guic.cc index 81fbad9c6b..3b3671f6b6 100644 --- a/crawl-ref/source/guic.cc +++ b/crawl-ref/source/guic.cc @@ -28,7 +28,7 @@ int TextRegionClass::cursor_x; int TextRegionClass::cursor_y; // more logical color naming -const int map_colors[MAX_MAP_COL][3]= +const int map_colors[MAX_MAP_COL][3] = { { 0, 0, 0}, // BLACK {128, 128, 128}, // DKGREY @@ -63,7 +63,7 @@ const int map_colors[MAX_MAP_COL][3]= {165, 91, 0}, // BROWN }; -const int term_colors[MAX_TERM_COL][3]= +const int term_colors[MAX_TERM_COL][3] = { { 0, 0, 0}, // BLACK { 0, 82, 255}, // BLUE @@ -134,10 +134,10 @@ void WinClass::placeRegion(RegionClass *r, int layer0, int margin_top, int margin_left, int margin_bottom, int margin_right) { - int sx0 =0; - int sy0 =0; - int ex0 =0; - int ey0 =0; + int sx0 = 0; + int sy0 = 0; + int ex0 = 0; + int ey0 = 0; int x = 0; int y = 0; @@ -191,11 +191,11 @@ void WinClass::redraw(int x1, int y1, int x2, int y2) int cx1, cx2, cy1, cy2; for (r = regions.begin();r != regions.end();r++) { - if (!(*r)->is_active()) continue; - if( (*r)->convert_redraw_rect(x1, y1, x2, y2, &cx1, &cy1, &cx2, &cy2)) - { + if (!(*r)->is_active()) + continue; + + if ( (*r)->convert_redraw_rect(x1, y1, x2, y2, &cx1, &cy1, &cx2, &cy2) ) (*r)->redraw(cx1, cy1, cx2, cy2); - } } } @@ -244,10 +244,10 @@ void TextRegionClass::resize(int x, int y) free(abuf); cbuf = (unsigned char *)malloc(x*y); abuf = (unsigned char *)malloc(x*y); - for (i=0; i=mx-1)cx2=mx-1; - if(cy2>=my-1)cy2=my-1; - if(cx1<0) cx1=0; - if(cy1<0) cy1=0; + if (cx2 >= mx - 1) + cx2 = mx - 1; + if (cy2 >= my - 1) + cy2 = my - 1; + if (cx1 < 0) + cx1 = 0; + if (cy1 < 0) + cy1 = 0; *rx1 = cx1; *ry1 = cy1; @@ -418,7 +422,8 @@ bool RegionClass::convert_redraw_rect(int x1, int y1, int x2, int y2, } bool TileRegionClass::convert_redraw_rect(int x1, int y1, int x2, int y2, - int *rx1, int *ry1, int *rx2, int *ry2) + int *rx1, int *ry1, + int *rx2, int *ry2) { int cx1 = x1-ox; int cy1 = y1-oy; @@ -428,13 +433,17 @@ bool TileRegionClass::convert_redraw_rect(int x1, int y1, int x2, int y2, int wwx = dx*mx; int wwy = dy*my; - if ( (cx2 < 0) || (cy2 < 0) || (cx1 >= wwx) || (cy1 >=wwy)) + if (cx2 < 0 || cy2 < 0 || cx1 >= wwx || cy1 >=wwy) return false; - if(cx2>=wwx-1)cx2=wwx-1; - if(cy2>=wwy-1)cy2=wwy-1; - if(cx1<0) cx1=0; - if(cy1<0) cy1=0; + if (cx2 >= wwx - 1) + cx2 = wwx - 1; + if (cy2 >= wwy - 1) + cy2 = wwy - 1; + if (cx1 < 0) + cx1 = 0; + if (cy1 < 0) + cy1 = 0; *rx1 = cx1; *ry1 = cy1; @@ -497,7 +506,7 @@ void TextRegionClass::scroll() { int idx; - if(!flag) + if (!flag) return; for (idx = 0; idx < mx*(my-1); idx++) @@ -530,19 +539,20 @@ void TextRegionClass::addstr(char *buffer) char buf2[1024]; int len = strlen(buffer); - if(!flag)return; + if (!flag) + return; j = 0; for (i = 0; i < len + 1; i++) { char c = buffer[i]; - bool newline=false; - if (c== '\n' || c== '\r') + bool newline = false; + if (c == '\n' || c == '\r') { - c=0; + c = 0; newline = true; - if (buffer[i+1]=='\n' || buffer[i+1]=='\r') + if (buffer[i+1] == '\n' || buffer[i+1] == '\r') i++; } buf2[j] = c; diff --git a/crawl-ref/source/invent.cc b/crawl-ref/source/invent.cc index be27796667..31c979aa22 100644 --- a/crawl-ref/source/invent.cc +++ b/crawl-ref/source/invent.cc @@ -661,16 +661,17 @@ unsigned char get_invent( int invent_type ) { unsigned char select; - while (true) { - select = invent_select(NULL, MT_INVLIST, invent_type, + while (true) + { + select = invent_select(NULL, MT_INVLIST, invent_type, MF_SINGLESELECT); - if ( isalpha(select) ) - { - const int invidx = letter_to_index(select); - if ( is_valid_item(you.inv[invidx]) ) + if ( isalpha(select) ) + { + const int invidx = letter_to_index(select); + if ( is_valid_item(you.inv[invidx]) ) describe_item( you.inv[invidx], true ); - } - else break; + } + else break; } redraw_screen(); return select; @@ -1023,18 +1024,23 @@ std::vector prompt_invent_items( return items; } -static int _digit_to_index( char digit, operation_types oper ) { +static int _digit_to_index( char digit, operation_types oper ) +{ const char iletter = static_cast(oper); - for ( int i = 0; i < ENDOFPACK; ++i ) { - if (is_valid_item(you.inv[i])) { + for ( int i = 0; i < ENDOFPACK; ++i ) + { + if (is_valid_item(you.inv[i])) + { const std::string& r(you.inv[i].inscription); /* note that r.size() is unsigned */ - for ( unsigned int j = 0; j + 2 < r.size(); ++j ) { - if ( r[j] == '@' && - (r[j+1] == iletter || r[j+1] == '*') && - r[j+2] == digit ) { + for ( unsigned int j = 0; j + 2 < r.size(); ++j ) + { + if ( r[j] == '@' + && (r[j+1] == iletter || r[j+1] == '*') + && r[j+2] == digit ) + { return i; } } @@ -1296,7 +1302,8 @@ int prompt_invent_item( const char *prompt, { /* scan for our item */ int res = _digit_to_index( keyin, oper ); - if ( res != -1 ) { + if ( res != -1 ) + { ret = res; if ( check_warning_inscriptions( you.inv[ret], oper ) ) break; @@ -1316,11 +1323,8 @@ int prompt_invent_item( const char *prompt, if (must_exist && !is_valid_item( you.inv[ret] )) mpr( "You do not have any such object." ); - else { - if ( check_warning_inscriptions( you.inv[ret], oper ) ) { - break; - } - } + else if ( check_warning_inscriptions( you.inv[ret], oper ) ) + break; } else if (!isspace( keyin )) { diff --git a/crawl-ref/source/item_use.cc b/crawl-ref/source/item_use.cc index 549fce4a71..7cdc352c9c 100644 --- a/crawl-ref/source/item_use.cc +++ b/crawl-ref/source/item_use.cc @@ -1251,7 +1251,7 @@ int get_next_fire_item(int current, int direction) if (current == -1) return fire_order[0]; - for (unsigned i=0; iname_aux(descrip, terse, ident, ignore_flags); const bool startvowel = is_vowel(auxname[0]); - if (descrip == DESC_INVENTORY_EQUIP || descrip == DESC_INVENTORY) + if (descrip == DESC_INVENTORY_EQUIP || descrip == DESC_INVENTORY) { if (in_inventory(*this)) // actually in inventory { @@ -102,7 +102,7 @@ std::string item_def::name(description_level_type descrip, else buff << " - "; } - else + else descrip = DESC_CAP_A; } @@ -232,7 +232,7 @@ std::string item_def::name(description_level_type descrip, equipped = true; } } - + if (descrip != DESC_PLAIN && descrip != DESC_BASENAME) { const bool tried = !ident && !equipped @@ -289,7 +289,7 @@ static const char* fixed_artefact_name( const item_def& item, bool ident ) case SPWPN_STAFF_OF_WUCAD_MU: return "Staff of Wucad Mu"; default: return "Brodale's Buggy Bola"; } - } + } else { switch (item.special) @@ -365,11 +365,11 @@ const char* weapon_brand_name(const item_def& item, bool terse) static const char* armour_ego_name( special_armour_type sparm, bool terse ) -{ +{ if (!terse) { switch ( sparm ) - { + { case SPARM_RUNNING: return "running"; case SPARM_FIRE_RESISTANCE: return "fire resistance"; case SPARM_COLD_RESISTANCE: return "cold resistance"; @@ -450,7 +450,7 @@ static const char* wand_secondary_string(int s) { switch (s) { - case 0: return ""; + case 0: return ""; case 1: return "jewelled "; case 2: return "curved "; case 3: return "long "; @@ -488,7 +488,7 @@ static const char* wand_primary_string(int p) case 11: return "plastic"; default: return "buggy"; } -} +} static const char* potion_type_name(int potiontype) { @@ -993,12 +993,12 @@ std::string item_def::name_aux( description_level_type desc, const bool dbname = (desc == DESC_DBNAME); const bool basename = (desc == DESC_BASENAME || (dbname && !know_type)); const bool qualname = (desc == DESC_QUALNAME); - + const bool know_curse = !basename && !qualname && !dbname && !testbits(ignore_flags, ISFLAG_KNOW_CURSE) && (ident || item_ident(*this, ISFLAG_KNOW_CURSE)); - + const bool __know_pluses = !basename && !qualname && !dbname && (ident || item_ident(*this, ISFLAG_KNOW_PLUSES)); @@ -1082,7 +1082,7 @@ std::string item_def::name_aux( description_level_type desc, buff << "glowing "; break; } - } + } if (!basename && !dbname) // always give racial type (it does have game effects) @@ -1094,7 +1094,7 @@ std::string item_def::name_aux( description_level_type desc, buff << "vampiric "; } buff << item_base_name(*this); - + if (know_brand) buff << weapon_brand_name(*this, terse); @@ -1109,7 +1109,7 @@ std::string item_def::name_aux( description_level_type desc, { if (brand == SPMSL_POISONED) buff << ((terse) ? "poison " : "poisoned "); - + if (brand == SPMSL_CURARE) buff << ((terse) ? "curare " : "curare-tipped "); } @@ -1220,7 +1220,7 @@ std::string item_def::name_aux( description_level_type desc, if (!basename && !dbname && is_hard_helmet(*this)) { const short dhelm = get_helmet_desc( *this ); - + buff << ((dhelm == THELM_DESC_PLAIN) ? "" : (dhelm == THELM_DESC_WINGED) ? "winged " : @@ -1308,7 +1308,7 @@ std::string item_def::name_aux( description_level_type desc, }; COMPILE_CHECK( ARRAYSIZE(potion_colours) == PDC_NCOLOURS, c1 ); - const char *qualifier = + const char *qualifier = (pqual < 0 || pqual >= PDQ_NQUALS)? "bug-filled " : potion_qualifiers[pqual]; @@ -1373,8 +1373,8 @@ std::string item_def::name_aux( description_level_type desc, } else { - const unsigned long sseed = - this->special + const unsigned long sseed = + this->special + (static_cast(it_plus) << 8) + (static_cast(OBJ_SCROLLS) << 16); buff << "labeled " << make_name(sseed, true); @@ -1486,7 +1486,7 @@ std::string item_def::name_aux( description_level_type desc, // left. if (this->plus2 != 0) { - if(top_card_is_known(*this)) + if (top_card_is_known(*this)) buff << ", "; if (this->plus2 > 0) @@ -1536,9 +1536,9 @@ std::string item_def::name_aux( description_level_type desc, if (!basename) buff << staff_secondary_string(this->special / 4) << staff_primary_string(this->special % 4); - + buff << (item_is_rod( *this ) ? "rod" : "staff"); - } + } else { buff << (item_is_rod( *this ) ? "rod" : "staff") @@ -1727,7 +1727,7 @@ void set_ident_type( object_class_type basetype, int subtype, { preserve_quiver_slots p; // Don't allow overwriting of known type with tried unless forced. - if (!force + if (!force && (setting == ID_MON_TRIED_TYPE || setting == ID_TRIED_TYPE) && setting <= get_ident_type( basetype, subtype )) { @@ -1883,8 +1883,8 @@ std::string make_name( unsigned long seed, bool all_cap ) name[i] = ' '; } else if (i > 0 - && (want_vowel - || (i > 1 + && (want_vowel + || (i > 1 && is_random_name_vowel( name[i - 1] ) && !is_random_name_vowel( name[i - 2] ) && (numb[(k + 4 * j) % 17] % 5) <= 1 ))) @@ -1900,10 +1900,10 @@ std::string make_name( unsigned long seed, bool all_cap ) name[i] = retlet( numb[(k + 14 * j) % 17] ); } else if (len < 7 - || i <= 2 || i >= len - 3 + || i <= 2 || i >= len - 3 || is_random_name_space( name[i - 1] ) || (i > 1 && is_random_name_space( name[i - 2] )) - || (i > 2 + || (i > 2 && !is_random_name_vowel( name[i - 1] ) && !is_random_name_vowel( name[i - 2] ))) { @@ -1911,8 +1911,8 @@ std::string make_name( unsigned long seed, bool all_cap ) continue; } } - else if (i > 1 - && name[i] == name[i - 1] + else if (i > 1 + && name[i] == name[i - 1] && (name[i] == 'y' || name[i] == 'i' || (numb[(k + 12 * j) % 17] % 5) <= 1)) { @@ -1953,7 +1953,7 @@ std::string make_name( unsigned long seed, bool all_cap ) case 11: strcat(name, "str"); i++; len++; break; case 12: strcat(name, "shr"); i++; len++; break; case 13: strcat(name, "thr"); i++; len++; break; - // start, middle, end + // start, middle, end case 14: strcat(name, "sm"); break; case 15: strcat(name, "sh"); break; case 16: strcat(name, "ch"); break; @@ -2051,15 +2051,15 @@ std::string make_name( unsigned long seed, bool all_cap ) } // catch break and try to give a final letter - if (i > 0 + if (i > 0 && !is_random_name_space( name[i - 1] ) - && name[i - 1] != 'y' + && name[i - 1] != 'y' && is_random_name_vowel( name[i - 1] ) && (count > 9 || (i < 8 && numb[16] % 3))) { name[i] = retlet( numb[j] ); } - + len = strlen( name ); if (len) @@ -2068,7 +2068,7 @@ std::string make_name( unsigned long seed, bool all_cap ) { if (!isspace( name[i] )) break; - else + else { name[i] = '\0'; len--; @@ -2086,7 +2086,7 @@ std::string make_name( unsigned long seed, bool all_cap ) if (all_cap || i == 0 || name[i - 1] == ' ') name[i] = toupper( name[i] ); - return name; + return name; } // end make_name() bool is_random_name_space(char let) diff --git a/crawl-ref/source/items.cc b/crawl-ref/source/items.cc index 6263621330..04e20be1eb 100644 --- a/crawl-ref/source/items.cc +++ b/crawl-ref/source/items.cc @@ -1428,10 +1428,9 @@ int find_free_slot(const item_def &i) // we re-try searching the oposite direction. // Return first free slot - for (slot = 0; slot < ENDOFPACK; ++slot) { + for (slot = 0; slot < ENDOFPACK; ++slot) if (!is_valid_item(you.inv[slot])) return slot; - } return (-1); #undef slotisfree @@ -1908,7 +1907,7 @@ bool drop_item( int item_dropped, int quant_drop, bool try_offer ) if ( grid_destroys_items(my_grid) ) { - if( !silenced(you.pos()) ) + if ( !silenced(you.pos()) ) mprf(MSGCH_SOUND, grid_item_destruction_message(my_grid)); item_was_destroyed(you.inv[item_dropped], NON_MONSTER); @@ -2331,7 +2330,7 @@ void autopickup() int inv_count(void) { - int count=0; + int count = 0; for (int i = 0; i < ENDOFPACK; i++) if (is_valid_item( you.inv[i] )) diff --git a/crawl-ref/source/libw32c.cc b/crawl-ref/source/libw32c.cc index cebee880f6..3e9f4b9675 100644 --- a/crawl-ref/source/libw32c.cc +++ b/crawl-ref/source/libw32c.cc @@ -85,9 +85,9 @@ static HANDLE outbuf = NULL; static int current_color = -1; static bool cursor_is_enabled = false; // dirty line (sx,ex,y) -static int chsx=0, chex=0, chy=-1; +static int chsx = 0, chex = 0, chy = -1; // cursor position (start at 0,0 --> 1,1) -static int cx=0, cy=0; +static int cx = 0, cy = 0; // and now, for the screen buffer static CHAR_INFO *screen = NULL; @@ -684,7 +684,7 @@ int wherey(void) void putch(char c) { // special case: check for '0' char: map to space - if (c==0) + if (c == 0) c = ' '; writeChar(c); diff --git a/crawl-ref/source/libwt.cc b/crawl-ref/source/libwt.cc index 750dbf7b0c..f36e12ebe5 100644 --- a/crawl-ref/source/libwt.cc +++ b/crawl-ref/source/libwt.cc @@ -81,7 +81,7 @@ void libgui_shutdown_sys(); void update_tip_text(const char *tip); void GetNextEvent(int *etype, int *key, bool *shift, bool *ctrl, - int *x1, int *y1, int *x2, int *y2); + int *x1, int *y1, int *x2, int *y2); void TileInitWin(); void delay(unsigned long ms); int kbhit(); @@ -104,14 +104,14 @@ void TileInitWin() for (i = 0; i < 256; i++) { chcol = (TileImg->pDib->bmiColors[i].rgbRed * 30 - + TileImg->pDib->bmiColors[i].rgbGreen * 59 - + TileImg->pDib->bmiColors[i].rgbBlue * 11)/100; - LPBYTE ptr = lpPalettes[1] + i * sizeof(RGBQUAD); + + TileImg->pDib->bmiColors[i].rgbGreen * 59 + + TileImg->pDib->bmiColors[i].rgbBlue * 11) / 100; + LPBYTE ptr = lpPalettes[1] + i * sizeof(RGBQUAD); ptr[2] = (BYTE)chcol; ptr[0] = (BYTE)( (chcol +1)/6 ); ptr[1] = (BYTE)( (chcol +1)/6 ); - ptr = lpPalettes[2] + i * sizeof(RGBQUAD); + ptr = lpPalettes[2] + i * sizeof(RGBQUAD); ptr[2] = ptr[0] = ptr[1] = (BYTE)chcol; } } @@ -120,7 +120,9 @@ void update_tip_text(const char *tip) { #define MAXTIP 512 static char oldtip[MAXTIP+1]; - if (strncmp(oldtip, tip, MAXTIP)==0) return; + if (strncmp(oldtip, tip, MAXTIP) == 0) + return; + strncpy(oldtip, tip, MAXTIP); tiTip.lpszText = (char *)tip; SendMessage(hTool, TTM_UPDATETIPTEXT, 0, (LPARAM)&tiTip); @@ -147,11 +149,12 @@ void GetNextEvent(int *etype, int *key, bool *sh, bool *ct, { TranslateMessage( &msg ); DispatchMessage( &msg ); - if(ev_tail != ev_head) break; + if (ev_tail != ev_head) + break; } struct ev_data *e = &ev_cue[ev_head]; ev_head++; - if(ev_head == EV_MAX) + if (ev_head == EV_MAX) ev_head = 0; *etype = e->type; @@ -166,12 +169,12 @@ void ev_push(struct ev_data *e) { ev_cue[ev_tail] = *e; ev_tail++; - if(ev_tail == EV_MAX) + if (ev_tail == EV_MAX) ev_tail = 0; } int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, - LPSTR lpCmdLine, int nCmdShow ) + LPSTR lpCmdLine, int nCmdShow ) { MSG msg; @@ -187,9 +190,9 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, // I'll be damned if I have to parse lpCmdLine myself... int argc; LPWSTR *wargv = CommandLineToArgvW(GetCommandLineW(), &argc); - char **argv = new char*[argc]; - int args_len = wcslen(GetCommandLineW()) + argc; - char *args = new char[args_len]; + char **argv = new char*[argc]; + int args_len = wcslen(GetCommandLineW()) + argc; + char *args = new char[args_len]; char *ptr = args; for (int i = 0; i < argc; i++) @@ -243,7 +246,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) static int cliy = 0; // For keypad - const unsigned char ck_table[9]= + const unsigned char ck_table[9] = { CK_END, CK_DOWN, CK_PGDN, CK_LEFT, CK_INSERT, CK_RIGHT, @@ -288,8 +291,8 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) ev.x1 = LOWORD(lParam); ev.y1 = HIWORD(lParam); ev.key = 1; - ev.sh = ((GetKeyState(VK_SHIFT) & 0x80)!=0)? true:false; - ev.ct = ((GetKeyState(VK_CONTROL) & 0x80)!=0)? true:false; + ev.sh = ((GetKeyState(VK_SHIFT) & 0x80) != 0)? true : false; + ev.ct = ((GetKeyState(VK_CONTROL) & 0x80) != 0)? true : false; if (message == WM_RBUTTONDOWN) ev.key = 2; if (message == WM_MBUTTONDOWN) ev.key = 3; ev_push(&ev); @@ -310,42 +313,41 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) case WM_MOUSEWHEEL: { - int z = (short)HIWORD(wParam); - ev.x1 = LOWORD(lParam) - clix; - ev.y1 = HIWORD(lParam) - cliy; - ev.type = EV_BUTTON; - ev.sh = ((GetKeyState(VK_SHIFT) & 0x80)!=0)? true:false; - ev.ct = ((GetKeyState(VK_CONTROL) & 0x80)!=0)? true:false; - ev.key = (z>0)? 4:5; - ev_push(&ev); + int z = (short)HIWORD(wParam); + ev.x1 = LOWORD(lParam) - clix; + ev.y1 = HIWORD(lParam) - cliy; + ev.type = EV_BUTTON; + ev.sh = ((GetKeyState(VK_SHIFT) & 0x80) != 0) ? true : false; + ev.ct = ((GetKeyState(VK_CONTROL) & 0x80) != 0) ? true : false; + ev.key = (z > 0) ? 4 : 5; + ev_push(&ev); return 0; } case WM_MOUSEMOVE: { - ev.type = EV_MOVE; + ev.type = EV_MOVE; ev.x1 = LOWORD(lParam); ev.y1 = HIWORD(lParam); - ev_push(&ev); + ev_push(&ev); return 0; } case WM_KEYDOWN: { - int ch=(int)wParam; + int ch = (int) wParam; int result = 0; - int dir = 0; - bool fs = ((GetKeyState(VK_SHIFT) & 0x80)!=0)? true:false; - bool fc = ((GetKeyState(VK_CONTROL)& 0x80)!=0)? true:false; - bool fa = ((GetKeyState(VK_MENU) & 0x80)!=0)? true:false; + int dir = 0; + bool fs = ((GetKeyState(VK_SHIFT) & 0x80) != 0)? true : false; + bool fc = ((GetKeyState(VK_CONTROL)& 0x80) != 0)? true : false; + bool fa = ((GetKeyState(VK_MENU) & 0x80) != 0)? true : false; - if (ch >= VK_NUMPAD1 && ch <= VK_NUMPAD9) - { - skip_key = true; - dir = ch - VK_NUMPAD0; - } - else - if ((VK_PRIOR <= ch && ch <=VK_DOWN) || (ch == VK_CLEAR) ) + if (ch >= VK_NUMPAD1 && ch <= VK_NUMPAD9) + { + skip_key = true; + dir = ch - VK_NUMPAD0; + } + else if (VK_PRIOR <= ch && ch <= VK_DOWN || ch == VK_CLEAR) { switch(ch) { @@ -359,33 +361,33 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) case VK_END: dir = 1; break; case VK_CLEAR: dir = 5; break; } - } + } if (dir != 0) { - ch = ck_table[dir-1]; + ch = ck_table[dir-1]; if (fc) - ch += CK_CTRL_UP - CK_UP; + ch += CK_CTRL_UP - CK_UP; if (fs) - ch += CK_SHIFT_UP - CK_UP; + ch += CK_SHIFT_UP - CK_UP; - if (fa) ch |= 2048; + if (fa) + ch |= 2048; ev.key = ch; - ev.type = EV_KEYIN; - ev_push(&ev); + ev.type = EV_KEYIN; + ev_push(&ev); return 0; } - else if ( ch >= VK_PAUSE - && !(ch >= VK_CAPITAL && ch <= VK_SPACE) - && ch !=VK_PROCESSKEY - && ch != VK_NUMLOCK - && !(ch >=VK_LSHIFT && ch<= VK_RMENU) - && !(ch >= 0x30 && ch<= 0x39) - && !(ch >= 0x41 && ch<= 0x5a) - && !(ch >= 0xa6 && ch<= 0xe4) - ) + else if (ch >= VK_PAUSE + && (ch < VK_CAPITAL || ch > VK_SPACE) + && ch != VK_PROCESSKEY + && ch != VK_NUMLOCK + && (ch < VK_LSHIFT || ch > VK_RMENU) + && (ch < 0x30 || ch > 0x39) + && (ch < 0x41 || ch > 0x5a) + && (ch < 0xa6 || ch > 0xe4)) { - result = 300+ch; + result = 300 + ch; } if (result) @@ -403,14 +405,14 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) case WM_CHAR: { - if (skip_key) - { - skip_key = false; - return 0; - } + if (skip_key) + { + skip_key = false; + return 0; + } ev.key = (int)wParam; - ev.type = EV_KEYIN; - ev_push(&ev); + ev.type = EV_KEYIN; + ev_push(&ev); return 0; } @@ -422,12 +424,12 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) return 0; } - case WM_MOVE: - { - clix = LOWORD(lParam); - cliy = HIWORD(lParam); - return 0; - } + case WM_MOVE: + { + clix = LOWORD(lParam); + cliy = HIWORD(lParam); + return 0; + } case WM_COMMAND: { @@ -435,22 +437,23 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) wmEvent = HIWORD(wParam); switch( wmId ) { + // XXX: Isn't that always the case? default: return DefWindowProc( hWnd, message, wParam, lParam ); } return 0; } case WM_CLOSE: - if ( (mouse_get_mode() == MOUSE_MODE_COMMAND) - ||(!crawl_state.need_save) ) + if (mouse_get_mode() == MOUSE_MODE_COMMAND + || !crawl_state.need_save ) { if (crawl_state.need_save) - { save_game(true); - } - libgui_shutdown(); + + libgui_shutdown(); } break; + case WM_DESTROY: { PostQuitMessage( 0 ); @@ -464,16 +467,21 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) } #ifdef USE_TILE -void TileDrawDungeonAux(){ +void TileDrawDungeonAux() +{ dib_pack *pBuf = region_tile->backbuf; - int new_palette = PAL_STD; - if (you.duration[DUR_BERSERKER]) new_palette = PAL_BER; - if (you.special_wield == SPWLD_SHADOW) new_palette = PAL_SHA; + int new_palette = PAL_STD; // standard + if (you.duration[DUR_BERSERKER]) + new_palette = PAL_BER; + + // XXX: is this supposed to override Berserk? + if (you.special_wield == SPWLD_SHADOW) + new_palette = PAL_SHA; if (new_palette != palette) { - palette = new_palette; + palette = new_palette; SetDIBColorTable(pBuf->hDC, 0, 256, (RGBQUAD *)lpPalettes[palette]); } } @@ -486,33 +494,33 @@ bool windows_change_font(char *font_name, int *font_size, bool dos) memset(&cf, 0, sizeof(cf)); cf.lStructSize = sizeof(cf); cf.iPointSize = *font_size; - cf.nSizeMin = 8; - cf.nSizeMax = 24; + cf.nSizeMin = 8; + cf.nSizeMax = 24; cf.Flags = CF_SCREENFONTS | CF_FIXEDPITCHONLY | CF_NOVERTFONTS - | CF_INITTOLOGFONTSTRUCT | CF_LIMITSIZE | CF_FORCEFONTEXIST; + | CF_INITTOLOGFONTSTRUCT | CF_LIMITSIZE | CF_FORCEFONTEXIST; LOGFONT lf; strcpy(lf.lfFaceName, font_name); - lf.lfHeight = 16; - lf.lfWidth = 0; - lf.lfEscapement = 0; - lf.lfOrientation = lf.lfEscapement; - lf.lfWeight = FW_NORMAL; - lf.lfItalic = FALSE; - lf.lfUnderline = FALSE; - lf.lfStrikeOut = FALSE; - lf.lfOutPrecision = OUT_DEFAULT_PRECIS; - lf.lfClipPrecision = CLIP_DEFAULT_PRECIS; - lf.lfQuality = DEFAULT_QUALITY; - lf.lfPitchAndFamily= FF_MODERN|FIXED_PITCH; - lf.lfCharSet = (dos)? OEM_CHARSET:ANSI_CHARSET; + lf.lfHeight = 16; + lf.lfWidth = 0; + lf.lfEscapement = 0; + lf.lfOrientation = lf.lfEscapement; + lf.lfWeight = FW_NORMAL; + lf.lfItalic = FALSE; + lf.lfUnderline = FALSE; + lf.lfStrikeOut = FALSE; + lf.lfOutPrecision = OUT_DEFAULT_PRECIS; + lf.lfClipPrecision = CLIP_DEFAULT_PRECIS; + lf.lfQuality = DEFAULT_QUALITY; + lf.lfPitchAndFamily = FF_MODERN | FIXED_PITCH; + lf.lfCharSet = (dos)? OEM_CHARSET:ANSI_CHARSET; cf.lpLogFont = &lf; if (ChooseFont(&cf)) { *font_size = (cf.iPointSize / 10); strcpy(font_name, lf.lfFaceName); - return true; + return true; } return false; } @@ -524,7 +532,7 @@ void windows_get_winpos(int *x, int *y) // set length wndpl.length = sizeof( WINDOWPLACEMENT ); - if( GetWindowPlacement( win_main->hWnd, &wndpl ) != 0 ) + if ( GetWindowPlacement( win_main->hWnd, &wndpl ) != 0 ) { *x = wndpl.rcNormalPosition.top; *y = wndpl.rcNormalPosition.left; @@ -542,7 +550,9 @@ int kbhit() if (PeekMessage(&msg, NULL, WM_CHAR, WM_CHAR, PM_NOREMOVE) || PeekMessage(&msg, NULL, WM_KEYDOWN, WM_KEYDOWN, PM_NOREMOVE)) + { return 1; + } else return 0; } diff --git a/crawl-ref/source/libx11.cc b/crawl-ref/source/libx11.cc index 0208a814ad..43ac0ed644 100644 --- a/crawl-ref/source/libx11.cc +++ b/crawl-ref/source/libx11.cc @@ -79,7 +79,7 @@ void GetNextEvent(int *etype, int *key, bool *shift, bool *ctrl, button = 2; else if (button == 2) button = 3; - + *key = button; break; } @@ -119,7 +119,7 @@ char *my_getenv(const char *envname, const char *def) const char *result = getenv(envname); if (!result) result = def; - + return (char *)result; } @@ -128,7 +128,7 @@ int my_getenv_int(const char *envname, int def) const char *rstr = getenv(envname); if (!rstr) return def; - + return atoi(rstr); } @@ -146,7 +146,7 @@ void update_tip_text(const char *tip) const bool is_main_screen = (win_main->active_layer == 0); const unsigned int height = is_main_screen ? region_tip->my : 1; - + const unsigned int width = is_main_screen ? region_tip->mx : region_crt->mx; @@ -248,7 +248,7 @@ int x11_keypress(XKeyEvent *xev) #define IsSpecialKey(keysym) \ ((unsigned)(keysym) >= 0xFF00) - const unsigned int ck_table[9]= + const unsigned int ck_table[9] = { CK_END, CK_DOWN, CK_PGDN, CK_LEFT, CK_INSERT, CK_RIGHT, @@ -327,42 +327,42 @@ int x11_keypress(XKeyEvent *xev) case XK_KP_End: dir = 1; break; - + case XK_KP_2: case XK_KP_Down: dir = 2; break; - + case XK_KP_3: case XK_KP_Page_Down: dir = 3; break; - + case XK_KP_6: case XK_KP_Right: dir = 6; break; - + case XK_KP_9: case XK_KP_Page_Up: dir = 9; break; - + case XK_KP_8: case XK_KP_Up: dir = 8; break; - + case XK_KP_7: case XK_KP_Home: dir = 7; break; - + case XK_KP_4: case XK_KP_Left: dir = 4; break; - + case XK_KP_5: dir = 5; break; @@ -375,7 +375,7 @@ int x11_keypress(XKeyEvent *xev) if (ms) result += CK_SHIFT_UP - CK_UP; if (mc) result += CK_CTRL_UP - CK_UP; - + return result; } @@ -384,19 +384,20 @@ int x11_keypress(XKeyEvent *xev) if (ms) base |= 1024; if (mc) base |= 2048; if (ma) base |= 4096; - + return base; } - + //Hack Special key - if (ks1 >=0xff00) + if (ks1 >= +0xff00) { base = 512 + ks1 - 0xff00; - + if (ms) base |= 1024; if (mc) base |= 2048; if (ma) base |= 4096; - + return base; } diff --git a/crawl-ref/source/luadgn.cc b/crawl-ref/source/luadgn.cc index 93324eaaeb..2e7657b84a 100644 --- a/crawl-ref/source/luadgn.cc +++ b/crawl-ref/source/luadgn.cc @@ -950,7 +950,8 @@ static int dgn_floor_colour(lua_State *ls) { error = "Can't set floor to black."; } - else { + else + { error = "No such colour as '"; error += s; error += "'"; @@ -980,7 +981,8 @@ static int dgn_rock_colour(lua_State *ls) { error = "Can't set rock to black."; } - else { + else + { error = "No such colour as '"; error += s; error += "'"; @@ -1019,7 +1021,8 @@ static int dgn_change_floor_colour(lua_State *ls) { error = "Can't set floor to black."; } - else { + else + { error = "No such colour as '"; error += s; error += "'"; @@ -1050,7 +1053,8 @@ static int dgn_change_rock_colour(lua_State *ls) { error = "Can't set rock to black."; } - else { + else + { error = "No such colour as '"; error += s; error += "'"; @@ -1438,15 +1442,14 @@ static int dgn_floor_halo(lua_State *ls) } for (int y = 0; y < GYM; ++y) - { for (int x = 0; x < GXM; ++x) { const dungeon_feature_type feat = grd[x][y]; if (feat == target) { - for (int i=-1; i<=1; i++) - for (int j=-1; j<=1; j++) + for (int i = -1; i <= 1; i++) + for (int j = -1; j <= 1; j++) { if (!map_bounds(x+i, y+j)) continue; @@ -1461,7 +1464,6 @@ static int dgn_floor_halo(lua_State *ls) } } } - } return (0); } diff --git a/crawl-ref/source/macro.cc b/crawl-ref/source/macro.cc index f834623bd0..74e294c4d7 100644 --- a/crawl-ref/source/macro.cc +++ b/crawl-ref/source/macro.cc @@ -342,7 +342,8 @@ static std::string vtostr( const keyseq &seq ) for (keyseq::const_iterator i = v->begin(); i != v->end(); i++) { - if (*i <= 32 || *i > 127) { + if (*i <= 32 || *i > 127) + { if (*i == KEY_MACRO_MORE_PROTECT) s << "\\{!more}"; else @@ -351,11 +352,11 @@ static std::string vtostr( const keyseq &seq ) snprintf( buff, sizeof(buff), "\\{%d}", *i ); s << buff; } - } else if (*i == '\\') { + } + else if (*i == '\\') s << "\\\\"; - } else { + else s << static_cast(*i); - } } return (s.str()); @@ -462,13 +463,15 @@ static void macro_buf_add_long( keyseq actions, tmp.pop_back(); } - if (tmp.size() == 0) { + if (tmp.size() == 0) + { // Didn't find a macro. Add the first keypress of the sequence // into the buffer, remove it from the sequence, and try again. macro_buf_add( actions.front() ); actions.pop_front(); - - } else { + } + else + { // Found a macro, which has already been added above. Now just // remove the macroed keys from the sequence. for (unsigned int i = 0; i < tmp.size(); i++) @@ -572,7 +575,8 @@ void macro_save( void ) f << "# WARNING: This file is entirely auto-generated." << std::endl << std::endl << "# Key Mappings:" << std::endl; - for (int mc = KC_DEFAULT; mc < KC_CONTEXT_COUNT; ++mc) { + for (int mc = KC_DEFAULT; mc < KC_CONTEXT_COUNT; ++mc) + { char keybuf[30] = "K:"; if (mc) snprintf(keybuf, sizeof keybuf, "K%d:", mc); @@ -610,7 +614,8 @@ static keyseq getch_mul( int (*rgetch)() = NULL ) // The a == 0 test is legacy code that I don't dare to remove. I // have a vague recollection of it being a kludge for conio support. - while ((kbhit() || a == 0)) { + while (kbhit() || a == 0) + { keys.push_back( a = rgetch() ); } @@ -826,26 +831,30 @@ static void _read_macros_from(const char* filename) { trim_string(s); // remove white space from ends - if (s[0] == '#') { - continue; // skip comments - - } else if (s.substr(0, 2) == "K:") { + if (s[0] == '#') + continue; // skip comments + else if (s.substr(0, 2) == "K:") + { key = parse_keyseq(s.substr(2)); keymap = true; keymc = KC_DEFAULT; - - } else if (s.length() >= 3 && s[0] == 'K' && s[2] == ':') { + } + else if (s.length() >= 3 && s[0] == 'K' && s[2] == ':') + { keymc = KeymapContext( KC_DEFAULT + s[1] - '0' ); - if (keymc >= KC_DEFAULT && keymc < KC_CONTEXT_COUNT) { + if (keymc >= KC_DEFAULT && keymc < KC_CONTEXT_COUNT) + { key = parse_keyseq(s.substr(3)); keymap = true; } - - } else if (s.substr(0, 2) == "M:") { + } + else if (s.substr(0, 2) == "M:") + { key = parse_keyseq(s.substr(2)); keymap = false; - - } else if (s.substr(0, 2) == "A:") { + } + else if (s.substr(0, 2) == "A:") + { action = parse_keyseq(s.substr(2)); macro_add( (keymap ? Keymaps[keymc] : Macros), key, action ); } diff --git a/crawl-ref/source/menu.cc b/crawl-ref/source/menu.cc index 40be0a8598..1a47b5a3a5 100644 --- a/crawl-ref/source/menu.cc +++ b/crawl-ref/source/menu.cc @@ -65,7 +65,7 @@ Menu::Menu( const formatted_string &fs ) if (nonblank && !starts_with_eol) last_text_colour = colour; - + check_add_formatted_line(last_text_colour, colour, line, true); if (nonblank && starts_with_eol) @@ -102,7 +102,7 @@ void Menu::check_add_formatted_line(int firstcol, int nextcol, for (int i = 0, col = firstcol; i < size; ++i, col = nextcol) { std::string &s(lines[i]); - + trim_string_right(s); MenuEntry *me = new MenuEntry(s); @@ -181,14 +181,17 @@ void Menu::reset() std::vector Menu::show(bool reuse_selections) { cursor_control cs(false); - - if (reuse_selections) { + + if (reuse_selections) + { get_selected(&sel); - } else { + } + else + { deselect_all(false); sel.clear(); } - + // Lose lines for the title + room for -more- line. pagesize = get_number_of_lines() - !!title - 1; @@ -239,7 +242,7 @@ bool Menu::process_key( int keyin ) lastch = keyin; return false; } - + bool nav = false, repaint = false; if (f_keyfilter) @@ -361,7 +364,7 @@ bool Menu::process_key( int keyin ) num = (num == -1)? keyin - '0' : num * 10 + keyin - '0'; } - + select_items( keyin, num ); get_selected( &sel ); if (sel.size() == 1 && (flags & MF_SINGLESELECT)) @@ -423,11 +426,11 @@ bool Menu::draw_title_suffix( const std::string &s, bool titlefirst ) s + std::string(avail_width - s.length(), ' '); cprintf("%s", towrite.c_str()); - + cgotoxy( oldx, oldy ); return true; } - + bool Menu::draw_title_suffix( const formatted_string &fs, bool titlefirst ) { int oldx = wherex(), oldy = wherey(); @@ -460,11 +463,11 @@ bool Menu::draw_title_suffix( const formatted_string &fs, bool titlefirst ) cprintf(fmt, " "); } } - + cgotoxy( oldx, oldy ); return true; } - + void Menu::draw_select_count( int count, bool force ) { if (!force && !is_set(MF_MULTISELECT)) @@ -478,7 +481,7 @@ void Menu::draw_select_count( int count, bool force ) { char buf[100] = ""; if (count) - snprintf(buf, sizeof buf, " (%d item%s) ", count, + snprintf(buf, sizeof buf, " (%d item%s) ", count, (count > 1? "s" : "")); draw_title_suffix( buf ); @@ -495,7 +498,7 @@ std::vector Menu::selected_entries() const void Menu::get_selected( std::vector *selected ) const { selected->clear(); - + for (int i = 0, count = items.size(); i < count; ++i) if (items[i]->selected()) selected->push_back( items[i] ); @@ -539,7 +542,7 @@ void Menu::select_items( int key, int qty ) { int final = items.size(); bool selected = false; - + // Process all items, in case user hits hotkey for an // item not on the current page. @@ -587,7 +590,7 @@ void Menu::select_items( int key, int qty ) bool Menu::is_selectable(int item) const { if (select_filter.empty()) return true; - + std::string text = items[item]->get_text(); for (int i = 0, count = select_filter.size(); i < count; ++i) { @@ -634,8 +637,8 @@ void Menu::select_index( int index, int qty ) } } } - else if (items[si]->level == MEL_ITEM && - (flags & (MF_SINGLESELECT | MF_MULTISELECT))) + else if (items[si]->level == MEL_ITEM && + (flags & (MF_SINGLESELECT | MF_MULTISELECT))) { last_selected = si; items[si]->select( qty ); @@ -667,7 +670,7 @@ void Menu::draw_menu() int end = first_entry + pagesize; if (end > (int) items.size()) end = items.size(); - + for (int i = first_entry; i < end; ++i) { draw_item( i ); @@ -853,7 +856,7 @@ void slider_menu::select_search(const std::string &s) lowercase(text); std::string::size_type found = text.find(srch); - if (found != std::string::npos + if (found != std::string::npos && found == text.find_first_not_of(" ")) { move_selection(i); @@ -905,7 +908,7 @@ void slider_menu::adjust_pagesizes(int recurse_depth) { if (first_entry == 1 && selected == 1) first_entry = 0; - + need_less = !!first_entry; pagesize = endy - starty + 1 - !!title - need_less; const int nitems = items.size(); @@ -917,7 +920,7 @@ void slider_menu::adjust_pagesizes(int recurse_depth) && (selected < first_entry || selected >= first_entry + pagesize) && recurse_depth > 0) fix_entry(recurse_depth - 1); - + calc_y_offset(); } @@ -944,7 +947,7 @@ std::vector slider_menu::show() if (!search.empty()) select_search(search); - + fix_entry(); do_menu(); @@ -992,7 +995,7 @@ void slider_menu::show_less() { if (!need_less) return ; - + if (first_entry > 0) less.display(); else @@ -1015,7 +1018,7 @@ void slider_menu::show_more() void slider_menu::calc_y_offset() { - y_offset = starty + !!title + need_less; + y_offset = starty + !!title + need_less; } int slider_menu::entry_end() const @@ -1039,7 +1042,7 @@ void slider_menu::draw_menu() cgotoxy(1, y_offset - 1); show_less(); - + for (int i = first_entry; i < end; ++i) draw_item( i ); @@ -1239,8 +1242,8 @@ void column_composer::add_formatted( strip_blank_lines(newlines); compose_formatted_column( - newlines, - col.lines, + newlines, + col.lines, margin == -1? col.margin : margin); col.lines += newlines.size(); @@ -1308,7 +1311,7 @@ void formatted_scroller::add_text(const std::string& s) break; else eolpos = newpos + 1; - } + } } void formatted_scroller::add_item_formatted_string(const formatted_string& fs, @@ -1316,7 +1319,8 @@ void formatted_scroller::add_item_formatted_string(const formatted_string& fs, { MenuEntry* me = new MenuEntry; me->data = new formatted_string(fs); - if ( hotkey ) { + if ( hotkey ) + { me->add_hotkey(hotkey); me->quantity = 1; } @@ -1469,10 +1473,10 @@ std::string get_linebreak_string(const std::string& s, int maxcol) return r; } -// takes a (possibly tagged) string, breaks it into lines and +// takes a (possibly tagged) string, breaks it into lines and // prints it into the given message channel void print_formatted_paragraph(std::string &s, int maxcol, - msg_channel_type channel) + msg_channel_type channel) { linebreak_string2(s,maxcol); std::string text; @@ -1480,13 +1484,14 @@ void print_formatted_paragraph(std::string &s, int maxcol, size_t loc = 0, oldloc = 0; while ( loc < s.size() ) { - if (s[loc] == '\n') { + if (s[loc] == '\n') + { text = s.substr(oldloc, loc-oldloc); formatted_message_history( text, channel ); oldloc = ++loc; } loc++; - } + } formatted_message_history( s.substr(oldloc, loc-oldloc), channel ); } @@ -1567,7 +1572,7 @@ bool formatted_scroller::line_up() } bool formatted_scroller::jump_to_hotkey( int keyin ) -{ +{ for ( unsigned int i = 0; i < items.size(); ++i ) if ( items[i]->is_hotkey(keyin) ) return jump_to(i); @@ -1639,7 +1644,7 @@ bool formatted_scroller::process_key( int keyin ) draw_menu(); else if (moved && is_set(MF_EASY_EXIT)) return (false); - + return true; } diff --git a/crawl-ref/source/message.cc b/crawl-ref/source/message.cc index 1659f230b1..222ebe315d 100644 --- a/crawl-ref/source/message.cc +++ b/crawl-ref/source/message.cc @@ -727,7 +727,7 @@ void formatted_message_history(const std::string &st_nocolor, std::vector fss; formatted_string::parse_string_to_multiple(st, fss); - for (unsigned int i=0; i #include -/* Period parameters */ +/* Period parameters */ #define N 624 #define M 397 #define MATRIX_A 0x9908b0dfUL /* constant vector a */ @@ -91,10 +91,11 @@ void pop_mt_state() /* initializes mt[N] with a seed */ void init_genrand(unsigned long s) { - mt[0]= s & 0xffffffffUL; - for (mti=1; mti> 30)) + mti); + mt[0] = s & 0xffffffffUL; + for (mti = 1; mti < N; mti++) + { + mt[mti] = + (1812433253UL * (mt[mti-1] ^ (mt[mti-1] >> 30)) + mti); /* See Knuth TAOCP Vol2. 3rd Ed. P.106 for multiplier. */ /* In the previous versions, MSBs of the seed affect */ /* only MSBs of the array mt[]. */ @@ -131,7 +132,7 @@ void init_by_array(unsigned long init_key[], int key_length) if (i>=N) { mt[0] = mt[N-1]; i=1; } } - mt[0] = 0x80000000UL; /* MSB is 1; assuring non-zero initial array */ + mt[0] = 0x80000000UL; /* MSB is 1; assuring non-zero initial array */ } #endif @@ -139,20 +140,23 @@ void init_by_array(unsigned long init_key[], int key_length) unsigned long genrand_int32(void) { unsigned long y; - static unsigned long mag01[2]={0x0UL, MATRIX_A}; + static unsigned long mag01[2] = {0x0UL, MATRIX_A}; /* mag01[x] = x * MATRIX_A for x=0,1 */ - if (mti >= N) { /* generate N words at one time */ + if (mti >= N) /* generate N words at one time */ + { int kk; if (mti == N+1) /* if init_genrand() has not been called, */ init_genrand(5489UL); /* a default initial seed is used */ - for (kk=0;kk> 1) ^ mag01[y & 0x1UL]; } - for (;kk> 1) ^ mag01[y & 0x1UL]; } @@ -161,7 +165,7 @@ unsigned long genrand_int32(void) mti = 0; } - + y = mt[mti++]; /* Tempering */ @@ -183,30 +187,30 @@ long genrand_int31(void) /* generates a random number on [0,1]-real-interval */ double genrand_real1(void) { - return genrand_int32()*(1.0/4294967295.0); - /* divided by 2^32-1 */ + return genrand_int32()*(1.0/4294967295.0); + /* divided by 2^32-1 */ } /* generates a random number on [0,1)-real-interval */ double genrand_real2(void) { - return genrand_int32()*(1.0/4294967296.0); + return genrand_int32()*(1.0/4294967296.0); /* divided by 2^32 */ } /* generates a random number on (0,1)-real-interval */ double genrand_real3(void) { - return (((double)genrand_int32()) + 0.5)*(1.0/4294967296.0); + return (((double)genrand_int32()) + 0.5)*(1.0/4294967296.0); /* divided by 2^32 */ } /* generates a random number on [0,1) with 53-bit resolution*/ -double genrand_res53(void) -{ - unsigned long a=genrand_int32()>>5, b=genrand_int32()>>6; - return(a*67108864.0+b)*(1.0/9007199254740992.0); -} +double genrand_res53(void) +{ + unsigned long a=genrand_int32()>>5, b=genrand_int32()>>6; + return(a*67108864.0+b)*(1.0/9007199254740992.0); +} /* These real versions are due to Isaku Wada, 2002/01/09 added */ int main(void) diff --git a/crawl-ref/source/ouch.cc b/crawl-ref/source/ouch.cc index b4b4527525..fa15841a3a 100644 --- a/crawl-ref/source/ouch.cc +++ b/crawl-ref/source/ouch.cc @@ -983,7 +983,8 @@ void end_game( scorefile_entry &se ) const int num_suffixes = sizeof(suffixes) / sizeof(const char*); - for (int i = 0; i < num_suffixes; ++i) { + for (int i = 0; i < num_suffixes; ++i) + { std::string tmpname = basename + suffixes[i]; unlink( tmpname.c_str() ); } diff --git a/crawl-ref/source/output.cc b/crawl-ref/source/output.cc index d18d88029e..c44d516731 100644 --- a/crawl-ref/source/output.cc +++ b/crawl-ref/source/output.cc @@ -131,7 +131,7 @@ static int _draw_colour_bar(int val, int max_val, int old_val, int old_disp, cgotoxy(ox, oy, GOTO_STAT); textcolor(BLACK); - for (int cx=0; cx < width; cx++) + for (int cx = 0; cx < width; cx++) { #ifdef USE_TILE // maybe this should use textbackground too? @@ -144,13 +144,18 @@ static int _draw_colour_bar(int val, int max_val, int old_val, int old_disp, putch(' '); #else - if (cx < disp) { + if (cx < disp) + { textcolor(default_colour); putch('='); - } else if (old_val > val && old_disp > disp && cx < old_disp) { + } + else if (old_val > val && old_disp > disp && cx < old_disp) + { textcolor(change_colour); putch('-'); - } else { + } + else + { textcolor(empty_colour); putch('-'); } @@ -280,7 +285,7 @@ static void _print_stats_hp(int x, int y) } cgotoxy(x+4, y, GOTO_STAT); - int col=-wherex(); + int col = -wherex(); cprintf( "%d", you.hp ); textcolor(LIGHTGREY); @@ -1172,9 +1177,9 @@ void update_monster_pane() { std::vector visible; get_playervisible_monsters(visible); - for (unsigned int i=0; itype, M_NO_EXP_GAIN )) { mons.push_back(monster_pane_info(visible[i])); diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc index cfcd8087a1..c0241995eb 100644 --- a/crawl-ref/source/player.cc +++ b/crawl-ref/source/player.cc @@ -1454,10 +1454,11 @@ bool player_res_asphyx() return (false); } -bool player_control_teleport(bool calc_unid) { - return ( you.duration[DUR_CONTROL_TELEPORT] || - player_equip(EQ_RINGS, RING_TELEPORT_CONTROL, calc_unid) || - you.mutation[MUT_TELEPORT_CONTROL] ); +bool player_control_teleport(bool calc_unid) +{ + return ( you.duration[DUR_CONTROL_TELEPORT] + || player_equip(EQ_RINGS, RING_TELEPORT_CONTROL, calc_unid) + || you.mutation[MUT_TELEPORT_CONTROL] ); } int player_res_torment(bool) @@ -2738,7 +2739,8 @@ int burden_change(void) { you.burden_state = BS_ENCUMBERED; - if (old_burdenstate != you.burden_state) { + if (old_burdenstate != you.burden_state) + { mpr("You are being weighed down by all of your possessions."); learned_something_new(TUT_HEAVY_LOAD); } diff --git a/crawl-ref/source/quiver.cc b/crawl-ref/source/quiver.cc index 0c290671ea..2b978c0096 100644 --- a/crawl-ref/source/quiver.cc +++ b/crawl-ref/source/quiver.cc @@ -3,7 +3,7 @@ * Summary: Player quiver functionality * * Last modified by $Author: $ on $Date: $ - * + * * - Only change last_used when actually using * - Not changing Qv; nobody knows about internals * - Track last_used of each type so each weapon can do the right thing @@ -39,14 +39,14 @@ player_quiver::player_quiver() // *slot_out filled in with the inv slot of the item we would like // to fire by default. If -1, the inv doesn't contain our desired // item. -// +// // *item_out filled in with item we would like to fire by default. // This can be returned even if the item is not in inv (although if // it is in inv, a reference to the inv item, with accurate count, // is returned) // // This is the item that will be displayed in Qv: -// +// void player_quiver::get_desired_item(const item_def** item_out, int* slot_out) const { const int slot = _get_pack_slot(m_last_used_of_type[m_last_used_type]); @@ -95,7 +95,7 @@ int player_quiver::get_fire_item(std::string* no_item_reason) const else if (full_fire_order.size() == 0) { *no_item_reason = "No suitable missiles."; - } + } else { const int skipped_item = full_fire_order[0]; @@ -124,7 +124,7 @@ void player_quiver::on_item_fired(const item_def& item) // Otherwise, it goes into last hand-thrown item. const item_def *weapon = you.weapon(); - + if (weapon && item.launched_by(*weapon)) { const ammo_t t = _get_weapon_ammo_type(weapon); @@ -138,7 +138,7 @@ void player_quiver::on_item_fired(const item_def& item) m_last_used_of_type[AMMO_THROW].quantity = 1; m_last_used_type = AMMO_THROW; } - + you.redraw_quiver = true; } @@ -171,7 +171,7 @@ void player_quiver::on_weapon_changed() m_last_used_type = _get_weapon_ammo_type(weapon); } } - + _maybe_fill_empty_slot(); } @@ -191,7 +191,7 @@ void player_quiver::on_inv_quantity_changed(int slot, int amt) else { // Maybe matches current stack. Redraw if so. - // + // const item_def* desired; int qv_slot; get_desired_item(&desired, &qv_slot); if (qv_slot == slot) @@ -213,7 +213,7 @@ void player_quiver::_maybe_fill_empty_slot() const launch_retval desired_ret = (slot == AMMO_THROW ? LRET_THROWN : LRET_LAUNCHED); std::vector order; _get_fire_order(order, false, weapon); - for (unsigned int i=0; i& v) const } // Get a sorted list of items to show in the fire interface. -// +// // If ignore_inscription_etc, ignore =f and Options.fire_items_start. // This is used for generating informational error messages, when the // fire order is empty. @@ -269,11 +269,12 @@ void player_quiver::_get_fire_order( continue; } - for (unsigned int i_flags=0; - i_flags= AMMO_THROW && m_last_used_type < NUM_AMMO); - const long count = unmarshallLong(inf); + const unsigned long count = unmarshallLong(inf); ASSERT(count <= ARRAYSIZE(m_last_used_of_type)); - for (int i=0; im_last_used_of_type), a); - for (int i=0; im_last_used_of_type[i]); @@ -343,13 +340,11 @@ preserve_quiver_slots::preserve_quiver_slots() preserve_quiver_slots::~preserve_quiver_slots() { if (! you.m_quiver) return; - for (int i=0; im_last_used_of_type[i] = you.inv[slot]; - } } you.redraw_quiver = true; } @@ -415,7 +410,7 @@ static int _get_pack_slot(const item_def& item) if (! is_valid_item(item)) return -1; - for (int i=0; i= SPWPN_START_FIXEDARTS) { return (true); @@ -320,7 +320,7 @@ static long calc_seed( const item_def &item ) return (item.special & RANDART_SEED_MASK); } -void randart_desc_properties( const item_def &item, +void randart_desc_properties( const item_def &item, randart_properties_t &proprt, randart_known_props_t &known, bool force_fake_props) @@ -564,11 +564,11 @@ static int randart_add_one_property( const item_def &item, return negench ? 0 : 1; } -void randart_wpn_properties( const item_def &item, +void randart_wpn_properties( const item_def &item, randart_properties_t &proprt, randart_known_props_t &known) { - ASSERT( is_random_artefact( item ) ); + ASSERT( is_random_artefact( item ) ); ASSERT( item.props.exists( KNOWN_PROPS_KEY ) ); const CrawlStoreValue &_val = item.props[KNOWN_PROPS_KEY]; ASSERT( _val.get_type() == SV_VEC ); @@ -662,7 +662,7 @@ void randart_wpn_properties( const item_def &item, proprt[RAP_BRAND] = (tmp >= 18) ? SPWPN_SPEED : (tmp >= 14) ? SPWPN_PROTECTION : - (tmp >= 10) ? SPWPN_VENOM + (tmp >= 10) ? SPWPN_VENOM : SPWPN_VORPAL + random2(3); if (atype == WPN_BLOWGUN && (proprt[RAP_BRAND] == SPWPN_VORPAL @@ -1028,12 +1028,12 @@ void randart_wpn_properties( const item_def &item, } } - if (one_chance_in(10) - && (aclass != OBJ_ARMOUR - || atype != ARM_CLOAK + if (one_chance_in(10) + && (aclass != OBJ_ARMOUR + || atype != ARM_CLOAK || get_equip_race(item) != ISFLAG_ELVEN) - && (aclass != OBJ_ARMOUR - || atype != ARM_BOOTS + && (aclass != OBJ_ARMOUR + || atype != ARM_BOOTS || get_equip_race(item) != ISFLAG_ELVEN) && get_armour_ego_type( item ) != SPARM_STEALTH) { @@ -1042,7 +1042,7 @@ void randart_wpn_properties( const item_def &item, if (one_chance_in(4)) { - proprt[RAP_STEALTH] = -proprt[RAP_STEALTH] - random2(20); + proprt[RAP_STEALTH] = -proprt[RAP_STEALTH] - random2(20); power_level--; } } @@ -1054,7 +1054,7 @@ void randart_wpn_properties( const item_def &item, proprt[RAP_CURSED] = 1; } -void randart_wpn_properties( const item_def &item, +void randart_wpn_properties( const item_def &item, randart_properties_t &proprt ) { randart_known_props_t known; @@ -1117,7 +1117,7 @@ int randart_wpn_num_props( const randart_properties_t &proprt ) void randart_wpn_learn_prop( item_def &item, randart_prop_type prop ) { - ASSERT( is_random_artefact( item ) ); + ASSERT( is_random_artefact( item ) ); ASSERT( item.props.exists( KNOWN_PROPS_KEY ) ); CrawlStoreValue &_val = item.props[KNOWN_PROPS_KEY]; ASSERT( _val.get_type() == SV_VEC ); @@ -1204,10 +1204,10 @@ std::string randart_name( const item_def &item ) god_gift = true; } } - + // get base type lookup += get_artefact_type(item.base_type); - + rng_save_excursion rng_state; seed_rng( seed ); @@ -1225,7 +1225,7 @@ std::string randart_name( const item_def &item ) if (appear.empty()) // still nothing found? appear = "non-descript"; } - + result += appear; result += " "; result += item_base_name(item); @@ -1236,15 +1236,15 @@ std::string randart_name( const item_def &item ) { result += item_base_name(item) + " "; std::string name = getRandNameString(lookup); - + if (name.empty() && god_gift) // if nothing found, try god name alone { name = getRandNameString(god_name(static_cast(item_orig), false)); - + if (name.empty()) // if still nothing found, try base type alone name = getRandNameString(get_artefact_type(item.base_type).c_str()); } - + if (name.empty()) // still nothing found? result += "of Bugginess"; else @@ -1273,7 +1273,7 @@ std::string randart_name( const item_def &item ) int find_unrandart_index(const item_def& artefact) { - for (int i=0; i < NO_UNRANDARTS; i++) + for (int i = 0; i < NO_UNRANDARTS; i++) { const unrandart_entry& candidate = unranddata[i]; if (candidate.ura_cl == artefact.base_type @@ -1311,7 +1311,7 @@ int find_okay_unrandart(unsigned char aclass, unsigned char atype) // base_type and sub_type. for (int i = 0, count = 0; i < NO_UNRANDARTS; i++) { - if (unranddata[i].ura_cl == aclass + if (unranddata[i].ura_cl == aclass && !does_unrandart_exist(i) && (atype == OBJ_RANDOM || unranddata[i].ura_ty == atype)) { @@ -1340,7 +1340,7 @@ bool make_item_fixed_artefact( item_def &item, bool in_abyss, int which ) const unique_item_status_type status = get_unique_item_status( OBJ_WEAPONS, which ); - if ((status == UNIQ_EXISTS + if ((status == UNIQ_EXISTS || (in_abyss && status == UNIQ_NOT_EXISTS) || (!in_abyss && status == UNIQ_LOST_IN_ABYSS)) && !force) @@ -1578,7 +1578,7 @@ static bool randart_is_redundant( const item_def &item, if (proprt[provides2] != 0) return true; - + return false; } @@ -1615,7 +1615,7 @@ static bool randart_is_conflicting( const item_def &item, case AMU_RAGE: conflicts = RAP_STEALTH; break; - } + } if (conflicts == RAP_NUM_PROPERTIES) return false; @@ -1631,7 +1631,7 @@ bool randart_is_bad( const item_def &item, randart_properties_t &proprt ) if (randart_wpn_num_props( proprt ) == 0) return true; - return ( randart_is_redundant( item, proprt ) || + return ( randart_is_redundant( item, proprt ) || randart_is_conflicting( item, proprt ) ); } @@ -1645,7 +1645,7 @@ bool randart_is_bad( const item_def &item ) bool make_item_randart( item_def &item ) { - if (item.base_type != OBJ_WEAPONS + if (item.base_type != OBJ_WEAPONS && item.base_type != OBJ_ARMOUR && item.base_type != OBJ_JEWELLERY) { @@ -1691,7 +1691,7 @@ bool make_item_unrandart( item_def &item, int unrand_index ) item.plus2 = unranddata[unrand_index].ura_pl2; item.colour = unranddata[unrand_index].ura_col; - item.flags |= ISFLAG_UNRANDART; + item.flags |= ISFLAG_UNRANDART; item.special = unranddata[ unrand_index ].prpty[ RAP_BRAND ]; if (unranddata[ unrand_index ].prpty[ RAP_CURSED ]) diff --git a/crawl-ref/source/religion.cc b/crawl-ref/source/religion.cc index a98c7655fa..68d21d8bdc 100644 --- a/crawl-ref/source/religion.cc +++ b/crawl-ref/source/religion.cc @@ -4078,8 +4078,8 @@ static bool _bless_weapon( god_type god, int brand, int colour ) { holy_word( 100, HOLY_WORD_GENERIC, true ); // un-bloodify surrounding squares - for (int i=-3;i<=3;i++) - for (int j=-3;j<=3;j++) + for (int i = -3; i <= 3; i++) + for (int j = -3; j <= 3; j++) { if (is_bloodcovered(you.x_pos+i, you.y_pos+j)) env.map[you.x_pos+i][you.y_pos+j].property = FPROP_NONE; diff --git a/crawl-ref/source/spells3.cc b/crawl-ref/source/spells3.cc index 50ca506833..a134e08736 100644 --- a/crawl-ref/source/spells3.cc +++ b/crawl-ref/source/spells3.cc @@ -869,8 +869,8 @@ bool remove_sanctuary(bool did_attack) const int radius = 5; bool seen_change = false; - for (int x=-radius; x<=radius; x++) - for (int y=-radius; y<=radius; y++) + for (int x = -radius; x <= radius; x++) + for (int y = -radius; y <= radius; y++) { int posx = env.sanctuary_pos.x + x; int posy = env.sanctuary_pos.y + y; @@ -917,8 +917,8 @@ void decrease_sanctuary_radius() return; radius = size+1; - for (int x=-radius; x<=radius; x++) - for (int y=-radius; y<=radius; y++) + for (int x = -radius; x <= radius; x++) + for (int y = -radius; y <= radius; y++) { int posx = env.sanctuary_pos.x + x; int posy = env.sanctuary_pos.y + y; @@ -968,9 +968,8 @@ bool cast_sanctuary(const int power) int count = 0; int monster = -1; - for (int x=-radius; x<=radius; x++) - { - for (int y=-radius; y<=radius; y++) + for (int x = -radius; x <= radius; x++) + for (int y = -radius; y <= radius; y++) { int posx = you.x_pos + x; int posy = you.y_pos + y; @@ -1011,7 +1010,6 @@ bool cast_sanctuary(const int power) else env.map[posx][posy].property = FPROP_SANCTUARY_2; // white } - } if (count == 1) simple_monster_message(&menv[monster], " turns to flee the light!"); @@ -1048,9 +1046,8 @@ void manage_halo() if (!you.duration[DUR_BACKLIGHT]) you.duration[DUR_BACKLIGHT] = 1; - for (int x=-radius; x<=radius; x++) - { - for (int y=-radius; y<=radius; y++) + for (int x = -radius; x <= radius; x++) + for (int y = -radius; y <= radius; y++) { int posx = you.x_pos + x; int posy = you.y_pos + y; @@ -1073,7 +1070,6 @@ void manage_halo() } } } - } } bool inside_halo(int posx, int posy) diff --git a/crawl-ref/source/stash.cc b/crawl-ref/source/stash.cc index 66629a968f..69b52bdd73 100644 --- a/crawl-ref/source/stash.cc +++ b/crawl-ref/source/stash.cc @@ -88,10 +88,10 @@ std::string stash_annotate_item(const char *s, { formatted_string fs; item_def dup = *item; - spellbook_contents( dup, - item->base_type == OBJ_BOOKS? + spellbook_contents( dup, + item->base_type == OBJ_BOOKS? RBOOK_READ_SPELL - : RBOOK_USE_STAFF, + : RBOOK_USE_STAFF, &fs ); text += EOL; text += fs.tostring(2, -2); @@ -118,7 +118,7 @@ void describe_stash(int x, int y) Stash *s = ls->find_stash(x, y); if (s) { - std::string desc = "[Stash: " + std::string desc = "[Stash: " + s->description() + "]"; mpr(desc.c_str(), MSGCH_EXAMINE_FILTER); } @@ -132,8 +132,8 @@ static void fully_identify_item(item_def *item) set_ident_flags( *item, ISFLAG_IDENT_MASK ); if (item->base_type != OBJ_WEAPONS) - set_ident_type( item->base_type, - item->sub_type, + set_ident_type( item->base_type, + item->sub_type, ID_KNOWN_TYPE ); } @@ -264,7 +264,7 @@ void Stash::update() if (grid_is_trap(feat)) trap = trap_type_at_xy(x, y); - + int objl = igrd[x][y]; // If this is your position, you know what's on this square if (x == you.x_pos && y == you.y_pos) @@ -301,7 +301,7 @@ void Stash::update() if (item.link == NON_ITEM) items.clear(); - // We knew of nothing on this square, so we'll assume this is the + // We knew of nothing on this square, so we'll assume this is the // only item here, but mark it as unverified unless we can see nothing // under the item. if (items.size() == 0) @@ -349,7 +349,7 @@ void Stash::update() // terribly clever, but it prevents the vector swelling forever. if (!verified) items.pop_back(); - // Items are different. We'll put this item in the front of our + // Items are different. We'll put this item in the front of our // vector, and mark this as unverified items.insert(items.begin(), item); verified = false; @@ -381,7 +381,7 @@ protected: void draw_stock_item(int index, const MenuEntry *me) const { - // Skip inventory draw function, as tiles code can't currently + // Skip inventory draw function, as tiles code can't currently // handle drawing items that aren't in mitm or in inventory. Menu::draw_stock_item(index, me); } @@ -395,7 +395,7 @@ void StashMenu::draw_title() textcolor(title->colour); cprintf( "%s", title->text.c_str()); if (title->quantity) - cprintf(", %d item%s", title->quantity, + cprintf(", %d item%s", title->quantity, title->quantity == 1? "" : "s"); cprintf(")"); if (can_travel) @@ -440,14 +440,14 @@ bool Stash::show_menu(const std::string &prefix, bool can_travel) const mtitle->quantity = items.size(); menu.set_title(mtitle); menu.load_items( InvMenu::xlat_itemvect(items), stash_menu_fixup); - + std::vector sel; while (true) { sel = menu.show(); if (menu.getkey() == 1) return true; - + if (sel.size() != 1) break; @@ -465,13 +465,13 @@ std::string Stash::description() const const item_def &item = items[0]; std::string desc = stash_item_name(item); - + size_t sz = items.size(); if (sz > 1) { char additionals[50]; - snprintf(additionals, sizeof additionals, - " (...%ld)", + snprintf(additionals, sizeof additionals, + " (...%ld)", (unsigned long) (sz - 1)); desc += additionals; } @@ -511,7 +511,7 @@ bool Stash::matches_search(const std::string &prefix, { std::string desc = munge_description(get_item_description(item, false, true)); - + if (search.matches(desc)) { if (!res.count++) @@ -530,7 +530,7 @@ bool Stash::matches_search(const std::string &prefix, res.matches = 1; } } - + if (res.matches) { res.stash = this; @@ -542,10 +542,10 @@ bool Stash::matches_search(const std::string &prefix, return !!res.matches; } -void Stash::write(std::ostream &os, - int refx, int refy, +void Stash::write(std::ostream &os, + int refx, int refy, std::string place, - bool identify) + bool identify) const { activate_notes(false); @@ -554,7 +554,7 @@ void Stash::write(std::ostream &os, << (place.length()? ", " + place : "") << ")" << std::endl; - + char buf[ITEMNAME_SIZE]; for (int i = 0; i < (int) items.size(); ++i) { @@ -617,7 +617,7 @@ void Stash::save(writer& outf) const marshallByte(outf, trap); // Note: Enabled save value is inverted logic, so that it defaults to true - marshallByte(outf, + marshallByte(outf, (unsigned char) ((verified? 1 : 0) | (!enabled? 2 : 0)) ); // And dump the items individually. We don't bother saving fields we're @@ -640,7 +640,7 @@ void Stash::load(reader& inf) trap = static_cast( static_cast( unmarshallByte(inf) )); - + unsigned char flags = unmarshallByte(inf); verified = (flags & 1) != 0; @@ -694,9 +694,9 @@ std::string ShopInfo::shop_item_name(const shop_item &si) const if (shoptype_identifies_stock(static_cast(this->shoptype))) const_cast(si).item.flags |= ISFLAG_IDENT_MASK; - + const std::string itemname = Stash::stash_item_name(si.item); - snprintf(shopitem, sizeof shopitem, "%s (%u gold)", + snprintf(shopitem, sizeof shopitem, "%s (%u gold)", itemname.c_str(), si.price); if ( oldflags != si.item.flags ) @@ -708,7 +708,7 @@ std::string ShopInfo::shop_item_name(const shop_item &si) const std::string ShopInfo::shop_item_desc(const shop_item &si) const { std::string desc; - + const unsigned long oldflags = si.item.flags; if (shoptype_identifies_stock(static_cast(this->shoptype))) @@ -718,7 +718,7 @@ std::string ShopInfo::shop_item_desc(const shop_item &si) const { desc = munge_description(get_item_description(si.item, false, true)); trim_string(desc); - + // Walk backwards and prepend indenting spaces to \n characters for (int i = desc.length() - 1; i >= 0; --i) if (desc[i] == '\n') @@ -737,7 +737,7 @@ void ShopInfo::describe_shop_item(const shop_item &si) const if (shoptype_identifies_stock(static_cast(this->shoptype))) const_cast(si).item.flags |= ISFLAG_IDENT_MASK; - + item_def it = static_cast(si.item); describe_item( it ); @@ -785,11 +785,11 @@ bool ShopInfo::show_menu(const std::string &place, sel = menu.show(); if (menu.getkey() == 1) return true; - + if (sel.size() != 1) break; - const shop_item *item = + const shop_item *item = static_cast( sel[0]->data ); describe_shop_item(*item); } @@ -802,7 +802,7 @@ std::string ShopInfo::description() const } bool ShopInfo::matches_search(const std::string &prefix, - const base_pattern &search, + const base_pattern &search, stash_search_result &res) const { if (items.empty() && visited) @@ -815,7 +815,7 @@ bool ShopInfo::matches_search(const std::string &prefix, std::string sname = shop_item_name(items[i]); std::string ann = stash_annotate_item( STASH_LUA_SEARCH_ANNOTATE, &items[i].item, true); - + bool thismatch = false; if (search.matches(prefix + " " + ann + sname)) thismatch = true; @@ -852,7 +852,7 @@ bool ShopInfo::matches_search(const std::string &prefix, res.pos.pos.x = x; res.pos.pos.y = y; } - + return match || res.matches; } @@ -1081,7 +1081,7 @@ int LevelStashes::_num_enabled_stashes() const if (!rawcount) return (0); - for (stashes_t::const_iterator iter = m_stashes.begin(); + for (stashes_t::const_iterator iter = m_stashes.begin(); iter != m_stashes.end(); iter++) { if (!iter->second.enabled) @@ -1136,7 +1136,7 @@ void LevelStashes::write(std::ostream &os, bool identify) const const Stash &s = m_stashes.begin()->second; int refx = s.getX(), refy = s.getY(); std::string levname = short_level_name(); - for (stashes_t::const_iterator iter = m_stashes.begin(); + for (stashes_t::const_iterator iter = m_stashes.begin(); iter != m_stashes.end(); iter++) { iter->second.write(os, refx, refy, levname, identify); @@ -1153,7 +1153,7 @@ void LevelStashes::save(writer& outf) const m_place.save(outf); // And write the individual stashes - for (stashes_t::const_iterator iter = m_stashes.begin(); + for (stashes_t::const_iterator iter = m_stashes.begin(); iter != m_stashes.end(); iter++) { iter->second.save(outf); @@ -1256,7 +1256,7 @@ void StashTracker::add_stash(int x, int y, bool verbose) if (s && s->enabled) mpr("Added stash."); } - + if (!current.stash_count()) remove_level(); } @@ -1337,7 +1337,7 @@ void StashTracker::update_visible_stashes( const dungeon_feature_type grid = grd[cx][cy]; if ((!lev || !lev->update_stash(cx, cy)) - && mode == ST_AGGRESSIVE + && mode == ST_AGGRESSIVE && (igrd[cx][cy] != NON_ITEM || !Stash::is_boring_feature(grid))) { @@ -1380,7 +1380,7 @@ void StashTracker::show_stash_search_prompt() mprf(MSGCH_PROMPT, "Search for what%s?", prompt_qual.c_str()); // Push the cursor down to the next line. Newline on the prompt will not // do the trick on DOS. - mpr("", MSGCH_PROMPT); + mpr("", MSGCH_PROMPT); } class stash_search_reader : public line_reader @@ -1409,15 +1409,18 @@ struct compare_by_distance bool operator()(const stash_search_result& lhs, const stash_search_result& rhs) { - if (lhs.player_distance != rhs.player_distance) { + if (lhs.player_distance != rhs.player_distance) + { // Sort by increasing distance return (lhs.player_distance < rhs.player_distance); - } else if (lhs.matches != rhs.matches) { + } + else if (lhs.matches != rhs.matches) + { // Then by decreasing number of matches return (lhs.matches > rhs.matches); - } else { - return false; } + else + return false; } }; @@ -1427,18 +1430,23 @@ struct compare_by_name bool operator()(const stash_search_result& lhs, const stash_search_result& rhs) { - if (lhs.match != rhs.match) { + if (lhs.match != rhs.match) + { // Sort by name return (lhs.match < rhs.match); - } else if (lhs.player_distance != rhs.player_distance) { + } + else if (lhs.player_distance != rhs.player_distance) + { // Then sort by increasing distance return (lhs.player_distance < rhs.player_distance); - } else if (lhs.matches != rhs.matches) { + } + else if (lhs.matches != rhs.matches) + { // Then by decreasing number of matches return (lhs.matches > rhs.matches); - } else { - return false; } + else + return false; } }; @@ -1469,7 +1477,7 @@ void StashTracker::search_stashes() break; } } - + mesclr(); if (!validline || (!*buf && !lastsearch.length())) return; @@ -1490,12 +1498,12 @@ void StashTracker::search_stashes() #else #define RE_ESCAPE "" #endif - + csearch = (RE_ESCAPE "{") + level_id::current().describe() + (RE_ESCAPE "}"); } - + std::vector results; base_pattern *search = NULL; @@ -1504,7 +1512,7 @@ void StashTracker::search_stashes() search = &tpat; lua_text_pattern ltpat( csearch ); - + if (lua_text_pattern::is_lua_pattern(csearch)) search = <pat; @@ -1533,16 +1541,20 @@ void StashTracker::search_stashes() while (true) { const char* sort_style; - if (sort_by_dist) { + if (sort_by_dist) + { std::sort(results.begin(), results.end(), compare_by_distance()); sort_style = "by dist"; - } else { + } + else + { std::sort(results.begin(), results.end(), compare_by_name()); sort_style = "by name"; } const bool again = display_search_results(results, sort_style); - if (!again) break; + if (!again) + break; sort_by_dist = !sort_by_dist; } } @@ -1566,7 +1578,7 @@ void StashTracker::get_matching_stashes( int ldist = level_distance(curr, results[i].pos.id); if (ldist == -1) ldist = 1000; - + results[i].player_distance = ldist; } } @@ -1599,12 +1611,12 @@ void StashSearchMenu::draw_title() cgotoxy(1, 1); textcolor(title->colour); cprintf("%d %s%s, sorted %s", - title->quantity, title->text.c_str(), + title->quantity, title->text.c_str(), title->quantity > 1? "es" : "", sort_style); char buf[200]; - snprintf(buf, 200, + snprintf(buf, 200, " [a-z: %s ?: change action /: change sort]", menu_action == ACT_TRAVEL ? "travel" : "examine"); @@ -1626,18 +1638,18 @@ bool StashSearchMenu::process_key(int key) request_toggle_sort_method = true; return false; } - + return Menu::process_key(key); } // Returns true to request redisplay with a different sort method bool StashTracker::display_search_results( - std::vector &results, + std::vector &results, const char* sort_style) { if (results.empty()) return false; - + bool travelable = can_travel_interlevel(); StashSearchMenu stashmenu(sort_style); @@ -1685,7 +1697,7 @@ bool StashTracker::display_search_results( if (sel.size() == 1 && stashmenu.menu_action == StashSearchMenu::ACT_EXAMINE) { - stash_search_result *res = + stash_search_result *res = static_cast(sel[0]->data); bool dotravel = false; @@ -1715,7 +1727,7 @@ bool StashTracker::display_search_results( redraw_screen(); if (sel.size() == 1 && stashmenu.menu_action == StashSearchMenu::ACT_TRAVEL) { - const stash_search_result *res = + const stash_search_result *res = static_cast(sel[0]->data); const level_pos lp = res->pos; start_translevel_travel(lp); diff --git a/crawl-ref/source/tags.cc b/crawl-ref/source/tags.cc index 736fb7ce90..a3b05febff 100644 --- a/crawl-ref/source/tags.cc +++ b/crawl-ref/source/tags.cc @@ -129,9 +129,8 @@ void writer::writeByte(unsigned char ch) { if (_file) fputc(ch, _file); - else { + else _pbuf->push_back(ch); - } } void writer::write(const void *data, size_t size) @@ -226,7 +225,7 @@ char unmarshallByte(reader &th) void marshallShort(std::vector& buf, short data) { - COMPILE_CHECK(sizeof(data)==2, c1); + COMPILE_CHECK(sizeof(data) == 2, c1); buf.push_back((unsigned char) ((data & 0xFF00) >> 8)); buf.push_back((unsigned char) ((data & 0x00FF) )); } @@ -785,13 +784,13 @@ void tag_set_expected(char tags[], int fileType) { int i; - for (i=0; i= TAG_YOU && i <=TAG_YOU_DUNGEON) + if (i >= TAG_YOU && i <= TAG_YOU_DUNGEON || i == TAG_LOST_MONSTERS) { tags[i] = 1; diff --git a/crawl-ref/source/tile1.cc b/crawl-ref/source/tile1.cc index af79c65a75..0abd629892 100644 --- a/crawl-ref/source/tile1.cc +++ b/crawl-ref/source/tile1.cc @@ -33,7 +33,7 @@ static FixedArray < unsigned int, GXM, GYM > tile_dngn; bool is_bazaar() { - return (you.level_type == LEVEL_PORTAL_VAULT && + return (you.level_type == LEVEL_PORTAL_VAULT && you.level_type_name == "bazaar"); } @@ -75,9 +75,9 @@ static int _tileidx_monster_base(int mon_idx, bool detected) const monsters* mon = &menv[mon_idx]; int grid = grd[mon->x][mon->y]; bool in_water = (grid == DNGN_SHALLOW_WATER || grid == DNGN_DEEP_WATER); - + int type = mon->type; - + // show only base class for detected monsters if (detected) type = mons_genus(type); @@ -852,7 +852,7 @@ static int _tileidx_fixed_artefact(int special) case SPWPN_VAMPIRES_TOOTH: return TILE_SPWPN_VAMPIRES_TOOTH; case SPWPN_STAFF_OF_WUCAD_MU: return TILE_SPWPN_STAFF_OF_WUCAD_MU; } - + return TILE_ERROR; } @@ -1111,7 +1111,7 @@ static int _tileidx_weapon(const item_def &item) case WPN_BARDICHE: return TILE_WPN_LOCHABER_AXE; } - + return TILE_ERROR; } @@ -1133,12 +1133,12 @@ static int _tileidx_missile(const item_def &item) return TILE_MI_DART_P; return TILE_MI_DART; - case MI_NEEDLE: + case MI_NEEDLE: if (brand == SPMSL_POISONED || brand == SPMSL_POISONED_II) return TILE_MI_NEEDLE_P; return TILE_MI_NEEDLE; } - + return TILE_ERROR; } @@ -1158,16 +1158,16 @@ static int _tileidx_armour(const item_def &item) switch(type) { - case ARM_ROBE: + case ARM_ROBE: return TILE_ARM_ROBE + etable[2][etype]; - + case ARM_LEATHER_ARMOUR: if (race == ISFLAG_ORCISH) return TILE_ARM_LEATHER_ARMOUR_ORC; if (race == ISFLAG_ELVEN) return TILE_ARM_LEATHER_ARMOUR_ELF; return TILE_ARM_LEATHER_ARMOUR + etable[2][etype]; - + case ARM_RING_MAIL: if (race == ISFLAG_ORCISH) return TILE_ARM_RING_MAIL_ORC; @@ -1176,7 +1176,7 @@ static int _tileidx_armour(const item_def &item) if (race == ISFLAG_DWARVEN) return TILE_ARM_RING_MAIL_DWA; return TILE_ARM_RING_MAIL + etable[1][etype]; - + case ARM_SCALE_MAIL: if (race == ISFLAG_ELVEN) return TILE_ARM_SCALE_MAIL_ELF; @@ -1206,7 +1206,7 @@ static int _tileidx_armour(const item_def &item) case ARM_SHIELD: return TILE_ARM_SHIELD + etable[2][etype]; - case ARM_CLOAK: + case ARM_CLOAK: return TILE_ARM_CLOAK + etable[3][etype]; case ARM_WIZARD_HAT: @@ -1221,10 +1221,10 @@ static int _tileidx_armour(const item_def &item) case ARM_GLOVES: return TILE_ARM_GLOVES + etable[3][etype]; - case ARM_BOOTS: + case ARM_BOOTS: return TILE_ARM_BOOTS + etable[3][etype]; - case ARM_BUCKLER: + case ARM_BUCKLER: return TILE_ARM_BUCKLER + etable[1][etype]; case ARM_LARGE_SHIELD: @@ -1239,7 +1239,7 @@ static int _tileidx_armour(const item_def &item) case ARM_ANIMAL_SKIN: return TILE_ARM_ANIMAL_SKIN + etable[1][etype]; - case ARM_TROLL_HIDE: + case ARM_TROLL_HIDE: return TILE_ARM_TROLL_HIDE; case ARM_TROLL_LEATHER_ARMOUR: @@ -1317,7 +1317,7 @@ static int _tileidx_food(const item_def &item) case FOOD_CHEESE: return TILE_FOOD_CHEESE; case FOOD_SAUSAGE: return TILE_FOOD_SAUSAGE; - case FOOD_CHUNK: + case FOOD_CHUNK: if (food_is_rotten(item)) return TILE_FOOD_CHUNK_ROTTEN; return TILE_FOOD_CHUNK; @@ -1357,7 +1357,7 @@ static int _tileidx_corpse(int mon) // all elves case MONS_ELF: return TILE_CORPSE_ELF; - + case MONS_JACKAL: return TILE_CORPSE_JACKAL; case MONS_HOUND: return TILE_CORPSE_HOUND; case MONS_WAR_DOG: return TILE_CORPSE_WAR_DOG; @@ -1390,13 +1390,13 @@ static int _tileidx_corpse(int mon) case MONS_MERMAID: return TILE_CORPSE_MERMAID; case MONS_MERFOLK: return TILE_CORPSE_MERFOLK_FIGHTER; - + case MONS_NECROPHAGE: return TILE_CORPSE_NECROPHAGE; case MONS_GHOUL: return TILE_CORPSE_GHOUL; // all orcs case MONS_ORC: return TILE_CORPSE_ORC; - + case MONS_RAT: return TILE_CORPSE_RAT; case MONS_QUOKKA: return TILE_CORPSE_QUOKKA; case MONS_GREY_RAT: return TILE_CORPSE_GREY_RAT; @@ -1410,7 +1410,7 @@ static int _tileidx_corpse(int mon) case MONS_REDBACK: return TILE_CORPSE_REDBACK; case MONS_MINOTAUR: return TILE_CORPSE_MINOTAUR; - + case MONS_UGLY_THING: return TILE_CORPSE_UGLY_THING; case MONS_VERY_UGLY_THING: return TILE_CORPSE_VERY_UGLY_THING; @@ -1466,11 +1466,11 @@ static int _tileidx_corpse(int mon) case MONS_GIANT_AMOEBA: return TILE_CORPSE_GIANT_AMOEBA; // all nagas case MONS_NAGA: return TILE_CORPSE_NAGA; - + // including ogre-mage case MONS_OGRE: return TILE_CORPSE_OGRE; case MONS_TWO_HEADED_OGRE: return TILE_CORPSE_TWO_HEADED_OGRE; - + case MONS_QUEEN_BEE: return TILE_CORPSE_QUEEN_BEE; case MONS_QUEEN_ANT: return TILE_CORPSE_QUEEN_ANT; @@ -1496,13 +1496,13 @@ static int _tileidx_corpse(int mon) case MONS_YAK: return TILE_CORPSE_YAK; case MONS_DEATH_YAK: return TILE_CORPSE_DEATH_YAK; - case MONS_GLOWING_SHAPESHIFTER: return TILE_CORPSE_GLOWING_SHAPESHIFTER; + case MONS_GLOWING_SHAPESHIFTER: return TILE_CORPSE_GLOWING_SHAPESHIFTER; case MONS_SHAPESHIFTER: return TILE_CORPSE_SHAPESHIFTER; // all humans case MONS_HUMAN: return TILE_CORPSE_HUMAN; } - + return TILE_ERROR; } @@ -1581,7 +1581,7 @@ static int _tileidx_misc(const item_def &item) case MISC_RUNE_OF_ZOT: return TILE_MISC_RUNE_OF_ZOT; } - + return TILE_ERROR; } @@ -1643,7 +1643,7 @@ int tileidx_item(const item_def &item) { if (is_random_artefact( item )) return TILE_RING_RANDOM_OFFSET + color - 1; - else + else return TILE_RING_NORMAL_OFFSET + special % 13; } else @@ -1654,7 +1654,7 @@ int tileidx_item(const item_def &item) return TILE_AMU_RANDOM_OFFSET + color - 1; else return TILE_AMU_NORMAL_OFFSET + special % 13; - } + } case OBJ_POTIONS: if (id[ IDTYPE_POTIONS ][type] == ID_KNOWN_TYPE @@ -1868,7 +1868,7 @@ int tileidx_feature(int object, int gx, int gy) return TILE_DNGN_DEEP_WATER; case DNGN_SHALLOW_WATER: return TILE_DNGN_SHALLOW_WATER; - case DNGN_FLOOR: + case DNGN_FLOOR: case DNGN_UNDISCOVERED_TRAP: return TILE_DNGN_FLOOR; case DNGN_FLOOR_SPECIAL: @@ -1885,8 +1885,8 @@ int tileidx_feature(int object, int gx, int gy) return TILE_DNGN_ENTER_SHOP; case DNGN_ENTER_LABYRINTH: return TILE_DNGN_ENTER_LABYRINTH; - case DNGN_STONE_STAIRS_DOWN_I: - case DNGN_STONE_STAIRS_DOWN_II: + case DNGN_STONE_STAIRS_DOWN_I: + case DNGN_STONE_STAIRS_DOWN_II: case DNGN_STONE_STAIRS_DOWN_III: return TILE_DNGN_STONE_STAIRS_DOWN; case DNGN_ESCAPE_HATCH_DOWN: @@ -2139,14 +2139,14 @@ int tileidx_unseen(int ch, const coord_def& gc) case 135: res = TILE_DNGN_DEEP_WATER; break; case 133: res = TILE_DNGN_BLUE_FOUNTAIN; break; case '}': res = TILE_MISC_CRYSTAL_BALL_OF_SEEING; break; - case 128: //old + case 128: //old case 254: res = TILE_DNGN_CLOSED_DOOR; break; case 129: res = TILE_DNGN_RETURN; break; case 132: res = TILE_UNSEEN_ENTRANCE; break; case 136: res = TILE_DNGN_ENTER; break; case 141: res = TILE_DNGN_LAVA; break; } - //if(res == TILE_ERROR)printf("undefined mapchar %d [%c]\n",ch,ch); + //if (res == TILE_ERROR) printf("undefined mapchar %d [%c]\n",ch,ch); return res | tile_unseen_flag(gc); } @@ -2187,7 +2187,7 @@ static void _finalize_tile(unsigned int *tile, bool is_special, get_num_floor_special_flavors() > 0) { (*tile) = get_floor_special_tile_idx() + special_flv; - ASSERT(special_flv >= 0 && + ASSERT(special_flv >= 0 && special_flv < get_num_floor_special_flavors()); } else if (orig == TILE_DNGN_FLOOR || orig == TILE_DNGN_FLOOR_SPECIAL) @@ -2252,8 +2252,8 @@ void tilep_calc_flags(int parts[], int flag[]) } /* - * Set default parts of each race - * body + optional beard, hair, etc + * Set default parts of each race + * body + optional beard, hair, etc */ int draconian_color(int race, int level) @@ -2304,7 +2304,7 @@ void tilep_race_default(int race, int gender, int level, int *parts) switch(race) { case SP_HUMAN: - result = TILEP_BASE_HUMAN; + result = TILEP_BASE_HUMAN; break; case SP_ELF: case SP_HIGH_ELF: @@ -2711,7 +2711,7 @@ int tilep_str_to_part(char *str) //special if (str[0] == '*') return TILEP_SHOW_EQUIP; - + //normal 2 digits return atoi(str); } @@ -2824,15 +2824,15 @@ int tilep_equ_weapon(const item_def &item) case MISC_STONE_OF_EARTH_ELEMENTALS: return TILEP_HAND1_STONE; case MISC_DISC_OF_STORMS: return TILEP_HAND1_DISC; - case MISC_CRYSTAL_BALL_OF_SEEING: - case MISC_CRYSTAL_BALL_OF_ENERGY: + case MISC_CRYSTAL_BALL_OF_SEEING: + case MISC_CRYSTAL_BALL_OF_ENERGY: case MISC_CRYSTAL_BALL_OF_FIXATION: return TILEP_HAND1_CRYSTAL; case MISC_LAMP_OF_FIRE: return TILEP_HAND1_LANTERN; case MISC_LANTERN_OF_SHADOWS: return TILEP_HAND1_BONE_LANTERN; case MISC_HORN_OF_GERYON: return TILEP_HAND1_HORN; - case MISC_BOX_OF_BEASTS: + case MISC_BOX_OF_BEASTS: case MISC_EMPTY_EBONY_CASKET: return TILEP_HAND1_BOX; case MISC_DECK_OF_ESCAPE: @@ -2991,7 +2991,7 @@ int tilep_equ_weapon(const item_def &item) case WPN_HAND_CROSSBOW: return TILEP_HAND1_CROSSBOW; case WPN_BLOWGUN: return TILEP_HAND1_BLOWGUN; case WPN_LONGBOW: return TILEP_HAND1_BOW3; - + default: return 0; } } @@ -3031,7 +3031,7 @@ int tilep_equ_armour(const item_def &item) switch (item.sub_type) { - case ARM_ROBE: + case ARM_ROBE: switch(item.colour) { // We've got a zillion robes; let's use 'em! @@ -3053,7 +3053,7 @@ int tilep_equ_armour(const item_def &item) case WHITE: return TILEP_BODY_ROBE_WHITE; default: return 0; } - + case ARM_LEATHER_ARMOUR: return TILEP_BODY_LEATHER_ARMOUR3; case ARM_RING_MAIL: return TILEP_BODY_RINGMAIL; case ARM_CHAIN_MAIL: return TILEP_BODY_CHAINMAIL; @@ -3080,7 +3080,7 @@ int tilep_equ_armour(const item_def &item) case ARM_SWAMP_DRAGON_ARMOUR: return TILEP_BODY_DRAGONARM_BROWN; case ARM_ANIMAL_SKIN: return TILEP_BODY_ANIMAL_SKIN; - case ARM_TROLL_HIDE: + case ARM_TROLL_HIDE: case ARM_TROLL_LEATHER_ARMOUR: return TILEP_BODY_TROLL_HIDE; default: return 0; @@ -3091,7 +3091,7 @@ int tilep_equ_shield(const item_def &item) { if (you.equip[EQ_SHIELD] == -1) return 0; - + if (item.base_type != OBJ_ARMOUR) return 0; @@ -3121,10 +3121,10 @@ int tilep_equ_cloak(const item_def &item) { if (you.equip[EQ_CLOAK] == -1) return 0; - + if (item.base_type != OBJ_ARMOUR || item.sub_type != ARM_CLOAK) return 0; - + switch (item.colour) { case BLACK: @@ -3339,7 +3339,7 @@ int tilep_equ_boots(const item_def &item) if (item.sub_type == ARM_NAGA_BARDING) return TILEP_BOOTS_NAGA_BARDING + std::min(etype, 3); - + if (item.sub_type == ARM_CENTAUR_BARDING) return TILEP_BOOTS_CENTAUR_BARDING + std::min(etype, 3); @@ -3411,10 +3411,10 @@ const char *get_parts_name(int part, int idx) { static char tmp[10]; const char *ptr = tilep_comment[ tilep_comment_ofs[part] -1 + idx ]; - + if (idx == 0) return ""; - + if (ptr[0] == 0) { sprintf(tmp,"%02d",idx); @@ -3512,9 +3512,9 @@ void tile_init_flavor() int right_grd = (x < GXM - 1) ? grd[x+1][y] : DNGN_ROCK_WALL; int up_grd = (y > 0) ? grd[x][y-1] : DNGN_ROCK_WALL; int down_grd = (y < GYM - 1) ? grd[x][y+1] : DNGN_ROCK_WALL; - unsigned short left_col = (x > 0) ? + unsigned short left_col = (x > 0) ? env.grid_colours[x-1][y] : BLACK; - unsigned short right_col = (x < GXM - 1) ? + unsigned short right_col = (x < GXM - 1) ? env.grid_colours[x+1][y] : BLACK; unsigned short up_col = (y > 0) ? env.grid_colours[x][y-1] : BLACK; @@ -3783,7 +3783,7 @@ void tile_place_item(int x, int y, int idx) int t = tileidx_item(mitm[idx]); if (mitm[idx].link != NON_ITEM) t |= TILE_FLAG_S_UNDER; - + env.tile_fg[x-1][y-1] = t; if (item_needs_autopickup(mitm[idx])) @@ -3820,7 +3820,7 @@ void tile_place_monster(int gx, int gy, int idx, bool foreground, bool detected) { return; } - + const coord_def gc(gx, gy); const coord_def ep = view2show(grid2view(gc)); @@ -4068,7 +4068,7 @@ void tile_finish_dngn(unsigned int *tileb, int cx, int cy) void tile_draw_dungeon(unsigned int *tileb) { tile_finish_dngn(tileb, you.x_pos, you.y_pos); - TileDrawDungeon(tileb); + TileDrawDungeon(tileb); } #define swapint(a, b) {int tmp = a; a = b; b = tmp;} @@ -4091,7 +4091,7 @@ static int _item_unid_type(const item_def &item) return 1; else return 0; - + case OBJ_SCROLLS: id0 = id[ IDTYPE_SCROLLS ][s]; break; @@ -4107,11 +4107,11 @@ static int _item_unid_type(const item_def &item) case OBJ_JEWELLERY: id0 = id[ IDTYPE_JEWELLERY ][s]; break; - + default: return 0; } - + if (id0 == ID_TRIED_TYPE) return 2; else if (id0 != ID_KNOWN_TYPE) @@ -4127,7 +4127,7 @@ static int _pack_floor_item(int *idx, int *flag, int *isort, int max) static int isort_weapon2[NUM_WEAPONS]; static int isort_armour2[NUM_ARMOURS]; - static const int isort_weapon[NUM_WEAPONS] = + static const int isort_weapon[NUM_WEAPONS] = { WPN_WHIP, WPN_CLUB, WPN_HAMMER, WPN_MACE, WPN_FLAIL, WPN_DEMON_WHIP, @@ -4149,13 +4149,13 @@ static int _pack_floor_item(int *idx, int *flag, int *isort, int max) WPN_SLING, WPN_BOW, WPN_CROSSBOW, WPN_HAND_CROSSBOW }; - static const int isort_armour[NUM_ARMOURS] = + static const int isort_armour[NUM_ARMOURS] = { - ARM_ROBE, + ARM_ROBE, ARM_ANIMAL_SKIN, ARM_LEATHER_ARMOUR, ARM_TROLL_LEATHER_ARMOUR, - ARM_RING_MAIL, ARM_SCALE_MAIL, ARM_CHAIN_MAIL, + ARM_RING_MAIL, ARM_SCALE_MAIL, ARM_CHAIN_MAIL, ARM_SPLINT_MAIL, ARM_BANDED_MAIL, ARM_PLATE_MAIL, ARM_CRYSTAL_PLATE_MAIL, ARM_SWAMP_DRAGON_ARMOUR, @@ -4180,7 +4180,7 @@ static int _pack_floor_item(int *idx, int *flag, int *isort, int max) for (int i = 0; i < NUM_WEAPONS; i++) isort_weapon2[isort_weapon[i]] = i; - + for (int i = 0; i < NUM_ARMOURS; i++) isort_armour2[isort_armour[i]] = i; @@ -4342,10 +4342,10 @@ void tile_draw_inv(int flag) } int n = 0; - + // item.base_type <-> char conversion table const static char *obj_syms = ")([/%#?=!#+\\0}x"; - + for (int i = 0; i < (int)strlen(item_chars); i++) { int top = n; diff --git a/crawl-ref/source/tile2.cc b/crawl-ref/source/tile2.cc index 64d5227eee..75f8f07ddc 100644 --- a/crawl-ref/source/tile2.cc +++ b/crawl-ref/source/tile2.cc @@ -93,11 +93,11 @@ int itemlist_idx[MAX_ITEMLIST]; char itemlist_key[MAX_ITEMLIST]; int itemlist_iflag[MAX_ITEMLIST]; int itemlist_flag = -1; -int itemlist_n=0; +int itemlist_n = 0; -static int wall_flavors = 0; -static int floor_flavors = 0; -static int special_flavors = 0; +static int wall_flavors = 0; +static int floor_flavors = 0; +static int special_flavors = 0; static int wall_tile_idx = 0; static int floor_tile_idx = 0; static int special_tile_idx = 0; @@ -444,7 +444,7 @@ static int _tcache_find_id_normal(int kind, int *fg, int *bg, int *is_new) tile_cache *tc = tcache[kind]; tile_cache *tc0 = &tc[tcache_head[kind_n_hash]]; - *is_new=0; + *is_new = 0; while (true) { @@ -529,13 +529,17 @@ void _tcache_overlay_player(img_type img, int dx, int dy, int part, int idx, int wx = TILE_X/nx; int wy = TILE_Y/ny; - if(!idx)return; - idx--; + if (!idx) + return; + idx--; tidx += idx/(nx*ny); - if (oy+wy > ymax) wy -= oy + wy - ymax; - if (wy<=0) return; + if (oy+wy > ymax) + wy -= oy + wy - ymax; + + if (wy <= 0) + return; xs = (tidx % TILEP_PER_ROW)*TILE_X; ys = (tidx / TILEP_PER_ROW)*TILE_Y; @@ -569,7 +573,7 @@ void _register_tile_mask(int tile, int region, int *copy, x0 = (tile % TILE_PER_ROW) * TILE_X; y0 = (tile / TILE_PER_ROW) * TILE_Y; - if (*copy!=0) + if (*copy != 0) memset(mask, 0, ux*uy); if (*copy == 2) @@ -578,13 +582,11 @@ void _register_tile_mask(int tile, int region, int *copy, ux = wx; for (x = 0; x < wx; x++) - { for (y = 0; y < wy; y++) { if (!ImgIsTransparentAt(src, x0+sx+x, y0+sy+y)) mask[(y+oy) * ux + (x+ox)] = 1; } - } } else { @@ -1493,7 +1495,7 @@ static bool _draw_doll(img_type img, dolls_data *doll, bool force_redraw = false _tcache_overlay_player(img, 0, 0, TILEP_PART_SHADOW, tile, TILE_Y, &c); } - else if(parts2[p] && flags[p]) + else if (parts2[p] && flags[p]) _tcache_overlay_player(img, 0, 0, p, parts2[p], ymax, &c); } return true; diff --git a/crawl-ref/source/travel.cc b/crawl-ref/source/travel.cc index d393a829c7..b73b49ecc2 100644 --- a/crawl-ref/source/travel.cc +++ b/crawl-ref/source/travel.cc @@ -77,7 +77,7 @@ enum IntertravelDestination TravelCache travel_cache; -// Tracks the distance between the target location on the target level and the +// Tracks the distance between the target location on the target level and the // stairs on the level. static std::vector curr_stairs; @@ -151,7 +151,7 @@ inline int feature_traverse_cost(dungeon_feature_type feature) return 2; else if (grid_is_trap(feature)) return 3; - + return 1; } @@ -196,7 +196,7 @@ const char *trap_name(int x, int y) { if (!traps_inited) init_traps(); - + const int ti = curr_traps[x][y]; if (ti != -1) { @@ -258,7 +258,7 @@ static void tile_exclude_gmap_update(const coord_def p) if (in_bounds(coord_def(px,py))) GmapUpdate(px, py, env.map[px][py].glyph(), true); } - + GmapDisplay(p.x,p.y); } #endif @@ -318,7 +318,7 @@ void cycle_exclude_radius(const coord_def &p) case 1 : curr_radius = 4; break; case 4 : curr_radius = LOS_RADIUS; break; } - + #ifdef USE_TILE tile_exclude_gmap_update(p); #endif @@ -352,7 +352,7 @@ void set_exclude(const coord_def &p, int radius) if (!in_bounds(p)) return; - + if (!is_terrain_known(p)) return; @@ -450,11 +450,11 @@ bool is_travelsafe_square(int x, int y, bool ignore_hostile, if (ignore_hostile && is_reseedable(x, y)) return true; - return (is_traversable(grid) + return (is_traversable(grid) #ifdef CLUA_BINDINGS - || - (is_trap(x, y) && - clua.callbooleanfn(false, "ch_cross_trap", + || + (is_trap(x, y) && + clua.callbooleanfn(false, "ch_cross_trap", "s", trap_name(x, y))) #endif ) @@ -484,12 +484,12 @@ static bool is_safe_move(int x, int y) if (is_trap(x, y) #ifdef CLUA_BINDINGS - && !clua.callbooleanfn(false, "ch_cross_trap", + && !clua.callbooleanfn(false, "ch_cross_trap", "s", trap_name(x, y)) #endif ) return (false); - + const int cloud = env.cgrid[x][y]; if (cloud == EMPTY_CLOUD) return (true); @@ -515,7 +515,7 @@ void init_travel_terrain_check(bool check_race_equip) { // Swimmers get deep water. signed char water = player_likes_water(true)? TRAVERSABLE : IMPASSABLE; - + // If the player has overridden deep water already, we'll respect that. set_pass_feature(DNGN_DEEP_WATER, water); @@ -759,14 +759,14 @@ bool prompt_stop_explore(int es_why) /* * Adds interesting stuf on (x, y) to explore_discoveries. - * + * * NOTE: These are env.map coords, add +1 to get grid coords. */ inline static void check_interesting_square(int x, int y, explore_discoveries &ed) { const coord_def pos(x, y); - + if (ES_item) { if (mgrd(pos) != NON_MONSTER) @@ -781,7 +781,7 @@ inline static void check_interesting_square(int x, int y, ed.found_item(pos, item); } } - + if (igrd(pos) != NON_ITEM) ed.found_item( pos, mitm[ igrd(pos) ] ); } @@ -995,7 +995,7 @@ static void explore_find_target_square() { mpr("Done exploring."); learned_something_new(TUT_DONE_EXPLORE); - } + } else { std::vector inacc; @@ -1003,7 +1003,7 @@ static void explore_find_target_square() inacc.push_back("items"); if (estatus & EST_PARTLY_EXPLORED) inacc.push_back("places"); - + mprf("Partly explored, can't reach some %s.", comma_separated_line( inacc.begin(), @@ -1032,7 +1032,7 @@ void explore_pickup_event(int did_pickup, int tried_pickup) reset_zigzag_info(); } } - + // Greedy explore has no good way to deal with an item that we can't // pick up, so the only thing to do is to stop. if (tried_pickup && you.running == RMODE_EXPLORE_GREEDY) @@ -1065,7 +1065,7 @@ void explore_pickup_event(int did_pickup, int tried_pickup) * Top-level travel control (called from input() in acr.cc). * * travel() is responsible for making the individual moves that constitute - * (interlevel) travel and explore and deciding when travel and explore + * (interlevel) travel and explore and deciding when travel and explore * end. * * Don't call travel() if you.running >= 0. @@ -1076,7 +1076,7 @@ command_type travel() char *move_x = &holdx; char *move_y = &holdy; holdx = holdy = 0; - + command_type result = CMD_NO_CMD; // Abort travel/explore if you're confused or a key was pressed. @@ -1205,18 +1205,18 @@ command_type travel() you.running = runmode; // Turn explore back on // For interlevel travel, we'll want to take the stairs unless - // the interlevel travel specified a destination square and + // the interlevel travel specified a destination square and // we've reached that destination square. else if (runmode == RMODE_INTERLEVEL && (level_target.p.pos != you.pos() || level_target.p.id != level_id::current())) { - if (last_stair.depth != -1 - && last_stair == level_id::current()) + if (last_stair.depth != -1 + && last_stair == level_id::current()) { // We're trying to take the same stairs again. Baaad. - // We don't directly call stop_running() because + // We don't directly call stop_running() because // you.running is probably 0, and stop_running() won't // notify Lua hooks if you.running == 0. you.running = runmode; @@ -1238,7 +1238,7 @@ command_type travel() return (CMD_NO_CMD); } } - + you.running = RMODE_INTERLEVEL; result = trans_negotiate_stairs(); @@ -1249,7 +1249,7 @@ command_type travel() last_stair = level_id::current(); // This is important, else we'll probably stop traveling - // the moment we clear the stairs. That's because the + // the moment we clear the stairs. That's because the // (running.x, running.y) destination will no longer be // valid on the new level. Setting running.x to zero forces // us to recalculate our travel target next turn (see @@ -1451,7 +1451,7 @@ coord_def travel_pathfind::pathfind(run_mode_type rmode) { if (rmode == RMODE_INTERLEVEL) rmode = RMODE_TRAVEL; - + runmode = rmode; // Check whether species or levitation permits travel through terrain such @@ -1465,7 +1465,7 @@ coord_def travel_pathfind::pathfind(run_mode_type rmode) ls = StashTrack.find_current_level(); next_travel_move.reset(); - + // For greedy explore, keep track of the closest unexplored territory and // the closest greedy square. Exploring to the nearest (unexplored / greedy) // square is easier, but it produces unintuitive explore behaviour where @@ -1479,12 +1479,12 @@ coord_def travel_pathfind::pathfind(run_mode_type rmode) // explore to favour unexplored territory over picking up items. For the // most natural greedy explore behaviour, explore_item_greed should be set // to 10 or more. - // + // unexplored_place = greedy_place = coord_def(0, 0); unexplored_dist = greedy_dist = UNFOUND_DIST; refdist = Options.explore_item_greed > 0? &unexplored_dist: &greedy_dist; - + // Abort run if we're trying to go someplace evil. Travel to traps is // specifically allowed here if the player insists on it. if (!floodout @@ -1511,7 +1511,7 @@ coord_def travel_pathfind::pathfind(run_mode_type rmode) // Which index of the circumference array are we currently looking at? circ_index = 0; - + ignore_hostile = false; // Set the seed point @@ -1528,7 +1528,7 @@ coord_def travel_pathfind::pathfind(run_mode_type rmode) if (path_examine_point(circumference[circ_index][i])) { return (runmode == RMODE_TRAVEL? travel_move() - : explore_target()); + : explore_target()); } } @@ -1548,7 +1548,7 @@ coord_def travel_pathfind::pathfind(run_mode_type rmode) } if (double_flood - && !ignore_hostile + && !ignore_hostile && !reseed_points.empty()) { // Reseed here @@ -1575,7 +1575,7 @@ coord_def travel_pathfind::pathfind(run_mode_type rmode) } return (rmode == RMODE_TRAVEL? travel_move() - : explore_target()); + : explore_target()); } bool travel_pathfind::square_slows_movement(const coord_def &c) @@ -1630,7 +1630,7 @@ bool travel_pathfind::path_flood(const coord_def &c, const coord_def &dc) unexplored_dist = traveled_distance; return (true); } - + if (unexplored_dist == UNFOUND_DIST) { unexplored_place = c; @@ -1661,18 +1661,18 @@ bool travel_pathfind::path_flood(const coord_def &c, const coord_def &dc) else unexplored_dist = INFINITE_DIST; } - + // greedy_dist is only ever set in greedy-explore so this check // implies greedy-explore. if (unexplored_dist != UNFOUND_DIST && greedy_dist != UNFOUND_DIST) return (true); } - if (dc != dest && !is_travelsafe_square(dc.x, dc.y, ignore_hostile)) + if (dc != dest && !is_travelsafe_square(dc.x, dc.y, ignore_hostile)) { - // This point is not okay to travel on, but if this is a + // This point is not okay to travel on, but if this is a // trap, we'll want to put it on the feature vector anyway. - if (is_reseedable(dc.x, dc.y) + if (is_reseedable(dc.x, dc.y) && !point_distance[dc.x][dc.y] && dc != start) { @@ -1687,7 +1687,7 @@ bool travel_pathfind::path_flood(const coord_def &c, const coord_def &dc) // Appropriate mystic number. Nobody else should check // this number, since this square is unsafe for travel. - point_distance[dc.x][dc.y] = + point_distance[dc.x][dc.y] = is_exclude_root(dc) ? PD_EXCLUDED : is_excluded(dc) ? PD_EXCLUDED_RADIUS : PD_TRAP; @@ -1724,7 +1724,7 @@ bool travel_pathfind::path_flood(const coord_def &c, const coord_def &dc) { const int feature = grd(dc); - if (((feature != DNGN_FLOOR + if (((feature != DNGN_FLOOR && feature != DNGN_SHALLOW_WATER && feature != DNGN_DEEP_WATER && feature != DNGN_LAVA) @@ -1780,13 +1780,13 @@ bool travel_pathfind::path_examine_point(const coord_def &c) if (path_flood(c, c + Compass[dir])) return (true); } - + return (false); } ///////////////////////////////////////////////////////////////////////////// -void find_travel_pos(int youx, int youy, +void find_travel_pos(int youx, int youy, char *move_x, char *move_y, std::vector* features) { @@ -1801,7 +1801,7 @@ void find_travel_pos(int youx, int youy, tp.set_feature_vector(features); run_mode_type rmode = move_x && move_y? RMODE_TRAVEL : RMODE_NOT_RUNNING; - + const coord_def dest = tp.pathfind( rmode ); if (dest.x == 0 && dest.y == 0) @@ -1827,7 +1827,7 @@ branch_type find_parent_branch(branch_type br) extern std::map stair_level; -void find_parent_branch(branch_type br, int depth, +void find_parent_branch(branch_type br, int depth, branch_type *pb, int *pd) { *pb = find_parent_branch(br); // Check depth before using *pb. @@ -1837,20 +1837,20 @@ void find_parent_branch(branch_type br, int depth, *pd = stair_level[br].depth; } -// Appends the passed in branch/depth to the given vector, then attempts to +// Appends the passed in branch/depth to the given vector, then attempts to // repeat the operation with the parent branch of the given branch. -// +// // As an example of what it does, assume this dungeon structure // Stairs to lair on D:11 // Stairs to snake pit on lair:5 // // If level 3 of the snake pit is the level we want to track back from, -// we'd call trackback(vec, BRANCH_SNAKE_PIT, 3), and the resulting vector will +// we'd call trackback(vec, BRANCH_SNAKE_PIT, 3), and the resulting vector will // look like: // { BRANCH_SNAKE_PIT, 3 }, { BRANCH_LAIR, 5 }, { BRANCH_MAIN_DUNGEON, 11 } // (Assuming, of course, that the vector started out empty.) // -void trackback(std::vector &vec, +void trackback(std::vector &vec, branch_type branch, int subdepth) { if (subdepth < 1 || subdepth > MAX_LEVELS) return; @@ -1868,13 +1868,13 @@ void trackback(std::vector &vec, } } -void track_intersect(std::vector &cur, +void track_intersect(std::vector &cur, std::vector &targ, level_id *cx) { cx->branch = BRANCH_MAIN_DUNGEON; cx->depth = -1; - + int us = int(cur.size()) - 1, them = int(targ.size()) - 1; for ( ; us >= 0 && them >= 0; us--, them--) @@ -1891,7 +1891,7 @@ void track_intersect(std::vector &cur, } /* - * Returns the number of stairs the player would need to take to go from + * Returns the number of stairs the player would need to take to go from * the 'first' level to the 'second' level. If there's no obvious route between * 'first' and 'second', returns -1. If first == second, returns 0. */ @@ -1926,8 +1926,8 @@ int level_distance(level_id first, level_id second) while (first.branch != intersect.branch) { distance += first.depth; - - find_parent_branch(first.branch, first.depth, + + find_parent_branch(first.branch, first.depth, &first.branch, &first.depth); if (!first.depth) return -1; @@ -1947,7 +1947,7 @@ int level_distance(level_id first, level_id second) } distance += sv[i].depth; } - + return distance; } @@ -1957,7 +1957,7 @@ std::string get_trans_travel_dest(const travel_target &target, { const int branch_id = target.p.id.branch; const char *branch = branches[branch_id].abbrevname; - + if (!branch) return (""); @@ -1998,7 +1998,7 @@ static int get_nearest_level_depth(unsigned char branch) level_id id = level_id::current(); do { - find_parent_branch(id.branch, id.depth, + find_parent_branch(id.branch, id.depth, &id.branch, &id.depth); if (id.depth && id.branch == branch) { @@ -2073,7 +2073,7 @@ static int prompt_travel_branch(int prompt_flags) const bool allow_waypoints = (prompt_flags & TPF_ALLOW_WAYPOINTS); const bool allow_updown = (prompt_flags & TPF_ALLOW_UPDOWN); const bool remember_targ = (prompt_flags & TPF_REMEMBER_TARGET); - + bool waypoint_list = false; const int waycount = allow_waypoints? travel_cache.get_waypoint_count() : 0; @@ -2114,7 +2114,7 @@ static int prompt_travel_branch(int prompt_flags) else if (waycount) segs.push_back("* - list waypoints"); } - + if (!trans_travel_dest.empty() && remember_targ) segs.push_back( make_stringf("Enter - %s", trans_travel_dest.c_str()) ); @@ -2175,7 +2175,7 @@ static int prompt_travel_branch(int prompt_flags) if (msg != "") { msg += "Go there anyway?"; - if(!yesno(msg.c_str())) + if (!yesno(msg.c_str())) return (ID_CANCEL); } #endif @@ -2187,7 +2187,7 @@ static int prompt_travel_branch(int prompt_flags) // Possibly a waypoint number? if ((keyin >= '0' && keyin <= '9') && allow_waypoints) return (-1 - (keyin - '0')); - + return (ID_CANCEL); } } @@ -2284,7 +2284,7 @@ static travel_target parse_travel_target( if (targ.entrance_only && !s.empty()) s = trimmed_string(s.substr(0, epos) + s.substr(epos + ekey.length())); - + if (!s.empty()) targ.p.id.depth = atoi(s.c_str()); @@ -2333,7 +2333,7 @@ static void travel_depth_munge(int munge_method, static travel_target prompt_travel_depth(const level_id &id) { travel_target target = travel_target(level_pos(id), false); - + // Handle one-level branches by not prompting. if (single_level_branch(target.p.id.branch)) return travel_target(level_id(target.p.id.branch, 1)); @@ -2354,7 +2354,7 @@ static travel_target prompt_travel_depth(const level_id &id) if (!response) return parse_travel_target(buf, target); - + if (response == ESCAPE) return travel_target(level_id(BRANCH_MAIN_DUNGEON, 0)); @@ -2367,14 +2367,14 @@ travel_target prompt_translevel_target(int prompt_flags) travel_target target; int branch = prompt_travel_branch(prompt_flags); const bool remember_targ = (prompt_flags & TPF_REMEMBER_TARGET); - + if (branch == ID_CANCEL) return (target); // If user chose to repeat last travel, return that. if (branch == ID_REPEAT) return (level_target); - + if (branch == ID_UP) { target.p = find_up_level(); @@ -2396,7 +2396,7 @@ travel_target prompt_translevel_target(int prompt_flags) travel_cache.travel_to_waypoint(-branch - 1); return target; } - + target.p.id.branch = static_cast(branch); // User's chosen a branch, so now we ask for a level. @@ -2418,7 +2418,7 @@ void start_translevel_travel(const travel_target &pos) { if (!i_feel_safe(true, true)) return; - + if (!can_travel_to(pos.p.id)) { if (you.level_type != LEVEL_DUNGEON) @@ -2433,7 +2433,7 @@ void start_translevel_travel(const travel_target &pos) start_travel(pos.p.pos.x, pos.p.pos.y); return; } - + level_target = pos; if (pos.p.id != level_id::current()) @@ -2505,7 +2505,7 @@ static int target_distance_from(const coord_def &pos) /* * Sets best_stair to the coordinates of the best stair on the player's current * level to take to get to the 'target' level. Should be called with 'distance' - * set to 0, 'stair' set to (you.x_pos, you.y_pos) and 'best_distance' set to + * set to 0, 'stair' set to (you.x_pos, you.y_pos) and 'best_distance' set to * -1. 'cur' should be the player's current level. * * If best_stair remains unchanged when this function returns, there is no @@ -2539,7 +2539,7 @@ static int find_transtravel_stair( const level_id &cur, if (is_excluded( stair, li.get_excludes() )) return (-1); - // If there's no target position on the target level, or we're on the + // If there's no target position on the target level, or we're on the // target, we're home. if (target.pos.x == -1 || target.pos == stair) return distance; @@ -2558,7 +2558,7 @@ static int find_transtravel_stair( const level_id &cur, // for a location on the same level. If that's the case, we can get // the distance off the travel_point_distance matrix. deltadist = travel_point_distance[target.pos.x][target.pos.y]; - if (!deltadist && + if (!deltadist && (stair.x != target.pos.x || stair.y != target.pos.y)) deltadist = -1; } @@ -2610,12 +2610,12 @@ static int find_transtravel_stair( const level_id &cur, // Skip placeholders, since there are no real stairs there. if (!si.can_travel()) continue; - + int deltadist = li.distance_between(this_stair, &si); if (!this_stair) { deltadist = travel_point_distance[si.position.x][si.position.y]; - if (!deltadist && + if (!deltadist && (you.x_pos != si.position.x || you.y_pos != si.position.y)) deltadist = -1; } @@ -2650,7 +2650,7 @@ static int find_transtravel_stair( const level_id &cur, { continue; } - + // We can only short-circuit the stair-following process if we // have no exact target location. If there *is* an exact target // location, we can't follow stairs for which we have incomplete @@ -2678,8 +2678,8 @@ static int find_transtravel_stair( const level_id &cur, { int dist = level_distance(dest.id, target.id); if (dist != -1 && - (dist < best_level_distance || - best_level_distance == -1)) + (dist < best_level_distance || + best_level_distance == -1)) { best_level_distance = dist; closest_level = dest.id; @@ -2690,7 +2690,7 @@ static int find_transtravel_stair( const level_id &cur, if (!dest.is_valid()) continue; - // We need to get the stairs at the new location and set the + // We need to get the stairs at the new location and set the // distance on them as well. LevelInfo &lo = travel_cache.get_level_info(dest.id); if (stair_info *so = lo.get_stair(dest.pos)) @@ -2707,7 +2707,7 @@ static int find_transtravel_stair( const level_id &cur, dist2stair, dest.pos, closest_level, best_level_distance, best_stair, target_has_excludes); - if (newdist != -1 && + if (newdist != -1 && (local_distance == -1 || local_distance > newdist)) { local_distance = newdist; @@ -2725,7 +2725,7 @@ static bool loadlev_populate_stair_distances(const level_pos &target) std::auto_ptr tmp(new crawl_environment(env)); bool loaded = false; - if (travel_load_map(target.id.branch, + if (travel_load_map(target.id.branch, absdungeon_depth(target.id.branch, target.id.depth))) { std::vector old_excludes = curr_excludes; @@ -2735,7 +2735,7 @@ static bool loadlev_populate_stair_distances(const level_pos &target) li.set_level_excludes(); populate_stair_distances(target); - + curr_excludes = old_excludes; loaded = !curr_stairs.empty(); } @@ -2777,7 +2777,7 @@ static bool find_transtravel_square(const level_pos &target, bool verbose) coord_def best_stair(-1, -1); coord_def cur_stair(you.x_pos, you.y_pos); - + level_id closest_level; int best_level_distance = -1; travel_cache.clear_distances(); @@ -2803,7 +2803,7 @@ static bool find_transtravel_square(const level_pos &target, bool verbose) int current_dist = level_distance(current, target.id); level_pos newlev; newlev.id = closest_level; - if (newlev.id != target.id + if (newlev.id != target.id && (current_dist == -1 || best_level_distance < current_dist)) return find_transtravel_square(newlev, verbose); } @@ -2836,7 +2836,7 @@ void start_travel(int x, int y) you.running.x = x; you.running.y = y; level_target = level_pos(level_id::current(), coord_def(x, y)); - + if (!can_travel_interlevel()) { // Start running @@ -2853,13 +2853,13 @@ void start_explore(bool grab_items) { if (Options.tut_explored) Options.tut_explored = 0; - + if (you.level_type == LEVEL_LABYRINTH || you.level_type == LEVEL_ABYSS) { mpr("It would help if you knew where you were, first."); return; } - + if (!i_feel_safe(true, true)) return; @@ -2872,7 +2872,7 @@ void start_explore(bool grab_items) more(); you.running = RMODE_EXPLORE; } - + // Clone shadow array off map mapshadow = env.map; @@ -3000,7 +3000,7 @@ level_id level_id::parse_level_id(const std::string &s) throw (std::string) depth.empty()? 1 : depth == "$" ? branches[br].depth : atoi(depth.c_str()); - + if (dep < 0 || dep > branches[br].depth) throw make_stringf("Invalid depth for %s in spec \"%s\"", branch.c_str(), s.c_str()); @@ -3108,7 +3108,7 @@ void LevelInfo::update_stair_distances() { // For each stair, we need to ask travel to populate the distance // array. - find_travel_pos(stairs[s].position.x, stairs[s].position.y, + find_travel_pos(stairs[s].position.x, stairs[s].position.y, NULL, NULL, NULL); for (int other = 0; other < end; ++other) @@ -3260,7 +3260,7 @@ void LevelInfo::correct_stair_list(const std::vector &s) { if (stairs[i].type != stair_info::PHYSICAL) continue; - + bool found = false; for (int j = s.size() - 1; j >= 0; --j) { @@ -3300,7 +3300,7 @@ void LevelInfo::correct_stair_list(const std::vector &s) && travel_hell_entry.is_valid()) si.destination = travel_hell_entry; - // We don't know where on the next level these stairs go to, but + // We don't know where on the next level these stairs go to, but // that can't be helped. That information will have to be filled // in whenever the player takes these stairs. stairs.push_back(si); @@ -3318,11 +3318,11 @@ void LevelInfo::resize_stair_distances() { const int nstairs = stairs.size(); stair_distances.reserve( nstairs * nstairs ); - stair_distances.resize( nstairs * nstairs, 0 ); + stair_distances.resize( nstairs * nstairs, 0 ); } -int LevelInfo::distance_between(const stair_info *s1, const stair_info *s2) - const +int LevelInfo::distance_between(const stair_info *s1, const stair_info *s2) + const { if (!s1 || !s2) return 0; if (s1 == s2) return 0; @@ -3345,7 +3345,7 @@ void LevelInfo::get_stairs(std::vector &st) if (((x == you.x_pos && y == you.y_pos) || envc) - && is_travelable_stair(grid) + && is_travelable_stair(grid) && (is_terrain_seen(x, y) || !is_branch_stair(x, y))) { // Convert to grid coords, because that's what we use @@ -3480,13 +3480,13 @@ void TravelCache::list_waypoints() const std::string dest; char choice[50]; int count = 0; - + for (int i = 0; i < TRAVEL_WAYPOINT_COUNT; ++i) { if (waypoints[i].id.depth == -1) continue; dest = get_trans_travel_dest(waypoints[i], false, true); - + snprintf(choice, sizeof choice, "(%d) %-8s", i, dest.c_str()); line += choice; if (!(++count % 5)) @@ -3530,7 +3530,7 @@ void TravelCache::delete_waypoint() { if (!get_waypoint_count()) return; - + while (get_waypoint_count()) { mesclr(); @@ -3573,7 +3573,7 @@ void TravelCache::add_waypoint(int x, int y) mpr("Sorry, you can't set a waypoint here."); return; } - + mesclr(); const bool waypoints_exist = get_waypoint_count(); @@ -3582,10 +3582,10 @@ void TravelCache::add_waypoint(int x, int y) mpr("Existing waypoints:"); list_waypoints(); } - + mprf(MSGCH_PROMPT, "Assign waypoint to what number? (0-9%s) ", waypoints_exist? ", D - delete waypoint" : ""); - + int keyin = tolower(get_ch()); if (waypoints_exist && keyin == 'd') @@ -3593,7 +3593,7 @@ void TravelCache::add_waypoint(int x, int y) delete_waypoint(); return; } - + if (keyin < '0' || keyin > '9') return; @@ -3652,7 +3652,7 @@ void TravelCache::save(writer& outf) const if (i->first.level_type == LEVEL_DUNGEON) ++level_count; } - + // Write level count: marshallShort(outf, level_count); @@ -3771,7 +3771,7 @@ void runrest::initialise(int dir, int mode) // Record the direction and starting tile type for later reference: set_run_check( 0, left ); set_run_check( 1, dir ); - set_run_check( 2, right ); + set_run_check( 2, right ); } if (runmode == RMODE_REST_DURATION) @@ -3910,7 +3910,7 @@ void runrest::check_mp() && you.magic_points > mp) { mpr("Magic restored."); - stop(); + stop(); } } @@ -3998,7 +3998,7 @@ void explore_discoveries::add_item(const item_def &i) item_def copy = i; copy.quantity = 1; const std::string cname = copy.name(DESC_PLAIN); - + // Try to find something to stack it with, stacking by name. for (int j = 0, size = items.size(); j < size; ++j) { @@ -4064,10 +4064,10 @@ template void explore_discoveries::say_any( mprf(stub, number_in_words(coll.size()).c_str()); return; } - + const std::string message = "Found " + comma_separated_line(coll.begin(), coll.end()) + "."; - + if ((int) message.length() >= get_number_of_cols()) mprf(stub, number_in_words(coll.size()).c_str()); else @@ -4081,7 +4081,7 @@ std::vector explore_discoveries::apply_quantities( { " leading ", " back to ", " to ", " of ", " in ", NULL }; - + std::vector things; for (int i = 0, size = v.size(); i < size; ++i) { diff --git a/crawl-ref/source/view.cc b/crawl-ref/source/view.cc index eb301e6f91..c44d007c07 100644 --- a/crawl-ref/source/view.cc +++ b/crawl-ref/source/view.cc @@ -4984,7 +4984,9 @@ class _inline_layout : public _layout bool _init() { // x: View gets leftover; then mlist; then hud gutter - if (leftover_x() < 0) return false; + if (leftover_x() < 0) + return false; + _increment(viewsz.x, leftover_x(), Options.view_max_width); if ((viewsz.x % 2) != 1) --viewsz.x; mlistsz.x = hudsz.x; @@ -4997,7 +4999,9 @@ class _inline_layout : public _layout // mlist tries to get at least its minimum // msg expands as much as it wants // mlist gets any leftovers - if (leftover_y() < 0) { return false; } + if (leftover_y() < 0) + return false; + _increment(viewsz.y, leftover_leftcol_y(), Options.view_max_height); if ((viewsz.y % 2) != 1) --viewsz.y; if (Options.classic_hud) -- cgit v1.2.3-54-g00ecf