void strreplaceall						(xr_string &str, LPCSTR S, LPCSTR N)
{
	LPCSTR	A;
	int		S_len = xr_strlen(S);
	while ((A = strstr(str.c_str(),S)) != 0)
		str.replace(A - str.c_str(),S_len,N);
}
Exemple #2
0
void TDB_packer::_load_(const xr_string& fname)
{
    	lbIncludeFolders->Items->Clear		();
    	lbIncludeFiles->Items->Clear		();

     	CInifile ini						(fname.c_str());

        if(ini.section_exist("include_folders"))
        {
           CInifile::Sect S 		= ini.r_section("include_folders");
           CInifile::SectCIt it 		= S.Data.begin();
           CInifile::SectCIt it_e 	= S.Data.end();
           for( ;it!=it_e; ++it)
           {
           		WideString 					ws;
                ws 							= (*it).first.c_str();
               lbIncludeFolders->Items->Add	(ws);
           }
        }
        if(ini.section_exist("include_files"))
        {
           CInifile::Sect S 		= ini.r_section("include_files");
           CInifile::SectCIt it 	= S.Data.begin();
           CInifile::SectCIt it_e 	= S.Data.end();
           for( ;it!=it_e; ++it)
           {
           		WideString 					ws;
                ws 							= (*it).first.c_str();
               lbIncludeFiles->Items->Add	(ws);
           }
        }
        Caption	=	fname.c_str();
}
Exemple #3
0
void CWeaponMagazined::GetBriefInfo(xr_string& str_name, xr_string& icon_sect_name, xr_string& str_count)
{
	int	AE = GetAmmoElapsed();
	int	AC = GetAmmoCurrent();

	if (AE == 0 || 0 == m_magazine.size())
		icon_sect_name = *m_ammoTypes[m_ammoType];
	else
		icon_sect_name = *m_ammoTypes[m_magazine.back().m_LocalAmmoType];

	string256		sItemName;
	strcpy_s(sItemName, *CStringTable().translate(pSettings->r_string(icon_sect_name.c_str(), "inv_name_short")));

	if (HasFireModes())
		strcat_s(sItemName, GetCurrentFireModeStr());

	str_name = sItemName;

	{
		if (!unlimited_ammo())
			sprintf_s(sItemName, "%d/%d", AE, AC - AE);
		else
			sprintf_s(sItemName, "%d/--", AE);

		str_count = sItemName;
	}
}
xr_string	EFS_Utils::AppendFolderToName(xr_string& tex_name, int depth, BOOL full_name)
{
	string1024 nm;
	xr_strcpy(nm,tex_name.c_str());
	tex_name = AppendFolderToName(nm,sizeof(nm),depth,full_name);
	return tex_name;
}
bool EFS_Utils::GetOpenName(LPCSTR initial, xr_string& buffer, bool bMulti, LPCSTR offset, int start_flt_ext )
{
	char			buf	[255*255]; //max files to select
	xr_strcpy			(buf, buffer.c_str());

/*
char* g_SHBF_Folder =("C:\\Program Files");
TCHAR path[_MAX_PATH];
BROWSEINFO info={NULL,NULL,path,"title",BIF_USENEWUI,BrowseCallbackProc, (LPARAM)g_SHBF_Folder };
SHBrowseForFolder       (&info);
*/
/*
	{
		HANDLE hDialog = OSDInit(true, "SDITEST", 0, 0, 0, 0, 0, 0);
		if(hDialog)
		{
			OSDRET osResult=OSDDoModal(hDialog, 0);
			OSDRelease(hDialog);
		}

	}
*/
//	bool bRes = false;
	bool bRes		= GetOpenNameInternal(initial, buf, sizeof(buf), bMulti, offset, start_flt_ext);

	if (bRes)
		buffer=(char*)buf;

	return bRes;
}
bool EFS_Utils::GetSaveName( LPCSTR initial, xr_string& buffer, LPCSTR offset, int start_flt_ext )
{
	string4096 buf;
	strcpy(buf,buffer.c_str());
	bool bRes = GetSaveName(initial,buf,sizeof(buf),offset,start_flt_ext);
	if (bRes) buffer=buf;
	return bRes;
}
Exemple #7
0
LPCSTR _GetItem(LPCSTR src, int index, xr_string& dst, char separator, LPCSTR def, bool trim)
{
    LPCSTR ptr;
    ptr = _SetPos(src, index, separator);
    if (ptr) _CopyVal(ptr, dst, separator);
    else dst = def;
    if (trim) _Trim(dst);
    return dst.c_str();
}
Exemple #8
0
bool CPropHelper::CNameAfterEdit(PropValue* sender, xr_string& edit_val)
{
	CTextValue* V	= dynamic_cast<CTextValue*>(sender); VERIFY(V);
    ListItem* L		= (ListItem*)sender->tag;
    shared_str tmp	= edit_val.c_str();
	bool accepted	= LHelper().NameAfterEdit(L,V->GetValue(),tmp);
    edit_val		= tmp.c_str();
    return 			accepted;
}
Exemple #9
0
LPCSTR _CopyVal(LPCSTR src, xr_string& dst, char separator)
{
    LPCSTR p;
    ptrdiff_t n;
    p = strchr(src, separator);
    n = (p > 0) ? (p - src) : xr_strlen(src);
    dst = src;
    dst = dst.erase(n, dst.length());
    return dst.c_str();
}
bool EFS_Utils::GetOpenName(LPCSTR initial, xr_string& buffer, bool bMulti, LPCSTR offset, int start_flt_ext )
{
	string_path		buf;
	strcpy			(buf,buffer.c_str());
	bool bRes		= GetOpenName(initial,buf,sizeof(buf),bMulti,offset,start_flt_ext);

	if (bRes) 
		buffer=(char*)buf;

	return bRes;
}
Exemple #11
0
xr_string EFS_Utils::ChangeFileExt(const xr_string& src, LPCSTR ext)
{
    return ChangeFileExt(src.c_str(), ext);
}
void print_free_functions				(lua_State *L, const luabind::object &object, LPCSTR header, const xr_string &indent)
{
	u32							count = 0;
	luabind::object::iterator	I = object.begin();
	luabind::object::iterator	E = object.end();
	for ( ; I != E; ++I) {
		if ((*I).type() != LUA_TFUNCTION)
			continue;
		(*I).pushvalue();
		luabind::detail::free_functions::function_rep* rep = 0;
		if (lua_iscfunction(L, -1))
		{
			if (lua_getupvalue(L, -1, 2) != 0)
			{
				// check the magic number that identifies luabind's functions
				if (lua_touserdata(L, -1) == (void*)0x1337)
				{
					if (lua_getupvalue(L, -2, 1) != 0)
					{
						if (!count)
							FastMsg("\n%snamespace %s {",indent.c_str(),header);
						++count;
						rep = static_cast<luabind::detail::free_functions::function_rep*>(lua_touserdata(L, -1));
						std::vector<luabind::detail::free_functions::overload_rep>::const_iterator	i = rep->overloads().begin();
						std::vector<luabind::detail::free_functions::overload_rep>::const_iterator	e = rep->overloads().end();
						for ( ; i != e; ++i) {
							xr_string	S;
							(*i).get_signature(L,S);
							FastMsg("    %sfunction %s%s;",indent.c_str(),rep->name(), process_signature(S).c_str());
						}
						lua_pop(L, 1);
					}
				}
				lua_pop(L, 1);
			}
		}
		lua_pop(L, 1);
	}
	{
		static xr_vector<xr_string> nesting_path;

		xr_string				_indent = indent;
		xr_string				last_key = "?";
		_indent.append			("    ");
		
		object.pushvalue();
		int n_table = lua_gettop(L);
		// Msg("# n_table = %d ", n_table);
		lua_pushnil		(L);		
		int save_top = lua_gettop(L);

// #pragma todo("alpet : при загруженной сохраненке здесь иногда происходит сбой invalid key to 'next', а потом креш в недрах Direct3D ")
		while (lua_next(L, n_table) != 0) {  
			last_key = "~"; 
			int key_type = lua_type(L, -2);			
			if (lua_type(L, -1) == LUA_TTABLE && key_type == LUA_TSTRING && lua_objlen(L, -2) > 0) {				
				last_key = lua_tostring(L, -2);
				LPCSTR	S = last_key.c_str();
				MsgCB("~#CONTEXT: last_key = %s", S);
				string_path script_name;
				sprintf_s(script_name, sizeof(script_name) - 1, "%s.script", S);
				if (nesting_path.size() == 0 && // скан глобального пространства имен
					(last_key == "" || last_key == "config" || last_key == "package" || last_key == "jit" || last_key == "loaded" || last_key == "md_list" ||
   					 FS.exist("$game_scripts$", script_name) )) // с дампом экспортируемых luabind вещей, возникают сбои!
				{
					Msg("! skipping namespace %s ", last_key.c_str());
					lua_pop(L, 1);
					continue;
				}
				
				if (xr_strcmp("_G", S)) {					
					luabind::object		object(L);
					object.set();
					// if (!xr_strcmp("security", S)) { S = S; } /// wtf?
					xr_string path_dump = "";
					for (u32 ns = 0; ns < nesting_path.size(); ns++)
						path_dump = path_dump + nesting_path.at(ns) + ".";

					path_dump = path_dump + S;
					Msg("#dumping namespace %s ", path_dump.c_str());
					nesting_path.push_back(S);

					u32 nest_level = nesting_path.size();
					// если слишком много вложений или начали повторяться строки
					if (nest_level < 2 &&
						!(nest_level > 1 && nesting_path.at(0) == S)
						)
					{
						print_free_functions(L, object, S, _indent);
					}
					else
					{
						// problem detected
						Msg("! WARN: to many nested levels for export = %d, or self-reference detected ", nest_level);
						FlushLog();
						dumper->flush();
					}
					nesting_path.pop_back();

				}
			}
			// #pragma todo("Dima to Dima : Remove this hack if find out why")			
			
			// */			
			// lua_pop	(L, 1);	// remove value from stack
			lua_pop(L, 1);
			if (lua_gettop(L) > save_top)
			{
				Msg("lua_gettop returned %d vs expected %d", lua_gettop(L), save_top);
				lua_settop(L, save_top);
			}
		} 		
		
	}
	if (count)
		FastMsg("%s};",indent.c_str());
}
Exemple #13
0
void CPropHelper::CNameBeforeEdit(PropValue* sender, xr_string& edit_val)
{
	int cnt			=_GetItemCount(edit_val.c_str(),'\\');
	edit_val		= _SetPos(edit_val.c_str(),cnt-1,'\\');
}
void print_free_functions				(lua_State *L, const luabind::object &object, LPCSTR header, const xr_string &indent)
{
	u32							count = 0;
	luabind::object::iterator	I = object.begin();
	luabind::object::iterator	E = object.end();
	for ( ; I != E; ++I) {
		if ((*I).type() != LUA_TFUNCTION)
			continue;
		(*I).pushvalue();
		luabind::detail::free_functions::function_rep* rep = 0;
		if (lua_iscfunction(L, -1))
		{
			if (lua_getupvalue(L, -1, 2) != 0)
			{
				// check the magic number that identifies luabind's functions
				if (lua_touserdata(L, -1) == (void*)0x1337)
				{
					if (lua_getupvalue(L, -2, 1) != 0)
					{
						if (!count)
							Msg("\n%snamespace %s {",indent.c_str(),header);
						++count;
						rep = static_cast<luabind::detail::free_functions::function_rep*>(lua_touserdata(L, -1));
						std::vector<luabind::detail::free_functions::overload_rep>::const_iterator	i = rep->overloads().begin();
						std::vector<luabind::detail::free_functions::overload_rep>::const_iterator	e = rep->overloads().end();
						for ( ; i != e; ++i) {
							xr_string	S;
							(*i).get_signature(L,S);
							Msg("    %sfunction %s%s;",indent.c_str(),rep->name(),process_signature(S).c_str());
						}
						lua_pop(L, 1);
					}
				}
				lua_pop(L, 1);
			}
		}
		lua_pop(L, 1);
	}
	{
		xr_string				_indent = indent;
		_indent.append			("    ");
		object.pushvalue();
		lua_pushnil		(L);
		while (lua_next(L, -2) != 0) {
			if (lua_type(L, -1) == LUA_TTABLE) {
				if (xr_strcmp("_G",lua_tostring(L, -2))) {
					LPCSTR				S = lua_tostring(L, -2);
					luabind::object		object(L);
					object.set			();
					if (!xr_strcmp("security",S)) {
						S = S;
					}
					print_free_functions(L,object,S,_indent);
				}
			}
#pragma todo("Dima to Dima : Remove this hack if find out why")
			if (lua_isnumber(L,-2)) {
				lua_pop(L,1);
				lua_pop(L,1);
				break;
			}
			lua_pop	(L, 1);
		}
	}
	if (count)
		Msg("%s};",indent.c_str());
}