Changeset 581

Show
Ignore:
Timestamp:
05/27/08 11:34:59 (8 months ago)
Author:
LeoD
Message:

fixed weird flickering bug

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/defend/demo/Player.d

    r574 r581  
    66 
    77import gen.math.Vector; 
     8import gen.util.Log; 
    89import gen.util.Wrapper; 
    910import gen.util.Serialize; 
     
    1920{ 
    2021private: 
     22    Logger logger; 
     23 
    2124    FileConduit file; 
    2225    float _speed = 20; 
     
    2427    ubyte[] dataBuffer; 
    2528    Phase phase; 
     29     
     30    bool finished = false; 
    2631 
    2732    ChunkHeader readChunkHeader() 
     
    97102    this(char[] filename) 
    98103    { 
     104        logger = Log.getLogger("demo"); 
     105     
    99106        file = new FileConduit(filename, FileConduit.ReadExisting); 
    100107        dataBuffer.length = 1024; 
     
    204211    override void startPhase() 
    205212    { 
     213        if(finished) 
     214            return; 
     215     
    206216        while(true) 
    207217        { 
    208218            if(file.position == file.length) 
    209219            { 
    210                 Stdout("demo finished playing").newline; 
     220                logger.info("demo finished playing"); 
     221                finished = true; 
    211222             
    212223                return; 
  • trunk/src/defend/game/hud/Mouse.d

    r576 r581  
    222222            { 
    223223                // Look if the mouse ray hits this object 
    224                 if(obj.visible && obj.intersectRay(ray)) 
     224                if(obj.visible && !obj.fogOfWarCulled && obj.intersectRay(ray)) 
    225225                { 
    226226                    // Deselect the object, if left shift is pressed 
     
    383383                if(target is null) 
    384384                { 
    385                     // tmp :D 
    386                     //for(uint i = 0; i < 100; i++)      
    387385                    gameObjects.order(gameObjects.gateway, selection, 
    388386                                      OrderMapRightClick(mapPos.x, mapPos.y)); 
     
    606604         
    607605        mouseCube.scaling = vec3(0.05, 0.05, 0.05); 
    608         mouseCube.hide = true; 
     606        mouseCube.hide = false; 
    609607        mouseCube.renderShadow = true; 
    610608 
  • trunk/src/defend/sim/Core.d

    r577 r581  
    262262 
    263263    // Properties 
    264     property_value_t[MAX_OBJECT_PROPERTIES] propertyFactors; 
     264    prop_t[MAX_OBJECT_PROPERTIES] propertyFactors; 
    265265 
    266266    // Effectors 
     
    310310 
    311311    // Basic properties 
    312     property_value_t[MAX_OBJECT_PROPERTIES] properties; 
     312    prop_t[MAX_OBJECT_PROPERTIES] properties; 
    313313 
    314314    // Number of tiles occupied 
     
    350350            return false; 
    351351 
     352        // TODO: fixed point 
    352353        float height = -1; 
    353354        const float tolerance = 0.2; 
     
    417418 
    418419        foreach(ref pf; propertyFactors) 
    419             pf = property_value_t.ctFromReal!(1.0); 
     420            pf = prop_t.ctFromReal!(1.0); 
    420421 
    421422        foreach(ref pf; properties) 
    422             pf = property_value_t.ctFromReal!(1.0); 
     423            pf = prop_t.ctFromReal!(1.0); 
    423424             
    424425        foreach(ref order; tempOrders) 
     
    429430 
    430431    // Set a property 
    431     override void mulPropertyFactor(property_t property, property_value_t value) 
     432    override void mulPropertyFactor(prop_type_t property, prop_t value) 
    432433    { 
    433434        propertyFactors[property] *= value; 
     
    435436 
    436437    // Returns a property factor 
    437     property_value_t getPropertyFactor(property_t property) 
     438    prop_t getPropertyFactor(prop_type_t property) 
    438439    { 
    439440        return (parent !is null ? 
    440                 parent.getPropertyFactor(property) : property_value_t.ctFromReal!(1.0)) * 
     441                parent.getPropertyFactor(property) : prop_t.ctFromReal!(1.0)) * 
    441442                propertyFactors[property]; 
    442443    } 
    443444 
    444445    // Returns the value of a property 
    445     property_value_t getProperty(property_t property) 
     446    prop_t getProperty(prop_type_t property) 
    446447    { 
    447448        return properties[property] * getPropertyFactor(property); 
     
    609610 
    610611    EffectorInfo[MAX_OBJECT_EFFECTORS] effectors; 
    611     property_value_t[MAX_OBJECT_PROPERTIES] propertyFactors; 
     612    prop_t[MAX_OBJECT_PROPERTIES] propertyFactors; 
    612613 
    613614    void realPos(vec3 v) { _realPos = v; } 
     
    685686 
    686687    // TODO: PLX CAN HAS STRINGS FOR PROPERTIES KTHX. 
    687     enum Property : property_t 
     688    enum Property : prop_type_t 
    688689    { 
    689690        MaxLife, 
     
    754755    } 
    755756 
    756     override void mulPropertyFactor(property_t property, property_value_t value) 
     757    override void mulPropertyFactor(prop_type_t property, prop_t value) 
    757758    { 
    758759        propertyFactors[property] *= value; 
    759760    } 
    760761     
    761     property_value_t property(property_t property) 
     762    prop_t property(prop_type_t property) 
    762763    { 
    763764        assert(property < MAX_OBJECT_PROPERTIES); 
     
    799800    final MapPos searchFreeTileAround(MapPos from) 
    800801    { 
     802        // TODO: fixed point 
    801803        bool hasResult = false; 
    802804        float minDistance; 
     
    926928         
    927929        foreach(ref pf; propertyFactors) 
    928             pf = property_value_t.ctFromReal!(1.0); 
     930            pf = prop_t.ctFromReal!(1.0); 
    929931         
    930932        // dis no good 
     
    15751577abstract class ObjectTechnology : Technology, Effector 
    15761578{ 
    1577     property_value_t[MAX_OBJECT_PROPERTIES] factors; 
     1579    prop_t[MAX_OBJECT_PROPERTIES] factors; 
    15781580     
    15791581    this() 
    15801582    { 
    1581         foreach(ref pf; factors) pf = property_value_t.ctFromReal!(1.0); 
     1583        foreach(ref pf; factors) pf = prop_t.ctFromReal!(1.0); 
    15821584    } 
    15831585     
     
    15861588        foreach(i, pf; factors) 
    15871589        { 
    1588             if(pf != property_value_t.ctFromReal!(1.0)) 
     1590            if(pf != prop_t.ctFromReal!(1.0)) 
    15891591                effected.mulPropertyFactor(i, pf); 
    15901592        }        
     
    15951597        foreach(i, pf; factors) 
    15961598        { 
    1597             if(pf != property_value_t.ctFromReal!(1.0)) 
    1598                 effected.mulPropertyFactor(i, property_value_t.ctFromReal!(1.0) / pf); 
     1599            if(pf != prop_t.ctFromReal!(1.0)) 
     1600                effected.mulPropertyFactor(i, prop_t.ctFromReal!(1.0) / pf); 
    15991601        }        
    16001602    } 
  • trunk/src/defend/sim/Effector.d

    r572 r581  
    99const uint MAX_OBJECT_PROPERTIES = 64; 
    1010 
    11 alias uint property_t; 
    12 alias fixed property_value_t; 
    13  
    14 property_value_t objProp(real r) { return property_value_t.fromReal(r); } 
     11alias uint prop_type_t; 
     12alias fixed prop_t; 
    1513 
    1614struct EffectorInfo 
     
    2220interface Effected 
    2321{ 
    24     void mulPropertyFactor(property_t, property_value_t); 
     22    void mulPropertyFactor(prop_type_t, prop_t); 
    2523} 
    2624 
  • trunk/src/defend/sim/civ/Test.d

    r572 r581  
    5959            with(civ.objectTypes["unit"]) 
    6060            { 
    61                 mulPropertyFactor(Unit.Property.MovementSpeed, objProp(2)); 
     61                mulPropertyFactor(Unit.Property.MovementSpeed, prop_t(2)); 
    6262            } 
    6363        } 
  • trunk/src/defend/sim/obj/Building.d

    r571 r581  
    6666{ 
    6767    BuildingQueueEntryType type; 
    68     ushort simulationSteps; 
     68    fixed progress; 
    6969     
    7070    union 
     
    7878        BuildingQueueEntry result; 
    7979        result.type = BuildingQueueEntryType.Unit; 
    80         result.simulationSteps = unitType.developmentSteps
     80        result.progress = fixed.fromInt(unitType.developmentSteps)
    8181        result.unitType = unitType; 
    8282         
     
    8888        BuildingQueueEntry result; 
    8989        result.type = BuildingQueueEntryType.Tech; 
    90         result.simulationSteps = tech.developmentSteps
     90        result.progress = fixed.fromInt(tech.developmentSteps)
    9191        result.tech = tech; 
    9292         
     
    382382    } 
    383383 
    384     enum Property : property_t 
     384    enum Property : prop_type_t 
    385385    { 
    386386        BuildSpeed = GameObject.Property.max + 1 
     
    409409                                      typeInfo.scale.z); 
    410410                                       
    411             propertyFactors[GameObject.Property.Sight] = property_value_t.ctFromReal!(0.1); 
     411            propertyFactors[GameObject.Property.Sight] = prop_t.ctFromReal!(0.1); 
    412412        } 
    413413    } 
     
    429429            _sceneNode.scaling = typeInfo.scale; 
    430430            status = Status.Finished; 
    431             propertyFactors[GameObject.Property.Sight] = property_value_t.ctFromReal!(1.0); 
     431            propertyFactors[GameObject.Property.Sight] = prop_t.ctFromReal!(1.0); 
    432432        } 
    433433    } 
     
    508508            auto entry = &queue[0]; 
    509509             
    510             assert(entry.simulationSteps != 0); 
    511  
    512             // well, this sucks :( 
    513             entry.simulationSteps -= min(cast(ushort)cast(real)property(Property.BuildSpeed), 
    514                                          entry.simulationSteps); 
    515              
    516             if(entry.simulationSteps == 0) 
     510            assert(entry.progress > fixed(0)); 
     511 
     512            entry.progress -= property(Property.BuildSpeed); 
     513             
     514            if(entry.progress <= fixed(0)) 
    517515            { 
    518516                switch(entry.type) 
     
    527525                    if(unitPos == mapPos) 
    528526                    { 
    529                         entry.simulationSteps = 30; 
     527                        Stdout("no place").newline; 
     528                        // no space to spawn unit, retry later 
     529                        entry.progress = fixed(50); 
    530530                        return; 
    531531                    } 
  • trunk/src/defend/sim/obj/Citizen.d

    r579 r581  
    3333            developmentSteps = 18; 
    3434            canBuild = [ "house" ]; 
    35             properties[GameObject.Property.MaxLife] = objProp(500); 
    36             properties[Unit.Property.Attack]        = objProp(10); 
    37             properties[Unit.Property.MovementSpeed] = objProp(5); 
    38             properties[Unit.Property.AttackSpeed]   = objProp(250); 
    39             properties[GameObject.Property.Sight]   = objProp(15); 
     35            properties[GameObject.Property.MaxLife] = prop_t(500); 
     36            properties[Unit.Property.Attack]        = prop_t(10); 
     37            properties[Unit.Property.MovementSpeed] = prop_t(5); 
     38            properties[Unit.Property.AttackSpeed]   = prop_t(250); 
     39            properties[GameObject.Property.Sight]   = prop_t(15); 
    4040        } 
    4141 
     
    231231    } 
    232232     
    233     enum Property : property_t 
     233    enum Property : prop_type_t 
    234234    { 
    235235        // Speed for building buildings 
  • trunk/src/defend/sim/obj/House.d

    r579 r581  
    2626            canBuild = [ "sheep", "citizen" ];      
    2727            canDevelop = [ "sheep on drugs" ]; 
    28             properties[GameObject.Property.MaxLife] = objProp(2000); 
    29             properties[GameObject.Property.Sight] = objProp(70); 
     28            properties[GameObject.Property.MaxLife] = prop_t(2000); 
     29            properties[GameObject.Property.Sight] = prop_t(70); 
    3030        } 
    3131         
  • trunk/src/defend/sim/obj/Sheep.d

    r580 r581  
    3232            normRotation = vec3(1.6, -1.6, 0); 
    3333            developmentSteps = 18; 
    34             properties[GameObject.Property.MaxLife] = objProp(500); 
    35             properties[Unit.Property.Attack]        = objProp(5); 
    36             properties[Unit.Property.MovementSpeed] = objProp(10); 
    37             properties[Unit.Property.AttackSpeed]   = objProp(50); 
    38             properties[GameObject.Property.Sight]   = objProp(20); 
     34            properties[GameObject.Property.MaxLife] = prop_t(500); 
     35            properties[Unit.Property.Attack]        = prop_t(5); 
     36            properties[Unit.Property.MovementSpeed] = prop_t(10); 
     37            properties[Unit.Property.AttackSpeed]   = prop_t(50); 
     38            properties[GameObject.Property.Sight]   = prop_t(20); 
    3939        } 
    4040         
  • trunk/src/defend/sim/obj/Unit.d

    r580 r581  
    2222import defend.Config; 
    2323import defend.mp.Types; 
     24import defend.mp.PlayerManager; 
    2425import defend.terrain.Map; 
    2526import defend.terrain.Terrain; 
     
    5354            targets = [ "sheep" ]; 
    5455            miniPic = "data/minipics/speed.png"; 
    55             factors[Unit.Property.MovementSpeed] = objProp(20); 
     56            factors[Unit.Property.MovementSpeed] = prop_t(20); 
    5657            developmentSteps = 20; 
    5758        } 
     
    9495        auto target = gameObjects.getObject(order.target); 
    9596     
    96         return OrderError.Okay; // tmp for testing 
    97         return target.owner != objects[0].owner ? 
    98                OrderError.Okay : OrderError.Error; 
     97        //return OrderError.Okay; // tmp for testing 
     98        return target.owner != objects[0].owner && 
     99               target.owner != NEUTRAL_PLAYER ? 
     100               OrderError.Okay : OrderError.Ignored; 
    99101    } 
    100102     
     
    370372    void finalDirection(vec3 v) { assert(v.ok); _finalDirection = v; } 
    371373     
    372     fixed movePercent; // from 0 to 1000 
    373     const MAX_MOVE_PERCENT = fixed.ctFromReal!(100); 
     374    fixed movePercent; 
     375    const MAX_MOVE_PERCENT = fixed.ctFromInt!(100); 
    374376     
    375377    // Attacking 
     
    513515        lastWayPoint = terrain.getWorldPos(mapPos); 
    514516        mapPos = p; 
    515         movePercent = fixed.fromInt(0); 
     517        movePercent = fixed(0); 
    516518        nextWayPoint = terrain.getWorldPos(mapPos); 
    517519         
     
    547549    } 
    548550 
    549     enum Property : property_t 
     551    enum Property : prop_type_t 
    550552    { 
    551553        Attack = GameObject.Property.max + 1, 
     
    699701            if(movePercent < MAX_MOVE_PERCENT) 
    700702                movePercent += property(Unit.Property.MovementSpeed); 
    701              
     703 
    702704            if(movePercent > MAX_MOVE_PERCENT) 
    703705                movePercent = MAX_MOVE_PERCENT; 
    704             
     706     
    705707            // Reached the next tile 
    706708            if(movePercent == MAX_MOVE_PERCENT) 
     
    733735                else if(!checkCollision(path[1])) 
    734736                { 
    735                     //logger.spam("tile before: [{}|{}]", path[1].x, path[1].y); 
    736737                    path = path[1 .. $]; 
    737                     //logger.spam("tile afterwards: [{}|{}]", path[1].x, path[1].y); 
    738738                    moveToPoint(path[0]); 
    739739                } 
     
    746746            realPos = lastWayPoint * (1.0 - percent) + nextWayPoint * percent; 
    747747             
    748             // Path finished 
    749             /*if(!path.length) 
    750             { 
    751                 direction = finalDirection; 
    752                 //moving = false; 
    753                 status = Status.Idle; 
    754                 moveFinished(); 
    755             }*/ 
    756              
    757748            break; 
    758749         
  • trunk/src/defend/terrain/FogOfWar.d

    r579 r581  
    104104            sprite.render(vec2.zero, visibleBuffer.texture); 
    105105             
     106            setTexture(1, null); 
    106107            setShader(null); 
     108            setTexture(0, null); 
    107109             
    108110            unsetFramebuffer(visitedBuffer); 
     
    131133            sprite.render(vec2.zero, lightmap); 
    132134             
     135            setTexture(1, null); 
     136            setTexture(2, null); 
    133137            setShader(null); 
     138            setTexture(0, null); 
    134139 
    135140            unsetFramebuffer(framebuffer); 
     
    281286    Texture texture() 
    282287    { 
     288        //enable = false; 
    283289        return enable ? framebuffer.texture : lightmap; 
    284290    } 
  • trunk/src/defend/terrain/Generator.d

    r580 r581  
    7777            //  localCreate(cast(player_id_t)0, "house", 40, 30); 
    7878             
    79             version(none) for(int i = 0; i < 50; i++) 
     79            version(all) for(int i = 0; i < 50; i++) 
    8080            { 
    8181                auto ti = getTypeInfo(NEUTRAL_PLAYER, "wood"); 
  • trunk/src/defend/terrain/Heightmap.d

    r564 r581  
    1616    MapPos _size; 
    1717 
     18    // TODO: fixed point 
    1819    float maxHeight = 0; 
    1920    float[] heightMap; 
  • trunk/src/defend/terrain/Map.d

    r565 r581  
    1616Map map; 
    1717 
     18// TODO: fixed point 
    1819struct MapTile 
    1920{ 
  • trunk/src/gen/image/Devil.d

    r446 r581  
    4242                 
    4343            case 8: 
    44                 ilConvertImage(IL_LUMINANCE, IL_UNSIGNED_BYTE); 
    45                 _format = ImageFormat.A
     44                ilConvertImage(IL_RGB, IL_UNSIGNED_BYTE); 
     45                _format = ImageFormat.RGB
    4646                break; 
    4747                 
  • trunk/src/gen/model/ModelMD2.d

    r580 r581  
    11module gen.model.ModelMD2; 
     2 
     3// this won't be needed anymore, once Lich is usable 
    24 
    35import tango.io.Stdout; 
     
    8284         
    8385        d["stand"] = a(0, 39, 9); 
    84         d["run"] = a(40, 45, 10); 
     86        d["run"] = a(40, 45, 6); 
    8587        d["attack"] = a(46, 53, 10); 
    8688        d["pain_a"] = a(54, 57, 7); 
     
    194196                    vertex.position.y = currPos.y + state.interp * (nextPos.y - currPos.y); 
    195197                    vertex.position.z = currPos.z + state.interp * (nextPos.z - currPos.z); 
    196          
     198                    
    197199                    bbox.max.x = .max(bbox.max.x, vertex.position.x); 
    198200                    bbox.max.y = .max(bbox.max.y, vertex.position.y); 
  • trunk/src/gen/scene/MeshNode.d

    r580 r581  
    6363        renderer.pushMatrix(); 
    6464        renderer.mulMatrix(absoluteModelview); 
     65        renderer.setColor(parent.color); // use color of parent model 
    6566         
    6667        mesh.render(); 
     
    7273        } 
    7374         
     75        renderer.setColor(vec3.one); 
    7476        renderer.popMatrix(); 
    7577    } 
  • trunk/src/xf/omg/core/Fixed.d

    r541 r581  
    4040    } 
    4141 
     42    template ctFromInt(int val) { 
     43        static assert (val >= minInt && val <= maxInt); 
     44        const fixed32T ctFromInt = { store : val << fracBits }; 
     45    } 
    4246 
    4347    static fixed32T fromInt(int val) {