From b3112bd3f6d0887fdf81610327c9edad08a0cfaf Mon Sep 17 00:00:00 2001 From: Ben Longbons Date: Sat, 10 Jan 2015 17:32:49 -0800 Subject: Use generated config for map --- src/mmo/consts.hpp | 7 ++++++- src/mmo/cxxstdio_enums.hpp | 49 +++++++++++++++++++++++++++------------------- src/mmo/extract_enums.hpp | 26 +++++++++++++++++------- src/mmo/strs.cpp | 32 ++++++++++++++++++++++++++++++ 4 files changed, 86 insertions(+), 28 deletions(-) create mode 100644 src/mmo/strs.cpp (limited to 'src/mmo') diff --git a/src/mmo/consts.hpp b/src/mmo/consts.hpp index c1a7eb6..5533446 100644 --- a/src/mmo/consts.hpp +++ b/src/mmo/consts.hpp @@ -54,6 +54,11 @@ constexpr int MAX_PARTY = 12; #define MIN_CLOTH_COLOR battle_config.min_cloth_color #define MAX_CLOTH_COLOR battle_config.max_cloth_color +namespace map +{ + struct map_session_data; +} + // WTF is this doing here? struct PartyMember { @@ -61,6 +66,6 @@ struct PartyMember CharName name; MapName map; int leader, online, lv; - struct map_session_data *sd; + map::map_session_data *sd; }; } // namespace tmwa diff --git a/src/mmo/cxxstdio_enums.hpp b/src/mmo/cxxstdio_enums.hpp index 6f428e8..28a8a14 100644 --- a/src/mmo/cxxstdio_enums.hpp +++ b/src/mmo/cxxstdio_enums.hpp @@ -29,49 +29,58 @@ namespace tmwa { namespace e { -enum class BF : uint16_t; enum class EPOS : uint16_t; -enum class MapCell : uint8_t; enum class Opt0 : uint16_t; -inline -auto decay_for_printf(BF v) -> typename remove_enum::type { return typename remove_enum::type(v); } inline auto decay_for_printf(EPOS v) -> typename remove_enum::type { return typename remove_enum::type(v); } inline -auto decay_for_printf(MapCell v) -> typename remove_enum::type { return typename remove_enum::type(v); } -inline auto decay_for_printf(Opt0 v) -> typename remove_enum::type { return typename remove_enum::type(v); } -} +} // namespace e + +enum class ItemLook : uint16_t; +enum class SP : uint16_t; +enum class SkillID : uint16_t; +enum class StatusChange : uint16_t; + +inline +auto decay_for_printf(ItemLook v) -> typename remove_enum::type { return typename remove_enum::type(v); } +inline +auto decay_for_printf(SP v) -> typename remove_enum::type { return typename remove_enum::type(v); } +inline +auto decay_for_printf(SkillID v) -> typename remove_enum::type { return typename remove_enum::type(v); } +inline +auto decay_for_printf(StatusChange v) -> typename remove_enum::type { return typename remove_enum::type(v); } + +namespace map +{ +namespace e +{ +enum class BF : uint16_t; +enum class MapCell : uint8_t; +inline +auto decay_for_printf(BF v) -> typename remove_enum::type { return typename remove_enum::type(v); } +inline +auto decay_for_printf(MapCell v) -> typename remove_enum::type { return typename remove_enum::type(v); } +} // namespace map::e namespace magic { enum class SPELLARG : uint8_t; inline auto decay_for_printf(SPELLARG v) -> typename remove_enum::type { return typename remove_enum::type(v); } -} +} // namespace map::magic enum class BL : uint8_t; enum class ByteCode : uint8_t; -enum class ItemLook : uint16_t; enum class MS : uint8_t; -enum class SP : uint16_t; -enum class SkillID : uint16_t; -enum class StatusChange : uint16_t; inline auto decay_for_printf(BL v) -> typename remove_enum::type { return typename remove_enum::type(v); } inline auto decay_for_printf(ByteCode v) -> typename remove_enum::type { return typename remove_enum::type(v); } inline -auto decay_for_printf(ItemLook v) -> typename remove_enum::type { return typename remove_enum::type(v); } -inline auto decay_for_printf(MS v) -> typename remove_enum::type { return typename remove_enum::type(v); } -inline -auto decay_for_printf(SP v) -> typename remove_enum::type { return typename remove_enum::type(v); } -inline -auto decay_for_printf(SkillID v) -> typename remove_enum::type { return typename remove_enum::type(v); } -inline -auto decay_for_printf(StatusChange v) -> typename remove_enum::type { return typename remove_enum::type(v); } +} // namespace map } // namespace tmwa diff --git a/src/mmo/extract_enums.hpp b/src/mmo/extract_enums.hpp index 1aab17e..0e8ac4c 100644 --- a/src/mmo/extract_enums.hpp +++ b/src/mmo/extract_enums.hpp @@ -32,7 +32,6 @@ namespace tmwa namespace e { enum class EPOS : uint16_t; -enum class MobMode : uint16_t; enum class Opt1 : uint16_t; enum class Opt2 : uint16_t; enum class Opt0 : uint16_t; @@ -40,18 +39,15 @@ enum class Opt0 : uint16_t; inline bool impl_extract(XString str, EPOS *iv) { return extract_as_int(str, iv); } inline -bool impl_extract(XString str, MobMode *iv) { return extract_as_int(str, iv); } -inline bool impl_extract(XString str, Opt1 *iv) { return extract_as_int(str, iv); } inline bool impl_extract(XString str, Opt2 *iv) { return extract_as_int(str, iv); } inline bool impl_extract(XString str, Opt0 *iv) { return extract_as_int(str, iv); } -} +} // namespace e enum class ItemLook : uint16_t; enum class ItemType : uint8_t; -enum class Race : uint8_t; enum class SEX : uint8_t; enum class SkillID : uint16_t; enum class StatusChange : uint16_t; @@ -61,8 +57,6 @@ bool impl_extract(XString str, ItemLook *iv) { return extract_as_int(str, iv); } inline bool impl_extract(XString str, ItemType *iv) { return extract_as_int(str, iv); } inline -bool impl_extract(XString str, Race *iv) { return extract_as_int(str, iv); } -inline bool impl_extract(XString str, SEX *iv) { return extract_as_int(str, iv); } inline bool impl_extract(XString str, SkillID *iv) { return extract_as_int(str, iv); } @@ -70,4 +64,22 @@ inline bool impl_extract(XString str, StatusChange *iv) { return extract_as_int(str, iv); } bool impl_extract(XString, DIR *); + +namespace map +{ +namespace e +{ +enum class MobMode : uint16_t; + +inline +bool impl_extract(XString str, MobMode *iv) { return extract_as_int(str, iv); } +} // namespace map::e +enum class Race : uint8_t; +enum class ATK; + +inline +bool impl_extract(XString str, Race *iv) { return extract_as_int(str, iv); } +inline +bool impl_extract(XString str, ATK *iv) { return extract_as_int(str, iv); } +} // namespace map } // namespace tmwa diff --git a/src/mmo/strs.cpp b/src/mmo/strs.cpp new file mode 100644 index 0000000..d780702 --- /dev/null +++ b/src/mmo/strs.cpp @@ -0,0 +1,32 @@ +#include "strs.hpp" +// strs.cpp - common string types +// +// Copyright © 2014 Ben Longbons +// +// This file is part of The Mana World (Athena server) +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +#include "../io/cxxstdio.hpp" + +#include "../poison.hpp" + + +namespace tmwa +{ +VString<49> convert_for_printf(NpcEvent ev) +{ + return STRNPRINTF(50, "%s::%s"_fmt, ev.npc, ev.label); +} +} // namespace tmwa -- cgit v1.2.3-70-g09d2