diff options
author | dshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573> | 2007-10-05 15:29:57 +0000 |
---|---|---|
committer | dshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573> | 2007-10-05 15:29:57 +0000 |
commit | db56e78ea41788ac69fa01e96d50f3ed611c3156 (patch) | |
tree | 09762f489c4a757c4bfda13dff5299e6a91a971e | |
parent | f3df3a8e5880f1f64c4fc67b64cbd0b965f03bb5 (diff) | |
download | crawl-ref-db56e78ea41788ac69fa01e96d50f3ed611c3156.tar.gz crawl-ref-db56e78ea41788ac69fa01e96d50f3ed611c3156.zip |
Fixed &Z segfault, and Lua compile flakiness for 0.3.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/branches/stone_soup-0.3@2336 c06c8d41-db1a-0410-9941-cceddc491573
-rw-r--r-- | crawl-ref/source/debug.cc | 21 | ||||
-rw-r--r-- | crawl-ref/source/makefile.unix | 3 | ||||
-rw-r--r-- | crawl-ref/source/spl-util.cc | 29 | ||||
-rw-r--r-- | crawl-ref/source/spl-util.h | 2 |
4 files changed, 30 insertions, 25 deletions
diff --git a/crawl-ref/source/debug.cc b/crawl-ref/source/debug.cc index 68de23496a..8c26fa8ae4 100644 --- a/crawl-ref/source/debug.cc +++ b/crawl-ref/source/debug.cc @@ -344,26 +344,17 @@ void cast_spec_spell(void) void cast_spec_spell_name(void) { char specs[80]; - char spname[80]; - mpr( "Cast which spell by name? ", MSGCH_PROMPT ); get_input_line( specs, sizeof( specs ) ); - for (int i = 0; i < NUM_SPELLS; i++) + spell_type type = spell_by_name(specs); + if (type == SPELL_NO_SPELL) { - strncpy( spname, - spell_title(static_cast<spell_type>(i)), - sizeof( spname ) ); - - if (strstr( strlwr(spname), strlwr(specs) ) != NULL) - { - your_spells(static_cast<spell_type>(i), 0, false); - return; - } + mpr((one_chance_in(20)) ? "Maybe you should go back to WIZARD school." + : "I couldn't find that spell."); + return; } - - mpr((one_chance_in(20)) ? "Maybe you should go back to WIZARD school." - : "I couldn't find that spell."); + your_spells(type, 0, false); } #endif diff --git a/crawl-ref/source/makefile.unix b/crawl-ref/source/makefile.unix index 1df5f96ba7..88ad4ed4eb 100644 --- a/crawl-ref/source/makefile.unix +++ b/crawl-ref/source/makefile.unix @@ -74,10 +74,7 @@ INCLUDES = -I/usr/include/ncurses LIBCURS = ncurses endif -ifeq ($(LUASRC),) LUASRC := util/lua/src -endif - LUALIB = lua LUALIBA = l$(LUALIB).a diff --git a/crawl-ref/source/spl-util.cc b/crawl-ref/source/spl-util.cc index ee09d5b374..71b773ac83 100644 --- a/crawl-ref/source/spl-util.cc +++ b/crawl-ref/source/spl-util.cc @@ -73,15 +73,28 @@ void init_spell_descs(void) // which corrupts the heap. for (unsigned int i = 0; i < SPELLDATASIZE - 1; i++) spell_list[spelldata[i].id] = i; +} // end init_spell_descs() + +spell_type spell_by_name(std::string name) +{ + if (name.empty()) + return (SPELL_NO_SPELL); + lowercase(name); + for (int i = 0; i < NUM_SPELLS; i++) { - if (spell_list[i] == -1) - spell_list[i] = spell_list[SPELL_NO_SPELL]; + spell_type type = static_cast<spell_type>(i); + const char *sptitle = spell_title(type); + if (!sptitle) + continue; + + if (name == lowercase_string(sptitle)) + return (type); } - return; -} // end init_spell_descs() + return (SPELL_NO_SPELL); +} int get_spell_slot_by_letter( char letter ) { @@ -254,7 +267,8 @@ int count_bits(unsigned int bits) const char *spell_title(spell_type spell) { - return (seekspell(spell)->title); + const spell_desc *spd = seekspell(spell); + return (spd? spd->title : NULL); } @@ -809,9 +823,10 @@ int spell_type2skill(unsigned int spelltype) */ //jmf: simplified; moved init code to top function, init_spell_descs() -static struct spell_desc *seekspell(spell_type spell) +static spell_desc *seekspell(spell_type spell) { - return (&spelldata[spell_list[spell]]); + const int index = spell_list[spell]; + return (index != -1? &spelldata[index] : NULL); } static bool cloud_helper(int (*func)(int, int, int, cloud_type, kill_category), diff --git a/crawl-ref/source/spl-util.h b/crawl-ref/source/spl-util.h index a29feb3a73..10428fbc3e 100644 --- a/crawl-ref/source/spl-util.h +++ b/crawl-ref/source/spl-util.h @@ -64,6 +64,8 @@ struct spell_desc //* * called from: acr void init_spell_descs(void); +spell_type spell_by_name(std::string name); + int get_spell_slot_by_letter( char letter ); spell_type get_spell_by_letter( char letter ); |