From 825783780158e0409eae0c683dd3a89757dee2dd Mon Sep 17 00:00:00 2001 From: Gleb Mazovetskiy Date: Sat, 1 May 2021 22:24:35 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20Fix=20line=20endings=20in=20Sour?= =?UTF-8?q?ce/qol/*?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/qol/autopickup.cpp | 122 ++++++++++++++++++------------------- Source/qol/autopickup.h | 26 ++++---- Source/qol/common.cpp | 124 +++++++++++++++++++------------------- Source/qol/common.h | 104 ++++++++++++++++---------------- 4 files changed, 188 insertions(+), 188 deletions(-) diff --git a/Source/qol/autopickup.cpp b/Source/qol/autopickup.cpp index 431d3e589..05e953f57 100644 --- a/Source/qol/autopickup.cpp +++ b/Source/qol/autopickup.cpp @@ -1,61 +1,61 @@ -/** -* @file autopickup.cpp -* -* QoL feature for automatically picking up gold -*/ - -#include "options.h" -#include "player.h" - -namespace devilution { -namespace { - -bool HasRoomForGold() -{ - for (int idx : plr[myplr].InvGrid) { - // Secondary item cell. No need to check those as we'll go through the main item cells anyway. - if (idx < 0) - continue; - - // Empty cell. 1x1 space available. - if (idx == 0) - return true; - - // Main item cell. Potentially a gold pile so check it. - auto item = plr[myplr].InvList[idx - 1]; - if (item._itype == ITYPE_GOLD && item._ivalue < MaxGold) - return true; - } - - return false; -} - -} // namespace - -void AutoGoldPickup(int pnum) -{ - if (!sgOptions.Gameplay.bAutoGoldPickup) - return; - - if (pnum != myplr) - return; - if (leveltype == DTYPE_TOWN) - return; - if (!HasRoomForGold()) - return; - - for (int dir = 0; dir < 8; dir++) { - int x = plr[pnum].position.tile.x + pathxdir[dir]; - int y = plr[pnum].position.tile.y + pathydir[dir]; - if (dItem[x][y] != 0) { - int itemIndex = dItem[x][y] - 1; - if (items[itemIndex]._itype == ITYPE_GOLD) { - NetSendCmdGItem(true, CMD_REQUESTAGITEM, pnum, pnum, itemIndex); - items[itemIndex]._iRequest = true; - PlaySFX(IS_IGRAB); - } - } - } -} - -} // namespace devilution +/** +* @file autopickup.cpp +* +* QoL feature for automatically picking up gold +*/ + +#include "options.h" +#include "player.h" + +namespace devilution { +namespace { + +bool HasRoomForGold() +{ + for (int idx : plr[myplr].InvGrid) { + // Secondary item cell. No need to check those as we'll go through the main item cells anyway. + if (idx < 0) + continue; + + // Empty cell. 1x1 space available. + if (idx == 0) + return true; + + // Main item cell. Potentially a gold pile so check it. + auto item = plr[myplr].InvList[idx - 1]; + if (item._itype == ITYPE_GOLD && item._ivalue < MaxGold) + return true; + } + + return false; +} + +} // namespace + +void AutoGoldPickup(int pnum) +{ + if (!sgOptions.Gameplay.bAutoGoldPickup) + return; + + if (pnum != myplr) + return; + if (leveltype == DTYPE_TOWN) + return; + if (!HasRoomForGold()) + return; + + for (int dir = 0; dir < 8; dir++) { + int x = plr[pnum].position.tile.x + pathxdir[dir]; + int y = plr[pnum].position.tile.y + pathydir[dir]; + if (dItem[x][y] != 0) { + int itemIndex = dItem[x][y] - 1; + if (items[itemIndex]._itype == ITYPE_GOLD) { + NetSendCmdGItem(true, CMD_REQUESTAGITEM, pnum, pnum, itemIndex); + items[itemIndex]._iRequest = true; + PlaySFX(IS_IGRAB); + } + } + } +} + +} // namespace devilution diff --git a/Source/qol/autopickup.h b/Source/qol/autopickup.h index 6c941a478..7806c2d58 100644 --- a/Source/qol/autopickup.h +++ b/Source/qol/autopickup.h @@ -1,13 +1,13 @@ -/** -* @file autopickup.h -* -* QoL feature for automatically picking up gold -*/ - -#pragma once - -namespace devilution { - -void AutoGoldPickup(int pnum); - -} // namespace devilution +/** +* @file autopickup.h +* +* QoL feature for automatically picking up gold +*/ + +#pragma once + +namespace devilution { + +void AutoGoldPickup(int pnum); + +} // namespace devilution diff --git a/Source/qol/common.cpp b/Source/qol/common.cpp index 78b7c0feb..50eba0360 100644 --- a/Source/qol/common.cpp +++ b/Source/qol/common.cpp @@ -1,62 +1,62 @@ -/** -* @file common.h -* -* Common functions for QoL features -*/ - -#include - -#include "common.h" -#include "control.h" -#include "engine.h" -#include "qol/monhealthbar.h" -#include "qol/xpbar.h" - -namespace devilution { - -int GetTextWidth(const char *s) -{ - int l = 0; - while (*s) { - l += fontkern[fontframe[gbFontTransTbl[static_cast(*s++)]]] + 1; - } - return l; -} - -void FastDrawHorizLine(const CelOutputBuffer &out, int x, int y, int width, Uint8 col) -{ - memset(out.at(x, y), col, width); -} - -void FastDrawVertLine(const CelOutputBuffer &out, int x, int y, int height, Uint8 col) -{ - BYTE *p = out.at(x, y); - for (int j = 0; j < height; j++) { - *p = col; - p += out.pitch(); - } -} - -char *PrintWithSeparator(char *out, long long n) -{ - if (n < 1000) { - return out + sprintf(out, "%lld", n); - } - - char *append = PrintWithSeparator(out, n / 1000); - return append + sprintf(append, ",%03lld", n % 1000); -} - -void FreeQol() -{ - FreeMonsterHealthBar(); - FreeXPBar(); -} - -void InitQol() -{ - InitMonsterHealthBar(); - InitXPBar(); -} - -} // namespace devilution +/** +* @file common.h +* +* Common functions for QoL features +*/ + +#include + +#include "common.h" +#include "control.h" +#include "engine.h" +#include "qol/monhealthbar.h" +#include "qol/xpbar.h" + +namespace devilution { + +int GetTextWidth(const char *s) +{ + int l = 0; + while (*s) { + l += fontkern[fontframe[gbFontTransTbl[static_cast(*s++)]]] + 1; + } + return l; +} + +void FastDrawHorizLine(const CelOutputBuffer &out, int x, int y, int width, Uint8 col) +{ + memset(out.at(x, y), col, width); +} + +void FastDrawVertLine(const CelOutputBuffer &out, int x, int y, int height, Uint8 col) +{ + BYTE *p = out.at(x, y); + for (int j = 0; j < height; j++) { + *p = col; + p += out.pitch(); + } +} + +char *PrintWithSeparator(char *out, long long n) +{ + if (n < 1000) { + return out + sprintf(out, "%lld", n); + } + + char *append = PrintWithSeparator(out, n / 1000); + return append + sprintf(append, ",%03lld", n % 1000); +} + +void FreeQol() +{ + FreeMonsterHealthBar(); + FreeXPBar(); +} + +void InitQol() +{ + InitMonsterHealthBar(); + InitXPBar(); +} + +} // namespace devilution diff --git a/Source/qol/common.h b/Source/qol/common.h index 58bfe5019..b429f70bc 100644 --- a/Source/qol/common.h +++ b/Source/qol/common.h @@ -1,52 +1,52 @@ -/** -* @file common.h -* -* Common functions for QoL features -*/ -#pragma once - -#include - -namespace devilution { - -struct CelOutputBuffer; - -/** - * @brief Return width (in pixels) of the passed in string, when printed with smaltext.cel. Does not consider line breaks. - * @param s String for which to compute width - * @return Pixel width of the string -*/ -int GetTextWidth(const char *s); - -/** - * @brief Quickly draw a horizontal line (via memset). Does not clip to output buffer. - * @param out Destination buffer - * @param x Start X coordinate (left end) - * @param y Vertical location of line - * @param width Number of pixels to fill - * @param col Color index to use for filling -*/ -void FastDrawHorizLine(const CelOutputBuffer &out, int x, int y, int width, Uint8 col); - -/** - * @brief Quickly draw a vertical line. Does not clip to output buffer. - * @param out Destination buffer - * @param x Horizontal location of line - * @param y Start Y coordinate (top end) - * @param height Number of pixels to fill - * @param col Color index to use for filling -*/ -void FastDrawVertLine(const CelOutputBuffer &out, int x, int y, int height, Uint8 col); - -/** - * @brief Prints integer into buffer, using ',' as thousands separator. - * @param out Destination buffer - * @param n Number to print - * @return Address of first character after printed number -*/ -char *PrintWithSeparator(char *out, long long n); - -void FreeQol(); -void InitQol(); - -} // namespace devilution +/** +* @file common.h +* +* Common functions for QoL features +*/ +#pragma once + +#include + +namespace devilution { + +struct CelOutputBuffer; + +/** + * @brief Return width (in pixels) of the passed in string, when printed with smaltext.cel. Does not consider line breaks. + * @param s String for which to compute width + * @return Pixel width of the string +*/ +int GetTextWidth(const char *s); + +/** + * @brief Quickly draw a horizontal line (via memset). Does not clip to output buffer. + * @param out Destination buffer + * @param x Start X coordinate (left end) + * @param y Vertical location of line + * @param width Number of pixels to fill + * @param col Color index to use for filling +*/ +void FastDrawHorizLine(const CelOutputBuffer &out, int x, int y, int width, Uint8 col); + +/** + * @brief Quickly draw a vertical line. Does not clip to output buffer. + * @param out Destination buffer + * @param x Horizontal location of line + * @param y Start Y coordinate (top end) + * @param height Number of pixels to fill + * @param col Color index to use for filling +*/ +void FastDrawVertLine(const CelOutputBuffer &out, int x, int y, int height, Uint8 col); + +/** + * @brief Prints integer into buffer, using ',' as thousands separator. + * @param out Destination buffer + * @param n Number to print + * @return Address of first character after printed number +*/ +char *PrintWithSeparator(char *out, long long n); + +void FreeQol(); +void InitQol(); + +} // namespace devilution