annotate src/conquer.c @ 18:1424868939a8

Indenting
author darius
date Wed, 24 Dec 1997 12:38:35 +0000
parents 2719a89505ba
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1 /*--------------------------------------------------------------------------
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
2 NETREK II -- Paradise
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
3
2719a89505ba 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
2719a89505ba 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
2719a89505ba 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
2719a89505ba 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
2719a89505ba 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
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
9 "as is" without express or implied warranty.
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
10
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
11 Xtrek Copyright 1986 Chris Guthrie
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
12 Netrek (Xtrek II) Copyright 1989 Kevin P. Smith
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
13 Scott Silvey
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
14 Paradise II (Netrek II) Copyright 1993 Larry Denys
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
15 Kurt Olsen
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
16 Brandon Gillespie
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
17 --------------------------------------------------------------------------*/
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
18
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
19
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
20 #include "config.h"
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
21 #include <sys/time.h>
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
22 #include <stdio.h>
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
23 #include <stdlib.h>
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
24 #include <string.h>
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
25 #include <math.h>
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
26 #include <setjmp.h>
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
27 #include <time.h>
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
28
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
29 #include "defs.h"
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
30 #include "struct.h"
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
31 #include "data.h"
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
32 #include "daemonII.h"
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
33 #include "misc.h"
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
34 #include "shmem.h"
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
35 #include "path.h"
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
36
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
37
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
38
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
39 /*----------------------------NUMBER DEFINES-------------------------------*/
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
40 #define SURRSTART 4 /* # planets where surrender starts */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
41 #define SURREND 7 /* # planets where surrender stops */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
42 #define SURRLENGTH 25 /* give them 30 minutes to sustain empire */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
43 /*-------------------------------------------------------------------------*/
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
44
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
45
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
46
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
47
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
48
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
49
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
50 /*----------------------------MODULE VARIABLES-----------------------------*/
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
51
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
52 /* used to store players found with the displayBest function */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
53 typedef struct playerlist
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
54 {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
55 char name[16]; /* player's name */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
56 char mapchars[2]; /* player's map window image */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
57 int planets, armies; /* planets taken and armies bombed */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
58 int resources, dooshes; /* resources bombed and armies dooshed */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
59 } Players;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
60
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
61 /*-------------------------------------------------------------------------*/
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
62
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
63
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
64
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
65
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
66
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
67
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
68 extern int enemy_admiral();
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
69 extern void perror();
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
70 extern void cause_kaboom();
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
71 extern void gen_planets();
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
72 extern void endtourn();
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
73 extern void stoptimer();
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
74 extern char *twoletters();
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
75 void checkwin();
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
76 void displayBest();
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
77
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
78 static void
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
79 swap(a, b)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
80 int *a, *b;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
81 {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
82 int t = *a;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
83 *a = *b;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
84 *b = t;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
85 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
86
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
87
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
88 /*----------------------------INTERNAL FUNCTIONS---------------------------*/
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
89
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
90 /*-----------------------------------GENOCIDE------------------------------*/
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
91 /*
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
92 * This function checks for a genocide. It also returns the two teams with
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
93 * the most players. It first goes through the four teams and finds the two
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
94 * teams with the greatest number of players. These two teams are returned
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
95 * in the parameters team1 and team2. If one of the teams does not have at
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
96 * least one planet then a 1 is returned. Otherwise a zero is returned.
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
97 */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
98
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
99 int
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
100 genocide(team1, team2)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
101 int *team1; /* where to put first team */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
102 int *team2; /* where to put second team */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
103 {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
104 int t1, t2; /* to hold two teams */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
105 int n1, n2; /* to hold number of ships on teams */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
106 int t; /* temp var */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
107 int i; /* looping var */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
108
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
109 t1 = FED; /* set first team */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
110 n1 = realNumShips(FED); /* get players on it */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
111 t2 = ROM; /* set second team */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
112 n2 = realNumShips(ROM); /* get players on it */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
113 if (n1 < n2)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
114 { /* place team with least players in t2 */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
115 swap(&n1, &n2);
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
116 swap(&t1, &t2);
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
117 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
118 if (realNumShips(KLI) > n2)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
119 { /* check the klingons */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
120 t2 = KLI;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
121 n2 = realNumShips(KLI);
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
122 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
123 if (n1 < n2)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
124 { /* place team with least players in t2 */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
125 swap(&n1, &n2);
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
126 swap(&t1, &t2);
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
127 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
128 if (realNumShips(ORI) > n2)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
129 { /* check the orions */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
130 t2 = ORI;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
131 n2 = realNumShips(ORI);
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
132 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
133 /* no longer necessarily in order */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
134 *team1 = t1; /* pass back team 1 */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
135 *team2 = t2; /* pass back team 2 */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
136 t = 0; /* no genocide detected yet */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
137 for (i = 0; i < NUMPLANETS; i++)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
138 { /* see if team 1 has a planet */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
139 if (planets[i].pl_owner == t1)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
140 { /* do they own this */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
141 t++; /* inc t andd then get out of loop */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
142 break;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
143 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
144 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
145 for (i = 0; i < NUMPLANETS; i++)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
146 { /* see if team 2 has a planet */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
147 if (planets[i].pl_owner == t2)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
148 { /* do they own this */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
149 t++; /* inc t andd then get out of loop */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
150 break;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
151 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
152 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
153 if (t != 2) /* if both teams do not have planets then */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
154 return (1); /* return that genocide has occured */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
155 else /* else genocide has not occured */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
156 return (0);
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
157 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
158
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
159
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
160
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
161
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
162 /*------------------------------CHECKSURRENDER-----------------------------*/
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
163 /*
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
164 * This function is called when a teams surrender status may have changed. It
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
165 * takes a team and uses the s_plcount in the teams structure to check
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
166 * whether a team has prevented surrender or the surrender process should
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
167 * begin.
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
168 */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
169
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
170 void
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
171 checksurrender(team, otherplanets)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
172 int team; /* the team to check */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
173 int otherplanets;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
174 {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
175 char buf[80]; /* to sprintf into */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
176
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
177 if ((teams[team].s_surrender > 0) && /* surrender timer running? */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
178 ((teams[team].s_plcount >= SURREND) ||
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
179 (teams[team].s_plcount * 2 > otherplanets)))
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
180 { /* and enough planets */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
181 pmessage("", 0, MALL, "");
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
182 sprintf(buf, "The %s %s prevented collapse of the empire.",
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
183 teams[team].name, teamVerbage[team]);
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
184 pmessage(buf, 0, MALL, MSERVA); /* message to all */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
185 pmessage("", 0, MALL, "");
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
186 teams[team].s_surrender = 0;/* stop surrender clock */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
187 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
188 else if ((teams[team].s_surrender == 0) && /* start surrender ? */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
189 (teams[team].s_plcount <= SURRSTART) &&
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
190 (teams[team].s_plcount * 2 <= otherplanets) &&
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
191 (realNumShips(team) >= configvals->tournplayers) &&
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
192 (teams[team].s_plcount < teams[team].s_plcountold))
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
193 {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
194 teams[team].s_surrender = SURRLENGTH;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
195 sprintf(buf, "The %s %s %d minutes before the empire collapses.",
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
196 teams[team].name, teamVerbage[team], SURRLENGTH);
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
197 pmessage("", 0, MALL, "");
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
198 pmessage(buf, 0, MALL, MSERVA);
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
199 sprintf(buf, "%d planets are needed to sustain the empire.",
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
200 SURREND);
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
201 pmessage(buf, 0, MALL, MSERVA);
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
202 pmessage("", 0, MALL, "");
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
203 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
204 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
205
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
206 /*-------------------------------------------------------------------------*/
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
207
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
208
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
209
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
210
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
211
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
212
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
213
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
214 /*------------------------------VISIBLE PROCEDURES-------------------------*/
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
215
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
216 /*---------------------------------UDSURRENDER-----------------------------*/
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
217 /*
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
218 * This function updates the surender stuff. There is also stuff for
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
219 * updating the ship construction timers here.
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
220 */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
221
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
222 void
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
223 udsurrend()
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
224 {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
225 register int i, t; /* looping vars */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
226 char buf[80];
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
227 struct planet *l;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
228 struct player *j;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
229
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
230 /* TC's termination of players not on a t-mode team */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
231 for (i = 0, j = &players[0]; i < MAXPLAYER; i++, j++)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
232 {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
233 if ((j->p_status == PALIVE) &&
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
234 !(j->p_flags & PFROBOT) && (j->p_team != NOBODY) &&
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
235 (realNumShips(j->p_team) < configvals->tournplayers) &&
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
236 (lrand48() % 5 == 0))
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
237 rescue(TERMINATOR, j->p_no, -1);
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
238 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
239 for (t = 0; t <= MAXTEAM; t++)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
240 { /* go through all teams */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
241 if ((teams[t].s_surrender == 0) ||
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
242 (realNumShips(t) < configvals->tournplayers))
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
243 continue; /* suspend if no t-mode */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
244 if (teams[t].s_plcount > SURRSTART) /* suspend timer if they have */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
245 continue; /* enough planets */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
246 teams[t].s_surrender--; /* dec the surrender timer */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
247 if (teams[t].s_surrender <= 0)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
248 { /* if timer ran out then */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
249 teams[t].s_surrender = -1;/* set it so it isnt 0 (otherwise it
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
250 * announces surrender again) (BG) */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
251 sprintf(buf, "The %s %s surrendered.", teams[t].name,
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
252 teamVerbage[t]); /* print surrender message */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
253 pmessage("", 0, MALL, "");
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
254 pmessage(buf, 0, MALL, MSERVA);
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
255 pmessage("", 0, MALL, "");
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
256 for (i = 0, l = &planets[i]; i < NUMPLANETS; i++, l++)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
257 {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
258 if (l->pl_owner == t)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
259 { /* neutralize and zero the */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
260 l->pl_owner = NOBODY; /* armies on all loser's planets */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
261 l->pl_armies = 0;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
262 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
263 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
264 checkwin(enemy_admiral(t)); /* go check the win */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
265 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
266 else if ((teams[t].s_surrender % 5) == 0 ||
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
267 (teams[t].s_surrender < 4))
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
268 {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
269 sprintf(buf, "The %s %s %d minutes remaining.",
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
270 teams[t].name, teamVerbage[t], teams[t].s_surrender);
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
271 pmessage("", 0, MALL, "");/* blank line */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
272 pmessage(buf, 0, MALL, MSERVA); /* printf counting down */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
273 sprintf(buf, "%d planets will sustain the empire. ", SURREND);
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
274 pmessage(buf, 0, MALL, MSERVA);
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
275 sprintf(buf, "%d or half enemy suspends countdown.", SURRSTART + 1);
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
276 pmessage(buf, 0, MALL, MSERVA);
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
277 pmessage("", 0, MALL, "");/* blank line */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
278 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
279 } /* end for team */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
280 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
281
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
282
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
283 /*------------------------------CONQUERMESSAGE-----------------------------*/
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
284 /*
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
285 * This function is called after a race is genocided. It lists the players
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
286 * on the winning and losing teams. The reason should be either GENOCIDE or
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
287 * SURRENDER. The list is written to the conquer file.
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
288 */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
289
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
290 void
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
291 conquerMessage(winners, losers, pno)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
292 int winners;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
293 int losers;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
294 int pno;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
295 /* the losing and winning teams */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
296 /* the person who won it */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
297 {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
298 char buf[80]; /* to sprintf into */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
299 FILE *conqfile; /* to open conquer file */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
300 time_t curtime; /* to get current time */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
301 char *paths; /* to hold path to directory */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
302
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
303 paths = build_path(CONQFILE);
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
304 conqfile = fopen(paths, "a"); /* open the conquer file */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
305 if (!conqfile)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
306 {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
307 perror("");
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
308 fprintf(stderr, "failed to open file %s\n", paths);
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
309 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
310 #ifdef LEAGUE_SUPPORT
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
311 #define OUT pmessage(buf, 0, MALL | MGENO, " "); \
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
312 if (conqfile) fprintf(conqfile, " %s\n", buf); \
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
313 tlog_conquerline(buf);
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
314 #else
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
315 #define OUT pmessage(buf, 0, MALL | MGENO, " "); \
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
316 if (conqfile) fprintf(conqfile, " %s\n", buf);
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
317 #endif
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
318
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
319 time(&curtime); /* get current time */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
320 strcpy(buf, "\nConquer! "); /* this is a genocide */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
321 strcat(buf, ctime(&curtime)); /* cat on current time */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
322 if (conqfile)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
323 fprintf(conqfile, " %s\n", buf); /* write it to conquer file */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
324 pmessage("***********************************************************",
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
325 0, MALL | MGENO, " "); /* print enclosure to messages */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
326
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
327 if (pno >= 0)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
328 {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
329 sprintf(buf, "The galaxy has been conquered by %s and the %s!!!!",
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
330 players[pno].p_name, teams[winners].name);
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
331 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
332 else
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
333 {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
334 sprintf(buf, "Stalemate.");
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
335 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
336 OUT;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
337
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
338 sprintf(buf,
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
339 #ifdef LEAGUE_SUPPORT
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
340 status2->league ? "The %s(%s):" :
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
341 #endif
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
342 "The %s:",
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
343 teams[winners].name
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
344 #ifdef LEAGUE_SUPPORT
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
345 ,((winners == (1 << status2->home.index)) ?
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
346 (&status2->home) :
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
347 (&status2->away))->name
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
348 #endif
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
349 );
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
350 OUT;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
351 displayBest(conqfile, winners); /* go display team 1 */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
352 sprintf(buf,
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
353 #ifdef LEAGUE_SUPPORT
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
354 status2->league ? "The %s(%s):" :
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
355 #endif
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
356 "The %s:",
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
357 teams[losers].name
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
358 #ifdef LEAGUE_SUPPORT
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
359 ,((losers == (1 << status2->home.index)) ?
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
360 (&status2->home) :
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
361 (&status2->away))->name
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
362 #endif
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
363 );
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
364 OUT;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
365 displayBest(conqfile, losers);/* go display team 2 */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
366 pmessage("***********************************************************",
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
367 0, MALL | MGENO, " "); /* printf the enclosure */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
368 if (conqfile)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
369 {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
370 fprintf(conqfile, "\n"); /* space between conquering */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
371 fclose(conqfile); /* close conquer file */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
372 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
373 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
374
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
375
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
376 void
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
377 refresh_team_planetcounts()
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
378 {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
379 int i;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
380 register struct planet *l; /* to point to planets */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
381
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
382 for (i = 0; i <= MAXTEAM; i++)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
383 { /* zero out each teams planet count */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
384 teams[i].s_plcountold = teams[i].s_plcount; /* save last planet count */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
385 teams[i].s_plcount = 0;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
386 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
387 for (i = 0, l = &planets[i]; i < NUMPLANETS; i++, l++) /* recompute */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
388 teams[l->pl_owner].s_plcount++; /* planet counts for teams */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
389 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
390
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
391 /* blow everyone up, print the conquer assessments, figure out who won. */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
392 void
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
393 endgame_effects(t1, t2, pno)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
394 int t1;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
395 int t2;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
396 int pno;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
397 {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
398 int i;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
399 struct player *j;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
400
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
401 refresh_team_planetcounts();
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
402
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
403 if (teams[t1].s_plcount < teams[t2].s_plcount)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
404 {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
405 int i;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
406 i = t1;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
407 t1 = t2;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
408 t2 = i; /* t1 is the winners */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
409 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
410 if (pno >= 0 && players[pno].p_team != t1)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
411 pno = -1; /* he can't win the game! */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
412
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
413 if (pno < 0)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
414 pno = enemy_admiral(t2);
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
415
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
416 if (teams[t1].s_plcount == teams[t2].s_plcount)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
417 {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
418 /* tie, nobody wins */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
419 pno = -1;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
420 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
421 status->genocides++; /* inc number of genocides */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
422 conquerMessage(t1, t2, pno); /* print conquer message */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
423
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
424 for (i = 0, j = &players[0]; i < MAXPLAYER; i++, j++)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
425 {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
426 if (j->p_status == PFREE) /* if player not in game */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
427 continue; /* ignore him */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
428 if (status->tourn) /* only inc genos if t-mode */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
429 j->p_stats.st_genocides++;/* inc player's genocides */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
430 j->p_whydead = KWINNER; /* because someone won */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
431 j->p_whodead = pno; /* set who won the game */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
432 j->p_status = POUTFIT; /* send them immediately to outfit screen */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
433 /*
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
434 * cause_kaboom (j);
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
435 */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
436 j->p_ntorp = 0; /* no torps shot */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
437 j->p_nplasmatorp = 0; /* no plasmas shot */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
438 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
439 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
440
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
441
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
442
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
443 /*-------------------------------CHECKWIN---------------------------------*/
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
444 /*
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
445 * This function is called when a planet is taken or beamed to zero. It
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
446 * recalculates s_plcount for each team. It then finds the two teams that
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
447 * are in t-mode. If either of them has just sustained the empire from
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
448 * collapse or should start the surrender procedure then that is done. If a
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
449 * team has been genocided then the genocide message is printed and the game
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
450 * is reset.
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
451 */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
452
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
453 void
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
454 checkwin(pno)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
455 int pno;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
456 {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
457 int g; /* to hold whether genocide occured */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
458 int t1, t2; /* to hold the t-mode teams */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
459
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
460 refresh_team_planetcounts();
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
461 g = genocide(&t1, &t2); /* check genocide */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
462 if (teams[t1].s_plcount < teams[t2].s_plcount)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
463 {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
464 int i;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
465 i = t1;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
466 t1 = t2;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
467 t2 = i; /* t1 is the winners */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
468 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
469 checksurrender(t1, teams[t2].s_plcount); /* check for change in */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
470 checksurrender(t2, teams[t1].s_plcount); /* surrender status */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
471 if (!g) /* if genocide did not occur */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
472 return; /* then return from func */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
473 teams[t1].s_surrender = 0; /* stop the surrender clock */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
474 teams[t2].s_surrender = 0;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
475
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
476 stoptimer();
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
477
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
478 #ifdef LEAGUE_SUPPORT
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
479 if (status2->league)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
480 {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
481 endtourn(); /* calls endgame_effects */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
482 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
483 else
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
484 #endif
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
485 endgame_effects(t1, t2, pno);
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
486 #if 0
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
487 gen_planets(); /* generate new galaxy */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
488
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
489 longjmp(env, 0); /* restart */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
490 #else
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
491 status->gameup = 0; /* exit the daemon */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
492 status->count = 0;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
493 save_planets();
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
494 sleep(2);
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
495 blast_shmem();
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
496 exit(0);
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
497 #endif
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
498 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
499
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
500
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
501
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
502
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
503
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
504
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
505
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
506 /*-------------------------------DISPLAYBEST-------------------------------*/
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
507 /*
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
508 * This function is used to get a list of players on a team after a genocide.
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
509 * It goes through the players and selects the ones that have inflicted the
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
510 * most damage. They are then printed to the message window and to the
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
511 * conquer file. They are arranged according to how much damage the players
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
512 * have inflicted on the enemy, with one planet taken counting as thirty
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
513 * armies bombed. A resource counts as 8 armies bombed and a army dooshed
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
514 * counts as five armies bombed.
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
515 */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
516
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
517 void
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
518 displayBest(conqfile, team)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
519 FILE *conqfile; /* the opened conquer file */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
520 int team; /* the winning team */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
521 {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
522 register int i, k, l; /* looping vars */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
523 register struct player *j; /* to point to players */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
524 int planets, armies; /* # planets and armies for player */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
525 int resources, dooshes; /* resources bombed, armies dooshed */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
526 Players winners[MAXPLAYER + 1]; /* to hold player's stats */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
527 char buf[100]; /* to sprintf into */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
528 int number; /* to hold # players found */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
529
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
530 number = 0; /* number of players found */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
531 for (i = 0, j = &players[0]; i < MAXPLAYER; i++, j++)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
532 {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
533 if ((j->p_team != team) || (j->p_status == PFREE)) /* player wrong race */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
534 continue; /* or not here, then forget him */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
535 planets = j->p_planets; /* get all planets and armies for */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
536 armies = j->p_armsbomb; /* entire game */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
537 resources = j->p_resbomb; /* get resources and armies dooshed */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
538 dooshes = j->p_dooshes;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
539 for (k = 0; k < number; k++)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
540 { /* go find postion in current list */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
541 if (30 * winners[k].planets + winners[k].armies + 8 * winners[k].resources
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
542 + 5 * winners[k].dooshes <
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
543 30 * planets + armies + 8 * resources + 5 * dooshes)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
544 {
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
545 break; /* break when position found */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
546 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
547 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
548 for (l = number; l >= k; l--) /* move other players to make room */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
549 winners[l + 1] = winners[l]; /* for new player */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
550 number++; /* we have found one more player */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
551 winners[k].planets = planets; /* record his planets and armies */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
552 winners[k].armies = armies;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
553 winners[k].resources = resources;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
554 winners[k].dooshes = dooshes;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
555 strncpy(winners[k].mapchars, twoletters(j), 2);
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
556 strncpy(winners[k].name, j->p_name, 16); /* get his name */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
557 winners[k].name[15] = 0; /* `Just in case' paranoia */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
558 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
559 for (k = 0; k < number; k++)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
560 { /* go through all players found */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
561 if (winners[k].planets != 0 || winners[k].armies != 0)
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
562 { /* damage done? */
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
563 sprintf(buf, " %16s (%2.2s) %d planets %d armies %d resources %d dooshes",
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
564 winners[k].name, winners[k].mapchars, winners[k].planets,
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
565 winners[k].armies, winners[k].resources, winners[k].dooshes);
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
566 OUT;
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
567 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
568 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
569 }
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
570
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
571 /*-------------------------------------------------------------------------*/
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
572
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
573
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
574
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
575
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
576
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
577
2719a89505ba First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
578 /*-----------END OF FILE-----*/