Skip to content

Commit

Permalink
Merge pull request #314 from External69/log-cleanup
Browse files Browse the repository at this point in the history
Log cleanup
  • Loading branch information
nico-abram authored Oct 25, 2018
2 parents 709b405 + 0712833 commit 4ef582b
Show file tree
Hide file tree
Showing 79 changed files with 493 additions and 380 deletions.
4 changes: 3 additions & 1 deletion Themes/_fallback/Scripts/02 ActorDef.lua
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,9 @@ function LoadActorFunc(path, level)
end

local Type = ActorUtil.GetFileType(path)
Trace("Loading " .. path .. ", type " .. tostring(Type))
if PREFSMAN:GetPreference("VerboseLogging") > 1 then
Trace("Loading " .. path .. ", type " .. tostring(Type))
end

if Type == "FileType_Lua" then
-- Load the file.
Expand Down
4 changes: 2 additions & 2 deletions src/CreateZip.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "global.h"
#include "global.h"

#if defined(_WINDOWS)
#include <tchar.h>
Expand Down Expand Up @@ -797,7 +797,7 @@ TZip::set_times()

unsigned short dosdate, dostime;
filetime2dosdatetime(*ptm, &dosdate, &dostime);
times.atime = time(nullptr);
times.atime = static_cast<lutime_t>(time(nullptr));
times.mtime = times.atime;
times.ctime = times.atime;
timestamp = dostime | ((static_cast<unsigned long>(dosdate)) << 16);
Expand Down
57 changes: 28 additions & 29 deletions src/DBProfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ DBProfile::LoadDBFromDir(string dir)
// Open a database file
db = new SQLite::Database(FILEMAN->ResolvePath(dir) + PROFILE_DB,
SQLite::OPEN_READWRITE);
} catch (std::exception& e) {
} catch (std::exception) {
return ProfileLoadResult_FailedNoProfile;
}
try {
Expand All @@ -55,7 +55,7 @@ DBProfile::LoadDBFromDir(string dir)
LoadScoreGoals(db);
LoadPlayLists(db);
LoadPlayerScores(db);
} catch (std::exception& e) {
} catch (std::exception) {
return ProfileLoadResult_FailedTampered;
}
delete db;
Expand Down Expand Up @@ -103,7 +103,7 @@ DBProfile::LoadGeneralData(SQLite::Database* db)
loadingProfile->m_iTotalHands = gDataQuery.getColumn(21);
loadingProfile->m_iTotalLifts = gDataQuery.getColumn(22);
loadingProfile->m_fPlayerRating =
static_cast<double>(gDataQuery.getColumn(23));
static_cast<float>(static_cast<double>(gDataQuery.getColumn(23)));

SQLite::Statement modifierQuery(*db, "SELECT * FROM defaultmodifiers");
while (modifierQuery.executeStep()) {
Expand All @@ -115,7 +115,7 @@ DBProfile::LoadGeneralData(SQLite::Database* db)
SQLite::Statement skillsetsQuery(*db, "SELECT * FROM playerskillsets");
while (skillsetsQuery.executeStep()) {
int skillsetNum = skillsetsQuery.getColumn(1);
float skillsetValue = static_cast<double>(skillsetsQuery.getColumn(2));
float skillsetValue = static_cast<float>(static_cast<double>(skillsetsQuery.getColumn(2)));
loadingProfile->m_fPlayerSkillsets[skillsetNum] = skillsetValue;
}

Expand Down Expand Up @@ -184,7 +184,7 @@ DBProfile::LoadPlayLists(SQLite::Database* db)
static_cast<Difficulty>(static_cast<int>(query.getColumn(2)));
ch.lastsong = static_cast<const char*>(query.getColumn(3));
ch.lastpack = static_cast<const char*>(query.getColumn(4));
ch.rate = static_cast<double>(query.getColumn(5));
ch.rate = static_cast<float>(static_cast<double>(query.getColumn(5)));

// check if this chart is loaded and overwrite any last-seen values with
// updated ones
Expand Down Expand Up @@ -214,7 +214,7 @@ DBProfile::LoadPlayLists(SQLite::Database* db)
static_cast<Difficulty>(static_cast<int>(query.getColumn(2)));
ch.lastsong = static_cast<const char*>(query.getColumn(3));
ch.lastpack = static_cast<const char*>(query.getColumn(4));
ch.rate = static_cast<double>(query.getColumn(5));
ch.rate = static_cast<float>(static_cast<double>(query.getColumn(5)));
ch.key = key;

// check if this chart is loaded and overwrite any last-seen values with
Expand Down Expand Up @@ -327,15 +327,15 @@ DBProfile::LoadPlayerScores(SQLite::Database* db)
HighScore& hs = scores[key].ScoresByRate[rate].scores[ScoreKey];
hs.SetSSRCalcVersion(query.getColumn(6));
hs.SetGrade(static_cast<Grade>(static_cast<int>(query.getColumn(7))));
hs.SetWifeScore(static_cast<double>(query.getColumn(8)));
hs.SetSSRNormPercent(static_cast<double>(query.getColumn(9)));
hs.SetWifeScore(static_cast<float>(static_cast<double>(query.getColumn(8))));
hs.SetSSRNormPercent(static_cast<float>(static_cast<double>(query.getColumn(9))));
hs.SetMusicRate(scores[key].KeyToRate(rate));
hs.SetJudgeScale(static_cast<double>(query.getColumn(10)));
hs.SetJudgeScale(static_cast<float>(static_cast<double>(query.getColumn(10))));
hs.SetChordCohesion(static_cast<int>(query.getColumn(11)) != 0);
hs.SetEtternaValid(static_cast<int>(query.getColumn(12)) != 0);
hs.SetChartKey(key);
hs.SetScoreKey(ScoreKey);
hs.SetSurviveSeconds(static_cast<double>(query.getColumn(13)));
hs.SetSurviveSeconds(static_cast<float>(static_cast<double>(query.getColumn(13))));
hs.SetMaxCombo(query.getColumn(14));
hs.SetModifiers(query.getColumn(15));
DateTime d;
Expand All @@ -356,7 +356,7 @@ DBProfile::LoadPlayerScores(SQLite::Database* db)
if (hs.GetWifeScore() > 0.f) {
FOREACH_ENUM(Skillset, ss)
hs.SetSkillsetSSR(ss,
static_cast<double>(query.getColumn(index++)));
static_cast<float>(static_cast<double>(query.getColumn(index++))));
}
hs.SetValidationKey(ValidationKey_Brittle,
static_cast<const char*>(query.getColumn(index++)));
Expand Down Expand Up @@ -424,9 +424,9 @@ DBProfile::LoadScoreGoals(SQLite::Database* db)
ck = static_cast<const char*>(query.getColumn(0));
// Load the scoregoal
ScoreGoal sg;
sg.rate = static_cast<double>(query.getColumn(1));
sg.rate = static_cast<float>(static_cast<double>(query.getColumn(1)));
sg.priority = query.getColumn(2);
sg.percent = static_cast<double>(query.getColumn(3));
sg.percent = static_cast<float>(static_cast<double>(query.getColumn(3)));
sg.timeassigned.FromString(
static_cast<const char*>(query.getColumn(4)));
sg.timeachieved.FromString(
Expand Down Expand Up @@ -458,7 +458,7 @@ DBProfile::SaveDBToDir(string dir,
// Open a database file
db = new SQLite::Database(filename,
SQLite::OPEN_READWRITE | SQLite::OPEN_CREATE);
} catch (std::exception& e) {
} catch (std::exception) {
return ProfileLoadResult_FailedNoProfile;
}
try {
Expand Down Expand Up @@ -505,7 +505,7 @@ DBProfile::SaveDBToDir(string dir,
db->exec("CREATE INDEX IF NOT EXISTS idx_songs "
"ON songs(song, pack, id)");
transaction.commit();
} catch (std::exception& e) {
} catch (std::exception) {
return ProfileLoadResult_FailedTampered;
}
delete db;
Expand Down Expand Up @@ -735,7 +735,7 @@ DBProfile::SavePlayLists(SQLite::Database* db, const Profile* profile) const
insertPlaylist.exec();
// db->exec("INSERT INTO playlists VALUES (NULL, \"" +
// (pl->second).name + "\")");
int plID = sqlite3_last_insert_rowid(db->getHandle());
int plID = (int)sqlite3_last_insert_rowid(db->getHandle());
FOREACH_CONST(Chart, (pl->second).chartlist, ch)
{
int chartID = FindOrCreateChart(
Expand All @@ -756,7 +756,7 @@ DBProfile::SavePlayLists(SQLite::Database* db, const Profile* profile) const
insertCourseRun.bind(1, plID);
insertCourseRun.exec();
int courseRunID =
sqlite3_last_insert_rowid(db->getHandle());
(int)sqlite3_last_insert_rowid(db->getHandle());
FOREACH_CONST(string, *run, scorekey)
{
SQLite::Statement insertRun(
Expand Down Expand Up @@ -866,7 +866,7 @@ DBProfile::SavePlayerScores(SQLite::Database* db,
insertChart.bind(2, songID);
insertChart.bind(3, ch.lastdiff);
insertChart.exec();
int chartID = sqlite3_last_insert_rowid(db->getHandle());
int chartID = (int)sqlite3_last_insert_rowid(db->getHandle());

// Add scores per rate
FOREACHM(int, ScoresAtRate, chartPair->second.ScoresByRate, ratePair)
Expand All @@ -884,7 +884,7 @@ DBProfile::SavePlayerScores(SQLite::Database* db,
insertScoresAtRate.bind(4,
ratePair->second.PBptr->GetScoreKey());
insertScoresAtRate.exec();
scoresAtRateID = sqlite3_last_insert_rowid(db->getHandle());
scoresAtRateID = (int)sqlite3_last_insert_rowid(db->getHandle());
}
FOREACHUM(string, HighScore, ratePair->second.scores, i)
{
Expand Down Expand Up @@ -975,7 +975,7 @@ DBProfile::SavePlayerScores(SQLite::Database* db,
break;
if (mode == LocalWithReplayData) {
int scoreID =
sqlite3_last_insert_rowid(db->getHandle());
(int)sqlite3_last_insert_rowid(db->getHandle());
try {
// Save Replay Data
if (hs->LoadReplayData()) {
Expand All @@ -999,8 +999,7 @@ DBProfile::SavePlayerScores(SQLite::Database* db,
insertOffset.exec();
}
}
} catch (std::exception&
e) { // No replay data for this score }
} catch (std::exception) { // No replay data for this score }
hs->UnloadReplayData();
}
}
Expand Down Expand Up @@ -1037,7 +1036,7 @@ DBProfile::FindOrCreateChartKey(SQLite::Database* db, string key)
if (exists)
return exists;
db->exec("INSERT INTO chartkeys VALUES (NULL, \"" + key + "\")");
return sqlite3_last_insert_rowid(db->getHandle());
return (int)sqlite3_last_insert_rowid(db->getHandle());
}

int
Expand All @@ -1054,7 +1053,7 @@ DBProfile::FindOrCreateSong(SQLite::Database* db, string pack, string song)
insertSong.bind(1, pack);
insertSong.bind(2, song);
insertSong.exec();
return sqlite3_last_insert_rowid(db->getHandle());
return (int)sqlite3_last_insert_rowid(db->getHandle());
}
return query.getColumn(0);
}
Expand Down Expand Up @@ -1085,7 +1084,7 @@ DBProfile::FindOrCreateChart(SQLite::Database* db,
insertChart.bind(2, songID);
insertChart.bind(3, diff);
insertChart.exec();
return sqlite3_last_insert_rowid(db->getHandle());
return (int)sqlite3_last_insert_rowid(db->getHandle());
} else {
return query.getColumn(0);
}
Expand All @@ -1108,7 +1107,7 @@ DBProfile::FindOrCreateScoreKey(SQLite::Database* db, string key)
if (exists)
return exists;
db->exec("INSERT INTO scorekeys VALUES (NULL, \"" + key + "\")");
return sqlite3_last_insert_rowid(db->getHandle());
return (int)sqlite3_last_insert_rowid(db->getHandle());
}

bool
Expand All @@ -1123,7 +1122,7 @@ DBProfile::WriteReplayData(const HighScore* hs)
// Open a database file
db = new SQLite::Database(filename,
SQLite::OPEN_READWRITE | SQLite::OPEN_CREATE);
} catch (std::exception& e) {
} catch (std::exception) {
return ProfileLoadResult_FailedNoProfile;
}
try {
Expand All @@ -1144,8 +1143,8 @@ DBProfile::WriteReplayData(const HighScore* hs)
insertOffset.exec();
}
transaction.commit();
} catch (std::exception& e) {
return ProfileLoadResult_FailedTampered;
} catch (std::exception) {
return ProfileLoadResult_FailedTampered != 0;
}
delete db;
return true;
Expand Down
8 changes: 4 additions & 4 deletions src/DifficultyList.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "global.h"
#include "global.h"
#include "CommonMetrics.h"
#include "DifficultyList.h"
#include "Foreach.h"
Expand Down Expand Up @@ -190,13 +190,13 @@ StepsDisplayList::UpdatePositions()
if (i < first_start)
ItemPosition = -0.5f;
else if (i < first_end)
ItemPosition = (float)pos++;
ItemPosition = static_cast<float>(pos++);
else if (i < second_start)
ItemPosition = halfsize - 0.5f;
else if (i < second_end)
ItemPosition = (float)pos++;
ItemPosition = static_cast<float>(pos++);
else
ItemPosition = (float)total - 0.5f;
ItemPosition = static_cast<float>(total) - 0.5f;

Row& row = Rows[i];

Expand Down
8 changes: 5 additions & 3 deletions src/GameSoundManager.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "global.h"
#include "global.h"
#include "AnnouncerManager.h"
#include "GameSoundManager.h"
#include "GameState.h"
Expand Down Expand Up @@ -436,13 +436,15 @@ GameSoundManager::~GameSoundManager()
LUA->UnsetGlobal("SOUND");

/* Signal the mixing thread to quit. */
LOG->Trace("Shutting down music start thread ...");
if (PREFSMAN->m_verbose_log > 1)
LOG->Trace("Shutting down music start thread ...");
g_Mutex->Lock();
g_Shutdown = true;
g_Mutex->Broadcast();
g_Mutex->Unlock();
MusicThread.Wait();
LOG->Trace("Music start thread shut down.");
if (PREFSMAN->m_verbose_log > 1)
LOG->Trace("Music start thread shut down.");

SAFE_DELETE(g_Playing);
SAFE_DELETE(g_Mutex);
Expand Down
3 changes: 2 additions & 1 deletion src/GameState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ class GameStateMessageHandler : public MessageSubscriber
if (sJoined == "")
sJoined = "none";

LOG->MapLog("JOINED", "Players joined: %s", sJoined.c_str());
if (PREFSMAN->m_verbose_log > 0)
LOG->MapLog("JOINED", "Players joined: %s", sJoined.c_str());
}
}
};
Expand Down
8 changes: 4 additions & 4 deletions src/GameplayAssist.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "global.h"
#include "global.h"
#include "CommonMetrics.h"
#include "GameState.h"
#include "GameplayAssist.h"
Expand Down Expand Up @@ -42,7 +42,7 @@ GameplayAssist::PlayTicks(const NoteData& nd, const PlayerState* ps)

// float fPositionSeconds = GAMESTATE->m_Position.m_fMusicSeconds;
fPositionSeconds += SOUNDMAN->GetPlayLatency() +
(float)CommonMetrics::TICK_EARLY_SECONDS + 0.250f;
static_cast<float>(CommonMetrics::TICK_EARLY_SECONDS) + 0.250f;
const TimingData& timing =
*GAMESTATE->m_pCurSteps[ps->m_PlayerNumber]->GetTimingData();
const float fSongBeat =
Expand Down Expand Up @@ -72,7 +72,7 @@ GameplayAssist::PlayTicks(const NoteData& nd, const PlayerState* ps)
RageSoundParams p;
p.m_StartTime =
position.m_LastBeatUpdate +
(fSecondsUntil - (float)CommonMetrics::TICK_EARLY_SECONDS);
(fSecondsUntil - static_cast<float>(CommonMetrics::TICK_EARLY_SECONDS));
m_soundAssistClap.Play(false, &p);
}
}
Expand Down Expand Up @@ -116,7 +116,7 @@ GameplayAssist::PlayTicks(const NoteData& nd, const PlayerState* ps)
RageSoundParams p;
p.m_StartTime =
position.m_LastBeatUpdate +
(fSecondsUntil - (float)CommonMetrics::TICK_EARLY_SECONDS);
(fSecondsUntil - static_cast<float>(CommonMetrics::TICK_EARLY_SECONDS));
if (bIsMeasure)
m_soundAssistMetronomeMeasure.Play(false, &p);
else
Expand Down
7 changes: 4 additions & 3 deletions src/MeterDisplay.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "global.h"
#include "global.h"
#include "ActorUtil.h"
#include "GameState.h"
#include "LuaManager.h"
Expand Down Expand Up @@ -31,8 +31,9 @@ MeterDisplay::Load(const RString& sStreamPath,
void
MeterDisplay::LoadFromNode(const XNode* pNode)
{
LOG->Trace("MeterDisplay::LoadFromNode(%s)",
ActorUtil::GetWhere(pNode).c_str());
if (PREFSMAN->m_verbose_log > 1)
LOG->Trace("MeterDisplay::LoadFromNode(%s)",
ActorUtil::GetWhere(pNode).c_str());

const XNode* pStream = pNode->GetChild("Stream");
if (pStream == NULL) {
Expand Down
4 changes: 2 additions & 2 deletions src/ModIconRow.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "global.h"
#include "global.h"
#include "ActorUtil.h"
#include "Foreach.h"
#include "GameState.h"
Expand Down Expand Up @@ -46,7 +46,7 @@ ModIconRow::Load(const RString& sMetricsGroup, PlayerNumber pn)
0,
NUM_OPTION_ICONS - 1,
-(NUM_OPTION_ICONS - 1) / 2.0f,
(float)(NUM_OPTION_ICONS - 1) / 2.0f);
static_cast<float>(NUM_OPTION_ICONS - 1) / 2.0f);
p->SetXY(fOffset * SPACING_X, fOffset * SPACING_Y);
p->Load(OPTION_ICON_METRICS_GROUP);
ActorUtil::LoadAllCommands(p, sMetricsGroup);
Expand Down
6 changes: 3 additions & 3 deletions src/Model.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "global.h"
#include "global.h"
#include "ActorUtil.h"
#include "Foreach.h"
#include "LuaBinding.h"
Expand Down Expand Up @@ -623,7 +623,7 @@ void
Model::SetPosition(float fSeconds)
{
m_fCurFrame = FRAMES_PER_SECOND * fSeconds;
m_fCurFrame = clamp(m_fCurFrame, 0, (float)m_pCurAnimation->nTotalFrames);
m_fCurFrame = clamp(m_fCurFrame, 0, static_cast<float>(m_pCurAnimation->nTotalFrames));
}

void
Expand All @@ -647,7 +647,7 @@ Model::AdvanceFrame(float fDeltaTime)
static_cast<float>(m_pCurAnimation->nTotalFrames));
else
m_fCurFrame =
clamp(m_fCurFrame, 0, (float)m_pCurAnimation->nTotalFrames);
clamp(m_fCurFrame, 0, static_cast<float>(m_pCurAnimation->nTotalFrames));
}

SetBones(m_pCurAnimation, m_fCurFrame, m_vpBones);
Expand Down
Loading

0 comments on commit 4ef582b

Please sign in to comment.