Outpost Universe Forums

Projects & Development => Outpost 2 Programming & Development => Topic started by: Hooman on January 03, 2016, 06:09:54 AM

Title: Tech File Parser Analysis
Post by: Hooman on January 03, 2016, 06:09:54 AM
I was looking through the tech file parsing code in Outpost 2 and thought I'd note the following things:


There are 4 main components the parser deals with:
Comments: Starts with a ";" and runs until the next newline character
Tokens  : An un-quoted sequence of characters (generally uppercase by convention) and underscore
Strings : A quoted sequence of characters (tabs and newlines are stripped)
Integers: An optional minus sign followed by a sequence of digits


The parser scans for the following tokens and parameters:
Code: [Select]
BEGIN_TECH      string:techName    int:techId
CATEGORY        int:category
DESCRIPTION     string:description
TEASER          string:teaser
IMPROVE_DESC    string:improveDesc
REQUIRES        int:requiredTechId
COST            int:cost    [edenCost = plymouthCost]
EDEN_COST       int:cost
PLYMOUTH_COST   int:cost
MAX_SCIENTISTS  int:maxScientists  [4..18]
LAB             int:lab     [1 = Basic, 2 = Standard, 3 = Advanced]
PLAYER_PROP     token:propName    int:newPropVaue
FUNCTION_RESULT token:propName    int:funcParam    [__fastcall func(int playerNum, int funcParam)]
UNIT_PROP       token:unitTypeName    token:propName    int:newPropValue
END_TECH


The following property tokens are supported:
Code: [Select]
UNIT_PROP:
Hit_Points        [Units, but generally Vehicles]
Armor             [Units, but specifically: GuardTower, Lynx, Panther]
Production_Capactity  [Buildings, both factory build rates, and capacity for others]
Move_Speed        [Vehicles]
Sight_Range       [Units, but specifically: LightTower, GuardTower, Weapons]
Rate_Of_Fire      [Weapons]
Build_Time        [Not used in standard tech files]
Power_Required    [Buildings, but specifically: GORF, Smelter, Rare Smelter]
Storage_Capacity  [Specifically: University train rate]
Storage_Bays      [Not used in standard tech files]
Production_Rate   [Vehicles, mostly colony building and repair]
Concussion_Damage [Weapons]
Penetration_Damage  [Weapons]
Improved          [Unit specific: Mine, RareMine, Smelter, RareSmelter, GORF, Observatory]
Workers_Required  [Buildings, but specifically: DIRT]
Common_Required   [Units, but generally vehicles]
Rare_Required     [Units, but generally vehicles]
Turn_Rate         [Not used in standard tech files]
Build_Points      [Not used in standard tech files]
PLAYER_PROP:
Ore
FUNCTION_RESULT:
Test_Function


The PLAYER_PROP and FUNCTION_RESULT tags quite are useless. The standard tech tree files don't use either of these two tags. The PLAYER_PROP can set the Ore (common) for a player as a research result. Note that it sets the ore, not adds the ore. I don't see a whole lot of use for it. The Test_Function which is called is just a no-op, and no other functions are available, making FUNCTION_RESULT quite pointless.