RADIO.CPP (13622B)
1 // 2 // Copyright 2020 Electronic Arts Inc. 3 // 4 // TiberianDawn.DLL and RedAlert.dll and corresponding source code is free 5 // software: you can redistribute it and/or modify it under the terms of 6 // the GNU General Public License as published by the Free Software Foundation, 7 // either version 3 of the License, or (at your option) any later version. 8 9 // TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed 10 // in the hope that it will be useful, but with permitted additional restrictions 11 // under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT 12 // distributed with this program. You should have received a copy of the 13 // GNU General Public License along with permitted additional restrictions 14 // with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection 15 16 /* $Header: F:\projects\c&c\vcs\code\radio.cpv 2.19 16 Oct 1995 16:50:12 JOE_BOSTIC $ */ 17 /*********************************************************************************************** 18 *** 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 *** 19 *********************************************************************************************** 20 * * 21 * Project Name : Command & Conquer * 22 * * 23 * File Name : RADIO.CPP * 24 * * 25 * Programmer : Joe L. Bostic * 26 * * 27 * Start Date : September 10, 1993 * 28 * * 29 * Last Update : June 25, 1995 [JLB] * 30 * * 31 *---------------------------------------------------------------------------------------------* 32 * Functions: * 33 * RadioClass::Debug_Dump -- Displays the current status of the radio to the mono monitor. * 34 * RadioClass::Receive_Message -- Handles receipt of a radio message. * 35 * RadioClass::Transmit_Message -- Transmit message from one object to another. * 36 * RadioClass::Limbo -- When limboing a unit will always break radio contact. * 37 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ 38 39 #include "function.h" 40 41 42 /* 43 ** These are the text representations of the radio messages that can be transmitted. 44 */ 45 char const * RadioClass::Messages[RADIO_COUNT] = { 46 "hisssss", 47 "Roger.", 48 "Come in.", 49 "Over and out.", 50 "Requesting transport.", 51 "Attach to transport.", 52 "I've got a delivery for you.", 53 "I'm performing load/unload maneuver. Be careful.", 54 "I'm clear.", 55 "You are clear to unload. Driving away now.", 56 "Am unable to comply.", 57 "I'm starting construction now... act busy.", 58 "I've finished construction. You are free.", 59 "We bumped, redraw yourself please.", 60 "I'm trying to load up now.", 61 "May I become a passenger?", 62 "Are you ready to receive shipment?", 63 "Are you trying to become a passenger?", 64 "Move to location X.", 65 "Do you need to move?", 66 "All right already. Now what?", 67 "I'm a passenger now.", 68 "Backup into refinery now.", 69 "Run away!", 70 "Tether established.", 71 "Tether broken.", 72 "Repair one step.", 73 "Are you prepared to fight?", 74 "Attack this target please.", 75 "Reload one step.", 76 "Take this kick! You... You...", 77 "Take this punch! You... You...", 78 "Fancy a little fisticuffs, eh?" 79 }; 80 81 82 #ifdef CHEAT_KEYS 83 /*********************************************************************************************** 84 * RadioClass::Debug_Dump -- Displays the current status of the radio to the mono monitor. * 85 * * 86 * This displays the radio connection value to the monochrome monitor. * 87 * * 88 * INPUT: none * 89 * * 90 * OUTPUT: none * 91 * * 92 * WARNINGS: none * 93 * * 94 * HISTORY: * 95 * 06/02/1994 JLB : Created. * 96 *=============================================================================================*/ 97 void RadioClass::Debug_Dump(MonoClass *mono) const 98 { 99 mono->Set_Cursor(34, 5);mono->Printf(Messages[LastMessage]); 100 if (Radio) { 101 mono->Set_Cursor(50, 1);mono->Printf("%04X", Radio->As_Target()); 102 } 103 MissionClass::Debug_Dump(mono); 104 } 105 #endif 106 107 108 /*********************************************************************************************** 109 * RadioClass::Receive_Message -- Handles receipt of a radio message. * 110 * * 111 * This is the base version of what should happen when a radio message is received. It * 112 * turns the radio off when the "OVER_OUT" message is received. All other messages are * 113 * merely acknowledged with a "ROGER". * 114 * * 115 * INPUT: from -- The object that is initiating this radio message (always valid). * 116 * * 117 * message -- The radio message received. * 118 * * 119 * param -- Reference to optional value that might be used to return more * 120 * information than can be conveyed in the simple radio response * 121 * messages. * 122 * * 123 * OUTPUT: Returns with the response radio message. * 124 * * 125 * WARNINGS: none * 126 * * 127 * HISTORY: * 128 * 05/28/1994 JLB : Created. * 129 * 09/24/1994 JLB : Streamlined to be only a communications carrier. * 130 * 05/22/1995 JLB : Recognized who is sending the message * 131 *=============================================================================================*/ 132 RadioMessageType RadioClass::Receive_Message(RadioClass * from, RadioMessageType message, long & param) 133 { 134 /* 135 ** Keep a record of the last message received by this radio. 136 */ 137 LastMessage = message; 138 139 /* 140 ** When this message is received, it means that the other object 141 ** has already turned its radio off. Turn this radio off as well. 142 ** This only applies if the message is coming from the object that 143 ** has an established conversation with this object. 144 */ 145 if (from == Radio && message == RADIO_OVER_OUT) { 146 MissionClass::Receive_Message(from, message, param); 147 Radio_Off(); 148 return(RADIO_ROGER); 149 } 150 151 /* 152 ** The "hello" message is an attempt to establish contact. If this radio 153 ** is already in an established conversation with another object, then 154 ** return with "negative". If all is well, return with "roger". 155 */ 156 if (message == RADIO_HELLO && Strength) { 157 if (Radio == from || !Radio) { 158 Radio = from; 159 return(RADIO_ROGER); 160 } 161 return(RADIO_NEGATIVE); 162 } 163 164 return(MissionClass::Receive_Message(from, message, param)); 165 } 166 167 168 /*********************************************************************************************** 169 * RadioClass::Transmit_Message -- Transmit message from one object to another. * 170 * * 171 * This routine is used to transmit a radio message from this object to another. Most * 172 * inter object coordination is handled through this mechanism. * 173 * * 174 * INPUT: to -- Pointer to the object that will receive the radio message. * 175 * * 176 * message -- The message itself (see RadioType). * 177 * * 178 * param -- Optional reference to parameter that might be used to pass or * 179 * receive additional information. * 180 * * 181 * OUTPUT: Returns with the response radio message from the receiving object. * 182 * * 183 * WARNINGS: none * 184 * * 185 * HISTORY: * 186 * 05/22/1995 JLB : Created. * 187 *=============================================================================================*/ 188 RadioMessageType RadioClass::Transmit_Message(RadioMessageType message, long & param, RadioClass * to) 189 { 190 if (!to) { 191 to = Contact_With_Whom(); 192 } 193 194 /* 195 ** If there is no target for the radio message, then always return static. 196 */ 197 if (!to) return(RADIO_STATIC); 198 199 /* 200 ** Handle some special case processing that occurs when certain messages 201 ** are transmitted. 202 */ 203 if (to == Radio && message == RADIO_OVER_OUT) { 204 Radio = 0; 205 } 206 207 /* 208 ** If this object is not in radio contact but the message 209 ** indicates that radio contact should be established, then 210 ** try to do so. If the other party agrees then contact 211 ** is established. 212 */ 213 if (/*!Radio &&*/ message == RADIO_HELLO) { 214 Transmit_Message(RADIO_OVER_OUT); 215 if (to->Receive_Message(this, message, param) == RADIO_ROGER) { 216 Radio = to; 217 return(RADIO_ROGER); 218 } 219 return(RADIO_NEGATIVE); 220 } 221 222 return(to->Receive_Message(this, message, param)); 223 } 224 225 226 /*********************************************************************************************** 227 * RadioClass::Limbo -- When limboing a unit will always break radio contact. * 228 * * 229 * This routine will break radio contact as the object is entering limbo state. * 230 * * 231 * INPUT: none * 232 * * 233 * OUTPUT: Was the object successfully limboed? * 234 * * 235 * WARNINGS: none * 236 * * 237 * HISTORY: * 238 * 06/25/1995 JLB : Created. * 239 *=============================================================================================*/ 240 bool RadioClass::Limbo(void) 241 { 242 if (!IsInLimbo) { 243 Transmit_Message(RADIO_OVER_OUT); 244 } 245 return(MissionClass::Limbo()); 246 } 247 248 249 RadioMessageType RadioClass::Transmit_Message(RadioMessageType message, RadioClass * to) {return(Transmit_Message(message, LParam, to));};