| 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 | |
| 19 | #include <cstring> |
| 20 | #include <filesystem> |
| 21 | |
| 22 | #include "cfile.h"cxx . . $ `<file>/cfile/cfile.h`/ |
| 23 | #include "manage.h"cxx . . $ `<file>/lib/manage.h`/ |
| 24 | #include "mono.h"cxx . . $ `<file>/ddebug/mono.h`/ |
| 25 | #include "pserror.h"cxx . . $ `<file>/misc/pserror.h`/ |
| 26 | #include "ddio.h"cxx . . $ `<file>/ddio/ddio.h`/ |
| 27 | #include "gamefile.h"cxx . . $ `<file>/Descent3/gamefile.h`/ |
| 28 | #include "gamefilepage.h"cxx . . $ `<file>/manage/gamefilepage.h`/ |
| 29 | #include "args.h"cxx . . $ `<file>/Descent3/args.h`/ |
| 30 | |
| 31 | // gamefilepage commands that are read/written |
| 32 | // A command is followed by a byte count describing how many bytes |
| 33 | // are in the data for the command |
| 34 | #define GAMEFILEPAGE_COMMAND_NAMEcxx . . $ `manage/gamefilepage.cpp:34:9`! 1 |
| 35 | #define GAMEFILEPAGE_COMMAND_DIR_NAMEcxx . . $ `manage/gamefilepage.cpp:35:9`! 2 |
| 36 | #define GAMEFILEPAGE_COMMAND_ENDcxx . . $ `manage/gamefilepage.cpp:36:9`! 3 |
| 37 | |
| 38 | #define GAMEFILE_VERSIONcxx . . $ `manage/gamefilepage.cpp:38:9`! 2 |
| 39 | |
| 40 | extern char *TablefileNameOverridecxx . . $ TablefileNameOverride.; |
| 41 | |
| 42 | // Given an open file pointer and a gamefile_page struct, writes that gamefile page out |
| 43 | void mng_WriteGamefilePagecxx . . $ mng_WriteGamefilePage(a65e5c267f491e9e).(CFILEcxx . . $ CFILE# *outfile, mngs_gamefile_pagecxx . . $ mngs_gamefile_page# *gamefilepage) { |
| 44 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(outfile != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!); |
| 45 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(gamefilepage != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!); |
| 46 | |
| 47 | cf_WriteBytecxx . . $ cf_WriteByte(17377ebd5835367f).(outfile, PAGETYPE_GAMEFILEcxx . . $ `lib/manage.h:57:9`!); |
| 48 | |
| 49 | cf_WriteBytecxx . . $ cf_WriteByte(17377ebd5835367f).(outfile, GAMEFILEPAGE_COMMAND_NAMEcxx . . $ `manage/gamefilepage.cpp:34:9`!); // write out gamefile name |
| 50 | cf_WriteBytecxx . . $ cf_WriteByte(17377ebd5835367f).(outfile, strlen(gamefilepage->gamefile_structcxx . . $ mngs_gamefile_page#gamefile_struct..namecxx . . $ gamefile#name.) + 1); |
| 51 | cf_WriteStringcxx . . $ cf_WriteString(643e1411966bd56c).(outfile, gamefilepage->gamefile_structcxx . . $ mngs_gamefile_page#gamefile_struct..namecxx . . $ gamefile#name.); |
| 52 | |
| 53 | cf_WriteBytecxx . . $ cf_WriteByte(17377ebd5835367f).(outfile, GAMEFILEPAGE_COMMAND_DIR_NAMEcxx . . $ `manage/gamefilepage.cpp:35:9`!); // write out gamefile name |
| 54 | cf_WriteBytecxx . . $ cf_WriteByte(17377ebd5835367f).(outfile, strlen(gamefilepage->gamefile_structcxx . . $ mngs_gamefile_page#gamefile_struct..dir_namecxx . . $ gamefile#dir_name.) + 1); |
| 55 | cf_WriteStringcxx . . $ cf_WriteString(643e1411966bd56c).(outfile, gamefilepage->gamefile_structcxx . . $ mngs_gamefile_page#gamefile_struct..dir_namecxx . . $ gamefile#dir_name.); |
| 56 | |
| 57 | cf_WriteBytecxx . . $ cf_WriteByte(17377ebd5835367f).(outfile, GAMEFILEPAGE_COMMAND_ENDcxx . . $ `manage/gamefilepage.cpp:36:9`!); // we're all done |
| 58 | cf_WriteBytecxx . . $ cf_WriteByte(17377ebd5835367f).(outfile, 0); |
| 59 | } |
| 60 | // Given an open file pointer and a gamefile_page struct, writes that gamefile page out |
| 61 | void mng_WriteNewGamefilePagecxx . . $ mng_WriteNewGamefilePage(a65e5c267f491e9e).(CFILEcxx . . $ CFILE# *outfile, mngs_gamefile_pagecxx . . $ mngs_gamefile_page# *gamefilepage) { |
| 62 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(outfile != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!); |
| 63 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(gamefilepage != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!); |
| 64 | |
| 65 | int offset = StartManagePagecxx . . $ StartManagePage(d1801a78c3072b68).(outfile, PAGETYPE_GAMEFILEcxx . . $ `lib/manage.h:57:9`!); |
| 66 | |
| 67 | cf_WriteShortcxx . . $ cf_WriteShort(d7cf1a05aca96fe5).(outfile, GAMEFILE_VERSIONcxx . . $ `manage/gamefilepage.cpp:38:9`!); |
| 68 | |
| 69 | cf_WriteStringcxx . . $ cf_WriteString(643e1411966bd56c).(outfile, gamefilepage->gamefile_structcxx . . $ mngs_gamefile_page#gamefile_struct..namecxx . . $ gamefile#name.); |
| 70 | cf_WriteStringcxx . . $ cf_WriteString(643e1411966bd56c).(outfile, gamefilepage->gamefile_structcxx . . $ mngs_gamefile_page#gamefile_struct..dir_namecxx . . $ gamefile#dir_name.); |
| 71 | |
| 72 | EndManagePagecxx . . $ EndManagePage(966989f25543eb13).(outfile, offset); |
| 73 | } |
| 74 | |
| 75 | // Reads a gamefile page from an open file. Returns 0 on error. |
| 76 | int mng_ReadNewGamefilePagecxx . . $ mng_ReadNewGamefilePage(6ed3275c23aad507).(CFILEcxx . . $ CFILE# *infile, mngs_gamefile_pagecxx . . $ mngs_gamefile_page# *gamefilepage) { |
| 77 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(infile != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!); |
| 78 | memset(gamefilepage, 0, sizeof(mngs_gamefile_pagecxx . . $ mngs_gamefile_page#)); |
| 79 | |
| 80 | int version = cf_ReadShortcxx . . $ cf_ReadShort(30b00389b433b379).(infile); |
| 81 | |
| 82 | cf_ReadStringcxx . . $ cf_ReadString(38cd788e4423eff6).(gamefilepage->gamefile_structcxx . . $ mngs_gamefile_page#gamefile_struct..namecxx . . $ gamefile#name., PAGENAME_LENcxx . . $ `lib/manage_external.h:49:9`!, infile); |
| 83 | cf_ReadStringcxx . . $ cf_ReadString(38cd788e4423eff6).(gamefilepage->gamefile_structcxx . . $ mngs_gamefile_page#gamefile_struct..dir_namecxx . . $ gamefile#dir_name., PAGENAME_LENcxx . . $ `lib/manage_external.h:49:9`!, infile); |
| 84 | |
| 85 | // This is a valid new page |
| 86 | gamefilepage->gamefile_structcxx . . $ mngs_gamefile_page#gamefile_struct..usedcxx . . $ gamefile#used. = 1; |
| 87 | |
| 88 | return 1; // successfully read |
| 89 | } |
| 90 | |
| 91 | // Reads a gamefile page from an open file. Returns 0 on error. |
| 92 | int mng_ReadGamefilePagecxx . . $ mng_ReadGamefilePage(6ed3275c23aad507).(CFILEcxx . . $ CFILE# *infile, mngs_gamefile_pagecxx . . $ mngs_gamefile_page# *gamefilepage) { |
| 93 | int done = 0; |
| 94 | char command; |
| 95 | uint16_tcxx . . $ uint16_t# len; |
| 96 | int i; |
| 97 | |
| 98 | if (!Old_table_methodcxx . . $ Old_table_method.) |
| 99 | return mng_ReadNewGamefilePagecxx . . $ mng_ReadNewGamefilePage(6ed3275c23aad507).(infile, gamefilepage); |
| 100 | |
| 101 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(infile != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!); |
| 102 | memset(gamefilepage, 0, sizeof(mngs_gamefile_pagecxx . . $ mngs_gamefile_page#)); |
| 103 | |
| 104 | while (!done) { |
| 105 | // Read in command byte then read in the length of that commands data |
| 106 | |
| 107 | command = cf_ReadBytecxx . . $ cf_ReadByte(dcbbf0b0e13758ec).(infile); |
| 108 | len = cf_ReadBytecxx . . $ cf_ReadByte(dcbbf0b0e13758ec).(infile); |
| 109 | |
| 110 | switch (command) { |
| 111 | case GAMEFILEPAGE_COMMAND_ENDcxx . . $ `manage/gamefilepage.cpp:36:9`!: |
| 112 | done = 1; |
| 113 | break; |
| 114 | case GAMEFILEPAGE_COMMAND_NAMEcxx . . $ `manage/gamefilepage.cpp:34:9`!: // the name of the gamefile model |
| 115 | cf_ReadStringcxx . . $ cf_ReadString(38cd788e4423eff6).(gamefilepage->gamefile_structcxx . . $ mngs_gamefile_page#gamefile_struct..namecxx . . $ gamefile#name., len + 1, infile); |
| 116 | break; |
| 117 | case GAMEFILEPAGE_COMMAND_DIR_NAMEcxx . . $ `manage/gamefilepage.cpp:35:9`!: |
| 118 | cf_ReadStringcxx . . $ cf_ReadString(38cd788e4423eff6).(gamefilepage->gamefile_structcxx . . $ mngs_gamefile_page#gamefile_struct..dir_namecxx . . $ gamefile#dir_name., len + 1, infile); |
| 119 | break; |
| 120 | default: |
| 121 | // Ignore the ones we don't know |
| 122 | for (i = 0; i < len; i++) |
| 123 | cf_ReadBytecxx . . $ cf_ReadByte(dcbbf0b0e13758ec).(infile); |
| 124 | break; |
| 125 | } |
| 126 | } |
| 127 | |
| 128 | // This is a valid new page |
| 129 | gamefilepage->gamefile_structcxx . . $ mngs_gamefile_page#gamefile_struct..usedcxx . . $ gamefile#used. = 1; |
| 130 | |
| 131 | return 1; // successfully read |
| 132 | } |
| 133 | |
| 134 | // Reads in the gamefile named "name" into gamefilepage struct |
| 135 | // Returns 0 on error or couldn't find, else 1 if all is good |
| 136 | int mng_FindSpecificGamefilePagecxx . . $ mng_FindSpecificGamefilePage(29668bacf028c4da).(char *name, mngs_gamefile_pagecxx . . $ mngs_gamefile_page# *gamefilepage, int offset) { |
| 137 | CFILEcxx . . $ CFILE# *infile; |
| 138 | uint8_tcxx . . $ uint8_t# pagetype; |
| 139 | int done = 0, found = 0; |
| 140 | stdcxx . . $ std/::filesystemcxx . . $ std/filesystem/::pathcxx . . $ std/filesystem/__cxx11/path# tablenamecxx . . $ std/filesystem/__cxx11/path#path(ced63f7c635d850d).; |
| 141 | |
| 142 | if (Loading_localscxx . . $ Loading_locals.) { |
| 143 | infile = cfopencxx . . $ cfopen(7c7b94e455f1ae56).(LocalTableFilenamecxx . . $ std/filesystem/__cxx11/path#path(835bc3a16b770d4d)., "rb"); |
| 144 | } else if (Loading_addon_tablecxx . . $ Loading_addon_table. != -1) { |
| 145 | infile = cfopencxx . . $ cfopen(7c7b94e455f1ae56).(AddOnDataTablescxx . . $ std/filesystem/__cxx11/path#path(835bc3a16b770d4d).[Loading_addon_tablecxx . . $ Loading_addon_table.].AddOnTableFilenamecxx . . $ AddOnTablefile#AddOnTableFilename., "rb"); |
| 146 | } else { |
| 147 | if (Network_upcxx . . $ Network_up. && Starting_editorcxx . . $ Starting_editor.) { |
| 148 | int farg = FindArgcxx . . $ FindArg(5c4306d8553b3696).("-filter"); |
| 149 | |
| 150 | if (farg) |
| 151 | tablename =cxx . . $ std/filesystem/__cxx11/path#`operator=`(d30197541d75bb9a). GameArgscxx . . $ GameArgs.[farg + 1]; |
| 152 | else |
| 153 | tablename =cxx . . $ std/filesystem/__cxx11/path#`operator=`(9c9aa2f17f237d0f). LocalTableDircxx . . $ LocalTableDir. /cxx . . $ std/filesystem/__cxx11/`operator/`(578e0438ad5f0e7e). NET_TABLEcxx . . $ `lib/manage.h:36:9`!; |
| 154 | |
| 155 | infile = cfopencxx . . $ cfopen(7c7b94e455f1ae56).(tablename, "rb"); |
| 156 | } else { |
| 157 | infile = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 158 | if (TablefileNameOverridecxx . . $ TablefileNameOverride.) { |
| 159 | infile = cfopencxx . . $ cfopen(7c7b94e455f1ae56).(TablefileNameOverridecxx . . $ std/filesystem/__cxx11/path#path(835bc3a16b770d4d)., "rb"); |
| 160 | } |
| 161 | |
| 162 | if (!infile) |
| 163 | infile = cfopencxx . . $ cfopen(7c7b94e455f1ae56).(TableFilenamecxx . . $ std/filesystem/__cxx11/path#path(835bc3a16b770d4d)., "rb"); |
| 164 | } |
| 165 | } |
| 166 | |
| 167 | if (!infile) |
| 168 | Errorcxx . . $ Error(326aeb464d16410c).("Cannot open table file."); |
| 169 | |
| 170 | // Read in the entire page file until we find the page we want |
| 171 | while (!done) { |
| 172 | if (cfeofcxx . . $ cfeof(413716a422df0036).(infile)) { |
| 173 | done = 1; |
| 174 | continue; |
| 175 | } |
| 176 | pagetype = cf_ReadBytecxx . . $ cf_ReadByte(dcbbf0b0e13758ec).(infile); |
| 177 | int len = cf_ReadIntcxx . . $ cf_ReadInt(d60d6f5e30f0c96a).(infile); |
| 178 | |
| 179 | // If not a gamefile page, just read it in and ignore it |
| 180 | if (pagetype != PAGETYPE_GAMEFILEcxx . . $ `lib/manage.h:57:9`!) { |
| 181 | cfseekcxx . . $ cfseek(f9992d249f032805).(infile, len - 4, SEEK_CURcxx . . $ `<external>/232824719582829767/stdio.h:111:9`!); |
| 182 | continue; |
| 183 | } |
| 184 | |
| 185 | mng_ReadNewGamefilePagecxx . . $ mng_ReadNewGamefilePage(6ed3275c23aad507).(infile, gamefilepage); |
| 186 | |
| 187 | if (!stricmpcxx . . $ `linux/linux_fix.h:43:9`!(name, gamefilepage->gamefile_struct.name)) { |
| 188 | // This is the page we want |
| 189 | found = 1; |
| 190 | done = 1; |
| 191 | } |
| 192 | } |
| 193 | |
| 194 | cfclosecxx . . $ cfclose(3639e799710acb68).(infile); |
| 195 | |
| 196 | return found; // successful! |
| 197 | } |
| 198 | |
| 199 | // Given a gamefile page, allocs a gamefile and calls AssignGamefilePageToGamefile to actually |
| 200 | // load models and values. Rturns gamefile handle on success, -1 if fail |
| 201 | int mng_SetAndLoadGamefilecxx . . $ mng_SetAndLoadGamefile(12f0a87f6c47ae40).(mngs_gamefile_pagecxx . . $ mngs_gamefile_page# *gamefilepage) { |
| 202 | int n; |
| 203 | |
| 204 | n = AllocGamefilecxx . . $ AllocGamefile(b126dc7c1de90089).(); |
| 205 | if (n < 0) |
| 206 | return -1; |
| 207 | if (!mng_AssignGamefilePageToGamefilecxx . . $ mng_AssignGamefilePageToGamefile(4651a8dff5775915).(gamefilepage, n)) |
| 208 | return -1; |
| 209 | |
| 210 | return n; |
| 211 | } |
| 212 | |
| 213 | // Given a gamefilepage and a gamefile handle, attempts to make gamefile n correspond to |
| 214 | // to the gamefilepage. |
| 215 | // Returns 1 on success, 0 otherwise |
| 216 | int mng_AssignGamefilePageToGamefilecxx . . $ mng_AssignGamefilePageToGamefile(4651a8dff5775915).(mngs_gamefile_pagecxx . . $ mngs_gamefile_page# *gamefilepage, int n) { |
| 217 | gamefilecxx . . $ gamefile# *gamefilepointer = &Gamefilescxx . . $ Gamefiles.[n]; |
| 218 | |
| 219 | // copy our values |
| 220 | memcpy(gamefilepointer, &gamefilepage->gamefile_structcxx . . $ mngs_gamefile_page#gamefile_struct., sizeof(gamefilecxx . . $ gamefile#)); |
| 221 | strcpy(gamefilepointer->namecxx . . $ gamefile#name., gamefilepage->gamefile_structcxx . . $ mngs_gamefile_page#gamefile_struct..namecxx . . $ gamefile#name.); |
| 222 | strcpy(gamefilepointer->dir_namecxx . . $ gamefile#dir_name., gamefilepage->gamefile_structcxx . . $ mngs_gamefile_page#gamefile_struct..dir_namecxx . . $ gamefile#dir_name.); |
| 223 | |
| 224 | // First see if our image differs from the one on the net |
| 225 | // If it is, make a copy |
| 226 | // If its a release version, don't do any of this |
| 227 | |
| 228 | #ifndef RELEASE |
| 229 | if (Network_upcxx . . $ Network_up.) { |
| 230 | stdcxx . . $ std/::filesystemcxx . . $ std/filesystem/::pathcxx . . $ std/filesystem/__cxx11/path# str = |
| 231 | stdcxx . . $ std/::filesystemcxx . . $ std/filesystem/::pathcxx . . $ std/filesystem/__cxx11/path#(LocalD3Dircxx . . $ LocalD3Dir.) /cxx . . $ std/filesystem/__cxx11/`operator/`(578e0438ad5f0e7e). "data"cxx . . $ std/filesystem/__cxx11/path#path(835bc3a16b770d4d). /cxx . . $ std/filesystem/__cxx11/`operator/`(578e0438ad5f0e7e). gamefilepointercxx . . $ std/filesystem/__cxx11/path#path(835bc3a16b770d4d).->dir_namecxx . . $ gamefile#dir_name. /cxx . . $ std/filesystem/__cxx11/`operator/`(578e0438ad5f0e7e). gamefilepointercxx . . $ std/filesystem/__cxx11/path#path(835bc3a16b770d4d).->namecxx . . $ gamefile#name.; |
| 232 | stdcxx . . $ std/::filesystemcxx . . $ std/filesystem/::pathcxx . . $ std/filesystem/__cxx11/path# netstr = |
| 233 | stdcxx . . $ std/::filesystemcxx . . $ std/filesystem/::pathcxx . . $ std/filesystem/__cxx11/path#(NetD3Dircxx . . $ NetD3Dir.) /cxx . . $ std/filesystem/__cxx11/`operator/`(578e0438ad5f0e7e). "data"cxx . . $ std/filesystem/__cxx11/path#path(835bc3a16b770d4d). /cxx . . $ std/filesystem/__cxx11/`operator/`(578e0438ad5f0e7e). gamefilepointercxx . . $ std/filesystem/__cxx11/path#path(835bc3a16b770d4d).->dir_namecxx . . $ gamefile#dir_name. /cxx . . $ std/filesystem/__cxx11/`operator/`(578e0438ad5f0e7e). gamefilepointercxx . . $ std/filesystem/__cxx11/path#path(835bc3a16b770d4d).->namecxx . . $ gamefile#name.; |
| 234 | |
| 235 | UpdatePrimitivecxx . . $ UpdatePrimitive(563e7f6fc320b4cb).(str, netstr, gamefilepointer->namecxx . . $ gamefile#name., PAGETYPE_GAMEFILEcxx . . $ `lib/manage.h:57:9`!, gamefilepointer->namecxx . . $ gamefile#name.); |
| 236 | |
| 237 | if (!Starting_editorcxx . . $ Starting_editor.) { |
| 238 | if (cf_Diffcxx . . $ cf_Diff(1b1fb50d0437e4a5).(str, netstr)) { |
| 239 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(1); // Get Jason Immediately...versions between local and net don't match! |
| 240 | |
| 241 | // Do it again so we can trace to see what is wrong |
| 242 | UpdatePrimitivecxx . . $ UpdatePrimitive(563e7f6fc320b4cb).(str, netstr, gamefilepointer->namecxx . . $ gamefile#name., PAGETYPE_GAMEFILEcxx . . $ `lib/manage.h:57:9`!, gamefilepointer->namecxx . . $ gamefile#name.); |
| 243 | } |
| 244 | } |
| 245 | } |
| 246 | #endif |
| 247 | |
| 248 | return 1; |
| 249 | } |
| 250 | |
| 251 | // Copies values from a gamefile into a gamefile_page |
| 252 | void mng_AssignGamefileToGamefilePagecxx . . $ mng_AssignGamefileToGamefilePage(d3c2d6055704c39b).(int n, mngs_gamefile_pagecxx . . $ mngs_gamefile_page# *gamefilepage) { |
| 253 | gamefilecxx . . $ gamefile# *gamefilepointer = &Gamefilescxx . . $ Gamefiles.[n]; |
| 254 | |
| 255 | // Assign the values |
| 256 | memcpy(&gamefilepage->gamefile_structcxx . . $ mngs_gamefile_page#gamefile_struct., gamefilepointer, sizeof(gamefilecxx . . $ gamefile#)); |
| 257 | |
| 258 | strcpy(gamefilepage->gamefile_structcxx . . $ mngs_gamefile_page#gamefile_struct..namecxx . . $ gamefile#name., gamefilepointer->namecxx . . $ gamefile#name.); |
| 259 | strcpy(gamefilepage->gamefile_structcxx . . $ mngs_gamefile_page#gamefile_struct..dir_namecxx . . $ gamefile#dir_name., gamefilepointer->dir_namecxx . . $ gamefile#dir_name.); |
| 260 | } |
| 261 | |
| 262 | // Loads a gamefile found in the net table file. It then allocs a gamefile and |
| 263 | // then calls SetAndLoadGamefile to actually load in any images/models associated |
| 264 | // with it |
| 265 | void mng_LoadNetGamefilePagecxx . . $ mng_LoadNetGamefilePage(5a5441f2f69caf20).(CFILEcxx . . $ CFILE# *infile, bool overlay) { |
| 266 | mngs_gamefile_pagecxx . . $ mngs_gamefile_page# gamefilepage; |
| 267 | memset(&gamefilepage, 0, sizeof(mngs_gamefile_pagecxx . . $ mngs_gamefile_page#)); |
| 268 | |
| 269 | if (mng_ReadNewGamefilePagecxx . . $ mng_ReadNewGamefilePage(6ed3275c23aad507).(infile, &gamefilepage)) { |
| 270 | int n = FindGamefileNamecxx . . $ FindGamefileName(1ef8e6ec083aabb9).(gamefilepage.gamefile_structcxx . . $ mngs_gamefile_page#gamefile_struct..namecxx . . $ gamefile#name.); |
| 271 | if (n != -1) { |
| 272 | if (overlay) { |
| 273 | mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "OVERLAYING GAMEFILE %s\n", gamefilepage.gamefile_struct.name); |
| 274 | mng_FreePagetypePrimitivescxx . . $ mng_FreePagetypePrimitives(99469d7ff9a1485a).(PAGETYPE_GAMEFILEcxx . . $ `lib/manage.h:57:9`!, gamefilepage.gamefile_structcxx . . $ mngs_gamefile_page#gamefile_struct..namecxx . . $ gamefile#name., 0); |
| 275 | mng_AssignGamefilePageToGamefilecxx . . $ mng_AssignGamefilePageToGamefile(4651a8dff5775915).(&gamefilepage, n); |
| 276 | } |
| 277 | return; |
| 278 | } |
| 279 | |
| 280 | int ret = mng_SetAndLoadGamefilecxx . . $ mng_SetAndLoadGamefile(12f0a87f6c47ae40).(&gamefilepage); |
| 281 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(ret >= 0); |
| 282 | } else |
| 283 | mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Could not load gamefilepage named %s!\n", gamefilepage.gamefile_struct.name); |
| 284 | } |
| 285 | |
| 286 | // Reads a gamefile page from a local table file. It then allocs a gamefile and |
| 287 | // loads any images/models associated with that gamefile |
| 288 | void mng_LoadLocalGamefilePagecxx . . $ mng_LoadLocalGamefilePage(3639e799710acb68).(CFILEcxx . . $ CFILE# *infile) { |
| 289 | mngs_gamefile_pagecxx . . $ mngs_gamefile_page# gamefilepage; |
| 290 | int ok = 0; |
| 291 | memset(&gamefilepage, 0, sizeof(mngs_gamefile_pagecxx . . $ mngs_gamefile_page#)); |
| 292 | |
| 293 | if (mng_ReadNewGamefilePagecxx . . $ mng_ReadNewGamefilePage(6ed3275c23aad507).(infile, &gamefilepage)) { |
| 294 | // Check to see if this is a local copy that is supposed |
| 295 | // to go over a network copy (supersede the net copy) |
| 296 | |
| 297 | int i = FindGamefileNamecxx . . $ FindGamefileName(1ef8e6ec083aabb9).(gamefilepage.gamefile_structcxx . . $ mngs_gamefile_page#gamefile_struct..namecxx . . $ gamefile#name.); |
| 298 | if (i != -1) { |
| 299 | // Make sure we really have this page checked out |
| 300 | mngs_Pagelockcxx . . $ mngs_Pagelock# pl; |
| 301 | |
| 302 | strcpy(pl.namecxx . . $ mngs_Pagelock#name., gamefilepage.gamefile_structcxx . . $ mngs_gamefile_page#gamefile_struct..namecxx . . $ gamefile#name.); |
| 303 | pl.pagetypecxx . . $ mngs_Pagelock#pagetype. = PAGETYPE_GAMEFILEcxx . . $ `lib/manage.h:57:9`!; |
| 304 | |
| 305 | /*if (Network_up && Stand_alone==0) |
| 306 | { |
| 307 | int locked=mng_CheckIfPageOwned(&pl,TableUser); |
| 308 | if (locked!=1) |
| 309 | Int3(); // Your local vs net copies of the lock file do not match |
| 310 | }*/ |
| 311 | |
| 312 | ok = 1; |
| 313 | bool need_to_load_page = true; |
| 314 | |
| 315 | if (Loading_addon_tablecxx . . $ Loading_addon_table. != -1) { |
| 316 | AddOnTablefilecxx . . $ AddOnTablefile# *addon; |
| 317 | int tidx; |
| 318 | |
| 319 | // see if we really need to load this page |
| 320 | // check to see if we already have loaded this page (because it was |
| 321 | // a dependancy of another) |
| 322 | addon = &AddOnDataTablescxx . . $ AddOnDataTables.[Loading_addon_tablecxx . . $ Loading_addon_table.]; |
| 323 | for (tidx = 0; tidx < addon->Num_addon_tracklockscxx . . $ AddOnTablefile#Num_addon_tracklocks.; tidx++) { |
| 324 | if (addon->Addon_tracklockscxx . . $ AddOnTablefile#Addon_tracklocks.[tidx].pagetypecxx . . $ mngs_track_lock#pagetype. == PAGETYPE_GAMEFILEcxx . . $ `lib/manage.h:57:9`! && |
| 325 | !stricmpcxx . . $ `linux/linux_fix.h:43:9`!(addon->Addon_tracklocks[tidx].name, gamefilepage.gamefile_struct.name)) { |
| 326 | // found it!! |
| 327 | mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "GamefilePage: %s previously loaded\n", gamefilepage.gamefile_struct.name); |
| 328 | need_to_load_page = false; |
| 329 | break; |
| 330 | } |
| 331 | } |
| 332 | } |
| 333 | |
| 334 | if (need_to_load_page) { |
| 335 | mng_FreePagetypePrimitivescxx . . $ mng_FreePagetypePrimitives(99469d7ff9a1485a).(PAGETYPE_GAMEFILEcxx . . $ `lib/manage.h:57:9`!, gamefilepage.gamefile_structcxx . . $ mngs_gamefile_page#gamefile_struct..namecxx . . $ gamefile#name., 0); |
| 336 | mng_AssignGamefilePageToGamefilecxx . . $ mng_AssignGamefilePageToGamefile(4651a8dff5775915).(&gamefilepage, i); |
| 337 | |
| 338 | // For addon data |
| 339 | if (Loading_addon_tablecxx . . $ Loading_addon_table. != -1) { |
| 340 | // this is an overlay of some sort..see which we are overlaying |
| 341 | int overlay = 1; |
| 342 | int addidx, tidx; |
| 343 | bool found = false; |
| 344 | for (addidx = Num_addon_tablescxx . . $ Num_addon_tables. - 1; addidx >= 0; addidx--) { |
| 345 | if (addidx == Loading_addon_tablecxx . . $ Loading_addon_table.) |
| 346 | continue; |
| 347 | AddOnTablefilecxx . . $ AddOnTablefile# *addon = &AddOnDataTablescxx . . $ AddOnDataTables.[addidx]; |
| 348 | |
| 349 | // look for the page in this table file |
| 350 | for (tidx = 0; tidx < addon->Num_addon_tracklockscxx . . $ AddOnTablefile#Num_addon_tracklocks.; tidx++) { |
| 351 | if (addon->Addon_tracklockscxx . . $ AddOnTablefile#Addon_tracklocks.[tidx].pagetypecxx . . $ mngs_track_lock#pagetype. == PAGETYPE_GAMEFILEcxx . . $ `lib/manage.h:57:9`! && |
| 352 | !stricmpcxx . . $ `linux/linux_fix.h:43:9`!(addon->Addon_tracklocks[tidx].name, gamefilepage.gamefile_struct.name)) { |
| 353 | // found it!! |
| 354 | found = true; |
| 355 | overlay = addidx + 2; |
| 356 | break; |
| 357 | } |
| 358 | } |
| 359 | |
| 360 | if (found) |
| 361 | break; |
| 362 | } |
| 363 | |
| 364 | mng_PushAddonPagecxx . . $ mng_PushAddonPage(99469d7ff9a1485a).(PAGETYPE_GAMEFILEcxx . . $ `lib/manage.h:57:9`!, gamefilepage.gamefile_structcxx . . $ mngs_gamefile_page#gamefile_struct..namecxx . . $ gamefile#name., overlay); |
| 365 | } |
| 366 | } |
| 367 | } else { |
| 368 | // This is a local gamefile that has never been checked in |
| 369 | if (mng_SetAndLoadGamefilecxx . . $ mng_SetAndLoadGamefile(12f0a87f6c47ae40).(&gamefilepage) < 0) |
| 370 | ok = 0; |
| 371 | else |
| 372 | ok = 1; |
| 373 | |
| 374 | // For addon data |
| 375 | if (ok && Loading_addon_tablecxx . . $ Loading_addon_table. != -1) |
| 376 | mng_PushAddonPagecxx . . $ mng_PushAddonPage(99469d7ff9a1485a).(PAGETYPE_GAMEFILEcxx . . $ `lib/manage.h:57:9`!, gamefilepage.gamefile_structcxx . . $ mngs_gamefile_page#gamefile_struct..namecxx . . $ gamefile#name., 0); |
| 377 | } |
| 378 | |
| 379 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(ok == 1); // There was problem loading a page! |
| 380 | |
| 381 | if (Loading_addon_tablecxx . . $ Loading_addon_table. == -1) |
| 382 | mng_AllocTrackLockcxx . . $ mng_AllocTrackLock(6abd07ddb1a912f0).(gamefilepage.gamefile_structcxx . . $ mngs_gamefile_page#gamefile_struct..namecxx . . $ gamefile#name., PAGETYPE_GAMEFILEcxx . . $ `lib/manage.h:57:9`!); |
| 383 | |
| 384 | } else |
| 385 | mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Could not load gamefilepage named %s!\n", gamefilepage.gamefile_struct.name); |
| 386 | } |