resize buffer in eval_command, it was too small for many commands.

increase MAXTEACHERS.
eliminate oldterrain warning in json_report.
This commit is contained in:
Enno Rehling 2015-08-06 16:52:24 +02:00
parent 6d4f05fad8
commit 1e6a83f357
6 changed files with 11 additions and 8 deletions

View File

@ -59,9 +59,11 @@ static int report_json(const char *filename, report_context * ctx, const char *c
if (sr) {
terrain_t ter = oldterrain(r->terrain);
if (ter == NOTERRAIN) {
log_warning("report_json: %s has no terrain id\n", r->terrain->_name);
data = 1 + r->terrain->_name[0];
}
else {
data = 1 + (int)ter;
}
data = 1 + (int)ter;
}
}
fprintf(F, "%d", data);

View File

@ -115,7 +115,9 @@ char* get_command(const order *ord, char *sbuffer, size_t size) {
assert(str);
if (text) --size;
bytes = (int)strlcpy(bufp, str, size);
if (wrptr(&bufp, &size, bytes) != 0) WARN_STATIC_BUFFER();
if (wrptr(&bufp, &size, bytes) != 0) {
WARN_STATIC_BUFFER();
}
if (text) *bufp++ = ' ';
}
else {

View File

@ -127,8 +127,7 @@ const struct terrain_type *newterrain(terrain_t t)
terrain_t oldterrain(const struct terrain_type * terrain)
{
terrain_t t;
if (terrain == NULL)
return NOTERRAIN;
assert(terrain);
for (t = 0; t != MAXTERRAINS; ++t) {
if (newterrains[t] == terrain)
return t;

View File

@ -2291,7 +2291,7 @@ static void eval_race(struct opstack **stack, const void *userdata)
static void eval_order(struct opstack **stack, const void *userdata)
{ /* order -> string */
const struct order *ord = (const struct order *)opop(stack).v;
char buf[512];
char buf[4096];
size_t len;
variant var;

View File

@ -222,7 +222,7 @@ bool report, int *academy)
teach->teachers[index] = NULL;
}
else {
log_warning("MAXTEACHERS is too low at %d", MAXTEACHERS);
log_error("MAXTEACHERS=%d is too low for student %s, teacher %s", MAXTEACHERS, unitname(student), unitname(teacher));
}
teach->value += n;

View File

@ -33,7 +33,7 @@ extern "C" {
extern bool is_migrant(struct unit *u);
extern int study_cost(struct unit *u, skill_t talent);
#define MAXTEACHERS 16
#define MAXTEACHERS 20
typedef struct teaching_info {
struct unit *teachers[MAXTEACHERS];
int value;