mirror of
https://github.com/AquariaOSE/Aquaria.git
synced 2025-01-26 02:07:26 +00:00
kill ARRAYSIZE(), there's the safer Countof()
This commit is contained in:
parent
67149a5b35
commit
960bd90fc8
1 changed files with 6 additions and 10 deletions
|
@ -24,10 +24,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
#include "StatsAndAchievements.h"
|
#include "StatsAndAchievements.h"
|
||||||
#include "ttvfs_stdio.h"
|
#include "ttvfs_stdio.h"
|
||||||
|
|
||||||
#ifndef ARRAYSIZE
|
|
||||||
#define ARRAYSIZE(x) (sizeof (x) / sizeof ((x)[0]))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define _ACH_ID( id, name ) { id, #id, name, "", 0, 0 }
|
#define _ACH_ID( id, name ) { id, #id, name, "", 0, 0 }
|
||||||
|
|
||||||
static Achievement g_rgAchievements[] =
|
static Achievement g_rgAchievements[] =
|
||||||
|
@ -153,7 +149,7 @@ void StatsAndAchievements::RunFrame()
|
||||||
{
|
{
|
||||||
requestedStats = true;
|
requestedStats = true;
|
||||||
|
|
||||||
const size_t max_achievements = ARRAYSIZE(g_rgAchievements);
|
const size_t max_achievements = Countof(g_rgAchievements);
|
||||||
VFILE *io = NULL;
|
VFILE *io = NULL;
|
||||||
|
|
||||||
// Get generic achievement data...
|
// Get generic achievement data...
|
||||||
|
@ -229,7 +225,7 @@ void StatsAndAchievements::RunFrame()
|
||||||
// but only if we're not in a mod
|
// but only if we're not in a mod
|
||||||
if (!dsq->mod.isActive())
|
if (!dsq->mod.isActive())
|
||||||
{
|
{
|
||||||
for (size_t iAch = 0; iAch < ARRAYSIZE( g_rgAchievements ); ++iAch )
|
for (size_t iAch = 0; iAch < Countof( g_rgAchievements ); ++iAch )
|
||||||
{
|
{
|
||||||
EvaluateAchievement( g_rgAchievements[iAch] );
|
EvaluateAchievement( g_rgAchievements[iAch] );
|
||||||
}
|
}
|
||||||
|
@ -252,7 +248,7 @@ void StatsAndAchievements::appendStringData(std::string &data)
|
||||||
|
|
||||||
count = 0;
|
count = 0;
|
||||||
data += "Unlocked:\n\n";
|
data += "Unlocked:\n\n";
|
||||||
for (size_t iAch = 0; iAch < ARRAYSIZE( g_rgAchievements ); ++iAch )
|
for (size_t iAch = 0; iAch < Countof( g_rgAchievements ); ++iAch )
|
||||||
{
|
{
|
||||||
const Achievement &ach = g_rgAchievements[iAch];
|
const Achievement &ach = g_rgAchievements[iAch];
|
||||||
if (!ach.achieved)
|
if (!ach.achieved)
|
||||||
|
@ -271,7 +267,7 @@ void StatsAndAchievements::appendStringData(std::string &data)
|
||||||
|
|
||||||
count = 0;
|
count = 0;
|
||||||
data += "Locked:\n\n";
|
data += "Locked:\n\n";
|
||||||
for (size_t iAch = 0; iAch < ARRAYSIZE( g_rgAchievements ); ++iAch )
|
for (size_t iAch = 0; iAch < Countof( g_rgAchievements ); ++iAch )
|
||||||
{
|
{
|
||||||
const Achievement &ach = g_rgAchievements[iAch];
|
const Achievement &ach = g_rgAchievements[iAch];
|
||||||
if (ach.achieved)
|
if (ach.achieved)
|
||||||
|
@ -812,7 +808,7 @@ void StatsAndAchievements::StoreStatsIfNecessary()
|
||||||
if (io == NULL)
|
if (io == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const size_t max_achievements = ARRAYSIZE(g_rgAchievements);
|
const size_t max_achievements = Countof(g_rgAchievements);
|
||||||
unsigned char *buf = new unsigned char[max_achievements];
|
unsigned char *buf = new unsigned char[max_achievements];
|
||||||
|
|
||||||
for (size_t i = 0; i < max_achievements; i++)
|
for (size_t i = 0; i < max_achievements; i++)
|
||||||
|
@ -828,7 +824,7 @@ void StatsAndAchievements::StoreStatsIfNecessary()
|
||||||
char cruft[101];
|
char cruft[101];
|
||||||
for (size_t i = 0; i < sizeof (cruft); i++)
|
for (size_t i = 0; i < sizeof (cruft); i++)
|
||||||
cruft[i] = (char) rand();
|
cruft[i] = (char) rand();
|
||||||
if (fwrite(cruft, sizeof (cruft[0]), ARRAYSIZE(cruft), io) != ARRAYSIZE(cruft))
|
if (fwrite(cruft, sizeof (cruft[0]), Countof(cruft), io) != Countof(cruft))
|
||||||
debugLog("Failed to write achievements 2");
|
debugLog("Failed to write achievements 2");
|
||||||
|
|
||||||
fclose(io);
|
fclose(io);
|
||||||
|
|
Loading…
Reference in a new issue