aboutsummaryrefslogtreecommitdiff
path: root/dat.h
diff options
context:
space:
mode:
authorrodri <rgl@antares-labs.eu>2023-09-15 08:57:29 +0000
committerrodri <rgl@antares-labs.eu>2023-09-15 08:57:29 +0000
commitae96cfa10904f1d69cd5c4189dc140fc563f960c (patch)
tree9b93cde1998b0ce4a35f94a9d3056946e8268458 /dat.h
parent118df45d3740cc6a391e181e60aeaef7571c5e0b (diff)
downloadbattleship-ae96cfa10904f1d69cd5c4189dc140fc563f960c.tar.gz
battleship-ae96cfa10904f1d69cd5c4189dc140fc563f960c.tar.bz2
battleship-ae96cfa10904f1d69cd5c4189dc140fc563f960c.zip
new server architecture.
Diffstat (limited to 'dat.h')
-rw-r--r--dat.h41
1 files changed, 34 insertions, 7 deletions
diff --git a/dat.h b/dat.h
index ad0b978..01ee61e 100644
--- a/dat.h
+++ b/dat.h
@@ -16,6 +16,8 @@ enum {
OV, /* vertical */
Waiting0 = 0,
+ Watching,
+ Ready,
Outlaying,
Waiting,
Playing,
@@ -34,9 +36,11 @@ enum {
typedef struct Ship Ship;
typedef struct Map Map;
typedef struct Board Board;
+typedef struct Chanpipe Chanpipe;
typedef struct Player Player;
typedef struct Match Match;
-typedef struct Chanpipe Chanpipe;
+typedef struct Msg Msg;
+typedef struct Stands Stands;
struct Ship
{
@@ -44,7 +48,7 @@ struct Ship
Rectangle bbox;
int orient;
int ncells;
- int *hit; /* |hit| = ncells and hit ∈ {0,1} */
+ int *hit; /* |hit| = ncells and hitᵢ ∈ {0,1} */
int sunk;
};
@@ -60,22 +64,45 @@ struct Board
Rectangle bbox;
};
+struct Chanpipe
+{
+ Channel *in;
+ Channel *out;
+ Channel *ctl;
+ int fd;
+};
+
struct Player
{
Map;
char name[8+1];
- int fd;
- int sfd;
int state;
+ Match *battle;
+ NetConnInfo *nci;
+ Chanpipe io;
+ Channel *ctl;
};
struct Match
{
+ RWLock;
+ int id;
Player *pl[2];
+ Channel *data;
+ Channel *ctl;
+ Match *prev;
+ Match *next;
};
-struct Chanpipe
+struct Msg
{
- Channel *c;
- int fd;
+ Player *from;
+ char *body;
+};
+
+struct Stands
+{
+ Player **seats;
+ ulong nused;
+ ulong cap;
};