Replace all print calls with vlog calls

This is pretty straight-forward to do.
This commit is contained in:
Misa
2021-02-23 15:21:29 -08:00
committed by Misa Elizabeth Kai
parent d9737589de
commit 96539f891c
16 changed files with 213 additions and 203 deletions

View File

@@ -14,6 +14,7 @@
#include "Maths.h"
#include "Unused.h"
#include "UtilityClass.h"
#include "Vlogging.h"
/* These are needed for PLATFORM_* crap */
#if defined(_WIN32)
@@ -68,8 +69,8 @@ int FILESYSTEM_init(char *argvZero, char* baseDir, char *assetsPath)
if (!PHYSFS_init(argvZero))
{
printf(
"Unable to initialize PhysFS: %s\n",
vlog_error(
"Unable to initialize PhysFS: %s",
PHYSFS_getErrorByCode(PHYSFS_getLastErrorCode())
);
return 0;
@@ -96,8 +97,8 @@ int FILESYSTEM_init(char *argvZero, char* baseDir, char *assetsPath)
/* Mount our base user directory */
if (!PHYSFS_mount(output, NULL, 0))
{
printf(
"Could not mount %s: %s\n",
vlog_error(
"Could not mount %s: %s",
output,
PHYSFS_getErrorByCode(PHYSFS_getLastErrorCode())
);
@@ -105,14 +106,14 @@ int FILESYSTEM_init(char *argvZero, char* baseDir, char *assetsPath)
}
if (!PHYSFS_setWriteDir(output))
{
printf(
"Could not set write dir to %s: %s\n",
vlog_error(
"Could not set write dir to %s: %s",
output,
PHYSFS_getErrorByCode(PHYSFS_getLastErrorCode())
);
return 0;
}
printf("Base directory: %s\n", output);
vlog_info("Base directory: %s", output);
/* Store full save directory */
SDL_snprintf(saveDir, sizeof(saveDir), "%s%s%s",
@@ -121,7 +122,7 @@ int FILESYSTEM_init(char *argvZero, char* baseDir, char *assetsPath)
pathSep
);
mkdir(saveDir, 0777); /* FIXME: Why did I not | this? -flibit */
printf("Save directory: %s\n", saveDir);
vlog_info("Save directory: %s", saveDir);
/* Store full level directory */
SDL_snprintf(levelDir, sizeof(levelDir), "%s%s%s",
@@ -130,13 +131,13 @@ int FILESYSTEM_init(char *argvZero, char* baseDir, char *assetsPath)
pathSep
);
mkdir(levelDir, 0777);
printf("Level directory: %s\n", levelDir);
vlog_info("Level directory: %s", levelDir);
basePath = SDL_GetBasePath();
if (basePath == NULL)
{
puts("Unable to determine base path, falling back to current directory");
vlog_warn("Unable to determine base path, falling back to current directory");
basePath = SDL_strdup("./");
}
@@ -154,10 +155,10 @@ int FILESYSTEM_init(char *argvZero, char* baseDir, char *assetsPath)
}
if (!PHYSFS_mount(output, NULL, 1))
{
puts("Error: data.zip missing!");
puts("You do not have data.zip!");
puts("Grab it from your purchased copy of the game,");
puts("or get it from the free Make and Play Edition.");
vlog_error("Error: data.zip missing!");
vlog_error("You do not have data.zip!");
vlog_error("Grab it from your purchased copy of the game,");
vlog_error("or get it from the free Make and Play Edition.");
SDL_ShowSimpleMessageBox(
SDL_MESSAGEBOX_ERROR,
@@ -174,7 +175,7 @@ int FILESYSTEM_init(char *argvZero, char* baseDir, char *assetsPath)
SDL_snprintf(output, sizeof(output), "%s%s", basePath, "gamecontrollerdb.txt");
if (SDL_GameControllerAddMappingsFromFile(output) < 0)
{
printf("gamecontrollerdb.txt not found!\n");
vlog_info("gamecontrollerdb.txt not found!");
}
retval = 1;
@@ -209,8 +210,8 @@ bool FILESYSTEM_isFile(const char* filename)
if (!success)
{
printf(
"Could not stat file: %s\n",
vlog_error(
"Could not stat file: %s",
PHYSFS_getErrorByCode(PHYSFS_getLastErrorCode())
);
return false;
@@ -296,7 +297,7 @@ static int setLevelDirError(const char* text, ...)
retval = SDL_vsnprintf(levelDirError, sizeof(levelDirError), text, list);
va_end(list);
puts(levelDirError);
vlog_error(levelDirError);
return retval;
}
@@ -321,8 +322,8 @@ static bool FILESYSTEM_mountAssetsFrom(const char *fname)
if (!PHYSFS_mount(path, virtualMountPath, 0))
{
printf(
"Error mounting %s: %s\n",
vlog_error(
"Error mounting %s: %s",
fname,
PHYSFS_getErrorByCode(PHYSFS_getLastErrorCode())
);
@@ -393,8 +394,8 @@ static bool checkZipStructure(const char* filename)
if (real_dir == NULL)
{
printf(
"Could not check %s: real directory doesn't exist\n",
vlog_error(
"Could not check %s: real directory doesn't exist",
filename
);
return false;
@@ -407,8 +408,8 @@ static bool checkZipStructure(const char* filename)
if (!PHYSFS_mount(real_path, mount_path, 1))
{
printf(
"Error mounting and checking %s: %s\n",
vlog_error(
"Error mounting and checking %s: %s",
filename,
PHYSFS_getErrorByCode(PHYSFS_getLastErrorCode())
);
@@ -465,8 +466,8 @@ static bool checkZipStructure(const char* filename)
if (!PHYSFS_unmount(real_path))
{
printf(
"Could not unmount %s: %s\n",
vlog_error(
"Could not unmount %s: %s",
mount_path,
PHYSFS_getErrorByCode(PHYSFS_getLastErrorCode())
);
@@ -486,8 +487,8 @@ void FILESYSTEM_loadZip(const char* filename)
if (!PHYSFS_mountHandle(zip, filename, "levels", 1))
{
printf(
"Could not mount %s: %s\n",
vlog_error(
"Could not mount %s: %s",
filename,
PHYSFS_getErrorByCode(PHYSFS_getLastErrorCode())
);
@@ -512,7 +513,7 @@ bool FILESYSTEM_mountAssets(const char* path)
);
if (FILESYSTEM_exists(virtual_path))
{
printf("Asset directory is .data.zip at %s\n", virtual_path);
vlog_info("Asset directory is .data.zip at %s", virtual_path);
if (!FILESYSTEM_mountAssetsFrom(virtual_path))
{
@@ -532,7 +533,7 @@ bool FILESYSTEM_mountAssets(const char* path)
if (FILESYSTEM_exists(virtual_path))
{
/* This is a full zipped-up level including assets */
printf("Asset directory is .zip at %s\n", virtual_path);
vlog_info("Asset directory is .zip at %s", virtual_path);
if (!FILESYSTEM_mountAssetsFrom(virtual_path))
{
@@ -552,7 +553,7 @@ bool FILESYSTEM_mountAssets(const char* path)
);
if (FILESYSTEM_exists(virtual_path))
{
printf("Asset directory exists at %s\n", virtual_path);
vlog_info("Asset directory exists at %s", virtual_path);
if (!FILESYSTEM_mountAssetsFrom(virtual_path))
{
@@ -565,7 +566,7 @@ bool FILESYSTEM_mountAssets(const char* path)
else
{
/* Wasn't a level zip, base zip, or folder! */
puts("Asset directory does not exist");
vlog_info("Asset directory does not exist");
}
#endif
}
@@ -582,7 +583,7 @@ void FILESYSTEM_unmountAssets(void)
{
if (assetDir[0] != '\0')
{
printf("Unmounting %s\n", assetDir);
vlog_info("Unmounting %s", assetDir);
PHYSFS_unmount(assetDir);
assetDir[0] = '\0';
graphics.reloadresources();
@@ -590,7 +591,7 @@ void FILESYSTEM_unmountAssets(void)
#if 0 /* flibit removed this because it was noisy, maybe keep for debug? */
else
{
printf("Cannot unmount when no asset directory is mounted\n");
vlog_info("Cannot unmount when no asset directory is mounted");
}
#endif
}
@@ -784,7 +785,7 @@ bool FILESYSTEM_loadBinaryBlob(binaryBlob* blob, const char* filename)
handle = PHYSFS_openRead(path);
if (handle == NULL)
{
printf("Unable to open file %s\n", filename);
vlog_info("Unable to open file %s", filename);
return false;
}
@@ -843,7 +844,7 @@ fail:
return false;
}
printf("The complete reloaded file size: %lli\n", size);
vlog_info("The complete reloaded file size: %lli", size);
for (i = 0; i < SDL_arraysize(blob->m_headers); ++i)
{
@@ -854,7 +855,7 @@ fail:
continue;
}
printf("%s unpacked\n", header->name);
vlog_info("%s unpacked", header->name);
}
return true;
@@ -926,8 +927,8 @@ void FILESYSTEM_enumerateLevelDirFileNames(
if (success == 0)
{
printf(
"Could not get list of levels: %s\n",
vlog_error(
"Could not get list of levels: %s",
PHYSFS_getErrorByCode(PHYSFS_getLastErrorCode())
);
}
@@ -949,8 +950,8 @@ static int PLATFORM_getOSDirectory(char* output, const size_t output_size)
if (FAILED(retcode))
{
printf(
"Could not get OS directory: SHGetFolderPathW returned 0x%08x\n",
vlog_error(
"Could not get OS directory: SHGetFolderPathW returned 0x%08x",
retcode
);
return 0;
@@ -968,8 +969,8 @@ static int PLATFORM_getOSDirectory(char* output, const size_t output_size)
);
if (num_bytes == 0)
{
printf(
"Could not get OS directory: UTF-8 conversion failed with %d\n",
vlog_error(
"Could not get OS directory: UTF-8 conversion failed with %d",
GetLastError()
);
return 0;
@@ -982,8 +983,8 @@ static int PLATFORM_getOSDirectory(char* output, const size_t output_size)
const char* prefDir = PHYSFS_getPrefDir("distractionware", "VVVVVV");
if (prefDir == NULL)
{
printf(
"Could not get OS directory: %s\n",
vlog_error(
"Could not get OS directory: %s",
PHYSFS_getErrorByCode(PHYSFS_getLastErrorCode())
);
return 0;
@@ -1014,7 +1015,7 @@ bool FILESYSTEM_openDirectory(const char *dname)
SDL_snprintf(url, sizeof(url), "file://%s", dname);
if (SDL_OpenURL(url) == -1)
{
printf("Error opening directory: %s\n", SDL_GetError());
vlog_error("Error opening directory: %s", SDL_GetError());
return false;
}
return true;
@@ -1032,7 +1033,7 @@ static void levelSaveCallback(const char* filename)
{
if (!FILESYSTEM_delete(filename))
{
printf("Error deleting %s\n", filename);
vlog_error("Error deleting %s", filename);
}
}
}
@@ -1050,8 +1051,8 @@ void FILESYSTEM_deleteLevelSaves(void)
if (success == 0)
{
printf(
"Could not enumerate saves/: %s\n",
vlog_error(
"Could not enumerate saves/: %s",
PHYSFS_getErrorByCode(PHYSFS_getLastErrorCode())
);
}