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

◆ RegisterParticle() [2/2]

static int ParticleList::RegisterParticle ( string root_path,
string file_name )
inlinestaticprivate

Registers a particle and returns its ID.

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

453 {
454 //takes care of case sensitivity issue
455 root_path.ToLower();
456 file_name.ToLower();
457
458 //makes sure filename is really just a filename
459 string justName = file_name;
460 int lastIndex = file_name.LastIndexOf("/");
461 if (lastIndex >= 0)
462 justName = justName.Substring(lastIndex + 1, justName.Length() - (lastIndex + 1));
463
464 if (!m_ParticlePaths)
465 m_ParticlePaths = new map<int, string>;
466
467 if (!m_ParticleNames)
468 m_ParticleNames = new map<string, int>;
469
470 string path = string.Format("%1%2", root_path, file_name);
471 string fullPath = string.Format("%1.ptc", path);
472
473 if ( !FileExist(fullPath) )
474 {
475 string devMsgSuffix;
476 #ifdef DEVELOPER
477 devMsgSuffix = " Then rebuild 'scripts' and 'graphics' PBOs.";
478 #endif
479 ErrorEx(string.Format("Particle file not found! <%1> Correct path to this particle in script file ParticleList.c!%2",
480 fullPath, devMsgSuffix), ErrorExSeverity.WARNING);
481 //return ParticleList.INVALID;
482 }
483
484 int existingNameId;
485 if (m_ParticleNames.Find(justName, existingNameId))
486 {
487 int existingPathId;
488 if (m_ParticlePaths.GetKeyByValueChecked(path, existingPathId))
489 {
490 if (existingNameId == existingPathId)
491 {
492 return existingNameId; // We have already registered this exact file
493 }
494 else
495 {
496 ErrorEx(string.Format("ParticleNames and ParticlePaths array are containing conflicting data. ID %1 vs ID %2", existingNameId, existingPathId));
497 }
498 }
499 else
500 {
501 ErrorEx(string.Format("Duplicate particle filename: %1; GetParticleIDByName will only work with the first path if there are two different paths.", file_name), ErrorExSeverity.WARNING);
502 }
503 }
504 else
505 {
506 m_ParticleNames.Insert(justName, m_lastID + 1);
507 }
508
509 ++m_lastID;
511 return m_lastID;
512 }
string path
Определения OptionSelectorMultistate.c:142
static int m_lastID
Определения ParticleList.c:16
static ref map< int, string > m_ParticlePaths
Определения ParticleList.c:13
static ref map< string, int > m_ParticleNames
Определения ParticleList.c:14
ErrorExSeverity
Определения EnDebug.c:62
enum ShapeType ErrorEx
proto bool FileExist(string name)
Check existence of file.
proto native int Length()
Returns length of string.
proto native int LastIndexOf(string sample)
Finds last 'sample' in 'str'. Returns -1 when not found.
proto string Substring(int start, int len)
Substring of 'str' from 'start' position 'len' number of characters.
static proto string Format(string fmt, void param1=NULL, void param2=NULL, void param3=NULL, void param4=NULL, void param5=NULL, void param6=NULL, void param7=NULL, void param8=NULL, void param9=NULL)
Gets n-th character from string.
proto int ToLower()
Changes string to lowercase. Returns length.

Перекрестные ссылки ErrorEx, FileExist(), string::LastIndexOf(), string::Length(), m_lastID, m_ParticleNames, m_ParticlePaths, path, string::Substring() и string::ToLower().