Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More rank stats fixes #3436

Merged
merged 2 commits into from
Nov 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 21 additions & 12 deletions src/droid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@
{
// FIXME: change when adding submarines to the game
// modifiedModelMatrix *= glm::translate(glm::vec3(0.f, -world_coord(1) / 2.3f, 0.f));
position.y += (world_coord(1) / 2.3f);

Check warning on line 254 in src/droid.cpp

View workflow job for this annotation

GitHub Actions / Arch :LATEST [GCC]

conversion from ‘float’ to ‘int’ may change value [-Wfloat-conversion]

Check warning on line 254 in src/droid.cpp

View workflow job for this annotation

GitHub Actions / Fedora :LATEST [GCC]

conversion from 'float' to 'int' may change value [-Wfloat-conversion]

Check warning on line 254 in src/droid.cpp

View workflow job for this annotation

GitHub Actions / Arch :LATEST [Clang]

implicit conversion turns floating-point number into integer: 'float' to 'int' [-Wfloat-conversion]

Check warning on line 254 in src/droid.cpp

View workflow job for this annotation

GitHub Actions / Fedora :LATEST [GCC -m32]

conversion from 'float' to 'int' may change value [-Wfloat-conversion]

Check warning on line 254 in src/droid.cpp

View workflow job for this annotation

GitHub Actions / Ubuntu 20.04 [Clang]

implicit conversion turns floating-point number into integer: 'float' to 'int' [-Wfloat-conversion]

Check warning on line 254 in src/droid.cpp

View workflow job for this annotation

GitHub Actions / Ubuntu 22.04 [Clang]

implicit conversion turns floating-point number into integer: 'float' to 'int' [-Wfloat-conversion]
}

EFFECT_TYPE type = DROID_ANIMEVENT_DYING_NORMAL;
Expand Down Expand Up @@ -2286,29 +2286,38 @@

UDWORD getNumDroidsForLevel(uint32_t player, UDWORD level)
{
DROID *psDroid;
UDWORD count = 0;
unsigned int idx = 0;
unsigned int count = 0;

if (player >= MAX_PLAYERS) { return 0; }

for (psDroid = apsDroidLists[player]; psDroid; psDroid = psDroid->psNext)
do
{
if (getDroidLevel(psDroid) == level)
DROID *psDroid = nullptr;
switch (idx)
{
count++;
case 0: psDroid = apsDroidLists[selectedPlayer]; break;
case 1: if (prevMissionType == LEVEL_TYPE::LDS_MKEEP_LIMBO) { psDroid = apsLimboDroids[selectedPlayer]; } break;
default: psDroid = nullptr;
}
}

if (prevMissionType == LEVEL_TYPE::LDS_MKEEP_LIMBO)
{
for (psDroid = apsLimboDroids[player]; psDroid; psDroid = psDroid->psNext)
for (; psDroid; psDroid = psDroid->psNext)
{
if (getDroidLevel(psDroid) == level)
{
count++;
++count;
}
if (isTransporter(psDroid))
{
for (DROID *psCurr = psDroid->psGroup->psList; psCurr != nullptr; psCurr = psCurr->psGrpNext)
{
if (psCurr != psDroid && getDroidLevel(psCurr) == level)
{
++count;
}
}
}
}
}
} while (++idx < 2);

return count;
}
Expand Down
6 changes: 3 additions & 3 deletions src/projectile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -963,7 +963,7 @@ static void proj_InFlightFunc(PROJECTILE *psProj)

/***************************************************************************/

static void proj_radiusSweep(PROJECTILE *psObj, WEAPON_STATS *psStats, DROID *destDroid, Vector3i &targetPos, bool empRadius)
static void proj_radiusSweep(PROJECTILE *psObj, WEAPON_STATS *psStats, Vector3i &targetPos, bool empRadius)
{
static GridList gridList; // static to avoid allocations.
gridList = gridStartIterate(targetPos.x, targetPos.y, (empRadius) ? psStats->upgrade[psObj->player].empRadius : psStats->upgrade[psObj->player].radius);
Expand Down Expand Up @@ -1277,11 +1277,11 @@ static void proj_ImpactFunc(PROJECTILE *psObj)

if (hasEMPRadius && psStats->weaponSubClass == WSC_EMP)
{
proj_radiusSweep(psObj, psStats, destDroid, targetPos, true);
proj_radiusSweep(psObj, psStats, targetPos, true);
}
if (hasRadius)
{
proj_radiusSweep(psObj, psStats, destDroid, targetPos, false);
proj_radiusSweep(psObj, psStats, targetPos, false);
}
}

Expand Down
28 changes: 25 additions & 3 deletions src/scores.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,9 +293,31 @@ END_GAME_STATS_DATA collectEndGameStatsData()
fullStats.numUnits = 0;
if (selectedPlayer < MAX_PLAYERS)
{
for (DROID *psDroid = apsDroidLists[selectedPlayer]; psDroid; psDroid = psDroid->psNext, fullStats.numUnits++) {}
for (DROID *psDroid = mission.apsDroidLists[selectedPlayer]; psDroid; psDroid = psDroid->psNext, fullStats.numUnits++) {}
if (prevMissionType == LEVEL_TYPE::LDS_MKEEP_LIMBO) { for (DROID *psDroid = apsLimboDroids[selectedPlayer]; psDroid; psDroid = psDroid->psNext, fullStats.numUnits++) {} }
unsigned int idx = 0;
do
{
DROID *psDroid = nullptr;
switch (idx)
{
case 0: psDroid = apsDroidLists[selectedPlayer]; break;
case 1: psDroid = mission.apsDroidLists[selectedPlayer]; break;
case 2: if (prevMissionType == LEVEL_TYPE::LDS_MKEEP_LIMBO) { psDroid = apsLimboDroids[selectedPlayer]; } break;
default: psDroid = nullptr;
}
for (; psDroid; psDroid = psDroid->psNext, ++fullStats.numUnits)
{
if (isTransporter(psDroid))
{
for (DROID *psCurr = psDroid->psGroup->psList; psCurr != nullptr; psCurr = psCurr->psGrpNext)
{
if (psCurr != psDroid)
{
++fullStats.numUnits;
}
}
}
}
} while (++idx < 3);
}

return fullStats;
Expand Down
Loading