Browse Source

Fix windows build

pull/3901/head
Gleb Mazovetskiy 4 years ago
parent
commit
e12adf689e
  1. 1
      Source/CMakeLists.txt
  2. 28
      Source/engine/direction.cpp
  3. 4
      Source/engine/direction.hpp
  4. 37
      Source/itemdat.cpp
  5. 3
      Source/itemdat.h
  6. 6
      Source/scrollrt.cpp

1
Source/CMakeLists.txt

@ -82,6 +82,7 @@ set(libdevilutionx_SRCS
controls/plrctrls.cpp
engine/animationinfo.cpp
engine/demomode.cpp
engine/direction.cpp
engine/load_cel.cpp
engine/random.cpp
engine/render/automap_render.cpp

28
Source/engine/direction.cpp

@ -0,0 +1,28 @@
#include "engine/direction.hpp"
namespace devilution {
string_view DirectionToString(Direction direction)
{
switch (direction) {
case Direction::South:
return "South";
case Direction::SouthWest:
return "SouthWest";
case Direction::West:
return "West";
case Direction::NorthWest:
return "NorthWest";
case Direction::North:
return "North";
case Direction::NorthEast:
return "NorthEast";
case Direction::East:
return "East";
case Direction::SouthEast:
return "SouthEast";
}
return "";
}
} // namespace devilution

4
Source/engine/direction.hpp

@ -3,6 +3,8 @@
#include <cstdint>
#include <type_traits>
#include "utils/stdcompat/string_view.hpp"
namespace devilution {
enum class Direction : std::uint8_t {
@ -37,4 +39,6 @@ constexpr Direction Opposite(Direction facing)
return static_cast<Direction>((static_cast<std::underlying_type_t<Direction>>(facing) + 4) % 8);
}
string_view DirectionToString(Direction direction);
} // namespace devilution

37
Source/itemdat.cpp

@ -9,6 +9,43 @@
namespace devilution {
string_view ItemTypeToString(ItemType itemType)
{
switch (itemType) {
case ItemType::Misc:
return "Misc";
case ItemType::Sword:
return "Sword";
case ItemType::Axe:
return "Axe";
case ItemType::Bow:
return "Bow";
case ItemType::Mace:
return "Mace";
case ItemType::Shield:
return "Shield";
case ItemType::LightArmor:
return "LightArmor";
case ItemType::Helm:
return "Helm";
case ItemType::MediumArmor:
return "MediumArmor";
case ItemType::HeavyArmor:
return "HeavyArmor";
case ItemType::Staff:
return "Staff";
case ItemType::Gold:
return "Gold";
case ItemType::Ring:
return "Ring";
case ItemType::Amulet:
return "Amulet";
case ItemType::None:
return "None";
}
return "";
}
/** Contains the data related to each item ID. */
ItemData AllItemsList[] = {
// clang-format off

3
Source/itemdat.h

@ -9,6 +9,7 @@
#include "objdat.h"
#include "spelldat.h"
#include "utils/stdcompat/string_view.hpp"
namespace devilution {
@ -244,6 +245,8 @@ enum class ItemType : int8_t {
None = -1,
};
string_view ItemTypeToString(ItemType itemType);
enum unique_base_item : int8_t {
UITYPE_NONE,
UITYPE_SHORTBOW,

6
Source/scrollrt.cpp

@ -427,7 +427,7 @@ void DrawMonster(const Surface &out, Point tilePosition, Point targetBufferPosit
"Draw Monster \"{}\" {}: facing {}, frame {} of {}",
monster.mName,
getMonsterModeDisplayName(monster._mmode),
monster._mdir,
DirectionToString(monster._mdir),
nCel,
frames);
return;
@ -529,7 +529,7 @@ void DrawPlayer(const Surface &out, int pnum, Point tilePosition, Point targetBu
pnum,
player._pName,
szMode,
player._pdir,
DirectionToString(player._pdir),
nCel,
frames);
return;
@ -717,7 +717,7 @@ void DrawItem(const Surface &out, Point tilePosition, Point targetBufferPosition
int nCel = item.AnimInfo.GetFrameToUseForRendering();
int frames = SDL_SwapLE32(*(DWORD *)cel->Data());
if (nCel < 1 || frames > 50 || nCel > frames) {
Log("Draw \"{}\" Item 1: frame {} of {}, item type=={}", item._iIName, nCel, frames, item._itype);
Log("Draw \"{}\" Item 1: frame {} of {}, item type=={}", item._iIName, nCel, frames, ItemTypeToString(item._itype));
return;
}

Loading…
Cancel
Save