Compare commits

..

3 Commits

Author SHA1 Message Date
Mr_Goldberg 02ee5f9a6d
Implement the TriggerItemDrop function. 2020-06-20 21:17:31 -04:00
Mr_Goldberg a0648d454c
Add a way to set subscribed groups. 2020-06-20 21:15:26 -04:00
Mr_Goldberg beffb89bda
Some refactoring. Added a define for the default callresult/callback timeout. 2020-06-20 21:14:37 -04:00
8 changed files with 64 additions and 13 deletions

View File

@ -48,6 +48,10 @@ Depots:
This is pretty rare but some games might use depot ids to see if dlcs are installed. You can provide a list of installed depots to the game with a steam_settings\depots.txt file. This is pretty rare but some games might use depot ids to see if dlcs are installed. You can provide a list of installed depots to the game with a steam_settings\depots.txt file.
See the steam_settings.EXAMPLE folder for an example. See the steam_settings.EXAMPLE folder for an example.
Subscribed Groups:
Some games like payday 2 check which groups you are subscribed in and unlock things based on that. You can provide a list of subscribed groups to the game with a steam_settings\subscribed_groups.txt file.
See steam_settings.EXAMPLE\subscribed_groups.EXAMPLE.txt for an example for payday 2.
App paths: App paths:
Some rare games might need to be provided one or more paths to app ids. For example the path to where a dlc is installed. This sets the paths returned by the Steam_Apps::GetAppInstallDir function. Some rare games might need to be provided one or more paths to app ids. For example the path to where a dlc is installed. This sets the paths returned by the Steam_Apps::GetAppInstallDir function.
See steam_settings.EXAMPLE\app_paths.EXAMPLE.txt for an example. See steam_settings.EXAMPLE\app_paths.EXAMPLE.txt for an example.

View File

@ -191,6 +191,19 @@ std::string get_lib_path() {
} }
#endif #endif
std::string get_full_lib_path()
{
std::string program_path;
#if defined(STEAM_WIN32)
char DllPath[MAX_PATH] = {0};
GetModuleFileName((HINSTANCE)&__ImageBase, DllPath, _countof(DllPath));
program_path = DllPath;
#else
program_path = get_lib_path();
#endif
return program_path;
}
std::string get_full_program_path() std::string get_full_program_path()
{ {
std::string env_program_path = get_env_variable("SteamAppPath"); std::string env_program_path = get_env_variable("SteamAppPath");
@ -203,15 +216,8 @@ std::string get_full_program_path()
} }
std::string program_path; std::string program_path;
#if defined(STEAM_WIN32) program_path = get_full_lib_path();
char DllPath[MAX_PATH] = {0}; return program_path.substr(0, program_path.rfind(PATH_SEPARATOR)).append(PATH_SEPARATOR);
GetModuleFileName((HINSTANCE)&__ImageBase, DllPath, _countof(DllPath));
program_path = DllPath;
#else
program_path = get_lib_path();
#endif
program_path = program_path.substr(0, program_path.rfind(PATH_SEPARATOR)).append(PATH_SEPARATOR);
return program_path;
} }
std::string get_current_path() std::string get_current_path()

View File

@ -161,10 +161,13 @@ CSteamID generate_steam_id_user();
CSteamID generate_steam_id_server(); CSteamID generate_steam_id_server();
CSteamID generate_steam_id_anonserver(); CSteamID generate_steam_id_anonserver();
CSteamID generate_steam_id_lobby(); CSteamID generate_steam_id_lobby();
std::string get_full_lib_path();
std::string get_full_program_path(); std::string get_full_program_path();
std::string get_current_path(); std::string get_current_path();
std::string canonical_path(std::string path); std::string canonical_path(std::string path);
#define DEFAULT_CB_TIMEOUT 0.002
class SteamCallResults { class SteamCallResults {
std::vector<struct Steam_Call_Result> callresults; std::vector<struct Steam_Call_Result> callresults;
std::vector<class CCallbackBase *> completed_callbacks; std::vector<class CCallbackBase *> completed_callbacks;
@ -238,7 +241,7 @@ public:
} }
} }
SteamAPICall_t addCallResult(SteamAPICall_t api_call, int iCallback, void *result, unsigned int size, double timeout=0.0, bool run_call_completed_cb=true) { SteamAPICall_t addCallResult(SteamAPICall_t api_call, int iCallback, void *result, unsigned int size, double timeout=DEFAULT_CB_TIMEOUT, bool run_call_completed_cb=true) {
auto cb_result = std::find_if(callresults.begin(), callresults.end(), [api_call](struct Steam_Call_Result const& item) { return item.api_call == api_call; }); auto cb_result = std::find_if(callresults.begin(), callresults.end(), [api_call](struct Steam_Call_Result const& item) { return item.api_call == api_call; });
if (cb_result != callresults.end()) { if (cb_result != callresults.end()) {
if (cb_result->reserved) { if (cb_result->reserved) {
@ -266,7 +269,7 @@ public:
return callresults.back().api_call; return callresults.back().api_call;
} }
SteamAPICall_t addCallResult(int iCallback, void *result, unsigned int size, double timeout=0.0, bool run_call_completed_cb=true) { SteamAPICall_t addCallResult(int iCallback, void *result, unsigned int size, double timeout=DEFAULT_CB_TIMEOUT, bool run_call_completed_cb=true) {
return addCallResult(generate_steam_api_call_id(), iCallback, result, size, timeout, run_call_completed_cb); return addCallResult(generate_steam_api_call_id(), iCallback, result, size, timeout, run_call_completed_cb);
} }
@ -419,11 +422,11 @@ public:
} }
void addCBResult(int iCallback, void *result, unsigned int size) { void addCBResult(int iCallback, void *result, unsigned int size) {
addCBResult(iCallback, result, size, 0.0, false); addCBResult(iCallback, result, size, DEFAULT_CB_TIMEOUT, false);
} }
void addCBResult(int iCallback, void *result, unsigned int size, bool dont_post_if_already) { void addCBResult(int iCallback, void *result, unsigned int size, bool dont_post_if_already) {
addCBResult(iCallback, result, size, 0.0, dont_post_if_already); addCBResult(iCallback, result, size, DEFAULT_CB_TIMEOUT, dont_post_if_already);
} }
void addCBResult(int iCallback, void *result, unsigned int size, double timeout) { void addCBResult(int iCallback, void *result, unsigned int size, double timeout) {

View File

@ -132,6 +132,9 @@ public:
std::map<std::string, Stat_config> getStats() { return stats; } std::map<std::string, Stat_config> getStats() { return stats; }
void setStatDefiniton(std::string name, struct Stat_config stat_config) {stats[name] = stat_config; } void setStatDefiniton(std::string name, struct Stat_config stat_config) {stats[name] = stat_config; }
//subscribed lobby/group ids
std::set<uint64> subscribed_groups;
//images //images
std::map<int, struct Image_Data> images; std::map<int, struct Image_Data> images;
int add_image(std::string data, uint32 width, uint32 height); int add_image(std::string data, uint32 width, uint32 height);

View File

@ -511,6 +511,28 @@ uint32 create_localstorage_settings(Settings **settings_client_out, Settings **s
} }
} }
{
std::string depots_config_path = Local_Storage::get_game_settings_path() + "subscribed_groups.txt";
std::ifstream input( depots_config_path );
if (input.is_open()) {
consume_bom(input);
for( std::string line; getline( input, line ); ) {
if (!line.empty() && line[line.length()-1] == '\n') {
line.pop_back();
}
if (!line.empty() && line[line.length()-1] == '\r') {
line.pop_back();
}
uint64 source_id = stoull(line);
settings_client->subscribed_groups.insert(source_id);
settings_server->subscribed_groups.insert(source_id);
PRINT_DEBUG("Added source %llu\n", source_id);
}
}
}
{ {
std::string mod_path = Local_Storage::get_game_settings_path() + "mods"; std::string mod_path = Local_Storage::get_game_settings_path() + "mods";
std::vector<std::string> paths = Local_Storage::get_filenames_path(mod_path); std::vector<std::string> paths = Local_Storage::get_filenames_path(mod_path);

View File

@ -502,6 +502,10 @@ bool IsUserInSource( CSteamID steamIDUser, CSteamID steamIDSource )
if (settings->get_lobby() == steamIDSource) { if (settings->get_lobby() == steamIDSource) {
return true; return true;
} }
if (settings->subscribed_groups.find(steamIDSource.ConvertToUint64()) != settings->subscribed_groups.end()) {
return true;
}
} else { } else {
Friend *f = find_friend(steamIDUser); Friend *f = find_friend(steamIDUser);
if (!f) return false; if (!f) return false;

View File

@ -540,6 +540,11 @@ bool TriggerItemDrop( SteamInventoryResult_t *pResultHandle, SteamItemDef_t drop
{ {
PRINT_DEBUG("TriggerItemDrop %p %i\n", pResultHandle, dropListDefinition); PRINT_DEBUG("TriggerItemDrop %p %i\n", pResultHandle, dropListDefinition);
//TODO: if gameserver return false //TODO: if gameserver return false
std::lock_guard<std::recursive_mutex> lock(global_mutex);
struct Steam_Inventory_Requests* request = new_inventory_result(false);
if (pResultHandle != nullptr)
*pResultHandle = request->inventory_result;
return true; return true;
} }

View File

@ -0,0 +1,4 @@
103582791433980119
103582791438562929
103582791441335905
103582791460014708