int CXCCRA2MapUpdaterApp::update() { int error = 0; try { CWaitCursor wait; CInternetSession is; CHttpFile* f = reinterpret_cast<CHttpFile*>(is.OpenURL("http://xccu.sourceforge.net/ra2_maps/official.ucf")); if (!f) error = 1; else { string s; while (1) { int cb_p = f->GetLength(); if (!cb_p) break; char* p = new char[cb_p + 1]; f->Read(p, cb_p); p[cb_p] = 0; s += p; delete[] p; } f->Close(); Cvirtual_tfile f; f.load_data(Cvirtual_binary(s.c_str(), s.length())); while (!f.eof()) { Cmulti_line l = f.read_line(); Cfname fname = xcc_dirs::get_dir(game_ra2) + l.get_next_line('=') + ".mmx"; if (!fname.exists()) { string version = l.get_next_line(','); string link = l.get_next_line(','); error = download_update(link, fname); if (error) { delete_file(fname); MessageBox(NULL, "Error retrieving update.", NULL, MB_ICONERROR); error = 0; } } } } } catch (CInternetException*) { error = 1; } if (error) MessageBox(NULL, "Error querying for update.", NULL, MB_ICONERROR); return error; }