u16 EDetail::_AddVert(const Fvector& p, float u, float v) { EVertexIn V(p,u,v); for (u16 k=0; k<(u16)number_vertices; k++) if (V.similar((EVertexIn&)vertices[k])) return k; number_vertices++; vertices = (fvfVertexIn*)xr_realloc(vertices,number_vertices*sizeof(fvfVertexIn)); vertices[number_vertices-1] = V; return u16(number_vertices-1); }
void CMemoryStream::write(const void* ptr, u32 count) { if (position+count > mem_size) { // reallocate if (mem_size==0) mem_size=128; while (mem_size <= (position+count)) mem_size*=2; data = (u8*)xr_realloc(data,mem_size); } CopyMemory(data+position,ptr,count); position+=count; if (position>file_size) file_size=position; }
void xrSASH::LoopNative() { string_path in_file; FS.update_path(in_file, "$app_data_root$", m_strBenchCfgName); CInifile ini(in_file); IReader* R = FS.r_open(in_file); if (R) { FS.r_close(R); int test_count = ini.line_count("benchmark"); LPCSTR test_name, t; shared_str test_command; for (int i = 0; i < test_count; ++i) { ini.r_line("benchmark", i, &test_name, &t); //xr_strcpy(g_sBenchmarkName, test_name); test_command = ini.r_string_wb("benchmark", test_name); u32 cmdSize = test_command.size() + 1; Core.Params = (char*)xr_realloc(Core.Params, cmdSize); xr_strcpy(Core.Params, cmdSize, test_command.c_str()); xr_strlwr(Core.Params); RunBenchmark(test_name); // Output results ReportNative(test_name); } } else Msg("oa:: Native path can't find \"%s\" config file.", in_file); FlushLog(); }
void CGameFont::Initialize (LPCSTR cShader, LPCSTR cTextureName) { string_path cTexture; LPCSTR _lang = pSettings->r_string("string_table", "font_prefix"); bool is_di = strstr(cTextureName, "ui_font_hud_01") || strstr(cTextureName, "ui_font_hud_02") || strstr(cTextureName, "ui_font_console_02"); if(_lang && !is_di) strconcat (sizeof(cTexture),cTexture, cTextureName, _lang); else strcpy_s (cTexture, sizeof(cTexture), cTextureName); uFlags &=~fsValid; vTS.set (1.f,1.f); // обязательно !!! eCurrentAlignment = alLeft; vInterval.set (1.f,1.f); strings.reserve (128); // check ini exist string_path fn,buf; strcpy_s (buf,cTexture); if (strext(buf)) *strext(buf)=0; R_ASSERT2 (FS.exist(fn,"$game_textures$",buf,".ini"),fn); CInifile* ini = CInifile::Create(fn); nNumChars = 0x100; TCMap = ( Fvector* ) xr_realloc( ( void* ) TCMap , nNumChars * sizeof( Fvector ) ); if ( ini->section_exist( "mb_symbol_coords" ) ) { nNumChars = 0x10000; TCMap = ( Fvector* ) xr_realloc( ( void* ) TCMap , nNumChars * sizeof( Fvector ) ); uFlags |= fsMultibyte; fHeight = ini->r_float( "mb_symbol_coords" , "height" ); fXStep = ceil( fHeight / 2.0f ); // Searching for the first valid character Fvector vFirstValid = {0,0,0}; if ( ini->line_exist( "mb_symbol_coords" , "09608" ) ) { Fvector v = ini->r_fvector3( "mb_symbol_coords" , "09608" ); vFirstValid.set( v.x , v.y , 1 + v[2] - v[0] ); } else for ( u32 i=0 ; i < nNumChars ; i++ ) { sprintf_s( buf ,sizeof(buf), "%05d" , i ); if ( ini->line_exist( "mb_symbol_coords" , buf ) ) { Fvector v = ini->r_fvector3( "mb_symbol_coords" , buf ); vFirstValid.set( v.x , v.y , 1 + v[2] - v[0] ); break; } } // Filling entire character table for ( u32 i=0 ; i < nNumChars ; i++ ) { sprintf_s( buf ,sizeof(buf), "%05d" , i ); if ( ini->line_exist( "mb_symbol_coords" , buf ) ) { Fvector v = ini->r_fvector3( "mb_symbol_coords" , buf ); TCMap[i].set( v.x , v.y , 1 + v[2] - v[0] ); } else TCMap[i] = vFirstValid; // "unassigned" unprintable characters } // Special case for space TCMap[ 0x0020 ].set( 0 , 0 , 0 ); // Special case for ideographic space TCMap[ 0x3000 ].set( 0 , 0 , 0 ); }else if (ini->section_exist("symbol_coords")) { float d = 0.0f; //. if(ini->section_exist("width_correction")) //. d = ini->r_float("width_correction", "value"); fHeight = ini->r_float("symbol_coords","height"); for (u32 i=0; i<nNumChars; i++){ sprintf_s (buf,sizeof(buf),"%03d",i); Fvector v = ini->r_fvector3("symbol_coords",buf); TCMap[i].set (v.x,v.y,v[2]-v[0]+d); } }else{ if (ini->section_exist("char widths")){ fHeight = ini->r_float("char widths","height"); int cpl = 16; for (u32 i=0; i<nNumChars; i++){ sprintf_s (buf,sizeof(buf),"%d",i); float w = ini->r_float("char widths",buf); TCMap[i].set ((i%cpl)*fHeight,(i/cpl)*fHeight,w); } }else{ R_ASSERT(ini->section_exist("font_size")); fHeight = ini->r_float("font_size","height"); float width = ini->r_float("font_size","width"); const int cpl = ini->r_s32 ("font_size","cpl"); for (u32 i=0; i<nNumChars; i++) TCMap[i].set ((i%cpl)*width,(i/cpl)*fHeight,width); } } fCurrentHeight = fHeight; CInifile::Destroy (ini); // Shading pFontRender->Initialize(cShader, cTexture); }