server/src/kernel/ship.h

128 lines
4.2 KiB
C
Raw Normal View History

2010-08-08 10:06:34 +02:00
/*
Copyright (c) 1998-2010, Enno Rehling <enno@eressea.de>
Katja Zedel <katze@felidae.kn-bremen.de
Christian Schlittchen <corwin@amber.kn-bremen.de>
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
**/
#ifndef H_KRNL_SHIP
#define H_KRNL_SHIP
#ifdef __cplusplus
extern "C" {
#endif
#include "types.h"
2011-03-07 08:02:35 +01:00
#define DAMAGE_SCALE 100 /* multiplier for sh->damage */
2010-08-08 10:06:34 +02:00
/* ship_type::flags */
#define SFL_OPENSEA 0x01
#define SFL_FLY 0x02
#define SFL_NOCOAST 0x04
2011-03-07 08:02:35 +01:00
typedef struct ship_type {
const char *name[2];
2010-08-08 10:06:34 +02:00
2011-03-07 08:02:35 +01:00
int range; /* range in regions */
int flags; /* flags */
int combat; /* modifier for combat */
2010-08-08 10:06:34 +02:00
2011-03-07 08:02:35 +01:00
double storm; /* multiplier for chance to drift in storm */
double damage; /* multiplier for damage taken by the ship */
2010-08-08 10:06:34 +02:00
2011-03-07 08:02:35 +01:00
int cabins; /* max. cabins (weight) */
int cargo; /* max. cargo (weight) */
2010-08-08 10:06:34 +02:00
2011-03-07 08:02:35 +01:00
int cptskill; /* min. skill of captain */
int minskill; /* min. skill to sail this (crew) */
int sumskill; /* min. sum of crew+captain */
2010-08-08 10:06:34 +02:00
2011-03-07 08:02:35 +01:00
int fishing; /* weekly income from fishing */
2010-08-08 10:06:34 +02:00
2011-03-07 08:02:35 +01:00
int at_bonus; /* Ver<65>ndert den Angriffsskill (default: 0) */
int df_bonus; /* Ver<65>ndert den Verteidigungskill (default: 0) */
float tac_bonus;
2010-08-08 10:06:34 +02:00
2011-03-07 08:02:35 +01:00
const struct terrain_type **coasts; /* coast that this ship can land on */
2010-08-08 10:06:34 +02:00
2011-03-07 08:02:35 +01:00
struct construction *construction; /* how to build a ship */
} ship_type;
2010-08-08 10:06:34 +02:00
2011-03-07 08:02:35 +01:00
extern struct quicklist *shiptypes;
2010-08-08 10:06:34 +02:00
/* Alte Schiffstypen: */
2011-03-07 08:02:35 +01:00
extern const ship_type *st_find(const char *name);
extern void st_register(const ship_type * type);
2010-08-08 10:06:34 +02:00
#define NOSHIP NULL
#define SF_DRIFTED 1<<0
#define SF_MOVED 1<<1
2011-03-07 08:02:35 +01:00
#define SF_DAMAGED 1<<2 /* for use in combat */
#define SF_SELECT 1<<3 /* previously FL_DH */
#define SF_FISHING 1<<4 /* was on an ocean, can fish */
#define SF_FLYING 1<<5 /* the ship can fly */
2010-08-08 10:06:34 +02:00
#define SFL_SAVEMASK (SF_FLYING)
#define INCOME_FISHING 10
2011-03-07 08:02:35 +01:00
typedef struct ship {
struct ship *next;
struct ship *nexthash;
struct unit * owner;
2011-03-07 08:02:35 +01:00
int no;
struct region *region;
char *name;
char *display;
struct attrib *attribs;
int size;
int damage; /* damage in 100th of a point of size */
unsigned int flags;
const struct ship_type *type;
direction_t coast;
} ship;
extern void damage_ship(ship * sh, double percent);
extern struct unit *captain(ship * sh);
extern struct unit *shipowner(struct ship *sh);
2011-03-07 08:02:35 +01:00
extern const char *shipname(const struct ship *self);
extern int shipcapacity(const struct ship *sh);
extern void getshipweight(const struct ship *sh, int *weight, int *cabins);
extern ship *new_ship(const struct ship_type *stype, struct region *r,
const struct locale *lang);
2011-03-07 08:02:35 +01:00
extern const char *write_shipname(const struct ship *sh, char *buffer,
size_t size);
extern struct ship *findship(int n);
extern struct ship *findshipr(const struct region *r, int n);
extern const struct ship_type *findshiptype(const char *s,
const struct locale *lang);
extern void write_ship_reference(const struct ship *sh,
struct storage *store);
extern void remove_ship(struct ship **slist, struct ship *s);
extern void free_ship(struct ship *s);
extern void free_ships(void);
extern const char *ship_getname(const struct ship *self);
extern void ship_setname(struct ship *self, const char *name);
2010-08-08 10:06:34 +02:00
#ifdef __cplusplus
}
#endif
#endif