Esempio n. 1
0
void Cpkt_ts_ini_reader::write_report(ostream& os) const
{
    CXSTE xste;
    bool xste_available = !xste.open(game_ra2_yr);
    os << "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\"><link rel=stylesheet href=\"http://xccu.sourceforge.net/xcc.css\"><title>PKT dump</title><table border=1>"
       << "<tr><th>Name<th>Description<th>Gamemode<th>Preview";
    for (t_map_list::const_iterator i = m_map_list.begin(); i != m_map_list.end(); i++)
    {
        /*
        bool skip = true;
        Cmulti_line l = i->second.m_gamemode;
        while (!l.empty())
        {
        	if (l.get_next_line(',') == "standard")
        	{
        		skip = false;
        		break;
        	}
        }
        if (skip)
        	continue;
        */
        string description = i->second.m_description;
        if (xste_available)
        {
            Ccsf_file& csf_f = xste.csf_f();
            if (csf_f.has_name(to_lower_copy(description)))
                description = csf_f.get_converted_value(to_lower_copy(description));
        }
        os << "<tr><td><a href=" << i->first << ".html>" << i->first << "</a><td>" << description << "<td>" << i->second.m_gamemode << "<td><img src=" << i->first << "_pv.png>";
        // page += "\"" + i->first + "\", " + "\"" + description + "\",\n";
    }
    os << "</table>";
    // os << page;
}
Esempio n. 2
0
int Cpkt_ts_ini_reader::process_key(const string& name, const string& value)
{
    switch (m_section)
    {
    case sei_multi_maps:
        m_map_list[to_lower_copy(value)];
        break;
    case sei_unknown:
        switch (find_id(name, map_code, mai_unknown))
        {
        case mai_description:
            m_map_list[m_current_map].m_description = value;
            break;
        case mai_cd:
            m_map_list[m_current_map].m_cd = value;
            break;
        case mai_minplayers:
            m_map_list[m_current_map].m_min_players = atoi(value.c_str());
            break;
        case mai_maxplayers:
            m_map_list[m_current_map].m_max_players = atoi(value.c_str());
            break;
        case mai_gamemode:
            m_map_list[m_current_map].m_gamemode = value;
            break;
        default:
            return 1;
        }
    }
    return 0;
}
Esempio n. 3
0
string read_string(const byte*& r)
{
	int cb_s = read_int(r);
	string s = to_lower_copy(string(reinterpret_cast<const char*>(r), cb_s));
	r += cb_s;
	return s;
}
Esempio n. 4
0
int main()
{
	Cmix_file::enable_ft_support();
	xcc_dirs::load_from_registry();
	string dir = xcc_dirs::get_dir(game_dune2);

	Cxd2_files files;
	if (files.load(dir))
		return 1;
	file_put(xcc_dirs::get_data_dir() + "xd2 files.xif", files.save().vdata());
	shared_data exe = file_get(dir + "dune2.exe");
	if (!exe.size())
		return 1;
	const char* e = reinterpret_cast<const char*>(exe.data());
	auto bt = reinterpret_cast<const t_building_type*>(&exe[194010]);
	for (auto& i : boost::make_iterator_range(bt, bt + 19))
	{
		ofstream("../xd2 be/dune/objects/" + to_lower_copy(string(e + 229504 + i.name)) + ".ini")
			<< "cameo = " << i.cameo_shp_index << endl
			<< "class = structure" << endl
			<< "cost = " << i.cost << endl
			<< "cx = " << (i.size == 0 || i.size == 2 ? 1 : i.size == 1 || i.size == 3 || i.size == 4 ? 2 : 3) << endl
			<< "cy = " << (i.size == 0 || i.size == 1 ? 1 : i.size == 2 || i.size == 3 || i.size == 5 ? 2 : 3) << endl
			<< "icon = " << i.icon_index << endl
			<< "power = " << i.power_in << endl
			<< "sight = " << i.sight << endl
			<< "strength = " << i.strength << endl
			<< "techlevel = " << i.techlevel << endl
			<< "wsa = " << e + 229504 + i.wsa << endl
			;
	}
	auto ut = reinterpret_cast<const t_unit_type*>(&exe[195840]);
	for (auto& i : boost::make_iterator_range(ut, ut + 27))
	{
		ofstream("../xd2 be/dune/objects/" + to_lower_copy(string(e + 229504 + i.name)) + ".ini")
			<< "body = " << i.body_shp_index << endl
			<< "cameo = " << i.cameo_shp_index << endl
			<< "cost = " << i.cost << endl
			<< "sight = " << i.sight << endl
			<< "speed = " << i.speed << endl
			<< "strength = " << i.strength << endl
			<< "turret = " << i.turret_shp_index << endl
			<< "wsa = " << e + 229504 + i.wsa << endl
			;
	}
	return 0;
}
Esempio n. 5
0
	map<string, int> words(string const &text) {
	  map<string, int> words;

	  /* This feels hacky, but short of writing a custom tokenizer,
	     it also feels like the simplest solution to these tests. */
	  regex re("^[']|[[:space:]]+[']|[']+[[:space:]]|[']$");
	  string result = regex_replace(text,re," ");

	  char_separator<char> sep(",.:!&@$%^&\n ");
	  tokenizer<char_separator<char>> tokens(result, sep);

	  for (auto &&word: tokens) words[to_lower_copy(word)] += 1;

	  return words;
	}
Esempio n. 6
0
void RegTree::LoadRealChildren( RegNode *node )
{
	if (node->m_realKey != NULL)
	{
		ClearRealChildren(node);

		for (DWORD index = 0; ; index++)
		{
			WCHAR keyName[MAX_KEY_LENGTH + 1];
			DWORD keyNameLen = _countof(keyName);
			WCHAR className[MAX_PATH + 1];
			DWORD classNameLen = _countof(className);
			if (Real_RegEnumKeyExW(node->m_realKey, index, keyName, &keyNameLen, NULL, className, &classNameLen, NULL) != ERROR_SUCCESS)
				break;

			HKEY newKey;
			if (Real_RegOpenKeyExW(node->m_realKey, keyName, 0, KEY_ALL_ACCESS, &newKey) != ERROR_SUCCESS)
				continue;

			typedef RegNodeList::index<RegNodeIndex::Name>::type Index;
			Index &childIndex = node->m_children.get<RegNodeIndex::Name>();
			Index::iterator iter = childIndex.find(to_lower_copy(wstring(keyName)));
			if (iter != childIndex.end())
				continue;

			auto_ptr<RegNode> newNode = RegNode::CreateReal(node->m_rootKey, keyName, newKey);
			newNode->m_parent = node;
			node->m_children.push_back(newNode.release());
		}

		BYTE *data = (BYTE*)malloc(1000000);
		for (DWORD index = 0; ; index++)
		{
			WCHAR valueName[MAX_VALUE_NAME_LENGTH + 1];
			DWORD valueNameLen = _countof(valueName);
			DWORD dataType = 0;
			DWORD dataSize =1000000;
			if (Real_RegEnumValueW(node->m_realKey, index, valueName, &valueNameLen, NULL, &dataType, data, &dataSize) != ERROR_SUCCESS)
				break;

			auto_ptr<RegValue> newValue = RegValue::Create(RegValueType_Real, valueName, dataType, data, dataSize);
			node->m_values.push_back(newValue.release());
		}
		free(data);
	}
}
Esempio n. 7
0
RegNode* RegTree::OpenKey( const RegPath &path, bool openAlways, LPDWORD disposition )
{
	RegNode *root = GetRoot(path.m_rootKey);
	if (path.m_segments.empty())
		return root;
 
	RegNode *parent = root;
	wstring subKey;
	BOOST_FOREACH(const wstring &segment, path.m_segments)
	{
		if (!subKey.empty())
			subKey += L"\\";
		subKey += segment;

		typedef RegNodeList::index<RegNodeIndex::Name>::type Index;
		Index &index = parent->m_children.get<RegNodeIndex::Name>();
		Index::iterator iter = index.find(to_lower_copy(segment));
		if (iter != index.end())
		{
			parent = *iter;
			if (openAlways && parent->m_type == RegNodeType_Real)
			{
				ClearRealChildren(parent);
				parent->m_type = RegNodeType_Normal;
			}
		}
		else
		{
			HKEY newKey;
			if (Real_RegOpenKeyExW(path.m_rootKey, subKey.c_str(), 0, KEY_ALL_ACCESS, &newKey) == ERROR_SUCCESS)
			{
				RegNode *newNode;
				if (openAlways)
					newNode = RegNode::CreateNormal(path.m_rootKey, segment, newKey).release();
				else
					newNode = RegNode::CreateReal(path.m_rootKey, segment, newKey).release();
				newNode->m_parent = parent;
				parent->m_children.push_back(newNode);
				parent = newNode;
				if (openAlways && disposition != NULL)
					*disposition = REG_OPENED_EXISTING_KEY;
			}
			else if (openAlways)
			{
				RegNode *newNode = RegNode::CreateNormal(path.m_rootKey, segment, NULL).release();
				newNode->m_parent = parent;
				parent->m_children.push_back(newNode);
				parent = newNode;
				if (disposition != NULL)
					*disposition = REG_CREATED_NEW_KEY;
			}
			else
			{
				parent = NULL;
				break;
			}
		}
	}

	return parent;
}
Esempio n. 8
0
void FileList::addPath(const FilePath &p) {
	_files.push_back(p);
	_fileMap.insert(std::make_pair(to_lower_copy(p.filePath.stem()), --_files.end()));
}