aboutsummaryrefslogtreecommitdiff
path: root/party.c
blob: 6eeaab45fd8ffdab74f1842d34a37aad765a50ce (plain)
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
42
43
44
45
46
47
48
49
50
51
#include <u.h>
#include <libc.h>
#include <ip.h>
#include <mp.h>
#include <libsec.h>
#include <thread.h>
#include <draw.h>
#include <geometry.h>
#include "dat.h"
#include "fns.h"

Party *
newparty(Party *p, Player *player0, Player *player1)
{
	Party *np;

	np = emalloc(sizeof(Party));
	np->players[0] = player0;
	np->players[1] = player1;

	np->u = newuniverse();
	inituniverse(np->u);

	addparty(p, np);

	return np;
}

void
delparty(Party *p)
{
	p->next->prev = p->prev;
	p->prev->next = p->next;
	deluniverse(p->u);
	free(p);
}

void
addparty(Party *p, Party *np)
{
	np->prev = p->prev;
	np->next = p;
	p->prev->next = np;
	p->prev = np;
}

void
initparty(Party *p)
{
	p->next = p->prev = p;
}