diff options
| author | untodesu <kirill@untode.su> | 2025-06-28 01:59:49 +0500 |
|---|---|---|
| committer | untodesu <kirill@untode.su> | 2025-06-28 01:59:49 +0500 |
| commit | 61e5bcef2629e2d68b805a956a96fff264d4f74d (patch) | |
| tree | bca3a94bac79d34e3c0db57c77604f5a823ecbda /game | |
| parent | 88c01588aa0830e219eaa62588839e4d1e2883ce (diff) | |
| download | voxelius-61e5bcef2629e2d68b805a956a96fff264d4f74d.tar.bz2 voxelius-61e5bcef2629e2d68b805a956a96fff264d4f74d.zip | |
Restructure dependencies and update to C++20
- Nuked static_assert from almost everywhere in the project
- Nuked binary dependency support. Might add one later though
- Separated dependency headers into a separate include subdirectory
- Grafted a thirdpartylegalnotices.txt generator from RITEG
- Pushed development snapshot version to 2126 (26th week of 2025)
Diffstat (limited to 'game')
52 files changed, 229 insertions, 200 deletions
diff --git a/game/client/CMakeLists.txt b/game/client/CMakeLists.txt index 8fc9858..15d2692 100644 --- a/game/client/CMakeLists.txt +++ b/game/client/CMakeLists.txt @@ -104,7 +104,7 @@ add_executable(vclient "${CMAKE_CURRENT_LIST_DIR}/voxel_sounds.hh" "${CMAKE_CURRENT_LIST_DIR}/window_title.cc" "${CMAKE_CURRENT_LIST_DIR}/window_title.hh") -target_compile_features(vclient PUBLIC cxx_std_17) +target_compile_features(vclient PUBLIC cxx_std_20) target_compile_definitions(vclient PUBLIC GLFW_INCLUDE_NONE) target_include_directories(vclient PUBLIC "${DEPS_INCLUDE_DIR}") target_include_directories(vclient PRIVATE "${PROJECT_SOURCE_DIR}") diff --git a/game/client/camera.cc b/game/client/camera.cc index 51e85ff..724ae66 100644 --- a/game/client/camera.cc +++ b/game/client/camera.cc @@ -94,13 +94,13 @@ void camera::update(void) if(!toggles::get(TOGGLE_PM_FLIGHT)) { // Apply the quake-like view rolling - client_angles[2] = cxpr::radians(-camera::roll_angle.get_value() * glm::dot(velocity.value / PMOVE_MAX_SPEED_GROUND, right_vector)); + client_angles[2] = vx::radians(-camera::roll_angle.get_value() * glm::dot(velocity.value / PMOVE_MAX_SPEED_GROUND, right_vector)); } const auto z_near = 0.01f; const auto z_far = 1.25f * static_cast<float>(CHUNK_SIZE * camera::view_distance.get_value()); - auto proj = glm::perspective(cxpr::radians(camera::vertical_fov.get_value()), globals::aspect, z_near, z_far); + auto proj = glm::perspective(vx::radians(camera::vertical_fov.get_value()), globals::aspect, z_near, z_far); auto view = platinumsrc_viewmatrix(camera::position_local, client_angles); camera::matrix = proj * view; diff --git a/game/client/chat.cc b/game/client/chat.cc index e727974..0a0c75d 100644 --- a/game/client/chat.cc +++ b/game/client/chat.cc @@ -41,7 +41,7 @@ static void append_text_message(const std::string& sender, const std::string& te { GuiChatMessage message; message.spawn = globals::curtime; - message.text = fmt::format("<{}> {}", sender, text); + message.text = std::format("<{}> {}", sender, text); message.color = ImGui::GetStyleColorVec4(ImGuiCol_Text); history.push_back(message); @@ -54,7 +54,7 @@ static void append_player_join(const std::string& sender) { GuiChatMessage message; message.spawn = globals::curtime; - message.text = fmt::format("{} {}", sender, language::resolve("chat.client_join")); + message.text = std::format("{} {}", sender, language::resolve("chat.client_join")); message.color = ImGui::GetStyleColorVec4(ImGuiCol_DragDropTarget); history.push_back(message); @@ -67,7 +67,7 @@ static void append_player_leave(const std::string& sender, const std::string& re { GuiChatMessage message; message.spawn = globals::curtime; - message.text = fmt::format("{} {} ({})", sender, language::resolve("chat.client_left"), language::resolve(reason.c_str())); + message.text = std::format("{} {} ({})", sender, language::resolve("chat.client_left"), language::resolve(reason.c_str())); message.color = ImGui::GetStyleColorVec4(ImGuiCol_DragDropTarget); history.push_back(message); @@ -221,7 +221,8 @@ void client_chat::layout(void) auto text_col = ImGui::GetColorU32(ImVec4(it->color.x, it->color.y, it->color.z, it->color.w * text_alpha)); draw_list->AddRectFilled(rect_pos, rect_end, rect_col); - draw_list->AddText(font, font->FontSize, text_pos, text_col, it->text.c_str(), it->text.c_str() + it->text.size(), window_size.x); + draw_list->AddText( + font, font->FontSize, text_pos, text_col, it->text.c_str(), it->text.c_str() + it->text.size(), window_size.x); ypos -= rect_size.y; } diff --git a/game/client/chunk_mesher.cc b/game/client/chunk_mesher.cc index 962997c..0271931 100644 --- a/game/client/chunk_mesher.cc +++ b/game/client/chunk_mesher.cc @@ -35,9 +35,9 @@ static const CachedChunkCoord get_cached_cpos(const chunk_pos& pivot, const chun if(pivot != cpos) { chunk_pos delta = pivot - cpos; - delta[0] = cxpr::clamp<std::int64_t>(delta[0], -1, 1); - delta[1] = cxpr::clamp<std::int64_t>(delta[1], -1, 1); - delta[2] = cxpr::clamp<std::int64_t>(delta[2], -1, 1); + delta[0] = vx::clamp<std::int64_t>(delta[0], -1, 1); + delta[1] = vx::clamp<std::int64_t>(delta[1], -1, 1); + delta[2] = vx::clamp<std::int64_t>(delta[2], -1, 1); if(delta[0]) { return nx[delta[0] + 1]; diff --git a/game/client/chunk_quad.hh b/game/client/chunk_quad.hh index 1e34b31..337bb1e 100644 --- a/game/client/chunk_quad.hh +++ b/game/client/chunk_quad.hh @@ -10,7 +10,8 @@ // [1] FFFFTTTTTTTTTTTAAAAA------------ using ChunkQuad = std::array<std::uint32_t, 2>; -constexpr inline static ChunkQuad make_chunk_quad(const glm::fvec3& position, const glm::fvec2& size, voxel_facing facing, std::size_t texture, std::size_t frames) +constexpr inline static ChunkQuad make_chunk_quad( + const glm::fvec3& position, const glm::fvec2& size, voxel_facing facing, std::size_t texture, std::size_t frames) { ChunkQuad result = {}; result[0] = 0x00000000; diff --git a/game/client/chunk_visibility.cc b/game/client/chunk_visibility.cc index 29e4a52..f832529 100644 --- a/game/client/chunk_visibility.cc +++ b/game/client/chunk_visibility.cc @@ -39,8 +39,8 @@ static void update_requests(void) } std::sort(requests.begin(), requests.end(), [](const chunk_pos& cpos_a, const chunk_pos& cpos_b) { - auto da = cxvectors::distance2(cpos_a, camera::position_chunk); - auto db = cxvectors::distance2(cpos_b, camera::position_chunk); + auto da = vx::distance2(cpos_a, camera::position_chunk); + auto db = vx::distance2(cpos_b, camera::position_chunk); return da > db; }); } diff --git a/game/client/crosshair.cc b/game/client/crosshair.cc index 72ece45..84a9a73 100644 --- a/game/client/crosshair.cc +++ b/game/client/crosshair.cc @@ -13,7 +13,8 @@ static resource_ptr<TextureGUI> texture; void crosshair::init(void) { - texture = resource::load<TextureGUI>("textures/gui/hud_crosshair.png", TEXTURE_GUI_LOAD_CLAMP_S | TEXTURE_GUI_LOAD_CLAMP_T | TEXTURE_GUI_LOAD_VFLIP); + texture = resource::load<TextureGUI>( + "textures/gui/hud_crosshair.png", TEXTURE_GUI_LOAD_CLAMP_S | TEXTURE_GUI_LOAD_CLAMP_T | TEXTURE_GUI_LOAD_VFLIP); if(texture == nullptr) { spdlog::critical("crosshair: texture load failed"); @@ -31,9 +32,10 @@ void crosshair::layout(void) auto viewport = ImGui::GetMainViewport(); auto draw_list = ImGui::GetForegroundDrawList(); - auto scaled_width = cxpr::max<int>(texture->size.x, globals::gui_scale * texture->size.x / 2); - auto scaled_height = cxpr::max<int>(texture->size.y, globals::gui_scale * texture->size.y / 2); - auto start = ImVec2(static_cast<int>(0.5f * viewport->Size.x) - (scaled_width / 2), static_cast<int>(0.5f * viewport->Size.y) - (scaled_height / 2)); + auto scaled_width = vx::max<int>(texture->size.x, globals::gui_scale * texture->size.x / 2); + auto scaled_height = vx::max<int>(texture->size.y, globals::gui_scale * texture->size.y / 2); + auto start = ImVec2( + static_cast<int>(0.5f * viewport->Size.x) - (scaled_width / 2), static_cast<int>(0.5f * viewport->Size.y) - (scaled_height / 2)); auto end = ImVec2(start.x + scaled_width, start.y + scaled_height); draw_list->AddImage(texture->handle, start, end); } diff --git a/game/client/direct_connection.cc b/game/client/direct_connection.cc index b239371..c2efc4e 100644 --- a/game/client/direct_connection.cc +++ b/game/client/direct_connection.cc @@ -59,7 +59,7 @@ static void connect_to_server(void) } if(parts.size() >= 2) { - parsed_port = cxpr::clamp<std::uint16_t>(strtoul(parts[1].c_str(), nullptr, 10), 1024, UINT16_MAX); + parsed_port = vx::clamp<std::uint16_t>(strtoul(parts[1].c_str(), nullptr, 10), 1024, UINT16_MAX); } else { parsed_port = protocol::PORT; } diff --git a/game/client/game.cc b/game/client/game.cc index 6f68cf9..8dc39f6 100644 --- a/game/client/game.cc +++ b/game/client/game.cc @@ -5,7 +5,6 @@ #include "core/angles.hh" #include "core/binfile.hh" #include "core/config.hh" -#include "core/feature.hh" #include "core/resource.hh" #include "shared/collision.hh" @@ -88,9 +87,9 @@ static void on_glfw_framebuffer_size(const GlfwFramebufferSizeEvent& event) { auto width_float = static_cast<float>(event.size.x); auto height_float = static_cast<float>(event.size.y); - auto wscale = cxpr::max(1U, cxpr::floor<unsigned int>(width_float / static_cast<float>(BASE_WIDTH))); - auto hscale = cxpr::max(1U, cxpr::floor<unsigned int>(height_float / static_cast<float>(BASE_HEIGHT))); - auto scale = cxpr::min(wscale, hscale); + auto wscale = vx::max(1U, vx::floor<unsigned int>(width_float / static_cast<float>(BASE_WIDTH))); + auto hscale = vx::max(1U, vx::floor<unsigned int>(height_float / static_cast<float>(BASE_HEIGHT))); + auto scale = vx::min(wscale, hscale); if(globals::gui_scale != scale) { auto& io = ImGui::GetIO(); @@ -113,8 +112,10 @@ static void on_glfw_framebuffer_size(const GlfwFramebufferSizeEvent& event) ImVector<ImWchar> ranges = {}; builder.BuildRanges(&ranges); - globals::font_default = io.Fonts->AddFontFromMemoryTTF(bin_unscii16->buffer, bin_unscii16->size, 16.0f * scale, &font_config, ranges.Data); - globals::font_chat = io.Fonts->AddFontFromMemoryTTF(bin_unscii16->buffer, bin_unscii16->size, 8.0f * scale, &font_config, ranges.Data); + globals::font_default = io.Fonts->AddFontFromMemoryTTF( + bin_unscii16->buffer, bin_unscii16->size, 16.0f * scale, &font_config, ranges.Data); + globals::font_chat = io.Fonts->AddFontFromMemoryTTF( + bin_unscii16->buffer, bin_unscii16->size, 8.0f * scale, &font_config, ranges.Data); globals::font_debug = io.Fonts->AddFontFromMemoryTTF(bin_unscii8->buffer, bin_unscii8->size, 4.0f * scale, &font_config); // Re-assign the default font @@ -578,8 +579,8 @@ void client_game::update_late(void) void client_game::render(void) { - auto scaled_width = globals::width / cxpr::max<int>(1, client_game::pixel_size.get_value()); - auto scaled_height = globals::height / cxpr::max<int>(1, client_game::pixel_size.get_value()); + auto scaled_width = globals::width / vx::max<int>(1, client_game::pixel_size.get_value()); + auto scaled_height = globals::height / vx::max<int>(1, client_game::pixel_size.get_value()); glViewport(0, 0, scaled_width, scaled_height); glBindFramebuffer(GL_FRAMEBUFFER, globals::world_fbo); @@ -595,7 +596,8 @@ void client_game::render(void) player_target::render(); if(globals::dimension) { - auto group = globals::dimension->entities.group(entt::get<PlayerComponent, CollisionComponent, HeadComponentIntr, TransformComponentIntr>); + auto group = globals::dimension->entities.group( + entt::get<PlayerComponent, CollisionComponent, HeadComponentIntr, TransformComponentIntr>); outline::prepare(); diff --git a/game/client/gamepad.cc b/game/client/gamepad.cc index 26411ba..6cbcb3f 100644 --- a/game/client/gamepad.cc +++ b/game/client/gamepad.cc @@ -132,7 +132,8 @@ void gamepad::update_late(void) if(glfwGetGamepadState(active_gamepad_id, &gamepad::state)) { for(int i = 0; i < NUM_AXES; ++i) { - if((cxpr::abs(gamepad::state.axes[i]) > GAMEPAD_AXIS_EVENT_THRESHOLD) && (cxpr::abs(gamepad::last_state.axes[i]) <= GAMEPAD_AXIS_EVENT_THRESHOLD)) { + if((vx::abs(gamepad::state.axes[i]) > GAMEPAD_AXIS_EVENT_THRESHOLD) + && (vx::abs(gamepad::last_state.axes[i]) <= GAMEPAD_AXIS_EVENT_THRESHOLD)) { GamepadAxisEvent event; event.action = GLFW_PRESS; event.axis = i; @@ -140,7 +141,8 @@ void gamepad::update_late(void) continue; } - if((cxpr::abs(gamepad::state.axes[i]) <= GAMEPAD_AXIS_EVENT_THRESHOLD) && (cxpr::abs(gamepad::last_state.axes[i]) > GAMEPAD_AXIS_EVENT_THRESHOLD)) { + if((vx::abs(gamepad::state.axes[i]) <= GAMEPAD_AXIS_EVENT_THRESHOLD) + && (vx::abs(gamepad::last_state.axes[i]) > GAMEPAD_AXIS_EVENT_THRESHOLD)) { GamepadAxisEvent event; event.action = GLFW_RELEASE; event.axis = i; diff --git a/game/client/gamepad_axis.cc b/game/client/gamepad_axis.cc index 4d4d953..546c647 100644 --- a/game/client/gamepad_axis.cc +++ b/game/client/gamepad_axis.cc @@ -39,7 +39,7 @@ ConfigGamepadAxis::ConfigGamepadAxis(int axis, bool inverted) m_inverted = inverted; m_gamepad_axis = axis; m_name = get_axis_name(axis); - m_full_string = fmt::format("{}:{}", m_name, m_inverted ? 1U : 0U); + m_full_string = std::format("{}:{}", m_name, m_inverted ? 1U : 0U); } const char* ConfigGamepadAxis::get(void) const @@ -58,7 +58,7 @@ void ConfigGamepadAxis::set(const char* value) m_inverted = new_invert; m_gamepad_axis = it.first; m_name = get_axis_name(m_gamepad_axis); - m_full_string = fmt::format("{}:{}", m_name, m_inverted ? 1U : 0U); + m_full_string = std::format("{}:{}", m_name, m_inverted ? 1U : 0U); return; } } @@ -67,7 +67,7 @@ void ConfigGamepadAxis::set(const char* value) m_inverted = false; m_gamepad_axis = INVALID_GAMEPAD_AXIS; m_name = UNKNOWN_AXIS_NAME; - m_full_string = fmt::format("{}:{}", m_name, m_inverted ? 1U : 0U); + m_full_string = std::format("{}:{}", m_name, m_inverted ? 1U : 0U); } int ConfigGamepadAxis::get_axis(void) const @@ -79,7 +79,7 @@ void ConfigGamepadAxis::set_axis(int axis) { m_gamepad_axis = axis; m_name = get_axis_name(axis); - m_full_string = fmt::format("{}:{}", m_name, m_inverted ? 1U : 0U); + m_full_string = std::format("{}:{}", m_name, m_inverted ? 1U : 0U); } bool ConfigGamepadAxis::is_inverted(void) const @@ -90,15 +90,15 @@ bool ConfigGamepadAxis::is_inverted(void) const void ConfigGamepadAxis::set_inverted(bool inverted) { m_inverted = inverted; - m_full_string = fmt::format("{}:{}", m_name, m_inverted ? 1U : 0U); + m_full_string = std::format("{}:{}", m_name, m_inverted ? 1U : 0U); } float ConfigGamepadAxis::get_value(const GLFWgamepadstate& state, float deadzone) const { - if(m_gamepad_axis <= cxpr::array_size(state.axes)) { + if(m_gamepad_axis <= vx::array_size(state.axes)) { auto value = state.axes[m_gamepad_axis]; - if(cxpr::abs(value) > deadzone) { + if(vx::abs(value) > deadzone) { return m_inverted ? -value : value; } diff --git a/game/client/gamepad_button.cc b/game/client/gamepad_button.cc index c236054..dd3dca7 100644 --- a/game/client/gamepad_button.cc +++ b/game/client/gamepad_button.cc @@ -86,5 +86,5 @@ bool ConfigGamepadButton::equals(int button) const bool ConfigGamepadButton::is_pressed(const GLFWgamepadstate& state) const { - return m_gamepad_button < cxpr::array_size(state.buttons) && state.buttons[m_gamepad_button] == GLFW_PRESS; + return m_gamepad_button < vx::array_size(state.buttons) && state.buttons[m_gamepad_button] == GLFW_PRESS; } diff --git a/game/client/hotbar.cc b/game/client/hotbar.cc index a783347..a2ed859 100644 --- a/game/client/hotbar.cc +++ b/game/client/hotbar.cc @@ -138,7 +138,8 @@ void hotbar::layout(void) // Draw the hotbar selector image auto selector_padding_a = SELECTOR_PADDING * globals::gui_scale; auto selector_padding_b = SELECTOR_PADDING * globals::gui_scale * 2.0f; - auto selector_start = ImVec2(background_start.x + hotbar::active_slot * item_size - selector_padding_a, background_start.y - selector_padding_a); + auto selector_start = ImVec2( + background_start.x + hotbar::active_slot * item_size - selector_padding_a, background_start.y - selector_padding_a); auto selector_end = ImVec2(selector_start.x + item_size + selector_padding_b, selector_start.y + item_size + selector_padding_b); draw_list->AddImage(hotbar_selector->handle, selector_start, selector_end); diff --git a/game/client/imdraw_ext.cc b/game/client/imdraw_ext.cc index 920063e..67df3c8 100644 --- a/game/client/imdraw_ext.cc +++ b/game/client/imdraw_ext.cc @@ -4,7 +4,8 @@ #include "client/globals.hh" -void imdraw_ext::text_shadow(const std::string& text, const ImVec2& position, ImU32 text_color, ImU32 shadow_color, ImFont* font, ImDrawList* draw_list) +void imdraw_ext::text_shadow( + const std::string& text, const ImVec2& position, ImU32 text_color, ImU32 shadow_color, ImFont* font, ImDrawList* draw_list) { const auto shadow_position = ImVec2(position.x + 0.5f * globals::gui_scale, position.y + 0.5f * globals::gui_scale); draw_list->AddText(font, font->FontSize, shadow_position, shadow_color, text.c_str(), text.c_str() + text.size()); diff --git a/game/client/imdraw_ext.hh b/game/client/imdraw_ext.hh index a73269e..0a84e69 100644 --- a/game/client/imdraw_ext.hh +++ b/game/client/imdraw_ext.hh @@ -4,7 +4,8 @@ namespace imdraw_ext { -void text_shadow(const std::string& text, const ImVec2& position, ImU32 text_color, ImU32 shadow_color, ImFont* font, ImDrawList* draw_list); +void text_shadow( + const std::string& text, const ImVec2& position, ImU32 text_color, ImU32 shadow_color, ImFont* font, ImDrawList* draw_list); } // namespace imdraw_ext #endif /* CLIENT_IMDRAW_EXT_HH */ diff --git a/game/client/interpolation.cc b/game/client/interpolation.cc index e820b62..27b6dfd 100644 --- a/game/client/interpolation.cc +++ b/game/client/interpolation.cc @@ -16,9 +16,9 @@ static void transform_interpolate(float alpha) auto group = globals::dimension->entities.group<TransformComponentIntr>(entt::get<TransformComponent, TransformComponentPrev>); for(auto [entity, interp, current, previous] : group.each()) { - interp.angles[0] = cxpr::lerp(previous.angles[0], current.angles[0], alpha); - interp.angles[1] = cxpr::lerp(previous.angles[1], current.angles[1], alpha); - interp.angles[2] = cxpr::lerp(previous.angles[2], current.angles[2], alpha); + interp.angles[0] = vx::lerp(previous.angles[0], current.angles[0], alpha); + interp.angles[1] = vx::lerp(previous.angles[1], current.angles[1], alpha); + interp.angles[2] = vx::lerp(previous.angles[2], current.angles[2], alpha); // Figure out previous chunk-local floating-point coordinates transformed // to the current WorldCoord's chunk domain coordinates; we're interpolating @@ -30,9 +30,9 @@ static void transform_interpolate(float alpha) interp.chunk.y = current.chunk.y; interp.chunk.z = current.chunk.z; - interp.local.x = cxpr::lerp(previous_local.x, current.local.x, alpha); - interp.local.y = cxpr::lerp(previous_local.y, current.local.y, alpha); - interp.local.z = cxpr::lerp(previous_local.z, current.local.z, alpha); + interp.local.x = vx::lerp(previous_local.x, current.local.x, alpha); + interp.local.y = vx::lerp(previous_local.y, current.local.y, alpha); + interp.local.z = vx::lerp(previous_local.z, current.local.z, alpha); } } @@ -41,13 +41,13 @@ static void head_interpolate(float alpha) auto group = globals::dimension->entities.group<HeadComponentIntr>(entt::get<HeadComponent, HeadComponentPrev>); for(auto [entity, interp, current, previous] : group.each()) { - interp.angles[0] = cxpr::lerp(previous.angles[0], current.angles[0], alpha); - interp.angles[1] = cxpr::lerp(previous.angles[1], current.angles[1], alpha); - interp.angles[2] = cxpr::lerp(previous.angles[2], current.angles[2], alpha); + interp.angles[0] = vx::lerp(previous.angles[0], current.angles[0], alpha); + interp.angles[1] = vx::lerp(previous.angles[1], current.angles[1], alpha); + interp.angles[2] = vx::lerp(previous.angles[2], current.angles[2], alpha); - interp.offset.x = cxpr::lerp(previous.offset.x, current.offset.x, alpha); - interp.offset.y = cxpr::lerp(previous.offset.y, current.offset.y, alpha); - interp.offset.z = cxpr::lerp(previous.offset.z, current.offset.z, alpha); + interp.offset.x = vx::lerp(previous.offset.x, current.offset.x, alpha); + interp.offset.y = vx::lerp(previous.offset.y, current.offset.y, alpha); + interp.offset.z = vx::lerp(previous.offset.z, current.offset.z, alpha); } } diff --git a/game/client/language.cc b/game/client/language.cc index 2d84996..2ae0bc6 100644 --- a/game/client/language.cc +++ b/game/client/language.cc @@ -64,7 +64,7 @@ void language::init(void) LanguageInfo info; info.ietf = std::string(ietf); info.endonym = std::string(endonym); - info.display = fmt::format("{} ({})", endonym, ietf); + info.display = std::format("{} ({})", endonym, ietf); manifest.push_back(info); } } @@ -105,7 +105,7 @@ void language::init_late(void) void language::set(LanguageIterator new_language) { if(new_language != manifest.cend()) { - auto path = fmt::format("lang/lang.{}.json", new_language->ietf); + auto path = std::format("lang/lang.{}.json", new_language->ietf); auto file = PHYSFS_openRead(path.c_str()); @@ -192,5 +192,5 @@ std::string language::resolve_gui(const char* key) // We need window tags to retain their hierarchy when a language // dynamically changes; ImGui allows to provide hidden unique identifiers // to GUI primitives that have their name change dynamically, so we're using this - return fmt::format("{}###{}", language::resolve(key), key); + return std::format("{}###{}", language::resolve(key), key); } diff --git a/game/client/listener.cc b/game/client/listener.cc index 76a7bac..6b691eb 100644 --- a/game/client/listener.cc +++ b/game/client/listener.cc @@ -34,5 +34,5 @@ void listener::update(void) alListenerfv(AL_ORIENTATION, orientation); } - alListenerf(AL_GAIN, cxpr::clamp(sound::volume_master.get_value() * 0.01f, 0.0f, 1.0f)); + alListenerf(AL_GAIN, vx::clamp(sound::volume_master.get_value() * 0.01f, 0.0f, 1.0f)); } diff --git a/game/client/main.cc b/game/client/main.cc index 3ed28ea..d9e915c 100644 --- a/game/client/main.cc +++ b/game/client/main.cc @@ -4,7 +4,6 @@ #include "core/cmdline.hh" #include "core/config.hh" #include "core/epoch.hh" -#include "core/feature.hh" #include "core/image.hh" #include "core/resource.hh" #include "core/version.hh" @@ -122,7 +121,8 @@ static void on_glfw_window_focus(GLFWwindow* window, int focused) ImGui_ImplGlfw_WindowFocusCallback(window, focused); } -static void GLAD_API_PTR on_opengl_message(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* message, const void* param) +static void GLAD_API_PTR on_opengl_message( + GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* message, const void* param) { spdlog::info("opengl: {}", reinterpret_cast<const char*>(message)); } @@ -155,7 +155,7 @@ int main(int argc, char** argv) shared_game::init(argc, argv); - spdlog::info("Voxelius Client {}", PROJECT_VERSION_STRING); + spdlog::info("Voxelius Client {}", project_version_string); glfwSetErrorCallback(&on_glfw_error); @@ -306,8 +306,8 @@ int main(int argc, char** argv) if(auto vmode = cmdline::get("mode")) { std::sscanf(vmode, "%dx%d", &vmode_width, &vmode_height); - vmode_height = cxpr::max(vmode_height, MIN_HEIGHT); - vmode_width = cxpr::max(vmode_width, MIN_WIDTH); + vmode_height = vx::max(vmode_height, MIN_HEIGHT); + vmode_width = vx::max(vmode_width, MIN_WIDTH); } glfwSetWindowSize(globals::window, vmode_width, vmode_height); diff --git a/game/client/main_menu.cc b/game/client/main_menu.cc index 55a8021..39763ec 100644 --- a/game/client/main_menu.cc +++ b/game/client/main_menu.cc @@ -89,7 +89,7 @@ void main_menu::layout(void) ImGui::Dummy(ImVec2(0.0f, 32.0f * globals::gui_scale)); } else { auto reference_height = 0.225f * window_size.y; - auto image_width = cxpr::min(window_size.x, reference_height * title_aspect); + auto image_width = vx::min(window_size.x, reference_height * title_aspect); auto image_height = image_width / title_aspect; ImGui::SetCursorPosX(0.5f * (window_size.x - image_width)); ImGui::Image(title->handle, ImVec2(image_width, image_height)); @@ -152,7 +152,7 @@ void main_menu::layout(void) ImGui::PushFont(globals::font_debug); ImGui::SetCursorScreenPos(ImVec2(padding.x + spacing.x, window_size.y - globals::font_debug->FontSize - padding.y - spacing.y)); - ImGui::Text("Voxelius %s", PROJECT_VERSION_STRING); + ImGui::Text("Voxelius %s", project_version_string.c_str()); ImGui::PopFont(); } diff --git a/game/client/message_box.cc b/game/client/message_box.cc index e103e80..da1b715 100644 --- a/game/client/message_box.cc +++ b/game/client/message_box.cc @@ -87,7 +87,7 @@ void message_box::set_subtitle(const char* subtitle) void message_box::add_button(const char* text, const message_box_action& action) { Button button = {}; - button.str_title = fmt::format("{}###MessageBox_Button{}", language::resolve(text), buttons.size()); + button.str_title = std::format("{}###MessageBox_Button{}", language::resolve(text), buttons.size()); button.action = action; buttons.push_back(button); diff --git a/game/client/metrics.cc b/game/client/metrics.cc index 3d3c2b4..312ff77 100644 --- a/game/client/metrics.cc +++ b/game/client/metrics.cc @@ -2,7 +2,6 @@ #include "client/metrics.hh" -#include "core/feature.hh" #include "core/version.hh" #include "shared/coord.hh" @@ -18,7 +17,8 @@ #include "client/imdraw_ext.hh" #include "client/session.hh" -constexpr static ImGuiWindowFlags WINDOW_FLAGS = ImGuiWindowFlags_NoBackground | ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoInputs | ImGuiWindowFlags_NoNav; +constexpr static ImGuiWindowFlags WINDOW_FLAGS = ImGuiWindowFlags_NoBackground | ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoInputs + | ImGuiWindowFlags_NoNav; static std::basic_string<GLubyte> r_version; static std::basic_string<GLubyte> r_renderer; @@ -48,29 +48,29 @@ void metrics::layout(void) auto y_step = 1.5f * globals::font_debug->FontSize; // Draw version - auto version_line = fmt::format("Voxelius {}", PROJECT_VERSION_STRING); + auto version_line = std::format("Voxelius {}", project_version_string); imdraw_ext::text_shadow(version_line, position, text_color, shadow_color, globals::font_debug, draw_list); position.y += 1.5f * y_step; // Draw client-side window framerate metrics auto window_framerate = 1.0f / globals::window_frametime_avg; auto window_frametime = 1000.0f * globals::window_frametime_avg; - auto window_fps_line = fmt::format("{:.02f} FPS [{:.02f} ms]", window_framerate, window_frametime); + auto window_fps_line = std::format("{:.02f} FPS [{:.02f} ms]", window_framerate, window_frametime); imdraw_ext::text_shadow(window_fps_line, position, text_color, shadow_color, globals::font_debug, draw_list); position.y += y_step; // Draw world rendering metrics - auto drawcall_line = fmt::format("World: {} DC / {} TRI", globals::num_drawcalls, globals::num_triangles); + auto drawcall_line = std::format("World: {} DC / {} TRI", globals::num_drawcalls, globals::num_triangles); imdraw_ext::text_shadow(drawcall_line, position, text_color, shadow_color, globals::font_debug, draw_list); position.y += y_step; // Draw OpenGL version string - auto r_version_line = fmt::format("GL_VERSION: {}", reinterpret_cast<const char*>(r_version.c_str())); + auto r_version_line = std::format("GL_VERSION: {}", reinterpret_cast<const char*>(r_version.c_str())); imdraw_ext::text_shadow(r_version_line, position, text_color, shadow_color, globals::font_debug, draw_list); position.y += y_step; // Draw OpenGL renderer string - auto r_renderer_line = fmt::format("GL_RENDERER: {}", reinterpret_cast<const char*>(r_renderer.c_str())); + auto r_renderer_line = std::format("GL_RENDERER: {}", reinterpret_cast<const char*>(r_renderer.c_str())); imdraw_ext::text_shadow(r_renderer_line, position, text_color, shadow_color, globals::font_debug, draw_list); position.y += 1.5f * y_step; @@ -80,19 +80,19 @@ void metrics::layout(void) // Draw player voxel position auto voxel_position = coord::to_voxel(transform.chunk, transform.local); - auto voxel_line = fmt::format("voxel: [{} {} {}]", voxel_position.x, voxel_position.y, voxel_position.z); + auto voxel_line = std::format("voxel: [{} {} {}]", voxel_position.x, voxel_position.y, voxel_position.z); imdraw_ext::text_shadow(voxel_line, position, text_color, shadow_color, globals::font_debug, draw_list); position.y += y_step; // Draw player world position - auto world_line = fmt::format( - "world: [{} {} {}] [{:.03f} {:.03f} {:.03f}]", transform.chunk.x, transform.chunk.y, transform.chunk.z, transform.local.x, transform.local.y, transform.local.z); + auto world_line = std::format("world: [{} {} {}] [{:.03f} {:.03f} {:.03f}]", transform.chunk.x, transform.chunk.y, transform.chunk.z, + transform.local.x, transform.local.y, transform.local.z); imdraw_ext::text_shadow(world_line, position, text_color, shadow_color, globals::font_debug, draw_list); position.y += y_step; // Draw player look angles auto angles = glm::degrees(transform.angles + head.angles); - auto angle_line = fmt::format("angle: [{: .03f} {: .03f} {: .03f}]", angles[0], angles[1], angles[2]); + auto angle_line = std::format("angle: [{: .03f} {: .03f} {: .03f}]", angles[0], angles[1], angles[2]); imdraw_ext::text_shadow(angle_line, position, text_color, shadow_color, globals::font_debug, draw_list); position.y += y_step; } diff --git a/game/client/play_menu.cc b/game/client/play_menu.cc index e6b8d2c..b9a6693 100644 --- a/game/client/play_menu.cc +++ b/game/client/play_menu.cc @@ -88,7 +88,7 @@ static void parse_hostname(ServerStatusItem* item, const std::string& hostname) } if(parts.size() >= 2) { - item->port = cxpr::clamp<std::uint16_t>(strtoul(parts[1].c_str(), nullptr, 10), 1024, UINT16_MAX); + item->port = vx::clamp<std::uint16_t>(strtoul(parts[1].c_str(), nullptr, 10), 1024, UINT16_MAX); } else { item->port = protocol::PORT; } @@ -122,7 +122,7 @@ static void edit_selected_server(void) input_itemname = selected_server->name; if(selected_server->port != protocol::PORT) { - input_hostname = fmt::format("{}:{}", selected_server->hostname, selected_server->port); + input_hostname = std::format("{}:{}", selected_server->hostname, selected_server->port); } else { input_hostname = selected_server->hostname; } @@ -229,7 +229,7 @@ static void layout_server_item(ServerStatusItem* item) const float item_width = ImGui::GetContentRegionAvail().x; const float line_height = ImGui::GetTextLineHeightWithSpacing(); - const std::string sid = fmt::format("###play_menu.servers.{}", static_cast<void*>(item)); + const std::string sid = std::format("###play_menu.servers.{}", static_cast<void*>(item)); if(ImGui::Selectable(sid.c_str(), (item == selected_server), 0, ImVec2(0.0, 2.0f * (line_height + padding.y + spacing.y)))) { selected_server = item; editing_server = false; @@ -252,7 +252,7 @@ static void layout_server_item(ServerStatusItem* item) draw_list->AddText(name_pos, ImGui::GetColorU32(ImGuiCol_Text), item->name.c_str(), item->name.c_str() + item->name.size()); if(item->status == item_status::REACHED) { - auto stats = fmt::format("{}/{}", item->num_players, item->max_players); + auto stats = std::format("{}/{}", item->num_players, item->max_players); auto stats_width = ImGui::CalcTextSize(stats.c_str(), stats.c_str() + stats.size()).x; auto stats_pos = ImVec2(cursor.x + item_width - stats_width - padding.x, cursor.y + padding.y); draw_list->AddText(stats_pos, ImGui::GetColorU32(ImGuiCol_TextDisabled), stats.c_str(), stats.c_str() + stats.size()); @@ -318,7 +318,8 @@ static void layout_server_edit(ServerStatusItem* item) ImGui::BeginDisabled(ignore_input); - if(ImGui::Button("OK###play_menu.servers.submit_input", ImVec2(-1.0f, 0.0f)) || (!ignore_input && ImGui::IsKeyPressed(ImGuiKey_Enter))) { + if(ImGui::Button("OK###play_menu.servers.submit_input", ImVec2(-1.0f, 0.0f)) + || (!ignore_input && ImGui::IsKeyPressed(ImGuiKey_Enter))) { parse_hostname(item, input_hostname); item->password = input_password; item->name = input_itemname.substr(0, MAX_SERVER_ITEM_NAME); @@ -481,7 +482,7 @@ void play_menu::deinit(void) std::ostringstream stream; for(const auto item : servers_deque) { - stream << fmt::format("{}:{}%{}%{}", item->hostname, item->port, item->password, item->name) << std::endl; + stream << std::format("{}:{}%{}%{}", item->hostname, item->port, item->password, item->name) << std::endl; } if(auto file = PHYSFS_openWrite(SERVERS_TXT)) { diff --git a/game/client/player_look.cc b/game/client/player_look.cc index e1e4c8e..767c171 100644 --- a/game/client/player_look.cc +++ b/game/client/player_look.cc @@ -18,8 +18,8 @@ #include "client/session.hh" #include "client/settings.hh" -constexpr static float PITCH_MIN = -1.0f * cxpr::radians(90.0f); -constexpr static float PITCH_MAX = +1.0f * cxpr::radians(90.0f); +constexpr static float PITCH_MIN = -1.0f * vx::radians(90.0f); +constexpr static float PITCH_MAX = +1.0f * vx::radians(90.0f); // Mouse options static ConfigBoolean mouse_raw_input(true); @@ -47,7 +47,7 @@ static void add_angles(float pitch, float yaw) head.angles[0] += pitch; head.angles[1] += yaw; - head.angles[0] = cxpr::clamp(head.angles[0], PITCH_MIN, PITCH_MAX); + head.angles[0] = vx::clamp(head.angles[0], PITCH_MIN, PITCH_MAX); head.angles = cxangles::wrap_180(head.angles); // Client-side head angles are not interpolated; @@ -73,8 +73,8 @@ static void on_glfw_cursor_pos(const GlfwCursorPosEvent& event) return; } - auto dx = -0.01f * static_cast<float>(mouse_sensitivity.get_value()) * cxpr::radians(event.pos.x - last_cursor.x); - auto dy = -0.01f * static_cast<float>(mouse_sensitivity.get_value()) * cxpr::radians(event.pos.y - last_cursor.y); + auto dx = -0.01f * static_cast<float>(mouse_sensitivity.get_value()) * vx::radians(event.pos.x - last_cursor.x); + auto dy = -0.01f * static_cast<float>(mouse_sensitivity.get_value()) * vx::radians(event.pos.y - last_cursor.y); add_angles(dy, dx); last_cursor = event.pos; @@ -105,7 +105,8 @@ void player_look::init(void) settings::add_slider(1, gamepad_accel_yaw, settings_location::GAMEPAD_GAMEPLAY, "player_look.gamepad.accel_yaw", false); settings::add_gamepad_axis(2, axis_pitch, settings_location::GAMEPAD_GAMEPLAY, "player_look.gp_axis.pitch"); settings::add_gamepad_axis(3, axis_yaw, settings_location::GAMEPAD_GAMEPLAY, "player_look.gp_axis.yaw"); - settings::add_slider(4, gamepad_fastlook_factor, settings_location::GAMEPAD_GAMEPLAY, "player_look.gamepad.fastlook_factor", true, "%.02f"); + settings::add_slider( + 4, gamepad_fastlook_factor, settings_location::GAMEPAD_GAMEPLAY, "player_look.gamepad.fastlook_factor", true, "%.02f"); settings::add_gamepad_button(5, button_fastlook, settings_location::GAMEPAD_GAMEPLAY, "player_look.gp_button.fastlook"); fastlook_enabled = false; diff --git a/game/client/player_move.cc b/game/client/player_move.cc index 6c61dba..d949d53 100644 --- a/game/client/player_move.cc +++ b/game/client/player_move.cc @@ -70,7 +70,7 @@ static glm::fvec3 pm_accelerate(const glm::fvec3& wishdir, const glm::fvec3& vel return velocity; } - auto accel_speed = cxpr::min(add_speed, accel * globals::fixed_frametime * wishspeed); + auto accel_speed = vx::min(add_speed, accel * globals::fixed_frametime * wishspeed); auto result = glm::fvec3(velocity); result.x += accel_speed * wishdir.x; @@ -89,7 +89,7 @@ static glm::fvec3 pm_ground_move(const glm::fvec3& wishdir, const glm::fvec3& ve { if(auto speed = glm::length(velocity)) { auto speed_drop = speed * PMOVE_FRICTION_GROUND * globals::fixed_frametime; - auto speed_factor = cxpr::max(speed - speed_drop, 0.0f) / speed; + auto speed_factor = vx::max(speed - speed_drop, 0.0f) / speed; return pm_accelerate(wishdir, velocity * speed_factor, PMOVE_ACCELERATION_GROUND, PMOVE_MAX_SPEED_GROUND); } @@ -205,7 +205,7 @@ void player_move::fixed_update(void) velocity.value.y = -PMOVE_JUMP_FORCE * globals::dimension->get_gravity(); auto new_speed = glm::length(glm::fvec2(velocity.value.x, velocity.value.z)); - auto new_speed_text = fmt::format("{:.02f} M/S", new_speed); + auto new_speed_text = std::format("{:.02f} M/S", new_speed); auto speed_change = new_speed - speedometer_value; speedometer_value = new_speed; @@ -213,7 +213,7 @@ void player_move::fixed_update(void) next_jump_us = globals::curtime + PMOVE_JUMP_COOLDOWN; if(enable_speedometer.get_value()) { - if(cxpr::abs(speed_change) < 0.01f) { + if(vx::abs(speed_change) < 0.01f) { // No considerable speed increase within // the precision we use to draw the speedometer status_lines::set(STATUS_DEBUG, new_speed_text, ImVec4(0.7f, 0.7f, 0.7f, 1.0f), 1.0f); diff --git a/game/client/program.cc b/game/client/program.cc index 339cdf8..8d4403a 100644 --- a/game/client/program.cc +++ b/game/client/program.cc @@ -112,9 +112,9 @@ bool GL_Program::update(void) } for(const auto& macro : vert_variants) - vert_source[macro.line] = fmt::format("#define {} {}", macro.name, macro.value); + vert_source[macro.line] = std::format("#define {} {}", macro.name, macro.value); for(const auto& macro : frag_variants) - frag_source[macro.line] = fmt::format("#define {} {}", macro.name, macro.value); + frag_source[macro.line] = std::format("#define {} {}", macro.name, macro.value); const std::string vsource = strtools::join(vert_source, "\r\n"); const std::string fsource = strtools::join(frag_source, "\r\n"); diff --git a/game/client/progress_bar.cc b/game/client/progress_bar.cc index 104a5c9..dfab705 100644 --- a/game/client/progress_bar.cc +++ b/game/client/progress_bar.cc @@ -57,10 +57,10 @@ void progress_bar::layout(void) const float modifier = std::exp(-8.0f * (0.5f + 0.5f * sinval)); ImVec4 color = {}; - color.x = cxpr::lerp(background.x, foreground.x, modifier); - color.y = cxpr::lerp(background.y, foreground.y, modifier); - color.z = cxpr::lerp(background.z, foreground.z, modifier); - color.w = cxpr::lerp(background.w, foreground.w, modifier); + color.x = vx::lerp(background.x, foreground.x, modifier); + color.y = vx::lerp(background.y, foreground.y, modifier); + color.z = vx::lerp(background.z, foreground.z, modifier); + color.w = vx::lerp(background.w, foreground.w, modifier); const ImVec2 start = ImVec2(base_xpos + bar_width * i, base_ypos); const ImVec2 end = ImVec2(start.x + bar_width, start.y + bar_height); @@ -105,6 +105,6 @@ void progress_bar::set_title(const char* title) void progress_bar::set_button(const char* text, const progress_bar_action& action) { - str_button = fmt::format("{}###ProgressBar_Button", language::resolve(text)); + str_button = std::format("{}###ProgressBar_Button", language::resolve(text)); button_action = action; } diff --git a/game/client/receive.cc b/game/client/receive.cc index 57a76da..742d3af 100644 --- a/game/client/receive.cc +++ b/game/client/receive.cc @@ -33,7 +33,8 @@ static bool synchronize_entity_id(Dimension* dimension, entt::entity entity) } session::disconnect("protocol.entity_id_desync"); - spdlog::critical("receive: entity desync: network {} resolved as client {}", static_cast<std::uint64_t>(entity), static_cast<std::uint64_t>(created)); + spdlog::critical("receive: entity desync: network {} resolved as client {}", static_cast<std::uint64_t>(entity), + static_cast<std::uint64_t>(created)); message_box::reset(); message_box::set_title("disconnected.disconnected"); diff --git a/game/client/scoreboard.cc b/game/client/scoreboard.cc index e39b56c..b437234 100644 --- a/game/client/scoreboard.cc +++ b/game/client/scoreboard.cc @@ -12,7 +12,8 @@ #include "client/session.hh" #include "client/settings.hh" -constexpr static ImGuiWindowFlags WINDOW_FLAGS = ImGuiWindowFlags_NoBackground | ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoInputs | ImGuiWindowFlags_NoNav; +constexpr static ImGuiWindowFlags WINDOW_FLAGS = ImGuiWindowFlags_NoNav | ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoInputs + | ImGuiWindowFlags_NoBackground; static ConfigKeyBind list_key(GLFW_KEY_TAB); @@ -66,7 +67,7 @@ void scoreboard::layout(void) // Having a minimum size allows for // generally better in-game visibility - const float true_size = cxpr::max<float>(0.25f * window_size.x, max_username_size); + const float true_size = vx::max<float>(0.25f * window_size.x, max_username_size); // Figure out username rect dimensions const float rect_start_x = 0.5f * window_size.x - 0.5f * true_size; diff --git a/game/client/screenshot.cc b/game/client/screenshot.cc index 08b484b..a42a815 100644 --- a/game/client/screenshot.cc +++ b/game/client/screenshot.cc @@ -62,8 +62,8 @@ void screenshot::take(void) glPixelStorei(GL_PACK_ALIGNMENT, old_pack_alignment); const auto directory = std::string("screenshots"); - const auto filename = fmt::format("{}.png", epoch::microseconds()); - const auto filepath = fmt::format("{}/{}", directory, filename); + const auto filename = std::format("{}.png", epoch::microseconds()); + const auto filepath = std::format("{}/{}", directory, filename); PHYSFS_mkdir(directory.c_str()); @@ -73,7 +73,7 @@ void screenshot::take(void) spdlog::info("screenshot: wrote {}", filepath); - client_chat::print(fmt::format("{} {}", language::resolve("chat.screenshot_message"), filename)); + client_chat::print(std::format("{} {}", language::resolve("chat.screenshot_message"), filename)); PHYSFS_close(file); } diff --git a/game/client/session.cc b/game/client/session.cc index dcf0ef2..d3676f3 100644 --- a/game/client/session.cc +++ b/game/client/session.cc @@ -33,7 +33,7 @@ static std::uint64_t server_password_hash = UINT64_MAX; static void set_fixed_tickrate(std::uint16_t tickrate) { - globals::fixed_frametime_us = 1000000U / cxpr::clamp<std::uint64_t>(tickrate, 10U, 300U); + globals::fixed_frametime_us = 1000000U / vx::clamp<std::uint64_t>(tickrate, 10U, 300U); globals::fixed_frametime = static_cast<float>(globals::fixed_frametime_us) / 1000000.0f; globals::fixed_accumulator = 0; } diff --git a/game/client/settings.cc b/game/client/settings.cc index 93fe475..46e1bde 100644 --- a/game/client/settings.cc +++ b/game/client/settings.cc @@ -252,8 +252,8 @@ void SettingValue::layout_label(void) const void SettingValue_CheckBox::refresh_wids(void) { - wids[0] = fmt::format("{}###{}", str_checkbox_false, static_cast<void*>(value)); - wids[1] = fmt::format("{}###{}", str_checkbox_true, static_cast<void*>(value)); + wids[0] = std::format("{}###{}", str_checkbox_false, static_cast<void*>(value)); + wids[1] = std::format("{}###{}", str_checkbox_true, static_cast<void*>(value)); } void SettingValue_CheckBox::layout(void) const @@ -386,8 +386,8 @@ void SettingValue_StepperInt::layout(void) const void SettingValue_StepperInt::refresh_wids(void) { for(std::size_t i = 0; i < wids.size(); ++i) { - auto key = fmt::format("settings.value.{}.{}", name, i); - wids[i] = fmt::format("{}###{}", language::resolve(key.c_str()), static_cast<const void*>(value)); + auto key = std::format("settings.value.{}.{}", name, i); + wids[i] = std::format("{}###{}", language::resolve(key.c_str()), static_cast<const void*>(value)); } } @@ -416,8 +416,8 @@ void SettingValue_StepperUnsigned::layout(void) const void SettingValue_StepperUnsigned::refresh_wids(void) { for(std::size_t i = 0; i < wids.size(); ++i) { - auto key = fmt::format("settings.value.{}.{}", name, i); - wids[i] = fmt::format("{}###{}", language::resolve(key.c_str()), static_cast<const void*>(value)); + auto key = std::format("settings.value.{}.{}", name, i); + wids[i] = std::format("{}###{}", language::resolve(key.c_str()), static_cast<const void*>(value)); } } @@ -437,8 +437,8 @@ void SettingValue_KeyBind::layout(void) const void SettingValue_KeyBind::refresh_wids(void) { - wids[0] = fmt::format("...###{}", static_cast<const void*>(value)); - wids[1] = fmt::format("{}###{}", value->get(), static_cast<const void*>(value)); + wids[0] = std::format("...###{}", static_cast<const void*>(value)); + wids[1] = std::format("{}###{}", value->get(), static_cast<const void*>(value)); } void SettingValue_GamepadAxis::layout(void) const @@ -471,9 +471,9 @@ void SettingValue_GamepadAxis::layout(void) const void SettingValue_GamepadAxis::refresh_wids(void) { - wids[0] = fmt::format("...###{}", static_cast<const void*>(value)); - wids[1] = fmt::format("{}###{}", value->get_name(), static_cast<const void*>(value)); - wid_checkbox = fmt::format("###CHECKBOX_{}", static_cast<const void*>(value)); + wids[0] = std::format("...###{}", static_cast<const void*>(value)); + wids[1] = std::format("{}###{}", value->get_name(), static_cast<const void*>(value)); + wid_checkbox = std::format("###CHECKBOX_{}", static_cast<const void*>(value)); } void SettingValue_GamepadButton::layout(void) const @@ -492,8 +492,8 @@ void SettingValue_GamepadButton::layout(void) const void SettingValue_GamepadButton::refresh_wids(void) { - wids[0] = fmt::format("...###{}", static_cast<const void*>(value)); - wids[1] = fmt::format("{}###{}", value->get(), static_cast<const void*>(value)); + wids[0] = std::format("...###{}", static_cast<const void*>(value)); + wids[1] = std::format("{}###{}", value->get(), static_cast<const void*>(value)); } void SettingValue_Language::layout(void) const @@ -646,10 +646,10 @@ static void on_language_set(const LanguageSetEvent& event) stepper->refresh_wids(); } - value->title = language::resolve(fmt::format("settings.value.{}", value->name).c_str()); + value->title = language::resolve(std::format("settings.value.{}", value->name).c_str()); if(value->has_tooltip) { - value->tooltip = language::resolve(fmt::format("settings.tooltip.{}", value->name).c_str()); + value->tooltip = language::resolve(std::format("settings.tooltip.{}", value->name).c_str()); } } } @@ -864,7 +864,7 @@ void settings::add_input(int priority, ConfigInt& value, settings_location locat setting_value->value = &value; setting_value->name = name; - setting_value->wid = fmt::format("###{}", static_cast<const void*>(setting_value->value)); + setting_value->wid = std::format("###{}", static_cast<const void*>(setting_value->value)); values[static_cast<unsigned int>(location)].push_back(setting_value); values_all.push_back(setting_value); @@ -879,7 +879,7 @@ void settings::add_input(int priority, ConfigFloat& value, settings_location loc setting_value->value = &value; setting_value->name = name; - setting_value->wid = fmt::format("###{}", static_cast<const void*>(setting_value->value)); + setting_value->wid = std::format("###{}", static_cast<const void*>(setting_value->value)); values[static_cast<unsigned int>(location)].push_back(setting_value); values_all.push_back(setting_value); @@ -894,13 +894,14 @@ void settings::add_input(int priority, ConfigUnsigned& value, settings_location setting_value->value = &value; setting_value->name = name; - setting_value->wid = fmt::format("###{}", static_cast<const void*>(setting_value->value)); + setting_value->wid = std::format("###{}", static_cast<const void*>(setting_value->value)); values[static_cast<unsigned int>(location)].push_back(setting_value); values_all.push_back(setting_value); } -void settings::add_input(int priority, ConfigString& value, settings_location location, const char* name, bool tooltip, bool allow_whitespace) +void settings::add_input( + int priority, ConfigString& value, settings_location location, const char* name, bool tooltip, bool allow_whitespace) { auto setting_value = new SettingValue_InputString; setting_value->type = setting_type::INPUT_STRING; @@ -910,7 +911,7 @@ void settings::add_input(int priority, ConfigString& value, settings_location lo setting_value->name = name; setting_value->allow_whitespace = allow_whitespace; - setting_value->wid = fmt::format("###{}", static_cast<const void*>(setting_value->value)); + setting_value->wid = std::format("###{}", static_cast<const void*>(setting_value->value)); values[static_cast<unsigned int>(location)].push_back(setting_value); values_all.push_back(setting_value); @@ -925,7 +926,7 @@ void settings::add_slider(int priority, ConfigInt& value, settings_location loca setting_value->value = &value; setting_value->name = name; - setting_value->wid = fmt::format("###{}", static_cast<const void*>(setting_value->value)); + setting_value->wid = std::format("###{}", static_cast<const void*>(setting_value->value)); values[static_cast<unsigned int>(location)].push_back(setting_value); values_all.push_back(setting_value); @@ -941,7 +942,7 @@ void settings::add_slider(int priority, ConfigFloat& value, settings_location lo setting_value->name = name; setting_value->format = format; - setting_value->wid = fmt::format("###{}", static_cast<const void*>(setting_value->value)); + setting_value->wid = std::format("###{}", static_cast<const void*>(setting_value->value)); values[static_cast<unsigned int>(location)].push_back(setting_value); values_all.push_back(setting_value); @@ -956,7 +957,7 @@ void settings::add_slider(int priority, ConfigUnsigned& value, settings_location setting_value->value = &value; setting_value->name = name; - setting_value->wid = fmt::format("###{}", static_cast<const void*>(setting_value->value)); + setting_value->wid = std::format("###{}", static_cast<const void*>(setting_value->value)); values[static_cast<unsigned int>(location)].push_back(setting_value); values_all.push_back(setting_value); @@ -1047,7 +1048,7 @@ void settings::add_language_select(int priority, settings_location location, con setting_value->has_tooltip = false; setting_value->name = name; - setting_value->wid = fmt::format("###{}", static_cast<const void*>(setting_value)); + setting_value->wid = std::format("###{}", static_cast<const void*>(setting_value)); values[static_cast<unsigned int>(location)].push_back(setting_value); values_all.push_back(setting_value); diff --git a/game/client/sound.cc b/game/client/sound.cc index c3ea543..28e0143 100644 --- a/game/client/sound.cc +++ b/game/client/sound.cc @@ -84,11 +84,11 @@ void sound::deinit(void) void sound::update(void) { - auto effects_gain = cxpr::clamp(0.01f * sound::volume_effects.get_value(), 0.0f, 1.0f); + auto effects_gain = vx::clamp(0.01f * sound::volume_effects.get_value(), 0.0f, 1.0f); alSourcef(generic_source, AL_GAIN, effects_gain); alSourcef(player_source, AL_GAIN, effects_gain); - auto ui_gain = cxpr::clamp(0.01f * sound::volume_ui.get_value(), 0.0f, 1.0f); + auto ui_gain = vx::clamp(0.01f * sound::volume_ui.get_value(), 0.0f, 1.0f); alSourcef(ui_source, AL_GAIN, ui_gain); } @@ -137,7 +137,7 @@ void sound::play_generic(resource_ptr<SoundEffect> sound, bool looping, float pi if(sfx_generic) { alSourcei(generic_source, AL_BUFFER, sfx_generic->buffer); alSourcei(generic_source, AL_LOOPING, looping); - alSourcef(generic_source, AL_PITCH, cxpr::clamp(pitch, MIN_PITCH, MAX_PITCH)); + alSourcef(generic_source, AL_PITCH, vx::clamp(pitch, MIN_PITCH, MAX_PITCH)); alSourcePlay(generic_source); } } @@ -153,7 +153,7 @@ void sound::play_entity(entt::entity entity, resource_ptr<SoundEffect> sound, bo if(emitter->sound) { alSourcei(emitter->source, AL_BUFFER, emitter->sound->buffer); alSourcei(emitter->source, AL_LOOPING, looping); - alSourcef(emitter->source, AL_PITCH, cxpr::clamp(pitch, MIN_PITCH, MAX_PITCH)); + alSourcef(emitter->source, AL_PITCH, vx::clamp(pitch, MIN_PITCH, MAX_PITCH)); alSourcePlay(emitter->source); } } @@ -179,7 +179,7 @@ void sound::play_player(resource_ptr<SoundEffect> sound, bool looping, float pit if(sfx_player) { alSourcei(player_source, AL_BUFFER, sfx_player->buffer); alSourcei(player_source, AL_LOOPING, looping); - alSourcef(player_source, AL_PITCH, cxpr::clamp(pitch, MIN_PITCH, MAX_PITCH)); + alSourcef(player_source, AL_PITCH, vx::clamp(pitch, MIN_PITCH, MAX_PITCH)); alSourcePlay(player_source); } } @@ -193,7 +193,7 @@ void sound::play_ui(resource_ptr<SoundEffect> sound, bool looping, float pitch) if(sfx_ui) { alSourcei(ui_source, AL_BUFFER, sfx_ui->buffer); alSourcei(ui_source, AL_LOOPING, looping); - alSourcef(ui_source, AL_PITCH, cxpr::clamp(pitch, MIN_PITCH, MAX_PITCH)); + alSourcef(ui_source, AL_PITCH, vx::clamp(pitch, MIN_PITCH, MAX_PITCH)); alSourcePlay(ui_source); } }
\ No newline at end of file diff --git a/game/client/sound_emitter.cc b/game/client/sound_emitter.cc index fd58c50..9b84df2 100644 --- a/game/client/sound_emitter.cc +++ b/game/client/sound_emitter.cc @@ -32,7 +32,7 @@ void SoundEmitterComponent::update(void) const auto view = globals::dimension->entities.view<SoundEmitterComponent>(); const auto& pivot = camera::position_chunk; - const auto gain = cxpr::clamp(sound::volume_effects.get_value() * 0.01f, 0.0f, 1.0f); + const auto gain = vx::clamp(sound::volume_effects.get_value() * 0.01f, 0.0f, 1.0f); for(const auto [entity, emitter] : view.each()) { alSourcef(emitter.source, AL_GAIN, gain); diff --git a/game/client/splash.cc b/game/client/splash.cc index 96159d2..f9c616b 100644 --- a/game/client/splash.cc +++ b/game/client/splash.cc @@ -5,7 +5,6 @@ #include "core/cmdline.hh" #include "core/constexpr.hh" #include "core/epoch.hh" -#include "core/feature.hh" #include "core/resource.hh" #include "client/glfw.hh" @@ -93,7 +92,7 @@ void client_splash::init_late(void) break; } - texture_alpha = cxpr::smoothstep(0.25f, 0.6f, static_cast<float>(remains) / static_cast<float>(DELAY_MICROSECONDS)); + texture_alpha = vx::smoothstep(0.25f, 0.6f, static_cast<float>(remains) / static_cast<float>(DELAY_MICROSECONDS)); client_splash::render(); } diff --git a/game/client/toggles.cc b/game/client/toggles.cc index fff8f4d..f40d6ed 100644 --- a/game/client/toggles.cc +++ b/game/client/toggles.cc @@ -25,9 +25,9 @@ static void print_toggle_state(const ToggleInfo& info) { if(info.description) { if(info.is_enabled) { - client_chat::print(fmt::format("[toggles] {} ON", info.description)); + client_chat::print(std::format("[toggles] {} ON", info.description)); } else { - client_chat::print(fmt::format("[toggles] {} OFF", info.description)); + client_chat::print(std::format("[toggles] {} OFF", info.description)); } } } diff --git a/game/client/voxel_atlas.cc b/game/client/voxel_atlas.cc index 0ce872f..ef996e2 100644 --- a/game/client/voxel_atlas.cc +++ b/game/client/voxel_atlas.cc @@ -71,7 +71,8 @@ static AtlasStrip* plane_new_strip(AtlasPlane& plane, const std::vector<std::str } const std::size_t offset = strip.offset + i; - glTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, offset, image->size.x, image->size.y, 1, GL_RGBA, GL_UNSIGNED_BYTE, image->pixels); + glTexSubImage3D( + GL_TEXTURE_2D_ARRAY, 0, 0, 0, offset, image->size.x, image->size.y, 1, GL_RGBA, GL_UNSIGNED_BYTE, image->pixels); } } @@ -87,19 +88,19 @@ void voxel_atlas::create(int width, int height, std::size_t count) { GLint max_plane_layers; - atlas_width = 1 << cxpr::log2(width); - atlas_height = 1 << cxpr::log2(height); + atlas_width = 1 << vx::log2(width); + atlas_height = 1 << vx::log2(height); // Clipping this at OpenGL 4.5 limit of 2048 is important due to // how voxel quad meshes are packed in memory: each texture index is // confined in 11 bits so having bigger atlas planes makes no sense; glGetIntegerv(GL_MAX_ARRAY_TEXTURE_LAYERS, &max_plane_layers); - max_plane_layers = cxpr::clamp(max_plane_layers, 256, 2048); + max_plane_layers = vx::clamp(max_plane_layers, 256, 2048); for(long i = count; i > 0L; i -= max_plane_layers) { AtlasPlane plane = {}; plane.plane_id = planes.size(); - plane.layer_count_max = cxpr::min<std::size_t>(max_plane_layers, i); + plane.layer_count_max = vx::min<std::size_t>(max_plane_layers, i); plane.layer_count = 0; const std::size_t save_id = plane.plane_id; diff --git a/game/client/window_title.cc b/game/client/window_title.cc index cfa25a3..517429d 100644 --- a/game/client/window_title.cc +++ b/game/client/window_title.cc @@ -2,7 +2,6 @@ #include "client/window_title.hh" -#include "core/feature.hh" #include "core/version.hh" #include "shared/splash.hh" @@ -14,9 +13,9 @@ void window_title::update(void) std::string title; if(globals::sound_ctx && globals::sound_dev) { - title = fmt::format("Voxelius {}: {}", PROJECT_VERSION_STRING, splash::get()); + title = std::format("Voxelius {}: {}", project_version_string, splash::get()); } else { - title = fmt::format("Voxelius {}: {} [NOSOUND]", PROJECT_VERSION_STRING, splash::get()); + title = std::format("Voxelius {}: {} [NOSOUND]", project_version_string, splash::get()); } glfwSetWindowTitle(globals::window, title.c_str()); diff --git a/game/server/CMakeLists.txt b/game/server/CMakeLists.txt index c2b6c06..a9c5cc9 100644 --- a/game/server/CMakeLists.txt +++ b/game/server/CMakeLists.txt @@ -24,7 +24,7 @@ add_executable(vserver "${CMAKE_CURRENT_LIST_DIR}/whitelist.hh" "${CMAKE_CURRENT_LIST_DIR}/worldgen.cc" "${CMAKE_CURRENT_LIST_DIR}/worldgen.hh") -target_compile_features(vserver PUBLIC cxx_std_17) +target_compile_features(vserver PUBLIC cxx_std_20) target_include_directories(vserver PUBLIC "${DEPS_INCLUDE_DIR}") target_include_directories(vserver PRIVATE "${PROJECT_SOURCE_DIR}") target_include_directories(vserver PRIVATE "${PROJECT_SOURCE_DIR}/game") diff --git a/game/server/main.cc b/game/server/main.cc index 42e76f4..734ae6a 100644 --- a/game/server/main.cc +++ b/game/server/main.cc @@ -30,7 +30,7 @@ int main(int argc, char** argv) shared_game::init(argc, argv); - spdlog::info("Voxelius Server {}", PROJECT_VERSION_STRING); + spdlog::info("Voxelius Server {}", project_version_string); globals::fixed_frametime = 0.0f; globals::fixed_frametime_avg = 0.0f; diff --git a/game/server/overworld.cc b/game/server/overworld.cc index 7021717..a280e06 100644 --- a/game/server/overworld.cc +++ b/game/server/overworld.cc @@ -12,7 +12,7 @@ static void compute_tree_feature(unsigned int height, Feature& feature, voxel_id log_voxel, voxel_id leaves_voxel) { // Ensure the tree height is too small - height = cxpr::max<unsigned int>(height, 4U); + height = vx::max<unsigned int>(height, 4U); // Put down a single piece of dirt feature.push_back({ voxel_pos(0, -1, 0), game_voxels::dirt, true }); @@ -214,14 +214,14 @@ const Overworld_Metadata& Overworld::get_or_create_metadata(const chunk_pos_xz& } auto nvdi_value = 0.5f + 0.5f * fnlGetNoise2D(&m_fnl_nvdi, cpos.x, cpos.y); - auto tree_density = (nvdi_value >= 0.33f) ? cxpr::floor<unsigned int>(nvdi_value * 4.0f) : 0U; + auto tree_density = (nvdi_value >= 0.33f) ? vx::floor<unsigned int>(nvdi_value * 4.0f) : 0U; for(unsigned int i = 0U; i < tree_density; ++i) { auto lpos = local_pos((twister() % CHUNK_SIZE), (twister() % OW_NUM_TREES), (twister() % CHUNK_SIZE)); auto is_unique = true; for(const auto& check_lpos : metadata.trees) { - if(cxvectors::distance2(check_lpos, lpos) <= 9) { + if(vx::distance2(check_lpos, lpos) <= 9) { is_unique = false; break; } @@ -350,7 +350,7 @@ void Overworld::generate_features(const chunk_pos& cpos, VoxelStorage& voxels) chunk_pos_xz(cpos.x + 1, cpos.z + 1), }; - for(unsigned int i = 0U; i < cxpr::array_size(tree_chunks); ++i) { + for(unsigned int i = 0U; i < vx::array_size(tree_chunks); ++i) { const auto& cpos_xz = tree_chunks[i]; const auto& metadata = get_or_create_metadata(cpos_xz); diff --git a/game/server/sessions.cc b/game/server/sessions.cc index a8745cb..43abbb7 100644 --- a/game/server/sessions.cc +++ b/game/server/sessions.cc @@ -115,11 +115,8 @@ static void on_login_request_packet(const protocol::LoginRequest& packet) dim_info.gravity = globals::spawn_dimension->get_gravity(); protocol::send(packet.peer, protocol::encode(dim_info)); - spdlog::info("sessions: {} [{}] logged in with client_index={} in {}", - session->client_username, - session->client_identity, - session->client_index, - globals::spawn_dimension->get_name()); + spdlog::info("sessions: {} [{}] logged in with client_index={} in {}", session->client_username, session->client_identity, + session->client_index, globals::spawn_dimension->get_name()); // FIXME: only send entities that are present within the current // player's view bounding box; this also would mean we're not sending diff --git a/game/server/universe.cc b/game/server/universe.cc index e7b8b0f..96884cf 100644 --- a/game/server/universe.cc +++ b/game/server/universe.cc @@ -33,7 +33,7 @@ static std::string make_chunk_filename(const DimensionMetadata* metadata, const const auto unsigned_x = static_cast<std::uint32_t>(cpos.x); const auto unsigned_y = static_cast<std::uint32_t>(cpos.y); const auto unsigned_z = static_cast<std::uint32_t>(cpos.z); - return fmt::format("{}/{:08X}-{:08X}-{:08X}.zvox", metadata->zvox_dir, unsigned_x, unsigned_y, unsigned_z); + return std::format("{}/{:08X}-{:08X}-{:08X}.zvox", metadata->zvox_dir, unsigned_x, unsigned_y, unsigned_z); } static void add_new_dimension(Dimension* dimension) @@ -43,7 +43,7 @@ static void add_new_dimension(Dimension* dimension) std::terminate(); } - auto dimension_dir = fmt::format("{}/{}", universe_name.get(), dimension->get_name()); + auto dimension_dir = std::format("{}/{}", universe_name.get(), dimension->get_name()); if(!PHYSFS_mkdir(dimension_dir.c_str())) { spdlog::critical("universe: {}: {}", dimension_dir, PHYSFS_getErrorByCode(PHYSFS_getLastErrorCode())); @@ -51,8 +51,8 @@ static void add_new_dimension(Dimension* dimension) } auto metadata = new DimensionMetadata; - metadata->config_path = fmt::format("{}/dimension.conf", dimension_dir); - metadata->zvox_dir = fmt::format("{}/chunk", dimension_dir); + metadata->config_path = std::format("{}/dimension.conf", dimension_dir); + metadata->zvox_dir = std::format("{}/chunk", dimension_dir); if(!PHYSFS_mkdir(metadata->zvox_dir.c_str())) { spdlog::critical("universe: {}: {}", metadata->zvox_dir, PHYSFS_getErrorByCode(PHYSFS_getLastErrorCode())); @@ -107,7 +107,7 @@ void universe::init_late(void) std::terminate(); } - universe_config_path = fmt::format("{}/universe.conf", universe_dir); + universe_config_path = std::format("{}/universe.conf", universe_dir); universe_config.load_file(universe_config_path.c_str()); add_new_dimension(new Overworld("world")); diff --git a/game/shared/CMakeLists.txt b/game/shared/CMakeLists.txt index b0cd086..e9d3762 100644 --- a/game/shared/CMakeLists.txt +++ b/game/shared/CMakeLists.txt @@ -49,9 +49,9 @@ add_library(shared STATIC "${CMAKE_CURRENT_LIST_DIR}/voxel_registry.hh" "${CMAKE_CURRENT_LIST_DIR}/voxel_storage.cc" "${CMAKE_CURRENT_LIST_DIR}/voxel_storage.hh") -target_compile_features(shared PUBLIC cxx_std_17) +target_compile_features(shared PUBLIC cxx_std_20) target_include_directories(shared PUBLIC "${DEPS_INCLUDE_DIR}") target_include_directories(shared PRIVATE "${PROJECT_SOURCE_DIR}") target_include_directories(shared PRIVATE "${PROJECT_SOURCE_DIR}/game") target_precompile_headers(shared PRIVATE "${CMAKE_CURRENT_LIST_DIR}/pch.hh") -target_link_libraries(shared PUBLIC core enet FNL miniz parson) +target_link_libraries(shared PUBLIC core enet entt FNL miniz parson thread_pool) diff --git a/game/shared/collision.cc b/game/shared/collision.cc index af880ab..dd51dd5 100644 --- a/game/shared/collision.cc +++ b/game/shared/collision.cc @@ -13,10 +13,11 @@ #include "shared/velocity.hh" #include "shared/voxel_registry.hh" -static int vgrid_collide(const Dimension* dimension, int d, CollisionComponent& collision, TransformComponent& transform, VelocityComponent& velocity, voxel_surface& touch_surface) +static int vgrid_collide(const Dimension* dimension, int d, CollisionComponent& collision, TransformComponent& transform, + VelocityComponent& velocity, voxel_surface& touch_surface) { const auto move = globals::fixed_frametime * velocity.value[d]; - const auto move_sign = cxpr::sign<int>(move); + const auto move_sign = vx::sign<int>(move); const auto& ref_aabb = collision.aabb; const auto current_aabb = ref_aabb.push(transform.local); @@ -26,14 +27,14 @@ static int vgrid_collide(const Dimension* dimension, int d, CollisionComponent& next_aabb.max[d] += move; local_pos lpos_min; - lpos_min.x = cxpr::floor<local_pos::value_type>(next_aabb.min.x); - lpos_min.y = cxpr::floor<local_pos::value_type>(next_aabb.min.y); - lpos_min.z = cxpr::floor<local_pos::value_type>(next_aabb.min.z); + lpos_min.x = vx::floor<local_pos::value_type>(next_aabb.min.x); + lpos_min.y = vx::floor<local_pos::value_type>(next_aabb.min.y); + lpos_min.z = vx::floor<local_pos::value_type>(next_aabb.min.z); local_pos lpos_max; - lpos_max.x = cxpr::ceil<local_pos::value_type>(next_aabb.max.x); - lpos_max.y = cxpr::ceil<local_pos::value_type>(next_aabb.max.y); - lpos_max.z = cxpr::ceil<local_pos::value_type>(next_aabb.max.z); + lpos_max.x = vx::ceil<local_pos::value_type>(next_aabb.max.x); + lpos_max.y = vx::ceil<local_pos::value_type>(next_aabb.max.y); + lpos_max.z = vx::ceil<local_pos::value_type>(next_aabb.max.z); // Other axes const int u = (d + 1) % 3; @@ -108,7 +109,7 @@ static int vgrid_collide(const Dimension* dimension, int d, CollisionComponent& if(latch_touch != voxel_touch::NOTHING) { if(latch_touch == voxel_touch::BOUNCE) { - const auto move_distance = cxpr::abs(current_aabb.min[d] - next_aabb.min[d]); + const auto move_distance = vx::abs(current_aabb.min[d] - next_aabb.min[d]); const auto threshold = 2.0f * globals::fixed_frametime; if(move_distance > threshold) { @@ -150,7 +151,7 @@ void CollisionComponent::fixed_update(Dimension* dimension) auto vertical_move = vgrid_collide(dimension, 1, collision, transform, velocity, surface); if(dimension->entities.any_of<GravityComponent>(entity)) { - if(vertical_move == cxpr::sign<int>(dimension->get_gravity())) { + if(vertical_move == vx::sign<int>(dimension->get_gravity())) { dimension->entities.emplace_or_replace<GroundedComponent>(entity, GroundedComponent { surface }); } else { dimension->entities.remove<GroundedComponent>(entity); diff --git a/game/shared/const.hh b/game/shared/const.hh index 8f8f0f9..4639c4b 100644 --- a/game/shared/const.hh +++ b/game/shared/const.hh @@ -7,7 +7,7 @@ constexpr static unsigned int CHUNK_SIZE = 16; constexpr static unsigned int CHUNK_AREA = CHUNK_SIZE * CHUNK_SIZE; constexpr static unsigned int CHUNK_VOLUME = CHUNK_SIZE * CHUNK_SIZE * CHUNK_SIZE; -constexpr static unsigned int CHUNK_BITSHIFT = cxpr::log2(CHUNK_SIZE); +constexpr static unsigned int CHUNK_BITSHIFT = vx::log2(CHUNK_SIZE); template<typename T> constexpr static glm::vec<3, T> DIR_NORTH = glm::vec<3, T>(0, 0, +1); diff --git a/game/shared/coord.hh b/game/shared/coord.hh index 4a11e60..f1a2e70 100644 --- a/game/shared/coord.hh +++ b/game/shared/coord.hh @@ -53,9 +53,9 @@ inline constexpr chunk_pos coord::to_chunk(const voxel_pos& vpos) inline constexpr local_pos coord::to_local(const voxel_pos& vpos) { return local_pos { - static_cast<local_pos::value_type>(cxpr::mod_signed<voxel_pos::value_type>(vpos.x, CHUNK_SIZE)), - static_cast<local_pos::value_type>(cxpr::mod_signed<voxel_pos::value_type>(vpos.y, CHUNK_SIZE)), - static_cast<local_pos::value_type>(cxpr::mod_signed<voxel_pos::value_type>(vpos.z, CHUNK_SIZE)), + static_cast<local_pos::value_type>(vx::mod_signed<voxel_pos::value_type>(vpos.x, CHUNK_SIZE)), + static_cast<local_pos::value_type>(vx::mod_signed<voxel_pos::value_type>(vpos.y, CHUNK_SIZE)), + static_cast<local_pos::value_type>(vx::mod_signed<voxel_pos::value_type>(vpos.z, CHUNK_SIZE)), }; } @@ -118,7 +118,8 @@ inline constexpr glm::fvec3 coord::to_relative(const chunk_pos& pivot_cpos, cons }; } -inline constexpr glm::fvec3 coord::to_relative(const chunk_pos& pivot_cpos, const glm::fvec3& pivot_fvec, const chunk_pos& cpos, const glm::fvec3& fvec) +inline constexpr glm::fvec3 coord::to_relative( + const chunk_pos& pivot_cpos, const glm::fvec3& pivot_fvec, const chunk_pos& cpos, const glm::fvec3& fvec) { return glm::fvec3 { static_cast<float>((cpos.x - pivot_cpos.x) << CHUNK_BITSHIFT) + (fvec.x - pivot_fvec.x), diff --git a/game/shared/game_items.cc b/game/shared/game_items.cc index f2f1c0c..6351969 100644 --- a/game/shared/game_items.cc +++ b/game/shared/game_items.cc @@ -19,31 +19,41 @@ item_id game_items::mud = NULL_ITEM_ID; void game_items::populate(void) { // Stone; a hardened slate rock - game_items::stone = item_registry::construct("stone").set_texture("textures/item/stone.png").set_place_voxel(game_voxels::stone).build(); + game_items::stone = + item_registry::construct("stone").set_texture("textures/item/stone.png").set_place_voxel(game_voxels::stone).build(); // Cobblestone; a bunch of small stones - game_items::cobblestone = item_registry::construct("cobblestone").set_texture("textures/item/cobblestone.png").set_place_voxel(game_voxels::cobblestone).build(); + game_items::cobblestone = item_registry::construct("cobblestone") + .set_texture("textures/item/cobblestone.png") + .set_place_voxel(game_voxels::cobblestone) + .build(); // Dirt; it's very dirty game_items::dirt = item_registry::construct("dirt").set_texture("textures/item/dirt.png").set_place_voxel(game_voxels::dirt).build(); // Grass; literally just grassy dirt - game_items::grass = item_registry::construct("grass").set_texture("textures/item/grass.png").set_place_voxel(game_voxels::grass).build(); + game_items::grass = + item_registry::construct("grass").set_texture("textures/item/grass.png").set_place_voxel(game_voxels::grass).build(); // Oak leaves; they're bushy! - game_items::oak_leaves = item_registry::construct("oak_leaves").set_texture("textures/item/oak_leaves.png").set_place_voxel(game_voxels::oak_leaves).build(); + game_items::oak_leaves = + item_registry::construct("oak_leaves").set_texture("textures/item/oak_leaves.png").set_place_voxel(game_voxels::oak_leaves).build(); // Oak planks; watch for splinters! - game_items::oak_planks = item_registry::construct("oak_planks").set_texture("textures/item/oak_planks.png").set_place_voxel(game_voxels::oak_planks).build(); + game_items::oak_planks = + item_registry::construct("oak_planks").set_texture("textures/item/oak_planks.png").set_place_voxel(game_voxels::oak_planks).build(); // Oak log; a big wad of wood - game_items::oak_log = item_registry::construct("oak_log").set_texture("textures/item/oak_log.png").set_place_voxel(game_voxels::oak_log).build(); + game_items::oak_log = + item_registry::construct("oak_log").set_texture("textures/item/oak_log.png").set_place_voxel(game_voxels::oak_log).build(); // Glass; used for windowing - game_items::glass = item_registry::construct("glass").set_texture("textures/item/glass.png").set_place_voxel(game_voxels::glass).build(); + game_items::glass = + item_registry::construct("glass").set_texture("textures/item/glass.png").set_place_voxel(game_voxels::glass).build(); // Slime; it's bouncy! - game_items::slime = item_registry::construct("slime").set_texture("textures/item/slime.png").set_place_voxel(game_voxels::slime).build(); + game_items::slime = + item_registry::construct("slime").set_texture("textures/item/slime.png").set_place_voxel(game_voxels::slime).build(); // Mud; you sink in it! game_items::mud = item_registry::construct("mud").set_texture("textures/item/mud.png").build(); diff --git a/game/shared/game_voxels.cc b/game/shared/game_voxels.cc index 23c953b..72410fc 100644 --- a/game/shared/game_voxels.cc +++ b/game/shared/game_voxels.cc @@ -66,11 +66,14 @@ void game_voxels::populate(void) .build(); // VTest-CK; a pure blue chromakey I used to make the game's logo - game_voxels::vtest_ck = voxel_registry::construct("vtest_ck", voxel_type::CUBE, false, false).add_texture_default("textures/voxel/chromakey.png").build(); + game_voxels::vtest_ck = + voxel_registry::construct("vtest_ck", voxel_type::CUBE, false, false).add_texture_default("textures/voxel/chromakey.png").build(); // Oak leaves; greenery. TODO: add trees as surface features - game_voxels::oak_leaves = - voxel_registry::construct("oak_leaves", voxel_type::CUBE, false, false).add_texture_default("textures/voxel/oak_leaves.png").set_surface(voxel_surface::GRASS).build(); + game_voxels::oak_leaves = voxel_registry::construct("oak_leaves", voxel_type::CUBE, false, false) + .add_texture_default("textures/voxel/oak_leaves.png") + .set_surface(voxel_surface::GRASS) + .build(); // Oak planks; the thing that comes out of oak logs game_voxels::oak_planks = voxel_registry::construct("oak_planks", voxel_type::CUBE, false, false) @@ -89,8 +92,10 @@ void game_voxels::populate(void) .build(); // Glass; blend rendering test - game_voxels::glass = - voxel_registry::construct("glass", voxel_type::CUBE, false, true).add_texture_default("textures/voxel/glass_01.png").set_surface(voxel_surface::GLASS).build(); + game_voxels::glass = voxel_registry::construct("glass", voxel_type::CUBE, false, true) + .add_texture_default("textures/voxel/glass_01.png") + .set_surface(voxel_surface::GLASS) + .build(); // Slime; it's bouncy! game_voxels::slime = voxel_registry::construct("slime", voxel_type::CUBE, false, true) diff --git a/game/shared/ray_dda.cc b/game/shared/ray_dda.cc index 3520817..75d4386 100644 --- a/game/shared/ray_dda.cc +++ b/game/shared/ray_dda.cc @@ -22,9 +22,9 @@ void RayDDA::reset(const Dimension* dimension, const chunk_pos& start_chunk, con this->start_fpos = start_fpos; this->direction = direction; - this->delta_dist.x = direction.x ? cxpr::abs(1.0f / direction.x) : std::numeric_limits<float>::max(); - this->delta_dist.y = direction.y ? cxpr::abs(1.0f / direction.y) : std::numeric_limits<float>::max(); - this->delta_dist.z = direction.z ? cxpr::abs(1.0f / direction.z) : std::numeric_limits<float>::max(); + this->delta_dist.x = direction.x ? vx::abs(1.0f / direction.x) : std::numeric_limits<float>::max(); + this->delta_dist.y = direction.y ? vx::abs(1.0f / direction.y) : std::numeric_limits<float>::max(); + this->delta_dist.z = direction.z ? vx::abs(1.0f / direction.z) : std::numeric_limits<float>::max(); this->distance = 0.0f; this->vpos = coord::to_voxel(start_chunk, start_fpos); diff --git a/game/shared/splash.cc b/game/shared/splash.cc index 2381f7a..0cd5f50 100644 --- a/game/shared/splash.cc +++ b/game/shared/splash.cc @@ -36,7 +36,7 @@ static void splash_init_filename(const char* filename) splash_lines.push_back(sanitize_line(line)); splash_random.seed(std::random_device()()); } else { - splash_lines.push_back(fmt::format("{}: {}", filename, PHYSFS_getErrorByCode(PHYSFS_getLastErrorCode()))); + splash_lines.push_back(std::format("{}: {}", filename, PHYSFS_getErrorByCode(PHYSFS_getLastErrorCode()))); splash_random.seed(std::random_device()()); } } diff --git a/game/shared/threading.cc b/game/shared/threading.cc index ad496ee..9e46d17 100644 --- a/game/shared/threading.cc +++ b/game/shared/threading.cc @@ -44,9 +44,9 @@ void threading::init(void) thread_pool_size = num_concurrent_threads; } else { if(num_concurrent_threads) { - thread_pool_size = cxpr::clamp<unsigned int>(std::strtoul(argument, nullptr, 10), 1U, num_concurrent_threads); + thread_pool_size = vx::clamp<unsigned int>(std::strtoul(argument, nullptr, 10), 1U, num_concurrent_threads); } else { - thread_pool_size = cxpr::max<unsigned int>(std::strtoul(argument, nullptr, 10), 1U); + thread_pool_size = vx::max<unsigned int>(std::strtoul(argument, nullptr, 10), 1U); } } |
