DayZ 1.27
DayZ Explorer by KGB
 
Загрузка...
Поиск...
Не найдено

◆ GetModelName()

string CGame::GetModelName ( string class_name)
inlineprivate

Get name of the p3d file of the given class name.

Аргументы
classname of the desired object
Возвращает
Name of the object's p3d file (without the '.p3d' suffix)

См. определение в файле Game.c строка 487

488 {
489 if ( class_name != "" )
490 {
491 string cfg = "CfgVehicles " + class_name + " model";
492 string model_path;
493 if ( GetGame().ConfigGetText(cfg, model_path) )
494 {
495 int to_substring_end = model_path.Length() - 4; // -4 to leave out the '.p3d' suffix
496 int to_substring_start = 0;
497
498 // Currently we have model path. To get the name out of it we need to parse this string from the end and stop at the first found '\' sign
499 for (int i = to_substring_end; i > 0; i--)
500 {
501 string sign = model_path.Get(i);
502 if ( sign == "\\" )
503 {
504 to_substring_start = i + 1;
505 break
506 }
507 }
508
509 string model_name = model_path.Substring(to_substring_start, to_substring_end - to_substring_start);
510 return model_name;
511 }
512 }
513
514 return "UNKNOWN_P3D_FILE";
515 }
class OptionSelectorMultistate extends OptionSelector class_name
proto bool ConfigGetText(string path, out string value)
Get string value from config on path.
proto native CGame GetGame()
proto native int Length()
Returns length of string.
proto string Get(int index)
Gets n-th character from string.
proto string Substring(int start, int len)
Substring of 'str' from 'start' position 'len' number of characters.

Перекрестные ссылки class_name, ConfigGetText(), string::Get(), GetGame(), string::Length() и string::Substring().

Используется в IEntity::GetModelName().