| 1 | /* |
| 2 | * Descent 3 |
| 3 | * Copyright (C) 2024 Parallax Software |
| 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 3 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, see <http://www.gnu.org/licenses/>. |
| 17 | |
| 18 | --- HISTORICAL COMMENTS FOLLOW --- |
| 19 | |
| 20 | * $Logfile: /DescentIII/Main/levelgoal.cpp $ |
| 21 | * $Revision: 50 $ |
| 22 | * $Date: 6/23/99 5:34p $ |
| 23 | * $Author: Jeff $ |
| 24 | * |
| 25 | * Level goal stuff, I guess. |
| 26 | * |
| 27 | * $Log: /DescentIII/Main/levelgoal.cpp $ |
| 28 | * |
| 29 | * 50 6/23/99 5:34p Jeff |
| 30 | * For some reason Linux started complaining about Status function, |
| 31 | * renaming it to GetStatus made it quiet. |
| 32 | * |
| 33 | * 49 5/23/99 8:39p Chris |
| 34 | * Now multiple equal priority (primary and secondary) goals are shown on |
| 35 | * the level goal tab |
| 36 | * |
| 37 | * 48 5/18/99 7:33p Jeff |
| 38 | * fixed game message log...using out-dated variable that is no longer |
| 39 | * used...switched to real buffer. We should remove the out-dated |
| 40 | * variable, but I don't want to break any code at this point. |
| 41 | * |
| 42 | * 47 5/12/99 6:02p Jeff |
| 43 | * flip order of saving/loading objects and players |
| 44 | * |
| 45 | * 46 5/09/99 10:49p Jason |
| 46 | * fixed some strings being truncuated in multiplayer games |
| 47 | * |
| 48 | * 45 5/08/99 4:55p Chris |
| 49 | * Only add HUD completion message if the lgoal is enabled |
| 50 | * |
| 51 | * 44 5/07/99 7:57p Jeff |
| 52 | * handle the multisafe condition of clearing the completed flag |
| 53 | * |
| 54 | * 43 5/02/99 5:09a Jeff |
| 55 | * send levelgoal state to joining clients |
| 56 | * |
| 57 | * 42 5/01/99 1:41a Jeff |
| 58 | * made levelgoals multi friendly |
| 59 | * |
| 60 | * 41 4/14/99 11:49a Matt |
| 61 | * Made localizable the goal completed HUD message |
| 62 | * |
| 63 | * 40 4/05/99 1:07p Chris |
| 64 | * Added a goal failed state |
| 65 | * |
| 66 | * 39 3/16/99 4:17p Matt |
| 67 | * Changed goal complete message from "<goal>: Completed!" to "Completed: |
| 68 | * <goal>" |
| 69 | * |
| 70 | * 38 3/10/99 2:25p Kevin |
| 71 | * Save/Load and Demo file fixes |
| 72 | * |
| 73 | * 37 3/04/99 7:39p Matt |
| 74 | * Added sound effects to FreeSpace-style persistent HUD messages. |
| 75 | * |
| 76 | * 36 3/04/99 6:12p Matt |
| 77 | * Changed color of goal complete message |
| 78 | * |
| 79 | * 35 3/03/99 5:34p Matt |
| 80 | * Added fade-out for goal complete messages |
| 81 | * |
| 82 | * 34 3/03/99 3:35a Chris |
| 83 | * Fixed. |
| 84 | * |
| 85 | * 33 3/02/99 6:39p Jeff |
| 86 | * level goals working in save/load game |
| 87 | * |
| 88 | * 32 3/02/99 5:44p Chris |
| 89 | * Fixed the save game problem with levelgoals |
| 90 | * |
| 91 | * 31 2/26/99 8:33a Chris |
| 92 | * : Completed! was added |
| 93 | * |
| 94 | * 30 2/23/99 1:03p Luke |
| 95 | * Fixed a bug where all goals where completing automatically |
| 96 | * |
| 97 | * 29 2/22/99 8:11p Chris |
| 98 | * Fixed a bug with saving goals |
| 99 | * |
| 100 | * 28 2/22/99 3:05p Chris |
| 101 | * Complete - minus coop |
| 102 | * |
| 103 | * 27 2/22/99 1:43a Chris |
| 104 | * Version 4 is near complete |
| 105 | * |
| 106 | * 26 2/21/99 7:49p Chris |
| 107 | * |
| 108 | * 25 2/21/99 7:47p Chris |
| 109 | * Finished up with the anywhere on terrain and anywhere on mine items :) |
| 110 | * |
| 111 | * 24 2/21/99 7:16p Chris |
| 112 | * Added the EVT_LEVEL_GOAL_ITEM_COMPLETE event |
| 113 | * |
| 114 | * 23 2/21/99 6:37p Chris |
| 115 | * |
| 116 | * 22 2/21/99 5:44p Nate |
| 117 | * Fixed a bug with GoalComplete being called directly from the |
| 118 | * Level_goals class. Oops. |
| 119 | * |
| 120 | * 21 2/21/99 4:47p Chris |
| 121 | * More updates |
| 122 | * |
| 123 | * 20 2/21/99 4:31p Chris |
| 124 | * Improving the level goal system... Not done. |
| 125 | * |
| 126 | * 19 2/20/99 6:19p Chris |
| 127 | * |
| 128 | * 18 2/20/99 6:18p Chris |
| 129 | * Improved levelgoals - not done |
| 130 | * |
| 131 | * 17 2/20/99 4:29p Chris |
| 132 | * SOme updates to the system, not done |
| 133 | * |
| 134 | * 16 2/20/99 2:59p Matt |
| 135 | * Made ShowGoalMessage() add the message to the game message buffer. |
| 136 | * |
| 137 | * 15 2/19/99 11:32a Chris |
| 138 | * Added GoalFindId |
| 139 | * |
| 140 | * 14 2/18/99 5:29p Matt |
| 141 | * Added ShowGoalMessage() |
| 142 | * |
| 143 | * 13 2/10/99 1:47p Matt |
| 144 | * Changed object handle symbolic constants |
| 145 | * |
| 146 | * 12 1/31/99 7:26p Matt |
| 147 | * Renamed a bunch of functions to have HUD capitalized |
| 148 | * |
| 149 | * 11 1/29/99 5:22p Jeff |
| 150 | * localization |
| 151 | * |
| 152 | * 10 10/15/98 8:54a Matt |
| 153 | * Don't call Endlevel() directly, but instead change the game state to |
| 154 | * end-of-level |
| 155 | * |
| 156 | */ |
| 157 | |
| 158 | #include "levelgoal.h"cxx . . $ `<file>/Descent3/levelgoal.h`/ |
| 159 | #include "mem.h"cxx . . $ `<file>/mem/mem.h`/ |
| 160 | #include "string.h" |
| 161 | #include "hud.h"cxx . . $ `<file>/Descent3/hud.h`/ |
| 162 | #include "game.h"cxx . . $ `<file>/Descent3/game.h`/ |
| 163 | #include "gamesequence.h"cxx . . $ `<file>/Descent3/gamesequence.h`/ |
| 164 | #include "stringtable.h"cxx . . $ `<file>/Descent3/stringtable.h`/ |
| 165 | #include <stdarg.h> |
| 166 | #include "pstring.h"cxx . . $ `<file>/misc/pstring.h`/ |
| 167 | #include "hlsoundlib.h"cxx . . $ `<file>/sndlib/hlsoundlib.h`/ |
| 168 | #include "sounds.h"cxx . . $ `<file>/Descent3/sounds.h`/ |
| 169 | #include "osiris_dll.h"cxx . . $ `<file>/Descent3/osiris_dll.h`/ |
| 170 | #include "room.h"cxx . . $ `<file>/Descent3/room.h`/ |
| 171 | #include "object.h"cxx . . $ `<file>/Descent3/object.h`/ |
| 172 | #include "trigger.h"cxx . . $ `<file>/Descent3/trigger.h`/ |
| 173 | #include "player.h"cxx . . $ `<file>/Descent3/player.h`/ |
| 174 | #include "multi.h"cxx . . $ `<file>/Descent3/multi.h`/ |
| 175 | #include "demofile.h"cxx . . $ `<file>/lib/demofile.h`/ |
| 176 | #include "osiris_share.h"cxx . . $ `<file>/Descent3/osiris_share.h`/ |
| 177 | #include "multisafe.h"cxx . . $ `<file>/Descent3/multisafe.h`/ |
| 178 | #include "multi.h"cxx . . $ `<file>/Descent3/multi.h`/ |
| 179 | #include "multi_world_state.h"cxx . . $ `<file>/Descent3/multi_world_state.h`/ |
| 180 | |
| 181 | #define GOAL_MESSAGE_TIMEcxx . . $ `Descent3/levelgoal.cpp:181:9`! 10.0 |
| 182 | #define GOAL_MESSAGE_COLORcxx . . $ `Descent3/levelgoal.cpp:182:9`! GR_RGB(0, 242, 148) |
| 183 | |
| 184 | levelgoalscxx . . $ levelgoals# Level_goalscxx . . $ Level_goals.; |
| 185 | |
| 186 | // This is the load/save version of the level goals |
| 187 | #define LEVEL_GOAL_VERSIONcxx . . $ `Descent3/levelgoal.cpp:187:9`! 4 |
| 188 | |
| 189 | void lgoalcxx . . $ lgoal#::GoalCompletecxx . . $ lgoal#GoalComplete(918ebd27a9ddbad3).(int handle, bool announce) { |
| 190 | m_goal_completedcxx . . $ lgoal#m_goal_completed. = true; |
| 191 | |
| 192 | tOSIRISEventInfocxx . . $ tOSIRISEventInfo# ei; |
| 193 | ei.evt_level_goal_completecxx . . $ tOSIRISEventInfo#$anonymous_type_1#evt_level_goal_complete..level_goal_indexcxx . . $ tOSIRISEVTLEVELGOALCOMPLETE#level_goal_index. = handle; |
| 194 | |
| 195 | Osiris_CallLevelEventcxx . . $ Osiris_CallLevelEvent(a880c8b99cdc05b4).(EVT_LEVEL_GOAL_COMPLETEcxx . . $ `scripts/osiris_common.h:394:9`!, &ei); |
| 196 | |
| 197 | if (m_namecxx . . $ lgoal#m_name. && announce && (this->m_flagscxx . . $ lgoal#m_flags. & LGF_ENABLEDcxx . . $ `Descent3/levelgoal_external.h:40:9`!)) { |
| 198 | // Draw on the HUD |
| 199 | int y = Game_window_hcxx . . $ Game_window_h. / 4; |
| 200 | // AddPersistentHUDMessage(GOAL_MESSAGE_COLOR,HUD_MSG_PERSISTENT_CENTER,y,GOAL_MESSAGE_TIME,m_completion_message); |
| 201 | char message[200]; |
| 202 | snprintf(message, sizeof(message), "%s %s", TXT_COMPLETED_HUDcxx . . $ `Descent3/stringtable.h:316:9`!, m_namecxx . . $ lgoal#m_name.); |
| 203 | if (Demo_flagscxx . . $ Demo_flags. == DF_RECORDINGcxx . . $ `lib/demofile.h:122:9`!) { |
| 204 | DemoWritePersistantHUDMessagecxx . . $ DemoWritePersistantHUDMessage(e60fbdfbe7e9abc2).(GOAL_MESSAGE_COLORcxx . . $ `Descent3/levelgoal.cpp:182:9`!, HUD_MSG_PERSISTENT_CENTERcxx . . $ `Descent3/hud.h:312:9`!, GOAL_MESSAGE_TIMEcxx . . $ `Descent3/levelgoal.cpp:181:9`!, GOAL_MESSAGE_TIMEcxx . . $ `Descent3/levelgoal.cpp:181:9`!, |
| 205 | HPF_FADEOUTcxx . . $ `Descent3/hud.h:401:9`! + HPF_FREESPACE_DRAWcxx . . $ `Descent3/hud.h:402:9`!, SOUND_GOAL_COMPLETEcxx . . $ `Descent3/sounds.h:146:9`!, message); |
| 206 | } |
| 207 | if (Demo_flagscxx . . $ Demo_flags. != DF_PLAYBACKcxx . . $ `lib/demofile.h:123:9`!) { |
| 208 | AddPersistentHUDMessagecxx . . $ AddPersistentHUDMessage(2c96e75cbf2ca747).(GOAL_MESSAGE_COLORcxx . . $ `Descent3/levelgoal.cpp:182:9`!, HUD_MSG_PERSISTENT_CENTERcxx . . $ `Descent3/hud.h:312:9`!, y, GOAL_MESSAGE_TIMEcxx . . $ `Descent3/levelgoal.cpp:181:9`!, |
| 209 | HPF_FADEOUTcxx . . $ `Descent3/hud.h:401:9`! + HPF_FREESPACE_DRAWcxx . . $ `Descent3/hud.h:402:9`!, SOUND_GOAL_COMPLETEcxx . . $ `Descent3/sounds.h:146:9`!, message); |
| 210 | } |
| 211 | |
| 212 | // Add to the game message buffer |
| 213 | AddGameMessagecxx . . $ AddGameMessage(85c52e162fed56f9).(message); |
| 214 | } |
| 215 | } |
| 216 | |
| 217 | int lgoalcxx . . $ lgoal#::AddItemcxx . . $ lgoal#AddItem(b126dc7c1de90089).() { |
| 218 | if (m_num_itemscxx . . $ lgoal#m_num_items. < MAX_GOAL_ITEMScxx . . $ `Descent3/levelgoal_external.h:62:9`!) { |
| 219 | if (m_num_itemscxx . . $ lgoal#m_num_items. < 1) { |
| 220 | m_itemcxx . . $ lgoal#m_item.[m_num_itemscxx . . $ lgoal#m_num_items.].m_typecxx . . $ litem#m_type. = LIT_OBJECTcxx . . $ `Descent3/levelgoal_external.h:28:9`!; |
| 221 | m_itemcxx . . $ lgoal#m_item.[m_num_itemscxx . . $ lgoal#m_num_items.].m_handlecxx . . $ litem#m_handle. = OBJECT_HANDLE_NONEcxx . . $ `Descent3/object_external.h:156:9`!; |
| 222 | m_itemcxx . . $ lgoal#m_item.[m_num_itemscxx . . $ lgoal#m_num_items.].m_f_donecxx . . $ litem#m_f_done. = false; |
| 223 | } else { |
| 224 | m_itemcxx . . $ lgoal#m_item.[m_num_itemscxx . . $ lgoal#m_num_items.].m_typecxx . . $ litem#m_type. = m_itemcxx . . $ lgoal#m_item.[0].m_typecxx . . $ litem#m_type.; |
| 225 | m_itemcxx . . $ lgoal#m_item.[m_num_itemscxx . . $ lgoal#m_num_items.].m_handlecxx . . $ litem#m_handle. = -1; |
| 226 | m_itemcxx . . $ lgoal#m_item.[m_num_itemscxx . . $ lgoal#m_num_items.].m_f_donecxx . . $ litem#m_f_done. = false; |
| 227 | } |
| 228 | |
| 229 | m_num_itemscxx . . $ lgoal#m_num_items.++; |
| 230 | return m_num_itemscxx . . $ lgoal#m_num_items. - 1; |
| 231 | } else { |
| 232 | return -1; |
| 233 | } |
| 234 | } |
| 235 | |
| 236 | bool lgoalcxx . . $ lgoal#::DeleteItemcxx . . $ lgoal#DeleteItem(83c267b20bac841a).(int index) { |
| 237 | int i; |
| 238 | |
| 239 | if (index < 0 || index >= m_num_itemscxx . . $ lgoal#m_num_items.) |
| 240 | return false; |
| 241 | |
| 242 | for (i = index; i < m_num_itemscxx . . $ lgoal#m_num_items. - 1; i++) { |
| 243 | m_itemcxx . . $ lgoal#m_item.[i] =cxx . . $ litem#`operator=`(700c5b271c88794a). m_itemcxx . . $ lgoal#m_item.[i + 1]; |
| 244 | } |
| 245 | |
| 246 | m_num_itemscxx . . $ lgoal#m_num_items.--; |
| 247 | |
| 248 | return true; |
| 249 | } |
| 250 | |
| 251 | bool lgoalcxx . . $ lgoal#::ItemInfocxx . . $ lgoal#ItemInfo(517b8770e5a0ffe0).(int index, char operation, char *type, int *handle, bool *done) { |
| 252 | if (index < 0 || index >= m_num_itemscxx . . $ lgoal#m_num_items.) |
| 253 | return false; |
| 254 | |
| 255 | switch (operation) { |
| 256 | case LO_SET_SPECIFIEDcxx . . $ `Descent3/levelgoal_external.h:33:9`!: |
| 257 | if (type) { |
| 258 | m_itemcxx . . $ lgoal#m_item.[index].m_typecxx . . $ litem#m_type. = *type; |
| 259 | } |
| 260 | if (handle) { |
| 261 | m_itemcxx . . $ lgoal#m_item.[index].m_handlecxx . . $ litem#m_handle. = *handle; |
| 262 | } |
| 263 | if (done) { |
| 264 | m_itemcxx . . $ lgoal#m_item.[index].m_f_donecxx . . $ litem#m_f_done. = *done; |
| 265 | } |
| 266 | return true; |
| 267 | break; |
| 268 | |
| 269 | case LO_GET_SPECIFIEDcxx . . $ `Descent3/levelgoal_external.h:34:9`!: |
| 270 | if (type) { |
| 271 | *type = m_itemcxx . . $ lgoal#m_item.[index].m_typecxx . . $ litem#m_type.; |
| 272 | } |
| 273 | if (handle) { |
| 274 | *handle = m_itemcxx . . $ lgoal#m_item.[index].m_handlecxx . . $ litem#m_handle.; |
| 275 | } |
| 276 | if (done) { |
| 277 | *done = m_itemcxx . . $ lgoal#m_item.[index].m_f_donecxx . . $ litem#m_f_done.; |
| 278 | } |
| 279 | return true; |
| 280 | break; |
| 281 | } |
| 282 | |
| 283 | return false; |
| 284 | } |
| 285 | |
| 286 | bool lgoalcxx . . $ lgoal#::SetNamecxx . . $ lgoal#SetName(ceb9eed3194142b2).(int handle, char *name) { |
| 287 | if (!name) |
| 288 | return false; |
| 289 | |
| 290 | if (m_namecxx . . $ lgoal#m_name.) |
| 291 | mem_freecxx . . $ `mem/mem.h:80:9`!(m_name); |
| 292 | |
| 293 | m_namecxx . . $ lgoal#m_name. = (char *)mem_malloccxx . . $ `mem/mem.h:79:9`!(strlen(name) + 1); |
| 294 | strcpy(m_namecxx . . $ lgoal#m_name., name); |
| 295 | m_modifiedcxx . . $ lgoal#m_modified. = 1; |
| 296 | |
| 297 | if (Game_modecxx . . $ Game_mode. & GM_MULTIcxx . . $ `Descent3/game.h:288:9`! && Netgamecxx . . $ Netgame..local_rolecxx . . $ netgame_info#local_role. != LR_CLIENTcxx . . $ `Descent3/multi_external.h:128:9`!) { |
| 298 | // send it off to the clients |
| 299 | SendMultiUpdatecxx . . $ lgoal#SendMultiUpdate(d4f767463ce0a6b3).(handle); |
| 300 | } |
| 301 | |
| 302 | return true; |
| 303 | } |
| 304 | |
| 305 | void lgoalcxx . . $ lgoal#::SendMultiUpdatecxx . . $ lgoal#SendMultiUpdate(d4f767463ce0a6b3).(int handle) { |
| 306 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(Game_mode & GM_MULTIcxx . . $ `Descent3/game.h:288:9`! && Netgame.local_role == LR_SERVERcxx . . $ `Descent3/multi_external.h:129:9`!); |
| 307 | |
| 308 | msafe_structcxx . . $ msafe_struct# mstruct; |
| 309 | |
| 310 | mstruct.indexcxx . . $ msafe_struct#index. = handle; |
| 311 | GetNamecxx . . $ lgoal#GetName(6abd07ddb1a912f0).(mstruct.messagecxx . . $ msafe_struct#message., MSAFE_MESSAGE_LENGTHcxx . . $ `scripts/osiris_common.h:1219:9`!); |
| 312 | mstruct.typecxx . . $ msafe_struct#type. = m_flagscxx . . $ lgoal#m_flags.; |
| 313 | mstruct.countcxx . . $ msafe_struct#count. = m_prioritycxx . . $ lgoal#m_priority.; |
| 314 | |
| 315 | msafe_CallFunctioncxx . . $ msafe_CallFunction(6cc1e8e00715904d).(MSAFE_MISC_LEVELGOALcxx . . $ `scripts/osiris_common.h:889:9`!, &mstruct); |
| 316 | } |
| 317 | |
| 318 | bool lgoalcxx . . $ lgoal#::SetCompletionMessagecxx . . $ lgoal#SetCompletionMessage(c6b7e35ff6de5671).(char *message) { |
| 319 | if (!message) |
| 320 | return false; |
| 321 | |
| 322 | if (m_completion_messagecxx . . $ lgoal#m_completion_message.) |
| 323 | mem_freecxx . . $ `mem/mem.h:80:9`!(m_completion_message); |
| 324 | |
| 325 | m_completion_messagecxx . . $ lgoal#m_completion_message. = (char *)mem_malloccxx . . $ `mem/mem.h:79:9`!(strlen(message) + 1); |
| 326 | strcpy(m_completion_messagecxx . . $ lgoal#m_completion_message., message); |
| 327 | |
| 328 | return true; |
| 329 | } |
| 330 | |
| 331 | bool lgoalcxx . . $ lgoal#::SetItemNamecxx . . $ lgoal#SetItemName(c6b7e35ff6de5671).(char *iname) { |
| 332 | if (!iname) |
| 333 | return false; |
| 334 | |
| 335 | if (m_item_namecxx . . $ lgoal#m_item_name.) |
| 336 | mem_freecxx . . $ `mem/mem.h:80:9`!(m_item_name); |
| 337 | |
| 338 | m_item_namecxx . . $ lgoal#m_item_name. = (char *)mem_malloccxx . . $ `mem/mem.h:79:9`!(strlen(iname) + 1); |
| 339 | strcpy(m_item_namecxx . . $ lgoal#m_item_name., iname); |
| 340 | |
| 341 | return true; |
| 342 | } |
| 343 | |
| 344 | bool lgoalcxx . . $ lgoal#::Prioritycxx . . $ lgoal#Priority(f3551096b2e9a55d).(int handle, char operation, int *value) { |
| 345 | if (!value) |
| 346 | return false; |
| 347 | |
| 348 | switch (operation) { |
| 349 | case LO_SET_SPECIFIEDcxx . . $ `Descent3/levelgoal_external.h:33:9`!: |
| 350 | m_prioritycxx . . $ lgoal#m_priority. = *value; |
| 351 | m_modifiedcxx . . $ lgoal#m_modified. = 1; |
| 352 | if (Game_modecxx . . $ Game_mode. & GM_MULTIcxx . . $ `Descent3/game.h:288:9`! && Netgamecxx . . $ Netgame..local_rolecxx . . $ netgame_info#local_role. != LR_CLIENTcxx . . $ `Descent3/multi_external.h:128:9`!) { |
| 353 | // send it off to the clients |
| 354 | SendMultiUpdatecxx . . $ lgoal#SendMultiUpdate(d4f767463ce0a6b3).(handle); |
| 355 | } |
| 356 | return true; |
| 357 | break; |
| 358 | case LO_GET_SPECIFIEDcxx . . $ `Descent3/levelgoal_external.h:34:9`!: |
| 359 | *value = m_prioritycxx . . $ lgoal#m_priority.; |
| 360 | return true; |
| 361 | break; |
| 362 | } |
| 363 | |
| 364 | return false; |
| 365 | } |
| 366 | |
| 367 | bool lgoalcxx . . $ lgoal#::GoalListcxx . . $ lgoal#GoalList(c4e55793fafc8042).(char operation, char *value) { |
| 368 | if (!value) |
| 369 | return false; |
| 370 | |
| 371 | switch (operation) { |
| 372 | case LO_SET_SPECIFIEDcxx . . $ `Descent3/levelgoal_external.h:33:9`!: |
| 373 | if (*value < 0) |
| 374 | *value = 0; |
| 375 | else if (*value >= MAX_GOAL_LISTScxx . . $ `Descent3/levelgoal_external.h:65:9`!) |
| 376 | *value = MAX_GOAL_LISTScxx . . $ `Descent3/levelgoal_external.h:65:9`! - 1; |
| 377 | |
| 378 | m_g_listcxx . . $ lgoal#m_g_list. = *value; |
| 379 | return true; |
| 380 | break; |
| 381 | case LO_GET_SPECIFIEDcxx . . $ `Descent3/levelgoal_external.h:34:9`!: |
| 382 | *value = m_g_listcxx . . $ lgoal#m_g_list.; |
| 383 | return true; |
| 384 | break; |
| 385 | } |
| 386 | |
| 387 | return false; |
| 388 | } |
| 389 | |
| 390 | bool lgoalcxx . . $ lgoal#::GetStatuscxx . . $ lgoal#GetStatus(861cbd76ae8afef5).(int handle, char operation, int *value, bool f_save_load, bool announce) { |
| 391 | if (!value) |
| 392 | return false; |
| 393 | |
| 394 | switch (operation) { |
| 395 | case LO_SET_SPECIFIEDcxx . . $ `Descent3/levelgoal_external.h:33:9`!: |
| 396 | m_flagscxx . . $ lgoal#m_flags. |= *value; |
| 397 | m_modifiedcxx . . $ lgoal#m_modified. = 1; |
| 398 | |
| 399 | if (((*value) & LGF_COMPLETEDcxx . . $ `Descent3/levelgoal_external.h:41:9`!) && !m_goal_completedcxx . . $ lgoal#m_goal_completed.) { |
| 400 | if (!f_save_load) |
| 401 | GoalCompletecxx . . $ lgoal#GoalComplete(918ebd27a9ddbad3).(handle, announce); |
| 402 | m_goal_completedcxx . . $ lgoal#m_goal_completed. = true; |
| 403 | } |
| 404 | |
| 405 | if (Game_modecxx . . $ Game_mode. & GM_MULTIcxx . . $ `Descent3/game.h:288:9`! && Netgamecxx . . $ Netgame..local_rolecxx . . $ netgame_info#local_role. != LR_CLIENTcxx . . $ `Descent3/multi_external.h:128:9`!) { |
| 406 | // send it off to the clients |
| 407 | SendMultiUpdatecxx . . $ lgoal#SendMultiUpdate(d4f767463ce0a6b3).(handle); |
| 408 | } |
| 409 | return true; |
| 410 | break; |
| 411 | case LO_GET_SPECIFIEDcxx . . $ `Descent3/levelgoal_external.h:34:9`!: |
| 412 | *value = m_flagscxx . . $ lgoal#m_flags.; |
| 413 | return true; |
| 414 | break; |
| 415 | case LO_CLEAR_SPECIFIEDcxx . . $ `Descent3/levelgoal_external.h:35:9`!: |
| 416 | // multisafe will pass in 0xFFFFFFFF on a clear before actually setting flags, |
| 417 | // so we need to ignore that case |
| 418 | if ((*value) != 0xFFFFFFFF && m_goal_completedcxx . . $ lgoal#m_goal_completed.) { |
| 419 | // check to see if we are marking this goal as "Not completed" |
| 420 | if ((*value) & LGF_COMPLETEDcxx . . $ `Descent3/levelgoal_external.h:41:9`!) { |
| 421 | // unmark this m_goal_completed variable |
| 422 | m_goal_completedcxx . . $ lgoal#m_goal_completed. = false; |
| 423 | } |
| 424 | } |
| 425 | |
| 426 | m_flagscxx . . $ lgoal#m_flags. &= ~(*value); |
| 427 | m_modifiedcxx . . $ lgoal#m_modified. = 1; |
| 428 | |
| 429 | if (Game_modecxx . . $ Game_mode. & GM_MULTIcxx . . $ `Descent3/game.h:288:9`! && Netgamecxx . . $ Netgame..local_rolecxx . . $ netgame_info#local_role. != LR_CLIENTcxx . . $ `Descent3/multi_external.h:128:9`!) { |
| 430 | // send it off to the clients |
| 431 | SendMultiUpdatecxx . . $ lgoal#SendMultiUpdate(d4f767463ce0a6b3).(handle); |
| 432 | } |
| 433 | return true; |
| 434 | break; |
| 435 | } |
| 436 | |
| 437 | return false; |
| 438 | } |
| 439 | |
| 440 | bool lgoalcxx . . $ lgoal#::SetDesccxx . . $ lgoal#SetDesc(c6b7e35ff6de5671).(char *desc) { |
| 441 | if (!desc) |
| 442 | return false; |
| 443 | |
| 444 | if (m_desccxx . . $ lgoal#m_desc.) |
| 445 | mem_freecxx . . $ `mem/mem.h:80:9`!(m_desc); |
| 446 | |
| 447 | m_desccxx . . $ lgoal#m_desc. = (char *)mem_malloccxx . . $ `mem/mem.h:79:9`!(strlen(desc) + 1); |
| 448 | strcpy(m_desccxx . . $ lgoal#m_desc., desc); |
| 449 | |
| 450 | return true; |
| 451 | } |
| 452 | |
| 453 | int lgoalcxx . . $ lgoal#::GetNamecxx . . $ lgoal#GetName(6abd07ddb1a912f0).(char *name, int buffer_size) { |
| 454 | if (!name) |
| 455 | return 0; |
| 456 | |
| 457 | if (buffer_size <= 0) |
| 458 | return strlen(m_namecxx . . $ lgoal#m_name.); |
| 459 | |
| 460 | if (m_namecxx . . $ lgoal#m_name. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) { |
| 461 | name[0] = '\0'; |
| 462 | return 0; |
| 463 | } |
| 464 | |
| 465 | strncpy(name, m_namecxx . . $ lgoal#m_name., buffer_size); |
| 466 | name[buffer_size - 1] = '\0'; |
| 467 | |
| 468 | return strlen(m_namecxx . . $ lgoal#m_name.); |
| 469 | } |
| 470 | |
| 471 | int lgoalcxx . . $ lgoal#::GetCompletionMessagecxx . . $ lgoal#GetCompletionMessage(6abd07ddb1a912f0).(char *message, int buffer_size) { |
| 472 | if (!message) |
| 473 | return 0; |
| 474 | |
| 475 | if (buffer_size <= 0) |
| 476 | return strlen(m_completion_messagecxx . . $ lgoal#m_completion_message.); |
| 477 | |
| 478 | if (m_completion_messagecxx . . $ lgoal#m_completion_message. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) { |
| 479 | message[0] = '\0'; |
| 480 | return 0; |
| 481 | } |
| 482 | |
| 483 | strncpy(message, m_completion_messagecxx . . $ lgoal#m_completion_message., buffer_size); |
| 484 | message[buffer_size - 1] = '\0'; |
| 485 | |
| 486 | return strlen(m_completion_messagecxx . . $ lgoal#m_completion_message.); |
| 487 | } |
| 488 | |
| 489 | int lgoalcxx . . $ lgoal#::GetItemNamecxx . . $ lgoal#GetItemName(6abd07ddb1a912f0).(char *iname, int buffer_size) { |
| 490 | if (!iname) |
| 491 | return 0; |
| 492 | |
| 493 | if (buffer_size <= 0) |
| 494 | return strlen(m_item_namecxx . . $ lgoal#m_item_name.); |
| 495 | |
| 496 | if (m_item_namecxx . . $ lgoal#m_item_name. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) { |
| 497 | iname[0] = '\0'; |
| 498 | return 0; |
| 499 | } |
| 500 | |
| 501 | strncpy(iname, m_item_namecxx . . $ lgoal#m_item_name., buffer_size); |
| 502 | iname[buffer_size - 1] = '\0'; |
| 503 | |
| 504 | return strlen(m_item_namecxx . . $ lgoal#m_item_name.); |
| 505 | } |
| 506 | |
| 507 | int lgoalcxx . . $ lgoal#::GetDesccxx . . $ lgoal#GetDesc(6abd07ddb1a912f0).(char *desc, int buffer_size) { |
| 508 | if (!desc) |
| 509 | return 0; |
| 510 | |
| 511 | if (buffer_size <= 0) |
| 512 | return strlen(m_desccxx . . $ lgoal#m_desc.); |
| 513 | |
| 514 | if (m_desccxx . . $ lgoal#m_desc. == NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) { |
| 515 | desc[0] = '\0'; |
| 516 | return 0; |
| 517 | } |
| 518 | |
| 519 | strncpy(desc, m_desccxx . . $ lgoal#m_desc., buffer_size); |
| 520 | desc[buffer_size - 1] = '\0'; |
| 521 | |
| 522 | return strlen(m_desccxx . . $ lgoal#m_desc.); |
| 523 | } |
| 524 | |
| 525 | int lgoalcxx . . $ lgoal#::GetNumItemscxx . . $ lgoal#GetNumItems(b126dc7c1de90089).() { return m_num_itemscxx . . $ lgoal#m_num_items.; } |
| 526 | |
| 527 | void lgoalcxx . . $ lgoal#::Resetcxx . . $ lgoal#Reset(b45ddcbc8423892c).(bool f_from_editor) { |
| 528 | if (m_namecxx . . $ lgoal#m_name.) |
| 529 | mem_freecxx . . $ `mem/mem.h:80:9`!(m_name); |
| 530 | |
| 531 | if (m_item_namecxx . . $ lgoal#m_item_name.) |
| 532 | mem_freecxx . . $ `mem/mem.h:80:9`!(m_item_name); |
| 533 | |
| 534 | if (m_desccxx . . $ lgoal#m_desc.) |
| 535 | mem_freecxx . . $ `mem/mem.h:80:9`!(m_desc); |
| 536 | |
| 537 | m_namecxx . . $ lgoal#m_name. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 538 | m_item_namecxx . . $ lgoal#m_item_name. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 539 | m_desccxx . . $ lgoal#m_desc. = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 540 | m_num_itemscxx . . $ lgoal#m_num_items. = 0; |
| 541 | m_prioritycxx . . $ lgoal#m_priority. = 0; |
| 542 | m_g_listcxx . . $ lgoal#m_g_list. = 0; |
| 543 | m_goal_completedcxx . . $ lgoal#m_goal_completed. = false; |
| 544 | |
| 545 | if (f_from_editor) |
| 546 | m_flagscxx . . $ lgoal#m_flags. = LGF_ENABLEDcxx . . $ `Descent3/levelgoal_external.h:40:9`! | LGF_TELCOM_LISTScxx . . $ `Descent3/levelgoal_external.h:42:9`! | LGF_COMP_DALLAScxx . . $ `Descent3/levelgoal_external.h:51:9`!; |
| 547 | else |
| 548 | m_flagscxx . . $ lgoal#m_flags. = 0; |
| 549 | } |
| 550 | |
| 551 | void lgoalcxx . . $ lgoal#::SendStateToPlayercxx . . $ lgoal#SendStateToPlayer(3e454b8ccf442868).(int index, int pnum) { |
| 552 | if (!(Game_modecxx . . $ Game_mode. & GM_MULTIcxx . . $ `Descent3/game.h:288:9`!)) |
| 553 | return; |
| 554 | |
| 555 | if (m_modifiedcxx . . $ lgoal#m_modified. == 0) |
| 556 | return; |
| 557 | |
| 558 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(Netgame.local_role == LR_SERVERcxx . . $ `Descent3/multi_external.h:129:9`!); |
| 559 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(pnum >= 0 && pnum < MAX_NET_PLAYERScxx . . $ `Descent3/multi_external.h:132:9`!); |
| 560 | |
| 561 | if (!(NetPlayerscxx . . $ NetPlayers.[pnum].flagscxx . . $ netplayer#flags. & NPF_CONNECTEDcxx . . $ `Descent3/multi_external.h:165:9`! && NetPlayerscxx . . $ NetPlayers.[pnum].sequencecxx . . $ netplayer#sequence. == NETSEQ_PLAYINGcxx . . $ `Descent3/multi_external.h:161:9`!)) |
| 562 | return; |
| 563 | |
| 564 | mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Sending modified LevelGoal %d to player %d\n", index, pnum); |
| 565 | |
| 566 | // now update the buddy handle list of the clients |
| 567 | int count = 0; |
| 568 | int size_offset; |
| 569 | uint8_tcxx . . $ uint8_t# data[MAX_GAME_DATA_SIZEcxx . . $ `Descent3/multi_external.h:134:9`!]; |
| 570 | |
| 571 | size_offset = START_DATAcxx . . $ START_DATA(8c36ee1faa9e0a0b).(MP_WORLD_STATEScxx . . $ `Descent3/multi.h:611:9`!, data, &count); |
| 572 | |
| 573 | MultiAddBytecxx . . $ MultiAddByte(3bbe8835367eaa4e).(WS_LEVELGOALcxx . . $ `Descent3/multi_world_state.h:40:9`!, data, &count); |
| 574 | MultiAddUshortcxx . . $ MultiAddUshort(309f537dbae2306e).(index, data, &count); |
| 575 | |
| 576 | MultiAddIntcxx . . $ MultiAddInt(49f79918a3afee3).(m_prioritycxx . . $ lgoal#m_priority., data, &count); |
| 577 | |
| 578 | char name[256]; |
| 579 | GetNamecxx . . $ lgoal#GetName(6abd07ddb1a912f0).(name, 256); |
| 580 | int len = strlen(name) + 1; |
| 581 | MultiAddBytecxx . . $ MultiAddByte(3bbe8835367eaa4e).(len, data, &count); |
| 582 | memcpy(&data[count], name, len); |
| 583 | count += len; |
| 584 | |
| 585 | MultiAddIntcxx . . $ MultiAddInt(49f79918a3afee3).(m_flagscxx . . $ lgoal#m_flags., data, &count); |
| 586 | |
| 587 | MultiAddBytecxx . . $ MultiAddByte(3bbe8835367eaa4e).(WS_ENDcxx . . $ `Descent3/multi_world_state.h:46:9`!, data, &count); |
| 588 | END_DATAcxx . . $ END_DATA(dde21517a502ab05).(count, data, size_offset); |
| 589 | |
| 590 | // Send it out |
| 591 | nw_SendReliablecxx . . $ nw_SendReliable(f6b56715d3e5e15a).(NetPlayerscxx . . $ NetPlayers.[pnum].reliable_socketcxx . . $ netplayer#reliable_socket., data, count, false); |
| 592 | } |
| 593 | |
| 594 | void lgoalcxx . . $ lgoal#::ResetModifiedcxx . . $ lgoal#ResetModified(49f6e7a06ebc5aa8).(void) { m_modifiedcxx . . $ lgoal#m_modified. = 0; } |
| 595 | |
| 596 | bool levelgoalscxx . . $ levelgoals#::GoalStatuscxx . . $ levelgoals#GoalStatus(a197d185bbe4f6f0).(int index, char operation, int *flags, bool announce) { |
| 597 | if (index < 0 || index >= m_num_goalscxx . . $ levelgoals#m_num_goals.) |
| 598 | return false; |
| 599 | |
| 600 | return m_goalcxx . . $ levelgoals#m_goal.[index].GetStatuscxx . . $ lgoal#GetStatus(861cbd76ae8afef5).(index, operation, flags, false, announce); |
| 601 | } |
| 602 | |
| 603 | bool levelgoalscxx . . $ levelgoals#::GoalPrioritycxx . . $ levelgoals#GoalPriority(f3551096b2e9a55d).(int index, char operation, int *flags) { |
| 604 | if (index < 0 || index >= m_num_goalscxx . . $ levelgoals#m_num_goals.) |
| 605 | return false; |
| 606 | |
| 607 | return m_goalcxx . . $ levelgoals#m_goal.[index].Prioritycxx . . $ lgoal#Priority(f3551096b2e9a55d).(index, operation, flags); |
| 608 | } |
| 609 | |
| 610 | bool levelgoalscxx . . $ levelgoals#::GoalGoalListcxx . . $ levelgoals#GoalGoalList(5a6a60347df10d71).(int index, char operation, char *value) { |
| 611 | if (index < 0 || index >= m_num_goalscxx . . $ levelgoals#m_num_goals.) |
| 612 | return false; |
| 613 | |
| 614 | return m_goalcxx . . $ levelgoals#m_goal.[index].GoalListcxx . . $ lgoal#GoalList(c4e55793fafc8042).(operation, value); |
| 615 | } |
| 616 | |
| 617 | int levelgoalscxx . . $ levelgoals#::AddGoalcxx . . $ levelgoals#AddGoal(73da94e76e6bd037).(bool f_from_editor) { |
| 618 | if (m_num_goalscxx . . $ levelgoals#m_num_goals. < MAX_LEVEL_GOALScxx . . $ `Descent3/levelgoal_external.h:63:9`!) { |
| 619 | m_goalcxx . . $ levelgoals#m_goal.[m_num_goalscxx . . $ levelgoals#m_num_goals.].Resetcxx . . $ lgoal#Reset(b45ddcbc8423892c).(f_from_editor); |
| 620 | m_num_goalscxx . . $ levelgoals#m_num_goals.++; |
| 621 | return m_num_goalscxx . . $ levelgoals#m_num_goals. - 1; |
| 622 | } else { |
| 623 | return -1; |
| 624 | } |
| 625 | } |
| 626 | |
| 627 | bool levelgoalscxx . . $ levelgoals#::DeleteGoalcxx . . $ levelgoals#DeleteGoal(83c267b20bac841a).(int index) { |
| 628 | int i; |
| 629 | |
| 630 | if (index < 0 || index >= m_num_goalscxx . . $ levelgoals#m_num_goals.) |
| 631 | return false; |
| 632 | |
| 633 | m_goalcxx . . $ levelgoals#m_goal.[index].Resetcxx . . $ lgoal#Reset(b45ddcbc8423892c).(false); |
| 634 | |
| 635 | for (i = index; i < m_num_goalscxx . . $ levelgoals#m_num_goals. - 1; i++) { |
| 636 | m_goalcxx . . $ levelgoals#m_goal.[i] =cxx . . $ lgoal#`operator=`(a54f0a620332f9f3). m_goalcxx . . $ levelgoals#m_goal.[i + 1]; |
| 637 | } |
| 638 | |
| 639 | m_num_goalscxx . . $ levelgoals#m_num_goals.--; |
| 640 | |
| 641 | return true; |
| 642 | } |
| 643 | |
| 644 | int levelgoalscxx . . $ levelgoals#::GoalAddItemcxx . . $ levelgoals#GoalAddItem(7864480464b09eea).(int goal_index) { |
| 645 | if (goal_index < 0 || goal_index >= m_num_goalscxx . . $ levelgoals#m_num_goals.) |
| 646 | return -1; |
| 647 | |
| 648 | return m_goalcxx . . $ levelgoals#m_goal.[goal_index].AddItemcxx . . $ lgoal#AddItem(b126dc7c1de90089).(); |
| 649 | } |
| 650 | |
| 651 | bool levelgoalscxx . . $ levelgoals#::GoalDeleteItemcxx . . $ levelgoals#GoalDeleteItem(cf9ef193275fa6d8).(int goal_index, int item_index) { |
| 652 | if (goal_index < 0 || goal_index >= m_num_goalscxx . . $ levelgoals#m_num_goals.) |
| 653 | return false; |
| 654 | |
| 655 | return m_goalcxx . . $ levelgoals#m_goal.[goal_index].DeleteItemcxx . . $ lgoal#DeleteItem(83c267b20bac841a).(item_index); |
| 656 | } |
| 657 | |
| 658 | bool levelgoalscxx . . $ levelgoals#::GoalItemInfocxx . . $ levelgoals#GoalItemInfo(af0847b9747ce646).(int goal_index, int index, char operation, char *type, int *handle, bool *done) { |
| 659 | if (goal_index < 0 || goal_index >= m_num_goalscxx . . $ levelgoals#m_num_goals.) |
| 660 | return false; |
| 661 | |
| 662 | return m_goalcxx . . $ levelgoals#m_goal.[goal_index].ItemInfocxx . . $ lgoal#ItemInfo(517b8770e5a0ffe0).(index, operation, type, handle, done); |
| 663 | } |
| 664 | |
| 665 | bool levelgoalscxx . . $ levelgoals#::GoalSetNamecxx . . $ levelgoals#GoalSetName(ceb9eed3194142b2).(int goal_index, char *name) { |
| 666 | if (goal_index < 0 || goal_index >= m_num_goalscxx . . $ levelgoals#m_num_goals.) |
| 667 | return false; |
| 668 | |
| 669 | return m_goalcxx . . $ levelgoals#m_goal.[goal_index].SetNamecxx . . $ lgoal#SetName(ceb9eed3194142b2).(goal_index, name); |
| 670 | } |
| 671 | |
| 672 | bool levelgoalscxx . . $ levelgoals#::GoalSetItemNamecxx . . $ levelgoals#GoalSetItemName(ceb9eed3194142b2).(int goal_index, char *iname) { |
| 673 | if (goal_index < 0 || goal_index >= m_num_goalscxx . . $ levelgoals#m_num_goals.) |
| 674 | return false; |
| 675 | |
| 676 | return m_goalcxx . . $ levelgoals#m_goal.[goal_index].SetItemNamecxx . . $ lgoal#SetItemName(c6b7e35ff6de5671).(iname); |
| 677 | } |
| 678 | |
| 679 | bool levelgoalscxx . . $ levelgoals#::GoalSetDesccxx . . $ levelgoals#GoalSetDesc(ceb9eed3194142b2).(int goal_index, char *desc) { |
| 680 | if (goal_index < 0 || goal_index >= m_num_goalscxx . . $ levelgoals#m_num_goals.) |
| 681 | return false; |
| 682 | |
| 683 | return m_goalcxx . . $ levelgoals#m_goal.[goal_index].SetDesccxx . . $ lgoal#SetDesc(c6b7e35ff6de5671).(desc); |
| 684 | } |
| 685 | |
| 686 | bool levelgoalscxx . . $ levelgoals#::GoalSetCompletionMessagecxx . . $ levelgoals#GoalSetCompletionMessage(ceb9eed3194142b2).(int goal_index, char *message) { |
| 687 | if (goal_index < 0 || goal_index >= m_num_goalscxx . . $ levelgoals#m_num_goals.) |
| 688 | return false; |
| 689 | |
| 690 | return m_goalcxx . . $ levelgoals#m_goal.[goal_index].SetCompletionMessagecxx . . $ lgoal#SetCompletionMessage(c6b7e35ff6de5671).(message); |
| 691 | } |
| 692 | |
| 693 | int levelgoalscxx . . $ levelgoals#::GoalGetNamecxx . . $ levelgoals#GoalGetName(6836bd73a290bb97).(int goal_index, char *name, int buffer_size) { |
| 694 | if (goal_index < 0 || goal_index >= m_num_goalscxx . . $ levelgoals#m_num_goals.) |
| 695 | return -1; |
| 696 | |
| 697 | return m_goalcxx . . $ levelgoals#m_goal.[goal_index].GetNamecxx . . $ lgoal#GetName(6abd07ddb1a912f0).(name, buffer_size); |
| 698 | } |
| 699 | |
| 700 | int levelgoalscxx . . $ levelgoals#::GoalGetCompletionMessagecxx . . $ levelgoals#GoalGetCompletionMessage(6836bd73a290bb97).(int goal_index, char *message, int buffer_size) { |
| 701 | if (goal_index < 0 || goal_index >= m_num_goalscxx . . $ levelgoals#m_num_goals.) |
| 702 | return -1; |
| 703 | |
| 704 | return m_goalcxx . . $ levelgoals#m_goal.[goal_index].GetCompletionMessagecxx . . $ lgoal#GetCompletionMessage(6abd07ddb1a912f0).(message, buffer_size); |
| 705 | } |
| 706 | |
| 707 | int levelgoalscxx . . $ levelgoals#::GoalGetItemNamecxx . . $ levelgoals#GoalGetItemName(6836bd73a290bb97).(int goal_index, char *iname, int buffer_size) { |
| 708 | if (goal_index < 0 || goal_index >= m_num_goalscxx . . $ levelgoals#m_num_goals.) |
| 709 | return -1; |
| 710 | |
| 711 | return m_goalcxx . . $ levelgoals#m_goal.[goal_index].GetItemNamecxx . . $ lgoal#GetItemName(6abd07ddb1a912f0).(iname, buffer_size); |
| 712 | } |
| 713 | |
| 714 | int levelgoalscxx . . $ levelgoals#::GoalGetDesccxx . . $ levelgoals#GoalGetDesc(6836bd73a290bb97).(int goal_index, char *desc, int buffer_size) { |
| 715 | if (goal_index < 0 || goal_index >= m_num_goalscxx . . $ levelgoals#m_num_goals.) |
| 716 | return -1; |
| 717 | |
| 718 | return m_goalcxx . . $ levelgoals#m_goal.[goal_index].GetDesccxx . . $ lgoal#GetDesc(6abd07ddb1a912f0).(desc, buffer_size); |
| 719 | } |
| 720 | |
| 721 | int levelgoalscxx . . $ levelgoals#::GoalGetNumItemscxx . . $ levelgoals#GoalGetNumItems(7864480464b09eea).(int goal_index) { |
| 722 | if (goal_index < 0 || goal_index >= m_num_goalscxx . . $ levelgoals#m_num_goals.) |
| 723 | return -1; |
| 724 | |
| 725 | return m_goalcxx . . $ levelgoals#m_goal.[goal_index].GetNumItemscxx . . $ lgoal#GetNumItems(b126dc7c1de90089).(); |
| 726 | } |
| 727 | |
| 728 | int levelgoalscxx . . $ levelgoals#::GetNumGoalscxx . . $ levelgoals#GetNumGoals(b126dc7c1de90089).() { return m_num_goalscxx . . $ levelgoals#m_num_goals.; } |
| 729 | |
| 730 | bool levelgoalscxx . . $ levelgoals#::SaveLevelGoalInfocxx . . $ levelgoals#SaveLevelGoalInfo(254217fab7598d49).(CFILEcxx . . $ CFILE# *fptr) { |
| 731 | int i; |
| 732 | cf_WriteShortcxx . . $ cf_WriteShort(d7cf1a05aca96fe5).(fptr, LEVEL_GOAL_VERSIONcxx . . $ `Descent3/levelgoal.cpp:187:9`!); |
| 733 | |
| 734 | cf_WriteShortcxx . . $ cf_WriteShort(d7cf1a05aca96fe5).(fptr, m_num_goalscxx . . $ levelgoals#m_num_goals.); |
| 735 | for (i = 0; i < m_num_goalscxx . . $ levelgoals#m_num_goals.; i++) { |
| 736 | char name[256]; |
| 737 | char iname[256]; |
| 738 | char desc[2560]; |
| 739 | char message[2560]; |
| 740 | int len; |
| 741 | int num_items; |
| 742 | int j; |
| 743 | int priority = 0; |
| 744 | char g_list = 0; |
| 745 | int status = 0; |
| 746 | |
| 747 | Level_goalscxx . . $ Level_goals..GoalStatuscxx . . $ levelgoals#GoalStatus(a197d185bbe4f6f0).(i, LO_GET_SPECIFIEDcxx . . $ `Descent3/levelgoal_external.h:34:9`!, &status); |
| 748 | cf_WriteIntcxx . . $ cf_WriteInt(966989f25543eb13).(fptr, status); |
| 749 | |
| 750 | Level_goalscxx . . $ Level_goals..GoalPrioritycxx . . $ levelgoals#GoalPriority(f3551096b2e9a55d).(i, LO_GET_SPECIFIEDcxx . . $ `Descent3/levelgoal_external.h:34:9`!, &priority); |
| 751 | cf_WriteIntcxx . . $ cf_WriteInt(966989f25543eb13).(fptr, priority); |
| 752 | |
| 753 | Level_goalscxx . . $ Level_goals..GoalGoalListcxx . . $ levelgoals#GoalGoalList(5a6a60347df10d71).(i, LO_GET_SPECIFIEDcxx . . $ `Descent3/levelgoal_external.h:34:9`!, &g_list); |
| 754 | cf_WriteBytecxx . . $ cf_WriteByte(17377ebd5835367f).(fptr, g_list); |
| 755 | |
| 756 | Level_goalscxx . . $ Level_goals..GoalGetNamecxx . . $ levelgoals#GoalGetName(6836bd73a290bb97).(i, name, 256); |
| 757 | Level_goalscxx . . $ Level_goals..GoalGetItemNamecxx . . $ levelgoals#GoalGetItemName(6836bd73a290bb97).(i, iname, 256); |
| 758 | Level_goalscxx . . $ Level_goals..GoalGetDesccxx . . $ levelgoals#GoalGetDesc(6836bd73a290bb97).(i, desc, 2560); |
| 759 | Level_goalscxx . . $ Level_goals..GoalGetCompletionMessagecxx . . $ levelgoals#GoalGetCompletionMessage(6836bd73a290bb97).(i, message, 2560); |
| 760 | |
| 761 | len = strlen(name); |
| 762 | cf_WriteShortcxx . . $ cf_WriteShort(d7cf1a05aca96fe5).(fptr, len); |
| 763 | if (len) { |
| 764 | cf_WriteBytescxx . . $ cf_WriteBytes(b35058f74b39c3a6).((uint8_tcxx . . $ uint8_t# *)name, len, fptr); |
| 765 | } |
| 766 | |
| 767 | len = strlen(iname); |
| 768 | cf_WriteShortcxx . . $ cf_WriteShort(d7cf1a05aca96fe5).(fptr, len); |
| 769 | if (len) { |
| 770 | cf_WriteBytescxx . . $ cf_WriteBytes(b35058f74b39c3a6).((uint8_tcxx . . $ uint8_t# *)iname, len, fptr); |
| 771 | } |
| 772 | |
| 773 | len = strlen(desc); |
| 774 | cf_WriteShortcxx . . $ cf_WriteShort(d7cf1a05aca96fe5).(fptr, len); |
| 775 | if (len) { |
| 776 | cf_WriteBytescxx . . $ cf_WriteBytes(b35058f74b39c3a6).((uint8_tcxx . . $ uint8_t# *)desc, len, fptr); |
| 777 | } |
| 778 | |
| 779 | len = strlen(message); |
| 780 | cf_WriteShortcxx . . $ cf_WriteShort(d7cf1a05aca96fe5).(fptr, len); |
| 781 | if (len) { |
| 782 | cf_WriteBytescxx . . $ cf_WriteBytes(b35058f74b39c3a6).((uint8_tcxx . . $ uint8_t# *)message, len, fptr); |
| 783 | } |
| 784 | |
| 785 | num_items = Level_goalscxx . . $ Level_goals..GoalGetNumItemscxx . . $ levelgoals#GoalGetNumItems(7864480464b09eea).(i); |
| 786 | cf_WriteShortcxx . . $ cf_WriteShort(d7cf1a05aca96fe5).(fptr, num_items); |
| 787 | for (j = 0; j < num_items; j++) { |
| 788 | char type = 0; |
| 789 | int handle; |
| 790 | bool f_done; |
| 791 | |
| 792 | Level_goalscxx . . $ Level_goals..GoalItemInfocxx . . $ levelgoals#GoalItemInfo(af0847b9747ce646).(i, j, LO_GET_SPECIFIEDcxx . . $ `Descent3/levelgoal_external.h:34:9`!, &type, &handle, &f_done); |
| 793 | cf_WriteBytecxx . . $ cf_WriteByte(17377ebd5835367f).(fptr, type); |
| 794 | cf_WriteIntcxx . . $ cf_WriteInt(966989f25543eb13).(fptr, handle); |
| 795 | cf_WriteBytecxx . . $ cf_WriteByte(17377ebd5835367f).(fptr, (char)f_done); |
| 796 | } |
| 797 | } |
| 798 | |
| 799 | cf_WriteIntcxx . . $ cf_WriteInt(966989f25543eb13).(fptr, m_flagscxx . . $ levelgoals#m_flags.); |
| 800 | |
| 801 | return true; |
| 802 | } |
| 803 | |
| 804 | bool levelgoalscxx . . $ levelgoals#::LGStatuscxx . . $ levelgoals#LGStatus(a986cf6c14500712).(char operation, int *value) { |
| 805 | if (!value) |
| 806 | return false; |
| 807 | |
| 808 | switch (operation) { |
| 809 | case LO_SET_SPECIFIEDcxx . . $ `Descent3/levelgoal_external.h:33:9`!: |
| 810 | m_flagscxx . . $ levelgoals#m_flags. |= *value; |
| 811 | return true; |
| 812 | break; |
| 813 | case LO_GET_SPECIFIEDcxx . . $ `Descent3/levelgoal_external.h:34:9`!: |
| 814 | *value = m_flagscxx . . $ levelgoals#m_flags.; |
| 815 | return true; |
| 816 | break; |
| 817 | case LO_CLEAR_SPECIFIEDcxx . . $ `Descent3/levelgoal_external.h:35:9`!: |
| 818 | m_flagscxx . . $ levelgoals#m_flags. &= ~(*value); |
| 819 | return true; |
| 820 | break; |
| 821 | } |
| 822 | |
| 823 | return false; |
| 824 | } |
| 825 | |
| 826 | bool levelgoalscxx . . $ levelgoals#::LoadLevelGoalInfocxx . . $ levelgoals#LoadLevelGoalInfo(254217fab7598d49).(CFILEcxx . . $ CFILE# *fptr) { |
| 827 | CleanupAfterLevelcxx . . $ levelgoals#CleanupAfterLevel(49f6e7a06ebc5aa8).(); |
| 828 | |
| 829 | int i; |
| 830 | int16_t version = cf_ReadShortcxx . . $ cf_ReadShort(30b00389b433b379).(fptr); |
| 831 | int num_goals = cf_ReadShortcxx . . $ cf_ReadShort(30b00389b433b379).(fptr); |
| 832 | |
| 833 | for (i = 0; i < num_goals; i++) { |
| 834 | char name[256]; |
| 835 | char iname[256]; |
| 836 | char desc[2560]; |
| 837 | char message[2560]; |
| 838 | int len; |
| 839 | int num_items; |
| 840 | int j; |
| 841 | int priority; |
| 842 | char g_list; |
| 843 | int status; |
| 844 | |
| 845 | int gi = AddGoalcxx . . $ levelgoals#AddGoal(73da94e76e6bd037).(false); |
| 846 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(gi == i); |
| 847 | |
| 848 | status = cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(fptr); |
| 849 | m_goalcxx . . $ levelgoals#m_goal.[i].GetStatuscxx . . $ lgoal#GetStatus(861cbd76ae8afef5).(i, LO_SET_SPECIFIEDcxx . . $ `Descent3/levelgoal_external.h:33:9`!, &status, true); |
| 850 | |
| 851 | priority = cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(fptr); |
| 852 | Level_goalscxx . . $ Level_goals..GoalPrioritycxx . . $ levelgoals#GoalPriority(f3551096b2e9a55d).(i, LO_SET_SPECIFIEDcxx . . $ `Descent3/levelgoal_external.h:33:9`!, &priority); |
| 853 | |
| 854 | if (version < 4) { |
| 855 | g_list = 0; |
| 856 | } else { |
| 857 | g_list = cf_ReadBytecxx . . $ cf_ReadByte(dcbbf0b0e13758ec).(fptr); |
| 858 | } |
| 859 | Level_goalscxx . . $ Level_goals..GoalGoalListcxx . . $ levelgoals#GoalGoalList(5a6a60347df10d71).(i, LO_SET_SPECIFIEDcxx . . $ `Descent3/levelgoal_external.h:33:9`!, &g_list); |
| 860 | |
| 861 | len = cf_ReadShortcxx . . $ cf_ReadShort(30b00389b433b379).(fptr); |
| 862 | if (len) { |
| 863 | cf_ReadBytescxx . . $ cf_ReadBytes(de6325ef3380a744).((uint8_tcxx . . $ uint8_t# *)name, len, fptr); |
| 864 | } |
| 865 | name[len] = '\0'; |
| 866 | |
| 867 | len = cf_ReadShortcxx . . $ cf_ReadShort(30b00389b433b379).(fptr); |
| 868 | if (len) { |
| 869 | cf_ReadBytescxx . . $ cf_ReadBytes(de6325ef3380a744).((uint8_tcxx . . $ uint8_t# *)iname, len, fptr); |
| 870 | } |
| 871 | iname[len] = '\0'; |
| 872 | |
| 873 | len = cf_ReadShortcxx . . $ cf_ReadShort(30b00389b433b379).(fptr); |
| 874 | if (len) { |
| 875 | cf_ReadBytescxx . . $ cf_ReadBytes(de6325ef3380a744).((uint8_tcxx . . $ uint8_t# *)desc, len, fptr); |
| 876 | } |
| 877 | desc[len] = '\0'; |
| 878 | |
| 879 | if (version < 3) { |
| 880 | message[0] = '\0'; |
| 881 | } else { |
| 882 | len = cf_ReadShortcxx . . $ cf_ReadShort(30b00389b433b379).(fptr); |
| 883 | if (len) { |
| 884 | cf_ReadBytescxx . . $ cf_ReadBytes(de6325ef3380a744).((uint8_tcxx . . $ uint8_t# *)message, len, fptr); |
| 885 | } |
| 886 | message[len] = '\0'; |
| 887 | } |
| 888 | |
| 889 | Level_goalscxx . . $ Level_goals..GoalSetNamecxx . . $ levelgoals#GoalSetName(ceb9eed3194142b2).(i, name); |
| 890 | Level_goalscxx . . $ Level_goals..GoalSetItemNamecxx . . $ levelgoals#GoalSetItemName(ceb9eed3194142b2).(i, iname); |
| 891 | Level_goalscxx . . $ Level_goals..GoalSetDesccxx . . $ levelgoals#GoalSetDesc(ceb9eed3194142b2).(i, desc); |
| 892 | Level_goalscxx . . $ Level_goals..GoalSetCompletionMessagecxx . . $ levelgoals#GoalSetCompletionMessage(ceb9eed3194142b2).(i, message); |
| 893 | |
| 894 | num_items = cf_ReadShortcxx . . $ cf_ReadShort(30b00389b433b379).(fptr); |
| 895 | for (j = 0; j < num_items; j++) { |
| 896 | char type; |
| 897 | int handle; |
| 898 | bool f_done; |
| 899 | |
| 900 | int item_slot = GoalAddItemcxx . . $ levelgoals#GoalAddItem(7864480464b09eea).(i); |
| 901 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(item_slot == j); |
| 902 | |
| 903 | type = cf_ReadBytecxx . . $ cf_ReadByte(dcbbf0b0e13758ec).(fptr); |
| 904 | handle = cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(fptr); |
| 905 | f_done = cf_ReadBytecxx . . $ cf_ReadByte(dcbbf0b0e13758ec).(fptr) != 0; |
| 906 | Level_goalscxx . . $ Level_goals..GoalItemInfocxx . . $ levelgoals#GoalItemInfo(af0847b9747ce646).(i, j, LO_SET_SPECIFIEDcxx . . $ `Descent3/levelgoal_external.h:33:9`!, &type, &handle, &f_done); |
| 907 | } |
| 908 | } |
| 909 | |
| 910 | if (version >= 2) |
| 911 | m_flagscxx . . $ levelgoals#m_flags. = cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(fptr); |
| 912 | else |
| 913 | m_flagscxx . . $ levelgoals#m_flags. = 0; |
| 914 | |
| 915 | ResetModifiedFlagscxx . . $ levelgoals#ResetModifiedFlags(49f6e7a06ebc5aa8).(); |
| 916 | |
| 917 | return true; |
| 918 | } |
| 919 | /* |
| 920 | int levelgoals::GetCurrentPrimaryGoalIndex() |
| 921 | { |
| 922 | int i; |
| 923 | int cp; |
| 924 | int bestp = -1; |
| 925 | int bestg = -1; |
| 926 | |
| 927 | for(i = 0; i < m_num_goals; i++) |
| 928 | { |
| 929 | int flags; |
| 930 | m_goal[i].GetStatus(i, LO_GET_SPECIFIED, &flags); |
| 931 | |
| 932 | if(!(flags & (LGF_SECONDARY_GOAL | LGF_COMPLETED))) |
| 933 | { |
| 934 | if(flags & LGF_ENABLED) |
| 935 | { |
| 936 | m_goal[i].Priority(i,LO_GET_SPECIFIED, &cp); |
| 937 | |
| 938 | if(cp > bestp) |
| 939 | { |
| 940 | bestp = cp; |
| 941 | bestg = i; |
| 942 | } |
| 943 | } |
| 944 | } |
| 945 | } |
| 946 | |
| 947 | return bestg; |
| 948 | }*/ |
| 949 | |
| 950 | // int m_num_active_primaries = 0; |
| 951 | // int m_active_primaries[MAX_LEVEL_GOALS]; |
| 952 | // int m_num_active_secondaries = 0; |
| 953 | // int m_active_secondaries[MAX_LEVEL_GOALS]; |
| 954 | |
| 955 | int levelgoalscxx . . $ levelgoals#::GetNumActivePrimaryGoalscxx . . $ levelgoals#GetNumActivePrimaryGoals(b126dc7c1de90089).() { |
| 956 | int x; |
| 957 | m_num_active_primariescxx . . $ levelgoals#m_num_active_primaries. = 0; |
| 958 | |
| 959 | int i; |
| 960 | int bestp[4]; |
| 961 | int cp; // Current priority |
| 962 | char cl; // Current list |
| 963 | int temp_p[MAX_GOAL_LISTScxx . . $ `Descent3/levelgoal_external.h:65:9`!][MAX_LEVEL_GOALScxx . . $ `Descent3/levelgoal_external.h:63:9`!]; |
| 964 | char temp_g[MAX_GOAL_LISTScxx . . $ `Descent3/levelgoal_external.h:65:9`!][MAX_LEVEL_GOALScxx . . $ `Descent3/levelgoal_external.h:63:9`!]; |
| 965 | |
| 966 | int temp_count[MAX_GOAL_LISTScxx . . $ `Descent3/levelgoal_external.h:65:9`!]; |
| 967 | |
| 968 | for (i = 0; i < MAX_GOAL_LISTScxx . . $ `Descent3/levelgoal_external.h:65:9`!; i++) { |
| 969 | bestp[i] = -1; |
| 970 | temp_count[i] = 0; |
| 971 | } |
| 972 | |
| 973 | // Determine the active number for the current list |
| 974 | for (i = 0; i < m_num_goalscxx . . $ levelgoals#m_num_goals.; i++) { |
| 975 | int flags; |
| 976 | m_goalcxx . . $ levelgoals#m_goal.[i].GetStatuscxx . . $ lgoal#GetStatus(861cbd76ae8afef5).(i, LO_GET_SPECIFIEDcxx . . $ `Descent3/levelgoal_external.h:34:9`!, &flags); |
| 977 | |
| 978 | if (!(flags & (LGF_COMPLETEDcxx . . $ `Descent3/levelgoal_external.h:41:9`! | LGF_FAILEDcxx . . $ `Descent3/levelgoal_external.h:45:9`! | LGF_SECONDARY_GOALcxx . . $ `Descent3/levelgoal_external.h:39:9`!))) { |
| 979 | if (flags & LGF_ENABLEDcxx . . $ `Descent3/levelgoal_external.h:40:9`!) { |
| 980 | m_goalcxx . . $ levelgoals#m_goal.[i].GoalListcxx . . $ lgoal#GoalList(c4e55793fafc8042).(LO_GET_SPECIFIEDcxx . . $ `Descent3/levelgoal_external.h:34:9`!, &cl); |
| 981 | m_goalcxx . . $ levelgoals#m_goal.[i].Prioritycxx . . $ lgoal#Priority(f3551096b2e9a55d).(i, LO_GET_SPECIFIEDcxx . . $ `Descent3/levelgoal_external.h:34:9`!, &cp); |
| 982 | |
| 983 | if (bestp[cl] == -1 || cp <= bestp[cl]) { |
| 984 | bestp[cl] = cp; |
| 985 | temp_p[cl][temp_count[cl]] = cp; |
| 986 | temp_g[cl][(temp_count[cl])++] = i; |
| 987 | } |
| 988 | } |
| 989 | } |
| 990 | } |
| 991 | |
| 992 | for (x = 0; x < MAX_GOAL_LISTScxx . . $ `Descent3/levelgoal_external.h:65:9`!; x++) { |
| 993 | for (i = 0; i < temp_count[x]; i++) { |
| 994 | if (temp_p[x][i] == bestp[x]) { |
| 995 | m_active_primariescxx . . $ levelgoals#m_active_primaries.[m_num_active_primariescxx . . $ levelgoals#m_num_active_primaries.++] = temp_g[x][i]; |
| 996 | } |
| 997 | } |
| 998 | } |
| 999 | |
| 1000 | return m_num_active_primariescxx . . $ levelgoals#m_num_active_primaries.; |
| 1001 | } |
| 1002 | |
| 1003 | int levelgoalscxx . . $ levelgoals#::GetActivePrimaryGoalcxx . . $ levelgoals#GetActivePrimaryGoal(7864480464b09eea).(int p_index) { |
| 1004 | if (p_index < 0 || p_index >= m_num_active_primariescxx . . $ levelgoals#m_num_active_primaries.) |
| 1005 | return -1; |
| 1006 | |
| 1007 | return m_active_primariescxx . . $ levelgoals#m_active_primaries.[p_index]; |
| 1008 | } |
| 1009 | |
| 1010 | int levelgoalscxx . . $ levelgoals#::GetNumActiveSecondaryGoalscxx . . $ levelgoals#GetNumActiveSecondaryGoals(b126dc7c1de90089).() { |
| 1011 | int x; |
| 1012 | m_num_active_secondariescxx . . $ levelgoals#m_num_active_secondaries. = 0; |
| 1013 | |
| 1014 | int i; |
| 1015 | int bestp[4]; |
| 1016 | int cp; // Current priority |
| 1017 | char cl; // Current list |
| 1018 | int temp_p[MAX_GOAL_LISTScxx . . $ `Descent3/levelgoal_external.h:65:9`!][MAX_LEVEL_GOALScxx . . $ `Descent3/levelgoal_external.h:63:9`!]; |
| 1019 | char temp_g[MAX_GOAL_LISTScxx . . $ `Descent3/levelgoal_external.h:65:9`!][MAX_LEVEL_GOALScxx . . $ `Descent3/levelgoal_external.h:63:9`!]; |
| 1020 | |
| 1021 | int temp_count[MAX_GOAL_LISTScxx . . $ `Descent3/levelgoal_external.h:65:9`!]; |
| 1022 | |
| 1023 | for (i = 0; i < MAX_GOAL_LISTScxx . . $ `Descent3/levelgoal_external.h:65:9`!; i++) { |
| 1024 | bestp[i] = -1; |
| 1025 | temp_count[i] = 0; |
| 1026 | } |
| 1027 | |
| 1028 | // Determine the active number for the current list |
| 1029 | for (i = 0; i < m_num_goalscxx . . $ levelgoals#m_num_goals.; i++) { |
| 1030 | int flags; |
| 1031 | m_goalcxx . . $ levelgoals#m_goal.[i].GetStatuscxx . . $ lgoal#GetStatus(861cbd76ae8afef5).(i, LO_GET_SPECIFIEDcxx . . $ `Descent3/levelgoal_external.h:34:9`!, &flags); |
| 1032 | |
| 1033 | if (!(flags & (LGF_COMPLETEDcxx . . $ `Descent3/levelgoal_external.h:41:9`! | LGF_FAILEDcxx . . $ `Descent3/levelgoal_external.h:45:9`!))) { |
| 1034 | if (flags & LGF_ENABLEDcxx . . $ `Descent3/levelgoal_external.h:40:9`!) { |
| 1035 | if (flags & LGF_SECONDARY_GOALcxx . . $ `Descent3/levelgoal_external.h:39:9`!) { |
| 1036 | m_goalcxx . . $ levelgoals#m_goal.[i].GoalListcxx . . $ lgoal#GoalList(c4e55793fafc8042).(LO_GET_SPECIFIEDcxx . . $ `Descent3/levelgoal_external.h:34:9`!, &cl); |
| 1037 | m_goalcxx . . $ levelgoals#m_goal.[i].Prioritycxx . . $ lgoal#Priority(f3551096b2e9a55d).(i, LO_GET_SPECIFIEDcxx . . $ `Descent3/levelgoal_external.h:34:9`!, &cp); |
| 1038 | |
| 1039 | if (bestp[cl] == -1 || cp <= bestp[cl]) { |
| 1040 | bestp[cl] = cp; |
| 1041 | temp_p[cl][temp_count[cl]] = cp; |
| 1042 | temp_g[cl][(temp_count[cl])++] = i; |
| 1043 | } |
| 1044 | } |
| 1045 | } |
| 1046 | } |
| 1047 | } |
| 1048 | |
| 1049 | for (x = 0; x < MAX_GOAL_LISTScxx . . $ `Descent3/levelgoal_external.h:65:9`!; x++) { |
| 1050 | for (i = 0; i < temp_count[x]; i++) { |
| 1051 | if (temp_p[x][i] == bestp[x]) { |
| 1052 | m_active_secondariescxx . . $ levelgoals#m_active_secondaries.[m_num_active_secondariescxx . . $ levelgoals#m_num_active_secondaries.++] = temp_g[x][i]; |
| 1053 | } |
| 1054 | } |
| 1055 | } |
| 1056 | |
| 1057 | return m_num_active_secondariescxx . . $ levelgoals#m_num_active_secondaries.; |
| 1058 | } |
| 1059 | |
| 1060 | int levelgoalscxx . . $ levelgoals#::GetActiveSecondaryGoalcxx . . $ levelgoals#GetActiveSecondaryGoal(7864480464b09eea).(int s_index) { |
| 1061 | if (s_index < 0 || s_index >= m_num_active_secondariescxx . . $ levelgoals#m_num_active_secondaries.) |
| 1062 | return -1; |
| 1063 | |
| 1064 | return m_active_secondariescxx . . $ levelgoals#m_active_secondaries.[s_index]; |
| 1065 | } |
| 1066 | |
| 1067 | void levelgoalscxx . . $ levelgoals#::DoFramecxx . . $ levelgoals#DoFrame(49f6e7a06ebc5aa8).() { |
| 1068 | int i; |
| 1069 | |
| 1070 | // Check for auto-completion |
| 1071 | for (i = 0; i < m_num_goalscxx . . $ levelgoals#m_num_goals.; i++) { |
| 1072 | int flags; |
| 1073 | m_goalcxx . . $ levelgoals#m_goal.[i].GetStatuscxx . . $ lgoal#GetStatus(861cbd76ae8afef5).(i, LO_GET_SPECIFIEDcxx . . $ `Descent3/levelgoal_external.h:34:9`!, &flags); |
| 1074 | |
| 1075 | if (!(flags & (LGF_COMPLETEDcxx . . $ `Descent3/levelgoal_external.h:41:9`! | LGF_FAILEDcxx . . $ `Descent3/levelgoal_external.h:45:9`!))) { |
| 1076 | if (flags & LGF_ENABLEDcxx . . $ `Descent3/levelgoal_external.h:40:9`!) { |
| 1077 | char ctype; |
| 1078 | int chandle; |
| 1079 | bool cdone; |
| 1080 | bool f_done = true; |
| 1081 | |
| 1082 | m_goalcxx . . $ levelgoals#m_goal.[i].ItemInfocxx . . $ lgoal#ItemInfo(517b8770e5a0ffe0).(0, LO_GET_SPECIFIEDcxx . . $ `Descent3/levelgoal_external.h:34:9`!, &ctype, &chandle, &cdone); |
| 1083 | |
| 1084 | if (ctype == LIT_TERRAIN_CELLcxx . . $ `Descent3/levelgoal_external.h:26:9`!) { |
| 1085 | if (Game_modecxx . . $ Game_mode. & GM_MULTIcxx . . $ `Descent3/game.h:288:9`!) { |
| 1086 | int j; |
| 1087 | |
| 1088 | for (j = 0; j < MAX_PLAYERScxx . . $ `Descent3/player_external_struct.h:86:9`!; j++) { |
| 1089 | if ((NetPlayerscxx . . $ NetPlayers.[j].flagscxx . . $ netplayer#flags. & NPF_CONNECTEDcxx . . $ `Descent3/multi_external.h:165:9`!) && (NetPlayerscxx . . $ NetPlayers.[j].sequencecxx . . $ netplayer#sequence. >= NETSEQ_PLAYINGcxx . . $ `Descent3/multi_external.h:161:9`!)) { |
| 1090 | objectcxx . . $ object# *player = &Objectscxx . . $ Objects.[Playerscxx . . $ Players.[j].objnumcxx . . $ player#objnum.]; |
| 1091 | if (!ROOMNUM_OUTSIDEcxx . . $ `lib/object_external_struct.h:127:9`!(player->roomnum)) { |
| 1092 | f_done = false; |
| 1093 | } |
| 1094 | } |
| 1095 | } |
| 1096 | } else { |
| 1097 | if (!ROOMNUM_OUTSIDEcxx . . $ `lib/object_external_struct.h:127:9`!(Player_object->roomnum)) { |
| 1098 | f_done = false; |
| 1099 | } |
| 1100 | } |
| 1101 | } else if (ctype == LIT_ANY_MINEcxx . . $ `Descent3/levelgoal_external.h:30:9`!) { |
| 1102 | if (Game_modecxx . . $ Game_mode. & GM_MULTIcxx . . $ `Descent3/game.h:288:9`!) { |
| 1103 | int j; |
| 1104 | |
| 1105 | for (j = 0; j < MAX_PLAYERScxx . . $ `Descent3/player_external_struct.h:86:9`!; j++) { |
| 1106 | if ((NetPlayerscxx . . $ NetPlayers.[j].flagscxx . . $ netplayer#flags. & NPF_CONNECTEDcxx . . $ `Descent3/multi_external.h:165:9`!) && (NetPlayerscxx . . $ NetPlayers.[j].sequencecxx . . $ netplayer#sequence. >= NETSEQ_PLAYINGcxx . . $ `Descent3/multi_external.h:161:9`!)) { |
| 1107 | objectcxx . . $ object# *player = &Objectscxx . . $ Objects.[Playerscxx . . $ Players.[j].objnumcxx . . $ player#objnum.]; |
| 1108 | if (ROOMNUM_OUTSIDEcxx . . $ `lib/object_external_struct.h:127:9`!(player->roomnum)) { |
| 1109 | f_done = false; |
| 1110 | } |
| 1111 | } |
| 1112 | } |
| 1113 | } else { |
| 1114 | if (ROOMNUM_OUTSIDEcxx . . $ `lib/object_external_struct.h:127:9`!(Player_object->roomnum)) { |
| 1115 | f_done = false; |
| 1116 | } |
| 1117 | } |
| 1118 | } else { |
| 1119 | continue; |
| 1120 | } |
| 1121 | |
| 1122 | if (f_done) { |
| 1123 | int flags = LGF_COMPLETEDcxx . . $ `Descent3/levelgoal_external.h:41:9`!; |
| 1124 | m_goalcxx . . $ levelgoals#m_goal.[i].GetStatuscxx . . $ lgoal#GetStatus(861cbd76ae8afef5).(i, LO_SET_SPECIFIEDcxx . . $ `Descent3/levelgoal_external.h:33:9`!, &flags); |
| 1125 | } |
| 1126 | } |
| 1127 | } |
| 1128 | } |
| 1129 | |
| 1130 | if (GetNumActivePrimaryGoalscxx . . $ levelgoals#GetNumActivePrimaryGoals(b126dc7c1de90089).() == 0 && !(m_flagscxx . . $ levelgoals#m_flags. & LF_ALL_PRIMARIES_DONEcxx . . $ `Descent3/levelgoal_external.h:23:9`!)) { |
| 1131 | m_flagscxx . . $ levelgoals#m_flags. |= LF_ALL_PRIMARIES_DONEcxx . . $ `Descent3/levelgoal_external.h:23:9`!; |
| 1132 | |
| 1133 | tOSIRISEventInfocxx . . $ tOSIRISEventInfo# ei; |
| 1134 | Osiris_CallLevelEventcxx . . $ Osiris_CallLevelEvent(a880c8b99cdc05b4).(EVT_ALL_LEVEL_GOALS_COMPLETEcxx . . $ `scripts/osiris_common.h:395:9`!, &ei); |
| 1135 | } |
| 1136 | } |
| 1137 | |
| 1138 | void levelgoalscxx . . $ levelgoals#::CleanupAfterLevelcxx . . $ levelgoals#CleanupAfterLevel(49f6e7a06ebc5aa8).() { |
| 1139 | int i; |
| 1140 | |
| 1141 | for (i = m_num_goalscxx . . $ levelgoals#m_num_goals.; i >= 0; i--) { |
| 1142 | DeleteGoalcxx . . $ levelgoals#DeleteGoal(83c267b20bac841a).(i); |
| 1143 | } |
| 1144 | } |
| 1145 | |
| 1146 | void levelgoalscxx . . $ levelgoals#::InitLevelcxx . . $ levelgoals#InitLevel(49f6e7a06ebc5aa8).() { |
| 1147 | int i, j; |
| 1148 | |
| 1149 | for (i = 0; i <= Highest_object_indexcxx . . $ Highest_object_index.; i++) { |
| 1150 | if (Objectscxx . . $ Objects.[i].typecxx . . $ object#type. != OBJ_NONEcxx . . $ `Descent3/object_external.h:159:9`!) { |
| 1151 | Objectscxx . . $ Objects.[i].flagscxx . . $ object#flags. &= |
| 1152 | (~(OF_INFORM_PLAYER_COLLIDE_TO_LGcxx . . $ `Descent3/object_external.h:300:9`! | OF_INFORM_PLAYER_WEAPON_COLLIDE_TO_LGcxx . . $ `Descent3/object_external.h:301:9`! | OF_INFORM_DESTROY_TO_LGcxx . . $ `Descent3/object_external.h:302:9`!)); |
| 1153 | } |
| 1154 | } |
| 1155 | |
| 1156 | for (i = 0; i <= Highest_room_indexcxx . . $ Highest_room_index.; i++) { |
| 1157 | if (Roomscxx . . $ Rooms.[i].usedcxx . . $ room#used.) { |
| 1158 | Roomscxx . . $ Rooms.[i].flagscxx . . $ room#flags. &= (~(RF_INFORM_RELINK_TO_LGcxx . . $ `Descent3/room_external.h:198:9`!)); |
| 1159 | } |
| 1160 | } |
| 1161 | |
| 1162 | for (i = 0; i < Num_triggerscxx . . $ Num_triggers.; i++) { |
| 1163 | Triggerscxx . . $ Triggers.[i].flagscxx . . $ trigger#flags. &= (~(TF_INFORM_ACTIVATE_TO_LGcxx . . $ `Descent3/trigger.h:97:9`!)); |
| 1164 | } |
| 1165 | |
| 1166 | for (i = 0; i < m_num_goalscxx . . $ levelgoals#m_num_goals.; i++) { |
| 1167 | int flags; |
| 1168 | m_goalcxx . . $ levelgoals#m_goal.[i].GetStatuscxx . . $ lgoal#GetStatus(861cbd76ae8afef5).(i, LO_GET_SPECIFIEDcxx . . $ `Descent3/levelgoal_external.h:34:9`!, &flags); |
| 1169 | flags &= LGF_COMP_MASKcxx . . $ `Descent3/levelgoal_external.h:53:9`!; |
| 1170 | |
| 1171 | for (j = 0; j < m_goalcxx . . $ levelgoals#m_goal.[i].GetNumItemscxx . . $ lgoal#GetNumItems(b126dc7c1de90089).(); j++) { |
| 1172 | char type; |
| 1173 | int handle; |
| 1174 | bool done; |
| 1175 | |
| 1176 | m_goalcxx . . $ levelgoals#m_goal.[i].ItemInfocxx . . $ lgoal#ItemInfo(517b8770e5a0ffe0).(j, LO_GET_SPECIFIEDcxx . . $ `Descent3/levelgoal_external.h:34:9`!, &type, &handle, &done); |
| 1177 | |
| 1178 | switch (type) { |
| 1179 | case LIT_TERRAIN_CELLcxx . . $ `Descent3/levelgoal_external.h:26:9`!: |
| 1180 | break; |
| 1181 | case LIT_INTERNAL_ROOMcxx . . $ `Descent3/levelgoal_external.h:27:9`!: |
| 1182 | if (flags == LGF_COMP_ENTERcxx . . $ `Descent3/levelgoal_external.h:47:9`!) { |
| 1183 | if (handle >= 0 && handle <= Highest_room_indexcxx . . $ Highest_room_index. && Roomscxx . . $ Rooms.[handle].usedcxx . . $ room#used.) { |
| 1184 | Roomscxx . . $ Rooms.[handle].flagscxx . . $ room#flags. |= RF_INFORM_RELINK_TO_LGcxx . . $ `Descent3/room_external.h:198:9`!; |
| 1185 | } |
| 1186 | } |
| 1187 | break; |
| 1188 | case LIT_OBJECTcxx . . $ `Descent3/levelgoal_external.h:28:9`!: |
| 1189 | if (flags == LGF_COMP_PLAYERcxx . . $ `Descent3/levelgoal_external.h:50:9`!) { |
| 1190 | objectcxx . . $ object# *obj = ObjGetcxx . . $ ObjGet(11672e354c0b263a).(handle); |
| 1191 | if (obj) { |
| 1192 | obj->flagscxx . . $ object#flags. |= OF_INFORM_PLAYER_COLLIDE_TO_LGcxx . . $ `Descent3/object_external.h:300:9`!; |
| 1193 | } |
| 1194 | } else if (flags == LGF_COMP_PLAYER_WEAPONcxx . . $ `Descent3/levelgoal_external.h:49:9`!) { |
| 1195 | objectcxx . . $ object# *obj = ObjGetcxx . . $ ObjGet(11672e354c0b263a).(handle); |
| 1196 | if (obj) { |
| 1197 | obj->flagscxx . . $ object#flags. |= OF_INFORM_PLAYER_WEAPON_COLLIDE_TO_LGcxx . . $ `Descent3/object_external.h:301:9`!; |
| 1198 | } |
| 1199 | } else if (flags == LGF_COMP_DESTROYcxx . . $ `Descent3/levelgoal_external.h:48:9`!) { |
| 1200 | objectcxx . . $ object# *obj = ObjGetcxx . . $ ObjGet(11672e354c0b263a).(handle); |
| 1201 | if (obj) { |
| 1202 | obj->flagscxx . . $ object#flags. |= OF_INFORM_DESTROY_TO_LGcxx . . $ `Descent3/object_external.h:302:9`!; |
| 1203 | } |
| 1204 | } |
| 1205 | break; |
| 1206 | case LIT_TRIGGERcxx . . $ `Descent3/levelgoal_external.h:29:9`!: |
| 1207 | if (handle >= 0 && handle < Num_triggerscxx . . $ Num_triggers.) { |
| 1208 | if (flags == LGF_COMP_ACTIVATEcxx . . $ `Descent3/levelgoal_external.h:46:9`!) { |
| 1209 | Triggerscxx . . $ Triggers.[handle].flagscxx . . $ trigger#flags. |= TF_INFORM_ACTIVATE_TO_LGcxx . . $ `Descent3/trigger.h:97:9`!; |
| 1210 | } |
| 1211 | } |
| 1212 | break; |
| 1213 | case LIT_ANY_MINEcxx . . $ `Descent3/levelgoal_external.h:30:9`!: |
| 1214 | break; |
| 1215 | } |
| 1216 | } |
| 1217 | } |
| 1218 | } |
| 1219 | |
| 1220 | void levelgoalscxx . . $ levelgoals#::Informcxx . . $ levelgoals#Inform(8589f1c7c2d24df6).(char type, int comp_type, int handle) { |
| 1221 | int i, j; |
| 1222 | |
| 1223 | for (i = 0; i < m_num_goalscxx . . $ levelgoals#m_num_goals.; i++) { |
| 1224 | int flags; |
| 1225 | m_goalcxx . . $ levelgoals#m_goal.[i].GetStatuscxx . . $ lgoal#GetStatus(861cbd76ae8afef5).(i, LO_GET_SPECIFIEDcxx . . $ `Descent3/levelgoal_external.h:34:9`!, &flags); |
| 1226 | |
| 1227 | if (!(flags & LGF_ENABLEDcxx . . $ `Descent3/levelgoal_external.h:40:9`!) && (comp_type == LGF_COMP_ACTIVATEcxx . . $ `Descent3/levelgoal_external.h:46:9`! || comp_type == LGF_COMP_ENTERcxx . . $ `Descent3/levelgoal_external.h:47:9`! || |
| 1228 | comp_type == LGF_COMP_PLAYER_WEAPONcxx . . $ `Descent3/levelgoal_external.h:49:9`! || comp_type == LGF_COMP_PLAYERcxx . . $ `Descent3/levelgoal_external.h:50:9`!)) { |
| 1229 | continue; |
| 1230 | } |
| 1231 | |
| 1232 | int cur_comp_type = flags & LGF_COMP_MASKcxx . . $ `Descent3/levelgoal_external.h:53:9`!; |
| 1233 | int num_items = m_goalcxx . . $ levelgoals#m_goal.[i].GetNumItemscxx . . $ lgoal#GetNumItems(b126dc7c1de90089).(); |
| 1234 | |
| 1235 | if (flags != LGF_COMP_DALLAScxx . . $ `Descent3/levelgoal_external.h:51:9`! && cur_comp_type != comp_type) { |
| 1236 | continue; |
| 1237 | } |
| 1238 | |
| 1239 | for (j = 0; j < num_items; j++) { |
| 1240 | char ctype; |
| 1241 | int chandle; |
| 1242 | bool cdone; |
| 1243 | |
| 1244 | m_goalcxx . . $ levelgoals#m_goal.[i].ItemInfocxx . . $ lgoal#ItemInfo(517b8770e5a0ffe0).(j, LO_GET_SPECIFIEDcxx . . $ `Descent3/levelgoal_external.h:34:9`!, &ctype, &chandle, &cdone); |
| 1245 | |
| 1246 | if (cdone || type != ctype || chandle != handle) { |
| 1247 | continue; |
| 1248 | } |
| 1249 | |
| 1250 | bool done = true; |
| 1251 | m_goalcxx . . $ levelgoals#m_goal.[i].ItemInfocxx . . $ lgoal#ItemInfo(517b8770e5a0ffe0).(j, LO_SET_SPECIFIEDcxx . . $ `Descent3/levelgoal_external.h:33:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, &done); |
| 1252 | |
| 1253 | int k; |
| 1254 | bool f_done = true; |
| 1255 | |
| 1256 | for (k = 0; k < num_items; k++) { |
| 1257 | m_goalcxx . . $ levelgoals#m_goal.[i].ItemInfocxx . . $ lgoal#ItemInfo(517b8770e5a0ffe0).(j, LO_SET_SPECIFIEDcxx . . $ `Descent3/levelgoal_external.h:33:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!, &done); |
| 1258 | if (!done) { |
| 1259 | f_done = false; |
| 1260 | break; |
| 1261 | } |
| 1262 | } |
| 1263 | |
| 1264 | if (f_done) { |
| 1265 | int flags = LGF_COMPLETEDcxx . . $ `Descent3/levelgoal_external.h:41:9`!; |
| 1266 | m_goalcxx . . $ levelgoals#m_goal.[i].GetStatuscxx . . $ lgoal#GetStatus(861cbd76ae8afef5).(i, LO_SET_SPECIFIEDcxx . . $ `Descent3/levelgoal_external.h:33:9`!, &flags); |
| 1267 | } |
| 1268 | |
| 1269 | // Make this after the goal complete is done so that designers can say, if this and not |
| 1270 | // goal complete |
| 1271 | tOSIRISEventInfocxx . . $ tOSIRISEventInfo# ei; |
| 1272 | ei.evt_level_goal_item_completecxx . . $ tOSIRISEventInfo#$anonymous_type_1#evt_level_goal_item_complete..level_goal_indexcxx . . $ tOSIRISEVTLEVELGOALITEMCOMPLETE#level_goal_index. = i; |
| 1273 | |
| 1274 | Osiris_CallLevelEventcxx . . $ Osiris_CallLevelEvent(a880c8b99cdc05b4).(EVT_LEVEL_GOAL_ITEM_COMPLETEcxx . . $ `scripts/osiris_common.h:396:9`!, &ei); |
| 1275 | } |
| 1276 | } |
| 1277 | } |
| 1278 | |
| 1279 | int levelgoalscxx . . $ levelgoals#::GoalFindIdcxx . . $ levelgoals#GoalFindId(5c4306d8553b3696).(const char *goal_name) { |
| 1280 | int i; |
| 1281 | char cur_name[200]; |
| 1282 | |
| 1283 | for (i = 0; i < m_num_goalscxx . . $ levelgoals#m_num_goals.; i++) { |
| 1284 | GoalGetNamecxx . . $ levelgoals#GoalGetName(6836bd73a290bb97).(i, cur_name, 200); |
| 1285 | if (stricmpcxx . . $ `linux/linux_fix.h:43:9`!(cur_name, goal_name) == 0) { |
| 1286 | return i; |
| 1287 | } |
| 1288 | } |
| 1289 | |
| 1290 | return -1; |
| 1291 | } |
| 1292 | |
| 1293 | void levelgoalscxx . . $ levelgoals#::ResetModifiedFlagscxx . . $ levelgoals#ResetModifiedFlags(49f6e7a06ebc5aa8).(void) { |
| 1294 | for (int i = 0; i < m_num_goalscxx . . $ levelgoals#m_num_goals.; i++) { |
| 1295 | m_goalcxx . . $ levelgoals#m_goal.[i].ResetModifiedcxx . . $ lgoal#ResetModified(49f6e7a06ebc5aa8).(); |
| 1296 | } |
| 1297 | } |
| 1298 | |
| 1299 | void levelgoalscxx . . $ levelgoals#::MultiSendChangedGoalscxx . . $ levelgoals#MultiSendChangedGoals(d4f767463ce0a6b3).(int pnum) { |
| 1300 | for (int i = 0; i < m_num_goalscxx . . $ levelgoals#m_num_goals.; i++) { |
| 1301 | m_goalcxx . . $ levelgoals#m_goal.[i].SendStateToPlayercxx . . $ lgoal#SendStateToPlayer(3e454b8ccf442868).(i, pnum); |
| 1302 | } |
| 1303 | } |