src/Analyzers/HeaderAnalyzer.php
protected function skipTriggerInfo()
    {
        // Effects and triggers are of variable size, but conditions are
        // constant.
        $conditionSize = (
            (11 * 4) + // 11 ints
            (4 * 4) + // area (4 ints)
            (3 * 4) // 3 ints
        );

        if ($this->version->isHDPatch4) {
            $conditionSize += 2 * 4; // 2 ints
        }

        $numTriggers = $this->readHeader('l', 4);
        for ($i = 0; $i < $numTriggers; $i += 1) {
            $this->position += 4 + (2 * 1) + (3 * 4); // int, 2 bools, 3 ints
            $descriptionLength = $this->readHeader('l', 4);
            // HD edition 4.x saves a length of -1 when the string is absent,
            // whereas older versions would use 0. That used to work fine
            // without this guard, but now we should only skip if the length is
            // positive.
            if ($descriptionLength > 0) {
                $this->position += $descriptionLength;
            }
            $nameLength = $this->readHeader('l', 4);
            if ($nameLength > 0) {
                $this->position += $nameLength;
            }
            $numEffects = $this->readHeader('l', 4);
            for ($j = 0; $j < $numEffects; $j += 1) {
                $this->position += 6 * 4; // 6 ints
                $numSelectedObjects = $this->readHeader('l', 4);
                if ($numSelectedObjects === -1) {
                    $numSelectedObjects = 0;
                }
                $this->position += 9 * 4; // 9 ints
                $this->position += 2 * 4; // location (2 ints)
                $this->position += 4 * 4; // area (2 locations)
                $this->position += 3 * 4; // 3 ints
                if ($this->version->isHDPatch4) {
                    $this->position += 4; // int for the new Attack Stance effect
                }
                $textLength = $this->readHeader('l', 4);
                if ($textLength > 0) {
                    $this->position += $textLength;
                }
                $soundFileNameLength = $this->readHeader('l', 4);
                if ($soundFileNameLength > 0) {
                    $this->position += $soundFileNameLength;
                }
                $this->position += $numSelectedObjects * 4; // unit IDs (one int each)
            }
            $this->position += $numEffects * 4; // effect order (list of ints)
            $numConditions = $this->readHeader('l', 4);
            $this->position += $numConditions * $conditionSize; // conditions
            $this->position += $numConditions * 4; // conditions order (list of ints)
        }

        if ($numTriggers > 0) {
            $this->position += $numTriggers * 4; // trigger order (list of ints)
            // TODO perhaps also set game type to Scenario here?
        }
    }
protected function skipTriggerInfo()
    {
        // Effects and triggers are of variable size, but conditions are
        // constant.
        $conditionSize = (
            (11 * 4) + // 11 ints
            (4 * 4) + // area (4 ints)
            (3 * 4) // 3 ints
        );

        if ($this->version->isHDPatch4) {
            $conditionSize += 2 * 4; // 2 ints
        }

        $numTriggers = $this->readHeader('l', 4);
        for ($i = 0; $i < $numTriggers; $i += 1) {
            $this->position += 4 + (2 * 1) + (3 * 4); // int, 2 bools, 3 ints
            $descriptionLength = $this->readHeader('l', 4);
            // HD edition 4.x saves a length of -1 when the string is absent,
            // whereas older versions would use 0. That used to work fine
            // without this guard, but now we should only skip if the length is
            // positive.
            if ($descriptionLength > 0) {
                $this->position += $descriptionLength;
            }
            $nameLength = $this->readHeader('l', 4);
            if ($nameLength > 0) {
                $this->position += $nameLength;
            }
            $numEffects = $this->readHeader('l', 4);
            for ($j = 0; $j < $numEffects; $j += 1) {
                $this->position += 6 * 4; // 6 ints
                $numSelectedObjects = $this->readHeader('l', 4);
                if ($numSelectedObjects === -1) {
                    $numSelectedObjects = 0;
                }
                $this->position += 9 * 4; // 9 ints
                $this->position += 2 * 4; // location (2 ints)
                $this->position += 4 * 4; // area (2 locations)
                $this->position += 3 * 4; // 3 ints
                if ($this->version->isHDPatch4) {
                    $this->position += 4; // int for the new Attack Stance effect
                }
                $textLength = $this->readHeader('l', 4);
                if ($textLength > 0) {
                    $this->position += $textLength;
                }
                $soundFileNameLength = $this->readHeader('l', 4);
                if ($soundFileNameLength > 0) {
                    $this->position += $soundFileNameLength;
                }
                $this->position += $numSelectedObjects * 4; // unit IDs (one int each)
            }
            $this->position += $numEffects * 4; // effect order (list of ints)
            $numConditions = $this->readHeader('l', 4);
            $this->position += $numConditions * $conditionSize; // conditions
            $this->position += $numConditions * 4; // conditions order (list of ints)
        }

        if ($numTriggers > 0) {
            $this->position += $numTriggers * 4; // trigger order (list of ints)
            // TODO perhaps also set game type to Scenario here?
        }
    }
protected function skipTriggerInfo ( ) { // Effects and triggers are of variable size, but conditions are // constant. $ conditionSize = ( ( 11 * 4 ) + // 11 ints ( 4 * 4 ) + // area (4 ints) ( 3 * 4 ) // 3 ints ) ; if ( $ this -> version -> isHDPatch4 ) { $ conditionSize += 2 * 4 ; // 2 ints } $ numTriggers = $ this -> readHeader ( 'l' , 4 ) ; for ( $ i = 0 ; $ i < $ numTriggers ; $ i += 1 ) { $ this -> position += 4 + ( 2 * 1 ) + ( 3 * 4 ) ; // int, 2 bools, 3 ints $ descriptionLength = $ this -> readHeader ( 'l' , 4 ) ; // HD edition 4.x saves a length of -1 when the string is absent, // whereas older versions would use 0. That used to work fine // without this guard, but now we should only skip if the length is // positive. if ( $ descriptionLength > 0 ) { $ this -> position += $ descriptionLength ; } $ nameLength = $ this -> readHeader ( 'l' , 4 ) ; if ( $ nameLength > 0 ) { $ this -> position += $ nameLength ; } $ numEffects = $ this -> readHeader ( 'l' , 4 ) ; for ( $ j = 0 ; $ j < $ numEffects ; $ j += 1 ) { $ this -> position += 6 * 4 ; // 6 ints $ numSelectedObjects = $ this -> readHeader ( 'l' , 4 ) ; if ( $ numSelectedObjects === - 1 ) { $ numSelectedObjects = 0 ; } $ this -> position += 9 * 4 ; // 9 ints $ this -> position += 2 * 4 ; // location (2 ints) $ this -> position += 4 * 4 ; // area (2 locations) $ this -> position += 3 * 4 ; // 3 ints if ( $ this -> version -> isHDPatch4 ) { $ this -> position += 4 ; // int for the new Attack Stance effect } $ textLength = $ this -> readHeader ( 'l' , 4 ) ; if ( $ textLength > 0 ) { $ this -> position += $ textLength ; } $ soundFileNameLength = $ this -> readHeader ( 'l' , 4 ) ; if ( $ soundFileNameLength > 0 ) { $ this -> position += $ soundFileNameLength ; } $ this -> position += $ numSelectedObjects * 4 ; // unit IDs (one int each) } $ this -> position += $ numEffects * 4 ; // effect order (list of ints) $ numConditions = $ this -> readHeader ( 'l' , 4 ) ; $ this -> position += $ numConditions * $ conditionSize ; // conditions $ this -> position += $ numConditions * 4 ; // conditions order (list of ints) } if ( $ numTriggers > 0 ) { $ this -> position += $ numTriggers * 4 ; // trigger order (list of ints) // TODO perhaps also set game type to Scenario here? } }
Skip a scenario triggers info block. See ScenarioTriggersAnalyzer for
contents of a trigger block.
Skip a scenario triggers info block . See ScenarioTriggersAnalyzer for contents of a trigger block .