From: <dsh...@us...> - 2006-11-22 08:41:22
|
Revision: 452 http://svn.sourceforge.net/crawl-ref/?rev=452&view=rev Author: dshaligram Date: 2006-11-22 00:41:20 -0800 (Wed, 22 Nov 2006) Log Message: ----------- Merged stone_soup r15:451 into trunk. Modified Paths: -------------- trunk/crawl-ref/source/AppHdr.h trunk/crawl-ref/source/Crawl.xcodeproj/project.pbxproj trunk/crawl-ref/source/FixAry.h trunk/crawl-ref/source/FixVec.h trunk/crawl-ref/source/Kills.cc trunk/crawl-ref/source/Kills.h trunk/crawl-ref/source/abl-show.cc trunk/crawl-ref/source/abyss.cc trunk/crawl-ref/source/acr.cc trunk/crawl-ref/source/beam.cc trunk/crawl-ref/source/beam.h trunk/crawl-ref/source/chardump.cc trunk/crawl-ref/source/chardump.h trunk/crawl-ref/source/cloud.cc trunk/crawl-ref/source/clua.cc trunk/crawl-ref/source/command.cc trunk/crawl-ref/source/command.h trunk/crawl-ref/source/debug.cc trunk/crawl-ref/source/debug.h trunk/crawl-ref/source/decks.cc trunk/crawl-ref/source/decks.h trunk/crawl-ref/source/defines.h trunk/crawl-ref/source/delay.cc trunk/crawl-ref/source/delay.h trunk/crawl-ref/source/describe.cc trunk/crawl-ref/source/describe.h trunk/crawl-ref/source/direct.cc trunk/crawl-ref/source/direct.h trunk/crawl-ref/source/dungeon.cc trunk/crawl-ref/source/dungeon.h trunk/crawl-ref/source/effects.cc trunk/crawl-ref/source/effects.h trunk/crawl-ref/source/enum.h trunk/crawl-ref/source/externs.h trunk/crawl-ref/source/fight.cc trunk/crawl-ref/source/fight.h trunk/crawl-ref/source/files.cc trunk/crawl-ref/source/files.h trunk/crawl-ref/source/food.cc trunk/crawl-ref/source/food.h trunk/crawl-ref/source/hiscores.cc trunk/crawl-ref/source/hiscores.h trunk/crawl-ref/source/initfile.cc trunk/crawl-ref/source/initfile.h trunk/crawl-ref/source/insult.cc trunk/crawl-ref/source/invent.cc trunk/crawl-ref/source/invent.h trunk/crawl-ref/source/it_use2.cc trunk/crawl-ref/source/it_use2.h trunk/crawl-ref/source/it_use3.cc trunk/crawl-ref/source/item_use.cc trunk/crawl-ref/source/item_use.h trunk/crawl-ref/source/itemname.cc trunk/crawl-ref/source/itemname.h trunk/crawl-ref/source/items.cc trunk/crawl-ref/source/items.h trunk/crawl-ref/source/lev-pand.cc trunk/crawl-ref/source/libunix.cc trunk/crawl-ref/source/libunix.h trunk/crawl-ref/source/libutil.cc trunk/crawl-ref/source/libutil.h trunk/crawl-ref/source/libw32c.cc trunk/crawl-ref/source/libw32c.h trunk/crawl-ref/source/lua/runrest.lua trunk/crawl-ref/source/lua/stash.lua trunk/crawl-ref/source/macro.cc trunk/crawl-ref/source/macro.h trunk/crawl-ref/source/makefile trunk/crawl-ref/source/makefile.dos trunk/crawl-ref/source/makefile.mgw trunk/crawl-ref/source/makefile.obj trunk/crawl-ref/source/makefile.osx trunk/crawl-ref/source/maps.cc trunk/crawl-ref/source/maps.h trunk/crawl-ref/source/menu.cc trunk/crawl-ref/source/menu.h trunk/crawl-ref/source/message.cc trunk/crawl-ref/source/message.h trunk/crawl-ref/source/misc/header trunk/crawl-ref/source/misc.cc trunk/crawl-ref/source/misc.h trunk/crawl-ref/source/mon-data.h trunk/crawl-ref/source/mon-pick.cc trunk/crawl-ref/source/mon-pick.h trunk/crawl-ref/source/mon-spll.h trunk/crawl-ref/source/mon-util.cc trunk/crawl-ref/source/mon-util.h trunk/crawl-ref/source/monplace.cc trunk/crawl-ref/source/monplace.h trunk/crawl-ref/source/monspeak.cc trunk/crawl-ref/source/monstuff.cc trunk/crawl-ref/source/monstuff.h trunk/crawl-ref/source/mstuff2.cc trunk/crawl-ref/source/mstuff2.h trunk/crawl-ref/source/mutation.cc trunk/crawl-ref/source/newgame.cc trunk/crawl-ref/source/ouch.cc trunk/crawl-ref/source/ouch.h trunk/crawl-ref/source/output.cc trunk/crawl-ref/source/output.h trunk/crawl-ref/source/overmap.cc trunk/crawl-ref/source/overmap.h trunk/crawl-ref/source/player.cc trunk/crawl-ref/source/player.h trunk/crawl-ref/source/randart.cc trunk/crawl-ref/source/religion.cc trunk/crawl-ref/source/religion.h trunk/crawl-ref/source/shopping.cc trunk/crawl-ref/source/shopping.h trunk/crawl-ref/source/skills.cc trunk/crawl-ref/source/skills.h trunk/crawl-ref/source/skills2.cc trunk/crawl-ref/source/skills2.h trunk/crawl-ref/source/spells1.cc trunk/crawl-ref/source/spells1.h trunk/crawl-ref/source/spells2.cc trunk/crawl-ref/source/spells2.h trunk/crawl-ref/source/spells3.cc trunk/crawl-ref/source/spells3.h trunk/crawl-ref/source/spells4.cc trunk/crawl-ref/source/spells4.h trunk/crawl-ref/source/spl-book.cc trunk/crawl-ref/source/spl-book.h trunk/crawl-ref/source/spl-cast.cc trunk/crawl-ref/source/spl-cast.h trunk/crawl-ref/source/spl-data.h trunk/crawl-ref/source/spl-util.cc trunk/crawl-ref/source/spl-util.h trunk/crawl-ref/source/stash.cc trunk/crawl-ref/source/stash.h trunk/crawl-ref/source/stuff.cc trunk/crawl-ref/source/stuff.h trunk/crawl-ref/source/tags.cc trunk/crawl-ref/source/tags.h trunk/crawl-ref/source/transfor.cc trunk/crawl-ref/source/transfor.h trunk/crawl-ref/source/travel.cc trunk/crawl-ref/source/travel.h trunk/crawl-ref/source/unrand.h trunk/crawl-ref/source/version.h trunk/crawl-ref/source/view.cc trunk/crawl-ref/source/view.h Added Paths: ----------- trunk/crawl-ref/source/dat/ trunk/crawl-ref/source/dat/levdes.vim trunk/crawl-ref/source/dat/splev.des trunk/crawl-ref/source/dat/vaults.des trunk/crawl-ref/source/itemprop.cc trunk/crawl-ref/source/itemprop.h trunk/crawl-ref/source/libdos.cc trunk/crawl-ref/source/libdos.h trunk/crawl-ref/source/lua/safechnk.lua trunk/crawl-ref/source/lua/trapwalk.lua trunk/crawl-ref/source/makefile.unix trunk/crawl-ref/source/mapdef.cc trunk/crawl-ref/source/mapdef.h trunk/crawl-ref/source/misc/src-pkg-excludes.lst trunk/crawl-ref/source/notes.cc trunk/crawl-ref/source/notes.h trunk/crawl-ref/source/prebuilt/ trunk/crawl-ref/source/prebuilt/levcomp.lex.cc trunk/crawl-ref/source/prebuilt/levcomp.tab.cc trunk/crawl-ref/source/prebuilt/levcomp.tab.h trunk/crawl-ref/source/util/ trunk/crawl-ref/source/util/levcomp.cc trunk/crawl-ref/source/util/levcomp.h trunk/crawl-ref/source/util/levcomp.lpp trunk/crawl-ref/source/util/levcomp.ypp Removed Paths: ------------- trunk/crawl-ref/source/MacString.cc trunk/crawl-ref/source/MacString.h trunk/crawl-ref/source/libemx.cc trunk/crawl-ref/source/libemx.h trunk/crawl-ref/source/libmac.cc trunk/crawl-ref/source/libmac.h trunk/crawl-ref/source/lua/safechunk.lua trunk/crawl-ref/source/machdr.h trunk/crawl-ref/source/makefile.bor trunk/crawl-ref/source/makefile.bsd trunk/crawl-ref/source/makefile.emx trunk/crawl-ref/source/makefile.lnx trunk/crawl-ref/source/makefile.sgi trunk/crawl-ref/source/makefile.sol trunk/crawl-ref/source/wpn-misc.cc trunk/crawl-ref/source/wpn-misc.h Modified: trunk/crawl-ref/source/AppHdr.h =================================================================== --- trunk/crawl-ref/source/AppHdr.h 2006-11-21 22:19:04 UTC (rev 451) +++ trunk/crawl-ref/source/AppHdr.h 2006-11-22 08:41:20 UTC (rev 452) @@ -14,6 +14,8 @@ * * Copyright \xA9 1999 Jesse Jones. * + * Modified for Crawl Reference by $Author$ on $Date$ + * * Change History (most recent first): * * <9> 9 Aug 2001 MV Added USE_RIVERS,USE_NEW_UNRANDS @@ -58,36 +60,27 @@ // // #define CLUA_BINDINGS -// ========================================================================= -// System Defines -// ========================================================================= -// Define plain_term for Unix and dos_term for DOS and EMX. - -#if defined(LINUX) +// OS X's Terminal.app has color handling problems; dark grey is +// especially bad, so we'll want to remap that. OS X is otherwise +// Unix-ish, so we shouldn't need other special handling. +#if defined(OSX) #define UNIX - #define USE_UNIX_SIGNALS -#elif defined(SOLARIS) - #define UNIX - #define USE_UNIX_SIGNALS -#elif defined(BSD) - #define UNIX -#elif defined(OSX) - #define UNIX - // Darkgrey is a particular problem in Terminal.app. #define USE_8_COLOUR_TERM_MAP #define COL_TO_REPLACE_DARKGREY BLUE -#elif defined(HPUX) - #define UNIX - #define USE_UNIX_SIGNALS - // Under HP-UX it's typically easier to use ncurses than try and - // get the colour curses library to work. -- bwr - #define CURSES_INCLUDE_FILE <ncurses.h> #endif +// ========================================================================= +// System Defines +// ========================================================================= +// Define plain_term for Unix and dos_term for DOS. + #ifdef UNIX #define PLAIN_TERM #define MULTIUSER + #define USE_UNIX_SIGNALS + #define FILE_SEPARATOR '/' + #define CHARACTER_SET 0 #define USE_ASCII_CHARACTERS #define USE_CURSES @@ -143,30 +136,13 @@ #include "libunix.h" -// To compile with EMX for OS/2 define USE_EMX macro with compiler command line -// (already defined in supplied makefile.emx) -#elif defined(USE_EMX) - #define DOS_TERM - #define EOL "\n" - #define CHARACTER_SET A_ALTCHARSET - - #include <string> - #include "libemx.h" - #elif _MSC_VER >= 1100 #include <string> #include "WinHdr.h" #error MSVC is not supported yet #define CHARACTER_SET A_ALTCHARSET -// macintosh is predefined on all the common Mac compilers -#elif defined(macintosh) - #define PLAIN_TERM - #define HAS_NAMESPACES 1 - #define EOL "\r" - #define CHARACTER_SET A_ALTCHARSET - #include <string> - #include "libmac.h" + #define FILE_SEPARATOR '/' #elif defined(DOS) #define DOS_TERM @@ -174,13 +150,20 @@ #define EOL "\r\n" #define CHARACTER_SET A_ALTCHARSET + #define FILE_SEPARATOR '\\' + #include <string> + #include "libdos.h" #ifdef __DJGPP__ #define NEED_SNPRINTF + + // [dshaligram] This is distressing, but djgpp lacks (v)snprintf, and + // we have to support DOS. Ow. FIXME + #define vsnprintf(buf, size, format, args) vsprintf(buf, format, args) #endif -#elif defined(WIN32CONSOLE) && (defined(__IBMCPP__) || defined(__BCPLUSPLUS__) || defined(__MINGW32__)) +#elif defined(WIN32CONSOLE) && (defined(__IBMCPP__) || defined(__MINGW32__)) #include "libw32c.h" #define PLAIN_TERM #define SHORT_FILE_NAMES @@ -188,6 +171,9 @@ #define CHARACTER_SET A_ALTCHARSET #define getstr(X,Y) getConsoleString(X,Y) + // NT and better are happy with /; I'm not sure how 9x reacts. + #define FILE_SEPARATOR '/' + // Uncomment to play sounds. winmm must be linked in if this is uncommented. // #define WINMM_PLAY_SOUNDS @@ -271,9 +257,6 @@ //jmf: New defines for a bunch of optional features. // ================================================= -------------------------- -// New silence code -- seems to actually work! Use it! -#define USE_SILENCE_CODE - // Use special colours for various channels of messages #define USE_COLOUR_MESSAGES @@ -300,7 +283,7 @@ // mv: (new 9 Aug 01) turns off missile trails, might be slow on some computers // #define MISSILE_TRAILS_OFF -// bwr: allow player to destroy items in inventory (but not equiped items) +// bwr: allow player to destroy items in inventory (but not equipped items) // See comment at items.cc::cmd_destroy_item() for details/issues. // #define ALLOW_DESTROY_ITEM_COMMAND @@ -315,7 +298,7 @@ #ifdef MULTIUSER // Define SAVE_DIR to the directory where saves, bones, and score file - // will go... end it with a '\'. Since all player files will be in the + // will go... end it with a '/'. Since all player files will be in the // same directory, the players UID will be appended when this option // is set. // @@ -323,8 +306,14 @@ // be dumped in the current directory. // // #define SAVE_DIR_PATH "/opt/crawl/lib/" - #define SAVE_DIR_PATH "" + // #define SAVE_DIR_PATH "" + // Define DATA_DIR_PATH to the directory where level-description (.des) + // files are stored. NOTE: If you're installing Crawl for a real multiuser + // system, you MUST do this. The directory must exist on the filesystem. + + // #define DATA_DIR_PATH "/opt/crawl" + // will make this little thing go away. Define SAVE_PACKAGE_CMD // to a command to compress and bundle the save game files into a // single unit... the two %s will be replaced with the players @@ -334,15 +323,20 @@ // PACKAGE_SUFFIX is used when the package file name is needed // // Comment these lines out if you want to leave the save files uncompressed. - // - // #define SAVE_PACKAGE_CMD "/usr/bin/zip -m -q -j -1 %s.zip %s.*" - // #define LOAD_UNPACKAGE_CMD "/usr/bin/unzip -q -o %s.zip -d" SAVE_DIR_PATH - // #define PACKAGE_SUFFIX ".zip" + #define SAVE_PACKAGE_CMD "/usr/bin/zip -m -q -j -1 %s.zip %s.*" +#ifdef SAVE_DIR_PATH + #define LOAD_UNPACKAGE_CMD "/usr/bin/unzip -q -o %s.zip -d" SAVE_DIR_PATH +#else + #define LOAD_UNPACKAGE_CMD "/usr/bin/unzip -q -o %s.zip" +#endif - // This provides some rudimentary protection against people using - // save file cheats on multi-user systems. - #define DO_ANTICHEAT_CHECKS +#ifdef SAVE_PACKAGE_CMD + // This is used to unpack specific files from the archive. + #define UNPACK_SPECIFIC_FILE_CMD LOAD_UNPACKAGE_CMD " %s" +#endif + #define PACKAGE_SUFFIX ".zip" + // This defines the chmod permissions for score and bones files. #define SHARED_FILES_CHMOD_PRIVATE 0664 #define SHARED_FILES_CHMOD_PUBLIC 0664 Modified: trunk/crawl-ref/source/Crawl.xcodeproj/project.pbxproj =================================================================== (Binary files differ) Modified: trunk/crawl-ref/source/FixAry.h =================================================================== --- trunk/crawl-ref/source/FixAry.h 2006-11-21 22:19:04 UTC (rev 451) +++ trunk/crawl-ref/source/FixAry.h 2006-11-22 08:41:20 UTC (rev 452) @@ -3,6 +3,8 @@ * Summary: Fixed size 2D vector class that asserts if you do something bad. * Written by: Jesse Jones * + * Modified for Crawl Reference by $Author$ on $Date$ + * * Change History (most recent first): * * <1> 6/16/00 JDJ Created Modified: trunk/crawl-ref/source/FixVec.h =================================================================== --- trunk/crawl-ref/source/FixVec.h 2006-11-21 22:19:04 UTC (rev 451) +++ trunk/crawl-ref/source/FixVec.h 2006-11-22 08:41:20 UTC (rev 452) @@ -12,7 +12,8 @@ #ifndef FIXVEC_H #define FIXVEC_H -#include <stdarg.h> +#include <cstdarg> +#include <cstring> #include "debug.h" @@ -39,16 +40,6 @@ typedef TYPE* iterator; typedef const TYPE* const_iterator; -#if 0 -#if MSVC >= 1100 - typedef std::reverse_iterator<const_iterator, const TYPE> const_reverse_iterator; - typedef std::reverse_iterator<iterator, TYPE> reverse_iterator; -#else - typedef std::reverse_iterator<const_iterator> const_reverse_iterator; - typedef std::reverse_iterator<iterator> reverse_iterator; -#endif -#endif - //----------------------------------- // Initialization/Destruction // @@ -57,6 +48,10 @@ FixedVector() {} + FixedVector(TYPE def) : mData() { + init(def); + } + FixedVector(TYPE value0, TYPE value1, ...); // Allows for something resembling C array initialization, eg // instead of "int a[3] = {0, 1, 2}" you'd use "FixedVector<int, 3> @@ -71,35 +66,31 @@ // API // public: - // ----- Size ----- - bool empty() const {return SIZE == 0;} - int size() const {return SIZE;} +// ----- Size ----- + bool empty() const {return SIZE == 0;} + size_t size() const {return SIZE;} - // ----- Access ----- - TYPE& operator[](unsigned long index) {ASSERT(index < SIZE); return mData[index];} - const TYPE& operator[](unsigned long index) const {ASSERT(index < SIZE); return mData[index];} - - TYPE& front() {ASSERT(SIZE > 0); return mData[0];} - const TYPE& front() const {ASSERT(SIZE > 0); return mData[0];} +// ----- Access ----- + TYPE& operator[](unsigned long index) {ASSERT(index < SIZE); return mData[index];} + const TYPE& operator[](unsigned long index) const {ASSERT(index < SIZE); return mData[index];} + + TYPE& front() {ASSERT(SIZE > 0); return mData[0];} + const TYPE& front() const {ASSERT(SIZE > 0); return mData[0];} - TYPE& back() {ASSERT(SIZE > 0); return mData[SIZE - 1];} - const TYPE& back() const {ASSERT(SIZE > 0); return mData[SIZE - 1];} - - TYPE* buffer() {return mData;} - const TYPE* buffer() const {return mData;} + TYPE& back() {ASSERT(SIZE > 0); return mData[SIZE - 1];} + const TYPE& back() const {ASSERT(SIZE > 0); return mData[SIZE - 1];} + + TYPE* buffer() {return mData;} + const TYPE* buffer() const {return mData;} - // ----- Iterating ----- - iterator begin() {return mData;} - const_iterator begin() const {return mData;} +// ----- Iterating ----- + iterator begin() {return mData;} + const_iterator begin() const {return mData;} - iterator end() {return this->begin() + this->size();} - const_iterator end() const {return this->begin() + this->size();} + iterator end() {return this->begin() + this->size();} + const_iterator end() const {return this->begin() + this->size();} -// reverse_iterator rbegin() {return reverse_iterator(this->end());} -// const_reverse_iterator rbegin() const {return const_reverse_iterator(this->end());} - -// reverse_iterator rend() {return reverse_iterator(this->begin());} -// const_reverse_iterator rend() const {return const_reverse_iterator(this->begin());} + void init(TYPE def); //----------------------------------- // Member Data @@ -115,19 +106,26 @@ template <class TYPE, int SIZE> FixedVector<TYPE, SIZE>::FixedVector(TYPE value0, TYPE value1, ...) { - mData[0] = value0; - mData[1] = value1; + mData[0] = value0; + mData[1] = value1; - va_list ap; - va_start(ap, value1); // second argument is last fixed parameter + va_list ap; + va_start(ap, value1); // second argument is last fixed parameter - for (int index = 2; index < SIZE; index++) { - TYPE value = va_arg(ap, TYPE); + for (int index = 2; index < SIZE; index++) { + TYPE value = va_arg(ap, TYPE); - mData[index] = value; - } + mData[index] = value; + } - va_end(ap); + va_end(ap); } +template <class TYPE, int SIZE> +void FixedVector<TYPE, SIZE>::init(TYPE def) +{ + for (int i = 0; i < SIZE; ++i) + mData[i] = def; +} + #endif // FIXVEC_H Modified: trunk/crawl-ref/source/Kills.cc =================================================================== --- trunk/crawl-ref/source/Kills.cc 2006-11-21 22:19:04 UTC (rev 451) +++ trunk/crawl-ref/source/Kills.cc 2006-11-22 08:41:20 UTC (rev 452) @@ -2,18 +2,23 @@ * File: Kills.cc * Summary: Player kill tracking * Written by: Darshan Shaligram + * + * Modified for Crawl Reference by $Author$ on $Date$ */ #include "AppHdr.h" + +#include <algorithm> + #include "chardump.h" #include "describe.h" #include "mon-util.h" #include "files.h" #include "itemname.h" +#include "misc.h" #include "travel.h" #include "tags.h" #include "Kills.h" #include "clua.h" -#include <algorithm> #define KILLS_MAJOR_VERSION 4 #define KILLS_MINOR_VERSION 1 @@ -22,25 +27,6 @@ static void kill_lua_filltable(std::vector<kill_exp> &v); #endif - -unsigned short get_packed_place( unsigned char branch, int subdepth, - char level_type ) -{ - unsigned short place = (unsigned short) - ( (branch << 8) | subdepth ); - if (level_type == LEVEL_ABYSS || level_type == LEVEL_PANDEMONIUM - || level_type == LEVEL_LABYRINTH) - place = (unsigned short) ( (level_type << 8) | 0xFF ); - return place; -} - -unsigned short get_packed_place() -{ - return get_packed_place( you.where_are_you, - subdungeon_depth(you.where_are_you, you.your_level), - you.level_type ); -} - /////////////////////////////////////////////////////////////////////////// // KillMaster // @@ -52,7 +38,7 @@ "others", }; -const char *KillMaster::category_name(KillCategory kc) const +const char *KillMaster::category_name(kill_category kc) const { if (kc >= KC_YOU && kc < KC_NCATEGORIES) return (kill_category_names[kc]); @@ -95,7 +81,7 @@ void KillMaster::record_kill(const monsters *mon, int killer, bool ispet) { - KillCategory kc = + kill_category kc = (killer == KILL_YOU || killer == KILL_YOU_MISSILE)? KC_YOU : (ispet)? KC_FRIENDLY : KC_OTHER; @@ -134,7 +120,7 @@ kills, count, i == KC_YOU? NULL : - category_name((KillCategory) i), + category_name((kill_category) i), needseparator ); needseparator = true; } @@ -155,13 +141,11 @@ #endif { // We can sum up ourselves, if Lua doesn't want to. - // FIXME: I'm not happy with the looks/wording of the grand total - // count. if (categories > 1) { // Give ourselves a newline first - killtext += EOL; - killtext += grandt + EOL; + killtext += "\n"; + killtext += grandt + "\n"; } } @@ -201,23 +185,23 @@ } #endif if (separator) - killtext += EOL; + killtext += "\n"; killtext += "Vanquished Creatures"; if (category) killtext += std::string(" (") + category + ")"; - killtext += EOL; + killtext += "\n"; for (int i = 0, sz = kills.size(); i < sz; ++i) { killtext += " " + kills[i].desc; - killtext += EOL; + killtext += "\n"; } { char numbuf[100]; snprintf(numbuf, sizeof numbuf, - "%ld creature%s vanquished." EOL, count, + "%ld creature%s vanquished." "\n", count, count > 1? "s" : ""); killtext += numbuf; } @@ -240,10 +224,10 @@ i != k.kills.end(); ++i) { const kill_monster_desc &kmd = i->first; - kill_def &k = kills[kmd]; + kill_def &ki = kills[kmd]; const kill_def &ko = i->second; bool uniq = mons_is_unique(kmd.monnum); - k.merge(ko, uniq); + ki.merge(ko, uniq); } } @@ -290,85 +274,13 @@ return (count); } -// Takes a packed 'place' and returns a compact stringified place name. -// XXX: This is done in several other places; a unified function to -// describe places would be nice. -std::string short_place_name(unsigned short place) -{ - unsigned char branch = (unsigned char) ((place >> 8) & 0xFF); - int lev = place & 0xFF; - - const char *s; - bool level_num = false; - if (lev == 0xFF) - { - switch (branch) - { - case LEVEL_ABYSS: - s = "Abyss"; - break; - case LEVEL_PANDEMONIUM: - s = "Pan"; - break; - case LEVEL_LABYRINTH: - s = "Lab"; - break; - default: - s = "Buggy Badlands"; - break; - } - } - else - { - switch (branch) - { - case BRANCH_VESTIBULE_OF_HELL: - s = "Hell"; - break; - case BRANCH_HALL_OF_BLADES: - s = "Blade"; - break; - case BRANCH_ECUMENICAL_TEMPLE: - s = "Temple"; - break; - default: - level_num = true; - s = (branch == BRANCH_DIS) ? "Dis:" : - (branch == BRANCH_GEHENNA) ? "Geh:" : - (branch == BRANCH_COCYTUS) ? "Coc:" : - (branch == BRANCH_TARTARUS) ? "Tar:" : - (branch == BRANCH_ORCISH_MINES) ? "Orc:" : - (branch == BRANCH_HIVE) ? "Hive:" : - (branch == BRANCH_LAIR) ? "Lair:" : - (branch == BRANCH_SLIME_PITS) ? "Slime:" : - (branch == BRANCH_VAULTS) ? "Vault:" : - (branch == BRANCH_CRYPT) ? "Crypt:" : - (branch == BRANCH_HALL_OF_ZOT) ? "Zot:" : - (branch == BRANCH_SNAKE_PIT) ? "Snake:" : - (branch == BRANCH_ELVEN_HALLS) ? "Elf:" : - (branch == BRANCH_TOMB) ? "Tomb:" : - (branch == BRANCH_SWAMP) ? "Swamp:" : "D:"; - break; - } - } - - std::string pl = s; - if (level_num) - { - char buf[20]; - snprintf(buf, sizeof buf, "%d", lev); - pl += buf; - } - return pl; -} - void Kills::save(FILE *file) const { // How many kill records do we have? writeLong(file, kills.size()); - kill_map::const_iterator iter = kills.begin(); - for ( ; iter != kills.end(); ++iter) + for ( kill_map::const_iterator iter = kills.begin(); + iter != kills.end(); ++iter) { iter->first.save(file); iter->second.save(file); @@ -377,7 +289,7 @@ // How many ghosts do we have? writeShort(file, ghosts.size()); for (ghost_vec::const_iterator iter = ghosts.begin(); - iter != ghosts.end(); ++iter) + iter != ghosts.end(); ++iter) { iter->save(file); } @@ -407,13 +319,13 @@ void Kills::record_ghost_kill(const struct monsters *mon) { - kill_ghost ghost(mon); - ghosts.push_back(ghost); + kill_ghost ghostk(mon); + ghosts.push_back(ghostk); } kill_def::kill_def(const struct monsters *mon) : kills(0), exp(0) { - exp = exper_value( (struct monsters *) mon); + exp = exper_value(mon); add_kill(mon, get_packed_place()); } @@ -460,9 +372,7 @@ // whole name is not suffixed by a modifier, such as 'zombie' or 'skeleton' if ( (pos = name.find(" of ")) != std::string::npos && !ends_with(name, no_of) ) - { return pluralize(name.substr(0, pos)) + name.substr(pos); - } else if (ends_with(name, "us")) // Fungus, ufetubus, for instance. return name.substr(0, name.length() - 2) + "i"; @@ -704,7 +614,7 @@ kill_ghost::kill_ghost(const struct monsters *mon) { - exp = exper_value( (struct monsters *) mon); + exp = exper_value(mon); place = get_packed_place(); ghost_name = ghost.name; @@ -738,7 +648,6 @@ kill_monster_desc::kill_monster_desc(const monsters *mon) { - // TODO: We need to understand how shapeshifters are handled. monnum = mon->type; modifier = M_NORMAL; switch (mon->type) @@ -758,8 +667,8 @@ } if (modifier != M_NORMAL) monnum = mon->number; - if (mons_has_ench((struct monsters *) mon, ENCH_SHAPESHIFTER) || - mons_has_ench((struct monsters *) mon, ENCH_GLOWING_SHAPESHIFTER)) + if (mons_has_ench(mon, ENCH_SHAPESHIFTER) || + mons_has_ench(mon, ENCH_GLOWING_SHAPESHIFTER)) modifier = M_SHAPESHIFTER; // XXX: Ugly hack - merge all mimics into one mimic record. @@ -907,7 +816,7 @@ } else { - switch (mons_holiness(ke->monnum)) + switch (mons_class_holiness(ke->monnum)) { case MH_HOLY: verdict = "holy"; break; case MH_NATURAL: verdict = "natural"; break; @@ -985,7 +894,7 @@ *skill += s; *skill += "\n"; - + return 0; } Modified: trunk/crawl-ref/source/Kills.h =================================================================== --- trunk/crawl-ref/source/Kills.h 2006-11-21 22:19:04 UTC (rev 451) +++ trunk/crawl-ref/source/Kills.h 2006-11-22 08:41:20 UTC (rev 452) @@ -160,7 +160,7 @@ std::string kill_info() const; private: - const char *category_name(KillCategory kc) const; + const char *category_name(kill_category kc) const; Kills categorized_kills[KC_NCATEGORIES]; private: @@ -169,13 +169,6 @@ const; }; -unsigned short get_packed_place(); - -unsigned short get_packed_place( unsigned char branch, int subdepth, - char level_type ); - -std::string short_place_name(unsigned short place); - enum KILL_DUMP_OPTIONS { KDO_NO_PLACES, // Don't dump places at all Deleted: trunk/crawl-ref/source/MacString.cc =================================================================== --- trunk/crawl-ref/source/MacString.cc 2006-11-21 22:19:04 UTC (rev 451) +++ trunk/crawl-ref/source/MacString.cc 2006-11-22 08:41:20 UTC (rev 452) @@ -1,199 +0,0 @@ -/* - * File: MacString.cc - * Summary: Wrapper around an immutable CFString. - * Written by: Jesse Jones (jes...@mi...) - * - * Change History (most recent first): - * - * <1> 6/04/02 JDJ Created - */ - -#include "AppHdr.h" -#include "MacString.h" - -#if macintosh - -#include <CoreFoundation/CFString.h> - -#include "debug.h" - - -// ======================================================================== -// Internal Functions -// ======================================================================== - -//--------------------------------------------------------------- -// -// ThrowIf -// -//--------------------------------------------------------------- -static void ThrowIf(bool predicate, const std::string& text) -{ - if (predicate) - throw std::runtime_error(text); -} - -#if __MWERKS__ -#pragma mark - -#endif - -// ============================================================================ -// class MacString -// ============================================================================ - -//--------------------------------------------------------------- -// -// MacString::~MacString -// -//--------------------------------------------------------------- -MacString::~MacString() -{ - CFRelease(mString); -} - - -//--------------------------------------------------------------- -// -// MacString::MacString () -// -//--------------------------------------------------------------- -MacString::MacString() -{ - mString = CFStringCreateWithCharacters(kCFAllocatorSystemDefault, NULL, 0); - ThrowIf(mString == NULL, "Couldn't create the CFString"); -} - - -//--------------------------------------------------------------- -// -// MacString::MacString (unsigned char*) -// -//--------------------------------------------------------------- -MacString::MacString(const unsigned char* str) -{ - ASSERT(str != NULL); - - CFStringEncoding encoding = CFStringGetSystemEncoding(); - mString = CFStringCreateWithPascalString(kCFAllocatorSystemDefault, str, encoding); - ThrowIf(mString == NULL, "Couldn't create the CFString"); -} - - -//--------------------------------------------------------------- -// -// MacString::MacString (char*) -// -//--------------------------------------------------------------- -MacString::MacString(const char* str) -{ - ASSERT(str != NULL); - - CFStringEncoding encoding = CFStringGetSystemEncoding(); - mString = CFStringCreateWithCString(kCFAllocatorSystemDefault, str, encoding); - ThrowIf(mString == NULL, "Couldn't create the CFString"); -} - - -//--------------------------------------------------------------- -// -// MacString::MacString (CFStringRef) -// -//--------------------------------------------------------------- -MacString::MacString(CFStringRef str) -{ - ASSERT(str != NULL); - - mString = str; - CFRetain(mString); -} - - -//--------------------------------------------------------------- -// -// MacString::MacString (CFMutableStringRef) -// -//--------------------------------------------------------------- -MacString::MacString(CFMutableStringRef str) -{ - ASSERT(str != NULL); - - mString = CFStringCreateCopy(kCFAllocatorSystemDefault, str); - ThrowIf(mString == NULL, "Couldn't create the CFString"); -} - - -//--------------------------------------------------------------- -// -// MacString::MacString (int) -// -//--------------------------------------------------------------- -MacString::MacString(int value) -{ - char buffer[32]; - sprintf(buffer, "%d", value); - - CFStringEncoding encoding = CFStringGetSystemEncoding(); - mString = CFStringCreateWithCString(kCFAllocatorSystemDefault, buffer, encoding); - ThrowIf(mString == NULL, "Couldn't create the CFString"); -} - - -//--------------------------------------------------------------- -// -// MacString::MacString (MacString) -// -//--------------------------------------------------------------- -MacString::MacString(const MacString& str) -{ - mString = str.mString; // immutable so we can refcount - CFRetain(mString); -} - - -//--------------------------------------------------------------- -// -// MacString::operator= (MacString) -// -//--------------------------------------------------------------- -MacString& MacString::operator=(const MacString& rhs) -{ - if (this != &rhs) - { - CFRelease(mString); - - mString = rhs.mString; // immutable so we can refcount - CFRetain(mString); - } - - return *this; -} - - -//--------------------------------------------------------------- -// -// MacString::length -// -//--------------------------------------------------------------- -size_t MacString::length() const -{ - size_t len = (size_t) CFStringGetLength(mString); - - return len; -} - - -//--------------------------------------------------------------- -// -// MacString::CopyTo -// -//--------------------------------------------------------------- -void MacString::CopyTo(unsigned char* buffer, CFIndex bytes) -{ - ASSERT(buffer != NULL || bytes == 0); - - bool converted = CFStringGetPascalString(mString, buffer, bytes, CFStringGetSystemEncoding()); - ThrowIf(!converted, "Couldn't convert the CFString into a Pascal string"); -} - - -#endif // macintosh Deleted: trunk/crawl-ref/source/MacString.h =================================================================== --- trunk/crawl-ref/source/MacString.h 2006-11-21 22:19:04 UTC (rev 451) +++ trunk/crawl-ref/source/MacString.h 2006-11-22 08:41:20 UTC (rev 452) @@ -1,71 +0,0 @@ -/* - * File: MacString.h - * Summary: Wrapper around an immutable CFString. - * Written by: Jesse Jones (jes...@mi...) - * - * Change History (most recent first): - * - * <1> 6/04/02 JDJ Created - */ - -#ifndef MAC_STRING_H -#define MAC_STRING_H - -#if macintosh - -#include <CoreFoundation/CFBase.h> - - -// ============================================================================ -// class MacString -//! Wrapper around an immutable CFString. -// ============================================================================ -class MacString { - -//----------------------------------- -// Initialization/Destruction -// -public: - ~MacString(); - - MacString(); - - MacString(const char* str); - MacString(const unsigned char* str); - /**< Uses default system encoding. */ - - MacString(CFStringRef str); - /**< Bumps the ref count. */ - - MacString(CFMutableStringRef str); - /**< Makes a copy. */ - - explicit MacString(int value); - - MacString(const MacString& str); - MacString& operator=(const MacString& rhs); - -//----------------------------------- -// API -// -public: - // ----- Size ----- - size_t length() const; - size_t size() const {return this->length();} - bool empty() const {return this->length() == 0;} - - // ----- Access ----- - void CopyTo(unsigned char* buffer, CFIndex bytes); - - operator CFStringRef() const {return mString;} - -//----------------------------------- -// Member Data -// -private: - CFStringRef mString; -}; - - -#endif // macintosh -#endif // MAC_STRING_H Modified: trunk/crawl-ref/source/abl-show.cc =================================================================== --- trunk/crawl-ref/source/abl-show.cc 2006-11-21 22:19:04 UTC (rev 451) +++ trunk/crawl-ref/source/abl-show.cc 2006-11-22 08:41:20 UTC (rev 452) @@ -105,12 +105,11 @@ { ABIL_BREATHE_STICKY_FLAME, "Breathe Sticky Flame", 0, 0, 125, 0, ABFLAG_BREATH }, { ABIL_BREATHE_STEAM, "Breathe Steam", 0, 0, 75, 0, ABFLAG_BREATH }, - // Handled with breath weapons, but doesn't cause a breathing delay - { ABIL_SPIT_ACID, "Spit Acid", 0, 0, 125, 0, ABFLAG_NONE }, + { ABIL_SPIT_ACID, "Spit Acid", 0, 0, 125, 0, ABFLAG_BREATH }, { ABIL_FLY, "Fly", 3, 0, 100, 0, ABFLAG_NONE }, { ABIL_SUMMON_MINOR_DEMON, "Summon Minor Demon", 3, 3, 75, 0, ABFLAG_NONE }, - { ABIL_SUMMON_DEMON, "Summon Demon", 5, 5, 150, 0, ABFLAG_NONE }, + { ABIL_SUMMON_DEMONS, "Summon Demons", 5, 5, 150, 0, ABFLAG_NONE }, { ABIL_HELLFIRE, "Hellfire", 8, 8, 200, 0, ABFLAG_NONE }, { ABIL_TORMENT, "Torment", 9, 0, 250, 0, ABFLAG_PAIN }, { ABIL_RAISE_DEAD, "Raise Dead", 5, 5, 150, 0, ABFLAG_NONE }, @@ -160,7 +159,7 @@ { ABIL_TSO_REPEL_UNDEAD, "Repel Undead", 1, 0, 100, 0, ABFLAG_NONE }, { ABIL_TSO_SMITING, "Smiting", 3, 0, 50, 2, ABFLAG_NONE }, { ABIL_TSO_ANNIHILATE_UNDEAD, "Annihilate Undead", 3, 0, 50, 2, ABFLAG_NONE }, - { ABIL_TSO_THUNDERBOLT, "Thunderbolt", 5, 0, 100, 2, ABFLAG_NONE }, + { ABIL_TSO_CLEANSING_FLAME, "Cleansing Flame", 5, 0, 100, 2, ABFLAG_NONE }, { ABIL_TSO_SUMMON_DAEVA, "Summon Daeva", 8, 0, 150, 4, ABFLAG_NONE }, // Kikubaaqudgha @@ -175,9 +174,6 @@ { ABIL_YRED_DRAIN_LIFE, "Drain Life", 6, 0, 200, 2, ABFLAG_NONE }, { ABIL_YRED_CONTROL_UNDEAD, "Control Undead", 5, 0, 150, 2, ABFLAG_NONE }, - // Vehumet - { ABIL_VEHUMET_CHANNEL_ENERGY, "Channel Energy", 0, 0, 50, 0, ABFLAG_NONE }, - // Okawaru { ABIL_OKAWARU_MIGHT, "Might", 2, 0, 50, 1, ABFLAG_NONE }, { ABIL_OKAWARU_HEALING, "Healing", 2, 0, 75, 1, ABFLAG_NONE }, @@ -190,6 +186,7 @@ { ABIL_MAKHLEB_GREATER_SERVANT_OF_MAKHLEB, "Greater Servant of Makhleb", 6, 0, 100, 3, ABFLAG_NONE }, // Sif Muna + { ABIL_SIF_MUNA_CHANNEL_ENERGY, "Channel Energy", 0, 0, 100, 0, ABFLAG_NONE }, { ABIL_SIF_MUNA_FORGET_SPELL, "Forget Spell", 5, 0, 0, 8, ABFLAG_NONE }, // Trog @@ -211,7 +208,6 @@ { ABIL_ROTTING, "Rotting", 4, 4, 0, 2, ABFLAG_NONE }, { ABIL_TORMENT_II, "Call Torment", 9, 0, 0, 3, ABFLAG_PAIN }, - { ABIL_SHUGGOTH_SEED, "Sow Shuggoth Seed", 12, 8, 0, 6, ABFLAG_NONE }, { ABIL_RENOUNCE_RELIGION, "Renounce Religion", 0, 0, 0, 0, ABFLAG_NONE }, }; @@ -467,12 +463,10 @@ // no turning back now... {dlb} const struct ability_def abil = get_ability_def(Curr_abil[abil_used].which); - // currently only delayed fireball is instantaneous -- bwr - you.turn_is_over = ((abil.flags & ABFLAG_INSTANT) ? 0 : 1); - if (random2avg(100, 3) < Curr_abil[abil_used].fail) { mpr("You fail to use your ability."); + you.turn_is_over = true; return (false); } @@ -576,8 +570,7 @@ case ABIL_BREATHE_POWER: case ABIL_BREATHE_STICKY_FLAME: case ABIL_BREATHE_STEAM: - if (you.duration[DUR_BREATH_WEAPON] - && Curr_abil[abil_used].which != ABIL_SPIT_ACID) + if (you.duration[DUR_BREATH_WEAPON]) { canned_msg(MSG_CANNOT_DO_YET); return (false); @@ -643,16 +636,11 @@ } - if (Curr_abil[abil_used].which != ABIL_SPIT_ACID) - { - you.duration[DUR_BREATH_WEAPON] = 3 + random2(5) - + random2(30 - you.experience_level); - } + you.duration[DUR_BREATH_WEAPON] = + 3 + random2(4) + random2(30 - you.experience_level) / 2; if (Curr_abil[abil_used].which == ABIL_BREATHE_STEAM) - { you.duration[DUR_BREATH_WEAPON] /= 2; - } break; case ABIL_EVOKE_BLINK: // randarts @@ -670,8 +658,9 @@ return (false); } - go_berserk(true); - exercise( SK_EVOCATIONS, 1 ); + // only exercise if berserk succeeds + if ( go_berserk(true) ) + exercise( SK_EVOCATIONS, 1 ); break; // fly (kenku) -- eventually becomes permanent (see acr.cc) @@ -710,13 +699,15 @@ summon_any_demon(DEMON_LESSER) ); break; - case ABIL_SUMMON_DEMON: + case ABIL_SUMMON_DEMONS: summon_ice_beast_etc( you.experience_level * 4, summon_any_demon(DEMON_COMMON) ); break; case ABIL_HELLFIRE: - your_spells(SPELL_HELLFIRE, 20 + you.experience_level, false); + if (your_spells(SPELL_HELLFIRE, + 20 + you.experience_level, false) == -1) + return (false); break; case ABIL_TORMENT: @@ -726,7 +717,7 @@ return (false); } - torment(you.x_pos, you.y_pos); + torment(TORMENT_GENERIC, you.x_pos, you.y_pos); break; case ABIL_RAISE_DEAD: @@ -873,14 +864,14 @@ exercise(SK_INVOCATIONS, 2 + random2(4)); break; - case ABIL_TSO_THUNDERBOLT: + case ABIL_TSO_CLEANSING_FLAME: if (spell_direction(spd, beam) == -1) { canned_msg(MSG_OK); return (false); } - zapping(ZAP_LIGHTNING, you.skills[SK_INVOCATIONS] * 6, beam); + zapping(ZAP_CLEANSING_FLAME, 20 + you.skills[SK_INVOCATIONS] * 6, beam); exercise(SK_INVOCATIONS, 3 + random2(6)); break; @@ -906,7 +897,8 @@ break; case ABIL_KIKU_INVOKE_DEATH: - summon_ice_beast_etc(20 + you.skills[SK_INVOCATIONS] * 3, MONS_REAPER); + summon_ice_beast_etc( + 20 + you.skills[SK_INVOCATIONS] * 3, MONS_REAPER, true); exercise(SK_INVOCATIONS, 10 + random2(14)); break; @@ -943,7 +935,7 @@ exercise(SK_INVOCATIONS, 3 + random2(4)); break; - case ABIL_VEHUMET_CHANNEL_ENERGY: + case ABIL_SIF_MUNA_CHANNEL_ENERGY: mpr("You channel some magical energy."); inc_mp(1 + random2(you.skills[SK_INVOCATIONS] / 4 + 2), false); @@ -1029,12 +1021,12 @@ beam.flavour = BEAM_ELECTRICITY; beam.target_x = you.x_pos; beam.target_y = you.y_pos; - strcpy(beam.beam_name, "blast of lightning"); + beam.name = "blast of lightning"; beam.colour = LIGHTCYAN; beam.thrower = KILL_YOU; beam.aux_source = "Makhleb's lightning strike"; beam.ex_size = 1 + you.skills[SK_INVOCATIONS] / 8; - beam.isTracer = false; + beam.is_tracer = false; // ... and fire! explosion(beam); @@ -1135,7 +1127,9 @@ return (false); } - your_spells( SPELL_HELLFIRE, 20 + you.experience_level, false ); + if (your_spells( SPELL_HELLFIRE, + 20 + you.experience_level, false ) == -1) + return (false); you.duration[DUR_BREATH_WEAPON] += 3 + random2(5) + random2(30 - you.experience_level); @@ -1153,24 +1147,10 @@ return (false); } - torment(you.x_pos, you.y_pos); + torment(TORMENT_GENERIC, you.x_pos, you.y_pos); exercise(SK_INVOCATIONS, 2 + random2(4)); break; - case ABIL_SHUGGOTH_SEED: - if (you.duration[DUR_SHUGGOTH_SEED_RELOAD]) - { - canned_msg(MSG_CANNOT_DO_YET); - return (false); - } - - cast_shuggoth_seed( you.experience_level * 2 - + you.skills[SK_INVOCATIONS] * 3 ); - - you.duration[DUR_SHUGGOTH_SEED_RELOAD] = 10 + random2avg(39, 2); - exercise(SK_INVOCATIONS, 2 + random2(4)); - break; - case ABIL_RENOUNCE_RELIGION: if (yesno("Really renounce your faith, foregoing its fabulous benefits?") && yesno( "Are you sure you won't change your mind later?" )) @@ -1188,6 +1168,9 @@ break; } + // currently only delayed fireball is instantaneous -- bwr + you.turn_is_over = !(abil.flags & ABFLAG_INSTANT); + // All failures should have returned by this point, so we'll // apply the costs -- its not too neat, but it works for now. -- bwr const int food_cost = abil.food_cost + random2avg(abil.food_cost, 2); @@ -1324,7 +1307,7 @@ if (cost_str.length() > 24) cost_str = cost_str.substr( 0, 24 ); - cprintf( cost_str.c_str() ); + cprintf( "%s", cost_str.c_str() ); gotoxy(60, wherey()); @@ -1468,7 +1451,7 @@ insert_ability( ABIL_SUMMON_MINOR_DEMON ); if (you.mutation[MUT_SUMMON_DEMONS]) - insert_ability( ABIL_SUMMON_DEMON ); + insert_ability( ABIL_SUMMON_DEMONS ); if (you.mutation[MUT_HURL_HELLFIRE]) insert_ability( ABIL_HELLFIRE ); @@ -1532,7 +1515,7 @@ if (you.piety >= 75) insert_ability( ABIL_TSO_ANNIHILATE_UNDEAD ); if (you.piety >= 100) - insert_ability( ABIL_TSO_THUNDERBOLT ); + insert_ability( ABIL_TSO_CLEANSING_FLAME ); if (you.piety >= 120) insert_ability( ABIL_TSO_SUMMON_DAEVA ); break; @@ -1602,15 +1585,12 @@ break; case GOD_SIF_MUNA: + if (you.piety >= 30) + insert_ability( ABIL_SIF_MUNA_CHANNEL_ENERGY ); if (you.piety >= 50) insert_ability( ABIL_SIF_MUNA_FORGET_SPELL ); break; - case GOD_VEHUMET: - if (you.piety >= 100) - insert_ability( ABIL_VEHUMET_CHANNEL_ENERGY ); - break; - default: break; } @@ -1754,11 +1734,6 @@ num_abil = 5; break; - case GOD_VEHUMET: - abil_start = ABIL_VEHUMET_CHANNEL_ENERGY; - num_abil = 1; - break; - case GOD_OKAWARU: abil_start = ABIL_OKAWARU_MIGHT; num_abil = 3; @@ -1770,8 +1745,8 @@ break; case GOD_SIF_MUNA: - abil_start = ABIL_SIF_MUNA_FORGET_SPELL; - num_abil = 1; + abil_start = ABIL_SIF_MUNA_CHANNEL_ENERGY; + num_abil = 2; break; case GOD_TROG: @@ -1784,6 +1759,7 @@ num_abil = 5; break; + case GOD_VEHUMET: case GOD_NEMELEX_XOBEH: case GOD_XOM: default: @@ -1973,7 +1949,7 @@ failure = 35 - you.experience_level; break; - case ABIL_SUMMON_DEMON: + case ABIL_SUMMON_DEMONS: failure = 40 - you.experience_level; break; @@ -2090,7 +2066,7 @@ failure = 40 - (you.piety / 20) - (5 * you.skills[SK_INVOCATIONS]); break; - case ABIL_VEHUMET_CHANNEL_ENERGY: + case ABIL_SIF_MUNA_CHANNEL_ENERGY: invoc = true; failure = 40 - you.intel - you.skills[SK_INVOCATIONS]; break; @@ -2113,7 +2089,7 @@ break; case ABIL_ZIN_HOLY_WORD: - case ABIL_TSO_THUNDERBOLT: + case ABIL_TSO_CLEANSING_FLAME: case ABIL_ELYVILON_RESTORATION: case ABIL_YRED_CONTROL_UNDEAD: case ABIL_OKAWARU_HASTE: @@ -2151,11 +2127,6 @@ failure = 70 - (you.piety / 25) - (you.skills[SK_INVOCATIONS] * 4); break; - case ABIL_SHUGGOTH_SEED: - invoc = true; - failure = 85 - (you.piety / 25) - (you.skills[SK_INVOCATIONS] * 3); - break; - case ABIL_RENOUNCE_RELIGION: invoc = true; perfect = true; Modified: trunk/crawl-ref/source/abyss.cc =================================================================== --- trunk/crawl-ref/source/abyss.cc 2006-11-21 22:19:04 UTC (rev 451) +++ trunk/crawl-ref/source/abyss.cc 2006-11-22 08:41:20 UTC (rev 452) @@ -3,6 +3,8 @@ * Summary: Misc functions (most of which don't appear to be related to priests). * Written by: Linley Henzell * + * Modified for Crawl Reference by $Author$ on $Date$ + * * Change History (most recent first): * * <2> 10/11/99 BCR Added Daniel's crash patch Modified: trunk/crawl-ref/source/acr.cc =================================================================== --- trunk/crawl-ref/source/acr.cc 2006-11-21 22:19:04 UTC (rev 451) +++ trunk/crawl-ref/source/acr.cc 2006-11-22 08:41:20 UTC (rev 452) @@ -3,6 +3,8 @@ * Summary: Main entry point, event loop, and some initialization functions * Written by: Linley Henzell * + * Modified for Crawl Reference by $Author$ on $Date$ + * * Change History (most recent first): * * <18> 7/29/00 JDJ values.h isn't included on Macs @@ -39,7 +41,7 @@ #include <string> // I don't seem to need values.h for VACPP.. -#if !defined(__IBMCPP__) && !defined(MAC) +#if !defined(__IBMCPP__) #include <limits.h> #endif @@ -64,16 +66,6 @@ #include <signal.h> #endif -#ifdef USE_EMX -#include <sys/types.h> -#endif - -#ifdef OS9 -#include <stat.h> -#else -#include <sys/stat.h> -#endif - #include "externs.h" #include "abl-show.h" @@ -97,15 +89,18 @@ #include "it_use2.h" #include "it_use3.h" #include "itemname.h" +#include "itemprop.h" #include "items.h" #include "lev-pand.h" #include "macro.h" +#include "maps.h" #include "misc.h" #include "monplace.h" #include "monstuff.h" #include "mon-util.h" #include "mutation.h" #include "newgame.h" +#include "notes.h" #include "ouch.h" #include "output.h" #include "overmap.h" @@ -126,25 +121,27 @@ #include "transfor.h" #include "travel.h" #include "view.h" -#include "wpn-misc.h" #include "stash.h" struct crawl_environment env; struct player you; struct system_environment SysEnv; +std::string init_file_location; // externed in newgame.cc + char info[ INFO_SIZE ]; // messaging queue extern'd everywhere {dlb} -int stealth; // externed in view.h // no it is not {dlb} +int stealth; // externed in view.cc char use_colour = 1; -FixedVector< char, NUM_STATUE_TYPES > Visible_Statue; +bool just_autoprayed = false; +bool about_to_autopray = false; // set to true once a new game starts or an old game loads bool game_has_started = false; // Clockwise, around the compass from north (same order as enum RUN_DIR) -static const struct coord_def Compass[8] = +const struct coord_def Compass[8] = { { 0, -1 }, { 1, -1 }, { 1, 0 }, { 1, 1 }, { 0, 1 }, { -1, 1 }, { -1, 0 }, { -1, -1 }, @@ -166,52 +163,32 @@ */ -void (*viewwindow) (char, bool); - -/* these are all defined in view.cc: */ -extern unsigned char (*mapch) (unsigned char); -extern unsigned char (*mapch2) (unsigned char); -unsigned char mapchar(unsigned char ldfk); -unsigned char mapchar2(unsigned char ldfk); -unsigned char mapchar3(unsigned char ldfk); -unsigned char mapchar4(unsigned char ldfk); - -/* - Function pointers are used to make switching between Unix and DOS char sets - possible as a runtime option (command-line -c) -*/ - -// these two are defined in view.cc. What does the player look like? -// (changed for shapechanging) -extern unsigned char your_sign; -extern unsigned char your_colour; - // Functions in main module -static void close_door(char move_x, char move_y); +static void close_door(int move_x, int move_y); static void do_berserk_no_combat_penalty(void); static bool initialise(void); static void input(void); -static void move_player(char move_x, char move_y); -static void open_door(char move_x, char move_y); +static void move_player(int move_x, int move_y); +static void open_door(int move_x, int move_y, bool check_confused = true); +static void start_running( int dir, int mode ); +static void close_door(int move_x, int move_y); +static void init_io(); +static void prep_input(); +static void input(); +static void middle_input(); +static void world_reacts(); +static command_type get_next_cmd(); +typedef int keycode_type; +static keycode_type get_next_keycode(); +static command_type keycode_to_command( keycode_type key ); + /* It all starts here. Some initialisations are run first, then straight to new_game and then input. */ int main( int argc, char *argv[] ) { -#ifdef USE_ASCII_CHARACTERS - // Default to the non-ibm set when it makes sense. - viewwindow = &viewwindow3; - mapch = &mapchar3; - mapch2 = &mapchar4; -#else - // Use the standard ibm default - viewwindow = &viewwindow2; - mapch = &mapchar; - mapch2 = &mapchar2; -#endif - // Load in the system environment variables get_system_environment(); @@ -239,8 +216,11 @@ } // Read the init file - read_init_file(); + init_file_location = read_init_file(); + // Read special levels and vaults. + read_maps(); + // now parse the args again, looking for everything else. parse_args( argc, argv, false ); @@ -251,26 +231,13 @@ exit(0); } -#ifdef UNIX - unixcurses_startup(); -#endif + init_io(); -#ifdef MAC - init_mac(); -#endif - -#ifdef WIN32CONSOLE - init_libw32c(); -#endif - #ifdef USE_MACROS // Load macros macro_init(); #endif - init_overmap(); // in overmap.cc (duh?) - clear_ids(); // in itemname.cc - bool game_start = initialise(); if (game_start || Options.always_greet) @@ -357,16 +324,23 @@ unixcurses_shutdown(); #endif -#ifdef MAC - deinit_mac(); + return 0; +} // end main() + +static void init_io() +{ +#ifdef UNIX + unixcurses_startup(); #endif -#ifdef USE_EMX - deinit_emx(); +#ifdef WIN32CONSOLE + init_libw32c(); #endif - return 0; -} // end main() +#ifdef DOS + init_libdos(); +#endif +} #ifdef WIZARD static void handle_wizard_command( void ) @@ -438,7 +412,7 @@ case 'v': // this command isn't very exciting... feel free to replace - i = prompt_invent_item( "Value of which item?", -1 ); + i = prompt_invent_item( "Value of which item?", MT_INVSELECT, -1 ); if (i == PROMPT_ABORT || !is_random_artefact( you.inv[i] )) { canned_msg( MSG_OK ); @@ -452,7 +426,8 @@ break; case '+': - i = prompt_invent_item( "Make an artefact out of which item?", -1 ); + i = prompt_invent_item( + "Make an artefact out of which item?", MT_INVSELECT, -1 ); if (i == PROMPT_ABORT) { canned_msg( MSG_OK ); @@ -593,6 +568,22 @@ tweak_object(); break; + case 'T': + debug_make_trap(); + break; + + case '\\': + debug_make_shop(); + break; + + case 'f': + debug_fight_statistics(false); + break; + + case 'F': + debug_fight_statistics(true); + break; + case 'm': create_spec_monster(); break; @@ -695,9 +686,13 @@ break; case '{': - magic_mapping(99, 100); + magic_mapping(1000, 100); break; + case '@': + debug_set_stats(); + break; + case '^': { int old_piety = you.piety; @@ -765,437 +760,312 @@ } #endif -// This function creates "equivalence classes" so that undiscovered -// traps and secret doors aren't running stopping points. -static char base_grid_type( char grid ) +// Set up the running variables for the current run. +static void start_running( int dir, int mode ) { - // Don't stop for undiscovered traps: - if (grid == DNGN_UNDISCOVERED_TRAP) - return (DNGN_FLOOR); - - // Or secret doors (which currently always look like rock walls): - if (grid == DNGN_SECRET_DOOR) - return (DNGN_ROCK_WALL); - - return (grid); + you.running.initialise(dir, mode); } -// Set up the front facing array for detecting terrain based stops -static void set_run_check( int index, int dir ) +static bool recharge_rod( item_def &rod, bool wielded ) { - you.run_check[index].dx = Compass[dir].x; - you.run_check[index].dy = Compass[dir].y; + if (!item_is_rod(rod) || rod.plus >= rod.plus2 || !enough_mp(1, true)) + return (false); - const int targ_x = you.x_pos + Compass[dir].x; - const int targ_y = you.y_pos + Compass[dir].y; + const int charge = rod.plus / ROD_CHARGE_MULT; - you.run_check[index].grid = base_grid_type( grd[ targ_x ][ targ_y ] ); -} + int rate = ((charge + 1) * ROD_CHARGE_MULT) / 10; + + rate *= (10 + skill_bump( SK_EVOCATIONS )); + rate = div_rand_round( rate, 100 ); -// Set up the running variables for the current run. -static void start_running( int dir, char mode ) -{ - if (dir == RDIR_REST) + if (rate < 5) + rate = 5; + else if (rate > ROD_CHARGE_MULT / 2) + rate = ROD_CHARGE_MULT / 2; + + // If not wielded, the rod charges far more slowly. + if (!wielded) + rate /= 5; + // Shields hamper recharging for wielded rods. + else if (player_shield()) + rate /= 2; + + if (rod.plus / ROD_CHARGE_MULT != (rod.plus + rate) / ROD_CHARGE_MULT) { - you.run_x = 0; - you.run_y = 0; - you.running = mode; - return; + dec_mp(1); + if (wielded) + you.wield_change = true; } - ASSERT( dir >= 0 && dir <= 7 ); + rod.plus += rate; + if (rod.plus > rod.plus2) + rod.plus = rod.plus2; - you.run_x = Compass[dir].x; - you.run_y = Compass[dir].y; - you.running = mode; + if (wielded && rod.plus == rod.plus2 && is_resting()) + stop_running(); - // Get the compass point to the left/right of intended travel: - const int left = (dir - 1 < 0) ? 7 : (dir - 1); - const int right = (dir + 1 > 7) ? 0 : (dir + 1); - - // Record the direction and starting tile type for later reference: - set_run_check( 0, left ); - set_run_check( 1, dir ); - set_run_check( 2, right ); + return (true); } -// Returns true if one of the front three grids has changed. -static bool check_stop_running( void ) +static void recharge_rods() { - if (env.cgrid[you.x_pos + you.run_x][you.y_pos + you.run_y] != EMPTY_CLOUD) - return (true); - - if (mgrd[you.x_pos + you.run_x][you.y_pos + you.run_y] != NON_MONSTER) - return (true); - - for (int i = 0; i < 3; i++) + const int wielded = you.equip[EQ_WEAPON]; + if (wielded != -1) { - const int targ_x = you.x_pos + you.run_check[i].dx; - const int targ_y = you.y_pos + you.run_check[i].dy; - const int targ_grid = base_grid_type( grd[ targ_x ][ targ_y ] ); - - if (you.run_check[i].grid != targ_grid) - return (true); + i... [truncated message content] |
From: <ha...@us...> - 2006-11-22 09:25:34
|
Revision: 454 http://svn.sourceforge.net/crawl-ref/?rev=454&view=rev Author: haranp Date: 2006-11-22 01:25:33 -0800 (Wed, 22 Nov 2006) Log Message: ----------- Fixed 160093: too many shield interaction messages. Modified Paths: -------------- trunk/crawl-ref/source/delay.cc trunk/crawl-ref/source/misc.cc trunk/crawl-ref/source/overmap.cc Modified: trunk/crawl-ref/source/delay.cc =================================================================== --- trunk/crawl-ref/source/delay.cc 2006-11-22 08:44:28 UTC (rev 453) +++ trunk/crawl-ref/source/delay.cc 2006-11-22 09:25:33 UTC (rev 454) @@ -708,7 +708,8 @@ if (item_cursed( arm )) mpr( "Oops, that feels deathly cold." ); - warn_shield_penalties(); + if (eq_slot == EQ_SHIELD) + warn_shield_penalties(); you.redraw_armour_class = 1; you.redraw_evasion = 1; Modified: trunk/crawl-ref/source/misc.cc =================================================================== --- trunk/crawl-ref/source/misc.cc 2006-11-22 08:44:28 UTC (rev 453) +++ trunk/crawl-ref/source/misc.cc 2006-11-22 09:25:33 UTC (rev 454) @@ -835,7 +835,7 @@ && stair_find < DNGN_RETURN_FROM_ORCISH_MINES)) { // no idea why such a huge switch and not 100-grd[][] - // planning ahead for re-organizaing grd[][] values - 13jan2000 {dlb} + // planning ahead for reorganizing grd[][] values - 13jan2000 {dlb} strcpy( info, "Welcome to " ); switch (stair_find) { Modified: trunk/crawl-ref/source/overmap.cc =================================================================== --- trunk/crawl-ref/source/overmap.cc 2006-11-22 08:44:28 UTC (rev 453) +++ trunk/crawl-ref/source/overmap.cc 2006-11-22 09:25:33 UTC (rev 454) @@ -98,7 +98,7 @@ stair_level[i] = -1; } // end init_overmap() -void display_overmap( void ) +void display_overmap() { #ifdef DOS_TERM char buffer[4800]; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dsh...@us...> - 2006-11-22 11:38:35
|
Revision: 459 http://svn.sourceforge.net/crawl-ref/?rev=459&view=rev Author: dshaligram Date: 2006-11-22 03:38:34 -0800 (Wed, 22 Nov 2006) Log Message: ----------- Restore old cursor behaviour on Windows, with little icky hooks to make it controllable for the newgame slider menu. Modified Paths: -------------- trunk/crawl-ref/source/libdos.h trunk/crawl-ref/source/libunix.h trunk/crawl-ref/source/libutil.h trunk/crawl-ref/source/libw32c.cc trunk/crawl-ref/source/libw32c.h Modified: trunk/crawl-ref/source/libdos.h =================================================================== --- trunk/crawl-ref/source/libdos.h 2006-11-22 10:58:06 UTC (rev 458) +++ trunk/crawl-ref/source/libdos.h 2006-11-22 11:38:34 UTC (rev 459) @@ -3,4 +3,7 @@ void init_libdos(); +inline void enable_smart_cursor(bool ) { } +inline bool is_smart_cursor_enabled() { return (false); } + #endif Modified: trunk/crawl-ref/source/libunix.h =================================================================== --- trunk/crawl-ref/source/libunix.h 2006-11-22 10:58:06 UTC (rev 458) +++ trunk/crawl-ref/source/libunix.h 2006-11-22 11:38:34 UTC (rev 459) @@ -41,6 +41,9 @@ void set_altcharset(bool alt_on); bool get_altcharset(); +inline void enable_smart_cursor(bool) { } +inline bool is_smart_cursor_enabled() { return (false); } + #ifndef _LIBUNIX_IMPLEMENTATION /* Some stuff from curses, to remove compiling warnings.. */ extern "C" Modified: trunk/crawl-ref/source/libutil.h =================================================================== --- trunk/crawl-ref/source/libutil.h 2006-11-22 10:58:06 UTC (rev 458) +++ trunk/crawl-ref/source/libutil.h 2006-11-22 11:38:34 UTC (rev 459) @@ -13,6 +13,7 @@ #ifndef LIBUTIL_H #define LIBUTIL_H +#include "AppHdr.h" #include "defines.h" #include <string> #include <vector> @@ -127,14 +128,19 @@ class cursor_control { public: - cursor_control(bool cs) : cstate(cs) { + cursor_control(bool cs) + : cstate(cs), smartcstate( is_smart_cursor_enabled() ) + { + enable_smart_cursor(false); _setcursortype(cs? _NORMALCURSOR : _NOCURSOR); } ~cursor_control() { _setcursortype(cstate? _NOCURSOR : _NORMALCURSOR); + enable_smart_cursor(smartcstate); } private: bool cstate; + bool smartcstate; }; // Reads lines of text; used internally by cancelable_get_line. Modified: trunk/crawl-ref/source/libw32c.cc =================================================================== --- trunk/crawl-ref/source/libw32c.cc 2006-11-22 10:58:06 UTC (rev 458) +++ trunk/crawl-ref/source/libw32c.cc 2006-11-22 11:38:34 UTC (rev 459) @@ -98,6 +98,8 @@ static unsigned InputCP, OutputCP; static const unsigned PREFERRED_CODEPAGE = 437; +static bool w32_smart_cursor = true; + // we can do straight translation of DOS color to win32 console color. #define WIN32COLOR(col) (WORD)(col) static void writeChar(char c); @@ -251,6 +253,16 @@ if (cx >= 80) cx = 80; } +void enable_smart_cursor(bool cursor) +{ + w32_smart_cursor = cursor; +} + +bool is_smart_cursor_enabled() +{ + return (w32_smart_cursor); +} + void bFlush(void) { COORD source; @@ -420,14 +432,12 @@ SetConsoleTitle( oldTitle ); } -// we don't take our cues from Crawl. Cursor is shown -// only on input. void _setcursortype(int curstype) { - _setcursortype_internal(curstype); + if (!w32_smart_cursor) + _setcursortype_internal(curstype); } - void _setcursortype_internal(int curstype) { CONSOLE_CURSOR_INFO cci; @@ -714,6 +724,10 @@ return repeat_key; } + const bool oldValue = current_cursor; + if (w32_smart_cursor) + _setcursortype_internal(_NORMALCURSOR); + while(1) { CLOCKIN @@ -740,9 +754,10 @@ } } } - // DEBUG - //fprintf(foo, "getch() returning %02x (%c)\n", key, key); + if (w32_smart_cursor) + _setcursortype_internal(oldValue); + return key; } @@ -755,7 +770,7 @@ int getche(void) { // turn buffering off temporarily - bool oldValue = buffering; + const bool oldValue = buffering; setBuffering(false); int val = getch(); @@ -805,9 +820,11 @@ setStringInput( true ); // force cursor - bool oldValue = current_cursor; - _setcursortype_internal(_NORMALCURSOR); + const bool oldValue = current_cursor; + if (w32_smart_cursor) + _setcursortype_internal(_NORMALCURSOR); + // set actual screen color to current color SetConsoleTextAttribute( outbuf, WIN32COLOR(current_color) ); @@ -830,7 +847,8 @@ setStringInput( false ); // restore old cursor - _setcursortype_internal(oldValue); + if (w32_smart_cursor) + _setcursortype_internal(oldValue); // return # of bytes read return (int)nread; Modified: trunk/crawl-ref/source/libw32c.h =================================================================== --- trunk/crawl-ref/source/libw32c.h 2006-11-22 10:58:06 UTC (rev 458) +++ trunk/crawl-ref/source/libw32c.h 2006-11-22 11:38:34 UTC (rev 459) @@ -45,6 +45,9 @@ void delay(int ms); void textbackground(int c); +void enable_smart_cursor(bool cursor); +bool is_smart_cursor_enabled(); + inline void srandom(unsigned int seed) { srand(seed); } #endif This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dsh...@us...> - 2006-11-22 11:55:16
|
Revision: 460 http://svn.sourceforge.net/crawl-ref/?rev=460&view=rev Author: dshaligram Date: 2006-11-22 03:55:11 -0800 (Wed, 22 Nov 2006) Log Message: ----------- Kill more g++ carps. Modified Paths: -------------- trunk/crawl-ref/source/item_use.cc trunk/crawl-ref/source/view.cc Modified: trunk/crawl-ref/source/item_use.cc =================================================================== --- trunk/crawl-ref/source/item_use.cc 2006-11-22 11:38:34 UTC (rev 459) +++ trunk/crawl-ref/source/item_use.cc 2006-11-22 11:55:11 UTC (rev 460) @@ -630,7 +630,7 @@ //--------------------------------------------------------------- void wear_armour(void) { - int armour_wear_2; + int armour_wear_2 = 0; if (!armour_prompt("Wear which item?", &armour_wear_2, OPER_WEAR)) return; Modified: trunk/crawl-ref/source/view.cc =================================================================== --- trunk/crawl-ref/source/view.cc 2006-11-22 11:38:34 UTC (rev 459) +++ trunk/crawl-ref/source/view.cc 2006-11-22 11:55:11 UTC (rev 460) @@ -3285,7 +3285,7 @@ { // [ds] Evil hack time again. Peek at grid, use that character. int object = grd[gx][gy]; - unsigned short glych, glycol; + unsigned short glych, glycol = 0; if (object == DNGN_SECRET_DOOR) object = grid_secret_door_appearance( gx, gy ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ha...@us...> - 2006-11-22 12:54:03
|
Revision: 462 http://svn.sourceforge.net/crawl-ref/?rev=462&view=rev Author: haranp Date: 2006-11-22 04:54:01 -0800 (Wed, 22 Nov 2006) Log Message: ----------- Goodbye, gold dropping. We wish thee well. If I misunderstood and this is still up for debate, my apologies and please revert. Modified Paths: -------------- trunk/crawl-ref/source/command.cc trunk/crawl-ref/source/invent.cc trunk/crawl-ref/source/items.cc Modified: trunk/crawl-ref/source/command.cc =================================================================== --- trunk/crawl-ref/source/command.cc 2006-11-22 12:16:28 UTC (rev 461) +++ trunk/crawl-ref/source/command.cc 2006-11-22 12:54:01 UTC (rev 462) @@ -164,7 +164,7 @@ -1, false, false ); - if (to_slot == PROMPT_ABORT) + if (to_slot == PROMPT_ABORT) { canned_msg( MSG_OK ); return; Modified: trunk/crawl-ref/source/invent.cc =================================================================== --- trunk/crawl-ref/source/invent.cc 2006-11-22 12:16:28 UTC (rev 461) +++ trunk/crawl-ref/source/invent.cc 2006-11-22 12:54:01 UTC (rev 462) @@ -619,7 +619,7 @@ // Note: We handle any "special" character first, so that // it can be used to override the others. - if (other_valid_char != '\0' && keyin == other_valid_char) + if (other_valid_char != 0 && keyin == other_valid_char) { ret = PROMPT_GOT_SPECIAL; break; @@ -804,7 +804,7 @@ // Note: We handle any "special" character first, so that // it can be used to override the others. - if (other_valid_char != '\0' && keyin == other_valid_char) + if (other_valid_char != 0 && keyin == other_valid_char) { ret = PROMPT_GOT_SPECIAL; break; Modified: trunk/crawl-ref/source/items.cc =================================================================== --- trunk/crawl-ref/source/items.cc 2006-11-22 12:16:28 UTC (rev 461) +++ trunk/crawl-ref/source/items.cc 2006-11-22 12:54:01 UTC (rev 462) @@ -1684,95 +1684,7 @@ return (true); } - -//--------------------------------------------------------------- -// -// drop_gold -// -//--------------------------------------------------------------- -static void drop_gold(unsigned int amount) -{ - const unsigned long BIGGEST_QUANT_VALUE = - ((1L << (sizeof(mitm[0].quantity)*8 - 1)) - 1000); - - if (you.gold > 0) - { - if (amount > you.gold) - amount = you.gold; - - snprintf( info, INFO_SIZE, "You drop %d gold piece%s.", - amount, (amount > 1) ? "s" : "" ); - mpr(info); - - // loop through items at grid location, look for gold - int i = igrd[you.x_pos][you.y_pos]; - - while(i != NON_ITEM) - { - if (mitm[i].base_type == OBJ_GOLD) - { - if ( mitm[i].quantity + amount > BIGGEST_QUANT_VALUE ) { - amount = BIGGEST_QUANT_VALUE - mitm[i].quantity; - snprintf(info, INFO_SIZE, - "But there's only room for %d.", amount); - mpr(info); - - } - inc_mitm_item_quantity( i, amount ); - you.gold -= amount; - you.redraw_gold = 1; - you.turn_is_over = true; - return; - } - - // follow link - i = mitm[i].link; - } - - // place on top. - i = get_item_slot(10); - if (i == NON_ITEM) - { - mpr( "Too many items on this level, not dropping the gold." ); - return; - } - if (amount > BIGGEST_QUANT_VALUE) { - amount = BIGGEST_QUANT_VALUE; - snprintf(info, INFO_SIZE, - "But there's only room for %d.", amount); - mpr(info); - } - - mitm[i].base_type = OBJ_GOLD; - mitm[i].quantity = amount; - // [ds] #&^#@&#! - mitm[i].colour = YELLOW; - mitm[i].flags = 0; - - move_item_to_grid( &i, you.x_pos, you.y_pos ); - - you.gold -= amount; - you.redraw_gold = 1; - - you.turn_is_over = true; - } - else - { - mpr("You don't have any money."); - } -} // end drop_gold() - bool drop_item( int item_dropped, int quant_drop ) { - if (item_dropped == PROMPT_GOT_SPECIAL) // ie '$' for gold - { - // drop gold - if (quant_drop < 0 || quant_drop > static_cast< int >( you.gold )) - quant_drop = you.gold; - - drop_gold( quant_drop ); - return (true); - } - if (quant_drop < 0 || quant_drop > you.inv[item_dropped].quantity) quant_drop = you.inv[item_dropped].quantity; @@ -1959,7 +1871,7 @@ MT_DROP, -1, drop_menu_title, - true, true, '$', + true, true, 0, &Options.drop_filter, drop_selitem_text, &items_for_multidrop ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ha...@us...> - 2006-11-22 13:16:24
|
Revision: 463 http://svn.sourceforge.net/crawl-ref/?rev=463&view=rev Author: haranp Date: 2006-11-22 05:16:23 -0800 (Wed, 22 Nov 2006) Log Message: ----------- Clean up speed mutation messages for nagas. Let golden draconians know that they resist acid. Modified Paths: -------------- trunk/crawl-ref/source/mutation.cc trunk/crawl-ref/source/player.cc Modified: trunk/crawl-ref/source/mutation.cc =================================================================== --- trunk/crawl-ref/source/mutation.cc 2006-11-22 12:54:01 UTC (rev 462) +++ trunk/crawl-ref/source/mutation.cc 2006-11-22 13:16:23 UTC (rev 463) @@ -56,6 +56,13 @@ "Your claws steel!" }; +const char* naga_speed_descrip[4] = { + "You cover the ground very slowly.", // 10*14/10 = 14 + "You cover the ground rather slowly.", // 8*14/10 = 11 + "You cover the ground rather quickly.", // 7*14/10 = 9 + "You cover the ground quickly.", // 6*14/10 = 8 +}; + const char *mutation_descrip[][3] = { {"You have tough skin (AC +1).", "You have very tough skin (AC +2).", "You have extremely tough skin (AC +3)."}, @@ -927,7 +934,8 @@ cprintf("Your system is immune to poisons." EOL); cprintf("You can see invisible." EOL); - cprintf("You move rather slowly." EOL); + // slowness can be overriden + cprintf("%s" EOL, naga_speed_descrip[you.mutation[MUT_FAST]]); j += 4; break; @@ -1053,7 +1061,8 @@ if (you.experience_level > 6) { cprintf("You can spit acid." EOL); - j++; + cprintf("You are resistant to acid." EOL); + j += 2; } break; @@ -1089,7 +1098,8 @@ if (you.mutation[i] != 0) { // this is already handled above: - if (you.species == SP_NAGA && i == MUT_BREATHE_POISON) + if (you.species == SP_NAGA && + (i == MUT_BREATHE_POISON || i == MUT_FAST)) continue; if (you.species == SP_CENTAUR && i == MUT_FAST) continue; Modified: trunk/crawl-ref/source/player.cc =================================================================== --- trunk/crawl-ref/source/player.cc 2006-11-22 12:54:01 UTC (rev 462) +++ trunk/crawl-ref/source/player.cc 2006-11-22 13:16:23 UTC (rev 463) @@ -2990,9 +2990,9 @@ if (you.slow && you.haste) mpr( "You are under both slowing and hasting effects." ); else if (you.slow) - mpr( "You actions are slowed." ); + mpr( "Your actions are slowed." ); else if (you.haste) - mpr( "You actions are hasted." ); + mpr( "Your actions are hasted." ); if (you.might) mpr( "You are mighty." ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dsh...@us...> - 2006-11-22 14:44:02
|
Revision: 467 http://svn.sourceforge.net/crawl-ref/?rev=467&view=rev Author: dshaligram Date: 2006-11-22 06:03:00 -0800 (Wed, 22 Nov 2006) Log Message: ----------- [1597623] Added draconian descriptions. I've editorialised freely. Draconian shifters are no longer helpless blinkers. Draconian callers are a little more evil. Modified Paths: -------------- trunk/crawl-ref/source/describe.cc trunk/crawl-ref/source/enum.h trunk/crawl-ref/source/mon-spll.h trunk/crawl-ref/source/mon-util.cc trunk/crawl-ref/source/monplace.cc trunk/crawl-ref/source/mstuff2.cc Modified: trunk/crawl-ref/source/describe.cc =================================================================== --- trunk/crawl-ref/source/describe.cc 2006-11-22 13:38:14 UTC (rev 466) +++ trunk/crawl-ref/source/describe.cc 2006-11-22 14:03:00 UTC (rev 467) @@ -4483,7 +4483,90 @@ #endif } // end describe_spell() +static std::string describe_draconian_role(const monsters *mon) +{ + switch (mon->type) + { + case MONS_DRACONIAN_SHIFTER: + return "It darts around disconcertingly without taking a step."; + case MONS_DRACONIAN_SCORCHER: + return "Its scales are sooty black from years of magical pyrotechnics."; + case MONS_DRACONIAN_ZEALOT: + return "In its gaze you see all the malefic power of its " + "terrible god."; + case MONS_DRACONIAN_ANNIHILATOR: + return "Crackling balls of pure energy hum and spark up and down its " + "scaled fists and arms."; + case MONS_DRACONIAN_CALLER: + return "It looks especially reptilian, and eager for company."; + case MONS_DRACONIAN_MONK: + return "It looks unnaturally strong and dangerous with its fists."; + case MONS_DRACONIAN_KNIGHT: + return "It wields a deadly weapon with menacing efficiency."; + } + return (""); +} +static std::string describe_draconian_colour(int species) +{ + switch (species) + { + case MONS_BLACK_DRACONIAN: + return "Sparks crackle and flare out of its mouth and nostrils."; + case MONS_MOTTLED_DRACONIAN: + return "Liquid flames drip from its mouth."; + case MONS_YELLOW_DRACONIAN: + return "Acid fumes swirl around it."; + case MONS_GREEN_DRACONIAN: + return "Venom steams and drips from its jaws."; + case MONS_PURPLE_DRACONIAN: + return "Its outline shimmers with wild energies."; + case MONS_RED_DRACONIAN: + return "Smoke pours from its nostrils."; + case MONS_WHITE_DRACONIAN: + return "Frost pours from its nostrils."; + case MONS_PALE_DRACONIAN: + return "It is cloaked in a pall of superheated steam."; + } + return (""); +} + +static std::string describe_draconian(const monsters *mon) +{ + std::string description; + const int subsp = draco_subspecies( mon ); + + if (subsp == MONS_DRACONIAN) + description += "A "; + else + description += "An enormous, muscular "; + + switch (subsp) + { + case MONS_DRACONIAN: description += "brown-"; break; + case MONS_BLACK_DRACONIAN: description += "black-"; break; + case MONS_MOTTLED_DRACONIAN: description += "mottled-"; break; + case MONS_YELLOW_DRACONIAN: description += "yellow-"; break; + case MONS_GREEN_DRACONIAN: description += "green-"; break; + case MONS_PURPLE_DRACONIAN: description += "purple-"; break; + case MONS_RED_DRACONIAN: description += "red-"; break; + case MONS_WHITE_DRACONIAN: description += "white-"; break; + case MONS_PALE_DRACONIAN: description += "pale-"; break; + default: + break; + } + + description += "scaled humanoid with wings."; + + if (subsp != MONS_DRACONIAN) + description += " " + describe_draconian_colour(subsp); + + if (subsp != mon->type) + description += " " + describe_draconian_role(mon); + + return (description); +} + //--------------------------------------------------------------- // // describe_monsters @@ -4688,8 +4771,8 @@ case MONS_ORC_PRIEST: description += "A servant of the ancient and cruel gods of the orcs," - " dressed in long robe. he's mumbling some strange prayers. " - "Hope that they will remain unheard."; + " dressed in long robe. It continually mumbles strange prayers. " + "Hope that they remain unheard."; break; case MONS_ORC_HIGH_PRIEST: @@ -5884,25 +5967,7 @@ case MONS_DRACONIAN_MONK: case MONS_DRACONIAN_KNIGHT: { - description += "A "; - - const int subsp = draco_subspecies( &menv[which_mons] ); - switch (subsp) - { - case MONS_DRACONIAN: description += "brown "; break; - case MONS_BLACK_DRACONIAN: description += "black "; break; - case MONS_MOTTLED_DRACONIAN: description += "mottled "; break; - case MONS_YELLOW_DRACONIAN: description += "yellow "; break; - case MONS_GREEN_DRACONIAN: description += "green "; break; - case MONS_PURPLE_DRACONIAN: description += "purple "; break; - case MONS_RED_DRACONIAN: description += "red "; break; - case MONS_WHITE_DRACONIAN: description += "white "; break; - case MONS_PALE_DRACONIAN: description += "pale "; break; - default: - break; - } - - description += "scaled humanoid with wings."; + description += describe_draconian( &menv[which_mons] ); break; } case MONS_PLAYER_GHOST: @@ -6182,7 +6247,7 @@ { if (!found_spell) { - description += "$Monster Spells:$"; + description += "$$Monster Spells:$"; found_spell = true; } Modified: trunk/crawl-ref/source/enum.h =================================================================== --- trunk/crawl-ref/source/enum.h 2006-11-22 13:38:14 UTC (rev 466) +++ trunk/crawl-ref/source/enum.h 2006-11-22 14:03:00 UTC (rev 467) @@ -2425,7 +2425,7 @@ MS_CONTROLLED_BLINK, MS_CONTROL_UNDEAD, MS_MIASMA, // 55 - MS_SUMMON_LIZARDS, + MS_SUMMON_DRAKES, MS_BLINK_OTHER, MS_DISPEL_UNDEAD, MS_HELLFROST, Modified: trunk/crawl-ref/source/mon-spll.h =================================================================== --- trunk/crawl-ref/source/mon-spll.h 2006-11-22 13:38:14 UTC (rev 466) +++ trunk/crawl-ref/source/mon-spll.h 2006-11-22 14:03:00 UTC (rev 467) @@ -760,14 +760,14 @@ { MST_DRAC_CALLER, MS_NO_SPELL, - MS_SUMMON_LIZARDS, - MS_SUMMON_LIZARDS, + MS_SUMMON_DRAKES, + MS_SUMMON_DRAKES, MS_NO_SPELL, MS_NO_SPELL, - MS_SUMMON_LIZARDS }, + MS_SUMMON_DRAKES }, { MST_DRAC_SHIFTER, - MS_NO_SPELL, + MS_BANISHMENT, MS_BLINK_OTHER, MS_BLINK, MS_NO_SPELL, Modified: trunk/crawl-ref/source/mon-util.cc =================================================================== --- trunk/crawl-ref/source/mon-util.cc 2006-11-22 13:38:14 UTC (rev 466) +++ trunk/crawl-ref/source/mon-util.cc 2006-11-22 14:03:00 UTC (rev 467) @@ -126,7 +126,7 @@ "Controlled Blink", "Control Undead", "Miasma", - "Summon Lizards", + "Summon Drakes", "Blink Other", "Dispel Undead", "Hellfrost", Modified: trunk/crawl-ref/source/monplace.cc =================================================================== --- trunk/crawl-ref/source/monplace.cc 2006-11-22 13:38:14 UTC (rev 466) +++ trunk/crawl-ref/source/monplace.cc 2006-11-22 14:03:00 UTC (rev 467) @@ -1486,14 +1486,11 @@ { case DRAGON_LIZARD: temp_rand = random2(100); - summoned = ((temp_rand > 85) ? MONS_GIANT_GECKO : - (temp_rand > 59) ? MONS_GIANT_LIZARD : - (temp_rand > 34) ? MONS_GIANT_IGUANA : - (temp_rand > 22) ? MONS_GILA_MONSTER : - (temp_rand > 11) ? MONS_KOMODO_DRAGON : - (temp_rand > 8) ? MONS_FIREDRAKE : - (temp_rand > 2) ? MONS_SWAMP_DRAKE - : MONS_DEATH_DRAKE ); + summoned = ((temp_rand > 80) ? MONS_SWAMP_DRAKE : + (temp_rand > 59) ? MONS_KOMODO_DRAGON : + (temp_rand > 34) ? MONS_FIREDRAKE : + (temp_rand > 11) ? MONS_DEATH_DRAKE : + MONS_DRAGON); break; case DRAGON_DRACONIAN: Modified: trunk/crawl-ref/source/mstuff2.cc =================================================================== --- trunk/crawl-ref/source/mstuff2.cc 2006-11-22 13:38:14 UTC (rev 466) +++ trunk/crawl-ref/source/mstuff2.cc 2006-11-22 14:03:00 UTC (rev 467) @@ -575,7 +575,7 @@ return; // Journey -- Added in Summon Lizards and Draconian - case MS_SUMMON_LIZARDS: + case MS_SUMMON_DRAKES: if (!mons_friendly( monster ) && !monsterNearby && monster_abjuration( 1, true ) > 0 && coinflip()) { @@ -589,11 +589,27 @@ if (duration > ENCH_ABJ_VI) duration = ENCH_ABJ_VI; - for (sumcount = 0; sumcount < sumcount2; sumcount++) { - create_monster( rand_dragon( DRAGON_LIZARD ), duration, - SAME_ATTITUDE(monster), - monster->x, monster->y, monster->foe, 250 ); + std::vector<int> monsters; + + for (sumcount = 0; sumcount < sumcount2; sumcount++) + { + const int mons = rand_dragon( DRAGON_LIZARD ); + if (mons == MONS_DRAGON) + { + monsters.clear(); + monsters.push_back( rand_dragon(DRAGON_DRAGON) ); + break; + } + monsters.push_back( mons ); + } + + for (int i = 0, size = monsters.size(); i < size; ++i) + { + create_monster( monsters[i], duration, + SAME_ATTITUDE(monster), + monster->x, monster->y, monster->foe, 250 ); + } } break; @@ -650,8 +666,10 @@ void setup_mons_cast(struct monsters *monster, struct bolt &pbolt, int spell_cast) { // always set these -- used by things other than fire_beam() - pbolt.ench_power = 12 * monster->hit_dice; + // [ds] Used to be 12 * MHD, reduced to 7 * HD. + pbolt.ench_power = 7 * monster->hit_dice; + if (spell_cast == MS_TELEPORT) pbolt.ench_power = 2000; else if (spell_cast == MS_PAIN) // this is cast by low HD monsters @@ -697,7 +715,7 @@ case MS_SUMMON_BEAST: // Geryon case MS_SUMMON_UNDEAD: // summon undead around player case MS_SUMMON_MUSHROOMS: - case MS_SUMMON_LIZARDS: + case MS_SUMMON_DRAKES: case MS_TORMENT: case MS_SUMMON_DEMON_GREATER: case MS_CANTRIP: @@ -716,7 +734,8 @@ pbolt.rangeMax = theBeam.rangeMax; pbolt.hit = theBeam.hit; pbolt.damage = theBeam.damage; - pbolt.ench_power = theBeam.ench_power; + if (theBeam.ench_power != -1) + pbolt.ench_power = theBeam.ench_power; pbolt.type = theBeam.type; pbolt.flavour = theBeam.flavour; pbolt.thrower = theBeam.thrower; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dsh...@us...> - 2006-11-23 10:33:22
|
Revision: 479 http://svn.sourceforge.net/crawl-ref/?rev=479&view=rev Author: dshaligram Date: 2006-11-23 02:33:20 -0800 (Thu, 23 Nov 2006) Log Message: ----------- [1599883] Interlevel travel now makes a best effort to avoid excludes. Perfection cannot be reached, since the travel cache may be wrong about where a staircase leads. Modified Paths: -------------- trunk/crawl-ref/source/travel.cc trunk/crawl-ref/source/travel.h Modified: trunk/crawl-ref/source/travel.cc =================================================================== --- trunk/crawl-ref/source/travel.cc 2006-11-23 09:41:45 UTC (rev 478) +++ trunk/crawl-ref/source/travel.cc 2006-11-23 10:33:20 UTC (rev 479) @@ -215,11 +215,11 @@ return traversable_terrain[(int) grid] == TRAVERSABLE; } -static bool is_excluded(int x, int y) +static bool is_excluded(int x, int y, const std::vector<coord_def> &exc) { - for (int i = 0, count = curr_excludes.size(); i < count; ++i) + for (int i = 0, count = exc.size(); i < count; ++i) { - const coord_def &c = curr_excludes[i]; + const coord_def &c = exc[i]; int dx = c.x - x, dy = c.y - y; if (dx * dx + dy * dy <= Options.travel_exclude_radius2) @@ -228,6 +228,17 @@ return false; } +inline static bool is_excluded(const coord_def &c, + const std::vector<coord_def> &exc) +{ + return is_excluded(c.x, c.y, exc); +} + +inline static bool is_excluded(int x, int y) +{ + return is_excluded(x, y, curr_excludes); +} + static bool is_exclude_root(int x, int y) { for (int i = 0, count = curr_excludes.size(); i < count; ++i) @@ -317,20 +328,6 @@ } } -void update_excludes() -{ - // Sanity checks - if (you.level_type == LEVEL_LABYRINTH || you.level_type == LEVEL_ABYSS) - return; - for (int i = curr_excludes.size() - 1; i >= 0; --i) - { - int x = curr_excludes[i].x, - y = curr_excludes[i].y; - if (!env.map[x - 1][y - 1]) - curr_excludes.erase( curr_excludes.begin() + i ); - } -} - void forget_square(int x, int y) { if (you.level_type == LEVEL_LABYRINTH || you.level_type == LEVEL_ABYSS) @@ -1857,17 +1854,26 @@ static int find_transtravel_stair( const level_id &cur, const level_pos &target, int distance, + // This is actually the current position on cur, + // not necessarily a stair. const coord_def &stair, level_id &closest_level, int &best_level_distance, - coord_def &best_stair) + coord_def &best_stair, + const bool target_has_excludes ) { int local_distance = -1; level_id player_level = level_id::get_current_level_id(); + LevelInfo &li = travel_cache.get_level_info(cur); + // Have we reached the target level? if (cur == target.id) { + // Are we in an exclude? If so, bail out. + if (is_excluded( stair, li.get_excludes() )) + return (-1); + // If there's no target position on the target level, or we're on the // target, we're home. if (target.pos.x == -1 || target.pos == stair) @@ -1916,7 +1922,6 @@ } } - LevelInfo &li = travel_cache.get_level_info(cur); std::vector<stair_info> &stairs = li.get_stairs(); // this_stair being NULL is perfectly acceptable, since we start with @@ -1969,7 +1974,11 @@ // have no exact target location. If there *is* an exact target // location, we can't follow stairs for which we have incomplete // information. - if (target.pos.x == -1 && dest.id == target.id) + // + // We can also not use incomplete stair information if there are + // excludes on the target level. + if (target.pos.x == -1 && dest.id == target.id + && !target_has_excludes) { if (local_distance == -1 || local_distance > dist2stair) { @@ -2012,7 +2021,8 @@ // Okay, take these stairs and keep going. int newdist = find_transtravel_stair(dest.id, target, dist2stair, dest.pos, closest_level, - best_level_distance, best_stair); + best_level_distance, best_stair, + target_has_excludes); if (newdist != -1 && (local_distance == -1 || local_distance > newdist)) { @@ -2083,9 +2093,11 @@ find_travel_pos(you.x_pos, you.y_pos, NULL, NULL, NULL); + const LevelInfo &target_level = travel_cache.get_level_info( target.id ); find_transtravel_stair(current, target, 0, cur_stair, closest_level, - best_level_distance, best_stair); + best_level_distance, best_stair, + !target_level.get_excludes().empty()); if (best_stair.x != -1 && best_stair.y != -1) { @@ -2099,7 +2111,8 @@ int current_dist = level_distance(current, target.id); level_pos newlev; newlev.id = closest_level; - if (current_dist == -1 || best_level_distance < current_dist) + if (newlev.id != target.id + && (current_dist == -1 || best_level_distance < current_dist)) return find_transtravel_square(newlev, verbose); } @@ -2394,9 +2407,6 @@ void LevelInfo::update() { - // We need to update all stair information and distances on this level. - update_excludes(); - // First, set excludes, so that stair distances will be correctly populated. excludes = curr_excludes; @@ -2955,8 +2965,6 @@ { if (can_travel_interlevel()) get_level_info(level_id::get_current_level_id()).update(); - else - update_excludes(); } void TravelCache::fixup_levels() Modified: trunk/crawl-ref/source/travel.h =================================================================== --- trunk/crawl-ref/source/travel.h 2006-11-23 09:41:45 UTC (rev 478) +++ trunk/crawl-ref/source/travel.h 2006-11-23 10:33:20 UTC (rev 479) @@ -241,6 +241,11 @@ void reset_distances(); void set_level_excludes(); + const std::vector<coord_def> &get_excludes() const + { + return excludes; + } + // Returns the travel distance between two stairs. If either stair is NULL, // or does not exist in our list of stairs, returns 0. int distance_between(const stair_info *s1, const stair_info *s2) const; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dsh...@us...> - 2006-11-23 12:42:34
|
Revision: 481 http://svn.sourceforge.net/crawl-ref/?rev=481&view=rev Author: dshaligram Date: 2006-11-23 04:42:32 -0800 (Thu, 23 Nov 2006) Log Message: ----------- [1601588] Bolts of fire melt wax. Note that fireballs are considered insufficiently hot for our purposes, as are the lesser fire spells. We may want to consider hellfire at some point. Modified Paths: -------------- trunk/crawl-ref/source/beam.cc trunk/crawl-ref/source/player.cc trunk/crawl-ref/source/player.h trunk/crawl-ref/source/spl-cast.cc Modified: trunk/crawl-ref/source/beam.cc =================================================================== --- trunk/crawl-ref/source/beam.cc 2006-11-23 10:53:22 UTC (rev 480) +++ trunk/crawl-ref/source/beam.cc 2006-11-23 12:42:32 UTC (rev 481) @@ -70,7 +70,7 @@ // helper functions (some of these, esp. affect(), should probably // be public): static void sticky_flame_monster( int mn, bool source, int hurt_final ); -static bool affectsWalls(struct bolt &beam); +static bool affectsWall(const bolt &beam, int wall_feature); static bool isBouncy(struct bolt &beam, unsigned char gridtype); static void beam_drop_object( struct bolt &beam, item_def *item, int x, int y ); static bool beam_term_on_target(struct bolt &beam, int x, int y); @@ -1276,7 +1276,7 @@ if (grid_is_solid(grd[tx][ty])) { // first, check to see if this beam affects walls. - if (affectsWalls(pbolt)) + if (affectsWall(pbolt, grd[tx][ty])) { // should we ever get a tracer with a wall-affecting // beam (possible I suppose), we'll quit tracing now. @@ -2436,7 +2436,7 @@ if (beam.is_tracer) // tracers always stop on walls. return (BEAM_STOP); - if (affectsWalls(beam)) + if (affectsWall(beam, grd[x][y])) { rangeUsed += affect_wall(beam, x, y); } @@ -2487,7 +2487,7 @@ return (rangeUsed); } -static bool affectsWalls(struct bolt &beam) +static bool affectsWall(const bolt &beam, int wall) { // don't know of any explosion that affects walls. But change it here // if there is. @@ -2503,6 +2503,11 @@ if (beam.flavour == BEAM_DISINTEGRATION && beam.damage.num >= 3) return (true); + if (beam.flavour == BEAM_FIRE + && wall == DNGN_WAX_WALL + && beam.name == "bolt of fire") + return (true); + // eye of devastation? if (beam.flavour == BEAM_NUKE) return (true); @@ -2546,7 +2551,27 @@ return (rangeUsed); } // END DIGGING EFFECT + + // FIRE effect + if (beam.flavour == BEAM_FIRE && beam.name == "bolt of fire") + { + const int wgrd = grd[x][y]; + if (wgrd != DNGN_WAX_WALL) + return (0); + grd[x][y] = DNGN_FLOOR; + if (see_grid(x, y)) + mprf("The wax bubbles and burns!"); + else if (player_can_smell()) + mprf("You smell burning wax."); + + place_cloud( + YOU_KILL(beam.thrower)? CLOUD_FIRE : CLOUD_FIRE_MON, + x, y, random2(10) + 15 ); + + return (BEAM_STOP); + } + // NUKE / DISRUPT if (beam.flavour == BEAM_DISINTEGRATION || beam.flavour == BEAM_NUKE) { Modified: trunk/crawl-ref/source/player.cc =================================================================== --- trunk/crawl-ref/source/player.cc 2006-11-23 10:53:22 UTC (rev 480) +++ trunk/crawl-ref/source/player.cc 2006-11-23 12:42:32 UTC (rev 481) @@ -871,6 +871,10 @@ return (res + player_res_fire(calc_unid) / 2); } +bool player_can_smell() +{ + return (you.species != SP_MUMMY); +} int player_res_fire(bool calc_unid) { Modified: trunk/crawl-ref/source/player.h =================================================================== --- trunk/crawl-ref/source/player.h 2006-11-23 10:53:22 UTC (rev 480) +++ trunk/crawl-ref/source/player.h 2006-11-23 12:42:32 UTC (rev 481) @@ -157,7 +157,9 @@ bool player_item_conserve(bool calc_unid = true); int player_mental_clarity(bool calc_unid = true); +bool player_can_smell(); + /* *********************************************************************** * called from: fight - files - ouch * *********************************************************************** */ Modified: trunk/crawl-ref/source/spl-cast.cc =================================================================== --- trunk/crawl-ref/source/spl-cast.cc 2006-11-23 10:53:22 UTC (rev 480) +++ trunk/crawl-ref/source/spl-cast.cc 2006-11-23 12:42:32 UTC (rev 481) @@ -2107,10 +2107,9 @@ canned_msg(MSG_NOTHING_HAPPENS); break; case 9: - // josh declares mummies cannot smell {dlb} - if (you.species != SP_MUMMY) + if (player_can_smell()) mpr("You smell something strange."); - else + else if (you.species == SP_MUMMY) mpr("Your bandages flutter."); } break; @@ -2713,8 +2712,7 @@ switch (random2(10)) { case 0: - // mummies cannot smell {dlb} - if (you.species != SP_MUMMY) + if (player_can_smell()) mpr("You smell decay."); break; case 1: @@ -2768,7 +2766,7 @@ break; case 2: // josh declares mummies cannot smell {dlb} - if (you.species != SP_MUMMY) + if (player_can_smell()) { mpr("You smell decay."); // identical to a harmless message you.rotting++; @@ -2910,8 +2908,7 @@ canned_msg(MSG_NOTHING_HAPPENS); break; case 9: - // mummies cannot smell - if (you.species != SP_MUMMY) + if (player_can_smell()) mpr("You smell something strange."); break; } @@ -3003,8 +3000,7 @@ mpr("You feel a strange surge of energy!"); break; case 4: - // mummies cannot smell - if (you.species != SP_MUMMY) + if (player_can_smell()) mpr("You smell smoke."); break; case 5: @@ -3390,20 +3386,18 @@ mpr("You are blasted with air!"); break; case 7: - // mummies cannot smell if (!silenced(you.x_pos, you.y_pos)) mpr("You hear a whooshing sound.", MSGCH_SOUND); - else if (you.species != SP_MUMMY) + else if (player_can_smell()) mpr("You smell ozone."); break; case 8: canned_msg(MSG_NOTHING_HAPPENS); break; case 9: - // mummies cannot smell if (!silenced(you.x_pos, you.y_pos)) mpr("You hear a crackling sound.", MSGCH_SOUND); - else if (you.species != SP_MUMMY) + else if (player_can_smell()) mpr("You smell something musty."); break; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ha...@us...> - 2006-11-23 17:44:44
|
Revision: 485 http://svn.sourceforge.net/crawl-ref/?rev=485&view=rev Author: haranp Date: 2006-11-23 09:44:30 -0800 (Thu, 23 Nov 2006) Log Message: ----------- Fixed 1594106: innate abilities were not being dumped. Note that this will cause a bug if you have more than 23 mutations simultaneously; fixing that will require patching formatted_string. Modified Paths: -------------- trunk/crawl-ref/source/chardump.cc trunk/crawl-ref/source/mutation.cc trunk/crawl-ref/source/mutation.h Modified: trunk/crawl-ref/source/chardump.cc =================================================================== --- trunk/crawl-ref/source/chardump.cc 2006-11-23 16:10:21 UTC (rev 484) +++ trunk/crawl-ref/source/chardump.cc 2006-11-23 17:44:30 UTC (rev 485) @@ -980,24 +980,10 @@ if (xz > 0) { - text += ""; text += "\n"; - text += " Mutations & Other Weirdness"; - text += "\n"; - - for (int j = 0; j < 100; j++) - { - if (you.mutation[j]) - { - if (you.demon_pow[j] > 0) - text += "* "; - - text += mutation_name(j); - text += "\n"; - } - } + text += describe_mutations(); + text += "\n\n"; } - text += "\n\n"; } // end dump_mutations() // ======================================================================== Modified: trunk/crawl-ref/source/mutation.cc =================================================================== --- trunk/crawl-ref/source/mutation.cc 2006-11-23 16:10:21 UTC (rev 484) +++ trunk/crawl-ref/source/mutation.cc 2006-11-23 17:44:30 UTC (rev 485) @@ -63,6 +63,13 @@ "You cover the ground quickly.", // 6*14/10 = 8 }; +const char* troll_claw_descrip[4] = { + "You have claws for hands.", + "You have sharp claws for hands.", + "You have very sharp claws for hands.", + "Your claws are sharper than steel." +}; + const char *mutation_descrip[][3] = { {"You have tough skin (AC +1).", "You have very tough skin (AC +2).", "You have extremely tough skin (AC +3)."}, @@ -879,217 +886,207 @@ 0 // }; -void display_mutations(void) +formatted_string describe_mutations() { - int i; - int j = 0; + std::string result; + bool have_any = false; const char *mut_title = "Innate abilities, Weirdness & Mutations"; - const int num_lines = get_number_of_lines(); -#ifdef DOS_TERM - char buffer[4800]; + // center title + int i; + i = 39 - strlen(mut_title) / 2; + if (i<0) i=0; - window(1, 1, 80, 25); - gettext(1, 1, 80, 25, buffer); -#endif + result += std::string(i, ' '); + result += "<white>"; + result += mut_title; + result += "</white>" EOL EOL; - clrscr(); - textcolor(WHITE); + result += "<lightblue>"; // inborn abilities and weirdness - // center title - i = 40 - strlen(mut_title) / 2; - if (i<1) i=1; - gotoxy(i, 1); - cprintf(mut_title); - gotoxy(1,3); - textcolor(LIGHTBLUE); //textcolor for inborn abilities and weirdness - switch (you.species) //mv: following code shows innate abilities - if any { case SP_MERFOLK: - cprintf("You revert to your normal form in water." EOL); - j++; + result += "You revert to your normal form in water." EOL; + have_any = true; break; case SP_SPRIGGAN: - cprintf("You can see invisible." EOL); - cprintf("You cover the ground extremely quickly." EOL); - j += 2; + result += "You can see invisible." EOL; + result += "You cover the ground extremely quickly." EOL; + have_any = true; break; case SP_CENTAUR: if (!you.mutation[MUT_FAST]) - cprintf("You cover the ground quickly." EOL); + result += "You cover the ground quickly." EOL; else - cprintf("You cover the ground extremely quickly." EOL); - j++; + result += "You cover the ground extremely quickly." EOL; + have_any = true; break; case SP_NAGA: // breathe poison replaces spit poison: if (!you.mutation[MUT_BREATHE_POISON]) - cprintf("You can spit poison." EOL); + result += "You can spit poison." EOL; else - cprintf("You can exhale a cloud of poison." EOL); + result += "<lightred>You can exhale a cloud of poison.</lightred>" EOL; - cprintf("Your system is immune to poisons." EOL); - cprintf("You can see invisible." EOL); + result += "Your system is immune to poisons." EOL; + result += "You can see invisible." EOL; // slowness can be overriden - cprintf("%s" EOL, naga_speed_descrip[you.mutation[MUT_FAST]]); - j += 4; + if ( you.mutation[MUT_FAST] ) + result += "<lightred>"; + result += naga_speed_descrip[you.mutation[MUT_FAST]]; + if ( you.mutation[MUT_FAST] ) + result += "</lightred>"; + result += EOL; + have_any = true; break; case SP_GNOME: - cprintf("You can sense your surroundings." EOL); - j++; + result += "You can sense your surroundings." EOL; + have_any = true; break; case SP_TROLL: - cprintf("Your body regenerates quickly." EOL); - switch ( you.mutation[MUT_CLAWS] ) { - case 0: - cprintf("You have claws for hands." EOL); - break; - case 1: - cprintf("You have sharp claws for hands." EOL); - break; - case 2: - cprintf("You have very sharp claws for hands." EOL); - break; - case 3: - // literally true - cprintf("Your claws are sharper than steel." EOL); - break; - default: - break; - } - j += 2; + result += "Your body regenerates quickly." EOL; + if ( you.mutation[MUT_CLAWS] ) + result += "<lightred>"; + result += troll_claw_descrip[you.mutation[MUT_CLAWS]]; + if ( you.mutation[MUT_CLAWS] ) + result += "</lightred"; + result += EOL; + have_any = true; break; case SP_GHOUL: - cprintf("Your body is rotting away." EOL); - cprintf("You are carnivorous." EOL); - j += 2; + result += "Your body is rotting away." EOL; + result += "You are carnivorous." EOL; + have_any = true; break; case SP_KOBOLD: - cprintf("You are carnivorous." EOL); - j++; + result += "You are carnivorous." EOL; + have_any = true; break; case SP_GREY_ELF: if (you.experience_level > 4) { - cprintf("You are very charming." EOL); - j++; + result += "You are very charming." EOL; + have_any = true; } break; case SP_KENKU: if (you.experience_level > 4) { - cprintf("You can fly"); - cprintf((you.experience_level > 14) ? " continuously." EOL : "." - EOL); - j++; + result += "You can fly"; + if (you.experience_level > 14) + result += " continuously"; + result += "." EOL; + have_any = true; } break; case SP_MUMMY: - cprintf("You are"); - cprintf((you.experience_level > 25) ? " very strongly" : - ((you.experience_level > 12) ? " strongly" : "")); - cprintf(" in touch with the powers of death." EOL); - j++; + result += "You are"; + if (you.experience_level > 25) + result += " very strongly"; + else if (you.experience_level > 12) + result += " strongly"; + result += " in touch with the powers of death." EOL; + if (you.experience_level >= 12) - { - cprintf("You can restore your body by infusing magical energy." EOL); - j++; - } + result += "You can restore your body by infusing magical energy." EOL; + have_any = true; break; case SP_GREEN_DRACONIAN: if (you.experience_level > 6) { - cprintf("You are resistant to poison." EOL); - cprintf("You can breathe poison." EOL); - j += 2; + result += "You are resistant to poison." EOL; + result += "You can breathe poison." EOL; + have_any = true; } break; case SP_RED_DRACONIAN: if (you.experience_level > 6) { - cprintf("You can breathe fire." EOL); - j++; + result += "You can breathe fire." EOL; + have_any = true; } if (you.experience_level > 17) { - cprintf("You are resistant to fire." EOL); - j++; + result += "You are resistant to fire." EOL; + have_any = true; } break; case SP_WHITE_DRACONIAN: if (you.experience_level > 6) { - cprintf("You can breathe frost." EOL); - j++; + result += "You can breathe frost." EOL; + have_any = true; } if (you.experience_level > 17) { - cprintf("You are resistant to cold." EOL); - j++; + result += "You are resistant to cold." EOL; + have_any = true; } break; case SP_BLACK_DRACONIAN: if (you.experience_level > 6) { - cprintf("You can breathe lightning." EOL); - j++; + result += "You can breathe lightning." EOL; + have_any = true; } if (you.experience_level > 17) { - cprintf("You are resistant to lightning." EOL); - j++; + result += "You are resistant to lightning." EOL; + have_any = true; } break; case SP_GOLDEN_DRACONIAN: if (you.experience_level > 6) { - cprintf("You can spit acid." EOL); - cprintf("You are resistant to acid." EOL); - j += 2; + result += "You can spit acid." EOL; + result += "You are resistant to acid." EOL; + have_any = true; } break; case SP_PURPLE_DRACONIAN: if (you.experience_level > 6) { - cprintf("You can breathe power." EOL); - j++; + result += "You can breathe power." EOL; + have_any = true; } break; case SP_MOTTLED_DRACONIAN: if (you.experience_level > 6) { - cprintf("You can breathe sticky flames." EOL); - j++; + result += "You can breathe sticky flames." EOL; + have_any = true; } break; case SP_PALE_DRACONIAN: if (you.experience_level > 6) { - cprintf("You can breathe steam." EOL); - j++; + result += "You can breathe steam." EOL; + have_any = true; } break; } //end switch - innate abilities + + result += "</lightcyan>"; textcolor(LIGHTGREY); @@ -1097,6 +1094,8 @@ { if (you.mutation[i] != 0) { + have_any = true; + // this is already handled above: if (you.species == SP_NAGA && (i == MUT_BREATHE_POISON || i == MUT_FAST)) @@ -1106,57 +1105,53 @@ if (you.species == SP_TROLL && i == MUT_CLAWS) continue; - j++; - textcolor(LIGHTGREY); + // mutation is actually a demonic power + if (you.demon_pow[i] != 0) + // enhanced by mutation + if ( you.demon_pow[i] < you.mutation[i] ) + result += "<lightred>"; + else + result += "<red>"; - if (j > num_lines - 4) - { - gotoxy( 1, num_lines - 1 ); - cprintf("-more-"); + result += mutation_name(i); - if (getch() == 0) - getch(); - - clrscr(); - - // center title - int x = 40 - strlen(mut_title) / 2; - if (x < 1) - x = 1; - - gotoxy(x, 1); - textcolor(WHITE); - cprintf(mut_title); - textcolor(LIGHTGREY); - gotoxy(1,3); - j = 1; - } - - /* mutation is actually a demonic power */ if (you.demon_pow[i] != 0) - textcolor(RED); + if ( you.demon_pow[i] < you.mutation[i] ) + result += "</lightred>"; + else + result += "</red>"; - /* same as above, but power is enhanced by mutation */ - if (you.demon_pow[i] != 0 && you.demon_pow[i] < you.mutation[i]) - textcolor(LIGHTRED); - - cprintf( mutation_name( i ) ); - cprintf(EOL); + result += EOL; } } - if (j == 0) - cprintf( "You are not a mutant." EOL ); + if (!have_any) + result += "You are not a mutant." EOL; + return formatted_string::parse_string(result); +} + +void display_mutations() +{ +#ifdef DOS_TERM + char buffer[4800]; + + window(1, 1, 80, 25); + gettext(1, 1, 80, 25, buffer); +#endif + + clrscr(); + gotoxy(1,1); + describe_mutations().display(); + if (getch() == 0) getch(); + #ifdef DOS_TERM puttext(1, 1, 80, 25, buffer); #endif +} - return; -} // end display_mutations() - bool mutate(int which_mutation, bool failMsg) { int mutat = which_mutation; Modified: trunk/crawl-ref/source/mutation.h =================================================================== --- trunk/crawl-ref/source/mutation.h 2006-11-23 16:10:21 UTC (rev 484) +++ trunk/crawl-ref/source/mutation.h 2006-11-23 17:44:30 UTC (rev 485) @@ -14,6 +14,8 @@ #ifndef MUTATION_H #define MUTATION_H +// for formatted_string +#include "menu.h" // last updated 12may2000 {dlb} /* *********************************************************************** @@ -27,9 +29,11 @@ /* *********************************************************************** * called from: acr * *********************************************************************** */ -void display_mutations(void); +void display_mutations(); +formatted_string describe_mutations(); + // last updated 12may2000 {dlb} /* *********************************************************************** * called from: decks - it_use2 - mutation - spells This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dsh...@us...> - 2006-11-24 08:48:08
|
Revision: 486 http://svn.sourceforge.net/crawl-ref/?rev=486&view=rev Author: dshaligram Date: 2006-11-24 00:48:05 -0800 (Fri, 24 Nov 2006) Log Message: ----------- [1601595] Lava smokes, swamp shallow water tends to mist. Cold spells fired over water trail freezing cloud. Smoke/steam spreads out a bit as it dissipates. I can't seem to make this look as pretty as I imagined it. :-( MAX_CLOUDS is still on 100. We may want to increase this. Monster pale draconians are pegged back to speed 10 (was 12). Modified Paths: -------------- trunk/crawl-ref/source/acr.cc trunk/crawl-ref/source/beam.cc trunk/crawl-ref/source/cloud.cc trunk/crawl-ref/source/cloud.h trunk/crawl-ref/source/direct.cc trunk/crawl-ref/source/enum.h trunk/crawl-ref/source/files.cc trunk/crawl-ref/source/initfile.cc trunk/crawl-ref/source/misc.cc trunk/crawl-ref/source/misc.h trunk/crawl-ref/source/mon-data.h trunk/crawl-ref/source/stuff.cc trunk/crawl-ref/source/travel.cc trunk/crawl-ref/source/view.cc Modified: trunk/crawl-ref/source/acr.cc =================================================================== --- trunk/crawl-ref/source/acr.cc 2006-11-23 17:44:30 UTC (rev 485) +++ trunk/crawl-ref/source/acr.cc 2006-11-24 08:48:05 UTC (rev 486) @@ -71,6 +71,7 @@ #include "abl-show.h" #include "abyss.h" #include "chardump.h" +#include "cloud.h" #include "clua.h" #include "command.h" #include "debug.h" @@ -2073,6 +2074,8 @@ if (you.num_turns != -1) you.num_turns++; + run_environment_effects(); + //if (random2(10) < you.skills [SK_TRAPS_DOORS] + 2) search_around(); stealth = check_stealth(); Modified: trunk/crawl-ref/source/beam.cc =================================================================== --- trunk/crawl-ref/source/beam.cc 2006-11-23 17:44:30 UTC (rev 485) +++ trunk/crawl-ref/source/beam.cc 2006-11-24 08:48:05 UTC (rev 486) @@ -2722,13 +2722,18 @@ // FIRE/COLD over water/lava if ( (grd[x][y] == DNGN_LAVA && beam.flavour == BEAM_COLD) - || ((grd[x][y] == DNGN_DEEP_WATER || grd[x][y] == DNGN_SHALLOW_WATER) - && beam.flavour == BEAM_FIRE) ) + || (grid_is_watery(grd[x][y]) && beam.flavour == BEAM_FIRE) ) { cloud_type = YOU_KILL(beam.thrower) ? CLOUD_STEAM : CLOUD_STEAM_MON; place_cloud( cloud_type, x, y, 2 + random2(5) ); } + if (beam.flavour == BEAM_COLD && grid_is_watery(grd[x][y])) + { + cloud_type = YOU_KILL(beam.thrower) ? CLOUD_COLD : CLOUD_COLD_MON; + place_cloud( cloud_type, x, y, 2 + random2(5) ); + } + // ORB OF ENERGY if (beam.name == "orb of energy") place_cloud( CLOUD_PURP_SMOKE, x, y, random2(5) + 1 ); Modified: trunk/crawl-ref/source/cloud.cc =================================================================== --- trunk/crawl-ref/source/cloud.cc 2006-11-23 17:44:30 UTC (rev 485) +++ trunk/crawl-ref/source/cloud.cc 2006-11-24 08:48:05 UTC (rev 486) @@ -16,21 +16,23 @@ #include "externs.h" #include "cloud.h" +#include "misc.h" #include "stuff.h" -void delete_cloud( int cloud ) +// Returns true if this cloud spreads out as it dissipates. +static bool cloud_spreads(const cloud_struct &cloud) { - if (env.cloud[ cloud ].type != CLOUD_NONE) + switch (cloud.type) { - const int cloud_x = env.cloud[ cloud ].x; - const int cloud_y = env.cloud[ cloud ].y; - - env.cloud[ cloud ].type = CLOUD_NONE; - env.cloud[ cloud ].decay = 0; - env.cloud[ cloud ].x = 0; - env.cloud[ cloud ].y = 0; - env.cgrid[ cloud_x ][ cloud_y ] = EMPTY_CLOUD; - env.cloud_no--; + case CLOUD_STEAM: + case CLOUD_STEAM_MON: + case CLOUD_GREY_SMOKE: + case CLOUD_BLACK_SMOKE: + case CLOUD_GREY_SMOKE_MON: + case CLOUD_BLACK_SMOKE_MON: + return (true); + default: + return (false); } } @@ -46,6 +48,123 @@ env.cloud_no++; } +static void place_new_cloud(int cltype, int x, int y, int decay) +{ + if (env.cloud_no >= MAX_CLOUDS) + return; + + // find slot for cloud + for (int ci = 0; ci < MAX_CLOUDS; ci++) + { + if (env.cloud[ci].type == CLOUD_NONE) // ie is empty + { + new_cloud( ci, cltype, x, y, decay ); + break; + } + } +} + +static int spread_cloud(const cloud_struct &cloud) +{ + const int spreadch = cloud.decay > 30? 80 : + cloud.decay > 20? 50 : + 30; + int extra_decay = 0; + + for (int yi = -1; yi <= 1; ++yi) + { + for (int xi = -1; xi <= 1; ++xi) + { + if ((!xi && !yi) || random2(100) >= spreadch) + continue; + + const int x = cloud.x + xi; + const int y = cloud.y + yi; + + if (!in_bounds(x, y) + || env.cgrid[x][y] != EMPTY_CLOUD + || grid_is_solid(grd[x][y])) + continue; + + int newdecay = cloud.decay / 2 + 1; + if (newdecay >= cloud.decay) + newdecay = cloud.decay - 1; + + place_new_cloud( cloud.type, x, y, newdecay ); + + extra_decay += 8; + } + } + + return (extra_decay); +} + +static void dissipate_cloud(int cc, cloud_struct &cloud, int dissipate) +{ + // apply calculated rate to the actual cloud: + cloud.decay -= dissipate; + + if (cloud_spreads(cloud) && cloud.decay > 10 && one_chance_in(5)) + cloud.decay -= spread_cloud(cloud); + + // check for total dissipation and handle accordingly: + if (cloud.decay < 1) + delete_cloud( cc ); +} + +void manage_clouds(void) +{ + // amount which cloud dissipates - must be unsigned! {dlb} + unsigned int dissipate = 0; + + for (unsigned char cc = 0; cc < MAX_CLOUDS; cc++) + { + if (env.cloud[cc].type == CLOUD_NONE) // no cloud -> next iteration + continue; + + dissipate = you.time_taken; + + // water -> flaming clouds: + // lava -> freezing clouds: + if ((env.cloud[cc].type == CLOUD_FIRE + || env.cloud[cc].type == CLOUD_FIRE_MON) + && grd[env.cloud[cc].x][env.cloud[cc].y] == DNGN_DEEP_WATER) + { + dissipate *= 4; + } + else if ((env.cloud[cc].type == CLOUD_COLD + || env.cloud[cc].type == CLOUD_COLD_MON) + && grd[env.cloud[cc].x][env.cloud[cc].y] == DNGN_LAVA) + { + dissipate *= 4; + } + + // double the amount when slowed - must be applied last(!): + if (you.slow) + dissipate *= 2; + + dissipate_cloud( cc, env.cloud[cc], dissipate ); + } + + return; +} // end manage_clouds() + +void delete_cloud( int cloud ) +{ + if (env.cloud[ cloud ].type != CLOUD_NONE) + { + const int cloud_x = env.cloud[ cloud ].x; + const int cloud_y = env.cloud[ cloud ].y; + + env.cloud[ cloud ].type = CLOUD_NONE; + env.cloud[ cloud ].decay = 0; + env.cloud[ cloud ].x = 0; + env.cloud[ cloud ].y = 0; + env.cgrid[ cloud_x ][ cloud_y ] = EMPTY_CLOUD; + env.cloud_no--; + } +} + // The current use of this function is for shifting in the abyss, so // that clouds get moved along with the rest of the map. void move_cloud( int cloud, int new_x, int new_y ) @@ -62,6 +181,16 @@ } } +// Places a cloud with the given stats assuming one doesn't already +// exist at that point. +void check_place_cloud( int cl_type, int x, int y, int lifetime ) +{ + if (!in_bounds(x, y) || env.cgrid[x][y] != EMPTY_CLOUD) + return; + + place_cloud( cl_type, x, y, lifetime ); +} + // Places a cloud with the given stats. May delete old clouds to make way // if there are too many (MAX_CLOUDS == 30) on level. Will overwrite an old // cloud under some circumstances. @@ -80,6 +209,7 @@ && env.cloud[ target_cgrid ].type <= CLOUD_STEAM) || env.cloud[ target_cgrid ].type == CLOUD_STINK || env.cloud[ target_cgrid ].type == CLOUD_BLACK_SMOKE + || env.cloud[ target_cgrid ].type == CLOUD_MIST || env.cloud[ target_cgrid ].decay <= 20) //soon gone { cl_new = env.cgrid[ ctarget_x ][ ctarget_y ]; @@ -103,6 +233,7 @@ && env.cloud[ ci ].type <= CLOUD_STEAM) || env.cloud[ ci ].type == CLOUD_STINK || env.cloud[ ci ].type == CLOUD_BLACK_SMOKE + || env.cloud[ ci ].type == CLOUD_MIST || env.cloud[ ci ].decay <= 20) //soon gone { cl_del = ci; Modified: trunk/crawl-ref/source/cloud.h =================================================================== --- trunk/crawl-ref/source/cloud.h 2006-11-23 17:44:30 UTC (rev 485) +++ trunk/crawl-ref/source/cloud.h 2006-11-24 08:48:05 UTC (rev 486) @@ -17,6 +17,9 @@ void delete_cloud( int cloud ); void move_cloud( int cloud, int new_x, int new_y ); +void check_place_cloud( int cl_type, int x, int y, int lifetime ); void place_cloud(unsigned char cl_type, unsigned char ctarget_x, unsigned char ctarget_y, unsigned char cl_range); +void manage_clouds(void); + #endif Modified: trunk/crawl-ref/source/direct.cc =================================================================== --- trunk/crawl-ref/source/direct.cc 2006-11-23 17:44:30 UTC (rev 485) +++ trunk/crawl-ref/source/direct.cc 2006-11-24 08:48:05 UTC (rev 486) @@ -1541,8 +1541,9 @@ (cloud_type == CLOUD_MIASMA || cloud_type == CLOUD_MIASMA_MON) ? "foul pestilence" : (cloud_type == CLOUD_BLACK_SMOKE - || cloud_type == CLOUD_BLACK_SMOKE_MON) ? "black smoke" - : "buggy goodness"); + || cloud_type == CLOUD_BLACK_SMOKE_MON) ? "black smoke" : + (cloud_type == CLOUD_MIST)? "thin mist" : + "buggy goodness"); strcat(info, " here."); mpr(info); } Modified: trunk/crawl-ref/source/enum.h =================================================================== --- trunk/crawl-ref/source/enum.h 2006-11-23 17:44:30 UTC (rev 485) +++ trunk/crawl-ref/source/enum.h 2006-11-24 08:48:05 UTC (rev 486) @@ -530,6 +530,7 @@ CLOUD_STEAM, // 8 CLOUD_MIASMA = 9, // 9: found 11jan2000 {dlb} CLOUD_BLACK_SMOKE = 10, //was: CLOUD_STICKY_FLAME and wrong 19jan2000 {dlb} + CLOUD_MIST, CLOUD_RANDOM = 98, CLOUD_DEBUGGING = 99, // 99: used once as 'nonexistent cloud' {dlb} // if env.cloud_type > 100, it is a monster's cloud {dlb} @@ -1158,6 +1159,7 @@ EC_FLOOR, // colour of the area's floor EC_ROCK, // colour of the area's rock EC_STONE, // colour of the area's stone + EC_MIST, // colour of mist EC_RANDOM // any colour (except BLACK) }; Modified: trunk/crawl-ref/source/files.cc =================================================================== --- trunk/crawl-ref/source/files.cc 2006-11-23 17:44:30 UTC (rev 485) +++ trunk/crawl-ref/source/files.cc 2006-11-24 08:48:05 UTC (rev 486) @@ -1118,6 +1118,8 @@ // Save the created/updated level out to disk: save_level( you.your_level, (you.level_type != LEVEL_DUNGEON), you.where_are_you ); + + setup_environment_effects(); } // end load() void save_level(int level_saved, bool was_a_labyrinth, char where_were_you) Modified: trunk/crawl-ref/source/initfile.cc =================================================================== --- trunk/crawl-ref/source/initfile.cc 2006-11-23 17:44:30 UTC (rev 485) +++ trunk/crawl-ref/source/initfile.cc 2006-11-24 08:48:05 UTC (rev 486) @@ -68,7 +68,7 @@ "magic", "mutagenic", "warp", "enchant", "heal", "holy", "dark", "death", "necro", "unholy", "vehumet", "crystal", "blood", "smoke", "slime", "jewel", "elven", "dwarven", "orcish", "gila", "floor", - "rock", "stone", "random" + "rock", "stone", "mist", "random" }; for (ret = 0; ret < 16; ret++) Modified: trunk/crawl-ref/source/misc.cc =================================================================== --- trunk/crawl-ref/source/misc.cc 2006-11-23 17:44:30 UTC (rev 485) +++ trunk/crawl-ref/source/misc.cc 2006-11-24 08:48:05 UTC (rev 486) @@ -162,6 +162,11 @@ return (grid == DNGN_SHALLOW_WATER || grid == DNGN_DEEP_WATER); } +bool grid_is_watery( int grid ) +{ + return (grid_is_water(grid) || grid == DNGN_BLUE_FOUNTAIN); +} + bool grid_destroys_items( int grid ) { return (grid == DNGN_LAVA || grid == DNGN_DEEP_WATER); @@ -1579,48 +1584,6 @@ exercise(SK_TRAPS_DOORS, 1 + random2(5) + (you.your_level / 5)); } // end disarm_trap() -void manage_clouds(void) -{ - // amount which cloud dissipates - must be unsigned! {dlb} - unsigned int dissipate = 0; - - for (unsigned char cc = 0; cc < MAX_CLOUDS; cc++) - { - if (env.cloud[cc].type == CLOUD_NONE) // no cloud -> next iteration - continue; - - dissipate = you.time_taken; - - // water -> flaming clouds: - // lava -> freezing clouds: - if ((env.cloud[cc].type == CLOUD_FIRE - || env.cloud[cc].type == CLOUD_FIRE_MON) - && grd[env.cloud[cc].x][env.cloud[cc].y] == DNGN_DEEP_WATER) - { - dissipate *= 4; - } - else if ((env.cloud[cc].type == CLOUD_COLD - || env.cloud[cc].type == CLOUD_COLD_MON) - && grd[env.cloud[cc].x][env.cloud[cc].y] == DNGN_LAVA) - { - dissipate *= 4; - } - - // double the amount when slowed - must be applied last(!): - if (you.slow) - dissipate *= 2; - - // apply calculated rate to the actual cloud: - env.cloud[cc].decay -= dissipate; - - // check for total dissipatation and handle accordingly: - if (env.cloud[cc].decay < 1) - delete_cloud( cc ); - } - - return; -} // end manage_clouds() - void weird_writing(char stringy[40]) { int temp_rand = 0; // for probability determinations {dlb} @@ -2194,3 +2157,80 @@ return curr_subdungeon_level; } + +//////////////////////////////////////////////////////////////////////////// +// Living breathing dungeon stuff. +// + +static std::vector<coord_def> sfx_seeds; + +void setup_environment_effects() +{ + sfx_seeds.clear(); + + for (int x = X_BOUND_1; x <= X_BOUND_2; ++x) + { + for (int y = Y_BOUND_1; y <= Y_BOUND_2; ++y) + { + if (!in_bounds(x, y)) + continue; + + const int grid = grd[x][y]; + if (grid == DNGN_LAVA + || (grid == DNGN_SHALLOW_WATER + && you.where_are_you == BRANCH_SWAMP)) + { + coord_def c = { x, y }; + sfx_seeds.push_back(c); + } + } + } +#ifdef DEBUG_DIAGNOSTICS + mprf(MSGCH_DIAGNOSTICS, "%u environment effect seeds", sfx_seeds.size()); +#endif +} + +static void apply_environment_effect(const coord_def &c) +{ + const int grid = grd[c.x][c.y]; + if (grid == DNGN_LAVA) + check_place_cloud( CLOUD_BLACK_SMOKE_MON, + c.x, c.y, random_range( 4, 8 ) ); + else if (grid == DNGN_SHALLOW_WATER) + check_place_cloud( CLOUD_MIST, + c.x, c.y, random_range( 2, 5 ) ); +} + +static const int Base_Sfx_Chance = 5; +void run_environment_effects() +{ + if (!you.time_taken) + return; + + // Each square in sfx_seeds has this chance of doing something special + // per turn. + const int sfx_chance = Base_Sfx_Chance * you.time_taken / 10; + const int nseeds = sfx_seeds.size(); + + // If there is a large number of seeds, speed things up by fudging the + // numbers. + if (nseeds > 100) + { + int nsels = div_rand_round( sfx_seeds.size() * sfx_chance, 100 ); + if (one_chance_in(5)) + nsels += random2(nsels * 3); + + for (int i = 0; i < nsels; ++i) + apply_environment_effect( sfx_seeds[ random2(nseeds) ] ); + } + else + { + for (int i = 0; i < nseeds; ++i) + { + if (random2(100) >= sfx_chance) + continue; + + apply_environment_effect( sfx_seeds[i] ); + } + } +} Modified: trunk/crawl-ref/source/misc.h =================================================================== --- trunk/crawl-ref/source/misc.h 2006-11-23 17:44:30 UTC (rev 485) +++ trunk/crawl-ref/source/misc.h 2006-11-24 08:48:05 UTC (rev 486) @@ -36,13 +36,6 @@ /* *********************************************************************** * called from: acr * *********************************************************************** */ -void manage_clouds(void); - - -// last updated 12may2000 {dlb} -/* *********************************************************************** - * called from: acr - * *********************************************************************** */ void disarm_trap(struct dist &disa); @@ -139,6 +132,7 @@ bool grid_is_opaque(int grid); bool grid_is_solid(int grid); bool grid_is_water(int grid); +bool grid_is_watery( int grid ); god_type grid_altar_god( unsigned char grid ); bool grid_is_branch_stairs( unsigned char grid ); int grid_secret_door_appearance( int gx, int gy ); @@ -150,6 +144,11 @@ bool i_feel_safe(); +void setup_environment_effects(); + +// Lava smokes, swamp water mists. +void run_environment_effects(); + ////////////////////////////////////////////////////////////////////// // Places and names // Modified: trunk/crawl-ref/source/mon-data.h =================================================================== --- trunk/crawl-ref/source/mon-data.h 2006-11-23 17:44:30 UTC (rev 485) +++ trunk/crawl-ref/source/mon-data.h 2006-11-24 08:48:05 UTC (rev 486) @@ -3665,7 +3665,7 @@ 900, 10, MONS_DRACONIAN, MONS_PALE_DRACONIAN, MH_NATURAL, -2, { 20, 0, 0, 0 }, { 14, 5, 4, 0 }, - 9, 14, 12, 10, MST_NO_SPELLS, CE_CONTAMINATED, Z_SMALL, S_ROAR, I_HIGH, + 9, 14, 10, 10, MST_NO_SPELLS, CE_CONTAMINATED, Z_SMALL, S_ROAR, I_HIGH, MONUSE_STARTING_EQUIPMENT } , Modified: trunk/crawl-ref/source/stuff.cc =================================================================== --- trunk/crawl-ref/source/stuff.cc 2006-11-23 17:44:30 UTC (rev 485) +++ trunk/crawl-ref/source/stuff.cc 2006-11-24 08:48:05 UTC (rev 486) @@ -1098,6 +1098,10 @@ ret = LIGHTGREY; break; + case EC_MIST: + ret = tmp_rand < 100? CYAN : BLUE; + break; + case EC_RANDOM: ret = 1 + random2(15); // always random break; Modified: trunk/crawl-ref/source/travel.cc =================================================================== --- trunk/crawl-ref/source/travel.cc 2006-11-23 17:44:30 UTC (rev 485) +++ trunk/crawl-ref/source/travel.cc 2006-11-24 08:48:05 UTC (rev 486) @@ -456,7 +456,8 @@ cloud_type == CLOUD_PURP_SMOKE || cloud_type == CLOUD_PURP_SMOKE_MON || cloud_type == CLOUD_BLACK_SMOKE || - cloud_type == CLOUD_BLACK_SMOKE_MON; + cloud_type == CLOUD_BLACK_SMOKE_MON || + cloud_type == CLOUD_MIST; } static bool player_is_permalevitating() Modified: trunk/crawl-ref/source/view.cc =================================================================== --- trunk/crawl-ref/source/view.cc 2006-11-23 17:44:30 UTC (rev 485) +++ trunk/crawl-ref/source/view.cc 2006-11-24 08:48:05 UTC (rev 486) @@ -890,6 +890,10 @@ which_colour = DARKGREY; break; + case CLOUD_MIST: + which_colour = EC_MIST; + break; + default: which_colour = LIGHTGREY; break; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dsh...@us...> - 2006-11-24 10:31:17
|
Revision: 487 http://svn.sourceforge.net/crawl-ref/?rev=487&view=rev Author: dshaligram Date: 2006-11-24 02:31:14 -0800 (Fri, 24 Nov 2006) Log Message: ----------- [1581184] Fixed rotting food being visible outside LOS. Modified Paths: -------------- trunk/crawl-ref/source/abyss.cc trunk/crawl-ref/source/acr.cc trunk/crawl-ref/source/externs.h trunk/crawl-ref/source/files.cc trunk/crawl-ref/source/player.cc trunk/crawl-ref/source/tags.cc trunk/crawl-ref/source/tags.h trunk/crawl-ref/source/view.cc trunk/crawl-ref/source/view.h Modified: trunk/crawl-ref/source/abyss.cc =================================================================== --- trunk/crawl-ref/source/abyss.cc 2006-11-24 08:48:05 UTC (rev 486) +++ trunk/crawl-ref/source/abyss.cc 2006-11-24 10:31:14 UTC (rev 487) @@ -71,6 +71,7 @@ for (j = 0; j < GYM; j++) { env.map[i][j] = 0; + env.map_col[i][j].clear(); } } Modified: trunk/crawl-ref/source/acr.cc =================================================================== --- trunk/crawl-ref/source/acr.cc 2006-11-24 08:48:05 UTC (rev 486) +++ trunk/crawl-ref/source/acr.cc 2006-11-24 10:31:14 UTC (rev 487) @@ -2728,6 +2728,7 @@ igrd[i][j] = NON_ITEM; mgrd[i][j] = NON_MONSTER; env.map[i][j] = 0; + env.map_col[i][j].clear(); } } Modified: trunk/crawl-ref/source/externs.h =================================================================== --- trunk/crawl-ref/source/externs.h 2006-11-24 08:48:05 UTC (rev 486) +++ trunk/crawl-ref/source/externs.h 2006-11-24 10:31:14 UTC (rev 487) @@ -599,6 +599,15 @@ unsigned char type; }; +struct map_colour +{ + short colour; + short flags; + + operator short () const { return colour; } + void clear() { colour = flags = 0; } +}; + struct crawl_environment { unsigned char rock_colour; @@ -612,7 +621,8 @@ FixedArray< int, GXM, GYM > igrid; // item grid FixedArray< unsigned char, GXM, GYM > cgrid; // cloud grid - FixedArray< unsigned short, GXM, GYM > map; // discovered terrain + FixedArray< unsigned short, GXM, GYM > map; // discovered terrain + FixedArray< map_colour, GXM, GYM > map_col; // map colours FixedArray< unsigned int, 19, 19> show; // view window char FixedArray< unsigned short, 19, 19> show_col; // view window colour Modified: trunk/crawl-ref/source/files.cc =================================================================== --- trunk/crawl-ref/source/files.cc 2006-11-24 08:48:05 UTC (rev 486) +++ trunk/crawl-ref/source/files.cc 2006-11-24 10:31:14 UTC (rev 487) @@ -773,7 +773,10 @@ for (j = 0; j < GYM; j++) { if (just_created_level) + { env.map[i][j] = 0; + env.map_col[i][j].clear(); + } if (you.char_direction == DIR_ASCENDING && you.level_type != LEVEL_PANDEMONIUM) @@ -1154,8 +1157,9 @@ // 0.8 widened env.map to 2 bytes // 0.9 inscriptions (hp) // 0.10 Monster colour and spells separated from mons->number. + // 0.11 env colours moved into env.mapcol - write_tagged_file( saveFile, SAVE_MAJOR_VERSION, 10, TAGTYPE_LEVEL ); + write_tagged_file( saveFile, SAVE_MAJOR_VERSION, 11, TAGTYPE_LEVEL ); fclose(saveFile); Modified: trunk/crawl-ref/source/player.cc =================================================================== --- trunk/crawl-ref/source/player.cc 2006-11-24 08:48:05 UTC (rev 486) +++ trunk/crawl-ref/source/player.cc 2006-11-24 10:31:14 UTC (rev 487) @@ -2135,6 +2135,7 @@ if (random2(100) < chance_forgotten) { env.map[xcount][ycount] = 0; + env.map_col[xcount][ycount].clear(); } } } Modified: trunk/crawl-ref/source/tags.cc =================================================================== --- trunk/crawl-ref/source/tags.cc 2006-11-24 08:48:05 UTC (rev 486) +++ trunk/crawl-ref/source/tags.cc 2006-11-24 10:31:14 UTC (rev 487) @@ -1436,6 +1436,8 @@ { marshallByte(th, grd[count_x][count_y]); marshallShort(th, env.map[count_x][count_y]); + marshallShort(th, env.map_col[count_x][count_y].colour); + marshallShort(th, env.map_col[count_x][count_y].flags); marshallByte(th, env.cgrid[count_x][count_y]); } } @@ -1598,6 +1600,14 @@ if ((env.map[i][j] & 0xFF) == 201) // what is this?? env.map[i][j] = (env.map[i][j] & 0xFF00U) | 239; + if (minorVersion >= 11) + { + env.map_col[i][j].colour = unmarshallShort(th); + env.map_col[i][j].flags = unmarshallShort(th); + } + else + env.map_col[i][j].clear(); + mgrd[i][j] = NON_MONSTER; env.cgrid[i][j] = unmarshallByte(th); Modified: trunk/crawl-ref/source/tags.h =================================================================== --- trunk/crawl-ref/source/tags.h 2006-11-24 08:48:05 UTC (rev 486) +++ trunk/crawl-ref/source/tags.h 2006-11-24 10:31:14 UTC (rev 487) @@ -59,7 +59,7 @@ /* *********************************************************************** * called from: acr * *********************************************************************** */ -void tag_init(long largest_tag = 50000); +void tag_init(long largest_tag = 100000); // last updated 22jan2001 {gdl} Modified: trunk/crawl-ref/source/view.cc =================================================================== --- trunk/crawl-ref/source/view.cc 2006-11-24 08:48:05 UTC (rev 486) +++ trunk/crawl-ref/source/view.cc 2006-11-24 10:31:14 UTC (rev 487) @@ -64,6 +64,10 @@ #define MAP_CHARACTER_MASK 0x00ff +// Flags that define what the player remembers on this square. +#define MC_ITEM 0x01 +#define MC_MONS 0x02 + struct feature_def { unsigned short symbol; // symbol used for seen terrain @@ -109,6 +113,7 @@ // Applies EC_ colour substitutions and brands. static unsigned fix_colour(unsigned raw_colour); +static int get_viewobj_flags(int viewobj); //--------------------------------------------------------------- // @@ -181,12 +186,61 @@ return (env.map[x - 1][y - 1] & MAP_DETECTED_MONSTER); } +void set_envmap_glyph(int x, int y, int chr, int col, int object) +{ + set_envmap_char(x, y, chr); + set_envmap_col(x, y, col, get_viewobj_flags(object)); +} + void set_envmap_char( int x, int y, unsigned char chr ) { env.map[x - 1][y - 1] &= (~MAP_CHARACTER_MASK); // clear old first env.map[x - 1][y - 1] |= chr; } +void set_envmap_col( int x, int y, int colour ) +{ + env.map_col[x - 1][y - 1].colour = colour; + env.map_col[x - 1][y - 1].flags = 0; +} + +void set_envmap_col( int x, int y, int colour, int flags ) +{ + env.map_col[x - 1][y - 1].colour = colour; + env.map_col[x - 1][y - 1].flags = flags; +} + +inline void set_envmap_item(int x, int y, bool isitem) +{ + if (isitem) + env.map_col[x - 1][y - 1].flags |= MC_ITEM; + else + env.map_col[x - 1][y - 1].flags &= ~MC_ITEM; +} + +inline void set_envmap_mons(int x, int y, bool ismons) +{ + if (ismons) + env.map_col[x - 1][y - 1].flags |= MC_MONS; + else + env.map_col[x - 1][y - 1].flags &= ~MC_MONS; +} + +bool is_envmap_item(int x, int y) +{ + return (env.map_col[x - 1][y - 1].flags & MC_ITEM); +} + +bool is_envmap_mons(int x, int y) +{ + return (env.map_col[x - 1][y - 1].flags & MC_MONS); +} + +int get_envmap_col(int x, int y) +{ + return (env.map_col[x - 1][y - 1].colour); +} + bool is_terrain_known( int x, int y ) { return (env.map[x - 1][y - 1] & (MAP_MAGIC_MAPPED_FLAG | MAP_SEEN_FLAG)); @@ -223,6 +277,7 @@ void clear_envmap_grid( int x, int y ) { env.map[x - 1][y - 1] = 0; + env.map_col[x - 1][y - 1].clear(); } void clear_envmap( void ) @@ -232,6 +287,7 @@ for (int j = 0; j < GYM; j++) { env.map[i][j] = 0; + env.map_col[i][j].clear(); } } } @@ -284,6 +340,21 @@ return (raw_colour); } +static int get_viewobj_flags(int object) +{ + // Check for monster glyphs. + if (object >= DNGN_START_OF_MONSTERS) + return (MC_MONS); + + // Check for item glyphs. + if (object >= DNGN_ITEM_ORB && object < DNGN_CLOUD) + return (MC_ITEM); + + // We don't care to look further; we could check for + // clouds here as well. + return (0); +} + static void get_symbol( unsigned int object, unsigned short *ch, unsigned short *colour ) { @@ -423,7 +494,6 @@ bool travel_colour ) { // XXX: Yes, the map array and the grid array are off by one. -- bwr - const int map_value = (unsigned char) env.map[x][y]; const unsigned short map_flags = env.map[x][y]; const int grid_value = grd[x + 1][y + 1]; @@ -445,31 +515,9 @@ if (tc == LIGHTGREEN || tc == LIGHTMAGENTA) return fix_colour(tc); - // XXX: Yeah, this is ugly, but until we have stored layers in the - // map we can't tell if we've seen a square, detected it, or just - // detected the item or monster on top... giving colour here will - // result in detect creature/item detecting features like stairs. -- bwr - if (map_value != get_sightmap_char(grid_value)) - { - // If there's an item on this square, change colour to indicate - // that, iff the item's glyph matches map_value. XXX: Potentially - // abusable? -- ds - int item = igrd[x + 1][y + 1]; - if (item_colour && item != NON_ITEM - && map_value == - get_sightmap_char(get_item_dngn_code(mitm[item]))) - { - unsigned ic = mitm[item].colour; + if (item_colour && is_envmap_item(x + 1, y + 1)) + return get_envmap_col(x + 1, y + 1); - if (mitm[item].link != NON_ITEM ) - ic |= COLFLAG_ITEM_HEAP; - - // If the item colour is the background colour, tweak it to WHITE - // instead to catch the player's eye. - return fix_colour( ic == tc? WHITE : ic ); - } - } - int feature_colour = DARKGREY; feature_colour = is_terrain_seen(x + 1, y + 1)? Feature[grid_value].seen_colour @@ -494,14 +542,11 @@ if (is_terrain_changed(x, y)) continue; - unsigned short envc = env.map[x][y] & MAP_CHARACTER_MASK; + unsigned short envc = get_envmap_char(x, y); if (!envc) continue; - const int item = igrd[x + 1][y + 1]; - if (item != NON_ITEM - && envc == - get_sightmap_char(get_item_dngn_code(mitm[item]))) + if (is_envmap_item(x, y)) continue; set_envmap_char(x, y, @@ -3444,7 +3489,7 @@ unsigned short ch; get_symbol( object, &ch, &colour ); - set_envmap_char( gx, gy, ch ); + set_envmap_glyph( gx, gy, ch, colour, object ); set_terrain_seen( gx, gy ); set_envmap_detected_mons(gx, gy, false); set_envmap_detected_item(gx, gy, false); @@ -3490,7 +3535,7 @@ if (buffy[bufcount] != 0) { // ... map that we've seen this - set_envmap_char( gx, gy, buffy[bufcount] ); + set_envmap_glyph( gx, gy, ch, colour, object ); set_terrain_seen( gx, gy ); set_envmap_detected_mons(gx, gy, false); set_envmap_detected_item(gx, gy, false); @@ -3512,7 +3557,8 @@ && is_terrain_seen( gx, gy )) { get_symbol( Show_Backup[ex][ey], &ch, &colour ); - set_envmap_char( gx, gy, ch ); + set_envmap_glyph( gx, gy, ch, colour, + Show_Backup[ex][ey] ); } // Now we get to filling in both the unseen Modified: trunk/crawl-ref/source/view.h =================================================================== --- trunk/crawl-ref/source/view.h 2006-11-24 08:48:05 UTC (rev 486) +++ trunk/crawl-ref/source/view.h 2006-11-24 10:31:14 UTC (rev 487) @@ -116,6 +116,9 @@ void set_envmap_char( int x, int y, unsigned char chr ); void set_envmap_detected_item(int x, int y, bool detected = true); void set_envmap_detected_mons(int x, int y, bool detected = true); +void set_envmap_col( int x, int y, int colour, int flags ); +void set_envmap_col( int x, int y, int colour ); + bool is_envmap_detected_item(int x, int y); bool is_envmap_detected_mons(int x, int y); void set_terrain_mapped( int x, int y ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ha...@us...> - 2006-11-26 14:54:51
|
Revision: 495 http://svn.sourceforge.net/crawl-ref/?rev=495&view=rev Author: haranp Date: 2006-11-26 06:54:48 -0800 (Sun, 26 Nov 2006) Log Message: ----------- New overview screen (the 'O' screen.) This involves changes in quite a few things, so the major savefile version is now 1, and old savefiles *will not load*! Lots of conditional loading code has therefore been removed. Minor savefile version dropped to 0 in everything. Modified Paths: -------------- trunk/crawl-ref/source/acr.cc trunk/crawl-ref/source/enum.h trunk/crawl-ref/source/externs.h trunk/crawl-ref/source/files.cc trunk/crawl-ref/source/menu.cc trunk/crawl-ref/source/menu.h trunk/crawl-ref/source/misc.cc trunk/crawl-ref/source/misc.h trunk/crawl-ref/source/mon-util.cc trunk/crawl-ref/source/mon-util.h trunk/crawl-ref/source/overmap.cc trunk/crawl-ref/source/overmap.h trunk/crawl-ref/source/tags.cc trunk/crawl-ref/source/travel.cc trunk/crawl-ref/source/travel.h trunk/crawl-ref/source/version.h trunk/crawl-ref/source/view.cc Modified: trunk/crawl-ref/source/acr.cc =================================================================== --- trunk/crawl-ref/source/acr.cc 2006-11-26 14:32:43 UTC (rev 494) +++ trunk/crawl-ref/source/acr.cc 2006-11-26 14:54:48 UTC (rev 495) @@ -830,22 +830,9 @@ of round */ bool apply_berserk_penalty = false; -/* There is now a distinction between keycodes and commands. - A keycode_type gets mapped through keycode_to_command to - become a command_type. - So a keycode_type could be something like 'H'; - a command_type would be something like COMMAND_RUN_LEFT. -*/ - /* - This function handles the player's input. It's called from main(), from - inside an endless loop. - - It's now undergone major refactoring. The code path is now: - 1. Get next player input item (key) - 2. Translate key to command - 3. Execute the command - 4. Update rest of world if necessary + This function handles the player's input. It's called from main(), from + inside an endless loop. */ static void input() { @@ -2685,7 +2672,6 @@ #endif seed_rng(); - init_overmap(); // in overmap.cc (duh?) clear_ids(); // in itemname.cc init_feature_table(); Modified: trunk/crawl-ref/source/enum.h =================================================================== --- trunk/crawl-ref/source/enum.h 2006-11-26 14:32:43 UTC (rev 494) +++ trunk/crawl-ref/source/enum.h 2006-11-26 14:54:48 UTC (rev 495) @@ -2690,6 +2690,16 @@ PSIZE_PROFILE // profile only (for stealth checks) }; +enum portal_type +{ + PORTAL_NONE = 0, + PORTAL_LABYRINTH, + PORTAL_HELL, + PORTAL_ABYSS, + PORTAL_PANDEMONIUM, + NUM_PORTALS +}; + // [dshaligram] If you edit potion colours/descriptions, also update // itemname.cc. enum potion_description_colour_type Modified: trunk/crawl-ref/source/externs.h =================================================================== --- trunk/crawl-ref/source/externs.h 2006-11-26 14:32:43 UTC (rev 494) +++ trunk/crawl-ref/source/externs.h 2006-11-26 14:54:48 UTC (rev 495) @@ -109,7 +109,7 @@ int x; int y; - // coord_def( int x_in = 0, int y_in = 0 ) : x(x_in), y(y_in) {}; + // coord_def( int x_in, int y_in ) : x(x_in), y(y_in) {}; bool operator == (const coord_def &other) const { return x == other.x && y == other.y; } @@ -117,6 +117,10 @@ bool operator != (const coord_def &other) const { return x != other.x || y != other.y; } + + bool operator < (const coord_def &other) const { + return (x < other.x) || (x == other.x && y < other.y); + } }; struct dice_def Modified: trunk/crawl-ref/source/files.cc =================================================================== --- trunk/crawl-ref/source/files.cc 2006-11-26 14:32:43 UTC (rev 494) +++ trunk/crawl-ref/source/files.cc 2006-11-26 14:54:48 UTC (rev 495) @@ -1146,21 +1146,8 @@ // nail all items to the ground fix_item_coordinates(); - // 0.0 initial genesis of saved format - // 0.1 added attitude tag - // 0.2 replaced old 'enchantment1' and with 'flags' (bitfield) - // 0.3 changes to make the item structure more sane - // 0.4 changes to the ghost save section - // 0.5 spell and ability letter arrays - // 0.6 inventory slots of items - // 0.7 origin tracking for items - // 0.8 widened env.map to 2 bytes - // 0.9 inscriptions (hp) - // 0.10 Monster colour and spells separated from mons->number. - // 0.11 env colours moved into env.mapcol + write_tagged_file( saveFile, SAVE_MAJOR_VERSION, 0, TAGTYPE_LEVEL ); - write_tagged_file( saveFile, SAVE_MAJOR_VERSION, 11, TAGTYPE_LEVEL ); - fclose(saveFile); DO_CHMOD_PRIVATE(cha_fil.c_str()); @@ -1225,14 +1212,7 @@ end(-1); } - // 0.0 initial genesis of saved format - // 0.1 changes to make the item structure more sane - // 0.2 spell and ability tables - // 0.3 added you.magic_contamination (05/03/05) - // 0.4 added item origins - // 0.5 added num_gifts - // 0.6 inscriptions - write_tagged_file( charf, SAVE_MAJOR_VERSION, 6, TAGTYPE_PLAYER ); + write_tagged_file( charf, SAVE_MAJOR_VERSION, 0, TAGTYPE_PLAYER ); fclose(charf); DO_CHMOD_PRIVATE(charFile.c_str()); @@ -1448,7 +1428,7 @@ if (majorVersion == SAVE_MAJOR_VERSION) return true; - return false; // if its not 0, no idea + return false; // if it's not 0, no idea } static void restore_version( FILE *restoreFile, @@ -1676,9 +1656,7 @@ return; } - // 0.0-0.3 old tagged savefile (values as unsigned char) - // 0.4 new tagged savefile (values as signed short) - write_tagged_file( gfile, SAVE_MAJOR_VERSION, 4, TAGTYPE_GHOST ); + write_tagged_file( gfile, SAVE_MAJOR_VERSION, 0, TAGTYPE_GHOST ); fclose(gfile); Modified: trunk/crawl-ref/source/menu.cc =================================================================== --- trunk/crawl-ref/source/menu.cc 2006-11-26 14:32:43 UTC (rev 494) +++ trunk/crawl-ref/source/menu.cc 2006-11-26 14:54:48 UTC (rev 495) @@ -1017,9 +1017,9 @@ { int size = ops.size(); if (!size) - return ; + return; - cap(s, size); + cap(s, size); cap(e, size); for (int i = s; i <= e && i < size; ++i) @@ -1205,3 +1205,74 @@ flines[f] += lines[i]; } } + +formatted_scroller::formatted_scroller(int _flags, const std::string& s) : + Menu(_flags) +{ + size_t eolpos = 0; + while ( true ) + { + const size_t newpos = s.find( EOL, eolpos ); + add_entry(new MenuEntry(std::string(s, eolpos, newpos-eolpos))); + if ( newpos == std::string::npos ) + break; + else + eolpos = newpos + strlen(EOL); + } +} + +void formatted_scroller::draw_item(int index, const MenuEntry *me) const +{ + formatted_string::parse_string(me->text).display(); +} + +int linebreak_string( std::string& s, int wrapcol, int maxcol ) +{ + size_t loc = 0; + int xpos = 0; + int breakcount = 0; + while ( loc < s.size() ) + { + if ( s[loc] == '<' ) // tag + { + // << escape + if ( loc + 1 < s.size() && s[loc+1] == '<' ) + { + ++xpos; + loc += 2; + // Um, we never break on <<. That's a feature. Right. + continue; + } + // skip tag + while ( loc < s.size() && s[loc] != '>' ) + ++loc; + ++loc; + } + else + { + // user-forced newline + if ( s[loc] == '\n' ) + xpos = 0; + // soft linebreak + else if ( s[loc] == ' ' && xpos > wrapcol ) + { + s.replace(loc, 1, EOL); + xpos = 0; + ++breakcount; + } + // hard linebreak + else if ( xpos > maxcol ) + { + s.insert(loc, EOL); + xpos = 0; + ++breakcount; + } + // bog-standard + else + ++xpos; + + ++loc; + } + } + return breakcount; +} Modified: trunk/crawl-ref/source/menu.h =================================================================== --- trunk/crawl-ref/source/menu.h 2006-11-26 14:32:43 UTC (rev 494) +++ trunk/crawl-ref/source/menu.h 2006-11-26 14:54:48 UTC (rev 495) @@ -404,6 +404,15 @@ std::vector<formatted_string> flines; }; +class formatted_scroller : public Menu +{ +public: + formatted_scroller(int flags, const std::string& s); +protected: + virtual void draw_item(int index, const MenuEntry* me) const; +}; + int menu_colour(const std::string &itemtext); +int linebreak_string( std::string& s, int wrapcol, int maxcol ); #endif Modified: trunk/crawl-ref/source/misc.cc =================================================================== --- trunk/crawl-ref/source/misc.cc 2006-11-26 14:32:43 UTC (rev 494) +++ trunk/crawl-ref/source/misc.cc 2006-11-26 14:54:48 UTC (rev 495) @@ -2001,6 +2001,45 @@ you.level_type ); } +bool single_level_branch( int branch ) +{ + return + branch == BRANCH_VESTIBULE_OF_HELL || + branch == BRANCH_HALL_OF_BLADES || + branch == BRANCH_ECUMENICAL_TEMPLE; +} + +std::string branch_name( int branch, bool terse ) +{ + const char* names[][2] = { + { "The Dungeon", "D" }, + { "The Iron City of Dis", "Dis" }, + { "Gehenna", "Geh" }, + { "The Vestibule of Hell", "Hell" }, + { "Cocytus", "Coc" }, + { "Tartarus", "Tar" }, + { "Inferno", "Inf" }, + { "The Pit", "Pit" }, + { "", "" }, + { "", "" }, + { "The Orcish Mines", "Orc" }, + { "The Hive", "Hive" }, + { "The Lair", "Lair" }, + { "The Slime Pits", "Slime" }, + { "The Vaults", "Vault" }, + { "The Crypt", "Crypt" }, + { "The Hall of Blades", "Blade" }, + { "The Hall of Zot", "Zot" }, + { "The Ecumenical Temple", "Temple" }, + { "The Snake Pit", "Snake" }, + { "The Elven Halls", "Elf" }, + { "The Tomb", "Tomb" }, + { "The Swamp", "Swamp" }, + { "The Caverns", "Cav" } + }; + return names[branch][terse]; +} + std::string place_name( unsigned short place, bool long_name, bool include_number ) { @@ -2022,68 +2061,10 @@ return ( long_name ? "Buggy Badlands" : "Bug" ); } } - else - { - switch (branch) - { - case BRANCH_VESTIBULE_OF_HELL: - return ( long_name ? "The Vestibule of Hell" : "Hell" ); - case BRANCH_HALL_OF_BLADES: - return ( long_name ? "The Hall of Blades" : "Blade" ); - case BRANCH_ECUMENICAL_TEMPLE: - return ( long_name ? "The Ecumenical Temple" : "Temple" ); - case BRANCH_DIS: - result = ( long_name ? "The Iron City of Dis" : "Dis"); - break; - case BRANCH_GEHENNA: - result = ( long_name ? "Gehenna" : "Geh" ); - break; - case BRANCH_COCYTUS: - result = ( long_name ? "Cocytus" : "Coc" ); - break; - case BRANCH_TARTARUS: - result = ( long_name ? "Tartarus" : "Tar" ); - break; - case BRANCH_ORCISH_MINES: - result = ( long_name ? "The Orcish Mines" : "Orc" ); - break; - case BRANCH_HIVE: - result = ( long_name ? "The Hive" : "Hive" ); - break; - case BRANCH_LAIR: - result = ( long_name ? "The Lair" : "Lair" ); - break; - case BRANCH_SLIME_PITS: - result = ( long_name ? "The Slime Pits" : "Slime" ); - break; - case BRANCH_VAULTS: - result = ( long_name ? "The Vaults" : "Vault" ); - break; - case BRANCH_CRYPT: - result = ( long_name ? "The Crypt" : "Crypt" ); - break; - case BRANCH_HALL_OF_ZOT: - result = ( long_name ? "The Hall of Zot" : "Zot" ); - break; - case BRANCH_SNAKE_PIT: - result = ( long_name ? "The Snake Pit" : "Snake" ); - break; - case BRANCH_ELVEN_HALLS: - result = ( long_name ? "The Elven Halls" : "Elf" ); - break; - case BRANCH_TOMB: - result = ( long_name ? "The Tomb" : "Tomb" ); - break; - case BRANCH_SWAMP: - result = ( long_name ? "The Swamp" : "Swamp" ); - break; - default: - result = ( long_name ? "The Dungeon" : "D" ); - break; - } - } - if ( include_number ) { + result = branch_name(branch, !long_name); + + if ( include_number && !single_level_branch(branch) ) { char buf[200]; if ( long_name ) { // decapitalize 'the' Modified: trunk/crawl-ref/source/misc.h =================================================================== --- trunk/crawl-ref/source/misc.h 2006-11-26 14:32:43 UTC (rev 494) +++ trunk/crawl-ref/source/misc.h 2006-11-26 14:54:48 UTC (rev 495) @@ -161,6 +161,7 @@ std::string short_place_name(level_id id); std::string place_name( unsigned short place, bool long_name = false, bool include_number = true ); +std::string branch_name( int branch, bool terse ); // Prepositional form of branch level name. For example, "in the // Abyss" or "on level 3 of the Main Dungeon". Modified: trunk/crawl-ref/source/mon-util.cc =================================================================== --- trunk/crawl-ref/source/mon-util.cc 2006-11-26 14:32:43 UTC (rev 494) +++ trunk/crawl-ref/source/mon-util.cc 2006-11-26 14:54:48 UTC (rev 495) @@ -1062,13 +1062,6 @@ return (x_val); } // end exper_value() -int obsolete_mons_spell_template_index(const monsters *mon) -{ - return (mons_class_flag(mon->type, M_SPELLCASTER)? - mon->number - : MST_NO_SPELLS); -} - void mons_load_spells( monsters *mon, int book ) { int x, y; Modified: trunk/crawl-ref/source/mon-util.h =================================================================== --- trunk/crawl-ref/source/mon-util.h 2006-11-26 14:32:43 UTC (rev 494) +++ trunk/crawl-ref/source/mon-util.h 2006-11-26 14:54:48 UTC (rev 495) @@ -331,9 +331,6 @@ int mons_class_colour(int mc); int mons_colour(const monsters *m); -// Only for save-compatibility. -int obsolete_mons_spell_template_index(const monsters *mon); - void mons_load_spells( monsters *mon, int book ); // last updated 12may2000 {dlb} Modified: trunk/crawl-ref/source/overmap.cc =================================================================== --- trunk/crawl-ref/source/overmap.cc 2006-11-26 14:32:43 UTC (rev 494) +++ trunk/crawl-ref/source/overmap.cc 2006-11-26 14:54:48 UTC (rev 495) @@ -27,99 +27,94 @@ // for #definitions of MAX_BRANCHES & MAX_LEVELS #include "files.h" -// for #definitions of MAX_BRANCHES & MAX_LEVELS +#include "menu.h" #include "misc.h" #include "religion.h" +#include "shopping.h" #include "stuff.h" #include "view.h" -enum -{ - NO_FEATURE = 0x00, - FEATURE_SHOP = 0x01, - FEATURE_LABYRINTH = 0x02, - FEATURE_HELL = 0x04, - FEATURE_ABYSS = 0x08, - FEATURE_PANDEMONIUM = 0x10 -}; +std::map<branch_type, level_id> stair_level; +std::map<level_pos, shop_type> shops_present; +std::map<level_pos, god_type> altars_present; +std::map<level_pos, portal_type> portals_present; -// These variables need to become part of the player struct -// and need to be stored in the .sav file: +static void seen_altar( god_type god, const coord_def& pos ); +static void seen_staircase(unsigned char which_staircase,const coord_def& pos); +static void seen_other_thing(unsigned char which_thing, const coord_def& pos); -// 0 == no altars; -// 100 == more than one altar; or -// # == which god for remaining numbers. - -FixedArray<unsigned char, MAX_LEVELS, MAX_BRANCHES> altars_present; -FixedVector<char, MAX_BRANCHES> stair_level; -FixedArray<unsigned char, MAX_LEVELS, MAX_BRANCHES> feature; - -int map_lines = 0; //mv: number of lines already printed on "over-map" screen - -//mv: prints one line in specified colour -// void print_one_map_line( const char *line, int colour ); -// void print_branch_entrance_line( const char *area ); - -void print_one_simple_line( const char *line, int colour ); -void print_one_highlighted_line( const char *pre, const char *text, - const char *post, int colour ); - -static void print_level_name( int branch, int depth, - bool &printed_branch, bool &printed_level ); - -void seen_notable_thing( int which_thing ) +void seen_notable_thing( int which_thing, int x, int y ) { // Don't record in temporary terrain if (you.level_type != LEVEL_DUNGEON) return; + + coord_def pos = {x, y}; const god_type god = grid_altar_god(which_thing); - if (god != GOD_NO_GOD) - seen_altar( god ); + seen_altar( god, pos ); else if (grid_is_branch_stairs( which_thing )) - seen_staircase( which_thing ); + seen_staircase( which_thing, pos ); else - seen_other_thing( which_thing ); + seen_other_thing( which_thing, pos ); } -void init_overmap( void ) +static const char* portaltype_to_string(portal_type p) { - for (int i = 0; i < MAX_LEVELS; i++) + switch ( p ) { - for (int j = 0; j < MAX_BRANCHES; j++) - { - altars_present[i][j] = 0; - feature[i][j] = 0; - } + case PORTAL_LABYRINTH: + return "<cyan>Labyrinth:</cyan>"; + case PORTAL_HELL: + return "<red>Hell:</red>"; + case PORTAL_ABYSS: + return "<magenta>Abyss:</magenta>"; + case PORTAL_PANDEMONIUM: + return "<blue>Pan:</blue>"; + default: + return "<lightred>Buggy:</lightred>"; } +} - for (int i = 0; i < MAX_BRANCHES; i++) - stair_level[i] = -1; -} // end init_overmap() +static char shoptype_to_char(shop_type s) +{ + switch ( s ) + { + case SHOP_WEAPON: + case SHOP_WEAPON_ANTIQUE: + return '('; + case SHOP_ARMOUR: + case SHOP_ARMOUR_ANTIQUE: + return '['; + case SHOP_GENERAL_ANTIQUE: + case SHOP_GENERAL: + return '*'; + case SHOP_JEWELLERY: + return '='; + case SHOP_WAND: + return '/'; + case SHOP_BOOK: + return ':'; + case SHOP_FOOD: + return '%'; + case SHOP_DISTILLERY: + return '!'; + case SHOP_SCROLL: + return '?'; + default: + return 'x'; + } +} void display_overmap() { -#ifdef DOS_TERM - char buffer[4800]; + char buffer[100]; + std::string disp; + bool seen_anything = false; - window(1, 1, 80, 25); - gettext(1, 1, 80, 25, buffer); -#endif - - //mv: must be set to 0 so "More..." message appears really at the - // bottom of the screen - //Don't forget it could be changed since the last call of display_overmap - map_lines = 0; - - clrscr(); - bool pr_lev = false; - bool output = false; - - print_one_simple_line(" Overview of the Dungeon", WHITE); - - // This is a more sensible order than the order of the enums -- bwr - const int list_order[] = + // better put this somewhere central + const branch_type list_order[] = { BRANCH_MAIN_DUNGEON, BRANCH_ECUMENICAL_TEMPLE, @@ -132,267 +127,165 @@ BRANCH_HALL_OF_ZOT }; - for (unsigned int index = 0; index < sizeof(list_order) / sizeof(int); index++) - { - const int i = list_order[index]; - bool printed_branch = false; + disp += " <white>Overview of the Dungeon</white>" EOL; - for (int j = 0; j < MAX_LEVELS; j++) + // print branches + int branchcount = 0; + for (unsigned int i = 1; i < sizeof(list_order)/sizeof(branch_type); ++i) + { + const branch_type branch = list_order[i]; + if ( stair_level.find(branch) != stair_level.end() ) { - bool printed_level = false; - - if (altars_present[j][i] != 0) + if ( !branchcount ) { - print_level_name( i, j, printed_branch, printed_level ); - output = true; - - if (altars_present[j][i] == 100) - { - print_one_highlighted_line( " - some ", - "altars to the gods", ".", - WHITE ); - } - else - { - snprintf( info, INFO_SIZE, "altar to %s", - god_name( altars_present[j][i] ) ); - - print_one_highlighted_line( " - an ", info, ".", WHITE ); - } + disp += EOL "<white>Branches:</white>" EOL; + seen_anything = true; } + + ++branchcount; - if ( (feature[j][i] & FEATURE_SHOP) ) - { - print_level_name( i, j, printed_branch, printed_level ); + snprintf(buffer, sizeof buffer, "<yellow>%-6s</yellow>: %-7s", + branch_name(branch, true).c_str(), + stair_level[branch].describe(false, true).c_str()); + disp += buffer; + if ( (branchcount % 4) == 0 ) + disp += EOL; + else + disp += " "; + } + } + if ( branchcount && (branchcount % 4) ) + disp += EOL; + + // print altars + // we loop through everything a dozen times, oh well + if ( !altars_present.empty() ) + { + disp += EOL "<white>Altars:</white>" EOL; + seen_anything = true; + } - // print_one_simple_line(" - facilities for the purchase of goods.",LIGHTGREY); + level_id last_id; + std::map<level_pos, god_type>::const_iterator ci_altar; + for ( int cur_god = GOD_NO_GOD; cur_god < NUM_GODS; ++cur_god ) + { + last_id.depth = 10000; // fake depth to be sure we don't match + // GOD_NO_GOD becomes your god + int real_god = (cur_god == GOD_NO_GOD ? you.religion : cur_god); + if ( cur_god == you.religion ) + continue; - print_one_highlighted_line( " - facilities for the ", - "purchase of goods", ".", LIGHTGREEN ); - output = true; - } - - if ( (feature[j][i] & FEATURE_ABYSS) ) + for ( ci_altar = altars_present.begin(); + ci_altar != altars_present.end(); + ++ci_altar ) + { + if ( ci_altar->second == real_god ) { - print_level_name( i, j, printed_branch, printed_level ); - // print_one_simple_line(" - a gateway into the Abyss.", LIGHTRED); - print_one_highlighted_line( " - a gateway into ", - "the Abyss", ".", MAGENTA ); - output = true; - } - - if ( (feature[j][i] & FEATURE_PANDEMONIUM) ) - { - print_level_name( i, j, printed_branch, printed_level ); - // print_one_simple_line(" - a link to Pandemonium.", LIGHTRED); - - print_one_highlighted_line( " - a link to ", "Pandemonium", - ".", LIGHTBLUE ); - output = true; - } - - if ( (feature[j][i] & FEATURE_HELL) ) - { - print_level_name( i, j, printed_branch, printed_level ); - // print_one_simple_line(" - a mouth of Hell.", LIGHTRED); - print_one_highlighted_line( " - a mouth of ", "Hell", ".", RED ); - output = true; - } - - if ( (feature[j][i] & FEATURE_LABYRINTH) ) - { - print_level_name( i, j, printed_branch, printed_level ); - // print_one_simple_line(" - the entrance of a Labyrinth.", LIGHTRED); - print_one_highlighted_line( " - an entrance to ", - "a Labyrinth", ".", CYAN ); - output = true; - } - - - // NB: k starts at 1 because there aren't any staircases - // to the main dungeon - for (int k = 1; k < MAX_BRANCHES; k++) - { - pr_lev = false; - // strcpy(info, " - a staircase leading to "); - info[0] = 0; - - if (stair_level[k] == j) + if ( last_id.depth == 10000 ) { - switch (i) + disp += god_name( ci_altar->second, false ); + disp += ": "; + disp += ci_altar->first.id.describe(false, true); + } + else + { + if ( last_id == ci_altar->first.id ) + disp += '*'; + else { - case BRANCH_LAIR: - switch (k) - { - case BRANCH_SLIME_PITS: - strcat(info, "the Slime Pits"); - pr_lev = true; - break; - case BRANCH_SNAKE_PIT: - strcat(info, "the Snake Pit"); - pr_lev = true; - break; - case BRANCH_SWAMP: - strcat(info, "the Swamp"); - pr_lev = true; - break; - } - break; - - case BRANCH_VAULTS: - switch (k) - { - case BRANCH_HALL_OF_BLADES: - strcat(info, "the Hall of Blades"); - pr_lev = true; - break; - case BRANCH_CRYPT: - strcat(info, "the Crypt"); - pr_lev = true; - break; - } - break; - - case BRANCH_CRYPT: - switch (k) - { - case BRANCH_TOMB: - strcat(info, "the Tomb"); - pr_lev = true; - break; - } - break; - - case BRANCH_ORCISH_MINES: - switch (k) - { - case BRANCH_ELVEN_HALLS: - strcat(info, "the Elven Halls"); - pr_lev = true; - break; - } - break; - - case BRANCH_MAIN_DUNGEON: - switch (k) - { - case BRANCH_ORCISH_MINES: - strcat(info, "the Orcish Mines"); - pr_lev = true; - break; - case BRANCH_HIVE: - strcat(info, "the Hive"); - pr_lev = true; - break; - case BRANCH_LAIR: - strcat(info, "the Lair"); - pr_lev = true; - break; - case BRANCH_VAULTS: - strcat(info, "the Vaults"); - pr_lev = true; - break; - case BRANCH_HALL_OF_ZOT: - strcat(info, "the Hall of Zot"); - pr_lev = true; - break; - case BRANCH_ECUMENICAL_TEMPLE: - strcat(info, "the Ecumenical Temple"); - pr_lev = true; - break; - } - break; + disp += ", "; + disp += ci_altar->first.id.describe(false, true); } } - - if (pr_lev) - { - print_level_name( i, j, printed_branch, printed_level ); - print_one_highlighted_line( " - the entrance to ", info, - ".", YELLOW ); - output = true; - } + last_id = ci_altar->first.id; } } + if ( last_id.depth != 10000 ) + disp += EOL; } - textcolor( LIGHTGREY ); - - if (!output) - cprintf( EOL "You have yet to discover anything worth noting." EOL ); - - getch(); - - redraw_screen(); - -#ifdef DOS_TERM - puttext(1, 1, 80, 25, buffer); -#endif -} // end display_overmap() - - -static void print_level_name( int branch, int depth, - bool &printed_branch, bool &printed_level ) -{ - if (!printed_branch) + // print shops + if (!shops_present.empty()) { - printed_branch = true; - - print_one_simple_line( "", YELLOW ); - print_one_simple_line( - (branch == BRANCH_MAIN_DUNGEON) ? "Main Dungeon" : - (branch == BRANCH_ORCISH_MINES) ? "The Orcish Mines" : - (branch == BRANCH_HIVE) ? "The Hive" : - (branch == BRANCH_LAIR) ? "The Lair" : - (branch == BRANCH_SLIME_PITS) ? "The Slime Pits" : - (branch == BRANCH_VAULTS) ? "The Vaults" : - (branch == BRANCH_CRYPT) ? "The Crypt" : - (branch == BRANCH_HALL_OF_BLADES) ? "The Hall of Blades" : - (branch == BRANCH_HALL_OF_ZOT) ? "The Hall of Zot" : - (branch == BRANCH_ECUMENICAL_TEMPLE) ? "The Ecumenical Temple" : - (branch == BRANCH_SNAKE_PIT) ? "The Snake Pit" : - (branch == BRANCH_ELVEN_HALLS) ? "The Elven Halls" : - (branch == BRANCH_TOMB) ? "The Tomb" : - (branch == BRANCH_SWAMP) ? "The Swamp" : - - (branch == BRANCH_DIS) ? "The Iron City of Dis" : - (branch == BRANCH_GEHENNA) ? "Gehenna" : - (branch == BRANCH_VESTIBULE_OF_HELL) ? "The Vestibule of Hell" : - (branch == BRANCH_COCYTUS) ? "Cocytus" : - (branch == BRANCH_TARTARUS) ? "Tartarus" - : "Unknown Area", - - YELLOW ); + disp += EOL "<white>Shops:</white>" EOL; + seen_anything = true; } - - if (!printed_level) + last_id.depth = 10000; + std::map<level_pos, shop_type>::const_iterator ci_shops; + int placecount = 0; + for ( ci_shops = shops_present.begin(); + ci_shops != shops_present.end(); + ++ci_shops ) { - printed_level = true; - - if (branch == BRANCH_ECUMENICAL_TEMPLE - || branch == BRANCH_HALL_OF_BLADES - || branch == BRANCH_VESTIBULE_OF_HELL) + if ( ci_shops->first.id != last_id ) { - // these areas only have one level... let's save the space - return; + if ( placecount ) + { + // there are at most 5 shops per level, plus 7 chars for + // the level name, plus 4 for the spacing; that makes + // a total of 16 chars per shop or exactly 5 per line. + if ( placecount % 5 == 0 ) + disp += EOL; + else + disp += " "; + } + ++placecount; + disp += "<brown>"; + disp += ci_shops->first.id.describe(false, true); + disp += "</brown>"; + disp += ": "; + last_id = ci_shops->first.id; } + disp += shoptype_to_char(ci_shops->second); + } + disp += EOL; - // we need our own buffer in here (info is used): - char buff[INFO_SIZE]; + // print portals + if ( !portals_present.empty() ) + { + disp += EOL "<white>Portals:</white>" EOL; + seen_anything = true; + } + for (int cur_portal = PORTAL_NONE; cur_portal < NUM_PORTALS; ++cur_portal) + { + last_id.depth = 10000; + std::map<level_pos, portal_type>::const_iterator ci_portals; + for ( ci_portals = portals_present.begin(); + ci_portals != portals_present.end(); + ++ci_portals ) + { + // one line per region should be enough, they're all of + // the form D:XX, except for labyrinth portals, of which + // you would need 11 (at least) to have a problem. + if ( ci_portals->second == cur_portal ) + { + if ( last_id.depth == 10000 ) + disp += portaltype_to_string(ci_portals->second); - if (branch == BRANCH_MAIN_DUNGEON) - depth += 1; - else if (branch >= BRANCH_ORCISH_MINES && branch <= BRANCH_SWAMP) - depth -= you.branch_stairs[ branch - BRANCH_ORCISH_MINES ]; - else // branch is in hell (all of which start at depth 28) - depth -= 26; - - snprintf( buff, INFO_SIZE, " Level %d:", depth ); - print_one_simple_line( buff, LIGHTRED ); + if ( ci_portals->first.id == last_id ) + disp += '*'; + else + { + disp += ' '; + disp += ci_portals->first.id.describe(false, true); + } + last_id = ci_portals->first.id; + } + } + if ( last_id.depth != 10000 ) + disp += EOL; } + + if (!seen_anything) + disp += "You haven't discovered anything interesting yet."; + + linebreak_string(disp, get_number_of_cols() - 5, get_number_of_cols() - 1); + formatted_scroller(MF_EASY_EXIT | MF_ANYPRINTABLE | MF_NOSELECT, + disp).show(); + redraw_screen(); } -void seen_staircase( unsigned char which_staircase ) +void seen_staircase( unsigned char which_staircase, const coord_def& pos ) { // which_staircase holds the grid value of the stair, must be converted // Only handles stairs, not gates or arches @@ -400,7 +293,7 @@ // - stairs returning to dungeon - predictable // - entrances to the hells - always in vestibule - unsigned char which_branch = BRANCH_MAIN_DUNGEON; + branch_type which_branch = BRANCH_MAIN_DUNGEON; switch ( which_staircase ) { @@ -461,110 +354,63 @@ ASSERT(which_branch != BRANCH_MAIN_DUNGEON); - stair_level[which_branch] = you.your_level; -} // end seen_staircase() + stair_level[which_branch] = level_id::get_current_level_id(); +} - // if player has seen an altar; record it -void seen_altar( unsigned char which_altar ) +void seen_altar( god_type god, const coord_def& pos ) { // can't record in abyss or pan. if ( you.level_type != LEVEL_DUNGEON ) return; + + // no point in recording Temple altars + if ( you.where_are_you == BRANCH_ECUMENICAL_TEMPLE ) + return; // portable; no point in recording - if ( which_altar == GOD_NEMELEX_XOBEH ) + if ( god == GOD_NEMELEX_XOBEH ) return; - // already seen - if ( altars_present[you.your_level][you.where_are_you] == which_altar ) - return; + level_pos where(level_id::get_current_level_id(), pos); + altars_present[where] = god; +} - if ( altars_present[you.your_level][you.where_are_you] == 0 ) - altars_present[you.your_level][you.where_are_you] = which_altar; - else - altars_present[you.your_level][you.where_are_you] = 100; -} // end seen_altar() - - -// if player has seen any other thing; record it -void seen_other_thing( unsigned char which_thing ) +portal_type feature_to_portal( unsigned char feat ) { - if ( you.level_type != LEVEL_DUNGEON ) // can't record in abyss or pan. - return; - - switch ( which_thing ) + switch ( feat ) { - case DNGN_ENTER_SHOP: - feature[you.your_level][you.where_are_you] |= FEATURE_SHOP; - break; case DNGN_ENTER_LABYRINTH: - feature[you.your_level][you.where_are_you] |= FEATURE_LABYRINTH; - break; + return PORTAL_LABYRINTH; case DNGN_ENTER_HELL: - feature[you.your_level][you.where_are_you] |= FEATURE_HELL; - break; + return PORTAL_HELL; case DNGN_ENTER_ABYSS: - feature[you.your_level][you.where_are_you] |= FEATURE_ABYSS; - break; + return PORTAL_ABYSS; case DNGN_ENTER_PANDEMONIUM: - feature[you.your_level][you.where_are_you] |= FEATURE_PANDEMONIUM; - break; + return PORTAL_PANDEMONIUM; + default: + return PORTAL_NONE; } -} // end seen_other_thing() - - -/* mv: this function prints one line at "Over-map screen" in specified colour. - * If map_lines = maximum number of lines (it means the screen is full) it - * prints "More..." message, read key, clear screen and after that prints new - * line - */ -void print_one_simple_line( const char *line, int colour) -{ - if (map_lines == (get_number_of_lines() - 2)) - { - textcolor( LIGHTGREY ); - cprintf(EOL); - cprintf("More..."); - getch(); - clrscr(); - map_lines = 0; - } - - textcolor( colour ); - cprintf( "%s" EOL, line ); - map_lines++; } -void print_one_highlighted_line( const char *pre, const char *text, - const char *post, int colour ) +// if player has seen any other thing; record it +void seen_other_thing( unsigned char which_thing, const coord_def& pos ) { - if (map_lines == (get_number_of_lines() - 2)) - { - textcolor( LIGHTGREY ); - cprintf(EOL); - cprintf("More..."); - getch(); - clrscr(); - map_lines = 0; - } + if ( you.level_type != LEVEL_DUNGEON ) // can't record in abyss or pan. + return; - if (pre[0] != 0) - { - textcolor( LIGHTGREY ); - cprintf( "%s", pre ); - } + level_pos where(level_id::get_current_level_id(), pos); - textcolor( colour ); - cprintf( "%s", text ); - - if (post[0] != 0) + switch ( which_thing ) { - textcolor( LIGHTGREY ); - cprintf( "%s", post ); + case DNGN_ENTER_SHOP: + shops_present[where] = + static_cast<shop_type>(get_shop(pos.x, pos.y)->type); + break; + default: + const portal_type portal = feature_to_portal(which_thing); + if ( portal != PORTAL_NONE ) + portals_present[where] = portal; + break; } - - cprintf( EOL ); - - map_lines++; -} +} // end seen_other_thing() Modified: trunk/crawl-ref/source/overmap.h =================================================================== --- trunk/crawl-ref/source/overmap.h 2006-11-26 14:32:43 UTC (rev 494) +++ trunk/crawl-ref/source/overmap.h 2006-11-26 14:54:48 UTC (rev 495) @@ -12,42 +12,7 @@ #ifndef OVERMAP_H #define OVERMAP_H +void seen_notable_thing( int which_thing, int x, int y ); +void display_overmap(); -void seen_notable_thing( int which_thing ); - -// last updated 12may2000 {dlb} -/* *********************************************************************** - * called from: view - * *********************************************************************** */ -void seen_altar(unsigned char which_altar); - - -// last updated 12may2000 {dlb} -/* *********************************************************************** - * called from: acr - * *********************************************************************** */ -void init_overmap(void); - - -// last updated 12may2000 {dlb} -/* *********************************************************************** - * called from: acr - * *********************************************************************** */ -void display_overmap(void); - - -// last updated 12may2000 {dlb} -/* *********************************************************************** - * called from: view - * *********************************************************************** */ -void seen_staircase(unsigned char which_staircase); - - -// last updated 12may2000 {dlb} -/* *********************************************************************** - * called from: view - * *********************************************************************** */ -void seen_other_thing(unsigned char which_thing); - - #endif Modified: trunk/crawl-ref/source/tags.cc =================================================================== --- trunk/crawl-ref/source/tags.cc 2006-11-26 14:32:43 UTC (rev 494) +++ trunk/crawl-ref/source/tags.cc 2006-11-26 14:54:48 UTC (rev 495) @@ -80,19 +80,20 @@ #include "skills2.h" #include "stuff.h" #include "tags.h" +#include "travel.h" // THE BIG IMPORTANT TAG CONSTRUCTION/PARSE BUFFER static char *tagBuffer = NULL; -// These three are defined in overmap.cc -extern FixedArray < unsigned char, MAX_LEVELS, MAX_BRANCHES > altars_present; -extern FixedVector < char, MAX_BRANCHES > stair_level; -extern FixedArray < unsigned char, MAX_LEVELS, MAX_BRANCHES > feature; +// defined in overmap.cc +extern std::map<branch_type, level_id> stair_level; +extern std::map<level_pos, shop_type> shops_present; +extern std::map<level_pos, god_type> altars_present; +extern std::map<level_pos, portal_type> portals_present; // temp file pairs used for file level cleanup FixedArray < bool, MAX_LEVELS, MAX_BRANCHES > tmp_file_pairs; - // static helpers static void tag_construct_you(struct tagHeader &th); static void tag_construct_you_items(struct tagHeader &th); @@ -194,9 +195,82 @@ return data; } +template<typename T> +void marshall_as_long(struct tagHeader& th, const T& t) +{ + marshallLong( th, static_cast<long>(t) ); +} + +template<typename key, typename value> +void marshallMap(struct tagHeader &th, const std::map<key,value>& data, + void (*key_marshall)(struct tagHeader&, const key&), + void (*value_marshall)(struct tagHeader&, const value&)) +{ + marshallLong( th, data.size() ); + typename std::map<key,value>::const_iterator ci; + for ( ci = data.begin(); ci != data.end(); ++ci ) + { + key_marshall(th, ci->first); + value_marshall(th, ci->second); + } +} + +void marshall_level_id( struct tagHeader& th, const level_id& id ) +{ + marshallByte(th, id.branch ); + marshallLong(th, id.depth ); +} + +void marshall_level_pos( struct tagHeader& th, const level_pos& lpos ) +{ + marshallLong(th, lpos.pos.x); + marshallLong(th, lpos.pos.y); + marshall_level_id(th, lpos.id); +} + +template<typename key, typename value> +void unmarshallMap(struct tagHeader& th, std::map<key,value>& data, + key (*key_unmarshall) (struct tagHeader&), + value (*value_unmarshall)(struct tagHeader&) ) +{ + long i, len = unmarshallLong(th); + key k; + value v; + for ( i = 0; i < len; ++i ) + { + k = key_unmarshall(th); + v = value_unmarshall(th); + data[k] = v; + } +} + +template<typename T> +T unmarshall_long_as( struct tagHeader& th ) +{ + return static_cast<T>(unmarshallLong(th)); +} + +level_id unmarshall_level_id( struct tagHeader& th ) +{ + level_id id; + id.branch = unmarshallByte(th); + id.depth = unmarshallLong(th); + return id; +} + +level_pos unmarshall_level_pos( struct tagHeader& th ) +{ + level_pos lpos; + lpos.pos.x = unmarshallLong(th); + lpos.pos.y = unmarshallLong(th); + lpos.id = unmarshall_level_id(th); + return lpos; +} + union float_marshall_kludge { // [ds] Does ANSI C guarantee that sizeof(float) == sizeof(long)? + // [haranp] no, unfortunately float f_num; long l_num; }; @@ -740,7 +814,6 @@ marshallShort(th,you.inv[i].plus2); marshallShort(th, you.inv[i].orig_place); marshallShort(th, you.inv[i].orig_monnum); - /*** HP CHANGE ***/ marshallString(th, you.inv[i].inscription.c_str(), 80); } @@ -800,22 +873,21 @@ // how many branches? marshallByte(th, MAX_BRANCHES); for (j = 0; j < 30; ++j) - { marshallByte(th,you.branch_stairs[j]); - marshallByte(th,stair_level[j]); - } - // how many levels? marshallShort(th, MAX_LEVELS); for (i = 0; i < MAX_LEVELS; ++i) - { for (j = 0; j < MAX_BRANCHES; ++j) - { - marshallByte(th,altars_present[i][j]); - marshallByte(th,feature[i][j]); - marshallBoolean(th,tmp_file_pairs[i][j]); - } - } + marshallBoolean(th, tmp_file_pairs[i][j]); + + marshallMap(th, stair_level, + marshall_as_long<branch_type>, marshall_level_id); + marshallMap(th, shops_present, + marshall_level_pos, marshall_as_long<shop_type>); + marshallMap(th, altars_present, + marshall_level_pos, marshall_as_long<god_type>); + marshallMap(th, portals_present, + marshall_level_pos, marshall_as_long<portal_type>); } static void tag_read_you(struct tagHeader &th, char minorVersion) @@ -910,34 +982,14 @@ you.spell_no++; } - if (minorVersion >= 2) - { - count_c = unmarshallByte(th); - for (i = 0; i < count_c; i++) - you.spell_letter_table[i] = unmarshallByte(th); + count_c = unmarshallByte(th); + for (i = 0; i < count_c; i++) + you.spell_letter_table[i] = unmarshallByte(th); + + count_c = unmarshallByte(th); + for (i = 0; i < count_c; i++) + you.ability_letter_table[i] = unmarshallShort(th); - count_c = unmarshallByte(th); - for (i = 0; i < count_c; i++) - you.ability_letter_table[i] = unmarshallShort(th); - } - else - { - for (i = 0; i < 52; i++) - { - you.spell_letter_table[i] = -1; - you.ability_letter_table[i] = ABIL_NON_ABILITY; - } - - for (i = 0; i < 25; i++) - { - if (you.spells[i] != SPELL_NO_SPELL) - you.spell_letter_table[i] = i; - } - - if (you.religion != GOD_NO_GOD) - set_god_ability_slots(); - } - // how many skills? count_c = unmarshallByte(th); for (j = 0; j < count_c; ++j) @@ -946,14 +998,9 @@ you.practise_skill[j] = unmarshallByte(th); you.skill_points[j] = unmarshallLong(th); - if (minorVersion >= 2) - you.skill_order[j] = unmarshallByte(th); + you.skill_order[j] = unmarshallByte(th); } - // initialize ordering when we don't read it in: - if (minorVersion < 2) - init_skill_order(); - // set up you.total_skill_points and you.skill_cost_level calc_total_skill_points(); @@ -980,26 +1027,13 @@ for (i = 0; i < count_c; i++) you.penance[i] = unmarshallByte(th); - if (minorVersion >= 2) - { - count_c = unmarshallByte(th); - for (i = 0; i < count_c; i++) - you.worshipped[i] = unmarshallByte(th); + count_c = unmarshallByte(th); + for (i = 0; i < count_c; i++) + you.worshipped[i] = unmarshallByte(th); + + for (i = 0; i < count_c; i++) + you.num_gifts[i] = unmarshallShort(th); - if (minorVersion >= 5) - for (i = 0; i < count_c; i++) - you.num_gifts[i] = unmarshallShort(th); - - } - else - { - for (i = 0; i < count_c; i++) - you.worshipped[i] = false; - - if (you.religion != GOD_NO_GOD) - you.worshipped[you.religion] = true; - } - you.gift_timeout = unmarshallByte(th); you.normal_vision = unmarshallByte(th); you.current_vision = unmarshallByte(th); @@ -1008,262 +1042,19 @@ // elapsed time you.elapsed_time = (double)unmarshallFloat(th); - if (minorVersion >= 1) - { - // wizard mode - you.wizard = (bool) unmarshallByte(th); + // wizard mode + you.wizard = (bool) unmarshallByte(th); - // time of character creation - unmarshallString( th, buff, 20 ); - you.birth_time = parse_date_string( buff ); - } + // time of character creation + unmarshallString( th, buff, 20 ); + you.birth_time = parse_date_string( buff ); - if (minorVersion >= 2) - { - you.real_time = unmarshallLong(th); - you.num_turns = unmarshallLong(th); - } - else - { - you.real_time = -1; - you.num_turns = -1; - } + you.real_time = unmarshallLong(th); + you.num_turns = unmarshallLong(th); - // you.magic_contamination 05/03/05 - if (minorVersion >= 3) - { - you.magic_contamination = unmarshallShort(th); - } + you.magic_contamination = unmarshallShort(th); } -static void tag_convert_to_4_3_item( item_def &item ) -{ - const unsigned char plus = item.plus; - const unsigned char plus2 = item.plus2; - const unsigned char ident = item.flags; - const unsigned char special = item.special; - - if (item.quantity <= 0) - return; - - // First, convert ident into flags: - item.flags = (ident == 3) ? ISFLAG_IDENT_MASK : - (ident > 0) ? ISFLAG_KNOW_CURSE - : 0; - - switch (item.base_type) - { - case OBJ_ARMOUR: - if ((ident == 1 && special % 30 >= 25) || ident == 2) - item.flags |= ISFLAG_KNOW_TYPE; - - // Convert special values - item.special %= 30; - if (item.special < 25) - { - if (item.sub_type == ARM_HELMET) - { - item.plus2 = plus2 % 30; - set_helmet_desc( item, (special / 30) << 8 ); - } - else - { - switch (special / 30) - { - case DARM_EMBROIDERED_SHINY: - set_equip_desc( item, ISFLAG_EMBROIDERED_SHINY ); - break; - case DARM_RUNED: - set_equip_desc( item, ISFLAG_RUNED ); - break; - case DARM_GLOWING: - set_equip_desc( item, ISFLAG_GLOWING ); - break; - case DARM_ELVEN: - set_equip_race( item, ISFLAG_ELVEN ); - break; - case DARM_DWARVEN: - set_equip_race( item, ISFLAG_DWARVEN ); - break; - case DARM_ORCISH: - set_equip_race( item, ISFLAG_ORCISH ); - break; - default: - break; - } - } - } - else if (item.special == 25) - { - item.flags |= ISFLAG_UNRANDART; - item.special = 0; - } - else - { - item.flags |= ISFLAG_RANDART; - - // calc old seed - item.special = item.base_type * special - + item.sub_type * (plus % 100) - + plus2 * 100; - } - break; - - case OBJ_WEAPONS: - if ((ident == 1 && (special < 180 && special % 30 >= 25)) || ident == 2) - item.flags |= ISFLAG_KNOW_TYPE; - - // Convert special values - if (special < 181) // don't mangle fixed artefacts - { - item.special %= 30; - if (item.special < 25) - { - switch (special / 30) - { - case DWPN_RUNED: - set_equip_desc( item, ISFLAG_RUNED ); - break; - case DWPN_GLOWING: - set_equip_desc( item, ISFLAG_GLOWING ); - break; - case DWPN_ORCISH: - set_equip_race( item, ISFLAG_ORCISH ); - break; - case DWPN_ELVEN: - set_equip_race( item, ISFLAG_ELVEN ); - break; - case DWPN_DWARVEN: - set_equip_race( item, ISFLAG_DWARVEN ); - break; - default: - break; - } - } - else if (item.special == 25) - { - item.flags |= ISFLAG_UNRANDART; - item.special = 0; - } - else - { - item.flags |= ISFLAG_RANDART; - - // calc old seed - item.special = item.base_type * special - + item.sub_type * (plus % 100) - + plus2 * 100; - } - } - break; - - case OBJ_MISSILES: - // Needles were moved into the bonus eggplant spot. -- bwr - if (item.sub_type == 6) - item.sub_type = MI_NEEDLE; - - if (ident == 2) - item.flags |= ISFLAG_KNOW_TYPE; - - // Convert special values - item.special %= 30; - switch (special / 30) - { - case DAMMO_ORCISH: - set_equip_race( item, ISFLAG_ORCISH ); - break; - case DAMMO_ELVEN: - set_equip_race( item, ISFLAG_ELVEN ); - break; - case DAMMO_DWARVEN: - set_equip_race( item, ISFLAG_DWARVEN ); - break; - default: - break; - } - break; - - case OBJ_WANDS: - if (ident == 2) - item.flags |= ISFLAG_KNOW_PLUSES; - break; - - case OBJ_JEWELLERY: - if (ident == 1 && (special == 200 || special == 201)) - item.flags |= ISFLAG_KNOW_TYPE; - else if (ident == 2) - item.flags |= (ISFLAG_KNOW_TYPE | ISFLAG_KNOW_PLUSES); - - if (special == 201) - { - item.flags |= ISFLAG_UNRANDART; - item.special = 0; - } - else if (special == 200) - { - item.flags |= ISFLAG_RANDART; - - // calc old seed - item.special = item.base_type * special - + item.sub_type * (plus % 100) - + plus2 * 100; - } - break; - - default: - if (ident > 0) - item.flags |= ISFLAG_KNOW_TYPE; - break; - } - - - // Second, convert plus and plus2 - if (item.base_type == OBJ_WEAPONS - || item.base_type == OBJ_MISSILES - || item.base_type == OBJ_ARMOUR - || item.base_type == OBJ_JEWELLERY) - { - item.plus = plus; - - // item is cursed: - if (plus > 100) - { - item.plus -= 100; - item.flags |= ISFLAG_CURSED; - } - - // Weapons use both as pluses. - // Non-artefact jewellery uses both as pluses. - // Artefact jewellery has literal values for both pluses. - // Armour and Missiles only use plus for their plus value. - // Armour has literal usage of plus2 for sub-subtypes. - if (item.base_type != OBJ_JEWELLERY) - { - item.plus -= 50; - - if (item.base_type == OBJ_WEAPONS) - item.plus2 -= 50; - } - else if (special != 200) - { - // regular jewellery & unrandarts -- unused pluses were 0s - if (item.plus) - item.plus -= 50; - - if (item.plus2) - item.plus2 -= 50; - } - else if (special == 200) - { - // Randart jewellery used pluses only as seeds, right now - // they're always zero (since random artefact rings avoid - // base types with pluses). - item.plus = 0; - item.plus2 = 0; - } - } -} - static void tag_read_you_items(struct tagHeader &th, char minorVersion) { int i,j; @@ -1276,45 +1067,22 @@ { you.inv[i].orig_monnum = you.inv[i].orig_place = 0; you.inv[i].inscription.clear(); - if (minorVersion < 1) - { - you.inv[i].base_type = (unsigned char) unmarshallByte(th); - you.inv[i].sub_type = (unsigned char) unmarshallByte(th); - you.inv[i].plus = (unsigned char) unmarshallByte(th); - you.inv[i].special = (unsigned char) unmarshallByte(th); - you.inv[i].colour = (unsigned char) unmarshallByte(th); - you.inv[i].flags = (unsigned char) unmarshallByte(th); - you.inv[i].quantity = unmarshallShort(th); - you.inv[i].plus2 = (unsigned char) unmarshallByte(th); + you.inv[i].base_type = (unsigned char) unmarshallByte(th); + you.inv[i].sub_type = (unsigned char) unmarshallByte(th); + you.inv[i].plus = unmarshallShort(th); + you.inv[i].special = unmarshallLong(th); + you.inv[i].colour = (unsigned char) unmarshallByte(th); + you.inv[i].flags = (unsigned long) unmarshallLong(th); + you.inv[i].quantity = unmarshallShort(th); + you.inv[i].plus2 = unmarshallShort(th); + + you.inv[i].orig_place = unmarshallShort(th); + you.inv[i].orig_monnum = unmarshallShort(th); - tag_convert_to_4_3_item( you.inv[i] ); - } - else - { - you.inv[i].base_type = (unsigned char) unmarshallByte(th); - you.inv[i].sub_type = (unsigned char) unmarshallByte(th); - you.inv[i].plus = unmarshallShort(th); - you.inv[i].special = unmarshallLong(th); - you.inv[i].colour = (unsigned char) unmarshallByte(th); - you.inv[i].flags = (unsigned long) unmarshallLong(th); - you.inv[i].quantity = unmarshallShort(th); - you.inv[i].plus2 = unmarshallShort(th); + char insstring[80]; + unmarshallString(th, insstring, 80); + you.inv[i].inscription = std::string(insstring); - if (minorVersion >= 4) - { - you.inv[i].orig_place = unmarshallShort(th); - you.inv[i].orig_monnum = unmarshallShort(th); - - if (minorVersion >= 6) - { - /*** HP CHANGE ***/ - char insstring[80]; - unmarshallString(th, insstring, 80); - you.inv[i].inscription = std::string(insstring); - } - } - } - // these never need to be saved for items in the inventory -- bwr you.inv[i].x = -1; you.inv[i].y = -1; @@ -1328,10 +1096,8 @@ // how many subtypes? count_c2 = unmarshallByte(th); for (i = 0; i < count_c; ++i) - { for (j = 0; j < count_c2; ++j) you.item_description[i][j] = unmarshallByte(th); - } // identification status // how many types? @@ -1398,22 +1164,21 @@ // how many branches? count_c = unmarshallByte(th); for (j = 0; j < count_c; ++j) - { you.branch_stairs[j] = unmarshallByte(th); - stair_level[j] = unmarshallByte(th); - } - // how many levels? count_s = unmarshallShort(th); for (i = 0; i < count_s; ++i) - { for (j = 0; j < count_c; ++j) - { - altars_present[i][j] = unmarshallByte(th); - feature[i][j] = unmarshallByte(th); tmp_file_pairs[i][j] = unmarshallBoolean(th); - } - } + + unmarshallMap(th, stair_level, + unmarshall_long_as<branch_type>, unmarshall_level_id); + unmarsh... [truncated message content] |
From: <ha...@us...> - 2006-11-27 07:30:19
|
Revision: 496 http://svn.sourceforge.net/crawl-ref/?rev=496&view=rev Author: haranp Date: 2006-11-26 23:30:18 -0800 (Sun, 26 Nov 2006) Log Message: ----------- Fixed hiding of draw_item() in derived classes of Menu. Modified Paths: -------------- trunk/crawl-ref/source/files.cc trunk/crawl-ref/source/menu.cc trunk/crawl-ref/source/menu.h Modified: trunk/crawl-ref/source/files.cc =================================================================== --- trunk/crawl-ref/source/files.cc 2006-11-26 14:54:48 UTC (rev 495) +++ trunk/crawl-ref/source/files.cc 2006-11-27 07:30:18 UTC (rev 496) @@ -85,9 +85,6 @@ void save_level(int level_saved, bool was_a_labyrinth, char where_were_you); -// temp file pairs used for file level cleanup -extern FixedArray < bool, MAX_LEVELS, MAX_BRANCHES > tmp_file_pairs; - /* Order for looking for conjurations for the 1st & 2nd spell slots, when finding spells to be remembered by a player's ghost: Modified: trunk/crawl-ref/source/menu.cc =================================================================== --- trunk/crawl-ref/source/menu.cc 2006-11-26 14:54:48 UTC (rev 495) +++ trunk/crawl-ref/source/menu.cc 2006-11-27 07:30:18 UTC (rev 496) @@ -506,10 +506,10 @@ return; gotoxy( 1, y_offset + index - first_entry ); - draw_item(index, items[index]); + draw_index_item(index, items[index]); } -void Menu::draw_item(int index, const MenuEntry *me) const +void Menu::draw_index_item(int index, const MenuEntry *me) const { if (f_drawitem) (*f_drawitem)(index, me); @@ -1221,7 +1221,7 @@ } } -void formatted_scroller::draw_item(int index, const MenuEntry *me) const +void formatted_scroller::draw_index_item(int index, const MenuEntry *me) const { formatted_string::parse_string(me->text).display(); } Modified: trunk/crawl-ref/source/menu.h =================================================================== --- trunk/crawl-ref/source/menu.h 2006-11-26 14:54:48 UTC (rev 495) +++ trunk/crawl-ref/source/menu.h 2006-11-27 07:30:18 UTC (rev 496) @@ -292,7 +292,7 @@ void do_menu(); virtual void draw_select_count(int count, bool force = false); virtual void draw_item( int index ) const; - virtual void draw_item(int index, const MenuEntry *me) const; + virtual void draw_index_item(int index, const MenuEntry *me) const; virtual void draw_stock_item(int index, const MenuEntry *me) const; virtual void draw_title(); @@ -409,7 +409,7 @@ public: formatted_scroller(int flags, const std::string& s); protected: - virtual void draw_item(int index, const MenuEntry* me) const; + virtual void draw_index_item(int index, const MenuEntry* me) const; }; int menu_colour(const std::string &itemtext); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dsh...@us...> - 2006-11-27 13:23:23
|
Revision: 498 http://svn.sourceforge.net/crawl-ref/?rev=498&view=rev Author: dshaligram Date: 2006-11-27 05:23:20 -0800 (Mon, 27 Nov 2006) Log Message: ----------- Fixed hiscores buffer segfault madness. Modified Paths: -------------- trunk/crawl-ref/source/hiscores.cc trunk/crawl-ref/source/hiscores.h trunk/crawl-ref/source/ouch.cc Modified: trunk/crawl-ref/source/hiscores.cc =================================================================== --- trunk/crawl-ref/source/hiscores.cc 2006-11-27 11:28:55 UTC (rev 497) +++ trunk/crawl-ref/source/hiscores.cc 2006-11-27 13:23:20 UTC (rev 498) @@ -214,25 +214,26 @@ else cprintf("%s", info); + std::string entry; // format the entry if (format == SCORE_TERSE) { - hiscores_format_single( info, hs_list[i] ); + entry = hiscores_format_single( hs_list[i] ); // truncate if we want short format - info[75] = 0; + if (entry.length() > 75) + entry = entry.substr(0, 75); } else { - hiscores_format_single_long( info, hs_list[i], + entry = hiscores_format_single_long( hs_list[i], (format == SCORE_VERBOSE) ); } - // print entry - strcat(info, EOL); + entry += EOL; if(use_printf) - printf("%s", info); + printf("%s", entry.c_str()); else - cprintf("%s", info); + cprintf("%s", entry.c_str()); if (i == newest_entry && !use_printf) textcolor(LIGHTGREY); @@ -254,11 +255,9 @@ return ("blasted"); // spells, wands } -void hiscores_format_single(char *buf, const scorefile_entry &se) +std::string hiscores_format_single(const scorefile_entry &se) { - std::string line = se.hiscore_line(scorefile_entry::DDV_ONELINE); - strncpy(buf, line.c_str(), INFO_SIZE); - buf[INFO_SIZE - 1] = 0; + return se.hiscore_line(scorefile_entry::DDV_ONELINE); } static bool hiscore_same_day( time_t t1, time_t t2 ) @@ -289,16 +288,14 @@ return (EOL " "); } -void hiscores_format_single_long( char *buf, const scorefile_entry &se, - bool verbose ) +std::string hiscores_format_single_long( const scorefile_entry &se, + bool verbose ) { - std::string line = - se.hiscore_line( + return se.hiscore_line( verbose? scorefile_entry::DDV_VERBOSE : scorefile_entry::DDV_NORMAL ); - strncpy(buf, line.c_str(), HIGHSCORE_SIZE); - buf[HIGHSCORE_SIZE - 1] = 0; + } // -------------------------------------------------------------------------- @@ -1510,7 +1507,7 @@ bool verbose = verbosity == DDV_VERBOSE; char scratch[INFO_SIZE]; - char buf[INFO_SIZE]; + char buf[HIGHSCORE_SIZE]; std::string desc; // Please excuse the following bit of mess in the name of flavour ;) Modified: trunk/crawl-ref/source/hiscores.h =================================================================== --- trunk/crawl-ref/source/hiscores.h 2006-11-27 11:28:55 UTC (rev 497) +++ trunk/crawl-ref/source/hiscores.h 2006-11-27 13:23:20 UTC (rev 498) @@ -28,8 +28,8 @@ /* *********************************************************************** * called from: ouch hiscores * *********************************************************************** */ -void hiscores_format_single( char *buffer, const scorefile_entry &se ); -void hiscores_format_single_long( char *buffer, const scorefile_entry &se, +std::string hiscores_format_single( const scorefile_entry &se ); +std::string hiscores_format_single_long( const scorefile_entry &se, bool verbose = false ); #endif // HISCORES_H Modified: trunk/crawl-ref/source/ouch.cc =================================================================== --- trunk/crawl-ref/source/ouch.cc 2006-11-27 11:28:55 UTC (rev 497) +++ trunk/crawl-ref/source/ouch.cc 2006-11-27 13:23:20 UTC (rev 498) @@ -891,15 +891,12 @@ cprintf( "Goodbye, %s.", you.your_name ); cprintf( EOL EOL " " ); // Space padding where # would go in list format - char scorebuff[ HIGHSCORE_SIZE ]; - hiscores_format_single_long( scorebuff, se, true ); - // truncate - scorebuff[ HIGHSCORE_SIZE - 1 ] = 0; + std::string hiscore = hiscores_format_single_long( se, true ); - const int lines = count_occurrences(scorebuff, EOL) + 1; + const int lines = count_occurrences(hiscore, EOL) + 1; - cprintf( scorebuff ); + cprintf( "%s", hiscore.c_str() ); cprintf( EOL "Best Crawlers -" EOL ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dsh...@us...> - 2006-11-27 14:27:14
|
Revision: 504 http://svn.sourceforge.net/crawl-ref/?rev=504&view=rev Author: dshaligram Date: 2006-11-27 06:27:12 -0800 (Mon, 27 Nov 2006) Log Message: ----------- Fixed char_set option being ignored. Modified Paths: -------------- trunk/crawl-ref/source/acr.cc trunk/crawl-ref/source/initfile.cc Modified: trunk/crawl-ref/source/acr.cc =================================================================== --- trunk/crawl-ref/source/acr.cc 2006-11-27 14:14:10 UTC (rev 503) +++ trunk/crawl-ref/source/acr.cc 2006-11-27 14:27:12 UTC (rev 504) @@ -2673,6 +2673,7 @@ seed_rng(); clear_ids(); // in itemname.cc + init_char_table(Options.char_set); init_feature_table(); init_properties(); @@ -2789,6 +2790,7 @@ you.your_name[kNameLen - 1] = 0; // In case Lua changed the character set. + init_char_table(Options.char_set); init_feature_table(); #endif viewwindow(1, false); // This just puts the view up for the first turn. Modified: trunk/crawl-ref/source/initfile.cc =================================================================== --- trunk/crawl-ref/source/initfile.cc 2006-11-27 14:14:10 UTC (rev 503) +++ trunk/crawl-ref/source/initfile.cc 2006-11-27 14:27:12 UTC (rev 504) @@ -523,7 +523,6 @@ #else char_set = CSET_IBM; #endif - init_char_table(char_set); // set it to the .crawlrc default autopickups = ((1L << 15) | // gold @@ -1169,8 +1168,6 @@ valid = false; } } - if (valid) - init_char_table(char_set); } else if (key == "default_autopickup") { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dsh...@us...> - 2006-11-27 15:45:49
|
Revision: 507 http://svn.sourceforge.net/crawl-ref/?rev=507&view=rev Author: dshaligram Date: 2006-11-27 07:45:45 -0800 (Mon, 27 Nov 2006) Log Message: ----------- [1603062] Fixed save_dir not working when LOAD_PACKAGE_CMD is defined (sartak). Modified Paths: -------------- trunk/crawl-ref/source/AppHdr.h trunk/crawl-ref/source/files.cc trunk/crawl-ref/source/files.h trunk/crawl-ref/source/newgame.cc Modified: trunk/crawl-ref/source/AppHdr.h =================================================================== --- trunk/crawl-ref/source/AppHdr.h 2006-11-27 14:47:56 UTC (rev 506) +++ trunk/crawl-ref/source/AppHdr.h 2006-11-27 15:45:45 UTC (rev 507) @@ -318,17 +318,14 @@ // to a command to compress and bundle the save game files into a // single unit... the two %s will be replaced with the players // save file name. Define LOAD_UNPACKAGE_CMD to undo this process - // the %s is the same as above. + // the %s is the same as above. The second %s in LOAD_UNPACKAGE_CMD + // is for the output directory. // // PACKAGE_SUFFIX is used when the package file name is needed // // Comment these lines out if you want to leave the save files uncompressed. #define SAVE_PACKAGE_CMD "/usr/bin/zip -m -q -j -1 %s.zip %s.*" -#ifdef SAVE_DIR_PATH - #define LOAD_UNPACKAGE_CMD "/usr/bin/unzip -q -o %s.zip -d" SAVE_DIR_PATH -#else - #define LOAD_UNPACKAGE_CMD "/usr/bin/unzip -q -o %s.zip" -#endif + #define LOAD_UNPACKAGE_CMD "/usr/bin/unzip -q -o %s.zip -d %s" #ifdef SAVE_PACKAGE_CMD // This is used to unpack specific files from the archive. Modified: trunk/crawl-ref/source/files.cc =================================================================== --- trunk/crawl-ref/source/files.cc 2006-11-27 14:47:56 UTC (rev 506) +++ trunk/crawl-ref/source/files.cc 2006-11-27 15:45:45 UTC (rev 507) @@ -465,14 +465,17 @@ 0, filename.length() - strlen(PACKAGE_SUFFIX)); - std::string zipname = get_savedir_path(basename); + const std::string zipname = get_savedir_path(basename); // This is the filename we actually read ourselves. filename = basename + ".sav"; + const std::string dir = get_savedir(); + char cmd_buff[1024]; snprintf( cmd_buff, sizeof(cmd_buff), UNPACK_SPECIFIC_FILE_CMD, zipname.c_str(), + dir.c_str(), filename.c_str() ); if (system(cmd_buff) != 0) @@ -495,6 +498,12 @@ return (chars); } +std::string get_savedir() +{ + const std::string &dir = Options.save_dir; + return (dir.empty()? "." : dir); +} + std::string get_savedir_filename(const char *prefix, const char *suffix, const char *extension, bool suppress_uid) { @@ -512,8 +521,8 @@ result += suffix; if ( *extension ) { - result += '.'; - result += extension; + result += '.'; + result += extension; } #ifdef DOS @@ -1161,7 +1170,7 @@ if (stashf) { stashes.save(stashf); fclose(stashf); - DO_CHMOD_PRIVATE(stashFile.c_str()); + DO_CHMOD_PRIVATE(stashFile.c_str()); } #endif @@ -1179,7 +1188,7 @@ if (killf) { you.kills.save(killf); fclose(killf); - DO_CHMOD_PRIVATE(killFile.c_str()); + DO_CHMOD_PRIVATE(killFile.c_str()); } /* travel cache */ @@ -1188,25 +1197,25 @@ if (travelf) { travel_cache.save(travelf); fclose(travelf); - DO_CHMOD_PRIVATE(travelCacheFile.c_str()); + DO_CHMOD_PRIVATE(travelCacheFile.c_str()); } /* notes */ std::string notesFile = get_savedir_filename(you.your_name, "", "nts"); FILE *notesf = fopen(notesFile.c_str(), "wb"); if (notesf) { - save_notes(notesf); + save_notes(notesf); fclose(notesf); - DO_CHMOD_PRIVATE(notesFile.c_str()); + DO_CHMOD_PRIVATE(notesFile.c_str()); } std::string charFile = get_savedir_filename(you.your_name, "", "sav"); FILE *charf = fopen(charFile.c_str(), "wb"); if (!charf) { - snprintf(info, INFO_SIZE, "Unable to open \"%s\" for writing!\n", + snprintf(info, INFO_SIZE, "Unable to open \"%s\" for writing!\n", charFile.c_str()); - perror(info); - end(-1); + perror(info); + end(-1); } write_tagged_file( charf, SAVE_MAJOR_VERSION, 0, TAGTYPE_PLAYER ); @@ -1346,8 +1355,8 @@ FILE *charf = fopen(charFile.c_str(), "rb"); if (!charf ) { - snprintf(info, INFO_SIZE, "Unable to open %s for reading!\n", - charFile.c_str() ); + snprintf(info, INFO_SIZE, "Unable to open %s for reading!\n", + charFile.c_str() ); perror(info); end(-1); } @@ -1367,7 +1376,7 @@ if (!feof(charf)) { snprintf( info, INFO_SIZE, "\nIncomplete read of \"%s\" - aborting.\n", - charFile.c_str()); + charFile.c_str()); perror(info); end(-1); } @@ -1405,8 +1414,8 @@ std::string notesFile = get_savedir_filename(you.your_name, "", "nts"); FILE *notesf = fopen(notesFile.c_str(), "rb"); if (notesf) { - load_notes(notesf); - fclose(notesf); + load_notes(notesf); + fclose(notesf); } } @@ -1820,7 +1829,7 @@ case SPELL_SUMMON_HORRIBLE_THINGS: return (MS_LEVEL_SUMMON); /* approximate */ case SPELL_SHADOW_CREATURES: - return (MS_LEVEL_SUMMON); /* approximate */ + return (MS_LEVEL_SUMMON); /* approximate */ case SPELL_ANIMATE_DEAD: return (MS_ANIMATE_DEAD); case SPELL_PAIN: Modified: trunk/crawl-ref/source/files.h =================================================================== --- trunk/crawl-ref/source/files.h 2006-11-27 14:47:56 UTC (rev 506) +++ trunk/crawl-ref/source/files.h 2006-11-27 15:45:45 UTC (rev 507) @@ -37,6 +37,7 @@ std::vector<player> find_saved_characters(); +std::string get_savedir(); std::string get_savedir_filename(const char *pre, const char *suf, const char *ext, bool suppress_uid = false); Modified: trunk/crawl-ref/source/newgame.cc =================================================================== --- trunk/crawl-ref/source/newgame.cc 2006-11-27 14:47:56 UTC (rev 506) +++ trunk/crawl-ref/source/newgame.cc 2006-11-27 15:45:45 UTC (rev 507) @@ -294,12 +294,15 @@ // Create command char cmd_buff[1024]; + const std::string directory = get_savedir(); + snprintf( cmd_buff, sizeof(cmd_buff), LOAD_UNPACKAGE_CMD, - basename.c_str() ); + basename.c_str(), directory.c_str() ); if (system( cmd_buff ) != 0) { - cprintf( EOL "Warning: Zip command (LOAD_UNPACKAGE_CMD) returned non-zero value!" EOL ); + cprintf( EOL "Warning: Zip command (LOAD_UNPACKAGE_CMD) " + "returned non-zero value!" EOL ); } // Remove save game package This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ha...@us...> - 2006-11-28 06:05:04
|
Revision: 513 http://svn.sourceforge.net/crawl-ref/?rev=513&view=rev Author: haranp Date: 2006-11-27 22:05:01 -0800 (Mon, 27 Nov 2006) Log Message: ----------- Changed '[empty]' autoinscription to 'empty'. Made 'empty' and 'tried' play nice with each other. Modified Paths: -------------- trunk/crawl-ref/source/effects.cc trunk/crawl-ref/source/item_use.cc trunk/crawl-ref/source/itemname.cc Modified: trunk/crawl-ref/source/effects.cc =================================================================== --- trunk/crawl-ref/source/effects.cc 2006-11-27 16:08:54 UTC (rev 512) +++ trunk/crawl-ref/source/effects.cc 2006-11-28 06:05:01 UTC (rev 513) @@ -1419,7 +1419,7 @@ if (wand.base_type == OBJ_WANDS) { // remove "empty" autoinscription - const char* empty_inscription = "[empty]"; + const char* empty_inscription = "empty"; size_t p = wand.inscription.find(empty_inscription); if ( p != std::string::npos ) { // found it, delete it Modified: trunk/crawl-ref/source/item_use.cc =================================================================== --- trunk/crawl-ref/source/item_use.cc 2006-11-27 16:08:54 UTC (rev 512) +++ trunk/crawl-ref/source/item_use.cc 2006-11-28 06:05:01 UTC (rev 513) @@ -2500,7 +2500,7 @@ if ( !you.inv[item_slot].inscription.empty() ) you.inv[item_slot].inscription += ' '; - you.inv[item_slot].inscription += "[empty]"; + you.inv[item_slot].inscription += "empty"; } } Modified: trunk/crawl-ref/source/itemname.cc =================================================================== --- trunk/crawl-ref/source/itemname.cc 2006-11-27 16:08:54 UTC (rev 512) +++ trunk/crawl-ref/source/itemname.cc 2006-11-28 06:05:01 UTC (rev 513) @@ -46,11 +46,27 @@ const item_def &item, char buff[ ITEMNAME_SIZE ], bool terse ); static char retvow(int sed); -static char retlet(int sed ); +static char retlet(int sed); // [dshaligram] For calls to item_name without a pre-allocated buffer. static char default_itembuf[ITEMNAME_SIZE]; +static bool is_tried_type( int basetype, int subtype ) +{ + switch ( basetype ) + { + case OBJ_SCROLLS: + return id[IDTYPE_SCROLLS][subtype] == ID_TRIED_TYPE; + case OBJ_POTIONS: + return id[IDTYPE_POTIONS][subtype] == ID_TRIED_TYPE; + case OBJ_WANDS: + return id[IDTYPE_WANDS][subtype] == ID_TRIED_TYPE; + default: + return false; + } +} + + bool is_vowel( const char chr ) { const char low = tolower( chr ); @@ -273,13 +289,17 @@ strncat( buff, " (around neck)", ITEMNAME_SIZE ); } } - /*** HP CHANGE -- warning -- possible stack overflow error ***/ - if ( item.inscription.size() > 0 ) // has an inscription + + if ( !item.inscription.empty() ) { strncat( buff, " {", 2 ); + if ( is_tried_type(item.base_type, item.sub_type) ) + strncat(buff, "tried, ", 10); strncat( buff, item.inscription.c_str(), ITEMNAME_SIZE ); strncat( buff, "}", 1 ); } + else if ( is_tried_type(item.base_type, item.sub_type) ) + strncat(buff, " {tried}", 10); return (buff); } // end item_name() @@ -303,7 +323,7 @@ int brand; unsigned char sparm; - buff[0] = '\0'; + buff[0] = 0; switch (item_clas) { @@ -814,11 +834,6 @@ (primary == 11) ? "plastic" : "buggy", ITEMNAME_SIZE); strncat(buff, " wand", ITEMNAME_SIZE ); - - if (id[ IDTYPE_WANDS ][item_typ] == ID_TRIED_TYPE) - { - strncat( buff, " {tried}" , ITEMNAME_SIZE ); - } } if (item_ident( item, ISFLAG_KNOW_PLUSES )) @@ -902,11 +917,6 @@ if (it_quant > 1) strncat(buff, "s", ITEMNAME_SIZE ); - - if (id[ IDTYPE_POTIONS ][item_typ] == ID_TRIED_TYPE) - { - strncat( buff, " {tried}" , ITEMNAME_SIZE ); - } } break; @@ -1048,11 +1058,6 @@ + (static_cast<unsigned long>(item_clas) << 16); make_name( sseed, true, buff3 ); strncat( buff, buff3 , ITEMNAME_SIZE ); - - if (id[ IDTYPE_SCROLLS ][item_typ] == ID_TRIED_TYPE) - { - strncat( buff, " {tried}" , ITEMNAME_SIZE ); - } } break; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ha...@us...> - 2006-11-28 06:45:57
|
Revision: 514 http://svn.sourceforge.net/crawl-ref/?rev=514&view=rev Author: haranp Date: 2006-11-27 22:45:56 -0800 (Mon, 27 Nov 2006) Log Message: ----------- 1601622: dissecting a yak/sheep can produce an animal skin. Modified Paths: -------------- trunk/crawl-ref/source/delay.cc trunk/crawl-ref/source/misc.cc trunk/crawl-ref/source/monstuff.cc Modified: trunk/crawl-ref/source/delay.cc =================================================================== --- trunk/crawl-ref/source/delay.cc 2006-11-28 06:05:01 UTC (rev 513) +++ trunk/crawl-ref/source/delay.cc 2006-11-28 06:45:56 UTC (rev 514) @@ -490,14 +490,11 @@ break; case DELAY_BUTCHER: - strcpy( info, "You finish " ); - strcat( info, (you.species == SP_TROLL - || you.species == SP_GHOUL) ? "ripping" - : "chopping" ); + snprintf(info, INFO_SIZE, "You finish %s the corpse into pieces.", + (you.species == SP_TROLL || + you.species == SP_GHOUL) ? "ripping" : "chopping" ); + mpr(info); - strcat( info, " the corpse into pieces." ); - mpr( info ); - turn_corpse_into_chunks( mitm[ delay.parm1 ] ); if (you.berserker && you.berserk_penalty != NO_BERSERK_PENALTY) Modified: trunk/crawl-ref/source/misc.cc =================================================================== --- trunk/crawl-ref/source/misc.cc 2006-11-28 06:05:01 UTC (rev 513) +++ trunk/crawl-ref/source/misc.cc 2006-11-28 06:45:56 UTC (rev 514) @@ -127,6 +127,10 @@ case MONS_SWAMP_DRAGON: mitm[o].sub_type = ARM_SWAMP_DRAGON_HIDE; break; + case MONS_SHEEP: + case MONS_YAK: + mitm[o].sub_type = ARM_ANIMAL_SKIN; + break; default: // future implementation {dlb} mitm[o].sub_type = ARM_ANIMAL_SKIN; Modified: trunk/crawl-ref/source/monstuff.cc =================================================================== --- trunk/crawl-ref/source/monstuff.cc 2006-11-28 06:05:01 UTC (rev 513) +++ trunk/crawl-ref/source/monstuff.cc 2006-11-28 06:45:56 UTC (rev 514) @@ -5156,6 +5156,8 @@ case MONS_STORM_DRAGON: case MONS_GOLDEN_DRAGON: case MONS_SWAMP_DRAGON: + case MONS_YAK: + case MONS_SHEEP: return (true); default: return (false); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ha...@us...> - 2006-11-28 10:32:51
|
Revision: 522 http://svn.sourceforge.net/crawl-ref/?rev=522&view=rev Author: haranp Date: 2006-11-28 02:32:48 -0800 (Tue, 28 Nov 2006) Log Message: ----------- Gave boots, gloves and helmets specific colours instead of cyan (magenta, red and green, specifically.) I'm no designer - speak up if you want these colours changed. Modified Paths: -------------- trunk/crawl-ref/source/dungeon.cc trunk/crawl-ref/source/stuff.cc trunk/crawl-ref/source/stuff.h Modified: trunk/crawl-ref/source/dungeon.cc =================================================================== --- trunk/crawl-ref/source/dungeon.cc 2006-11-28 10:09:53 UTC (rev 521) +++ trunk/crawl-ref/source/dungeon.cc 2006-11-28 10:32:48 UTC (rev 522) @@ -6012,16 +6012,12 @@ switch (item.sub_type) { + case ARM_CLOAK: case ARM_ROBE: - do { - item.colour = random_colour(); - } while ( item.colour == LIGHTCYAN ); - break; - case ARM_CLOAK: case ARM_NAGA_BARDING: case ARM_CENTAUR_BARDING: case ARM_CAP: - item.colour = random_colour(); + item.colour = random_uncommon_colour(); break; case ARM_HELMET: @@ -6029,14 +6025,18 @@ if (get_helmet_type(item) == THELM_CAP || get_helmet_type(item) == THELM_WIZARD_HAT) { - item.colour = random_colour(); + item.colour = random_uncommon_colour(); } else - item.colour = LIGHTCYAN; + item.colour = GREEN; break; - case ARM_BOOTS: // maybe more interesting boot colours? + case ARM_BOOTS: + item.colour = RED; + break; case ARM_GLOVES: + item.colour = MAGENTA; + break; case ARM_LEATHER_ARMOUR: item.colour = BROWN; break; Modified: trunk/crawl-ref/source/stuff.cc =================================================================== --- trunk/crawl-ref/source/stuff.cc 2006-11-28 10:09:53 UTC (rev 521) +++ trunk/crawl-ref/source/stuff.cc 2006-11-28 10:32:48 UTC (rev 522) @@ -920,6 +920,16 @@ return (1 + random2(15)); } // end random_colour() +unsigned char random_uncommon_colour() +{ + unsigned char result; + do { + result = random_colour(); + } while ( result == LIGHTCYAN || result == CYAN || result == BROWN ); + return result; +} + + // returns if a colour is one of the special element colours (ie not regular) bool is_element_colour( int col ) { Modified: trunk/crawl-ref/source/stuff.h =================================================================== --- trunk/crawl-ref/source/stuff.h 2006-11-28 10:09:53 UTC (rev 521) +++ trunk/crawl-ref/source/stuff.h 2006-11-28 10:32:48 UTC (rev 522) @@ -78,6 +78,7 @@ bool player_can_hear(char x, char y); unsigned char random_colour(void); +unsigned char random_uncommon_colour(); bool is_element_colour( int col ); int element_colour( int element, bool no_random = false ); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dsh...@us...> - 2006-11-28 12:40:45
|
Revision: 524 http://svn.sourceforge.net/crawl-ref/?rev=524&view=rev Author: dshaligram Date: 2006-11-28 04:40:42 -0800 (Tue, 28 Nov 2006) Log Message: ----------- Fixed feature and cset options being ignored. Modified Paths: -------------- trunk/crawl-ref/source/externs.h trunk/crawl-ref/source/initfile.cc trunk/crawl-ref/source/view.cc trunk/crawl-ref/source/view.h Modified: trunk/crawl-ref/source/externs.h =================================================================== --- trunk/crawl-ref/source/externs.h 2006-11-28 11:03:12 UTC (rev 523) +++ trunk/crawl-ref/source/externs.h 2006-11-28 12:40:42 UTC (rev 524) @@ -701,6 +701,23 @@ int colour; }; +struct feature_def +{ + unsigned short symbol; // symbol used for seen terrain + unsigned short magic_symbol; // symbol used for magic-mapped terrain + unsigned short colour; // normal in LoS colour + unsigned short map_colour; // colour when out of LoS on display + unsigned short seen_colour; // map_colour when is_terrain_seen() + bool notable; // gets noted when seen + bool seen_effect; // requires special handling when seen +}; + +struct feature_override +{ + dungeon_feature_type feat; + feature_def override; +}; + class InitLineInput; struct game_options { @@ -713,6 +730,10 @@ void read_options(InitLineInput &, bool runscripts); public: + // View options + std::vector<feature_override> feature_overrides; + unsigned cset_override[NUM_CSET][NUM_DCHAR_TYPES]; + std::string save_dir; // Directory where saves and bones go. std::string player_name; @@ -758,7 +779,7 @@ bool delay_message_clear; // avoid clearing messages each turn unsigned friend_brand; // Attribute for branding friendly monsters bool no_dark_brand; // Attribute for branding friendly monsters - bool macro_meta_entry; // Allow user to use \{foo} sequences when + bool macro_meta_entry; // Allow user to use numeric sequences when // creating macros int fire_items_start; // index of first item for fire command @@ -906,6 +927,13 @@ int o_colour(const char *name, int def = LIGHTGREY) const; private: + void clear_feature_overrides(); + void clear_cset_overrides(); + void add_cset_override(char_set_type set, const std::string &overrides); + void add_cset_override(char_set_type set, dungeon_char_type dc, + unsigned char symbol); + void add_feature_override(const std::string &); + void set_default_activity_interrupts(); void clear_activity_interrupts(FixedVector<bool, NUM_AINTERRUPTS> &eints); void set_activity_interrupt( Modified: trunk/crawl-ref/source/initfile.cc =================================================================== --- trunk/crawl-ref/source/initfile.cc 2006-11-28 11:03:12 UTC (rev 523) +++ trunk/crawl-ref/source/initfile.cc 2006-11-28 12:40:42 UTC (rev 524) @@ -24,6 +24,7 @@ #include "clua.h" #include "delay.h" +#include "direct.h" #include "Kills.h" #include "files.h" #include "defines.h" @@ -698,6 +699,103 @@ initialise_travel(); } +void game_options::clear_cset_overrides() +{ + memset(cset_override, 0, sizeof cset_override); +} + +void game_options::clear_feature_overrides() +{ + feature_overrides.clear(); +} + +static unsigned short read_symbol(std::string s) +{ + if (s.empty()) + return (0); + if (s.length() == 1) + return s[0]; + + if (s[0] == '\\') + s = s.substr(1); + + int feat = atoi(s.c_str()); + if (feat < 0) + feat = 0; + return static_cast<unsigned short>(feat); +} + +void game_options::add_feature_override(const std::string &text) +{ + std::string::size_type epos = text.rfind("}"); + if (epos == std::string::npos) + return; + + std::string::size_type spos = text.rfind("{", epos); + if (spos == std::string::npos) + return; + + std::string fname = text.substr(0, spos); + std::string props = text.substr(spos + 1, epos - spos - 1); + std::vector<std::string> iprops = split_string(",", props, true, true); + + if (iprops.size() < 1 || iprops.size() > 5) + return; + + if (iprops.size() < 5) + iprops.resize(5); + + trim_string(fname); + std::vector<dungeon_feature_type> feats = features_by_desc(fname); + if (feats.empty()) + return; + + for (int i = 0, size = feats.size(); i < size; ++i) + { + feature_override fov; + fov.feat = feats[i]; + + fov.override.symbol = read_symbol(iprops[0]); + fov.override.magic_symbol = read_symbol(iprops[1]); + fov.override.colour = str_to_colour(iprops[2], BLACK); + fov.override.map_colour = str_to_colour(iprops[3], BLACK); + fov.override.seen_colour = str_to_colour(iprops[4], BLACK); + + feature_overrides.push_back(fov); + } +} + +void game_options::add_cset_override( + char_set_type set, const std::string &overrides) +{ + std::vector<std::string> overs = split_string(",", overrides); + for (int i = 0, size = overs.size(); i < size; ++i) + { + std::vector<std::string> mapping = split_string(":", overs[i]); + if (mapping.size() != 2) + continue; + + dungeon_char_type dc = dchar_by_name(mapping[0]); + if (dc == NUM_DCHAR_TYPES) + continue; + + unsigned char symbol = + static_cast<unsigned char>(read_symbol(mapping[1])); + + if (set == NUM_CSET) + for (int c = 0; c < NUM_CSET; ++c) + add_cset_override(char_set_type(c), dc, symbol); + else + add_cset_override(set, dc, symbol); + } +} + +void game_options::add_cset_override(char_set_type set, dungeon_char_type dc, + unsigned char symbol) +{ + cset_override[set][dc] = symbol; +} + // returns where the init file was read from std::string read_init_file(bool runscript) { Modified: trunk/crawl-ref/source/view.cc =================================================================== --- trunk/crawl-ref/source/view.cc 2006-11-28 11:03:12 UTC (rev 523) +++ trunk/crawl-ref/source/view.cc 2006-11-28 12:40:42 UTC (rev 524) @@ -68,26 +68,8 @@ #define MC_ITEM 0x01 #define MC_MONS 0x02 -struct feature_def -{ - unsigned short symbol; // symbol used for seen terrain - unsigned short magic_symbol; // symbol used for magic-mapped terrain - unsigned short colour; // normal in LoS colour - unsigned short map_colour; // colour when out of LoS on display - unsigned short seen_colour; // map_colour when is_terrain_seen() - bool notable; // gets noted when seen - bool seen_effect; // requires special handling when seen -}; +static FixedVector<feature_def, NUM_FEATURES> Feature; -struct feature_override -{ - dungeon_feature_type feat; - feature_def override; -}; - -static FixedVector< struct feature_def, NUM_FEATURES > Feature; -static std::vector<feature_override> Feature_Overrides; - #if defined(DOS_TERM) // DOS functions like gettext() and puttext() can only // work with arrays of characters, not shorts. @@ -2601,8 +2583,6 @@ }, }; -static unsigned char cset_override[NUM_CSET][NUM_DCHAR_TYPES]; - dungeon_char_type dchar_by_name(const std::string &name) { const char *dchar_names[] = @@ -2623,118 +2603,22 @@ return (NUM_DCHAR_TYPES); } -void clear_cset_overrides() -{ - memset(cset_override, 0, sizeof cset_override); -} - -static unsigned short read_symbol(std::string s) -{ - if (s.empty()) - return (0); - if (s.length() == 1) - return s[0]; - - if (s[0] == '\\') - s = s.substr(1); - - int feat = atoi(s.c_str()); - if (feat < 0) - feat = 0; - return static_cast<unsigned short>(feat); -} - -void add_cset_override(char_set_type set, dungeon_char_type dc, - unsigned char symbol) -{ - cset_override[set][dc] = symbol; -} - -void add_cset_override(char_set_type set, const std::string &overrides) -{ - std::vector<std::string> overs = split_string(",", overrides); - for (int i = 0, size = overs.size(); i < size; ++i) - { - std::vector<std::string> mapping = split_string(":", overs[i]); - if (mapping.size() != 2) - continue; - - dungeon_char_type dc = dchar_by_name(mapping[0]); - if (dc == NUM_DCHAR_TYPES) - continue; - - unsigned char symbol = - static_cast<unsigned char>(read_symbol(mapping[1])); - - if (set == NUM_CSET) - for (int c = 0; c < NUM_CSET; ++c) - add_cset_override(char_set_type(c), dc, symbol); - else - add_cset_override(set, dc, symbol); - } -} - void init_char_table( char_set_type set ) { for (int i = 0; i < NUM_DCHAR_TYPES; i++) { - if (cset_override[set][i]) - Options.char_table[i] = cset_override[set][i]; + if (Options.cset_override[set][i]) + Options.char_table[i] = Options.cset_override[set][i]; else Options.char_table[i] = table[set][i]; } } -void clear_feature_overrides() -{ - Feature_Overrides.clear(); -} - -void add_feature_override(const std::string &text) -{ - std::string::size_type epos = text.rfind("}"); - if (epos == std::string::npos) - return; - - std::string::size_type spos = text.rfind("{", epos); - if (spos == std::string::npos) - return; - - std::string fname = text.substr(0, spos); - std::string props = text.substr(spos + 1, epos - spos - 1); - std::vector<std::string> iprops = split_string(",", props, true, true); - - if (iprops.size() < 1 || iprops.size() > 5) - return; - - if (iprops.size() < 5) - iprops.resize(5); - - trim_string(fname); - std::vector<dungeon_feature_type> feats = features_by_desc(fname); - if (feats.empty()) - return; - - for (int i = 0, size = feats.size(); i < size; ++i) - { - feature_override fov; - fov.feat = feats[i]; - - fov.override.symbol = read_symbol(iprops[0]); - fov.override.magic_symbol = read_symbol(iprops[1]); - fov.override.colour = str_to_colour(iprops[2], BLACK); - fov.override.map_colour = str_to_colour(iprops[3], BLACK); - fov.override.seen_colour = str_to_colour(iprops[4], BLACK); - - Feature_Overrides.push_back(fov); - } -} - void apply_feature_overrides() { - for (int i = 0, size = Feature_Overrides.size(); i < size; ++i) + for (int i = 0, size = Options.feature_overrides.size(); i < size; ++i) { - const feature_override &fov = Feature_Overrides[i]; + const feature_override &fov = Options.feature_overrides[i]; const feature_def &ofeat = fov.override; feature_def &feat = Feature[fov.feat]; Modified: trunk/crawl-ref/source/view.h =================================================================== --- trunk/crawl-ref/source/view.h 2006-11-28 11:03:12 UTC (rev 523) +++ trunk/crawl-ref/source/view.h 2006-11-28 12:40:42 UTC (rev 524) @@ -143,6 +143,8 @@ bool find_ray( int sourcex, int sourcey, int targetx, int targety, bool allow_fallback, ray_def& ray ); +dungeon_char_type dchar_by_name(const std::string &name); + #if defined(WIN32CONSOLE) || defined(DOS) unsigned short dos_brand( unsigned short colour, unsigned brand = CHATTR_REVERSE); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dsh...@us...> - 2006-11-29 12:43:21
|
Revision: 526 http://svn.sourceforge.net/crawl-ref/?rev=526&view=rev Author: dshaligram Date: 2006-11-29 04:43:17 -0800 (Wed, 29 Nov 2006) Log Message: ----------- [1602285] Fixed newgame slider bugs. Modified Paths: -------------- trunk/crawl-ref/source/menu.cc trunk/crawl-ref/source/menu.h trunk/crawl-ref/source/player.cc Modified: trunk/crawl-ref/source/menu.cc =================================================================== --- trunk/crawl-ref/source/menu.cc 2006-11-28 19:48:40 UTC (rev 525) +++ trunk/crawl-ref/source/menu.cc 2006-11-29 12:43:17 UTC (rev 526) @@ -408,7 +408,9 @@ { for (int i = 0, count = items.size(); i < count; ++i) { - if (items[i]->level != MEL_ITEM) continue; + if (items[i]->level != MEL_ITEM + || items[i]->hotkeys.empty()) + continue; if (is_hotkey(i, items[i]->hotkeys[0]) && is_selectable(i)) { items[i]->select( qty ); @@ -421,8 +423,9 @@ { for (int i = si + 1, count = items.size(); i < count; ++i) { - if (items[i]->level != MEL_ITEM) - break; + if (items[i]->level != MEL_ITEM + || items[i]->hotkeys.empty()) + continue; if (is_hotkey(i, items[i]->hotkeys[0])) { items[i]->select( qty ); @@ -578,7 +581,8 @@ slider_menu::slider_menu(int fl) : Menu(fl), less(), starty(1), endy(get_number_of_lines()), - selected(0), search() + selected(0), need_less(true), need_more(true), oldselect(0), + lastkey(0), search() { less.textcolor(DARKGREY); less.cprintf("<---- More"); @@ -620,6 +624,10 @@ int slider_menu::post_process(int key) { + const time_t now = time(NULL); + if (now - lastkey >= 2) + search.clear(); + lastkey = now; select_search( search += key ); return (key); } @@ -630,9 +638,9 @@ // If we ever need to use slider_menu elsewhere, we should factor it out. if (key == CK_ESCAPE || key == '\t') { - int old = selected; + oldselect = selected; selected = -1; - draw_item(old); + draw_item(oldselect); sel.clear(); search.clear(); lastch = key; @@ -643,9 +651,9 @@ (key == CK_UP || key == CK_PGUP || key == '<' || key == ';') && Menu::is_set(MF_EASY_EXIT)) { - int old = selected; + oldselect = selected; selected = -1; - draw_item(old); + draw_item(oldselect); search.clear(); return (false); } @@ -653,10 +661,32 @@ return Menu::process_key(key); } +void slider_menu::adjust_pagesizes(int recurse_depth) +{ + if (first_entry == 1 && selected == 1) + first_entry = 0; + + need_less = !!first_entry; + pagesize = endy - starty + 1 - !!title - need_less; + const int nitems = items.size(); + need_more = first_entry + pagesize < nitems; + if (need_more) + pagesize--; + + if (selected != -1 + && (selected < first_entry || selected >= first_entry + pagesize) + && recurse_depth > 0) + fix_entry(recurse_depth - 1); + + calc_y_offset(); +} + void slider_menu::display() { - // We lose two lines for each of the --More prompts - pagesize = endy - starty - 1 - !!title; + adjust_pagesizes(); + + if (selected != -1) + oldselect = selected; selected = -1; draw_menu(); } @@ -667,13 +697,15 @@ sel.clear(); - // We lose two lines for each of the --More prompts - pagesize = endy - starty - 1 - !!title; + adjust_pagesizes(); if (selected == -1) - selected = 0; + selected = oldselect; - select_search(search); + if (!search.empty()) + select_search(search); + + fix_entry(); do_menu(); if (selected >= 0 && selected <= (int) items.size()) @@ -689,10 +721,17 @@ return (NULL); } +void slider_menu::fill_line() const +{ + const int x = wherex(), maxx = get_number_of_cols(); + if (x < maxx) + cprintf("%-*s", maxx - x, ""); +} + void slider_menu::draw_stock_item(int index, const MenuEntry *me) const { Menu::draw_stock_item(index, me); - cprintf("%-*s", get_number_of_cols() - wherex() + 1, ""); + fill_line(); } int slider_menu::item_colour(int index, const MenuEntry *me) const @@ -709,25 +748,57 @@ return (colour); } +void slider_menu::show_less() +{ + if (!need_less) + return ; + + if (first_entry > 0) + less.display(); + else + textattr(LIGHTGREY); + fill_line(); +} + +void slider_menu::show_more() +{ + if (!need_more) + return ; + const int end = entry_end(); + gotoxy( 1, y_offset + pagesize ); + if (end < (int) items.size() || is_set(MF_ALWAYS_SHOW_MORE)) + more.display(); + else + textattr(LIGHTGREY); + fill_line(); +} + +void slider_menu::calc_y_offset() +{ + y_offset = starty + !!title + need_less; +} + +int slider_menu::entry_end() const +{ + int end = first_entry + pagesize; + if (end > (int) items.size()) end = items.size(); + return (end); +} + void slider_menu::draw_menu() { gotoxy(1, starty); write_title(); - y_offset = starty + !!title + 1; - int end = first_entry + pagesize; - if (end > (int) items.size()) end = items.size(); + calc_y_offset(); + int end = entry_end(); + // We're using get_number_of_cols() - 1 because we want to avoid line wrap // on DOS (the conio.h functions go batshit if that happens). gotoxy(1, y_offset - 1); - if (first_entry > 0) - less.display(); - else - { - textattr(LIGHTGREY); - cprintf("%-*s", get_number_of_cols() - 1, ""); - } + + show_less(); for (int i = first_entry; i < end; ++i) draw_item( i ); @@ -736,17 +807,10 @@ for (int i = end; i < first_entry + pagesize; ++i) { gotoxy(1, y_offset + i - first_entry); - cprintf("%-*s", get_number_of_cols() - 1, ""); - } + cprintf("%-*s", get_number_of_cols() - 2, ""); + } - gotoxy( 1, y_offset + pagesize ); - if (end < (int) items.size() || is_set(MF_ALWAYS_SHOW_MORE)) - more.display(); - else - { - textattr(LIGHTGREY); - cprintf("%-*s", get_number_of_cols() - 1, ""); - } + show_more(); } void slider_menu::select_items(int, int) @@ -761,7 +825,7 @@ return Menu::is_set(flag); } -bool slider_menu::fix_entry() +bool slider_menu::fix_entry(int recurse_depth) { if (selected < 0 || selected >= (int) items.size()) return (false); @@ -776,6 +840,9 @@ first_entry = 0; } + if (recurse_depth > 0) + adjust_pagesizes(recurse_depth - 1); + return (first_entry != oldfirst); } Modified: trunk/crawl-ref/source/menu.h =================================================================== --- trunk/crawl-ref/source/menu.h 2006-11-28 19:48:40 UTC (rev 525) +++ trunk/crawl-ref/source/menu.h 2006-11-29 12:43:17 UTC (rev 526) @@ -4,6 +4,7 @@ #include <string> #include <vector> #include <algorithm> +#include <time.h> #include "AppHdr.h" #include "externs.h" #include "defines.h" @@ -337,6 +338,12 @@ int item_colour(int index, const MenuEntry *me) const; void draw_stock_item(int index, const MenuEntry *me) const; void draw_menu(); + void show_less(); + void show_more(); + void calc_y_offset(); + void adjust_pagesizes(int rdepth = 3); + int entry_end() const; + void fill_line() const; void new_selection(int nsel); bool move_selection(int nsel); @@ -348,7 +355,7 @@ bool is_set(int flag) const; void select_items( int key, int qty ); - bool fix_entry(); + bool fix_entry(int rdepth = 3); bool process_key( int keyin ); int post_process(int key); @@ -359,6 +366,9 @@ formatted_string less; int starty, endy; int selected; + bool need_less, need_more; + int oldselect; + time_t lastkey; std::string search; }; Modified: trunk/crawl-ref/source/player.cc =================================================================== --- trunk/crawl-ref/source/player.cc 2006-11-28 19:48:40 UTC (rev 525) +++ trunk/crawl-ref/source/player.cc 2006-11-29 12:43:17 UTC (rev 526) @@ -4572,5 +4572,7 @@ bool player::operator < (const player &p) const { - return (experience > p.experience); + return (experience > p.experience + || (experience == p.experience && + stricmp(your_name, p.your_name) < 0)); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ha...@us...> - 2006-11-29 18:12:55
|
Revision: 528 http://svn.sourceforge.net/crawl-ref/?rev=528&view=rev Author: haranp Date: 2006-11-29 10:12:52 -0800 (Wed, 29 Nov 2006) Log Message: ----------- Redid how the resists screen works (both in-game and in-dump.) Minor notes refactoring. Added a basic notes browser on '_'. Modified Paths: -------------- trunk/crawl-ref/source/acr.cc trunk/crawl-ref/source/chardump.cc trunk/crawl-ref/source/chardump.h trunk/crawl-ref/source/enum.h trunk/crawl-ref/source/initfile.cc trunk/crawl-ref/source/initfile.h trunk/crawl-ref/source/menu.cc trunk/crawl-ref/source/menu.h trunk/crawl-ref/source/notes.cc trunk/crawl-ref/source/notes.h trunk/crawl-ref/source/output.cc trunk/crawl-ref/source/output.h trunk/crawl-ref/source/overmap.cc Modified: trunk/crawl-ref/source/acr.cc =================================================================== --- trunk/crawl-ref/source/acr.cc 2006-11-29 13:21:50 UTC (rev 527) +++ trunk/crawl-ref/source/acr.cc 2006-11-29 18:12:52 UTC (rev 528) @@ -839,8 +839,8 @@ you.turn_is_over = false; prep_input(); - /* you.paralysis check */ - if ( you.paralysis ) { + if ( you.paralysis ) + { world_reacts(); return; } @@ -851,13 +851,14 @@ gotoxy(18,9); - if ( you_are_delayed() ) { + if ( you_are_delayed() ) + { world_reacts(); return; } - /* Change from previous code! */ - if ( you.turn_is_over ) { + if ( you.turn_is_over ) + { world_reacts(); return; } @@ -1040,6 +1041,10 @@ make_user_note(); break; + case CMD_DISPLAY_NOTES: + display_notes(); + break; + case CMD_CLEAR_MAP: if (you.level_type != LEVEL_LABYRINTH && you.level_type != LEVEL_ABYSS) { @@ -2345,6 +2350,7 @@ case '%': return CMD_RESISTS_SCREEN; case ',': return CMD_PICKUP; case ':': return CMD_MAKE_NOTE; + case '_': return CMD_DISPLAY_NOTES; case ';': return CMD_INSPECT_FLOOR; case '!': return CMD_SHOUT; case '^': return CMD_DISPLAY_RELIGION; Modified: trunk/crawl-ref/source/chardump.cc =================================================================== --- trunk/crawl-ref/source/chardump.cc 2006-11-29 13:21:50 UTC (rev 527) +++ trunk/crawl-ref/source/chardump.cc 2006-11-29 18:12:52 UTC (rev 528) @@ -490,38 +490,14 @@ //--------------------------------------------------------------- static void dump_stats2( std::string & text, bool calc_unid) { - char buffer[24*3][45]; - char str_pass[80]; - char* ptr_n; + std::vector<formatted_string> vfs = get_full_detail(calc_unid); - get_full_detail(&buffer[0][0], calc_unid); - - for (int i = 0; i < 24; i++) + for (unsigned int i = 0; i < vfs.size(); i++) { - ptr_n = &buffer[i][0]; - if (buffer[i+24][0] == 0 && buffer[i+24*2][0] == 0) - snprintf(&str_pass[0], 45, "%s", ptr_n); - else - snprintf(&str_pass[0], 45, "%-32s", ptr_n); - text += str_pass; - - ptr_n = &buffer[i+24][0]; - if (buffer[i+24*2][0] == 0) - snprintf(&str_pass[0], 45, "%s", ptr_n); - else - snprintf(&str_pass[0], 45, "%-20s", ptr_n); - text += str_pass; - - ptr_n = &buffer[i+24*2][0]; - if (buffer[i+24*2][0] != 0) - { - snprintf(&str_pass[0], 45, "%s", ptr_n); - text += str_pass; - } - text += "\n"; + text += vfs[i]; + text += '\n'; } - - text += "\n" "\n"; + text += "\n\n"; } static void sdump_notes(const std::string &, std::string& text) @@ -532,7 +508,7 @@ text += "\nNotes\n| Turn |Location | Note\n"; text += "--------------------------------------------------------------\n"; for ( unsigned i = 0; i < note_list.size(); ++i ) { - text += describe_note(note_list[i]); + text += note_list[i].describe(); text += "\n"; } text += "\n"; @@ -1037,72 +1013,61 @@ return (succeeded); } // end dump_char() -static void set_resist_dump_color( const char* data ) { - while ( *data && *data != ':' ) - ++data; - if ( *data == 0 ) - return; - ++data; - int pluscount = 0; - while ( *data ) { - if ( *data == '+' ) - ++pluscount; - if ( *data == 'x' ) - --pluscount; - ++data; +void display_notes() +{ +#ifdef DOS_TERM + char dosbuffer[4000]; + gettext( 1, 1, 80, 25, dosbuffer ); + window( 1, 1, 80, 25 ); +#endif + Menu scr; + scr.set_title( new MenuEntry("| Turn |Location | Note")); + for ( unsigned int i = 0; i < note_list.size(); ++i ) + { + std::string prefix = note_list[i].describe(true, true, false); + std::string suffix = note_list[i].describe(false, false, true); + if ( suffix.empty() ) + continue; + int spaceleft = get_number_of_cols() - prefix.length() - 1; + if ( spaceleft <= 0 ) + return; + linebreak_string(suffix, spaceleft - 4, spaceleft); + std::vector<std::string> parts = split_string("\n", suffix); + scr.add_entry(new MenuEntry(prefix + parts[0])); + for ( unsigned int j = 1; j < parts.size(); ++j ) + scr.add_entry(new MenuEntry(std::string(prefix.length()-2, ' ') + + std::string("| ") + parts[j])); + } - switch ( pluscount ) { - case 3: - case 2: - textcolor(LIGHTGREEN); - break; - case 1: - textcolor(GREEN); - break; - case -1: - textcolor(RED); - break; - case -2: - case -3: - textcolor(LIGHTRED); - break; - default: - textcolor(LIGHTGREY); - break; - } + scr.show(); +#ifdef DOS_TERM + puttext(1, 1, 80, 25, dosbuffer); + window(1, 1, 80, 25); +#endif + redraw_screen(); } -void resists_screen() { +void resists_screen() +{ #ifdef DOS_TERM char dosbuffer[4000]; gettext( 1, 1, 80, 25, dosbuffer ); window( 1, 1, 80, 25 ); #endif + std::vector<formatted_string> vfs = get_full_detail(false); clrscr(); + gotoxy(1,1); textcolor(LIGHTGREY); - char buffer[24*3][45]; - get_full_detail(&buffer[0][0], false); - - for (int line = 0; line < 24; ++line ) { - for ( int block = 0; block < 3; ++block ) { - const int idx = block * 24 + line; - if ( buffer[idx][0] ) { - gotoxy( block == 2 ? 53 : block * 32 + 1, line+1 ); - /* FIXME - hack - magic number 14 */ - if ( block != 0 && line < 14 ) - set_resist_dump_color(buffer[idx]); - cprintf("%s", buffer[idx] ); - textcolor(LIGHTGREY); - } - } + formatted_scroller scr; + for ( unsigned i = 0; i < vfs.size(); ++i ) + { + scr.add_item_formatted_string(vfs[i]); } - - getch(); + scr.show(); #ifdef DOS_TERM puttext(1, 1, 80, 25, dosbuffer); window(1, 1, 80, 25); #endif - redraw_screen(); } Modified: trunk/crawl-ref/source/chardump.h =================================================================== --- trunk/crawl-ref/source/chardump.h 2006-11-29 13:21:50 UTC (rev 527) +++ trunk/crawl-ref/source/chardump.h 2006-11-29 18:12:52 UTC (rev 528) @@ -22,6 +22,7 @@ bool full_id = false); void resists_screen(); +void display_notes(); std::string munge_description(const std::string &inStr); Modified: trunk/crawl-ref/source/enum.h =================================================================== --- trunk/crawl-ref/source/enum.h 2006-11-29 13:21:50 UTC (rev 527) +++ trunk/crawl-ref/source/enum.h 2006-11-29 18:12:52 UTC (rev 528) @@ -645,6 +645,7 @@ CMD_TOGGLE_AUTOPRAYER, CMD_MAKE_NOTE, CMD_RESISTS_SCREEN, + CMD_DISPLAY_NOTES, /* overmap commands */ CMD_MAP_CLEAR_MAP, Modified: trunk/crawl-ref/source/initfile.cc =================================================================== --- trunk/crawl-ref/source/initfile.cc 2006-11-29 13:21:50 UTC (rev 527) +++ trunk/crawl-ref/source/initfile.cc 2006-11-29 18:12:52 UTC (rev 528) @@ -51,18 +51,26 @@ dest.insert( dest.end(), src.begin(), src.end() ); } +const std::string cols[16] = +{ + "black", "blue", "green", "cyan", "red", "magenta", "brown", + "lightgrey", "darkgrey", "lightblue", "lightgreen", "lightcyan", + "lightred", "lightmagenta", "yellow", "white" +}; + +const char* colour_to_str(unsigned char colour) +{ + if ( colour >= 16 ) + return "lightgrey"; + else + return cols[colour].c_str(); +} + // returns -1 if unmatched else returns 0-15 int str_to_colour( const std::string &str, int default_colour ) { int ret; - const std::string cols[16] = - { - "black", "blue", "green", "cyan", "red", "magenta", "brown", - "lightgrey", "darkgrey", "lightblue", "lightgreen", "lightcyan", - "lightred", "lightmagenta", "yellow", "white" - }; - const std::string element_cols[] = { "fire", "ice", "earth", "electricity", "air", "poison", "water", Modified: trunk/crawl-ref/source/initfile.h =================================================================== --- trunk/crawl-ref/source/initfile.h 2006-11-29 13:21:50 UTC (rev 527) +++ trunk/crawl-ref/source/initfile.h 2006-11-29 18:12:52 UTC (rev 528) @@ -20,6 +20,7 @@ std::string & trim_string( std::string &str ); std::string & tolower_string( std::string &str ); int str_to_colour( const std::string &str, int default_colour = -1 ); +const char* colour_to_str( unsigned char colour ); // last updated 12may2000 {dlb} /* *********************************************************************** Modified: trunk/crawl-ref/source/menu.cc =================================================================== --- trunk/crawl-ref/source/menu.cc 2006-11-29 13:21:50 UTC (rev 527) +++ trunk/crawl-ref/source/menu.cc 2006-11-29 18:12:52 UTC (rev 528) @@ -1276,23 +1276,52 @@ formatted_scroller::formatted_scroller(int _flags, const std::string& s) : Menu(_flags) { + add_text(s); +} + +void formatted_scroller::add_text(const std::string& s) +{ size_t eolpos = 0; while ( true ) { - const size_t newpos = s.find( EOL, eolpos ); - add_entry(new MenuEntry(std::string(s, eolpos, newpos-eolpos))); + const size_t newpos = s.find( "\n", eolpos ); + add_item_formatted_string(formatted_string::parse_string(std::string(s, eolpos, newpos-eolpos))); if ( newpos == std::string::npos ) break; else - eolpos = newpos + strlen(EOL); - } + eolpos = newpos + 1; + } } +void formatted_scroller::add_item_formatted_string(const formatted_string& fs) +{ + MenuEntry* me = new MenuEntry; + me->data = new formatted_string(fs); + add_entry(me); +} + +void formatted_scroller::add_item_string(const std::string& s) +{ + add_entry( new MenuEntry(s) ); +} + void formatted_scroller::draw_index_item(int index, const MenuEntry *me) const { - formatted_string::parse_string(me->text).display(); + if ( me->data == NULL ) + Menu::draw_index_item(index, me); + else + static_cast<formatted_string*>(me->data)->display(); } +formatted_scroller::~formatted_scroller() +{ + // very important: this destructor is called *before* the + // base (Menu) class destructor...which is at it should be. + for ( unsigned i = 0; i < items.size(); ++i ) + if ( items[i]->data != NULL ) + delete static_cast<formatted_string*>(items[i]->data); +} + int linebreak_string( std::string& s, int wrapcol, int maxcol ) { size_t loc = 0; @@ -1323,14 +1352,14 @@ // soft linebreak else if ( s[loc] == ' ' && xpos > wrapcol ) { - s.replace(loc, 1, EOL); + s.replace(loc, 1, "\n"); xpos = 0; ++breakcount; } // hard linebreak else if ( xpos > maxcol ) { - s.insert(loc, EOL); + s.insert(loc, "\n"); xpos = 0; ++breakcount; } Modified: trunk/crawl-ref/source/menu.h =================================================================== --- trunk/crawl-ref/source/menu.h 2006-11-29 13:21:50 UTC (rev 527) +++ trunk/crawl-ref/source/menu.h 2006-11-29 18:12:52 UTC (rev 528) @@ -417,7 +417,12 @@ class formatted_scroller : public Menu { public: + formatted_scroller() {} formatted_scroller(int flags, const std::string& s); + virtual void add_item_formatted_string(const formatted_string& s); + virtual void add_item_string(const std::string& s); + virtual void add_text(const std::string& s); + virtual ~formatted_scroller(); protected: virtual void draw_index_item(int index, const MenuEntry* me) const; }; Modified: trunk/crawl-ref/source/notes.cc =================================================================== --- trunk/crawl-ref/source/notes.cc 2006-11-29 13:21:50 UTC (rev 527) +++ trunk/crawl-ref/source/notes.cc 2006-11-29 18:12:52 UTC (rev 528) @@ -226,102 +226,118 @@ return ordinals[number-1]; } -std::string describe_note( const Note& note ) { - char buf[200], buf2[50]; +std::string Note::describe( bool when, bool where, bool what ) const { - switch ( note.type ) { - case NOTE_HP_CHANGE: - // [ds] Shortened HP change note from "Had X hitpoints" to accommodate - // the cause for the loss of hitpoints. - snprintf(buf, sizeof buf, "HP: %d/%d [%s]", - note.first, note.second, note.name.c_str()); - break; - case NOTE_MP_CHANGE: - snprintf(buf, sizeof buf, "Mana: %d/%d", note.first, note.second); - break; - case NOTE_MAXHP_CHANGE: - snprintf(buf, sizeof buf, "Reached %d max hit points", note.first); - break; - case NOTE_MAXMP_CHANGE: - snprintf(buf, sizeof buf, "Reached %d max mana", note.first); - break; - case NOTE_XP_LEVEL_CHANGE: - snprintf(buf, sizeof buf, "Reached XP level %d. %s", note.first, - note.name.c_str()); - break; - case NOTE_DUNGEON_LEVEL_CHANGE: - snprintf(buf, sizeof buf, "Entered %s", - place_name(note.packed_place, true, true).c_str()); - break; - case NOTE_LEARN_SPELL: - snprintf(buf, sizeof buf, "Learned a level %d spell: %s", - spell_difficulty(note.first), spell_title(note.first)); - break; - case NOTE_GET_GOD: - snprintf(buf, sizeof buf, "Became a worshipper of %s", - god_name(note.first, true)); - break; - case NOTE_LOSE_GOD: - snprintf(buf, sizeof buf, "Fell from the grace of %s", - god_name(note.first)); - break; - case NOTE_GOD_GIFT: - snprintf(buf, sizeof buf, "Received a gift from %s", - god_name(note.first)); - break; - case NOTE_ID_ITEM: - if (note.desc.length() > 0) - snprintf(buf, sizeof buf, "Identified %s (%s)", note.name.c_str(), - note.desc.c_str()); - else - snprintf(buf, sizeof buf, "Identified %s", note.name.c_str()); - break; - case NOTE_GET_ITEM: - snprintf(buf, sizeof buf, "Got %s", note.name.c_str()); - break; - case NOTE_GAIN_SKILL: - snprintf(buf, sizeof buf, "Reached skill %d in %s", - note.second, skill_name(note.first)); - break; - case NOTE_SEEN_MONSTER: - snprintf(buf, sizeof buf, "Noticed %s", note.name.c_str() ); - break; - case NOTE_KILL_MONSTER: - snprintf(buf, sizeof buf, "Defeated %s", note.name.c_str()); - break; - case NOTE_POLY_MONSTER: - snprintf(buf, sizeof buf, "%s changed form", note.name.c_str() ); - break; - case NOTE_GOD_POWER: - snprintf(buf, sizeof buf, "Acquired %s's %s power", - god_name(note.first), - number_to_ordinal(real_god_power(note.first, note.second)+1)); - break; - case NOTE_GET_MUTATION: - snprintf(buf, sizeof buf, "Gained mutation: %s", - mutation_name(note.first, note.second == 0 ? 1 : note.second)); - break; - case NOTE_LOSE_MUTATION: - snprintf(buf, sizeof buf, "Lost mutation: %s", - mutation_name(note.first, - note.second == 3 ? 3 : note.second+1)); - break; - case NOTE_USER_NOTE: - snprintf(buf, sizeof buf, "%s", note.name.c_str()); - break; - case NOTE_MESSAGE: - snprintf(buf, sizeof buf, "%s", note.name.c_str()); - break; - default: - snprintf(buf, sizeof buf, "Buggy note description: unknown note type"); - break; + std::string result; + + if ( when ) + { + char buf[20]; + snprintf(buf, sizeof buf, "| %5ld ", turn ); + result += buf; } - snprintf(buf2, sizeof buf2, "| %5ld | ", note.turn ); - std::string placename = short_place_name(note.packed_place); - while ( placename.length() < 7 ) - placename += ' '; - return std::string(buf2) + placename + std::string(" | ") + - std::string(buf); + if ( where ) + { + result += "| "; + std::string placename = short_place_name(packed_place); + while ( placename.length() < 7 ) + placename += ' '; + result += placename; + result += " | "; + } + if ( what ) + { + char buf[200]; + switch ( type ) { + case NOTE_HP_CHANGE: + // [ds] Shortened HP change note from "Had X hitpoints" to + // accommodate the cause for the loss of hitpoints. + snprintf(buf, sizeof buf, "HP: %d/%d [%s]", + first, second, name.c_str()); + break; + case NOTE_MP_CHANGE: + snprintf(buf, sizeof buf, "Mana: %d/%d", first, second); + break; + case NOTE_MAXHP_CHANGE: + snprintf(buf, sizeof buf, "Reached %d max hit points", first); + break; + case NOTE_MAXMP_CHANGE: + snprintf(buf, sizeof buf, "Reached %d max mana", first); + break; + case NOTE_XP_LEVEL_CHANGE: + snprintf(buf, sizeof buf, "Reached XP level %d. %s", first, + name.c_str()); + break; + case NOTE_DUNGEON_LEVEL_CHANGE: + snprintf(buf, sizeof buf, "Entered %s", + place_name(packed_place, true, true).c_str()); + break; + case NOTE_LEARN_SPELL: + snprintf(buf, sizeof buf, "Learned a level %d spell: %s", + spell_difficulty(first), spell_title(first)); + break; + case NOTE_GET_GOD: + snprintf(buf, sizeof buf, "Became a worshipper of %s", + god_name(first, true)); + break; + case NOTE_LOSE_GOD: + snprintf(buf, sizeof buf, "Fell from the grace of %s", + god_name(first)); + break; + case NOTE_GOD_GIFT: + snprintf(buf, sizeof buf, "Received a gift from %s", + god_name(first)); + break; + case NOTE_ID_ITEM: + if (desc.length() > 0) + snprintf(buf, sizeof buf, "Identified %s (%s)", + name.c_str(), desc.c_str()); + else + snprintf(buf, sizeof buf, "Identified %s", name.c_str()); + break; + case NOTE_GET_ITEM: + snprintf(buf, sizeof buf, "Got %s", name.c_str()); + break; + case NOTE_GAIN_SKILL: + snprintf(buf, sizeof buf, "Reached skill %d in %s", + second, skill_name(first)); + break; + case NOTE_SEEN_MONSTER: + snprintf(buf, sizeof buf, "Noticed %s", name.c_str() ); + break; + case NOTE_KILL_MONSTER: + snprintf(buf, sizeof buf, "Defeated %s", name.c_str()); + break; + case NOTE_POLY_MONSTER: + snprintf(buf, sizeof buf, "%s changed form", name.c_str() ); + break; + case NOTE_GOD_POWER: + snprintf(buf, sizeof buf, "Acquired %s's %s power", + god_name(first), + number_to_ordinal(real_god_power(first, second)+1)); + break; + case NOTE_GET_MUTATION: + snprintf(buf, sizeof buf, "Gained mutation: %s", + mutation_name(first, second == 0 ? 1 : second)); + break; + case NOTE_LOSE_MUTATION: + snprintf(buf, sizeof buf, "Lost mutation: %s", + mutation_name(first, second == 3 ? 3 : second+1)); + break; + case NOTE_USER_NOTE: + snprintf(buf, sizeof buf, "%s", name.c_str()); + break; + case NOTE_MESSAGE: + snprintf(buf, sizeof buf, "%s", name.c_str()); + break; + default: + snprintf(buf, sizeof buf, + "Buggy note description: unknown note type"); + break; + } + result += buf; + } + return result; } Note::Note() { Modified: trunk/crawl-ref/source/notes.h =================================================================== --- trunk/crawl-ref/source/notes.h 2006-11-29 13:21:50 UTC (rev 527) +++ trunk/crawl-ref/source/notes.h 2006-11-29 18:12:52 UTC (rev 528) @@ -53,10 +53,11 @@ std::string desc; void load( FILE* fp ); void save( FILE* fp ) const; + std::string describe( bool when = true, bool where = true, + bool what = true ) const; }; extern std::vector<Note> note_list; -std::string describe_note( const Note& note ); void activate_notes( bool active ); bool notes_are_active(); void take_note( const Note& note ); Modified: trunk/crawl-ref/source/output.cc =================================================================== --- trunk/crawl-ref/source/output.cc 2006-11-29 13:21:50 UTC (rev 527) +++ trunk/crawl-ref/source/output.cc 2006-11-29 18:12:52 UTC (rev 528) @@ -23,6 +23,7 @@ #include "externs.h" #include "fight.h" +#include "initfile.h" #include "itemname.h" #include "menu.h" #include "ouch.h" @@ -551,14 +552,14 @@ #endif } // end print_stats() -unsigned char* itosym1(int stat) +const char* itosym1(int stat) { - return (unsigned char*)( (stat >= 1) ? "+ " : ". " ); + return ( (stat >= 1) ? "+ " : ". " ); } -unsigned char* itosym3(int stat) +const char* itosym3(int stat) { - return (unsigned char*)( (stat >= 3) ? "+ + +" : + return ( (stat >= 3) ? "+ + +" : (stat == 2) ? "+ + ." : (stat == 1) ? "+ . ." : (stat == 0) ? ". . ." : @@ -600,79 +601,112 @@ return -1; } -void get_full_detail(char* buffer, bool calc_unid) +static const char* determine_color_string( int level ) { + switch ( level ) { + case 3: + case 2: + return "<lightgreen>"; + case 1: + return "<green>"; + case -1: + return "<red>"; + case -2: + case -3: + return "<lightred>"; + default: + return "<lightgrey>"; + } +} + +std::vector<formatted_string> get_full_detail(bool calc_unid) { -#define CUR_AD &buffer[++lines*45],44 -#define BUF_SIZE 24*3*45 - int lines = -1; + char buf[1000]; + // 3 columns, splits at columns 32, 52 + column_composer cols(3, 32, 52); + snprintf(buf, sizeof buf, + "<red>%s the %s</red>\n\n" + "Race : %s\n" + "Class : %s\n" + "Worship : %s\n" + "Level : %7d\n" + "Exp : %7lu\n", + you.your_name, player_title(), + species_name(you.species,you.experience_level), + you.class_name, + you.religion == GOD_NO_GOD? "" : god_name(you.religion), + you.experience_level, + you.experience); + cols.add_formatted(0, buf, false); - memset(buffer, 0, BUF_SIZE); - - snprintf(CUR_AD, "%s the %s", you.your_name, player_title()); - lines++; - snprintf(CUR_AD, "Race : %s", species_name(you.species,you.experience_level) ); - snprintf(CUR_AD, "Class : %s", you.class_name); - snprintf(CUR_AD, "Worship : %s", - you.religion == GOD_NO_GOD? "" : god_name(you.religion) ); - snprintf(CUR_AD, "Level : %7d", you.experience_level); - snprintf(CUR_AD, "Exp : %7lu", you.experience); - if (you.experience_level < 27) { - int xp_needed = (exp_needed(you.experience_level+2) - you.experience) + 1; - snprintf(CUR_AD, "Next Level : %7lu", exp_needed(you.experience_level + 2) + 1); - snprintf(CUR_AD, "Exp Needed : %7d", xp_needed); + int xp_needed = (exp_needed(you.experience_level+2)-you.experience)+1; + snprintf(buf, sizeof buf, + "Next Level : %7lu\n" + "Exp Needed : %7d\n", + exp_needed(you.experience_level + 2) + 1, + xp_needed); + cols.add_formatted(0, buf, false); } else - { - snprintf(CUR_AD, " "); - snprintf(CUR_AD, " "); - } + cols.add_formatted(0, "\n\n", false); + + snprintf(buf, sizeof buf, + "Spls.Left : %7d\n" + "Gold : %7d\n", + player_spell_levels(), + you.gold); + cols.add_formatted(0, buf, false); - snprintf(CUR_AD, "Spls.Left : %7d", player_spell_levels() ); - snprintf(CUR_AD, "Gold : %7d", you.gold ); - - lines++; - if (!player_rotted()) { if (you.hp < you.hp_max) - snprintf(CUR_AD, "HP : %3d/%d", you.hp, you.hp_max); + snprintf(buf, sizeof buf, "HP : %3d/%d",you.hp,you.hp_max); else - snprintf(CUR_AD, "HP : %3d", you.hp); + snprintf(buf, sizeof buf, "HP : %3d", you.hp); } else { - snprintf(CUR_AD, "HP : %3d/%d (%d)", - you.hp, you.hp_max, you.hp_max + player_rotted() ); + snprintf(buf, sizeof buf, "HP : %3d/%d (%d)", + you.hp, you.hp_max, you.hp_max + player_rotted() ); } + cols.add_formatted(0, buf, true); if (you.magic_points < you.max_magic_points) - snprintf(CUR_AD, "MP : %3d/%d", - you.magic_points, you.max_magic_points); + snprintf(buf, sizeof buf, "MP : %3d/%d", + you.magic_points, you.max_magic_points); else - snprintf(CUR_AD, "MP : %3d", you.magic_points); + snprintf(buf, sizeof buf, "MP : %3d", you.magic_points); + cols.add_formatted(0, buf, false); if (you.strength == you.max_strength) - snprintf(CUR_AD, "Str : %3d", you.strength); + snprintf(buf, sizeof buf, "Str : %3d", you.strength); else - snprintf(CUR_AD, "Str : %3d (%d)", - you.strength, you.max_strength); + snprintf(buf, sizeof buf, "Str : %3d (%d)", + you.strength, you.max_strength); + cols.add_formatted(0, buf, false); if (you.intel == you.max_intel) - snprintf(CUR_AD, "Int : %3d", you.intel); + snprintf(buf, sizeof buf, "Int : %3d", you.intel); else - snprintf(CUR_AD, "Int : %3d (%d)", you.intel, you.max_intel); + snprintf(buf, sizeof buf, "Int : %3d (%d)", + you.intel, you.max_intel); + cols.add_formatted(0, buf, false); if (you.dex == you.max_dex) - snprintf(CUR_AD, "Dex : %3d", you.dex); + snprintf(buf, sizeof buf, "Dex : %3d", you.dex); else - snprintf(CUR_AD, "Dex : %3d (%d)", you.dex, you.max_dex); + snprintf(buf, sizeof buf, "Dex : %3d (%d)",you.dex,you.max_dex); + cols.add_formatted(0, buf, false); - snprintf(CUR_AD, "AC : %3d", player_AC() ); - snprintf(CUR_AD, "Evasion : %3d", player_evasion() ); - snprintf(CUR_AD, "Shield : %3d", player_shield_class() ); - lines++; + snprintf(buf, sizeof buf, + "AC : %3d\n" + "Evasion : %3d\n" + "Shield : %3d\n", + player_AC(), + player_evasion(), + player_shield_class()); + cols.add_formatted(0, buf, false); if (you.real_time != -1) { @@ -680,35 +714,48 @@ char buff[200]; make_time_string( curr, buff, sizeof(buff), true ); - snprintf(CUR_AD, "Play time : %10s", buff); - snprintf(CUR_AD, "Turns : %10ld", you.num_turns ); + snprintf(buf, sizeof buf, + "Play time : %10s\n" + "Turns : %10ld\n", + buff, you.num_turns ); + cols.add_formatted(0, buf, true); } - lines = 24 + 1; + const int rfire = player_res_fire(calc_unid); + const int rcold = player_res_cold(calc_unid); + const int rlife = player_prot_life(calc_unid); + const int rpois = player_res_poison(calc_unid); + const int relec = player_res_electricity(calc_unid); - snprintf(CUR_AD, "Res.Fire : %s", - itosym3( player_res_fire(calc_unid) ) ); - snprintf(CUR_AD, "Res.Cold : %s", - itosym3( player_res_cold(calc_unid) ) ); - snprintf(CUR_AD, "Life Prot.: %s", - itosym3( player_prot_life(calc_unid) ) ); - snprintf(CUR_AD, "Res.Poison: %s", - itosym1( player_res_poison(calc_unid) ) ); - snprintf(CUR_AD, "Res.Elec. : %s", - itosym1( player_res_electricity(calc_unid) ) ); - lines++; - - snprintf(CUR_AD, "Sust.Abil.: %s", - itosym1( player_sust_abil(calc_unid) ) ); - snprintf(CUR_AD, "Res.Mut. : %s", - itosym1( wearing_amulet( AMU_RESIST_MUTATION, calc_unid) ) ); - snprintf(CUR_AD, "Res.Slow : %s", - itosym1( wearing_amulet( AMU_RESIST_SLOW, calc_unid) ) ); - snprintf(CUR_AD, "Clarity : %s", - itosym1( wearing_amulet( AMU_CLARITY, calc_unid) ) ); - lines++; - lines++; + snprintf(buf, sizeof buf, "\n\n" + "Res.Fire : %s%s\n" + "Res.Cold : %s%s\n" + "Life Prot.: %s%s\n" + "Res.Poison: %s%s\n" + "Res.Elec. : %s%s\n", + determine_color_string(rfire), itosym3(rfire), + determine_color_string(rcold), itosym3(rcold), + determine_color_string(rlife), itosym3(rlife), + determine_color_string(rpois), itosym1(rpois), + determine_color_string(relec), itosym1(relec)); + cols.add_formatted(1, buf, false); + const int rsust = player_sust_abil(calc_unid); + const int rmuta = wearing_amulet(AMU_RESIST_MUTATION, calc_unid); + const int rslow = wearing_amulet(AMU_RESIST_SLOW, calc_unid); + const int rclar = wearing_amulet(AMU_CLARITY, calc_unid); + + snprintf(buf, sizeof buf, + "Sust.Abil.: %s%s\n" + "Res.Mut. : %s%s\n" + "Res.Slow : %s%s\n" + "Clarity : %s%s\n \n", + determine_color_string(rsust), itosym1(rsust), + determine_color_string(rmuta), itosym1(rmuta), + determine_color_string(rslow), itosym1(rslow), + determine_color_string(rclar), itosym1(rclar)); + cols.add_formatted(1, buf, true); + { char str_pass[ITEMNAME_SIZE]; const int e_order[] = @@ -729,86 +776,116 @@ if ( you.equip[ e_order[i] ] != -1) { - in_name( you.equip[ e_order[i] ], DESC_PLAIN, - str_pass, true ); - snprintf(CUR_AD, "%-7s: %s", slot, str_pass); + const int inum = you.equip[e_order[i]]; + in_name( inum, DESC_PLAIN, str_pass, true ); + str_pass[38] = 0; // truncate + const char* colname = colour_to_str(you.inv[inum].colour); + snprintf(buf, sizeof buf, "%-7s: <%s>%s</%s>", + slot, colname, str_pass, colname); } else { if (e_order[i] == EQ_WEAPON) { if (you.attribute[ATTR_TRANSFORMATION] == TRAN_BLADE_HANDS) - snprintf(CUR_AD, "%-7s: Blade Hands", slot); + snprintf(buf, sizeof buf, "%-7s: Blade Hands", slot); else if (you.skills[SK_UNARMED_COMBAT]) - snprintf(CUR_AD, "%-7s: Unarmed", slot); + snprintf(buf, sizeof buf, "%-7s: Unarmed", slot); else - snprintf(CUR_AD, "%-7s:", slot); + snprintf(buf, sizeof buf, "%-7s:", slot); } else { - snprintf(CUR_AD, "%-7s:", slot); + snprintf(buf, sizeof buf, "%-7s:", slot); } } + cols.add_formatted(1, buf, false); } } - lines = 24 * 2 + 1; - snprintf(CUR_AD, "See Invis. : %s", - itosym1( player_see_invis(calc_unid) ) ); - snprintf(CUR_AD, "Warding : %s", - itosym1( wearing_amulet(AMU_WARDING, calc_unid) - || (you.religion == GOD_VEHUMET && - you.duration[DUR_PRAYER] && - !player_under_penance() && - you.piety >= 75) ) ); - snprintf(CUR_AD, "Conserve : %s", - itosym1( wearing_amulet( AMU_CONSERVATION, calc_unid) ) ); - snprintf(CUR_AD, "Res.Corr. : %s", - itosym1( wearing_amulet( AMU_RESIST_CORROSION, calc_unid) ) ); - - if ( !wearing_amulet( AMU_THE_GOURMAND, calc_unid) ) - { - switch (you.species) - { - case SP_GHOUL: - snprintf(CUR_AD, "Saprovore : %s", itosym3(3) ); - break; + const int rinvi = player_see_invis(calc_unid); + const int rward = wearing_amulet(AMU_WARDING, calc_unid) || + (you.religion == GOD_VEHUMET && you.duration[DUR_PRAYER] && + !player_under_penance() && you.piety >= 75); + const int rcons = wearing_amulet(AMU_CONSERVATION, calc_unid); + const int rcorr = wearing_amulet(AMU_RESIST_CORROSION, calc_unid); - case SP_KOBOLD: - case SP_TROLL: - snprintf(CUR_AD, "Saprovore : %s", itosym3(2) ); - break; + snprintf(buf, sizeof buf, "\n\n" + "See Invis. : %s%s\n" + "Warding : %s%s\n" + "Conserve : %s%s\n" + "Res.Corr. : %s%s\n", + determine_color_string(rinvi), itosym1(rinvi), + determine_color_string(rward), itosym1(rward), + determine_color_string(rcons), itosym1(rcons), + determine_color_string(rcorr), itosym1(rcorr)); + cols.add_formatted(2, buf, false); + + int saplevel = 0; + switch (you.species) + { + case SP_GHOUL: + saplevel = 3; + snprintf(buf, sizeof buf, "Saprovore : %s%s", + determine_color_string(3), itosym3(3) ); + break; - case SP_HILL_ORC: - case SP_OGRE: - snprintf(CUR_AD, "Saprovore : %s", itosym3(1) ); - break; + case SP_KOBOLD: + case SP_TROLL: + saplevel = 2; + snprintf(buf, sizeof buf, "Saprovore : %s%s", + determine_color_string(2), itosym3(2) ); + break; - default: - snprintf(CUR_AD, "Gourmand : %s", itosym1(0) ); - break; - } + case SP_HILL_ORC: + case SP_OGRE: + saplevel = 1; + break; + default: + saplevel = 0; + break; } + const char* pregourmand; + const char* postgourmand; + if ( wearing_amulet(AMU_THE_GOURMAND, calc_unid) ) + { + pregourmand = "Gourmand : "; + postgourmand = itosym1(1); + saplevel = 1; + } else { - snprintf(CUR_AD, "Gourmand : %s", - itosym1( wearing_amulet( AMU_THE_GOURMAND, calc_unid) ) ); + pregourmand = "Saprovore : "; + postgourmand = itosym3(saplevel); } - - lines++; + snprintf(buf, sizeof buf, "%s%s%s", pregourmand, + determine_color_string(saplevel), postgourmand); + cols.add_formatted(2, buf, false); + cols.add_formatted(2, " \n", false); + if ( scan_randarts(RAP_PREVENT_TELEPORTATION, calc_unid) ) - snprintf(CUR_AD, "Prev.Telep.: %s", - itosym1( scan_randarts(RAP_PREVENT_TELEPORTATION, calc_unid) ) ); + snprintf(buf, sizeof buf, "Prev.Telep.: %s%s", + determine_color_string(-1), itosym1(1)); else - snprintf(CUR_AD, "Rnd.Telep. : %s", - itosym1( player_teleport(calc_unid) ) ); - snprintf(CUR_AD, "Ctrl.Telep.: %s", - itosym1( player_control_teleport(calc_unid) ) ); - snprintf(CUR_AD, "Levitation : %s", itosym1( player_is_levitating() ) ); - snprintf(CUR_AD, "Ctrl.Flight: %s", - itosym1( wearing_amulet(AMU_CONTROLLED_FLIGHT, calc_unid) ) ); - lines++; + { + const int rrtel = player_teleport(calc_unid); + snprintf(buf, sizeof buf, "Rnd.Telep. : %s%s", + determine_color_string(rrtel), itosym1(rrtel)); + } + cols.add_formatted(2, buf, false); - return; + const int rctel = player_control_teleport(calc_unid); + const int rlevi = player_is_levitating(); + const int rcfli = wearing_amulet(AMU_CONTROLLED_FLIGHT, calc_unid); + snprintf(buf, sizeof buf, + "Ctrl.Telep.: %s%s\n" + "Levitation : %s%s\n" + "Ctrl.Flight: %s%s\n", + determine_color_string(rctel), itosym1(rctel), + determine_color_string(rlevi), itosym1(rlevi), + determine_color_string(rcfli), itosym1(rcfli)); + cols.add_formatted(2, buf, false); + + return cols.formatted_lines(); } Modified: trunk/crawl-ref/source/output.h =================================================================== --- trunk/crawl-ref/source/output.h 2006-11-29 13:21:50 UTC (rev 527) +++ trunk/crawl-ref/source/output.h 2006-11-29 18:12:52 UTC (rev 528) @@ -14,6 +14,8 @@ #ifndef OUTPUT_H #define OUTPUT_H +#include "menu.h" + // last updated 12may2000 {dlb} /* *********************************************************************** * called from: acr - player - stuff @@ -23,7 +25,7 @@ /* *********************************************************************** * called from: chardump * *********************************************************************** */ -void get_full_detail(char* buffer, bool calc_unid); +std::vector<formatted_string> get_full_detail(bool calc_unid); const char *equip_slot_to_name(int equip); Modified: trunk/crawl-ref/source/overmap.cc =================================================================== --- trunk/crawl-ref/source/overmap.cc 2006-11-29 13:21:50 UTC (rev 527) +++ trunk/crawl-ref/source/overmap.cc 2006-11-29 18:12:52 UTC (rev 528) @@ -127,7 +127,7 @@ BRANCH_HALL_OF_ZOT }; - disp += " <white>Overview of the Dungeon</white>" EOL; + disp += " <white>Overview of the Dungeon</white>\n" ; // print branches int branchcount = 0; @@ -138,7 +138,7 @@ { if ( !branchcount ) { - disp += EOL "<white>Branches:</white>" EOL; + disp += "\n<white>Branches:</white>\n"; seen_anything = true; } @@ -149,19 +149,19 @@ stair_level[branch].describe(false, true).c_str()); disp += buffer; if ( (branchcount % 4) == 0 ) - disp += EOL; + disp += "\n"; else disp += " "; } } if ( branchcount && (branchcount % 4) ) - disp += EOL; + disp += "\n"; // print altars // we loop through everything a dozen times, oh well if ( !altars_present.empty() ) { - disp += EOL "<white>Altars:</white>" EOL; + disp += "\n<white>Altars:</white>\n"; seen_anything = true; } @@ -201,13 +201,13 @@ } } if ( last_id.depth != 10000 ) - disp += EOL; + disp += "\n"; } // print shops if (!shops_present.empty()) { - disp += EOL "<white>Shops:</white>" EOL; + disp += "\n<white>Shops:</white>\n"; seen_anything = true; } last_id.depth = 10000; @@ -225,7 +225,7 @@ // the level name, plus 4 for the spacing; that makes // a total of 16 chars per shop or exactly 5 per line. if ( placecount % 5 == 0 ) - disp += EOL; + disp += "\n"; else disp += " "; } @@ -238,12 +238,12 @@ } disp += shoptype_to_char(ci_shops->second); } - disp += EOL; + disp += "\n"; // print portals if ( !portals_present.empty() ) { - disp += EOL "<white>Portals:</white>" EOL; + disp += "\n<white>Portals:</white>\n"; seen_anything = true; } for (int cur_portal = PORTAL_NONE; cur_portal < NUM_PORTALS; ++cur_portal) @@ -273,7 +273,7 @@ } } if ( last_id.depth != 10000 ) - disp += EOL; + disp += "\n"; } if (!seen_anything) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <ha...@us...> - 2006-11-30 09:48:26
|
Revision: 530 http://svn.sourceforge.net/crawl-ref/?rev=530&view=rev Author: haranp Date: 2006-11-30 01:48:24 -0800 (Thu, 30 Nov 2006) Log Message: ----------- Noted and hooked god mollification. Modified Paths: -------------- trunk/crawl-ref/source/notes.cc trunk/crawl-ref/source/notes.h trunk/crawl-ref/source/religion.cc Modified: trunk/crawl-ref/source/notes.cc =================================================================== --- trunk/crawl-ref/source/notes.cc 2006-11-30 08:34:37 UTC (rev 529) +++ trunk/crawl-ref/source/notes.cc 2006-11-30 09:48:24 UTC (rev 530) @@ -138,9 +138,10 @@ note.type == NOTE_POLY_MONSTER || note.type == NOTE_USER_NOTE || note.type == NOTE_MESSAGE || - note.type == NOTE_LOSE_GOD ) + note.type == NOTE_LOSE_GOD || + note.type == NOTE_MOLLIFY_GOD ) return true; - + /* never noteworthy, hooked up for fun or future use */ if ( note.type == NOTE_GET_ITEM || note.type == NOTE_MP_CHANGE || @@ -284,6 +285,10 @@ snprintf(buf, sizeof buf, "Fell from the grace of %s", god_name(first)); break; + case NOTE_MOLLIFY_GOD: + snprintf(buf, sizeof buf, "Was forgiven by %s", + god_name(first)); + break; case NOTE_GOD_GIFT: snprintf(buf, sizeof buf, "Received a gift from %s", god_name(first)); Modified: trunk/crawl-ref/source/notes.h =================================================================== --- trunk/crawl-ref/source/notes.h 2006-11-30 08:34:37 UTC (rev 529) +++ trunk/crawl-ref/source/notes.h 2006-11-30 09:48:24 UTC (rev 530) @@ -29,15 +29,15 @@ NOTE_GET_MUTATION, /* needs: mutation idx */ NOTE_LOSE_MUTATION, /* needs: mutation idx */ NOTE_ID_ITEM, /* needs: item name (string) */ - /* NOT HOOKED YET */ - NOTE_GET_ITEM, /* needs: item name (string) */ + NOTE_GET_ITEM, /* needs: item name (string) NOT HOOKED */ NOTE_GAIN_SKILL, /* needs: skill id, level */ NOTE_SEEN_MONSTER, /* needs: monster name (string) */ NOTE_KILL_MONSTER, /* needs: monster name (string) */ NOTE_POLY_MONSTER, /* needs: monster name (string) */ NOTE_USER_NOTE, /* needs: description string */ - NOTE_MESSAGE, /* needs: message string */ + NOTE_MESSAGE, /* needs: message string */ NOTE_LOSE_GOD, /* needs: god id */ + NOTE_MOLLIFY_GOD, /* needs: god id */ NOTE_NUM_TYPES }; Modified: trunk/crawl-ref/source/religion.cc =================================================================== --- trunk/crawl-ref/source/religion.cc 2006-11-30 08:34:37 UTC (rev 529) +++ trunk/crawl-ref/source/religion.cc 2006-11-30 09:48:24 UTC (rev 530) @@ -91,6 +91,7 @@ if (you.penance[god] <= val) { simple_god_message(" seems mollified.", god); + take_note(Note(NOTE_MOLLIFY_GOD, god)); you.penance[god] = 0; } else This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <dsh...@us...> - 2006-11-30 10:38:04
|
Revision: 531 http://svn.sourceforge.net/crawl-ref/?rev=531&view=rev Author: dshaligram Date: 2006-11-30 02:38:01 -0800 (Thu, 30 Nov 2006) Log Message: ----------- [1605400] Fixed inability to wield stuff when carrying no weapons. Modified Paths: -------------- trunk/crawl-ref/source/invent.cc trunk/crawl-ref/source/item_use.cc trunk/crawl-ref/source/menu.cc Modified: trunk/crawl-ref/source/invent.cc =================================================================== --- trunk/crawl-ref/source/invent.cc 2006-11-30 09:48:24 UTC (rev 530) +++ trunk/crawl-ref/source/invent.cc 2006-11-30 10:38:01 UTC (rev 531) @@ -362,9 +362,6 @@ unsigned char InvMenu::getkey() const { unsigned char mkey = lastch; - // Fake an ESCAPE if the menu is empty. - if (!item_count()) - mkey = ESCAPE; if (!isalnum(mkey) && mkey != '$' && mkey != '-' && mkey != '?' && mkey != '*' && mkey != ESCAPE) mkey = ' '; Modified: trunk/crawl-ref/source/item_use.cc =================================================================== --- trunk/crawl-ref/source/item_use.cc 2006-11-30 09:48:24 UTC (rev 530) +++ trunk/crawl-ref/source/item_use.cc 2006-11-30 10:38:01 UTC (rev 531) @@ -177,7 +177,8 @@ return (false); } - // Any general reasons why we can't wield a new object? + // Look for conditions like berserking that could prevent wielding + // weapons. if (!can_wield(NULL, true)) return (false); @@ -201,8 +202,8 @@ && you.inv[item_slot].base_type != OBJ_MISSILES && you.inv[item_slot].base_type != OBJ_STAVES; - // Prompt if not using the auto swap command, - // or if the swap slot is empty. + // Prompt if not using the auto swap command, or if the swap slot + // is empty. if (!auto_wield || !is_valid_item(you.inv[item_slot]) || force_unwield) { if (!auto_wield) Modified: trunk/crawl-ref/source/menu.cc =================================================================== --- trunk/crawl-ref/source/menu.cc 2006-11-30 09:48:24 UTC (rev 530) +++ trunk/crawl-ref/source/menu.cc 2006-11-30 10:38:01 UTC (rev 531) @@ -155,8 +155,11 @@ bool Menu::process_key( int keyin ) { if (items.size() == 0) + { + lastch = keyin; return false; - + } + bool nav = false, repaint = false; if (f_keyfilter) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |