annotate src/planets.c @ 12:8f2256d473fb

Empty changelog
author darius
date Sat, 06 Dec 1997 05:10:46 +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
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
20 #define PLANETS 1
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
21 #define GRID 0 /* for space grid */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
22
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
23 #include "config.h"
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
24 #include <stdio.h>
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
25 #include <stdlib.h>
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
26 #include <string.h>
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
27 #include <math.h>
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
28 #include <setjmp.h>
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
29 #include <sys/types.h>
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
30 #include <sys/time.h>
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
31 #include <unistd.h>
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
32
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
33 #include "struct.h"
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
34 #include "data.h"
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
35 #include "daemonII.h"
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
36 #include "planets.h"
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
37 #include "misc.h"
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
38 #include "conquer.h"
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
39 #include "player.h"
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
40 #include "grid.h"
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
41 #include "shmem.h"
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
42 #include "terrain.h"
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
43
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
44
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
45 /* define this if you want the experimental dragging-into-star-counts mod */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
46 #define GIVESTARKILLS
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 #define friendly(fred, bart) \
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
49 (!(fred->p_team & (bart->p_swar|bart->p_hostile)) && \
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
50 !(bart->p_team & (fred->p_swar|fred->p_hostile)))
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
51
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
52
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
53 /* defines dealing with growth timers */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
54 #define PLGFUEL configvals->plgrow.fuel /* time for growth of fuel
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
55 * depot */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
56 #define PLGAGRI configvals->plgrow.agri /* time for growth of agri */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
57 #define PLGREPAIR configvals->plgrow.repair /* time for growth of
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
58 * repair */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
59 #define PLGSHIP configvals->plgrow.shipyard /* time for growth of
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
60 * shipyard */
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 /* other defines */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
63 #define UCVISIBLE 40000 /* dist for uncloaked visibility */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
64 #define CVISMIN 12000 /* cloakers always visible distance */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
65 #define CVISSPEED 2000 /* cloak dist added per warp point */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
66 #define CVISIBLE 25000 /* dist for cloaked visibility */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
67 #define PLFIREDIST 1500 /* distance planets fire at players */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
68 #define PLVISDIST 5000 /* dist planets sense enemy players */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
69 #define REVOLT 200 /* chance out of 1000 of revolt start */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
70 #define STARTREV 8 /* for revolt timer */
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
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
73
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
74
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
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
77
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
78 /*-----------------------------MODULE VARIABLES----------------------------*/
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
79
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
80 /* the list of all possible planet names */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
81 char *pnames[] =
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
82 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
83 /* Federation planets */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
84 "Rigel", "Canopus", "Beta Crucis", "Organia", "Deneb",
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
85 "Ceti Alpha V", "Altair", "Vega", "Alpha Centauri",
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
86 /* Romulan worlds */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
87 "Eridani", "Aldeberan", "Regulus", "Capella", "Tauri",
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
88 "Draconis", "Sirius", "Indi", "Hydrae",
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
89 /* Klingon worlds */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
90 "Pleiades V", "Andromeda", "Lalande", "Pollux", "Lyrae",
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
91 "Scorpii", "Mira", "Cygni", "Castor",
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
92 /* Orion worlds */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
93 "Cassiopia", "El Nath", "Spica", "Procyon", "Polaris",
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
94 "Arcturus", "Ursae Majoris", "Herculis", "Antares",
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 /* new worlds */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
97 "Planet 10", "Bezier", "Sequent", "Ophiuchi", "Lacaille",
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
98 "Luyten", "Pavonis", "Wolf 424", "Ross 882", "Cephei",
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
99 "Kruger", "Groombridge", "Maanen's Star", "Heinlein",
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
100 "Pixel", "Lazarus", "Mycroft", "Asimov", "Varley",
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
101 "Clarke's Star", "Ren", "Stimpy", "Foo", "Jolt Cola",
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
102 "Kelly Bundy", "Tyrell", "Roy", "Deckard", "Vangelis",
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
103 "Orpheus", "Xanth", "Tatooine", "Ludicrous", "Ogg",
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
104 "Scum", "Twink", "Chiapucci", "Bugno", "Hampsten", "Fignon",
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
105 "Paradise", "Azriel", "Gargamel", "Smurf Village",
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
106 "Praxis", "Acherner", "Arrakis", "Caladan", "Giedi Prime",
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
107 "Clue", "Paulina", "Sith", "Salusa", "Ahrain", "Cerranos",
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
108 "Darkurthe", "Dagobah", "Phaze", "Chatsubu", "Lemond",
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
109 "Bronco", "Vulcan", "Eden", "Klein", "Merckx", "Tarot",
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
110 "Mottet", "Roche", "Doorstop", "Shaedron", "Fondriest",
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 /* Bob's fave worlds */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
113 "Wayne's World", "DanjerHaus", "Anvil", /* B-52s */ "Claire",
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
114 "Planet Reebok", "Sony Corp.", "SEGA!", "McWorld",
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
115 "Tokyo", "New York", "D.C.", "Atlanta", /* places I've never been */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
116 /* Tony */ "Levin",
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
117 "Planet Woogie", "Nancy", "Wilson", /* real people */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
118 "Beavis", "Butthead",
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
119 "Memolo", /* Matt Memolo was murdered in Miami in July
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
120 * of '93. He was a really swell guy. "...he
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
121 * would go far out of his way to give you
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
122 * the shirt off his back." - ajc */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
123 /* names from the T.V. shows */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
124 "New Berlin",
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 * "Bejor", "Cardassia" I'm not including these till I can spell them - RF
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
127 */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
128
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
129 /* Mike's fave worlds */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
130 "Melmac", "Order", "Yosemite", "New Chicago", "Ceptus", "Ork",
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
131 "Levi 501", "Toughskin", "Wonka",
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
132
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
133 /* book names */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
134 "Terminus", "Magrathea", "Trantor", "Synnax", "Coruscant",
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
135
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
136 /* Moons, names, etc. */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
137 "Io ", "Titan", "Europa", "Ganymede", "Charon",
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
138 "Tholia", "Gor", "Kzin", "Aerth",
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
139 "Proxima", "Cellust", "Calamar", "Icarus",
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
140 "New Prague",
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 /* How about the solar system? */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
143 "Mercury", "Venus", "Mars", "Jupiter", "Saturn", "Neptune",
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
144 "Uranus", "Pluto", /* are Neptune and Uranus in order? */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
145
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
146 #if 0
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
147 /* Player's names */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
148 "Claypigeon", "Maxout", "Fungus", "Lynx",
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
149 "Bubbles", "KnightRaven", "Bolo", "Vladimir",
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
150 "Gajah Mada", "Trippix", "Shrew", "Bob Dobbs", "Wibble",
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
151 "Rogue"
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
152 #endif
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
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
155 #define MAXNAMES (sizeof(pnames)/sizeof(char *)) /* # of planet names */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
156
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
157 char *homenames[] = /* names of the race's home worlds */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
158 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
159 " ", "Earth", "Romulus", " ", "Klingus", " ", " ", " ",
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
160 "Orion"
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
161 };
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
162
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
163
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
164 /*
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
165 * This table is used to turn the four bits of resources flags into a three
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
166 * bit number. The shipyard and the repair are ORed together. All the non
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
167 * resource bits need to be masked off with PLRESMASK before this table is
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
168 * used
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 int restores[16] = {0, 1, 2, 3, 4, 5, 6, 7, 1, 1, 3, 3, 5, 5, 7, 7};
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
171
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 /*
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
174 * This is a matrix that determines the chance a planet has of popping. The
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
175 * chance is expressed as a chance out of 100. The matrix is accessed with
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
176 * the planet's atmosphere type and the resource bits after they have been
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
177 * converted to 3 bits with the table above.
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
178 */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
179 int popchance[4][8] = {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
180 /*
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
181 * 000 00Z 0f0 0fZ a00 a0Z af0 afZ--the resources flags,
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
182 * Z=r|s
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
183 */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
184 {2, 3, 2, 2, 5, 7, 4, 8}, /* poison */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
185 {3, 5, 2, 4, 9, 11, 7, 12}, /* atmos #3 */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
186 {5, 7, 4, 6, 12, 14, 10, 15}, /* atmos #2 */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
187 {8, 12, 7, 10, 20, 24, 18, 23}/* atmos #1 */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
188 };
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 * This is a matrix that determines the multiplier for popping. When popping
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
193 * the armies on a planet will be multiplied by this multiplier to get the
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
194 * number of extra armies that grow. A negative number indicates negative
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
195 * growth.
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
196 */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
197 float popmult[4][8] = {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
198 /* 000 00Z 0f0 0fZ a00 a0Z af0 afZ */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
199 {-0.08, 0.00, -0.10, -0.03, 0.00, 0.05, -0.05, 0.05}, /* poison */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
200 {0.03, 0.05, 0.02, 0.04, 0.06, 0.07, 0.06, 0.07}, /* atmos #3 */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
201 {0.05, 0.07, 0.05, 0.06, 0.10, 0.11, 0.08, 0.10}, /* atmos #2 */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
202 {0.09, 0.12, 0.08, 0.10, 0.17, 0.19, 0.15, 0.18} /* atmos #1 */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
203 };
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
204
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
205
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
206 /*
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
207 * This is a matrix that determines the maximum army capacity of a planet.
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
208 * Once this capacity is reached, no other armies can grow there.
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 float popcap[4][8] = {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
211 /*
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
212 * 000 00Z 0f0 0fZ a00 a0Z af0 afZ--the resources flags,
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
213 * Z=r|s
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 {5, 10, 7, 10, 15, 15, 10, 18}, /* poison */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
216 {9, 14, 11, 14, 20, 20, 14, 22}, /* atmos #3 */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
217 {12, 18, 15, 18, 25, 25, 19, 27}, /* atmos #2 */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
218 {15, 22, 18, 25, 40, 35, 27, 40} /* atmos #1 */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
219 };
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
220
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
221 /*-------------------------------------------------------------------------*/
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
222
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
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
225
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
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
228
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
229
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
230 #ifdef LEAGUE_SUPPORT
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
231 extern void tlog_res();
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
232 extern void tlog_bomb();
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
233 extern void tlog_bres();
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
234 extern void tlog_plankill();
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
235 extern void tlog_revolt();
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
236 extern void tlog_pop();
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
237 #else
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
238 #define tlog_res(a,b)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
239 #define tlog_bomb(a,b,c)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
240 #define tlog_bres(a,b,c)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
241 #define tlog_plankill(a,b,c)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
242 #define tlog_revolt(a)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
243 #define tlog_pop(a,b)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
244 #endif
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
245 extern void scout_planet();
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
246 extern int inflict_damage();
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
247 extern void killmess();
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
248 extern int enemy_admiral();
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
249 extern off_t lseek();
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
250 extern int write();
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
251
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
252 /*------------------------------INTERNAL FUNCTIONS-------------------------*/
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
253
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
254 void fill_planets();
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 #ifndef NO_QSORT
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
258 /* used by the qsort() in sortnames() below */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
259 static int
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
260 comp_pl_name(a, b)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
261 void *a, *b;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
262 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
263 return strcasecmp(((struct planet *) a)->pl_name,
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
264 ((struct planet *) b)->pl_name);
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
265 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
266 #endif
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
267
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
268 /*--------------------------------SORTNAMES---------------------------------*/
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
269 /*
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
270 * This function sorts the planet into a alphabeticly increasing list. It
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
271 * operates on the global planets structure. This uses a simple bubble sort
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
272 * because I was too lazy to write anything more sophisticated.
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
273 */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
274
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
275 /*
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
276 * Bubble sorts suck. Let's use the qsort library function instead, if
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
277 * available (HK)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
278 */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
279
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
280 void
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
281 sortnames()
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
282 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
283 #ifdef NO_QSORT
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
284 struct planet ptemp; /* temporary space to hold planet */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
285 int exchange; /* flag for exchange made in pass */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
286 int i; /* looping var */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
287 int t; /* temp var */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
288
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
289 exchange = 1; /* no exchanges done yet */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
290 while (exchange)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
291 { /* do until no exchanges */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
292 exchange = 0; /* no exchanges for this pass yet */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
293 for (i = 0; i < NUMPLANETS - 1; i++)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
294 { /* go through list */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
295 if (strcmp(planets[i].pl_name, planets[i + 1].pl_name) > 0)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
296 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
297 t = planets[i].pl_no; /* exchange planet numbers */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
298 planets[i].pl_no = planets[i + 1].pl_no;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
299 planets[i + 1].pl_no = t;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
300 memcpy(&ptemp, &(planets[i]), sizeof(struct planet));
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
301 memcpy(&(planets[i]), &(planets[i + 1]), sizeof(struct planet));
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
302 memcpy(&(planets[i + 1]), &ptemp, sizeof(struct planet));
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
303 exchange++; /* we made an exchange this pass */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
304 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
305 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
306 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
307 #else
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
308 int i;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
309
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
310 qsort(planets, NUMPLANETS, sizeof(struct planet), comp_pl_name);
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
311 for (i = 0; i < NUMPLANETS; i++) /* go through the planets */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
312 planets[i].pl_no = i; /* and fix their pl_no value */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
313 #endif
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
314 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
315
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
316
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
317 /*--------------------------------INITPLANETS-------------------------------*/
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
318 /*
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
319 * This function generates the names and initializes the fields in the
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
320 * planets structure. The planet names need to be sorted afterthe planets
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
321 * have been placed.
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
322 */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
323
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
324 void
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
325 initplanets()
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
326 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
327 int i, j; /* looping vars */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
328 int nused[MAXNAMES]; /* to mark which names are used */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
329
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
330 for (i = 0; i < MAXNAMES; i++)/* go through all possible names */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
331 nused[i] = 0; /* mark name is not used yet */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
332 for (i = 0; i < NUMPLANETS; i++)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
333 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
334 planets[i].pl_no = i; /* set planet number */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
335 planets[i].pl_flags = PLPARADISE; /* Paradise planet */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
336 planets[i].pl_owner = NOBODY; /* no owner yet */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
337 planets[i].pl_x = 0; /* just to intialize x and y */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
338 planets[i].pl_y = 0;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
339 j = lrand48() % MAXNAMES; /* get a random name */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
340 do
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
341 { /* do until unused name found */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
342 j = (j + 1) % MAXNAMES; /* go on to next name in list */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
343 } while (nused[j]); /* until unused name found */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
344 nused[j] = 1; /* mark name as used */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
345 strcpy(planets[i].pl_name, pnames[j]); /* copy into planet struct */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
346 planets[i].pl_namelen = strlen(pnames[j]); /* set name's length */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
347 #if 1
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
348 planets[i].pl_hostile = 0; /* planet doesn't hate anyone yet */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
349 #else
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
350 planets[i].pl_torbit = 0; /* no teams orbiting */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
351 #endif
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
352 planets[i].pl_tshiprepair = 0; /* zero the repair growth timer */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
353 planets[i].pl_tagri = 0; /* zero the agri growth timer */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
354 planets[i].pl_tfuel = 0; /* zero the fuel growth timer */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
355 planets[i].pl_armies = 0; /* no armies yet */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
356 planets[i].pl_warning = 0; /* no warning being counted down for */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
357 planets[i].pl_system = 0; /* not in a system yet */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
358 planets[i].pl_hinfo = NOBODY; /* no race has info on planet */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
359 for (j = 0; j < MAXTEAM + 1; j++)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
360 { /* go through four races */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
361 planets[i].pl_tinfo[j].owner = NOBODY; /* do not know who owns it */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
362 planets[i].pl_tinfo[j].armies = 0; /* no armies on planet */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
363 planets[i].pl_tinfo[j].flags = PLPARADISE; /* know nothing about
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
364 * flags */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
365 planets[i].pl_tinfo[j].timestamp = 0; /* set the timestamp */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
366 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
367 planets[i].pl_trevolt = 0; /* revolt timer not counting down */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
368 #if GRID
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
369 planets[i].pl_next = NULL; /* set fields related to space grid */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
370 planets[i].pl_previous = NULL;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
371 planets[i].pl_gridnum = 0;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
372 #endif
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
373 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
374 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
375
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
376
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
377
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
378
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
379 /*-------------------------------GROWPLANETS------------------------------*/
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
380 /*
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
381 * This function grows resources on planets. It goes through all planets and
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
382 * updates the growth timers and checks for growth. Independent planets do
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
383 * not grow. This function also checks to see if any player in a starbase is
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
384 * orbiting a planet and adjusts the planet's growth rate if so.
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
385 */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
386
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
387 void
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
388 growplanets()
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
389 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
390 int i; /* looping var */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
391 struct planet *p; /* to point within planets */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
392 int add; /* number to add to timers */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
393
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
394 if (!status->tourn)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
395 return;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
396
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
397 if (!configvals->resource_bombing)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
398 return;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
399
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
400 for (i = 0; i < MAXPLAYER; i++)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
401 { /* go through all players */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
402 struct player *py = &players[i]; /* and look for orbiting */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
403 if ((py->p_status != PALIVE) || /* starbases */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
404 (py->p_ship.s_type != STARBASE) ||
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
405 !(py->p_flags & PFORBIT))
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
406 continue;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
407 p = &planets[py->p_planet]; /* found one, get planet */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
408 p->pl_tfuel += 20; /* give growth rate a boost */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
409 p->pl_tagri += 30; /* NOTE: change these if PLG consts */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
410 p->pl_tshiprepair += 50; /* change */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
411 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
412 p = &planets[0]; /* start with first planet */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
413 for (i = 0; i < NUMPLANETS; i++, p++)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
414 { /* through all planets */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
415 if (p->pl_owner == NOBODY) /* if independent then */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
416 continue; /* no growth */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
417 add = p->pl_armies / 2; /* rate based on armies */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
418 p->pl_tfuel += add; /* add to fuel timer */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
419 p->pl_tfuel = (p->pl_tfuel > PLGFUEL) ? PLGFUEL : p->pl_tfuel;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
420 if ((!(p->pl_flags & PLFUEL)) /* if no fuel */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
421 && (p->pl_flags & PLDILYTH) /* and dilythium deposits */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
422 && (p->pl_tfuel >= PLGFUEL))
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
423 { /* and timer high enough */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
424 p->pl_flags |= (PLFUEL | PLREDRAW); /* create fuel depot */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
425 p->pl_tinfo[p->pl_owner].flags = p->pl_flags;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
426 p->pl_tinfo[p->pl_owner].timestamp = status->clock;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
427 tlog_res(p, "FUEL");
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
428 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
429 p->pl_tagri += add; /* add to agri timer */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
430 p->pl_tagri = (p->pl_tagri > PLGAGRI) ? PLGAGRI : p->pl_tagri;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
431 if ((!(p->pl_flags & PLAGRI)) /* if no agri on planet */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
432 && (p->pl_flags & PLARABLE) /* and arable */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
433 && (p->pl_tagri >= PLGAGRI))
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
434 { /* and timer high enough */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
435 p->pl_flags |= (PLAGRI | PLREDRAW); /* create agri planet */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
436 p->pl_tinfo[p->pl_owner].flags = p->pl_flags;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
437 p->pl_tinfo[p->pl_owner].timestamp = status->clock;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
438 tlog_res(p, "AGRI");
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
439 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
440 p->pl_tshiprepair += add; /* add to ship/repair timer */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
441 if ((!(p->pl_flags & PLREPAIR)) /* if not repair */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
442 && (p->pl_flags & PLMETAL) /* and metal deposits */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
443 && (p->pl_tshiprepair >= PLGREPAIR))
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
444 { /* and timer high enough */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
445 p->pl_flags |= (PLREPAIR | PLREDRAW); /* create repair station */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
446 p->pl_tinfo[p->pl_owner].flags = p->pl_flags;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
447 p->pl_tinfo[p->pl_owner].timestamp = status->clock;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
448 tlog_res(p, "REPAIR");
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
449 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
450 p->pl_tshiprepair = (p->pl_tshiprepair > PLGSHIP) ? PLGSHIP :
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
451 p->pl_tshiprepair; /* clamp value to max */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
452 if ((!(p->pl_flags & PLSHIPYARD)) /* if not repair */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
453 && (p->pl_flags & PLMETAL) /* and metal deposits */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
454 && (p->pl_tshiprepair >= PLGSHIP))
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
455 { /* and timer high enough */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
456 p->pl_flags |= (PLSHIPYARD | PLREDRAW); /* create repair station */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
457 p->pl_tinfo[p->pl_owner].flags = p->pl_flags;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
458 p->pl_tinfo[p->pl_owner].timestamp = status->clock;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
459 tlog_res(p, "SHIPYARD");
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
460 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
461 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
462 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
463
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
464
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
465
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
466
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
467 /*----------------------------------PVISIBLE------------------------------*/
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
468 /*
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
469 * This function goes through the players and checks the other playes to see
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
470 * if an enemy is close enough to see him. THIS FUNCTION SHOULD EVENTUALLY
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
471 * USE THE SPACE GRID.
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
472 */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
473
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
474 void
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
475 pvisible()
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
476 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
477 struct player *p; /* to point to a player */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
478 int i; /* looping var */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
479 int h; /* looping var */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
480 struct player *pl2; /* to point to other players */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
481 int dx, dy; /* delta coords */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
482 int dist; /* to hold distance */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
483
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
484 for (i = 0, p = &players[0]; i < MAXPLAYER; i++, p++)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
485 p->p_flags &= ~PFSEEN; /* clear all players' the seen flags */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
486 for (i = 0, p = &players[i]; i < MAXPLAYER - 1; i++, p++)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
487 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
488 if (p->p_status != PFREE && /* only do if player alive */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
489 p->p_status != POBSERVE)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
490 { /* observers can't augment team scanning */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
491 for (h = i + 1, pl2 = &players[h]; h < MAXPLAYER; h++, pl2++)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
492 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
493 if ((pl2->p_status == PFREE) || (pl2->p_status == POBSERVE)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
494 || (pl2->p_flags & PFROBOT) /* if not alive or robot or */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
495 || (pl2->p_team == p->p_team)) /* same team then continue */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
496 continue;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
497 dx = ABS(pl2->p_x - p->p_x); /* calc delta coords */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
498 dy = ABS(pl2->p_y - p->p_y);
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
499 if ((dx > UCVISIBLE) || (dy > UCVISIBLE)) /* if obviously too far
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
500 * away */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
501 continue; /* then don't bother further */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
502 dist = ihypot(dx, dy);
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
503 if (dist > UCVISIBLE) /* out of range */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
504 continue; /* on to next ship */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
505 if ((dist < CVISMIN + CVISSPEED * pl2->p_speed) ||
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
506 (!(pl2->p_flags & PFCLOAK)))
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
507 pl2->p_flags |= PFSEEN; /* if close then visible */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
508 if ((dist < CVISMIN + CVISSPEED * p->p_speed) ||
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
509 (!(p->p_flags & PFCLOAK)))
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
510 p->p_flags |= PFSEEN; /* second player */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
511 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
512 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
513 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
514 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
515
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
516
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
517
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
518 void
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
519 blast_resource(p, l, res, dival)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
520 struct player *p;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
521 struct planet *l;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
522 int res;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
523 double dival;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
524 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
525 if (status->tourn)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
526 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
527 p->p_stats.st_di += dival;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
528 p->p_stats.st_tresbomb++;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
529 p->p_resbomb++;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
530 status->resbomb++;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
531 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
532 l->pl_flags &= ~res;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
533 l->pl_tinfo[l->pl_owner].flags = l->pl_flags;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
534 l->pl_tinfo[l->pl_owner].timestamp = status->clock;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
535 l->pl_tinfo[p->p_team].flags = l->pl_flags;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
536 l->pl_tinfo[p->p_team].timestamp = status->clock;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
537 l->pl_flags |= PLREDRAW; /* slate for redraw */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
538 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
539
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
540 /*-----------------------------------PBOMB---------------------------------*/
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
541 /*
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
542 * This function goes through the players and does the bombing if any player
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
543 * is bombing. This will knock resources off of planets. If a player is
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
544 * bombing a planet that another team owns, then that team will see the
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
545 * player by having the PFSEEN flag set.
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
546 */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
547
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
548 void
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
549 pbomb()
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
550 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
551 struct player *p; /* to point to a player */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
552 int i; /* looping var */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
553 struct planet *l; /* to point to planet being bombed */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
554 char buf[90]; /* to sprintf messages into */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
555 char buf1[80];
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
556 int rnd; /* to hold armies to knock off */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
557
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
558 for (i = 0, p = &players[0]; i < MAXPLAYER; i++, p++)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
559 { /* go through playrs */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
560 if ((p->p_status == PALIVE) /* only do if player is alive */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
561 && (p->p_flags & PFORBIT) /* and he is orbiting */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
562 && (p->p_flags & PFBOMB))
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
563 { /* and he is bombing */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
564
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
565 l = &planets[p->p_planet];/* get planet being bombed */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
566
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
567 if ((!((p->p_swar | p->p_hostile) & l->pl_owner))
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
568 && (l->pl_owner != NOBODY))
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
569 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
570 /* if he's non-hostile, quit bombing */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
571 p->p_flags &= ~PFBOMB;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
572 continue;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
573 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
574 if ((l->pl_warning <= 0) && (l->pl_owner != NOBODY))
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
575 { /* warning? */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
576 l->pl_warning = 50 / PLFIGHTFUSE; /* reset warning timer */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
577 sprintf(buf, "We are being attacked by %s %s who is %d%% damaged.",
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
578 p->p_name, twoletters(p),
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
579 (100 * p->p_damage) / (p->p_ship.s_maxdamage));
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
580 sprintf(buf1, "%-3s->%-3s", l->pl_name, teams[l->pl_owner].shortname);
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
581 pmessage(buf, l->pl_owner, MTEAM | MBOMB, buf1); /* send message */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
582
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
583 /* CRD feature: shipyard guardians - MAK, 2-Jun-93 */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
584 if ((l->pl_flags & PLSHIPYARD) && (!status->tourn))
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
585 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
586 rescue(l->pl_owner, 0, l->pl_no);
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
587 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
588 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
589 p->p_swar |= l->pl_owner; /* set player at war w/ owner */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
590 rnd = (lrand48() % 50) + p->p_ship.s_bomb; /* pick random number */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
591 rnd = (int) ((float) rnd / 33.0 + 0.5); /* calc armies bombed */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
592 if (rnd <= 0)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
593 continue; /* can't bomb negative armies */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
594 if (l->pl_armies > 4)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
595 { /* if armies to bomb then */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
596 l->pl_armies -= rnd; /* kill off armies */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
597 tlog_bomb(l, p, rnd);
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
598 l->pl_armies = (l->pl_armies < 1) ? 1 : l->pl_armies;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
599 l->pl_tinfo[l->pl_owner].armies = l->pl_armies;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
600 l->pl_tinfo[l->pl_owner].timestamp = status->clock;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
601 l->pl_tinfo[p->p_team].armies = l->pl_armies;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
602 l->pl_tinfo[p->p_team].timestamp = status->clock;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
603 if (l->pl_armies < 5) /* if planet needs to be redrawn */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
604 l->pl_flags |= PLREDRAW; /* schedule planet for redraw */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
605 if (l->pl_owner != NOBODY)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
606 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
607 credit_armiesbombed(p, rnd, l);
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
608 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
609 } /* now do the resource bombing */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
610 if ((l->pl_armies > 4) ||
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
611 (!configvals->resource_bombing)) /* no bombing resources if
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
612 * armies */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
613 continue; /* on planet or in bronco-mode */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
614 #if defined(AEDILE) || defined(SLOW_BOMB)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
615 l->pl_tfuel -= rnd * 5; /* knock fuel timer down */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
616 #else
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
617 l->pl_tfuel -= rnd * 8; /* knock fuel timer down */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
618 #endif
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
619 l->pl_tfuel = (l->pl_tfuel < 0) ? 0 : l->pl_tfuel;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
620 if ((l->pl_tfuel == 0) && (l->pl_flags & PLFUEL))
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
621 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
622 blast_resource(p, l, PLFUEL, 0.10);
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
623 tlog_bres(l, p, "FUEL");
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
624 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
625 #if defined(AEDILE) || defined(SLOW_BOMB)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
626 l->pl_tagri -= rnd * 4; /* attack the agri timer */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
627 #else
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
628 l->pl_tagri -= rnd * 6; /* attack the agri timer */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
629 #endif
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
630 l->pl_tagri = (l->pl_tagri < 0) ? 0 : l->pl_tagri;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
631 if ((l->pl_tagri == 0) && (l->pl_flags & PLAGRI))
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
632 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
633 blast_resource(p, l, PLAGRI, 0.25);
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
634 tlog_bres(l, p, "AGRI");
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
635 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
636 #if defined(AEDILE) || defined(SLOW_BOMB)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
637 l->pl_tshiprepair -= rnd * 5; /* knock ship/repr down */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
638 #else
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
639 l->pl_tshiprepair -= rnd * 8; /* knock ship/repr down */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
640 #endif
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
641 l->pl_tshiprepair = (l->pl_tshiprepair < 0) ? 0 :
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
642 l->pl_tshiprepair;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
643 if ((l->pl_tshiprepair < PLGREPAIR) && (l->pl_flags & PLSHIPYARD))
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
644 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
645 blast_resource(p, l, PLSHIPYARD, 0.10);
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
646 tlog_bres(l, p, "SHIPYARD");
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
647 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
648 if ((l->pl_tshiprepair == 0) && (l->pl_flags & PLREPAIR))
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
649 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
650 blast_resource(p, l, PLREPAIR, 0.20);
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
651 tlog_bres(l, p, "REPAIR");
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
652 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
653 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
654 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
655 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
656
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
657
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
658
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
659
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
660 /*---------------------------------PFIRE-----------------------------------*/
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
661 /*
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
662 * This function goes through the planets and sees if any enemy players are
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
663 * close enough to be fired upon by the planet. It also checks to see if
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
664 * players are close enough to the planet so that the planet should be
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
665 * redrawn. Enemy planets will 'see' players that are very close to them.
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
666 * THIS FUNCTION SHOULD EVENTUALLY USE THE SPACE GRID.
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
667 */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
668
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
669 void
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
670 pfire()
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
671 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
672 struct player *p; /* to point to a player */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
673 int i, j; /* looping vars */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
674 struct planet *l; /* to point to the planets */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
675 int dx, dy; /* to hold delta coords */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
676 int dist; /* to hold distance */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
677 int dam; /* to hold damage */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
678 int boost; /* for warp zones, total boost [BDyess] */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
679
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
680 for (j = 0, p = &players[0]; j < MAXPLAYER; j++, p++)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
681 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
682 if (p->p_status != PALIVE)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
683 continue;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
684 boost = 0; /* default no bonus or penalty [BDyess] */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
685 for (i = 0, l = &planets[0]; i < NUMPLANETS; i++, l++)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
686 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
687 if ((p->p_team == l->pl_owner) && (PL_TYPE(*l) != PLSTAR)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
688 && !configvals->warpzone)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
689 continue; /* no, then continue */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
690 dx = ABS(l->pl_x - p->p_x); /* calc delta coorda between */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
691 dy = ABS(l->pl_y - p->p_y); /* planet and player */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
692 dist = ihypot(dx, dy);
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
693
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
694 if (dist < configvals->warpzone)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
695 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
696 /* within warp boost/block range [BDyess] */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
697 if (p->p_team == l->pl_owner)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
698 boost += configvals->warpzone - dist;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
699 else if (l->pl_owner != NOBODY &&
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
700 ((p->p_swar | p->p_hostile) & l->pl_owner))
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
701 boost -= configvals->warpzone - dist;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
702 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
703
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
704 if (dx < 6 * PLFIREDIST && dy < 6 * PLFIREDIST) /* redraw planet */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
705 l->pl_flags |= PLREDRAW;/* if player is very close */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
706
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
707 if (dist <= p->p_ship.s_scanrange)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
708 { /* check for scanners */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
709 scout_planet(p->p_no, l->pl_no);
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
710 #if 0
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
711 handled in scout_planet now.
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
712 l->pl_hinfo |= p->p_team;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
713 l->pl_tinfo[p->p_team].armies = l->pl_armies;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
714 l->pl_tinfo[p->p_team].flags = l->pl_flags;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
715 l->pl_tinfo[p->p_team].owner = l->pl_owner;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
716 l->pl_tinfo[p->p_team].timestamp = status->clock;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
717 #endif
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
718 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
719
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
720 if (dist > PLVISDIST)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
721 continue;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
722 if ((dist < PLVISDIST) && (l->pl_owner != NOBODY) /* enemy planet */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
723 && ((p->p_swar | p->p_hostile) & l->pl_owner)) /* see players */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
724 p->p_flags |= PFSEEN; /* let team see enemy */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
725 if ((dist > PFIREDIST) ||
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
726 ((dist > PFIREDIST / 2) &&
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
727 (PL_TYPE(*l) == PLWHOLE))) /* if not within range */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
728 continue; /* go on to next playert */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
729 if (((p->p_swar | p->p_hostile) & l->pl_owner)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
730 || ((l->pl_owner == NOBODY)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
731 #if 1
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
732 && (l->pl_hostile & p->p_team)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
733 #else
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
734 && (l->pl_torbit & (p->p_team << 4))
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
735 #endif
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
736 && (l->pl_armies != 0))
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
737 || (PL_TYPE(*l) == PLWHOLE) || (PL_TYPE(*l) == PLSTAR))
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
738 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
739 dam = l->pl_armies / 7 + 2; /* calc the damage */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
740 if (PL_TYPE(*l) == PLWHOLE)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
741 { /* if a wormhole... */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
742 /* ...place outside the new wormhole's radius. */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
743 if ((wh_effect[SS_WARP] && !(p->p_flags & PFWARP))
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
744 || (!wh_effect[SS_WARP]))
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
745 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
746 p->p_x = l->pl_armies +
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
747 (((PLFIREDIST / 2) + 50) * Cos[p->p_dir]);
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
748 p->p_y = l->pl_radius +
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
749 (((PLFIREDIST / 2) + 50) * Sin[p->p_dir]);
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
750 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
751 if ((p->p_speed > (p->p_ship.s_imp.maxspeed / 2)) &&
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
752 (wh_effect[SS_IMPULSE]))
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
753 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
754 dam = ((p->p_ship.s_mass / 100) * (p->p_speed -
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
755 p->p_ship.s_imp.maxspeed / 2));
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
756 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
757 else
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
758 dam = 0;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
759
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
760 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
761 else if (PL_TYPE(*l) == PLSTAR) /* if planet is a star */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
762 dam = 150; /* do massive damage */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
763 /*
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
764 * this needs to be reworked and most of it jammed into
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
765 * inflict_damage
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
766 */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
767 p->p_whodead = i; /* which planet is shooting */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
768 if (dam > 0 && inflict_damage(0, 0, p, dam, KPLANET))
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
769 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
770 struct player *killer = 0;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
771 p->p_whydead = KPLANET; /* set killed by a planet */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
772 if (PL_TYPE(*l) == PLSTAR)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
773 { /* killed by star? */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
774 #ifdef GIVESTARKILLS
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
775 int pln;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
776 for (pln = 0, killer = &players[0];
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
777 pln < MAXPLAYER;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
778 pln++, killer++)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
779 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
780 if (killer->p_status != PALIVE)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
781 continue;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
782 if (!friendly(killer, p) && killer->p_tractor == p->p_no
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
783 && killer->p_flags & (PFTRACT | PFPRESS))
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
784 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
785
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
786 killer->p_kills += 1 + (p->p_armies + p->p_kills) / 10;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
787 killerstats(killer->p_no, p);
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
788 checkmaxkills(killer->p_no);
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
789 break;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
790 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
791 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
792 if (pln >= MAXPLAYER)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
793 killer = 0;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
794 #endif
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
795 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
796 killmess(p, killer);
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
797 tlog_plankill(p, l, killer);
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
798 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
799 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
800 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
801 /* found the boost for this player, make adjustments if in warp [BDyess] */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
802 if (configvals->warpzone && p->p_flags & PFWARP)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
803 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
804 if (boost == 0 && p->p_zone > 0)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
805 { /* did get warp bonus, lost it */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
806 if (p->p_desspeed > p->p_ship.s_warp.maxspeed)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
807 p->p_desspeed = p->p_ship.s_warp.maxspeed;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
808 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
809 else if (boost < 0 && p->p_zone >= 0)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
810 { /* warp no longer allowed */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
811 p->p_desspeed = p->p_ship.s_imp.maxspeed;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
812 if (!configvals->warpdecel)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
813 p->p_flags &= ~PFWARP;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
814 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
815 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
816 p->p_zone = boost;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
817 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
818 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
819
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
820
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
821
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
822
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
823 /*---------------------------------REVOLT---------------------------------*/
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
824 /*
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
825 * This function does the revolt of a planet. It updates the revolt timer
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
826 * and prints the messages that warn the team.
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
827 */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
828
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
829 void
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
830 revolt(l)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
831 struct planet *l; /* the planet to check */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
832 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
833 if (!configvals->revolts)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
834 return;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
835
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
836 if (l->pl_trevolt > 0)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
837 { /* revolt timer running? */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
838 char buf[80]; /* to sprintf into */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
839
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
840 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
841 int i;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
842 for (i = 0; i < MAXPLAYER; i++)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
843 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
844 if (players[i].p_status == PALIVE
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
845 && (players[i].p_flags & (PFORBIT | PFDOCK)) == PFORBIT
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
846 && players[i].p_planet == l->pl_no
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
847 && players[i].p_team == l->pl_owner)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
848 return; /* orbiting ship delays revolt */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
849 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
850 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
851
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
852 l->pl_trevolt--; /* dec the timer */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
853 if ((l->pl_trevolt == 0) && (l->pl_armies > 2))
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
854 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
855 l->pl_trevolt = 0; /* turn off revolt timer */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
856 sprintf(buf, "The revolution on %s has been put down.",
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
857 l->pl_name); /* get message to display */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
858 pmessage(buf, l->pl_owner, MTEAM | MCONQ, "PREFECT->");
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
859 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
860 else if ((l->pl_trevolt == 0) && (l->pl_armies == 2))
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
861 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
862 l->pl_trevolt = STARTREV; /* more time til last army */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
863 l->pl_armies--; /* kill one army */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
864 l->pl_tinfo[l->pl_owner].armies = l->pl_armies;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
865 l->pl_tinfo[l->pl_owner].timestamp = status->clock;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
866 sprintf(buf, "We cannot hold out much longer on %s",
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
867 l->pl_name); /* get message to display */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
868 pmessage(buf, l->pl_owner, MTEAM | MCONQ, "PREFECT->");
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
869 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
870 else if (l->pl_trevolt == 0)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
871 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
872 l->pl_trevolt = 0; /* revolution succeeded */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
873 sprintf(buf, "The planet %s has been lost to revolutionaries",
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
874 l->pl_name); /* get message to display */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
875 pmessage(buf, l->pl_owner, MTEAM | MCONQ, "PREFECT->");
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
876
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
877 tlog_revolt(l);
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
878
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
879 l->pl_tinfo[l->pl_owner].timestamp = status->clock;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
880 l->pl_tinfo[l->pl_owner].owner = NOBODY;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
881 l->pl_owner = NOBODY;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
882 l->pl_flags |= PLREDRAW; /* slate for redraw */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
883 checkwin(enemy_admiral(-1)); /* check for game end */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
884
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
885 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
886 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
887 else
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
888 { /* no revolt timer--check for start */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
889 if ((l->pl_armies <= 2) && (!(l->pl_armies == 0))
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
890 && ((lrand48() % 1000) <= REVOLT))
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
891 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
892 char buf[80]; /* to sprintf message into */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
893
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
894 sprintf(buf, "There is civil unrest on %s", l->pl_name);
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
895 pmessage(buf, l->pl_owner, MTEAM | MCONQ, "PREFECT>>");
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
896 l->pl_trevolt = STARTREV; /* time before revolution */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
897 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
898 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
899 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
900
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
901 void
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
902 check_revolt()
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
903 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
904 static int planetlist[MAXPLANETS];
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
905 static int count = 0;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
906 int idx;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
907 struct planet *l;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
908
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
909 if (!status->tourn)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
910 return;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
911
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
912 if (count < 1)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
913 fill_planets(planetlist, &count, -1);
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
914
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
915 idx = planetlist[--count];
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
916 l = &planets[idx];
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
917
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
918 if (l->pl_armies > 0 && l->pl_owner != NOBODY)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
919 revolt(l);
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
920 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
921
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
922 /*-------------------------------------------------------------------------*/
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
923
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
924
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
925
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
926
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
927
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
928
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
929 /* struct planet *stars[NUMPLANETS + 1]; */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
930
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
931 static void
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
932 build_stars_array()
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
933 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
934 int i;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
935 struct planet *pl;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
936
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
937 for (i = 0; i < NUMPLANETS; i++)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
938 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
939 pl = &planets[i];
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
940 if (PL_TYPE(*pl) == PLSTAR)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
941 stars[pl->pl_system] = i;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
942 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
943 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
944
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
945 /*------------------------------VISIBLE FUNCTIONS-------------------------*/
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
946
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
947 /*-------------------------------GEN_PLANETS-------------------------------*/
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
948 /*
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
949 * This function generates a number of random planets. The planets are
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
950 * arranged in systems and are also placed so that they are not too close to
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
951 * any other planets. The races are then given home planets.
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
952 */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
953
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
954 void
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
955 gen_planets()
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
956 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
957 int i;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
958 struct planet *pl;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
959
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
960 status->clock = 0; /* reset the timestamp clock */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
961
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
962 switch (configvals->galaxygenerator)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
963 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
964 case 2:
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
965 gen_galaxy_2(); /* Bob Forsman's compact galaxy generator */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
966 break;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
967 case 3:
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
968 gen_galaxy_3(); /* Heath's better race placement galaxy
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
969 * generator */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
970 break;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
971 case 4:
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
972 gen_galaxy_4(); /* Mike's Bronco emulator */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
973 break;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
974 case 5:
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
975 gen_galaxy_5(); /* Mike's small-galaxy generator */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
976 break;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
977 case 6:
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
978 gen_galaxy_6(); /* Brandon's hack on Heath's to give 2 */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
979 break; /* systems to each race */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
980 case 7:
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
981 gen_galaxy_7(); /* Eric Dormans deepspace galaxy gen, rooted
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
982 * in galaxy gen 6. */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
983 break;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
984 case 1:
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
985 default:
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
986 gen_galaxy_1(); /* original paradiseII galaxy generator */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
987 break;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
988 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
989
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
990 if (configvals->galaxygenerator != 4)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
991 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
992 /* gotta do this before they are sorted */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
993 for (i = 0; i < NUMPLANETS; i++)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
994 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
995 pl = &planets[i];
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
996 if (PL_TYPE(*pl) == PLSTAR ||
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
997 ((pl->pl_system == 0) && (PL_TYPE(*pl) != PLWHOLE)))
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
998 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
999 pl->pl_radius = 0;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1000 pl->pl_angle = 0;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1001 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1002 else if (PL_TYPE(*pl) != PLWHOLE)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1003 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1004 int dx, dy;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1005 dx = pl->pl_x - planets[pl->pl_system - 1].pl_x;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1006 dy = pl->pl_y - planets[pl->pl_system - 1].pl_y;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1007 pl->pl_radius = ihypot(dx, dy);
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1008 pl->pl_angle = atan2((double) dy, (double) dx);
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1009 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1010 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1011 sortnames(); /* sort the names of planets */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1012 build_stars_array();
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1013 if (configvals->neworbits)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1014 pl_neworbit();
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1015 generate_terrain();
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1016 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1017 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1018
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1019 void
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1020 pl_neworbit()
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1021 /*
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1022 * rearranges a pre-existing galaxy setup such that planets orbit at more
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1023 * "unique" distances from their star. Asteroids look and probably play bad
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1024 * when all the planets are approx. the same dist from the star, so I'd
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1025 * suggest turning this on if you plan to have asteroids or orbiting planets
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1026 * on your server. I'd suggest turning it on even if you don't. :) -MDM
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1027 */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1028 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1029 register int i, j;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1030 register struct planet *p;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1031 register int numStars = 0, planetsThisStar = 0;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1032 #ifndef IRIX
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1033 int planetList[NUMPLANETS];
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1034 #else
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1035 int planetList[70];
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1036 #endif
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1037
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1038 /* find the number of stars */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1039 for (i = 0; i < MAXPLANETS; i++)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1040 if (PL_TYPE(planets[i]) == PLSTAR)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1041 numStars++;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1042
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1043 /* for each star, find the number of planets, and the average distance */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1044
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1045 for (i = 1; i <= numStars; i++)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1046 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1047 planetsThisStar = 0;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1048 for (j = 0; j < MAXPLANETS; j++)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1049 if (planets[j].pl_system == i)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1050 planetList[planetsThisStar++] = j;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1051
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1052 /*
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1053 * now move the planets such that each planet we came across gets its
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1054 * previous distance from it's star, times (it's position in the
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1055 * planetList array)/(planetsThisStar/1.6). also make sure that new
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1056 * radius isin't so close to star ship can't orbit it. Heh. Separate
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1057 * the men from the boyz, eh?
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1058 */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1059
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1060 for (j = 0; j < planetsThisStar; j++)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1061 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1062 planets[planetList[j]].pl_radius =
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1063 (int) ((float) planets[planetList[j]].pl_radius *
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1064 ((float) (j + 1) / (float) (planetsThisStar / 1.6))) + 1500;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1065 planets[planetList[j]].pl_x =
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1066 planets[stars[i]].pl_x +
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1067 (int) ((float) cos(planets[planetList[j]].pl_angle) *
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1068 (float) planets[planetList[j]].pl_radius);
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1069 planets[planetList[j]].pl_y =
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1070 planets[stars[i]].pl_y +
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1071 (int) ((float) sin(planets[planetList[j]].pl_angle) *
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1072 (float) planets[planetList[j]].pl_radius);
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1073 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1074 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1075 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1076
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1077 void
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1078 moveplanets()
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1079 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1080 register int i; /* for looping */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1081 register struct planet *l; /* to point to individual plaent */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1082
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1083 if (stars[1] < 0)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1084 build_stars_array();
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1085
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1086 /* totally experimental planet moving stuff */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1087 for (i = 0; i < NUMPLANETS; i++)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1088 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1089 int x, y;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1090 double r;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1091 l = &planets[i];
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1092 if (PL_TYPE(*l) == PLSTAR || l->pl_system == 0)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1093 continue; /* write code for them another time */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1094
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1095 r = l->pl_radius;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1096 l->pl_angle += configvals->planupdspd * 1e2 / sqrt(r * r * r);
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1097 if (l->pl_angle > 2 * M_PI)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1098 l->pl_angle -= 2 * M_PI;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1099 x = planets[stars[l->pl_system]].pl_x + cos(l->pl_angle) * l->pl_radius;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1100 y = planets[stars[l->pl_system]].pl_y + sin(l->pl_angle) * l->pl_radius;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1101 move_planet(i, x, y, 1);
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1102 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1103 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1104
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1105
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1106 /*
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1107 * This function pops the armies on planets. It now uses the tables that are
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1108 * in this module. Negative growth is supported.
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1109 */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1110
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1111 static void
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1112 pop_one_planet1(l)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1113 struct planet *l;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1114 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1115 int r; /* to hold resource index */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1116 int a; /* to hold atmosphere index */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1117 int t; /* temp var */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1118 float ft; /* another temp */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1119
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1120 r = (l->pl_flags & PLRESMASK) >> PLRESSHIFT; /* get resource bits */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1121 r = restores[r]; /* convert to 3 bits */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1122 a = l->pl_flags & PLATMASK; /* get atmosphere bits */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1123 a = a >> PLATSHIFT; /* shift to lower two bits of int */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1124
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1125 #ifdef UFL
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1126 t = status2->league ? popchance[a][r] : 8;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1127 #else
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1128 t = popchance[a][r]; /* get pop chance */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1129 #endif
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1130 if (t < lrand48() % 100) /* if planet misses chance */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1131 return; /* then on to next planet */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1132 ft = popmult[a][r]; /* get pop multiplier */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1133 if (ft >= 0)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1134 { /* positive multiplier */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1135 int incr;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1136
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1137 if (l->pl_armies >= popcap[a][r])
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1138 return;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1139
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1140 if (l->pl_armies < 4) /* chance of going over four */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1141 l->pl_flags |= PLREDRAW; /* slate planet for redraw */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1142 if (configvals->new_army_growth)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1143 #ifdef AEDILE
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1144 incr = 0.5 + ft * 2.0 * (float) (lrand48() % 6 + 3);
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1145 #else
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1146 incr = 1 + 0.5 + ft * (float) (l->pl_armies);
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1147 #endif
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1148 else
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1149 /* what about agri? */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1150 incr = 1 + lrand48() % 3; /* bronco is always 1-3 armies/pop */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1151 tlog_pop(l, incr);
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1152 l->pl_armies += incr; /* add on multiplier armies */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1153 l->pl_tinfo[l->pl_owner].armies = l->pl_armies;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1154 l->pl_tinfo[l->pl_owner].timestamp = status->clock;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1155 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1156 else
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1157 { /* negative multiplier */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1158 int decr;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1159 if (l->pl_armies < 4) /* no killing all the armies on */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1160 return; /* a planet */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1161 l->pl_flags |= PLREDRAW; /* slate planet for redraw */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1162 decr = 1 + 0.5 - ft * (float) (l->pl_armies);
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1163 tlog_pop(l, -decr);
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1164 l->pl_armies -= decr; /* subtract armies */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1165 l->pl_armies = (l->pl_armies < 0) ? 0 : l->pl_armies;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1166 if (l->pl_armies <= 0)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1167 { /* if all died then */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1168 l->pl_armies = 0; /* no negative armies */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1169 l->pl_tinfo[l->pl_owner].armies = 0; /* old owner knows */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1170 l->pl_tinfo[l->pl_owner].timestamp = status->clock;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1171 l->pl_tinfo[l->pl_owner].owner = NOBODY;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1172 l->pl_owner = NOBODY; /* planet is neutral */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1173 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1174 l->pl_tinfo[l->pl_owner].armies = l->pl_armies;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1175 l->pl_tinfo[l->pl_owner].timestamp = status->clock;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1176 if (l->pl_armies == 0) /* if all armies died */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1177 checkwin(enemy_admiral(-1)); /* check if game over */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1178 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1179 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1180 /*
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1181 * */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1182
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1183 static void
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1184 pop_one_planet2(l)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1185 struct planet *l;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1186 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1187 int delta = 0;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1188 int atmosphere = (l->pl_flags & PLATMASK) >> PLATSHIFT;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1189 int surface = (l->pl_flags & PLSURMASK) >> PLSURSHIFT;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1190
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1191 if (l->pl_armies < 4 && (l->pl_flags & PLAGRI))
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1192 delta++;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1193
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1194 if (atmosphere == 0)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1195 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1196 if (l->pl_armies >= 4 && drand48() < 0.5)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1197 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1198 delta--;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1199 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1200 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1201 else if (atmosphere < 3)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1202 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1203 if (drand48() <
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1204 ((atmosphere == 1)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1205 ? (l->pl_armies < 4 ? 0.2 : 0.1)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1206 : (l->pl_armies < 4 ? 0.5 : 0.2)))
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1207 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1208 delta++;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1209 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1210 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1211 else
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1212 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1213 if (drand48() < (l->pl_armies < 4 ? 0.3 : 0.2))
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1214 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1215 static int table[] = {2, 2, 2, 3, 3, 3, 4, 4};
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1216 int max = table[surface];
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1217 delta++;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1218 if (l->pl_flags & PLAGRI && l->pl_armies >= 4)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1219 max++; /* armies<4 handled at top */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1220 delta += lrand48() % max;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1221 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1222 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1223
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1224 if (l->pl_armies == 0 && delta > 1)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1225 delta = 1; /* training that first army is tough */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1226
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1227 tlog_pop(l, delta);
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1228
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1229 if (delta > 0 &&
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1230 l->pl_armies > popcap[atmosphere]
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1231 [restores[(l->pl_flags & PLRESMASK) >> PLRESSHIFT]])
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1232 delta = 0;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1233 l->pl_armies += delta;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1234
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1235 /*
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1236 * I doubt this if statement will ever get executed unless someone's
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1237 * frobbing shmem
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1238 */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1239 if (l->pl_armies <= 0)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1240 { /* if all died then */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1241 l->pl_armies = 0; /* no negative armies */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1242
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1243 tlog_revolt(l); /* well, not exactly. */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1244
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1245 l->pl_tinfo[l->pl_owner].armies = 0; /* old owner knows */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1246 l->pl_tinfo[l->pl_owner].timestamp = status->clock;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1247 l->pl_tinfo[l->pl_owner].owner = NOBODY;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1248 l->pl_owner = NOBODY; /* planet is neutral */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1249 checkwin(enemy_admiral(-1));/* check if game over */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1250 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1251
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1252 l->pl_tinfo[l->pl_owner].armies = l->pl_armies;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1253 l->pl_tinfo[l->pl_owner].timestamp = status->clock;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1254 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1255
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1256 void
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1257 pop_one_planet(l)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1258 struct planet *l;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1259 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1260 #if 0
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1261 printf("popping planet #%d %x\n", l->pl_no, l->pl_owner);
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1262 fflush(stdout);
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1263 #endif
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1264
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1265 switch (configvals->popscheme)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1266 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1267 case 1:
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1268 pop_one_planet2(l);
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1269 break;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1270 default:
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1271 case 0:
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1272 pop_one_planet1(l);
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1273 break;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1274 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1275 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1276
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1277
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1278 /*-------------------------------UDPLANETS----------------------------------*/
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1279
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1280 void
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1281 fill_planets(plist, count, owner)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1282 int *plist; /* array */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1283 int *count; /* scalar */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1284 int owner;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1285 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1286 int i;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1287 *count = 0;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1288 for (i = 0; i < configvals->numplanets; i++)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1289 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1290 if (owner < 0 || planets[i].pl_owner == owner)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1291 plist[(*count)++] = i;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1292 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1293
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1294 for (i = *count - 1; i > 0; i--)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1295 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1296 int idx = lrand48() % (i + 1);
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1297 int temp = plist[idx];
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1298 plist[idx] = plist[i];
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1299 plist[i] = temp;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1300 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1301 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1302
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1303 int
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1304 find_other_team(teammask)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1305 int teammask;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1306 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1307 int counts[NUMTEAM];
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1308 int i;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1309 for (i = 0; i < NUMTEAM; i++)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1310 counts[i] = 0;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1311 for (i = 0; i < MAXPLAYER; i++)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1312 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1313 int teamidx = mask_to_idx(players[i].p_team);
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1314 if (teamidx >= 0 && teamidx < NUMTEAM && !(teammask & (1 << teamidx)))
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1315 counts[teamidx]++;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1316 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1317
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1318 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1319 int max = -1;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1320 int rval = 0;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1321 for (i = 0; i < NUMTEAM; i++)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1322 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1323 if (counts[i] > max && !(teammask & (1 << i)))
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1324 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1325 max = counts[i];
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1326 rval = 1 << i;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1327 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1328 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1329 return rval;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1330 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1331 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1332
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1333 void
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1334 popplanets()
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1335 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1336 register int i; /* for looping */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1337 register struct planet *l; /* to point to individual plaent */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1338
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1339 if (!status->tourn) /* check t-mode */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1340 return; /* do not pop planets */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1341
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1342 switch (configvals->popchoice)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1343 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1344 case 0:
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1345 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1346 static int fuse = 0;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1347 if (++fuse < PLANETFUSE)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1348 return; /* nothing to do */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1349 fuse = 0;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1350 for (i = 0, l = &planets[i]; i < NUMPLANETS; i++, l++)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1351 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1352 if ((l->pl_armies == 0) ||
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1353 (PL_TYPE(*l) == PLSTAR) ||
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1354 (PL_TYPE(*l) == PLWHOLE)) /* if no armies to pop */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1355 continue; /* go to next planet */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1356 #if 0
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1357 if (l->pl_owner != NOBODY) /* only team planets can revolt */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1358 revolt(l); /* check for revolt */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1359 #endif
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1360 pop_one_planet(l);
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1361 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1362 } break;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1363 case 1:
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1364 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1365 #if 0
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1366 static int indplanets[MAXPLANETS];
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1367 static int indcount = 0;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1368 #endif
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1369 static int Aplanets[MAXPLANETS];
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1370 static int Acount = 0, Amask = 0;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1371 static int Bplanets[MAXPLANETS];
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1372 static int Bcount = 0, Bmask = 0;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1373
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1374 int INDchance;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1375 float Achance, Bchance;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1376 float f;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1377
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1378 /* make sure there's planets in the lists */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1379 #if 0
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1380 if (indcount < 1)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1381 fill_planets(indplanets, &indcount, NOBODY);
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1382 #endif
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1383 if (Acount < 1)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1384 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1385 Amask = find_other_team(Bmask);
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1386 fill_planets(Aplanets, &Acount, Amask);
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1387 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1388 if (Bcount < 1)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1389 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1390 Bmask = find_other_team(Amask);
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1391 fill_planets(Bplanets, &Bcount, Bmask);
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1392 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1393
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1394 /* figure out the probabilities */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1395 INDchance = Achance = Bchance = 0;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1396 for (i = 0; i < configvals->numplanets; i++)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1397 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1398 if (planets[i].pl_owner == Amask)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1399 Achance += 1.0;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1400 else if (planets[i].pl_owner == Bmask)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1401 Bchance += 1.0;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1402 else if (!((PL_TYPE(planets[i]) == PLSTAR) ||
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1403 (PL_TYPE(planets[i]) == PLWHOLE)))
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1404 /* if (planets[i].pl_owner == NOBODY) */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1405 INDchance += 1.0;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1406 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1407
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1408 #ifdef LOOSING_ADVANTAGE
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1409 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1410 double la = LOOSING_ADVANTAGE;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1411 if (Achance < Bchance)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1412 Achance *= (la - (la - 1) * Achance / Bchance);
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1413 else
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1414 Bchance *= (la - (la - 1) * Bchance / Achance);
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1415 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1416 #endif
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1417
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1418 f = drand48() * (INDchance + Achance + Bchance);
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1419 if (f < INDchance)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1420 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1421 #if 0 /* 3rd-race planets and INDs don't pop */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1422 pop_one_planet(&planets[indplanets[--indcount]]);
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1423 #endif
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1424 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1425 else if (f - INDchance < Achance)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1426 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1427 pop_one_planet(&planets[Aplanets[--Acount]]);
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1428 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1429 else
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1430 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1431 pop_one_planet(&planets[Bplanets[--Bcount]]);
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1432 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1433
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1434 } break;
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1435 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1436 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1437
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1438
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1439
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1440
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1441
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1442 /*----------------------------------PLFIGHT--------------------------------*/
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1443 /*
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1444 * This function does the fighting for a planet. It decs the warning timer
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1445 * and clears the REDRAW flag. It then handles the bombing for the players.
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1446 * It then goes on to see if a player is visible to the other team by
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1447 * checking the closeness of other players. The planets are then checked to
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1448 * see if they are close enough to fire on enemy players.
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1449 */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1450
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1451 void
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1452 plfight()
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1453 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1454 register int h; /* looping vars */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1455 register struct planet *l; /* for looping through planets */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1456
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1457 for (h = 0, l = &planets[h]; h < NUMPLANETS; h++, l++)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1458 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1459 l->pl_flags &= ~PLREDRAW; /* clear the PLDRAW flag */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1460 if (l->pl_warning > 0) /* check if timer needs dec */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1461 l->pl_warning--; /* dec the warning timer */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1462 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1463 pbomb(); /* go do bombing for players */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1464 pvisible(); /* check visibility w/ other players */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1465 pfire(); /* let planets fire on other players */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1466 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1467
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1468
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1469
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1470
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1471 /*-------------------------------SAVE_PLANETS-----------------------------*/
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1472 /*
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1473 * This function saves the planets structure to disk. The plfd variable is a
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1474 * handle on the previously opened .planets file. The function also saves
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1475 * the status to the glfd file.
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1476 */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1477
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1478 void
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1479 save_planets()
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1480 {
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1481 if (plfd >= 0)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1482 { /* if plfd file open */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1483 (void) lseek(plfd, (long) 0, 0); /* save the planets */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1484 (void) write(plfd, (char *) planets, sizeof(struct planet) * MAXPLANETS);
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1485 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1486 if (glfd >= 0)
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1487 { /* if glfd file open then */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1488 (void) lseek(glfd, (long) 0, 0); /* save the status */
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1489 (void) write(glfd, (char *) status, sizeof(struct status));
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1490 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1491 }
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1492
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1493 /*-------------------------------------------------------------------------*/
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1494
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1495
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1496
8c6d5731234d First entry of Paradise Server 2.9 patch 10 Beta
darius
parents:
diff changeset
1497 /*----------END OF FILE--------*/