dxx-rebirth/common/main/fuelcen.h

186 lines
6 KiB
C
Raw Normal View History

2006-03-20 17:12:09 +00:00
/*
2014-06-01 17:55:23 +00:00
* Portions of this file are copyright Rebirth contributors and licensed as
* described in COPYING.txt.
* Portions of this file are copyright Parallax Software and licensed
* according to the Parallax license below.
* See COPYING.txt for license details.
2006-03-20 17:12:09 +00:00
THE COMPUTER CODE CONTAINED HEREIN IS THE SOLE PROPERTY OF PARALLAX
SOFTWARE CORPORATION ("PARALLAX"). PARALLAX, IN DISTRIBUTING THE CODE TO
END-USERS, AND SUBJECT TO ALL OF THE TERMS AND CONDITIONS HEREIN, GRANTS A
ROYALTY-FREE, PERPETUAL LICENSE TO SUCH END-USERS FOR USE BY SUCH END-USERS
IN USING, DISPLAYING, AND CREATING DERIVATIVE WORKS THEREOF, SO LONG AS
SUCH USE, DISPLAY OR CREATION IS FOR NON-COMMERCIAL, ROYALTY OR REVENUE
FREE PURPOSES. IN NO EVENT SHALL THE END-USER USE THE COMPUTER CODE
CONTAINED HEREIN FOR REVENUE-BEARING PURPOSES. THE END-USER UNDERSTANDS
AND AGREES TO THE TERMS HEREIN AND ACCEPTS THE SAME BY USE OF THIS FILE.
COPYRIGHT 1993-1999 PARALLAX SOFTWARE CORPORATION. ALL RIGHTS RESERVED.
*/
/*
*
* Definitions for fueling centers.
*
*/
2015-01-29 04:27:36 +00:00
#pragma once
2006-03-20 17:12:09 +00:00
#ifdef __cplusplus
#include "pack.h"
#include "fwd-object.h"
#include "fwd-segment.h"
#include "fwd-vecmat.h"
2006-03-20 17:12:09 +00:00
//------------------------------------------------------------
// A refueling center is one segment... to identify it in the
// segment structure, the "special" field is set to
// SEGMENT_IS_FUELCEN. The "value" field is then used for how
// much fuel the center has left, with a maximum value of 100.
//-------------------------------------------------------------
// To hook into Inferno:
// * When all segents are deleted or before a new mine is created
// or loaded, call fuelcen_reset().
// * Add call to fuelcen_create(segment * segp) to make a segment
// which isn't a fuel center be a fuel center.
// * When a mine is loaded call fuelcen_activate(segp) with each
// new segment as it loads. Always do this.
// * When a segment is deleted, always call fuelcen_delete(segp).
// * When an object that needs to be refueled is in a segment, call
// fuelcen_give_fuel(segp) to get fuel. (Call once for any refueling
// object once per frame with the object's current segment.) This
// will return a value between 0 and 100 that tells how much fuel
// he got.
#if defined(DXX_BUILD_DESCENT_I) || defined(DXX_BUILD_DESCENT_II)
namespace dsx {
2006-03-20 17:12:09 +00:00
// Destroys all fuel centers, clears segment backpointer array.
void fuelcen_reset();
2006-03-20 17:12:09 +00:00
// Makes a segment a fuel center.
2014-10-02 03:02:34 +00:00
void fuelcen_create( vsegptridx_t segp);
2006-03-20 17:12:09 +00:00
// Makes a fuel center active... needs to be called when
// a segment is loaded from disk.
2014-10-02 03:02:34 +00:00
void fuelcen_activate( vsegptridx_t segp, int station_type );
2006-03-20 17:12:09 +00:00
// Deletes a segment as a fuel center.
2015-07-12 01:04:18 +00:00
void fuelcen_delete(vsegptr_t segp);
2006-03-20 17:12:09 +00:00
// Create a matcen robot
2014-10-02 03:02:34 +00:00
objptridx_t create_morph_robot(vsegptridx_t segp, const vms_vector &object_pos, int object_id);
2006-03-20 17:12:09 +00:00
// Returns the amount of fuel/shields this segment can give up.
2006-03-20 17:12:09 +00:00
// Can be from 0 to 100.
2015-05-09 17:39:00 +00:00
fix fuelcen_give_fuel(vcsegptr_t segp, fix MaxAmountCanTake);
}
2006-03-20 17:12:09 +00:00
// Call once per frame.
void fuelcen_update_all();
// Called to repair an object
//--repair-- int refuel_do_repair_effect( object * obj, int first_time, int repair_seg );
namespace dsx {
#if defined(DXX_BUILD_DESCENT_I)
#define MAX_NUM_FUELCENS 50
#elif defined(DXX_BUILD_DESCENT_II)
2015-05-09 17:39:00 +00:00
fix repaircen_give_shields(vcsegptr_t segp, fix MaxAmountCanTake);
2006-03-20 17:12:09 +00:00
#define MAX_NUM_FUELCENS 70
#endif
#endif
}
2006-03-20 17:12:09 +00:00
//--repair-- //do the repair center for this frame
//--repair-- void do_repair_sequence(object *obj);
//--repair--
//--repair-- //see if we should start the repair center
//--repair-- void check_start_repair_center(object *obj);
//--repair--
//--repair-- //if repairing, cut it short
//--repair-- abort_repair_center();
// An array of pointers to segments with fuel centers.
struct FuelCenter : public prohibit_void_ptr<FuelCenter>
{
2006-03-20 17:12:09 +00:00
int Type;
segnum_t segnum;
2006-03-20 17:12:09 +00:00
sbyte Flag;
sbyte Enabled;
sbyte Lives; // Number of times this can be enabled.
fix Capacity;
fix MaxCapacity;
fix Timer; // used in matcen for when next robot comes out
fix Disable_time; // Time until center disabled.
2014-01-18 18:02:02 +00:00
};
2006-03-20 17:12:09 +00:00
// The max number of robot centers per mine.
#define MAX_ROBOT_CENTERS 20
struct d1_matcen_info : public prohibit_void_ptr<d1_matcen_info>
{
2015-08-22 20:43:03 +00:00
array<unsigned, 1> robot_flags; // Up to 32 different robots
segnum_t segnum; // Segment this is attached to.
2006-03-20 17:12:09 +00:00
short fuelcen_num; // Index in fuelcen array.
2014-01-12 23:00:43 +00:00
};
2006-03-20 17:12:09 +00:00
#if defined(DXX_BUILD_DESCENT_I) || defined(DXX_BUILD_DESCENT_II)
namespace dsx {
#if defined(DXX_BUILD_DESCENT_I)
typedef d1_matcen_info matcen_info;
2014-01-12 23:00:43 +00:00
void matcen_info_read(PHYSFS_file *fp, matcen_info &ps, int version);
#elif defined(DXX_BUILD_DESCENT_II)
struct matcen_info : public prohibit_void_ptr<matcen_info>
{
2015-08-22 20:43:03 +00:00
array<unsigned, 2> robot_flags; // Up to 64 different robots
segnum_t segnum; // Segment this is attached to.
2006-03-20 17:12:09 +00:00
short fuelcen_num; // Index in fuelcen array.
2014-01-12 23:00:43 +00:00
};
void matcen_info_read(PHYSFS_file *fp, matcen_info &ps);
#endif
2006-03-20 17:12:09 +00:00
extern const char Special_names[MAX_CENTER_TYPES][11];
2014-01-18 18:02:02 +00:00
extern array<matcen_info, MAX_ROBOT_CENTERS> RobotCenters;
2014-01-18 18:02:02 +00:00
extern array<FuelCenter, MAX_NUM_FUELCENS> Station;
static inline long operator-(FuelCenter *s, array<FuelCenter, MAX_NUM_FUELCENS> &a)
{
return std::distance(a.begin(), s);
}
2006-03-20 17:12:09 +00:00
// Called when a materialization center gets triggered by the player
// flying through some trigger!
2014-11-23 04:58:45 +00:00
void trigger_matcen(vsegptridx_t segnum);
2006-03-20 17:12:09 +00:00
extern void disable_matcens(void);
extern void init_all_matcens(void);
/*
* reads a matcen_info structure from a PHYSFS_file
*/
#if defined(DXX_BUILD_DESCENT_II)
2014-10-02 03:02:34 +00:00
void fuelcen_check_for_hoard_goal(vsegptr_t segp);
2006-03-20 17:12:09 +00:00
/*
* reads an d1_matcen_info structure from a PHYSFS_file
2006-03-20 17:12:09 +00:00
*/
2014-01-12 23:00:43 +00:00
void d1_matcen_info_read(PHYSFS_file *fp, matcen_info &mi);
#endif
2006-03-20 17:12:09 +00:00
2014-01-12 23:00:43 +00:00
void matcen_info_write(PHYSFS_file *fp, const matcen_info &mi, short version);
}
namespace dcx {
extern unsigned Num_robot_centers;
extern unsigned Num_fuelcenters;
extern const fix EnergyToCreateOneRobot;
}
#endif
2006-03-20 17:12:09 +00:00
2014-01-12 23:00:43 +00:00
void fuelcen_read(PHYSFS_file *fp, FuelCenter &fc);
void fuelcen_write(PHYSFS_file *fp, const FuelCenter &fc);
#endif