* Clamped power variable before assignment to params in object manager. Attempted to fix formatting issues. * Fixed Clamp function not implemented correctly. * Fixed formatting issue, space after commas. * Created ClampPower method in object_manager.h and implemented in object_manager.cpp, Removed similar code from robotmain.cpp * Removed redundant call to ClampPower in object_manager.cpp * Added second call to ClampPower back to object_manager.cpp. Made ClampPower method private. Attempted to fix whitespace issues. * Fixed missing assignment to params.power in CreateObject method of object_manager.cpp * fixed white space at end of line 182 in object_manager.h * Fixed doxygen compatibility issue.fix-quicksave-sim-speed-crash
parent
f1d6787b08
commit
c4385961c4
|
@ -142,6 +142,8 @@ CObject* CObjectManager::CreateObject(ObjectCreateParams params)
|
|||
}
|
||||
}
|
||||
|
||||
params.power = ClampPower(params.type,params.power);
|
||||
|
||||
assert(m_objects.find(params.id) == m_objects.end());
|
||||
|
||||
auto objectUPtr = m_objectFactory->CreateObject(params);
|
||||
|
@ -163,10 +165,20 @@ CObject* CObjectManager::CreateObject(Math::Vector pos, float angle, ObjectType
|
|||
params.angle = angle;
|
||||
params.type = type;
|
||||
params.power = power;
|
||||
|
||||
return CreateObject(params);
|
||||
}
|
||||
|
||||
float CObjectManager::ClampPower(ObjectType type, float power)
|
||||
{
|
||||
float min = 0;
|
||||
float max = 100;
|
||||
if (type == OBJECT_POWER || type == OBJECT_ATOMIC)
|
||||
{
|
||||
max = 1;
|
||||
}
|
||||
return Math::Clamp(power, min, max);
|
||||
}
|
||||
|
||||
std::vector<CObject*> CObjectManager::GetObjectsOfTeam(int team)
|
||||
{
|
||||
std::vector<CObject*> result;
|
||||
|
|
|
@ -303,6 +303,8 @@ public:
|
|||
//@}
|
||||
|
||||
private:
|
||||
//! Prevents creation of overcharged power cells
|
||||
float ClampPower(ObjectType type, float power);
|
||||
void CleanRemovedObjectsIfNeeded();
|
||||
|
||||
private:
|
||||
|
|
Loading…
Reference in New Issue