Skip to content

Commit fb74872

Browse files
committed
Use fmt instead of string_formatter
1 parent 665e5a7 commit fb74872

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+16950
-824
lines changed

Makefile

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -975,7 +975,7 @@ ifeq ($(HEADERPOPULARITY), 1)
975975
else
976976
SOURCES := $(wildcard $(SRC_DIR)/*.cpp)
977977
endif
978-
THIRD_PARTY_SOURCES := $(wildcard $(SRC_DIR)/third-party/flatbuffers/*.cpp)
978+
THIRD_PARTY_SOURCES := $(wildcard $(SRC_DIR)/third-party/flatbuffers/*.cpp $(SRC_DIR)/third-party/fmt/*.cc)
979979
THIRD_PARTY_C_SOURCES := $(wildcard $(SRC_DIR)/third-party/zstd/common/*.c $(SRC_DIR)/third-party/zstd/compress/*.c $(SRC_DIR)/third-party/zstd/decompress/*.c)
980980
HEADERS := $(wildcard $(SRC_DIR)/*.h)
981981
TESTSRC := $(wildcard tests/*.cpp)
@@ -1017,7 +1017,10 @@ endif
10171017

10181018
SOURCES += $(IMGUI_SOURCES)
10191019

1020-
_OBJS = $(SOURCES:$(SRC_DIR)/%.cpp=%.o)
1020+
CPP_SOURCES := $(filter %.cpp,$(SOURCES))
1021+
CC_SOURCES := $(filter %.cc,$(SOURCES))
1022+
_OBJS = $(CPP_SOURCES:$(SRC_DIR)/%.cpp=%.o)
1023+
_OBJS += $(CC_SOURCES:$(SRC_DIR)/%.cc=%.o)
10211024
_OBJS += $(C_SOURCES:$(SRC_DIR)/%.c=%.o)
10221025
ifeq ($(TARGETSYSTEM),WINDOWS)
10231026
RSRC = $(wildcard $(SRC_DIR)/*.rc)
@@ -1136,6 +1139,9 @@ $(shell mkdir -p $(DIRS))
11361139
$(ODIR)/%.inc: $(SRC_DIR)/%.cpp
11371140
$(CXX) $(CPPFLAGS) $(DEFINES) $(CXXFLAGS) -Wno-error -H -E $< -o /dev/null 2> $@
11381141

1142+
$(ODIR)/%.inc: $(SRC_DIR)/%.cc
1143+
$(CXX) $(CPPFLAGS) $(DEFINES) $(CXXFLAGS) -Wno-error -H -E $< -o /dev/null 2> $@
1144+
11391145
$(ODIR)/%.inc: $(SRC_DIR)/%.c
11401146
$(CXX) -x c $(CPPFLAGS) $(DEFINES) $(CFLAGS) -Wno-error -H -E $< -o /dev/null 2> $@
11411147

@@ -1146,6 +1152,9 @@ includes: $(OBJS:.o=.inc)
11461152
$(ODIR)/third-party/%.o: $(SRC_DIR)/third-party/%.cpp
11471153
$(CXX) $(CPPFLAGS) $(DEFINES) $(CXXFLAGS) -w -MMD -MP -c $< -o $@
11481154

1155+
$(ODIR)/third-party/%.o: $(SRC_DIR)/third-party/%.cc
1156+
$(CXX) $(CPPFLAGS) $(DEFINES) $(CXXFLAGS) -w -MMD -MP -c $< -o $@
1157+
11491158
$(ODIR)/third-party/%.o: $(SRC_DIR)/third-party/%.c
11501159
$(CXX) -x c $(CPPFLAGS) $(DEFINES) $(CFLAGS) -w -MMD -MP -c $< -o $@
11511160

android/app/jni/src/third-party/Android.mk

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ LOCAL_CPP_FEATURES := exceptions rtti
1010

1111
# Add your application source files here...
1212
FLATBUFFERS_SRCS := $(sort $(wildcard $(LOCAL_PATH)/third-party/flatbuffers/*.cpp))
13+
FMT_SRCS := $(sort $(wildcard $(LOCAL_PATH)/third-party/fmt/*.cc))
1314
ZSTD_SRCS := $(sort $(wildcard $(LOCAL_PATH)/third-party/zstd/common/*.c) $(wildcard $(LOCAL_PATH)/third-party/zstd/compress/*.c) $(wildcard $(LOCAL_PATH)/third-party/zstd/decompress/*.c))
14-
LOCAL_SRC_FILES := $(sort $(FLATBUFFERS_SRCS:$(LOCAL_PATH)/%=%) $(ZSTD_SRCS:$(LOCAL_PATH)/%=%))
15+
LOCAL_SRC_FILES := $(sort $(FLATBUFFERS_SRCS:$(LOCAL_PATH)/%=%) $(FMT_SRCS:$(LOCAL_PATH)/%=%) $(ZSTD_SRCS:$(LOCAL_PATH)/%=%))
1516

1617
LOCAL_CFLAGS += -DBACKTRACE=1 -DLOCALIZE=1 -DZSTD_STATIC_LINKING_ONLY -DZSTD_DISABLE_ASM -Wextra -Wall -fsigned-char
1718

msvc-full-features/Cataclysm-lib-vcpkg-static.vcxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,10 @@
181181
<Project>{8a533a64-435d-4d4f-9ff0-1e97aace9374}</Project>
182182
<LinkLibraryDependencies>false</LinkLibraryDependencies>
183183
</ProjectReference>
184+
<ProjectReference Include="fmt.vcxproj">
185+
<Project>{f2098959-aad9-4210-a64c-fc4a09a45556}</Project>
186+
<LinkLibraryDependencies>false</LinkLibraryDependencies>
187+
</ProjectReference>
184188
<ProjectReference Include="zstd.vcxproj">
185189
<Project>{f49f14c6-b046-41c7-b707-03366f4b1578}</Project>
186190
<LinkLibraryDependencies>false</LinkLibraryDependencies>

msvc-full-features/Cataclysm-vcpkg-static.sln

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
Microsoft Visual Studio Solution File, Format Version 12.00
3-
# Visual Studio Version 17
4-
VisualStudioVersion = 17.1.32104.313
3+
# Visual Studio Version 18
4+
VisualStudioVersion = 18.3.11312.210 d18.3
55
MinimumVisualStudioVersion = 10.0.40219.1
66
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{04F55049-F0DE-4AE6-9D10-3DB97DFF2E2F}"
77
ProjectSection(SolutionItems) = preProject
@@ -32,6 +32,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zstd", "zstd.vcxproj", "{F4
3232
EndProject
3333
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zzip", "zzip.vcxproj", "{1232212E-8B83-40E9-B502-F25DBC4DB6CF}"
3434
EndProject
35+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fmt", "fmt.vcxproj", "{F2098959-AAD9-4210-A64C-FC4A09A45556}"
36+
EndProject
3537
Global
3638
GlobalSection(SolutionConfigurationPlatforms) = preSolution
3739
Debug|ARM64EC = Debug|ARM64EC
@@ -352,6 +354,42 @@ Global
352354
{1232212E-8B83-40E9-B502-F25DBC4DB6CF}.Release-NoTiles|x64.Build.0 = Release|x64
353355
{1232212E-8B83-40E9-B502-F25DBC4DB6CF}.Release-NoTiles|x86.ActiveCfg = Release|Win32
354356
{1232212E-8B83-40E9-B502-F25DBC4DB6CF}.Release-NoTiles|x86.Build.0 = Release|Win32
357+
{F2098959-AAD9-4210-A64C-FC4A09A45556}.Debug|ARM64EC.ActiveCfg = Debug|ARM64EC
358+
{F2098959-AAD9-4210-A64C-FC4A09A45556}.Debug|ARM64EC.Build.0 = Debug|ARM64EC
359+
{F2098959-AAD9-4210-A64C-FC4A09A45556}.Debug|x64.ActiveCfg = Debug|x64
360+
{F2098959-AAD9-4210-A64C-FC4A09A45556}.Debug|x64.Build.0 = Debug|x64
361+
{F2098959-AAD9-4210-A64C-FC4A09A45556}.Debug|x86.ActiveCfg = Debug|Win32
362+
{F2098959-AAD9-4210-A64C-FC4A09A45556}.Debug|x86.Build.0 = Debug|Win32
363+
{F2098959-AAD9-4210-A64C-FC4A09A45556}.Debug-NoTiles|ARM64EC.ActiveCfg = Debug|ARM64EC
364+
{F2098959-AAD9-4210-A64C-FC4A09A45556}.Debug-NoTiles|ARM64EC.Build.0 = Debug|ARM64EC
365+
{F2098959-AAD9-4210-A64C-FC4A09A45556}.Debug-NoTiles|x64.ActiveCfg = Debug|x64
366+
{F2098959-AAD9-4210-A64C-FC4A09A45556}.Debug-NoTiles|x64.Build.0 = Debug|x64
367+
{F2098959-AAD9-4210-A64C-FC4A09A45556}.Debug-NoTiles|x86.ActiveCfg = Debug|Win32
368+
{F2098959-AAD9-4210-A64C-FC4A09A45556}.Debug-NoTiles|x86.Build.0 = Debug|Win32
369+
{F2098959-AAD9-4210-A64C-FC4A09A45556}.Quick|ARM64EC.ActiveCfg = Release|ARM64EC
370+
{F2098959-AAD9-4210-A64C-FC4A09A45556}.Quick|ARM64EC.Build.0 = Release|ARM64EC
371+
{F2098959-AAD9-4210-A64C-FC4A09A45556}.Quick|x64.ActiveCfg = Release|x64
372+
{F2098959-AAD9-4210-A64C-FC4A09A45556}.Quick|x64.Build.0 = Release|x64
373+
{F2098959-AAD9-4210-A64C-FC4A09A45556}.Quick|x86.ActiveCfg = Debug|Win32
374+
{F2098959-AAD9-4210-A64C-FC4A09A45556}.Quick|x86.Build.0 = Debug|Win32
375+
{F2098959-AAD9-4210-A64C-FC4A09A45556}.Quick-NoTiles|ARM64EC.ActiveCfg = Release|ARM64EC
376+
{F2098959-AAD9-4210-A64C-FC4A09A45556}.Quick-NoTiles|ARM64EC.Build.0 = Release|ARM64EC
377+
{F2098959-AAD9-4210-A64C-FC4A09A45556}.Quick-NoTiles|x64.ActiveCfg = Release|x64
378+
{F2098959-AAD9-4210-A64C-FC4A09A45556}.Quick-NoTiles|x64.Build.0 = Release|x64
379+
{F2098959-AAD9-4210-A64C-FC4A09A45556}.Quick-NoTiles|x86.ActiveCfg = Release|Win32
380+
{F2098959-AAD9-4210-A64C-FC4A09A45556}.Quick-NoTiles|x86.Build.0 = Release|Win32
381+
{F2098959-AAD9-4210-A64C-FC4A09A45556}.Release|ARM64EC.ActiveCfg = Release|ARM64EC
382+
{F2098959-AAD9-4210-A64C-FC4A09A45556}.Release|ARM64EC.Build.0 = Release|ARM64EC
383+
{F2098959-AAD9-4210-A64C-FC4A09A45556}.Release|x64.ActiveCfg = Release|x64
384+
{F2098959-AAD9-4210-A64C-FC4A09A45556}.Release|x64.Build.0 = Release|x64
385+
{F2098959-AAD9-4210-A64C-FC4A09A45556}.Release|x86.ActiveCfg = Release|Win32
386+
{F2098959-AAD9-4210-A64C-FC4A09A45556}.Release|x86.Build.0 = Release|Win32
387+
{F2098959-AAD9-4210-A64C-FC4A09A45556}.Release-NoTiles|ARM64EC.ActiveCfg = Release|ARM64EC
388+
{F2098959-AAD9-4210-A64C-FC4A09A45556}.Release-NoTiles|ARM64EC.Build.0 = Release|ARM64EC
389+
{F2098959-AAD9-4210-A64C-FC4A09A45556}.Release-NoTiles|x64.ActiveCfg = Release|x64
390+
{F2098959-AAD9-4210-A64C-FC4A09A45556}.Release-NoTiles|x64.Build.0 = Release|x64
391+
{F2098959-AAD9-4210-A64C-FC4A09A45556}.Release-NoTiles|x86.ActiveCfg = Release|Win32
392+
{F2098959-AAD9-4210-A64C-FC4A09A45556}.Release-NoTiles|x86.Build.0 = Release|Win32
355393
EndGlobalSection
356394
GlobalSection(SolutionProperties) = preSolution
357395
HideSolutionNode = FALSE

src/bionics.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2081,7 +2081,8 @@ bool Character::can_uninstall_bionic( const bionic &bio, Character &installer, b
20812081
}
20822082

20832083
if( bio.id->cant_remove_reason.has_value() ) {
2084-
popup( string_format( bio.id->cant_remove_reason.value(), disp_name( true ), disp_name() ) );
2084+
popup( string_format( bio.id->cant_remove_reason.value().translated(), disp_name( true ),
2085+
disp_name() ) );
20852086
return false;
20862087
}
20872088

src/bodypart.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,11 @@ enum body_part : int {
6464
num_bp
6565
};
6666

67+
inline auto format_as( body_part bp )
68+
{
69+
return static_cast<std::underlying_type_t<body_part>>( bp );
70+
}
71+
6772
template<>
6873
struct enum_traits<body_part> {
6974
static constexpr body_part last = body_part::num_bp;

src/calendar.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ enum moon_phase {
5454
MOON_PHASE_MAX
5555
};
5656

57+
inline auto format_as( moon_phase mp )
58+
{
59+
return static_cast<std::underlying_type_t<moon_phase>>( mp );
60+
}
61+
5762
enum class time_accuracy {
5863
/** No accuracy, no idea what time it is **/
5964
NONE = 0,

src/cata_path.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
#include <filesystem>
99

10+
#include "string_formatter.h"
11+
1012
/**
1113
* One of the problems of filesystem paths is they lack contextual awareness
1214
* of 'where' they are. They're just a list of segments pointing into the
@@ -162,4 +164,12 @@ class cata_path
162164
}
163165
};
164166

167+
template<>
168+
struct fmt::formatter<cata_path> : formatter<const char *> {
169+
template<typename Ctx>
170+
auto format( const cata_path &p, Ctx &ctx ) const {
171+
return formatter<const char *>::format( p.generic_u8string().c_str(), ctx );
172+
}
173+
};
174+
165175
#endif // CATA_SRC_CATA_PATH_H

src/clothing_mod.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ enum clothing_mod_type : int {
2828
num_clothing_mod_types
2929
};
3030

31+
inline auto format_as( clothing_mod_type cmt )
32+
{
33+
return static_cast<std::underlying_type_t<clothing_mod_type>>( cmt );
34+
}
35+
3136
template<>
3237
struct enum_traits<clothing_mod_type> {
3338
static constexpr clothing_mod_type last = clothing_mod_type::num_clothing_mod_types;

src/color.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,11 @@ enum color_id {
335335
num_colors
336336
};
337337

338+
inline auto format_as( color_id cid )
339+
{
340+
return static_cast<std::underlying_type_t<color_id>>( cid );
341+
}
342+
338343
class cata_path;
339344
class JsonArray;
340345
class JsonOut;

0 commit comments

Comments
 (0)