Browse Source

Migrate existing log entries

pull/1689/head
Jmgr 5 years ago committed by Anders Jenbo
parent
commit
1b7e0d2cb3
  1. 5
      Source/DiabloUI/art.cpp
  2. 5
      Source/DiabloUI/credits.cpp
  3. 3
      Source/DiabloUI/diabloui.cpp
  4. 9
      Source/DiabloUI/dialogs.cpp
  5. 5
      Source/DiabloUI/fonts.cpp
  6. 3
      Source/DiabloUI/ttf_render_wrapped.cpp
  7. 5
      Source/capture.cpp
  8. 11
      Source/controls/devices/game_controller.cpp
  9. 9
      Source/controls/devices/joystick.cpp
  10. 5
      Source/dvlnet/base_protocol.h
  11. 11
      Source/dvlnet/protocol_zt.cpp
  12. 3
      Source/dvlnet/tcp_server.cpp
  13. 4
      Source/dvlnet/zerotier_lwip.cpp
  14. 7
      Source/dvlnet/zerotier_native.cpp
  15. 3
      Source/dx.cpp
  16. 10
      Source/init.cpp
  17. 7
      Source/miniwin/misc_msg.cpp
  18. 15
      Source/mpqapi.cpp
  19. 5
      Source/player.cpp
  20. 35
      Source/scrollrt.cpp
  21. 7
      Source/sound.cpp
  22. 5
      Source/storm/storm.cpp
  23. 5
      Source/storm/storm_sdl_rw.cpp
  24. 11
      Source/storm/storm_svid.cpp
  25. 9
      Source/utils/display.cpp
  26. 5
      Source/utils/file_util.cpp
  27. 3
      Source/utils/paths.cpp
  28. 5
      Source/utils/soundsample.cpp
  29. 3
      Source/utils/thread.cpp

5
Source/DiabloUI/art.cpp

@ -2,6 +2,7 @@
#include "storm/storm.h"
#include "utils/display.h"
#include "utils/sdl_compat.h"
#include "utils/log.hpp"
namespace devilution {
@ -14,7 +15,7 @@ void LoadArt(const char *pszFile, Art *art, int frames, SDL_Color *pPalette)
DWORD width, height, bpp;
if (!SBmpLoadImage(pszFile, nullptr, nullptr, 0, &width, &height, &bpp)) {
SDL_Log("Failed to load image meta");
Log("Failed to load image meta");
return;
}
@ -37,7 +38,7 @@ void LoadArt(const char *pszFile, Art *art, int frames, SDL_Color *pPalette)
if (!SBmpLoadImage(pszFile, pPalette, static_cast<BYTE *>(artSurface->pixels),
artSurface->pitch * artSurface->format->BytesPerPixel * height, nullptr, nullptr, nullptr)) {
SDL_Log("Failed to load image");
Log("Failed to load image");
return;
}

5
Source/DiabloUI/credits.cpp

@ -13,6 +13,7 @@
#include "utils/display.h"
#include "utils/sdl_compat.h"
#include "utils/sdl_ptrs.h"
#include "utils/log.hpp"
namespace devilution {
@ -57,7 +58,7 @@ SDL_Surface *RenderText(const char *text, SDL_Color color)
return nullptr;
SDL_Surface *result = TTF_RenderUTF8_Solid(font, text, color);
if (result == nullptr)
SDL_Log("%s", TTF_GetError());
Log("{}", TTF_GetError());
return result;
}
@ -79,7 +80,7 @@ CachedLine PrepareLine(std::size_t index)
const SDL_Color &textColor = palette->colors[224];
SDL_Color colors[3] = { maskColor, textColor, shadowColor };
if (SDLC_SetSurfaceColors(surface.get(), colors, 0, 3) <= -1)
SDL_Log("%s", SDL_GetError());
Log("{}", SDL_GetError());
SDLC_SetColorKey(surface.get(), 0);
// Blit the shadow first:

3
Source/DiabloUI/diabloui.cpp

@ -19,6 +19,7 @@
#include "utils/sdl_ptrs.h"
#include "utils/stubs.h"
#include "utils/utf8.h"
#include "utils/log.hpp"
#ifdef __SWITCH__
// for virtual keyboard on Switch
@ -307,7 +308,7 @@ void UiFocusNavigation(SDL_Event *event)
if ((SDL_GetModState() & KMOD_CTRL) != 0) {
char *clipboard = SDL_GetClipboardText();
if (clipboard == nullptr) {
SDL_Log("%s", SDL_GetError());
Log("{}", SDL_GetError());
} else {
SelheroCatToName(clipboard, UiTextInput, UiTextInputLen);
}

9
Source/DiabloUI/dialogs.cpp

@ -11,6 +11,7 @@
#include "dx.h"
#include "palette.h"
#include "utils/display.h"
#include "utils/log.hpp"
namespace devilution {
@ -262,16 +263,16 @@ void UiOkDialog(const char *text, const char *caption, bool error, const std::ve
if (!gbActive || inDialog) {
if (SDL_ShowCursor(SDL_ENABLE) <= -1) {
SDL_Log("%s", SDL_GetError());
Log("{}", SDL_GetError());
}
#ifndef RUN_TESTS
if (SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, text, caption, nullptr) <= -1) {
SDL_Log("%s", SDL_GetError());
Log("{}", SDL_GetError());
#else
{
#endif
SDL_Log("%s", text);
SDL_Log("%s", caption);
Log("{}", text);
Log("{}", caption);
}
return;
}

5
Source/DiabloUI/fonts.cpp

@ -3,6 +3,7 @@
#include "diablo.h"
#include "utils/file_util.h"
#include "utils/paths.h"
#include "utils/log.hpp"
namespace devilution {
@ -59,7 +60,7 @@ void LoadTtfFont()
{
if (TTF_WasInit() == 0) {
if (TTF_Init() == -1) {
SDL_Log("TTF_Init: %s", TTF_GetError());
Log("TTF_Init: {}", TTF_GetError());
diablo_quit(1);
}
was_fonts_init = true;
@ -73,7 +74,7 @@ void LoadTtfFont()
#endif
font = TTF_OpenFont(ttfFontPath.c_str(), 17);
if (font == nullptr) {
SDL_Log("TTF_OpenFont: %s", TTF_GetError());
Log("TTF_OpenFont: {}", TTF_GetError());
return;
}

3
Source/DiabloUI/ttf_render_wrapped.cpp

@ -11,6 +11,7 @@
#endif
#include "utils/sdl_compat.h"
#include "utils/log.hpp"
namespace devilution {
@ -152,7 +153,7 @@ SDL_Surface *RenderUTF8_Solid_Wrapped(TTF_Font *font, const char *text, SDL_Colo
}
SDL_Surface *tmp = TTF_RenderUTF8_Solid(font, text, fg);
if (tmp == nullptr) {
SDL_Log("%s", TTF_GetError());
Log("{}", TTF_GetError());
SDL_FreeSurface(textbuf);
SDL_free(strLines);
SDL_stack_free(str);

5
Source/capture.cpp

@ -13,6 +13,7 @@
#include "utils/file_util.h"
#include "utils/paths.h"
#include "utils/ui_fwd.h"
#include "utils/log.hpp"
namespace devilution {
@ -194,10 +195,10 @@ void CaptureScreen()
outStream->close();
if (!success) {
SDL_Log("Failed to save screenshot at %s", fileName.c_str());
Log("Failed to save screenshot at {}", fileName);
RemoveFile(fileName.c_str());
} else {
SDL_Log("Screenshot saved at %s", fileName.c_str());
Log("Screenshot saved at {}", fileName);
}
SDL_Delay(300);
for (int i = 0; i < 256; i++) {

11
Source/controls/devices/game_controller.cpp

@ -8,6 +8,7 @@
#include "controls/devices/joystick.h"
#include "utils/sdl_ptrs.h"
#include "utils/stubs.h"
#include "utils/log.hpp"
namespace devilution {
@ -154,11 +155,11 @@ bool GameController::ProcessAxisMotion(const SDL_Event &event)
void GameController::Add(int joystickIndex)
{
SDL_Log("Opening game controller for joystick at index %d", joystickIndex);
Log("Opening game controller for joystick at index {}", joystickIndex);
GameController result;
result.sdl_game_controller_ = SDL_GameControllerOpen(joystickIndex);
if (result.sdl_game_controller_ == nullptr) {
SDL_Log("%s", SDL_GetError());
Log("{}", SDL_GetError());
SDL_ClearError();
return;
}
@ -168,12 +169,12 @@ void GameController::Add(int joystickIndex)
const SDL_JoystickGUID guid = SDL_JoystickGetGUID(sdlJoystick);
SDLUniquePtr<char> mapping { SDL_GameControllerMappingForGUID(guid) };
SDL_Log("Opened game controller with mapping:\n%s", mapping.get());
Log("Opened game controller with mapping:\n{}", mapping.get());
}
void GameController::Remove(SDL_JoystickID instanceId)
{
SDL_Log("Removing game controller with instance id %d", instanceId);
Log("Removing game controller with instance id {}", instanceId);
for (std::size_t i = 0; i < controllers_->size(); ++i) {
const GameController &controller = (*controllers_)[i];
if (controller.instance_id_ != instanceId)
@ -182,7 +183,7 @@ void GameController::Remove(SDL_JoystickID instanceId)
sgbControllerActive = !controllers_->empty();
return;
}
SDL_Log("Game controller not found with instance id: %d", instanceId);
Log("Game controller not found with instance id: {}", instanceId);
}
GameController *GameController::Get(SDL_JoystickID instanceId)

9
Source/controls/devices/joystick.cpp

@ -4,6 +4,7 @@
#include "controls/controller_motion.h"
#include "utils/stubs.h"
#include "utils/log.hpp"
namespace devilution {
@ -251,11 +252,11 @@ void Joystick::Add(int deviceIndex)
if (SDL_NumJoysticks() <= deviceIndex)
return;
Joystick result;
SDL_Log("Adding joystick %d: %s", deviceIndex,
Log("Adding joystick {}: {}", deviceIndex,
SDL_JoystickNameForIndex(deviceIndex));
result.sdl_joystick_ = SDL_JoystickOpen(deviceIndex);
if (result.sdl_joystick_ == nullptr) {
SDL_Log("%s", SDL_GetError());
Log("{}", SDL_GetError());
SDL_ClearError();
return;
}
@ -269,7 +270,7 @@ void Joystick::Add(int deviceIndex)
void Joystick::Remove(SDL_JoystickID instanceId)
{
#ifndef USE_SDL1
SDL_Log("Removing joystick (instance id: %d)", instanceId);
Log("Removing joystick (instance id: {})", instanceId);
for (std::size_t i = 0; i < joysticks_->size(); ++i) {
const Joystick &joystick = (*joysticks_)[i];
if (joystick.instance_id_ != instanceId)
@ -278,7 +279,7 @@ void Joystick::Remove(SDL_JoystickID instanceId)
sgbControllerActive = !joysticks_->empty();
return;
}
SDL_Log("Joystick not found with instance id: %d", instanceId);
Log("Joystick not found with instance id: {}", instanceId);
#endif
}

5
Source/dvlnet/base_protocol.h

@ -8,6 +8,7 @@
#include "dvlnet/base.h"
#include "dvlnet/packet.h"
#include "player.h"
#include "utils/log.hpp"
namespace devilution {
namespace net {
@ -182,11 +183,11 @@ void base_protocol<P>::recv()
} catch (packet_exception &e) {
// drop packet
proto.disconnect(sender);
SDL_Log("%s", e.what());
Log("{}", e.what());
}
}
} catch (std::exception &e) {
SDL_Log("%s", e.what());
Log("{}", e.what());
return;
}
}

11
Source/dvlnet/protocol_zt.cpp

@ -16,6 +16,7 @@
#include <lwip/tcpip.h>
#include "dvlnet/zerotier_native.h"
#include "utils/log.hpp"
namespace devilution::net {
@ -60,7 +61,7 @@ bool protocol_zt::network_online()
set_reuseaddr(fd_udp);
auto ret = lwip_bind(fd_udp, (struct sockaddr *)&in6, sizeof(in6));
if (ret < 0) {
SDL_Log("lwip, (udp) bind: %s\n", strerror(errno));
Log("lwip, (udp) bind: {}", strerror(errno));
throw protocol_exception();
}
set_nonblock(fd_udp);
@ -70,12 +71,12 @@ bool protocol_zt::network_online()
set_reuseaddr(fd_tcp);
auto r1 = lwip_bind(fd_tcp, (struct sockaddr *)&in6, sizeof(in6));
if (r1 < 0) {
SDL_Log("lwip, (tcp) bind: %s\n", strerror(errno));
Log("lwip, (tcp) bind: {}", strerror(errno));
throw protocol_exception();
}
auto r2 = lwip_listen(fd_tcp, 10);
if (r2 < 0) {
SDL_Log("lwip, listen: %s\n", strerror(errno));
Log("lwip, listen: {}", strerror(errno));
throw protocol_exception();
}
set_nonblock(fd_tcp);
@ -208,7 +209,7 @@ bool protocol_zt::accept_all()
endpoint ep;
std::copy(in6.sin6_addr.s6_addr, in6.sin6_addr.s6_addr + 16, ep.addr.begin());
if (peer_list[ep].fd != -1) {
SDL_Log("protocol_zt::accept_all: WARNING: overwriting connection\n");
Log("protocol_zt::accept_all: WARNING: overwriting connection");
lwip_close(peer_list[ep].fd);
}
set_nonblock(newfd);
@ -247,7 +248,7 @@ void protocol_zt::disconnect(const endpoint &peer)
if (peer_list.count(peer)) {
if (peer_list[peer].fd != -1) {
if (lwip_close(peer_list[peer].fd) < 0) {
SDL_Log("lwip_close: %s\n", strerror(errno));
Log("lwip_close: {}", strerror(errno));
}
}
peer_list.erase(peer);

3
Source/dvlnet/tcp_server.cpp

@ -6,6 +6,7 @@
#include <utility>
#include "dvlnet/base.h"
#include "utils/log.hpp"
namespace devilution::net {
@ -84,7 +85,7 @@ void tcp_server::handle_recv(const scc &con, const asio::error_code &ec,
handle_recv_packet(*pkt);
}
} catch (dvlnet_exception &e) {
SDL_Log("Network error: %s", e.what());
Log("Network error: {}", e.what());
drop_connection(con);
return;
}

4
Source/dvlnet/zerotier_lwip.cpp

@ -13,6 +13,8 @@
#include "utils/sdl2_backports.h"
#endif
#include "utils/log.hpp"
#include "dvlnet/zerotier_native.h"
namespace devilution::net {
@ -22,7 +24,7 @@ void print_ip6_addr(void *x)
char ipstr[INET6_ADDRSTRLEN];
auto *in = static_cast<sockaddr_in6 *>(x);
lwip_inet_ntop(AF_INET6, &(in->sin6_addr), ipstr, INET6_ADDRSTRLEN);
SDL_Log("ZeroTier: ZTS_EVENT_ADDR_NEW_IP6, addr=%s\n", ipstr);
Log("ZeroTier: ZTS_EVENT_ADDR_NEW_IP6, addr={}", ipstr);
}
void zt_ip6setup()

7
Source/dvlnet/zerotier_native.cpp

@ -13,6 +13,7 @@
#include <cstdlib>
#include "utils/paths.h"
#include "utils/log.hpp"
#include "dvlnet/zerotier_lwip.h"
@ -30,17 +31,17 @@ static void Callback(struct zts_callback_msg *msg)
{
//printf("callback %i\n", msg->eventCode);
if (msg->eventCode == ZTS_EVENT_NODE_ONLINE) {
SDL_Log("ZeroTier: ZTS_EVENT_NODE_ONLINE, nodeId=%llx\n", (unsigned long long)msg->node->address);
Log("ZeroTier: ZTS_EVENT_NODE_ONLINE, nodeId={:x}", (unsigned long long)msg->node->address);
zt_node_online = true;
if (!zt_joined) {
zts_join(ZtNetwork);
zt_joined = true;
}
} else if (msg->eventCode == ZTS_EVENT_NODE_OFFLINE) {
SDL_Log("ZeroTier: ZTS_EVENT_NODE_OFFLINE\n");
Log("ZeroTier: ZTS_EVENT_NODE_OFFLINE");
zt_node_online = false;
} else if (msg->eventCode == ZTS_EVENT_NETWORK_READY_IP6) {
SDL_Log("ZeroTier: ZTS_EVENT_NETWORK_READY_IP6, networkId=%llx\n", (unsigned long long)msg->network->nwid);
Log("ZeroTier: ZTS_EVENT_NETWORK_READY_IP6, networkId={:x}", (unsigned long long)msg->network->nwid);
zt_ip6setup();
zt_network_ready = true;
} else if (msg->eventCode == ZTS_EVENT_ADDR_ADDED_IP6) {

3
Source/dx.cpp

@ -11,6 +11,7 @@
#include "render.h"
#include "storm/storm.h"
#include "utils/display.h"
#include "utils/log.hpp"
#ifdef __3DS__
#include <3ds.h>
@ -132,7 +133,7 @@ void unlock_buf(BYTE idx)
CelOutputBuffer GlobalBackBuffer()
{
if (sgdwLockCount == 0) {
SDL_Log("WARNING: Trying to obtain GlobalBackBuffer() without holding a lock\n");
Log("WARNING: Trying to obtain GlobalBackBuffer() without holding a lock");
return CelOutputBuffer();
}

10
Source/init.cpp

@ -14,6 +14,7 @@
#include "storm/storm.h"
#include "utils/paths.h"
#include "utils/ui_fwd.h"
#include "utils/log.hpp"
#ifdef __vita__
// increase default allowed heap size on Vita
@ -58,16 +59,16 @@ HANDLE init_test_access(const std::vector<std::string> &paths, const char *mpq_n
for (const auto &path : paths) {
mpq_abspath = path + mpq_name;
if (SFileOpenArchive(mpq_abspath.c_str(), 0, MPQ_OPEN_READ_ONLY, &archive)) {
SDL_LogVerbose(SDL_LOG_CATEGORY_APPLICATION, " Found: %s in %s", mpq_name, path.c_str());
LogVerbose(" Found: %s in %s", mpq_name, path.c_str());
SFileSetBasePath(path.c_str());
return archive;
}
if (SErrGetLastError() != STORM_ERROR_FILE_NOT_FOUND) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Open error %u: %s", SErrGetLastError(), mpq_abspath.c_str());
LogError("Open error %u: %s", SErrGetLastError(), mpq_abspath.c_str());
}
}
if (SErrGetLastError() == STORM_ERROR_FILE_NOT_FOUND) {
SDL_LogVerbose(SDL_LOG_CATEGORY_APPLICATION, "Missing: %s", mpq_name);
LogVerbose("Missing: %s", mpq_name);
}
return nullptr;
@ -171,8 +172,7 @@ void init_archives()
message.append(paths[i]);
message += '\'';
}
SDL_LogVerbose(SDL_LOG_CATEGORY_APPLICATION,
"MPQ search paths%s", message.c_str());
LogVerbose("MPQ search paths%s", message.c_str());
}
diabdat_mpq = init_test_access(paths, "DIABDAT.MPQ");

7
Source/miniwin/misc_msg.cpp

@ -15,6 +15,7 @@
#include "utils/display.h"
#include "utils/sdl_compat.h"
#include "utils/stubs.h"
#include "utils/log.hpp"
#ifdef __SWITCH__
#include "platform/switch/docking.h"
@ -244,7 +245,7 @@ static int TranslateSdlKey(SDL_Keysym key)
} else if (sym >= SDLK_F1 && sym <= SDLK_F12) {
return DVL_VK_F1 + (sym - SDLK_F1);
}
SDL_Log("unknown key: name=%s sym=0x%X scan=%d mod=0x%X", SDL_GetKeyName(sym), sym, key.scancode, key.mod);
Log("unknown key: name={} sym=0x{:X} scan={} mod=0x{:X}", SDL_GetKeyName(sym), sym, key.scancode, key.mod);
return -1;
}
}
@ -265,7 +266,7 @@ WPARAM KeystateForMouse(WPARAM ret)
bool FalseAvail(const char *name, int value)
{
SDL_LogDebug(SDL_LOG_CATEGORY_APPLICATION, "Unhandled SDL event: %s %d", name, value);
LogDebug("Unhandled SDL event: %s %d", name, value);
return true;
}
@ -668,7 +669,7 @@ bool TranslateMessage(const MSG *lpMsg)
#ifdef _DEBUG
if (key >= 32) {
SDL_Log("char: %c", key);
Log("char: {:c}", key);
}
#endif

15
Source/mpqapi.cpp

@ -17,6 +17,7 @@
#include "encrypt.h"
#include "engine.h"
#include "utils/file_util.h"
#include "utils/log.hpp"
namespace devilution {
@ -160,10 +161,10 @@ private:
const char *error_message = std::strerror(errno);
if (error_message == nullptr)
error_message = "";
SDL_LogError(SDL_LOG_CATEGORY_SYSTEM, fmt_with_error.c_str(), args..., error_message);
LogError(LogCategory::System, fmt_with_error.c_str(), args..., error_message);
#ifdef _DEBUG
} else {
SDL_LogVerbose(SDL_LOG_CATEGORY_SYSTEM, fmt, args...);
LogVerbose(LogCategory::System, fmt, args...);
#endif
}
return !s_->fail();
@ -195,17 +196,17 @@ struct Archive {
{
Close();
#ifdef _DEBUG
SDL_Log("Opening %s", name);
Log("Opening {}", name);
#endif
exists = FileExists(name);
std::ios::openmode mode = std::ios::in | std::ios::out | std::ios::binary;
if (exists) {
if (GetFileSize(name, &size) == 0) {
SDL_Log("GetFileSize(\"%s\") failed with \"%s\"", name, std::strerror(errno));
Log("GetFileSize(\"{}\") failed with \"{}\"", name, std::strerror(errno));
return false;
}
#ifdef _DEBUG
SDL_Log("GetFileSize(\"%s\") = %" PRIuMAX, name, size);
Log("GetFileSize(\"{}\") = {}", name, size);
#endif
} else {
mode |= std::ios::trunc;
@ -225,7 +226,7 @@ struct Archive {
if (!stream.IsOpen())
return true;
#ifdef _DEBUG
SDL_Log("Closing %s", name.c_str());
Log("Closing {}", name);
#endif
bool result = true;
@ -234,7 +235,7 @@ struct Archive {
stream.Close();
if (modified && result && size != 0) {
#ifdef _DEBUG
SDL_Log("ResizeFile(\"%s\", %" PRIuMAX ")", name.c_str(), size);
Log("ResizeFile(\"{}\", {})", name, size);
#endif
result = ResizeFile(name.c_str(), size);
}

5
Source/player.cpp

@ -22,6 +22,7 @@
#include "stores.h"
#include "storm/storm.h"
#include "towners.h"
#include "utils/log.hpp"
namespace devilution {
@ -3768,12 +3769,12 @@ int GetFrameToUseForPlayerRendering(const PlayerStruct *pPlayer)
// this can happen if we are at the last frame and the next game tick is due (nthread_GetProgressToNextGameTick returns 1.0f)
if (absoluteAnimationFrame > (relevantAnimationFramesForDistributing + 1)) {
// we should never have +2 frames even if next game tick is due
SDL_Log("GetFrameToUseForPlayerRendering: Calculated an invalid Animation Frame (Calculated %d MaxFrame %d)", absoluteAnimationFrame, relevantAnimationFramesForDistributing);
Log("GetFrameToUseForPlayerRendering: Calculated an invalid Animation Frame (Calculated {} MaxFrame {})", absoluteAnimationFrame, relevantAnimationFramesForDistributing);
}
return relevantAnimationFramesForDistributing;
}
if (absoluteAnimationFrame <= 0) {
SDL_Log("GetFrameToUseForPlayerRendering: Calculated an invalid Animation Frame (Calculated %d)", absoluteAnimationFrame);
Log("GetFrameToUseForPlayerRendering: Calculated an invalid Animation Frame (Calculated {})", absoluteAnimationFrame);
return 1;
}
return absoluteAnimationFrame;

35
Source/scrollrt.cpp

@ -28,6 +28,7 @@
#include "render.h"
#include "stores.h"
#include "towners.h"
#include "utils/log.hpp"
namespace devilution {
@ -257,13 +258,13 @@ void DrawMissilePrivate(const CelOutputBuffer &out, MissileStruct *m, int sx, in
BYTE *pCelBuff = m->_miAnimData;
if (pCelBuff == nullptr) {
SDL_Log("Draw Missile 2 type %d: NULL Cel Buffer", m->_mitype);
Log("Draw Missile 2 type {}: NULL Cel Buffer", m->_mitype);
return;
}
int nCel = m->_miAnimFrame;
int frames = SDL_SwapLE32(*(DWORD *)pCelBuff);
if (nCel < 1 || frames > 50 || nCel > frames) {
SDL_Log("Draw Missile 2: frame %d of %d, missile type==%d", nCel, frames, m->_mitype);
Log("Draw Missile 2: frame {} of {}, missile type=={}", nCel, frames, m->_mitype);
return;
}
int mx = sx + m->position.offset.x - m->_miAnimWidth2;
@ -320,13 +321,13 @@ void DrawMissile(const CelOutputBuffer &out, int x, int y, int sx, int sy, bool
static void DrawMonster(const CelOutputBuffer &out, int x, int y, int mx, int my, int m)
{
if (m < 0 || m >= MAXMONSTERS) {
SDL_Log("Draw Monster: tried to draw illegal monster %d", m);
Log("Draw Monster: tried to draw illegal monster {}", m);
return;
}
BYTE *pCelBuff = monster[m]._mAnimData;
if (pCelBuff == nullptr) {
SDL_Log("Draw Monster \"%s\": NULL Cel Buffer", monster[m].mName);
Log("Draw Monster \"{}\": NULL Cel Buffer", monster[m].mName);
return;
}
@ -336,8 +337,8 @@ static void DrawMonster(const CelOutputBuffer &out, int x, int y, int mx, int my
const char *szMode = "unknown action";
if (monster[m]._mmode <= 17)
szMode = szMonModeAssert[monster[m]._mmode];
SDL_Log(
"Draw Monster \"%s\" %s: facing %d, frame %d of %d",
Log(
"Draw Monster \"{}\" {}: facing {}, frame {} of {}",
monster[m].mName,
szMode,
monster[m]._mdir,
@ -420,7 +421,7 @@ static void DrawPlayer(const CelOutputBuffer &out, int pnum, int x, int y, int p
int nWidth = pPlayer->_pAnimWidth;
if (pCelBuff == nullptr) {
SDL_Log("Drawing player %d \"%s\": NULL Cel Buffer", pnum, plr[pnum]._pName);
Log("Drawing player {} \"{}\": NULL Cel Buffer", pnum, plr[pnum]._pName);
return;
}
@ -429,8 +430,8 @@ static void DrawPlayer(const CelOutputBuffer &out, int pnum, int x, int y, int p
const char *szMode = "unknown action";
if (plr[pnum]._pmode <= PM_QUIT)
szMode = szPlrModeAssert[plr[pnum]._pmode];
SDL_Log(
"Drawing player %d \"%s\" %s: facing %d, frame %d of %d",
Log(
"Drawing player {} \"{}\" {}: facing {}, frame {} of {}",
pnum,
plr[pnum]._pName,
szMode,
@ -529,14 +530,14 @@ static void DrawObject(const CelOutputBuffer &out, int x, int y, int ox, int oy,
BYTE *pCelBuff = object[bv]._oAnimData;
if (pCelBuff == nullptr) {
SDL_Log("Draw Object type %d: NULL Cel Buffer", object[bv]._otype);
Log("Draw Object type {}: NULL Cel Buffer", object[bv]._otype);
return;
}
int nCel = object[bv]._oAnimFrame;
int frames = SDL_SwapLE32(*(DWORD *)pCelBuff);
if (nCel < 1 || frames > 50 || nCel > frames) {
SDL_Log("Draw Object: frame %d of %d, object type==%d", nCel, frames, object[bv]._otype);
Log("Draw Object: frame {} of {}, object type=={}", nCel, frames, object[bv]._otype);
return;
}
@ -628,14 +629,14 @@ static void DrawItem(const CelOutputBuffer &out, int x, int y, int sx, int sy, b
BYTE *pCelBuff = pItem->_iAnimData;
if (pCelBuff == nullptr) {
SDL_Log("Draw Item \"%s\" 1: NULL Cel Buffer", pItem->_iIName);
Log("Draw Item \"{}\" 1: NULL Cel Buffer", pItem->_iIName);
return;
}
int nCel = pItem->_iAnimFrame;
int frames = SDL_SwapLE32(*(DWORD *)pCelBuff);
if (nCel < 1 || frames > 50 || nCel > frames) {
SDL_Log("Draw \"%s\" Item 1: frame %d of %d, item type==%d", pItem->_iIName, nCel, frames, pItem->_itype);
Log("Draw \"{}\" Item 1: frame {} of {}, item type=={}", pItem->_iIName, nCel, frames, pItem->_itype);
return;
}
@ -677,7 +678,7 @@ static void DrawMonsterHelper(const CelOutputBuffer &out, int x, int y, int oy,
return;
if (mi < 0 || mi >= MAXMONSTERS) {
SDL_Log("Draw Monster: tried to draw illegal monster %d", mi);
Log("Draw Monster: tried to draw illegal monster {}", mi);
return;
}
@ -687,7 +688,7 @@ static void DrawMonsterHelper(const CelOutputBuffer &out, int x, int y, int oy,
}
if (pMonster->MType == nullptr) {
SDL_Log("Draw Monster \"%s\": uninitialized monster", pMonster->mName);
Log("Draw Monster \"{}\": uninitialized monster", pMonster->mName);
return;
}
@ -713,7 +714,7 @@ static void DrawPlayerHelper(const CelOutputBuffer &out, int x, int y, int sx, i
p = p > 0 ? p - 1 : -(p + 1);
if (p < 0 || p >= MAX_PLRS) {
SDL_Log("draw player: tried to draw illegal player %d", p);
Log("draw player: tried to draw illegal player {}", p);
return;
}
@ -775,7 +776,7 @@ static void scrollrt_draw_dungeon(const CelOutputBuffer &out, int sx, int sy, in
int frames = SDL_SwapLE32(*(DWORD *)pCelBuff);
int nCel = pDeadGuy->_deadFrame;
if (nCel < 1 || frames > 50 || nCel > frames) {
SDL_Log("Unclipped dead: frame %d of %d, deadnum==%d", nCel, frames, (bDead & 0x1F) - 1);
Log("Unclipped dead: frame {} of {}, deadnum=={}", nCel, frames, (bDead & 0x1F) - 1);
break;
}
if (pDeadGuy->_deadtrans != 0) {

7
Source/sound.cpp

@ -11,6 +11,7 @@
#include "storm/storm.h"
#include "storm/storm_sdl_rw.h"
#include "utils/stubs.h"
#include "utils/log.hpp"
namespace devilution {
@ -172,7 +173,7 @@ void snd_init()
int result = Mix_OpenAudio(22050, AUDIO_S16LSB, 2, 1024);
if (result < 0) {
SDL_Log("%s", Mix_GetError());
Log("{}", Mix_GetError());
}
Mix_AllocateChannels(25);
Mix_ReserveChannels(1); // reserve one channel for naration (SFileDda*)
@ -228,7 +229,7 @@ void music_start(uint8_t nTrack)
#endif
music = Mix_LoadMUSType_RW(musicRw, MUS_NONE, /*freesrc=*/1);
if (music == nullptr) {
SDL_Log("Mix_LoadMUSType_RW: %s", Mix_GetError());
Log("Mix_LoadMUSType_RW: {}", Mix_GetError());
#ifndef DISABLE_STREAMING_MUSIC
SFileCloseFile(sghMusic);
sghMusic = nullptr;
@ -242,7 +243,7 @@ void music_start(uint8_t nTrack)
Mix_VolumeMusic(MIX_MAX_VOLUME - MIX_MAX_VOLUME * sgOptions.Audio.nMusicVolume / VOLUME_MIN);
if (Mix_PlayMusic(music, -1) < 0) {
SDL_Log("Mix_PlayMusic: %s", Mix_GetError());
Log("Mix_PlayMusic: {}", Mix_GetError());
Mix_FreeMusic(music);
music = nullptr;
#ifndef DISABLE_STREAMING_MUSIC

5
Source/storm/storm.cpp

@ -13,6 +13,7 @@
#include "options.h"
#include "utils/paths.h"
#include "utils/stubs.h"
#include "utils/log.hpp"
// Include Windows headers for Get/SetLastError.
#if defined(_WIN32)
@ -120,7 +121,7 @@ bool SFileOpenFile(const char *filename, HANDLE *phFile)
}
if (!result || (*phFile == nullptr)) {
SDL_Log("%s: Not found: %s", __FUNCTION__, filename);
Log("{}: Not found: {}", __FUNCTION__, filename);
}
return result;
}
@ -232,7 +233,7 @@ bool SBmpLoadImage(const char *pszFileName, SDL_Color *pPalette, BYTE *pBuffer,
if (pPalette && pcxhdr.BitsPerPixel == 8) {
const auto pos = SFileSetFilePointer(hFile, -768, DVL_FILE_CURRENT);
if (pos == static_cast<std::uint64_t>(-1)) {
SDL_Log("SFileSetFilePointer error: %ud", (unsigned int)SErrGetLastError());
Log("SFileSetFilePointer error: {}", (unsigned int)SErrGetLastError());
}
SFileReadFile(hFile, paldata, 768, nullptr, nullptr);

5
Source/storm/storm_sdl_rw.cpp

@ -5,6 +5,7 @@
#include "engine.h"
#include "storm/storm.h"
#include "utils/log.hpp"
namespace devilution {
@ -47,7 +48,7 @@ static int SFileRwSeek(struct SDL_RWops *context, int offset, int whence)
}
const std::uint64_t pos = SFileSetFilePointer(SFileRwGetHandle(context), offset, swhence);
if (pos == static_cast<std::uint64_t>(-1)) {
SDL_Log("SFileRwSeek error: %ud", (unsigned int)SErrGetLastError());
Log("SFileRwSeek error: {}", (unsigned int)SErrGetLastError());
}
return pos;
}
@ -62,7 +63,7 @@ static int SFileRwRead(struct SDL_RWops *context, void *ptr, int size, int maxnu
if (!SFileReadFile(SFileRwGetHandle(context), ptr, maxnum * size, &numRead, nullptr)) {
const DWORD errCode = SErrGetLastError();
if (errCode != STORM_ERROR_HANDLE_EOF) {
SDL_Log("SFileRwRead error: %u %u ERROR CODE %u", (unsigned int)size, (unsigned int)maxnum, (unsigned int)errCode);
Log("SFileRwRead error: {} {} ERROR CODE {}", (unsigned int)size, (unsigned int)maxnum, (unsigned int)errCode);
}
}
return numRead / size;

11
Source/storm/storm_svid.cpp

@ -14,6 +14,7 @@
#include "storm/storm.h"
#include "utils/display.h"
#include "utils/sdl_compat.h"
#include "utils/log.hpp"
#if !SDL_VERSION_ATLEAST(2, 0, 4)
#include <queue>
@ -202,7 +203,7 @@ bool HaveAudio()
void SVidRestartMixer()
{
if (Mix_OpenAudio(22050, AUDIO_S16LSB, 2, 1024) < 0) {
SDL_Log("%s", Mix_GetError());
Log("{}", Mix_GetError());
}
Mix_AllocateChannels(25);
Mix_ReserveChannels(1);
@ -370,7 +371,7 @@ bool SVidPlayContinue()
memcpy(logical_palette, orig_palette, sizeof(logical_palette));
if (SDLC_SetSurfaceAndPaletteColors(SVidSurface, SVidPalette, colors, 0, 256) <= -1) {
SDL_Log("%s", SDL_GetError());
Log("{}", SDL_GetError());
return false;
}
}
@ -384,7 +385,7 @@ bool SVidPlayContinue()
unsigned char *audio = SVidApplyVolume(smk_get_audio(SVidSMK, 0), len);
#if SDL_VERSION_ATLEAST(2, 0, 4)
if (SDL_QueueAudio(deviceId, audio, len) <= -1) {
SDL_Log("%s", SDL_GetError());
Log("{}", SDL_GetError());
return false;
}
#else
@ -400,7 +401,7 @@ bool SVidPlayContinue()
#ifndef USE_SDL1
if (renderer != nullptr) {
if (SDL_BlitSurface(SVidSurface, nullptr, GetOutputSurface(), nullptr) <= -1) {
SDL_Log("%s", SDL_GetError());
Log("{}", SDL_GetError());
return false;
}
} else
@ -443,7 +444,7 @@ bool SVidPlayContinue()
SDLSurfaceUniquePtr converted { SDL_ConvertSurfaceFormat(SVidSurface, wndFormat, 0) };
#endif
if (SDL_BlitScaled(converted.get(), nullptr, outputSurface, &outputRect) <= -1) {
SDL_Log("%s", SDL_GetError());
Log("{}", SDL_GetError());
return false;
}
}

9
Source/utils/display.cpp

@ -12,6 +12,7 @@
#include "controls/devices/kbcontroller.h"
#include "controls/game_controls.h"
#include "options.h"
#include "utils/log.hpp"
#ifdef USE_SDL1
#ifndef SDL1_VIDEO_MODE_BPP
@ -34,10 +35,10 @@ Uint16 borderRight;
#ifdef USE_SDL1
void SetVideoMode(int width, int height, int bpp, uint32_t flags)
{
SDL_Log("Setting video mode %dx%d bpp=%u flags=0x%08X", width, height, bpp, flags);
Log("Setting video mode {}x{} bpp={} flags=0x{:08X}", width, height, bpp, flags);
SDL_SetVideoMode(width, height, bpp, flags);
const SDL_VideoInfo &current = *SDL_GetVideoInfo();
SDL_Log("Video mode is now %dx%d bpp=%u flags=0x%08X",
Log("Video mode is now {}x{} bpp={} flags=0x{:08X}",
current.current_w, current.current_h, current.vfmt->BitsPerPixel, SDL_GetVideoSurface()->flags);
ghMainWnd = SDL_GetVideoSurface();
}
@ -49,7 +50,7 @@ void SetVideoModeToPrimary(bool fullscreen, int width, int height)
flags |= SDL_FULLSCREEN;
SetVideoMode(width, height, SDL1_VIDEO_MODE_BPP, flags);
if (OutputRequiresScaling())
SDL_Log("Using software scaling");
Log("Using software scaling");
}
#endif
@ -84,7 +85,7 @@ void CalculatePreferdWindowSize(int &width, int &height)
{
#ifdef USE_SDL1
const SDL_VideoInfo &best = *SDL_GetVideoInfo();
SDL_Log("Best video mode reported as: %dx%d bpp=%d hw_available=%u",
Log("Best video mode reported as: {}x{} bpp={} hw_available={}",
best.current_w, best.current_h, best.vfmt->BitsPerPixel, best.hw_available);
#else
SDL_DisplayMode mode;

5
Source/utils/file_util.cpp

@ -1,4 +1,5 @@
#include "utils/file_util.h"
#include "utils/log.hpp"
#include <algorithm>
#include <string>
@ -104,9 +105,9 @@ void RemoveFile(const char *lpFileName)
fclose(f);
remove(name.c_str());
f = nullptr;
SDL_Log("Removed file: %s", name.c_str());
Log("Removed file: {}", name);
} else {
SDL_Log("Failed to remove file: %s", name.c_str());
Log("Failed to remove file: {}", name);
}
}

3
Source/utils/paths.cpp

@ -1,4 +1,5 @@
#include "utils/paths.h"
#include "utils/log.hpp"
#include <SDL.h>
@ -41,7 +42,7 @@ std::string *FromSDL(char *s)
if (s != nullptr) {
SDL_free(s);
} else {
SDL_Log("%s", SDL_GetError());
Log("{}", SDL_GetError());
SDL_ClearError();
}
return result;

5
Source/utils/soundsample.cpp

@ -9,6 +9,7 @@
#include "storm/storm_sdl_rw.h"
#include "utils/stubs.h"
#include "utils/log.hpp"
namespace devilution {
@ -48,7 +49,7 @@ void SoundSample::Play(int lVolume, int lPan, int channel)
channel = Mix_PlayChannel(channel, chunk, 0);
if (channel == -1) {
SDL_Log("Too few channels, skipping sound");
Log("Too few channels, skipping sound");
return;
}
@ -79,7 +80,7 @@ int SoundSample::SetChunkStream(HANDLE stormHandle)
{
chunk = Mix_LoadWAV_RW(SFileRw_FromStormHandle(stormHandle), /*freesrc=*/1);
if (chunk == nullptr) {
SDL_Log("Mix_LoadWAV_RW: %s", Mix_GetError());
Log("Mix_LoadWAV_RW: {}", Mix_GetError());
return -1;
}
return 0;

3
Source/utils/thread.cpp

@ -5,6 +5,7 @@
#include "appfat.h"
#include "utils/stubs.h"
#include "utils/log.hpp"
namespace devilution {
@ -72,7 +73,7 @@ int WaitForEvent(event_emul *e)
}
int ret = SDL_CondWait(e->cond, e->mutex);
if (ret <= -1 || SDL_CondSignal(e->cond) <= -1 || SDL_UnlockMutex(e->mutex) <= -1) {
SDL_Log("%s", SDL_GetError());
Log("{}", SDL_GetError());
return -1;
}
return ret;

Loading…
Cancel
Save