mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-02 13:01:27 +12:00
cheat_manager: improve parser errors
This commit is contained in:
parent
d0bb9d2b62
commit
47040be3ad
8 changed files with 124 additions and 84 deletions
32
Utilities/cheat_info.cpp
Normal file
32
Utilities/cheat_info.cpp
Normal file
|
@ -0,0 +1,32 @@
|
|||
#include "stdafx.h"
|
||||
#include "cheat_info.h"
|
||||
#include "Config.h"
|
||||
#include "StrUtil.h"
|
||||
|
||||
LOG_CHANNEL(log_cheat, "Cheat");
|
||||
|
||||
bool cheat_info::from_str(const std::string& cheat_line)
|
||||
{
|
||||
auto cheat_vec = fmt::split(cheat_line, {"@@@"}, false);
|
||||
|
||||
s64 val64 = 0;
|
||||
if (cheat_vec.size() != 5 || !cfg::try_to_int64(&val64, cheat_vec[2], 0, cheat_type_max - 1))
|
||||
{
|
||||
log_cheat.fatal("Failed to parse cheat line");
|
||||
return false;
|
||||
}
|
||||
|
||||
game = cheat_vec[0];
|
||||
description = cheat_vec[1];
|
||||
type = cheat_type{::narrow<u8>(val64)};
|
||||
offset = std::stoul(cheat_vec[3]);
|
||||
red_script = cheat_vec[4];
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string cheat_info::to_str() const
|
||||
{
|
||||
std::string cheat_str = game + "@@@" + description + "@@@" + std::to_string(static_cast<u8>(type)) + "@@@" + std::to_string(offset) + "@@@" + red_script + "@@@";
|
||||
return cheat_str;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue