forked from github/server
move bsdstring use to reports.c
This commit is contained in:
parent
6a9320a0d0
commit
0170a6fc09
3 changed files with 41 additions and 36 deletions
|
@ -2195,6 +2195,42 @@ static void eval_trail(struct opstack **stack, const void *userdata)
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void report_race_skills(const race *rc, char *zText, size_t length, const struct locale *lang)
|
||||||
|
{
|
||||||
|
size_t size = length - 1;
|
||||||
|
int dh = 0, dh1 = 0, sk;
|
||||||
|
char *bufp = zText;
|
||||||
|
|
||||||
|
for (sk = 0; sk < MAXSKILLS; ++sk) {
|
||||||
|
if (skill_enabled(sk) && rc->bonus[sk] > -5)
|
||||||
|
dh++;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (sk = 0; sk < MAXSKILLS; sk++) {
|
||||||
|
if (skill_enabled(sk) && rc->bonus[sk] > -5) {
|
||||||
|
size_t bytes;
|
||||||
|
dh--;
|
||||||
|
if (dh1 == 0) {
|
||||||
|
dh1 = 1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (dh == 0) {
|
||||||
|
bytes = str_strlcpy(bufp, LOC(lang, "list_and"), size);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
bytes = str_strlcpy(bufp, ", ", size);
|
||||||
|
}
|
||||||
|
assert(bytes <= INT_MAX);
|
||||||
|
BUFFER_STRCAT(bufp, size, bytes);
|
||||||
|
}
|
||||||
|
bytes = str_strlcpy(bufp, skillname((skill_t)sk, lang),
|
||||||
|
size);
|
||||||
|
assert(bytes <= INT_MAX);
|
||||||
|
BUFFER_STRCAT(bufp, size, (int)bytes);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void eval_direction(struct opstack **stack, const void *userdata)
|
static void eval_direction(struct opstack **stack, const void *userdata)
|
||||||
{
|
{
|
||||||
const faction *report = (const faction *)userdata;
|
const faction *report = (const faction *)userdata;
|
||||||
|
|
|
@ -120,6 +120,7 @@ extern "C" {
|
||||||
int report_items(const struct unit *u, struct item *result, int size,
|
int report_items(const struct unit *u, struct item *result, int size,
|
||||||
const struct unit *owner, const struct faction *viewer);
|
const struct unit *owner, const struct faction *viewer);
|
||||||
void report_warnings(struct faction *f, const struct gamedate *date);
|
void report_warnings(struct faction *f, const struct gamedate *date);
|
||||||
|
void report_race_skills(const struct race *rc, char *zText, size_t length, const struct locale *lang);
|
||||||
void report_item(const struct unit *owner, const struct item *i,
|
void report_item(const struct unit *owner, const struct item *i,
|
||||||
const struct faction *viewer, const char **name, const char **basename,
|
const struct faction *viewer, const char **name, const char **basename,
|
||||||
int *number, bool singular);
|
int *number, bool singular);
|
||||||
|
|
40
src/spells.c
40
src/spells.c
|
@ -18,6 +18,7 @@
|
||||||
#include "spells.h"
|
#include "spells.h"
|
||||||
|
|
||||||
#include "guard.h"
|
#include "guard.h"
|
||||||
|
#include "reports.h"
|
||||||
#include "spy.h"
|
#include "spy.h"
|
||||||
#include "vortex.h"
|
#include "vortex.h"
|
||||||
#include "laws.h"
|
#include "laws.h"
|
||||||
|
@ -72,7 +73,6 @@
|
||||||
#include <util/assert.h>
|
#include <util/assert.h>
|
||||||
#include <util/attrib.h>
|
#include <util/attrib.h>
|
||||||
#include <util/base36.h>
|
#include <util/base36.h>
|
||||||
#include <util/bsdstring.h>
|
|
||||||
#include <util/event.h>
|
#include <util/event.h>
|
||||||
#include <util/gamedata.h>
|
#include <util/gamedata.h>
|
||||||
#include <util/language.h>
|
#include <util/language.h>
|
||||||
|
@ -537,11 +537,9 @@ static int sp_summon_familiar(castorder * co)
|
||||||
unit *mage = co->magician.u;
|
unit *mage = co->magician.u;
|
||||||
int cast_level = co->level;
|
int cast_level = co->level;
|
||||||
const race *rc;
|
const race *rc;
|
||||||
int sk;
|
int dh;
|
||||||
int dh, dh1;
|
|
||||||
message *msg;
|
message *msg;
|
||||||
char zText[2048], *bufp = zText;
|
char zText[2048];
|
||||||
size_t size = sizeof(zText) - 1;
|
|
||||||
|
|
||||||
if (get_familiar(mage) != NULL) {
|
if (get_familiar(mage) != NULL) {
|
||||||
cmistake(mage, co->order, 199, MSG_MAGIC);
|
cmistake(mage, co->order, 199, MSG_MAGIC);
|
||||||
|
@ -581,37 +579,7 @@ static int sp_summon_familiar(castorder * co)
|
||||||
msg_release(msg);
|
msg_release(msg);
|
||||||
make_familiar(mage, r, rc, zText);
|
make_familiar(mage, r, rc, zText);
|
||||||
|
|
||||||
dh = 0;
|
report_race_skills(rc, zText, sizeof(zText), mage->faction->locale);
|
||||||
dh1 = 0;
|
|
||||||
for (sk = 0; sk < MAXSKILLS; ++sk) {
|
|
||||||
if (skill_enabled(sk) && rc->bonus[sk] > -5)
|
|
||||||
dh++;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (sk = 0; sk < MAXSKILLS; sk++) {
|
|
||||||
if (skill_enabled(sk) && rc->bonus[sk] > -5) {
|
|
||||||
size_t bytes;
|
|
||||||
dh--;
|
|
||||||
if (dh1 == 0) {
|
|
||||||
dh1 = 1;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (dh == 0) {
|
|
||||||
bytes = str_strlcpy(bufp, LOC(mage->faction->locale,
|
|
||||||
"list_and"), size);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
bytes = str_strlcpy(bufp, ", ", size);
|
|
||||||
}
|
|
||||||
assert(bytes <= INT_MAX);
|
|
||||||
BUFFER_STRCAT(bufp, size, bytes);
|
|
||||||
}
|
|
||||||
bytes = str_strlcpy(bufp, skillname((skill_t)sk, mage->faction->locale),
|
|
||||||
size);
|
|
||||||
assert(bytes <= INT_MAX);
|
|
||||||
BUFFER_STRCAT(bufp, size, (int)bytes);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ADDMSG(&mage->faction->msgs, msg_message("familiar_describe",
|
ADDMSG(&mage->faction->msgs, msg_message("familiar_describe",
|
||||||
"mage race skills", mage, rc, zText));
|
"mage race skills", mage, rc, zText));
|
||||||
return cast_level;
|
return cast_level;
|
||||||
|
|
Loading…
Reference in a new issue