I am working on my "PHP Genie" project which reads/edits/writes Scenarios and Saved-Games. Currently, I am starting version 2. I will however give a few snippets from version 1 which is still a beta. Version 3 will have a User-Interface. I also intend to make a mini-map viewer in version 3 or 4.
Because I am still working on reading scenario contents, I have used a method to skip to the scenario's triggers using a Magic-Keyword. For now, here are the snippets...
Run PHP Designer and set the Preferences for debugging to the "php.exe" file.
Create "Index.php" with the following contents:
<?
# Extend limits for huge amounts of triggers:
ini_set ( 'memory_limit' , '1024M' ) ;
ini_set ( 'max_execution_time' , 300 ) ;
# Set class:
class Scenario
{
# The output variable:
static $O ;
# This function must be absolutely perfect.
# The slightest error is not at all acceptable.
# It writes all triggers into raw scenario data.
# I prefer the PACK function rather than SPRINTF.
function Write ( $I )
{
$W = 0 ;
self :: $X .= pack ( 'L1' , count ( $I ) ) ; # <TriggersCount>
foreach ( $I as $T )
{
$T [4 ] = substr ( $T [ 4 ] , 0 , 64 ) ; # Maximum length 64
$T [5 ] = substr ( $T [ 5 ] , 0 , 44 ) ; # Maximum length 44
self :: $X .= pack ( 'L1' , ( $T [0 ] ? 1 : 0 ) ) ; # < Enabled>
self :: $X .= pack ( 'L1' , ( $T [1 ] ? 1 : 0 ) ) ; # < Looping>
self :: $X .= pack ( 'C1' , 0 ) ; # <Unknown_1>
self :: $X .= pack ( 'C1' , ( $T [2 ] ? 1 : 0 ) ) ; # < Objective>
self :: $X .= pack ( 'L1' , ( isset ( $T [3 ] ) ? $T [ 3 ] : 0 ) ) ; # < ObjOrder>
self :: $X .= pack ( 'C1' , 0 ) ; # <Unknown_2_1>
self :: $X .= pack ( 'C1' , 0 ) ; # <Unknown_2_2>
self :: $X .= pack ( 'C1' , 0 ) ; # <Unknown_2_3>
self :: $X .= pack ( 'C1' , 0 ) ; # <Unknown_2_4>
self :: $X .= pack ( 'L1' , strlen ( $T [4 ] ) + 1 ) ; # < DescLength>
self :: $X .= pack ( 'A*' , $T [4 ] ) . pack ( 'C1' , 0 ) ; # < DescValue>
self :: $X .= pack ( 'L1' , strlen ( $T [5 ] ) + 1 ) ; # < NameLength>
self :: $X .= pack ( 'A*' , $T [5 ] ) . pack ( 'C1' , 0 ) ; # < NameValue>
self :: $X .= pack ( 'L1' , count ( $T [E ] ) ) ; # < EffectsCounts>
if ( count ( $T [E ] ) )
{
foreach ( $T [E ] as $E )
{
self :: $X .= pack ( 'L1' , ( isset ( $E [0 ] ) ? $E [ 0 ] : 0 ) ) ; # < Type>
self :: $X .= pack ( 'L1' , 23 ) ; # <Check>
self :: $X .= pack ( 'L1' , ( isset ( $E [Z ] ) ? $E [ Z ] : -1 ) ) ; # < AIGoal>
self :: $X .= pack ( 'L1' , ( isset ( $E [Q ] ) ? $E [ Q ] : -1 ) ) ; # < Amount>
self :: $X .= pack ( 'L1' , ( isset ( $E [R ] ) ? $E [ R ] : -1 ) ) ; # < Resource>
self :: $X .= pack ( 'L1' , ( isset ( $E [M ] ) ? $E [ M ] : -1 ) ) ; # < Diplomacy>
self :: $X .= pack ( 'L1' , ( count ( $E [S ] ) ? count ( $E [ S ] ) : -1 ) ) ; # < Selected>
self :: $X .= pack ( 'L1' , ( isset ( $E [O ] ) ? $E [ O ] : -1 ) ) ; # < UnitLoc>
self :: $X .= pack ( 'L1' , ( isset ( $E [U ] ) ? $E [ U ] : -1 ) ) ; # < UnitConst>
self :: $X .= pack ( 'L1' , ( isset ( $E [P ] ) ? $E [ P ] : -1 ) ) ; # < PSource>
self :: $X .= pack ( 'L1' , ( isset ( $E [E ] ) ? $E [ E ] : -1 ) ) ; # < PTarget>
self :: $X .= pack ( 'L1' , ( isset ( $E [H ] ) ? $E [ H ] : -1 ) ) ; # < Tech>
self :: $X .= pack ( 'L1' , ( isset ( $E [B ] ) ? $E [ B ] : -1 ) ) ; # < StringID>
self :: $X .= pack ( 'L1' , ( isset ( $E [K ] ) ? $E [ K ] : -1 ) ) ; # < Unknown>
self :: $X .= pack ( 'L1' , ( isset ( $E [T ] ) ? $E [ T ] : -1 ) ) ; # < Time>
self :: $X .= pack ( 'L1' , ( isset ( $E [I ] ) ? $E [ I ] : -1 ) ) ; # < Trigger>
self :: $X .= pack ( 'L1' , ( isset ( $E [L ] ) ? $E [ L ] [ 0 ] : -1 ) ) ; # < Location> [ X]
self :: $X .= pack ( 'L1' , ( isset ( $E [L ] ) ? $E [ L ] [ 1 ] : -1 ) ) ; # < Location> [ Y]
self :: $X .= pack ( 'L1' , ( isset ( $E [A ] ) ? $E [ A ] [ 0 ] [ 0 ] : -1 ) ) ; # < Area> [ 0] [ X]
self :: $X .= pack ( 'L1' , ( isset ( $E [A ] ) ? $E [ A ] [ 0 ] [ 1 ] : -1 ) ) ; # < Area> [ 0] [ Y]
self :: $X .= pack ( 'L1' , ( isset ( $E [A ] ) ? $E [ A ] [ 1 ] [ 0 ] : -1 ) ) ; # < Area> [ 1] [ X]
self :: $X .= pack ( 'L1' , ( isset ( $E [A ] ) ? $E [ A ] [ 1 ] [ 1 ] : -1 ) ) ; # < Area> [ 1] [ Y]
self :: $X .= pack ( 'L1' , ( isset ( $E [G ]