forked from github/server
bugfix travelthru()
This commit is contained in:
parent
618bb6363a
commit
a3ffe42a89
|
@ -569,14 +569,13 @@ matmod(const attrib * a, const unit * u, const resource_type * material, int val
|
|||
return value;
|
||||
}
|
||||
|
||||
/** 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)
|
||||
/* Use up resources for building an object. returns the actual size
|
||||
* being built
|
||||
* 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.
|
||||
*/
|
||||
{
|
||||
const construction * type = ctype;
|
||||
int skills; /* number of skill points remainig */
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
/* vi: set ts=2:
|
||||
+-------------------+ Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
| | Enno Rehling <enno@eressea-pbem.de>
|
||||
| Eressea PBEM host | Katja Zedel <katze@felidae.kn-bremen.de>
|
||||
| (c) 1998 - 2003 | Henning Peters <faroul@beyond.kn-bremen.de>
|
||||
| | Ingo Wilken <Ingo.Wilken@informatik.uni-oldenburg.de>
|
||||
+-------------------+ Stefan Reich <reich@halbling.de>
|
||||
+-------------------+ Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
| | Enno Rehling <enno@eressea-pbem.de>
|
||||
| Eressea PBEM host | Katja Zedel <katze@felidae.kn-bremen.de>
|
||||
| (c) 1998 - 2003 | Henning Peters <faroul@beyond.kn-bremen.de>
|
||||
| | Ingo Wilken <Ingo.Wilken@informatik.uni-oldenburg.de>
|
||||
+-------------------+ Stefan Reich <reich@halbling.de>
|
||||
|
||||
This program may not be used, modified or distributed
|
||||
without prior permission by the authors of Eressea.
|
||||
This program may not be used, modified or distributed
|
||||
without prior permission by the authors of Eressea.
|
||||
*/
|
||||
#include <config.h>
|
||||
#include "log.h"
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
/* vi: set ts=2:
|
||||
+-------------------+ Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
| | Enno Rehling <enno@eressea-pbem.de>
|
||||
| Eressea PBEM host | Katja Zedel <katze@felidae.kn-bremen.de>
|
||||
| (c) 1998 - 2003 | Henning Peters <faroul@beyond.kn-bremen.de>
|
||||
| | Ingo Wilken <Ingo.Wilken@informatik.uni-oldenburg.de>
|
||||
+-------------------+ Stefan Reich <reich@halbling.de>
|
||||
+-------------------+ Christian Schlittchen <corwin@amber.kn-bremen.de>
|
||||
| | Enno Rehling <enno@eressea-pbem.de>
|
||||
| Eressea PBEM host | Katja Zedel <katze@felidae.kn-bremen.de>
|
||||
| (c) 1998 - 2003 | Henning Peters <faroul@beyond.kn-bremen.de>
|
||||
| | Ingo Wilken <Ingo.Wilken@informatik.uni-oldenburg.de>
|
||||
+-------------------+ Stefan Reich <reich@halbling.de>
|
||||
|
||||
This program may not be used, modified or distributed
|
||||
without prior permission by the authors of Eressea.
|
||||
This program may not be used, modified or distributed
|
||||
without prior permission by the authors of Eressea.
|
||||
*/
|
||||
#ifndef H_UTIL_LOG
|
||||
#define H_UTIL_LOG
|
||||
|
@ -15,19 +15,20 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
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_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
|
||||
#define log_info(x) _log_info x
|
||||
|
||||
/* use macros above instead of these: */
|
||||
extern void _log_warn(const char * format, ...);
|
||||
extern void _log_error(const char * format, ...);
|
||||
extern void _log_info(unsigned int flag, const char * format, ...);
|
||||
/* use macros above instead of these: */
|
||||
extern void _log_warn(const char * format, ...);
|
||||
extern void _log_error(const char * format, ...);
|
||||
extern void _log_info(unsigned int flag, const char * format, ...);
|
||||
|
||||
#define LOG_FLUSH (1<<0)
|
||||
#define LOG_CPWARNING (1<<1)
|
||||
|
|
Loading…
Reference in New Issue