annotate src/grid.c @ 5:054275999194

Initial revision
author darius
date Sat, 06 Dec 1997 04:37:03 +0000
parents aa38447a4b21
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4
aa38447a4b21 First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1 /*--------------------------------------------------------------------------
aa38447a4b21 First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
2 NETREK II -- Paradise
aa38447a4b21 First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
3
aa38447a4b21 First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
4 Permission to use, copy, modify, and distribute this software and its
aa38447a4b21 First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
5 documentation, or any derivative works thereof, for any NON-COMMERCIAL
aa38447a4b21 First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
6 purpose and without fee is hereby granted, provided that this copyright
aa38447a4b21 First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
7 notice appear in all copies. No representations are made about the
aa38447a4b21 First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
8 suitability of this software for any purpose. This software is provided
aa38447a4b21 First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
9 "as is" without express or implied warranty.
aa38447a4b21 First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
10
aa38447a4b21 First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
11 Xtrek Copyright 1986 Chris Guthrie
aa38447a4b21 First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
12 Netrek (Xtrek II) Copyright 1989 Kevin P. Smith
aa38447a4b21 First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
13 Scott Silvey
aa38447a4b21 First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
14 Paradise II (Netrek II) Copyright 1993 Larry Denys
aa38447a4b21 First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
15 Kurt Olsen
aa38447a4b21 First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
16 Brandon Gillespie
aa38447a4b21 First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
17 --------------------------------------------------------------------------*/
aa38447a4b21 First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
18
aa38447a4b21 First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
19 #include "config.h"
aa38447a4b21 First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
20 #include "struct.h"
aa38447a4b21 First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
21 #include "shmem.h"
aa38447a4b21 First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
22
aa38447a4b21 First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
23 /*
aa38447a4b21 First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
24 * This function should be called any time a planet is relocated. It is in
aa38447a4b21 First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
25 * charge of updating the space grid.
aa38447a4b21 First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
26 */
aa38447a4b21 First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
27 void
aa38447a4b21 First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
28 move_planet(pno, x, y, isold)
aa38447a4b21 First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
29 int pno; /* planet number */
aa38447a4b21 First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
30 int x, y;
aa38447a4b21 First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
31 int isold; /* 0 if the planet has not yet been entered
aa38447a4b21 First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
32 * into the grid */
aa38447a4b21 First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
33 {
aa38447a4b21 First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
34 struct planet *pl = &planets[pno];
aa38447a4b21 First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
35
aa38447a4b21 First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
36 if (isold)
aa38447a4b21 First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
37 {
aa38447a4b21 First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
38 /* remove from previous space grid position */
aa38447a4b21 First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
39 }
aa38447a4b21 First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
40 pl->pl_x = x;
aa38447a4b21 First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
41 pl->pl_y = y;
aa38447a4b21 First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
42
aa38447a4b21 First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
43 /* enter into space grid */
aa38447a4b21 First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
44 }
aa38447a4b21 First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
45
aa38447a4b21 First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
46 void
aa38447a4b21 First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
47 move_player(pno, x, y, isold)
aa38447a4b21 First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
48 int pno; /* player number */
aa38447a4b21 First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
49 int x, y;
aa38447a4b21 First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
50 int isold; /* 0 if the player has not yet been entered
aa38447a4b21 First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
51 * into the grid */
aa38447a4b21 First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
52 {
aa38447a4b21 First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
53 struct player *pl = &players[pno];
aa38447a4b21 First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
54
aa38447a4b21 First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
55 if (isold)
aa38447a4b21 First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
56 {
aa38447a4b21 First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
57 }
aa38447a4b21 First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
58 pl->p_x = x;
aa38447a4b21 First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
59 pl->p_y = y;
aa38447a4b21 First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
60
aa38447a4b21 First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
61 /* enter into space grid */
aa38447a4b21 First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
62 }
aa38447a4b21 First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
63
aa38447a4b21 First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
64 void
aa38447a4b21 First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
65 move_torp(tno, x, y, isold)
aa38447a4b21 First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
66 int tno; /* torp number */
aa38447a4b21 First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
67 int x, y;
aa38447a4b21 First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
68 int isold; /* 0 if the torp has not yet been entered
aa38447a4b21 First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
69 * into the grid */
aa38447a4b21 First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
70 {
aa38447a4b21 First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
71 struct torp *t = &torps[tno];
aa38447a4b21 First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
72
aa38447a4b21 First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
73 if (isold)
aa38447a4b21 First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
74 {
aa38447a4b21 First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
75 }
aa38447a4b21 First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
76 t->t_x = x;
aa38447a4b21 First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
77 t->t_y = y;
aa38447a4b21 First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
78
aa38447a4b21 First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
79 /* enter into space grid */
aa38447a4b21 First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
80 }
aa38447a4b21 First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
81
aa38447a4b21 First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
82 void
aa38447a4b21 First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
83 move_missile(dno, x, y, isold)
aa38447a4b21 First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
84 int dno; /* missile number */
aa38447a4b21 First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
85 int x, y;
aa38447a4b21 First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
86 int isold; /* 0 if the missile has not yet been entered
aa38447a4b21 First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
87 * into the grid */
aa38447a4b21 First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
88 {
aa38447a4b21 First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
89 struct missile *d = &missiles[dno];
aa38447a4b21 First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
90
aa38447a4b21 First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
91 if (isold)
aa38447a4b21 First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
92 {
aa38447a4b21 First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
93 }
aa38447a4b21 First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
94 d->ms_x = x;
aa38447a4b21 First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
95 d->ms_y = y;
aa38447a4b21 First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
96
aa38447a4b21 First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
97 /* enter into space grid */
aa38447a4b21 First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
98 }