forked from github/server
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:
parent
6d4f05fad8
commit
1e6a83f357
|
@ -59,11 +59,13 @@ static int report_json(const char *filename, report_context * ctx, const char *c
|
||||||
if (sr) {
|
if (sr) {
|
||||||
terrain_t ter = oldterrain(r->terrain);
|
terrain_t ter = oldterrain(r->terrain);
|
||||||
if (ter == NOTERRAIN) {
|
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);
|
fprintf(F, "%d", data);
|
||||||
if (x != maxx || y != maxy) fputs(", ", F);
|
if (x != maxx || y != maxy) fputs(", ", F);
|
||||||
}
|
}
|
||||||
|
|
|
@ -115,7 +115,9 @@ char* get_command(const order *ord, char *sbuffer, size_t size) {
|
||||||
assert(str);
|
assert(str);
|
||||||
if (text) --size;
|
if (text) --size;
|
||||||
bytes = (int)strlcpy(bufp, str, 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++ = ' ';
|
if (text) *bufp++ = ' ';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -127,8 +127,7 @@ const struct terrain_type *newterrain(terrain_t t)
|
||||||
terrain_t oldterrain(const struct terrain_type * terrain)
|
terrain_t oldterrain(const struct terrain_type * terrain)
|
||||||
{
|
{
|
||||||
terrain_t t;
|
terrain_t t;
|
||||||
if (terrain == NULL)
|
assert(terrain);
|
||||||
return NOTERRAIN;
|
|
||||||
for (t = 0; t != MAXTERRAINS; ++t) {
|
for (t = 0; t != MAXTERRAINS; ++t) {
|
||||||
if (newterrains[t] == terrain)
|
if (newterrains[t] == terrain)
|
||||||
return t;
|
return t;
|
||||||
|
|
|
@ -2291,7 +2291,7 @@ static void eval_race(struct opstack **stack, const void *userdata)
|
||||||
static void eval_order(struct opstack **stack, const void *userdata)
|
static void eval_order(struct opstack **stack, const void *userdata)
|
||||||
{ /* order -> string */
|
{ /* order -> string */
|
||||||
const struct order *ord = (const struct order *)opop(stack).v;
|
const struct order *ord = (const struct order *)opop(stack).v;
|
||||||
char buf[512];
|
char buf[4096];
|
||||||
size_t len;
|
size_t len;
|
||||||
variant var;
|
variant var;
|
||||||
|
|
||||||
|
|
|
@ -222,7 +222,7 @@ bool report, int *academy)
|
||||||
teach->teachers[index] = NULL;
|
teach->teachers[index] = NULL;
|
||||||
}
|
}
|
||||||
else {
|
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;
|
teach->value += n;
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ extern "C" {
|
||||||
extern bool is_migrant(struct unit *u);
|
extern bool is_migrant(struct unit *u);
|
||||||
extern int study_cost(struct unit *u, skill_t talent);
|
extern int study_cost(struct unit *u, skill_t talent);
|
||||||
|
|
||||||
#define MAXTEACHERS 16
|
#define MAXTEACHERS 20
|
||||||
typedef struct teaching_info {
|
typedef struct teaching_info {
|
||||||
struct unit *teachers[MAXTEACHERS];
|
struct unit *teachers[MAXTEACHERS];
|
||||||
int value;
|
int value;
|
||||||
|
|
Loading…
Reference in New Issue