"FOLGEnde Einheiten reiten, können aber nicht folgen"
- fixed a bug in reporting travelthru that was caused by that fix
Issue: 1438
This commit is contained in:
Enno Rehling 2008-06-04 16:18:53 +00:00
parent 310fa1e3f2
commit a5d17f6c24
3 changed files with 33 additions and 28 deletions

View file

@ -38,6 +38,7 @@
#include "race.h" #include "race.h"
#include "region.h" #include "region.h"
#include "render.h" #include "render.h"
#include "reports.h"
#include "save.h" #include "save.h"
#include "ship.h" #include "ship.h"
#include "skill.h" #include "skill.h"
@ -1325,6 +1326,25 @@ enum {
TRAVEL_RUNNING TRAVEL_RUNNING
}; };
static arg_regions *
var_copy_regions(const region_list * begin, int size)
{
const region_list * rsrc;
if (size>0) {
int i = 0;
arg_regions * dst = (arg_regions *)malloc(sizeof(arg_regions) + sizeof(region*) * size);
dst->nregions = size;
dst->regions = (region**)(dst+1);
for (rsrc = begin; i!=size; rsrc=rsrc->next) {
dst->regions[i++] = rsrc->data;
}
return dst;
}
return NULL;
}
static const region_list * static const region_list *
travel_route(unit * u, const region_list * route_begin, const region_list * route_end, order * ord, int mode) travel_route(unit * u, const region_list * route_begin, const region_list * route_end, order * ord, int mode)
{ {
@ -1469,8 +1489,9 @@ travel_route(unit * u, const region_list * route_begin, const region_list * rout
/* Berichte über Durchreiseregionen */ /* Berichte über Durchreiseregionen */
if (mode!=TRAVEL_TRANSPORTED) { if (mode!=TRAVEL_TRANSPORTED) {
arg_regions * ar = var_copy_regions(route_begin, steps-1);
ADDMSG(&u->faction->msgs, msg_message("travel", ADDMSG(&u->faction->msgs, msg_message("travel",
"unit mode start end regions", u, walkmode, r, current, route_begin->next?route_begin:NULL)); "unit mode start end regions", u, walkmode, r, current, ar));
} }
mark_travelthru(u, r, route_begin, iroute); mark_travelthru(u, r, route_begin, iroute);

View file

@ -1432,31 +1432,6 @@ var_free_resources(variant x)
x.v = 0; x.v = 0;
} }
static variant
var_copy_regions(variant x)
{
region_list * rsrc;
int size = 0;
for (rsrc = (region_list*)x.v; rsrc!=NULL; rsrc=rsrc->next) {
++size;
}
if (size>0) {
arg_regions * dst = (arg_regions *)malloc(sizeof(arg_regions) + sizeof(region*) * size);
dst->nregions = size;
dst->regions = (region**)(dst+1);
size = 0;
for (rsrc = (region_list*)x.v; rsrc!=NULL; rsrc=rsrc->next) {
dst->regions[size++] = rsrc->data;
}
x.v = dst;
} else {
x.v = NULL;
}
return x;
}
static void static void
var_free_regions(variant x) var_free_regions(variant x)
{ {
@ -1844,6 +1819,10 @@ eval_trail(struct opstack ** stack, const void * userdata) /* order -> string */
size_t size = sizeof(buf) - 1; size_t size = sizeof(buf) - 1;
variant var; variant var;
char * bufp = buf; char * bufp = buf;
#ifdef _SECURECRT_ERRCODE_VALUES_DEFINED
/* stupid MS broke snprintf */
int eold = errno;
#endif
if (regions!=NULL) { if (regions!=NULL) {
end = regions->nregions-1; end = regions->nregions-1;
@ -1866,6 +1845,11 @@ eval_trail(struct opstack ** stack, const void * userdata) /* order -> string */
*bufp = 0; *bufp = 0;
var.v = strcpy(balloc(bufp-buf+1), buf); var.v = strcpy(balloc(bufp-buf+1), buf);
opush(stack, var); opush(stack, var);
#ifdef _SECURECRT_ERRCODE_VALUES_DEFINED
if (errno==ERANGE) {
errno = eold;
}
#endif
} }
static void static void
@ -1929,7 +1913,7 @@ reports_init(void)
register_argtype("order", var_free_order, var_copy_order, VAR_VOIDPTR); register_argtype("order", var_free_order, var_copy_order, VAR_VOIDPTR);
register_argtype("resources", var_free_resources, NULL, VAR_VOIDPTR); register_argtype("resources", var_free_resources, NULL, VAR_VOIDPTR);
register_argtype("items", var_free_resources, var_copy_items, VAR_VOIDPTR); register_argtype("items", var_free_resources, var_copy_items, VAR_VOIDPTR);
register_argtype("regions", var_free_regions, var_copy_regions, VAR_VOIDPTR); register_argtype("regions", var_free_regions, NULL, VAR_VOIDPTR);
/* register functions that turn message contents to readable strings */ /* register functions that turn message contents to readable strings */
add_function("alliance", &eval_alliance); add_function("alliance", &eval_alliance);

View file

@ -61,7 +61,7 @@ function process(orders)
-- loadscript("eressea/multis.lua") -- loadscript("eressea/multis.lua")
-- run the turn: -- run the turn:
set_encoding("utf8") -- set_encoding("utf8")
if read_orders(orders) ~= 0 then if read_orders(orders) ~= 0 then
print("could not read " .. orders) print("could not read " .. orders)
return -1 return -1