summaryrefslogtreecommitdiffstats
path: root/crawl-ref
diff options
context:
space:
mode:
authorharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2009-06-10 22:15:27 +0000
committerharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2009-06-10 22:15:27 +0000
commit8139324f50a0685218d606c7e89e44f3c3ab9da8 (patch)
treea58ee0b8c2c72abb97ead0c9c4ee43dd10c07010 /crawl-ref
parent677bb30a8e6bc99e66955e829329dba3f217e535 (diff)
downloadcrawl-ref-8139324f50a0685218d606c7e89e44f3c3ab9da8.tar.gz
crawl-ref-8139324f50a0685218d606c7e89e44f3c3ab9da8.zip
Fix 2800089: the standard does not guarantee that you can convert
from integer types to pointers and back. While we're at it, fix an older bug which might trigger if we ever have a platform where different pointer types have different sizes. Technically the standard does not guarantee (I think) that this isn't the case. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@9947 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref')
-rw-r--r--crawl-ref/source/abl-show.cc8
-rw-r--r--crawl-ref/source/spl-book.cc4
2 files changed, 6 insertions, 6 deletions
diff --git a/crawl-ref/source/abl-show.cc b/crawl-ref/source/abl-show.cc
index 30d4e972b5..c811679bef 100644
--- a/crawl-ref/source/abl-show.cc
+++ b/crawl-ref/source/abl-show.cc
@@ -1985,7 +1985,7 @@ int choose_ability_menu(const std::vector<talent>& talents)
{
MenuEntry* me = new MenuEntry(_describe_talent(talents[i]),
MEL_ITEM, 1, talents[i].hotkey);
- me->data = reinterpret_cast<void*>(numbers+i);
+ me->data = &numbers[i];
abil_menu.add_entry(me);
}
}
@@ -1999,7 +1999,7 @@ int choose_ability_menu(const std::vector<talent>& talents)
{
MenuEntry* me = new MenuEntry(_describe_talent(talents[i]),
MEL_ITEM, 1, talents[i].hotkey);
- me->data = reinterpret_cast<void*>(numbers+i);
+ me->data = &numbers[i];
abil_menu.add_entry(me);
}
}
@@ -2015,12 +2015,12 @@ int choose_ability_menu(const std::vector<talent>& talents)
ASSERT(sel.size() == 1);
ASSERT(sel[0]->hotkeys.size() == 1);
- int selected = *(reinterpret_cast<int*>(sel[0]->data));
+ int selected = *(static_cast<int*>(sel[0]->data));
if (abil_menu.menu_action == Menu::ACT_EXAMINE)
_print_talent_description(talents[selected]);
else
- return (*(reinterpret_cast<int*>(sel[0]->data)));
+ return (*(static_cast<int*>(sel[0]->data)));
}
}
diff --git a/crawl-ref/source/spl-book.cc b/crawl-ref/source/spl-book.cc
index c400cbf099..bf83e90f73 100644
--- a/crawl-ref/source/spl-book.cc
+++ b/crawl-ref/source/spl-book.cc
@@ -1523,7 +1523,7 @@ static spell_type _choose_mem_spell(spell_list &spells,
MenuEntry* me = new MenuEntry(desc.str(), MEL_ITEM, 1,
index_to_letter(i % 52));
- me->data = (void*) i;
+ me->data = &spells[i];
spell_menu.add_entry(me);
}
@@ -1539,7 +1539,7 @@ static spell_type _choose_mem_spell(spell_list &spells,
ASSERT(sel.size() == 1);
- const spell_type spell = spells[(int) sel[0]->data];
+ const spell_type spell = *static_cast<spell_type*>(sel[0]->data);
ASSERT(is_valid_spell(spell));
return (spell);