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

cleo.log improvements #182

Merged
merged 3 commits into from
Sep 10, 2024
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
49 changes: 35 additions & 14 deletions cleo_plugins/Audio/CSoundSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,22 @@ namespace CLEO

void EnumerateBassDevices(int& total, int& enabled, int& default_device)
{
TRACE(""); // separator
TRACE("Listing audio devices:");

BASS_DEVICEINFO info;
for (default_device = -1, enabled = 0, total = 0; BASS_GetDeviceInfo(total, &info); ++total)
enabled = 0;
default_device = -1;
for (total = 0; BASS_GetDeviceInfo(total, &info); ++total)
{
if (info.flags & BASS_DEVICE_ENABLED) ++enabled;
if (info.flags & BASS_DEVICE_DEFAULT) default_device = total;
TRACE("Found sound device %d%s: %s", total, default_device == total ?
" (default)" : "", info.name);

bool isEnabled = info.flags & BASS_DEVICE_ENABLED;
if (isEnabled) ++enabled;

TRACE(" %d: %s%s", total, info.name, isEnabled ? "" : " (disabled)");
}
TRACE(" Default device index: %d", default_device);
}

bool isNetworkSource(const char* path)
Expand Down Expand Up @@ -58,19 +66,32 @@ namespace CLEO
LegacyModeDefaultStreamType = (eStreamType)GetPrivateProfileInt("General", "LegacyModeDefaultStreamType", 0, config.c_str());
allowNetworkSources = GetPrivateProfileInt("General", "AllowNetworkSources", 1, config.c_str()) != 0;

int default_device, total_devices, enabled_devices;
EnumerateBassDevices(total_devices, enabled_devices, default_device);
int deviceIndex, total_devices, enabled_devices;
EnumerateBassDevices(total_devices, enabled_devices, deviceIndex);

int forceDevice = GetPrivateProfileInt("General", "AudioDevice", -1, config.c_str());
BASS_DEVICEINFO info = { nullptr, nullptr, 0 };
if (forceDevice != -1 && BASS_GetDeviceInfo(forceDevice, &info) && (info.flags & BASS_DEVICE_ENABLED))
default_device = forceDevice;
BASS_DEVICEINFO info = { "Unknown device", nullptr, 0 };
BASS_GetDeviceInfo(deviceIndex, &info);

TRACE("On system found %d devices, %d enabled devices, assuming device to use: %d (%s)",
total_devices, enabled_devices, default_device, BASS_GetDeviceInfo(default_device, &info) ?
info.name : "Unknown device");
int forceIndex = GetPrivateProfileInt("General", "AudioDevice", -1, config.c_str());
if (forceIndex != -1)
{
BASS_DEVICEINFO forceInfo = { "Unknown device", nullptr, 0 };
if (BASS_GetDeviceInfo(forceIndex, &forceInfo) && forceInfo.flags & BASS_DEVICE_ENABLED)
{
TRACE("Force selecting audio device #%d: %s", forceIndex, forceInfo.name);
deviceIndex = forceIndex;
}
else
{
LOG_WARNING(0, "Failed to force select device #%d! Selecting default audio device #%d: %s", forceIndex, deviceIndex, info.name);
}
}
else
{
TRACE("Selecting default audio device #%d: %s", deviceIndex, info.name);
}

if (BASS_Init(default_device, 44100, BASS_DEVICE_3D, RsGlobal.ps->window, nullptr) &&
if (BASS_Init(deviceIndex, 44100, BASS_DEVICE_3D, RsGlobal.ps->window, nullptr) &&
BASS_Set3DFactors(1.0f, 3.0f, 80.0f) &&
BASS_Set3DPosition(&pos, &vel, &front, &top))
{
Expand Down
5 changes: 4 additions & 1 deletion cleo_plugins/Text/CTextManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ namespace CLEO

void CTextManager::LoadFxts()
{
TRACE(""); // separator
TRACE("Loading CLEO text files...");

// create FXT directory if not present yet
FS::create_directory(FS::path(Gta_Root_Dir_Path).append("cleo\\cleo_text"));

Expand All @@ -103,7 +106,7 @@ namespace CLEO
{
std::ifstream stream(list.strings[i]);
auto result = ParseFxtFile(stream);
TRACE("Added %d new FXT entries from file %s", result, list.strings[i]);
TRACE("Added %d new FXT entries from file '%s'", result, list.strings[i]);
}
catch (std::exception& ex)
{
Expand Down
1 change: 1 addition & 0 deletions source/CCustomOpcodeSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,7 @@ namespace CLEO
{
if (initialized) return;

TRACE(""); // separator
TRACE("Initializing CLEO core opcodes...");

CLEO_RegisterOpcode(0x0051, opcode_0051);
Expand Down
3 changes: 3 additions & 0 deletions source/CPluginSystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ void CPluginSystem::LoadPlugins()
CLEO_StringListFree(files);
};

TRACE(""); // separator
TRACE("Listing CLEO plugins:");
ScanPluginsDir(FS::path(Filepath_Cleo).append("cleo_plugins").string(), "SA.", ".cleo");
ScanPluginsDir(FS::path(Filepath_Cleo).append("cleo_plugins").string(), "", ".cleo"); // legacy plugins in new location
Expand All @@ -68,6 +69,7 @@ void CPluginSystem::LoadPlugins()
for (auto it = paths.crbegin(); it != paths.crend(); it++)
{
const auto filename = it->c_str();
TRACE(""); // separator
TRACE("Loading plugin '%s'", filename);

HMODULE hlib = LoadLibrary(filename);
Expand All @@ -79,6 +81,7 @@ void CPluginSystem::LoadPlugins()

plugins.push_back(hlib);
}
TRACE(""); // separator
}
else
{
Expand Down
5 changes: 3 additions & 2 deletions source/CScriptEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1023,7 +1023,7 @@ namespace CLEO

if (!found.empty())
{
TRACE("Starting CLEO scripts");
TRACE("Starting CLEO scripts...");

for (const auto& path : found)
{
Expand Down Expand Up @@ -1476,7 +1476,8 @@ namespace CLEO
LastSearchPed(0), LastSearchCar(0), LastSearchObj(0),
CompatVer(CLEO_VER_CUR)
{
TRACE("Loading custom script %s...", szFileName);
TRACE(""); // separator
TRACE("Loading custom script '%s'...", szFileName);

bIsCustom = true;
bIsMission = bUseMissionCleanup = bIsMiss;
Expand Down
2 changes: 2 additions & 0 deletions source/CleoBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ namespace CLEO

saveSlot = MenuManager->m_bWantToLoad ? MenuManager->m_nSelectedSaveGame : -1;

TRACE(""); // separator
TRACE("Starting new game, save slot: %d", saveSlot);

// execute registered callbacks
Expand All @@ -175,6 +176,7 @@ namespace CLEO
if (!m_bGameInProgress) return;
m_bGameInProgress = false;

TRACE(""); // separator
TRACE("Ending current game");
GetInstance().CallCallbacks(eCallbackId::GameEnd); // execute registered callbacks
ScriptEngine.GameEnd();
Expand Down