bugfix travelthru()
This commit is contained in:
Enno Rehling 2004-04-12 11:00:22 +00:00
parent 618bb6363a
commit a3ffe42a89
5 changed files with 136 additions and 112 deletions

View File

@ -569,14 +569,13 @@ matmod(const attrib * a, const unit * u, const resource_type * material, int val
return value;
}
int
build(unit * u, const construction * ctype, int completed, int want)
/* Use up resources for building an object. returns the actual size
* being built
/** Use up resources for building an object.
* Build up to 'size' points of 'type', where 'completed'
* of the first object have already been finished. return the
* actual size that could be built.
*/
int
build(unit * u, const construction * ctype, int completed, int want)
{
const construction * type = ctype;
int skills; /* number of skill points remainig */

View File

@ -432,12 +432,19 @@ do_maelstrom(region *r, unit *u)
}
}
/** sets a marker in the region telling that the unit has travelled through it
* this is used for two distinctly different purposes:
* - to report that a unit has travelled through. the report function
* makes sure to only report the ships of travellers, not the travellers
* themselves
* - to report the region to the traveller
*/
void
travelthru(unit * u, region * r)
travelthru(const unit * u, region * r)
{
attrib *ru = a_add(&r->attribs, a_new(&at_travelunit));
ru->data.v = u;
ru->data.v = (void*)u;
/* the first and last region of the faction gets reset, because travelthrough
* could be in regions that are located before the [first, last] interval,
@ -473,6 +480,16 @@ leave_trail(unit * u, region **route, region * to)
td->dir = dir;
td->age = 2;
}
}
static void
travel_route(const unit * u, region ** route)
{
region **ri = route;
while (*ri) {
region * r = *ri++;
travelthru(u, r);
}
}
@ -498,6 +515,7 @@ move_ship(ship * sh, region * from, region * to, region ** route)
leave_trail(u, route, to);
trail=true;
}
if (route!=NULL) travel_route(u, route);
if (from!=to) {
u->ship = NULL; /* damit move_unit() kein leave() macht */
move_unit(u, to, ulist);

View File

@ -57,7 +57,7 @@ extern struct unit *is_guarded(struct region * r, struct unit * u, unsigned int
extern int enoughsailors(struct region * r, struct ship * sh);
extern boolean canswim(struct unit *u);
extern struct unit *kapitaen(struct region * r, struct ship * sh);
extern void travelthru(struct unit * u, struct region * r);
extern void travelthru(const struct unit * u, struct region * r);
extern struct ship * move_ship(struct ship * sh, struct region * from, struct region * to, struct region ** route);
extern void follow_unit(void);

View File

@ -21,6 +21,12 @@
static int flags = LOG_FLUSH|LOG_CPERROR|LOG_CPWARNING;
static FILE * logfile;
void
log_flush(void)
{
fflush(logfile);
}
void
log_puts(const char * str)
{
@ -37,7 +43,7 @@ log_printf(const char * format, ...)
vfprintf(logfile, format, marker);
va_end(marker);
if (flags & LOG_FLUSH) {
fflush(logfile);
log_flush();
}
}
@ -85,7 +91,7 @@ _log_warn(const char * format, ...)
va_end(marker);
}
if (flags & LOG_FLUSH) {
fflush(logfile);
log_flush();
}
}
}
@ -108,7 +114,7 @@ _log_error(const char * format, ...)
va_end(marker);
}
if (flags & LOG_FLUSH) {
fflush(logfile);
log_flush();
}
}
}
@ -131,7 +137,7 @@ _log_info(unsigned int flag, const char * format, ...)
va_end(marker);
}
if (flags & LOG_FLUSH) {
fflush(logfile);
log_flush();
}
}
}

View File

@ -19,6 +19,7 @@ extern void log_open(const char * filename);
extern void log_printf(const char * str, ...);
extern void log_puts(const char * str);
extern void log_close(void);
extern void log_flush(void);
#define log_warning(x) _log_warn x
#define log_error(x) _log_error x