This commit was generated by cvs2svn to compensate for changes in r2,
[btb/d2x.git] / main / fuelcen.c
1 /*
2 THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
3 SOFTWARE CORPORATION ("PARALLAX").  PARALLAX, IN DISTRIBUTING THE CODE TO
4 END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
5 ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
6 IN USING, DISPLAYING,  AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
7 SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
8 FREE PURPOSES.  IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
9 CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES.  THE END-USER UNDERSTANDS
10 AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.  
11 COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION.  ALL RIGHTS RESERVED.
12 */
13
14
15 #ifdef RCS
16 static char rcsid[] = "$Id: fuelcen.c,v 1.1.1.1 2001-01-19 03:29:59 bradleyb Exp $";
17 #endif
18
19 #include <conf.h>
20 #include <stdio.h>
21 #include <stdlib.h>
22 #include <math.h>
23 #include <string.h>
24
25 #include "fuelcen.h"
26 #include "gameseg.h"
27 #include "game.h"               // For FrameTime
28 #include "error.h"
29 #include "mono.h"
30 #include "gauges.h"
31 #include "vclip.h"
32 #include "fireball.h"
33 #include "robot.h"
34 #include "powerup.h"
35
36 #include "wall.h"
37 #include "sounds.h"
38 #include "morph.h"
39 #include "3d.h"
40 #include "bm.h"
41 #include "polyobj.h"
42 #include "ai.h"
43 #include "gamemine.h"
44 #include "gamesave.h"
45 #include "player.h"
46 #include "collide.h"
47 #include "laser.h"
48 #include "network.h"
49 #include "multi.h"
50 #include "multibot.h"
51
52 // The max number of fuel stations per mine.
53
54 fix Fuelcen_refill_speed = i2f(1);
55 fix Fuelcen_give_amount = i2f(25);
56 fix Fuelcen_max_amount = i2f(100);
57
58 // Every time a robot is created in the morphing code, it decreases capacity of the morpher
59 // by this amount... when capacity gets to 0, no more morphers...
60 fix EnergyToCreateOneRobot = i2f(1);
61
62 #define MATCEN_HP_DEFAULT                       F1_0*500; // Hitpoints
63 #define MATCEN_INTERVAL_DEFAULT F1_0*5; //  5 seconds
64
65 matcen_info RobotCenters[MAX_ROBOT_CENTERS];
66 int Num_robot_centers;
67
68 FuelCenter Station[MAX_NUM_FUELCENS];
69 int Num_fuelcenters = 0;
70
71 segment * PlayerSegment= NULL;
72
73 #ifdef EDITOR
74 char    Special_names[MAX_CENTER_TYPES][11] = {
75         "NOTHING   ",
76         "FUELCEN   ",
77         "REPAIRCEN ",
78         "CONTROLCEN",
79         "ROBOTMAKER",
80         "GOAL_RED",
81         "GOAL_BLUE",
82 };
83 #endif
84
85 //------------------------------------------------------------
86 // Resets all fuel center info
87 void fuelcen_reset()
88 {
89         int i;
90
91         Num_fuelcenters = 0;
92         //mprintf( (0, "All fuel centers reset.\n"));
93
94         for(i=0; i<MAX_SEGMENTS; i++ )
95                 Segment2s[i].special = SEGMENT_IS_NOTHING;
96
97         Num_robot_centers = 0;
98
99 }
100
101 #ifndef NDEBUG          //this is sometimes called by people from the debugger
102 void reset_all_robot_centers() 
103 {
104         int i;
105
106         // Remove all materialization centers
107         for (i=0; i<Num_segments; i++)
108                 if (Segment2s[i].special == SEGMENT_IS_ROBOTMAKER) {
109                         Segment2s[i].special = SEGMENT_IS_NOTHING;
110                         Segment2s[i].matcen_num = -1;
111                 }
112 }
113 #endif
114
115 //------------------------------------------------------------
116 // Turns a segment into a fully charged up fuel center...
117 void fuelcen_create( segment *segp)
118 {
119         segment2        *seg2p = &Segment2s[segp-Segments];
120
121         int     station_type;
122
123         station_type = seg2p->special;
124
125         switch( station_type )  {
126         case SEGMENT_IS_NOTHING:
127         case SEGMENT_IS_GOAL_BLUE:
128         case SEGMENT_IS_GOAL_RED:
129                 return;
130         case SEGMENT_IS_FUELCEN:
131         case SEGMENT_IS_REPAIRCEN:
132         case SEGMENT_IS_CONTROLCEN:
133         case SEGMENT_IS_ROBOTMAKER:
134                 break;
135         default:
136                 Error( "Invalid station type %d in fuelcen.c\n", station_type );
137         }
138
139         Assert( (seg2p != NULL) );
140         if ( seg2p == NULL ) return;
141
142         Assert( Num_fuelcenters < MAX_NUM_FUELCENS );
143         Assert( Num_fuelcenters > -1 );
144
145         seg2p->value = Num_fuelcenters;
146         Station[Num_fuelcenters].Type = station_type;
147         Station[Num_fuelcenters].MaxCapacity = Fuelcen_max_amount;
148         Station[Num_fuelcenters].Capacity = Station[Num_fuelcenters].MaxCapacity;
149         Station[Num_fuelcenters].segnum = seg2p-Segment2s;
150         Station[Num_fuelcenters].Timer = -1;
151         Station[Num_fuelcenters].Flag = 0;
152 //      Station[Num_fuelcenters].NextRobotType = -1;
153 //      Station[Num_fuelcenters].last_created_obj=NULL;
154 //      Station[Num_fuelcenters].last_created_sig = -1;
155         compute_segment_center(&Station[Num_fuelcenters].Center, segp);
156
157 //      if (station_type == SEGMENT_IS_ROBOTMAKER)
158 //              Station[Num_fuelcenters].Capacity = i2f(Difficulty_level + 3);
159
160         //mprintf( (0, "Segment %d is assigned to be fuel center %d.\n", Station[Num_fuelcenters].segnum, Num_fuelcenters ));
161         Num_fuelcenters++;
162 }
163
164 //------------------------------------------------------------
165 // Adds a matcen that already is a special type into the Station array.
166 // This function is separate from other fuelcens because we don't want values reset.
167 void matcen_create( segment *segp)
168 {
169         segment2        *seg2p = &Segment2s[segp-Segments];
170
171         int     station_type = seg2p->special;
172
173         Assert( (seg2p != NULL) );
174         Assert(station_type == SEGMENT_IS_ROBOTMAKER);
175         if ( seg2p == NULL ) return;
176
177         Assert( Num_fuelcenters < MAX_NUM_FUELCENS );
178         Assert( Num_fuelcenters > -1 );
179
180         seg2p->value = Num_fuelcenters;
181         Station[Num_fuelcenters].Type = station_type;
182         Station[Num_fuelcenters].Capacity = i2f(Difficulty_level + 3);
183         Station[Num_fuelcenters].MaxCapacity = Station[Num_fuelcenters].Capacity;
184
185         Station[Num_fuelcenters].segnum = seg2p-Segment2s;
186         Station[Num_fuelcenters].Timer = -1;
187         Station[Num_fuelcenters].Flag = 0;
188 //      Station[Num_fuelcenters].NextRobotType = -1;
189 //      Station[Num_fuelcenters].last_created_obj=NULL;
190 //      Station[Num_fuelcenters].last_created_sig = -1;
191         compute_segment_center(&Station[Num_fuelcenters].Center, &Segments[seg2p-Segment2s] );
192
193         seg2p->matcen_num = Num_robot_centers;
194         Num_robot_centers++;
195
196         RobotCenters[seg2p->matcen_num].hit_points = MATCEN_HP_DEFAULT;
197         RobotCenters[seg2p->matcen_num].interval = MATCEN_INTERVAL_DEFAULT;
198         RobotCenters[seg2p->matcen_num].segnum = seg2p-Segment2s;
199         RobotCenters[seg2p->matcen_num].fuelcen_num = Num_fuelcenters;
200
201         //mprintf( (0, "Segment %d is assigned to be fuel center %d.\n", Station[Num_fuelcenters].segnum, Num_fuelcenters ));
202         Num_fuelcenters++;
203 }
204
205 //------------------------------------------------------------
206 // Adds a segment that already is a special type into the Station array.
207 void fuelcen_activate( segment * segp, int station_type )
208 {
209         segment2        *seg2p = &Segment2s[segp-Segments];
210
211         seg2p->special = station_type;
212
213         if (seg2p->special == SEGMENT_IS_ROBOTMAKER)
214                 matcen_create( segp);
215         else
216                 fuelcen_create( segp);
217         
218 }
219
220 //      The lower this number is, the more quickly the center can be re-triggered.
221 //      If it's too low, it can mean all the robots won't be put out, but for about 5
222 //      robots, that's not real likely.
223 #define MATCEN_LIFE (i2f(30-2*Difficulty_level))
224
225 //------------------------------------------------------------
226 //      Trigger (enable) the materialization center in segment segnum
227 void trigger_matcen(int segnum)
228 {
229         // -- segment           *segp = &Segments[segnum];
230         segment2                *seg2p = &Segment2s[segnum];
231         vms_vector      pos, delta;
232         FuelCenter      *robotcen;
233         int                     objnum;
234
235         mprintf((0, "Trigger matcen, segment %i\n", segnum));
236
237         Assert(seg2p->special == SEGMENT_IS_ROBOTMAKER);
238         Assert(seg2p->matcen_num < Num_fuelcenters);
239         Assert((seg2p->matcen_num >= 0) && (seg2p->matcen_num <= Highest_segment_index));
240
241         robotcen = &Station[RobotCenters[seg2p->matcen_num].fuelcen_num];
242
243         if (robotcen->Enabled == 1)
244                 return;
245
246         if (!robotcen->Lives)
247                 return;
248
249         //      MK: 11/18/95, At insane, matcens work forever!
250         if (Difficulty_level+1 < NDL)
251                 robotcen->Lives--;
252
253         robotcen->Timer = F1_0*1000;    //      Make sure the first robot gets emitted right away.
254         robotcen->Enabled = 1;                  //      Say this center is enabled, it can create robots.
255         robotcen->Capacity = i2f(Difficulty_level + 3);
256         robotcen->Disable_time = MATCEN_LIFE;
257
258         //      Create a bright object in the segment.
259         pos = robotcen->Center;
260         vm_vec_sub(&delta, &Vertices[Segments[segnum].verts[0]], &robotcen->Center);
261         vm_vec_scale_add2(&pos, &delta, F1_0/2);
262         objnum = obj_create( OBJ_LIGHT, 0, segnum, &pos, NULL, 0, CT_LIGHT, MT_NONE, RT_NONE );
263         if (objnum != -1) {
264                 Objects[objnum].lifeleft = MATCEN_LIFE;
265                 Objects[objnum].ctype.light_info.intensity = i2f(8);    //      Light cast by a fuelcen.
266         } else {
267                 mprintf((1, "Can't create invisible flare for matcen.\n"));
268                 Int3();
269         }
270 //      mprintf((0, "Created invisibile flare, object=%i, segment=%i, pos=%7.3f %7.3f%7.3f\n", objnum, segnum, f2fl(pos.x), f2fl(pos.y), f2fl(pos.z)));
271 }
272
273 #ifdef EDITOR
274 //------------------------------------------------------------
275 // Takes away a segment's fuel center properties.
276 //      Deletes the segment point entry in the FuelCenter list.
277 void fuelcen_delete( segment * segp )
278 {
279         segment2        *seg2p = &Segment2s[segp-Segments];
280         int i, j;
281
282 Restart: ;
283
284         seg2p->special = 0;
285
286         for (i=0; i<Num_fuelcenters; i++ )      {
287                 if ( Station[i].segnum == segp-Segments )       {
288
289                         // If Robot maker is deleted, fix Segments and RobotCenters.
290                         if (Station[i].Type == SEGMENT_IS_ROBOTMAKER) {
291                                 Num_robot_centers--;
292                                 Assert(Num_robot_centers >= 0);
293
294                                 for (j=seg2p->matcen_num; j<Num_robot_centers; j++)
295                                         RobotCenters[j] = RobotCenters[j+1];
296
297                                 for (j=0; j<Num_fuelcenters; j++) {
298                                         if ( Station[j].Type == SEGMENT_IS_ROBOTMAKER )
299                                                 if ( Segment2s[Station[j].segnum].matcen_num > seg2p->matcen_num )
300                                                         Segment2s[Station[j].segnum].matcen_num--;
301                                 }
302                         }
303
304                         //fix RobotCenters so they point to correct fuelcenter
305                         for (j=0; j<Num_robot_centers; j++ )
306                                 if (RobotCenters[j].fuelcen_num > i)            //this robotcenter's fuelcen is changing
307                                         RobotCenters[j].fuelcen_num--;
308
309                         Num_fuelcenters--;
310                         Assert(Num_fuelcenters >= 0);
311                         for (j=i; j<Num_fuelcenters; j++ )      {
312                                 Station[j] = Station[j+1];
313                                 Segment2s[Station[j].segnum].value = j;
314                         }
315                         goto Restart;
316                 }
317         }
318
319 }
320 #endif
321
322 #define ROBOT_GEN_TIME (i2f(5))
323
324 object * create_morph_robot( segment *segp, vms_vector *object_pos, int object_id)
325 {
326         short           objnum;
327         object  *obj;
328         int             default_behavior;
329
330         Players[Player_num].num_robots_level++;
331         Players[Player_num].num_robots_total++;
332
333         objnum = obj_create(OBJ_ROBOT, object_id, segp-Segments, object_pos,
334                                 &vmd_identity_matrix, Polygon_models[Robot_info[object_id].model_num].rad,
335                                 CT_AI, MT_PHYSICS, RT_POLYOBJ);
336
337         if ( objnum < 0 ) {
338                 mprintf((1, "Can't create morph robot.  Aborting morph.\n"));
339                 Int3();
340                 return NULL;
341         }
342
343         obj = &Objects[objnum];
344
345         //Set polygon-object-specific data 
346
347         obj->rtype.pobj_info.model_num = Robot_info[obj->id].model_num;
348         obj->rtype.pobj_info.subobj_flags = 0;
349
350         //set Physics info
351
352         obj->mtype.phys_info.mass = Robot_info[obj->id].mass;
353         obj->mtype.phys_info.drag = Robot_info[obj->id].drag;
354
355         obj->mtype.phys_info.flags |= (PF_LEVELLING);
356
357         obj->shields = Robot_info[obj->id].strength;
358         
359         default_behavior = Robot_info[obj->id].behavior;
360
361         init_ai_object(obj-Objects, default_behavior, -1 );             //      Note, -1 = segment this robot goes to to hide, should probably be something useful
362
363         create_n_segment_path(obj, 6, -1);              //      Create a 6 segment path from creation point.
364
365         Ai_local_info[objnum].mode = ai_behavior_to_mode(default_behavior);
366
367         return obj;
368 }
369
370 int Num_extry_robots = 15;
371
372 #ifndef NDEBUG
373 int     FrameCount_last_msg = 0;
374 #endif
375
376 //      ----------------------------------------------------------------------------------------------------------
377 void robotmaker_proc( FuelCenter * robotcen )
378 {
379         fix             dist_to_player;
380         vms_vector      cur_object_loc; //, direction;
381         int             matcen_num, segnum, objnum;
382         object  *obj;
383         fix             top_time;
384         vms_vector      direction;
385
386         if (robotcen->Enabled == 0)
387                 return;
388
389         if (robotcen->Disable_time > 0) {
390                 robotcen->Disable_time -= FrameTime;
391                 if (robotcen->Disable_time <= 0) {
392                         mprintf((0, "Robot center #%i gets disabled due to time running out.\n", robotcen-Station));
393                         robotcen->Enabled = 0;
394                 }
395         }
396
397         // mprintf((0, "Capacity of robot maker #%i is %i\n", robotcen - Station, robotcen->Capacity));
398
399         //      No robot making in multiplayer mode.
400 #ifdef NETWORK
401 #ifndef SHAREWARE
402         if ((Game_mode & GM_MULTI) && (!(Game_mode & GM_MULTI_ROBOTS) || !network_i_am_master()))
403                 return;
404 #else
405         if (Game_mode & GM_MULTI)
406                 return;
407 #endif
408 #endif
409
410         // Wait until transmorgafier has capacity to make a robot...
411         if ( robotcen->Capacity <= 0 ) {
412                 return;
413         }
414
415         matcen_num = Segment2s[robotcen->segnum].matcen_num;
416         //mprintf((0, "Robotmaker #%i flags = %8x\n", matcen_num, RobotCenters[matcen_num].robot_flags));
417
418         if ( matcen_num == -1 ) {
419                 mprintf((0, "Non-functional robotcen at %d\n", robotcen->segnum));
420                 return;
421         }
422
423         if (RobotCenters[matcen_num].robot_flags[0]==0 && RobotCenters[matcen_num].robot_flags[1]==0) {
424                 //mprintf((0, "robot_flags = 0 at robot maker #%i\n", RobotCenters[matcen_num].robot_flags));
425                 return;
426         }
427
428         // Wait until we have a free slot for this puppy...
429    //     <<<<<<<<<<<<<<<< Num robots in mine >>>>>>>>>>>>>>>>>>>>>>>>>>    <<<<<<<<<<<< Max robots in mine >>>>>>>>>>>>>>>
430         if ( (Players[Player_num].num_robots_level - Players[Player_num].num_kills_level) >= (Gamesave_num_org_robots + Num_extry_robots ) ) {
431                 #ifndef NDEBUG
432                 if (FrameCount > FrameCount_last_msg + 20) {
433                         mprintf((0, "Cannot morph until you kill one!\n"));
434                         FrameCount_last_msg = FrameCount;
435                 }
436                 #endif
437                 return;
438         }
439
440         robotcen->Timer += FrameTime;
441
442         switch( robotcen->Flag )        {
443         case 0:         // Wait until next robot can generate
444                 if (Game_mode & GM_MULTI) 
445                 {
446                         top_time = ROBOT_GEN_TIME;      
447                 }
448                 else 
449                 {
450                         dist_to_player = vm_vec_dist_quick( &ConsoleObject->pos, &robotcen->Center );
451                         top_time = dist_to_player/64 + d_rand() * 2 + F1_0*2;
452                         if ( top_time > ROBOT_GEN_TIME )
453                                 top_time = ROBOT_GEN_TIME + d_rand();
454                         if ( top_time < F1_0*2 )
455                                 top_time = F1_0*3/2 + d_rand()*2;
456                 }
457
458                 // mprintf( (0, "Time between morphs %d seconds, dist_to_player = %7.3f\n", f2i(top_time), f2fl(dist_to_player) ));
459
460                 if (robotcen->Timer > top_time )        {
461                         int     count=0;
462                         int     i, my_station_num = robotcen-Station;
463                         object *obj;
464
465                         //      Make sure this robotmaker hasn't put out its max without having any of them killed.
466                         for (i=0; i<=Highest_object_index; i++)
467                                 if (Objects[i].type == OBJ_ROBOT)
468                                         if ((Objects[i].matcen_creator^0x80) == my_station_num)
469                                                 count++;
470                         if (count > Difficulty_level + 3) {
471                                 mprintf((0, "Cannot morph: center %i has already put out %i robots.\n", my_station_num, count));
472                                 robotcen->Timer /= 2;
473                                 return;
474                         }
475
476                         //      Whack on any robot or player in the matcen segment.
477                         count=0;
478                         segnum = robotcen->segnum;
479                         for (objnum=Segments[segnum].objects;objnum!=-1;objnum=Objects[objnum].next)    {
480                                 count++;
481                                 if ( count > MAX_OBJECTS )      {
482                                         mprintf((0, "Object list in segment %d is circular.", segnum ));
483                                         Int3();
484                                         return;
485                                 }
486                                 if (Objects[objnum].type==OBJ_ROBOT) {
487                                         collide_robot_and_materialization_center(&Objects[objnum]);
488                                         robotcen->Timer = top_time/2;
489                                         return;
490                                 } else if (Objects[objnum].type==OBJ_PLAYER ) {
491                                         collide_player_and_materialization_center(&Objects[objnum]);
492                                         robotcen->Timer = top_time/2;
493                                         return;
494                                 }
495                         }
496
497                         compute_segment_center(&cur_object_loc, &Segments[robotcen->segnum]);
498                         // HACK!!! The 10 under here should be something equal to the 1/2 the size of the segment.
499                         obj = object_create_explosion(robotcen->segnum, &cur_object_loc, i2f(10), VCLIP_MORPHING_ROBOT );
500
501                         if (obj)
502                                 extract_orient_from_segment(&obj->orient,&Segments[robotcen->segnum]);
503
504                         if ( Vclip[VCLIP_MORPHING_ROBOT].sound_num > -1 )               {
505                                 digi_link_sound_to_pos( Vclip[VCLIP_MORPHING_ROBOT].sound_num, robotcen->segnum, 0, &cur_object_loc, 0, F1_0 );
506                         }
507                         robotcen->Flag  = 1;
508                         robotcen->Timer = 0;
509
510                 }
511                 break;
512         case 1:                 // Wait until 1/2 second after VCLIP started.
513                 if (robotcen->Timer > (Vclip[VCLIP_MORPHING_ROBOT].play_time/2) )       {
514
515                         robotcen->Capacity -= EnergyToCreateOneRobot;
516                         robotcen->Flag = 0;
517
518                         robotcen->Timer = 0;
519                         compute_segment_center(&cur_object_loc, &Segments[robotcen->segnum]);
520
521                         // If this is the first materialization, set to valid robot.
522                         if (RobotCenters[matcen_num].robot_flags[0] != 0 || RobotCenters[matcen_num].robot_flags[1] != 0) {
523                                 int     type;
524                                 uint    flags;
525                                 byte    legal_types[64];                //      64 bits, the width of robot_flags[].
526                                 int     num_types, robot_index, i;
527
528                                 num_types = 0;
529                                 for (i=0;i<2;i++) {
530                                         robot_index = i*32;
531                                         flags = RobotCenters[matcen_num].robot_flags[i];
532                                         while (flags) {
533                                                 if (flags & 1)
534                                                         legal_types[num_types++] = robot_index;
535                                                 flags >>= 1;
536                                                 robot_index++;
537                                         }
538                                 }
539
540                                 //mprintf((0, "Flags = %08x, %2i legal types to morph: \n", RobotCenters[matcen_num].robot_flags, num_types));
541                                 //for (i=0; i<num_types; i++)
542                                 //      mprintf((0, "%2i ", legal_types[i]));
543                                 //mprintf((0, "\n"));
544
545                                 if (num_types == 1)
546                                         type = legal_types[0];
547                                 else
548                                         type = legal_types[(d_rand() * num_types) / 32768];
549
550                                 mprintf((0, "Morph: (type = %i) (seg = %i) (capacity = %08x)\n", type, robotcen->segnum, robotcen->Capacity));
551                                 obj = create_morph_robot(&Segments[robotcen->segnum], &cur_object_loc, type );
552                                 if (obj != NULL) {
553 #ifndef SHAREWARE
554 #ifdef NETWORK
555                                         if (Game_mode & GM_MULTI)
556                                                 multi_send_create_robot(robotcen-Station, obj-Objects, type);
557 #endif
558 #endif
559                                         obj->matcen_creator = (robotcen-Station) | 0x80;
560
561                                         // Make object faces player...
562                                         vm_vec_sub( &direction, &ConsoleObject->pos,&obj->pos );
563                                         vm_vector_2_matrix( &obj->orient, &direction, &obj->orient.uvec, NULL);
564         
565                                         morph_start( obj );
566                                         //robotcen->last_created_obj = obj;
567                                         //robotcen->last_created_sig = robotcen->last_created_obj->signature;
568                                 } else
569                                         mprintf((0, "Warning: create_morph_robot returned NULL (no objects left?)\n"));
570
571                         }
572   
573                 }
574                 break;
575         default:
576                 robotcen->Flag = 0;
577                 robotcen->Timer = 0;
578         }
579 }
580
581
582 //-------------------------------------------------------------
583 // Called once per frame, replenishes fuel supply.
584 void fuelcen_update_all()
585 {
586         int i;
587         fix AmountToreplenish;
588         
589         AmountToreplenish = fixmul(FrameTime,Fuelcen_refill_speed);
590
591         for (i=0; i<Num_fuelcenters; i++ )      {
592                 if ( Station[i].Type == SEGMENT_IS_ROBOTMAKER ) {
593                         if (! (Game_suspended & SUSP_ROBOTS))
594                                 robotmaker_proc( &Station[i] );
595                 } else if ( Station[i].Type == SEGMENT_IS_CONTROLCEN )  {
596                         //controlcen_proc( &Station[i] );
597         
598                 } else if ( (Station[i].MaxCapacity > 0) && (PlayerSegment!=&Segments[Station[i].segnum]) )     {
599                         if ( Station[i].Capacity < Station[i].MaxCapacity )     {
600                                 Station[i].Capacity += AmountToreplenish;
601                                 //mprintf( (0, "Fuel center %d replenished to %d.\n", i, f2i(Station[i].Capacity) ));
602                                 if ( Station[i].Capacity >= Station[i].MaxCapacity )            {
603                                         Station[i].Capacity = Station[i].MaxCapacity;
604                                         //gauge_message( "Fuel center is fully recharged!    " );
605                                 }
606                         }
607                 }
608         }
609 }
610
611 //--unused-- //-------------------------------------------------------------
612 //--unused-- // replenishes all fuel supplies.
613 //--unused-- void fuelcen_replenish_all()
614 //--unused-- {
615 //--unused--    int i;
616 //--unused-- 
617 //--unused--    for (i=0; i<Num_fuelcenters; i++ )      {
618 //--unused--            Station[i].Capacity = Station[i].MaxCapacity;
619 //--unused--    }
620 //--unused--    //mprintf( (0, "All fuel centers are replenished\n" ));
621 //--unused-- 
622 //--unused-- }
623
624 #define FUELCEN_SOUND_DELAY (f1_0/4)            //play every half second
625
626 //-------------------------------------------------------------
627 fix fuelcen_give_fuel(segment *segp, fix MaxAmountCanTake )
628 {
629         segment2        *seg2p = &Segment2s[segp-Segments];
630
631         static fix last_play_time=0;
632
633         Assert( segp != NULL );
634
635         PlayerSegment = segp;
636
637         if ( (segp) && (seg2p->special==SEGMENT_IS_FUELCEN) )   {
638                 fix amount;
639
640                 detect_escort_goal_accomplished(-4);    //      UGLY! Hack! -4 means went through fuelcen.
641
642 //              if (Station[segp->value].MaxCapacity<=0)        {
643 //                      HUD_init_message( "Fuelcenter %d is destroyed.", segp->value );
644 //                      return 0;
645 //              }
646
647 //              if (Station[segp->value].Capacity<=0)   {
648 //                      HUD_init_message( "Fuelcenter %d is empty.", segp->value );
649 //                      return 0;
650 //              }
651
652                 if (MaxAmountCanTake <= 0 )     {
653 //                      //gauge_message( "Fueled up!");
654                         return 0;
655                 }
656
657                 amount = fixmul(FrameTime,Fuelcen_give_amount);
658
659                 if (amount > MaxAmountCanTake )
660                         amount = MaxAmountCanTake;
661
662 //              if (!(Game_mode & GM_MULTI))
663 //                      if ( Station[segp->value].Capacity < amount  )  {
664 //                              amount = Station[segp->value].Capacity;
665 //                              Station[segp->value].Capacity = 0;
666 //                      } else {
667 //                              Station[segp->value].Capacity -= amount;
668 //                      }
669
670                 if (last_play_time > GameTime)
671                         last_play_time = 0;
672
673                 if (GameTime > last_play_time+FUELCEN_SOUND_DELAY) {
674
675                         digi_play_sample( SOUND_REFUEL_STATION_GIVING_FUEL, F1_0/2 );
676 #ifdef NETWORK
677                         if (Game_mode & GM_MULTI)
678                                 multi_send_play_sound(SOUND_REFUEL_STATION_GIVING_FUEL, F1_0/2);
679 #endif
680
681                         last_play_time = GameTime;
682                 }
683
684
685                 //HUD_init_message( "Fuelcen %d has %d/%d fuel", segp->value,f2i(Station[segp->value].Capacity),f2i(Station[segp->value].MaxCapacity) );
686                 return amount;
687
688         } else {
689                 return 0;
690         }
691 }
692
693 //--unused-- //-----------------------------------------------------------
694 //--unused-- // Damages a fuel center
695 //--unused-- void fuelcen_damage(segment *segp, fix damage )
696 //--unused-- {
697 //--unused--    //int i;
698 //--unused--    // int  station_num = segp->value;
699 //--unused-- 
700 //--unused--    Assert( segp != NULL );
701 //--unused--    if ( segp == NULL ) return;
702 //--unused-- 
703 //--unused--    mprintf((0, "Obsolete function fuelcen_damage() called with seg=%i, damage=%7.3f\n", segp-Segments, f2fl(damage)));
704 //--unused--    switch( segp->special ) {
705 //--unused--    case SEGMENT_IS_NOTHING:
706 //--unused--            return;
707 //--unused--    case SEGMENT_IS_ROBOTMAKER:
708 //--unused-- //--               // Robotmaker hit by laser
709 //--unused-- //--               if (Station[station_num].MaxCapacity<=0 )       {
710 //--unused-- //--                       // Shooting a already destroyed materializer
711 //--unused-- //--               } else {
712 //--unused-- //--                       Station[station_num].MaxCapacity -= damage;
713 //--unused-- //--                       if (Station[station_num].Capacity > Station[station_num].MaxCapacity )  {
714 //--unused-- //--                               Station[station_num].Capacity = Station[station_num].MaxCapacity;
715 //--unused-- //--                       }
716 //--unused-- //--                       if (Station[station_num].MaxCapacity <= 0 )     {
717 //--unused-- //--                               Station[station_num].MaxCapacity = 0;
718 //--unused-- //--                               // Robotmaker dead
719 //--unused-- //--                               for (i=0; i<6; i++ )
720 //--unused-- //--                                       segp->sides[i].tmap_num2 = 0;
721 //--unused-- //--                       }
722 //--unused-- //--               }
723 //--unused-- //--               //mprintf( (0, "Materializatormografier has %x capacity left\n", Station[station_num].MaxCapacity ));
724 //--unused--            break;
725 //--unused--    case SEGMENT_IS_FUELCEN:        
726 //--unused-- //--               digi_play_sample( SOUND_REFUEL_STATION_HIT );
727 //--unused-- //--               if (Station[station_num].MaxCapacity>0 )        {
728 //--unused-- //--                       Station[station_num].MaxCapacity -= damage;
729 //--unused-- //--                       if (Station[station_num].Capacity > Station[station_num].MaxCapacity )  {
730 //--unused-- //--                               Station[station_num].Capacity = Station[station_num].MaxCapacity;
731 //--unused-- //--                       }
732 //--unused-- //--                       if (Station[station_num].MaxCapacity <= 0 )     {
733 //--unused-- //--                               Station[station_num].MaxCapacity = 0;
734 //--unused-- //--                               digi_play_sample( SOUND_REFUEL_STATION_DESTROYED );
735 //--unused-- //--                       }
736 //--unused-- //--               } else {
737 //--unused-- //--                       Station[station_num].MaxCapacity = 0;
738 //--unused-- //--               }
739 //--unused-- //--               HUD_init_message( "Fuelcenter %d damaged", station_num );
740 //--unused--            break;
741 //--unused--    case SEGMENT_IS_REPAIRCEN:
742 //--unused--            break;
743 //--unused--    case SEGMENT_IS_CONTROLCEN:
744 //--unused--            break;
745 //--unused--    default:
746 //--unused--            Error( "Invalid type in fuelcen.c" );
747 //--unused--    }
748 //--unused-- }
749
750 //--unused-- // ----------------------------------------------------------------------------------------------------------
751 //--unused-- fixang my_delta_ang(fixang a,fixang b)
752 //--unused-- {
753 //--unused--    fixang delta0,delta1;
754 //--unused-- 
755 //--unused--    return (abs(delta0 = a - b) < abs(delta1 = b - a)) ? delta0 : delta1;
756 //--unused-- 
757 //--unused-- }
758
759 //--unused-- // ----------------------------------------------------------------------------------------------------------
760 //--unused-- //return though which side of seg0 is seg1
761 //--unused-- int john_find_connect_side(int seg0,int seg1)
762 //--unused-- {
763 //--unused--    segment *Seg=&Segments[seg0];
764 //--unused--    int i;
765 //--unused-- 
766 //--unused--    for (i=MAX_SIDES_PER_SEGMENT;i--;) if (Seg->children[i]==seg1) return i;
767 //--unused-- 
768 //--unused--    return -1;
769 //--unused-- }
770
771 //      ----------------------------------------------------------------------------------------------------------
772 //--unused-- vms_angvec start_angles, delta_angles, goal_angles;
773 //--unused-- vms_vector start_pos, delta_pos, goal_pos;
774 //--unused-- int FuelStationSeg;
775 //--unused-- fix current_time,delta_time;
776 //--unused-- int next_side, side_index;
777 //--unused-- int * sidelist;
778
779 //--repair-- int Repairing;
780 //--repair-- vms_vector repair_save_uvec;               //the player's upvec when enter repaircen
781 //--repair-- object *RepairObj=NULL;            //which object getting repaired
782 //--repair-- int disable_repair_center=0;
783 //--repair-- fix repair_rate;
784 //--repair-- #define FULL_REPAIR_RATE i2f(10)
785
786 //--unused-- ubyte save_control_type,save_movement_type;
787
788 //--unused-- int SideOrderBack[] = {WFRONT, WRIGHT, WTOP, WLEFT, WBOTTOM, WBACK};
789 //--unused-- int SideOrderFront[] =  {WBACK, WLEFT, WTOP, WRIGHT, WBOTTOM, WFRONT};
790 //--unused-- int SideOrderLeft[] =  { WRIGHT, WBACK, WTOP, WFRONT, WBOTTOM, WLEFT };
791 //--unused-- int SideOrderRight[] =  { WLEFT, WFRONT, WTOP, WBACK, WBOTTOM, WRIGHT };
792 //--unused-- int SideOrderTop[] =  { WBOTTOM, WLEFT, WBACK, WRIGHT, WFRONT, WTOP };
793 //--unused-- int SideOrderBottom[] =  { WTOP, WLEFT, WFRONT, WRIGHT, WBACK, WBOTTOM };
794
795 //--unused-- int SideUpVector[] = {WBOTTOM, WFRONT, WBOTTOM, WFRONT, WBOTTOM, WBOTTOM };
796
797 //--repair-- // ----------------------------------------------------------------------------------------------------------
798 //--repair-- void refuel_calc_deltas(object *obj, int next_side, int repair_seg)
799 //--repair-- {
800 //--repair--    vms_vector nextcenter, headfvec, *headuvec;
801 //--repair--    vms_matrix goal_orient;
802 //--repair-- 
803 //--repair--    // Find time for this movement
804 //--repair--    delta_time = F1_0;              // one second...
805 //--repair--            
806 //--repair--    // Find start and goal position
807 //--repair--    start_pos = obj->pos;
808 //--repair--    
809 //--repair--    // Find delta position to get to goal position
810 //--repair--    compute_segment_center(&goal_pos,&Segments[repair_seg]);
811 //--repair--    vm_vec_sub( &delta_pos,&goal_pos,&start_pos);
812 //--repair--    
813 //--repair--    // Find start angles
814 //--repair--    //angles_from_vector(&start_angles,&obj->orient.fvec);
815 //--repair--    vm_extract_angles_matrix(&start_angles,&obj->orient);
816 //--repair--    
817 //--repair--    // Find delta angles to get to goal orientation
818 //--repair--    med_compute_center_point_on_side(&nextcenter,&Segments[repair_seg],next_side);
819 //--repair--    vm_vec_sub(&headfvec,&nextcenter,&goal_pos);
820 //--repair--    //mprintf( (0, "Next_side = %d, Head fvec = %d,%d,%d\n", next_side, headfvec.x, headfvec.y, headfvec.z ));
821 //--repair-- 
822 //--repair--    if (next_side == 5)                                             //last side
823 //--repair--            headuvec = &repair_save_uvec;
824 //--repair--    else
825 //--repair--            headuvec = &Segments[repair_seg].sides[SideUpVector[next_side]].normals[0];
826 //--repair-- 
827 //--repair--    vm_vector_2_matrix(&goal_orient,&headfvec,headuvec,NULL);
828 //--repair--    vm_extract_angles_matrix(&goal_angles,&goal_orient);
829 //--repair--    delta_angles.p = my_delta_ang(start_angles.p,goal_angles.p);
830 //--repair--    delta_angles.b = my_delta_ang(start_angles.b,goal_angles.b);
831 //--repair--    delta_angles.h = my_delta_ang(start_angles.h,goal_angles.h);
832 //--repair--    current_time = 0;
833 //--repair--    Repairing = 0;
834 //--repair-- }
835 //--repair-- 
836 //--repair-- // ----------------------------------------------------------------------------------------------------------
837 //--repair-- //if repairing, cut it short
838 //--repair-- abort_repair_center()
839 //--repair-- {
840 //--repair--    if (!RepairObj || side_index==5)
841 //--repair--            return;
842 //--repair-- 
843 //--repair--    current_time = 0;
844 //--repair--    side_index = 5;
845 //--repair--    next_side = sidelist[side_index];
846 //--repair--    refuel_calc_deltas(RepairObj, next_side, FuelStationSeg);
847 //--repair-- }
848 //--repair-- 
849 //--repair-- // ----------------------------------------------------------------------------------------------------------
850 //--repair-- void repair_ship_damage()
851 //--repair-- {
852 //--repair--    //mprintf((0,"Repairing ship damage\n"));
853 //--repair-- }
854 //--repair-- 
855 //--repair-- // ----------------------------------------------------------------------------------------------------------
856 //--repair-- int refuel_do_repair_effect( object * obj, int first_time, int repair_seg )        {
857 //--repair-- 
858 //--repair--    obj->mtype.phys_info.velocity.x = 0;                            
859 //--repair--    obj->mtype.phys_info.velocity.y = 0;                            
860 //--repair--    obj->mtype.phys_info.velocity.z = 0;                            
861 //--repair-- 
862 //--repair--    if (first_time) {
863 //--repair--            int entry_side;
864 //--repair--            current_time = 0;
865 //--repair-- 
866 //--repair--            digi_play_sample( SOUND_REPAIR_STATION_PLAYER_ENTERING, F1_0 );
867 //--repair-- 
868 //--repair--            entry_side = john_find_connect_side(repair_seg,obj->segnum );
869 //--repair--            Assert( entry_side > -1 );
870 //--repair-- 
871 //--repair--            switch( entry_side )    {
872 //--repair--            case WBACK: sidelist = SideOrderBack; break;
873 //--repair--            case WFRONT: sidelist = SideOrderFront; break;
874 //--repair--            case WLEFT: sidelist = SideOrderLeft; break;
875 //--repair--            case WRIGHT: sidelist = SideOrderRight; break;
876 //--repair--            case WTOP: sidelist = SideOrderTop; break;
877 //--repair--            case WBOTTOM: sidelist = SideOrderBottom; break;
878 //--repair--            }
879 //--repair--            side_index = 0;
880 //--repair--            next_side = sidelist[side_index];
881 //--repair-- 
882 //--repair--            refuel_calc_deltas(obj,next_side, repair_seg);
883 //--repair--    } 
884 //--repair-- 
885 //--repair--    //update shields
886 //--repair--    if (Players[Player_num].shields < MAX_SHIELDS) {        //if above max, don't mess with it
887 //--repair-- 
888 //--repair--            Players[Player_num].shields += fixmul(FrameTime,repair_rate);
889 //--repair-- 
890 //--repair--            if (Players[Player_num].shields > MAX_SHIELDS)
891 //--repair--                    Players[Player_num].shields = MAX_SHIELDS;
892 //--repair--    }
893 //--repair-- 
894 //--repair--    current_time += FrameTime;
895 //--repair-- 
896 //--repair--    if (current_time >= delta_time )        {
897 //--repair--            vms_angvec av;
898 //--repair--            obj->pos = goal_pos;
899 //--repair--            av      = goal_angles;
900 //--repair--            vm_angles_2_matrix(&obj->orient,&av);
901 //--repair-- 
902 //--repair--            if (side_index >= 5 )   
903 //--repair--                    return 1;               // Done being repaired...
904 //--repair-- 
905 //--repair--            if (Repairing==0)               {
906 //--repair--                    //mprintf( (0, "<MACHINE EFFECT ON SIDE %d>\n", next_side ));
907 //--repair--                    //digi_play_sample( SOUND_REPAIR_STATION_FIXING );
908 //--repair--                    Repairing=1;
909 //--repair-- 
910 //--repair--                    switch( next_side )     {
911 //--repair--                    case 0: digi_play_sample( SOUND_REPAIR_STATION_FIXING_1,F1_0 ); break;
912 //--repair--                    case 1: digi_play_sample( SOUND_REPAIR_STATION_FIXING_2,F1_0 ); break;
913 //--repair--                    case 2: digi_play_sample( SOUND_REPAIR_STATION_FIXING_3,F1_0 ); break;
914 //--repair--                    case 3: digi_play_sample( SOUND_REPAIR_STATION_FIXING_4,F1_0 ); break;
915 //--repair--                    case 4: digi_play_sample( SOUND_REPAIR_STATION_FIXING_1,F1_0 ); break;
916 //--repair--                    case 5: digi_play_sample( SOUND_REPAIR_STATION_FIXING_2,F1_0 ); break;
917 //--repair--                    }
918 //--repair--            
919 //--repair--                    repair_ship_damage();
920 //--repair-- 
921 //--repair--            }
922 //--repair-- 
923 //--repair--            if (current_time >= (delta_time+(F1_0/2)) )     {
924 //--repair--                    current_time = 0;
925 //--repair--                    // Find next side...
926 //--repair--                    side_index++;
927 //--repair--                    if (side_index >= 6 ) return 1;
928 //--repair--                    next_side = sidelist[side_index];
929 //--repair--    
930 //--repair--                    refuel_calc_deltas(obj, next_side, repair_seg);
931 //--repair--            }
932 //--repair-- 
933 //--repair--    } else {
934 //--repair--            fix factor, p,b,h;      
935 //--repair--            vms_angvec av;
936 //--repair-- 
937 //--repair--            factor = fixdiv( current_time,delta_time );
938 //--repair-- 
939 //--repair--            // Find object's current position
940 //--repair--            obj->pos = delta_pos;
941 //--repair--            vm_vec_scale( &obj->pos, factor );
942 //--repair--            vm_vec_add2( &obj->pos, &start_pos );
943 //--repair--                    
944 //--repair--            // Find object's current orientation
945 //--repair--            p       = fixmul(delta_angles.p,factor);
946 //--repair--            b       = fixmul(delta_angles.b,factor);
947 //--repair--            h       = fixmul(delta_angles.h,factor);
948 //--repair--            av.p = (fixang)p + start_angles.p;
949 //--repair--            av.b = (fixang)b + start_angles.b;
950 //--repair--            av.h = (fixang)h + start_angles.h;
951 //--repair--            vm_angles_2_matrix(&obj->orient,&av);
952 //--repair-- 
953 //--repair--    }
954 //--repair-- 
955 //--repair--    update_object_seg(obj);         //update segment
956 //--repair-- 
957 //--repair--    return 0;
958 //--repair-- }
959 //--repair-- 
960 //--repair-- // ----------------------------------------------------------------------------------------------------------
961 //--repair-- //do the repair center for this frame
962 //--repair-- void do_repair_sequence(object *obj)
963 //--repair-- {
964 //--repair--    Assert(obj == RepairObj);
965 //--repair-- 
966 //--repair--    if (refuel_do_repair_effect( obj, 0, FuelStationSeg )) {
967 //--repair--            if (Players[Player_num].shields < MAX_SHIELDS)
968 //--repair--                    Players[Player_num].shields = MAX_SHIELDS;
969 //--repair--            obj->control_type = save_control_type;
970 //--repair--            obj->movement_type = save_movement_type;
971 //--repair--            disable_repair_center=1;
972 //--repair--            RepairObj = NULL;
973 //--repair-- 
974 //--repair-- 
975 //--repair--            //the two lines below will spit the player out of the rapair center,
976 //--repair--            //but what happen is that the ship just bangs into the door
977 //--repair--            //if (obj->movement_type == MT_PHYSICS)
978 //--repair--            //      vm_vec_copy_scale(&obj->mtype.phys_info.velocity,&obj->orient.fvec,i2f(200));
979 //--repair--    }
980 //--repair-- 
981 //--repair-- }
982 //--repair-- 
983 //--repair-- // ----------------------------------------------------------------------------------------------------------
984 //--repair-- //see if we should start the repair center
985 //--repair-- void check_start_repair_center(object *obj)
986 //--repair-- {
987 //--repair--    if (RepairObj != NULL) return;          //already in repair center
988 //--repair-- 
989 //--repair--    if (Lsegments[obj->segnum].special_type & SS_REPAIR_CENTER) {
990 //--repair-- 
991 //--repair--            if (!disable_repair_center) {
992 //--repair--                    //have just entered repair center
993 //--repair-- 
994 //--repair--                    RepairObj = obj;
995 //--repair--                    repair_save_uvec = obj->orient.uvec;
996 //--repair-- 
997 //--repair--                    repair_rate = fixmuldiv(FULL_REPAIR_RATE,(MAX_SHIELDS - Players[Player_num].shields),MAX_SHIELDS);
998 //--repair-- 
999 //--repair--                    save_control_type = obj->control_type;
1000 //--repair--                    save_movement_type = obj->movement_type;
1001 //--repair-- 
1002 //--repair--                    obj->control_type = CT_REPAIRCEN;
1003 //--repair--                    obj->movement_type = MT_NONE;
1004 //--repair-- 
1005 //--repair--                    FuelStationSeg  = Lsegments[obj->segnum].special_segment;
1006 //--repair--                    Assert(FuelStationSeg != -1);
1007 //--repair-- 
1008 //--repair--                    if (refuel_do_repair_effect( obj, 1, FuelStationSeg )) {
1009 //--repair--                            Int3();         //can this happen?
1010 //--repair--                            obj->control_type = CT_FLYING;
1011 //--repair--                            obj->movement_type = MT_PHYSICS;
1012 //--repair--                    }
1013 //--repair--            }
1014 //--repair--    }
1015 //--repair--    else
1016 //--repair--            disable_repair_center=0;
1017 //--repair-- 
1018 //--repair-- }
1019
1020 //      --------------------------------------------------------------------------------------------
1021 void disable_matcens(void)
1022 {
1023         int     i;
1024
1025         for (i=0; i<Num_robot_centers; i++) {
1026                 Station[i].Enabled = 0;
1027                 Station[i].Disable_time = 0;
1028         }
1029 }
1030
1031 //      --------------------------------------------------------------------------------------------
1032 //      Initialize all materialization centers.
1033 //      Give them all the right number of lives.
1034 void init_all_matcens(void)
1035 {
1036         int     i;
1037
1038         for (i=0; i<Num_fuelcenters; i++)
1039                 if (Station[i].Type == SEGMENT_IS_ROBOTMAKER) {
1040                         Station[i].Lives = 3;
1041                         Station[i].Enabled = 0;
1042                         Station[i].Disable_time = 0;
1043 #ifndef NDEBUG
1044 {
1045                         //      Make sure this fuelcen is pointed at by a matcen.
1046                         int     j;
1047                         for (j=0; j<Num_robot_centers; j++) {
1048                                 if (RobotCenters[j].fuelcen_num == i)
1049                                         break;
1050                         }
1051                         Assert(j != Num_robot_centers);
1052 }
1053 #endif
1054
1055                 }
1056
1057 #ifndef NDEBUG
1058         //      Make sure all matcens point at a fuelcen
1059         for (i=0; i<Num_robot_centers; i++) {
1060                 int     fuelcen_num = RobotCenters[i].fuelcen_num;
1061
1062                 Assert(fuelcen_num < Num_fuelcenters);
1063                 Assert(Station[fuelcen_num].Type == SEGMENT_IS_ROBOTMAKER);
1064         }
1065 #endif
1066
1067 }
1068
1069 #ifdef NETWORK
1070 extern void multi_send_capture_bonus (char);
1071
1072 void fuelcen_check_for_goal(segment *segp)
1073 {
1074         segment2        *seg2p = &Segment2s[segp-Segments];
1075
1076         Assert( segp != NULL );
1077         Assert (Game_mode & GM_CAPTURE);
1078
1079         if (seg2p->special==SEGMENT_IS_GOAL_BLUE )      {
1080
1081                         if ((get_team(Player_num)==TEAM_BLUE) && (Players[Player_num].flags & PLAYER_FLAGS_FLAG))
1082                          {
1083                                 mprintf ((0,"In goal segment BLUE\n"));
1084
1085                                 multi_send_capture_bonus (Player_num);
1086                                 Players[Player_num].flags &=(~(PLAYER_FLAGS_FLAG));
1087                                 maybe_drop_net_powerup (POW_FLAG_RED);
1088                          }
1089                  }
1090         if ( seg2p->special==SEGMENT_IS_GOAL_RED) {
1091
1092                         if ((get_team(Player_num)==TEAM_RED) && (Players[Player_num].flags & PLAYER_FLAGS_FLAG))
1093                          {              
1094                                 mprintf ((0,"In goal segment RED\n"));
1095                                 multi_send_capture_bonus (Player_num);
1096                                 Players[Player_num].flags &=(~(PLAYER_FLAGS_FLAG));
1097                                 maybe_drop_net_powerup (POW_FLAG_BLUE);
1098                          }
1099                  }
1100   } 
1101
1102 void fuelcen_check_for_hoard_goal(segment *segp)
1103 {
1104         segment2        *seg2p = &Segment2s[segp-Segments];
1105
1106         Assert( segp != NULL );
1107         Assert (Game_mode & GM_HOARD);
1108
1109    if (Player_is_dead)
1110                 return;
1111
1112         if (seg2p->special==SEGMENT_IS_GOAL_BLUE || seg2p->special==SEGMENT_IS_GOAL_RED  )      
1113         {
1114                 if (Players[Player_num].secondary_ammo[PROXIMITY_INDEX])
1115                 {
1116                                 mprintf ((0,"In orb goal!\n"));
1117                                 multi_send_orb_bonus (Player_num);
1118                                 Players[Player_num].flags &=(~(PLAYER_FLAGS_FLAG));
1119                                 Players[Player_num].secondary_ammo[PROXIMITY_INDEX]=0;
1120       }
1121         }
1122
1123
1124
1125 #endif
1126
1127
1128