Skip to content
This repository has been archived by the owner on Apr 29, 2024. It is now read-only.

Commit

Permalink
fix indentation, rename bTmpOff variable
Browse files Browse the repository at this point in the history
  • Loading branch information
ugeen4 committed Jan 12, 2022
1 parent ad4c1b8 commit 05302e4
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 38 deletions.
20 changes: 10 additions & 10 deletions src/libs/ship/src/ship.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1287,12 +1287,12 @@ uint64_t SHIP::ProcessMessage(MESSAGE &message)
core.Send_Message(flag_id, "lili", MSG_FLAG_INIT, GetModelEID(), GetNation(GetACharacter()), GetId());
break;
// boal 20.08.06 redrawing the flag <--
case MSG_SHIP_LIGHTSRESET: {
const auto bLight = message.Long() != 0;
if (const auto pShipsLights = static_cast<IShipLights *>(EntityManager::GetEntityPointer(shipLights)))
case MSG_SHIP_LIGHTSRESET: {
const auto bLight = message.Long() != 0;
if (const auto pShipsLights = static_cast<IShipLights *>(EntityManager::GetEntityPointer(shipLights)))
pShipsLights->ResetLights(this, bLight);
break;
}
}
case MSG_SHIP_DO_FAKE_FIRE: {
const std::string &cBort = message.String();
float fRandTime = message.Float();
Expand Down Expand Up @@ -1351,7 +1351,7 @@ void SHIP::FakeFire(const char *sBort, float fRandTime)
CVECTOR vDirTemp = mRot * vDir;
float fDir = NormalizeAngle(atan2f(vDirTemp.x, vDirTemp.z));

core.PostEvent("Ship_FakeFire", (uint32_t)(1000 * fRandTime * rand() / RAND_MAX), "ffff", vCurPos.x, vCurPos.y, vCurPos.z, fDir);
core.PostEvent("Ship_FakeFire", (uint32_t)(1000 * fRandTime * rand() / RAND_MAX), "ffff", vCurPos.x, vCurPos.y, vCurPos.z, fDir);
}
}
dwIdx++;
Expand Down Expand Up @@ -1541,11 +1541,11 @@ bool SHIP::Mount(ATTRIBUTES *_pAShip)
if (pFDay && pFNight)
((bLights) ? pFDay : pFNight)->flags &= (~NODE::VISIBLE);

if(bLights && bFlares)
{
const auto pShipsLights = static_cast<IShipLights *>(EntityManager::GetEntityPointer(shipLights));
pShipsLights->ResetLights(this, bLights);
}
if(bLights && bFlares)
{
const auto pShipsLights = static_cast<IShipLights *>(EntityManager::GetEntityPointer(shipLights));
pShipsLights->ResetLights(this, bLights);
}

// add fireplaces
ScanShipForFirePlaces();
Expand Down
53 changes: 26 additions & 27 deletions src/libs/ship/src/ship_lights.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ void ShipLights::AddDynamicLights(VAI_OBJBASE *pObject, const CVECTOR &vPos)
light.pObject = pObject;
light.vPos = vPos;
light.bOff = false;
light.bTmpOff = false;
light.bLightOff = false;
light.bBrokenTimeOff = false;
light.fCurTime = 0.0;
light.fTotalTime = pLT->fLifeTime;
Expand Down Expand Up @@ -229,17 +229,17 @@ void ShipLights::AddFlare(VAI_OBJBASE *pObject, bool bLight, MODEL *pModel, cons
}
}

pL->pNode = pModel->FindNode(str2);
if (!pL->pNode)
pL->pNode = pModel->FindNode(str2);
if (!pL->pNode)
{
aLights.pop_back();
return;
}
// lights & flares position transform
pL->vPos = m.Pos();
CMatrix mNode = pL->pNode->glob_mtx;
mNode.Transposition();
pL->vPos = mNode * pL->vPos;
// lights & flares position transform
pL->vPos = m.Pos();
CMatrix mNode = pL->pNode->glob_mtx;
mNode.Transposition();
pL->vPos = mNode * pL->vPos;
}

LightType *pLT = FindLightType((bLight) ? "default" : "flare");
Expand All @@ -256,7 +256,7 @@ void ShipLights::AddFlare(VAI_OBJBASE *pObject, bool bLight, MODEL *pModel, cons
pL->fBrokenTime = 0.0f;
pL->fTotalBrokenTime = 0.0f;
pL->bOff = false;
pL->bTmpOff = true;
pL->bLightOff = true;
pL->bBrokenTimeOff = false;
pL->bDead = false;

Expand Down Expand Up @@ -379,13 +379,13 @@ void ShipLights::AddLights(VAI_OBJBASE *pObject, MODEL *pModel, bool bLights, bo
{
pNode->geo->GetLabel(i, label);

if (sFlares == label.group_name)
if (sFlares == label.group_name)
{
AddFlare(pObject, false, pModel, label);
continue;
}

if (sLights == label.group_name)
if (sLights == label.group_name)
{
AddFlare(pObject, true, pModel, label);
}
Expand All @@ -396,14 +396,14 @@ void ShipLights::AddLights(VAI_OBJBASE *pObject, MODEL *pModel, bool bLights, bo

void ShipLights::SetLights(VAI_OBJBASE *pObject)
{
if(!bLoadLights) return;
if(!bLoadLights) return;

uint32_t i;
aSelectedLights.clear();

for (i = 0; i < aLights.size(); i++)
{
if (aLights[i].bOff || aLights[i].bTmpOff )
if (aLights[i].bOff || aLights[i].bLightOff )
continue;
if (!aLights[i].bDynamicLight)
{
Expand Down Expand Up @@ -431,7 +431,7 @@ void ShipLights::SetLights(VAI_OBJBASE *pObject)
std::sort(aSelectedLights.begin(), aSelectedLights.end());

for (i = 0; i < aLights.size(); i++)
if (!aLights[i].bOff && !aLights[i].bTmpOff && aLights[i].pObject == pObject && !aLights[i].bCoronaOnly)
if (!aLights[i].bOff && !aLights[i].bLightOff && aLights[i].pObject == pObject && !aLights[i].bCoronaOnly)
{
aSelectedLights.insert(aSelectedLights.begin(), SelectedLight{aLights[i].fCurDistance, i});
}
Expand Down Expand Up @@ -464,7 +464,7 @@ void ShipLights::Execute(uint32_t dwDeltaTime)
{
ShipLight &L = aLights[i];

if (L.bOff || L.bTmpOff)
if (L.bOff || L.bLightOff)
continue;

if (!L.bDynamicLight)
Expand Down Expand Up @@ -510,7 +510,7 @@ void ShipLights::Execute(uint32_t dwDeltaTime)
const float fLen = fDistance * sqrtf(~(vCamPos - L.vCurPos));
L.bVisible = fDistance >= 1.0f || (fLen < 0.6f);

if (!L.bOff && !L.bTmpOff && L.bVisible)
if (!L.bOff && !L.bLightOff && L.bVisible)
{
const float fDistance = pCollide->Trace(its, vCamPos, L.vCurPos, nullptr, 0);
const float fLen = (1.0f - fDistance) * sqrtf(~(vCamPos - L.vCurPos));
Expand Down Expand Up @@ -598,7 +598,7 @@ void ShipLights::Realize(uint32_t dwDeltaTime)
{
ShipLight &L = aLights[i];

if (L.bOff || L.bTmpOff)
if (L.bOff || L.bLightOff)
continue;

float fDistanceFade = 1.0f;
Expand Down Expand Up @@ -653,15 +653,14 @@ void ShipLights::UnSetLights(VAI_OBJBASE *pObject)

void ShipLights::ResetLights(VAI_OBJBASE *pObject, bool bLight)
{
for (uint32_t i = 0; i < aLights.size(); i++)
{
ShipLight &L = aLights[i];
if (L.bOff)
continue;
if(bLight) L.bTmpOff = false;
else L.bTmpOff = true;
}
}
for (auto &light : aLights)
{
if (!light.bOff)
{
light.bLightOff = !bLight;
}
}
}

uint64_t ShipLights::ProcessMessage(MESSAGE &message)
{
Expand Down
2 changes: 1 addition & 1 deletion src/libs/ship/src/ship_lights.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class ShipLights : public IShipLights
bool bVisible;
float fTotalBrokenTime, fBrokenTime;
bool bOff, bBrokenTimeOff;
bool bTmpOff;
bool bLightOff;
bool bDead;
LightType *pLT;
};
Expand Down

0 comments on commit 05302e4

Please sign in to comment.