Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
81 changes: 81 additions & 0 deletions winter/Code/emley/kachemak/kachemak.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <version/version.hpp>
#include <torrent.hpp>

//! Structure for data files that deals with Kachemak.
struct KachemakVersion
{
std::string file_name;
Expand All @@ -26,28 +27,108 @@ struct KachemakPatch
std::size_t temp_required;
};

//! Enum class that specifies the category of the directory to check if it has free space.
enum class FreeSpaceCheckCategory
{
Temporary,
Permanent
};

//! The Kachemak class.
class Kachemak : public Version
{
public:
//! Constructor of the class.
/*!
\param sourcemod_path The path of the sourcemod directory, found within Steam directory.
\param folder_name The name of the folder for the game.
\param source_url The link to the game's downloadable path online.
\param butler_path The path of butler.
*/
Kachemak(const std::filesystem::path& sourcemod_path, const std::filesystem::path& folder_name,
const std::string& source_url, const std::filesystem::path& butler_path);

//! Function to install sourcemod games.
/*!
\return Status code for the installation.
*/
virtual int install();
//! Function to install sourcemod games through a specific path.
/*!
* \param custom_path Path where the game would be installed.
\return Status code post-installation.
*/
virtual int install_path(std::filesystem::path custom_path);

//! Function to check on free spaces at specific directories, depending on its category.
/*!
\param size Specified Size to check on.
\param category The category of the directory.
*/
int free_space_check(const uintmax_t size, const FreeSpaceCheckCategory& category);
//! Function to check on free spaces at specific directories, depending on its path.
/*!
* \param size Specified Size to check on.
* \param category The path of the directory.
*
* Status code post-checking are as such:
* 0: success
* 1: not enough temp storage
* 2: not enough permanent storage
* \return Status code post-checking.
*/
int free_space_check_path(const uintmax_t size, const std::filesystem::path custom_path);
//! Function to update games installed by Adastral
/*!
* Status code post-update are as such:
* 0: success
* 1: symlink fail
* 2: space check fail
* 3: already on latest / verification needed first
*
* \return Status code post-update.
*/
int update();

//! Function to verify games installed by Adastral
/*!
* Status code post-verification are as such:
* 0: success
* 4: not installed
* \return Status code post-verification.
*/
int verify();
//! Function to extract games stored as .zip files.
/*!
* \param input_file Name of the input file.
* \param output_directory Name of the output directory.
* \param size Size of the file.
* Status code post-extract are as such:
* -1: failure
* 0: success
* 1: not enough free space
* \return Status code post-extract.
*/
int extract(const std::string& input_file, const std::string& output_directory, const size_t& size);
//! Function to extract games stored as .zip files to a custom path.
/*!
* \param input_file Name of the input file.
* \param output_directory Path of the output directory.
* \param size Size of the file.
* Status code post-extract are as such:
* -1: failure
* 0: success
* 1: not enough free space
* \return Status code post-extract.
*/
int extract_path(const std::string& input_file, const std::string& output_directory, const size_t& size);
//! Function to get the tag of an installed game.
std::string get_installed_version_tag();
//! Function to get the latest version code of an installed game.
std::string get_latest_version_code();
//! Function to get the latest version tag of an installed game.
std::string get_latest_version_tag();
//! Boolean that checks whether verification is forced or not.
bool force_verify = false;

private:
Expand Down
17 changes: 17 additions & 0 deletions winter/Code/net/net.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,26 @@
class net
{
public:
/*!
Function to download items to a temporary folder.
\param url URL link to download from.
\param name Name of the temp folder.
\param progress State of the progress
\param event Kind of event enabled for downloading, defaults to nullptr.
\param path Path of the temporary folder, defaults to nullptr.
*/
static std::string download_to_temp(std::string url, std::string name, bool progress = false,
EventSystem* event = nullptr, std::filesystem::path* path = nullptr);

/*!
Function to get string data from server.
\param url URL link to download from.
*/
std::string get_string_data_from_server(const std::string& url);
/*!
Function to get string data from server.
\param url URL link to download from.
*/
std::vector<char> get_bin_data_from_server(const std::string& url);
// Get path object for the systems sourcemods folder (win/linux)
private:
Expand Down
58 changes: 58 additions & 0 deletions winter/Code/palace/palace.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <map>
#include <nlohmann/json.hpp>

//! Structure dealing with metadata of the game.
struct GameMetadata
{
std::string name;
Expand All @@ -16,21 +17,78 @@ struct GameMetadata
class palace
{
public:
/*!
Constructor of the class.
\param path Steam path.
*/
palace(std::string path = "");
//! Deconstructor of the class.
~palace();

//! Function to fetch server data.
void fetch_server_data();

//! Function to download assets from server to internal Adastral folder.
void download_assets();

//! Function to initialize games for Adastral to detect.
int init_games();

/*!
Function to update a specific game.
\param game_name Name of Adastral-supported game.
*/
int update_game(const std::string &game_name);

/*!
Function to update a specific game in a custom path.
\param game_name Name of Adastral-supported game.
\param custom_path Custom path of the Adastral-supported game.
*/
int update_game_with_path(const std::string &game_name, std::string custom_path);
/*!
Function to verify game's integrity.
\param game_name Name of Adastral-supported game.
*/
int verify_game(const std::string &game_name);
/*!
Function to launch the game itself.
\param game_name Name of Adastral-supported game.
\param arguments Launch arguments of the game.
*/
int launch_game(const std::string &game_name, const std::string &arguments);
/*!
Function to check if the app is installed
\param app_id Steam app id.
\return If the app is installed or not.
*/
bool is_app_installed(const std::string &app_id);

/*!
Function to get the application path.
\param app_id Steam app id.
\return The path of the application.
*/
std::filesystem::path get_app_path(const std::string &app_id);
/*!
Function to get the sourcemod folder path from Steam folder.
\return Path of the sourcemod folder.*/
std::filesystem::path find_sourcemod_path();
/*
*/
std::filesystem::path get_asset(std::string hash);
/*!
Function to get the list of Adastral-supported games.
\return vector variable containing the list.
*/
std::vector<std::string> get_games();
/*!
Function to get the list of Adastral-supported games that are installed.
\return vector variable containing the installed games list.
*/
std::vector<std::string> get_installed_games();


std::filesystem::path sourcemods_path;
std::filesystem::path steam_path;
std::unordered_map<std::string, GameMetadata *> server_games;
Expand Down
25 changes: 25 additions & 0 deletions winter/Code/sys/sys.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,34 @@
class sys
{
public:
/*!
Function to execute a system function through a parameter.
\param params Set of parameters.
*/
static int exec_with_param(const std::vector<std::string>& params);
/*!
Function to recursively delete contents of directory.
\param dir path of the directory
\return 0 if success, 1 if input path doesn't exist, 2 if input path isn't a directory.
*/
static int delete_directory_content(const std::filesystem::path& dir);
/*!
Function to extract zip files.
\param input_file Input of the zip archive file.
\param output_file Direction of the output zip archive file.
*/
static int extract_zip(const std::string& input_file, const std::string& output_file);

/*!
Function to get path of Steam.
\return Steam path.
*/
static std::filesystem::path get_steam_path();

/*!
Function to parse vdf files.
\param file_path File path of the vdf file.
\return Result of parsed VDF file.
*/
static tyti::vdf::object parse_vdf_file(std::filesystem::path file_path);
};
6 changes: 6 additions & 0 deletions winter/Code/torrent/torrent.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,11 @@
class torrent
{
public:
/*!
Function to download from a turrent file using libtorrent.
\param torrent_url URL of the torrent.
\param path Path to save the contents to.
\param event Events from the EventSystem.
*/
static int libtorrent_download(const std::string &torrent_url, const std::string &path, EventSystem *event = nullptr);
};
6 changes: 3 additions & 3 deletions winter/doc/Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ PROJECT_ICON =
# entered, it will be relative to the location where Doxygen was started. If
# left blank the current directory will be used.

OUTPUT_DIRECTORY = /home/rr/adastral/osprey/winter/doc
OUTPUT_DIRECTORY =

# If the CREATE_SUBDIRS tag is set to YES then Doxygen will create up to 4096
# sub-directories (in 2 levels) under the output directory of each output format
Expand Down Expand Up @@ -965,7 +965,7 @@ WARN_LOGFILE =
# spaces. See also FILE_PATTERNS and EXTENSION_MAPPING
# Note: If this tag is empty the current directory is searched.

INPUT = /home/rr/adastral/osprey/winter/Code
INPUT = ../Code

# This tag can be used to specify the character encoding of the source files
# that Doxygen parses. Internally Doxygen uses the UTF-8 encoding. Doxygen uses
Expand Down Expand Up @@ -1087,7 +1087,7 @@ EXCLUDE_SYMLINKS = NO
# Note that the wildcards are matched against the file with absolute path, so to
# exclude all test directories for example use the pattern */test/*

EXCLUDE_PATTERNS =
EXCLUDE_PATTERNS = ../Code/shared/sha256* ../Code/sys/zip*

# The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names
# (namespaces, classes, functions, etc.) that should be excluded from the
Expand Down