| 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/mission_download.cpp $ |
| 21 | * $Revision: 29 $ |
| 22 | * $Date: 10/21/01 6:34p $ |
| 23 | * $Author: Kevin $ |
| 24 | * |
| 25 | * Mission file downloading system |
| 26 | * |
| 27 | * |
| 28 | * $Log: /DescentIII/Main/mission_download.cpp $ |
| 29 | * |
| 30 | * 29 10/21/01 6:34p Kevin |
| 31 | * minor fix to prevent a buffer overflow (not a reported bug, just |
| 32 | * something I noticed and thought was a good idea to avoid). |
| 33 | * |
| 34 | * 28 8/29/01 4:04p Matt |
| 35 | * Changed download directory from pxo.net to outrage.com |
| 36 | * |
| 37 | * 27 4/28/00 6:48p Jeff |
| 38 | * created _strlwr for linux |
| 39 | * |
| 40 | * 26 4/19/00 5:18p Matt |
| 41 | * From Duane for 1.4 |
| 42 | * ifdef-out mod download code for Mac |
| 43 | * |
| 44 | * 25 3/26/00 10:29p Kevin |
| 45 | * MOD Downloader for 1.4 patch. |
| 46 | * |
| 47 | * 24 11/04/99 12:35a Chris |
| 48 | * Added support for Merc |
| 49 | * |
| 50 | * 23 10/22/99 1:36p Matt |
| 51 | * Mac merge |
| 52 | * |
| 53 | * 22 10/18/99 1:27p Kevin |
| 54 | * Added cf_IsFileInHog |
| 55 | * |
| 56 | * 21 8/23/99 5:12p Kevin |
| 57 | * Proxy support |
| 58 | * |
| 59 | * 20 8/15/99 8:07p Jeff |
| 60 | * display interface when extracting files from a zip |
| 61 | * |
| 62 | * 19 8/15/99 4:27p Kevin |
| 63 | * possibly fixed mission download bug |
| 64 | * |
| 65 | * 18 8/13/99 8:00p Jeff |
| 66 | * handle zip files with new unzip class |
| 67 | * |
| 68 | * 17 7/21/99 3:48p Kevin |
| 69 | * changed left border. |
| 70 | * |
| 71 | * 16 5/18/99 10:31p Kevin |
| 72 | * fixed problem with joining d3.mn3 games and using the minimum install |
| 73 | * level |
| 74 | * |
| 75 | * 15 4/23/99 6:02p Kevin |
| 76 | * fixed bug when you can't download a mission |
| 77 | * |
| 78 | * 14 4/14/99 3:56a Jeff |
| 79 | * fixed case mismatch in #includes |
| 80 | * |
| 81 | * 13 4/07/99 9:38a Kevin |
| 82 | * Fixed bug when there were no URLs in the mission file |
| 83 | * |
| 84 | * 12 4/03/99 9:26p Jeff |
| 85 | * changed dialogs that weren't using UID_OK and UID_CANCEL to use and |
| 86 | * handle them properly |
| 87 | * |
| 88 | * 11 3/23/99 8:57a Kevin |
| 89 | * Fixed a bug if the user hits cancel |
| 90 | * |
| 91 | * 10 3/03/99 2:32p Kevin |
| 92 | * |
| 93 | * 9 3/03/99 12:33a Kevin |
| 94 | * Minor OEM changes |
| 95 | * |
| 96 | * 8 2/07/99 1:17a Jeff |
| 97 | * peppered UI dialogs that were missing NEWUIRES_FORCEQUIT to handle it |
| 98 | * |
| 99 | * 7 2/03/99 4:20p Kevin |
| 100 | * Got multiplayer working with .mn3 files, and setup autodownloading |
| 101 | * |
| 102 | * 6 1/29/99 5:22p Jeff |
| 103 | * localization |
| 104 | * |
| 105 | * 5 12/30/98 12:42p Kevin |
| 106 | * Mission downloading localization |
| 107 | * |
| 108 | * 4 12/30/98 12:19p Kevin |
| 109 | * |
| 110 | * 3 12/30/98 12:15p Kevin |
| 111 | * Auto Mission Download system |
| 112 | * |
| 113 | * 2 12/28/98 2:22p Kevin |
| 114 | * Initial mission downloading system |
| 115 | * |
| 116 | * 1 12/28/98 11:42a Kevin |
| 117 | * |
| 118 | * |
| 119 | */ |
| 120 | |
| 121 | #include <stdio.h> |
| 122 | |
| 123 | #include "pstypes.h"cxx . . $ `<file>/lib/pstypes.h`/ |
| 124 | #include "mem.h"cxx . . $ `<file>/mem/mem.h`/ |
| 125 | #include "args.h"cxx . . $ `<file>/Descent3/args.h`/ |
| 126 | #include "descent.h"cxx . . $ `<file>/Descent3/descent.h`/ |
| 127 | #include "networking.h"cxx . . $ `<file>/lib/networking.h`/ |
| 128 | #include "multi.h"cxx . . $ `<file>/Descent3/multi.h`/ |
| 129 | #include "ui.h"cxx . . $ `<file>/ui/ui.h`/ |
| 130 | #include "newui.h"cxx . . $ `<file>/Descent3/newui.h`/ |
| 131 | #include "ddio.h"cxx . . $ `<file>/ddio/ddio.h`/ |
| 132 | #include "stringtable.h"cxx . . $ `<file>/Descent3/stringtable.h`/ |
| 133 | #include "multi_dll_mgr.h"cxx . . $ `<file>/Descent3/multi_dll_mgr.h`/ |
| 134 | // #include "inetgetfile.h" |
| 135 | #include "grtext.h"cxx . . $ `<file>/grtext/grtext.h`/ |
| 136 | #include "Mission.h"cxx . . $ `<file>/Descent3/Mission.h`/ |
| 137 | #include "mission_download.h"cxx . . $ `<file>/Descent3/mission_download.h`/ |
| 138 | #include "renderer.h"cxx . . $ `<file>/lib/renderer.h`/ |
| 139 | |
| 140 | #include "unzip.h"cxx . . $ `<file>/unzip/unzip.h`/ |
| 141 | |
| 142 | int Got_urlcxx . . $ Got_url.; |
| 143 | msn_urlscxx . . $ msn_urls# msn_URLcxx . . $ msn_URL. = {"", {"", "", "", "", ""}}; |
| 144 | msn_urlscxx . . $ msn_urls# Net_msn_URLscxx . . $ Net_msn_URLs.; |
| 145 | |
| 146 | extern char Proxy_servercxx . . $ Proxy_server.[200]; |
| 147 | extern int16_t Proxy_portcxx . . $ Proxy_port.; |
| 148 | |
| 149 | int msn_ExtractZipFilecxx . . $ msn_ExtractZipFile(e99f026884c896d5).(char *zipfilename, char *mn3name); |
| 150 | |
| 151 | // Request a URL structure from a server containing a list of download locations |
| 152 | // For the current mission being played |
| 153 | msn_urlscxx . . $ msn_urls# *msn_GetURLcxx . . $ msn_GetURL(c097198ad337281a).(network_addresscxx . . $ network_address# *net_addr) { |
| 154 | |
| 155 | int count = 0; |
| 156 | int size; |
| 157 | int tries = 0; |
| 158 | uint8_tcxx . . $ uint8_t# data[MAX_GAME_DATA_SIZEcxx . . $ `Descent3/multi_external.h:134:9`!]; |
| 159 | float start_time; |
| 160 | network_addresscxx . . $ network_address# from_addr; |
| 161 | |
| 162 | size = START_DATAcxx . . $ START_DATA(8c36ee1faa9e0a0b).(MP_ASK_FOR_URLcxx . . $ `Descent3/multi.h:621:9`!, data, &count); |
| 163 | END_DATAcxx . . $ END_DATA(dde21517a502ab05).(count, data, size); |
| 164 | |
| 165 | Got_urlcxx . . $ Got_url. = -1; |
| 166 | |
| 167 | while (tries < 5 && Got_urlcxx . . $ Got_url. == -1) { |
| 168 | // Send the request |
| 169 | ASSERTcxx . . $ `misc/pserror.h:246:9`!(size > 0); |
| 170 | nw_Sendcxx . . $ nw_Send(102d2f582237fe86).(net_addr, data, count, 0); |
| 171 | tries++; |
| 172 | |
| 173 | start_time = timer_GetTimecxx . . $ `ddio/ddio.h:236:9`!(); |
| 174 | while ((timer_GetTimecxx . . $ `ddio/ddio.h:236:9`!() - start_time < URL_ASK_POLL_TIMEcxx . . $ `Descent3/mission_download.h:50:9`!) && Got_urlcxx . . $ Got_url. == -1) { |
| 175 | int packsize; |
| 176 | while (((packsize = nw_Receivecxx . . $ nw_Receive(4faaf8d0141e84f4).(Multi_receive_buffercxx . . $ Multi_receive_buffer., &from_addr)) > 0) && Got_urlcxx . . $ Got_url. == -1) { |
| 177 | MultiProcessBigDatacxx . . $ MultiProcessBigData(c3263a6d42f31e8c).(Multi_receive_buffercxx . . $ Multi_receive_buffer., packsize, &from_addr); |
| 178 | } |
| 179 | } |
| 180 | } |
| 181 | |
| 182 | if (tries >= 5 || Got_urlcxx . . $ Got_url. != 1) |
| 183 | return NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 184 | |
| 185 | return &msn_URLcxx . . $ msn_URL.; |
| 186 | } |
| 187 | |
| 188 | // Get the list of URLs in the msn file |
| 189 | msn_urlscxx . . $ msn_urls# *msn_GetURLcxx . . $ msn_GetURL(86aa1e18fac6a05c).(char *msnfile) { |
| 190 | // static msn_urls url; |
| 191 | // strcpy(url.msnname,msnfile); |
| 192 | return &Net_msn_URLscxx . . $ Net_msn_URLs.; |
| 193 | } |
| 194 | |
| 195 | #define MSN_DWNLD_CHOICE_Hcxx . . $ `Descent3/mission_download.cpp:195:9`! 256 |
| 196 | #define MSN_DWNLD_CHOICE_Wcxx . . $ `Descent3/mission_download.cpp:196:9`! 512 |
| 197 | |
| 198 | // Present the user with a list of URLs to download from. Return the 0 based selection, or -1 if cancel is hit. |
| 199 | int msn_ShowDownloadChoicescxx . . $ msn_ShowDownloadChoices(276ae1968d51ebb).(msn_urlscxx . . $ msn_urls# *urls) { |
| 200 | UITextItemcxx . . $ UITextItem# title_textcxx . . $ UITextItem#UITextItem(5f8aa4f2725849c4).(TXT_DOWNLOADPROMPTcxx . . $ `Descent3/stringtable.h:445:9`!, UICOL_WINDOW_TITLEcxx . . $ `Descent3/newui.h:219:9`!); |
| 201 | UITextItemcxx . . $ UITextItem# title1_textcxx . . $ UITextItem#UITextItem(5f8aa4f2725849c4).(TXT_DONTHAVEMSNcxx . . $ `Descent3/stringtable.h:446:9`!, UICOL_WINDOW_TITLEcxx . . $ `Descent3/newui.h:219:9`!); |
| 202 | UITextItemcxx . . $ UITextItem# header_textcxx . . $ UITextItem#UITextItem(5f8aa4f2725849c4).(TXT_DOWNLOADMSNcxx . . $ `Descent3/stringtable.h:447:9`!, UICOL_TEXT_NORMALcxx . . $ `Descent3/newui.h:218:9`!); |
| 203 | UIHotspotcxx . . $ UIHotspot# ok_hotcxx . . $ UIHotspot#UIHotspot(49f6e7a06ebc5aa8).; |
| 204 | UIHotspotcxx . . $ UIHotspot# cancel_hotcxx . . $ UIHotspot#UIHotspot(49f6e7a06ebc5aa8).; |
| 205 | NewUIListBoxcxx . . $ NewUIListBox# choices_list; |
| 206 | |
| 207 | NewUIGameWindowcxx . . $ NewUIGameWindow# menu_wndcxx . . $ NewUIGameWindow#NewUIGameWindow(49f6e7a06ebc5aa8).; |
| 208 | |
| 209 | UITextcxx . . $ UIText# texts[10]; |
| 210 | |
| 211 | int exit_menu = 0; |
| 212 | int ret = 0; |
| 213 | |
| 214 | menu_wnd.Createcxx . . $ NewUIGameWindow#Create(1559a299834bcdd5).(10, 10, MSN_DWNLD_CHOICE_Wcxx . . $ `Descent3/mission_download.cpp:196:9`!, MSN_DWNLD_CHOICE_Hcxx . . $ `Descent3/mission_download.cpp:195:9`!, UIF_PROCESS_ALLcxx . . $ `ui/ui.h:348:9`! | UIF_CENTERcxx . . $ `ui/ui.h:342:9`!); |
| 215 | texts[0].Createcxx . . $ UIText#Create(c90f152919fa414d).(&menu_wnd, &header_text, 0, 8, UIF_CENTERcxx . . $ `ui/ui.h:342:9`!); |
| 216 | texts[1].Createcxx . . $ UIText#Create(c90f152919fa414d).(&menu_wnd, &title_text, 0, 55, UIF_CENTERcxx . . $ `ui/ui.h:342:9`!); |
| 217 | texts[2].Createcxx . . $ UIText#Create(c90f152919fa414d).(&menu_wnd, &title1_text, 0, 35, UIF_CENTERcxx . . $ `ui/ui.h:342:9`!); |
| 218 | |
| 219 | UITextItemcxx . . $ UITextItem# ok_offcxx . . $ UITextItem#UITextItem(5f8aa4f2725849c4).(TXT_OKcxx . . $ `Descent3/stringtable.h:34:9`!, UICOL_HOTSPOT_LOcxx . . $ `Descent3/newui.h:214:9`!, UIALPHA_HOTSPOT_LOcxx . . $ `Descent3/newui.h:225:9`!); |
| 220 | UITextItemcxx . . $ UITextItem# ok_oncxx . . $ UITextItem#UITextItem(5f8aa4f2725849c4).(TXT_OKcxx . . $ `Descent3/stringtable.h:34:9`!, UICOL_HOTSPOT_HIcxx . . $ `Descent3/newui.h:217:9`!, UIALPHA_HOTSPOT_HIcxx . . $ `Descent3/newui.h:226:9`!); |
| 221 | UITextItemcxx . . $ UITextItem# cancel_offcxx . . $ UITextItem#UITextItem(5f8aa4f2725849c4).(TXT_CANCELcxx . . $ `Descent3/stringtable.h:35:9`!, UICOL_HOTSPOT_LOcxx . . $ `Descent3/newui.h:214:9`!, UIALPHA_HOTSPOT_LOcxx . . $ `Descent3/newui.h:225:9`!); |
| 222 | UITextItemcxx . . $ UITextItem# cancel_oncxx . . $ UITextItem#UITextItem(5f8aa4f2725849c4).(TXT_CANCELcxx . . $ `Descent3/stringtable.h:35:9`!, UICOL_HOTSPOT_HIcxx . . $ `Descent3/newui.h:217:9`!, UIALPHA_HOTSPOT_HIcxx . . $ `Descent3/newui.h:226:9`!); |
| 223 | |
| 224 | int ok_x, cancel_x; |
| 225 | GetCenteredTextPoscxx . . $ GetCenteredTextPos(fb34de7af53046bd).(menu_wnd.Wcxx . . $ UIObject#W(455f465bc33b4cdf).(), 20, ok_on.widthcxx . . $ UITextItem#width(b126dc7c1de90089).(), cancel_on.widthcxx . . $ UITextItem#width(b126dc7c1de90089).(), &ok_x, &cancel_x); |
| 226 | |
| 227 | ok_hot.Createcxx . . $ UIHotspot#Create(ee4237d76742fc72).(&menu_wnd, UID_OKcxx . . $ `ui/ui.h:368:9`!, KEY_ENTERcxx . . $ `ddio/ddio_common.h:268:9`!, &ok_off, &ok_on, ok_x, MSN_DWNLD_CHOICE_Hcxx . . $ `Descent3/mission_download.cpp:195:9`! - OKCANCEL_YOFFSETcxx . . $ `Descent3/newui.h:250:9`!, 0, 0, |
| 228 | UIF_FITcxx . . $ `ui/ui.h:343:9`!); |
| 229 | cancel_hot.Createcxx . . $ UIHotspot#Create(ee4237d76742fc72).(&menu_wnd, UID_CANCELcxx . . $ `ui/ui.h:369:9`!, KEY_ESCcxx . . $ `ddio/ddio_common.h:267:9`!, &cancel_off, &cancel_on, cancel_x, |
| 230 | MSN_DWNLD_CHOICE_Hcxx . . $ `Descent3/mission_download.cpp:195:9`! - OKCANCEL_YOFFSETcxx . . $ `Descent3/newui.h:250:9`!, 0, 0, UIF_FITcxx . . $ `ui/ui.h:343:9`!); |
| 231 | |
| 232 | choices_list.Createcxx . . $ NewUIListBox#Create(43707b8add2f137d).(&menu_wnd, 1, 0, 70, 480, 128, UIF_CENTERcxx . . $ `ui/ui.h:342:9`! | UILB_NOSORTcxx . . $ `ui/ui.h:356:9`!); |
| 233 | choices_list.SetSelectedColorcxx . . $ UIListBox#SetSelectedColor(cb2f890c2fdad230).(UICOL_LISTBOX_HIcxx . . $ `Descent3/newui.h:222:9`!); |
| 234 | choices_list.SetHiliteColorcxx . . $ UIListBox#SetHiliteColor(cb2f890c2fdad230).(UICOL_LISTBOX_HIcxx . . $ `Descent3/newui.h:222:9`!); |
| 235 | choices_list.RemoveAllcxx . . $ UIListBox#RemoveAll(49f6e7a06ebc5aa8).(); |
| 236 | |
| 237 | UITextItemcxx . . $ UITextItem# urlticxx . . $ UITextItem#UITextItem(49f6e7a06ebc5aa8).[MAX_MISSION_URL_COUNTcxx . . $ `Descent3/mission_download.h:48:9`!]; |
| 238 | // urls |
| 239 | int i; |
| 240 | int urlcount = 0; |
| 241 | for (i = 0; i < MAX_MISSION_URL_COUNTcxx . . $ `Descent3/mission_download.h:48:9`!; i++) { |
| 242 | if (urls->URLcxx . . $ msn_urls#URL.[i][0]) { |
| 243 | urlti[i] =cxx . . $ UITextItem#`operator=`(5ad635489e71ed3b). UITextItemcxx . . $ UITextItem#UITextItem(5f8aa4f2725849c4).(urls->URLcxx . . $ msn_urls#URL.[i], UICOL_LISTBOX_LOcxx . . $ `Descent3/newui.h:221:9`!); |
| 244 | choices_list.AddItemcxx . . $ UIListBox#AddItem(f57aa2fef0df48a8).(&urlti[i]); |
| 245 | urlcount++; |
| 246 | } |
| 247 | } |
| 248 | if (urlcount == 0) { |
| 249 | // Message that the mission can't be downloaded |
| 250 | DoMessageBoxcxx . . $ DoMessageBox(dcc99837539e9edc).(TXT_ERRORcxx . . $ `Descent3/stringtable.h:165:9`!, TXT_FMTCANTDNLDcxx . . $ `Descent3/stringtable.h:454:9`!, MSGBOX_OKcxx . . $ `Descent3/newui_core.h:78:9`!); |
| 251 | menu_wnd.Destroycxx . . $ UIWindow#Destroy(49f6e7a06ebc5aa8).(); |
| 252 | return -1; |
| 253 | } |
| 254 | menu_wnd.Opencxx . . $ UIWindow#Open(49f6e7a06ebc5aa8).(); |
| 255 | |
| 256 | while (!exit_menu) { |
| 257 | int res; |
| 258 | |
| 259 | res = DoUIcxx . . $ DoUI(b126dc7c1de90089).(); |
| 260 | switch (res) { |
| 261 | case NEWUIRES_FORCEQUITcxx . . $ `Descent3/newui_core.h:131:9`!: |
| 262 | case UID_CANCELcxx . . $ `ui/ui.h:369:9`!: |
| 263 | ret = -1; |
| 264 | menu_wnd.Closecxx . . $ UIWindow#Close(49f6e7a06ebc5aa8).(); |
| 265 | exit_menu = 1; |
| 266 | break; |
| 267 | case UID_OKcxx . . $ `ui/ui.h:368:9`!: |
| 268 | ret = choices_list.GetSelectedIndexcxx . . $ UIListBox#GetSelectedIndex(455f465bc33b4cdf).(); |
| 269 | menu_wnd.Closecxx . . $ UIWindow#Close(49f6e7a06ebc5aa8).(); |
| 270 | exit_menu = 1; |
| 271 | break; |
| 272 | } |
| 273 | } |
| 274 | menu_wnd.Destroycxx . . $ UIWindow#Destroy(49f6e7a06ebc5aa8).(); |
| 275 | return ret; |
| 276 | } |
| 277 | |
| 278 | #define MSN_REFRESH_INTERVALcxx . . $ `Descent3/mission_download.cpp:278:9`! .5 |
| 279 | |
| 280 | #define MSN_DWNLD_STATUS_Hcxx . . $ `Descent3/mission_download.cpp:280:9`! 256 |
| 281 | #define MSN_DWNLD_STATUS_Wcxx . . $ `Descent3/mission_download.cpp:281:9`! 512 |
| 282 | |
| 283 | #define MSN_BORDER_Wcxx . . $ `Descent3/mission_download.cpp:283:9`! 30 |
| 284 | #define MSN_BORDER_Hcxx . . $ `Descent3/mission_download.cpp:284:9`! 40 |
| 285 | |
| 286 | #define MSN_COL_1cxx . . $ `Descent3/mission_download.cpp:286:9`! MSN_BORDER_W |
| 287 | #define MSN_COL_2cxx . . $ `Descent3/mission_download.cpp:287:9`! ((MSN_DWNLD_STATUS_W / 2) + (MSN_BORDER_W / 2)) |
| 288 | |
| 289 | #define MSN_ROW_1cxx . . $ `Descent3/mission_download.cpp:289:9`! MSN_BORDER_H |
| 290 | #define MSN_ROW_2cxx . . $ `Descent3/mission_download.cpp:290:9`! (MSN_BORDER_H + 30) |
| 291 | #define MSN_ROW_3cxx . . $ `Descent3/mission_download.cpp:291:9`! (MSN_BORDER_H + 60) |
| 292 | #define MSN_ROW_4cxx . . $ `Descent3/mission_download.cpp:292:9`! (MSN_BORDER_H + 90) |
| 293 | #define MSN_ROW_5cxx . . $ `Descent3/mission_download.cpp:293:9`! (MSN_BORDER_H + 120) |
| 294 | |
| 295 | #define DOWNLOAD_STATUS_URL_TEXTcxx . . $ `Descent3/mission_download.cpp:295:9`! TXT_FMTDOWNLOADING |
| 296 | #define DOWNLOAD_STATUS_RCVD_TEXTcxx . . $ `Descent3/mission_download.cpp:296:9`! TXT_FMTRECEIVED |
| 297 | #define DOWNLOAD_STATUS_TOTAL_TEXTcxx . . $ `Descent3/mission_download.cpp:297:9`! TXT_FMTTOTAL |
| 298 | #define DOWNLOAD_STATUS_ELAPS_TEXTcxx . . $ `Descent3/mission_download.cpp:298:9`! TXT_FMTTIMEELAPSED |
| 299 | #define DOWNLOAD_STATUS_TIME_R_TEXTcxx . . $ `Descent3/mission_download.cpp:299:9`! TXT_FMTTIMELEFT |
| 300 | #define DOWNLOAD_STATUS_XFERRATE_TEXTcxx . . $ `Descent3/mission_download.cpp:300:9`! TXT_FMTXFERRATE |
| 301 | |
| 302 | #define MSN_MAX_STRING_LENcxx . . $ `Descent3/mission_download.cpp:302:9`! 100 |
| 303 | |
| 304 | // Start downloading the file at the url specifies, showing a status screen |
| 305 | // Return codes: |
| 306 | // 0 Failed or cancelled |
| 307 | // 1 Success |
| 308 | int msn_DownloadWithStatuscxx . . $ msn_DownloadWithStatus(e99f026884c896d5).(char *url, char *filename) { |
| 309 | return 0; |
| 310 | /* |
| 311 | char qualfile[_MAX_PATH*2]; |
| 312 | float last_refresh; |
| 313 | int total_bytes = 0; |
| 314 | int received_bytes = 0; |
| 315 | int time_elapsed = 0; |
| 316 | int time_remain = 0; |
| 317 | int xfer_rate = 0; |
| 318 | int starttime = timer_GetTime(); |
| 319 | bool file_is_zip = false; |
| 320 | |
| 321 | //check to see if we are downloading a zip file |
| 322 | char *url_ptr; |
| 323 | url_ptr = url + strlen(url); |
| 324 | while(url_ptr > url && *url_ptr!='.') url_ptr--; |
| 325 | if(*url_ptr=='.') |
| 326 | { |
| 327 | //now see if the rest of the extension is ZIP |
| 328 | if(!stricmp(url_ptr,".ZIP")) |
| 329 | { |
| 330 | mprintf(0,"We're downloading a zip file!!!\n"); |
| 331 | file_is_zip = true; |
| 332 | } |
| 333 | } |
| 334 | |
| 335 | char fmturl[MSN_MAX_STRING_LEN]; |
| 336 | char fmtrcvd[MSN_MAX_STRING_LEN]; |
| 337 | char fmttotal[MSN_MAX_STRING_LEN]; |
| 338 | char fmtelaps[MSN_MAX_STRING_LEN]; |
| 339 | char fmttimer[MSN_MAX_STRING_LEN]; |
| 340 | char fmtrate[MSN_MAX_STRING_LEN]; |
| 341 | |
| 342 | sprintf(fmturl,DOWNLOAD_STATUS_URL_TEXT,url); |
| 343 | msn_ClipURLToWidth(MSN_DWNLD_STATUS_W-(MSN_COL_1+MSN_BORDER_W),fmturl); |
| 344 | sprintf(fmtrcvd,DOWNLOAD_STATUS_RCVD_TEXT,received_bytes); |
| 345 | sprintf(fmttotal,DOWNLOAD_STATUS_TOTAL_TEXT,total_bytes); |
| 346 | sprintf(fmtelaps,DOWNLOAD_STATUS_ELAPS_TEXT,msn_SecondsToString(time_elapsed)); |
| 347 | sprintf(fmttimer,DOWNLOAD_STATUS_TIME_R_TEXT,msn_SecondsToString(time_remain)); |
| 348 | sprintf(fmtrate,DOWNLOAD_STATUS_XFERRATE_TEXT,xfer_rate); |
| 349 | |
| 350 | if(file_is_zip) |
| 351 | { |
| 352 | char fname[_MAX_FNAME]; |
| 353 | char *s_ptr,*d_ptr; |
| 354 | s_ptr = filename; |
| 355 | d_ptr = fname; |
| 356 | while(*s_ptr && *s_ptr!='.'){ *d_ptr = *s_ptr; s_ptr++; d_ptr++;} |
| 357 | *d_ptr = '\0'; |
| 358 | strcat(fname,".zip"); |
| 359 | ddio_MakePath(qualfile,D3MissionsDir,fname,NULL); |
| 360 | }else |
| 361 | { |
| 362 | ddio_MakePath(qualfile,D3MissionsDir,filename,NULL); |
| 363 | } |
| 364 | InetGetFile *getmsnfile; |
| 365 | if(Proxy_server[0]) |
| 366 | { |
| 367 | getmsnfile = new InetGetFile(url,qualfile,Proxy_server,Proxy_port); |
| 368 | } |
| 369 | else |
| 370 | { |
| 371 | getmsnfile = new InetGetFile(url,qualfile); |
| 372 | } |
| 373 | |
| 374 | UITextItem title_text(TXT_MD_DOWNLOADSTATUS,UICOL_TEXT_NORMAL); |
| 375 | |
| 376 | UIHotspot cancel_hot; |
| 377 | |
| 378 | UITextItem download_text(fmturl,UICOL_TEXT_NORMAL);; |
| 379 | UITextItem rcvd_text(fmtrcvd,UICOL_TEXT_NORMAL); |
| 380 | UITextItem total_text(fmttotal,UICOL_TEXT_NORMAL); |
| 381 | UITextItem elaps_text(fmtelaps,UICOL_TEXT_NORMAL); |
| 382 | UITextItem time_r_text(fmttimer,UICOL_TEXT_NORMAL); |
| 383 | UITextItem rate_text(fmtrate,UICOL_TEXT_NORMAL); |
| 384 | |
| 385 | NewUIGameWindow menu_wnd; |
| 386 | |
| 387 | UIText texts[10]; |
| 388 | UIProgress progress; |
| 389 | |
| 390 | int exit_menu=0; |
| 391 | int ret=0; |
| 392 | |
| 393 | menu_wnd.Create(10,10,MSN_DWNLD_STATUS_W,MSN_DWNLD_STATUS_H,UIF_PROCESS_ALL | UIF_CENTER); |
| 394 | texts[0].Create (&menu_wnd,&title_text,0,8,UIF_CENTER); |
| 395 | texts[1].Create (&menu_wnd,&download_text,MSN_COL_1,MSN_ROW_1,0); |
| 396 | texts[2].Create (&menu_wnd,&rcvd_text,MSN_COL_1,MSN_ROW_2,0); |
| 397 | texts[3].Create (&menu_wnd,&total_text,MSN_COL_2,MSN_ROW_2,0); |
| 398 | texts[4].Create (&menu_wnd,&elaps_text,MSN_COL_1,MSN_ROW_3,0); |
| 399 | texts[5].Create (&menu_wnd,&time_r_text,MSN_COL_2,MSN_ROW_3,0); |
| 400 | texts[6].Create (&menu_wnd,&rate_text,MSN_COL_1,MSN_ROW_4,0); |
| 401 | |
| 402 | UITextItem cancel_off(TXT_CANCEL,UICOL_HOTSPOT_LO,UIALPHA_HOTSPOT_LO); |
| 403 | UITextItem cancel_on(TXT_CANCEL,UICOL_HOTSPOT_HI,UIALPHA_HOTSPOT_HI); |
| 404 | |
| 405 | progress.Create(&menu_wnd,MSN_COL_1,MSN_ROW_5,MSN_DWNLD_STATUS_W-(MSN_BORDER_W*2),35,0); |
| 406 | |
| 407 | int cancel_x = 0; |
| 408 | |
| 409 | cancel_hot.Create(&menu_wnd, UID_CANCEL, KEY_ESC, &cancel_off,&cancel_on, |
| 410 | cancel_x, MSN_DWNLD_STATUS_H - OKCANCEL_YOFFSET, |
| 411 | 0,0,UIF_FIT|UIF_CENTER); menu_wnd.Open(); |
| 412 | |
| 413 | last_refresh = timer_GetTime()-MSN_REFRESH_INTERVAL; |
| 414 | |
| 415 | while (!exit_menu) |
| 416 | { |
| 417 | int res; |
| 418 | |
| 419 | if((timer_GetTime()-last_refresh)>MSN_REFRESH_INTERVAL) |
| 420 | { |
| 421 | |
| 422 | //Update the dialog |
| 423 | //mprintf(0,"!"); |
| 424 | |
| 425 | if(getmsnfile->IsFileReceived()) |
| 426 | { |
| 427 | //File transfer successful! |
| 428 | mprintf(0,"Succesfully received the file!\n"); |
| 429 | exit_menu = 1; |
| 430 | |
| 431 | if(file_is_zip) |
| 432 | { |
| 433 | // now we gotta handle the zip file |
| 434 | ret = msn_ExtractZipFile(qualfile,filename); |
| 435 | }else |
| 436 | { |
| 437 | ret = 1; |
| 438 | } |
| 439 | } |
| 440 | |
| 441 | if(getmsnfile->IsFileError()) |
| 442 | { |
| 443 | //File transfer Error! |
| 444 | DoMessageBox(TXT_ERROR,TXT_FMTCANTDNLD,MSGBOX_OK); |
| 445 | //Delete the file that didn't finish! |
| 446 | ddio_DeleteFile(qualfile); |
| 447 | mprintf(0,"Couldn't download the file! Error: %d\n",getmsnfile->GetErrorCode()); |
| 448 | exit_menu = 1; |
| 449 | ret = 0; |
| 450 | } |
| 451 | |
| 452 | last_refresh = timer_GetTime(); |
| 453 | received_bytes = getmsnfile->GetBytesIn(); |
| 454 | total_bytes = getmsnfile->GetTotalBytes(); |
| 455 | |
| 456 | time_elapsed = timer_GetTime()-starttime; |
| 457 | |
| 458 | if(total_bytes) |
| 459 | { |
| 460 | time_remain = ((float)(total_bytes-received_bytes))/((float)(received_bytes/time_elapsed)); |
| 461 | } |
| 462 | if(time_elapsed&&received_bytes) |
| 463 | { |
| 464 | xfer_rate = ((float)(received_bytes/time_elapsed)); |
| 465 | } |
| 466 | texts[1].Destroy(); |
| 467 | texts[2].Destroy(); |
| 468 | texts[3].Destroy(); |
| 469 | texts[4].Destroy(); |
| 470 | texts[5].Destroy(); |
| 471 | texts[6].Destroy(); |
| 472 | |
| 473 | sprintf(fmturl,DOWNLOAD_STATUS_URL_TEXT,url); |
| 474 | msn_ClipURLToWidth(MSN_DWNLD_STATUS_W-(MSN_COL_1+MSN_BORDER_W),fmturl); |
| 475 | sprintf(fmtrcvd,DOWNLOAD_STATUS_RCVD_TEXT,received_bytes); |
| 476 | sprintf(fmttotal,DOWNLOAD_STATUS_TOTAL_TEXT,total_bytes); |
| 477 | sprintf(fmtelaps,DOWNLOAD_STATUS_ELAPS_TEXT,msn_SecondsToString(time_elapsed)); |
| 478 | sprintf(fmttimer,DOWNLOAD_STATUS_TIME_R_TEXT,msn_SecondsToString(time_remain)); |
| 479 | msn_ClipURLToWidth(MSN_DWNLD_STATUS_W-(MSN_COL_2+MSN_BORDER_W),fmttimer); |
| 480 | sprintf(fmtrate,DOWNLOAD_STATUS_XFERRATE_TEXT,xfer_rate); |
| 481 | |
| 482 | download_text = UITextItem (fmturl,UICOL_TEXT_NORMAL);; |
| 483 | rcvd_text = UITextItem (fmtrcvd,UICOL_TEXT_NORMAL); |
| 484 | total_text = UITextItem (fmttotal,UICOL_TEXT_NORMAL); |
| 485 | elaps_text = UITextItem (fmtelaps,UICOL_TEXT_NORMAL); |
| 486 | time_r_text = UITextItem (fmttimer,UICOL_TEXT_NORMAL); |
| 487 | rate_text = UITextItem (fmtrate,UICOL_TEXT_NORMAL); |
| 488 | |
| 489 | texts[1].Create (&menu_wnd,&download_text,MSN_COL_1,MSN_ROW_1,0); |
| 490 | texts[2].Create (&menu_wnd,&rcvd_text,MSN_COL_1,MSN_ROW_2,0); |
| 491 | texts[3].Create (&menu_wnd,&total_text,MSN_COL_2,MSN_ROW_2,0); |
| 492 | texts[4].Create (&menu_wnd,&elaps_text,MSN_COL_1,MSN_ROW_3,0); |
| 493 | texts[5].Create (&menu_wnd,&time_r_text,MSN_COL_2,MSN_ROW_3,0); |
| 494 | texts[6].Create (&menu_wnd,&rate_text,MSN_COL_1,MSN_ROW_4,0); |
| 495 | |
| 496 | progress.Update(((float)((float)received_bytes)/((float)total_bytes))); |
| 497 | //mprintf(0,"@"); |
| 498 | } |
| 499 | //mprintf(0,"-In"); |
| 500 | res = PollUI(); |
| 501 | //mprintf(0,"-Out"); |
| 502 | switch(res) |
| 503 | { |
| 504 | case UID_CANCEL: |
| 505 | getmsnfile->AbortGet(); |
| 506 | ddio_DeleteFile(qualfile); |
| 507 | exit_menu = 1; |
| 508 | ret = 0; |
| 509 | break; |
| 510 | } |
| 511 | } |
| 512 | menu_wnd.Close(); |
| 513 | menu_wnd.Destroy(); |
| 514 | delete getmsnfile; |
| 515 | return ret; |
| 516 | */ |
| 517 | } |
| 518 | |
| 519 | void msn_DoAskForURLcxx . . $ msn_DoAskForURL(b4ed6bda213be74).(uint8_tcxx . . $ uint8_t# *indata, network_addresscxx . . $ network_address# *net_addr) { |
| 520 | static msn_urlscxx . . $ msn_urls# *url; |
| 521 | int count = 0; |
| 522 | int size; |
| 523 | int i; |
| 524 | uint8_tcxx . . $ uint8_t# data[MAX_GAME_DATA_SIZEcxx . . $ `Descent3/multi_external.h:134:9`!]; |
| 525 | int num_urls = 0; |
| 526 | |
| 527 | if (Netgamecxx . . $ Netgame..local_rolecxx . . $ netgame_info#local_role. == LR_SERVERcxx . . $ `Descent3/multi_external.h:129:9`!) { |
| 528 | size = START_DATAcxx . . $ START_DATA(8c36ee1faa9e0a0b).(MP_CUR_MSN_URLScxx . . $ `Descent3/multi.h:622:9`!, data, &count); |
| 529 | |
| 530 | url = msn_GetURLcxx . . $ msn_GetURL(86aa1e18fac6a05c).(Netgamecxx . . $ Netgame..missioncxx . . $ netgame_info#mission.); |
| 531 | if (url) { |
| 532 | for (i = 0; i < MAX_MISSION_URL_COUNTcxx . . $ `Descent3/mission_download.h:48:9`!; i++) { |
| 533 | if (url->URLcxx . . $ msn_urls#URL.[0]) { |
| 534 | num_urls++; |
| 535 | } |
| 536 | } |
| 537 | } |
| 538 | // length of the msn |
| 539 | int msnlen = strlen(Netgamecxx . . $ Netgame..missioncxx . . $ netgame_info#mission.) + 1; |
| 540 | MultiAddBytecxx . . $ MultiAddByte(3bbe8835367eaa4e).(msnlen, data, &count); |
| 541 | // Copy the mission name |
| 542 | memcpy(data + count, url->URLcxx . . $ msn_urls#URL.[i], msnlen); |
| 543 | count += msnlen; |
| 544 | |
| 545 | // Silly copy protection. Don't download the mn3 if |
| 546 | //"clang.wav" is in it. |
| 547 | if (cf_IsFileInHogcxx . . $ cf_IsFileInHog(1b1fb50d0437e4a5).(Netgamecxx . . $ std/filesystem/__cxx11/path#path(835bc3a16b770d4d)..missioncxx . . $ netgame_info#mission., "clang.wav"cxx . . $ std/filesystem/__cxx11/path#path(835bc3a16b770d4d).)) { |
| 548 | num_urls = 0; |
| 549 | return; |
| 550 | } |
| 551 | |
| 552 | // Number of URLs |
| 553 | MultiAddBytecxx . . $ MultiAddByte(3bbe8835367eaa4e).(num_urls, data, &count); |
| 554 | for (i = 0; i < num_urls; i++) { |
| 555 | uint16_tcxx . . $ uint16_t# urllen = strlen(url->URLcxx . . $ msn_urls#URL.[i]) + 1; |
| 556 | if ((count + urllen) >= MAX_GAME_DATA_SIZEcxx . . $ `Descent3/multi_external.h:134:9`!) { |
| 557 | // if for some reason the URLS exceed what a packet can send |
| 558 | // rather than overflow the memory buffer, just don't send out the packet. |
| 559 | // I would just fit any URLS that I can but this is safer to put in a patch. |
| 560 | return; |
| 561 | } |
| 562 | |
| 563 | // Write the lenght of the url |
| 564 | MultiAddUshortcxx . . $ MultiAddUshort(309f537dbae2306e).(urllen, data, &count); |
| 565 | // Now write the url |
| 566 | memcpy(data + count, url->URLcxx . . $ msn_urls#URL.[i], urllen); |
| 567 | count += urllen; |
| 568 | } |
| 569 | END_DATAcxx . . $ END_DATA(dde21517a502ab05).(count, data, size); |
| 570 | nw_Sendcxx . . $ nw_Send(102d2f582237fe86).(net_addr, data, count, 0); |
| 571 | } |
| 572 | } |
| 573 | |
| 574 | void msn_DoCurrMsnURLscxx . . $ msn_DoCurrMsnURLs(b4ed6bda213be74).(uint8_tcxx . . $ uint8_t# *data, network_addresscxx . . $ network_address# *net_addr) { |
| 575 | int count = 0; |
| 576 | int num_urls = 0; |
| 577 | int i; |
| 578 | |
| 579 | memset(&msn_URLcxx . . $ msn_URL., 0, sizeof(msn_URLcxx . . $ msn_URL.)); |
| 580 | |
| 581 | SKIP_HEADERcxx . . $ SKIP_HEADER(849dbebf9185c2d3).(data, &count); |
| 582 | // Get the mission name |
| 583 | int msnlen = MultiGetBytecxx . . $ MultiGetByte(96e36f15bd3e0281).(data, &count); |
| 584 | memcpy(&msn_URLcxx . . $ msn_URL..msnnamecxx . . $ msn_urls#msnname., data + count, msnlen); |
| 585 | count += msnlen; |
| 586 | num_urls = MultiGetBytecxx . . $ MultiGetByte(96e36f15bd3e0281).(data, &count); |
| 587 | |
| 588 | for (i = 0; i < num_urls; i++) { |
| 589 | uint16_tcxx . . $ uint16_t# urllen = MultiGetUshortcxx . . $ MultiGetUshort(4574463662eb5370).(data, &count); |
| 590 | memcpy(msn_URLcxx . . $ msn_URL..URLcxx . . $ msn_urls#URL.[i], data + count, urllen); |
| 591 | count += urllen; |
| 592 | } |
| 593 | Got_urlcxx . . $ Got_url. = 1; |
| 594 | } |
| 595 | |
| 596 | // Check if a file exists. |
| 597 | // If it does, return true |
| 598 | // If it doesn't attempt to download it. On success return true |
| 599 | // Otherwise return false |
| 600 | int msn_CheckGetMissioncxx . . $ msn_CheckGetMission(aa7cc0aa9d631463).(network_addresscxx . . $ network_address# *net_addr, char *filename) { |
| 601 | #ifdef OEM |
| 602 | return 1; |
| 603 | #else |
| 604 | // Don't download local missions |
| 605 | char pathname[_MAX_PATHcxx . . $ `linux/linux_fix.h:34:9`!]; |
| 606 | ddio_MakePathcxx . . $ ddio_MakePath(9ad4b0815420a85).(pathname, D3MissionsDircxx . . $ D3MissionsDir., filename, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!); |
| 607 | if (cfexistcxx . . $ cfexist(293b0826c8d9cb54).(filenamecxx . . $ std/filesystem/__cxx11/path#path(835bc3a16b770d4d).) || cfexistcxx . . $ cfexist(293b0826c8d9cb54).(pathnamecxx . . $ std/filesystem/__cxx11/path#path(835bc3a16b770d4d).)) { |
| 608 | return 1; |
| 609 | } |
| 610 | |
| 611 | msn_urlscxx . . $ msn_urls# *murls; |
| 612 | |
| 613 | murls = msn_GetURLcxx . . $ msn_GetURL(c097198ad337281a).(net_addr); |
| 614 | if (murls) { |
| 615 | int sel = msn_ShowDownloadChoicescxx . . $ msn_ShowDownloadChoices(276ae1968d51ebb).(murls); |
| 616 | if (sel != -1) { |
| 617 | // Get the item that was selected! |
| 618 | mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Downloading missions file from %s\n", murls->URL[sel]); |
| 619 | if (msn_DownloadWithStatuscxx . . $ msn_DownloadWithStatus(e99f026884c896d5).(murls->URLcxx . . $ msn_urls#URL.[sel], filename)) { |
| 620 | return 1; |
| 621 | } |
| 622 | } |
| 623 | } else { |
| 624 | DoMessageBoxcxx . . $ DoMessageBox(dcc99837539e9edc).(TXT_ERRORcxx . . $ `Descent3/stringtable.h:165:9`!, TXT_FMTCANTDNLDcxx . . $ `Descent3/stringtable.h:454:9`!, MSGBOX_OKcxx . . $ `Descent3/newui_core.h:78:9`!); |
| 625 | } |
| 626 | return 0; |
| 627 | #endif |
| 628 | } |
| 629 | |
| 630 | void msn_ClipURLToWidthcxx . . $ msn_ClipURLToWidth(577809987ad7a468).(int width, char *string) { |
| 631 | if (!string) |
| 632 | return; |
| 633 | |
| 634 | int string_length = strlen(string); |
| 635 | |
| 636 | int size = 0; |
| 637 | char save = string[0]; |
| 638 | string[0] = '\0'; |
| 639 | while (size < string_length) { |
| 640 | if ((grtext_GetTextLineWidthcxx . . $ grtext_GetTextLineWidth(5c4306d8553b3696).(string)) >= width) { |
| 641 | return; |
| 642 | } |
| 643 | // replace the char and move to the next |
| 644 | string[size] = save; |
| 645 | size++; |
| 646 | save = string[size]; |
| 647 | string[size] = '\0'; |
| 648 | } |
| 649 | } |
| 650 | |
| 651 | char *msn_SecondsToStringcxx . . $ msn_SecondsToString(ff224f080444ee45).(int time_sec) { |
| 652 | static char fmttime[100]; |
| 653 | char fmttemp[100] = ""; |
| 654 | int hours; |
| 655 | int minutes; |
| 656 | int seconds; |
| 657 | int i; |
| 658 | fmttime[0] = '\0'; |
| 659 | hours = time_sec / 3600; |
| 660 | i = time_sec % 3600; |
| 661 | minutes = i / 60; |
| 662 | seconds = time_sec % 60; |
| 663 | if (hours) { |
| 664 | snprintf(fmttemp, sizeof(fmttemp), TXT_FMTTIMEHOURcxx . . $ `Descent3/stringtable.h:455:9`!, hours); |
| 665 | strcat(fmttime, " "); |
| 666 | strcat(fmttime, fmttemp); |
| 667 | } |
| 668 | if (minutes) { |
| 669 | snprintf(fmttemp, sizeof(fmttemp), TXT_FMTTIMEMINcxx . . $ `Descent3/stringtable.h:456:9`!, minutes); |
| 670 | strcat(fmttime, " "); |
| 671 | strcat(fmttime, fmttemp); |
| 672 | } |
| 673 | if (seconds) { |
| 674 | snprintf(fmttemp, sizeof(fmttemp), TXT_FMTTIMESECcxx . . $ `Descent3/stringtable.h:457:9`!, seconds); |
| 675 | strcat(fmttime, fmttemp); |
| 676 | } |
| 677 | return fmttime; |
| 678 | } |
| 679 | |
| 680 | void _get_zipfilenamecxx . . $ _get_zipfilename(516c7abb35f952e5).(char *output, char *directory, char *zipfilename) { |
| 681 | char *s = strrchr(zipfilename, '/'); |
| 682 | if (s) |
| 683 | s++; |
| 684 | else |
| 685 | s = zipfilename; |
| 686 | |
| 687 | ddio_MakePathcxx . . $ ddio_MakePath(9ad4b0815420a85).(output, directory, s, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!); |
| 688 | } |
| 689 | |
| 690 | // return 0 on failure |
| 691 | // return 1 on success |
| 692 | int msn_ExtractZipFilecxx . . $ msn_ExtractZipFile(e99f026884c896d5).(char *zipfilename, char *mn3name) { |
| 693 | |
| 694 | mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Extracting ZIP File (%s) to missions directory\n", zipfilename); |
| 695 | if (!cfexistcxx . . $ cfexist(293b0826c8d9cb54).(zipfilenamecxx . . $ std/filesystem/__cxx11/path#path(835bc3a16b770d4d).)) { |
| 696 | mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Zip file doesn't exist\n"); |
| 697 | return 0; |
| 698 | } |
| 699 | |
| 700 | char mission_directory[_MAX_PATHcxx . . $ `linux/linux_fix.h:34:9`!]; |
| 701 | char output_filename[_MAX_PATHcxx . . $ `linux/linux_fix.h:34:9`!]; |
| 702 | char buffer[256 + 32]; |
| 703 | |
| 704 | ddio_MakePathcxx . . $ ddio_MakePath(9ad4b0815420a85).(mission_directory, LocalD3Dircxx . . $ LocalD3Dir., "missions", NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!); |
| 705 | |
| 706 | // now go through the zip file and extract all the files out that we can |
| 707 | ZIPcxx . . $ ZIP# zfilecxx . . $ ZIP#ZIP(49f6e7a06ebc5aa8).; |
| 708 | zipentrycxx . . $ zipentry# *ze; |
| 709 | |
| 710 | if (!zfile.OpenZipcxx . . $ ZIP#OpenZip(c5f7da30cbc0f4e9).(zipfilename)) { |
| 711 | mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Unable to open zip file\n"); |
| 712 | return 0; |
| 713 | } |
| 714 | |
| 715 | NewUIGameWindowcxx . . $ NewUIGameWindow# windowcxx . . $ NewUIGameWindow#NewUIGameWindow(49f6e7a06ebc5aa8).; |
| 716 | UIConsoleGadgetcxx . . $ UIConsoleGadget# consolecxx . . $ UIConsoleGadget#UIConsoleGadget(49f6e7a06ebc5aa8).; |
| 717 | |
| 718 | // Create all the UI Items |
| 719 | window.Createcxx . . $ NewUIGameWindow#Create(1559a299834bcdd5).(0, 0, 384, 288); |
| 720 | console.Createcxx . . $ UIConsoleGadget#Create(f586159e43e8c8b5).(&window, 0x99, 25, 25, 0, 35, 18, 0); |
| 721 | window.Opencxx . . $ UIWindow#Open(49f6e7a06ebc5aa8).(); |
| 722 | |
| 723 | bool found_mn3 = false; |
| 724 | bool process_file; |
| 725 | |
| 726 | while ((ze = zfile.ReadNextZipEntrycxx . . $ ZIP#ReadNextZipEntry(49bfa059dac8e27d).()) != NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!) { |
| 727 | if (ze->crc32cxx . . $ zipentry#crc32. == 0) |
| 728 | continue; // skip directories |
| 729 | |
| 730 | Descentcxx . . $ Descent.->defercxx . . $ oeApplication#defer(db52760e79bf9054).(); |
| 731 | process_file = true; |
| 732 | |
| 733 | mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Processesing: %s\n", ze->name); |
| 734 | |
| 735 | if (ze->compression_methodcxx . . $ zipentry#compression_method. == 0x0000 || ze->compression_methodcxx . . $ zipentry#compression_method. == 0x0008) { |
| 736 | char *rfile = strrchr(ze->namecxx . . $ zipentry#name., '/'); |
| 737 | if (rfile) |
| 738 | rfile++; |
| 739 | else |
| 740 | rfile = ze->namecxx . . $ zipentry#name.; |
| 741 | |
| 742 | snprintf(buffer, sizeof(buffer), "%s %s...", (ze->compression_methodcxx . . $ zipentry#compression_method. == 0x0000) ? "Extracting" : "Inflating", |
| 743 | rfile); |
| 744 | console.putscxx . . $ UIConsoleGadget#puts(d7adf5cfafc0e15a).(GR_GREENcxx . . $ GR_GREEN., buffer); |
| 745 | |
| 746 | // create the filename for this file |
| 747 | _get_zipfilenamecxx . . $ _get_zipfilename(516c7abb35f952e5).(output_filename, mission_directory, ze->namecxx . . $ zipentry#name.); |
| 748 | |
| 749 | if (cfexistcxx . . $ cfexist(293b0826c8d9cb54).(output_filenamecxx . . $ std/filesystem/__cxx11/path#path(835bc3a16b770d4d).)) { |
| 750 | snprintf(buffer, sizeof(buffer), "%s already exists. Overwrite?", output_filename); |
| 751 | if (DoMessageBoxcxx . . $ DoMessageBox(dcc99837539e9edc).("Confirm", buffer, MSGBOX_YESNOcxx . . $ `Descent3/newui_core.h:80:9`!, UICOL_WINDOW_TITLEcxx . . $ `Descent3/newui.h:219:9`!, UICOL_TEXT_NORMALcxx . . $ `Descent3/newui.h:218:9`!)) { |
| 752 | // delete the file |
| 753 | mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Deleting %s\n", zipfilename); |
| 754 | if (!ddio_DeleteFilecxx . . $ ddio_DeleteFile(5c4306d8553b3696).(output_filename)) { |
| 755 | process_file = false; |
| 756 | console.putscxx . . $ UIConsoleGadget#puts(d7adf5cfafc0e15a).(GR_GREENcxx . . $ GR_GREEN., "[Unable to Write] "); |
| 757 | } else { |
| 758 | console.putscxx . . $ UIConsoleGadget#puts(d7adf5cfafc0e15a).(GR_GREENcxx . . $ GR_GREEN., "[Overwriting] "); |
| 759 | } |
| 760 | } else { |
| 761 | process_file = false; |
| 762 | console.putscxx . . $ UIConsoleGadget#puts(d7adf5cfafc0e15a).(GR_GREENcxx . . $ GR_GREEN., "[Skipped] "); |
| 763 | } |
| 764 | } |
| 765 | |
| 766 | // extract this file |
| 767 | if (process_file) { |
| 768 | // update the screen |
| 769 | DoUIFramecxx . . $ DoUIFrame(49f6e7a06ebc5aa8).(); |
| 770 | rend_Flipcxx . . $ rend_Flip(49f6e7a06ebc5aa8).(); |
| 771 | |
| 772 | int ret = zfile.ExtractFilecxx . . $ ZIP#ExtractFile(6368df9ccc80b6b3).(ze, output_filename); |
| 773 | if (ret < 0) { |
| 774 | if (ret == -9) { |
| 775 | mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, " Error writing to file\n"); |
| 776 | snprintf(buffer, sizeof(buffer), "\nError writing to file (Out of space?)"); |
| 777 | } else { |
| 778 | mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, " Error %d extracting file\n", ret); |
| 779 | snprintf(buffer, sizeof(buffer), "\nError %d extracting file", ret); |
| 780 | } |
| 781 | console.putscxx . . $ UIConsoleGadget#puts(d7adf5cfafc0e15a).(GR_GREENcxx . . $ GR_GREEN., buffer); |
| 782 | if (cfexistcxx . . $ cfexist(293b0826c8d9cb54).(output_filenamecxx . . $ std/filesystem/__cxx11/path#path(835bc3a16b770d4d).)) { |
| 783 | ddio_DeleteFilecxx . . $ ddio_DeleteFile(5c4306d8553b3696).(output_filename); |
| 784 | } |
| 785 | } else { |
| 786 | // check the CRC |
| 787 | uint32_tcxx . . $ uint32_t# crc = cf_GetfileCRCcxx . . $ cf_GetfileCRC(eb3222378d8a05e0).(output_filenamecxx . . $ std/filesystem/__cxx11/path#path(835bc3a16b770d4d).); |
| 788 | if (crc == ze->crc32cxx . . $ zipentry#crc32.) { |
| 789 | console.putscxx . . $ UIConsoleGadget#puts(d7adf5cfafc0e15a).(GR_GREENcxx . . $ GR_GREEN., "CRC OK"); |
| 790 | |
| 791 | // check to see if we extracted our mn3 |
| 792 | if (CompareZipFileNamecxx . . $ CompareZipFileName(5ae29d726ae57f88).(ze->namecxx . . $ zipentry#name., mn3name)) { |
| 793 | found_mn3 = true; |
| 794 | } |
| 795 | } else { |
| 796 | console.putscxx . . $ UIConsoleGadget#puts(d7adf5cfafc0e15a).(GR_GREENcxx . . $ GR_GREEN., "CRC FAIL!"); |
| 797 | ddio_DeleteFilecxx . . $ ddio_DeleteFile(5c4306d8553b3696).(output_filename); |
| 798 | } |
| 799 | } |
| 800 | } |
| 801 | |
| 802 | } else { |
| 803 | mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Unsupported compression for file (%s)\n", ze->name); |
| 804 | console.putscxx . . $ UIConsoleGadget#puts(d7adf5cfafc0e15a).(GR_GREENcxx . . $ GR_GREEN., "Unsupported compression!!"); |
| 805 | } |
| 806 | |
| 807 | console.putscxx . . $ UIConsoleGadget#puts(d7adf5cfafc0e15a).(GR_GREENcxx . . $ GR_GREEN., "\n"); |
| 808 | DoUIFramecxx . . $ DoUIFrame(49f6e7a06ebc5aa8).(); |
| 809 | rend_Flipcxx . . $ rend_Flip(49f6e7a06ebc5aa8).(); |
| 810 | } |
| 811 | zfile.CloseZipcxx . . $ ZIP#CloseZip(49f6e7a06ebc5aa8).(); |
| 812 | |
| 813 | if (DoMessageBoxcxx . . $ DoMessageBox(dcc99837539e9edc).("Confirm", "Do you want to delete the zip file? It is no longer needed.", MSGBOX_YESNOcxx . . $ `Descent3/newui_core.h:80:9`!, |
| 814 | UICOL_WINDOW_TITLEcxx . . $ `Descent3/newui.h:219:9`!, UICOL_TEXT_NORMALcxx . . $ `Descent3/newui.h:218:9`!)) { |
| 815 | // delete the file |
| 816 | mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Deleting %s\n", zipfilename); |
| 817 | ddio_DeleteFilecxx . . $ ddio_DeleteFile(5c4306d8553b3696).(zipfilename); |
| 818 | } |
| 819 | |
| 820 | window.Closecxx . . $ UIWindow#Close(49f6e7a06ebc5aa8).(); |
| 821 | window.Destroycxx . . $ UIWindow#Destroy(49f6e7a06ebc5aa8).(); |
| 822 | |
| 823 | if (!found_mn3) |
| 824 | return 0; |
| 825 | |
| 826 | return 1; |
| 827 | } |
| 828 | |
| 829 | #if defined(POSIXcxx . . $ `<built-in>:480:9`!) |
| 830 | char *_strlwrcxx . . $ _strlwr(7a9722d75b371431).(char *string) { |
| 831 | char *ptr = string; |
| 832 | while (*ptr) { |
| 833 | *ptr = tolower(*ptr); |
| 834 | ptr++; |
| 835 | } |
| 836 | return string; |
| 837 | } |
| 838 | #endif |
| 839 | |
| 840 | #define MOD_URL_BASEPATHcxx . . $ `Descent3/mission_download.cpp:840:9`! "http://www.descent3.com/mods/" // WAS: "http://www.pxo.net/descent3/mods/" |
| 841 | |
| 842 | int CheckGetD3Mcxx . . $ CheckGetD3M(1ef8e6ec083aabb9).(char *d3m) { |
| 843 | #if !defined(OEM) |
| 844 | |
| 845 | char modurl[MAX_MISSION_URL_LENcxx . . $ `Descent3/mission_download.h:47:9`! + 1]; |
| 846 | char *lowurl; |
| 847 | char pathname[_MAX_PATHcxx . . $ `linux/linux_fix.h:34:9`!]; |
| 848 | char *fixedd3m = NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!; |
| 849 | |
| 850 | ddio_MakePathcxx . . $ ddio_MakePath(9ad4b0815420a85).(pathname, LocalD3Dircxx . . $ LocalD3Dir., "Netgames", d3m, NULLcxx . . $ `/usr/lib/gcc/x86_64-linux-gnu/15/include/stddef.h:416:9`!); |
| 851 | if (cfexistcxx . . $ cfexist(293b0826c8d9cb54).(d3mcxx . . $ std/filesystem/__cxx11/path#path(835bc3a16b770d4d).) || cfexistcxx . . $ cfexist(293b0826c8d9cb54).(pathnamecxx . . $ std/filesystem/__cxx11/path#path(835bc3a16b770d4d).)) { |
| 852 | return 1; |
| 853 | } |
| 854 | |
| 855 | // Now we need to replace evil spaces with underscores, so the downloader will work |
| 856 | fixedd3m = mem_strdupcxx . . $ `mem/mem.h:81:9`!(d3m); |
| 857 | char *p = fixedd3m; |
| 858 | while (*p) { |
| 859 | if (*p == ' ') { |
| 860 | *p = '_'; |
| 861 | } |
| 862 | p++; |
| 863 | } |
| 864 | // This should be the url we can download from. |
| 865 | int iurlbase = FindArgcxx . . $ FindArg(5c4306d8553b3696).("-d3mbaseurl"); |
| 866 | if (!iurlbase) { |
| 867 | strcpy(modurl, MOD_URL_BASEPATHcxx . . $ `Descent3/mission_download.cpp:840:9`!); |
| 868 | } else { |
| 869 | strcpy(modurl, GameArgscxx . . $ GameArgs.[iurlbase + 1]); |
| 870 | } |
| 871 | |
| 872 | strcat(modurl, fixedd3m); |
| 873 | |
| 874 | lowurl = mem_strdupcxx . . $ `mem/mem.h:81:9`!(_strlwr(modurl)); |
| 875 | mprintfcxx . . $ `ddebug/mono.h:82:9`!(0, "Downloading mod file from %s\n", modurl); |
| 876 | |
| 877 | if (ModDownloadWithStatuscxx . . $ ModDownloadWithStatus(e99f026884c896d5).(modurl, d3m)) { |
| 878 | mem_freecxx . . $ `mem/mem.h:80:9`!(fixedd3m); |
| 879 | return 1; |
| 880 | } |
| 881 | |
| 882 | mem_freecxx . . $ `mem/mem.h:80:9`!(lowurl); |
| 883 | mem_freecxx . . $ `mem/mem.h:80:9`!(fixedd3m); |
| 884 | return 0; |
| 885 | #endif |
| 886 | } |
| 887 | |
| 888 | // Start downloading the file at the url specifies, showing a status screen |
| 889 | // Return codes: |
| 890 | // 0 Failed or cancelled |
| 891 | // 1 Success |
| 892 | int ModDownloadWithStatuscxx . . $ ModDownloadWithStatus(e99f026884c896d5).(char *url, char *filename) { |
| 893 | return 0; |
| 894 | /* |
| 895 | char qualfile[_MAX_PATH*2]; |
| 896 | float last_refresh; |
| 897 | int total_bytes = 0; |
| 898 | int received_bytes = 0; |
| 899 | int time_elapsed = 0; |
| 900 | int time_remain = 0; |
| 901 | int xfer_rate = 0; |
| 902 | int starttime = timer_GetTime(); |
| 903 | bool file_is_zip = false; |
| 904 | |
| 905 | //check to see if we are downloading a zip file |
| 906 | char *url_ptr; |
| 907 | url_ptr = url + strlen(url); |
| 908 | while(url_ptr > url && *url_ptr!='.') url_ptr--; |
| 909 | if(*url_ptr=='.') |
| 910 | { |
| 911 | //now see if the rest of the extension is ZIP |
| 912 | if(!stricmp(url_ptr,".ZIP")) |
| 913 | { |
| 914 | mprintf(0,"We're downloading a zip file!!!\n"); |
| 915 | file_is_zip = true; |
| 916 | } |
| 917 | } |
| 918 | |
| 919 | char fmturl[MSN_MAX_STRING_LEN]; |
| 920 | char fmtrcvd[MSN_MAX_STRING_LEN]; |
| 921 | char fmttotal[MSN_MAX_STRING_LEN]; |
| 922 | char fmtelaps[MSN_MAX_STRING_LEN]; |
| 923 | char fmttimer[MSN_MAX_STRING_LEN]; |
| 924 | char fmtrate[MSN_MAX_STRING_LEN]; |
| 925 | |
| 926 | sprintf(fmturl,DOWNLOAD_STATUS_URL_TEXT,url); |
| 927 | msn_ClipURLToWidth(MSN_DWNLD_STATUS_W-(MSN_COL_1+MSN_BORDER_W),fmturl); |
| 928 | sprintf(fmtrcvd,DOWNLOAD_STATUS_RCVD_TEXT,received_bytes); |
| 929 | sprintf(fmttotal,DOWNLOAD_STATUS_TOTAL_TEXT,total_bytes); |
| 930 | sprintf(fmtelaps,DOWNLOAD_STATUS_ELAPS_TEXT,msn_SecondsToString(time_elapsed)); |
| 931 | sprintf(fmttimer,DOWNLOAD_STATUS_TIME_R_TEXT,msn_SecondsToString(time_remain)); |
| 932 | sprintf(fmtrate,DOWNLOAD_STATUS_XFERRATE_TEXT,xfer_rate); |
| 933 | |
| 934 | if(file_is_zip) |
| 935 | { |
| 936 | char fname[_MAX_FNAME]; |
| 937 | char *s_ptr,*d_ptr; |
| 938 | s_ptr = filename; |
| 939 | d_ptr = fname; |
| 940 | while(*s_ptr && *s_ptr!='.'){ *d_ptr = *s_ptr; s_ptr++; d_ptr++;} |
| 941 | *d_ptr = '\0'; |
| 942 | strcat(fname,".zip"); |
| 943 | ddio_MakePath(qualfile, LocalD3Dir, "Netgames", fname, NULL); |
| 944 | //ddio_MakePath(qualfile,D3MissionsDir,fname,NULL); |
| 945 | }else |
| 946 | { |
| 947 | //ddio_MakePath(qualfile,D3MissionsDir,filename,NULL); |
| 948 | ddio_MakePath(qualfile, LocalD3Dir, "Netgames", filename, NULL); |
| 949 | } |
| 950 | InetGetFile *getmsnfile; |
| 951 | if(Proxy_server[0]) |
| 952 | { |
| 953 | getmsnfile = new InetGetFile(url,qualfile,Proxy_server,Proxy_port); |
| 954 | } |
| 955 | else |
| 956 | { |
| 957 | getmsnfile = new InetGetFile(url,qualfile); |
| 958 | } |
| 959 | //InetGetFile getmsnfile(url,qualfile); |
| 960 | |
| 961 | UITextItem title_text(TXT_MD_DOWNLOADSTATUS,UICOL_TEXT_NORMAL); |
| 962 | |
| 963 | UIHotspot cancel_hot; |
| 964 | |
| 965 | UITextItem download_text(fmturl,UICOL_TEXT_NORMAL);; |
| 966 | UITextItem rcvd_text(fmtrcvd,UICOL_TEXT_NORMAL); |
| 967 | UITextItem total_text(fmttotal,UICOL_TEXT_NORMAL); |
| 968 | UITextItem elaps_text(fmtelaps,UICOL_TEXT_NORMAL); |
| 969 | UITextItem time_r_text(fmttimer,UICOL_TEXT_NORMAL); |
| 970 | UITextItem rate_text(fmtrate,UICOL_TEXT_NORMAL); |
| 971 | |
| 972 | NewUIGameWindow menu_wnd; |
| 973 | |
| 974 | UIText texts[10]; |
| 975 | UIProgress progress; |
| 976 | |
| 977 | int exit_menu=0; |
| 978 | int ret=0; |
| 979 | |
| 980 | menu_wnd.Create(10,10,MSN_DWNLD_STATUS_W,MSN_DWNLD_STATUS_H,UIF_PROCESS_ALL | UIF_CENTER); |
| 981 | texts[0].Create (&menu_wnd,&title_text,0,8,UIF_CENTER); |
| 982 | texts[1].Create (&menu_wnd,&download_text,MSN_COL_1,MSN_ROW_1,0); |
| 983 | texts[2].Create (&menu_wnd,&rcvd_text,MSN_COL_1,MSN_ROW_2,0); |
| 984 | texts[3].Create (&menu_wnd,&total_text,MSN_COL_2,MSN_ROW_2,0); |
| 985 | texts[4].Create (&menu_wnd,&elaps_text,MSN_COL_1,MSN_ROW_3,0); |
| 986 | texts[5].Create (&menu_wnd,&time_r_text,MSN_COL_2,MSN_ROW_3,0); |
| 987 | texts[6].Create (&menu_wnd,&rate_text,MSN_COL_1,MSN_ROW_4,0); |
| 988 | |
| 989 | UITextItem cancel_off(TXT_CANCEL,UICOL_HOTSPOT_LO,UIALPHA_HOTSPOT_LO); |
| 990 | UITextItem cancel_on(TXT_CANCEL,UICOL_HOTSPOT_HI,UIALPHA_HOTSPOT_HI); |
| 991 | |
| 992 | progress.Create(&menu_wnd,MSN_COL_1,MSN_ROW_5,MSN_DWNLD_STATUS_W-(MSN_BORDER_W*2),35,0); |
| 993 | |
| 994 | int cancel_x = 0; |
| 995 | |
| 996 | cancel_hot.Create(&menu_wnd, UID_CANCEL, KEY_ESC, &cancel_off,&cancel_on, |
| 997 | cancel_x, MSN_DWNLD_STATUS_H - OKCANCEL_YOFFSET, |
| 998 | 0,0,UIF_FIT|UIF_CENTER); menu_wnd.Open(); |
| 999 | |
| 1000 | last_refresh = timer_GetTime()-MSN_REFRESH_INTERVAL; |
| 1001 | |
| 1002 | while (!exit_menu) |
| 1003 | { |
| 1004 | int res; |
| 1005 | |
| 1006 | if((timer_GetTime()-last_refresh)>MSN_REFRESH_INTERVAL) |
| 1007 | { |
| 1008 | |
| 1009 | //Update the dialog |
| 1010 | //mprintf(0,"!"); |
| 1011 | |
| 1012 | if(getmsnfile->IsFileReceived()) |
| 1013 | { |
| 1014 | //File transfer successful! |
| 1015 | mprintf(0,"Succesfully received the file!\n"); |
| 1016 | exit_menu = 1; |
| 1017 | |
| 1018 | if(file_is_zip) |
| 1019 | { |
| 1020 | // now we gotta handle the zip file |
| 1021 | ret = msn_ExtractZipFile(qualfile,filename); |
| 1022 | }else |
| 1023 | { |
| 1024 | ret = 1; |
| 1025 | } |
| 1026 | } |
| 1027 | |
| 1028 | if(getmsnfile->IsFileError()) |
| 1029 | { |
| 1030 | //File transfer Error! |
| 1031 | DoMessageBox(TXT_ERROR,TXT_FMTCANTDNLD,MSGBOX_OK); |
| 1032 | //Delete the file that didn't finish! |
| 1033 | ddio_DeleteFile(qualfile); |
| 1034 | mprintf(0,"Couldn't download the file! Error: %d\n",getmsnfile->GetErrorCode()); |
| 1035 | exit_menu = 1; |
| 1036 | ret = 0; |
| 1037 | } |
| 1038 | |
| 1039 | last_refresh = timer_GetTime(); |
| 1040 | received_bytes = getmsnfile->GetBytesIn(); |
| 1041 | total_bytes = getmsnfile->GetTotalBytes(); |
| 1042 | |
| 1043 | time_elapsed = timer_GetTime()-starttime; |
| 1044 | |
| 1045 | if(total_bytes) |
| 1046 | { |
| 1047 | time_remain = ((float)(total_bytes-received_bytes))/((float)(received_bytes/time_elapsed)); |
| 1048 | } |
| 1049 | if(time_elapsed&&received_bytes) |
| 1050 | { |
| 1051 | xfer_rate = ((float)(received_bytes/time_elapsed)); |
| 1052 | } |
| 1053 | texts[1].Destroy(); |
| 1054 | texts[2].Destroy(); |
| 1055 | texts[3].Destroy(); |
| 1056 | texts[4].Destroy(); |
| 1057 | texts[5].Destroy(); |
| 1058 | texts[6].Destroy(); |
| 1059 | |
| 1060 | sprintf(fmturl,DOWNLOAD_STATUS_URL_TEXT,url); |
| 1061 | msn_ClipURLToWidth(MSN_DWNLD_STATUS_W-(MSN_COL_1+MSN_BORDER_W),fmturl); |
| 1062 | sprintf(fmtrcvd,DOWNLOAD_STATUS_RCVD_TEXT,received_bytes); |
| 1063 | sprintf(fmttotal,DOWNLOAD_STATUS_TOTAL_TEXT,total_bytes); |
| 1064 | sprintf(fmtelaps,DOWNLOAD_STATUS_ELAPS_TEXT,msn_SecondsToString(time_elapsed)); |
| 1065 | sprintf(fmttimer,DOWNLOAD_STATUS_TIME_R_TEXT,msn_SecondsToString(time_remain)); |
| 1066 | msn_ClipURLToWidth(MSN_DWNLD_STATUS_W-(MSN_COL_2+MSN_BORDER_W),fmttimer); |
| 1067 | sprintf(fmtrate,DOWNLOAD_STATUS_XFERRATE_TEXT,xfer_rate); |
| 1068 | |
| 1069 | download_text = UITextItem (fmturl,UICOL_TEXT_NORMAL);; |
| 1070 | rcvd_text = UITextItem (fmtrcvd,UICOL_TEXT_NORMAL); |
| 1071 | total_text = UITextItem (fmttotal,UICOL_TEXT_NORMAL); |
| 1072 | elaps_text = UITextItem (fmtelaps,UICOL_TEXT_NORMAL); |
| 1073 | time_r_text = UITextItem (fmttimer,UICOL_TEXT_NORMAL); |
| 1074 | rate_text = UITextItem (fmtrate,UICOL_TEXT_NORMAL); |
| 1075 | |
| 1076 | texts[1].Create (&menu_wnd,&download_text,MSN_COL_1,MSN_ROW_1,0); |
| 1077 | texts[2].Create (&menu_wnd,&rcvd_text,MSN_COL_1,MSN_ROW_2,0); |
| 1078 | texts[3].Create (&menu_wnd,&total_text,MSN_COL_2,MSN_ROW_2,0); |
| 1079 | texts[4].Create (&menu_wnd,&elaps_text,MSN_COL_1,MSN_ROW_3,0); |
| 1080 | texts[5].Create (&menu_wnd,&time_r_text,MSN_COL_2,MSN_ROW_3,0); |
| 1081 | texts[6].Create (&menu_wnd,&rate_text,MSN_COL_1,MSN_ROW_4,0); |
| 1082 | |
| 1083 | progress.Update(((float)((float)received_bytes)/((float)total_bytes))); |
| 1084 | //mprintf(0,"@"); |
| 1085 | } |
| 1086 | //mprintf(0,"-In"); |
| 1087 | res = PollUI(); |
| 1088 | //mprintf(0,"-Out"); |
| 1089 | switch(res) |
| 1090 | { |
| 1091 | case UID_CANCEL: |
| 1092 | getmsnfile->AbortGet(); |
| 1093 | ddio_DeleteFile(qualfile); |
| 1094 | exit_menu = 1; |
| 1095 | ret = 0; |
| 1096 | break; |
| 1097 | } |
| 1098 | } |
| 1099 | menu_wnd.Close(); |
| 1100 | menu_wnd.Destroy(); |
| 1101 | delete getmsnfile; |
| 1102 | return ret; |
| 1103 | */ |
| 1104 | } |