espionage messages will now report spellbooks

This commit is contained in:
Enno Rehling 2012-05-25 23:01:21 -07:00
parent 303dd7cc94
commit bc95ea80fb
2 changed files with 25 additions and 24 deletions

View File

@ -38,7 +38,6 @@ without prior permission by the authors of Eressea.
#include <kernel/faction.h> #include <kernel/faction.h>
#include <kernel/group.h> #include <kernel/group.h>
#include <kernel/item.h> #include <kernel/item.h>
#include <kernel/magic.h>
#include <kernel/message.h> #include <kernel/message.h>
#include <kernel/move.h> #include <kernel/move.h>
#include <kernel/order.h> #include <kernel/order.h>

View File

@ -28,7 +28,6 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <kernel/faction.h> #include <kernel/faction.h>
#include <kernel/group.h> #include <kernel/group.h>
#include <kernel/item.h> #include <kernel/item.h>
#include <kernel/magic.h>
#include <kernel/message.h> #include <kernel/message.h>
#include <kernel/move.h> #include <kernel/move.h>
#include <kernel/order.h> #include <kernel/order.h>
@ -38,6 +37,8 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <kernel/resources.h> #include <kernel/resources.h>
#include <kernel/ship.h> #include <kernel/ship.h>
#include <kernel/skill.h> #include <kernel/skill.h>
#include <kernel/spell.h>
#include <kernel/spellbook.h>
#include <kernel/terrain.h> #include <kernel/terrain.h>
#include <kernel/unit.h> #include <kernel/unit.h>
@ -700,32 +701,33 @@ bufunit(const faction * f, const unit * u, int indent, int mode, char *buf,
} }
if (u->faction == f || telepath_see) { if (u->faction == f || telepath_see) {
sc_mage *m = get_mage(u); spellbook *book = unit_get_spellbook(u);
if (m != NULL) { if (book) {
quicklist *ql = m->spells; quicklist *ql = book->spells;
int qi, t = effskill(u, SK_MAGIC); int qi, header, maxlevel = effskill(u, SK_MAGIC);
int bytes = int bytes = snprintf(bufp, size, ". Aura %d/%d", get_spellpoints(u), max_spellpoints(u->region, u));
snprintf(bufp, size, ". Aura %d/%d", get_spellpoints(u), if (bytes < 0 || wrptr(&bufp, &size, bytes) != 0) {
max_spellpoints(u->region, u));
if (bytes < 0 || wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER(); WARN_STATIC_BUFFER();
}
for (dh = 0, qi = 0; ql; ql_advance(&ql, &qi, 1)) { for (header = 0, qi = 0; ql; ql_advance(&ql, &qi, 1)) {
spell *sp = (spell *) ql_get(ql, qi); spellbook_entry * sbe = (spellbook_entry *) ql_get(ql, qi);
if (sp->level > t) if (sbe->level <= maxlevel) {
continue; if (!header) {
if (!dh) { bytes = snprintf(bufp, size, ", %s: ", LOC(f->locale, "nr_spells"));
bytes = snprintf(bufp, size, ", %s: ", LOC(f->locale, "nr_spells")); header = 1;
dh = 1; } else {
} else { bytes = (int)strlcpy(bufp, ", ", size);
bytes = (int)strlcpy(bufp, ", ", size); }
if (bytes < 0 || wrptr(&bufp, &size, bytes) != 0) {
WARN_STATIC_BUFFER();
}
bytes = (int)strlcpy(bufp, spell_name(sbe->sp, f->locale), size);
if (bytes < 0 || wrptr(&bufp, &size, bytes) != 0) {
WARN_STATIC_BUFFER();
}
} }
if (bytes < 0 || wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER();
bytes = (int)strlcpy(bufp, spell_name(sp, f->locale), size);
if (bytes < 0 || wrptr(&bufp, &size, bytes) != 0)
WARN_STATIC_BUFFER();
} }
for (i = 0; i != MAXCOMBATSPELLS; ++i) { for (i = 0; i != MAXCOMBATSPELLS; ++i) {