~ubuntu-branches/debian/squeeze/freeciv/squeeze

« back to all changes in this revision

Viewing changes to server/spacerace.c

  • Committer: Bazaar Package Importer
  • Author(s): Clint Adams, Karl Goetz, Clint Adams
  • Date: 2010-02-23 22:09:02 UTC
  • mfrom: (1.2.13 upstream)
  • Revision ID: james.westby@ubuntu.com-20100223220902-kiyrmr9i4152cka5
Tags: 2.2.0-1
[ Karl Goetz ]
* Remove civserver files in /etc/ggzd/ (Closes: 523772, 517787)
* Adding ${misc:Depends} to all binary packages (lintian warnings)

[ Clint Adams ]
* New upstream version.
  - Drop data_dsc_use_bindir.diff (binary pathnames have changed).

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
#include <assert.h>
19
19
#include <string.h>
20
20
 
 
21
/* utility */
 
22
#include "fcintl.h"
 
23
#include "log.h"
 
24
#include "shared.h"
 
25
 
 
26
/* common */
21
27
#include "events.h"
22
 
#include "fcintl.h"
23
28
#include "game.h"
24
 
#include "log.h"
25
29
#include "packets.h"
26
 
#include "shared.h"
27
30
#include "spaceship.h"
28
31
 
 
32
/* server */
29
33
#include "plrhand.h"
 
34
#include "notify.h"
30
35
#include "srv_main.h"
31
36
 
32
37
#include "spacerace.h"
124
129
      struct packet_spaceship_info info;
125
130
      struct player_spaceship *ship = &pplayer->spaceship;
126
131
          
127
 
      info.player_num = pplayer->player_no;
 
132
      info.player_num = player_number(pplayer);
128
133
      info.sship_state = ship->state;
129
134
      info.structurals = ship->structurals;
130
135
      info.components = ship->components;
161
166
  int arrival;
162
167
 
163
168
  if (!find_palace(pplayer)) {
164
 
    notify_player(pplayer, NULL, E_SPACESHIP,
 
169
    notify_player(pplayer, NULL, E_SPACESHIP, ftc_server,
165
170
                  _("You need to have a capital in order to launch "
166
 
                    "your spaceship."));
 
171
                    "your spaceship."));
167
172
    return;
168
173
  }
169
174
  if (ship->state >= SSHIP_LAUNCHED) {
170
 
    notify_player(pplayer, NULL, E_SPACESHIP,
171
 
                  _("Your spaceship is already launched!"));
 
175
    notify_player(pplayer, NULL, E_SPACESHIP, ftc_server,
 
176
                  _("Your spaceship is already launched!"));
172
177
    return;
173
178
  }
174
179
  if (ship->state != SSHIP_STARTED
175
180
      || ship->success_rate == 0.0) {
176
 
    notify_player(pplayer, NULL, E_SPACESHIP,
177
 
                  _("Your spaceship can't be launched yet!"));
 
181
    notify_player(pplayer, NULL, E_SPACESHIP, ftc_server,
 
182
                  _("Your spaceship can't be launched yet!"));
178
183
    return;
179
184
  }
180
185
 
182
187
  ship->launch_year = game.info.year;
183
188
  arrival = ship->launch_year + (int) ship->travel_time;
184
189
 
185
 
  notify_player(NULL, NULL, E_SPACESHIP,
186
 
                   _("The %s have launched a spaceship!  "
187
 
                     "It is estimated to arrive on Alpha Centauri in %s."),
188
 
                   nation_plural_for_player(pplayer),
189
 
                   textyear(arrival));
 
190
  notify_player(NULL, NULL, E_SPACESHIP, ftc_server,
 
191
                _("The %s have launched a spaceship!  "
 
192
                  "It is estimated to arrive on Alpha Centauri in %s."),
 
193
                nation_plural_for_player(pplayer),
 
194
                textyear(arrival));
190
195
 
191
196
  send_spaceship_info(pplayer, NULL);
192
197
}
200
205
  struct player_spaceship *ship = &pplayer->spaceship;
201
206
  
202
207
  if (ship->state == SSHIP_NONE) {
203
 
    notify_player(pplayer, NULL, E_SPACESHIP,
204
 
                  _("Spaceship action received,"
205
 
                    " but you don't have a spaceship!"));
 
208
    notify_player(pplayer, NULL, E_SPACESHIP, ftc_server,
 
209
                  _("Spaceship action received,"
 
210
                    " but you don't have a spaceship!"));
206
211
    return;
207
212
  }
208
213
  if (ship->state >= SSHIP_LAUNCHED) {
209
 
    notify_player(pplayer, NULL, E_SPACESHIP,
210
 
                  _("You can't modify your spaceship after launch!"));
 
214
    notify_player(pplayer, NULL, E_SPACESHIP, ftc_server,
 
215
                  _("You can't modify your spaceship after launch!"));
211
216
    return;
212
217
  }
213
218
  if (type == SSHIP_PLACE_STRUCTURAL) {
215
220
      return;
216
221
    }
217
222
    if (num_spaceship_structurals_placed(ship) >= ship->structurals) {
218
 
      notify_player(pplayer, NULL, E_SPACESHIP,
219
 
                    _("You don't have any unplaced Space Structurals!"));
 
223
      notify_player(pplayer, NULL, E_SPACESHIP, ftc_server,
 
224
                    _("You don't have any unplaced Space Structurals!"));
220
225
      return;
221
226
    }
222
227
    if (num!=0 && !ship->structure[structurals_info[num].required]) {
223
 
      notify_player(pplayer, NULL, E_SPACESHIP,
224
 
                    _("That Space Structural"
225
 
                      " would not be connected!"));
 
228
      notify_player(pplayer, NULL, E_SPACESHIP, ftc_server,
 
229
                    _("That Space Structural would not be connected!"));
226
230
      return;
227
231
    }
228
232
    ship->structure[num] = TRUE;
235
239
      return;
236
240
    }
237
241
    if (ship->fuel + ship->propulsion >= ship->components) {
238
 
      notify_player(pplayer, NULL, E_SPACESHIP,
239
 
                    _("You don't have any unplaced"
240
 
                      " Space Components!"));
 
242
      notify_player(pplayer, NULL, E_SPACESHIP, ftc_server,
 
243
                    _("You don't have any unplaced Space Components!"));
241
244
      return;
242
245
    }
243
246
    if (num > NUM_SS_COMPONENTS/2) {
244
 
      notify_player(pplayer, NULL, E_SPACESHIP,
245
 
                    _("Your spaceship already has"
246
 
                      " the maximum number of Fuel Components!"));
 
247
      notify_player(pplayer, NULL, E_SPACESHIP, ftc_server,
 
248
                    _("Your spaceship already has"
 
249
                      " the maximum number of Fuel Components!"));
247
250
      return;
248
251
    }
249
252
    ship->fuel++;
256
259
      return;
257
260
    }
258
261
    if (ship->fuel + ship->propulsion >= ship->components) {
259
 
      notify_player(pplayer, NULL, E_SPACESHIP,
260
 
                    _("You don't have any unplaced"
261
 
                      " Space Components!"));
 
262
      notify_player(pplayer, NULL, E_SPACESHIP, ftc_server,
 
263
                    _("You don't have any unplaced"
 
264
                      " Space Components!"));
262
265
      return;
263
266
    }
264
267
    if (num > NUM_SS_COMPONENTS/2) {
265
 
      notify_player(pplayer, NULL, E_SPACESHIP,
266
 
                    _("Your spaceship already has the"
267
 
                      " maximum number of Propulsion Components!"));
 
268
      notify_player(pplayer, NULL, E_SPACESHIP, ftc_server,
 
269
                    _("Your spaceship already has the"
 
270
                      " maximum number of Propulsion Components!"));
268
271
      return;
269
272
    }
270
273
    ship->propulsion++;
277
280
      return;
278
281
    }
279
282
    if (ship->habitation + ship->life_support + ship->solar_panels
280
 
        >= ship->modules) {
281
 
      notify_player(pplayer, NULL, E_SPACESHIP,
282
 
                    _("You don't have any unplaced"
283
 
                      " Space Modules!"));
 
283
        >= ship->modules) {
 
284
      notify_player(pplayer, NULL, E_SPACESHIP, ftc_server,
 
285
                    _("You don't have any unplaced Space Modules!"));
284
286
      return;
285
287
    }
286
 
    if (num > NUM_SS_MODULES/3) {
287
 
      notify_player(pplayer, NULL, E_SPACESHIP,
288
 
                    _("Your spaceship already has the"
289
 
                      " maximum number of Habitation Modules!"));
 
288
    if (num > NUM_SS_MODULES / 3) {
 
289
      notify_player(pplayer, NULL, E_SPACESHIP, ftc_server,
 
290
                    _("Your spaceship already has the"
 
291
                      " maximum number of Habitation Modules!"));
290
292
      return;
291
293
    }
292
294
    ship->habitation++;
299
301
      return;
300
302
    }
301
303
    if (ship->habitation + ship->life_support + ship->solar_panels
302
 
        >= ship->modules) {
303
 
      notify_player(pplayer, NULL, E_SPACESHIP,
304
 
                    _("You don't have any unplaced"
305
 
                      " Space Modules!"));
 
304
        >= ship->modules) {
 
305
      notify_player(pplayer, NULL, E_SPACESHIP, ftc_server,
 
306
                    _("You don't have any unplaced Space Modules!"));
306
307
      return;
307
308
    }
308
 
    if (num > NUM_SS_MODULES/3) {
309
 
      notify_player(pplayer, NULL, E_SPACESHIP,
310
 
                    _("Your spaceship already has the"
311
 
                      " maximum number of Life Support Modules!"));
 
309
    if (num > NUM_SS_MODULES / 3) {
 
310
      notify_player(pplayer, NULL, E_SPACESHIP, ftc_server,
 
311
                    _("Your spaceship already has the"
 
312
                      " maximum number of Life Support Modules!"));
312
313
      return;
313
314
    }
314
315
    ship->life_support++;
321
322
      return;
322
323
    }
323
324
    if (ship->habitation + ship->life_support + ship->solar_panels
324
 
        >= ship->modules) {
325
 
      notify_player(pplayer, NULL, E_SPACESHIP,
326
 
                    _("You don't have any unplaced"
327
 
                      " Space Modules!"));
 
325
        >= ship->modules) {
 
326
      notify_player(pplayer, NULL, E_SPACESHIP, ftc_server,
 
327
                    _("You don't have any unplaced Space Modules!"));
328
328
      return;
329
329
    }
330
 
    if (num > NUM_SS_MODULES/3) {
331
 
      notify_player(pplayer, NULL, E_SPACESHIP,
332
 
                    _("Your spaceship already has the"
333
 
                      " maximum number of Solar Panel Modules!"));
 
330
    if (num > NUM_SS_MODULES / 3) {
 
331
      notify_player(pplayer, NULL, E_SPACESHIP, ftc_server,
 
332
                    _("Your spaceship already has the"
 
333
                      " maximum number of Solar Panel Modules!"));
334
334
      return;
335
335
    }
336
336
    ship->solar_panels++;
347
347
**************************************************************************/
348
348
void spaceship_lost(struct player *pplayer)
349
349
{
350
 
  notify_player(NULL, NULL, E_SPACESHIP,
351
 
                   _("Without guidance from the capital, the %s "
352
 
                     "spaceship is lost!"),
353
 
                   nation_adjective_for_player(pplayer));
 
350
  notify_player(NULL, NULL, E_SPACESHIP, ftc_server,
 
351
                _("Without guidance from the capital, the %s "
 
352
                  "spaceship is lost!"),
 
353
                nation_adjective_for_player(pplayer));
354
354
  spaceship_init(&pplayer->spaceship);
355
355
  send_spaceship_info(pplayer, NULL);
356
356
}