Skip to content

Commit e83570f

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

Some content is hidden

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

53 files changed

+17078
-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

msvc-full-features/fmt.vcxproj

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<ItemGroup Label="ProjectConfigurations">
4+
<ProjectConfiguration Include="Debug|ARM64EC">
5+
<Configuration>Debug</Configuration>
6+
<Platform>ARM64EC</Platform>
7+
</ProjectConfiguration>
8+
<ProjectConfiguration Include="Debug|Win32">
9+
<Configuration>Debug</Configuration>
10+
<Platform>Win32</Platform>
11+
</ProjectConfiguration>
12+
<ProjectConfiguration Include="Release|ARM64EC">
13+
<Configuration>Release</Configuration>
14+
<Platform>ARM64EC</Platform>
15+
</ProjectConfiguration>
16+
<ProjectConfiguration Include="Release|Win32">
17+
<Configuration>Release</Configuration>
18+
<Platform>Win32</Platform>
19+
</ProjectConfiguration>
20+
<ProjectConfiguration Include="Debug|x64">
21+
<Configuration>Debug</Configuration>
22+
<Platform>x64</Platform>
23+
</ProjectConfiguration>
24+
<ProjectConfiguration Include="Release|x64">
25+
<Configuration>Release</Configuration>
26+
<Platform>x64</Platform>
27+
</ProjectConfiguration>
28+
</ItemGroup>
29+
<ItemGroup>
30+
<ClInclude Include="..\src\third-party\fmt\args.h" />
31+
<ClInclude Include="..\src\third-party\fmt\base.h" />
32+
<ClInclude Include="..\src\third-party\fmt\chrono.h" />
33+
<ClInclude Include="..\src\third-party\fmt\color.h" />
34+
<ClInclude Include="..\src\third-party\fmt\compile.h" />
35+
<ClInclude Include="..\src\third-party\fmt\core.h" />
36+
<ClInclude Include="..\src\third-party\fmt\format-inl.h" />
37+
<ClInclude Include="..\src\third-party\fmt\format.h" />
38+
<ClInclude Include="..\src\third-party\fmt\os.h" />
39+
<ClInclude Include="..\src\third-party\fmt\ostream.h" />
40+
<ClInclude Include="..\src\third-party\fmt\printf.h" />
41+
<ClInclude Include="..\src\third-party\fmt\ranges.h" />
42+
<ClInclude Include="..\src\third-party\fmt\std.h" />
43+
<ClInclude Include="..\src\third-party\fmt\xchar.h" />
44+
</ItemGroup>
45+
<ItemGroup>
46+
<ClCompile Include="..\src\third-party\fmt\format.cc" />
47+
<ClCompile Include="..\src\third-party\fmt\os.cc" />
48+
</ItemGroup>
49+
<PropertyGroup Label="Globals">
50+
<VCProjectVersion>16.0</VCProjectVersion>
51+
<Keyword>Win32Proj</Keyword>
52+
<ProjectGuid>{f2098959-aad9-4210-a64c-fc4a09a45556}</ProjectGuid>
53+
<RootNamespace>flatbuffers</RootNamespace>
54+
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
55+
</PropertyGroup>
56+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
57+
<PropertyGroup Label="Configuration">
58+
<ConfigurationType>StaticLibrary</ConfigurationType>
59+
<PlatformToolset>$(DefaultPlatformToolset)</PlatformToolset>
60+
<CharacterSet>Unicode</CharacterSet>
61+
<PreferredToolArchitecture>x64</PreferredToolArchitecture>
62+
</PropertyGroup>
63+
<PropertyGroup Condition="'$(Configuration)'=='Debug'" Label="Configuration">
64+
<UseDebugLibraries>true</UseDebugLibraries>
65+
</PropertyGroup>
66+
<PropertyGroup Condition="'$(Configuration)'=='Release'" Label="Configuration">
67+
<UseDebugLibraries>false</UseDebugLibraries>
68+
<WholeProgramOptimization>false</WholeProgramOptimization>
69+
</PropertyGroup>
70+
<Import Project="Cataclysm.Cpp.props" />
71+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
72+
<ImportGroup Label="ExtensionSettings">
73+
</ImportGroup>
74+
<ImportGroup Label="Shared">
75+
</ImportGroup>
76+
<ImportGroup Label="PropertySheets">
77+
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
78+
<Import Project="Cataclysm-common.props" />
79+
</ImportGroup>
80+
<PropertyGroup Label="UserMacros" />
81+
<PropertyGroup Condition="'$(Configuration)'=='Debug'">
82+
<LinkIncremental>true</LinkIncremental>
83+
</PropertyGroup>
84+
<PropertyGroup Condition="'$(Configuration)'=='Release'">
85+
<LinkIncremental>false</LinkIncremental>
86+
</PropertyGroup>
87+
<PropertyGroup Label="Vcpkg">
88+
<VcpkgEnabled>false</VcpkgEnabled>
89+
</PropertyGroup>
90+
<ItemDefinitionGroup>
91+
<ClCompile>
92+
<PreprocessorDefinitions>_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
93+
</ClCompile>
94+
</ItemDefinitionGroup>
95+
<ItemDefinitionGroup Condition="'$(Configuration)'=='Debug'">
96+
<ClCompile>
97+
<WarningLevel>Level3</WarningLevel>
98+
<FunctionLevelLinking>true</FunctionLevelLinking>
99+
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
100+
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
101+
</ClCompile>
102+
<Link>
103+
<EnableCOMDATFolding>true</EnableCOMDATFolding>
104+
<OptimizeReferences>true</OptimizeReferences>
105+
</Link>
106+
</ItemDefinitionGroup>
107+
<ItemDefinitionGroup Condition="'$(Configuration)'=='Release'">
108+
<ClCompile>
109+
<WarningLevel>Level3</WarningLevel>
110+
<FunctionLevelLinking>true</FunctionLevelLinking>
111+
<IntrinsicFunctions>true</IntrinsicFunctions>
112+
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
113+
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
114+
</ClCompile>
115+
<Link>
116+
<EnableCOMDATFolding>true</EnableCOMDATFolding>
117+
<OptimizeReferences>true</OptimizeReferences>
118+
</Link>
119+
</ItemDefinitionGroup>
120+
<ItemDefinitionGroup Condition="'$(Platform)'=='Win32'">
121+
<ClCompile>
122+
<PreprocessorDefinitions>WIN32;%(PreprocessorDefinitions)</PreprocessorDefinitions>
123+
</ClCompile>
124+
</ItemDefinitionGroup>
125+
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
126+
<ImportGroup Label="ExtensionTargets">
127+
</ImportGroup>
128+
</Project>

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;

0 commit comments

Comments
 (0)