diff --git a/Source/DiabloUI/art.cpp b/Source/DiabloUI/art.cpp index 949455589..e3f316290 100644 --- a/Source/DiabloUI/art.cpp +++ b/Source/DiabloUI/art.cpp @@ -57,8 +57,8 @@ void LoadMaskedArt(const char *pszFile, Art *art, int frames, int mask) void LoadArt(Art *art, const BYTE *artData, int w, int h, int frames) { art->frames = frames; - art->surface = ScaleSurfaceToOutput(SDLSurfaceUniquePtr{SDL_CreateRGBSurfaceWithFormatFrom( - const_cast(artData), w, h, 8, w, SDL_PIXELFORMAT_INDEX8)}); + art->surface = ScaleSurfaceToOutput(SDLSurfaceUniquePtr { SDL_CreateRGBSurfaceWithFormatFrom( + const_cast(artData), w, h, 8, w, SDL_PIXELFORMAT_INDEX8) }); art->logical_width = w; art->frame_height = h / frames; } diff --git a/Source/DiabloUI/selhero.cpp b/Source/DiabloUI/selhero.cpp index ab9895752..88c3ab893 100644 --- a/Source/DiabloUI/selhero.cpp +++ b/Source/DiabloUI/selhero.cpp @@ -629,7 +629,7 @@ static void UiSelHeroDialog( } while (selhero_navigateYesNo); *dlgresult = selhero_result; - strncpy(*name, selhero_heroInfo.name, sizeof(*name)); + strncpy(*name, selhero_heroInfo.name, sizeof(*name)); } void UiSelHeroSingDialog( diff --git a/Source/appfat.h b/Source/appfat.h index 16c6c4c26..93755f808 100644 --- a/Source/appfat.h +++ b/Source/appfat.h @@ -17,8 +17,12 @@ namespace devilution { #ifndef _DEBUG #define assert(exp) -#define assurance(exp, value) if (!(exp)) return -#define commitment(exp, value) if (!(exp)) return false +#define assurance(exp, value) \ + if (!(exp)) \ + return +#define commitment(exp, value) \ + if (!(exp)) \ + return false #else #define assert(exp) (void)((exp) || (assert_fail(__LINE__, __FILE__, #exp), 0)) #define assurance(exp, value) (void)((exp) || (app_fatal("%s: %s was %i", __func__, #exp, value), 0)) @@ -35,4 +39,4 @@ void DrawDlg(const char *pszFmt, ...) DVL_PRINTF_ATTRIBUTE(1, 2); [[noreturn]] void InsertCDDlg(); [[noreturn]] void DirErrorDlg(const char *error); -} +} // namespace devilution diff --git a/Source/automap.h b/Source/automap.h index c46cbd12f..477d778cf 100644 --- a/Source/automap.h +++ b/Source/automap.h @@ -84,4 +84,4 @@ void SetAutomapView(Sint32 x, Sint32 y); */ void AutomapZoomReset(); -} +} // namespace devilution diff --git a/Source/codec.h b/Source/codec.h index a49207c16..81bbe455b 100644 --- a/Source/codec.h +++ b/Source/codec.h @@ -13,4 +13,4 @@ int codec_decode(BYTE *pbSrcDst, DWORD size, const char *pszPassword); DWORD codec_get_encoded_len(DWORD dwSrcBytes); void codec_encode(BYTE *pbSrcDst, DWORD size, int size_64, const char *pszPassword); -} +} // namespace devilution diff --git a/Source/control.h b/Source/control.h index 2e98bb30e..b7558a277 100644 --- a/Source/control.h +++ b/Source/control.h @@ -164,4 +164,4 @@ extern const BYTE gbFontTransTbl[256]; extern RECT32 ChrBtnsRect[4]; -} +} // namespace devilution diff --git a/Source/controls/README.md b/Source/controls/README.md index 629606321..86f00d3c7 100644 --- a/Source/controls/README.md +++ b/Source/controls/README.md @@ -1,4 +1,4 @@ -# Controls handling +#Controls handling DevilutionX supports mouse & keyboard and gamepad input. diff --git a/Source/controls/devices/game_controller.cpp b/Source/controls/devices/game_controller.cpp index bb52ea36f..f1911da8c 100644 --- a/Source/controls/devices/game_controller.cpp +++ b/Source/controls/devices/game_controller.cpp @@ -167,7 +167,7 @@ void GameController::Add(int joystick_index) controllers_->push_back(result); const SDL_JoystickGUID guid = SDL_JoystickGetGUID(sdl_joystick); - SDLUniquePtr mapping{SDL_GameControllerMappingForGUID(guid)}; + SDLUniquePtr mapping { SDL_GameControllerMappingForGUID(guid) }; SDL_Log("Opened game controller with mapping:\n%s", mapping.get()); } diff --git a/Source/cursor.h b/Source/cursor.h index cb554acba..78ed809ec 100644 --- a/Source/cursor.h +++ b/Source/cursor.h @@ -57,4 +57,4 @@ void CheckCursMove(); extern const int InvItemWidth[]; extern const int InvItemHeight[]; -} +} // namespace devilution diff --git a/Source/dead.h b/Source/dead.h index 93a55fb04..4bdfbe6fa 100644 --- a/Source/dead.h +++ b/Source/dead.h @@ -28,4 +28,4 @@ void InitDead(); void AddDead(int dx, int dy, int8_t dv, direction ddir); void SetDead(); -} +} // namespace devilution diff --git a/Source/debug.h b/Source/debug.h index 69f3df164..b20096d28 100644 --- a/Source/debug.h +++ b/Source/debug.h @@ -23,4 +23,4 @@ void PrintDebugQuest(); void GetDebugMonster(); void NextDebugMonster(); -} +} // namespace devilution diff --git a/Source/diablo.h b/Source/diablo.h index ff4026452..70242b52d 100644 --- a/Source/diablo.h +++ b/Source/diablo.h @@ -80,4 +80,4 @@ extern int debug_mode_key_j; #endif extern bool gbFriendlyMode; -} +} // namespace devilution diff --git a/Source/doom.h b/Source/doom.h index 1df25858f..1a0e41cc7 100644 --- a/Source/doom.h +++ b/Source/doom.h @@ -17,4 +17,4 @@ void doom_init(); void doom_close(); void doom_draw(CelOutputBuffer out); -} +} // namespace devilution diff --git a/Source/drlg_l1.h b/Source/drlg_l1.h index 2c0c136f0..d0a75cc7f 100644 --- a/Source/drlg_l1.h +++ b/Source/drlg_l1.h @@ -32,4 +32,4 @@ void drlg_l1_crypt_pattern5(int rndper); void drlg_l1_crypt_pattern6(int rndper); void drlg_l1_crypt_pattern7(int rndper); -} +} // namespace devilution diff --git a/Source/drlg_l2.h b/Source/drlg_l2.h index 47e802fff..d415766fc 100644 --- a/Source/drlg_l2.h +++ b/Source/drlg_l2.h @@ -34,4 +34,4 @@ void LoadL2Dungeon(const char *sFileName, int vx, int vy); void LoadPreL2Dungeon(const char *sFileName, int vx, int vy); void CreateL2Dungeon(DWORD rseed, lvl_entry entry); -} +} // namespace devilution diff --git a/Source/drlg_l3.cpp b/Source/drlg_l3.cpp index 7b88db44d..14ea1e01e 100644 --- a/Source/drlg_l3.cpp +++ b/Source/drlg_l3.cpp @@ -1983,7 +1983,8 @@ static void DRLG_L3Wood() volatile // visual studio 2019 throws internal compiler error without it, see #708 #endif - int i, j, x, y, xx, yy, rt, rp, x1, y1, x2, y2; + int i, + j, x, y, xx, yy, rt, rp, x1, y1, x2, y2; bool skip; for (j = 1; j < DMAXY - 1; j++) { // BUGFIX: Change '0' to '1' (fixed) diff --git a/Source/drlg_l3.h b/Source/drlg_l3.h index fc64cd2a9..7280a83ef 100644 --- a/Source/drlg_l3.h +++ b/Source/drlg_l3.h @@ -15,4 +15,4 @@ void CreateL3Dungeon(DWORD rseed, lvl_entry entry); void LoadL3Dungeon(const char *sFileName, int vx, int vy); void LoadPreL3Dungeon(const char *sFileName, int vx, int vy); -} +} // namespace devilution diff --git a/Source/drlg_l4.h b/Source/drlg_l4.h index a77d5f349..ed572d78e 100644 --- a/Source/drlg_l4.h +++ b/Source/drlg_l4.h @@ -22,4 +22,4 @@ bool IsDURWall(char d); bool IsDLLWall(char dd); void CreateL4Dungeon(DWORD rseed, lvl_entry entry); -} +} // namespace devilution diff --git a/Source/dthread.h b/Source/dthread.h index a23ead056..19b114689 100644 --- a/Source/dthread.h +++ b/Source/dthread.h @@ -12,4 +12,4 @@ void dthread_send_delta(int pnum, char cmd, void *pbSrc, int dwLen); void dthread_start(); void dthread_cleanup(); -} +} // namespace devilution diff --git a/Source/dvlnet/base.cpp b/Source/dvlnet/base.cpp index 08cce081a..e05f31531 100644 --- a/Source/dvlnet/base.cpp +++ b/Source/dvlnet/base.cpp @@ -38,7 +38,7 @@ void base::handle_accept(packet &pkt) connected_table[plr_self] = true; } if (game_init_info != pkt.info()) { - if(pkt.info().size() != sizeof(GameData)) { + if (pkt.info().size() != sizeof(GameData)) { ABORT(); } // we joined and did not create diff --git a/Source/dvlnet/base_protocol.h b/Source/dvlnet/base_protocol.h index f88d669e0..84c96968a 100644 --- a/Source/dvlnet/base_protocol.h +++ b/Source/dvlnet/base_protocol.h @@ -12,7 +12,7 @@ namespace devilution { namespace net { -template +template class base_protocol : public base { public: virtual int create(std::string addrstr, std::string passwd); @@ -49,17 +49,17 @@ private: void wait_join(); }; -template +template plr_t base_protocol

::get_master() { plr_t ret = plr_self; for (plr_t i = 0; i < MAX_PLRS; ++i) - if(peers[i]) + if (peers[i]) ret = std::min(ret, i); return ret; } -template +template bool base_protocol

::wait_network() { // wait for ZeroTier for 5 seconds @@ -71,14 +71,14 @@ bool base_protocol

::wait_network() return proto.network_online(); } -template +template void base_protocol

::disconnect_net(plr_t plr) { proto.disconnect(peers[plr]); peers[plr] = endpoint(); } -template +template bool base_protocol

::wait_firstpeer() { // wait for peer for 5 seconds @@ -94,21 +94,21 @@ bool base_protocol

::wait_firstpeer() return (bool)firstpeer; } -template +template void base_protocol

::send_info_request() { auto pkt = pktfty->make_packet(PLR_BROADCAST, - PLR_MASTER); + PLR_MASTER); proto.send_oob_mc(pkt->data()); } -template +template void base_protocol

::wait_join() { randombytes_buf(reinterpret_cast(&cookie_self), - sizeof(cookie_t)); + sizeof(cookie_t)); auto pkt = pktfty->make_packet(PLR_BROADCAST, - PLR_MASTER, cookie_self, game_init_info); + PLR_MASTER, cookie_self, game_init_info); proto.send(firstpeer, pkt->data()); for (auto i = 0; i < 500; ++i) { recv(); @@ -118,13 +118,13 @@ void base_protocol

::wait_join() } } -template +template int base_protocol

::create(std::string addrstr, std::string passwd) { setup_password(passwd); gamename = addrstr; - if(wait_network()) { + if (wait_network()) { plr_self = 0; connected_table[plr_self] = true; } @@ -132,44 +132,44 @@ int base_protocol

::create(std::string addrstr, std::string passwd) return (plr_self == PLR_BROADCAST ? MAX_PLRS : plr_self); } -template +template int base_protocol

::join(std::string addrstr, std::string passwd) { //addrstr = "fd80:56c2:e21c:0:199:931d:b14:c4d2"; setup_password(passwd); gamename = addrstr; - if(wait_network()) - if(wait_firstpeer()) + if (wait_network()) + if (wait_firstpeer()) wait_join(); return (plr_self == PLR_BROADCAST ? MAX_PLRS : plr_self); } -template +template void base_protocol

::poll() { recv(); } -template +template void base_protocol

::send(packet &pkt) { - if(pkt.dest() < MAX_PLRS) { - if(pkt.dest() == myplr) + if (pkt.dest() < MAX_PLRS) { + if (pkt.dest() == myplr) return; - if(peers[pkt.dest()]) + if (peers[pkt.dest()]) proto.send(peers[pkt.dest()], pkt.data()); - } else if(pkt.dest() == PLR_BROADCAST) { + } else if (pkt.dest() == PLR_BROADCAST) { for (auto &peer : peers) - if(peer) + if (peer) proto.send(peer, pkt.data()); - } else if(pkt.dest() == PLR_MASTER) { + } else if (pkt.dest() == PLR_MASTER) { throw dvlnet_exception(); } else { throw dvlnet_exception(); } } -template +template void base_protocol

::recv() { try { @@ -191,7 +191,7 @@ void base_protocol

::recv() } } -template +template void base_protocol

::handle_join_request(packet &pkt, endpoint sender) { plr_t i; @@ -201,7 +201,7 @@ void base_protocol

::handle_join_request(packet &pkt, endpoint sender) break; } } - if(i >= MAX_PLRS) { + if (i >= MAX_PLRS) { //already full return; } @@ -218,7 +218,7 @@ void base_protocol

::handle_join_request(packet &pkt, endpoint sender) proto.send(sender, reply->data()); } -template +template void base_protocol

::recv_decrypted(packet &pkt, endpoint sender) { if (pkt.src() == PLR_BROADCAST && pkt.dest() == PLR_MASTER && pkt.type() == PT_INFO_REPLY) { @@ -231,20 +231,20 @@ void base_protocol

::recv_decrypted(packet &pkt, endpoint sender) recv_ingame(pkt, sender); } -template +template void base_protocol

::recv_ingame(packet &pkt, endpoint sender) { if (pkt.src() == PLR_BROADCAST && pkt.dest() == PLR_MASTER) { - if(pkt.type() == PT_JOIN_REQUEST) { + if (pkt.type() == PT_JOIN_REQUEST) { handle_join_request(pkt, sender); - } else if(pkt.type() == PT_INFO_REQUEST) { - if((plr_self != PLR_BROADCAST) && (get_master() == plr_self)) { + } else if (pkt.type() == PT_INFO_REQUEST) { + if ((plr_self != PLR_BROADCAST) && (get_master() == plr_self)) { buffer_t buf; buf.resize(gamename.size()); std::memcpy(buf.data(), &gamename[0], gamename.size()); auto reply = pktfty->make_packet(PLR_BROADCAST, - PLR_MASTER, - buf); + PLR_MASTER, + buf); proto.send_oob(sender, reply->data()); } } @@ -265,18 +265,18 @@ void base_protocol

::recv_ingame(packet &pkt, endpoint sender) recv_local(pkt); } -template +template std::vector base_protocol

::get_gamelist() { recv(); std::vector ret; - for (auto& s : game_list) { + for (auto &s : game_list) { ret.push_back(s.first); } return ret; } -template +template bool base_protocol

::SNetLeaveGame(int type) { auto ret = base::SNetLeaveGame(type); @@ -284,7 +284,7 @@ bool base_protocol

::SNetLeaveGame(int type) return ret; } -template +template std::string base_protocol

::make_default_gamename() { return proto.make_default_gamename(); diff --git a/Source/dvlnet/cdwrap.h b/Source/dvlnet/cdwrap.h index fa56c9be6..4ae0fe75a 100644 --- a/Source/dvlnet/cdwrap.h +++ b/Source/dvlnet/cdwrap.h @@ -161,7 +161,7 @@ bool cdwrap::SNetGetTurnsInTransit(DWORD *turns) template std::string cdwrap::make_default_gamename() { - return dvlnet_wrap->make_default_gamename(); + return dvlnet_wrap->make_default_gamename(); } } // namespace net diff --git a/Source/dvlnet/protocol_zt.cpp b/Source/dvlnet/protocol_zt.cpp index 88127ed31..369627806 100644 --- a/Source/dvlnet/protocol_zt.cpp +++ b/Source/dvlnet/protocol_zt.cpp @@ -36,45 +36,46 @@ void protocol_zt::set_nonblock(int fd) void protocol_zt::set_nodelay(int fd) { const int yes = 1; - lwip_setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, (void*)&yes, sizeof(yes)); + lwip_setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, (void *)&yes, sizeof(yes)); } void protocol_zt::set_reuseaddr(int fd) { const int yes = 1; - lwip_setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (void*)&yes, sizeof(yes)); + lwip_setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (void *)&yes, sizeof(yes)); } bool protocol_zt::network_online() { - if(!zerotier_network_ready()) + if (!zerotier_network_ready()) return false; - struct sockaddr_in6 in6{}; + struct sockaddr_in6 in6 { + }; in6.sin6_port = htons(default_port); in6.sin6_family = AF_INET6; in6.sin6_addr = in6addr_any; - if(fd_udp == -1) { + if (fd_udp == -1) { fd_udp = lwip_socket(AF_INET6, SOCK_DGRAM, 0); set_reuseaddr(fd_udp); auto ret = lwip_bind(fd_udp, (struct sockaddr *)&in6, sizeof(in6)); - if(ret < 0) { + if (ret < 0) { SDL_Log("lwip, (udp) bind: %s\n", strerror(errno)); throw protocol_exception(); } set_nonblock(fd_udp); } - if(fd_tcp == -1) { + if (fd_tcp == -1) { fd_tcp = lwip_socket(AF_INET6, SOCK_STREAM, 0); set_reuseaddr(fd_tcp); auto r1 = lwip_bind(fd_tcp, (struct sockaddr *)&in6, sizeof(in6)); - if(r1 < 0) { + if (r1 < 0) { SDL_Log("lwip, (tcp) bind: %s\n", strerror(errno)); throw protocol_exception(); } auto r2 = lwip_listen(fd_tcp, 10); - if(r2 < 0) { + if (r2 < 0) { SDL_Log("lwip, listen: %s\n", strerror(errno)); throw protocol_exception(); } @@ -84,15 +85,16 @@ bool protocol_zt::network_online() return true; } -bool protocol_zt::send(const endpoint& peer, const buffer_t& data) +bool protocol_zt::send(const endpoint &peer, const buffer_t &data) { peer_list[peer].send_queue.push_back(frame_queue::make_frame(data)); return true; } -bool protocol_zt::send_oob(const endpoint& peer, const buffer_t& data) +bool protocol_zt::send_oob(const endpoint &peer, const buffer_t &data) { - struct sockaddr_in6 in6{}; + struct sockaddr_in6 in6 { + }; in6.sin6_port = htons(default_port); in6.sin6_family = AF_INET6; std::copy(peer.addr.begin(), peer.addr.end(), in6.sin6_addr.s6_addr); @@ -100,35 +102,36 @@ bool protocol_zt::send_oob(const endpoint& peer, const buffer_t& data) return true; } -bool protocol_zt::send_oob_mc(const buffer_t& data) +bool protocol_zt::send_oob_mc(const buffer_t &data) { endpoint mc; - std::copy(dvl_multicast_addr, dvl_multicast_addr+16, mc.addr.begin()); + std::copy(dvl_multicast_addr, dvl_multicast_addr + 16, mc.addr.begin()); return send_oob(mc, data); } -bool protocol_zt::send_queued_peer(const endpoint& peer) +bool protocol_zt::send_queued_peer(const endpoint &peer) { - if(peer_list[peer].fd == -1) { + if (peer_list[peer].fd == -1) { peer_list[peer].fd = lwip_socket(AF_INET6, SOCK_STREAM, 0); set_nodelay(peer_list[peer].fd); set_nonblock(peer_list[peer].fd); - struct sockaddr_in6 in6{}; + struct sockaddr_in6 in6 { + }; in6.sin6_port = htons(default_port); in6.sin6_family = AF_INET6; std::copy(peer.addr.begin(), peer.addr.end(), in6.sin6_addr.s6_addr); lwip_connect(peer_list[peer].fd, (const struct sockaddr *)&in6, sizeof(in6)); } - while(!peer_list[peer].send_queue.empty()) { + while (!peer_list[peer].send_queue.empty()) { auto len = peer_list[peer].send_queue.front().size(); auto r = lwip_send(peer_list[peer].fd, peer_list[peer].send_queue.front().data(), len, 0); - if(r < 0) { + if (r < 0) { // handle error return false; } else if (decltype(len)(r) < len) { // partial send auto it = peer_list[peer].send_queue.front().begin(); - peer_list[peer].send_queue.front().erase(it, it+r); + peer_list[peer].send_queue.front().erase(it, it + r); return true; } else if (decltype(len)(r) == len) { peer_list[peer].send_queue.pop_front(); @@ -139,15 +142,15 @@ bool protocol_zt::send_queued_peer(const endpoint& peer) return true; } -bool protocol_zt::recv_peer(const endpoint& peer) +bool protocol_zt::recv_peer(const endpoint &peer) { unsigned char buf[PKTBUF_LEN]; - while(true) { + while (true) { auto len = lwip_recv(peer_list[peer].fd, buf, sizeof(buf), 0); - if(len >= 0) { - peer_list[peer].recv_queue.write(buffer_t(buf, buf+len)); + if (len >= 0) { + peer_list[peer].recv_queue.write(buffer_t(buf, buf + len)); } else { - if(errno == EAGAIN || errno == EWOULDBLOCK) { + if (errno == EAGAIN || errno == EWOULDBLOCK) { return true; } else { return false; @@ -158,8 +161,8 @@ bool protocol_zt::recv_peer(const endpoint& peer) bool protocol_zt::send_queued_all() { - for(auto& peer : peer_list) { - if(!send_queued_peer(peer.first)) { + for (auto &peer : peer_list) { + if (!send_queued_peer(peer.first)) { // disconnect this peer } } @@ -168,9 +171,9 @@ bool protocol_zt::send_queued_all() bool protocol_zt::recv_from_peers() { - for(auto& peer : peer_list) { - if(peer.second.fd != -1) { - if(!recv_peer(peer.first)) { + for (auto &peer : peer_list) { + if (peer.second.fd != -1) { + if (!recv_peer(peer.first)) { // error, disconnect? } } @@ -181,29 +184,31 @@ bool protocol_zt::recv_from_peers() bool protocol_zt::recv_from_udp() { unsigned char buf[PKTBUF_LEN]; - struct sockaddr_in6 in6{}; + struct sockaddr_in6 in6 { + }; socklen_t addrlen = sizeof(in6); auto len = lwip_recvfrom(fd_udp, buf, sizeof(buf), 0, (struct sockaddr *)&in6, &addrlen); - if(len < 0) + if (len < 0) return false; - buffer_t data(buf, buf+len); + buffer_t data(buf, buf + len); endpoint ep; - std::copy(in6.sin6_addr.s6_addr, in6.sin6_addr.s6_addr+16, ep.addr.begin()); + std::copy(in6.sin6_addr.s6_addr, in6.sin6_addr.s6_addr + 16, ep.addr.begin()); oob_recv_queue.push_back(std::make_pair(std::move(ep), std::move(data))); return true; } bool protocol_zt::accept_all() { - struct sockaddr_in6 in6{}; + struct sockaddr_in6 in6 { + }; socklen_t addrlen = sizeof(in6); - while(true) { + while (true) { auto newfd = lwip_accept(fd_tcp, (struct sockaddr *)&in6, &addrlen); - if(newfd < 0) + if (newfd < 0) break; endpoint ep; - std::copy(in6.sin6_addr.s6_addr, in6.sin6_addr.s6_addr+16, ep.addr.begin()); - if(peer_list[ep].fd != -1) { + 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"); lwip_close(peer_list[ep].fd); } @@ -214,22 +219,22 @@ bool protocol_zt::accept_all() return true; } -bool protocol_zt::recv(endpoint& peer, buffer_t& data) +bool protocol_zt::recv(endpoint &peer, buffer_t &data) { accept_all(); send_queued_all(); recv_from_peers(); recv_from_udp(); - if(!oob_recv_queue.empty()) { + if (!oob_recv_queue.empty()) { peer = oob_recv_queue.front().first; data = oob_recv_queue.front().second; oob_recv_queue.pop_front(); return true; } - for(auto& p : peer_list) { - if(p.second.recv_queue.packet_ready()) { + for (auto &p : peer_list) { + if (p.second.recv_queue.packet_ready()) { peer = p.first; data = p.second.recv_queue.read_packet(); return true; @@ -238,11 +243,11 @@ bool protocol_zt::recv(endpoint& peer, buffer_t& data) return false; } -void protocol_zt::disconnect(const endpoint& peer) +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) { + 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)); } } @@ -252,16 +257,16 @@ void protocol_zt::disconnect(const endpoint& peer) void protocol_zt::close_all() { - if(fd_tcp != -1) { + if (fd_tcp != -1) { lwip_close(fd_tcp); fd_tcp = -1; } - if(fd_udp != -1) { + if (fd_udp != -1) { lwip_close(fd_udp); fd_udp = -1; } - for(auto& i : peer_list) { - if(i.second.fd != -1) + for (auto &i : peer_list) { + if (i.second.fd != -1) lwip_close(i.second.fd); } peer_list.clear(); @@ -272,15 +277,15 @@ protocol_zt::~protocol_zt() close_all(); } -void protocol_zt::endpoint::from_string(const std::string& str) +void protocol_zt::endpoint::from_string(const std::string &str) { ip_addr_t a; - if(!ipaddr_aton(str.c_str(), &a)) + if (!ipaddr_aton(str.c_str(), &a)) return; - if(!IP_IS_V6_VAL(a)) + if (!IP_IS_V6_VAL(a)) return; - const unsigned char* r = reinterpret_cast(a.u_addr.ip6.addr); - std::copy(r, r+16, addr.begin()); + const unsigned char *r = reinterpret_cast(a.u_addr.ip6.addr); + std::copy(r, r + 16, addr.begin()); } uint64_t protocol_zt::current_ms() @@ -294,9 +299,9 @@ std::string protocol_zt::make_default_gamename() std::string allowed_chars = "abcdefghkopqrstuvwxyz"; std::random_device rd; std::uniform_int_distribution dist(0, allowed_chars.size() - 1); - for(int i = 0; i < 5; ++i) { + for (int i = 0; i < 5; ++i) { ret += allowed_chars.at(dist(rd)); - } + } return ret; } diff --git a/Source/dvlnet/protocol_zt.h b/Source/dvlnet/protocol_zt.h index d6d3ecaa8..dc4ee9c84 100644 --- a/Source/dvlnet/protocol_zt.h +++ b/Source/dvlnet/protocol_zt.h @@ -15,7 +15,7 @@ namespace devilution { namespace net { class protocol_exception : public std::exception { - public: +public: const char *what() const throw() override { return "Protocol error"; @@ -30,11 +30,11 @@ public: explicit operator bool() const { - auto empty = std::array{}; + auto empty = std::array {}; return (addr != empty); } - bool operator<(const endpoint& rhs) const + bool operator<(const endpoint &rhs) const { return addr < rhs.addr; } @@ -44,23 +44,23 @@ public: return buffer_t(addr.begin(), addr.end()); } - void unserialize(const buffer_t& buf) + void unserialize(const buffer_t &buf) { - if(buf.size() != 16) + if (buf.size() != 16) throw protocol_exception(); std::copy(buf.begin(), buf.end(), addr.begin()); } - void from_string(const std::string& str); + void from_string(const std::string &str); }; protocol_zt(); ~protocol_zt(); - void disconnect(const endpoint& peer); - bool send(const endpoint& peer, const buffer_t& data); - bool send_oob(const endpoint& peer, const buffer_t& data); - bool send_oob_mc(const buffer_t& data); - bool recv(endpoint& peer, buffer_t& data); + void disconnect(const endpoint &peer); + bool send(const endpoint &peer, const buffer_t &data); + bool send_oob(const endpoint &peer, const buffer_t &data); + bool send_oob_mc(const buffer_t &data); + bool recv(endpoint &peer, buffer_t &data); bool network_online(); std::string make_default_gamename(); @@ -87,8 +87,8 @@ private: void set_nodelay(int fd); void set_reuseaddr(int fd); - bool send_queued_peer(const endpoint& peer); - bool recv_peer(const endpoint& peer); + bool send_queued_peer(const endpoint &peer); + bool recv_peer(const endpoint &peer); bool send_queued_all(); bool recv_from_peers(); bool recv_from_udp(); diff --git a/Source/dvlnet/tcp_client.h b/Source/dvlnet/tcp_client.h index 1863cd1ef..a5f8815b3 100644 --- a/Source/dvlnet/tcp_client.h +++ b/Source/dvlnet/tcp_client.h @@ -28,6 +28,7 @@ public: virtual ~tcp_client(); virtual std::string make_default_gamename(); + private: frame_queue recv_queue; buffer_t recv_buffer = buffer_t(frame_queue::max_frame_size); diff --git a/Source/dvlnet/zerotier_lwip.cpp b/Source/dvlnet/zerotier_lwip.cpp index d6a151309..026826155 100644 --- a/Source/dvlnet/zerotier_lwip.cpp +++ b/Source/dvlnet/zerotier_lwip.cpp @@ -18,10 +18,10 @@ namespace devilution { namespace net { -void print_ip6_addr(void* x) +void print_ip6_addr(void *x) { char ipstr[INET6_ADDRSTRLEN]; - struct sockaddr_in6 *in = (struct sockaddr_in6*)x; + struct sockaddr_in6 *in = (struct 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); } @@ -36,5 +36,5 @@ void zt_ip6setup() UNLOCK_TCPIP_CORE(); } -} -} +} // namespace net +} // namespace devilution diff --git a/Source/dvlnet/zerotier_lwip.h b/Source/dvlnet/zerotier_lwip.h index 540fa5ded..13bf80990 100644 --- a/Source/dvlnet/zerotier_lwip.h +++ b/Source/dvlnet/zerotier_lwip.h @@ -1,8 +1,8 @@ namespace devilution { namespace net { -void print_ip6_addr(void* x); +void print_ip6_addr(void *x); void zt_ip6setup(); -} -} +} // namespace net +} // namespace devilution diff --git a/Source/dvlnet/zerotier_native.cpp b/Source/dvlnet/zerotier_native.cpp index d3c35896b..077b3f93c 100644 --- a/Source/dvlnet/zerotier_native.cpp +++ b/Source/dvlnet/zerotier_native.cpp @@ -30,21 +30,21 @@ static std::atomic_bool zt_joined(false); static void callback(struct zts_callback_msg *msg) { //printf("callback %i\n", msg->eventCode); - if(msg->eventCode == ZTS_EVENT_NODE_ONLINE) { + if (msg->eventCode == ZTS_EVENT_NODE_ONLINE) { SDL_Log("ZeroTier: ZTS_EVENT_NODE_ONLINE, nodeId=%llx\n", (unsigned long long)msg->node->address); zt_node_online = true; - if(!zt_joined) { + if (!zt_joined) { zts_join(zt_network); zt_joined = true; } - } else if(msg->eventCode == ZTS_EVENT_NODE_OFFLINE) { + } else if (msg->eventCode == ZTS_EVENT_NODE_OFFLINE) { SDL_Log("ZeroTier: ZTS_EVENT_NODE_OFFLINE\n"); zt_node_online = false; - } else if(msg->eventCode == ZTS_EVENT_NETWORK_READY_IP6) { + } 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); zt_ip6setup(); zt_network_ready = true; - } else if(msg->eventCode == ZTS_EVENT_ADDR_ADDED_IP6) { + } else if (msg->eventCode == ZTS_EVENT_ADDR_ADDED_IP6) { print_ip6_addr(&(msg->addr->addr)); } } @@ -61,11 +61,11 @@ void zerotier_network_stop() void zerotier_network_start() { - if(zt_started) + if (zt_started) return; - zts_start(GetPrefPath().c_str(), (void(*)(void*))callback, 0); + zts_start(GetPrefPath().c_str(), (void (*)(void *))callback, 0); std::atexit(zerotier_network_stop); } -} -} +} // namespace net +} // namespace devilution diff --git a/Source/dvlnet/zerotier_native.h b/Source/dvlnet/zerotier_native.h index 06512d5d2..66c40678a 100644 --- a/Source/dvlnet/zerotier_native.h +++ b/Source/dvlnet/zerotier_native.h @@ -9,9 +9,10 @@ void zerotier_network_stop(); // NOTE: We have patched our libzt to have the corresponding multicast // MAC hardcoded, since libzt is still missing the proper handling. -const unsigned char dvl_multicast_addr[16] = - {0xff, 0x0e, 0xa8, 0xa9, 0xb6, 0x11, 0x58, 0xce, - 0x04, 0x12, 0xfd, 0x73, 0x37, 0x86, 0x6f, 0xb7}; +const unsigned char dvl_multicast_addr[16] = { + 0xff, 0x0e, 0xa8, 0xa9, 0xb6, 0x11, 0x58, 0xce, + 0x04, 0x12, 0xfd, 0x73, 0x37, 0x86, 0x6f, 0xb7 +}; -} -} +} // namespace net +} // namespace devilution diff --git a/Source/dx.h b/Source/dx.h index 682bf5f6e..a52da3db9 100644 --- a/Source/dx.h +++ b/Source/dx.h @@ -22,4 +22,4 @@ void Blit(SDL_Surface *src, SDL_Rect *src_rect, SDL_Rect *dst_rect); void RenderPresent(); void PaletteGetEntries(DWORD dwNumEntries, SDL_Color *lpEntries); -} +} // namespace devilution diff --git a/Source/effects.h b/Source/effects.h index 6847d6aa3..53fa93a89 100644 --- a/Source/effects.h +++ b/Source/effects.h @@ -1081,4 +1081,4 @@ void ui_sound_init(); void effects_play_sound(const char *snd_file); int GetSFXLength(int nSFX); -} +} // namespace devilution diff --git a/Source/encrypt.h b/Source/encrypt.h index 2d1edda7f..e19e00d9e 100644 --- a/Source/encrypt.h +++ b/Source/encrypt.h @@ -26,4 +26,4 @@ void InitHash(); DWORD PkwareCompress(BYTE *srcData, DWORD size); void PkwareDecompress(BYTE *pbInBuff, int recv_size, int dwMaxBytes); -} +} // namespace devilution diff --git a/Source/enum_traits.h b/Source/enum_traits.h index 23d9edb56..134fd740c 100644 --- a/Source/enum_traits.h +++ b/Source/enum_traits.h @@ -55,4 +55,4 @@ typename enum_values::Iterator end(enum_values) return typename enum_values::Iterator(static_cast::type>(T::LAST) + 1); } -} +} // namespace devilution diff --git a/Source/error.h b/Source/error.h index 55b9cdbb7..a21f296bc 100644 --- a/Source/error.h +++ b/Source/error.h @@ -76,4 +76,4 @@ void InitDiabloMsg(diablo_message e); void ClrDiabloMsg(); void DrawDiabloMsg(CelOutputBuffer out); -} +} // namespace devilution diff --git a/Source/gendung.h b/Source/gendung.h index cc82f2aed..c55d7625b 100644 --- a/Source/gendung.h +++ b/Source/gendung.h @@ -184,4 +184,4 @@ void DRLG_HoldThemeRooms(); bool SkipThemeRoom(int x, int y); void InitLevels(); -} +} // namespace devilution diff --git a/Source/gmenu.h b/Source/gmenu.h index 734030828..31d484644 100644 --- a/Source/gmenu.h +++ b/Source/gmenu.h @@ -34,4 +34,4 @@ void gmenu_slider_set(TMenuItem *pItem, int min, int max, int gamma); int gmenu_slider_get(TMenuItem *pItem, int min, int max); void gmenu_slider_steps(TMenuItem *pItem, int dwTicks); -} +} // namespace devilution diff --git a/Source/help.h b/Source/help.h index f337422d9..19a51c09c 100644 --- a/Source/help.h +++ b/Source/help.h @@ -17,4 +17,4 @@ void DisplayHelp(); void HelpScrollUp(); void HelpScrollDown(); -} +} // namespace devilution diff --git a/Source/init.h b/Source/init.h index 87ebccd6d..4c77331fb 100644 --- a/Source/init.h +++ b/Source/init.h @@ -38,4 +38,4 @@ WNDPROC SetWindowProc(WNDPROC NewProc); extern char gszVersionNumber[64]; extern char gszProductName[64]; -} +} // namespace devilution diff --git a/Source/interfac.h b/Source/interfac.h index 75decd14b..a4851d143 100644 --- a/Source/interfac.h +++ b/Source/interfac.h @@ -46,4 +46,4 @@ void interface_msg_pump(); bool IncProgress(); void ShowProgress(interface_mode uMsg); -} +} // namespace devilution diff --git a/Source/inv.cpp b/Source/inv.cpp index 6e1aea33f..de57e502b 100644 --- a/Source/inv.cpp +++ b/Source/inv.cpp @@ -764,7 +764,6 @@ bool AutoPlaceItemInInventorySlot(int playerNumber, int slotIndex, const ItemStr return done; } - bool GoldAutoPlace(int pnum) { bool done = false; diff --git a/Source/itemdat.h b/Source/itemdat.h index aa743f460..a5a4a9b5b 100644 --- a/Source/itemdat.h +++ b/Source/itemdat.h @@ -599,4 +599,4 @@ extern const PLStruct PL_Prefix[]; extern const PLStruct PL_Suffix[]; extern const UItemStruct UniqueItemList[]; -} +} // namespace devilution diff --git a/Source/items.cpp b/Source/items.cpp index 9167789d3..53ea7baa3 100644 --- a/Source/items.cpp +++ b/Source/items.cpp @@ -2619,7 +2619,7 @@ void SpawnItem(int m, int x, int y, bool sendmsg) if (monster[m]._uniqtype || ((monster[m].MData->mTreasure & 0x8000) && gbIsMultiplayer)) { idx = RndUItem(m); if (idx < 0) { - SpawnUnique((_unique_items)-(idx + 1), x, y); + SpawnUnique((_unique_items) - (idx + 1), x, y); return; } onlygood = true; @@ -2631,7 +2631,7 @@ void SpawnItem(int m, int x, int y, bool sendmsg) idx--; onlygood = false; } else { - SpawnUnique((_unique_items)-(idx + 1), x, y); + SpawnUnique((_unique_items) - (idx + 1), x, y); return; } } else { @@ -4497,11 +4497,11 @@ static void SpawnOnePremium(int i, int plvl, int myplr) case ITYPE_MARMOR: case ITYPE_HARMOR: { const auto mostValuablePlayerArmor = plr[myplr].GetMostValuableItem( - [](const ItemStruct &item) { - return item._itype == ITYPE_LARMOR - || item._itype == ITYPE_MARMOR - || item._itype == ITYPE_HARMOR; - }); + [](const ItemStruct &item) { + return item._itype == ITYPE_LARMOR + || item._itype == ITYPE_MARMOR + || item._itype == ITYPE_HARMOR; + }); ivalue = mostValuablePlayerArmor == nullptr ? 0 : mostValuablePlayerArmor->_iIvalue; break; @@ -4516,7 +4516,7 @@ static void SpawnOnePremium(int i, int plvl, int myplr) case ITYPE_RING: case ITYPE_AMULET: { const auto mostValuablePlayerItem = plr[myplr].GetMostValuableItem( - [](const ItemStruct &item) { return item._itype == items[0]._itype; }); + [](const ItemStruct &item) { return item._itype == items[0]._itype; }); ivalue = mostValuablePlayerItem == nullptr ? 0 : mostValuablePlayerItem->_iIvalue; break; @@ -4528,12 +4528,14 @@ static void SpawnOnePremium(int i, int plvl, int myplr) ivalue *= 0.8; count++; - } while (keepgoing || ((items[0]._iIvalue > 200000 - || items[0]._iMinStr > strength - || items[0]._iMinMag > magic - || items[0]._iMinDex > dexterity - || items[0]._iIvalue < ivalue) - && count < 150)); + } while (keepgoing + || (( + items[0]._iIvalue > 200000 + || items[0]._iMinStr > strength + || items[0]._iMinMag > magic + || items[0]._iMinDex > dexterity + || items[0]._iIvalue < ivalue)) + && count < 150); premiumitem[i] = items[0]; premiumitem[i]._iCreateInfo = plvl | CF_SMITHPREMIUM; premiumitem[i]._iIdentified = true; @@ -4819,11 +4821,11 @@ void SpawnBoy(int lvl) case ITYPE_MARMOR: case ITYPE_HARMOR: { const auto mostValuablePlayerArmor = plr[myplr].GetMostValuableItem( - [](const ItemStruct &item) { - return item._itype == ITYPE_LARMOR - || item._itype == ITYPE_MARMOR - || item._itype == ITYPE_HARMOR; - }); + [](const ItemStruct &item) { + return item._itype == ITYPE_LARMOR + || item._itype == ITYPE_MARMOR + || item._itype == ITYPE_HARMOR; + }); ivalue = mostValuablePlayerArmor == nullptr ? 0 : mostValuablePlayerArmor->_iIvalue; break; @@ -4838,7 +4840,7 @@ void SpawnBoy(int lvl) case ITYPE_RING: case ITYPE_AMULET: { const auto mostValuablePlayerItem = plr[myplr].GetMostValuableItem( - [itemType](const ItemStruct &item) { return item._itype == itemType; }); + [itemType](const ItemStruct &item) { return item._itype == itemType; }); ivalue = mostValuablePlayerItem == nullptr ? 0 : mostValuablePlayerItem->_iIvalue; break; @@ -4876,12 +4878,14 @@ void SpawnBoy(int lvl) break; } } - } while (keepgoing || ((items[0]._iIvalue > 200000 - || items[0]._iMinStr > strength - || items[0]._iMinMag > magic - || items[0]._iMinDex > dexterity - || items[0]._iIvalue < ivalue) - && count < 250)); + } while (keepgoing + || (( + items[0]._iIvalue > 200000 + || items[0]._iMinStr > strength + || items[0]._iMinMag > magic + || items[0]._iMinDex > dexterity + || items[0]._iIvalue < ivalue) + && count < 250)); boyitem = items[0]; boyitem._iCreateInfo = lvl | CF_BOY; boyitem._iIdentified = true; diff --git a/Source/loadsave.cpp b/Source/loadsave.cpp index 6d48ec19c..4d37c2c71 100644 --- a/Source/loadsave.cpp +++ b/Source/loadsave.cpp @@ -1919,10 +1919,10 @@ void SaveGameData() file.writeLE(automapflag); file.writeBE(AutoMapScale); - } -void SaveGame() { +void SaveGame() +{ gbValidSaveFile = true; pfile_write_hero(/*write_game_data=*/true); } diff --git a/Source/loadsave.h b/Source/loadsave.h index 1ae031721..263560dea 100644 --- a/Source/loadsave.h +++ b/Source/loadsave.h @@ -31,4 +31,4 @@ void SaveGame(); void SaveLevel(); void LoadLevel(); -} +} // namespace devilution diff --git a/Source/mainmenu.h b/Source/mainmenu.h index 4e627a4d7..db7411b95 100644 --- a/Source/mainmenu.h +++ b/Source/mainmenu.h @@ -14,4 +14,4 @@ extern char gszHero[16]; bool mainmenu_select_hero_dialog(GameData *gameData); void mainmenu_loop(); -} +} // namespace devilution diff --git a/Source/minitext.h b/Source/minitext.h index b7904b3ce..35fedb2a0 100644 --- a/Source/minitext.h +++ b/Source/minitext.h @@ -25,4 +25,4 @@ void DrawQTextBack(CelOutputBuffer out); */ void DrawQText(CelOutputBuffer out); -} +} // namespace devilution diff --git a/Source/misdat.h b/Source/misdat.h index c94c9d3f1..9ef7d89be 100644 --- a/Source/misdat.h +++ b/Source/misdat.h @@ -115,4 +115,4 @@ typedef struct MisFileData { extern MissileData missiledata[]; extern MisFileData misfiledata[]; -} +} // namespace devilution diff --git a/Source/missiles.h b/Source/missiles.h index bdb8439f4..d9304ff44 100644 --- a/Source/missiles.h +++ b/Source/missiles.h @@ -239,4 +239,4 @@ void ProcessMissiles(); void missiles_process_charge(); void ClearMissileSpot(int mi); -} +} // namespace devilution diff --git a/Source/monstdat.h b/Source/monstdat.h index 2d6cdcc75..291ec4079 100644 --- a/Source/monstdat.h +++ b/Source/monstdat.h @@ -285,4 +285,4 @@ extern const _monster_id MonstConvTbl[]; extern const char MonstAvailTbl[]; extern const UniqMonstStruct UniqMonst[]; -} +} // namespace devilution diff --git a/Source/monster.cpp b/Source/monster.cpp index a75beb3a5..6db1b0f09 100644 --- a/Source/monster.cpp +++ b/Source/monster.cpp @@ -4030,7 +4030,7 @@ void MAI_Golum(int i) md = left[md]; for (j = 0; j < 8 && !ok; j++) { - md = right[md]; + md = right[md]; ok = DirOK(i, md); } if (ok) diff --git a/Source/monster.h b/Source/monster.h index 898a958d0..4cf05484f 100644 --- a/Source/monster.h +++ b/Source/monster.h @@ -97,9 +97,11 @@ enum monster_goal : uint8_t { }; enum placeflag : uint8_t { + // clang-format off PLACE_SCATTER = 1 << 0, PLACE_SPECIAL = 1 << 1, PLACE_UNIQUE = 1 << 2, + // clang-format on }; struct AnimStruct { @@ -334,4 +336,4 @@ extern direction opposite[8]; extern int offset_x[8]; extern int offset_y[8]; -} +} // namespace devilution diff --git a/Source/movie.h b/Source/movie.h index ce665dda2..af1bce6b3 100644 --- a/Source/movie.h +++ b/Source/movie.h @@ -14,4 +14,4 @@ extern bool loop_movie; void play_movie(const char *pszMovie, bool user_can_close); -} +} // namespace devilution diff --git a/Source/mpqapi.h b/Source/mpqapi.h index 4603858ed..8b764c964 100644 --- a/Source/mpqapi.h +++ b/Source/mpqapi.h @@ -46,4 +46,4 @@ bool mpqapi_has_file(const char *pszName); bool OpenMPQ(const char *pszArchive, DWORD dwChar); bool mpqapi_flush_and_close(const char *pszArchive, bool bFree, DWORD dwChar); -} +} // namespace devilution diff --git a/Source/msg.h b/Source/msg.h index 497cf1989..b7ec1ca3a 100644 --- a/Source/msg.h +++ b/Source/msg.h @@ -453,4 +453,4 @@ void NetSendCmdString(int pmask, const char *pszStr); void delta_close_portal(int pnum); DWORD ParseCmd(int pnum, TCmd *pCmd); -} +} // namespace devilution diff --git a/Source/multi.h b/Source/multi.h index 8b37fceb7..d3b6ba2af 100644 --- a/Source/multi.h +++ b/Source/multi.h @@ -63,4 +63,4 @@ bool multi_init_single(GameData *gameData); bool multi_init_multi(GameData *gameData, bool *pfExitProgram); void recv_plrinfo(int pnum, TCmdPlrInfoHdr *p, bool recv); -} +} // namespace devilution diff --git a/Source/nthread.h b/Source/nthread.h index e3d76e46f..f4740a975 100644 --- a/Source/nthread.h +++ b/Source/nthread.h @@ -33,4 +33,4 @@ bool nthread_has_500ms_passed(); */ void nthread_UpdateProgressToNextGameTick(); -} +} // namespace devilution diff --git a/Source/objdat.h b/Source/objdat.h index 4c02ca08c..9eceb86ce 100644 --- a/Source/objdat.h +++ b/Source/objdat.h @@ -249,4 +249,4 @@ extern const char *const ObjMasterLoadList[]; extern const char *ObjCryptLoadList[]; extern const char *ObjHiveLoadList[]; -} +} // namespace devilution diff --git a/Source/options.h b/Source/options.h index 97faf8a9b..7a7415980 100644 --- a/Source/options.h +++ b/Source/options.h @@ -102,7 +102,7 @@ struct ControllerOptions { bool bDpadHotkeys; /** @brief Shoulder gamepad shoulder buttons act as potions by default */ bool bSwapShoulderButtonMode; - /** @brief Configure gamepad joysticks deadzone */ + /** @brief Configure gamepad joysticks deadzone */ float fDeadzone; #ifdef __vita__ /** @brief Enable input via rear touchpad */ @@ -137,4 +137,4 @@ struct Options { extern Options sgOptions; -} +} // namespace devilution diff --git a/Source/pack.h b/Source/pack.h index de1bc3f23..342d91285 100644 --- a/Source/pack.h +++ b/Source/pack.h @@ -81,4 +81,4 @@ void UnPackPlayer(PkPlayerStruct *pPack, int pnum, bool netSync); void PackItem(PkItemStruct *id, const ItemStruct *is); void UnPackItem(const PkItemStruct *is, ItemStruct *id, bool isHellfire); -} +} // namespace devilution diff --git a/Source/palette.h b/Source/palette.h index f86dcb920..34a6900d5 100644 --- a/Source/palette.h +++ b/Source/palette.h @@ -52,4 +52,4 @@ void palette_update_crypt(); void palette_update_hive(); void palette_update_quest_palette(int n); -} +} // namespace devilution diff --git a/Source/path.h b/Source/path.h index 4f6d4e6a1..2cb7be26a 100644 --- a/Source/path.h +++ b/Source/path.h @@ -41,4 +41,4 @@ PATHNODE *path_new_step(); extern const char pathxdir[8]; extern const char pathydir[8]; -} +} // namespace devilution diff --git a/Source/platform/vita/keyboard.cpp b/Source/platform/vita/keyboard.cpp index adb529226..82bfeba4c 100644 --- a/Source/platform/vita/keyboard.cpp +++ b/Source/platform/vita/keyboard.cpp @@ -2,8 +2,8 @@ #include #include -#include -#include +#include +#include #include "platform/vita/keyboard.h" static void utf16_to_utf8(const uint16_t *src, uint8_t *dst) @@ -12,10 +12,10 @@ static void utf16_to_utf8(const uint16_t *src, uint8_t *dst) for (i = 0; src[i]; i++) { if ((src[i] & 0xFF80) == 0) { *(dst++) = src[i] & 0xFF; - } else if((src[i] & 0xF800) == 0) { + } else if ((src[i] & 0xF800) == 0) { *(dst++) = ((src[i] >> 6) & 0xFF) | 0xC0; *(dst++) = (src[i] & 0x3F) | 0x80; - } else if((src[i] & 0xFC00) == 0xD800 && (src[i + 1] & 0xFC00) == 0xDC00) { + } else if ((src[i] & 0xFC00) == 0xD800 && (src[i + 1] & 0xFC00) == 0xDC00) { *(dst++) = (((src[i] + 64) >> 8) & 0x3) | 0xF0; *(dst++) = (((src[i] >> 2) + 16) & 0x3F) | 0x80; *(dst++) = ((src[i] >> 4) & 0x30) | 0x80 | ((src[i + 1] << 2) & 0xF); @@ -52,7 +52,7 @@ static void utf8_to_utf16(const uint8_t *src, uint16_t *dst) static int vita_input_thread(void *ime_buffer) { - while(1) { + while (1) { // update IME status. Terminate, if finished SceCommonDialogStatus dialogStatus = sceImeDialogGetStatus(); if (dialogStatus == SCE_COMMON_DIALOG_STATUS_FINISHED) { @@ -63,12 +63,12 @@ static int vita_input_thread(void *ime_buffer) sceImeDialogGetResult(&result); // Convert UTF16 to UTF8 - utf16_to_utf8((SceWChar16*)ime_buffer, utf8_buffer); + utf16_to_utf8((SceWChar16 *)ime_buffer, utf8_buffer); // send sdl event SDL_Event event; event.text.type = SDL_TEXTINPUT; - SDL_utf8strlcpy(event.text.text, (const char*)utf8_buffer, SDL_arraysize(event.text.text)); + SDL_utf8strlcpy(event.text.text, (const char *)utf8_buffer, SDL_arraysize(event.text.text)); SDL_PushEvent(&event); sceImeDialogTerm(); @@ -86,8 +86,8 @@ static int vita_keyboard_get(const char *guide_text, const char *initial_text, i SDL_memset(&title, 0, sizeof(title)); SDL_memset(&text, 0, sizeof(text)); - utf8_to_utf16((const uint8_t*)guide_text, title); - utf8_to_utf16((const uint8_t*)initial_text, text); + utf8_to_utf16((const uint8_t *)guide_text, title); + utf8_to_utf16((const uint8_t *)initial_text, text); SceImeDialogParam param; sceImeDialogParamInit(¶m); @@ -116,5 +116,5 @@ void vita_start_text_input(const char *guide_text, const char *initial_text, int SceWChar16 ime_buffer[SCE_IME_DIALOG_MAX_TEXT_LENGTH]; if (vita_keyboard_get(guide_text, initial_text, max_length, ime_buffer)) { SDL_CreateThread(vita_input_thread, "vita_input_thread", (void *)ime_buffer); - } + } } diff --git a/Source/player.cpp b/Source/player.cpp index 51af1225c..de826868e 100644 --- a/Source/player.cpp +++ b/Source/player.cpp @@ -3699,7 +3699,7 @@ void ProcessPlayerAnimation(int pnum) } } -Sint32 GetFrameToUseForPlayerRendering(const PlayerStruct* pPlayer) +Sint32 GetFrameToUseForPlayerRendering(const PlayerStruct *pPlayer) { // Normal logic is used, // - if no frame-skipping is required and so we have exactly one Animationframe per GameTick (_pAnimUsedNumFrames = 0) @@ -3720,13 +3720,17 @@ Sint32 GetFrameToUseForPlayerRendering(const PlayerStruct* pPlayer) relevantAnimationLength = pPlayer->_pAnimLen; } float progressToNextGameTick = gfProgressToNextGameTick; - float totalGameTicksForCurrentAnimationSequence = progressToNextGameTick + (float)pPlayer->_pAnimGameTicksSinceSequenceStarted; // we don't use the processed game ticks alone but also the fragtion of the next game tick (if a rendering happens between game ticks). This helps to smooth the animations. + // we don't use the processed game ticks alone but also the fragtion of the next game tick (if a rendering happens between game ticks). This helps to smooth the animations. + float totalGameTicksForCurrentAnimationSequence = progressToNextGameTick + (float)pPlayer->_pAnimGameTicksSinceSequenceStarted; int animationMaxGameTickets = relevantAnimationLength; if (pPlayer->_pAnimDelay > 1) animationMaxGameTickets = (relevantAnimationLength * pPlayer->_pAnimDelay); - float gameTickModifier = (float)animationMaxGameTickets / (float)(relevantAnimationLength - pPlayer->_pAnimNumSkippedFrames); // if we skipped Frames we need to expand the GameTicks to make one GameTick for this Animation "faster" - int absolutAnimationFrame = 1 + (int)(totalGameTicksForCurrentAnimationSequence * gameTickModifier); // 1 added for rounding reasons. float to int cast always truncate. - if (absolutAnimationFrame > relevantAnimationLength) // this can happen if we are at the last frame and the next game tick is due (nthread_GetProgressToNextGameTick returns 1.0f) + // if we skipped Frames we need to expand the GameTicks to make one GameTick for this Animation "faster" + float gameTickModifier = (float)animationMaxGameTickets / (float)(relevantAnimationLength - pPlayer->_pAnimNumSkippedFrames); + // 1 added for rounding reasons. float to int cast always truncate. + int absolutAnimationFrame = 1 + (int)(totalGameTicksForCurrentAnimationSequence * gameTickModifier); + // this can happen if we are at the last frame and the next game tick is due (nthread_GetProgressToNextGameTick returns 1.0f) + if (absolutAnimationFrame > relevantAnimationLength) return relevantAnimationLength; if (absolutAnimationFrame <= 0) { SDL_Log("GetFrameToUseForPlayerRendering: Calculated an invalid Animation Frame"); diff --git a/Source/plrmsg.h b/Source/plrmsg.h index 404f26068..2e086458d 100644 --- a/Source/plrmsg.h +++ b/Source/plrmsg.h @@ -23,4 +23,4 @@ void ClearPlrMsg(); void InitPlrMsg(); void DrawPlrMsg(CelOutputBuffer out); -} +} // namespace devilution diff --git a/Source/portal.h b/Source/portal.h index 73d5ba630..073c348f9 100644 --- a/Source/portal.h +++ b/Source/portal.h @@ -36,4 +36,4 @@ void GetPortalLevel(); void GetPortalLvlPos(); bool PosOkPortal(int lvl, int x, int y); -} +} // namespace devilution diff --git a/Source/quests.h b/Source/quests.h index be81a1620..b667b287d 100644 --- a/Source/quests.h +++ b/Source/quests.h @@ -95,4 +95,4 @@ void SetMultiQuest(int q, quest_state s, int l, int v1); /* rdata */ extern QuestData questlist[]; -} +} // namespace devilution diff --git a/Source/render.cpp b/Source/render.cpp index e1c6e11a7..5a8b2b75b 100644 --- a/Source/render.cpp +++ b/Source/render.cpp @@ -437,7 +437,8 @@ inline void DoRenderLine(BYTE *dst, BYTE *src, int n, BYTE *tbl, DWORD mask) #if DVL_HAVE_ATTRIBUTE(always_inline) || (defined(__GNUC__) && !defined(__clang__)) __attribute__((always_inline)) #endif -inline void RenderLine(BYTE *dst_begin, BYTE *dst_end, BYTE **dst, BYTE **src, int n, BYTE *tbl, DWORD mask) +inline void +RenderLine(BYTE *dst_begin, BYTE *dst_end, BYTE **dst, BYTE **src, int n, BYTE *tbl, DWORD mask) { #ifdef NO_OVERDRAW if (*dst >= dst_begin && *dst <= dst_end) @@ -453,7 +454,8 @@ inline void RenderLine(BYTE *dst_begin, BYTE *dst_end, BYTE **dst, BYTE **src, i __attribute__((no_sanitize("shift-base"))) #endif -void RenderTile(CelOutputBuffer out, int x, int y) +void +RenderTile(CelOutputBuffer out, int x, int y) { int i, j; char c, v, tile; diff --git a/Source/scrollrt.h b/Source/scrollrt.h index 0c23c37fd..9eb86b2fc 100644 --- a/Source/scrollrt.h +++ b/Source/scrollrt.h @@ -61,4 +61,4 @@ void EnableFrameCount(); void scrollrt_draw_game_screen(bool draw_cursor); void DrawAndBlit(); -} +} // namespace devilution diff --git a/Source/setmaps.h b/Source/setmaps.h index 123826220..7016cbc25 100644 --- a/Source/setmaps.h +++ b/Source/setmaps.h @@ -13,4 +13,4 @@ void LoadSetMap(); /* rdata */ extern const char *const quest_level_names[]; -} +} // namespace devilution diff --git a/Source/sha.h b/Source/sha.h index 9d605b78c..e417e4952 100644 --- a/Source/sha.h +++ b/Source/sha.h @@ -22,4 +22,4 @@ void SHA1Result(int n, char Message_Digest[SHA1HashSize]); void SHA1Calculate(int n, const char *data, char Message_Digest[SHA1HashSize]); void SHA1Reset(int n); -} +} // namespace devilution diff --git a/Source/sound.h b/Source/sound.h index a57f0a737..f6a9faba1 100644 --- a/Source/sound.h +++ b/Source/sound.h @@ -57,4 +57,4 @@ extern bool gbMusicOn; extern bool gbSoundOn; extern bool gbDupSounds; -} +} // namespace devilution diff --git a/Source/spelldat.h b/Source/spelldat.h index b472cb33d..c86b38e56 100644 --- a/Source/spelldat.h +++ b/Source/spelldat.h @@ -219,4 +219,4 @@ struct SpellData { extern SpellData spelldata[]; -} +} // namespace devilution diff --git a/Source/spells.h b/Source/spells.h index 7e860a349..6374b2382 100644 --- a/Source/spells.h +++ b/Source/spells.h @@ -20,4 +20,4 @@ void DoHealOther(int pnum, int rid); int GetSpellBookLevel(spell_id s); int GetSpellStaffLevel(spell_id s); -} +} // namespace devilution diff --git a/Source/stores.h b/Source/stores.h index 43f99243f..43e1a9bdc 100644 --- a/Source/stores.h +++ b/Source/stores.h @@ -116,4 +116,4 @@ void STextEnter(); void CheckStoreBtn(); void ReleaseStoreBtn(); -} +} // namespace devilution diff --git a/Source/storm/storm.cpp b/Source/storm/storm.cpp index 3e5b9ec73..b6170aa77 100644 --- a/Source/storm/storm.cpp +++ b/Source/storm/storm.cpp @@ -277,15 +277,15 @@ bool getIniBool(const char *sectionName, const char *keyName, bool defaultValue) float getIniFloat(const char *sectionName, const char *keyName, float defaultValue) { - radon::Section *section = getIni().getSection(sectionName); - if (!section) - return defaultValue; + radon::Section *section = getIni().getSection(sectionName); + if (!section) + return defaultValue; - radon::Key *key = section->getKey(keyName); - if (!key) - return defaultValue; + radon::Key *key = section->getKey(keyName); + if (!key) + return defaultValue; - return key->getFloatValue(); + return key->getFloatValue(); } bool getIniValue(const char *sectionName, const char *keyName, char *string, int stringSize, const char *defaultString) diff --git a/Source/storm/storm.h b/Source/storm/storm.h index 7b29a7298..a0e0f719d 100644 --- a/Source/storm/storm.h +++ b/Source/storm/storm.h @@ -103,10 +103,10 @@ struct CCritSect { // Game states #define GAMESTATE_PRIVATE 0x01 -#define GAMESTATE_FULL 0x02 -#define GAMESTATE_ACTIVE 0x04 +#define GAMESTATE_FULL 0x02 +#define GAMESTATE_ACTIVE 0x04 #define GAMESTATE_STARTED 0x08 -#define GAMESTATE_REPLAY 0x80 +#define GAMESTATE_REPLAY 0x80 #define PS_CONNECTED 0x10000 #define PS_TURN_ARRIVED 0x20000 @@ -155,9 +155,8 @@ bool SNetGetGameInfo(game_info type, void *dst, unsigned int length); * * Returns true if the function was called successfully and false otherwise. */ -bool - SNetGetTurnsInTransit( - DWORD *turns); +bool SNetGetTurnsInTransit( + DWORD *turns); // Network provider structures typedef struct _client_info { @@ -202,7 +201,7 @@ bool SNetPerformUpgrade(DWORD *upgradestatus); bool SNetReceiveMessage(int *senderplayerid, char **data, int *databytes); bool SNetReceiveTurns(int a1, int arraysize, char **arraydata, DWORD *arraydatabytes, DWORD *arrayplayerstatus); -typedef void(*SEVTHANDLER)(struct _SNETEVENT *); +typedef void (*SEVTHANDLER)(struct _SNETEVENT *); /* SNetSendMessage @ 127 * @@ -222,7 +221,7 @@ typedef void(*SEVTHANDLER)(struct _SNETEVENT *); bool SNetSendMessage(int playerID, void *data, unsigned int databytes); // Macro values to target specific players -#define SNPLAYER_ALL -1 +#define SNPLAYER_ALL -1 #define SNPLAYER_OTHERS -2 #define MPQ_FLAG_READ_ONLY 1 @@ -250,7 +249,7 @@ bool WINAPI SFileCloseArchive(HANDLE hArchive); bool WINAPI SFileOpenFileEx(HANDLE hMpq, const char *szFileName, DWORD dwSearchScope, HANDLE *phFile); bool WINAPI SFileReadFile(HANDLE hFile, void *buffer, DWORD nNumberOfBytesToRead, DWORD *read, LONG *lpDistanceToMoveHigh); DWORD WINAPI SFileGetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh); -DWORD WINAPI SFileSetFilePointer(HANDLE, int, int*, int); +DWORD WINAPI SFileSetFilePointer(HANDLE, int, int *, int); bool WINAPI SFileCloseFile(HANDLE hFile); /* SBmpLoadImage @ 323 @@ -267,15 +266,14 @@ bool WINAPI SFileCloseFile(HANDLE hFile); * * Returns true if the image was supported and loaded correctly, false otherwise. */ -bool - SBmpLoadImage( - const char *pszFileName, - SDL_Color *pPalette, - BYTE *pBuffer, - DWORD dwBuffersize, - DWORD *pdwWidth, - DWORD *pdwHeight, - DWORD *pdwBpp); +bool SBmpLoadImage( + const char *pszFileName, + SDL_Color *pPalette, + BYTE *pBuffer, + DWORD dwBuffersize, + DWORD *pdwWidth, + DWORD *pdwHeight, + DWORD *pdwBpp); bool getIniBool(const char *sectionName, const char *keyName, bool defaultValue = false); float getIniFloat(const char *sectionName, const char *keyName, float defaultValue); @@ -318,11 +316,11 @@ DWORD SErrGetLastError(); void SErrSetLastError(DWORD dwErrCode); // Values for dwErrCode -#define STORM_ERROR_GAME_TERMINATED 0x85100069 -#define STORM_ERROR_INVALID_PLAYER 0x8510006a -#define STORM_ERROR_NO_MESSAGES_WAITING 0x8510006b -#define STORM_ERROR_NOT_IN_GAME 0x85100070 -#define STORM_ERROR_REQUIRES_UPGRADE 0x85100077 +#define STORM_ERROR_GAME_TERMINATED 0x85100069 +#define STORM_ERROR_INVALID_PLAYER 0x8510006a +#define STORM_ERROR_NO_MESSAGES_WAITING 0x8510006b +#define STORM_ERROR_NOT_IN_GAME 0x85100070 +#define STORM_ERROR_REQUIRES_UPGRADE 0x85100077 /* SStrCopy @ 501 * @@ -354,18 +352,18 @@ bool SFileEnableDirectAccess(bool enable); // Sets the file's 64-bit seek position. inline std::uint64_t SFileSetFilePointer(HANDLE hFile, std::int64_t offset, int whence) { - int high = static_cast(offset) >> 32; - int low = static_cast(offset); - low = SFileSetFilePointer(hFile, low, &high, whence); - return (static_cast(high) << 32) | low; + int high = static_cast(offset) >> 32; + int low = static_cast(offset); + low = SFileSetFilePointer(hFile, low, &high, whence); + return (static_cast(high) << 32) | low; } // Returns the current 64-bit file seek position. inline std::uint64_t SFileGetFilePointer(HANDLE hFile) { - // We use `SFileSetFilePointer` with offset 0 to get the current position - // because there is no `SFileGetFilePointer`. - return SFileSetFilePointer(hFile, 0, DVL_FILE_CURRENT); + // We use `SFileSetFilePointer` with offset 0 to get the current position + // because there is no `SFileGetFilePointer`. + return SFileSetFilePointer(hFile, 0, DVL_FILE_CURRENT); } #endif diff --git a/Source/sync.h b/Source/sync.h index d6f093069..709992fa9 100644 --- a/Source/sync.h +++ b/Source/sync.h @@ -11,4 +11,4 @@ Uint32 sync_all_monsters(const Uint8 *pbBuf, Uint32 dwMaxLen); Uint32 sync_update(int pnum, const Uint8 *pbBuf); void sync_init(); -} +} // namespace devilution diff --git a/Source/themes.h b/Source/themes.h index b0d93c551..bf52d6ddb 100644 --- a/Source/themes.h +++ b/Source/themes.h @@ -25,4 +25,4 @@ void InitThemes(); void HoldThemeRooms(); void CreateThemeRooms(); -} +} // namespace devilution diff --git a/Source/tmsg.h b/Source/tmsg.h index 59591883b..4b0d4946b 100644 --- a/Source/tmsg.h +++ b/Source/tmsg.h @@ -29,4 +29,4 @@ void tmsg_add(Uint8 *pbMsg, Uint8 bLen); void tmsg_start(); void tmsg_cleanup(); -} +} // namespace devilution diff --git a/Source/town.h b/Source/town.h index dce14daa4..71f0b109c 100644 --- a/Source/town.h +++ b/Source/town.h @@ -14,4 +14,4 @@ void TownOpenHive(); void TownOpenGrave(); void CreateTown(lvl_entry entry); -} +} // namespace devilution diff --git a/Source/towners.h b/Source/towners.h index fa81a419c..c300da0b0 100644 --- a/Source/towners.h +++ b/Source/towners.h @@ -43,8 +43,8 @@ struct TownerStruct { uint8_t *_tNData; uint8_t *_tAnimData; int16_t _tSeed; - int16_t _tx; // Tile X-position of NPC - int16_t _ty; // Tile Y-position of NPC + int16_t _tx; // Tile X-position of NPC + int16_t _ty; // Tile Y-position of NPC int16_t _tAnimWidth; int16_t _tAnimWidth2; int16_t _tAnimDelay; // Tick length of each frame in the current animation diff --git a/Source/track.h b/Source/track.h index 57220c673..e83475002 100644 --- a/Source/track.h +++ b/Source/track.h @@ -11,4 +11,4 @@ void track_process(); void track_repeat_walk(bool rep); bool track_isscrolling(); -} +} // namespace devilution diff --git a/Source/trigs.h b/Source/trigs.h index 629e7db91..9008e2504 100644 --- a/Source/trigs.h +++ b/Source/trigs.h @@ -37,4 +37,4 @@ void Freeupstairs(); void CheckTrigForce(); void CheckTriggers(); -} +} // namespace devilution diff --git a/Source/utils/paths.cpp b/Source/utils/paths.cpp index ab178540d..85cbcb01f 100644 --- a/Source/utils/paths.cpp +++ b/Source/utils/paths.cpp @@ -27,24 +27,24 @@ std::string *ttfName = NULL; void AddTrailingSlash(std::string *path) { #ifdef _WIN32 - if (!path->empty() && path->back() != '\\') - *path += '\\'; + if (!path->empty() && path->back() != '\\') + *path += '\\'; #else - if (!path->empty() && path->back() != '/') - *path += '/'; + if (!path->empty() && path->back() != '/') + *path += '/'; #endif } std::string *FromSDL(char *s) { - std::string *result = new std::string(s != NULL ? s : ""); - if (s != NULL) { - SDL_free(s); - } else { - SDL_Log("%s", SDL_GetError()); - SDL_ClearError(); - } - return result; + std::string *result = new std::string(s != NULL ? s : ""); + if (s != NULL) { + SDL_free(s); + } else { + SDL_Log("%s", SDL_GetError()); + SDL_ClearError(); + } + return result; } } // namespace diff --git a/Source/utils/sdl2_backports.h b/Source/utils/sdl2_backports.h index 30697deee..2b5bd9dd2 100644 --- a/Source/utils/sdl2_backports.h +++ b/Source/utils/sdl2_backports.h @@ -10,8 +10,10 @@ #if !SDL_VERSION_ATLEAST(2, 0, 4) inline SDL_bool SDL_PointInRect(const SDL_Point *p, const SDL_Rect *r) { - return ( (p->x >= r->x) && (p->x < (r->x + r->w)) && - (p->y >= r->y) && (p->y < (r->y + r->h)) ) ? SDL_TRUE : SDL_FALSE; + return ((p->x >= r->x) && (p->x < (r->x + r->w)) + && (p->y >= r->y) && (p->y < (r->y + r->h))) + ? SDL_TRUE + : SDL_FALSE; } #endif diff --git a/Source/utils/sdl2_to_1_2_backports.h b/Source/utils/sdl2_to_1_2_backports.h index eeb61c3dc..ba4b9adf3 100644 --- a/Source/utils/sdl2_to_1_2_backports.h +++ b/Source/utils/sdl2_to_1_2_backports.h @@ -55,26 +55,25 @@ #define SDL_JoystickNameForIndex SDL_JoystickName enum SDL_LogCategory { - SDL_LOG_CATEGORY_APPLICATION, - SDL_LOG_CATEGORY_ERROR, - SDL_LOG_CATEGORY_ASSERT, - SDL_LOG_CATEGORY_SYSTEM, - SDL_LOG_CATEGORY_AUDIO, - SDL_LOG_CATEGORY_VIDEO, - SDL_LOG_CATEGORY_RENDER, - SDL_LOG_CATEGORY_INPUT, - SDL_LOG_CATEGORY_TEST, + SDL_LOG_CATEGORY_APPLICATION, + SDL_LOG_CATEGORY_ERROR, + SDL_LOG_CATEGORY_ASSERT, + SDL_LOG_CATEGORY_SYSTEM, + SDL_LOG_CATEGORY_AUDIO, + SDL_LOG_CATEGORY_VIDEO, + SDL_LOG_CATEGORY_RENDER, + SDL_LOG_CATEGORY_INPUT, + SDL_LOG_CATEGORY_TEST, }; -enum SDL_LogPriority -{ - SDL_LOG_PRIORITY_VERBOSE = 1, - SDL_LOG_PRIORITY_DEBUG, - SDL_LOG_PRIORITY_INFO, - SDL_LOG_PRIORITY_WARN, - SDL_LOG_PRIORITY_ERROR, - SDL_LOG_PRIORITY_CRITICAL, - SDL_NUM_LOG_PRIORITIES +enum SDL_LogPriority { + SDL_LOG_PRIORITY_VERBOSE = 1, + SDL_LOG_PRIORITY_DEBUG, + SDL_LOG_PRIORITY_INFO, + SDL_LOG_PRIORITY_WARN, + SDL_LOG_PRIORITY_ERROR, + SDL_LOG_PRIORITY_CRITICAL, + SDL_NUM_LOG_PRIORITIES }; void SDL_Log(const char *fmt, ...) DVL_PRINTF_ATTRIBUTE(1, 2); diff --git a/Source/utils/stubs.h b/Source/utils/stubs.h index cd7259173..dc8dc6516 100644 --- a/Source/utils/stubs.h +++ b/Source/utils/stubs.h @@ -4,16 +4,16 @@ #include #include -#define UNIMPLEMENTED() \ - do { \ +#define UNIMPLEMENTED() \ + do { \ SDL_Log("UNIMPLEMENTED: %s @ %s:%d", __FUNCTION__, __FILE__, __LINE__); \ - abort(); \ + abort(); \ } while (0) -#define ABORT() \ - do { \ +#define ABORT() \ + do { \ SDL_Log("ABORT: %s @ %s:%d", __FUNCTION__, __FILE__, __LINE__); \ - abort(); \ + abort(); \ } while (0) #define ASSERT(x) \