summaryrefslogtreecommitdiff
path: root/src/spells6.cc
diff options
context:
space:
mode:
authorBardur Arantsson <bardur@scientician.net>2015-02-23 09:11:55 +0100
committerBardur Arantsson <bardur@scientician.net>2015-02-23 09:11:55 +0100
commit2875e4c17679a4b3297e7a0ee51447432d7d8d83 (patch)
tree5ef45bb66bc388405d4e2a4f7847539185b8ef8e /src/spells6.cc
parente6788d465e047d9492d45f1d4620a772384ba2ef (diff)
Fix bug related to God spellbooks
Diffstat (limited to 'src/spells6.cc')
-rw-r--r--src/spells6.cc9
1 files changed, 5 insertions, 4 deletions
diff --git a/src/spells6.cc b/src/spells6.cc
index ceb9b050..b1db90d0 100644
--- a/src/spells6.cc
+++ b/src/spells6.cc
@@ -3,6 +3,7 @@
#include "spell_type.hpp"
#include <vector>
+#include <type_traits>
struct school_provider
{
@@ -42,8 +43,10 @@ static void school_init(school_type *school, cptr name, s16b skill)
{
assert(school != NULL);
+ static_assert(std::is_pod<school_type>::value, "Cannot initialize non-POD using memset!");
memset(school, 0, sizeof(school_type));
+ school->providers = new school_provider_list();
school->name = name;
school->skill = skill;
@@ -97,16 +100,14 @@ static school_type *god_school_new(s32b *school_idx, byte god)
static void school_god(school_type *school, byte god, int mul, int div)
{
+ assert(school->providers != nullptr);
+
deity_type *deity = god_at(god);
assert(deity != NULL);
/* Ignore gods which aren't enabled for this module. */
if (god_enabled(deity))
{
- if (school->providers == NULL) {
- school->providers = new school_provider_list();
- }
-
school->providers->v.push_back(school_provider_new(god, mul, div));
}
}