summaryrefslogtreecommitdiffstats
path: root/platform
diff options
context:
space:
mode:
Diffstat (limited to 'platform')
-rw-r--r--platform/android/export/export.cpp18
-rw-r--r--platform/android/export/export_plugin.cpp7
-rw-r--r--platform/android/export/gradle_export_util.cpp5
-rw-r--r--platform/linuxbsd/wayland/wayland_thread.cpp6
-rw-r--r--platform/macos/export/export_plugin.cpp4
-rw-r--r--platform/web/api/web_tools_editor_plugin.cpp2
-rw-r--r--platform/windows/display_server_windows.h1
-rw-r--r--platform/windows/os_windows.cpp24
-rw-r--r--platform/windows/os_windows.h1
9 files changed, 49 insertions, 19 deletions
diff --git a/platform/android/export/export.cpp b/platform/android/export/export.cpp
index d2b64c74a4..dc7a287a91 100644
--- a/platform/android/export/export.cpp
+++ b/platform/android/export/export.cpp
@@ -37,6 +37,8 @@
#include "editor/editor_settings.h"
#include "editor/export/editor_export.h"
+String get_default_android_sdk_path();
+
void register_android_exporter_types() {
GDREGISTER_VIRTUAL_CLASS(EditorExportPlatformAndroid);
}
@@ -54,8 +56,10 @@ void register_android_exporter() {
#else
EDITOR_DEF_BASIC("export/android/java_sdk_path", OS::get_singleton()->get_environment("JAVA_HOME"));
EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING, "export/android/java_sdk_path", PROPERTY_HINT_GLOBAL_DIR));
- EDITOR_DEF_BASIC("export/android/android_sdk_path", OS::get_singleton()->get_environment("ANDROID_HOME"));
+
+ EDITOR_DEF_BASIC("export/android/android_sdk_path", OS::get_singleton()->has_environment("ANDROID_HOME") ? OS::get_singleton()->get_environment("ANDROID_HOME") : get_default_android_sdk_path());
EditorSettings::get_singleton()->add_property_hint(PropertyInfo(Variant::STRING, "export/android/android_sdk_path", PROPERTY_HINT_GLOBAL_DIR));
+
EDITOR_DEF("export/android/force_system_user", false);
EDITOR_DEF("export/android/shutdown_adb_on_exit", true);
@@ -69,3 +73,15 @@ void register_android_exporter() {
Ref<EditorExportPlatformAndroid> exporter = Ref<EditorExportPlatformAndroid>(memnew(EditorExportPlatformAndroid));
EditorExport::get_singleton()->add_export_platform(exporter);
}
+
+inline String get_default_android_sdk_path() {
+#ifdef WINDOWS_ENABLED
+ return OS::get_singleton()->get_environment("LOCALAPPDATA").path_join("Android/Sdk");
+#elif LINUXBSD_ENABLED
+ return OS::get_singleton()->get_environment("HOME").path_join("Android/Sdk");
+#elif MACOS_ENABLED
+ return OS::get_singleton()->get_environment("HOME").path_join("Library/Android/sdk");
+#else
+ return String();
+#endif
+}
diff --git a/platform/android/export/export_plugin.cpp b/platform/android/export/export_plugin.cpp
index df3142ecbb..e20de99c2d 100644
--- a/platform/android/export/export_plugin.cpp
+++ b/platform/android/export/export_plugin.cpp
@@ -790,9 +790,10 @@ Error EditorExportPlatformAndroid::save_apk_so(void *p_userdata, const SharedObj
Error EditorExportPlatformAndroid::save_apk_file(void *p_userdata, const String &p_path, const Vector<uint8_t> &p_data, int p_file, int p_total, const Vector<String> &p_enc_in_filters, const Vector<String> &p_enc_ex_filters, const Vector<uint8_t> &p_key, uint64_t p_seed) {
APKExportData *ed = static_cast<APKExportData *>(p_userdata);
- String dst_path = p_path.replace_first("res://", "assets/");
+ const String path = ResourceUID::ensure_path(p_path);
+ const String dst_path = path.replace_first("res://", "assets/");
- store_in_apk(ed, dst_path, p_data, _should_compress_asset(p_path, p_data) ? Z_DEFLATED : 0);
+ store_in_apk(ed, dst_path, p_data, _should_compress_asset(path, p_data) ? Z_DEFLATED : 0);
return OK;
}
@@ -1564,7 +1565,7 @@ void EditorExportPlatformAndroid::_fix_resources(const Ref<EditorExportPreset> &
str = get_project_name(package_name);
} else {
- String lang = str.substr(str.rfind("-") + 1, str.length()).replace("-", "_");
+ String lang = str.substr(str.rfind_char('-') + 1, str.length()).replace("-", "_");
if (appnames.has(lang)) {
str = appnames[lang];
} else {
diff --git a/platform/android/export/gradle_export_util.cpp b/platform/android/export/gradle_export_util.cpp
index 3603565805..433888581f 100644
--- a/platform/android/export/gradle_export_util.cpp
+++ b/platform/android/export/gradle_export_util.cpp
@@ -171,8 +171,9 @@ Error store_string_at_path(const String &p_path, const String &p_data) {
// This method will be called ONLY when gradle build is enabled.
Error rename_and_store_file_in_gradle_project(void *p_userdata, const String &p_path, const Vector<uint8_t> &p_data, int p_file, int p_total, const Vector<String> &p_enc_in_filters, const Vector<String> &p_enc_ex_filters, const Vector<uint8_t> &p_key, uint64_t p_seed) {
CustomExportData *export_data = static_cast<CustomExportData *>(p_userdata);
- String dst_path = p_path.replace_first("res://", export_data->assets_directory + "/");
- print_verbose("Saving project files from " + p_path + " into " + dst_path);
+ const String path = ResourceUID::ensure_path(p_path);
+ const String dst_path = path.replace_first("res://", export_data->assets_directory + "/");
+ print_verbose("Saving project files from " + path + " into " + dst_path);
Error err = store_file_at_path(dst_path, p_data);
return err;
}
diff --git a/platform/linuxbsd/wayland/wayland_thread.cpp b/platform/linuxbsd/wayland/wayland_thread.cpp
index e066e78e5b..d8d58ba54b 100644
--- a/platform/linuxbsd/wayland/wayland_thread.cpp
+++ b/platform/linuxbsd/wayland/wayland_thread.cpp
@@ -3988,10 +3988,10 @@ void WaylandThread::selection_set_text(const String &p_text) {
wl_data_source_add_listener(ss->wl_data_source_selection, &wl_data_source_listener, ss);
wl_data_source_offer(ss->wl_data_source_selection, "text/plain;charset=utf-8");
wl_data_source_offer(ss->wl_data_source_selection, "text/plain");
- }
- // TODO: Implement a good way of getting the latest serial from the user.
- wl_data_device_set_selection(ss->wl_data_device, ss->wl_data_source_selection, MAX(ss->pointer_data.button_serial, ss->last_key_pressed_serial));
+ // TODO: Implement a good way of getting the latest serial from the user.
+ wl_data_device_set_selection(ss->wl_data_device, ss->wl_data_source_selection, MAX(ss->pointer_data.button_serial, ss->last_key_pressed_serial));
+ }
// Wait for the message to get to the server before continuing, otherwise the
// clipboard update might come with a delay.
diff --git a/platform/macos/export/export_plugin.cpp b/platform/macos/export/export_plugin.cpp
index bf5645d9a6..b9f9d8d613 100644
--- a/platform/macos/export/export_plugin.cpp
+++ b/platform/macos/export/export_plugin.cpp
@@ -970,7 +970,7 @@ Error EditorExportPlatformMacOS::_notarize(const Ref<EditorExportPreset> &p_pres
return Error::FAILED;
} else {
print_verbose("rcodesign (" + p_path + "):\n" + str);
- int next_nl = str.find("\n", rq_offset);
+ int next_nl = str.find_char('\n', rq_offset);
String request_uuid = (next_nl == -1) ? str.substr(rq_offset + 23, -1) : str.substr(rq_offset + 23, next_nl - rq_offset - 23);
add_message(EXPORT_MESSAGE_INFO, TTR("Notarization"), vformat(TTR("Notarization request UUID: \"%s\""), request_uuid));
add_message(EXPORT_MESSAGE_INFO, TTR("Notarization"), TTR("The notarization process generally takes less than an hour."));
@@ -1054,7 +1054,7 @@ Error EditorExportPlatformMacOS::_notarize(const Ref<EditorExportPreset> &p_pres
return Error::FAILED;
} else {
print_verbose("notarytool (" + p_path + "):\n" + str);
- int next_nl = str.find("\n", rq_offset);
+ int next_nl = str.find_char('\n', rq_offset);
String request_uuid = (next_nl == -1) ? str.substr(rq_offset + 4, -1) : str.substr(rq_offset + 4, next_nl - rq_offset - 4);
add_message(EXPORT_MESSAGE_INFO, TTR("Notarization"), vformat(TTR("Notarization request UUID: \"%s\""), request_uuid));
add_message(EXPORT_MESSAGE_INFO, TTR("Notarization"), TTR("The notarization process generally takes less than an hour."));
diff --git a/platform/web/api/web_tools_editor_plugin.cpp b/platform/web/api/web_tools_editor_plugin.cpp
index d39773bde2..61801372ba 100644
--- a/platform/web/api/web_tools_editor_plugin.cpp
+++ b/platform/web/api/web_tools_editor_plugin.cpp
@@ -80,7 +80,7 @@ void WebToolsEditorPlugin::_download_zip() {
const String output_path = String("/tmp").path_join(output_name);
zipFile zip = zipOpen2(output_path.utf8().get_data(), APPEND_STATUS_CREATE, nullptr, &io);
- const String base_path = resource_path.substr(0, resource_path.rfind("/")) + "/";
+ const String base_path = resource_path.substr(0, resource_path.rfind_char('/')) + "/";
_zip_recursive(resource_path, base_path, zip);
zipClose(zip, nullptr);
{
diff --git a/platform/windows/display_server_windows.h b/platform/windows/display_server_windows.h
index 0462d3f8fa..32ed8823d3 100644
--- a/platform/windows/display_server_windows.h
+++ b/platform/windows/display_server_windows.h
@@ -40,7 +40,6 @@
#include "core/input/input.h"
#include "core/io/image.h"
#include "core/os/os.h"
-#include "drivers/unix/ip_unix.h"
#include "drivers/wasapi/audio_driver_wasapi.h"
#include "drivers/winmidi/midi_driver_winmidi.h"
#include "servers/audio_server.h"
diff --git a/platform/windows/os_windows.cpp b/platform/windows/os_windows.cpp
index fcc4655cbe..a25b7ea4ca 100644
--- a/platform/windows/os_windows.cpp
+++ b/platform/windows/os_windows.cpp
@@ -43,6 +43,7 @@
#include "drivers/windows/dir_access_windows.h"
#include "drivers/windows/file_access_windows.h"
#include "drivers/windows/file_access_windows_pipe.h"
+#include "drivers/windows/ip_windows.h"
#include "drivers/windows/net_socket_winsock.h"
#include "main/main.h"
#include "servers/audio_server.h"
@@ -69,6 +70,7 @@
extern "C" {
__declspec(dllexport) DWORD NvOptimusEnablement = 1;
__declspec(dllexport) int AmdPowerXpressRequestHighPerformance = 1;
+__declspec(dllexport) void NoHotPatch() {} // Disable Nahimic code injection.
}
// Workaround mingw-w64 < 4.0 bug
@@ -274,7 +276,7 @@ void OS_Windows::initialize() {
current_pi.pi.hProcess = GetCurrentProcess();
process_map->insert(GetCurrentProcessId(), current_pi);
- IPUnix::make_default();
+ IPWindows::make_default();
main_loop = nullptr;
HRESULT hr = DWriteCreateFactory(DWRITE_FACTORY_TYPE_SHARED, __uuidof(IDWriteFactory), reinterpret_cast<IUnknown **>(&dwrite_factory));
@@ -815,10 +817,22 @@ double OS_Windows::get_unix_time() const {
}
void OS_Windows::delay_usec(uint32_t p_usec) const {
- if (p_usec < 1000) {
- Sleep(1);
- } else {
- Sleep(p_usec / 1000);
+ constexpr uint32_t tolerance = 1000 + 20;
+
+ uint64_t t0 = get_ticks_usec();
+ uint64_t target_time = t0 + p_usec;
+
+ // Calculate sleep duration with a tolerance for fine-tuning.
+ if (p_usec > tolerance) {
+ uint32_t coarse_sleep_usec = p_usec - tolerance;
+ if (coarse_sleep_usec >= 1000) {
+ Sleep(coarse_sleep_usec / 1000);
+ }
+ }
+
+ // Spin-wait until we reach the precise target time.
+ while (get_ticks_usec() < target_time) {
+ YieldProcessor();
}
}
diff --git a/platform/windows/os_windows.h b/platform/windows/os_windows.h
index a32e535f0b..fd98f9b14b 100644
--- a/platform/windows/os_windows.h
+++ b/platform/windows/os_windows.h
@@ -37,7 +37,6 @@
#include "core/config/project_settings.h"
#include "core/input/input.h"
#include "core/os/os.h"
-#include "drivers/unix/ip_unix.h"
#include "drivers/wasapi/audio_driver_wasapi.h"
#include "drivers/winmidi/midi_driver_winmidi.h"
#include "servers/audio_server.h"