Changeset 549

Show
Ignore:
Timestamp:
05/20/08 12:44:25 (8 months ago)
Author:
LeoD
Message:

this also removes the need for object type infos to be copyable

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/defend/objects/Core.d

    r548 r549  
    196196abstract class ObjectButton 
    197197{ 
    198 protected: 
    199     void assign(ObjectButton o) 
    200     { 
    201         o.id = id; 
    202         o.widget = widget; 
    203         o.pos = pos; 
    204         o.showCache = false; 
    205         o.doPlaceObject = doPlaceObject; 
    206         o.placeObject = placeObject; 
    207     } 
    208  
    209 public: 
    210     abstract ObjectButton dup(); 
    211  
    212198    button_id_t id; 
    213199    Widget widget; 
     
    215201    bool showCache; 
    216202 
     203    // Let the user place an object, then send OrderPlaceObject 
    217204    bool doPlaceObject = false; 
    218  
    219     // Let the user place an object, then send OrderPlaceObject 
    220205    object_type_t placeObject; 
    221206 
     207    // Returns whether the button shall be made visible 
    222208    abstract bool show(GameObject object); 
     209     
    223210    abstract void onLeftClick(GameObject[] objects); 
    224211    abstract char[] miniPic(); 
     
    302289            assert(object.typeInfo.objectClass == whatClass); 
    303290        }); 
    304     } 
    305  
    306     // Duplication 
    307     void assign(ObjectTypeInfo o) 
    308     { 
    309         o.logger = logger; 
    310         o.buttonCounter = 0; 
    311         o.propertyFactors[] = propertyFactors[]; 
    312         o.available = available; 
    313         o.abstractType = abstractType; 
    314         o.model = model; 
    315         o.posOffset = posOffset; 
    316         o.scale = scale; 
    317         o.miniPic = miniPic; 
    318         o.properties[] = properties[]; 
    319         o.dimension = dimension; 
    320         o.gameObjects = gameObjects; 
    321         o.objectType = objectType; 
    322         o.parentType = parentType; 
    323         o.objectClass = objectClass; 
    324291    } 
    325292 
     
    359326    typedef uint local_id_t; 
    360327    local_id_t localTypeID; 
    361  
    362     abstract ObjectTypeInfo dup(); 
    363328 
    364329    // Check if an order is valid 
     
    607572 
    608573public: 
    609     override ObjectTypeInfo dup() 
    610     { 
    611         auto result = new BaseTypeInfo; 
    612         assign(result); 
    613          
    614         return result; 
    615     } 
    616  
    617574    override void construct() 
    618575    { 
  • trunk/src/defend/objects/types/Building.d

    r541 r549  
    143143class BuildingTypeInfo : BaseTypeInfo 
    144144{ 
    145 protected: 
    146     override void assign(ObjectTypeInfo t) 
    147     { 
    148         super.assign(t); 
    149          
    150         auto o = cast(BuildingTypeInfo)t; 
    151         assert(o !is null); 
    152          
    153         o.canBuild = canBuild.dup; 
    154         o.canDevelop = canDevelop.dup; 
    155         o.buildSteps = buildSteps; 
    156     } 
    157  
    158 public: 
    159145    object_type_t[] canBuild; 
    160146    tech_t[] canDevelop; 
     
    162148    // Time needed for building (in simulation steps) 
    163149    uint buildSteps = 30; 
    164      
    165     override ObjectTypeInfo dup() 
    166     { 
    167         auto result = new BuildingTypeInfo; 
    168         assign(result); 
    169          
    170         return result; 
    171     } 
    172      
     150 
    173151    // Orders 
    174152    override OrderError checkOrder(GameObject[] objects, OrderMapRightClick* order) 
     
    191169    class ButtonBuildUnit : ObjectButton 
    192170    { 
    193     protected: 
    194         override void assign(ObjectButton t) 
    195         { 
    196             super.assign(t); 
    197              
    198             auto o = cast(ButtonBuildUnit)t; 
    199             assert(o !is null); 
    200              
    201             o.unitType = unitType; 
    202             o._unitTypePointer = null; 
    203         } 
    204      
    205     public: 
    206171        object_type_t unitType; 
    207172        UnitTypeInfo _unitTypePointer; 
     
    210175        { 
    211176            unitType = t; 
    212         } 
    213          
    214         override ObjectButton dup() 
    215         { 
    216             auto result = new ButtonBuildUnit(unitType); 
    217             assign(result); 
    218              
    219             return result; 
    220177        } 
    221178         
     
    288245    class ButtonTech : ObjectButton 
    289246    { 
    290     protected: 
    291         override void assign(ObjectButton t) 
    292         { 
    293             super.assign(t); 
    294              
    295             auto o = cast(ButtonTech)t; 
    296             assert(o !is null); 
    297              
    298             o.tech = tech; 
    299             o._techPointer = null; 
    300         } 
    301      
    302     public: 
    303247        tech_t tech; 
    304248        Technology _techPointer; 
     
    307251        { 
    308252            tech = t; 
    309         } 
    310          
    311         override ObjectButton dup() 
    312         { 
    313             auto result = new ButtonTech(tech); 
    314             assign(result); 
    315              
    316             return result; 
    317253        } 
    318254         
  • trunk/src/defend/objects/types/Citizen.d

    r547 r549  
    4545class CitizenTypeInfo : UnitTypeInfo 
    4646{ 
    47 protected: 
    48     override void assign(ObjectTypeInfo t) 
    49     { 
    50         super.assign(t); 
    51          
    52         auto o = cast(CitizenTypeInfo)t; 
    53         assert(o !is null); 
    54          
    55         o.canBuild = canBuild.dup; 
    56     } 
    57  
    58 public: 
    5947    object_type_t[] canBuild; 
    60      
    61     override ObjectTypeInfo dup() 
    62     { 
    63         auto result = new CitizenTypeInfo; 
    64         assign(result); 
    65          
    66         return result; 
    67     } 
    6848     
    6949    override OrderError checkOrder(GameObject[] objects, OrderObjectRightClick* order) 
     
    148128    class ButtonBuildBuilding : ObjectButton 
    149129    { 
    150     protected: 
    151         override void assign(ObjectButton t) 
    152         { 
    153             super.assign(t); 
    154              
    155             auto o = cast(ButtonBuildBuilding)t; 
    156             assert(o !is null); 
    157              
    158             o.buildingType = buildingType; 
    159             o._buildingTypePointer = null; 
    160         } 
    161      
    162     public: 
    163130        object_type_t buildingType; 
    164131        BuildingTypeInfo _buildingTypePointer; 
     
    169136            doPlaceObject = true; 
    170137            placeObject = t; 
    171         } 
    172          
    173         override ObjectButton dup() 
    174         { 
    175             auto result = new ButtonBuildBuilding(buildingType); 
    176             assign(result); 
    177              
    178             return result; 
    179138        } 
    180139         
  • trunk/src/defend/objects/types/Resource.d

    r541 r549  
    4848class ResourceTypeInfo : BaseTypeInfo 
    4949{ 
    50 protected: 
    51     override void assign(ObjectTypeInfo t) 
    52     { 
    53         super.assign(t); 
    54          
    55         auto o = cast(ResourceTypeInfo)t; 
    56         assert(o !is null); 
    57          
    58         o.resourceType = resourceType; 
    59         o.initialAmount = initialAmount; 
    60     } 
    61  
    62 public: 
    6350    ResourceType resourceType; 
    6451    uint initialAmount; 
    65      
    66     override ResourceTypeInfo dup() 
    67     { 
    68         auto result = new ResourceTypeInfo; 
    69         assign(result); 
    70          
    71         return result; 
    72     } 
    7352     
    7453    override void construct() 
  • trunk/src/defend/objects/types/Unit.d

    r542 r549  
    137137class UnitTypeInfo : BaseTypeInfo 
    138138{ 
    139 protected: 
    140     override void assign(ObjectTypeInfo t) 
    141     { 
    142         super.assign(t); 
    143          
    144         auto o = cast(UnitTypeInfo)t; 
    145         assert(o !is null); 
    146          
    147         o.developmentSteps = developmentSteps; 
    148     } 
    149      
    150 public: 
    151139    // Time needed for development (in simulation steps) 
    152140    uint developmentSteps = 30; 
    153  
    154     override ObjectTypeInfo dup() 
    155     { 
    156         auto result = new UnitTypeInfo; 
    157         assign(result); 
    158          
    159         return result; 
    160     } 
    161141 
    162142    // Orders