Skip to content

Commit 961dc28

Browse files
committed
reverse a lot of changes from #27; use size_t for array indexing instead of unsigned int and avoid use of unsigned in other contexts
1 parent d8e7869 commit 961dc28

File tree

7 files changed

+104
-102
lines changed

7 files changed

+104
-102
lines changed

Source/Entities/LimbPath.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,8 +341,8 @@ float LimbPath::GetRegularProgress() const {
341341
return prog / m_RegularLength;
342342
}
343343

344-
unsigned int LimbPath::GetCurrentSegmentNumber() const {
345-
unsigned int progress = 0;
344+
int LimbPath::GetCurrentSegmentNumber() const {
345+
int progress = 0;
346346
if (!m_Ended && !IsStaticPoint()) {
347347
for (std::deque<Vector>::const_iterator itr = m_Segments.begin(); itr != m_CurrentSegment; ++itr) {
348348
progress++;

Source/Entities/LimbPath.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,13 +94,13 @@ namespace RTE {
9494
/// Gets the number of Vector:s the internal array of 'waypoints' or
9595
/// segments of this LimbPath.
9696
/// @return An int with he count.
97-
unsigned int GetSegCount() const { return m_Segments.size(); }
97+
int GetSegCount() const { return m_Segments.size(); }
9898

9999
/// Gets a pointer to the segment at the given index. Ownership is NOT transferred.
100100
/// @param segmentIndex The index of the segment to get.
101101
/// @return A pointer to the segment at the given index. Ownership is NOT transferred.
102-
Vector* GetSegment(unsigned int segmentIndex) {
103-
if (segmentIndex < m_Segments.size()) {
102+
Vector* GetSegment(int segmentIndex) {
103+
if (segmentIndex < static_cast<int>(m_Segments.size())) {
104104
return &m_Segments.at(segmentIndex);
105105
}
106106
return nullptr;
@@ -219,7 +219,7 @@ namespace RTE {
219219

220220
/// Gets the current segment as a number, rather than an iterator.
221221
/// @return The current segment as a number.
222-
unsigned int GetCurrentSegmentNumber() const;
222+
int GetCurrentSegmentNumber() const;
223223

224224
/// Sets a new array of 'waypoints' or segments of this LimbPath.
225225
/// @param newSpeed An int specifying how many segments there are in the following
@@ -374,7 +374,7 @@ namespace RTE {
374374
// The iterator to the segment of the path that the limb ended up on the end of
375375
std::deque<Vector>::iterator m_CurrentSegment;
376376

377-
unsigned int m_FootCollisionsDisabledSegment; //!< The segment after which foot collisions will be disabled for this limbpath, if it's for legs.
377+
int m_FootCollisionsDisabledSegment; //!< The segment after which foot collisions will be disabled for this limbpath, if it's for legs.
378378

379379
// Normalized measure of how far the limb has progressed toward the
380380
// current segment's target. 0.0 means its farther away than the

Source/Entities/MOSRotating.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1457,7 +1457,7 @@ bool MOSRotating::AttachableIsHardcoded(const Attachable* attachableToCheck) con
14571457
return false;
14581458
}
14591459

1460-
unsigned long attachableUniqueID = attachableToCheck->GetUniqueID();
1460+
long attachableUniqueID = attachableToCheck->GetUniqueID();
14611461
return m_HardcodedAttachableUniqueIDsAndRemovers.find(attachableUniqueID) != m_HardcodedAttachableUniqueIDsAndRemovers.end() || m_HardcodedAttachableUniqueIDsAndSetters.find(attachableUniqueID) != m_HardcodedAttachableUniqueIDsAndSetters.end();
14621462
}
14631463

Source/Entities/MovableObject.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ using namespace RTE;
2222

2323
AbstractClassInfo(MovableObject, SceneObject);
2424

25-
std::atomic<unsigned long int> MovableObject::m_UniqueIDCounter = 1;
25+
std::atomic<long> MovableObject::m_UniqueIDCounter = 1;
2626
std::string MovableObject::ms_EmptyString = "";
2727

2828
MovableObject::MovableObject() {

Source/Entities/MovableObject.h

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -720,7 +720,7 @@ namespace RTE {
720720
/// Returns force vector in newtons of the specified Force record.
721721
/// @param n Force record index to get data from.
722722
/// @return Force vector in newtons of the specified Force record.
723-
Vector GetForceVector(unsigned int n) {
723+
Vector GetForceVector(size_t n) {
724724
if (n > 0 && n < m_Forces.size())
725725
return m_Forces[n].first;
726726
else
@@ -734,7 +734,7 @@ namespace RTE {
734734
/// Returns offset vector in METERS (not pixels) of the specified Force record.
735735
/// @param n Force record index to get data from.
736736
/// @return Offset vector in meters of the specified Force record.
737-
Vector GetForceOffset(unsigned int n) {
737+
Vector GetForceOffset(size_t n) {
738738
if (n > 0 && n < m_Forces.size())
739739
return m_Forces[n].second;
740740
else
@@ -743,14 +743,14 @@ namespace RTE {
743743

744744
/// Sets force vector in newtons of the specified Force record.
745745
/// @param n Force record index to get data from. New Vector force value in newtons.
746-
void SetForceVector(unsigned int n, Vector v) {
746+
void SetForceVector(size_t n, Vector v) {
747747
if (n > 0 && n < m_Forces.size())
748748
m_Forces[n].first = v;
749749
}
750750

751751
/// Sets offset vector in METERS (not pixels) of the specified Force record.
752752
/// @param n Force record index to get data from. New Vector offset value in meters.
753-
void SetForceOffset(unsigned int n, Vector v) {
753+
void SetForceOffset(size_t n, Vector v) {
754754
if (n > 0 && n < m_Forces.size())
755755
m_Forces[n].second = v;
756756
}
@@ -766,7 +766,7 @@ namespace RTE {
766766
/// Returns Impulse vector in newtons of the specified Impulse record.
767767
/// @param n Impulse record index to get data from.
768768
/// @return Impulse vector in newtons of the specified Impulse record.
769-
Vector GetImpulseVector(unsigned int n) {
769+
Vector GetImpulseVector(size_t n) {
770770
if (n > 0 && n < m_ImpulseForces.size())
771771
return m_ImpulseForces[n].first;
772772
else
@@ -776,7 +776,7 @@ namespace RTE {
776776
/// Returns offset vector in METERS (not pixels) of the specified Impulse record.
777777
/// @param n Impulse record index to get data from.
778778
/// @return Offset vector in meters of the specified Impulse record.
779-
Vector GetImpulseOffset(unsigned int n) {
779+
Vector GetImpulseOffset(size_t n) {
780780
if (n > 0 && n < m_ImpulseForces.size())
781781
return m_ImpulseForces[n].second;
782782
else
@@ -786,14 +786,14 @@ namespace RTE {
786786
/// Returns offset vector in METERS (not pixels) of the specified Impulse record.
787787
/// @param n Impulse record index to get data from.
788788
/// @return Offset vector in meters of the specified Impulse record.
789-
void SetImpulseVector(unsigned int n, Vector v) {
789+
void SetImpulseVector(size_t n, Vector v) {
790790
if (n > 0 && n < m_ImpulseForces.size())
791791
m_ImpulseForces[n].first = v;
792792
}
793793

794794
/// Sets offset vector in METERS (not pixels) of the specified Impulse record.
795795
/// @param n Impulse record index to get data from. New Vector offset value in meters.
796-
void SetImpulseOffset(unsigned int n, Vector v) {
796+
void SetImpulseOffset(size_t n, Vector v) {
797797
if (n > 0 && n < m_ImpulseForces.size())
798798
m_ImpulseForces[n].second = v;
799799
}
@@ -939,11 +939,11 @@ namespace RTE {
939939

940940
/// Returns the next unique id for MO's and increments unique ID counter
941941
/// @return Returns the next unique id.
942-
static unsigned long int GetNextUniqueID() { return ++m_UniqueIDCounter; }
942+
static long GetNextUniqueID() { return ++m_UniqueIDCounter; }
943943

944944
/// Returns this MO's unique persistent ID
945945
/// @return Returns this MO's unique persistent ID
946-
unsigned long int const GetUniqueID() const { return m_UniqueID; }
946+
long GetUniqueID() const { return m_UniqueID; }
947947

948948
/// Gets the preset name and unique ID of this MO, often useful for error messages.
949949
/// @return A string containing the unique ID and preset name of this MO.
@@ -1098,7 +1098,7 @@ namespace RTE {
10981098
// Member variables
10991099
static Entity::ClassInfo m_sClass;
11001100
// Global counter with unique ID's
1101-
static std::atomic<unsigned long int> m_UniqueIDCounter;
1101+
static std::atomic<long> m_UniqueIDCounter;
11021102
// The type of MO this is, either Actor, Item, or Particle
11031103
int m_MOType;
11041104
float m_Mass; // In metric kilograms (kg).
@@ -1229,7 +1229,7 @@ namespace RTE {
12291229
bool m_RandomizeEffectRotAngleEveryFrame;
12301230

12311231
// This object's unique persistent ID
1232-
long int m_UniqueID;
1232+
long m_UniqueID;
12331233
// In which radis should we look to remove orphaned terrain on terrain penetration,
12341234
// must not be greater than SceneMan::ORPHANSIZE, or will be truncated
12351235
int m_RemoveOrphanTerrainRadius;
@@ -1254,7 +1254,7 @@ namespace RTE {
12541254
// Unique ID of particle hit this MO
12551255
long int m_ParticleUniqueIDHit;
12561256
// Number of sim update frame when last collision was detected
1257-
unsigned int m_LastCollisionSimFrameNumber;
1257+
int m_LastCollisionSimFrameNumber;
12581258
int m_SimUpdatesBetweenScriptedUpdates; //!< The number of Sim updates between each scripted update for this MovableObject.
12591259
int m_SimUpdatesSinceLastScriptedUpdate; //!< The counter for the current number of Sim updates since this MovableObject last ran a scripted update.
12601260

0 commit comments

Comments
 (0)