4 changed files with 188 additions and 188 deletions
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -1,62 +1,62 @@
|
||||
/**
|
||||
* @file common.h |
||||
* |
||||
* Common functions for QoL features |
||||
*/ |
||||
|
||||
#include <SDL.h> |
||||
|
||||
#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<BYTE>(*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 <SDL.h> |
||||
|
||||
#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<BYTE>(*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
|
||||
|
||||
@ -1,52 +1,52 @@
|
||||
/**
|
||||
* @file common.h |
||||
* |
||||
* Common functions for QoL features |
||||
*/ |
||||
#pragma once |
||||
|
||||
#include <SDL.h> |
||||
|
||||
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 <SDL.h> |
||||
|
||||
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
|
||||
|
||||
Loading…
Reference in new issue