annotate src/plutil.c @ 8:0836fb919dfa

First entry of Paradise Server 2.9 patch 10 Beta
author darius
date Sat, 06 Dec 1997 04:37:05 +0000
parents 8c6d5731234d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1 /*--------------------------------------------------------------------------
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
2 NETREK II -- Paradise
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
3
8c6d5731234d 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
8c6d5731234d 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
8c6d5731234d 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
8c6d5731234d 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
8c6d5731234d 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
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
9 "as is" without express or implied warranty.
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
10
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
11 Xtrek Copyright 1986 Chris Guthrie
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
12 Netrek (Xtrek II) Copyright 1989 Kevin P. Smith
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
13 Scott Silvey
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
14 Paradise II (Netrek II) Copyright 1993 Larry Denys
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
15 Kurt Olsen
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
16 Brandon Gillespie
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
17 --------------------------------------------------------------------------*/
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
18
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
19 #include "config.h"
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
20 #include <math.h>
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
21
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
22 #include "plutil.h"
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
23 #include "data.h"
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
24 #include "shmem.h"
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
25
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
26 int
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
27 idx_to_mask(i)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
28 int i;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
29 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
30 if (i >= 0)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
31 return 1 << i;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
32 else
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
33 return 0;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
34 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
35
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
36 int
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
37 mask_to_idx(m)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
38 int m;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
39 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
40 int i;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
41 if (!m)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
42 return -1;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
43 for (i = 0; m > 1; i++, m >>= 1);
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
44 return i;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
45 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
46
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
47 /*
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
48 */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
49
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
50 int
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
51 in_warp(pl)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
52 struct player *pl;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
53 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
54 if (pl->p_flags & PFDOCK)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
55 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
56 /* if we are docked, then we have the same state as our base */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
57 return in_warp(&players[pl->p_docked]);
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
58 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
59 return (pl->p_flags & PFWARP) || pl->p_warptime;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
60 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
61
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
62
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
63 int
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
64 undock_player(pl)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
65 struct player *pl;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
66 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
67 struct player *base;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
68
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
69 if (!(pl->p_flags & PFDOCK))
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
70 return 0;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
71
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
72 base = &players[pl->p_docked];
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
73 base->p_docked--; /* base no longer has as many docked */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
74 base->p_port[pl->p_port[0]] = VACANT; /* the port is vacant */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
75
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
76 /* what if the player is being undocked because he died? */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
77 if (base->p_ship.s_type == JUMPSHIP)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
78 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
79 pl->p_jsdock = 1;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
80 pl->p_lastjs = pl->p_docked;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
81 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
82 pl->p_flags &= ~PFDOCK;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
83 pl->p_docked = -1;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
84 pl->p_port[0] = VACANT;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
85
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
86 return 1;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
87 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
88
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
89 int
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
90 base_undock(base, port_id)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
91 struct player *base;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
92 int port_id;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
93 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
94 struct player *pl;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
95
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
96 if (base->p_port[port_id] < 0)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
97 return 0;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
98
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
99 pl = &players[base->p_port[port_id]];
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
100
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
101 base->p_docked--;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
102 base->p_port[port_id] = VACANT;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
103
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
104 /* if the jumpship kicks you off, he doesn't get credited. -RF */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
105
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
106 pl->p_flags &= ~PFDOCK;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
107 pl->p_docked = -1;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
108 pl->p_port[0] = VACANT;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
109 return 1;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
110 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
111
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
112 void
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
113 enforce_dock_position(pl)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
114 struct player *pl;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
115 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
116 struct player *base;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
117 unsigned char angle;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
118 int port_id;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
119
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
120 if (!(pl->p_flags & PFDOCK))
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
121 return;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
122
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
123 base = &players[pl->p_docked];
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
124 port_id = pl->p_port[0];
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
125
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
126 if ((base->p_ship.s_type == STARBASE) || (base->p_ship.s_type == WARBASE) ||
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
127 (base->p_ship.s_type == JUMPSHIP))
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
128 angle = (port_id * 2 + 1) * 128 / base->p_ship.s_numports;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
129 else
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
130 angle = base->p_dir + 64 + (128 * port_id); /* max of two ports, really */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
131 move_player(pl->p_no, (int) (base->p_x + DOCKDIST * Cos[angle]),
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
132 (int) (base->p_y + DOCKDIST * Sin[angle]), 1);
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
133
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
134 pl->p_speed = pl->p_desspeed = 0;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
135 if ((base->p_ship.s_type == STARBASE) || (base->p_ship.s_type == WARBASE) ||
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
136 (base->p_ship.s_type == JUMPSHIP))
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
137 pl->p_dir = pl->p_desdir = angle + 64;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
138 else
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
139 pl->p_dir = pl->p_desdir = base->p_dir;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
140 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
141
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
142 void
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
143 dock_to(pl, base_num, port_id)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
144 struct player *pl;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
145 int base_num, port_id;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
146 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
147 struct player *base = &players[base_num];
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
148
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
149 undock_player(pl);
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
150
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
151 base->p_docked++;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
152 base->p_port[port_id] = pl->p_no;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
153
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
154 pl->p_flags |= PFDOCK; /* we are docked */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
155 pl->p_docked = base_num; /* to this base */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
156 pl->p_port[0] = port_id; /* in this docking bay */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
157
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
158 enforce_dock_position(pl);
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
159 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
160
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
161 void
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
162 scout_planet(p_no, pl_no)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
163 int p_no;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
164 int pl_no;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
165 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
166 struct player *fred = &players[p_no];
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
167 struct planet *mars = &planets[pl_no];
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
168 int oldness = status->clock - mars->pl_tinfo[fred->p_team].timestamp;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
169
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
170 if (!status->tourn)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
171 return;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
172
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
173 if ((mars->pl_owner != fred->p_team) &&
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
174 (oldness > 2))
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
175 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
176 #define LOG2OFe 1.442695
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
177 double scoutdi = log((double) oldness) * LOG2OFe / 100;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
178 if (scoutdi > 0.1)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
179 scoutdi = 0.1;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
180 fred->p_stats.st_di += scoutdi;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
181 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
182 mars->pl_hinfo |= fred->p_team;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
183 if (mars->pl_owner != fred->p_team)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
184 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
185 mars->pl_tinfo[fred->p_team].flags = mars->pl_flags;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
186 mars->pl_tinfo[fred->p_team].armies = mars->pl_armies;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
187 mars->pl_tinfo[fred->p_team].owner = mars->pl_owner;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
188 mars->pl_tinfo[fred->p_team].timestamp = status->clock;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
189 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
190 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
191
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
192 /*
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
193 * */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
194
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
195 void
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
196 evaporate(pl)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
197 struct player *pl;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
198 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
199 /* put someone on the outfit screen with no ill effects */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
200
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
201 undock_player(pl); /* if docked then undock me */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
202
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
203 if (allows_docking(pl->p_ship))
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
204 { /* if ships can dock */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
205 int k;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
206 for (k = 0; k < pl->p_ship.s_numports; k++)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
207 base_undock(pl, k); /* remove all docked ships */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
208 pl->p_docked = 0; /* no ships docked anymore */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
209 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
210 if (pl->p_flags & PFORBIT)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
211 { /* if orbiting then */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
212 pl->p_flags &= ~PFORBIT; /* eject from orbit */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
213 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
214
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
215 pl->p_status = POUTFIT;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
216 pl->p_whydead = KPROVIDENCE;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
217 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
218
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
219 void
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
220 explode_everyone(whydead, minlive)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
221 int whydead;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
222 int minlive;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
223 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
224 int i;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
225 for (i = 0; i < MAXPLAYER; i++)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
226 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
227 if (players[i].p_status != PALIVE
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
228 && players[i].p_status != POBSERVE)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
229 continue;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
230
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
231 if (players[i].p_updates < minlive)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
232 continue;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
233
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
234 players[i].p_whydead = whydead;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
235 players[i].p_whodead = 0;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
236 players[i].p_status = PEXPLODE;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
237 players[i].p_explode = 10;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
238 players[i].p_ntorp = 0; /* no torps shot */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
239 players[i].p_nplasmatorp = 0; /* no plasmas shot */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
240 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
241 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
242
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
243
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
244 /* round randomly, but weighted by the fractional part */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
245
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
246 int
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
247 random_round(d)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
248 double d;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
249 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
250 int rval = floor(d);
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
251 if (drand48() < d - rval)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
252 rval++;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
253 return rval;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
254 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
255
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
256
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
257 char *
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
258 twoletters(pl)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
259 struct player *pl;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
260 /* calculate the two letters that form the players designation (e.g. R4) */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
261 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
262 #define RINGSIZE MAXPLAYER+3
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
263 static char buf[RINGSIZE][3]; /* ring of buffers so that this */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
264 static int idx; /* proc can be called several times before
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
265 * the results are used */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
266 if (idx >= RINGSIZE)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
267 idx = 0;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
268 buf[idx][0] = teams[pl->p_team].letter;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
269 buf[idx][1] = shipnos[pl->p_no];
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
270 buf[idx][2] = 0;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
271 return buf[idx++];
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
272 }