Skip to content

Commit

Permalink
Merge pull request #959 from ulteq/removed-beamengine-friend
Browse files Browse the repository at this point in the history
[Cleanup] Removed friend 'Beam' from BeamEngine class
  • Loading branch information
ulteq committed May 21, 2016
2 parents 400293e + 33d2cfe commit 34c4faf
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 11 deletions.
10 changes: 10 additions & 0 deletions source/main/gameplay/BeamEngine.cpp
Expand Up @@ -902,6 +902,16 @@ void BeamEngine::setRPM(float rpm)
curEngineRPM = rpm;
}

void BeamEngine::setPrime(int p)
{
prime = p;
}

void BeamEngine::setHydroPumpWork(float work)
{
hydropump = work;
}

void BeamEngine::setSpin(float rpm)
{
curWheelRevolutions = rpm;
Expand Down
11 changes: 10 additions & 1 deletion source/main/gameplay/BeamEngine.h
Expand Up @@ -28,7 +28,6 @@ along with Rigs of Rods. If not, see <http://www.gnu.org/licenses/>.
*/
class BeamEngine : public ZeroedMemoryAllocator
{
friend class Beam;
friend class RigSpawner;
friend class RigInspector; // Debug utility class

Expand Down Expand Up @@ -91,6 +90,16 @@ class BeamEngine : public ZeroedMemoryAllocator
*/
void setRPM(float rpm);

/**
* Set current engine prime.
*/
void setPrime(int p);

/**
* Set current hydro pump work.
*/
void setHydroPumpWork(float work);

/**
* Set current wheel spinning speed.
*/
Expand Down
12 changes: 6 additions & 6 deletions source/main/physics/Beam.cpp
Expand Up @@ -402,7 +402,7 @@ void Beam::scaleTruck(float value)
{
//engine->maxRPM *= value;
//engine->iddleRPM *= value;
engine->engineTorque *= value;
//engine->engineTorque *= value;
//engine->stallRPM *= value;
//engine->brakingTorque *= value;
}
Expand Down Expand Up @@ -1792,8 +1792,8 @@ void Beam::sendStreamData()
send_oob->engine_clutch = engine->getClutch();
send_oob->engine_gear = engine->getGear();

if (engine->contact) send_oob->flagmask += NETMASK_ENGINE_CONT;
if (engine->running) send_oob->flagmask += NETMASK_ENGINE_RUN;
if (engine->hasContact()) send_oob->flagmask += NETMASK_ENGINE_CONT;
if (engine->isRunning()) send_oob->flagmask += NETMASK_ENGINE_RUN;

if (engine->getAutoMode() == BeamEngine::AUTOMATIC) send_oob->flagmask += NETMASK_ENGINE_MODE_AUTOMATIC;
else if (engine->getAutoMode() == BeamEngine::SEMIAUTO) send_oob->flagmask += NETMASK_ENGINE_MODE_SEMIAUTO;
Expand Down Expand Up @@ -4805,7 +4805,7 @@ bool Beam::isLocked()
bool Beam::navigateTo(Vector3 &in)
{
// start engine if not running
if (engine && !engine->running)
if (engine && !engine->isRunning())
engine->start();

Vector3 TargetPosition = in;
Expand Down Expand Up @@ -5001,11 +5001,11 @@ void Beam::updateDashBoards(float dt)
dash->setFloat(DD_ENGINE_TURBO, turbo);

// ignition
bool ign = (engine->contact && !engine->running);
bool ign = (engine->hasContact() && !engine->isRunning());
dash->setBool(DD_ENGINE_IGNITION, ign);

// battery
bool batt = (engine->contact && !engine->running);
bool batt = (engine->hasContact() && !engine->isRunning());
dash->setBool(DD_ENGINE_BATTERY, batt);

// clutch warning
Expand Down
9 changes: 5 additions & 4 deletions source/main/physics/BeamForcesEuler.cpp
Expand Up @@ -1245,7 +1245,7 @@ void Beam::calcForcesEulerCompute(int doUpdate, Real dt, int step, int maxsteps)
if (bbeam_dir*beams[bbeam].autoMovingMode > 0)
v = 1;

if (beams[bbeam].commandNeedsEngine && ((engine && !engine->running) || !canwork)) continue;
if (beams[bbeam].commandNeedsEngine && ((engine && !engine->isRunning()) || !canwork)) continue;

if (v > 0.0f && beams[bbeam].commandEngineCoupling > 0.0f)
requestpower = true;
Expand Down Expand Up @@ -1298,7 +1298,7 @@ void Beam::calcForcesEulerCompute(int doUpdate, Real dt, int step, int maxsteps)
float v = 0.0f;
int rota = std::abs(commandkey[i].rotators[j]) - 1;

if (rotators[rota].rotatorNeedsEngine && ((engine && !engine->running) || !canwork)) continue;
if (rotators[rota].rotatorNeedsEngine && ((engine && !engine->isRunning()) || !canwork)) continue;

if (rotaInertia)
{
Expand All @@ -1324,9 +1324,10 @@ void Beam::calcForcesEulerCompute(int doUpdate, Real dt, int step, int maxsteps)

if (engine)
{
engine->hydropump = work;
engine->prime = requested;
engine->setHydroPumpWork(work);
engine->setPrime(requested);
}

if (doUpdate && state==ACTIVATED)
{
#ifdef USE_OPENAL
Expand Down

0 comments on commit 34c4faf

Please sign in to comment.