diff --git a/CMakeLists.txt b/CMakeLists.txt index a5d1ea07b..8b5cdd061 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -333,6 +333,8 @@ endif () set(LINK_LIBS ${LINK_LIBS} sokol ${ALSA_LIBRARIES}) if(NOT EMSCRIPTEN AND NOT ANDROID AND NOT IOS) + target_include_directories(${PROJECT_NAME} PRIVATE src/openssl/include) + target_include_directories(${PROJECT_NAME} PRIVATE src/curl/include) set(LINK_LIBS ${LINK_LIBS} curl) endif() diff --git a/src/main.c b/src/main.c index 7af0bb5a1..53d991ef0 100644 --- a/src/main.c +++ b/src/main.c @@ -2804,7 +2804,16 @@ void se_capture_cloud_callback(void* userdata, void* data){ cloud_state.save_states_busy_swap[slot] = false; mutex_unlock(cloud_state.save_states_mutex[slot]); } -void se_capture_state_slot_cloud(int slot){ +void se_write_png_cloud(void* context, void* data, int size){ + char file[SB_FILE_PATH_SIZE]; + size_t slot = (size_t)context; + snprintf(file,SB_FILE_PATH_SIZE,"%016llx.slot%zu.state.png",emu_state.game_checksum,slot); + // data is freed after this function returns, so we need to copy it + void* data_copy = malloc(size); + memcpy(data_copy,data,size); + cloud_drive_upload(cloud_state.drive, file, "image/png", data_copy, (size_t)size, se_capture_cloud_callback, (void*)slot); +} +void se_capture_state_slot_cloud(size_t slot){ if(emu_state.rom_loaded==false)return; se_save_state_t* save_state = cloud_state.save_states+slot; se_capture_state(&core, save_state); @@ -2813,17 +2822,10 @@ void se_capture_state_slot_cloud(int slot){ uint32_t width=0, height=0; uint8_t* imdata = se_save_state_to_image(save_state, &width,&height); int len; - void* data = stbi_write_png_to_mem(imdata, 0, width, height, 4, &len); // Freed in cloud_drive_upload callback + stbi_write_png_to_func(se_write_png_cloud, (void*)slot, width, height, 4, imdata, 0); free(imdata); - if (data) { - char file[SB_FILE_PATH_SIZE]; - snprintf(file,SB_FILE_PATH_SIZE,"%016llx.slot%d.state.png",emu_state.game_checksum,slot); - cloud_drive_upload(cloud_state.drive, file, "image/png", data, (size_t)len, se_capture_cloud_callback, (void*)(size_t)slot); - } else { - printf("Failed to write png to memory\n"); - } } -void se_restore_state_slot_cloud(int slot){ +void se_restore_state_slot_cloud(size_t slot){ se_restore_state(&core, cloud_state.save_states+slot); } static void se_drive_ready_callback(cloud_drive_t* drive){ @@ -5614,7 +5616,7 @@ void se_draw_save_states(bool cloud){ int win_w = igGetWindowContentRegionWidth(); ImDrawList*dl= igGetWindowDrawList(); if(!emu_state.rom_loaded)se_push_disabled(); - for(int i=0;i