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