Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions src/Ormin/OBSLexicalParser/TES4/Context/ESMAnalyzer.php
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ public function getScriptType($scriptName)
$tryAgainst = preg_replace("#_#", "", $scriptName);

if (!isset($this->scriptTypes[$tryAgainst])) {
throw new ConversionException("Script " . $scriptName . " not found in ESM - cannot find its script type.");
throw new ConversionException("Script {$scriptName} not found in ESM - cannot find its script type.");
}

return $this->scriptTypes[$tryAgainst];
Expand All @@ -263,9 +263,9 @@ public function resolveScriptTypeByItsAttachedName($attachedName)


if ( //three preg matches are for performance reasons - much better than grouping
preg_match("#REFR................EDID..(?i)" . $attachedName . "(?-i)\x{00}NAME..(....)#s", $this->esm, $refrFormidMatches) ||
preg_match("#ACRE................EDID..(?i)" . $attachedName . "(?-i)\x{00}NAME..(....)#s", $this->esm, $acreFormidMatches) ||
preg_match("#ACHR................EDID..(?i)" . $attachedName . "(?-i)\x{00}NAME..(....)#s", $this->esm, $achrFormidMatches)
preg_match("#REFR................EDID..(?i){$attachedName}(?-i)\x{00}NAME..(....)#s", $this->esm, $refrFormidMatches) ||
preg_match("#ACRE................EDID..(?i){$attachedName}(?-i)\x{00}NAME..(....)#s", $this->esm, $acreFormidMatches) ||
preg_match("#ACHR................EDID..(?i){$attachedName}(?-i)\x{00}NAME..(....)#s", $this->esm, $achrFormidMatches)
) {

if(!empty($refrFormidMatches)) {
Expand Down Expand Up @@ -295,9 +295,9 @@ public function resolveScriptTypeByItsAttachedName($attachedName)
}

if($searchedFormType != "NPC_") {
preg_match("#".$searchedFormType."........" . $targetFormidString . ".*?SCRI..(....)#s", $this->esm, $matches);
preg_match("#".$searchedFormType."........{$targetFormidString}.*?SCRI..(....)#s", $this->esm, $matches);
} else {
if (preg_match("#NPC_(....)...." . $targetFormidString . "#s", $this->esm, $failoverMatches, PREG_OFFSET_CAPTURE)) {
if (preg_match("#NPC_(....)....{$targetFormidString}#s", $this->esm, $failoverMatches, PREG_OFFSET_CAPTURE)) {
$baseDataOffset = $failoverMatches[0][1] + 24;
$dataLengthMatch = $failoverMatches[1][0];
$dataLength = 0;
Expand All @@ -315,12 +315,12 @@ public function resolveScriptTypeByItsAttachedName($attachedName)

} else {
//Just go with usual matching via EDID
preg_match("#EDID..(?i)" . $attachedName . "(?-i)\x{00}.*?SCRI..(....)#s", $this->esm, $matches);
preg_match("#EDID..(?i){$attachedName}(?-i)\x{00}.*?SCRI..(....)#s", $this->esm, $matches);

}

if (empty($matches)) {
throw new ConversionException("Cannot resolve script type by searching its base form edid " . $attachedName);
throw new ConversionException("Cannot resolve script type by searching its base form edid {$attachedName}");
}

$hex = $matches[1];
Expand All @@ -336,10 +336,10 @@ public function resolveScriptTypeByItsAttachedName($attachedName)
}


preg_match("#SCPT........" . $hexString . "....EDID..([a-zA-Z0-9]+)#si", $this->esm, $dataMatches);
preg_match("#SCPT........{$hexString}....EDID..([a-zA-Z0-9]+)#si", $this->esm, $dataMatches);

if (empty($dataMatches)) {
throw new ConversionException("For EDID " . $attachedName . " and script formid " . $hexFormid . " we couldn't find any scripts in ESM.");
throw new ConversionException("For EDID {$attachedName} and script formid {$hexFormid} we couldn't find any scripts in ESM.");
}

$customType = TES5TypeFactory::memberByValue($dataMatches[1]);
Expand All @@ -350,4 +350,4 @@ public function resolveScriptTypeByItsAttachedName($attachedName)

}

}
}