This Trac instance is not used for development anymore!

We migrated our development workflow to git and Gitea.
To test the future redirection, replace trac by ariadne in the page URL.

Changeset 10017 for ps


Ignore:
Timestamp:
08/16/11 13:18:32 (13 years ago)
Author:
philip
Message:

Fix -Wconversion warnings in simulation code.
Cast to smaller integer types explicitly.
Generally avoid platform-dependent types (size_t) in simulation code.
Use float versions of math.h functions, not double.

Location:
ps/trunk/source
Files:
34 edited

Legend:

Unmodified
Added
Removed
  • ps/trunk/source/graphics/ShaderProgram.h

    r9419 r10017  
    6464        friend class CShaderProgramARB;
    6565    private:
    66         Binding(int v, int f) : vertex(v), fragment(f) { }
     66        Binding(int v, int f) : vertex((i16)v), fragment((i16)f) { }
    6767        i16 vertex;
    6868        i16 fragment;
  • ps/trunk/source/lib/os_path.h

    r9362 r10017  
    4747    {
    4848        ENSURE(wstring[i] <= UCHAR_MAX);
    49         string[i] = wstring[i];
     49        string[i] = (char)wstring[i];
    5050    }
    5151    return string;
  • ps/trunk/source/lib/timer.h

    r9362 r10017  
    200200    std::wstring ToString() const
    201201    {
    202         ENSURE(m_cycles >= 0.0);
     202        ENSURE(m_cycles >= 0);
    203203        return StringForCycles(m_cycles);
    204204    }
     
    206206    double ToSeconds() const
    207207    {
    208         return m_cycles / os_cpu_ClockFrequency();
     208        return (double)m_cycles / os_cpu_ClockFrequency();
    209209    }
    210210
  • ps/trunk/source/maths/Fixed.h

    r8160 r10017  
    149149    static CFixed FromString(const CStrW& s);
    150150
     151    /// Convert to float. May be lossy - float can't represent all values.
    151152    float ToFloat() const
    152153    {
    153         return value / (float)fract_pow2;
    154     }
    155 
     154        return (float)value / (float)fract_pow2;
     155    }
     156
     157    /// Convert to double. Won't be lossy - double can precisely represent all values.
    156158    double ToDouble() const
    157159    {
  • ps/trunk/source/ps/Overlay.h

    r7214 r10017  
    5252    SColor4ub AsSColor4ub() const
    5353    {
    54         return SColor4ub((int)(r*255.0), (int)(g*255.0), (int)(b*255.0), (int)(a*255.0));
     54        return SColor4ub((u8)(r*255.0), (u8)(g*255.0), (u8)(b*255.0), (u8)(a*255.0));
    5555    }
    5656
  • ps/trunk/source/ps/utf16string.h

    r7259 r10017  
    6262        const char_type* end=s;
    6363        while (*end) end++;
    64         return end-s;
     64        return (size_t)(end-s);
    6565    }
    6666
  • ps/trunk/source/simulation2/components/CCmpAIManager.cpp

    r9852 r10017  
    142142            u8* img = buf.get() + hdr_size;
    143143            for (size_t i = 0; i < data.size(); ++i)
    144                 img[i] = (data[i] * 255) / max;
     144                img[i] = (u8)((data[i] * 255) / max);
    145145
    146146            tex_write(&t, filename);
     
    360360    void SerializeState(ISerializer& serializer)
    361361    {
    362         serializer.NumberU32_Unbounded("num ais", m_Players.size());
     362        serializer.NumberU32_Unbounded("num ais", (u32)m_Players.size());
    363363
    364364        for (size_t i = 0; i < m_Players.size(); ++i)
     
    368368            serializer.ScriptVal("data", m_Players[i]->m_Obj);
    369369
    370             serializer.NumberU32_Unbounded("num commands", m_Players[i]->m_Commands.size());
     370            serializer.NumberU32_Unbounded("num commands", (u32)m_Players[i]->m_Commands.size());
    371371            for (size_t j = 0; j < m_Players[i]->m_Commands.size(); ++j)
    372372            {
     
    528528            const CMessageProgressiveLoad& msgData = static_cast<const CMessageProgressiveLoad&> (msg);
    529529
    530             *msgData.total += m_TemplateNames.size();
     530            *msgData.total += (int)m_TemplateNames.size();
    531531
    532532            if (*msgData.progressed)
     
    536536                *msgData.progressed = true;
    537537
    538             *msgData.progress += m_TemplateLoadedIdx;
     538            *msgData.progress += (int)m_TemplateLoadedIdx;
    539539
    540540            break;
  • ps/trunk/source/simulation2/components/CCmpFootprint.cpp

    r9970 r10017  
    164164
    165165        // Max spawning distance in tiles
    166         const size_t maxSpawningDistance = 4;
     166        const i32 maxSpawningDistance = 4;
    167167
    168168        if (m_Shape == CIRCLE)
    169169        {
    170170            // Expand outwards from foundation
    171             for (size_t dist = 0; dist <= maxSpawningDistance; ++dist)
     171            for (i32 dist = 0; dist <= maxSpawningDistance; ++dist)
    172172            {
    173173                // The spawn point should be far enough from this footprint to fit the unit, plus a little gap
    174                 entity_pos_t clearance = spawnedRadius + entity_pos_t::FromInt(2 + CELL_SIZE*dist);
     174                entity_pos_t clearance = spawnedRadius + entity_pos_t::FromInt(2 + (int)CELL_SIZE*dist);
    175175                entity_pos_t radius = m_Size0 + clearance;
    176176
    177177                // Try equally-spaced points around the circle in alternating directions, starting from the front
    178                 const ssize_t numPoints = 31 + 2*dist;
    179                 for (ssize_t i = 0; i < (numPoints+1)/2; i = (i > 0 ? -i : 1-i)) // [0, +1, -1, +2, -2, ... (np-1)/2, -(np-1)/2]
     178                const i32 numPoints = 31 + 2*dist;
     179                for (i32 i = 0; i < (numPoints+1)/2; i = (i > 0 ? -i : 1-i)) // [0, +1, -1, +2, -2, ... (np-1)/2, -(np-1)/2]
    180180                {
    181181                    entity_angle_t angle = initialAngle + (entity_angle_t::Pi()*2).Multiply(entity_angle_t::FromInt(i)/(int)numPoints);
     
    198198
    199199            // Expand outwards from foundation
    200             for (size_t dist = 0; dist <= maxSpawningDistance; ++dist)
     200            for (i32 dist = 0; dist <= maxSpawningDistance; ++dist)
    201201            {
    202202                // The spawn point should be far enough from this footprint to fit the unit, plus a little gap
    203                 entity_pos_t clearance = spawnedRadius + entity_pos_t::FromInt(2 + CELL_SIZE*dist);
    204 
    205                 for (size_t edge = 0; edge < 4; ++edge)
     203                entity_pos_t clearance = spawnedRadius + entity_pos_t::FromInt(2 + (int)CELL_SIZE*dist);
     204
     205                for (i32 edge = 0; edge < 4; ++edge)
    206206                {
    207207                    // Try equally-spaced points along the edge in alternating directions, starting from the middle
    208                     const ssize_t numPoints = 9 + 2*dist;
     208                    const i32 numPoints = 9 + 2*dist;
    209209
    210210                    // Compute the direction and length of the current edge
     
    237237                    dir = dir.Multiply((sx + clearance*2) / (int)(numPoints-1));
    238238
    239                     for (ssize_t i = 0; i < (numPoints+1)/2; i = (i > 0 ? -i : 1-i)) // [0, +1, -1, +2, -2, ... (np-1)/2, -(np-1)/2]
     239                    for (i32 i = 0; i < (numPoints+1)/2; i = (i > 0 ? -i : 1-i)) // [0, +1, -1, +2, -2, ... (np-1)/2, -(np-1)/2]
    240240                    {
    241241                        CFixedVector2D pos (center + dir*i);
  • ps/trunk/source/simulation2/components/CCmpMinimap.cpp

    r8867 r10017  
    8888        {
    8989            m_UsePlayerColour = false;
    90             m_R = colour.GetChild("@r").ToInt();
    91             m_G = colour.GetChild("@g").ToInt();
    92             m_B = colour.GetChild("@b").ToInt();
     90            m_R = (u8)colour.GetChild("@r").ToInt();
     91            m_G = (u8)colour.GetChild("@g").ToInt();
     92            m_B = (u8)colour.GetChild("@b").ToInt();
    9393        }
    9494        else
     
    177177                break;
    178178            CColor colour = cmpPlayer->GetColour();
    179             m_R = (int)(colour.r*255.0);
    180             m_G = (int)(colour.g*255.0);
    181             m_B = (int)(colour.b*255.0);
     179            m_R = (u8)(colour.r*255.0);
     180            m_G = (u8)(colour.g*255.0);
     181            m_B = (u8)(colour.b*255.0);
     182            // TODO: probably should avoid using floating-point here
    182183
    183184            break;
  • ps/trunk/source/simulation2/components/CCmpMotionBall.cpp

    r8867 r10017  
    9595    float z = pos.Z.ToFloat();
    9696
    97     CVector3D normal;
    98     GetSimContext().GetTerrain().CalcNormal(x / CELL_SIZE, z / CELL_SIZE, normal);
     97    CVector3D normal = GetSimContext().GetTerrain().CalcExactNormal(x, z);
    9998    // Flatten the vector, to get the downhill force
    10099    float g = 10.f;
     
    108107    float dt_ = dt.ToFloat();
    109108
    110     m_SpeedX *= pow(drag, dt_);
    111     m_SpeedZ *= pow(drag, dt_);
     109    m_SpeedX *= powf(drag, dt_);
     110    m_SpeedZ *= powf(drag, dt_);
    112111
    113112    cmpPosition->MoveTo(entity_pos_t::FromFloat(x + m_SpeedX * dt_), entity_pos_t::FromFloat(z + m_SpeedZ * dt_));
  • ps/trunk/source/simulation2/components/CCmpObstruction.cpp

    r9970 r10017  
    4141    DEFAULT_COMPONENT_ALLOCATOR(Obstruction)
    4242
     43    typedef ICmpObstructionManager::tag_t tag_t;
     44    typedef ICmpObstructionManager::flags_t flags_t;
     45
    4346    // Template state:
    4447
     
    4952    entity_pos_t m_Size0; // radius or width
    5053    entity_pos_t m_Size1; // radius or depth
    51     u8 m_TemplateFlags;
     54    flags_t m_TemplateFlags;
    5255
    5356    // Dynamic state:
     
    5659    bool m_Moving;
    5760    entity_id_t m_ControlGroup;
    58     ICmpObstructionManager::tag_t m_Tag;
    59     u8 m_Flags;
     61    tag_t m_Tag;
     62    flags_t m_Flags;
    6063
    6164    static std::string GetSchema()
     
    128131        m_Flags = m_TemplateFlags;
    129132        if (paramNode.GetChild("DisableBlockMovement").ToBool())
    130             m_Flags &= ~ICmpObstructionManager::FLAG_BLOCK_MOVEMENT;
     133            m_Flags &= (flags_t)(~ICmpObstructionManager::FLAG_BLOCK_MOVEMENT);
    131134        if (paramNode.GetChild("DisableBlockPathfinding").ToBool())
    132             m_Flags &= ~ICmpObstructionManager::FLAG_BLOCK_PATHFINDING;
     135            m_Flags &= (flags_t)(~ICmpObstructionManager::FLAG_BLOCK_PATHFINDING);
    133136
    134137        m_Active = paramNode.GetChild("Active").ToBool();
    135138
    136         m_Tag = ICmpObstructionManager::tag_t();
     139        m_Tag = tag_t();
    137140        m_Moving = false;
    138141        m_ControlGroup = GetEntityId();
     
    195198                else
    196199                    m_Tag = cmpObstructionManager->AddUnitShape(GetEntityId(),
    197                         data.x, data.z, m_Size0, m_Flags | (m_Moving ? ICmpObstructionManager::FLAG_MOVING : 0), m_ControlGroup);
     200                        data.x, data.z, m_Size0, (flags_t)(m_Flags | (m_Moving ? ICmpObstructionManager::FLAG_MOVING : 0)), m_ControlGroup);
    198201            }
    199202            else if (!data.inWorld && m_Tag.valid())
    200203            {
    201204                cmpObstructionManager->RemoveShape(m_Tag);
    202                 m_Tag = ICmpObstructionManager::tag_t();
     205                m_Tag = tag_t();
    203206            }
    204207            break;
     
    213216
    214217                cmpObstructionManager->RemoveShape(m_Tag);
    215                 m_Tag = ICmpObstructionManager::tag_t();
     218                m_Tag = tag_t();
    216219            }
    217220            break;
     
    245248            else
    246249                m_Tag = cmpObstructionManager->AddUnitShape(GetEntityId(),
    247                     pos.X, pos.Y, m_Size0, m_Flags | (m_Moving ? ICmpObstructionManager::FLAG_MOVING : 0), m_ControlGroup);
     250                    pos.X, pos.Y, m_Size0, (flags_t)(m_Flags | (m_Moving ? ICmpObstructionManager::FLAG_MOVING : 0)), m_ControlGroup);
    248251        }
    249252        else if (!active && m_Active)
     
    260263
    261264                cmpObstructionManager->RemoveShape(m_Tag);
    262                 m_Tag = ICmpObstructionManager::tag_t();
     265                m_Tag = tag_t();
    263266            }
    264267        }
     
    271274        {
    272275            // Remove the blocking flags
    273             m_Flags &= ~ICmpObstructionManager::FLAG_BLOCK_MOVEMENT;
    274             m_Flags &= ~ICmpObstructionManager::FLAG_BLOCK_PATHFINDING;
     276            m_Flags &= (flags_t)(~ICmpObstructionManager::FLAG_BLOCK_MOVEMENT);
     277            m_Flags &= (flags_t)(~ICmpObstructionManager::FLAG_BLOCK_PATHFINDING);
    275278        }
    276279        else
    277280        {
    278281            // Add the blocking flags if the template had enabled them
    279             m_Flags |= (m_TemplateFlags & ICmpObstructionManager::FLAG_BLOCK_MOVEMENT);
    280             m_Flags |= (m_TemplateFlags & ICmpObstructionManager::FLAG_BLOCK_PATHFINDING);
     282            m_Flags = (flags_t)(m_Flags | (m_TemplateFlags & ICmpObstructionManager::FLAG_BLOCK_MOVEMENT));
     283            m_Flags = (flags_t)(m_Flags | (m_TemplateFlags & ICmpObstructionManager::FLAG_BLOCK_PATHFINDING));
    281284        }
    282285
  • ps/trunk/source/simulation2/components/CCmpObstructionManager.cpp

    r9362 r10017  
    5252    entity_pos_t x, z;
    5353    entity_pos_t r; // radius of circle, or half width of square
    54     u8 flags;
     54    ICmpObstructionManager::flags_t flags;
    5555    entity_id_t group; // control group (typically the owner entity, or a formation controller entity) (units ignore collisions with others in the same group)
    5656};
     
    6565    CFixedVector2D u, v; // orthogonal unit vectors - axes of local coordinate space
    6666    entity_pos_t hw, hh; // half width/height in local coordinate space
    67     u8 flags;
     67    ICmpObstructionManager::flags_t flags;
    6868};
    6969
     
    246246    }
    247247
    248     virtual tag_t AddUnitShape(entity_id_t ent, entity_pos_t x, entity_pos_t z, entity_pos_t r, u8 flags, entity_id_t group)
     248    virtual tag_t AddUnitShape(entity_id_t ent, entity_pos_t x, entity_pos_t z, entity_pos_t r, flags_t flags, entity_id_t group)
    249249    {
    250250        UnitShape shape = { ent, x, z, r, flags, group };
    251         size_t id = m_UnitShapeNext++;
     251        u32 id = m_UnitShapeNext++;
    252252        m_UnitShapes[id] = shape;
    253253        MakeDirtyUnit(flags);
     
    258258    }
    259259
    260     virtual tag_t AddStaticShape(entity_id_t ent, entity_pos_t x, entity_pos_t z, entity_angle_t a, entity_pos_t w, entity_pos_t h, u8 flags)
     260    virtual tag_t AddStaticShape(entity_id_t ent, entity_pos_t x, entity_pos_t z, entity_angle_t a, entity_pos_t w, entity_pos_t h, flags_t flags)
    261261    {
    262262        fixed s, c;
     
    266266
    267267        StaticShape shape = { ent, x, z, u, v, w/2, h/2, flags };
    268         size_t id = m_StaticShapeNext++;
     268        u32 id = m_StaticShapeNext++;
    269269        m_StaticShapes[id] = shape;
    270270        MakeDirtyStatic(flags);
     
    351351                shape.flags |= FLAG_MOVING;
    352352            else
    353                 shape.flags &= ~FLAG_MOVING;
     353                shape.flags &= (flags_t)~FLAG_MOVING;
    354354
    355355            MakeDirtyDebug();
     
    469469     * Call this when a static shape has changed.
    470470     */
    471     void MakeDirtyStatic(u8 flags)
     471    void MakeDirtyStatic(flags_t flags)
    472472    {
    473473        if (flags & (FLAG_BLOCK_PATHFINDING|FLAG_BLOCK_FOUNDATION))
     
    481481     * Call this when a unit shape has changed.
    482482     */
    483     void MakeDirtyUnit(u8 flags)
     483    void MakeDirtyUnit(flags_t flags)
    484484    {
    485485        if (flags & (FLAG_BLOCK_PATHFINDING|FLAG_BLOCK_FOUNDATION))
     
    691691static void NearestTile(entity_pos_t x, entity_pos_t z, u16& i, u16& j, u16 w, u16 h)
    692692{
    693     i = clamp((x / (int)CELL_SIZE).ToInt_RoundToZero(), 0, w-1);
    694     j = clamp((z / (int)CELL_SIZE).ToInt_RoundToZero(), 0, h-1);
     693    i = (u16)clamp((x / (int)CELL_SIZE).ToInt_RoundToZero(), 0, w-1);
     694    j = (u16)clamp((z / (int)CELL_SIZE).ToInt_RoundToZero(), 0, h-1);
    695695}
    696696
     
    700700static void TileCenter(u16 i, u16 j, entity_pos_t& x, entity_pos_t& z)
    701701{
    702     x = entity_pos_t::FromInt(i*(int)CELL_SIZE + CELL_SIZE/2);
    703     z = entity_pos_t::FromInt(j*(int)CELL_SIZE + CELL_SIZE/2);
     702    x = entity_pos_t::FromInt(i*(int)CELL_SIZE + (int)CELL_SIZE/2);
     703    z = entity_pos_t::FromInt(j*(int)CELL_SIZE + (int)CELL_SIZE/2);
    704704}
    705705
     
    811811
    812812    // WARNING: CCmpRangeManager::LosIsOffWorld needs to be kept in sync with this
    813     const ssize_t edgeSize = 3; // number of tiles around the edge that will be off-world
     813    const u16 edgeSize = 3; // number of tiles around the edge that will be off-world
    814814
    815815    u8 edgeFlags = TILE_OBSTRUCTED_PATHFINDING | TILE_OBSTRUCTED_FOUNDATION | TILE_OUTOFBOUNDS;
     
    845845                grid.set(i, j, edgeFlags);
    846846        for (u16 j = 0; j < grid.m_H; ++j)
    847             for (u16 i = i1-edgeSize+1; i < grid.m_W; ++i)
     847            for (u16 i = (u16)(i1-edgeSize+1); i < grid.m_W; ++i)
    848848                grid.set(i, j, edgeFlags);
    849849        for (u16 j = 0; j < j0+edgeSize; ++j)
    850             for (u16 i = i0+edgeSize; i < i1-edgeSize+1; ++i)
     850            for (u16 i = (u16)(i0+edgeSize); i < i1-edgeSize+1; ++i)
    851851                grid.set(i, j, edgeFlags);
    852         for (u16 j = j1-edgeSize+1; j < grid.m_H; ++j)
    853             for (u16 i = i0+edgeSize; i < i1-edgeSize+1; ++i)
     852        for (u16 j = (u16)(j1-edgeSize+1); j < grid.m_H; ++j)
     853            for (u16 i = (u16)(i0+edgeSize); i < i1-edgeSize+1; ++i)
    854854                grid.set(i, j, edgeFlags);
    855855    }
     
    967967            m_DebugOverlayLines.push_back(SOverlayLine());
    968968            m_DebugOverlayLines.back().m_Color = defaultColour;
    969             float a = atan2(it->second.v.X.ToFloat(), it->second.v.Y.ToFloat());
     969            float a = atan2f(it->second.v.X.ToFloat(), it->second.v.Y.ToFloat());
    970970            SimRender::ConstructSquareOnGround(GetSimContext(), it->second.x.ToFloat(), it->second.z.ToFloat(), it->second.hw.ToFloat()*2, it->second.hh.ToFloat()*2, a, m_DebugOverlayLines.back(), true);
    971971        }
  • ps/trunk/source/simulation2/components/CCmpPathfinder.cpp

    r10007 r10017  
    3232#include "simulation2/components/ICmpObstruction.h"
    3333#include "simulation2/components/ICmpObstructionManager.h"
     34#include "simulation2/components/ICmpTerrain.h"
    3435#include "simulation2/components/ICmpWaterManager.h"
    3536#include "simulation2/serialization/SerializeTemplates.h"
     
    7879    // will require some adjustment and rethinking.
    7980    const CParamNode pathingSettings = externalParamNode.GetChild("Pathfinder");
    80     m_MaxSameTurnMoves = pathingSettings.GetChild("MaxSameTurnMoves").ToInt();
     81    m_MaxSameTurnMoves = (u16)pathingSettings.GetChild("MaxSameTurnMoves").ToInt();
    8182
    8283
     
    306307void CCmpPathfinder::UpdateGrid()
    307308{
     309    CmpPtr<ICmpTerrain> cmpTerrain(GetSimContext(), SYSTEM_ENTITY);
     310    if (cmpTerrain.null())
     311        return; // error
     312
    308313    // If the terrain was resized then delete the old grid data
    309     if (m_Grid && m_MapSize != GetSimContext().GetTerrain().GetTilesPerSide())
     314    if (m_Grid && m_MapSize != cmpTerrain->GetTilesPerSide())
    310315    {
    311316        SAFE_DELETE(m_Grid);
     
    317322    if (!m_Grid)
    318323    {
    319         // TOOD: these bits should come from ICmpTerrain
    320         ssize_t size = GetSimContext().GetTerrain().GetTilesPerSide();
    321 
    322         ENSURE(size >= 1 && size <= 0xffff); // must fit in 16 bits
    323         m_MapSize = size;
     324        m_MapSize = cmpTerrain->GetTilesPerSide();
    324325        m_Grid = new Grid<TerrainTile>(m_MapSize, m_MapSize);
    325326        m_ObstructionGrid = new Grid<u8>(m_MapSize, m_MapSize);
     
    354355                    t |= 1;
    355356                else
    356                     t &= ~1;
     357                    t &= (TerrainTile)~1;
    357358
    358359                if (obstruct & ICmpObstructionManager::TILE_OBSTRUCTED_FOUNDATION)
    359360                    t |= 2;
    360361                else
    361                     t &= ~2;
     362                    t &= (TerrainTile)~2;
    362363            }
    363364        }
     
    418419
    419420        // Expand influences on land to find shore distance
    420         for (size_t y = 0; y < m_MapSize; ++y)
     421        for (u16 y = 0; y < m_MapSize; ++y)
    421422        {
    422423            u16 min = shoreMax;
    423             for (size_t x = 0; x < m_MapSize; ++x)
     424            for (u16 x = 0; x < m_MapSize; ++x)
    424425            {
    425426                if (!waterGrid.get(x, y))
     
    434435                }
    435436            }
    436             for (size_t x = m_MapSize; x > 0; --x)
     437            for (u16 x = m_MapSize; x > 0; --x)
    437438            {
    438439                if (!waterGrid.get(x-1, y))
     
    448449            }
    449450        }
    450         for (size_t x = 0; x < m_MapSize; ++x)
     451        for (u16 x = 0; x < m_MapSize; ++x)
    451452        {
    452453            u16 min = shoreMax;
    453             for (size_t y = 0; y < m_MapSize; ++y)
     454            for (u16 y = 0; y < m_MapSize; ++y)
    454455            {
    455456                if (!waterGrid.get(x, y))
     
    464465                }
    465466            }
    466             for (size_t y = m_MapSize; y > 0; --y)
     467            for (u16 y = m_MapSize; y > 0; --y)
    467468            {
    468469                if (!waterGrid.get(x, y-1))
     
    601602void CCmpPathfinder::ProcessSameTurnMoves()
    602603{
    603     u32 moveCount;
    604 
    605604    if (!m_AsyncLongPathRequests.empty())
    606605    {
    607606        // Figure out how many moves we can do this time
    608         moveCount = m_MaxSameTurnMoves - m_SameTurnMovesCount;
    609    
     607        i32 moveCount = m_MaxSameTurnMoves - m_SameTurnMovesCount;
     608
    610609        if (moveCount <= 0)
    611610            return;
     
    613612        // Copy the long request elements we are going to process into a new array
    614613        std::vector<AsyncLongPathRequest> longRequests;
    615         if (m_AsyncLongPathRequests.size() <= moveCount)
     614        if ((i32)m_AsyncLongPathRequests.size() <= moveCount)
    616615        {
    617616            m_AsyncLongPathRequests.swap(longRequests);
    618             moveCount = longRequests.size();
     617            moveCount = (i32)longRequests.size();
    619618        }
    620619        else
     
    627626        ProcessLongRequests(longRequests);
    628627
    629         m_SameTurnMovesCount += moveCount;
     628        m_SameTurnMovesCount = (u16)(m_SameTurnMovesCount + moveCount);
    630629    }
    631630   
     
    633632    {
    634633        // Figure out how many moves we can do now
    635         moveCount = m_MaxSameTurnMoves - m_SameTurnMovesCount;
     634        i32 moveCount = m_MaxSameTurnMoves - m_SameTurnMovesCount;
    636635
    637636        if (moveCount <= 0)
     
    640639        // Copy the short request elements we are going to process into a new array
    641640        std::vector<AsyncShortPathRequest> shortRequests;
    642         if (m_AsyncShortPathRequests.size() <= moveCount)
     641        if ((i32)m_AsyncShortPathRequests.size() <= moveCount)
    643642        {
    644643            m_AsyncShortPathRequests.swap(shortRequests);
    645             moveCount = shortRequests.size();
     644            moveCount = (i32)shortRequests.size();
    646645        }
    647646        else
     
    654653        ProcessShortRequests(shortRequests);
    655654
    656         m_SameTurnMovesCount += moveCount;
     655        m_SameTurnMovesCount = (u16)(m_SameTurnMovesCount + moveCount);
    657656    }
    658657}
  • ps/trunk/source/simulation2/components/CCmpPathfinder_Common.h

    r9970 r10017  
    278278    void NearestTile(entity_pos_t x, entity_pos_t z, u16& i, u16& j)
    279279    {
    280         i = clamp((x / (int)CELL_SIZE).ToInt_RoundToZero(), 0, m_MapSize-1);
    281         j = clamp((z / (int)CELL_SIZE).ToInt_RoundToZero(), 0, m_MapSize-1);
     280        i = (u16)clamp((x / (int)CELL_SIZE).ToInt_RoundToZero(), 0, m_MapSize-1);
     281        j = (u16)clamp((z / (int)CELL_SIZE).ToInt_RoundToZero(), 0, m_MapSize-1);
    282282    }
    283283
     
    287287    static void TileCenter(u16 i, u16 j, entity_pos_t& x, entity_pos_t& z)
    288288    {
    289         x = entity_pos_t::FromInt(i*(int)CELL_SIZE + CELL_SIZE/2);
    290         z = entity_pos_t::FromInt(j*(int)CELL_SIZE + CELL_SIZE/2);
     289        x = entity_pos_t::FromInt(i*(int)CELL_SIZE + (int)CELL_SIZE/2);
     290        z = entity_pos_t::FromInt(j*(int)CELL_SIZE + (int)CELL_SIZE/2);
    291291    }
    292292
  • ps/trunk/source/simulation2/components/CCmpPathfinder_Tile.cpp

    r9566 r10017  
    6161
    6262    // Get pi,pj coords of predecessor to this tile on best path, given i,j coords of this tile
    63     u16 GetPredI(u16 i) { return i+dpi; }
    64     u16 GetPredJ(u16 j) { return j+dpj; }
     63    u16 GetPredI(u16 i) { return (u16)(i + dpi); }
     64    u16 GetPredJ(u16 j) { return (u16)(j + dpj); }
    6565    // Set the pi,pj coords of predecessor, given i,j coords of this tile
    6666    void SetPred(u16 pi_, u16 pj_, u16 i, u16 j)
    6767    {
    68         dpi = pi_-i;
    69         dpj = pj_-j;
     68        dpi = (i8)((int)pi_ - (int)i);
     69        dpj = (i8)((int)pj_ - (int)j);
    7070#if PATHFIND_DEBUG
    7171        // predecessor must be adjacent
     
    115115    virtual void ProcessTile(ssize_t i, ssize_t j)
    116116    {
    117         if (m_Pathfinder.m_Grid && !IS_PASSABLE(m_Pathfinder.m_Grid->get(i, j), m_Pathfinder.m_DebugPassClass))
     117        if (m_Pathfinder.m_Grid && !IS_PASSABLE(m_Pathfinder.m_Grid->get((int)i, (int)j), m_Pathfinder.m_DebugPassClass))
    118118            RenderTile(CColor(1, 0, 0, 0.6f), false);
    119119
    120120        if (m_Pathfinder.m_DebugGrid)
    121121        {
    122             PathfindTile& n = m_Pathfinder.m_DebugGrid->get(i, j);
    123 
    124             float c = clamp(n.GetStep() / (float)m_Pathfinder.m_DebugSteps, 0.f, 1.f);
     122            PathfindTile& n = m_Pathfinder.m_DebugGrid->get((int)i, (int)j);
     123
     124            float c = clamp((float)n.GetStep() / (float)m_Pathfinder.m_DebugSteps, 0.f, 1.f);
    125125
    126126            if (n.IsOpen())
     
    388388    // otherwise just aim at the center point. (We'll never try moving outwards to a square shape.)
    389389    if (goal.type == Goal::CIRCLE)
    390         state.rGoal = (goal.hw / (int)CELL_SIZE).ToInt_RoundToZero();
     390        state.rGoal = (u16)(goal.hw / (int)CELL_SIZE).ToInt_RoundToZero();
    391391    else
    392392        state.rGoal = 0;
     
    462462        u32 g = state.tiles->get(i, j).cost;
    463463        if (i > 0)
    464             ProcessNeighbour(i, j, i-1, j, g, state);
     464            ProcessNeighbour(i, j, (u16)(i-1), j, g, state);
    465465        if (i < m_MapSize-1)
    466             ProcessNeighbour(i, j, i+1, j, g, state);
     466            ProcessNeighbour(i, j, (u16)(i+1), j, g, state);
    467467        if (j > 0)
    468             ProcessNeighbour(i, j, i, j-1, g, state);
     468            ProcessNeighbour(i, j, i, (u16)(j-1), g, state);
    469469        if (j < m_MapSize-1)
    470             ProcessNeighbour(i, j, i, j+1, g, state);
     470            ProcessNeighbour(i, j, i, (u16)(j+1), g, state);
    471471    }
    472472
  • ps/trunk/source/simulation2/components/CCmpPathfinder_Vertex.cpp

    r9362 r10017  
    383383                if (any)
    384384                {
    385                     CFixedVector2D v0 = CFixedVector2D(fixed::FromInt(i * CELL_SIZE) - r, fixed::FromInt(j * CELL_SIZE) - r);
    386                     CFixedVector2D v1 = CFixedVector2D(fixed::FromInt((i+1) * CELL_SIZE) + r, fixed::FromInt((j+1) * CELL_SIZE) + r);
     385                    CFixedVector2D v0 = CFixedVector2D(fixed::FromInt(i * (int)CELL_SIZE) - r, fixed::FromInt(j * (int)CELL_SIZE) - r);
     386                    CFixedVector2D v1 = CFixedVector2D(fixed::FromInt((i+1) * (int)CELL_SIZE) + r, fixed::FromInt((j+1) * (int)CELL_SIZE) + r);
    387387                    Edge e = { v0, v1 };
    388388                    edgesAA.push_back(e);
     
    410410        case TileEdge::BOTTOM:
    411411        {
    412             v0 = CFixedVector2D(fixed::FromInt(i * CELL_SIZE) - r, fixed::FromInt(j * CELL_SIZE) - r);
    413             v1 = CFixedVector2D(fixed::FromInt((i+1) * CELL_SIZE) + r, fixed::FromInt(j * CELL_SIZE) - r);
     412            v0 = CFixedVector2D(fixed::FromInt(i * (int)CELL_SIZE) - r, fixed::FromInt(j * (int)CELL_SIZE) - r);
     413            v1 = CFixedVector2D(fixed::FromInt((i+1) * (int)CELL_SIZE) + r, fixed::FromInt(j * (int)CELL_SIZE) - r);
    414414            vert.p.X = v0.X - EDGE_EXPAND_DELTA; vert.p.Y = v0.Y - EDGE_EXPAND_DELTA; vert.quadInward = QUADRANT_TR; vertexes.push_back(vert);
    415415            vert.p.X = v1.X + EDGE_EXPAND_DELTA; vert.p.Y = v1.Y - EDGE_EXPAND_DELTA; vert.quadInward = QUADRANT_TL; vertexes.push_back(vert);
     
    418418        case TileEdge::TOP:
    419419        {
    420             v0 = CFixedVector2D(fixed::FromInt((i+1) * CELL_SIZE) + r, fixed::FromInt((j+1) * CELL_SIZE) + r);
    421             v1 = CFixedVector2D(fixed::FromInt(i * CELL_SIZE) - r, fixed::FromInt((j+1) * CELL_SIZE) + r);
     420            v0 = CFixedVector2D(fixed::FromInt((i+1) * (int)CELL_SIZE) + r, fixed::FromInt((j+1) * (int)CELL_SIZE) + r);
     421            v1 = CFixedVector2D(fixed::FromInt(i * (int)CELL_SIZE) - r, fixed::FromInt((j+1) * (int)CELL_SIZE) + r);
    422422            vert.p.X = v0.X + EDGE_EXPAND_DELTA; vert.p.Y = v0.Y + EDGE_EXPAND_DELTA; vert.quadInward = QUADRANT_BL; vertexes.push_back(vert);
    423423            vert.p.X = v1.X - EDGE_EXPAND_DELTA; vert.p.Y = v1.Y + EDGE_EXPAND_DELTA; vert.quadInward = QUADRANT_BR; vertexes.push_back(vert);
     
    426426        case TileEdge::LEFT:
    427427        {
    428             v0 = CFixedVector2D(fixed::FromInt(i * CELL_SIZE) - r, fixed::FromInt((j+1) * CELL_SIZE) + r);
    429             v1 = CFixedVector2D(fixed::FromInt(i * CELL_SIZE) - r, fixed::FromInt(j * CELL_SIZE) - r);
     428            v0 = CFixedVector2D(fixed::FromInt(i * (int)CELL_SIZE) - r, fixed::FromInt((j+1) * (int)CELL_SIZE) + r);
     429            v1 = CFixedVector2D(fixed::FromInt(i * (int)CELL_SIZE) - r, fixed::FromInt(j * (int)CELL_SIZE) - r);
    430430            vert.p.X = v0.X - EDGE_EXPAND_DELTA; vert.p.Y = v0.Y + EDGE_EXPAND_DELTA; vert.quadInward = QUADRANT_BR; vertexes.push_back(vert);
    431431            vert.p.X = v1.X - EDGE_EXPAND_DELTA; vert.p.Y = v1.Y - EDGE_EXPAND_DELTA; vert.quadInward = QUADRANT_TR; vertexes.push_back(vert);
     
    434434        case TileEdge::RIGHT:
    435435        {
    436             v0 = CFixedVector2D(fixed::FromInt((i+1) * CELL_SIZE) + r, fixed::FromInt(j * CELL_SIZE) - r);
    437             v1 = CFixedVector2D(fixed::FromInt((i+1) * CELL_SIZE) + r, fixed::FromInt((j+1) * CELL_SIZE) + r);
     436            v0 = CFixedVector2D(fixed::FromInt((i+1) * (int)CELL_SIZE) + r, fixed::FromInt(j * (int)CELL_SIZE) - r);
     437            v1 = CFixedVector2D(fixed::FromInt((i+1) * (int)CELL_SIZE) + r, fixed::FromInt((j+1) * (int)CELL_SIZE) + r);
    438438            vert.p.X = v0.X + EDGE_EXPAND_DELTA; vert.p.Y = v0.Y - EDGE_EXPAND_DELTA; vert.quadInward = QUADRANT_TL; vertexes.push_back(vert);
    439439            vert.p.X = v1.X + EDGE_EXPAND_DELTA; vert.p.Y = v1.Y + EDGE_EXPAND_DELTA; vert.quadInward = QUADRANT_BL; vertexes.push_back(vert);
     
    524524        case CCmpPathfinder::Goal::SQUARE:
    525525        {
    526             float a = atan2(goal.v.X.ToFloat(), goal.v.Y.ToFloat());
     526            float a = atan2f(goal.v.X.ToFloat(), goal.v.Y.ToFloat());
    527527            SimRender::ConstructSquareOnGround(GetSimContext(), goal.x.ToFloat(), goal.z.ToFloat(), goal.hw.ToFloat()*2, goal.hh.ToFloat()*2, a, m_DebugOverlayShortPathLines.back(), true);
    528528            break;
     
    801801                    // was very near another unit), don't restrict further pathing.
    802802                    if (vertexes[n].quadInward && !(curr.id == START_VERTEX_ID && g < fixed::FromInt(8)))
    803                         vertexes[n].quadOutward = ((~vertexes[n].quadInward) & quad);
     803                        vertexes[n].quadOutward = ((~vertexes[n].quadInward) & quad) & 0xF;
    804804
    805805                    if (n == GOAL_VERTEX_ID)
     
    830830                    // direction (but not go into the inside of the shape).
    831831                    if (vertexes[n].quadInward)
    832                         vertexes[n].quadOutward = ((~vertexes[n].quadInward) & quad);
     832                        vertexes[n].quadOutward = ((~vertexes[n].quadInward) & quad) & 0xF;
    833833
    834834                    if (n == GOAL_VERTEX_ID)
  • ps/trunk/source/simulation2/components/CCmpPosition.cpp

    r9605 r10017  
    396396            float delta = rotY - m_InterpolatedRotY;
    397397            // Wrap delta to -M_PI..M_PI
    398             delta = fmod(delta + (float)M_PI, 2*(float)M_PI); // range -2PI..2PI
     398            delta = fmodf(delta + (float)M_PI, 2*(float)M_PI); // range -2PI..2PI
    399399            if (delta < 0) delta += 2*(float)M_PI; // range 0..2PI
    400400            delta -= (float)M_PI; // range -M_PI..M_PI
  • ps/trunk/source/simulation2/components/CCmpProjectileManager.cpp

    r9494 r10017  
    197197
    198198    CVector3D offset = projectile.target - projectile.pos;
    199     float horizDistance = hypot(offset.X, offset.Z);
     199    float horizDistance = hypotf(offset.X, offset.Z);
    200200
    201201    projectile.speedFactor = 1.f;
     
    222222        // To prevent arrows going crazily far after missing the target,
    223223        // apply a bit of drag to them
    224         projectile.speedFactor *= pow(1.0f - 0.4f*projectile.speedFactor, dt);
     224        projectile.speedFactor *= powf(1.0f - 0.4f*projectile.speedFactor, dt);
    225225    }
    226226    else
     
    283283        axis.Normalize();
    284284
    285     float angle = acos(up.Dot(delta));
     285    float angle = acosf(up.Dot(delta));
    286286
    287287    CMatrix3D transform;
  • ps/trunk/source/simulation2/components/CCmpRangeManager.cpp

    r9951 r10017  
    201201    // 2-bit ELosState per player, starting with player 1 (not 0!) up to player MAX_LOS_PLAYER_ID (inclusive)
    202202    std::vector<u32> m_LosState;
    203     static const int MAX_LOS_PLAYER_ID = 16;
     203    static const player_id_t MAX_LOS_PLAYER_ID = 16;
    204204
    205205    // Special static visibility data for the "reveal whole map" mode
     
    378378            }
    379379
    380             it->second.owner = msgData.to;
     380            ENSURE(-128 <= msgData.to && msgData.to <= 127);
     381            it->second.owner = (i8)msgData.to;
    381382
    382383            break;
     
    422423        m_WorldX1 = x1;
    423424        m_WorldZ1 = z1;
    424         m_TerrainVerticesPerSide = vertices;
     425        m_TerrainVerticesPerSide = (i32)vertices;
    425426
    426427        ResetDerivedData(false);
     
    468469        std::vector<int> owners, int requiredInterface)
    469470    {
    470         size_t id = m_QueryNext++;
     471        tag_t id = m_QueryNext++;
    471472        m_Queries[id] = ConstructQuery(source, minRange, maxRange, owners, requiredInterface);
    472473
    473         return (tag_t)id;
     474        return id;
    474475    }
    475476
     
    775776                m_DebugOverlayLines.push_back(SOverlayLine());
    776777                m_DebugOverlayLines.back().m_Color = (q.enabled ? enabledRingColour : disabledRingColour);
    777                 SimRender::ConstructCircleOnGround(GetSimContext(), pos.X.ToFloat(), pos.Y.ToDouble(), q.maxRange.ToFloat(), m_DebugOverlayLines.back(), true);
     778                SimRender::ConstructCircleOnGround(GetSimContext(), pos.X.ToFloat(), pos.Y.ToFloat(), q.maxRange.ToFloat(), m_DebugOverlayLines.back(), true);
    778779
    779780                // Draw the min range circle
     
    782783                    m_DebugOverlayLines.push_back(SOverlayLine());
    783784                    m_DebugOverlayLines.back().m_Color = (q.enabled ? enabledRingColour : disabledRingColour);
    784                     SimRender::ConstructCircleOnGround(GetSimContext(), pos.X.ToFloat(), pos.Y.ToDouble(), q.minRange.ToFloat(), m_DebugOverlayLines.back(), true);
     785                    SimRender::ConstructCircleOnGround(GetSimContext(), pos.X.ToFloat(), pos.Y.ToFloat(), q.minRange.ToFloat(), m_DebugOverlayLines.back(), true);
    785786                }
    786787
     
    912913        // for every vertex around that tile, to mark them as explored
    913914
    914         for (size_t j = 0; j < grid.m_H; ++j)
    915         {
    916             for (size_t i = 0; i < grid.m_W; ++i)
     915        for (u16 j = 0; j < grid.m_H; ++j)
     916        {
     917            for (u16 i = 0; i < grid.m_W; ++i)
    917918            {
    918919                u8 p = grid.get(i, j);
     
    980981            }
    981982
    982             counts[idx] += 1;
     983            counts[idx] = (u16)(counts[idx] + 1); // ignore overflow; the player should never have 64K units
    983984        }
    984985    }
     
    997998        for (i32 idx = idx0; idx <= idx1; ++idx)
    998999        {
    999             counts[idx] -= 1;
     1000            counts[idx] = (u16)(counts[idx] - 1);
    10001001
    10011002            // Decreasing from non-zero to zero - move from visible+explored to explored
     
    11971198    }
    11981199
    1199     void LosAdd(i8 owner, entity_pos_t visionRange, CFixedVector2D pos)
     1200    void LosAdd(player_id_t owner, entity_pos_t visionRange, CFixedVector2D pos)
    12001201    {
    12011202        if (visionRange.IsZero() || owner <= 0 || owner > MAX_LOS_PLAYER_ID)
    12021203            return;
    12031204
    1204         LosUpdateHelper<true>(owner, visionRange, pos);
    1205     }
    1206 
    1207     void LosRemove(i8 owner, entity_pos_t visionRange, CFixedVector2D pos)
     1205        LosUpdateHelper<true>((u8)owner, visionRange, pos);
     1206    }
     1207
     1208    void LosRemove(player_id_t owner, entity_pos_t visionRange, CFixedVector2D pos)
    12081209    {
    12091210        if (visionRange.IsZero() || owner <= 0 || owner > MAX_LOS_PLAYER_ID)
    12101211            return;
    12111212
    1212         LosUpdateHelper<false>(owner, visionRange, pos);
    1213     }
    1214 
    1215     void LosMove(i8 owner, entity_pos_t visionRange, CFixedVector2D from, CFixedVector2D to)
     1213        LosUpdateHelper<false>((u8)owner, visionRange, pos);
     1214    }
     1215
     1216    void LosMove(player_id_t owner, entity_pos_t visionRange, CFixedVector2D from, CFixedVector2D to)
    12161217    {
    12171218        if (visionRange.IsZero() || owner <= 0 || owner > MAX_LOS_PLAYER_ID)
     
    12221223            // If it's a very large move, then simply remove and add to the new position
    12231224
    1224             LosUpdateHelper<false>(owner, visionRange, from);
    1225             LosUpdateHelper<true>(owner, visionRange, to);
     1225            LosUpdateHelper<false>((u8)owner, visionRange, from);
     1226            LosUpdateHelper<true>((u8)owner, visionRange, to);
    12261227        }
    12271228        else
     
    12291230            // Otherwise use the version optimised for mostly-overlapping circles
    12301231
    1231             LosUpdateHelperIncremental(owner, visionRange, from, to);
     1232            LosUpdateHelperIncremental((u8)owner, visionRange, from, to);
    12321233        }
    12331234    }
  • ps/trunk/source/simulation2/components/CCmpTerrain.cpp

    r9566 r10017  
    8080    }
    8181
    82     virtual uint32_t GetVerticesPerSide()
     82    virtual u16 GetTilesPerSide()
    8383    {
    84         return m_Terrain->GetVerticesPerSide();
     84        ssize_t tiles = m_Terrain->GetTilesPerSide();
     85        ENSURE(1 <= tiles && tiles <= 65535);
     86        return (u16)tiles;
     87    }
     88
     89    virtual u16 GetVerticesPerSide()
     90    {
     91        ssize_t vertices = m_Terrain->GetVerticesPerSide();
     92        ENSURE(1 <= vertices && vertices <= 65535);
     93        return (u16)vertices;
    8594    }
    8695
     
    94103        // TODO: should refactor this code to be nicer
    95104
     105        u16 tiles = GetTilesPerSide();
     106        u16 vertices = GetVerticesPerSide();
     107
    96108        CmpPtr<ICmpObstructionManager> cmpObstructionManager(GetSimContext(), SYSTEM_ENTITY);
    97109        if (!cmpObstructionManager.null())
    98110        {
    99111            cmpObstructionManager->SetBounds(entity_pos_t::Zero(), entity_pos_t::Zero(),
    100                     entity_pos_t::FromInt(m_Terrain->GetTilesPerSide()*CELL_SIZE),
    101                     entity_pos_t::FromInt(m_Terrain->GetTilesPerSide()*CELL_SIZE));
     112                    entity_pos_t::FromInt(tiles*(int)CELL_SIZE),
     113                    entity_pos_t::FromInt(tiles*(int)CELL_SIZE));
    102114        }
    103115
     
    106118        {
    107119            cmpRangeManager->SetBounds(entity_pos_t::Zero(), entity_pos_t::Zero(),
    108                     entity_pos_t::FromInt(m_Terrain->GetTilesPerSide()*CELL_SIZE),
    109                     entity_pos_t::FromInt(m_Terrain->GetTilesPerSide()*CELL_SIZE),
    110                     m_Terrain->GetVerticesPerSide());
     120                    entity_pos_t::FromInt(tiles*(int)CELL_SIZE),
     121                    entity_pos_t::FromInt(tiles*(int)CELL_SIZE),
     122                    vertices);
    111123        }
    112124
    113         MakeDirty(0, 0, m_Terrain->GetTilesPerSide()+1, m_Terrain->GetTilesPerSide()+1);
     125        MakeDirty(0, 0, tiles+1, tiles+1);
    114126    }
    115127
    116     virtual void MakeDirty(ssize_t i0, ssize_t j0, ssize_t i1, ssize_t j1)
     128    virtual void MakeDirty(i32 i0, i32 j0, i32 i1, i32 j1)
    117129    {
    118130        CMessageTerrainChanged msg(i0, j0, i1, j1);
  • ps/trunk/source/simulation2/components/CCmpTerritoryInfluence.cpp

    r9906 r10017  
    3030    DEFAULT_COMPONENT_ALLOCATOR(TerritoryInfluence)
    3131
    32     int m_Cost;
     32    i32 m_Cost;
    3333    u32 m_Weight;
    3434    u32 m_Radius;
     
    7676    }
    7777
    78     virtual int GetCost()
     78    virtual i32 GetCost()
    7979    {
    8080        return m_Cost;
  • ps/trunk/source/simulation2/components/CCmpTerritoryManager.cpp

    r9970 r10017  
    9898        CParamNode::LoadXML(externalParamNode, L"simulation/data/territorymanager.xml");
    9999
    100         m_ImpassableCost = externalParamNode.GetChild("TerritoryManager").GetChild("ImpassableCost").ToInt();
     100        int impassableCost = externalParamNode.GetChild("TerritoryManager").GetChild("ImpassableCost").ToInt();
     101        ENSURE(0 <= impassableCost && impassableCost <= 255);
     102        m_ImpassableCost = (u8)impassableCost;
    101103        m_BorderThickness = externalParamNode.GetChild("TerritoryManager").GetChild("BorderThickness").ToFixed().ToFloat();
    102104        m_BorderSeparation = externalParamNode.GetChild("TerritoryManager").GetChild("BorderSeparation").ToFixed().ToFloat();
     
    260262        u16 z = tile.id.second;
    261263        if (x > 0)
    262             ProcessNeighbour(falloff, x-1, z, tile.rank, false, grid, openTiles, costGrid);
     264            ProcessNeighbour(falloff, (u16)(x-1), z, tile.rank, false, grid, openTiles, costGrid);
    263265        if (x < tilesW-1)
    264             ProcessNeighbour(falloff, x+1, z, tile.rank, false, grid, openTiles, costGrid);
     266            ProcessNeighbour(falloff, (u16)(x+1), z, tile.rank, false, grid, openTiles, costGrid);
    265267        if (z > 0)
    266             ProcessNeighbour(falloff, x, z-1, tile.rank, false, grid, openTiles, costGrid);
     268            ProcessNeighbour(falloff, x, (u16)(z-1), tile.rank, false, grid, openTiles, costGrid);
    267269        if (z < tilesH-1)
    268             ProcessNeighbour(falloff, x, z+1, tile.rank, false, grid, openTiles, costGrid);
     270            ProcessNeighbour(falloff, x, (u16)(z+1), tile.rank, false, grid, openTiles, costGrid);
    269271        if (x > 0 && z > 0)
    270             ProcessNeighbour(falloff, x-1, z-1, tile.rank, true, grid, openTiles, costGrid);
     272            ProcessNeighbour(falloff, (u16)(x-1), (u16)(z-1), tile.rank, true, grid, openTiles, costGrid);
    271273        if (x > 0 && z < tilesH-1)
    272             ProcessNeighbour(falloff, x-1, z+1, tile.rank, true, grid, openTiles, costGrid);
     274            ProcessNeighbour(falloff, (u16)(x-1), (u16)(z+1), tile.rank, true, grid, openTiles, costGrid);
    273275        if (x < tilesW-1 && z > 0)
    274             ProcessNeighbour(falloff, x+1, z-1, tile.rank, true, grid, openTiles, costGrid);
     276            ProcessNeighbour(falloff, (u16)(x+1), (u16)(z-1), tile.rank, true, grid, openTiles, costGrid);
    275277        if (x < tilesW-1 && z < tilesH-1)
    276             ProcessNeighbour(falloff, x+1, z+1, tile.rank, true, grid, openTiles, costGrid);
     278            ProcessNeighbour(falloff, (u16)(x+1), (u16)(z+1), tile.rank, true, grid, openTiles, costGrid);
    277279    }
    278280}
     
    286288
    287289    CmpPtr<ICmpTerrain> cmpTerrain(GetSimContext(), SYSTEM_ENTITY);
    288     uint32_t tilesW = cmpTerrain->GetVerticesPerSide() - 1;
    289     uint32_t tilesH = cmpTerrain->GetVerticesPerSide() - 1;
     290    u16 tilesW = cmpTerrain->GetTilesPerSide();
     291    u16 tilesH = cmpTerrain->GetTilesPerSide();
    290292
    291293    SAFE_DELETE(m_Territories);
     
    299301    ICmpPathfinder::pass_class_t passClassDefault = cmpPathfinder->GetPassabilityClass("default");
    300302    const Grid<u16>& passGrid = cmpPathfinder->GetPassabilityGrid();
    301     for (u32 j = 0; j < tilesH; ++j)
    302     {
    303         for (u32 i = 0; i < tilesW; ++i)
     303    for (u16 j = 0; j < tilesH; ++j)
     304    {
     305        for (u16 i = 0; i < tilesW; ++i)
    304306        {
    305307            u16 g = passGrid.get(i, j);
     
    365367            CmpPtr<ICmpPosition> cmpPosition(GetSimContext(), *eit);
    366368            CFixedVector2D pos = cmpPosition->GetPosition2D();
    367             int i = clamp((pos.X / (int)CELL_SIZE).ToInt_RoundToNegInfinity(), 0, (int)tilesW-1);
    368             int j = clamp((pos.Y / (int)CELL_SIZE).ToInt_RoundToNegInfinity(), 0, (int)tilesH-1);
     369            u16 i = (u16)clamp((pos.X / (int)CELL_SIZE).ToInt_RoundToNegInfinity(), 0, tilesW-1);
     370            u16 j = (u16)clamp((pos.Y / (int)CELL_SIZE).ToInt_RoundToNegInfinity(), 0, tilesH-1);
    369371
    370372            CmpPtr<ICmpTerritoryInfluence> cmpTerritoryInfluence(GetSimContext(), *eit);
     
    419421static void NearestTile(entity_pos_t x, entity_pos_t z, u16& i, u16& j, u16 w, u16 h)
    420422{
    421     i = clamp((x / (int)CELL_SIZE).ToInt_RoundToZero(), 0, w-1);
    422     j = clamp((z / (int)CELL_SIZE).ToInt_RoundToZero(), 0, h-1);
     423    i = (u16)clamp((x / (int)CELL_SIZE).ToInt_RoundToZero(), 0, w-1);
     424    j = (u16)clamp((z / (int)CELL_SIZE).ToInt_RoundToZero(), 0, h-1);
    423425}
    424426
     
    428430static void TileCenter(u16 i, u16 j, entity_pos_t& x, entity_pos_t& z)
    429431{
    430     x = entity_pos_t::FromInt(i*(int)CELL_SIZE + CELL_SIZE/2);
    431     z = entity_pos_t::FromInt(j*(int)CELL_SIZE + CELL_SIZE/2);
     432    x = entity_pos_t::FromInt(i*(int)CELL_SIZE + (int)CELL_SIZE/2);
     433    z = entity_pos_t::FromInt(j*(int)CELL_SIZE + (int)CELL_SIZE/2);
    432434}
    433435
     
    441443        ICmpTerritoryInfluence* cmpTerritoryInfluence = static_cast<ICmpTerritoryInfluence*>(it->second);
    442444
    443         int cost = cmpTerritoryInfluence->GetCost();
     445        i32 cost = cmpTerritoryInfluence->GetCost();
    444446        if (cost == -1)
    445447            continue;
     
    466468                TileCenter(i, j, x, z);
    467469                if (Geometry::PointIsInSquare(CFixedVector2D(x - square.x, z - square.z), square.u, square.v, halfSize))
    468                     grid.set(i, j, cost);
     470                    grid.set(i, j, (u8)cost);
    469471            }
    470472        }
     
    493495
    494496    // Try to find an assigned tile
    495     for (int j = 0; j < grid.m_H; ++j)
    496     {
    497         for (int i = 0; i < grid.m_W; ++i)
     497    for (u16 j = 0; j < grid.m_H; ++j)
     498    {
     499        for (u16 i = 0; i < grid.m_W; ++i)
    498500        {
    499501            u8 owner = grid.get(i, j);
     
    508510                std::vector<CVector2D>& points = boundaries.back().points;
    509511
    510                 int dir = 0; // 0 == bottom edge of tile, 1 == right, 2 == top, 3 == left
    511 
    512                 int cdir = dir;
    513                 int ci = i, cj = j;
     512                u8 dir = 0; // 0 == bottom edge of tile, 1 == right, 2 == top, 3 == left
     513
     514                u8 cdir = dir;
     515                u16 ci = i, cj = j;
     516
     517                u16 maxi = (u16)(grid.m_W-1);
     518                u16 maxj = (u16)(grid.m_H-1);
    514519
    515520                while (true)
     
    523528                    {
    524529                    case 0:
    525                         if (ci < grid.m_W-1 && cj > 0 && grid.get(ci+1, cj-1) == owner)
     530                        if (ci < maxi && cj > 0 && grid.get(ci+1, cj-1) == owner)
    526531                        {
    527532                            ++ci;
     
    529534                            cdir = 3;
    530535                        }
    531                         else if (ci < grid.m_W-1 && grid.get(ci+1, cj) == owner)
     536                        else if (ci < maxi && grid.get(ci+1, cj) == owner)
    532537                            ++ci;
    533538                        else
     
    535540                        break;
    536541                    case 1:
    537                         if (ci < grid.m_W-1 && cj < grid.m_H-1 && grid.get(ci+1, cj+1) == owner)
     542                        if (ci < maxi && cj < maxj && grid.get(ci+1, cj+1) == owner)
    538543                        {
    539544                            ++ci;
     
    541546                            cdir = 0;
    542547                        }
    543                         else if (cj < grid.m_H-1 && grid.get(ci, cj+1) == owner)
     548                        else if (cj < maxj && grid.get(ci, cj+1) == owner)
    544549                            ++cj;
    545550                        else
     
    547552                        break;
    548553                    case 2:
    549                         if (ci > 0 && cj < grid.m_H-1 && grid.get(ci-1, cj+1) == owner)
     554                        if (ci > 0 && cj < maxj && grid.get(ci-1, cj+1) == owner)
    550555                        {
    551556                            --ci;
     
    579584                // Zero out this whole territory with a simple flood fill, so we don't
    580585                // process it a second time
    581                 std::vector<std::pair<int, int> > tileStack;
     586                std::vector<std::pair<u16, u16> > tileStack;
    582587
    583588#define ZERO_AND_PUSH(i, j) STMT(grid.set(i, j, 0); tileStack.push_back(std::make_pair(i, j)); )
     
    592597                    if (ti > 0 && grid.get(ti-1, tj) == owner)
    593598                        ZERO_AND_PUSH(ti-1, tj);
    594                     if (ti < grid.m_W-1 && grid.get(ti+1, tj) == owner)
     599                    if (ti < maxi && grid.get(ti+1, tj) == owner)
    595600                        ZERO_AND_PUSH(ti+1, tj);
    596601                    if (tj > 0 && grid.get(ti, tj-1) == owner)
    597602                        ZERO_AND_PUSH(ti, tj-1);
    598                     if (tj < grid.m_H-1 && grid.get(ti, tj+1) == owner)
     603                    if (tj < maxj && grid.get(ti, tj+1) == owner)
    599604                        ZERO_AND_PUSH(ti, tj+1);
    600605
    601606                    if (ti > 0 && tj > 0 && grid.get(ti-1, tj-1) == owner)
    602607                        ZERO_AND_PUSH(ti-1, tj-1);
    603                     if (ti > 0 && tj < grid.m_H-1 && grid.get(ti-1, tj+1) == owner)
     608                    if (ti > 0 && tj < maxj && grid.get(ti-1, tj+1) == owner)
    604609                        ZERO_AND_PUSH(ti-1, tj+1);
    605                     if (ti < grid.m_W-1 && tj > 0 && grid.get(ti+1, tj-1) == owner)
     610                    if (ti < maxi && tj > 0 && grid.get(ti+1, tj-1) == owner)
    606611                        ZERO_AND_PUSH(ti+1, tj-1);
    607                     if (ti < grid.m_W-1 && tj < grid.m_H-1 && grid.get(ti+1, tj+1) == owner)
     612                    if (ti < maxi && tj < maxj && grid.get(ti+1, tj+1) == owner)
    608613                        ZERO_AND_PUSH(ti+1, tj+1);
    609614                }
     
    704709        return;
    705710
    706     u8 id = m_TerritoryManager.m_Territories->get(i, j);
     711    u8 id = m_TerritoryManager.m_Territories->get((int)i, (int)j);
    707712
    708713    float a = 0.2f;
  • ps/trunk/source/simulation2/components/CCmpUnitMotion.cpp

    r9970 r10017  
    10431043    entity_pos_t distLeft = minDistance;
    10441044
    1045     for (ssize_t i = path.m_Waypoints.size()-1; i >= 0; --i)
     1045    for (ssize_t i = (ssize_t)path.m_Waypoints.size()-1; i >= 0; --i)
    10461046    {
    10471047        // Check if the next path segment is longer than the requested minimum
  • ps/trunk/source/simulation2/components/CCmpVisualActor.cpp

    r9345 r10017  
    352352        // Save some data from the old unit
    353353        CColor shading = m_Unit->GetModel().GetShadingColor();
    354         size_t playerID = m_Unit->GetModel().GetPlayerID();
     354        player_id_t playerID = m_Unit->GetModel().GetPlayerID();
    355355
    356356        // Replace with the new unit
  • ps/trunk/source/simulation2/components/ICmpObstructionManager.h

    r8899 r10017  
    7979        FLAG_MOVING             = (1 << 4)  // indicates this unit is currently moving
    8080    };
     81
     82    /**
     83     * Bitmask of EFlag values.
     84     */
     85    typedef u8 flags_t;
    8186
    8287    /**
     
    98103     * @return a valid tag for manipulating the shape
    99104     */
    100     virtual tag_t AddStaticShape(entity_id_t ent, entity_pos_t x, entity_pos_t z, entity_angle_t a, entity_pos_t w, entity_pos_t h, u8 flags) = 0;
     105    virtual tag_t AddStaticShape(entity_id_t ent, entity_pos_t x, entity_pos_t z, entity_angle_t a, entity_pos_t w, entity_pos_t h, flags_t flags) = 0;
    101106
    102107    /**
     
    110115     * @return a valid tag for manipulating the shape
    111116     */
    112     virtual tag_t AddUnitShape(entity_id_t ent, entity_pos_t x, entity_pos_t z, entity_angle_t r, u8 flags, entity_id_t group) = 0;
     117    virtual tag_t AddUnitShape(entity_id_t ent, entity_pos_t x, entity_pos_t z, entity_angle_t r, flags_t flags, entity_id_t group) = 0;
    113118
    114119    /**
     
    263268{
    264269public:
     270    typedef ICmpObstructionManager::tag_t tag_t;
     271    typedef ICmpObstructionManager::flags_t flags_t;
     272
    265273    virtual ~IObstructionTestFilter() {}
    266274
     
    272280     * @param group the control group (typically the shape's unit, or the unit's formation controller, or 0)
    273281     */
    274     virtual bool Allowed(ICmpObstructionManager::tag_t tag, u8 flags, entity_id_t group) const = 0;
     282    virtual bool Allowed(tag_t tag, flags_t flags, entity_id_t group) const = 0;
    275283};
    276284
     
    281289{
    282290public:
    283     virtual bool Allowed(ICmpObstructionManager::tag_t UNUSED(tag), u8 UNUSED(flags), entity_id_t UNUSED(group)) const
     291    virtual bool Allowed(tag_t UNUSED(tag), flags_t UNUSED(flags), entity_id_t UNUSED(group)) const
    284292    {
    285293        return true;
     
    293301{
    294302public:
    295     virtual bool Allowed(ICmpObstructionManager::tag_t UNUSED(tag), u8 flags, entity_id_t UNUSED(group)) const
     303    virtual bool Allowed(tag_t UNUSED(tag), flags_t flags, entity_id_t UNUSED(group)) const
    296304    {
    297305        return !(flags & ICmpObstructionManager::FLAG_MOVING);
     
    314322    }
    315323
    316     virtual bool Allowed(ICmpObstructionManager::tag_t UNUSED(tag), u8 flags, entity_id_t group) const
     324    virtual bool Allowed(tag_t UNUSED(tag), flags_t flags, entity_id_t group) const
    317325    {
    318326        if (group == m_Group)
     
    331339class SkipTagObstructionFilter : public IObstructionTestFilter
    332340{
    333     ICmpObstructionManager::tag_t m_Tag;
    334 public:
    335     SkipTagObstructionFilter(ICmpObstructionManager::tag_t tag) : m_Tag(tag)
    336     {
    337     }
    338 
    339     virtual bool Allowed(ICmpObstructionManager::tag_t tag, u8 UNUSED(flags), entity_id_t UNUSED(group)) const
     341    tag_t m_Tag;
     342public:
     343    SkipTagObstructionFilter(tag_t tag) : m_Tag(tag)
     344    {
     345    }
     346
     347    virtual bool Allowed(tag_t tag, flags_t UNUSED(flags), entity_id_t UNUSED(group)) const
    340348    {
    341349        return tag.n != m_Tag.n;
     
    348356class SkipTagFlagsObstructionFilter : public IObstructionTestFilter
    349357{
    350     ICmpObstructionManager::tag_t m_Tag;
    351     u8 m_Mask;
    352 public:
    353     SkipTagFlagsObstructionFilter(ICmpObstructionManager::tag_t tag, u8 mask) : m_Tag(tag), m_Mask(mask)
    354     {
    355     }
    356 
    357     virtual bool Allowed(ICmpObstructionManager::tag_t tag, u8 flags, entity_id_t UNUSED(group)) const
     358    tag_t m_Tag;
     359    flags_t m_Mask;
     360public:
     361    SkipTagFlagsObstructionFilter(tag_t tag, flags_t mask) : m_Tag(tag), m_Mask(mask)
     362    {
     363    }
     364
     365    virtual bool Allowed(tag_t tag, flags_t flags, entity_id_t UNUSED(group)) const
    358366    {
    359367        return (tag.n != m_Tag.n && (flags & m_Mask) != 0);
  • ps/trunk/source/simulation2/components/ICmpTerrain.h

    r9566 r10017  
    3636    virtual float GetExactGroundLevel(float x, float z) = 0;
    3737
    38     virtual uint32_t GetVerticesPerSide() = 0;
     38    /**
     39     * Returns number of tiles per side on the terrain.
     40     * Return value is always non-zero.
     41     */
     42    virtual u16 GetTilesPerSide() = 0;
     43
     44    /**
     45     * Returns number of vertices per side on the terrain.
     46     * Return value is always non-zero.
     47     */
     48    virtual u16 GetVerticesPerSide() = 0;
    3949
    4050    virtual CTerrain* GetCTerrain() = 0;
     
    5262     * sent to any components that care about terrain changes.
    5363     */
    54     virtual void MakeDirty(ssize_t i0, ssize_t j0, ssize_t i1, ssize_t j1) = 0;
     64    virtual void MakeDirty(i32 i0, i32 j0, i32 i1, i32 j1) = 0;
    5565
    5666    DECLARE_INTERFACE_TYPE(Terrain)
  • ps/trunk/source/simulation2/components/ICmpTerritoryInfluence.h

    r9906 r10017  
    2929     * under the entity's obstruction.
    3030     */
    31     virtual int GetCost() = 0;
     31    virtual i32 GetCost() = 0;
    3232
    3333    virtual u32 GetWeight() = 0;
  • ps/trunk/source/simulation2/helpers/Grid.h

    r9362 r10017  
    8181    }
    8282
    83     void set(size_t i, size_t j, const T& value)
     83    void set(int i, int j, const T& value)
    8484    {
    8585#if GRID_BOUNDS_DEBUG
    86         ENSURE(i < m_W && j < m_H);
     86        ENSURE(0 <= i && i < m_W && 0 <= j && j < m_H);
    8787#endif
    8888        m_Data[j*m_W + i] = value;
    8989    }
    9090
    91     T& get(size_t i, size_t j) const
     91    T& get(int i, int j) const
    9292    {
    9393#if GRID_BOUNDS_DEBUG
    94         ENSURE(i < m_W && j < m_H);
     94        ENSURE(0 <= i && i < m_W && 0 <= j && j < m_H);
    9595#endif
    9696        return m_Data[j*m_W + i];
     
    114114    enum { BucketBits = 4, BucketSize = 1 << BucketBits };
    115115
    116     T* GetBucket(size_t i, size_t j)
     116    T* GetBucket(int i, int j)
    117117    {
    118118        size_t b = (j >> BucketBits) * m_BW + (i >> BucketBits);
     
    130130        ENSURE(m_W && m_H);
    131131
    132         m_BW = (m_W + BucketSize-1) >> BucketBits;
    133         m_BH = (m_H + BucketSize-1) >> BucketBits;
     132        m_BW = (u16)((m_W + BucketSize-1) >> BucketBits);
     133        m_BH = (u16)((m_H + BucketSize-1) >> BucketBits);
    134134
    135135        m_Data = new T*[m_BW*m_BH];
     
    151151    }
    152152
    153     void set(size_t i, size_t j, const T& value)
     153    void set(int i, int j, const T& value)
    154154    {
    155155#if GRID_BOUNDS_DEBUG
    156         ENSURE(i < m_W && j < m_H);
     156        ENSURE(0 <= i && i < m_W && 0 <= j && j < m_H);
    157157#endif
    158158        GetBucket(i, j)[(j % BucketSize)*BucketSize + (i % BucketSize)] = value;
    159159    }
    160160
    161     T& get(size_t i, size_t j)
     161    T& get(int i, int j)
    162162    {
    163163#if GRID_BOUNDS_DEBUG
    164         ENSURE(i < m_W && j < m_H);
     164        ENSURE(0 <= i && i < m_W && 0 <= j && j < m_H);
    165165#endif
    166166        return GetBucket(i, j)[(j % BucketSize)*BucketSize + (i % BucketSize)];
  • ps/trunk/source/simulation2/helpers/Render.cpp

    r9929 r10017  
    8888    for (size_t i = 0; i <= numPoints; ++i) // use '<=' so it's a closed loop
    8989    {
    90         float a = i * 2 * (float)M_PI / numPoints;
    91         float px = x + radius * sin(a);
    92         float pz = z + radius * cos(a);
     90        float a = (float)i * 2 * (float)M_PI / (float)numPoints;
     91        float px = x + radius * sinf(a);
     92        float pz = z + radius * cosf(a);
    9393        float py = std::max(water, cmpTerrain->GetExactGroundLevel(px, pz)) + heightOffset;
    9494        overlay.m_Coords.push_back(px);
     
    101101static void SplitLine(std::vector<std::pair<float, float> >& coords, float x1, float y1, float x2, float y2)
    102102{
    103     float length = sqrt(SQR(x1 - x2) + SQR(y1 - y2));
     103    float length = sqrtf(SQR(x1 - x2) + SQR(y1 - y2));
    104104    size_t pieces = ((int)length) / CELL_SIZE;
    105105    if (pieces > 0)
    106106    {
    107         float xPieceLength = (x1 - x2) / pieces;
    108         float yPieceLength = (y1 - y2) / pieces;
     107        float xPieceLength = (x1 - x2) / (float)pieces;
     108        float yPieceLength = (y1 - y2) / (float)pieces;
    109109        for (size_t i = 1; i <= (pieces - 1); ++i)
    110110        {
    111             coords.push_back(std::make_pair(x1 - (xPieceLength * i), y1 - (yPieceLength * i)));
     111            coords.push_back(std::make_pair(x1 - (xPieceLength * (float)i), y1 - (yPieceLength * (float)i)));
    112112        }
    113113    }
     
    132132    }
    133133
    134     float c = cos(a);
    135     float s = sin(a);
     134    float c = cosf(a);
     135    float s = sinf(a);
    136136
    137137    std::vector<std::pair<float, float> > coords;
  • ps/trunk/source/simulation2/helpers/Spatial.h

    r9362 r10017  
    6161        ENSURE(toMin.X <= toMax.X && toMin.Y <= toMax.Y);
    6262
    63         size_t i0 = GetI0(toMin.X);
    64         size_t j0 = GetJ0(toMin.Y);
    65         size_t i1 = GetI1(toMax.X);
    66         size_t j1 = GetJ1(toMax.Y);
    67         for (size_t j = j0; j <= j1; ++j)
     63        u32 i0 = GetI0(toMin.X);
     64        u32 j0 = GetJ0(toMin.Y);
     65        u32 i1 = GetI1(toMax.X);
     66        u32 j1 = GetJ1(toMax.Y);
     67        for (u32 j = j0; j <= j1; ++j)
    6868        {
    69             for (size_t i = i0; i <= i1; ++i)
     69            for (u32 i = i0; i <= i1; ++i)
    7070            {
    7171                std::vector<T>& div = m_Divisions.at(i + j*m_DivisionsW);
     
    8484        ENSURE(fromMin.X <= fromMax.X && fromMin.Y <= fromMax.Y);
    8585
    86         size_t i0 = GetI0(fromMin.X);
    87         size_t j0 = GetJ0(fromMin.Y);
    88         size_t i1 = GetI1(fromMax.X);
    89         size_t j1 = GetJ1(fromMax.Y);
    90         for (size_t j = j0; j <= j1; ++j)
     86        u32 i0 = GetI0(fromMin.X);
     87        u32 j0 = GetJ0(fromMin.Y);
     88        u32 i1 = GetI1(fromMax.X);
     89        u32 j1 = GetJ1(fromMax.Y);
     90        for (u32 j = j0; j <= j1; ++j)
    9191        {
    92             for (size_t i = i0; i <= i1; ++i)
     92            for (u32 i = i0; i <= i1; ++i)
    9393            {
    9494                std::vector<T>& div = m_Divisions.at(i + j*m_DivisionsW);
    9595
    96                 for (size_t n = 0; n < div.size(); ++n)
     96                for (u32 n = 0; n < div.size(); ++n)
    9797                {
    9898                    if (div[n] == item)
     
    156156        ENSURE(posMin.X <= posMax.X && posMin.Y <= posMax.Y);
    157157
    158         size_t i0 = GetI0(posMin.X);
    159         size_t j0 = GetJ0(posMin.Y);
    160         size_t i1 = GetI1(posMax.X);
    161         size_t j1 = GetJ1(posMax.Y);
    162         for (size_t j = j0; j <= j1; ++j)
     158        u32 i0 = GetI0(posMin.X);
     159        u32 j0 = GetJ0(posMin.Y);
     160        u32 i1 = GetI1(posMax.X);
     161        u32 j1 = GetJ1(posMax.Y);
     162        for (u32 j = j0; j <= j1; ++j)
    163163        {
    164             for (size_t i = i0; i <= i1; ++i)
     164            for (u32 i = i0; i <= i1; ++i)
    165165            {
    166166                std::vector<T>& div = m_Divisions.at(i + j*m_DivisionsW);
     
    193193    // points precisely between divisions are counted in both):
    194194
    195     size_t GetI0(entity_pos_t x)
     195    u32 GetI0(entity_pos_t x)
    196196    {
    197197        return Clamp((x / m_DivisionSize).ToInt_RoundToInfinity()-1, 0, (int)m_DivisionsW-1);
    198198    }
    199199
    200     size_t GetJ0(entity_pos_t z)
     200    u32 GetJ0(entity_pos_t z)
    201201    {
    202202        return Clamp((z / m_DivisionSize).ToInt_RoundToInfinity()-1, 0, (int)m_DivisionsH-1);
    203203    }
    204204
    205     size_t GetI1(entity_pos_t x)
     205    u32 GetI1(entity_pos_t x)
    206206    {
    207207        return Clamp((x / m_DivisionSize).ToInt_RoundToNegInfinity(), 0, (int)m_DivisionsW-1);
    208208    }
    209209
    210     size_t GetJ1(entity_pos_t z)
     210    u32 GetJ1(entity_pos_t z)
    211211    {
    212212        return Clamp((z / m_DivisionSize).ToInt_RoundToNegInfinity(), 0, (int)m_DivisionsH-1);
    213213    }
    214214
    215     size_t GetIndex0(CFixedVector2D pos)
     215    u32 GetIndex0(CFixedVector2D pos)
    216216    {
    217217        return GetI0(pos.X) + GetJ0(pos.Y)*m_DivisionsW;
    218218    }
    219219
    220     size_t GetIndex1(CFixedVector2D pos)
     220    u32 GetIndex1(CFixedVector2D pos)
    221221    {
    222222        return GetI1(pos.X) + GetJ1(pos.Y)*m_DivisionsW;
     
    225225    entity_pos_t m_DivisionSize;
    226226    std::vector<std::vector<T> > m_Divisions;
    227     size_t m_DivisionsW;
    228     size_t m_DivisionsH;
     227    u32 m_DivisionsW;
     228    u32 m_DivisionsH;
    229229
    230230    template<typename ELEM> friend struct SerializeSpatialSubdivision;
  • ps/trunk/source/simulation2/scripting/EngineScriptConversions.cpp

    r9852 r10017  
    217217        return JSVAL_VOID;
    218218
    219     size_t len = val.m_W * val.m_H;
     219    jsuint len = val.m_W * val.m_H;
    220220    JSObject *darray = js_CreateTypedArray(cx, js::TypedArray::TYPE_UINT16, len);
    221221    if (!darray)
  • ps/trunk/source/simulation2/serialization/DebugSerializer.cpp

    r9362 r10017  
    4040// TODO: we just do e+0xx now; ought to handle varying precisions and inf and nan etc too
    4141template<typename T>
    42 std::string canonfloat(T value, size_t prec)
     42std::string canonfloat(T value, int prec)
    4343{
    4444    std::stringstream str;
  • ps/trunk/source/simulation2/system/ComponentTest.h

    r9178 r10017  
    178178    }
    179179
    180     virtual uint32_t GetVerticesPerSide()
     180    virtual u16 GetTilesPerSide()
     181    {
     182        return 16;
     183    }
     184
     185    virtual u16 GetVerticesPerSide()
    181186    {
    182187        return 17;
     
    188193    }
    189194
    190     virtual void MakeDirty(ssize_t UNUSED(i0), ssize_t UNUSED(j0), ssize_t UNUSED(i1), ssize_t UNUSED(j1))
     195    virtual void MakeDirty(i32 UNUSED(i0), i32 UNUSED(j0), i32 UNUSED(i1), i32 UNUSED(j1))
    191196    {
    192197    }
  • ps/trunk/source/sound/SoundGroup.h

    r7442 r10017  
    9696
    9797    // Set a flag using a value from eSndGrpFlags
    98     inline void SetFlag(int flag) { m_Flags |= flag; }
     98    inline void SetFlag(int flag) { m_Flags = (unsigned char)(m_Flags | flag); }
    9999
    100100    // Test flag, returns true if flag is set.
Note: See TracChangeset for help on using the changeset viewer.