diff options
author | j-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-04-15 13:17:04 +0000 |
---|---|---|
committer | j-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-04-15 13:17:04 +0000 |
commit | 961af9991a452fe8ae5abe186a93df67d7169239 (patch) | |
tree | ac77ca2c7664faa6cfe17f9d342bd6afe32ee35f | |
parent | 83a88e5198b9b3c71123164d315d0fd94c4101be (diff) | |
download | crawl-ref-961af9991a452fe8ae5abe186a93df67d7169239.tar.gz crawl-ref-961af9991a452fe8ae5abe186a93df67d7169239.zip |
Another one of those pesky spacing changes.
One of these days Crawl *will* win the Cleanest Code Championship,
just you wait... :p
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@4242 c06c8d41-db1a-0410-9941-cceddc491573
-rw-r--r-- | crawl-ref/source/command.cc | 63 | ||||
-rw-r--r-- | crawl-ref/source/describe.cc | 2 | ||||
-rw-r--r-- | crawl-ref/source/files.cc | 112 | ||||
-rw-r--r-- | crawl-ref/source/guic-win.cc | 377 | ||||
-rw-r--r-- | crawl-ref/source/guic-x11.cc | 645 | ||||
-rw-r--r-- | crawl-ref/source/guic.cc | 69 | ||||
-rw-r--r-- | crawl-ref/source/items.cc | 6 | ||||
-rw-r--r-- | crawl-ref/source/libw32c.cc | 35 | ||||
-rw-r--r-- | crawl-ref/source/libwt.cc | 4 | ||||
-rw-r--r-- | crawl-ref/source/macro.cc | 182 | ||||
-rw-r--r-- | crawl-ref/source/message.cc | 36 | ||||
-rw-r--r-- | crawl-ref/source/monplace.cc | 6 | ||||
-rw-r--r-- | crawl-ref/source/mstuff2.cc | 4 | ||||
-rw-r--r-- | crawl-ref/source/output.cc | 34 | ||||
-rw-r--r-- | crawl-ref/source/stuff.cc | 4 | ||||
-rw-r--r-- | crawl-ref/source/tags.cc | 12 | ||||
-rw-r--r-- | crawl-ref/source/tile2.cc | 94 |
17 files changed, 867 insertions, 818 deletions
diff --git a/crawl-ref/source/command.cc b/crawl-ref/source/command.cc index 4319b76850..0c3e90c297 100644 --- a/crawl-ref/source/command.cc +++ b/crawl-ref/source/command.cc @@ -71,7 +71,7 @@ static const char *features[] = { #ifdef WIZARD "Wizard mode", #endif - + #if defined(REGEX_POSIX) "POSIX regexps", #elif defined(REGEX_PCRE) @@ -125,7 +125,7 @@ void swap_inv_slots(int from_slot, int to_slot, bool verbose) item_def tmp = you.inv[to_slot]; you.inv[to_slot] = you.inv[from_slot]; you.inv[from_slot] = tmp; - + // slot switching tmp.slot = you.inv[to_slot].slot; you.inv[to_slot].slot = you.inv[from_slot].slot; @@ -177,10 +177,10 @@ static void _adjust_item(void) mpr(you.inv[from_slot].name(DESC_INVENTORY_EQUIP).c_str()); to_slot = prompt_invent_item( - "Adjust to which letter?", - MT_INVLIST, - -1, - false, + "Adjust to which letter?", + MT_INVLIST, + -1, + false, false ); if (to_slot == PROMPT_ABORT) { @@ -211,7 +211,7 @@ static void adjust_spells(void) if (keyin == '?' || keyin == '*') keyin = list_spells(); } - + if ( !isalpha(keyin) ) { canned_msg( MSG_OK ); @@ -319,9 +319,9 @@ static void adjust_ability(void) << std::endl; const int index1 = letter_to_index(talents[selected].hotkey); - + msg::streams(MSGCH_PROMPT) << "Adjust to which letter?" << std::endl; - + const int keyin = get_ch(); if ( !isalpha(keyin) ) @@ -351,7 +351,7 @@ static void adjust_ability(void) break; } } - + if (!printed_message) msg::stream << "Moving to: " << static_cast<char>(keyin) << " - " @@ -365,10 +365,10 @@ static void adjust_ability(void) } void list_armour() -{ +{ std::ostringstream estr; for (int i = EQ_CLOAK; i <= EQ_BODY_ARMOUR; i++) - { + { const int armour_id = you.equip[i]; int colour = MSGCOL_BLACK; @@ -569,7 +569,7 @@ static const char *targeting_help_1 = "<h>Targeting (zapping wands, casting spells, etc.):\n" "The keys from examine surroundings also work here.\n" "In addition, you can use:\n" - "<w>.</w> : fire at target (<w>Enter</w>, <w>Del</w>, <w>Space</w>)\n" + "<w>.</w> : fire at target (<w>Enter</w>, <w>Del</w>, <w>Space</w>)\n" "<w>!</w> : fire at target and stop there (may hit submerged creatures)\n" "<w>p</w> : fire at Previous target (also <w>f</w>)\n" "<w>:</w> : show/hide beam path\n" @@ -589,7 +589,7 @@ static const char *targeting_help_2 = "<w>)</w> : cycle to previous suitable missile.\n" "<w>i</w> : choose from inventory.\n" ; - + // Add the contents of the file fp to the scroller menu m. // If first_hotkey is nonzero, that will be the hotkey for the @@ -609,7 +609,7 @@ static void add_file_to_scroller(FILE* fp, formatted_scroller& m, for ( int i = 0; i < get_number_of_lines(); ++i ) m.add_entry(new MenuEntry(std::string())); m.add_entry(new MenuEntry(std::string(), MEL_TITLE)); - + while (fgets(buf, sizeof buf, fp)) { MenuEntry* me = new MenuEntry(buf); @@ -1036,7 +1036,7 @@ static bool find_description(bool &again, std::string& error_inout) want_regex = false; want_sort = false; doing_branches = true; - + break; default: @@ -1246,7 +1246,7 @@ static int keyhelp_keyfilter(int ch) { switch (ch) { - case ':': + case ':': // If the game has begun, show notes. if (crawl_state.need_save) { @@ -1255,24 +1255,25 @@ static int keyhelp_keyfilter(int ch) } break; - case '/': - { + case '/': + { bool again = false; std::string error; - do { - if (find_description(again, error)) - if ( getch() == 0 ) - getch(); + do + { + // resets 'again' + if (find_description(again, error) && getch() == 0 ) + getch(); + if (again) - { mesclr(true); - } - } while(again); + } + while (again); viewwindow(true, false); return -1; - } + } } return ch; } @@ -1310,7 +1311,7 @@ std::string help_highlighter::get_species_key() const if (player_genus(GENPC_DRACONIAN)) strip_tag(result, species_name(you.species, you.experience_level, true)); - + result += " "; return (result); } @@ -1389,7 +1390,7 @@ static void show_keyhelp_menu(const std::vector<formatted_string> &lines, "<w>5</w>. List of Enchantments\n" "<w>6</w>. Inscriptions\n", true, true, cmdhelp_textfilter); - + std::vector<formatted_string> blines = cols.formatted_lines(); unsigned i; for (i = 0; i < blines.size(); ++i ) @@ -1724,7 +1725,7 @@ void list_commands(bool wizard, int hotkey, bool do_redraw_screen) add_formatted_tutorial_help(cols); else add_formatted_keyhelp(cols); - + show_keyhelp_menu(cols.formatted_lines(), true, false, hotkey); if (do_redraw_screen) @@ -1770,7 +1771,7 @@ static void list_wizard_commands() "S : set skill to level\n", true, true); - cols.add_formatted(1, + cols.add_formatted(1, "t : tweak object properties\n" "T : make a trap\n" "v : show gold value of an item\n" diff --git a/crawl-ref/source/describe.cc b/crawl-ref/source/describe.cc index 4dd81fc3cf..6265445d16 100644 --- a/crawl-ref/source/describe.cc +++ b/crawl-ref/source/describe.cc @@ -102,7 +102,7 @@ void print_description( const std::string &d ) textcolor(LIGHTGREY); - while(currentPos < d.length()) + while (currentPos < d.length()) { if (currentPos != 0) cgotoxy(1, wherey() + 1); diff --git a/crawl-ref/source/files.cc b/crawl-ref/source/files.cc index b0626e786b..020fd0a31c 100644 --- a/crawl-ref/source/files.cc +++ b/crawl-ref/source/files.cc @@ -135,25 +135,25 @@ static void redraw_all(void) REDRAW_LINE_1_MASK | REDRAW_LINE_2_MASK | REDRAW_LINE_3_MASK; } -static bool determine_version( FILE *restoreFile, +static bool determine_version( FILE *restoreFile, char &majorVersion, char &minorVersion ); -static void restore_version( FILE *restoreFile, +static void restore_version( FILE *restoreFile, char majorVersion, char minorVersion ); -static bool determine_level_version( FILE *levelFile, +static bool determine_level_version( FILE *levelFile, char &majorVersion, char &minorVersion ); -static void restore_level_version( FILE *levelFile, +static void restore_level_version( FILE *levelFile, char majorVersion, char minorVersion ); -static bool determine_ghost_version( FILE *ghostFile, +static bool determine_ghost_version( FILE *ghostFile, char &majorVersion, char &minorVersion ); -static void restore_ghost_version( FILE *ghostFile, +static void restore_ghost_version( FILE *ghostFile, char majorVersion, char minorVersion ); -static void restore_tagged_file( FILE *restoreFile, int fileType, +static void restore_tagged_file( FILE *restoreFile, int fileType, char minorVersion ); static void load_ghost(); @@ -181,7 +181,7 @@ static bool is_uid_file(const std::string &name, const std::string &ext) save_suffix = save_suffix.substr(Options.save_dir.length()); std::string::size_type suffix_pos = name.find(save_suffix); - return (suffix_pos != std::string::npos + return (suffix_pos != std::string::npos && suffix_pos == name.length() - save_suffix.length() && suffix_pos != 0); } @@ -216,7 +216,7 @@ player_save_info read_character_info(const std::string &savefile) const player backup(you); restore_tagged_file(charf, TAGTYPE_PLAYER_NAME, minorVersion); - + fromfile = you; you.copy_from(backup); } @@ -348,7 +348,7 @@ static bool create_dirs(const std::string &dir) { std::string sep = " "; sep[0] = FILE_SEPARATOR; - std::vector<std::string> segments = + std::vector<std::string> segments = split_string( sep.c_str(), dir, @@ -379,10 +379,10 @@ std::string datafile_path(std::string basename, #if FILE_SEPARATOR != '/' basename = replace_all_of(basename, "/", std::string(1, FILE_SEPARATOR)); #endif - + if (test_base_path && file_exists(basename)) return (basename); - + std::string cdir = !SysEnv.crawl_dir.empty()? SysEnv.crawl_dir : ""; const std::string rawbases[] = { @@ -435,7 +435,7 @@ std::string datafile_path(std::string basename, // Die horribly. if (croak_on_fail) - end(1, false, "Cannot find data file '%s' anywhere, aborting\n", + end(1, false, "Cannot find data file '%s' anywhere, aborting\n", basename.c_str()); return (""); @@ -467,7 +467,7 @@ bool check_dir(const std::string &whatdir, std::string &dir, bool silent) return (true); } -// Given a simple (relative) name of a save file, returns the full path of +// Given a simple (relative) name of a save file, returns the full path of // the file in the Crawl saves directory. You can use path segments in // shortpath (separated by /) and get_savedir_path will canonicalise them // to the platform's native file separator. @@ -503,7 +503,7 @@ std::vector<player_save_info> find_saved_characters() if (!is_packed_save(filename)) continue; - std::string basename = + std::string basename = filename.substr( 0, filename.length() - strlen(PACKAGE_SUFFIX)); @@ -549,7 +549,7 @@ std::string get_savedir() } std::string get_savedir_filename(const std::string &prefix, - const std::string &suffix, + const std::string &suffix, const std::string &extension, bool suppress_uid) { @@ -637,7 +637,7 @@ static void write_version( FILE *dataFile, int majorVersion, int minorVersion, // with the first 16-bits of the Crawl version, and the following // 7 16-bit words set to 0. marshallShort(outf, GHOST_SIGNATURE); - + // Write the three remaining 32-bit words of padding. for (int i = 0; i < 3; ++i) marshallLong(outf, 0); @@ -655,12 +655,10 @@ static void write_tagged_file( FILE *dataFile, char majorVersion, write_version( dataFile, majorVersion, minorVersion, extended_version ); // all other tags - for(int i=1; i<NUM_TAGS; i++) + for (int i = 1; i < NUM_TAGS; i++) { if (tags[i] == 1) - { tag_write((tag_type)i, dataFile); - } } } @@ -684,11 +682,11 @@ bool travel_load_map( branch_type branch, int absdepth ) fclose(levelFile); return false; } - + tag_read(levelFile, minorVersion); fclose( levelFile ); - + return true; } @@ -718,7 +716,7 @@ static void place_player_on_stair(branch_type old_branch, bool find_first = true; // Order is important here: - if (you.level_type == LEVEL_DUNGEON + if (you.level_type == LEVEL_DUNGEON && old_branch == BRANCH_VESTIBULE_OF_HELL && stair_taken == DNGN_STONE_STAIRS_UP_I) { @@ -741,13 +739,13 @@ static void place_player_on_stair(branch_type old_branch, // the vestibule and labyrith always start from this stair stair_taken = DNGN_STONE_STAIRS_UP_I; } - else if (stair_taken >= DNGN_STONE_STAIRS_DOWN_I + else if (stair_taken >= DNGN_STONE_STAIRS_DOWN_I && stair_taken <= DNGN_ESCAPE_HATCH_DOWN) { // look for coresponding up stair stair_taken += (DNGN_STONE_STAIRS_UP_I - DNGN_STONE_STAIRS_DOWN_I); } - else if (stair_taken >= DNGN_STONE_STAIRS_UP_I + else if (stair_taken >= DNGN_STONE_STAIRS_UP_I && stair_taken <= DNGN_ESCAPE_HATCH_UP) { // look for coresponding down stair @@ -763,11 +761,11 @@ static void place_player_on_stair(branch_type old_branch, else if (stair_taken >= DNGN_ENTER_FIRST_BRANCH && stair_taken < DNGN_RETURN_FROM_FIRST_BRANCH) { - // find exit staircase from subdungeon when entering + // find exit staircase from subdungeon when entering stair_taken += (DNGN_RETURN_FROM_FIRST_BRANCH - DNGN_ENTER_FIRST_BRANCH); } - else if (stair_taken >= DNGN_ENTER_DIS + else if (stair_taken >= DNGN_ENTER_DIS && stair_taken <= DNGN_TRANSIT_PANDEMONIUM) { // when entering a hell or pandemonium @@ -792,7 +790,7 @@ static void place_player_on_stair(branch_type old_branch, stair_taken = DNGN_FLOOR; find_first = false; } - + const coord_def where_to_go = dgn_find_nearby_stair(static_cast<dungeon_feature_type>(stair_taken), you.pos(), find_first); @@ -834,11 +832,11 @@ static bool grab_follower_at(const coord_def &pos) { if (pos == you.pos()) return (false); - + monsters *fmenv = monster_at(pos); if (!fmenv || !fmenv->alive()) return (false); - + // monster has to be already tagged in order to follow: if (!testbits( fmenv->flags, MF_TAKING_STAIRS )) return (false); @@ -922,7 +920,7 @@ static void do_lost_items(level_area_type old_level_type) { if (old_level_type == LEVEL_DUNGEON) return; - + for (int i = 0; i < MAX_ITEMS; i++) { item_def& item(mitm[i]); @@ -952,7 +950,7 @@ bool load( dungeon_feature_type stair_taken, load_mode_type load_mode, const bool make_changes = (load_mode != LOAD_RESTART_GAME && load_mode != LOAD_VISITOR); - + bool just_created_level = false; std::string cha_fil = make_filename( you.your_name, you.your_level, @@ -1098,7 +1096,7 @@ bool load( dungeon_feature_type stair_taken, load_mode_type load_mode, { if (just_created_level) level_welcome_messages(); - + // Activate markers that want activating, but only when // entering a new level in an existing game. If we're starting // a new game, or reloading an existing game, @@ -1111,9 +1109,9 @@ bool load( dungeon_feature_type stair_taken, load_mode_type load_mode, // Centaurs have difficulty with stairs int timeval = ((you.species != SP_CENTAUR) ? player_movement_speed() - : 15); + : 15); - // new levels have less wary monsters: + // new levels have less wary monsters: if (just_created_level) timeval /= 2; @@ -1215,7 +1213,7 @@ void save_level(int level_saved, level_area_type old_ltype, void save_game(bool leave_game, const char *farewellmsg) { unwind_bool saving_game(crawl_state.saving_game, true); - + /* Stashes */ std::string stashFile = get_savedir_filename( you.your_name, "", "st" ); FILE *stashf = fopen(stashFile.c_str(), "wb"); @@ -1256,7 +1254,7 @@ void save_game(bool leave_game, const char *farewellmsg) fclose(travelf); DO_CHMOD_PRIVATE(travelCacheFile.c_str()); } - + /* notes */ std::string notesFile = get_savedir_filename(you.your_name, "", "nts"); FILE *notesf = fopen(notesFile.c_str(), "wb"); @@ -1269,7 +1267,7 @@ void save_game(bool leave_game, const char *farewellmsg) } /* tutorial */ - + std::string tutorFile = get_savedir_filename(you.your_name, "", "tut"); FILE *tutorf = fopen(tutorFile.c_str(), "wb"); if (tutorf) @@ -1305,7 +1303,7 @@ void save_game(bool leave_game, const char *farewellmsg) std::string basename = get_savedir_filename(you.your_name, "", ""); char cmd_buff[1024]; - snprintf( cmd_buff, sizeof(cmd_buff), + snprintf( cmd_buff, sizeof(cmd_buff), SAVE_PACKAGE_CMD, basename.c_str(), basename.c_str() ); if (system( cmd_buff ) != 0) { @@ -1358,7 +1356,7 @@ void load_ghost(void) if (majorVersion != SAVE_MAJOR_VERSION || minorVersion != GHOST_MINOR_VERSION) { - + fclose(gfile); unlink(cha_fil.c_str()); return; @@ -1397,7 +1395,7 @@ void load_ghost(void) menv[imn].set_ghost(ghosts[0]); menv[imn].ghost_init(); - ghosts.erase(ghosts.begin()); + ghosts.erase(ghosts.begin()); } } @@ -1465,7 +1463,7 @@ void restore_game(void) } /* tutorial */ - + std::string tutorFile = get_savedir_filename(you.your_name, "", "tut"); FILE *tutorf = fopen(tutorFile.c_str(), "rb"); if (tutorf) @@ -1482,7 +1480,7 @@ static void _restore_level(const level_id &original) you.where_are_you = original.branch; you.your_level = original.absdepth(); you.level_type = original.level_type; - + load( DNGN_STONE_STAIRS_DOWN_I, LOAD_VISITOR, you.level_type, you.your_level, you.where_are_you ); } @@ -1507,17 +1505,17 @@ bool apply_to_level(const level_id &level, bool preserve_current, bool (*applicator)()) { ASSERT(is_existing_level(level)); - + const level_id original = level_id::current(); if (level != original) { if (preserve_current) save_level(you.your_level, you.level_type, you.where_are_you); - + you.where_are_you = level.branch; you.your_level = level.absdepth(); you.level_type = level.level_type; - + // Load the dungeon level... load( DNGN_STONE_STAIRS_DOWN_I, LOAD_VISITOR, LEVEL_DUNGEON, original.absdepth(), @@ -1531,7 +1529,7 @@ bool apply_to_level(const level_id &level, bool preserve_current, { // And save it back. save_level(you.your_level, you.level_type, you.where_are_you); - + if (preserve_current) _restore_level(original); } @@ -1556,7 +1554,7 @@ bool apply_to_all_dungeons(bool (*applicator)()) if (!is_existing_level(thislevel)) continue; - + // Don't apply to the original level - already done up top. if (original == thislevel) continue; @@ -1571,7 +1569,7 @@ bool apply_to_all_dungeons(bool (*applicator)()) return success; } -static bool determine_version( FILE *restoreFile, +static bool determine_version( FILE *restoreFile, char &majorVersion, char &minorVersion ) { // read first two bytes. @@ -1589,7 +1587,7 @@ static bool determine_version( FILE *restoreFile, return false; // if it's not 0, no idea } -static void restore_version( FILE *restoreFile, +static void restore_version( FILE *restoreFile, char majorVersion, char minorVersion ) { // assuming the following check can be removed once we can read all @@ -1611,7 +1609,7 @@ static void restore_version( FILE *restoreFile, } // generic v4 restore function -static void restore_tagged_file( FILE *restoreFile, int fileType, +static void restore_tagged_file( FILE *restoreFile, int fileType, char minorVersion ) { char tags[NUM_TAGS]; @@ -1622,7 +1620,7 @@ static void restore_tagged_file( FILE *restoreFile, int fileType, tag_type tt = tag_read(restoreFile, minorVersion); if (tt == TAG_NO_TAG) break; - + tags[tt] = 0; // tag read if (fileType == TAGTYPE_PLAYER_NAME) break; @@ -1636,7 +1634,7 @@ static void restore_tagged_file( FILE *restoreFile, int fileType, } } -static bool determine_level_version( FILE *levelFile, +static bool determine_level_version( FILE *levelFile, char &majorVersion, char &minorVersion ) { // read first two bytes. @@ -1654,7 +1652,7 @@ static bool determine_level_version( FILE *levelFile, return false; // if its not SAVE_MAJOR_VERSION, no idea } -static void restore_level_version( FILE *levelFile, +static void restore_level_version( FILE *levelFile, char majorVersion, char minorVersion ) { // assuming the following check can be removed once we can read all @@ -1676,7 +1674,7 @@ static void restore_level_version( FILE *levelFile, } } -static bool determine_ghost_version( FILE *ghostFile, +static bool determine_ghost_version( FILE *ghostFile, char &majorVersion, char &minorVersion ) { // read first two bytes. @@ -1704,7 +1702,7 @@ static bool determine_ghost_version( FILE *ghostFile, return false; // if its not SAVE_MAJOR_VERSION, no idea! } -static void restore_ghost_version( FILE *ghostFile, +static void restore_ghost_version( FILE *ghostFile, char majorVersion, char minorVersion ) { switch(majorVersion) @@ -1737,7 +1735,7 @@ void save_ghost( bool force ) } ghosts = ghost_demon::find_ghosts(); - + gfile = lk_open("wb", cha_fil); if (gfile == NULL) diff --git a/crawl-ref/source/guic-win.cc b/crawl-ref/source/guic-win.cc index 5d611b712b..834e4eda44 100644 --- a/crawl-ref/source/guic-win.cc +++ b/crawl-ref/source/guic-win.cc @@ -172,31 +172,39 @@ void RegionClass::copy_font(RegionClass *r) void RegionClass::set_std_palette(RGBQUAD *pPal) { int i; - for(i=0;i<256;i++) + for (i = 0; i < 256; i++) { - std_palette[i].rgbRed = pPal[i].rgbRed ; - std_palette[i].rgbGreen = pPal[i].rgbGreen; - std_palette[i].rgbBlue = pPal[i].rgbBlue ; + std_palette[i].rgbRed = pPal[i].rgbRed ; + std_palette[i].rgbGreen = pPal[i].rgbGreen; + std_palette[i].rgbBlue = pPal[i].rgbBlue ; - if ( (pPal[i].rgbRed == 0) - &&(pPal[i].rgbGreen == 0) - &&(pPal[i].rgbBlue == 0) ) + if (pPal[i].rgbRed == 0 + && pPal[i].rgbGreen == 0 + && pPal[i].rgbBlue == 0) + { pix_black = i; + } - if ( (pPal[i].rgbRed == 255) - &&(pPal[i].rgbGreen == 255) - &&(pPal[i].rgbBlue == 255) ) + if (pPal[i].rgbRed == 255 + && pPal[i].rgbGreen == 255 + && pPal[i].rgbBlue == 255) + { pix_white = i; + } - if ( (pPal[i].rgbRed == 255) - &&(pPal[i].rgbGreen == 0 ) - &&(pPal[i].rgbBlue == 255) ) + if (pPal[i].rgbRed == 255 + && pPal[i].rgbGreen == 0 + && pPal[i].rgbBlue == 255) + { pix_magenta = i; + } - if ( (pPal[i].rgbRed == 1) - &&(pPal[i].rgbGreen == 1) - &&(pPal[i].rgbBlue == 1) ) + if (pPal[i].rgbRed == 1 + && pPal[i].rgbGreen == 1 + && pPal[i].rgbBlue == 1) + { pix_rimcolor = i; + } } std_palette[pix_transparent].rgbRed = 0; @@ -219,15 +227,15 @@ void RegionClass::init_backbuf(RGBQUAD *pPal, int ncolor) (sizeof(BITMAPINFO) + 256 * sizeof(RGBQUAD)) ); // set header data - backbuf->pDib->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); - backbuf->pDib->bmiHeader.biPlanes = 1; - backbuf->pDib->bmiHeader.biBitCount = 8; - backbuf->pDib->bmiHeader.biCompression=BI_RGB; - backbuf->pDib->bmiHeader.biSizeImage=0; - backbuf->pDib->bmiHeader.biXPelsPerMeter=0; - backbuf->pDib->bmiHeader.biYPelsPerMeter=0; - backbuf->pDib->bmiHeader.biClrUsed=0; - backbuf->pDib->bmiHeader.biClrImportant=0; + backbuf->pDib->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); + backbuf->pDib->bmiHeader.biPlanes = 1; + backbuf->pDib->bmiHeader.biBitCount = 8; + backbuf->pDib->bmiHeader.biCompression = BI_RGB; + backbuf->pDib->bmiHeader.biSizeImage = 0; + backbuf->pDib->bmiHeader.biXPelsPerMeter = 0; + backbuf->pDib->bmiHeader.biYPelsPerMeter = 0; + backbuf->pDib->bmiHeader.biClrUsed = 0; + backbuf->pDib->bmiHeader.biClrImportant = 0; // set palette data for (i = 0; i < ncolor; i++) @@ -260,8 +268,8 @@ void RegionClass::init_backbuf(RGBQUAD *pPal, int ncolor) ReleaseDC(0, hdc1); } } - backbuf->pDibZero = (backbuf->pDibBits) - + (backbuf->Height -1) * backbuf->Width; + backbuf->pDibZero = (backbuf->pDibBits + + (backbuf->Height -1) * backbuf->Width); } void RegionClass::resize_backbuf() @@ -273,10 +281,10 @@ void RegionClass::resize_backbuf() if (backbuf->hDib != NULL) DeleteObject(backbuf->hDib); // set dimension - backbuf->pDib->bmiHeader.biWidth = mx*dx; - backbuf->pDib->bmiHeader.biHeight = my*dy; - backbuf->Width = mx * dx; - backbuf->Height= my * dy; + backbuf->pDib->bmiHeader.biWidth = mx*dx; + backbuf->pDib->bmiHeader.biHeight = my*dy; + backbuf->Width = mx * dx; + backbuf->Height = my * dy; HDC hdc1 = GetDC(0); HDC hdc2 = GetDC(win->hWnd); @@ -288,8 +296,8 @@ void RegionClass::resize_backbuf() ReleaseDC(win->hWnd, hdc2); ReleaseDC(0, hdc1); - backbuf->pDibZero = (backbuf->pDibBits) - + (backbuf->Height -1) * backbuf->Width; + backbuf->pDibZero = (backbuf->pDibBits + + (backbuf->Height -1) * backbuf->Width); for (i = 0; i< mx*dx*my*dy; i++) *(backbuf->pDibBits + i) = pix_black; @@ -307,20 +315,19 @@ void TileRegionClass::resize_backbuf() void TextRegionClass::init_backbuf() { - /* not use */ + /* not used */ } void TileRegionClass::init_backbuf(RGBQUAD *pPal) { int i; if (!pPal) - RegionClass::init_backbuf(std_palette, 256); + RegionClass::init_backbuf(std_palette, 256); else - RegionClass::init_backbuf(pPal, 256); + RegionClass::init_backbuf(pPal, 256); for (i = 0; i< mx*dx*my*dy; i++) *(backbuf->pDibBits + i) = pix_black; - } void MapRegionClass::init_backbuf() @@ -329,12 +336,12 @@ void MapRegionClass::init_backbuf() RGBQUAD scol[MAX_MAP_COL]; int i; - for (i=0; i< MAX_MAP_COL;i++) + for (i = 0; i < MAX_MAP_COL; i++) { - scol[i].rgbBlue = map_colors[i][2]; - scol[i].rgbGreen = map_colors[i][1]; - scol[i].rgbRed = map_colors[i][0]; - scol[i].rgbReserved = 0; + scol[i].rgbBlue = map_colors[i][2]; + scol[i].rgbGreen = map_colors[i][1]; + scol[i].rgbRed = map_colors[i][0]; + scol[i].rgbReserved = 0; } // just resize @@ -345,10 +352,12 @@ void MapRegionClass::init_backbuf() for (i = 0; i < MAX_MAP_COL; i++) { - if ( (backbuf->pDib->bmiColors[i].rgbRed == 0) - &&(backbuf->pDib->bmiColors[i].rgbGreen == 0) - &&(backbuf->pDib->bmiColors[i].rgbBlue == 0) ) + if (backbuf->pDib->bmiColors[i].rgbRed == 0 + && backbuf->pDib->bmiColors[i].rgbGreen == 0 + && backbuf->pDib->bmiColors[i].rgbBlue == 0) + { black = i; + } } for (i = 0; i< mx*dx*my*dy; i++) @@ -357,19 +366,20 @@ void MapRegionClass::init_backbuf() // defined to object, not to class void TextRegionClass::draw_string(int x, int y, unsigned char *buf, - int len, int col) + int len, int col) { HDC hdc = GetDC(win->hWnd); RECT rc; - rc.left = ox + x * dx; - rc.right = rc.left + len * dx; - rc.top = oy + y * dy; + rc.left = ox + x * dx; + rc.right = rc.left + len * dx; + rc.top = oy + y * dy; rc.bottom = rc.top + dy; + SelectObject(hdc, font); SetBkColor(hdc, term_pix[col>>4]); SetTextColor(hdc, term_pix[col&0x0f]); ExtTextOut(hdc, rc.left, rc.top, ETO_CLIPPED, &rc, - (char *)buf, len, NULL); + (char *)buf, len, NULL); ReleaseDC(win->hWnd, hdc); } @@ -381,20 +391,21 @@ void TextRegionClass::draw_cursor(int x, int y) int cx = x - cx_ofs; int cy = y - cy_ofs; - if(!flag)return; + if (!flag) + return; - hdc =GetDC(win->hWnd); + hdc = GetDC(win->hWnd); SelectObject(hdc, font); - rc.left = ox + cx * dx ; - rc.right = rc.left + (2 * dx); - rc.top = oy + cy * dy; + rc.left = ox + cx * dx ; + rc.right = rc.left + (2 * dx); + rc.top = oy + cy * dy; rc.bottom = rc.top + dy; SetBkMode(hdc, TRANSPARENT); SetTextColor(hdc, term_pix[0x0f]); ExtTextOut(hdc, rc.left, rc.top, ETO_CLIPPED, &rc, - "_ ", 2, NULL); + "_ ", 2, NULL); ReleaseDC(win->hWnd, hdc); } @@ -405,16 +416,17 @@ void TextRegionClass::erase_cursor(){ int adrs = y0 * mx + x0; int col = abuf[adrs]; - if(!flag)return; + if (!flag) + return; RECT rc; - HDC hdc =GetDC(win->hWnd); + HDC hdc = GetDC(win->hWnd); SelectObject(hdc, font); //restore previous cursor cell - rc.left = ox + x0 * dx; - rc.right= rc.left + (2 * dx); - rc.top = oy + y0 * dy; + rc.left = ox + x0 * dx; + rc.right = rc.left + (2 * dx); + rc.top = oy + y0 * dy; rc.bottom = rc.top + dy; unsigned char rchar[3]; @@ -427,14 +439,14 @@ void TextRegionClass::erase_cursor(){ rchar[1] = cbuf[adrs+1]; rchar[2] = '\0'; ExtTextOut(hdc, rc.left, rc.top, ETO_CLIPPED, &rc, - (char *)&rchar, 2, NULL); + (char *)&rchar, 2, NULL); } else #endif { rchar[1] = '\0'; ExtTextOut(hdc, rc.left, rc.top, ETO_CLIPPED, &rc, - (char *)&rchar, 1, NULL); + (char *)&rchar, 1, NULL); } ReleaseDC(win->hWnd, hdc); } @@ -458,9 +470,8 @@ void TileRegionClass::clear() void MapRegionClass::clear() { for (int i = 0; i < mx2*my2; i++) - { - mbuf[i]=PIX_BLACK; - } + mbuf[i] = PIX_BLACK; + RegionClass::clear(); } @@ -468,10 +479,10 @@ void TextRegionClass::clear() { int i; - for (i=0; i<mx*my; i++) + for (i = 0; i < mx*my; i++) { - cbuf[i]=' '; - abuf[i]=0; + cbuf[i] =' '; + abuf[i] =0; } RegionClass::clear(); } @@ -491,26 +502,22 @@ BOOL WinClass::create(const char *name) if ( GetSystemMetrics(SM_CXSCREEN) < (ox + wx) ) ox =0; AdjustWindowRectEx(&rc, - (WS_OVERLAPPED | WS_SYSMENU | - WS_MINIMIZEBOX | WS_CAPTION | - WS_VISIBLE), + (WS_OVERLAPPED | WS_SYSMENU | WS_MINIMIZEBOX + | WS_CAPTION | WS_VISIBLE), false, 0); if (hWnd == NULL) { hWnd = CreateWindowEx(0, "CrawlList",name, - (WS_OVERLAPPED | WS_SYSMENU | - WS_MINIMIZEBOX | WS_CAPTION | - WS_VISIBLE), - ox, oy, //pos - rc.right - rc.left, rc.bottom - rc.top, //size - HWND_DESKTOP, NULL, hInst, NULL); + (WS_OVERLAPPED | WS_SYSMENU | WS_MINIMIZEBOX + | WS_CAPTION | WS_VISIBLE), + ox, oy, //pos + rc.right - rc.left, rc.bottom - rc.top, //size + HWND_DESKTOP, NULL, hInst, NULL); ShowWindow( hWnd, nCmdShow ); } - if( !hWnd ) - { + if ( !hWnd ) return FALSE; - } clear(); return TRUE; @@ -518,8 +525,8 @@ BOOL WinClass::create(const char *name) void WinClass::move() { - SetWindowPos(hWnd, 0, ox, oy, wx, wy, SWP_NOSIZE); - UpdateWindow( hWnd ); + SetWindowPos(hWnd, 0, ox, oy, wx, wy, SWP_NOSIZE); + UpdateWindow( hWnd ); } void WinClass::resize() @@ -531,15 +538,15 @@ void WinClass::resize() rc.bottom = wy; AdjustWindowRectEx(&rc, - (WS_OVERLAPPED | WS_SYSMENU | - WS_MINIMIZEBOX | WS_CAPTION | - WS_VISIBLE), + (WS_OVERLAPPED | WS_SYSMENU | WS_MINIMIZEBOX + | WS_CAPTION | WS_VISIBLE), false, 0); SetWindowPos(hWnd, 0, ox, oy, - rc.right - rc.left, - rc.bottom - rc.top, - SWP_NOMOVE); + rc.right - rc.left, + rc.bottom - rc.top, + SWP_NOMOVE); + UpdateWindow( hWnd ); } @@ -578,30 +585,27 @@ void MapRegionClass::draw_data(unsigned char *buf) int bufx = mx * dx; int bufy = my * dy; - bufx = (bufx+3)/4; - bufx *=4; + bufx = (bufx+3)/4; + bufx *= 4; #define BUF_IDX(x,y, x1, y1) ((x)*dx-(y)*dy*bufx + (x1) - (y1)*bufx) // upper left corner LPBYTE pDibBit0 = backbuf->pDibBits + bufx*(bufy-1); ppix = pDibBit0; - inc_x = dx; + inc_x = dx; inc_x0 = 1; - inc_y = - mx2 * inc_x + BUF_IDX(0, 1, 0, 0); + inc_y = - mx2 * inc_x + BUF_IDX(0, 1, 0, 0); inc_y0 = - dx * inc_x0 + BUF_IDX(0, 0, 0, 1); // erase old markers const int marker_length = 2; for (int j = 0; j < dy * marker_length; j++) - { *(pDibBit0 + BUF_IDX(px, 0, dx/2 + x_margin, j)) = MAP_BLACK; - } + for (int j = 0; j < dx * marker_length; j++) - { *(pDibBit0 + BUF_IDX(0, py, j, dy/2 + y_margin)) = MAP_BLACK; - } force_redraw = true; @@ -618,8 +622,8 @@ void MapRegionClass::draw_data(unsigned char *buf) px = i; py = j; } - if ( (col != get_col(i,j)) || force_redraw || - i < marker_length || j < marker_length) + if ( col != get_col(i,j) || force_redraw + || i < marker_length || j < marker_length) { dpix = ppix; for (int y = 0; y < dy; y++) @@ -640,13 +644,10 @@ void MapRegionClass::draw_data(unsigned char *buf) // draw new markers for (int j = 0; j < dy * marker_length; j++) - { *(pDibBit0 + BUF_IDX(px, 0, dx/2 + x_margin, j)) = MAP_WHITE; - } + for (int j = 0; j < dx * marker_length; j++) - { *(pDibBit0 + BUF_IDX(0, py, j, dy/2 + y_margin)) = MAP_WHITE; - } redraw(); force_redraw = false; @@ -665,7 +666,9 @@ LPBYTE dib_ref_pixel(dib_pack* dib, int x, int y) bool ImgIsTransparentAt(img_type img, int x, int y) { - if (pix_transparent == *( dib_ref_pixel(img, x, y) )) return true; + if (pix_transparent == *( dib_ref_pixel(img, x, y) )) + return true; + return false; } void ImgSetTransparentPix(img_type img) @@ -675,7 +678,9 @@ void ImgSetTransparentPix(img_type img) img_type ImgCreateSimple(int wx, int wy) { - if (wx ==0 || wy == 0) return NULL; + if (wx == 0 || wy == 0) + return NULL; + dib_pack *ptr = (dib_pack *)GlobalAlloc(GPTR, sizeof(dib_pack)); ptr->pDibBits = (LPBYTE)GlobalAlloc(GPTR, wx*wy ); @@ -692,7 +697,8 @@ img_type ImgCreateSimple(int wx, int wy) void ImgDestroy(img_type img) { - if (!img) return; + if (!img) + return; if (img->pDib) GlobalFree(img->pDib); if (img->hDC) DeleteDC (img->hDC); @@ -712,17 +718,20 @@ img_type ImgLoadFile(const char *name) hdc1 = GetDC(0); - fh=CreateFile(name, GENERIC_READ,0,NULL,OPEN_EXISTING, - FILE_ATTRIBUTE_NORMAL,NULL); - if (fh == INVALID_HANDLE_VALUE) return NULL; + fh = CreateFile(name, GENERIC_READ, 0, NULL, OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL, NULL); + + if (fh == INVALID_HANDLE_VALUE) + return NULL; SetFilePointer(fh,0,NULL,FILE_BEGIN); if (!ReadFile(fh,&bmHead, sizeof(BITMAPFILEHEADER), &dummy, NULL)) - return NULL; + return NULL; img = (dib_pack *) GlobalAlloc(GPTR, sizeof(dib_pack)); - if (!img) return NULL; + if (!img) + return NULL; img->pDib = (LPBITMAPINFO)GlobalAlloc(GPTR, (sizeof(BITMAPINFO) + 256 * sizeof(RGBQUAD)) ); @@ -733,8 +742,9 @@ img_type ImgLoadFile(const char *name) } SetFilePointer(fh, sizeof(BITMAPFILEHEADER), NULL, FILE_BEGIN); - if (!ReadFile(fh,img->pDib, sizeof(BITMAPINFOHEADER)+ 256 * sizeof(RGBQUAD), - &dummy, NULL)) + if (!ReadFile(fh, img->pDib, + sizeof(BITMAPINFOHEADER) + 256 * sizeof(RGBQUAD), + &dummy, NULL)) { GlobalFree(img->pDib); GlobalFree(img); @@ -781,27 +791,29 @@ void ImgClear(img_type img) // Copy internal image to another internal image void ImgCopy(img_type src, int sx, int sy, int wx, int wy, - img_type dest, int dx, int dy, int copy) + img_type dest, int dx, int dy, int copy) { int x, y; BYTE pix; - if(copy) + if (copy) { - for(x=0;x<wx;x++){ - for(y=0;y<wy;y++){ - pix = *( dib_ref_pixel(src, sx+x, sy+y) ); - *( dib_ref_pixel(dest, dx+x, dy+y) ) = pix; - }} + for (x = 0; x < wx; x++) + for (y = 0; y < wy; y++) + { + pix = *( dib_ref_pixel(src, sx+x, sy+y) ); + *( dib_ref_pixel(dest, dx+x, dy+y) ) = pix; + } } else { - for(x=0;x<wx;x++){ - for(y=0;y<wy;y++){ - pix = *( dib_ref_pixel(src, sx+x, sy+y) ); - if(pix!=pix_transparent) - *( dib_ref_pixel(dest, dx+x, dy+y) ) = pix; - }} + for (x = 0; x < wx; x++) + for (y = 0; y < wy; y++) + { + pix = *( dib_ref_pixel(src, sx+x, sy+y) ); + if (pix!=pix_transparent) + *( dib_ref_pixel(dest, dx+x, dy+y) ) = pix; + } } } @@ -814,21 +826,26 @@ void ImgCopyH(img_type src, int sx, int sy, int wx, int wy, if(copy) { - for(x=0;x<wx;x++){ - for(y=0;y<wy;y++){ - pix = *( dib_ref_pixel(src, sx+x, sy+y) ); - if (pix == pix_rimcolor) pix = pix_magenta; - *( dib_ref_pixel(dest, dx+x, dy+y) ) = pix; - }} + for (x = 0; x < wx; x++) + for (y = 0; y < wy; y++) + { + pix = *( dib_ref_pixel(src, sx+x, sy+y) ); + if (pix == pix_rimcolor) pix = pix_magenta; + *( dib_ref_pixel(dest, dx+x, dy+y) ) = pix; + } } else { - for(x=0;x<wx;x++){ - for(y=0;y<wy;y++){ - pix = *( dib_ref_pixel(src, sx+x, sy+y) ); - if (pix == pix_rimcolor) pix = pix_magenta; - if(pix!=pix_transparent) *( dib_ref_pixel(dest, dx+x, dy+y) ) = pix; - }} + for (x = 0; x < wx; x++) + for (y = 0; y < wy; y++) + { + pix = *( dib_ref_pixel(src, sx+x, sy+y) ); + + if (pix == pix_rimcolor) + pix = pix_magenta; + if (pix != pix_transparent) + *( dib_ref_pixel(dest, dx+x, dy+y) ) = pix; + } } } @@ -840,13 +857,14 @@ void ImgCopyMasked(img_type src, int sx, int sy, int wx, int wy, int x, y; BYTE pix; int count = 0; - for(y=0;y<wy;y++){ - for(x=0;x<wx;x++){ - pix = *( dib_ref_pixel(src, sx+x, sy+y) ); - if (mask[count]==0 && pix != pix_transparent) - *( dib_ref_pixel(dest, dx+x, dy+y) ) = pix; - count++; - }} + for (y = 0; y < wy; y++) + for (x = 0; x < wx; x++) + { + pix = *( dib_ref_pixel(src, sx+x, sy+y) ); + if (mask[count]==0 && pix != pix_transparent) + *( dib_ref_pixel(dest, dx+x, dy+y) ) = pix; + count++; + } } // Copy internal image to another internal image @@ -856,14 +874,16 @@ void ImgCopyMaskedH(img_type src, int sx, int sy, int wx, int wy, int x, y; BYTE pix; int count = 0; - for(y=0;y<wy;y++){ - for(x=0;x<wx;x++){ - pix = *( dib_ref_pixel(src, sx+x, sy+y) ); - if (pix == pix_rimcolor) pix = pix_magenta; - if (mask[count]==0 && pix != pix_transparent) - *( dib_ref_pixel(dest, dx+x, dy+y) ) = pix; - count++; - }} + for (y = 0; y < wy; y++) + for (x = 0; x < wx; x++) + { + pix = *( dib_ref_pixel(src, sx+x, sy+y) ); + if (pix == pix_rimcolor) + pix = pix_magenta; + if (mask[count]==0 && pix != pix_transparent) + *( dib_ref_pixel(dest, dx+x, dy+y) ) = pix; + count++; + } } void WinClass::fillrect(int left, int top, int right, int bottom, int color) @@ -872,12 +892,12 @@ void WinClass::fillrect(int left, int top, int right, int bottom, int color) HBRUSH curbrush; HDC curbrushhdc = NULL; - RECT currect; + RECT currect; curbrush = CreateSolidBrush(term_pix[color]); - currect.left = left; - currect.right = right; - currect.top = top; - currect.bottom= bottom; + currect.left = left; + currect.right = right; + currect.top = top; + currect.bottom = bottom; SelectObject(curbrushhdc, curbrush); FillRect(hdc, &currect, curbrush); DeleteObject(curbrush); @@ -899,13 +919,13 @@ void RegionClass::framerect(int left, int top, int right, int bottom, int color) HDC hdc = GetDC(win->hWnd); HBRUSH curbrush; - HDC curbrushhdc = NULL; + HDC curbrushhdc = NULL; RECT currect; curbrush = CreateSolidBrush(term_pix[color]); - currect.left = sx+left; - currect.right = sx+right; - currect.top = sy+top; - currect.bottom= sy+bottom; + currect.left = sx + left; + currect.right = sx + right; + currect.top = sy + top; + currect.bottom = sy + bottom; SelectObject(curbrushhdc, curbrush); FrameRect(hdc, &currect, curbrush); DeleteObject(curbrush); @@ -919,13 +939,13 @@ void TileRegionClass::framerect(int left, int top, int right, int bottom, { HDC dhdc = backbuf->hDC; HBRUSH curbrush; - HDC curbrushhdc = NULL; + HDC curbrushhdc = NULL; RECT currect; curbrush = CreateSolidBrush(term_pix[color]); - currect.left = left; - currect.right = right; - currect.top = top; - currect.bottom= bottom; + currect.left = left; + currect.right = right; + currect.top = top; + currect.bottom = bottom; SelectObject(curbrushhdc, curbrush); FrameRect(dhdc, &currect, curbrush); DeleteObject(curbrush); @@ -937,13 +957,13 @@ void RegionClass::fillrect(int left, int top, int right, int bottom, int color) HDC hdc = GetDC(win->hWnd); HBRUSH curbrush; - HDC curbrushhdc = NULL; + HDC curbrushhdc = NULL; RECT currect; curbrush = CreateSolidBrush(term_pix[color]); - currect.left = sx+left; - currect.right = sx+right; - currect.top = sy+top; - currect.bottom= sy+bottom; + currect.left = sx + left; + currect.right = sx + right; + currect.top = sy + top; + currect.bottom = sy + bottom; SelectObject(curbrushhdc, curbrush); FillRect(hdc, &currect, curbrush); DeleteObject(curbrush); @@ -957,16 +977,15 @@ void TileRegionClass::fillrect(int left, int top, int right, int bottom, { HDC dhdc = backbuf->hDC; HBRUSH curbrush; - HDC curbrushhdc = NULL; + HDC curbrushhdc = NULL; RECT currect; curbrush = CreateSolidBrush(term_pix[color]); - currect.left = left; - currect.right = right; - currect.top = top; - currect.bottom= bottom; + currect.left = left; + currect.right = right; + currect.top = top; + currect.bottom = bottom; SelectObject(curbrushhdc, curbrush); FillRect(dhdc, &currect, curbrush); DeleteObject(curbrush); DeleteDC(curbrushhdc); } - diff --git a/crawl-ref/source/guic-x11.cc b/crawl-ref/source/guic-x11.cc index ce688ac80c..c2b989a0e1 100644 --- a/crawl-ref/source/guic-x11.cc +++ b/crawl-ref/source/guic-x11.cc @@ -34,7 +34,7 @@ static unsigned long pix_hilite; static unsigned long pix_black; static unsigned long pix_rimcolor; static int x11_byte_per_pixel_ximage(); -static unsigned long create_pixel(unsigned int red, unsigned int green, +static unsigned long create_pixel(unsigned int red, unsigned int green, unsigned int blue); static XImage *read_png(const char *fname); @@ -327,14 +327,11 @@ void MapRegionClass::draw_data(unsigned char *buf) const int marker_length = 2; - for(int yy = 0; yy < dy * marker_length; yy++) - { + for (int yy = 0; yy < dy * marker_length; yy++) XPutPixel(backbuf, px*dx+dx/2 + x_margin, yy, map_pix[MAP_BLACK]); - } - for(int xx = 0; xx < dx * marker_length; xx++) - { + + for (int xx = 0; xx < dx * marker_length; xx++) XPutPixel(backbuf, xx, py*dy+dy/2 + y_margin, map_pix[MAP_BLACK]); - } for (int y = 0; y < my - y_margin; y++) { @@ -347,14 +344,14 @@ void MapRegionClass::draw_data(unsigned char *buf) px = x; py = y; } - if(col != get_col(x, y) || force_redraw || - x < marker_length || y < marker_length) + if (col != get_col(x, y) || force_redraw + || x < marker_length || y < marker_length) { - for(int xx=0; xx<dx; xx++) - for(int yy=0; yy<dy; yy++) + for (int xx=0; xx<dx; xx++) + for (int yy=0; yy<dy; yy++) { XPutPixel(backbuf, x_margin + x*dx+xx, - y_margin + y*dy+yy, map_pix[col]); + y_margin + y*dy+yy, map_pix[col]); } set_col(col, x, y); @@ -362,14 +359,11 @@ void MapRegionClass::draw_data(unsigned char *buf) } } - for(int yy = 0; yy < dy * marker_length; yy++) - { + for (int yy = 0; yy < dy * marker_length; yy++) XPutPixel(backbuf, px*dx+dx/2 + x_margin, yy, map_pix[MAP_WHITE]); - } - for(int xx = 0; xx < dx * marker_length; xx++) - { + + for (int xx = 0; xx < dx * marker_length; xx++) XPutPixel(backbuf, xx, py*dy+dy/2 + y_margin, map_pix[MAP_WHITE]); - } redraw(); XFlush(display); @@ -418,11 +412,11 @@ img_type ImgLoadFile(const char *name) void ImgClear(img_type img) { - int x,y; + int x, y; ASSERT(img != NULL); - for(y=0;y<img->height;y++) - for(x=0;x<img->width;x++) - XPutPixel(img, x, y, pix_transparent); + for (x = 0; x < img->width; x++) + for (y = 0; y < img->height; y++) + XPutPixel(img, x, y, pix_transparent); } // Copy internal image to another internal image @@ -434,65 +428,72 @@ void ImgCopy(img_type src, int sx, int sy, int wx, int wy, int bpl_s = src->bytes_per_line; int bpl_d = dest->bytes_per_line; - ASSERT(sx>=0); - ASSERT(sy>=0); - ASSERT(sx+wx<=(src->width)); - ASSERT(sy+wy<=(src->height)); - ASSERT(dx>=0); - ASSERT(dy>=0); - ASSERT(dx+wx<=(dest->width)); - ASSERT(dy+wy<=(dest->height)); + ASSERT(sx >= 0); + ASSERT(sy >= 0); + ASSERT(sx + wx <= src->width); + ASSERT(sy + wy <= src->height); + ASSERT(dx >= 0); + ASSERT(dy >= 0); + ASSERT(dx + wx <= dest->width); + ASSERT(dy + wy <= dest->height); - if(copy==1) + if (copy == 1) { - char *p_src = (char *)(src->data + bpl_s * sy + sx * bpp); + char *p_src = (char *)(src->data + bpl_s * sy + sx * bpp); char *p_dest = (char *)(dest->data + bpl_d * dy + dx * bpp); - for(y=0;y<wy;y++){ + for (y = 0; y < wy; y++) + { memcpy(p_dest, p_src, wx * bpp); - p_src += bpl_s; + p_src += bpl_s; p_dest += bpl_d; } } - else if(bpp<=1) + else if (bpp <= 1) { - CARD8 *p_src = (CARD8 *)(src->data + bpl_s * sy + sx * bpp); + CARD8 *p_src = (CARD8 *)(src->data + bpl_s * sy + sx * bpp); CARD8 *p_dest = (CARD8 *)(dest->data + bpl_d * dy + dx * bpp); - for(y=0;y<wy;y++){ - for(x=0;x<wx;x++){ + for (y = 0; y < wy; y++) + { + for (x = 0; x < wx; x++) + { //X11 specific - if(p_src[x] != pix_transparent) + if (p_src[x] != pix_transparent) p_dest[x] = p_src[x]; } - p_src += bpl_s; + p_src += bpl_s; p_dest += bpl_d; } } - else if(bpp<=2) + else if (bpp <= 2) { - CARD16 *p_src = (CARD16 *)(src->data + bpl_s * sy + sx * bpp); + CARD16 *p_src = (CARD16 *)(src->data + bpl_s * sy + sx * bpp); CARD16 *p_dest = (CARD16 *)(dest->data + bpl_d * dy + dx * bpp); - for(y=0;y<wy;y++){ - for(x=0;x<wx;x++){ + for (y = 0; y < wy; y++) + { + for (x = 0; x < wx; x++) + { //X11 specific - if(p_src[x] != pix_transparent) + if (p_src[x] != pix_transparent) p_dest[x] = p_src[x]; } - p_src += bpl_s/bpp; + p_src += bpl_s/bpp; p_dest += bpl_d/bpp; } } - else if(bpp<=4) + else if (bpp <= 4) { - CARD32 *p_src = (CARD32 *)(src->data + bpl_s * sy + sx * bpp); + CARD32 *p_src = (CARD32 *)(src->data + bpl_s * sy + sx * bpp); CARD32 *p_dest = (CARD32 *)(dest->data + bpl_d * dy + dx * bpp); - for(y=0;y<wy;y++){ - for(x=0;x<wx;x++){ + for (y = 0; y < wy; y++) + { + for (x = 0; x < wx; x++) + { //X11 specific - if(p_src[x] != pix_transparent) + if (p_src[x] != pix_transparent) p_dest[x] = p_src[x]; } - p_src += bpl_s/bpp; + p_src += bpl_s/bpp; p_dest += bpl_d/bpp; } } @@ -508,74 +509,78 @@ void ImgCopyH(img_type src, int sx, int sy, int wx, int wy, int bpl_s = src->bytes_per_line; int bpl_d = dest->bytes_per_line; - ASSERT(sx>=0); - ASSERT(sy>=0); - ASSERT(sx+wx<=(src->width)); - ASSERT(sy+wy<=(src->height)); - ASSERT(dx>=0); - ASSERT(dy>=0); - ASSERT(dx+wx<=(dest->width)); - ASSERT(dy+wy<=(dest->height)); + ASSERT(sx >= 0); + ASSERT(sy >= 0); + ASSERT(sx + wx <= src->width); + ASSERT(sy + wy <= src->height); + ASSERT(dx >= 0); + ASSERT(dy >= 0); + ASSERT(dx + wx <= dest->width); + ASSERT(dy + wy <= dest->height); - if(copy==1) + if (copy == 1) { - char *p_src = (char *)(src->data + bpl_s * sy + sx * bpp); + char *p_src = (char *)(src->data + bpl_s * sy + sx * bpp); char *p_dest = (char *)(dest->data + bpl_d * dy + dx * bpp); - for(y=0;y<wy;y++){ + for (y = 0; y < wy; y++) + { memcpy(p_dest, p_src, wx * bpp); - p_src += bpl_s; + p_src += bpl_s; p_dest += bpl_d; } } - else if(bpp<=1) + else if (bpp <= 1) { - CARD8 *p_src = (CARD8 *)(src->data + bpl_s * sy + sx * bpp); + CARD8 *p_src = (CARD8 *)(src->data + bpl_s * sy + sx * bpp); CARD8 *p_dest = (CARD8 *)(dest->data + bpl_d * dy + dx * bpp); - for(y=0;y<wy;y++){ - for(x=0;x<wx;x++){ + for (y = 0; y < wy; y++) + { + for (x = 0; x < wx; x++) + { //X11 specific - if(p_src[x] == pix_rimcolor) + if (p_src[x] == pix_rimcolor) p_dest[x] = pix_hilite; - - else if(p_src[x] != pix_transparent) + else if (p_src[x] != pix_transparent) p_dest[x] = p_src[x]; } - p_src += bpl_s; + p_src += bpl_s; p_dest += bpl_d; } } - else if(bpp<=2) + else if (bpp <= 2) { - CARD16 *p_src = (CARD16 *)(src->data + bpl_s * sy + sx * bpp); + CARD16 *p_src = (CARD16 *)(src->data + bpl_s * sy + sx * bpp); CARD16 *p_dest = (CARD16 *)(dest->data + bpl_d * dy + dx * bpp); - for(y=0;y<wy;y++){ - for(x=0;x<wx;x++){ + for (y = 0; y < wy; y++) + { + for (x = 0; x < wx; x++) + { //X11 specific - if(p_src[x] == pix_rimcolor) + if (p_src[x] == pix_rimcolor) p_dest[x] = pix_hilite; - - else if(p_src[x] != pix_transparent) + else if (p_src[x] != pix_transparent) p_dest[x] = p_src[x]; } - p_src += bpl_s/bpp; + p_src += bpl_s/bpp; p_dest += bpl_d/bpp; } } - else if(bpp<=4) + else if (bpp <= 4) { - CARD32 *p_src = (CARD32 *)(src->data + bpl_s * sy + sx * bpp); + CARD32 *p_src = (CARD32 *)(src->data + bpl_s * sy + sx * bpp); CARD32 *p_dest = (CARD32 *)(dest->data + bpl_d * dy + dx * bpp); - for(y=0;y<wy;y++){ - for(x=0;x<wx;x++){ + for (y = 0; y < wy; y++) + { + for (x = 0; x < wx; x++) + { //X11 specific - if(p_src[x] == pix_rimcolor) + if (p_src[x] == pix_rimcolor) p_dest[x] = pix_hilite; - - else if(p_src[x] != pix_transparent) + else if (p_src[x] != pix_transparent) p_dest[x] = p_src[x]; } - p_src += bpl_s/bpp; + p_src += bpl_s/bpp; p_dest += bpl_d/bpp; } } @@ -591,64 +596,68 @@ void ImgCopyMasked(img_type src, int sx, int sy, int wx, int wy, int bpp = src->bytes_per_line / src->width; int bpl_s = src->bytes_per_line; int bpl_d = dest->bytes_per_line; - ASSERT(sx>=0); - ASSERT(sy>=0); - ASSERT(sx+wx<=(src->width)); - ASSERT(sy+wy<=(src->height)); - ASSERT(dx>=0); - ASSERT(dy>=0); - ASSERT(dx+wx<=(dest->width)); - ASSERT(dy+wy<=(dest->height)); - + ASSERT(sx >= 0); + ASSERT(sy >= 0); + ASSERT(sx + wx <= src->width); + ASSERT(sy + wy <= src->height); + ASSERT(dx >= 0); + ASSERT(dy >= 0); + ASSERT(dx + wx <= dest->width); + ASSERT(dy + wy <= dest->height); count = 0; - if(bpp<=1) + if (bpp <= 1) { - CARD8 *p_src = (CARD8 *)(src->data + bpl_s * sy + sx * bpp); + CARD8 *p_src = (CARD8 *)(src->data + bpl_s * sy + sx * bpp); CARD8 *p_dest = (CARD8 *)(dest->data + bpl_d * dy + dx * bpp); - for(y=0;y<wy;y++){ - for(x=0;x<wx;x++){ + for (y = 0; y < wy; y++) + { + 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++; + count++; } - p_src += bpl_s; + p_src += bpl_s; p_dest += bpl_d; } } - else if(bpp<=2) + else if (bpp <= 2) { - CARD16 *p_src = (CARD16 *)(src->data + bpl_s * sy + sx * bpp); + CARD16 *p_src = (CARD16 *)(src->data + bpl_s * sy + sx * bpp); CARD16 *p_dest = (CARD16 *)(dest->data + bpl_d * dy + dx * bpp); - for(y=0;y<wy;y++){ - for(x=0;x<wx;x++){ + for (y = 0; y < wy; y++) + { + 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++; + count++; } - p_src += bpl_s/bpp; + p_src += bpl_s/bpp; p_dest += bpl_d/bpp; } } - else if(bpp<=4) + else if (bpp <= 4) { - CARD32 *p_src = (CARD32 *)(src->data + bpl_s * sy + sx * bpp); + CARD32 *p_src = (CARD32 *)(src->data + bpl_s * sy + sx * bpp); CARD32 *p_dest = (CARD32 *)(dest->data + bpl_d * dy + dx * bpp); - for(y=0;y<wy;y++){ - for(x=0;x<wx;x++){ + for (y = 0; y < wy; y++) + { + 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++; + count++; } - p_src += bpl_s/bpp; + p_src += bpl_s/bpp; p_dest += bpl_d/bpp; } } - } // Copy internal image to another internal image @@ -659,71 +668,75 @@ void ImgCopyMaskedH(img_type src, int sx, int sy, int wx, int wy, int bpp = src->bytes_per_line / src->width; int bpl_s = src->bytes_per_line; int bpl_d = dest->bytes_per_line; - ASSERT(sx>=0); - ASSERT(sy>=0); - ASSERT(sx+wx<=(src->width)); - ASSERT(sy+wy<=(src->height)); - ASSERT(dx>=0); - ASSERT(dy>=0); - ASSERT(dx+wx<=(dest->width)); - ASSERT(dy+wy<=(dest->height)); - + ASSERT(sx >= 0); + ASSERT(sy >= 0); + ASSERT(sx + wx <= src->width); + ASSERT(sy + wy <= src->height); + ASSERT(dx >= 0); + ASSERT(dy >= 0); + ASSERT(dx + wx <= dest->width); + ASSERT(dy + wy <= dest->height); count = 0; - if(bpp<=1) + if (bpp <= 1) { - CARD8 *p_src = (CARD8 *)(src->data + bpl_s * sy + sx * bpp); + CARD8 *p_src = (CARD8 *)(src->data + bpl_s * sy + sx * bpp); CARD8 *p_dest = (CARD8 *)(dest->data + bpl_d * dy + dx * bpp); - for(y=0;y<wy;y++){ - for(x=0;x<wx;x++){ + for (y = 0; y < wy; y++) + { + for (x = 0; x < wx; x++) + { //X11 specific - if(p_src[x] == pix_rimcolor) + 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++; + count++; } - p_src += bpl_s; + p_src += bpl_s; p_dest += bpl_d; } } - else if(bpp<=2) + else if (bpp <= 2) { - CARD16 *p_src = (CARD16 *)(src->data + bpl_s * sy + sx * bpp); + CARD16 *p_src = (CARD16 *)(src->data + bpl_s * sy + sx * bpp); CARD16 *p_dest = (CARD16 *)(dest->data + bpl_d * dy + dx * bpp); - for(y=0;y<wy;y++){ - for(x=0;x<wx;x++){ + for (y = 0; y < wy; y++) + { + for (x = 0; x < wx; x++) + { //X11 specific - if(p_src[x] == pix_rimcolor) + 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++; + count++; } - p_src += bpl_s/bpp; + p_src += bpl_s/bpp; p_dest += bpl_d/bpp; } } - else if(bpp<=4) + else if (bpp <= 4) { - CARD32 *p_src = (CARD32 *)(src->data + bpl_s * sy + sx * bpp); + CARD32 *p_src = (CARD32 *)(src->data + bpl_s * sy + sx * bpp); CARD32 *p_dest = (CARD32 *)(dest->data + bpl_d * dy + dx * bpp); - for(y=0;y<wy;y++){ - for(x=0;x<wx;x++){ + for (y = 0; y < wy; y++) + { + for (x = 0; x < wx; x++) + { //X11 specific - if(p_src[x] == pix_rimcolor) + 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++; + count++; } - p_src += bpl_s/bpp; + p_src += bpl_s/bpp; p_dest += bpl_d/bpp; } } - } void TileRegionClass::DrawPanel(int left, int top, int width, int height) @@ -746,12 +759,14 @@ void TileRegionClass::framerect(int left, int top, int right, int bottom, int x,y; int pix = term_pix[color]; - for (x=left; x<=right; x++){ + for (x = left; x <= right; x++) + { XPutPixel(backbuf, x, top, pix); XPutPixel(backbuf, x, bottom, pix); } - for (y=top+1; y< bottom; y++){ + for (y = top+1; y < bottom; y++) + { XPutPixel(backbuf, left, y, pix); XPutPixel(backbuf, right, y, pix); } @@ -777,15 +792,14 @@ void TileRegionClass::fillrect(int left, int top, int right, int bottom, int x,y; int pix = term_pix[color]; - ASSERT(left>=0); - ASSERT(top>=0); - ASSERT(right<mx*dx); - ASSERT(bottom<my*dy); + ASSERT(left >= 0); + ASSERT(top >= 0); + ASSERT(right < mx*dx); + ASSERT(bottom < my*dy); - for (x=left; x<=right; x++){ - for (y=top; y<= bottom; y++){ - XPutPixel(backbuf, x, y, pix); - }} + for (x = left; x <= right; x++) + for (y = top; y <= bottom; y++) + XPutPixel(backbuf, x, y, pix); } /********************************************/ @@ -806,25 +820,25 @@ bool GuicInit(Display **d, int *s) *s = screen; // for text display - for(i=0;i<MAX_TERM_COL;i++) + for (i = 0; i < MAX_TERM_COL; i++) { const int *c = term_colors[i]; - term_pix[i] = create_pixel(c[0],c[1],c[2]); - term_gc[i]= XCreateGC(display,RootWindow(display,screen),0,0); + term_pix[i] = create_pixel(c[0], c[1], c[2]); + term_gc[i] = XCreateGC(display, RootWindow(display,screen), 0, 0); XSetForeground(display,term_gc[i], term_pix[i]); } // for text display - for(i=0;i<MAX_MAP_COL;i++) + for (i = 0; i < MAX_MAP_COL; i++) { const int *c = map_colors[i]; - map_pix[i] = create_pixel(c[0],c[1],c[2]); - map_gc[i]= XCreateGC(display,RootWindow(display,screen),0,0); + map_pix[i] = create_pixel(c[0], c[1], c[2]); + map_gc[i] = XCreateGC(display, RootWindow(display,screen), 0, 0); XSetForeground(display, map_gc[i], map_pix[i]); } // for Image manipulation - pix_black = term_pix[PIX_BLACK] ; - pix_hilite = term_pix[PIX_LIGHTMAGENTA] ; + pix_black = term_pix[PIX_BLACK] ; + pix_hilite = term_pix[PIX_LIGHTMAGENTA] ; pix_rimcolor = create_pixel(1,1,1); return true; @@ -834,10 +848,10 @@ void GuicDeinit() { int i; - for(i=0;i<MAX_TERM_COL;i++) + for (i = 0; i < MAX_TERM_COL; i++) XFreeGC(display,term_gc[i]); - for(i=0;i<MAX_MAP_COL;i++) + for (i = 0; i < MAX_MAP_COL; i++) XFreeGC(display,map_gc[i]); XCloseDisplay(display); @@ -847,19 +861,22 @@ static int x11_byte_per_pixel_ximage() { int i = 1; int j = (DefaultDepth(display, screen) - 1) >> 2; - while (j >>= 1) i <<= 1; + while (j >>= 1) + { + i <<= 1; + } return i; } -unsigned long create_pixel(unsigned int red, unsigned int green, +unsigned long create_pixel(unsigned int red, unsigned int green, unsigned int blue) { Colormap cmap = DefaultColormapOfScreen(DefaultScreenOfDisplay(display)); XColor xcolour; - xcolour.red = red * 256; + xcolour.red = red * 256; xcolour.green = green * 256; - xcolour.blue = blue * 256; + xcolour.blue = blue * 256; xcolour.flags = DoRed | DoGreen | DoBlue; XAllocColor(display, cmap, &xcolour); @@ -903,88 +920,96 @@ unsigned long create_pixel(unsigned int red, unsigned int green, XImage *read_png (const char *fname) { - char sig_buf [SIG_CHECK_SIZE]; - png_struct *png_ptr; - png_info *info_ptr; - png_byte **png_image; - png_byte *png_pixel; - unsigned int x, y; - int linesize; - png_uint_16 c; - unsigned int i; - - //X11 - XImage *res; - unsigned long pix_table[256]; - - - FILE *ifp = fopen(fname,"r"); - - if(!ifp) { fprintf(stderr, "File not found: %s", fname); return NULL; } - - if (fread (sig_buf, 1, SIG_CHECK_SIZE, ifp) != SIG_CHECK_SIZE) - pm_error ("input file empty or too short"); - if (png_sig_cmp ((unsigned char *)sig_buf, (png_size_t) 0, (png_size_t) SIG_CHECK_SIZE) != 0) - pm_error ("input file not a PNG file"); - - png_ptr = png_create_read_struct (PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); - if (png_ptr == NULL) { - pm_error ("cannot allocate LIBPNG structure"); - } - info_ptr = png_create_info_struct (png_ptr); - if (info_ptr == NULL) { - png_destroy_read_struct (&png_ptr, (png_infopp)NULL, (png_infopp)NULL); - pm_error ("cannot allocate LIBPNG structures"); - } - - if (setjmp (png_ptr->jmpbuf)) { - png_destroy_read_struct (&png_ptr, (png_infopp)NULL, (png_infopp)NULL); - free (png_ptr); - free (info_ptr); - pm_error ("setjmp returns error condition"); - } + char sig_buf [SIG_CHECK_SIZE]; + png_struct *png_ptr; + png_info *info_ptr; + png_byte **png_image; + png_byte *png_pixel; + unsigned int x, y; + int linesize; + png_uint_16 c; + unsigned int i; + + //X11 + XImage *res; + unsigned long pix_table[256]; + + FILE *ifp = fopen(fname,"r"); + + if (!ifp) + { + fprintf(stderr, "File not found: %s", fname); + return NULL; + } - png_init_io (png_ptr, ifp); - png_set_sig_bytes (png_ptr, SIG_CHECK_SIZE); - png_read_info (png_ptr, info_ptr); + if (fread (sig_buf, 1, SIG_CHECK_SIZE, ifp) != SIG_CHECK_SIZE) + pm_error ("input file empty or too short"); + if (png_sig_cmp ((unsigned char *)sig_buf, (png_size_t) 0, + (png_size_t) SIG_CHECK_SIZE) != 0) + { + pm_error ("input file not a PNG file"); + } + png_ptr = png_create_read_struct (PNG_LIBPNG_VER_STRING, NULL, NULL, NULL); + if (png_ptr == NULL) + pm_error ("cannot allocate LIBPNG structure"); + info_ptr = png_create_info_struct (png_ptr); + if (info_ptr == NULL) + { + png_destroy_read_struct (&png_ptr, (png_infopp)NULL, (png_infopp)NULL); + pm_error ("cannot allocate LIBPNG structures"); + } - png_image = (png_byte **)malloc (info_ptr->height * sizeof (png_byte*)); - if (png_image == NULL) { - free (png_ptr); - free (info_ptr); - pm_error ("couldn't alloc space for image"); - } - - if (info_ptr->bit_depth == 16) - linesize = 2 * info_ptr->width; - else - linesize = info_ptr->width; - - if (info_ptr->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) - linesize *= 2; - else - if (info_ptr->color_type == PNG_COLOR_TYPE_RGB) - linesize *= 3; - else - if (info_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA) - linesize *= 4; - - for (y = 0 ; y < info_ptr->height ; y++) { - png_image[y] = (png_byte *)malloc (linesize); - if (png_image[y] == NULL) { - for (x = 0 ; x < y ; x++) - free (png_image[x]); - free (png_image); - free (png_ptr); - free (info_ptr); - pm_error ("couldn't alloc space for image"); + if (setjmp (png_ptr->jmpbuf)) + { + png_destroy_read_struct (&png_ptr, (png_infopp)NULL, (png_infopp)NULL); + free (png_ptr); + free (info_ptr); + pm_error ("setjmp returns error condition"); } - } - if (info_ptr->bit_depth < 8) - png_set_packing (png_ptr); + png_init_io (png_ptr, ifp); + png_set_sig_bytes (png_ptr, SIG_CHECK_SIZE); + png_read_info (png_ptr, info_ptr); + + png_image = (png_byte **)malloc (info_ptr->height * sizeof (png_byte*)); + if (png_image == NULL) + { + free (png_ptr); + free (info_ptr); + pm_error ("couldn't alloc space for image"); + } + + if (info_ptr->bit_depth == 16) + linesize = 2 * info_ptr->width; + else + linesize = info_ptr->width; + + if (info_ptr->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) + linesize *= 2; + else if (info_ptr->color_type == PNG_COLOR_TYPE_RGB) + linesize *= 3; + else if (info_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA) + linesize *= 4; + + for (y = 0 ; y < info_ptr->height ; y++) + { + png_image[y] = (png_byte *)malloc (linesize); + if (png_image[y] == NULL) + { + for (x = 0; x < y; x++) + free (png_image[x]); + + free (png_image); + free (png_ptr); + free (info_ptr); + pm_error ("couldn't alloc space for image"); + } + } + + if (info_ptr->bit_depth < 8) + png_set_packing (png_ptr); /* sBIT handling is very tricky. If we are extracting only the image, we can use the sBIT info for grayscale and color images, if the three @@ -994,69 +1019,75 @@ XImage *read_png (const char *fname) so we will use the sBIT info only for transparency, if we know that only solid and fully transparent is used */ - if (info_ptr->valid & PNG_INFO_sBIT) { - + if (info_ptr->valid & PNG_INFO_sBIT) + { if ((info_ptr->color_type == PNG_COLOR_TYPE_PALETTE || info_ptr->color_type == PNG_COLOR_TYPE_RGB || info_ptr->color_type == PNG_COLOR_TYPE_RGB_ALPHA) && (info_ptr->sig_bit.red != info_ptr->sig_bit.green || - info_ptr->sig_bit.red != info_ptr->sig_bit.blue) ) { - pm_message ("different bit depths for color channels not supported"); - pm_message ("writing file with %d bit resolution", info_ptr->bit_depth); - } else - if ((info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) && - (info_ptr->sig_bit.red < 255)) { - for (i = 0 ; i < info_ptr->num_palette ; i++) { - info_ptr->palette[i].red >>= (8 - info_ptr->sig_bit.red); - info_ptr->palette[i].green >>= (8 - info_ptr->sig_bit.green); - info_ptr->palette[i].blue >>= (8 - info_ptr->sig_bit.blue); - } - - } else - if ((info_ptr->color_type == PNG_COLOR_TYPE_GRAY || - info_ptr->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) && - (info_ptr->sig_bit.gray < info_ptr->bit_depth)) { - png_set_shift (png_ptr, &(info_ptr->sig_bit)); - } - - - } - - if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) - { -//X11 - for (i = 0 ; i < info_ptr->num_palette ; i++) - pix_table[i] = create_pixel(info_ptr->palette[i].red, - info_ptr->palette[i].green, info_ptr->palette[i].blue); - } - else - if (info_ptr->color_type == PNG_COLOR_TYPE_GRAY) - { + info_ptr->sig_bit.red != info_ptr->sig_bit.blue) ) + { + pm_message ("different bit depths for color channels not " + "supported"); + pm_message ("writing file with %d bit resolution", + info_ptr->bit_depth); + } + else if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE + && info_ptr->sig_bit.red < 255) + { + for (i = 0 ; i < info_ptr->num_palette ; i++) + { + info_ptr->palette[i].red >>= (8 - info_ptr->sig_bit.red); + info_ptr->palette[i].green >>= (8 - info_ptr->sig_bit.green); + info_ptr->palette[i].blue >>= (8 - info_ptr->sig_bit.blue); + } + } + else if ((info_ptr->color_type == PNG_COLOR_TYPE_GRAY + || info_ptr->color_type == PNG_COLOR_TYPE_GRAY_ALPHA) + && info_ptr->sig_bit.gray < info_ptr->bit_depth) + { + png_set_shift (png_ptr, &(info_ptr->sig_bit)); + } + } + + if (info_ptr->color_type == PNG_COLOR_TYPE_PALETTE) + { + //X11 + for (i = 0 ; i < info_ptr->num_palette ; i++) + pix_table[i] = create_pixel(info_ptr->palette[i].red, + + info_ptr->palette[i].green, info_ptr->palette[i].blue); + } + else if (info_ptr->color_type == PNG_COLOR_TYPE_GRAY) + { + //X11 for (i = 0 ; i < 256 ; i++) -//X11 - pix_table[i] = create_pixel(i, i, i); - } + pix_table[i] = create_pixel(i, i, i); + } - png_read_image (png_ptr, png_image); - png_read_end (png_ptr, info_ptr); + png_read_image (png_ptr, png_image); + png_read_end (png_ptr, info_ptr); - res = ImgCreateSimple(info_ptr->width, info_ptr->height); + res = ImgCreateSimple(info_ptr->width, info_ptr->height); - for (y = 0 ; y < info_ptr->height ; y++) { - png_pixel = png_image[y]; - for (x = 0 ; x < info_ptr->width ; x++) { - c = *png_pixel; - png_pixel++; - XPutPixel(res, x, y, pix_table[c]); + for (y = 0; y < info_ptr->height; y++) + { + png_pixel = png_image[y]; + for (x = 0; x < info_ptr->width; x++) + { + c = *png_pixel; + png_pixel++; + XPutPixel(res, x, y, pix_table[c]); + } } - } - for (y = 0 ; y < info_ptr->height ; y++) - free (png_image[y]); - free (png_image); - free (png_ptr); - free (info_ptr); + for (y = 0 ; y < info_ptr->height ; y++) + free (png_image[y]); + + free (png_image); + free (png_ptr); + free (info_ptr); - fclose(ifp); - return res; + fclose(ifp); + return res; } diff --git a/crawl-ref/source/guic.cc b/crawl-ref/source/guic.cc index 7d6dac4a1b..81fbad9c6b 100644 --- a/crawl-ref/source/guic.cc +++ b/crawl-ref/source/guic.cc @@ -189,7 +189,7 @@ void WinClass::redraw(int x1, int y1, int x2, int y2) { std::vector <RegionClass *>::iterator r; int cx1, cx2, cy1, cy2; - for (r = regions.begin();r != regions.end();r++) + 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)) @@ -356,7 +356,7 @@ void RegionClass::make_active() { if (!flag) return; win->active_layer = layer; -} +} void RegionClass::redraw(int x1, int y1, int x2, int y2) { @@ -388,7 +388,7 @@ int MapRegionClass::get_col(int x, int y) } /*------------------------------------------*/ -bool RegionClass::convert_redraw_rect(int x1, int y1, int x2, int y2, +bool RegionClass::convert_redraw_rect(int x1, int y1, int x2, int y2, int *rx1, int *ry1, int *rx2, int *ry2) { int cx1 = x1-ox; @@ -417,7 +417,7 @@ bool RegionClass::convert_redraw_rect(int x1, int y1, int x2, int y2, return true; } -bool TileRegionClass::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 cx1 = x1-ox; @@ -490,7 +490,7 @@ bool TileRegionClass::mouse_pos(int mouse_x, int mouse_y, int *cx, int *cy) } /* - * Text related + * Text related */ void TextRegionClass::scroll() @@ -500,13 +500,13 @@ void TextRegionClass::scroll() if(!flag) return; - for(idx=0; idx<mx*(my-1);idx++) + for (idx = 0; idx < mx*(my-1); idx++) { cbuf[idx] = cbuf[idx + mx]; abuf[idx] = abuf[idx + mx]; } - for(idx=mx*(my-1);idx<mx*my;idx++) + for (idx = mx*(my-1); idx < mx*my; idx++) { cbuf[idx] = ' '; abuf[idx] = 0; @@ -532,9 +532,9 @@ void TextRegionClass::addstr(char *buffer) if(!flag)return; - j=0; + j = 0; - for(i=0;i<len+1;i++) + for (i = 0; i < len + 1; i++) { char c = buffer[i]; bool newline=false; @@ -547,7 +547,8 @@ void TextRegionClass::addstr(char *buffer) } buf2[j] = c; j++; - if(c==0) + + if (c == 0) { if (j-1 != 0) addstr_aux(buf2, j - 1); // draw it @@ -555,14 +556,15 @@ void TextRegionClass::addstr(char *buffer) { print_x = cx_ofs; print_y++; - j=0; + j = 0; - if(print_y - cy_ofs == my) + if (print_y - cy_ofs == my) scroll(); } } } - if (cursor_flag) cgotoxy(print_x+1, print_y+1); + if (cursor_flag) + cgotoxy(print_x+1, print_y+1); } void TextRegionClass::addstr_aux(char *buffer, int len) @@ -574,15 +576,15 @@ void TextRegionClass::addstr_aux(char *buffer, int len) int head = x; int tail = x + len - 1; - if(!flag) + if (!flag) return; adjust_region(&head, &tail, y); - for (i=0; i < len && x + i < mx;i++) + for (i = 0; i < len && x + i < mx; i++) { - cbuf[adrs+x+i]=buffer[i]; - abuf[adrs+x+i]=text_col; + cbuf[adrs+x+i] = buffer[i]; + abuf[adrs+x+i] = text_col; } draw_string(head, y, &cbuf[adrs+head], tail-head, text_col); print_x += len; @@ -591,10 +593,10 @@ void TextRegionClass::addstr_aux(char *buffer, int len) void TextRegionClass::redraw(int x1, int y1, int x2, int y2) { int x, y; - if(!flag) + if (!flag) return; - for(y=y1;y<=y2;y++) + for (y = y1; y <= y2; y++) { unsigned char *a = &abuf[y * mx]; unsigned char *c = &cbuf[y * mx]; @@ -602,16 +604,17 @@ void TextRegionClass::redraw(int x1, int y1, int x2, int y2) int tail = x2; adjust_region(&head, &tail, y); - x=head; + x = head; int col = a[x]; - while (x<=tail) + while (x <= tail) { int oldcol = col; - if (x==tail) + if (x == tail) col = -1; else col = a[x]; + if (oldcol != col) { draw_string(head, y, &c[head], x-head, oldcol); @@ -621,7 +624,7 @@ void TextRegionClass::redraw(int x1, int y1, int x2, int y2) } } - if(cursor_region == this && cursor_flag == 1) + if (cursor_region == this && cursor_flag == 1) draw_cursor(cursor_x, cursor_y); sys_flush(); @@ -635,11 +638,12 @@ void TextRegionClass::clear_to_end_of_line() int col = text_col; int adrs = cy * mx; - if(!flag) + if (!flag) return; ASSERT(adrs + mx - 1 < mx * my); - for(i=cx; i<mx; i++){ + for (i = cx; i < mx; i++) + { cbuf[adrs+i] = ' '; abuf[adrs+i] = col; } @@ -652,18 +656,21 @@ void TextRegionClass::clear_to_end_of_screen() int cy = print_y - cy_ofs; int col = text_col; - if(!flag)return; + if (!flag) + return; - for(i=cy*mx; i<mx*my; i++){ - cbuf[i]=' '; - abuf[i]=col; + for (i = cy*mx; i < mx*my; i++) + { + cbuf[i] = ' '; + abuf[i] = col; } redraw(0, cy, mx-1, my-1); } void TextRegionClass::putch(unsigned char ch) { - if (ch==0) ch=32; + if (ch == 0) + ch=32; addstr_aux((char *)&ch, 1); } @@ -716,7 +723,7 @@ void TextRegionClass::_setcursortype(int curstype) { cursor_flag = curstype; if (cursor_region != NULL) - cursor_region ->erase_cursor(); + cursor_region->erase_cursor(); if (curstype) { diff --git a/crawl-ref/source/items.cc b/crawl-ref/source/items.cc index 54b4ec0bf3..6263621330 100644 --- a/crawl-ref/source/items.cc +++ b/crawl-ref/source/items.cc @@ -314,7 +314,7 @@ void inc_inv_item_quantity( int obj, int amount ) { if (you.equip[EQ_WEAPON] == obj) you.wield_change = true; - + you.m_quiver->on_inv_quantity_changed(obj, amount); you.inv[obj].quantity += amount; burden_change(); @@ -2333,11 +2333,9 @@ int inv_count(void) { int count=0; - for(int i = 0; i < ENDOFPACK; i++) - { + for (int i = 0; i < ENDOFPACK; i++) if (is_valid_item( you.inv[i] )) count++; - } return count; } diff --git a/crawl-ref/source/libw32c.cc b/crawl-ref/source/libw32c.cc index 27b1ca9377..cebee880f6 100644 --- a/crawl-ref/source/libw32c.cc +++ b/crawl-ref/source/libw32c.cc @@ -239,7 +239,7 @@ void set_mouse_enabled(bool enabled) inmode |= ENABLE_MOUSE_INPUT; else inmode &= ~ENABLE_MOUSE_INPUT; - + ::SetConsoleMode(inbuf, inmode); } } @@ -317,7 +317,7 @@ static void set_w32_screen_size() delete [] screen; screen = NULL; } - + screen = new CHAR_INFO[screensize.X * screensize.Y]; COORD topleft; @@ -378,7 +378,7 @@ void init_libw32c(void) // set up screen size set_w32_screen_size(); - + // initialise text color textcolor(DARKGREY); @@ -390,7 +390,7 @@ void init_libw32c(void) crawl_state.terminal_resize_handler = w32_term_resizer; crawl_state.terminal_resize_check = w32_check_screen_resize; - + // JWM, 06/12/2004: Code page setting, as XP does not use ANSI 437 by // default. InputCP = GetConsoleCP(); @@ -412,7 +412,7 @@ void deinit_libw32c(void) if (inbuf == NULL || outbuf == NULL) return; - // JWM, 06/12/2004: Code page stuff. If it was the preferred code page, it + // JWM, 06/12/2004: Code page stuff. If it was the preferred code page, it // doesn't need restoring. Shouldn't be an error and too bad if there is. if (InputCP && InputCP != PREFERRED_CODEPAGE) SetConsoleCP(InputCP); @@ -429,7 +429,7 @@ void deinit_libw32c(void) delete [] screen; screen = NULL; - + // finally, restore title SetConsoleTitle( oldTitle ); } @@ -480,15 +480,13 @@ void clrscr(void) PCHAR_INFO pci = screen; - for(x = 0; x < screensize.X; x++) - { - for(y = 0; y < screensize.Y; y++) + for (x = 0; x < screensize.X; x++) + for (y = 0; y < screensize.Y; y++) { pci->Char.AsciiChar = ' '; pci->Attributes = 0; pci++; } - } source.X = 0; source.Y = 0; @@ -639,7 +637,7 @@ static void cprintf_aux(const char *s) // loop through string char *p = (char *)s; - while(*p) + while (*p) { writeChar(*p++); } @@ -722,7 +720,7 @@ int key_to_command( int keyin ) { if (keyin >= CK_UP && keyin <= CK_CTRL_PGDN) return ck_tr[ keyin - CK_UP ]; - + if (keyin == CK_DELETE) return '.'; @@ -760,15 +758,16 @@ int vk_translate( WORD VirtCode, CHAR c, DWORD cKeys) // see if we're a vkey int mkey; - for(mkey = 0; mkey<VKEY_MAPPINGS; mkey++) - if (VirtCode == vk_tr[0][mkey]) break; + for (mkey = 0; mkey<VKEY_MAPPINGS; mkey++) + if (VirtCode == vk_tr[0][mkey]) + break; // step 4 - just return the damn key. if (mkey == VKEY_MAPPINGS) { if (c) return c; - + // ds -- Icky hacks to allow keymaps with funky keys. if (ctrlDown) VirtCode |= 512; @@ -788,7 +787,7 @@ int vk_translate( WORD VirtCode, CHAR c, DWORD cKeys) // control key? if (ctrlDown) return vk_tr[3][mkey]; - + // shifted? if (shftDown) return vk_tr[2][mkey]; @@ -807,7 +806,7 @@ static int w32_proc_mouse_event(const MOUSE_EVENT_RECORD &mer) if (!crawl_state.mouse_enabled) return (0); - + c_mouse_event cme(pos); if (mer.dwEventFlags & MOUSE_MOVED) return (CK_MOUSE_MOVE); @@ -882,7 +881,7 @@ int getch_ck(void) } } break; - + case WINDOW_BUFFER_SIZE_EVENT: w32_handle_resize_event(); break; diff --git a/crawl-ref/source/libwt.cc b/crawl-ref/source/libwt.cc index 8e494a94bd..750dbf7b0c 100644 --- a/crawl-ref/source/libwt.cc +++ b/crawl-ref/source/libwt.cc @@ -28,7 +28,7 @@ #include "cio.h" #include "debug.h" #include "externs.h" -#include "files.h" +#include "files.h" #include "guic.h" #include "itemprop.h" #include "state.h" @@ -143,7 +143,7 @@ void GetNextEvent(int *etype, int *key, bool *sh, bool *ct, { MSG msg; - while( GetMessage(&msg, NULL, 0, 0) ) + while ( GetMessage(&msg, NULL, 0, 0) ) { TranslateMessage( &msg ); DispatchMessage( &msg ); diff --git a/crawl-ref/source/macro.cc b/crawl-ref/source/macro.cc index 25a81f2a8d..f834623bd0 100644 --- a/crawl-ref/source/macro.cc +++ b/crawl-ref/source/macro.cc @@ -17,14 +17,14 @@ * - For generic game code, #define getch() getchm(). * - getchm() works by reading characters from an internal * buffer. If none are available, new characters are read into - * the buffer with getch_mul(). + * the buffer with getch_mul(). * - getch_mul() reads at least one character, but will read more * if available (determined using kbhit(), which should be defined - * in the platform specific libraries). + * in the platform specific libraries). * - Before adding the characters read into the buffer, any macros * in the sequence are replaced (see macro_add_buf_long for the * details). - * + * * (When the above text mentions characters, it actually means int). */ @@ -172,15 +172,15 @@ static int userfunc_getindex(const std::string &fname) return (userfunctions.size() - 1); } -/* +/* * Returns the name of the file that contains macros. */ -static std::string get_macro_file() +static std::string get_macro_file() { std::string dir = !Options.macro_dir.empty()? Options.macro_dir : !SysEnv.crawl_dir.empty()? SysEnv.crawl_dir : ""; - + if (!dir.empty()) { #ifndef DGL_MACRO_ABSOLUTE_PATH @@ -204,7 +204,7 @@ static void buf2keyseq(const char *buff, keyseq &k) if (!buff) return; - // convert c_str to keyseq + // convert c_str to keyseq // Check for user functions if (*buff == '=' && buff[1] == '=' && buff[2] == '=' && buff[3]) @@ -214,7 +214,7 @@ static void buf2keyseq(const char *buff, keyseq &k) k.push_back( USERFUNCBASE - index ); } else - { + { const int len = strlen( buff ); for (int i = 0; i < len; i++) k.push_back( buff[i] ); @@ -242,22 +242,22 @@ static int read_key_code(std::string s) return strtol(s.c_str(), &tail, base); } -/* +/* * Takes as argument a string, and returns a sequence of keys described * by the string. Most characters produce their own ASCII code. These - * are the cases: + * are the cases: * \\ produces the ASCII code of a single \ * \{123} produces 123 (decimal) * \{^A} produces 1 (Ctrl-A) * \{x40} produces 64 (hexadecimal code) * \{!more} or \{!m} disables -more- prompt until the end of the macro. */ -static keyseq parse_keyseq( std::string s ) +static keyseq parse_keyseq( std::string s ) { int state = 0; keyseq v; int num; - + if (s.find("===") == 0) { buf2keyseq(s.c_str(), v); @@ -265,20 +265,20 @@ static keyseq parse_keyseq( std::string s ) } bool more_reset = false; - for (int i = 0, size = s.length(); i < size; ++i) + for (int i = 0, size = s.length(); i < size; ++i) { char c = s[i]; - - switch (state) - { + + switch (state) + { case 0: // Normal state if (c == '\\') state = 1; else v.push_back(c); - break; + break; - case 1: // Last char is a '\' + case 1: // Last char is a '\' if (c == '\\') { state = 0; @@ -288,7 +288,7 @@ static keyseq parse_keyseq( std::string s ) { state = 2; num = 0; - } + } // XXX Error handling break; @@ -316,15 +316,15 @@ static keyseq parse_keyseq( std::string s ) } } } - + return (v); } /* * Serializes a key sequence into a string of the format described - * above. + * above. */ -static std::string vtostr( const keyseq &seq ) +static std::string vtostr( const keyseq &seq ) { std::ostringstream s; @@ -339,8 +339,8 @@ static std::string vtostr( const keyseq &seq ) v = &dummy; } - - for (keyseq::const_iterator i = v->begin(); i != v->end(); i++) + + for (keyseq::const_iterator i = v->begin(); i != v->end(); i++) { if (*i <= 32 || *i > 127) { if (*i == KEY_MACRO_MORE_PROTECT) @@ -357,14 +357,14 @@ static std::string vtostr( const keyseq &seq ) s << static_cast<char>(*i); } } - + return (s.str()); } /* * Add a macro (suprise, suprise). */ -static void macro_add( macromap &mapref, keyseq key, keyseq action ) +static void macro_add( macromap &mapref, keyseq key, keyseq action ) { mapref[key] = action; } @@ -382,14 +382,14 @@ static void macro_add( macromap &mapref, keyseq key, const char *buff ) */ static void macro_del( macromap &mapref, keyseq key ) { - mapref.erase( key ); + mapref.erase( key ); } /* * Adds keypresses from a sequence into the internal keybuffer. Ignores - * macros. + * macros. */ -void macro_buf_add( const keyseq &actions, bool reverse) +void macro_buf_add( const keyseq &actions, bool reverse) { keyseq act; bool need_more_reset = false; @@ -409,12 +409,12 @@ void macro_buf_add( const keyseq &actions, bool reverse) Buffer.insert( reverse? Buffer.begin() : Buffer.end(), act.begin(), act.end() ); -} +} /* * Adds a single keypress into the internal keybuffer. */ -void macro_buf_add( int key, bool reverse ) +void macro_buf_add( int key, bool reverse ) { if (reverse) Buffer.push_front( key ); @@ -425,52 +425,52 @@ void macro_buf_add( int key, bool reverse ) /* * Adds keypresses from a sequence into the internal keybuffer. Does some - * O(N^2) analysis to the sequence to replace macros. + * O(N^2) analysis to the sequence to replace macros. */ static void macro_buf_add_long( keyseq actions, - macromap &keymap = Keymaps[KC_DEFAULT] ) + macromap &keymap = Keymaps[KC_DEFAULT] ) { keyseq tmp; - + // debug << "Adding: " << vtostr(actions) << endl; // debug.flush(); - - // Check whether any subsequences of the sequence are macros. + + // Check whether any subsequences of the sequence are macros. // The matching starts from as early as possible, and is // as long as possible given the first constraint. I.e from - // the sequence "abcdef" and macros "ab", "bcde" and "de" + // the sequence "abcdef" and macros "ab", "bcde" and "de" // "ab" and "de" are recognized as macros. - - while (actions.size() > 0) + + while (actions.size() > 0) { tmp = actions; - - while (tmp.size() > 0) + + while (tmp.size() > 0) { keyseq result = keymap[tmp]; - - // Found a macro. Add the expansion (action) of the - // macro into the buffer. + + // Found a macro. Add the expansion (action) of the + // macro into the buffer. if (result.size() > 0) { macro_buf_add( result ); break; } - + // Didn't find a macro. Remove a key from the end - // of the sequence, and try again. + // of the sequence, and try again. tmp.pop_back(); - } - + } + 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. + // into the buffer, remove it from the sequence, and try again. macro_buf_add( actions.front() ); actions.pop_front(); } else { // Found a macro, which has already been added above. Now just - // remove the macroed keys from the sequence. + // remove the macroed keys from the sequence. for (unsigned int i = 0; i < tmp.size(); i++) actions.pop_front(); } @@ -485,7 +485,7 @@ bool is_processing_macro() } /* - * Command macros are only applied from the immediate front of the + * Command macros are only applied from the immediate front of the * buffer, and only when the game is expecting a command. */ static void macro_buf_apply_command_macro( void ) @@ -495,7 +495,7 @@ static void macro_buf_apply_command_macro( void ) // find the longest match from the start of the buffer and replace it while (tmp.size() > 0) { - const keyseq &result = Macros[tmp]; + const keyseq &result = Macros[tmp]; if (result.size() > 0) { @@ -513,7 +513,7 @@ static void macro_buf_apply_command_macro( void ) macro_buf_add(result, true); - break; + break; } tmp.pop_back(); @@ -524,7 +524,7 @@ static void macro_buf_apply_command_macro( void ) * Removes the earliest keypress from the keybuffer, and returns its * value. If buffer was empty, returns -1; */ -static int macro_buf_get( void ) +static int macro_buf_get( void ) { if (Buffer.size() == 0) { @@ -550,13 +550,13 @@ static int macro_buf_get( void ) static void write_map(std::ofstream &f, const macromap &mp, const char *key) { - for (macromap::const_iterator i = mp.begin(); i != mp.end(); i++) + for (macromap::const_iterator i = mp.begin(); i != mp.end(); i++) { - // Need this check, since empty values are added into the + // Need this check, since empty values are added into the // macro struct for all used keyboard commands. if (i->second.size()) { - f << key << vtostr((*i).first) << std::endl + f << key << vtostr((*i).first) << std::endl << "A:" << vtostr((*i).second) << std::endl << std::endl; } } @@ -565,7 +565,7 @@ static void write_map(std::ofstream &f, const macromap &mp, const char *key) /* * Saves macros into the macrofile, overwriting the old one. */ -void macro_save( void ) +void macro_save( void ) { std::ofstream f; f.open( get_macro_file().c_str() ); @@ -581,19 +581,19 @@ void macro_save( void ) f << "# Command Macros:" << std::endl; write_map(f, Macros, "M:"); - + f.close(); } /* - * Reads as many keypresses as are available (waiting for at least one), - * and returns them as a single keyseq. + * Reads as many keypresses as are available (waiting for at least one), + * and returns them as a single keyseq. */ -static keyseq getch_mul( int (*rgetch)() = NULL ) +static keyseq getch_mul( int (*rgetch)() = NULL ) { - keyseq keys; + keyseq keys; int a; - + // Something's gone wrong with replaying keys if crawl needs to // get new keys from the user. if (crawl_state.is_replaying_keys()) @@ -607,30 +607,30 @@ static keyseq getch_mul( int (*rgetch)() = NULL ) rgetch = m_getch; keys.push_back( a = rgetch() ); - - // 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. + + // 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)) { keys.push_back( a = rgetch() ); } - + return (keys); } -/* - * Replacement for getch(). Returns keys from the key buffer if available. - * If not, adds some content to the buffer, and returns some of it. +/* + * Replacement for getch(). Returns keys from the key buffer if available. + * If not, adds some content to the buffer, and returns some of it. */ -int getchm( int (*rgetch)() ) +int getchm( int (*rgetch)() ) { return getchm( KC_DEFAULT, rgetch ); } -int getchm(KeymapContext mc, int (*rgetch)()) +int getchm(KeymapContext mc, int (*rgetch)()) { int a; - - // Got data from buffer. + + // Got data from buffer. if ((a = macro_buf_get()) != -1) return (a); @@ -642,11 +642,11 @@ int getchm(KeymapContext mc, int (*rgetch)()) return (macro_buf_get()); } -/* - * Replacement for getch(). Returns keys from the key buffer if available. - * If not, adds some content to the buffer, and returns some of it. +/* + * Replacement for getch(). Returns keys from the key buffer if available. + * If not, adds some content to the buffer, and returns some of it. */ -int getch_with_command_macros( void ) +int getch_with_command_macros( void ) { if (Buffer.size() == 0) { @@ -664,7 +664,7 @@ int getch_with_command_macros( void ) /* * Flush the buffer. Later we'll probably want to give the player options - * as to when this happens (ex. always before command input, casting failed). + * as to when this happens (ex. always before command input, casting failed). */ void flush_input_buffer( int reason ) { @@ -766,7 +766,7 @@ void macro_add_query( void ) cprintf( "%s" EOL, (vtostr( key )).c_str() ); // echo key to screen - if (mapref[key].size() > 0) + if (mapref[key].size() > 0) { mprf(MSGCH_WARN, "Current Action: %s", vtostr(mapref[key]).c_str()); mpr( "Do you wish to (r)edefine, (c)lear, or (a)bort?", MSGCH_PROMPT ); @@ -789,12 +789,12 @@ void macro_add_query( void ) mpr( "Input Macro Action: ", MSGCH_PROMPT ); - // Using getch_mul() here isn't very useful... We'd like the + // Using getch_mul() here isn't very useful... We'd like the // flexibility to define multicharacter macros without having // to resort to editing files and restarting the game. -- bwr // keyseq act = getch_mul(); - char buff[4096]; + char buff[4096]; get_input_line(buff, sizeof buff); if (Options.macro_meta_entry) @@ -819,28 +819,28 @@ static void _read_macros_from(const char* filename) keyseq key, action; bool keymap = false; KeymapContext keymc = KC_DEFAULT; - + f.open( filename ); - - while (f >> s) + + while (f >> s) { trim_string(s); // remove white space from ends - if (s[0] == '#') { + 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] == ':') { keymc = KeymapContext( KC_DEFAULT + s[1] - '0' ); if (keymc >= KC_DEFAULT && keymc < KC_CONTEXT_COUNT) { key = parse_keyseq(s.substr(3)); keymap = true; } - + } else if (s.substr(0, 2) == "M:") { key = parse_keyseq(s.substr(2)); keymap = false; @@ -852,7 +852,7 @@ static void _read_macros_from(const char* filename) } } -int macro_init( void ) +int macro_init( void ) { _read_macros_from(get_macro_file().c_str()); @@ -960,7 +960,7 @@ void remove_key_recorder(key_recorder* recorder) { std::vector<key_recorder*>::iterator i; - for(i = recorders.begin(); i != recorders.end(); i++) + for (i = recorders.begin(); i != recorders.end(); i++) if (*i == recorder) { recorders.erase(i); diff --git a/crawl-ref/source/message.cc b/crawl-ref/source/message.cc index abb7f2f7fa..1659f230b1 100644 --- a/crawl-ref/source/message.cc +++ b/crawl-ref/source/message.cc @@ -109,7 +109,7 @@ namespace msg { this->muted = m; } - + // again, can be improved int mpr_stream_buf::overflow(int c) { @@ -121,7 +121,7 @@ namespace msg // null-terminate and print the string internal_buf[internal_count] = 0; mpr(internal_buf, channel, param); - + internal_count = 0; // reset to defaults (param changing isn't sticky) @@ -129,7 +129,7 @@ namespace msg } else internal_buf[internal_count++] = c; - + if ( internal_count + 3 > INTERNAL_LENGTH ) { mpr("oops, hit overflow", MSGCH_DANGER); @@ -226,7 +226,7 @@ int channel_to_colour( msg_channel_type channel, int param ) { if (you.asleep()) return (DARKGREY); - + char ret; switch (Options.channels[ channel ]) @@ -361,11 +361,11 @@ int channel_to_colour( msg_channel_type channel, int param ) #endif -static void do_message_print( msg_channel_type channel, int param, +static void do_message_print( msg_channel_type channel, int param, const char *format, va_list argp ) { char buff[200]; - vsnprintf( buff, sizeof( buff ), format, argp ); + vsnprintf( buff, sizeof( buff ), format, argp ); buff[199] = 0; mpr(buff, channel, param); @@ -377,7 +377,7 @@ void mprf( msg_channel_type channel, int param, const char *format, ... ) va_start( argp, format ); do_message_print( channel, param, format, argp ); va_end( argp ); -} +} void mprf( msg_channel_type channel, const char *format, ... ) { @@ -456,7 +456,7 @@ void mpr_comma_separated_list(const std::string prefix, std::string out = prefix; unsigned width = get_number_of_cols() - 1; - for(int i = 0, size = list.size(); i < size; i++) + for (int i = 0, size = list.size(); i < size; i++) { std::string new_str = list[i]; @@ -610,7 +610,7 @@ static int prepare_message(const std::string& imsg, msg_channel_type channel, mpr_check_patterns(imsg, channel, param); flush_input_buffer( FLUSH_ON_MESSAGE ); const int num_lines = crawl_view.msgsz.y; - + if (New_Message_Count == num_lines - 1) more(); } @@ -621,7 +621,7 @@ static void base_mpr(const char *inf, msg_channel_type channel, int param) { const std::string imsg = inf; const int colour = prepare_message( imsg, channel, param ); - + if ( colour == MSGCOL_MUTED ) return; @@ -630,7 +630,7 @@ static void base_mpr(const char *inf, msg_channel_type channel, int param) { return; } - + if (need_prefix) { message_out( Message_Line, colour, "-", 1, false ); @@ -695,7 +695,7 @@ void formatted_mpr(const formatted_string& fs, msg_channel_type channel, // messages. // // If wrap_col > 0, text is wrapped at that column. -// +// void formatted_message_history(const std::string &st_nocolor, msg_channel_type channel, int param, int wrap_col) @@ -832,7 +832,7 @@ std::string get_last_messages(int mcount) { if (mcount <= 0) return std::string(); - + if (mcount > NUM_STORED_MESSAGES) mcount = NUM_STORED_MESSAGES; @@ -847,7 +847,7 @@ std::string get_last_messages(int mcount) for (int i = initial; i != Next_Message; ) { const message_item &msg = Store_Message[i]; - + if (msg.text.length() && is_channel_dumpworthy(msg.channel)) { text += msg.text; @@ -973,7 +973,7 @@ void replay_messages(void) } else if (win_start_line >= first_message) rel_start = win_start_line - first_message + 1; - else + else rel_start = (win_start_line + NUM_STORED_MESSAGES) - first_message + 1; int rel_end = rel_start + (num_lines - 2) - 1; @@ -984,7 +984,7 @@ void replay_messages(void) cprintf(EOL); cprintf( "<< Lines %d-%d of %d (Up: k<-8, Down: j>+2) >>", rel_start, rel_end, num_msgs ); - + keyin = getch(); if ((full_buffer && NUM_STORED_MESSAGES > num_lines - 2) @@ -1001,7 +1001,7 @@ void replay_messages(void) if (keyin == 'k' || keyin == '8' || keyin == '-' || keyin == '<') { new_line = win_start_line - (num_lines - 2); - + // end_mark is equivalent to Next_Message, but // is always less than win_start_line. end_mark = first_message; @@ -1037,7 +1037,7 @@ void replay_messages(void) // hit bottom if (new_line >= end_mark - (num_lines - 2)) - new_line = end_mark - (num_lines - 2) + 1; + new_line = end_mark - (num_lines - 2) + 1; if (new_line >= NUM_STORED_MESSAGES) new_line -= NUM_STORED_MESSAGES; diff --git a/crawl-ref/source/monplace.cc b/crawl-ref/source/monplace.cc index 01611ef586..756417bdde 100644 --- a/crawl-ref/source/monplace.cc +++ b/crawl-ref/source/monplace.cc @@ -378,7 +378,7 @@ static int resolve_monster_type(int mon_type, proximity_type proximity, { int tries = 0; int pval = 0; - while(++tries <= 320) + while (++tries <= 320) { px = 5 + random2(GXM - 10); py = 5 + random2(GYM - 10); @@ -517,7 +517,7 @@ bool place_monster(int &id, int mon_type, int power, beh_type behaviour, // c) in the 'correct' proximity to the player dungeon_feature_type grid_wanted = habitat2grid( mons_habitat_by_type(mon_type) ); - while(true) + while (true) { // handled above, won't change anymore if (proximity == PROX_NEAR_STAIRS && tries) @@ -676,7 +676,7 @@ bool place_monster(int &id, int mon_type, int power, beh_type behaviour, menv[id].flags |= MF_BAND_MEMBER; // (5) for each band monster, loop call to place_monster_aux(). - for(i = 1; i < band_size; i++) + for (i = 1; i < band_size; i++) { const int band_id = place_monster_aux( band_monsters[i], behaviour, target, px, py, diff --git a/crawl-ref/source/mstuff2.cc b/crawl-ref/source/mstuff2.cc index 08705851d7..b99185c2bb 100644 --- a/crawl-ref/source/mstuff2.cc +++ b/crawl-ref/source/mstuff2.cc @@ -978,14 +978,14 @@ void monster_teleport(struct monsters *monster, bool instan, bool silent) mons_clear_trapping_net(monster); int newx, newy; - while(true) + while (true) { newx = 10 + random2(GXM - 20); newy = 10 + random2(GYM - 20); // don't land on top of another monster if (mgrd[newx][newy] != NON_MONSTER - || (newx == you.x_pos && newy == you.y_pos)) + || newx == you.x_pos && newy == you.y_pos) { continue; } diff --git a/crawl-ref/source/output.cc b/crawl-ref/source/output.cc index dcbf49ff5a..d18d88029e 100644 --- a/crawl-ref/source/output.cc +++ b/crawl-ref/source/output.cc @@ -119,7 +119,7 @@ static int _draw_colour_bar(int val, int max_val, int old_val, int old_disp, if (max_val <= 0) return -1; - + // Don't redraw colour bars while resting // *unless* we'll stop doing so right after that if (you.running >= 2 && is_resting() && val != max_val) @@ -204,7 +204,7 @@ static int _count_digits(int val) static std::string _describe_hunger() { bool vamp = (you.species == SP_VAMPIRE); - + switch (you.hunger_state) { case HS_ENGORGED: @@ -458,7 +458,7 @@ static void _print_stats_qv(int y) cgotoxy(1, y, GOTO_STAT); textcolor(Options.status_caption_colour); cprintf("Qv: "); - + const item_def* item; int q; you.m_quiver->get_desired_item(&item, &q); @@ -649,7 +649,7 @@ static void _print_stats_line2(int y) _dur_colour( BLUE, (you.duration[DUR_SILENCE] <= 20) ); cprintf("Touch "); } - + if (you.duration[DUR_BARGAIN] && wherex() < get_number_of_cols() - 5) { _dur_colour( BLUE, (you.duration[DUR_BARGAIN] <= 15) ); @@ -690,7 +690,7 @@ static void _print_stats_line3(int y) textcolor( RED ); // no different levels cprintf( "Conf " ); } - + if (you.duration[DUR_BEHELD]) { textcolor( RED ); // no different levels @@ -845,7 +845,7 @@ void print_stats(void) you.wield_change = false; you.redraw_quiver = false; - + if (you.redraw_status_flags & REDRAW_LINE_1_MASK) _print_stats_line1(12); @@ -1015,7 +1015,7 @@ monster_pane_info::less_than(const monster_pane_info& m1, return false; } - + void monster_pane_info::to_string( int count, @@ -1264,7 +1264,7 @@ const char *equip_slot_to_name(int equip) if (equip < 0 || equip >= NUM_EQUIP) return ""; - + return s_equip_slot_names[equip]; } @@ -1327,7 +1327,7 @@ std::vector<formatted_string> get_full_detail(bool calc_unid, long sc) const std::string score = (sc > -1? make_stringf(" (%ld points)", sc) : ""); - + snprintf(buf, sizeof buf, "<yellow>%s the %s</yellow>%s\n\n" "Race : %s\n" @@ -1469,7 +1469,7 @@ std::vector<formatted_string> get_full_detail(bool calc_unid, long sc) EQ_GLOVES, EQ_BOOTS, EQ_AMULET, EQ_RIGHT_RING, EQ_LEFT_RING }; - for(int i = 0; i < NUM_EQUIP; i++) + for (int i = 0; i < NUM_EQUIP; i++) { int eqslot = e_order[i]; const char *slot = equip_slot_to_name( eqslot ); @@ -1581,7 +1581,7 @@ static void _print_overview_screen_equip(column_composer& cols, }; char buf[100]; - for(int i = 0; i < NUM_EQUIP; i++) + for (int i = 0; i < NUM_EQUIP; i++) { int eqslot = e_order[i]; @@ -1704,7 +1704,7 @@ static std::string _overview_screen_title() text += std::string(get_number_of_cols() - linelength - 1, ' '); text += time_turns; text += "</yellow>\n"; - + return text; } @@ -1998,7 +1998,7 @@ std::string _status_mut_abilities() text += "recuperating"; else text += "regenerating"; - + if (you.species == SP_VAMPIRE && you.hunger_state != HS_SATIATED) { if (you.hunger_state <= HS_HUNGRY) @@ -2035,10 +2035,10 @@ std::string _status_mut_abilities() if (you.duration[DUR_DEATH_CHANNEL]) text += "death channel, "; - if (you.duration[DUR_FORESCRY]) + if (you.duration[DUR_FORESCRY]) text += "forewarned, "; - if (you.duration[DUR_SILENCE]) + if (you.duration[DUR_SILENCE]) text += "radiating silence, "; if (you.duration[DUR_INVIS]) @@ -2135,7 +2135,7 @@ std::string _status_mut_abilities() (mr < 120) ? "very" : (mr < 140) ? "extremely" : "incredibly"); - + text += info; // character evaluates their ability to sneak around: @@ -2908,7 +2908,7 @@ std::string _status_mut_abilities() //---------------------------- // print ability information //---------------------------- - + text += print_abilities(); linebreak_string2(text, get_number_of_cols()); diff --git a/crawl-ref/source/stuff.cc b/crawl-ref/source/stuff.cc index b8f862365c..8b8e4da889 100644 --- a/crawl-ref/source/stuff.cc +++ b/crawl-ref/source/stuff.cc @@ -1399,8 +1399,7 @@ int near_stairs(const coord_def &p, int max_dist, { coord_def inc; for (inc.x = -max_dist; inc.x <= max_dist; inc.x++) - { - for(inc.y = -max_dist; inc.y <= max_dist; inc.y++) + for (inc.y = -max_dist; inc.y <= max_dist; inc.y++) { const coord_def np(p + inc); @@ -1433,7 +1432,6 @@ int near_stairs(const coord_def &p, int max_dist, return (np == you.pos()? 2 : 1); } } - } return false; } diff --git a/crawl-ref/source/tags.cc b/crawl-ref/source/tags.cc index 78a74fd8b7..736fb7ce90 100644 --- a/crawl-ref/source/tags.cc +++ b/crawl-ref/source/tags.cc @@ -785,7 +785,7 @@ void tag_set_expected(char tags[], int fileType) { int i; - for(i=0; i<NUM_TAGS; i++) + for (i=0; i<NUM_TAGS; i++) { tags[i] = -1; switch(fileType) @@ -2104,16 +2104,16 @@ void tag_missing_level_attitude() // can be used to determine friendly/neutral/ // hostile. int i; - bool isFriendly; + bool is_friendly; unsigned int new_beh = BEH_WANDER; - for(i=0; i<MAX_MONSTERS; i++) + for (i = 0; i < MAX_MONSTERS; i++) { // only do actual monsters if (menv[i].type < 0) continue; - isFriendly = testbits(menv[i].flags, MF_CREATED_FRIENDLY); + is_friendly = testbits(menv[i].flags, MF_CREATED_FRIENDLY); menv[i].foe = MHITNOT; @@ -2132,13 +2132,13 @@ void tag_missing_level_attitude() break; case 7: // old BEH_ENSLAVED if (!menv[i].has_ench(ENCH_CHARM)) - isFriendly = true; + is_friendly = true; break; default: break; } - menv[i].attitude = (isFriendly)? ATT_FRIENDLY : ATT_HOSTILE; + menv[i].attitude = (is_friendly) ? ATT_FRIENDLY : ATT_HOSTILE; menv[i].behaviour = static_cast<beh_type>(new_beh); menv[i].foe_memory = 0; } diff --git a/crawl-ref/source/tile2.cc b/crawl-ref/source/tile2.cc index 3d466581ec..64d5227eee 100644 --- a/crawl-ref/source/tile2.cc +++ b/crawl-ref/source/tile2.cc @@ -4,7 +4,7 @@ * * Modified for Crawl Reference by $Author: j-p-e-g $ on $Date: 2008-03-07 $ */ - + #include "AppHdr.h" #ifdef USE_TILE @@ -381,7 +381,7 @@ void _clear_tcache() tc[i].prev = NULL; else tc[i].prev = &tc[i-1]; - + if (i == i_end) tc[i].next = NULL; else @@ -563,7 +563,7 @@ void _register_tile_mask(int tile, int region, int *copy, int ux = wx; int uy = wy; img_type src = TileImg; - + tile &= TILE_FLAG_MASK; x0 = (tile % TILE_PER_ROW) * TILE_X; @@ -606,7 +606,7 @@ void _tile_draw_grid(int kind, int xx, int yy) if (xx < 0 || yy < 0 || xx >= tile_xmax || yy>= tile_ymax) return; - + fg[0] = t1buf[xx+1][yy+1]; bg[0] = t2buf[xx+1][yy+1]; @@ -615,7 +615,7 @@ void _tile_draw_grid(int kind, int xx, int yy) ix = _tcache_find_id_normal(kind, fg, bg, &is_new); screen_tcach_idx[kind][xx+yy*tile_xmax] = ix; - + if (is_new || ix!=ix_old || force_redraw_tile) { int x_dest = tcache_ox_normal[kind]+xx* TILE_UX_NORMAL; @@ -633,12 +633,12 @@ static void _update_single_grid(int x, int y) int sx, sy, wx, wy; _tile_draw_grid(TCACHE0_NORMAL, x, y); - + sx = x*TILE_UX_NORMAL; sy = y*TILE_UY_NORMAL; wx = TILE_UX_NORMAL; wy = TILE_UY_NORMAL; - + region_tile->redraw(sx, sy, sx+wx-1, sy+wy-1); } @@ -776,7 +776,7 @@ void _tcache_compose_normal(int ix, int *fg, int *bg) NULL); status_shift += 5; } - + if (fg0 & TILE_FLAG_POISON) { _tcache_overlay(tc_img, ix, TILE_POISON, TREGION_0_NORMAL, &c, NULL, @@ -874,7 +874,7 @@ void LoadDungeonView(unsigned int *tileb) { if (tileb[count] == tileb[count+1]) tileb[count] = 0; - + t1buf[x+1][y+1] = tileb[count++]; t2buf[x+1][y+1] = tileb[count++]; } @@ -1099,7 +1099,7 @@ void WallIdx(int &wall, int &floor, int &special) int depth = player_branch_depth(); int branch_depth = your_branch().depth; - + switch (you.where_are_you) { case BRANCH_MAIN_DUNGEON: @@ -1329,7 +1329,7 @@ static bool _draw_doll(img_type img, dolls_data *doll, bool force_redraw = false if (default_parts[TILEP_PART_BASE] != parts[TILEP_PART_BASE]) force_redraw = true; - + parts[TILEP_PART_BASE] = default_parts[TILEP_PART_BASE]; // TODO enne - make these configurable. @@ -1428,7 +1428,7 @@ static bool _draw_doll(img_type img, dolls_data *doll, bool force_redraw = false // There is player_has_claws() but it is not equivalent. // Claws appear if they're big enough to not wear gloves // or on races that have claws. - if (parts2[i] == 0 && (you.mutation[MUT_CLAWS] >= 3 || + if (parts2[i] == 0 && (you.mutation[MUT_CLAWS] >= 3 || you.species == SP_TROLL || you.species == SP_GHOUL)) { parts2[i] = TILEP_ARM_CLAWS; @@ -1489,7 +1489,7 @@ static bool _draw_doll(img_type img, dolls_data *doll, bool force_redraw = false char tile = (parts2[p] == TILEP_BOOTS_NAGA_BARDING) ? TILEP_SHADOW_NAGA_BARDING : TILEP_SHADOW_CENTAUR_BARDING; - + _tcache_overlay_player(img, 0, 0, TILEP_PART_SHADOW, tile, TILE_Y, &c); } @@ -1702,7 +1702,7 @@ void TilePlayerEdit() tile_str = TILE_TEXT_DOLLS_E; sx = (tile_str % TILE_PER_ROW) * TILE_X; sy = (tile_str / TILE_PER_ROW) * TILE_Y; - + ImgCopy(TileImg, sx, sy, TILE_X, TILE_Y/2, ScrBufImg, (TILE_X * 3) - 8,PARTS_Y - 8 -24, 0); ImgCopy(TileImg, sx, sy+ TILE_Y/2, TILE_X, TILE_Y/2, @@ -1750,7 +1750,7 @@ void TilePlayerEdit() } else { - for(i = 0; i < PARTS_DISP_MAX; i++) + for (i = 0; i < PARTS_DISP_MAX; i++) { int index; if (dolls[cur_doll].parts[ p_lines[cur_part] ] @@ -1760,14 +1760,14 @@ void TilePlayerEdit() } else { - index = i + dolls[cur_doll].parts[ p_lines[cur_part] ] + index = i + dolls[cur_doll].parts[ p_lines[cur_part] ] - (PARTS_DISP_MAX / 2); } if (index < 0) index = index + tilep_parts_total[ p_lines[cur_part] ] + 1; if (index > tilep_parts_total[ p_lines[cur_part] ]) index = index - tilep_parts_total[ p_lines[cur_part] ] - 1; - + _tcache_overlay_player(PartsImg, i * TILE_X, 0, p_lines[cur_part], index, TILE_Y, &d); } @@ -1823,19 +1823,19 @@ void TilePlayerEdit() case 'h': inc = -1; break; - + case 'l': inc = +1; break; - + case 'H': inc = -PARTS_DISP_MAX; break; - + case 'L': inc = +PARTS_DISP_MAX; break; - + case 'j': if (cur_part < (PARTS_ITEMS-1) ) cur_part += 1; @@ -1873,7 +1873,7 @@ void TilePlayerEdit() case CONTROL('D'): tilep_job_default(you.char_class, current_gender, dolls[cur_doll].parts); - + for (i = 2; i < PARTS_ITEMS; i++) display_parts_idx(i); break; @@ -1944,10 +1944,10 @@ void TilePlayerEdit() * ( random2(tilep_parts_total[ TILEP_PART_BEARD ]) + 1 ); dolls[cur_doll].parts[TILEP_PART_HELM] = coinflip() * ( random2(tilep_parts_total[ TILEP_PART_HELM ]) + 1 ); - + for (i = 2; i < PARTS_ITEMS; i++) display_parts_idx(i); - + break; case '*': @@ -1992,7 +1992,7 @@ void TilePlayerEdit() cur_doll++; else cur_doll--; - + if (cur_doll < 0) cur_doll = DOLLS_MAX - 1; else if (cur_doll == DOLLS_MAX) @@ -2009,7 +2009,7 @@ void TilePlayerEdit() { if (*target == TILEP_SHOW_EQUIP) continue; - + (*target) += inc; (*target) += tilep_parts_total[ p_lines[cur_part] ] + 1; (*target) %= tilep_parts_total[ p_lines[cur_part] ] + 1; @@ -2056,10 +2056,8 @@ void TilePlayerEdit() } for (k = 0; k < tcache_kind; k++) - { - for( x = 0; x < tile_xmax * tile_ymax; x++) - screen_tcach_idx[k][x] = -1; - } + for (x = 0; x < tile_xmax * tile_ymax; x++) + screen_tcach_idx[k][x] = -1; clrscr(); redraw_screen(); @@ -2570,10 +2568,10 @@ static void _mcache_init() { mc_data[i].lock_flag = false; mc_data[i].next = NULL; - + if (i != N_MCACHE - 1) mc_data[i].next = &mc_data[i+1]; - + mc_data[i].idx = TILE_MCACHE_START + i; mc_data[i].mon_tile = 0; mc_data[i].equ_tile = 0; @@ -2673,10 +2671,10 @@ int TileMcacheFind(int mon_tile, int equ_tile, int draco) #endif if (best2 != -1) return best2; - + if (best3 != -1) return best3; - + if (draco != 0) return TILE_ERROR; else @@ -2696,20 +2694,20 @@ int TileMcacheFind(int mon_tile, int equ_tile, int draco) _mcache_compose_draco(mc->idx, draco, mon_tile, equ_tile); else _mcache_compose(mc->idx, mon_tile, equ_tile); - + mc->mon_tile = mon_tile; mc->equ_tile = equ_tile; mc->draco = draco; - + // move cache to the head to reduce future search time if (prev) prev->next = mc->next; if (mc != mc_head) mc->next = mc_head; - + mc_head = mc; mc->lock_flag = true; - + return mc->idx; } @@ -2846,24 +2844,24 @@ void TileDrawOneItem(int region, int i, char key, int idx, const int offset_amount = TILE_X/4; int offset = 0; - + int help = num; int c100 = help/100; help -= c100*100; - + if (c100) { _TilePutch('0' + c100, r->backbuf, dx+offset, dy); offset += offset_amount; } - + int c10 = help/10; if (c10 || c100) { _TilePutch('0' + c10, r->backbuf, dx+offset, dy); offset += offset_amount; } - + int c1 = help % 10; _TilePutch('0' + c1, r->backbuf, dx+offset, dy); } @@ -2878,19 +2876,19 @@ void TileDrawOneItem(int region, int i, char key, int idx, itemlist_key[i] = key; itemlist_idx[i] = idx; itemlist_iflag[i] = 0; - + if (floor) itemlist_iflag[i] |= TILEI_FLAG_FLOOR; - + if (tried) itemlist_iflag[i] |= TILEI_FLAG_TRIED; - + if (equip) itemlist_iflag[i] |= TILEI_FLAG_EQUIP; - + if (cursed) itemlist_iflag[i] |= TILEI_FLAG_CURSE; - + if (select) itemlist_iflag[i] |= TILEI_FLAG_SELECT; @@ -2980,7 +2978,7 @@ void TileMoveInvCursor(int ix) if (ix != -1) TileDrawInvCursor(ix, true); - + last_cursor = ix; } |