This repository has been archived by the owner on Feb 27, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 298
/
Copy pathCARGO.CPP
183 lines (167 loc) · 10.5 KB
/
CARGO.CPP
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
/*
** Command & Conquer(tm)
** Copyright 2025 Electronic Arts Inc.
**
** This program is free software: you can redistribute it and/or modify
** it under the terms of the GNU General Public License as published by
** the Free Software Foundation, either version 3 of the License, or
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/* $Header: F:\projects\c&c\vcs\code\cargo.cpv 2.18 16 Oct 1995 16:49:50 JOE_BOSTIC $ */
/***********************************************************************************************
*** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
***********************************************************************************************
* *
* Project Name : Command & Conquer *
* *
* File Name : CARGO.CPP *
* *
* Programmer : Joe L. Bostic *
* *
* Start Date : April 23, 1994 *
* *
* Last Update : 10/31/94 [JLB] *
* *
*---------------------------------------------------------------------------------------------*
* Functions: *
* CargoClass::Attach -- Add unit to cargo hold. *
* CargoClass::Attached_Object -- Determine attached unit pointer. *
* CargoClass::Detach_Object -- Removes a unit from the cargo hold. *
* CargoClass::Debug_Dump -- Displays the cargo value to the monochrome screen. *
* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
#include "function.h"
#ifdef CHEAT_KEYS
/***********************************************************************************************
* CargoClass::Debug_Dump -- Displays the cargo value to the monochrome screen. *
* *
* This routine is used to dump the current cargo value to the monochrome monitor. *
* *
* INPUT: none *
* *
* OUTPUT: none *
* *
* WARNINGS: none *
* *
* HISTORY: *
* 06/02/1994 JLB : Created. *
*=============================================================================================*/
void CargoClass::Debug_Dump(MonoClass * mono) const
{
if (How_Many()) {
mono->Set_Cursor(63, 3);
mono->Printf("(%d)%04X", How_Many(), Attached_Object());
}
}
#endif
/***********************************************************************************************
* CargoClass::Attach -- Add unit to cargo hold. *
* *
* This routine will add the specified unit to the cargo hold. The *
* unit will chain to any existing units in the hold. The chaining is *
* in a LIFO order. *
* *
* INPUT: object-- Pointer to the object to attach to the cargo hold. *
* *
* OUTPUT: none *
* *
* WARNINGS: none *
* *
* HISTORY: *
* 04/23/1994 JLB : Created. *
* 10/31/94 JLB : Handles chained objects. *
*=============================================================================================*/
void CargoClass::Attach(FootClass * object)
{
/*
** If there is no object, then no action is necessary.
*/
if (!object) return;
object->Limbo();
/*
** Attach any existing cargo hold object to the end of the list as indicated by the
** object pointer passed into this routine. This is necessary because several objects may
** be attached at one time or several objects may be attached as a result of several calls
** to this routine. Either case must be handled properly.
*/
ObjectClass * o = object->Next;
while (o) {
if (!o->Next) break;
o = o->Next;
}
if (o) {
o->Next = CargoHold;
} else {
object->Next = CargoHold;
}
/*
** Finally, assign the object pointer as the first object attached to this cargo hold.
*/
CargoHold = object;
Quantity = 0;
object = CargoHold;
while (object) {
Quantity++;
object = (FootClass *)object->Next;
}
}
/***********************************************************************************************
* CargoClass::Detach_Object -- Removes a unit from the cargo hold. *
* *
* This routine will take a unit from the cargo hold and extract it. *
* The unit extracted is the last unit added to the hold. If there *
* is no unit in the hold or the occupant is not a unit, then NULL is *
* returned. *
* *
* INPUT: none *
* *
* OUTPUT: Returns with a pointer to the unit that has been extracted. *
* *
* WARNINGS: none *
* *
* HISTORY: *
* 04/23/1994 JLB : Created. *
* 06/07/1994 JLB : Handles generic object types. *
*=============================================================================================*/
FootClass * CargoClass::Detach_Object(void)
{
FootClass * unit = Attached_Object();
if (unit) {
CargoHold = (FootClass *)unit->Next;
unit->Next = 0;
Quantity--;
}
return(unit);
}
/***********************************************************************************************
* CargoClass::Attached_Object -- Determine attached unit pointer. *
* *
* This routine will return with a pointer to the attached unit if one *
* is present. One would need to know this if this is a transport *
* unit and it needs to unload. *
* *
* INPUT: none *
* *
* OUTPUT: Returns a pointer to the attached unit. If there is no *
* attached unit, then return NULL. *
* *
* WARNINGS: none *
* *
* HISTORY: *
* 09/07/1992 JLB : Created. *
* 06/07/1994 JLB : Handles generic object types. *
*=============================================================================================*/
FootClass * CargoClass::Attached_Object(void) const
{
if (Is_Something_Attached()) {
return(CargoHold);
}
return(NULL);
}