1 /*
2 Solar Conquest
3 Copyright (C) 2006 Greg Beaman
4 
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
9 
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 GNU General Public License for more details.
14 
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19 
20 #define PROJECTILE_TYPE_BULLET 1
21 #define PROJECTILE_TYPE_ROCKET 2
22 #define PROJECTILE_TYPE_LASER 3
23 #define PROJECTILE_TYPE_FLAK 4
24 #define PROJECTILE_TYPE_SMALLROCKET 5
25 #define PROJECTILE_TYPE_PLASMA 6
26 
27 class CProjectileData
28 {
29 private:
30 public:
31 	int id;
32 	int type;
33 	int damage;
34 	float colorR;
35 	float colorG;
36 	float colorB;
37 	float colorA;
38 	float lifeTime;
39 	float fireDelay;
40 	float maxSpeed;
41 	float strafeSpeed;
42 	float turnRate;
43 	float radius;
44 
45 	bool lockonProjectile;
46 
47 	CProjectileData* prevData;
48 	CProjectileData* nextData;
49 
50 	CSoundListNode* sound;
51 
52 	CProjectileData();
53 	~CProjectileData();
54 };
55 
CProjectileData()56 CProjectileData::CProjectileData()
57 {
58 	prevData = NULL;
59 	nextData = NULL;
60 
61 	sound = NULL;
62 
63 	lockonProjectile = false;
64 }
65 
~CProjectileData()66 CProjectileData::~CProjectileData()
67 {
68 }
69 
70 CProjectileData* g_firstProjectileData = NULL;
71 
72 //Just quickly places the Projectile data at the beginning of the linked list
AddProjectileData(int id)73 CProjectileData* AddProjectileData(int id)
74 {
75 	CProjectileData* newData;
76 	newData = new CProjectileData();
77 	if (!newData)
78 		return NULL;
79 	newData->nextData = g_firstProjectileData;
80 	if (g_firstProjectileData)
81 		g_firstProjectileData->prevData = newData;
82 	g_firstProjectileData = newData;
83 	newData->id = id;
84 	return newData;
85 }
86 
DeleteProjectileData(CProjectileData * data)87 void DeleteProjectileData(CProjectileData* data)
88 {
89 	if (!data)
90 		return;
91 
92 	if (data->prevData)
93 		data->prevData->nextData = data->nextData;
94 	else
95 		g_firstProjectileData = data->nextData;
96 	if (data->nextData)
97 		data->nextData->prevData = data->prevData;
98 	delete data;
99 }
100 
FindProjectileData(int id)101 CProjectileData* FindProjectileData(int id)
102 {
103 	CProjectileData* data = g_firstProjectileData;
104 	while (data)
105 	{
106 		if (data->id == id)
107 			return data;
108 		data = data->nextData;
109 	}
110 	return NULL;
111 }
112 
DeleteAllProjectileData()113 void DeleteAllProjectileData()
114 {
115 	CProjectileData* curData;
116 	CProjectileData* tmpData;
117 	curData = g_firstProjectileData;
118 	while (curData)
119 	{
120 		tmpData = curData->nextData;
121 		delete curData;
122 		curData = tmpData;
123 	}
124 	g_firstProjectileData = NULL;
125 }
126