Fixed cli timed unlocks/locks + added one more spacing option (#136)

update dev branch + fixes & enhancements to timed achievements
This commit is contained in:
DeadStarlin 2022-11-29 12:21:00 +01:00 committed by GitHub
parent d928423c23
commit 04f02fe69d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 16 additions and 5 deletions

View File

@ -53,9 +53,9 @@ Run SamRewritten by opening the corresponding desktop entry, or by using the `sa
## Gentoo Installation
SamRewritten is available as `games-util/samrewritten` through the following overlay:
SamRewritten is available as `games-util/samrewritten` through the GURU overlay:
https://github.com/telans/EBUILDS
https://wiki.gentoo.org/wiki/Project:GURU
# Features

View File

@ -76,7 +76,7 @@ The socket implementation is found under [`src/sockets`](/src/sockets). The file
As mentioned above, [`MyGameSocket`](/src/sockets/MyGameSocket.cpp) is responsible for server logic. It implements much of the Steamworks SDK features, so to understand it fully, we encourage you to familiarize yourself with [the framework's documentation](https://partner.steamgames.com/doc/sdk/api).
If you spend more time looking at the implementation, you can see that something odd happening. Indeed, part of the achievement data is retrieved through the Steamworks API (legacy code), and the rest (as well as the stats) are retrieved through a "schema parser". Indeed, some information about the achievements cannot be retrieved through Steamworks, like the achievement icon URL.
If you spend more time looking at the implementation, you can see that something odd happening. Indeed, part of the achievement data is retrieved through the Steamworks API (legacy code), and the rest (as well as the stats) are retrieved through a ["schema parser"](/src/schema_parser). Indeed, some information about the achievements cannot be retrieved through Steamworks, like the achievement icon URL.
That is why we implemented a parser, that will explore Steam's internal cache files to retrieve additional information. Note that the relevant cache isn't always loaded until the app is started: we did not find a way around calling [`SteamAPI_Init`](https://partner.steamgames.com/doc/sdk/api#SteamAPI_Init) with reliable results.

View File

@ -53,7 +53,7 @@ bool go_cli_mode(int argc, char* argv[], AppId_t *return_app_id) {
("timed", "Do a timed achievement modification. Arguments that affect this are --amount, --units, --spacing, and --order")
("amount", "Control the amount of time spent for --timed modifications. Specify units with --units. Default is 1000", cxxopts::value<uint64_t>())
("units", "Control the units of time spent for --timed modifications. Set to 'seconds', 'minutes', 'hours', or 'days'. Default is seconds", cxxopts::value<std::string>())
("spacing", "Control the spacing between appying each modification for --timed modifications. Set to 'even' or 'random'. Default is even", cxxopts::value<std::string>())
("spacing", "Control the spacing between appying each modification for --timed modifications. Set to 'even', 'evenish' or 'random'. Default is even", cxxopts::value<std::string>())
("order", "Control the order --timed achievement modifications are applied in. Set to 'selection' or 'random'. Default is selection", cxxopts::value<std::string>())
("statnames", "Change stats for an AppId. Separate stat names by a comma. Use with statvalues to name the values in order", cxxopts::value<std::vector<std::string>>())
("statvalues", "Change stats for an AppId. Separate stat values by a comma. Use with statnames to name the values in order", cxxopts::value<std::vector<std::string>>())
@ -261,6 +261,8 @@ bool go_cli_mode(int argc, char* argv[], AppId_t *return_app_id) {
spacing = EVEN_SPACING;
} else if (spacing_input == "random") {
spacing = RANDOM_SPACING;
} else if (spacing_input == "evenish") {
spacing = EVEN_FREE_SPACING;
} else {
std::cerr << "invalid spacing: " << spacing_input << std::endl;
return true;
@ -288,6 +290,7 @@ bool go_cli_mode(int argc, char* argv[], AppId_t *return_app_id) {
<< " (or " << (((double)times[0]) / 60) << " minutes or "
<< ((((double)times[0]) / 60) / 60) << " hours)" << std::endl;
std::this_thread::sleep_for(std::chrono::seconds(times[0]));
g_steam->commit_next_timed_modification();
times.erase(times.begin());
}
g_steam->quit_game();

View File

@ -347,6 +347,13 @@ MySteam::setup_timed_modifications(uint64_t seconds, MODIFICATION_SPACING spacin
{
if (spacing == EVEN_SPACING) {
times.push_back((i + 1) * (seconds / size));
} else if (spacing == EVEN_FREE_SPACING) {
uint64_t time = (i + 1) * (seconds / size);
bool positive = rand() % 2;
int sign = 1;
if (!positive)
sign = -1;
times.push_back(time + sign*(((((double)rand()) / RAND_MAX))*time*0.1));
} else {
times.push_back(seconds * (((double)rand()) / RAND_MAX));
}

View File

@ -11,6 +11,7 @@
enum MODIFICATION_SPACING {
EVEN_SPACING = 0,
RANDOM_SPACING = 1,
EVEN_FREE_SPACING = 2,
};
enum MODIFICATION_ORDER {
@ -210,4 +211,4 @@ private:
std::vector<AchievementChange_t> m_achievement_changes;
std::vector<StatChange_t> m_stat_changes;
};
};