- Timestamp:
- 08/16/11 13:18:32 (13 years ago)
- Location:
- ps/trunk/source
- Files:
-
- 34 edited
-
graphics/ShaderProgram.h (modified) (1 diff)
-
lib/os_path.h (modified) (1 diff)
-
lib/timer.h (modified) (2 diffs)
-
maths/Fixed.h (modified) (1 diff)
-
ps/Overlay.h (modified) (1 diff)
-
ps/utf16string.h (modified) (1 diff)
-
simulation2/components/CCmpAIManager.cpp (modified) (5 diffs)
-
simulation2/components/CCmpFootprint.cpp (modified) (3 diffs)
-
simulation2/components/CCmpMinimap.cpp (modified) (2 diffs)
-
simulation2/components/CCmpMotionBall.cpp (modified) (2 diffs)
-
simulation2/components/CCmpObstruction.cpp (modified) (9 diffs)
-
simulation2/components/CCmpObstructionManager.cpp (modified) (13 diffs)
-
simulation2/components/CCmpPathfinder.cpp (modified) (15 diffs)
-
simulation2/components/CCmpPathfinder_Common.h (modified) (2 diffs)
-
simulation2/components/CCmpPathfinder_Tile.cpp (modified) (4 diffs)
-
simulation2/components/CCmpPathfinder_Vertex.cpp (modified) (8 diffs)
-
simulation2/components/CCmpPosition.cpp (modified) (1 diff)
-
simulation2/components/CCmpProjectileManager.cpp (modified) (3 diffs)
-
simulation2/components/CCmpRangeManager.cpp (modified) (12 diffs)
-
simulation2/components/CCmpTerrain.cpp (modified) (3 diffs)
-
simulation2/components/CCmpTerritoryInfluence.cpp (modified) (2 diffs)
-
simulation2/components/CCmpTerritoryManager.cpp (modified) (19 diffs)
-
simulation2/components/CCmpUnitMotion.cpp (modified) (1 diff)
-
simulation2/components/CCmpVisualActor.cpp (modified) (1 diff)
-
simulation2/components/ICmpObstructionManager.h (modified) (10 diffs)
-
simulation2/components/ICmpTerrain.h (modified) (2 diffs)
-
simulation2/components/ICmpTerritoryInfluence.h (modified) (1 diff)
-
simulation2/helpers/Grid.h (modified) (4 diffs)
-
simulation2/helpers/Render.cpp (modified) (3 diffs)
-
simulation2/helpers/Spatial.h (modified) (5 diffs)
-
simulation2/scripting/EngineScriptConversions.cpp (modified) (1 diff)
-
simulation2/serialization/DebugSerializer.cpp (modified) (1 diff)
-
simulation2/system/ComponentTest.h (modified) (2 diffs)
-
sound/SoundGroup.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
ps/trunk/source/graphics/ShaderProgram.h
r9419 r10017 64 64 friend class CShaderProgramARB; 65 65 private: 66 Binding(int v, int f) : vertex( v), fragment(f) { }66 Binding(int v, int f) : vertex((i16)v), fragment((i16)f) { } 67 67 i16 vertex; 68 68 i16 fragment; -
ps/trunk/source/lib/os_path.h
r9362 r10017 47 47 { 48 48 ENSURE(wstring[i] <= UCHAR_MAX); 49 string[i] = wstring[i];49 string[i] = (char)wstring[i]; 50 50 } 51 51 return string; -
ps/trunk/source/lib/timer.h
r9362 r10017 200 200 std::wstring ToString() const 201 201 { 202 ENSURE(m_cycles >= 0 .0);202 ENSURE(m_cycles >= 0); 203 203 return StringForCycles(m_cycles); 204 204 } … … 206 206 double ToSeconds() const 207 207 { 208 return m_cycles / os_cpu_ClockFrequency();208 return (double)m_cycles / os_cpu_ClockFrequency(); 209 209 } 210 210 -
ps/trunk/source/maths/Fixed.h
r8160 r10017 149 149 static CFixed FromString(const CStrW& s); 150 150 151 /// Convert to float. May be lossy - float can't represent all values. 151 152 float ToFloat() const 152 153 { 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. 156 158 double ToDouble() const 157 159 { -
ps/trunk/source/ps/Overlay.h
r7214 r10017 52 52 SColor4ub AsSColor4ub() const 53 53 { 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)); 55 55 } 56 56 -
ps/trunk/source/ps/utf16string.h
r7259 r10017 62 62 const char_type* end=s; 63 63 while (*end) end++; 64 return end-s;64 return (size_t)(end-s); 65 65 } 66 66 -
ps/trunk/source/simulation2/components/CCmpAIManager.cpp
r9852 r10017 142 142 u8* img = buf.get() + hdr_size; 143 143 for (size_t i = 0; i < data.size(); ++i) 144 img[i] = ( data[i] * 255) / max;144 img[i] = (u8)((data[i] * 255) / max); 145 145 146 146 tex_write(&t, filename); … … 360 360 void SerializeState(ISerializer& serializer) 361 361 { 362 serializer.NumberU32_Unbounded("num ais", m_Players.size());362 serializer.NumberU32_Unbounded("num ais", (u32)m_Players.size()); 363 363 364 364 for (size_t i = 0; i < m_Players.size(); ++i) … … 368 368 serializer.ScriptVal("data", m_Players[i]->m_Obj); 369 369 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()); 371 371 for (size_t j = 0; j < m_Players[i]->m_Commands.size(); ++j) 372 372 { … … 528 528 const CMessageProgressiveLoad& msgData = static_cast<const CMessageProgressiveLoad&> (msg); 529 529 530 *msgData.total += m_TemplateNames.size();530 *msgData.total += (int)m_TemplateNames.size(); 531 531 532 532 if (*msgData.progressed) … … 536 536 *msgData.progressed = true; 537 537 538 *msgData.progress += m_TemplateLoadedIdx;538 *msgData.progress += (int)m_TemplateLoadedIdx; 539 539 540 540 break; -
ps/trunk/source/simulation2/components/CCmpFootprint.cpp
r9970 r10017 164 164 165 165 // Max spawning distance in tiles 166 const size_tmaxSpawningDistance = 4;166 const i32 maxSpawningDistance = 4; 167 167 168 168 if (m_Shape == CIRCLE) 169 169 { 170 170 // Expand outwards from foundation 171 for ( size_tdist = 0; dist <= maxSpawningDistance; ++dist)171 for (i32 dist = 0; dist <= maxSpawningDistance; ++dist) 172 172 { 173 173 // 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); 175 175 entity_pos_t radius = m_Size0 + clearance; 176 176 177 177 // Try equally-spaced points around the circle in alternating directions, starting from the front 178 const ssize_tnumPoints = 31 + 2*dist;179 for ( ssize_ti = 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] 180 180 { 181 181 entity_angle_t angle = initialAngle + (entity_angle_t::Pi()*2).Multiply(entity_angle_t::FromInt(i)/(int)numPoints); … … 198 198 199 199 // Expand outwards from foundation 200 for ( size_tdist = 0; dist <= maxSpawningDistance; ++dist)200 for (i32 dist = 0; dist <= maxSpawningDistance; ++dist) 201 201 { 202 202 // 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_tedge = 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) 206 206 { 207 207 // Try equally-spaced points along the edge in alternating directions, starting from the middle 208 const ssize_tnumPoints = 9 + 2*dist;208 const i32 numPoints = 9 + 2*dist; 209 209 210 210 // Compute the direction and length of the current edge … … 237 237 dir = dir.Multiply((sx + clearance*2) / (int)(numPoints-1)); 238 238 239 for ( ssize_ti = 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] 240 240 { 241 241 CFixedVector2D pos (center + dir*i); -
ps/trunk/source/simulation2/components/CCmpMinimap.cpp
r8867 r10017 88 88 { 89 89 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(); 93 93 } 94 94 else … … 177 177 break; 178 178 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 182 183 183 184 break; -
ps/trunk/source/simulation2/components/CCmpMotionBall.cpp
r8867 r10017 95 95 float z = pos.Z.ToFloat(); 96 96 97 CVector3D normal; 98 GetSimContext().GetTerrain().CalcNormal(x / CELL_SIZE, z / CELL_SIZE, normal); 97 CVector3D normal = GetSimContext().GetTerrain().CalcExactNormal(x, z); 99 98 // Flatten the vector, to get the downhill force 100 99 float g = 10.f; … … 108 107 float dt_ = dt.ToFloat(); 109 108 110 m_SpeedX *= pow (drag, dt_);111 m_SpeedZ *= pow (drag, dt_);109 m_SpeedX *= powf(drag, dt_); 110 m_SpeedZ *= powf(drag, dt_); 112 111 113 112 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 41 41 DEFAULT_COMPONENT_ALLOCATOR(Obstruction) 42 42 43 typedef ICmpObstructionManager::tag_t tag_t; 44 typedef ICmpObstructionManager::flags_t flags_t; 45 43 46 // Template state: 44 47 … … 49 52 entity_pos_t m_Size0; // radius or width 50 53 entity_pos_t m_Size1; // radius or depth 51 u8m_TemplateFlags;54 flags_t m_TemplateFlags; 52 55 53 56 // Dynamic state: … … 56 59 bool m_Moving; 57 60 entity_id_t m_ControlGroup; 58 ICmpObstructionManager::tag_t m_Tag;59 u8m_Flags;61 tag_t m_Tag; 62 flags_t m_Flags; 60 63 61 64 static std::string GetSchema() … … 128 131 m_Flags = m_TemplateFlags; 129 132 if (paramNode.GetChild("DisableBlockMovement").ToBool()) 130 m_Flags &= ~ICmpObstructionManager::FLAG_BLOCK_MOVEMENT;133 m_Flags &= (flags_t)(~ICmpObstructionManager::FLAG_BLOCK_MOVEMENT); 131 134 if (paramNode.GetChild("DisableBlockPathfinding").ToBool()) 132 m_Flags &= ~ICmpObstructionManager::FLAG_BLOCK_PATHFINDING;135 m_Flags &= (flags_t)(~ICmpObstructionManager::FLAG_BLOCK_PATHFINDING); 133 136 134 137 m_Active = paramNode.GetChild("Active").ToBool(); 135 138 136 m_Tag = ICmpObstructionManager::tag_t();139 m_Tag = tag_t(); 137 140 m_Moving = false; 138 141 m_ControlGroup = GetEntityId(); … … 195 198 else 196 199 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); 198 201 } 199 202 else if (!data.inWorld && m_Tag.valid()) 200 203 { 201 204 cmpObstructionManager->RemoveShape(m_Tag); 202 m_Tag = ICmpObstructionManager::tag_t();205 m_Tag = tag_t(); 203 206 } 204 207 break; … … 213 216 214 217 cmpObstructionManager->RemoveShape(m_Tag); 215 m_Tag = ICmpObstructionManager::tag_t();218 m_Tag = tag_t(); 216 219 } 217 220 break; … … 245 248 else 246 249 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); 248 251 } 249 252 else if (!active && m_Active) … … 260 263 261 264 cmpObstructionManager->RemoveShape(m_Tag); 262 m_Tag = ICmpObstructionManager::tag_t();265 m_Tag = tag_t(); 263 266 } 264 267 } … … 271 274 { 272 275 // 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); 275 278 } 276 279 else 277 280 { 278 281 // 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)); 281 284 } 282 285 -
ps/trunk/source/simulation2/components/CCmpObstructionManager.cpp
r9362 r10017 52 52 entity_pos_t x, z; 53 53 entity_pos_t r; // radius of circle, or half width of square 54 u8flags;54 ICmpObstructionManager::flags_t flags; 55 55 entity_id_t group; // control group (typically the owner entity, or a formation controller entity) (units ignore collisions with others in the same group) 56 56 }; … … 65 65 CFixedVector2D u, v; // orthogonal unit vectors - axes of local coordinate space 66 66 entity_pos_t hw, hh; // half width/height in local coordinate space 67 u8flags;67 ICmpObstructionManager::flags_t flags; 68 68 }; 69 69 … … 246 246 } 247 247 248 virtual tag_t AddUnitShape(entity_id_t ent, entity_pos_t x, entity_pos_t z, entity_pos_t r, u8flags, 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) 249 249 { 250 250 UnitShape shape = { ent, x, z, r, flags, group }; 251 size_tid = m_UnitShapeNext++;251 u32 id = m_UnitShapeNext++; 252 252 m_UnitShapes[id] = shape; 253 253 MakeDirtyUnit(flags); … … 258 258 } 259 259 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, u8flags)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) 261 261 { 262 262 fixed s, c; … … 266 266 267 267 StaticShape shape = { ent, x, z, u, v, w/2, h/2, flags }; 268 size_tid = m_StaticShapeNext++;268 u32 id = m_StaticShapeNext++; 269 269 m_StaticShapes[id] = shape; 270 270 MakeDirtyStatic(flags); … … 351 351 shape.flags |= FLAG_MOVING; 352 352 else 353 shape.flags &= ~FLAG_MOVING;353 shape.flags &= (flags_t)~FLAG_MOVING; 354 354 355 355 MakeDirtyDebug(); … … 469 469 * Call this when a static shape has changed. 470 470 */ 471 void MakeDirtyStatic( u8flags)471 void MakeDirtyStatic(flags_t flags) 472 472 { 473 473 if (flags & (FLAG_BLOCK_PATHFINDING|FLAG_BLOCK_FOUNDATION)) … … 481 481 * Call this when a unit shape has changed. 482 482 */ 483 void MakeDirtyUnit( u8flags)483 void MakeDirtyUnit(flags_t flags) 484 484 { 485 485 if (flags & (FLAG_BLOCK_PATHFINDING|FLAG_BLOCK_FOUNDATION)) … … 691 691 static void NearestTile(entity_pos_t x, entity_pos_t z, u16& i, u16& j, u16 w, u16 h) 692 692 { 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); 695 695 } 696 696 … … 700 700 static void TileCenter(u16 i, u16 j, entity_pos_t& x, entity_pos_t& z) 701 701 { 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); 704 704 } 705 705 … … 811 811 812 812 // WARNING: CCmpRangeManager::LosIsOffWorld needs to be kept in sync with this 813 const ssize_tedgeSize = 3; // number of tiles around the edge that will be off-world813 const u16 edgeSize = 3; // number of tiles around the edge that will be off-world 814 814 815 815 u8 edgeFlags = TILE_OBSTRUCTED_PATHFINDING | TILE_OBSTRUCTED_FOUNDATION | TILE_OUTOFBOUNDS; … … 845 845 grid.set(i, j, edgeFlags); 846 846 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) 848 848 grid.set(i, j, edgeFlags); 849 849 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) 851 851 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) 854 854 grid.set(i, j, edgeFlags); 855 855 } … … 967 967 m_DebugOverlayLines.push_back(SOverlayLine()); 968 968 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()); 970 970 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); 971 971 } -
ps/trunk/source/simulation2/components/CCmpPathfinder.cpp
r10007 r10017 32 32 #include "simulation2/components/ICmpObstruction.h" 33 33 #include "simulation2/components/ICmpObstructionManager.h" 34 #include "simulation2/components/ICmpTerrain.h" 34 35 #include "simulation2/components/ICmpWaterManager.h" 35 36 #include "simulation2/serialization/SerializeTemplates.h" … … 78 79 // will require some adjustment and rethinking. 79 80 const CParamNode pathingSettings = externalParamNode.GetChild("Pathfinder"); 80 m_MaxSameTurnMoves = pathingSettings.GetChild("MaxSameTurnMoves").ToInt();81 m_MaxSameTurnMoves = (u16)pathingSettings.GetChild("MaxSameTurnMoves").ToInt(); 81 82 82 83 … … 306 307 void CCmpPathfinder::UpdateGrid() 307 308 { 309 CmpPtr<ICmpTerrain> cmpTerrain(GetSimContext(), SYSTEM_ENTITY); 310 if (cmpTerrain.null()) 311 return; // error 312 308 313 // 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()) 310 315 { 311 316 SAFE_DELETE(m_Grid); … … 317 322 if (!m_Grid) 318 323 { 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(); 324 325 m_Grid = new Grid<TerrainTile>(m_MapSize, m_MapSize); 325 326 m_ObstructionGrid = new Grid<u8>(m_MapSize, m_MapSize); … … 354 355 t |= 1; 355 356 else 356 t &= ~1;357 t &= (TerrainTile)~1; 357 358 358 359 if (obstruct & ICmpObstructionManager::TILE_OBSTRUCTED_FOUNDATION) 359 360 t |= 2; 360 361 else 361 t &= ~2;362 t &= (TerrainTile)~2; 362 363 } 363 364 } … … 418 419 419 420 // Expand influences on land to find shore distance 420 for ( size_ty = 0; y < m_MapSize; ++y)421 for (u16 y = 0; y < m_MapSize; ++y) 421 422 { 422 423 u16 min = shoreMax; 423 for ( size_tx = 0; x < m_MapSize; ++x)424 for (u16 x = 0; x < m_MapSize; ++x) 424 425 { 425 426 if (!waterGrid.get(x, y)) … … 434 435 } 435 436 } 436 for ( size_tx = m_MapSize; x > 0; --x)437 for (u16 x = m_MapSize; x > 0; --x) 437 438 { 438 439 if (!waterGrid.get(x-1, y)) … … 448 449 } 449 450 } 450 for ( size_tx = 0; x < m_MapSize; ++x)451 for (u16 x = 0; x < m_MapSize; ++x) 451 452 { 452 453 u16 min = shoreMax; 453 for ( size_ty = 0; y < m_MapSize; ++y)454 for (u16 y = 0; y < m_MapSize; ++y) 454 455 { 455 456 if (!waterGrid.get(x, y)) … … 464 465 } 465 466 } 466 for ( size_ty = m_MapSize; y > 0; --y)467 for (u16 y = m_MapSize; y > 0; --y) 467 468 { 468 469 if (!waterGrid.get(x, y-1)) … … 601 602 void CCmpPathfinder::ProcessSameTurnMoves() 602 603 { 603 u32 moveCount;604 605 604 if (!m_AsyncLongPathRequests.empty()) 606 605 { 607 606 // 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 610 609 if (moveCount <= 0) 611 610 return; … … 613 612 // Copy the long request elements we are going to process into a new array 614 613 std::vector<AsyncLongPathRequest> longRequests; 615 if ( m_AsyncLongPathRequests.size() <= moveCount)614 if ((i32)m_AsyncLongPathRequests.size() <= moveCount) 616 615 { 617 616 m_AsyncLongPathRequests.swap(longRequests); 618 moveCount = longRequests.size();617 moveCount = (i32)longRequests.size(); 619 618 } 620 619 else … … 627 626 ProcessLongRequests(longRequests); 628 627 629 m_SameTurnMovesCount += moveCount;628 m_SameTurnMovesCount = (u16)(m_SameTurnMovesCount + moveCount); 630 629 } 631 630 … … 633 632 { 634 633 // Figure out how many moves we can do now 635 moveCount = m_MaxSameTurnMoves - m_SameTurnMovesCount;634 i32 moveCount = m_MaxSameTurnMoves - m_SameTurnMovesCount; 636 635 637 636 if (moveCount <= 0) … … 640 639 // Copy the short request elements we are going to process into a new array 641 640 std::vector<AsyncShortPathRequest> shortRequests; 642 if ( m_AsyncShortPathRequests.size() <= moveCount)641 if ((i32)m_AsyncShortPathRequests.size() <= moveCount) 643 642 { 644 643 m_AsyncShortPathRequests.swap(shortRequests); 645 moveCount = shortRequests.size();644 moveCount = (i32)shortRequests.size(); 646 645 } 647 646 else … … 654 653 ProcessShortRequests(shortRequests); 655 654 656 m_SameTurnMovesCount += moveCount;655 m_SameTurnMovesCount = (u16)(m_SameTurnMovesCount + moveCount); 657 656 } 658 657 } -
ps/trunk/source/simulation2/components/CCmpPathfinder_Common.h
r9970 r10017 278 278 void NearestTile(entity_pos_t x, entity_pos_t z, u16& i, u16& j) 279 279 { 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); 282 282 } 283 283 … … 287 287 static void TileCenter(u16 i, u16 j, entity_pos_t& x, entity_pos_t& z) 288 288 { 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); 291 291 } 292 292 -
ps/trunk/source/simulation2/components/CCmpPathfinder_Tile.cpp
r9566 r10017 61 61 62 62 // 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); } 65 65 // Set the pi,pj coords of predecessor, given i,j coords of this tile 66 66 void SetPred(u16 pi_, u16 pj_, u16 i, u16 j) 67 67 { 68 dpi = pi_-i;69 dpj = pj_-j;68 dpi = (i8)((int)pi_ - (int)i); 69 dpj = (i8)((int)pj_ - (int)j); 70 70 #if PATHFIND_DEBUG 71 71 // predecessor must be adjacent … … 115 115 virtual void ProcessTile(ssize_t i, ssize_t j) 116 116 { 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)) 118 118 RenderTile(CColor(1, 0, 0, 0.6f), false); 119 119 120 120 if (m_Pathfinder.m_DebugGrid) 121 121 { 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); 125 125 126 126 if (n.IsOpen()) … … 388 388 // otherwise just aim at the center point. (We'll never try moving outwards to a square shape.) 389 389 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(); 391 391 else 392 392 state.rGoal = 0; … … 462 462 u32 g = state.tiles->get(i, j).cost; 463 463 if (i > 0) 464 ProcessNeighbour(i, j, i-1, j, g, state);464 ProcessNeighbour(i, j, (u16)(i-1), j, g, state); 465 465 if (i < m_MapSize-1) 466 ProcessNeighbour(i, j, i+1, j, g, state);466 ProcessNeighbour(i, j, (u16)(i+1), j, g, state); 467 467 if (j > 0) 468 ProcessNeighbour(i, j, i, j-1, g, state);468 ProcessNeighbour(i, j, i, (u16)(j-1), g, state); 469 469 if (j < m_MapSize-1) 470 ProcessNeighbour(i, j, i, j+1, g, state);470 ProcessNeighbour(i, j, i, (u16)(j+1), g, state); 471 471 } 472 472 -
ps/trunk/source/simulation2/components/CCmpPathfinder_Vertex.cpp
r9362 r10017 383 383 if (any) 384 384 { 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); 387 387 Edge e = { v0, v1 }; 388 388 edgesAA.push_back(e); … … 410 410 case TileEdge::BOTTOM: 411 411 { 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); 414 414 vert.p.X = v0.X - EDGE_EXPAND_DELTA; vert.p.Y = v0.Y - EDGE_EXPAND_DELTA; vert.quadInward = QUADRANT_TR; vertexes.push_back(vert); 415 415 vert.p.X = v1.X + EDGE_EXPAND_DELTA; vert.p.Y = v1.Y - EDGE_EXPAND_DELTA; vert.quadInward = QUADRANT_TL; vertexes.push_back(vert); … … 418 418 case TileEdge::TOP: 419 419 { 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); 422 422 vert.p.X = v0.X + EDGE_EXPAND_DELTA; vert.p.Y = v0.Y + EDGE_EXPAND_DELTA; vert.quadInward = QUADRANT_BL; vertexes.push_back(vert); 423 423 vert.p.X = v1.X - EDGE_EXPAND_DELTA; vert.p.Y = v1.Y + EDGE_EXPAND_DELTA; vert.quadInward = QUADRANT_BR; vertexes.push_back(vert); … … 426 426 case TileEdge::LEFT: 427 427 { 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); 430 430 vert.p.X = v0.X - EDGE_EXPAND_DELTA; vert.p.Y = v0.Y + EDGE_EXPAND_DELTA; vert.quadInward = QUADRANT_BR; vertexes.push_back(vert); 431 431 vert.p.X = v1.X - EDGE_EXPAND_DELTA; vert.p.Y = v1.Y - EDGE_EXPAND_DELTA; vert.quadInward = QUADRANT_TR; vertexes.push_back(vert); … … 434 434 case TileEdge::RIGHT: 435 435 { 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); 438 438 vert.p.X = v0.X + EDGE_EXPAND_DELTA; vert.p.Y = v0.Y - EDGE_EXPAND_DELTA; vert.quadInward = QUADRANT_TL; vertexes.push_back(vert); 439 439 vert.p.X = v1.X + EDGE_EXPAND_DELTA; vert.p.Y = v1.Y + EDGE_EXPAND_DELTA; vert.quadInward = QUADRANT_BL; vertexes.push_back(vert); … … 524 524 case CCmpPathfinder::Goal::SQUARE: 525 525 { 526 float a = atan2 (goal.v.X.ToFloat(), goal.v.Y.ToFloat());526 float a = atan2f(goal.v.X.ToFloat(), goal.v.Y.ToFloat()); 527 527 SimRender::ConstructSquareOnGround(GetSimContext(), goal.x.ToFloat(), goal.z.ToFloat(), goal.hw.ToFloat()*2, goal.hh.ToFloat()*2, a, m_DebugOverlayShortPathLines.back(), true); 528 528 break; … … 801 801 // was very near another unit), don't restrict further pathing. 802 802 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; 804 804 805 805 if (n == GOAL_VERTEX_ID) … … 830 830 // direction (but not go into the inside of the shape). 831 831 if (vertexes[n].quadInward) 832 vertexes[n].quadOutward = ((~vertexes[n].quadInward) & quad) ;832 vertexes[n].quadOutward = ((~vertexes[n].quadInward) & quad) & 0xF; 833 833 834 834 if (n == GOAL_VERTEX_ID) -
ps/trunk/source/simulation2/components/CCmpPosition.cpp
r9605 r10017 396 396 float delta = rotY - m_InterpolatedRotY; 397 397 // Wrap delta to -M_PI..M_PI 398 delta = fmod (delta + (float)M_PI, 2*(float)M_PI); // range -2PI..2PI398 delta = fmodf(delta + (float)M_PI, 2*(float)M_PI); // range -2PI..2PI 399 399 if (delta < 0) delta += 2*(float)M_PI; // range 0..2PI 400 400 delta -= (float)M_PI; // range -M_PI..M_PI -
ps/trunk/source/simulation2/components/CCmpProjectileManager.cpp
r9494 r10017 197 197 198 198 CVector3D offset = projectile.target - projectile.pos; 199 float horizDistance = hypot (offset.X, offset.Z);199 float horizDistance = hypotf(offset.X, offset.Z); 200 200 201 201 projectile.speedFactor = 1.f; … … 222 222 // To prevent arrows going crazily far after missing the target, 223 223 // 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); 225 225 } 226 226 else … … 283 283 axis.Normalize(); 284 284 285 float angle = acos (up.Dot(delta));285 float angle = acosf(up.Dot(delta)); 286 286 287 287 CMatrix3D transform; -
ps/trunk/source/simulation2/components/CCmpRangeManager.cpp
r9951 r10017 201 201 // 2-bit ELosState per player, starting with player 1 (not 0!) up to player MAX_LOS_PLAYER_ID (inclusive) 202 202 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; 204 204 205 205 // Special static visibility data for the "reveal whole map" mode … … 378 378 } 379 379 380 it->second.owner = msgData.to; 380 ENSURE(-128 <= msgData.to && msgData.to <= 127); 381 it->second.owner = (i8)msgData.to; 381 382 382 383 break; … … 422 423 m_WorldX1 = x1; 423 424 m_WorldZ1 = z1; 424 m_TerrainVerticesPerSide = vertices;425 m_TerrainVerticesPerSide = (i32)vertices; 425 426 426 427 ResetDerivedData(false); … … 468 469 std::vector<int> owners, int requiredInterface) 469 470 { 470 size_t id = m_QueryNext++;471 tag_t id = m_QueryNext++; 471 472 m_Queries[id] = ConstructQuery(source, minRange, maxRange, owners, requiredInterface); 472 473 473 return (tag_t)id;474 return id; 474 475 } 475 476 … … 775 776 m_DebugOverlayLines.push_back(SOverlayLine()); 776 777 m_DebugOverlayLines.back().m_Color = (q.enabled ? enabledRingColour : disabledRingColour); 777 SimRender::ConstructCircleOnGround(GetSimContext(), pos.X.ToFloat(), pos.Y.To Double(), q.maxRange.ToFloat(), m_DebugOverlayLines.back(), true);778 SimRender::ConstructCircleOnGround(GetSimContext(), pos.X.ToFloat(), pos.Y.ToFloat(), q.maxRange.ToFloat(), m_DebugOverlayLines.back(), true); 778 779 779 780 // Draw the min range circle … … 782 783 m_DebugOverlayLines.push_back(SOverlayLine()); 783 784 m_DebugOverlayLines.back().m_Color = (q.enabled ? enabledRingColour : disabledRingColour); 784 SimRender::ConstructCircleOnGround(GetSimContext(), pos.X.ToFloat(), pos.Y.To Double(), q.minRange.ToFloat(), m_DebugOverlayLines.back(), true);785 SimRender::ConstructCircleOnGround(GetSimContext(), pos.X.ToFloat(), pos.Y.ToFloat(), q.minRange.ToFloat(), m_DebugOverlayLines.back(), true); 785 786 } 786 787 … … 912 913 // for every vertex around that tile, to mark them as explored 913 914 914 for ( size_tj = 0; j < grid.m_H; ++j)915 { 916 for ( size_ti = 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) 917 918 { 918 919 u8 p = grid.get(i, j); … … 980 981 } 981 982 982 counts[idx] += 1;983 counts[idx] = (u16)(counts[idx] + 1); // ignore overflow; the player should never have 64K units 983 984 } 984 985 } … … 997 998 for (i32 idx = idx0; idx <= idx1; ++idx) 998 999 { 999 counts[idx] -= 1;1000 counts[idx] = (u16)(counts[idx] - 1); 1000 1001 1001 1002 // Decreasing from non-zero to zero - move from visible+explored to explored … … 1197 1198 } 1198 1199 1199 void LosAdd( i8owner, entity_pos_t visionRange, CFixedVector2D pos)1200 void LosAdd(player_id_t owner, entity_pos_t visionRange, CFixedVector2D pos) 1200 1201 { 1201 1202 if (visionRange.IsZero() || owner <= 0 || owner > MAX_LOS_PLAYER_ID) 1202 1203 return; 1203 1204 1204 LosUpdateHelper<true>( owner, visionRange, pos);1205 } 1206 1207 void LosRemove( i8owner, 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) 1208 1209 { 1209 1210 if (visionRange.IsZero() || owner <= 0 || owner > MAX_LOS_PLAYER_ID) 1210 1211 return; 1211 1212 1212 LosUpdateHelper<false>( owner, visionRange, pos);1213 } 1214 1215 void LosMove( i8owner, 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) 1216 1217 { 1217 1218 if (visionRange.IsZero() || owner <= 0 || owner > MAX_LOS_PLAYER_ID) … … 1222 1223 // If it's a very large move, then simply remove and add to the new position 1223 1224 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); 1226 1227 } 1227 1228 else … … 1229 1230 // Otherwise use the version optimised for mostly-overlapping circles 1230 1231 1231 LosUpdateHelperIncremental( owner, visionRange, from, to);1232 LosUpdateHelperIncremental((u8)owner, visionRange, from, to); 1232 1233 } 1233 1234 } -
ps/trunk/source/simulation2/components/CCmpTerrain.cpp
r9566 r10017 80 80 } 81 81 82 virtual u int32_t GetVerticesPerSide()82 virtual u16 GetTilesPerSide() 83 83 { 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; 85 94 } 86 95 … … 94 103 // TODO: should refactor this code to be nicer 95 104 105 u16 tiles = GetTilesPerSide(); 106 u16 vertices = GetVerticesPerSide(); 107 96 108 CmpPtr<ICmpObstructionManager> cmpObstructionManager(GetSimContext(), SYSTEM_ENTITY); 97 109 if (!cmpObstructionManager.null()) 98 110 { 99 111 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)); 102 114 } 103 115 … … 106 118 { 107 119 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); 111 123 } 112 124 113 MakeDirty(0, 0, m_Terrain->GetTilesPerSide()+1, m_Terrain->GetTilesPerSide()+1);125 MakeDirty(0, 0, tiles+1, tiles+1); 114 126 } 115 127 116 virtual void MakeDirty( ssize_t i0, ssize_t j0, ssize_t i1, ssize_tj1)128 virtual void MakeDirty(i32 i0, i32 j0, i32 i1, i32 j1) 117 129 { 118 130 CMessageTerrainChanged msg(i0, j0, i1, j1); -
ps/trunk/source/simulation2/components/CCmpTerritoryInfluence.cpp
r9906 r10017 30 30 DEFAULT_COMPONENT_ALLOCATOR(TerritoryInfluence) 31 31 32 i ntm_Cost;32 i32 m_Cost; 33 33 u32 m_Weight; 34 34 u32 m_Radius; … … 76 76 } 77 77 78 virtual i ntGetCost()78 virtual i32 GetCost() 79 79 { 80 80 return m_Cost; -
ps/trunk/source/simulation2/components/CCmpTerritoryManager.cpp
r9970 r10017 98 98 CParamNode::LoadXML(externalParamNode, L"simulation/data/territorymanager.xml"); 99 99 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; 101 103 m_BorderThickness = externalParamNode.GetChild("TerritoryManager").GetChild("BorderThickness").ToFixed().ToFloat(); 102 104 m_BorderSeparation = externalParamNode.GetChild("TerritoryManager").GetChild("BorderSeparation").ToFixed().ToFloat(); … … 260 262 u16 z = tile.id.second; 261 263 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); 263 265 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); 265 267 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); 267 269 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); 269 271 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); 271 273 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); 273 275 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); 275 277 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); 277 279 } 278 280 } … … 286 288 287 289 CmpPtr<ICmpTerrain> cmpTerrain(GetSimContext(), SYSTEM_ENTITY); 288 u int32_t tilesW = cmpTerrain->GetVerticesPerSide() - 1;289 u int32_t tilesH = cmpTerrain->GetVerticesPerSide() - 1;290 u16 tilesW = cmpTerrain->GetTilesPerSide(); 291 u16 tilesH = cmpTerrain->GetTilesPerSide(); 290 292 291 293 SAFE_DELETE(m_Territories); … … 299 301 ICmpPathfinder::pass_class_t passClassDefault = cmpPathfinder->GetPassabilityClass("default"); 300 302 const Grid<u16>& passGrid = cmpPathfinder->GetPassabilityGrid(); 301 for (u 32j = 0; j < tilesH; ++j)302 { 303 for (u 32i = 0; i < tilesW; ++i)303 for (u16 j = 0; j < tilesH; ++j) 304 { 305 for (u16 i = 0; i < tilesW; ++i) 304 306 { 305 307 u16 g = passGrid.get(i, j); … … 365 367 CmpPtr<ICmpPosition> cmpPosition(GetSimContext(), *eit); 366 368 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); 369 371 370 372 CmpPtr<ICmpTerritoryInfluence> cmpTerritoryInfluence(GetSimContext(), *eit); … … 419 421 static void NearestTile(entity_pos_t x, entity_pos_t z, u16& i, u16& j, u16 w, u16 h) 420 422 { 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); 423 425 } 424 426 … … 428 430 static void TileCenter(u16 i, u16 j, entity_pos_t& x, entity_pos_t& z) 429 431 { 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); 432 434 } 433 435 … … 441 443 ICmpTerritoryInfluence* cmpTerritoryInfluence = static_cast<ICmpTerritoryInfluence*>(it->second); 442 444 443 i ntcost = cmpTerritoryInfluence->GetCost();445 i32 cost = cmpTerritoryInfluence->GetCost(); 444 446 if (cost == -1) 445 447 continue; … … 466 468 TileCenter(i, j, x, z); 467 469 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); 469 471 } 470 472 } … … 493 495 494 496 // Try to find an assigned tile 495 for ( intj = 0; j < grid.m_H; ++j)496 { 497 for ( inti = 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) 498 500 { 499 501 u8 owner = grid.get(i, j); … … 508 510 std::vector<CVector2D>& points = boundaries.back().points; 509 511 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); 514 519 515 520 while (true) … … 523 528 { 524 529 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) 526 531 { 527 532 ++ci; … … 529 534 cdir = 3; 530 535 } 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) 532 537 ++ci; 533 538 else … … 535 540 break; 536 541 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) 538 543 { 539 544 ++ci; … … 541 546 cdir = 0; 542 547 } 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) 544 549 ++cj; 545 550 else … … 547 552 break; 548 553 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) 550 555 { 551 556 --ci; … … 579 584 // Zero out this whole territory with a simple flood fill, so we don't 580 585 // process it a second time 581 std::vector<std::pair< int, int> > tileStack;586 std::vector<std::pair<u16, u16> > tileStack; 582 587 583 588 #define ZERO_AND_PUSH(i, j) STMT(grid.set(i, j, 0); tileStack.push_back(std::make_pair(i, j)); ) … … 592 597 if (ti > 0 && grid.get(ti-1, tj) == owner) 593 598 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) 595 600 ZERO_AND_PUSH(ti+1, tj); 596 601 if (tj > 0 && grid.get(ti, tj-1) == owner) 597 602 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) 599 604 ZERO_AND_PUSH(ti, tj+1); 600 605 601 606 if (ti > 0 && tj > 0 && grid.get(ti-1, tj-1) == owner) 602 607 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) 604 609 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) 606 611 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) 608 613 ZERO_AND_PUSH(ti+1, tj+1); 609 614 } … … 704 709 return; 705 710 706 u8 id = m_TerritoryManager.m_Territories->get( i,j);711 u8 id = m_TerritoryManager.m_Territories->get((int)i, (int)j); 707 712 708 713 float a = 0.2f; -
ps/trunk/source/simulation2/components/CCmpUnitMotion.cpp
r9970 r10017 1043 1043 entity_pos_t distLeft = minDistance; 1044 1044 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) 1046 1046 { 1047 1047 // Check if the next path segment is longer than the requested minimum -
ps/trunk/source/simulation2/components/CCmpVisualActor.cpp
r9345 r10017 352 352 // Save some data from the old unit 353 353 CColor shading = m_Unit->GetModel().GetShadingColor(); 354 size_t playerID = m_Unit->GetModel().GetPlayerID();354 player_id_t playerID = m_Unit->GetModel().GetPlayerID(); 355 355 356 356 // Replace with the new unit -
ps/trunk/source/simulation2/components/ICmpObstructionManager.h
r8899 r10017 79 79 FLAG_MOVING = (1 << 4) // indicates this unit is currently moving 80 80 }; 81 82 /** 83 * Bitmask of EFlag values. 84 */ 85 typedef u8 flags_t; 81 86 82 87 /** … … 98 103 * @return a valid tag for manipulating the shape 99 104 */ 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, u8flags) = 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; 101 106 102 107 /** … … 110 115 * @return a valid tag for manipulating the shape 111 116 */ 112 virtual tag_t AddUnitShape(entity_id_t ent, entity_pos_t x, entity_pos_t z, entity_angle_t r, u8flags, 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; 113 118 114 119 /** … … 263 268 { 264 269 public: 270 typedef ICmpObstructionManager::tag_t tag_t; 271 typedef ICmpObstructionManager::flags_t flags_t; 272 265 273 virtual ~IObstructionTestFilter() {} 266 274 … … 272 280 * @param group the control group (typically the shape's unit, or the unit's formation controller, or 0) 273 281 */ 274 virtual bool Allowed( ICmpObstructionManager::tag_t tag, u8flags, entity_id_t group) const = 0;282 virtual bool Allowed(tag_t tag, flags_t flags, entity_id_t group) const = 0; 275 283 }; 276 284 … … 281 289 { 282 290 public: 283 virtual bool Allowed( ICmpObstructionManager::tag_t UNUSED(tag), u8UNUSED(flags), entity_id_t UNUSED(group)) const291 virtual bool Allowed(tag_t UNUSED(tag), flags_t UNUSED(flags), entity_id_t UNUSED(group)) const 284 292 { 285 293 return true; … … 293 301 { 294 302 public: 295 virtual bool Allowed( ICmpObstructionManager::tag_t UNUSED(tag), u8flags, entity_id_t UNUSED(group)) const303 virtual bool Allowed(tag_t UNUSED(tag), flags_t flags, entity_id_t UNUSED(group)) const 296 304 { 297 305 return !(flags & ICmpObstructionManager::FLAG_MOVING); … … 314 322 } 315 323 316 virtual bool Allowed( ICmpObstructionManager::tag_t UNUSED(tag), u8flags, entity_id_t group) const324 virtual bool Allowed(tag_t UNUSED(tag), flags_t flags, entity_id_t group) const 317 325 { 318 326 if (group == m_Group) … … 331 339 class SkipTagObstructionFilter : public IObstructionTestFilter 332 340 { 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, u8UNUSED(flags), entity_id_t UNUSED(group)) const341 tag_t m_Tag; 342 public: 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 340 348 { 341 349 return tag.n != m_Tag.n; … … 348 356 class SkipTagFlagsObstructionFilter : public IObstructionTestFilter 349 357 { 350 ICmpObstructionManager::tag_t m_Tag;351 u8m_Mask;352 public: 353 SkipTagFlagsObstructionFilter( ICmpObstructionManager::tag_t tag, u8mask) : m_Tag(tag), m_Mask(mask)354 { 355 } 356 357 virtual bool Allowed( ICmpObstructionManager::tag_t tag, u8flags, entity_id_t UNUSED(group)) const358 tag_t m_Tag; 359 flags_t m_Mask; 360 public: 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 358 366 { 359 367 return (tag.n != m_Tag.n && (flags & m_Mask) != 0); -
ps/trunk/source/simulation2/components/ICmpTerrain.h
r9566 r10017 36 36 virtual float GetExactGroundLevel(float x, float z) = 0; 37 37 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; 39 49 40 50 virtual CTerrain* GetCTerrain() = 0; … … 52 62 * sent to any components that care about terrain changes. 53 63 */ 54 virtual void MakeDirty( ssize_t i0, ssize_t j0, ssize_t i1, ssize_tj1) = 0;64 virtual void MakeDirty(i32 i0, i32 j0, i32 i1, i32 j1) = 0; 55 65 56 66 DECLARE_INTERFACE_TYPE(Terrain) -
ps/trunk/source/simulation2/components/ICmpTerritoryInfluence.h
r9906 r10017 29 29 * under the entity's obstruction. 30 30 */ 31 virtual i ntGetCost() = 0;31 virtual i32 GetCost() = 0; 32 32 33 33 virtual u32 GetWeight() = 0; -
ps/trunk/source/simulation2/helpers/Grid.h
r9362 r10017 81 81 } 82 82 83 void set( size_t i, size_t j, const T& value)83 void set(int i, int j, const T& value) 84 84 { 85 85 #if GRID_BOUNDS_DEBUG 86 ENSURE( i < m_W&& j < m_H);86 ENSURE(0 <= i && i < m_W && 0 <= j && j < m_H); 87 87 #endif 88 88 m_Data[j*m_W + i] = value; 89 89 } 90 90 91 T& get( size_t i, size_t j) const91 T& get(int i, int j) const 92 92 { 93 93 #if GRID_BOUNDS_DEBUG 94 ENSURE( i < m_W&& j < m_H);94 ENSURE(0 <= i && i < m_W && 0 <= j && j < m_H); 95 95 #endif 96 96 return m_Data[j*m_W + i]; … … 114 114 enum { BucketBits = 4, BucketSize = 1 << BucketBits }; 115 115 116 T* GetBucket( size_t i, size_t j)116 T* GetBucket(int i, int j) 117 117 { 118 118 size_t b = (j >> BucketBits) * m_BW + (i >> BucketBits); … … 130 130 ENSURE(m_W && m_H); 131 131 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); 134 134 135 135 m_Data = new T*[m_BW*m_BH]; … … 151 151 } 152 152 153 void set( size_t i, size_t j, const T& value)153 void set(int i, int j, const T& value) 154 154 { 155 155 #if GRID_BOUNDS_DEBUG 156 ENSURE( i < m_W&& j < m_H);156 ENSURE(0 <= i && i < m_W && 0 <= j && j < m_H); 157 157 #endif 158 158 GetBucket(i, j)[(j % BucketSize)*BucketSize + (i % BucketSize)] = value; 159 159 } 160 160 161 T& get( size_t i, size_t j)161 T& get(int i, int j) 162 162 { 163 163 #if GRID_BOUNDS_DEBUG 164 ENSURE( i < m_W&& j < m_H);164 ENSURE(0 <= i && i < m_W && 0 <= j && j < m_H); 165 165 #endif 166 166 return GetBucket(i, j)[(j % BucketSize)*BucketSize + (i % BucketSize)]; -
ps/trunk/source/simulation2/helpers/Render.cpp
r9929 r10017 88 88 for (size_t i = 0; i <= numPoints; ++i) // use '<=' so it's a closed loop 89 89 { 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); 93 93 float py = std::max(water, cmpTerrain->GetExactGroundLevel(px, pz)) + heightOffset; 94 94 overlay.m_Coords.push_back(px); … … 101 101 static void SplitLine(std::vector<std::pair<float, float> >& coords, float x1, float y1, float x2, float y2) 102 102 { 103 float length = sqrt (SQR(x1 - x2) + SQR(y1 - y2));103 float length = sqrtf(SQR(x1 - x2) + SQR(y1 - y2)); 104 104 size_t pieces = ((int)length) / CELL_SIZE; 105 105 if (pieces > 0) 106 106 { 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; 109 109 for (size_t i = 1; i <= (pieces - 1); ++i) 110 110 { 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))); 112 112 } 113 113 } … … 132 132 } 133 133 134 float c = cos (a);135 float s = sin (a);134 float c = cosf(a); 135 float s = sinf(a); 136 136 137 137 std::vector<std::pair<float, float> > coords; -
ps/trunk/source/simulation2/helpers/Spatial.h
r9362 r10017 61 61 ENSURE(toMin.X <= toMax.X && toMin.Y <= toMax.Y); 62 62 63 size_ti0 = GetI0(toMin.X);64 size_tj0 = GetJ0(toMin.Y);65 size_ti1 = GetI1(toMax.X);66 size_tj1 = GetJ1(toMax.Y);67 for ( size_tj = 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) 68 68 { 69 for ( size_ti = i0; i <= i1; ++i)69 for (u32 i = i0; i <= i1; ++i) 70 70 { 71 71 std::vector<T>& div = m_Divisions.at(i + j*m_DivisionsW); … … 84 84 ENSURE(fromMin.X <= fromMax.X && fromMin.Y <= fromMax.Y); 85 85 86 size_ti0 = GetI0(fromMin.X);87 size_tj0 = GetJ0(fromMin.Y);88 size_ti1 = GetI1(fromMax.X);89 size_tj1 = GetJ1(fromMax.Y);90 for ( size_tj = 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) 91 91 { 92 for ( size_ti = i0; i <= i1; ++i)92 for (u32 i = i0; i <= i1; ++i) 93 93 { 94 94 std::vector<T>& div = m_Divisions.at(i + j*m_DivisionsW); 95 95 96 for ( size_tn = 0; n < div.size(); ++n)96 for (u32 n = 0; n < div.size(); ++n) 97 97 { 98 98 if (div[n] == item) … … 156 156 ENSURE(posMin.X <= posMax.X && posMin.Y <= posMax.Y); 157 157 158 size_ti0 = GetI0(posMin.X);159 size_tj0 = GetJ0(posMin.Y);160 size_ti1 = GetI1(posMax.X);161 size_tj1 = GetJ1(posMax.Y);162 for ( size_tj = 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) 163 163 { 164 for ( size_ti = i0; i <= i1; ++i)164 for (u32 i = i0; i <= i1; ++i) 165 165 { 166 166 std::vector<T>& div = m_Divisions.at(i + j*m_DivisionsW); … … 193 193 // points precisely between divisions are counted in both): 194 194 195 size_tGetI0(entity_pos_t x)195 u32 GetI0(entity_pos_t x) 196 196 { 197 197 return Clamp((x / m_DivisionSize).ToInt_RoundToInfinity()-1, 0, (int)m_DivisionsW-1); 198 198 } 199 199 200 size_tGetJ0(entity_pos_t z)200 u32 GetJ0(entity_pos_t z) 201 201 { 202 202 return Clamp((z / m_DivisionSize).ToInt_RoundToInfinity()-1, 0, (int)m_DivisionsH-1); 203 203 } 204 204 205 size_tGetI1(entity_pos_t x)205 u32 GetI1(entity_pos_t x) 206 206 { 207 207 return Clamp((x / m_DivisionSize).ToInt_RoundToNegInfinity(), 0, (int)m_DivisionsW-1); 208 208 } 209 209 210 size_tGetJ1(entity_pos_t z)210 u32 GetJ1(entity_pos_t z) 211 211 { 212 212 return Clamp((z / m_DivisionSize).ToInt_RoundToNegInfinity(), 0, (int)m_DivisionsH-1); 213 213 } 214 214 215 size_tGetIndex0(CFixedVector2D pos)215 u32 GetIndex0(CFixedVector2D pos) 216 216 { 217 217 return GetI0(pos.X) + GetJ0(pos.Y)*m_DivisionsW; 218 218 } 219 219 220 size_tGetIndex1(CFixedVector2D pos)220 u32 GetIndex1(CFixedVector2D pos) 221 221 { 222 222 return GetI1(pos.X) + GetJ1(pos.Y)*m_DivisionsW; … … 225 225 entity_pos_t m_DivisionSize; 226 226 std::vector<std::vector<T> > m_Divisions; 227 size_tm_DivisionsW;228 size_tm_DivisionsH;227 u32 m_DivisionsW; 228 u32 m_DivisionsH; 229 229 230 230 template<typename ELEM> friend struct SerializeSpatialSubdivision; -
ps/trunk/source/simulation2/scripting/EngineScriptConversions.cpp
r9852 r10017 217 217 return JSVAL_VOID; 218 218 219 size_t len = val.m_W * val.m_H;219 jsuint len = val.m_W * val.m_H; 220 220 JSObject *darray = js_CreateTypedArray(cx, js::TypedArray::TYPE_UINT16, len); 221 221 if (!darray) -
ps/trunk/source/simulation2/serialization/DebugSerializer.cpp
r9362 r10017 40 40 // TODO: we just do e+0xx now; ought to handle varying precisions and inf and nan etc too 41 41 template<typename T> 42 std::string canonfloat(T value, size_t prec)42 std::string canonfloat(T value, int prec) 43 43 { 44 44 std::stringstream str; -
ps/trunk/source/simulation2/system/ComponentTest.h
r9178 r10017 178 178 } 179 179 180 virtual uint32_t GetVerticesPerSide() 180 virtual u16 GetTilesPerSide() 181 { 182 return 16; 183 } 184 185 virtual u16 GetVerticesPerSide() 181 186 { 182 187 return 17; … … 188 193 } 189 194 190 virtual void MakeDirty( ssize_t UNUSED(i0), ssize_t UNUSED(j0), ssize_t UNUSED(i1), ssize_tUNUSED(j1))195 virtual void MakeDirty(i32 UNUSED(i0), i32 UNUSED(j0), i32 UNUSED(i1), i32 UNUSED(j1)) 191 196 { 192 197 } -
ps/trunk/source/sound/SoundGroup.h
r7442 r10017 96 96 97 97 // 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); } 99 99 100 100 // Test flag, returns true if flag is set.
Note:
See TracChangeset
for help on using the changeset viewer.
