mirror of
https://github.com/libretro/RetroArch
synced 2025-04-10 15:45:19 +00:00
* Rewrite some snprintfs
* task_steam.c - add license header
This commit is contained in:
parent
23b06dca69
commit
10a351228b
@ -1493,9 +1493,10 @@ bool command_event_save_core_config(
|
|||||||
for (i = 0; i < 16; i++)
|
for (i = 0; i < 16; i++)
|
||||||
{
|
{
|
||||||
if (i)
|
if (i)
|
||||||
snprintf(tmp, sizeof(tmp), "%s-%u.cfg", config_path, i);
|
snprintf(tmp, sizeof(tmp), "%s-%u", config_path, i);
|
||||||
else
|
else
|
||||||
snprintf(tmp, sizeof(tmp), "%s.cfg", config_path);
|
strlcpy(tmp, config_path, sizeof(tmp));
|
||||||
|
strlcat(tmp, ".cfg", sizeof(tmp));
|
||||||
|
|
||||||
if (!path_is_valid(tmp))
|
if (!path_is_valid(tmp))
|
||||||
{
|
{
|
||||||
|
@ -4664,18 +4664,27 @@ static bool runloop_check_movie_init(input_driver_state_t *input_st,
|
|||||||
char msg[16384], path[8192];
|
char msg[16384], path[8192];
|
||||||
bsv_movie_t *state = NULL;
|
bsv_movie_t *state = NULL;
|
||||||
int state_slot = settings->ints.state_slot;
|
int state_slot = settings->ints.state_slot;
|
||||||
|
msg[0] = '\0';
|
||||||
msg[0] = path[0] = '\0';
|
|
||||||
|
|
||||||
configuration_set_uint(settings, settings->uints.rewind_granularity, 1);
|
configuration_set_uint(settings, settings->uints.rewind_granularity, 1);
|
||||||
|
|
||||||
if (state_slot > 0)
|
if (state_slot > 0)
|
||||||
|
{
|
||||||
|
path[0] = '\0';
|
||||||
snprintf(path, sizeof(path), "%s%d.bsv",
|
snprintf(path, sizeof(path), "%s%d.bsv",
|
||||||
input_st->bsv_movie_state.movie_path,
|
input_st->bsv_movie_state.movie_path,
|
||||||
state_slot);
|
state_slot);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
snprintf(path, sizeof(path), "%s.bsv",
|
{
|
||||||
input_st->bsv_movie_state.movie_path);
|
size_t _len = strlcpy(path,
|
||||||
|
input_st->bsv_movie_state.movie_path, sizeof(path));
|
||||||
|
path[_len ] = '.';
|
||||||
|
path[_len+1] = 'b';
|
||||||
|
path[_len+2] = 's';
|
||||||
|
path[_len+3] = 'v';
|
||||||
|
path[_len+4] = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
snprintf(msg, sizeof(msg), "%s \"%s\".",
|
snprintf(msg, sizeof(msg), "%s \"%s\".",
|
||||||
msg_hash_to_str(MSG_STARTING_MOVIE_RECORD_TO),
|
msg_hash_to_str(MSG_STARTING_MOVIE_RECORD_TO),
|
||||||
|
@ -1,3 +1,17 @@
|
|||||||
|
/* RetroArch - A frontend for libretro.
|
||||||
|
*
|
||||||
|
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
||||||
|
* of the GNU General Public License as published by the Free Software Found-
|
||||||
|
* ation, either version 3 of the License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
||||||
|
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
||||||
|
* PURPOSE. See the GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License along with RetroArch.
|
||||||
|
* If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
#include <compat/strl.h>
|
#include <compat/strl.h>
|
||||||
|
|
||||||
#include "tasks_internal.h"
|
#include "tasks_internal.h"
|
||||||
@ -5,7 +19,8 @@
|
|||||||
#include "../runloop.h"
|
#include "../runloop.h"
|
||||||
#include "../steam/steam.h"
|
#include "../steam/steam.h"
|
||||||
|
|
||||||
typedef struct steam_core_dlc_install_state {
|
typedef struct steam_core_dlc_install_state
|
||||||
|
{
|
||||||
AppId app_id;
|
AppId app_id;
|
||||||
char *name;
|
char *name;
|
||||||
bool has_downloaded;
|
bool has_downloaded;
|
||||||
@ -13,50 +28,54 @@ typedef struct steam_core_dlc_install_state {
|
|||||||
|
|
||||||
static void task_steam_core_dlc_install_handler(retro_task_t *task)
|
static void task_steam_core_dlc_install_handler(retro_task_t *task)
|
||||||
{
|
{
|
||||||
char msg[PATH_MAX_LENGTH] = { 0 };
|
|
||||||
steam_core_dlc_install_state_t *state = NULL;
|
|
||||||
MistResult result = MistResult_Success;
|
|
||||||
bool downloading = false;
|
|
||||||
uint64_t bytes_downloaded = 0;
|
|
||||||
uint64_t bytes_total = 0;
|
|
||||||
int8_t progress;
|
int8_t progress;
|
||||||
|
steam_core_dlc_install_state_t *state = NULL;
|
||||||
|
MistResult result = MistResult_Success;
|
||||||
|
bool downloading = false;
|
||||||
|
uint64_t bytes_downloaded = 0;
|
||||||
|
uint64_t bytes_total = 0;
|
||||||
|
|
||||||
if (!task)
|
if (!task)
|
||||||
goto task_finished;
|
goto task_finished;
|
||||||
|
|
||||||
state = (steam_core_dlc_install_state_t*)task->state;
|
if (!(state = (steam_core_dlc_install_state_t*)task->state))
|
||||||
|
|
||||||
if (!state)
|
|
||||||
goto task_finished;
|
goto task_finished;
|
||||||
|
|
||||||
if (task_get_cancelled(task))
|
if (task_get_cancelled(task))
|
||||||
goto task_finished;
|
goto task_finished;
|
||||||
|
|
||||||
result = mist_steam_apps_get_dlc_download_progress(state->app_id, &downloading, &bytes_downloaded, &bytes_total);
|
result = mist_steam_apps_get_dlc_download_progress(state->app_id, &downloading, &bytes_downloaded, &bytes_total);
|
||||||
if(MIST_IS_ERROR(result)) goto task_finished;
|
if (MIST_IS_ERROR(result))
|
||||||
if(!downloading)
|
goto task_finished;
|
||||||
|
if (!downloading)
|
||||||
{
|
{
|
||||||
if(state->has_downloaded) goto task_finished;
|
if (state->has_downloaded)
|
||||||
|
goto task_finished;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
state->has_downloaded = true;
|
state->has_downloaded = true;
|
||||||
|
|
||||||
// Min bytes total to avoid division by zero at start
|
/* Min bytes total to avoid division by zero at start */
|
||||||
if(bytes_total < 1) bytes_total = 1;
|
if (bytes_total < 1)
|
||||||
|
bytes_total = 1;
|
||||||
|
|
||||||
progress = (int8_t)((bytes_downloaded * 100) / bytes_total);
|
progress = (int8_t)((bytes_downloaded * 100) / bytes_total);
|
||||||
if(progress < 0) progress = 0;
|
if (progress < 0)
|
||||||
if(progress > 100) progress = 100;
|
progress = 0;
|
||||||
|
else if (progress > 100)
|
||||||
|
progress = 100;
|
||||||
|
|
||||||
task_set_progress(task, progress);
|
task_set_progress(task, progress);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
task_finished:
|
task_finished:
|
||||||
if (task) task_set_finished(task, true);
|
if (task)
|
||||||
|
task_set_finished(task, true);
|
||||||
|
|
||||||
/* If finished successfully */
|
/* If finished successfully */
|
||||||
if(MIST_IS_SUCCESS(result))
|
if (MIST_IS_SUCCESS(result))
|
||||||
{
|
{
|
||||||
|
char msg[PATH_MAX_LENGTH];
|
||||||
strlcpy(msg, msg_hash_to_str(MSG_CORE_INSTALLED),
|
strlcpy(msg, msg_hash_to_str(MSG_CORE_INSTALLED),
|
||||||
sizeof(msg));
|
sizeof(msg));
|
||||||
strlcat(msg, state->name,
|
strlcat(msg, state->name,
|
||||||
@ -80,18 +99,17 @@ void task_push_steam_core_dlc_install(
|
|||||||
{
|
{
|
||||||
char task_title[PATH_MAX_LENGTH];
|
char task_title[PATH_MAX_LENGTH];
|
||||||
|
|
||||||
retro_task_t *task = task_init();
|
retro_task_t *task = task_init();
|
||||||
steam_core_dlc_install_state_t* state = (steam_core_dlc_install_state_t*)calloc(1,
|
steam_core_dlc_install_state_t* state = (steam_core_dlc_install_state_t*)calloc(1,
|
||||||
sizeof(steam_core_dlc_install_state_t));
|
sizeof(steam_core_dlc_install_state_t));
|
||||||
|
|
||||||
state->app_id = app_id;
|
state->app_id = app_id;
|
||||||
state->name = strdup(name);
|
state->name = strdup(name);
|
||||||
state->has_downloaded = false;
|
state->has_downloaded = false;
|
||||||
|
|
||||||
strlcpy(task_title, msg_hash_to_str(MSG_CORE_STEAM_INSTALLING),
|
strlcpy(task_title, msg_hash_to_str(MSG_CORE_STEAM_INSTALLING),
|
||||||
sizeof(task_title));
|
sizeof(task_title));
|
||||||
strlcat(task_title, name,
|
strlcat(task_title, name, sizeof(task_title));
|
||||||
sizeof(task_title));
|
|
||||||
|
|
||||||
task->handler = task_steam_core_dlc_install_handler;
|
task->handler = task_steam_core_dlc_install_handler;
|
||||||
task->state = state;
|
task->state = state;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user