forked from andbof/yastg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ship.h
41 lines (34 loc) · 875 Bytes
/
ship.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#ifndef _HAS_SHIP_H
#define _HAS_SHIP_H
#include <pthread.h>
#include "cargo.h"
#include "list.h"
#include "ship_type.h"
enum postype {
NONE,
SYSTEM,
PORT,
PLANET,
SHIP
};
struct ship {
char *name;
struct ship_type *type;
struct player *owner;
enum postype postype;
void *pos;
pthread_rwlock_t cargo_lock;
struct list_head cargo;
struct list_head cargo_names;
struct list_head list;
};
#include "player.h"
void ship_free(struct ship *ship);
int ship_go(struct ship *ship, enum postype postype, void *pos);
int new_ship_to_player(struct ship_type *ship_type, struct player *player);
/*
* Must be called with the appropriate locks (i.e. ship->cargo_lock) held
*/
int move_cargo_to_ship(struct ship * const ship, struct cargo * const cargo, long amount);
int move_cargo_from_ship(struct ship * const ship, struct cargo * const cargo, long amount);
#endif