Esempio n. 1
0
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;
}
Esempio n. 2
0
int Cvxl_file::extract_as_pcx(const Cfname& name, t_file_type ft, const t_palet _palet) const
{
	t_palet palet;
	memcpy(palet, _palet, sizeof(t_palet));
	convert_palet_18_to_24(palet);
	const t_vxl_section_tailer& section_tailer = *get_section_tailer(0);
	const int cx = section_tailer.cx;
	const int cy = section_tailer.cy;
	const int cz = section_tailer.cz;
	Cvirtual_binary s;
	for (int i = 0; i < cz; i++)
	{
		memset(s.write_start(cx * cy), 0, cx * cy);
		int j = 0;
		for (int y = 0; y < cy; y++)
		{
			for (int x = 0; x < cx; x++)
			{
				const byte* r = get_span_data(0, j);
				if (r)
				{
					int z = 0;
					while (z < cz)
					{
						z += *r++;
						int c = *r++;
						while (c--)
						{
							if (i == z)
								s.data_edit()[x + cx * y] = *r;
							r += 2;
							z++;
						}
						r++;
					}
				}
				j++;
			}
		}
		Cfname t = name;
		t.set_title(name.get_ftitle() + " " + nwzl(4, i));
		int error = image_file_write(t, ft, s.data(), palet, cx, cy);
		if (error)
			return error;
	}
	return 0;
}
Esempio n. 3
0
int Cwsa_dune2_file::extract_as_pcx(const Cfname& name, const t_palet _palet) const
{
	t_palet palet;
	convert_palet_18_to_24(_palet, palet);
	int error = 0;
	const int cx = get_cx();
	const int cy = get_cy();
	const int c_frames = get_c_frames();
	byte* frame = new byte[cx * cy];
	byte* s = new byte[64 << 10];
	byte* d = new byte[cx * cy * 2];
	memset(frame, 0, cx * cy);
	for (int i = 0; i < c_frames; i++)
	{
		if (get_offset(i))
		{
			decode80(get_frame(i), s);
			decode40(s, frame);
		}
		int cb_d = pcx_encode(frame, d, cx, cy, 1);
		Cpcx_file_write f;
		Cfname t = name;
		t.set_title(name.get_ftitle() + " " + nwzl(4, i));
		error = f.open_write(t);
		if (error)
			break;
		f.set_size(cx, cy, 1);
		error = f.write_header();
		if (!error)
			error = f.write_image(d, cb_d);
		if (!error)
			error = f.write_palet(palet);
		f.close();
		if (error)
			break;
	}
	delete[] d;
	delete[] s;
	delete[] frame;
	return error;
}
int CXCCRA2RadarCustomizerDlg::customize_radar(t_game game, int theater)
{
	CWaitCursor wait;
	const string theater_mname[] = {"snow", "temp", "urb", "des", "lun", "ubn"};

	const Cfname fname = xcc_dirs::get_dir(game) + "iso" + theater_mname[theater] + ".mix";
	if (m_reset)
		return delete_file(fname);
	Cmix_file main_mix;
	int error = main_mix.open(xcc_dirs::get_main_mix(game));
	if (!error)
	{
		Ccc_file mix_f(false);
		error = mix_f.open(fname.get_fname(), main_mix);
		if (!error)
		{
			error = mix_f.extract(fname);
			mix_f.close();
			Cfile32 mix_fe;
			mix_fe.open_edit(fname);
			Cmix_file mix_f;
			mix_f.open(mix_fe.h());
			for (int i = 0; i < mix_f.get_c_files(); i++)
			{
				const int id = mix_f.get_id(i);
				Ctmp_ts_file f;
				f.open(id, mix_f);
				if (f.is_valid())
				{
					for (int j = 0; j < f.get_c_tiles(); j++)
					{
						if (!f.get_index()[j])
							continue;
						t_tmp_image_header header = *f.get_image_header(j);
						if (m_relative)
						{
							header.radar_red_left = header.radar_red_left * m_red / 255;
							header.radar_red_right = header.radar_red_right * m_red / 255;
							header.radar_green_left = header.radar_green_left * m_green / 255;
							header.radar_green_right = header.radar_green_right * m_green / 255;
							header.radar_blue_left = header.radar_blue_left * m_blue / 255;
							header.radar_blue_right = header.radar_blue_right * m_blue / 255;
						}
						else
						{
							header.radar_red_left = header.radar_red_right = m_red;
							header.radar_green_left = header.radar_green_right = m_green;
							header.radar_blue_left = header.radar_blue_right = m_blue;
						}
						mix_fe.seek(mix_f.get_offset(id) + f.get_index()[j]);
						mix_fe.write(&header, sizeof(t_tmp_image_header));
					}
				}
				f.close();
			}
			mix_f.close();
			mix_fe.close();
		}
		main_mix.close();
	}
	return 0;
}
Esempio n. 5
0
int main()
{
	xcc_dirs::load_from_registry();
	Cmix_file::enable_ft_support();
	mix_cache::load();
	mix_database::load();
	check_dir(xcc_dirs::get_dir(game));
	check_dir(xcc_dirs::get_cd_dir());
	check_dir("f:/");
	int known = 0;
	int total = flist.size();
	for (auto& i : flist)
		known += !mix_database::get_name(game, i.first).empty();
	ofstream log_f("c:/log.txt");
	for (auto& i : flist)
		check_name(mix_database::get_name(game, i.first), log_f);
	if (0)
	{
		init_filename_chars();
		for (int i = 0; i < 256; i++)
		{
			if (filename_chars[i])
				log_f << static_cast<char>(i);
		}
		log_f << endl;
	}
	if (0)
	{
		Ccc_file f(true);
		f.open("c:/temp/filemon.log");
		Cvirtual_tfile t;
		t.load_data(f.vdata());
		while (!t.eof())
		{
			Cmulti_line l = t.read_line();
			l.get_next_line('\t');
			l.get_next_line('\t');
			l.get_next_line('\t');
			l.get_next_line('\t');
			check_name(static_cast<Cfname>(l.get_next_line('\t')).get_fname(), log_f);
		}
		f.close();
	}
	if (0)
	{
		for (auto& i : flist)
		{
			Cfname name = mix_database::get_name(game, i.first);
			name.set_ext(".hva");
			int id = Cmix_file::get_id(game, name);
			if (flist.find(id) != flist.end() && mix_database::get_name(game, id).empty())
			{
				cout << "found: " << name.get_fname() << endl;
				log_f << name.get_fname() << '\t' << endl;
			}
		}
	}
	if (1)
	{
		// check_binary_file("c:/games/ra2/game.exe", log_f);
		// check_binary_file("c:/games/ra2/gamemd.exe", log_f);
		// check_text_file("c:/temp/missions.pkt", log_f);
		string name = "c:/temp/";
		WIN32_FIND_DATA finddata;
		HANDLE findhandle = FindFirstFile((name + "*.ini").c_str(), &finddata);
		if (findhandle != INVALID_HANDLE_VALUE)
		{
			do
			{
				if (~finddata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
					check_text_file(name + finddata.cFileName, log_f);
			}
			while (FindNextFile(findhandle, &finddata));
			FindClose(findhandle);
		}
	}
	if (0)
	{
		int id = Cmix_file::get_id(game, "");
		if (flist.find(id) != flist.end() && mix_database::get_name(game, id).empty())
			cout << "not found" << endl;
	}
	cout << "Known: " << known << endl
		<< "Total: " << total << endl;
	mix_cache::save();
	return 0;
}