2 * $Logfile: /Freespace2/code/Network/multi_update.cpp $
8 * Revision 1.1 2002/05/03 03:28:10 root
12 * 9 10/14/99 3:35p Jefff
15 * 8 8/24/99 1:50a Dave
16 * Fixed client-side afterburner stuttering. Added checkbox for no version
17 * checking on PXO join. Made button info passing more friendly between
20 * 7 8/22/99 1:19p Dave
21 * Fixed up http proxy code. Cleaned up scoring code. Reverse the order in
22 * which d3d cards are detected.
24 * 6 5/19/99 4:07p Dave
25 * Moved versioning code into a nice isolated common place. Fixed up
26 * updating code on the pxo screen. Fixed several stub problems.
28 * 5 2/04/99 6:29p Dave
29 * First full working rev of FS2 PXO support. Fixed Glide lighting
32 * 4 11/05/98 4:18p Dave
33 * First run nebula support. Beefed up localization a bit. Removed all
34 * conditional compiles for foreign versions. Modified mission file
37 * 3 10/09/98 2:57p Dave
38 * Starting splitting up OS stuff.
40 * 2 10/07/98 10:53a Dave
43 * 1 10/07/98 10:50a Dave
45 * 15 9/10/98 1:17p Dave
46 * Put in code to flag missions and campaigns as being MD or not in Fred
47 * and Freespace. Put in multiplayer support for filtering out MD
48 * missions. Put in multiplayer popups for warning of non-valid missions.
50 * 14 9/09/98 5:53p Dave
51 * Put in new tracker packets in API. Change cfile to be able to checksum
54 * 13 7/24/98 11:13a Allender
55 * change way that the version.nfo file is parsed so that bogus returns
56 * from the HTTP server are accurately caught
58 * 12 7/20/98 12:51p Allender
59 * don't remove the version.nfo file if we are exiting to launcher for
60 * update. The launcher asssumes that the file is already present.
62 * 11 7/15/98 10:50a Allender
63 * changed web site to get version.nfo from
65 * 10 7/15/98 10:17a Dave
66 * Made the website address lookup more robust.
68 * 9 7/15/98 10:04a Dave
69 * Change connect() procedure so that it uses non blocking sockets and
70 * freespace doesn't "hang"
72 * 8 7/13/98 10:30a Lawrance
73 * add index numbers for newly localized strings
75 * 7 7/13/98 10:12a Dave
76 * Remove improperly localized strings.
78 * 6 7/10/98 5:04p Dave
79 * Fix connection speed bug on standalone server.
81 * 5 7/10/98 11:33a Dave
82 * Give the user extra options when the need for updating is detected on
83 * PXO screen. Send special command line arg to fslauncher.
85 * 4 7/09/98 6:07p Dave
86 * Format the text in the error dialog better.
88 * 3 7/09/98 6:01p Dave
89 * Firsts full version of PXO updater. Put in stub for displaying
92 * 2 7/09/98 4:51p Dave
93 * First revision of PXO autoupdate check system.
95 * 1 7/09/98 2:09p Dave
102 #include "multi_update.h"
104 #include "gamesequence.h"
105 #include "osregistry.h"
108 #include "inetgetfile.h"
111 // -------------------------------------------------------------------------------------------------------------------
112 // MULTI UPDATE DEFINES/VARS
116 InetGetFile *Multi_update_get = NULL;
118 // set this to be true so that game_shutdown() will fire up the launcher, then post a quit game event
119 int Multi_update_fireup_launcher_on_exit = 0;
121 // error code string for convenient reporting
122 char Multi_update_error_string[512];
124 // -------------------------------------------------------------------------------------------------------------------
125 // MULTI UPDATE FUNCTIONS
128 // initialize the http xfer of the version info file, return 1 on success
129 int multi_update_http_init()
131 char url_file[512] = "";
132 char local_file[512] = "";
135 strcpy(url_file, VERSION_URL);
138 strcpy(local_file, Cfile_root_dir);
139 strcat(local_file, "\\");
140 strcat(local_file, VERSION_LOC_FNAME);
143 Multi_update_get = new InetGetFile(url_file, local_file);
144 if(Multi_update_get == NULL){
146 strcpy(Multi_update_error_string, XSTR("Could not get data from website", 977));
154 // do frame for the popup. returns 0 if not done yet, 1 if succeeded, 2 on error
155 int multi_update_http_do()
158 if(Multi_update_get == NULL){
160 strcpy(Multi_update_error_string, XSTR("Could not get data from website", 977));
166 if(Multi_update_get->IsFileError()){
167 delete Multi_update_get;
168 Multi_update_get = NULL;
171 strcpy(Multi_update_error_string, XSTR("Could not get data from website", 977));
177 if(Multi_update_get->IsFileReceived()){
178 delete Multi_update_get;
179 Multi_update_get = NULL;
183 // connecting, receiving
184 if(Multi_update_get->IsConnecting() || Multi_update_get->IsReceiving()){
191 // close down the http xfer
192 void multi_update_http_close()
196 // error verifying, prompt the user for some action
197 int multi_update_error_verifying()
201 memset(out_str, 0, 512);
202 strcpy(out_str, "(");
203 strcat(out_str, Multi_update_error_string);
204 strcat(out_str, ")\n\n");
205 strcat(out_str, XSTR("There was an error verifying your version of Freespace, if you continue, you will not necessarily be up to date", 978));
207 switch(popup(PF_USE_AFFIRMATIVE_ICON | PF_USE_NEGATIVE_ICON, 2, XSTR("&Go back", 1524), XSTR("&Continue", 1525), out_str)){
208 // continue on in freespace like nothing happened
211 return MULTI_UPDATE_CONTINUE;
213 // go back to the main menu
215 return MULTI_UPDATE_MAIN_MENU;
218 // should never happen, but if so, move back to the main menu
219 return MULTI_UPDATE_MAIN_MENU;
222 // check to see if the version of FS on this machine is not recent. run in a popup
223 // if the versions don't check out, bail to the launcher
224 // returns 0 if freespace should continue, 1 if freespace should go back to the main menu,
225 // and 2 if the "shutdown" event was posted
226 int multi_update_gobaby()
230 int my_code = MULTI_UPDATE_MAIN_MENU;
233 if(os_config_read_uint(NULL, "SkipVerify", 0)){
234 return MULTI_UPDATE_CONTINUE;
237 memset(Multi_update_error_string, 0, 512);
239 // initialize the http connection
240 if(!multi_update_http_init()){
241 return multi_update_error_verifying();
245 extern char Multi_options_proxy[512];
246 extern ushort Multi_options_proxy_port;
247 if(strlen(Multi_options_proxy) > 0){
248 sprintf(msg, "%s (%s : %d)", XSTR("Verifying Freespace Version",981), Multi_options_proxy, Multi_options_proxy_port);
250 strcpy(msg, XSTR("Verifying Freespace Version",981));
252 ret_code = popup_till_condition(multi_update_http_do, XSTR("Cancel",948), msg);
254 // determine what to do now
258 // compare the versions
259 switch(version_compare(VERSION_LOC_FNAME, NULL, NULL, NULL, NULL, NULL, NULL)){
262 my_code = multi_update_error_verifying();
265 // earlier version - need to update
267 switch(popup(PF_USE_AFFIRMATIVE_ICON | PF_USE_NEGATIVE_ICON, 2, "&Update Later", "&Yes", XSTR("A new version of Freespace is available. You must update to the new version to play on PXO\n\nAuto update now?", 980))){
268 // update later (go back to main hall for now
271 my_code = MULTI_UPDATE_MAIN_MENU;
275 // set things up so that the launcher is launched when Freespace is done closing
276 Multi_update_fireup_launcher_on_exit = 1;
277 gameseq_post_event(GS_EVENT_QUIT_GAME);
279 my_code = MULTI_UPDATE_SHUTTING_DOWN;
283 // same version or higher
286 my_code = MULTI_UPDATE_CONTINUE;
291 // error of some kind (should probably notify the user or something)
293 my_code = multi_update_error_verifying();
296 // this should never happen, but if it does, go back to the main menu
298 my_code = multi_update_error_verifying();
303 multi_update_http_close();