Merge branch 'master' into 'overlay_h'
# Conflicts: # .gitlab-ci.yml # dll/steam_client.cpp # dll/steam_inventory.h # dll/steam_user_stats.hmerge-requests/28/head
commit
d1a4adc5bd
|
@ -56,7 +56,7 @@ build_steamos:
|
|||
|
||||
build_windows:
|
||||
stage: build
|
||||
image: fedora
|
||||
image: fedora:29
|
||||
|
||||
script:
|
||||
- dnf -y install wine wget p7zip sed dos2unix unzip
|
||||
|
@ -76,6 +76,7 @@ build_windows:
|
|||
- DLL_FILES="$(ls ImGui/*.cpp | tr "\n" " ")"; sed "s|ImGui/\*.cpp|$DLL_FILES|g" -i *.bat
|
||||
- DLL_FILES="$(ls ImGui/impls/*.cpp | tr "\n" " ")"; sed "s|ImGui/impls/\*.cpp|$DLL_FILES|g" -i *.bat
|
||||
- DLL_FILES="$(ls dll/*.proto | tr "\n" " " | sed "s/.proto/.pb.cc/g")"; sed "s|dll/\*.cc|$DLL_FILES|g" -i *.bat
|
||||
- DLL_FILES="$(ls steamclient_loader/*.cpp | tr "\n" " ")"; sed "s|steamclient_loader/\*.cpp|$DLL_FILES|g" -i *.bat
|
||||
- export WINEDEBUG=-all
|
||||
- wine cmd /c build_win_debug_experimental.bat
|
||||
- wine cmd /c build_win_release.bat
|
||||
|
@ -111,13 +112,10 @@ build_cmake_linux:
|
|||
|
||||
build_cmake_windows:
|
||||
stage: build
|
||||
image: fedora
|
||||
image: fedora:29
|
||||
|
||||
before_script:
|
||||
- dnf update -y
|
||||
- dnf install 'dnf-command(config-manager)' -y
|
||||
- dnf config-manager --add-repo https://dl.winehq.org/wine-builds/fedora/30/winehq.repo
|
||||
- dnf install wget unzip p7zip winehq-devel samba-winbind-clients -y
|
||||
- dnf -y install wine wget p7zip sed dos2unix
|
||||
- wget 'https://gitlab.com/Mr_Goldberg/goldberg_emulator/uploads/48db8f434a193aae872279dc4f5dde6a/sdk_standalone.7z'
|
||||
- 7za x sdk_standalone.7z -osdk_standalone
|
||||
- wget 'https://github.com/Kitware/CMake/releases/download/v3.15.0-rc1/cmake-3.15.0-rc1-win64-x64.zip'
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
This is a build of the experimental version of my emu in steamclient mode with an included loader. See both the regular and experimental readmes for how to configure it.
|
||||
Note that all emu config files should be put beside the steamclient dll. You do not need to put a steam_interfaces.txt file for the steamclient version of the emu.
|
||||
|
||||
To use the loader, put both steamclient dlls and the loader in a folder and edit the config file. Make sure you put the right appid in the ini file.
|
|
@ -60,13 +60,17 @@ The steam appid can also be set using the SteamAppId or SteamGameId env variable
|
|||
Offline mode:
|
||||
Some games that connect to online servers might only work if the steam emu behaves like steam is in offline mode. If you need this create a offline.txt file in the steam_settings folder.
|
||||
|
||||
Disable networking:
|
||||
If for some reason you want to disable all the networking functionality of the emu you can create a disable_networking.txt file in the steam_settings folder. This will of course break all the
|
||||
networking functionality so games that use networking related functionality like lobbies or those that launch a server in the background will not work.
|
||||
|
||||
Custom Broadcast ips:
|
||||
If you want to set custom ips (or domains) which the emulator will send broadcast packets to, make a list of them, one on each line in: Goldberg SteamEmu Saves\settings\custom_broadcasts.txt
|
||||
If the custom ips/domains are specific for one game only you can put the custom_broadcasts.txt in the steam_settings\ folder.
|
||||
An example is provided in steam_settings.EXAMPLE\custom_broadcasts.EXAMPLE.txt
|
||||
|
||||
Items or Inventory:
|
||||
Create a folder named steam_settings right beside steam_api.dll if there isn't one already. In that folder, create a file named items.json which will contain every item you want to have in your game.
|
||||
Achievements, Items or Inventory:
|
||||
Create a folder named steam_settings right beside steam_api.dll if there isn't one already. In that folder, create a file named items.json and/or achievements.json which will contain every item/achievement you want to have in your game.
|
||||
An example can be found in steam_settings.EXAMPLE that works with Killing Floor 2.
|
||||
The items.json syntax is simple, you SHOULD validate your .json file before trying to run your game or you won't have any item in your inventory. Just look for "online json validator" on your web brower to valide your file.
|
||||
You can use https://steamdb.info/ to list items and attributes they have and put them into your .json.
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
cd /d "%~dp0"
|
||||
del /Q /S release\*
|
||||
rmdir /S /Q release\experimental
|
||||
rmdir /S /Q release\experimental_steamclient
|
||||
rmdir /S /Q release\lobby_connect
|
||||
rmdir /S /Q release
|
||||
mkdir release
|
||||
|
@ -18,5 +19,6 @@ cl /LD /DNO_OVERLAY /DEMU_RELEASE_BUILD /DNDEBUG /I%PROTOBUF_X64_DIRECTORY%\incl
|
|||
copy Readme_release.txt release\Readme.txt
|
||||
xcopy /s files_example\* release\
|
||||
call build_win_release_experimental.bat
|
||||
call build_win_release_experimental_steamclient.bat
|
||||
call build_win_lobby_connect.bat
|
||||
call build_win_find_interfaces.bat
|
||||
|
|
|
@ -0,0 +1,16 @@
|
|||
@echo off
|
||||
cd /d "%~dp0"
|
||||
mkdir release\experimental_steamclient
|
||||
del /Q release\experimental_steamclient\*
|
||||
call build_set_protobuf_directories.bat
|
||||
"%PROTOC_X86_EXE%" -I.\dll\ --cpp_out=.\dll\ .\dll\net.proto
|
||||
call build_env_x86.bat
|
||||
cl dll/rtlgenrandom.c dll/rtlgenrandom.def
|
||||
cl /LD /DEMU_RELEASE_BUILD /DEMU_EXPERIMENTAL_BUILD /DSTEAMCLIENT_DLL /DCONTROLLER_SUPPORT /DNDEBUG /I%PROTOBUF_X86_DIRECTORY%\include\ dll/*.cpp dll/*.cc detours/*.cpp controller/gamepad.c "%PROTOBUF_X86_LIBRARY%" Iphlpapi.lib Ws2_32.lib rtlgenrandom.lib Shell32.lib /EHsc /MP12 /Ox /link /debug:none /OUT:release\experimental_steamclient\steamclient.dll
|
||||
"%PROTOC_X64_EXE%" -I.\dll\ --cpp_out=.\dll\ .\dll\net.proto
|
||||
cl steamclient_loader/*.cpp advapi32.lib user32.lib /EHsc /MP12 /Ox /link /debug:none /OUT:release\experimental_steamclient\steamclient_loader.exe
|
||||
copy steamclient_loader\ColdClientLoader.ini release\experimental_steamclient\
|
||||
call build_env_x64.bat
|
||||
cl dll/rtlgenrandom.c dll/rtlgenrandom.def
|
||||
cl /LD /DEMU_RELEASE_BUILD /DEMU_EXPERIMENTAL_BUILD /DSTEAMCLIENT_DLL /DCONTROLLER_SUPPORT /DNDEBUG /I%PROTOBUF_X64_DIRECTORY%\include\ dll/*.cpp dll/*.cc detours/*.cpp controller/gamepad.c "%PROTOBUF_X64_LIBRARY%" Iphlpapi.lib Ws2_32.lib rtlgenrandom.lib Shell32.lib /EHsc /MP12 /Ox /link /debug:none /OUT:release\experimental_steamclient\steamclient64.dll
|
||||
copy Readme_experimental_steamclient.txt release\experimental_steamclient\Readme.txt
|
10
dll/base.h
10
dll/base.h
|
@ -132,8 +132,12 @@ struct Steam_Call_Result {
|
|||
return check_timedout(created, STEAM_CALLRESULT_TIMEOUT);
|
||||
}
|
||||
|
||||
bool call_completed() {
|
||||
return (!reserved) && check_timedout(created, run_in);
|
||||
}
|
||||
|
||||
bool can_execute() {
|
||||
return (!reserved) && (!to_delete) && check_timedout(created, run_in);
|
||||
return (!to_delete) && call_completed();
|
||||
}
|
||||
|
||||
bool has_cb() {
|
||||
|
@ -191,14 +195,14 @@ public:
|
|||
bool exists(SteamAPICall_t api_call) {
|
||||
auto cr = std::find_if(callresults.begin(), callresults.end(), [api_call](struct Steam_Call_Result const& item) { return item.api_call == api_call; });
|
||||
if (cr == callresults.end()) return false;
|
||||
if (cr->reserved) return false;
|
||||
if (!cr->call_completed()) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool callback_result(SteamAPICall_t api_call, void *copy_to, unsigned int size) {
|
||||
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->reserved) return false;
|
||||
if (!cb_result->call_completed()) return false;
|
||||
if (cb_result->result.size() > size) return false;
|
||||
|
||||
memcpy(copy_to, &(cb_result->result[0]), cb_result->result.size());
|
||||
|
|
|
@ -1,62 +0,0 @@
|
|||
/* Copyright (C) 2019 Nemirtingas (Maxime P)
|
||||
This file is part of the Goldberg Emulator
|
||||
|
||||
The Goldberg Emulator is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 3 of the License, or (at your option) any later version.
|
||||
|
||||
The Goldberg Emulator 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the Goldberg Emulator; if not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
#include "item_db_loader.h"
|
||||
|
||||
#include <fstream>
|
||||
#include "../json/json.hpp"
|
||||
|
||||
void read_items_db(std::string items_db, std::map<SteamItemDef_t, std::map<std::string, std::string>> *items, std::atomic_bool *is_loadedb)
|
||||
{
|
||||
std::ifstream items_file(items_db);
|
||||
// If there is a file and we opened it
|
||||
if( items_file )
|
||||
{
|
||||
items_file.seekg(0, std::ios::end);
|
||||
size_t size = items_file.tellg();
|
||||
std::string buffer(size, '\0');
|
||||
items_file.seekg(0);
|
||||
// Read it entirely, if the .json file gets too big,
|
||||
// I should look into this and split reads into smaller parts.
|
||||
items_file.read(&buffer[0], size);
|
||||
items_file.close();
|
||||
|
||||
try
|
||||
{
|
||||
std::map<SteamItemDef_t, std::map<std::string, std::string>> tmp;
|
||||
nlohmann::json json = nlohmann::json::parse(buffer);
|
||||
|
||||
for (auto& i : json.items())
|
||||
{
|
||||
SteamItemDef_t key = std::stoi((*i).key());
|
||||
nlohmann::json& value = (*i).value();
|
||||
for (auto& j : value.items())
|
||||
{
|
||||
tmp[key][(*j).key()] = (*j).value();
|
||||
}
|
||||
}
|
||||
|
||||
items->swap(tmp);
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
PRINT_DEBUG("Error while parsing json: %s\n", e.what());
|
||||
}
|
||||
}
|
||||
|
||||
PRINT_DEBUG("Loaded json. Loaded %u items.\n", items->size());
|
||||
*is_loadedb = true;
|
||||
}
|
|
@ -1,24 +0,0 @@
|
|||
/* Copyright (C) 2019 Nemirtingas (Maxime P)
|
||||
This file is part of the Goldberg Emulator
|
||||
|
||||
The Goldberg Emulator is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 3 of the License, or (at your option) any later version.
|
||||
|
||||
The Goldberg Emulator 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with the Goldberg Emulator;*/
|
||||
#ifndef __ITEM_DB_LOADER_INCLUDED__
|
||||
#define __ITEM_DB_LOADER_INCLUDED__
|
||||
|
||||
#include "base.h" // For SteamItemDef_t
|
||||
|
||||
#include <atomic>
|
||||
void read_items_db(std::string items_db, std::map<SteamItemDef_t, std::map<std::string, std::string>> *items, std::atomic_bool *is_loaded);
|
||||
|
||||
#endif//__ITEM_DB_LOADER_INCLUDED__
|
|
@ -20,6 +20,7 @@
|
|||
#include <fstream>
|
||||
#include <algorithm>
|
||||
#include <iterator>
|
||||
#include <iomanip>
|
||||
|
||||
struct File_Data {
|
||||
std::string name;
|
||||
|
@ -393,7 +394,7 @@ std::string Local_Storage::get_program_path()
|
|||
|
||||
std::string Local_Storage::get_game_settings_path()
|
||||
{
|
||||
return get_program_path().append(GAME_SETTINGS_FOLDER).append(PATH_SEPARATOR);
|
||||
return get_program_path().append(game_settings_folder).append(PATH_SEPARATOR);
|
||||
}
|
||||
|
||||
#if defined(STEAM_WIN32)
|
||||
|
@ -523,7 +524,7 @@ std::string Local_Storage::get_path(std::string folder)
|
|||
|
||||
std::string Local_Storage::get_global_settings_path()
|
||||
{
|
||||
return save_directory + SETTINGS_STORAGE_FOLDER + PATH_SEPARATOR;
|
||||
return save_directory + settings_storage_folder + PATH_SEPARATOR;
|
||||
}
|
||||
|
||||
std::vector<std::string> Local_Storage::get_filenames_path(std::string path)
|
||||
|
|
|
@ -21,18 +21,21 @@
|
|||
#ifndef LOCAL_STORAGE_INCLUDE
|
||||
#define LOCAL_STORAGE_INCLUDE
|
||||
|
||||
#define SETTINGS_STORAGE_FOLDER "settings"
|
||||
#define REMOTE_STORAGE_FOLDER "remote"
|
||||
#define STATS_STORAGE_FOLDER "stats"
|
||||
#define USER_DATA_FOLDER "local"
|
||||
|
||||
#define GAME_SETTINGS_FOLDER "steam_settings"
|
||||
|
||||
#include <string>
|
||||
#include "../json/json.hpp"
|
||||
|
||||
#define MAX_FILENAME_LENGTH 300
|
||||
|
||||
class Local_Storage {
|
||||
public:
|
||||
static constexpr auto inventory_storage_folder = "inventory";
|
||||
static constexpr auto settings_storage_folder = "settings";
|
||||
static constexpr auto remote_storage_folder = "remote";
|
||||
static constexpr auto stats_storage_folder = "stats";
|
||||
static constexpr auto user_data_storage = "local";
|
||||
static constexpr auto game_settings_folder = "steam_settings";
|
||||
|
||||
private:
|
||||
std::string save_directory;
|
||||
std::string appid;
|
||||
public:
|
||||
|
|
|
@ -711,18 +711,26 @@ bool Networking::handle_low_level_udp(Common_Message *msg, IP_PORT ip_port)
|
|||
|
||||
#define NUM_TCP_WAITING 128
|
||||
|
||||
Networking::Networking(CSteamID id, uint32 appid, uint16 port, std::set<uint32_t> *custom_broadcasts)
|
||||
Networking::Networking(CSteamID id, uint32 appid, uint16 port, std::set<uint32_t> *custom_broadcasts, bool disable_sockets)
|
||||
{
|
||||
run_at_startup();
|
||||
tcp_port = udp_port = port;
|
||||
own_ip = 0x7F000001;
|
||||
alive = true;
|
||||
last_run = std::chrono::high_resolution_clock::now();
|
||||
this->appid = appid;
|
||||
|
||||
if (disable_sockets) {
|
||||
enabled = false;
|
||||
udp_socket = -1;
|
||||
tcp_socket = -1;
|
||||
return;
|
||||
}
|
||||
|
||||
if (custom_broadcasts) {
|
||||
std::transform(custom_broadcasts->begin(), custom_broadcasts->end(), std::back_inserter(this->custom_broadcasts), [](uint32 ip) {return htonl(ip);});
|
||||
}
|
||||
|
||||
run_at_startup();
|
||||
sock_t sock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
|
||||
PRINT_DEBUG("UDP socket: %u\n", sock);
|
||||
if (is_socket_valid(sock) && set_socket_nonblocking(sock)) {
|
||||
|
@ -1059,6 +1067,7 @@ void Networking::Run()
|
|||
|
||||
void Networking::addListenId(CSteamID id)
|
||||
{
|
||||
if (!enabled) return;
|
||||
auto i = std::find(ids.begin(), ids.end(), id);
|
||||
if (i != ids.end()) {
|
||||
return;
|
||||
|
@ -1092,6 +1101,8 @@ bool Networking::sendToIPPort(Common_Message *msg, uint32 ip, uint16 port, bool
|
|||
|
||||
bool Networking::sendTo(Common_Message *msg, bool reliable, Connection *conn)
|
||||
{
|
||||
if (!enabled) return false;
|
||||
|
||||
bool ret = false;
|
||||
CSteamID dest_id((uint64)msg->dest_id());
|
||||
if (std::find(ids.begin(), ids.end(), dest_id) != ids.end()) {
|
||||
|
|
|
@ -125,7 +125,7 @@ public:
|
|||
//NOTE: for all functions ips/ports are passed/returned in host byte order
|
||||
//ex: 127.0.0.1 should be passed as 0x7F000001
|
||||
static std::set<uint32> resolve_ip(std::string dns);
|
||||
Networking(CSteamID id, uint32 appid, uint16 port, std::set<uint32_t> *custom_broadcasts);
|
||||
Networking(CSteamID id, uint32 appid, uint16 port, std::set<uint32_t> *custom_broadcasts, bool disable_sockets);
|
||||
void addListenId(CSteamID id);
|
||||
void setAppID(uint32 appid);
|
||||
void Run();
|
||||
|
|
|
@ -135,6 +135,9 @@ public:
|
|||
|
||||
//controller
|
||||
struct Controller_Settings controller_settings;
|
||||
|
||||
//networking
|
||||
bool disable_networking = false;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -217,7 +217,7 @@ uint32 create_localstorage_settings(Settings **settings_client_out, Settings **s
|
|||
uint64 steam_id = 0;
|
||||
bool generate_new = false;
|
||||
//try to load steam id from game specific settings folder first
|
||||
if (local_storage->get_data(SETTINGS_STORAGE_FOLDER, "user_steam_id.txt", array_steam_id, sizeof(array_steam_id) - 1) > 0) {
|
||||
if (local_storage->get_data(Local_Storage::settings_storage_folder, "user_steam_id.txt", array_steam_id, sizeof(array_steam_id) - 1) > 0) {
|
||||
user_id = CSteamID((uint64)std::atoll(array_steam_id));
|
||||
if (!user_id.IsValid()) {
|
||||
generate_new = true;
|
||||
|
@ -247,6 +247,7 @@ uint32 create_localstorage_settings(Settings **settings_client_out, Settings **s
|
|||
}
|
||||
|
||||
bool steam_offline_mode = false;
|
||||
bool disable_networking = false;
|
||||
{
|
||||
std::string steam_settings_path = Local_Storage::get_game_settings_path();
|
||||
|
||||
|
@ -255,6 +256,8 @@ uint32 create_localstorage_settings(Settings **settings_client_out, Settings **s
|
|||
PRINT_DEBUG("steam settings path %s\n", p.c_str());
|
||||
if (p == "offline.txt") {
|
||||
steam_offline_mode = true;
|
||||
} else if (p == "disable_networking.txt") {
|
||||
disable_networking = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -265,6 +268,8 @@ uint32 create_localstorage_settings(Settings **settings_client_out, Settings **s
|
|||
settings_server->set_port(port);
|
||||
settings_client->custom_broadcasts = custom_broadcasts;
|
||||
settings_server->custom_broadcasts = custom_broadcasts;
|
||||
settings_client->disable_networking = disable_networking;
|
||||
settings_server->disable_networking = disable_networking;
|
||||
|
||||
{
|
||||
std::string dlc_config_path = Local_Storage::get_game_settings_path() + "DLC.txt";
|
||||
|
|
|
@ -42,7 +42,6 @@ static void background_thread(Steam_Client *client)
|
|||
Steam_Client::Steam_Client()
|
||||
{
|
||||
uint32 appid = create_localstorage_settings(&settings_client, &settings_server, &local_storage);
|
||||
std::string items_db_file_path = (Local_Storage::get_game_settings_path() + "items.json");
|
||||
|
||||
{
|
||||
std::ifstream chk_ovlay(Local_Storage::get_program_path() + PATH_SEPARATOR + "disable_overlay.txt", std::ios::in);
|
||||
|
@ -79,7 +78,7 @@ Steam_Client::Steam_Client()
|
|||
steam_music = new Steam_Music(callbacks_client);
|
||||
steam_musicremote = new Steam_MusicRemote();
|
||||
steam_HTMLsurface = new Steam_HTMLsurface(settings_client, network, callback_results_client, callbacks_client);
|
||||
steam_inventory = new Steam_Inventory(settings_client, callback_results_client, callbacks_client, run_every_runcb, items_db_file_path);
|
||||
steam_inventory = new Steam_Inventory(settings_client, callback_results_client, callbacks_client, run_every_runcb, local_storage);
|
||||
steam_video = new Steam_Video();
|
||||
steam_parental = new Steam_Parental();
|
||||
steam_networking_sockets = new Steam_Networking_Sockets(settings_client, network, callback_results_client, callbacks_client, run_every_runcb);
|
||||
|
@ -97,7 +96,7 @@ Steam_Client::Steam_Client()
|
|||
steam_gameserverstats = new Steam_GameServerStats(settings_server, network, callback_results_server, callbacks_server);
|
||||
steam_gameserver_networking = new Steam_Networking(settings_server, network, callbacks_server, run_every_runcb);
|
||||
steam_gameserver_http = new Steam_HTTP(settings_server, network, callback_results_server, callbacks_server);
|
||||
steam_gameserver_inventory = new Steam_Inventory(settings_server, callback_results_server, callbacks_server, run_every_runcb, items_db_file_path);
|
||||
steam_gameserver_inventory = new Steam_Inventory(settings_server, callback_results_server, callbacks_server, run_every_runcb, local_storage);
|
||||
steam_gameserver_ugc = new Steam_UGC(settings_server, callback_results_server, callbacks_server);
|
||||
steam_gameserver_apps = new Steam_Apps(settings_server, callback_results_server);
|
||||
steam_gameserver_networking_sockets = new Steam_Networking_Sockets(settings_server, network, callback_results_server, callbacks_server, run_every_runcb);
|
||||
|
|
|
@ -682,7 +682,8 @@ int GetAnalogActionOrigins( InputHandle_t inputHandle, InputActionSetHandle_t ac
|
|||
break;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -15,8 +15,8 @@
|
|||
License along with the Goldberg Emulator; if not, see
|
||||
<http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include "item_db_loader.h"
|
||||
#include <thread>
|
||||
#include "base.h" // For SteamItemDef_t
|
||||
#include "../json/json.hpp"
|
||||
|
||||
struct Steam_Inventory_Requests {
|
||||
double timeout = 0.1;
|
||||
|
@ -42,21 +42,23 @@ class Steam_Inventory :
|
|||
public ISteamInventory002,
|
||||
public ISteamInventory
|
||||
{
|
||||
public:
|
||||
static constexpr auto items_user_file = "items.json";
|
||||
static constexpr auto items_default_file = "default_items.json";
|
||||
|
||||
private:
|
||||
class Settings *settings;
|
||||
class SteamCallResults *callback_results;
|
||||
class SteamCallBacks *callbacks;
|
||||
class RunEveryRunCB *run_every_runcb;
|
||||
class Local_Storage* local_storage;
|
||||
|
||||
std::vector<struct Steam_Inventory_Requests> inventory_requests;
|
||||
|
||||
std::map<SteamItemDef_t, std::map<std::string, std::string>> items;
|
||||
// Like typedefs
|
||||
using item_iterator = std::map<SteamItemDef_t, std::map<std::string, std::string>>::iterator;
|
||||
using attr_iterator = std::map<std::string, std::string>::iterator;
|
||||
nlohmann::json defined_items;
|
||||
nlohmann::json user_items;
|
||||
|
||||
std::atomic_bool items_loaded;
|
||||
std::string items_db_file;
|
||||
std::once_flag load_items_flag;
|
||||
bool inventory_loaded;
|
||||
bool call_definition_update;
|
||||
bool item_definitions_loaded;
|
||||
|
||||
|
@ -129,19 +131,7 @@ Steam_Inventory(class Settings *settings, class SteamCallResults *callback_resul
|
|||
call_definition_update(false),
|
||||
item_definitions_loaded(false)
|
||||
{
|
||||
items_db_file = items_db_file_path;
|
||||
PRINT_DEBUG("Items file path: %s\n", items_db_file.c_str());
|
||||
items_loaded = false;
|
||||
|
||||
this->settings = settings;
|
||||
this->callbacks = callbacks;
|
||||
this->callback_results = callback_results;
|
||||
this->run_every_runcb = run_every_runcb;
|
||||
this->run_every_runcb->add(&Steam_Inventory::run_every_runcb_cb, this);
|
||||
|
||||
call_definition_update = false;
|
||||
definition_update_called = false;
|
||||
full_update_called = false;
|
||||
}
|
||||
|
||||
~Steam_Inventory()
|
||||
|
@ -188,6 +178,7 @@ bool GetResultItems( SteamInventoryResult_t resultHandle,
|
|||
struct Steam_Inventory_Requests *request = get_inventory_result(resultHandle);
|
||||
if (!request) return false;
|
||||
if (!request->result_done()) return false;
|
||||
if (!inventory_loaded) return false;
|
||||
|
||||
if (pOutItemsArray != nullptr)
|
||||
{
|
||||
|
@ -196,11 +187,18 @@ bool GetResultItems( SteamInventoryResult_t resultHandle,
|
|||
|
||||
if (request->full_query) {
|
||||
// We end if we reached the end of items or the end of buffer
|
||||
for( auto i = items.begin(); i != items.end() && max_items; ++i, --max_items )
|
||||
for( auto i = user_items.begin(); i != user_items.end() && max_items; ++i, --max_items )
|
||||
{
|
||||
pOutItemsArray->m_iDefinition = i->first;
|
||||
pOutItemsArray->m_itemId = i->first;
|
||||
pOutItemsArray->m_unQuantity = 1;
|
||||
pOutItemsArray->m_iDefinition = std::stoi(i.key());
|
||||
pOutItemsArray->m_itemId = pOutItemsArray->m_iDefinition;
|
||||
try
|
||||
{
|
||||
pOutItemsArray->m_unQuantity = i.value().get<int>();
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
pOutItemsArray->m_unQuantity = 0;
|
||||
}
|
||||
pOutItemsArray->m_unFlags = k_ESteamItemNoTrade;
|
||||
++pOutItemsArray;
|
||||
}
|
||||
|
@ -602,15 +600,15 @@ bool GetItemDefinitionIDs(
|
|||
|
||||
if (pItemDefIDs == nullptr)
|
||||
{
|
||||
*punItemDefIDsArraySize = items.size();
|
||||
*punItemDefIDsArraySize = defined_items.size();
|
||||
return true;
|
||||
}
|
||||
|
||||
if (*punItemDefIDsArraySize < items.size())
|
||||
if (*punItemDefIDsArraySize < defined_items.size())
|
||||
return false;
|
||||
|
||||
for (auto& i : items)
|
||||
*pItemDefIDs++ = i.first;
|
||||
for (auto i = defined_items.begin(); i != defined_items.end(); ++i)
|
||||
*pItemDefIDs++ = std::stoi(i.key());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -631,25 +629,39 @@ bool GetItemDefinitionProperty( SteamItemDef_t iDefinition, const char *pchPrope
|
|||
PRINT_DEBUG("GetItemDefinitionProperty %i %s\n", iDefinition, pchPropertyName);
|
||||
std::lock_guard<std::recursive_mutex> lock(global_mutex);
|
||||
|
||||
item_iterator item;
|
||||
if ((item = items.find(iDefinition)) != items.end())
|
||||
auto item = defined_items.find(std::to_string(iDefinition));
|
||||
if (item != defined_items.end())
|
||||
{
|
||||
attr_iterator attr;
|
||||
if (pchPropertyName != nullptr)
|
||||
{
|
||||
// Should I check for punValueBufferSizeOut == nullptr ?
|
||||
// Try to get the property
|
||||
if ((attr = item->second.find(pchPropertyName)) != items[iDefinition].end())
|
||||
auto attr = item.value().find(pchPropertyName);
|
||||
if (attr != item.value().end())
|
||||
{
|
||||
std::string const& val = attr->second;
|
||||
std::string val;
|
||||
try
|
||||
{
|
||||
val = attr.value().get<std::string>();
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
pchPropertyName = "";
|
||||
*punValueBufferSizeOut = 0;
|
||||
PRINT_DEBUG("Error, item: %d, attr: %s is not a string!", iDefinition, pchPropertyName);
|
||||
return true;
|
||||
}
|
||||
if (pchValueBuffer != nullptr)
|
||||
{
|
||||
// copy what we can
|
||||
strncpy(pchValueBuffer, val.c_str(), *punValueBufferSizeOut);
|
||||
}
|
||||
|
||||
// Set punValueBufferSizeOut to the property size
|
||||
*punValueBufferSizeOut = std::min(static_cast<uint32>(val.length() + 1), *punValueBufferSizeOut);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Set punValueBufferSizeOut to the property size
|
||||
*punValueBufferSizeOut = val.length() + 1;
|
||||
}
|
||||
|
||||
if (pchValueBuffer != nullptr)
|
||||
{
|
||||
|
@ -672,8 +684,8 @@ bool GetItemDefinitionProperty( SteamItemDef_t iDefinition, const char *pchPrope
|
|||
{
|
||||
// Should I check for punValueBufferSizeOut == nullptr ?
|
||||
*punValueBufferSizeOut = 0;
|
||||
for (auto& i : item->second)
|
||||
*punValueBufferSizeOut += i.first.length() + 1; // Size of key + comma, and the last is not a comma but null char
|
||||
for (auto i = item.value().begin(); i != item.value().end(); ++i)
|
||||
*punValueBufferSizeOut += i.key().length() + 1; // Size of key + comma, and the last is not a comma but null char
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -681,16 +693,16 @@ bool GetItemDefinitionProperty( SteamItemDef_t iDefinition, const char *pchPrope
|
|||
uint32_t len = *punValueBufferSizeOut-1;
|
||||
*punValueBufferSizeOut = 0;
|
||||
memset(pchValueBuffer, 0, len);
|
||||
for( auto i = item->second.begin(); i != item->second.end() && len > 0; ++i )
|
||||
for( auto i = item.value().begin(); i != item.value().end() && len > 0; ++i )
|
||||
{
|
||||
strncat(pchValueBuffer, i->first.c_str(), len);
|
||||
strncat(pchValueBuffer, i.key().c_str(), len);
|
||||
// Count how many chars we copied
|
||||
// Either the string length or the buffer size if its too small
|
||||
uint32 x = std::min(len, static_cast<uint32>(i->first.length()));
|
||||
uint32 x = std::min(len, static_cast<uint32>(i.key().length()));
|
||||
*punValueBufferSizeOut += x;
|
||||
len -= x;
|
||||
|
||||
if (len && std::distance(i, item->second.end()) != 1) // If this is not the last item, add a comma
|
||||
if (len && std::distance(i, item.value().end()) != 1) // If this is not the last item, add a comma
|
||||
strncat(pchValueBuffer, ",", len--);
|
||||
|
||||
// Always add 1, its a comma or the null terminator
|
||||
|
@ -745,7 +757,10 @@ STEAM_CALL_RESULT( SteamInventoryRequestPricesResult_t )
|
|||
SteamAPICall_t RequestPrices()
|
||||
{
|
||||
PRINT_DEBUG("RequestPrices\n");
|
||||
return 0;
|
||||
SteamInventoryRequestPricesResult_t data;
|
||||
data.m_result = k_EResultOK;
|
||||
memcpy(data.m_rgchCurrency, "USD", 4);
|
||||
return callback_results->addCallResult(data.k_iCallback, &data, sizeof(data), 0.2);
|
||||
}
|
||||
|
||||
|
||||
|
@ -753,6 +768,7 @@ SteamAPICall_t RequestPrices()
|
|||
uint32 GetNumItemsWithPrices()
|
||||
{
|
||||
PRINT_DEBUG("GetNumItemsWithPrices\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool GetItemsWithPrices( STEAM_ARRAY_COUNT(unArrayLength) STEAM_OUT_ARRAY_COUNT(pArrayItemDefs, Items with prices) SteamItemDef_t *pArrayItemDefs,
|
||||
|
@ -761,6 +777,7 @@ bool GetItemsWithPrices( STEAM_ARRAY_COUNT(unArrayLength) STEAM_OUT_ARRAY_COUNT(
|
|||
uint32 unArrayLength )
|
||||
{
|
||||
PRINT_DEBUG("GetItemsWithPrices\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Returns item definition ids and their prices in the user's local currency.
|
||||
|
@ -836,7 +853,7 @@ void RunCallbacks()
|
|||
//only gets called once
|
||||
//also gets called when getting items
|
||||
SteamInventoryDefinitionUpdate_t data = {};
|
||||
callbacks->addCBResult(data.k_iCallback, &data, sizeof(data));
|
||||
callbacks->addCBResult(data.k_iCallback, &data, sizeof(data), 0.05);
|
||||
}
|
||||
|
||||
call_definition_update = false;
|
||||
|
@ -850,8 +867,7 @@ void RunCallbacks()
|
|||
if (inventory_loaded)
|
||||
{
|
||||
std::chrono::system_clock::time_point now = std::chrono::system_clock::now();
|
||||
|
||||
for (auto & r : inventory_requests) {
|
||||
for (auto& r : inventory_requests) {
|
||||
if (!r.done && std::chrono::duration_cast<std::chrono::duration<double>>(now - r.time_created).count() > r.timeout) {
|
||||
if (r.full_query) {
|
||||
// SteamInventoryFullUpdate_t callbacks are triggered when GetAllItems
|
||||
|
|
|
@ -1165,7 +1165,8 @@ void RunCallbacks()
|
|||
}
|
||||
}
|
||||
} else {
|
||||
int compare_to = stoi(value->second, 0, 0);
|
||||
try {
|
||||
int compare_to = std::stoi(value->second, 0, 0);
|
||||
PRINT_DEBUG("Compare Values %i %i\n", compare_to, f.value_int);
|
||||
if (f.eComparisonType == k_ELobbyComparisonEqual) {
|
||||
if (compare_to == f.value_int) {
|
||||
|
@ -1176,6 +1177,10 @@ void RunCallbacks()
|
|||
use = false;
|
||||
}
|
||||
}
|
||||
} catch (...) {
|
||||
//Same case as if the key is not in the lobby?
|
||||
use = false;
|
||||
}
|
||||
//TODO: add more comparisons
|
||||
}
|
||||
} else {
|
||||
|
|
|
@ -1045,6 +1045,7 @@ bool GetHostedDedicatedServerAddress001( SteamDatagramHostedAddress *pRouting )
|
|||
/// directly share it with clients.
|
||||
virtual EResult GetHostedDedicatedServerAddress( SteamDatagramHostedAddress *pRouting )
|
||||
{
|
||||
PRINT_DEBUG("Steam_Networking_Sockets::GetHostedDedicatedServerAddress %p\n", pRouting);
|
||||
std::lock_guard<std::recursive_mutex> lock(global_mutex);
|
||||
pRouting->SetDevAddress(network->getOwnIP(), 27054);
|
||||
return k_EResultOK;
|
||||
|
|
|
@ -28,6 +28,7 @@ public ISteamNetworkingUtils
|
|||
class RunEveryRunCB *run_every_runcb;
|
||||
std::chrono::time_point<std::chrono::steady_clock> initialized_time = std::chrono::steady_clock::now();
|
||||
FSteamNetworkingSocketsDebugOutput debug_function;
|
||||
bool relay_initialized = false;
|
||||
|
||||
public:
|
||||
static void steam_callback(void *object, Common_Message *msg)
|
||||
|
@ -67,6 +68,7 @@ Steam_Networking_Utils(class Settings *settings, class Networking *network, clas
|
|||
bool InitializeRelayAccess()
|
||||
{
|
||||
PRINT_DEBUG("Steam_Networking_Utils::InitializeRelayAccess\n");
|
||||
relay_initialized = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -80,44 +82,71 @@ bool InitializeRelayAccess()
|
|||
/// more details, you can pass a non-NULL value.
|
||||
ESteamNetworkingAvailability GetRelayNetworkStatus( SteamRelayNetworkStatus_t *pDetails )
|
||||
{
|
||||
PRINT_DEBUG("Steam_Networking_Utils::GetRelayNetworkStatus\n");
|
||||
PRINT_DEBUG("Steam_Networking_Utils::GetRelayNetworkStatus %p\n", pDetails);
|
||||
std::lock_guard<std::recursive_mutex> lock(global_mutex);
|
||||
|
||||
//TODO: check if this is how real steam returns it
|
||||
SteamRelayNetworkStatus_t data = {};
|
||||
if (relay_initialized) {
|
||||
data.m_eAvail = k_ESteamNetworkingAvailability_Current;
|
||||
data.m_bPingMeasurementInProgress = 0;
|
||||
data.m_eAvailAnyRelay = k_ESteamNetworkingAvailability_Current;
|
||||
data.m_eAvailNetworkConfig = k_ESteamNetworkingAvailability_Current;
|
||||
strcpy(data.m_debugMsg, "OK");
|
||||
}
|
||||
|
||||
if (pDetails) {
|
||||
*pDetails = data;
|
||||
}
|
||||
|
||||
return k_ESteamNetworkingAvailability_Current;
|
||||
}
|
||||
|
||||
float GetLocalPingLocation( SteamNetworkPingLocation_t &result )
|
||||
{
|
||||
PRINT_DEBUG("Steam_Networking_Utils::GetLocalPingLocation\n");
|
||||
if (relay_initialized) {
|
||||
result.m_data[2] = 123;
|
||||
result.m_data[8] = 67;
|
||||
return 2.0;
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
int EstimatePingTimeBetweenTwoLocations( const SteamNetworkPingLocation_t &location1, const SteamNetworkPingLocation_t &location2 )
|
||||
{
|
||||
PRINT_DEBUG("Steam_Networking_Utils::EstimatePingTimeBetweenTwoLocations\n");
|
||||
return k_nSteamNetworkingPing_Unknown ;
|
||||
//return k_nSteamNetworkingPing_Unknown;
|
||||
return 10;
|
||||
}
|
||||
|
||||
|
||||
int EstimatePingTimeFromLocalHost( const SteamNetworkPingLocation_t &remoteLocation )
|
||||
{
|
||||
PRINT_DEBUG("Steam_Networking_Utils::EstimatePingTimeFromLocalHost\n");
|
||||
return 10;
|
||||
}
|
||||
|
||||
|
||||
void ConvertPingLocationToString( const SteamNetworkPingLocation_t &location, char *pszBuf, int cchBufSize )
|
||||
{
|
||||
PRINT_DEBUG("Steam_Networking_Utils::ConvertPingLocationToString\n");
|
||||
strncpy(pszBuf, "fra=10+2", cchBufSize);
|
||||
}
|
||||
|
||||
|
||||
bool ParsePingLocationString( const char *pszString, SteamNetworkPingLocation_t &result )
|
||||
{
|
||||
PRINT_DEBUG("Steam_Networking_Utils::ParsePingLocationString\n");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool CheckPingDataUpToDate( float flMaxAgeSeconds )
|
||||
{
|
||||
PRINT_DEBUG("Steam_Networking_Utils::CheckPingDataUpToDate %f\n", flMaxAgeSeconds);
|
||||
relay_initialized = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -125,6 +154,7 @@ bool CheckPingDataUpToDate( float flMaxAgeSeconds )
|
|||
bool IsPingMeasurementInProgress()
|
||||
{
|
||||
PRINT_DEBUG("Steam_Networking_Utils::IsPingMeasurementInProgress\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@ Steam_Remote_Storage(class Settings *settings, Local_Storage *local_storage, cla
|
|||
this->local_storage = local_storage;
|
||||
this->callback_results = callback_results;
|
||||
steam_cloud_enabled = true;
|
||||
local_storage->update_save_filenames(REMOTE_STORAGE_FOLDER);
|
||||
local_storage->update_save_filenames(Local_Storage::remote_storage_folder);
|
||||
}
|
||||
|
||||
// NOTE
|
||||
|
@ -83,8 +83,12 @@ Steam_Remote_Storage(class Settings *settings, Local_Storage *local_storage, cla
|
|||
bool FileWrite( const char *pchFile, const void *pvData, int32 cubData )
|
||||
{
|
||||
PRINT_DEBUG("Steam_Remote_Storage::FileWrite %s %u\n", pchFile, cubData);
|
||||
if (!pchFile || cubData <= 0 || cubData > k_unMaxCloudFileChunkSize) {
|
||||
return false;
|
||||
}
|
||||
|
||||
std::lock_guard<std::recursive_mutex> lock(global_mutex);
|
||||
int data_stored = local_storage->store_data(REMOTE_STORAGE_FOLDER, pchFile, (char* )pvData, cubData);
|
||||
int data_stored = local_storage->store_data(Local_Storage::remote_storage_folder, pchFile, (char* )pvData, cubData);
|
||||
PRINT_DEBUG("Steam_Remote_Storage::Stored %i, %u\n", data_stored, data_stored == cubData);
|
||||
return data_stored == cubData;
|
||||
}
|
||||
|
@ -93,7 +97,7 @@ int32 FileRead( const char *pchFile, void *pvData, int32 cubDataToRead )
|
|||
{
|
||||
PRINT_DEBUG("Steam_Remote_Storage::FileRead %s %i\n", pchFile, cubDataToRead);
|
||||
std::lock_guard<std::recursive_mutex> lock(global_mutex);
|
||||
int read_data = local_storage->get_data(REMOTE_STORAGE_FOLDER, pchFile, (char* )pvData, cubDataToRead);
|
||||
int read_data = local_storage->get_data(Local_Storage::remote_storage_folder, pchFile, (char* )pvData, cubDataToRead);
|
||||
if (read_data < 0) read_data = 0;
|
||||
PRINT_DEBUG("Read %i\n", read_data);
|
||||
return read_data;
|
||||
|
@ -103,12 +107,16 @@ STEAM_CALL_RESULT( RemoteStorageFileWriteAsyncComplete_t )
|
|||
SteamAPICall_t FileWriteAsync( const char *pchFile, const void *pvData, uint32 cubData )
|
||||
{
|
||||
PRINT_DEBUG("Steam_Remote_Storage::FileWriteAsync\n");
|
||||
std::lock_guard<std::recursive_mutex> lock(global_mutex);
|
||||
bool success = local_storage->store_data(REMOTE_STORAGE_FOLDER, pchFile, (char* )pvData, cubData) == cubData;
|
||||
RemoteStorageFileWriteAsyncComplete_t data;
|
||||
data.m_eResult = k_EResultOK;
|
||||
if (!pchFile || cubData > k_unMaxCloudFileChunkSize || cubData == 0) {
|
||||
return k_uAPICallInvalid;
|
||||
}
|
||||
|
||||
return callback_results->addCallResult(data.k_iCallback, &data, sizeof(data));
|
||||
std::lock_guard<std::recursive_mutex> lock(global_mutex);
|
||||
bool success = local_storage->store_data(Local_Storage::remote_storage_folder, pchFile, (char* )pvData, cubData) == cubData;
|
||||
RemoteStorageFileWriteAsyncComplete_t data;
|
||||
data.m_eResult = success ? k_EResultOK : k_EResultFail;
|
||||
|
||||
return callback_results->addCallResult(data.k_iCallback, &data, sizeof(data), 0.01);
|
||||
}
|
||||
|
||||
|
||||
|
@ -118,7 +126,7 @@ SteamAPICall_t FileReadAsync( const char *pchFile, uint32 nOffset, uint32 cubToR
|
|||
PRINT_DEBUG("Steam_Remote_Storage::FileReadAsync\n");
|
||||
std::lock_guard<std::recursive_mutex> lock(global_mutex);
|
||||
|
||||
unsigned int size = local_storage->file_size(REMOTE_STORAGE_FOLDER, pchFile);
|
||||
unsigned int size = local_storage->file_size(Local_Storage::remote_storage_folder, pchFile);
|
||||
|
||||
RemoteStorageFileReadAsyncComplete_t data;
|
||||
if (size <= nOffset) {
|
||||
|
@ -153,7 +161,7 @@ bool FileReadAsyncComplete( SteamAPICall_t hReadCall, void *pvBuffer, uint32 cub
|
|||
return false;
|
||||
|
||||
char *temp = new char[a_read->size];
|
||||
int read_data = local_storage->get_data(REMOTE_STORAGE_FOLDER, a_read->file_name, (char* )temp, a_read->size);
|
||||
int read_data = local_storage->get_data(Local_Storage::remote_storage_folder, a_read->file_name, (char* )temp, a_read->size);
|
||||
if (read_data < a_read->to_read + a_read->offset) {
|
||||
delete[] temp;
|
||||
return false;
|
||||
|
@ -175,7 +183,7 @@ bool FileForget( const char *pchFile )
|
|||
bool FileDelete( const char *pchFile )
|
||||
{
|
||||
PRINT_DEBUG("Steam_Remote_Storage::FileDelete\n");
|
||||
return local_storage->file_delete(REMOTE_STORAGE_FOLDER, pchFile);
|
||||
return local_storage->file_delete(Local_Storage::remote_storage_folder, pchFile);
|
||||
}
|
||||
|
||||
STEAM_CALL_RESULT( RemoteStorageFileShareResult_t )
|
||||
|
@ -184,7 +192,7 @@ SteamAPICall_t FileShare( const char *pchFile )
|
|||
PRINT_DEBUG("Steam_Remote_Storage::FileShare\n");
|
||||
std::lock_guard<std::recursive_mutex> lock(global_mutex);
|
||||
RemoteStorageFileShareResult_t data = {};
|
||||
if (local_storage->file_exists(REMOTE_STORAGE_FOLDER, pchFile)) {
|
||||
if (local_storage->file_exists(Local_Storage::remote_storage_folder, pchFile)) {
|
||||
data.m_eResult = k_EResultOK;
|
||||
data.m_hFile = generate_steam_api_call_id();
|
||||
strncpy(data.m_rgchFilename, pchFile, sizeof(data.m_rgchFilename) - 1);
|
||||
|
@ -237,7 +245,7 @@ bool FileWriteStreamClose( UGCFileWriteStreamHandle_t writeHandle )
|
|||
if (stream_writes.end() == request)
|
||||
return false;
|
||||
|
||||
local_storage->store_data(REMOTE_STORAGE_FOLDER, request->file_name, request->file_data.data(), request->file_data.size());
|
||||
local_storage->store_data(Local_Storage::remote_storage_folder, request->file_name, request->file_data.data(), request->file_data.size());
|
||||
stream_writes.erase(request);
|
||||
return true;
|
||||
}
|
||||
|
@ -258,25 +266,25 @@ bool FileWriteStreamCancel( UGCFileWriteStreamHandle_t writeHandle )
|
|||
bool FileExists( const char *pchFile )
|
||||
{
|
||||
PRINT_DEBUG("Steam_Remote_Storage::FileExists %s\n", pchFile);
|
||||
return local_storage->file_exists(REMOTE_STORAGE_FOLDER, pchFile);
|
||||
return local_storage->file_exists(Local_Storage::remote_storage_folder, pchFile);
|
||||
}
|
||||
|
||||
bool FilePersisted( const char *pchFile )
|
||||
{
|
||||
PRINT_DEBUG("Steam_Remote_Storage::FilePersisted\n");
|
||||
return local_storage->file_exists(REMOTE_STORAGE_FOLDER, pchFile);
|
||||
return local_storage->file_exists(Local_Storage::remote_storage_folder, pchFile);
|
||||
}
|
||||
|
||||
int32 GetFileSize( const char *pchFile )
|
||||
{
|
||||
PRINT_DEBUG("Steam_Remote_Storage::GetFileSize %s\n", pchFile);
|
||||
return local_storage->file_size(REMOTE_STORAGE_FOLDER, pchFile);
|
||||
return local_storage->file_size(Local_Storage::remote_storage_folder, pchFile);
|
||||
}
|
||||
|
||||
int64 GetFileTimestamp( const char *pchFile )
|
||||
{
|
||||
PRINT_DEBUG("Steam_Remote_Storage::GetFileTimestamp\n");
|
||||
return local_storage->file_timestamp(REMOTE_STORAGE_FOLDER, pchFile);
|
||||
return local_storage->file_timestamp(Local_Storage::remote_storage_folder, pchFile);
|
||||
}
|
||||
|
||||
ERemoteStoragePlatform GetSyncPlatforms( const char *pchFile )
|
||||
|
@ -290,7 +298,7 @@ ERemoteStoragePlatform GetSyncPlatforms( const char *pchFile )
|
|||
int32 GetFileCount()
|
||||
{
|
||||
PRINT_DEBUG("Steam_Remote_Storage::GetFileCount\n");
|
||||
int32 num = local_storage->count_files(REMOTE_STORAGE_FOLDER);
|
||||
int32 num = local_storage->count_files(Local_Storage::remote_storage_folder);
|
||||
PRINT_DEBUG("Steam_Remote_Storage::File count: %i\n", num);
|
||||
return num;
|
||||
}
|
||||
|
@ -299,7 +307,7 @@ const char *GetFileNameAndSize( int iFile, int32 *pnFileSizeInBytes )
|
|||
{
|
||||
PRINT_DEBUG("Steam_Remote_Storage::GetFileNameAndSize %i\n", iFile);
|
||||
static char output_filename[MAX_FILENAME_LENGTH];
|
||||
if (local_storage->iterate_file(REMOTE_STORAGE_FOLDER, iFile, output_filename, pnFileSizeInBytes)) {
|
||||
if (local_storage->iterate_file(Local_Storage::remote_storage_folder, iFile, output_filename, pnFileSizeInBytes)) {
|
||||
PRINT_DEBUG("Steam_Remote_Storage::Name: |%s|, size: %i\n", output_filename, pnFileSizeInBytes ? *pnFileSizeInBytes : 0);
|
||||
return output_filename;
|
||||
} else {
|
||||
|
@ -372,7 +380,7 @@ SteamAPICall_t UGCDownload( UGCHandle_t hContent, uint32 unPriority )
|
|||
data.m_eResult = k_EResultOK;
|
||||
data.m_hFile = hContent;
|
||||
data.m_nAppID = settings->get_local_game_id().AppID();
|
||||
data.m_nSizeInBytes = local_storage->file_size(REMOTE_STORAGE_FOLDER, shared_files[hContent]);
|
||||
data.m_nSizeInBytes = local_storage->file_size(Local_Storage::remote_storage_folder, shared_files[hContent]);
|
||||
shared_files[hContent].copy(data.m_pchFileName, sizeof(data.m_pchFileName) - 1);
|
||||
data.m_ulSteamIDOwner = settings->get_local_steam_id().ConvertToUint64();
|
||||
downloaded_files[hContent].file = shared_files[hContent];
|
||||
|
@ -426,7 +434,7 @@ int32 UGCRead( UGCHandle_t hContent, void *pvData, int32 cubDataToRead, uint32 c
|
|||
}
|
||||
|
||||
Downloaded_File f = downloaded_files[hContent];
|
||||
int read_data = local_storage->get_data(REMOTE_STORAGE_FOLDER, f.file, (char* )pvData, cubDataToRead, cOffset);
|
||||
int read_data = local_storage->get_data(Local_Storage::remote_storage_folder, f.file, (char* )pvData, cubDataToRead, cOffset);
|
||||
|
||||
if (eAction == k_EUGCRead_Close || (eAction == k_EUGCRead_ContinueReadingUntilFinished && (read_data < cubDataToRead || (cOffset + cubDataToRead) >= f.total_size))) {
|
||||
downloaded_files.erase(hContent);
|
||||
|
|
|
@ -149,7 +149,7 @@ bool GetUserDataFolder( char *pchBuffer, int cubBuffer )
|
|||
PRINT_DEBUG("GetUserDataFolder\n");
|
||||
if (!cubBuffer) return false;
|
||||
|
||||
std::string user_data = local_storage->get_path(USER_DATA_FOLDER);
|
||||
std::string user_data = local_storage->get_path(Local_Storage::user_data_storage);
|
||||
strncpy(pchBuffer, user_data.c_str(), cubBuffer - 1);
|
||||
pchBuffer[cubBuffer - 1] = 0;
|
||||
return true;
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"2001": 1,
|
||||
"2002": 1
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
Rename this to: disable_networking.txt to disable all networking functionality.
|
|
@ -0,0 +1,212 @@
|
|||
// My own modified version of ColdClientLoader originally written by Rat431
|
||||
|
||||
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
||||
// Windows Header Files
|
||||
#include <windows.h>
|
||||
// C RunTime Header Files
|
||||
#include <stdlib.h>
|
||||
#include <malloc.h>
|
||||
#include <memory.h>
|
||||
#include <tchar.h>
|
||||
|
||||
bool IsNotRelativePathOrRemoveFileName(CHAR* output, bool Remove)
|
||||
{
|
||||
int LG = lstrlenA(output);
|
||||
for (int i = LG; i > 0; i--) {
|
||||
if (output[i] == '\\') {
|
||||
if(Remove)
|
||||
RtlFillMemory(&output[i], LG - i, NULL);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
int APIENTRY wWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPWSTR lpCmdLine, _In_ int nCmdShow)
|
||||
{
|
||||
CHAR CurrentDirectory[MAX_PATH] = { 0 };
|
||||
CHAR Client64Path[MAX_PATH] = { 0 };
|
||||
CHAR ClientPath[MAX_PATH] = { 0 };
|
||||
CHAR ExeFile[MAX_PATH] = { 0 };
|
||||
CHAR ExeRunDir[MAX_PATH] = { 0 };
|
||||
CHAR ExeCommandLine[300] = { 0 };
|
||||
CHAR AppId[128] = { 0 };
|
||||
|
||||
STARTUPINFOA info = { sizeof(info) };
|
||||
PROCESS_INFORMATION processInfo;
|
||||
|
||||
int Length = GetModuleFileNameA(GetModuleHandleA(NULL), CurrentDirectory, sizeof(CurrentDirectory)) + 1;
|
||||
for (int i = Length; i > 0; i--) {
|
||||
if (CurrentDirectory[i] == '\\') {
|
||||
lstrcpyA(&CurrentDirectory[i + 1], "ColdClientLoader.ini");
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (GetFileAttributesA(CurrentDirectory) == INVALID_FILE_ATTRIBUTES) {
|
||||
MessageBoxA(NULL, "Couldn't find the configuration file(ColdClientLoader.ini).", "ColdClientLoader", MB_ICONERROR);
|
||||
ExitProcess(NULL);
|
||||
}
|
||||
|
||||
GetPrivateProfileStringA("SteamClient", "SteamClient64Dll", "", Client64Path, MAX_PATH, CurrentDirectory);
|
||||
GetPrivateProfileStringA("SteamClient", "SteamClientDll", "", ClientPath, MAX_PATH, CurrentDirectory);
|
||||
GetPrivateProfileStringA("SteamClient", "Exe", NULL, ExeFile, MAX_PATH, CurrentDirectory);
|
||||
GetPrivateProfileStringA("SteamClient", "ExeRunDir", NULL, ExeRunDir, MAX_PATH, CurrentDirectory);
|
||||
GetPrivateProfileStringA("SteamClient", "ExeCommandLine", NULL, ExeCommandLine, 300, CurrentDirectory);
|
||||
GetPrivateProfileStringA("SteamClient", "AppId", NULL, AppId, sizeof(AppId), CurrentDirectory);
|
||||
|
||||
if (AppId[0]) {
|
||||
SetEnvironmentVariableA("SteamAppId", AppId);
|
||||
SetEnvironmentVariableA("SteamGameId", AppId);
|
||||
}
|
||||
|
||||
CHAR TMP[MAX_PATH] = { 0 };
|
||||
if (!IsNotRelativePathOrRemoveFileName(Client64Path, false)) {
|
||||
ZeroMemory(TMP, sizeof(TMP));
|
||||
lstrcpyA(TMP, Client64Path);
|
||||
ZeroMemory(Client64Path, sizeof(Client64Path));
|
||||
GetFullPathNameA(TMP, MAX_PATH, Client64Path, NULL);
|
||||
}
|
||||
if (!IsNotRelativePathOrRemoveFileName(ClientPath, false)) {
|
||||
ZeroMemory(TMP, sizeof(TMP));
|
||||
lstrcpyA(TMP, ClientPath);
|
||||
ZeroMemory(ClientPath, sizeof(ClientPath));
|
||||
GetFullPathNameA(TMP, MAX_PATH, ClientPath, NULL);
|
||||
}
|
||||
if (!IsNotRelativePathOrRemoveFileName(ExeFile, false)) {
|
||||
ZeroMemory(TMP, sizeof(TMP));
|
||||
lstrcpyA(TMP, ExeFile);
|
||||
ZeroMemory(ExeFile, sizeof(ExeFile));
|
||||
GetFullPathNameA(TMP, MAX_PATH, ExeFile, NULL);
|
||||
}
|
||||
if (!IsNotRelativePathOrRemoveFileName(ExeRunDir, false)) {
|
||||
ZeroMemory(TMP, sizeof(TMP));
|
||||
lstrcpyA(TMP, ExeRunDir);
|
||||
ZeroMemory(ExeRunDir, sizeof(ExeRunDir));
|
||||
GetFullPathNameA(TMP, MAX_PATH, ExeRunDir, NULL);
|
||||
}
|
||||
|
||||
if (GetFileAttributesA(Client64Path) == INVALID_FILE_ATTRIBUTES) {
|
||||
MessageBoxA(NULL, "Couldn't find the requested SteamClient64Dll.", "ColdClientLoader", MB_ICONERROR);
|
||||
ExitProcess(NULL);
|
||||
}
|
||||
|
||||
if (GetFileAttributesA(ClientPath) == INVALID_FILE_ATTRIBUTES) {
|
||||
MessageBoxA(NULL, "Couldn't find the requested SteamClientDll.", "ColdClientLoader", MB_ICONERROR);
|
||||
ExitProcess(NULL);
|
||||
}
|
||||
|
||||
if (GetFileAttributesA(ExeFile) == INVALID_FILE_ATTRIBUTES) {
|
||||
MessageBoxA(NULL, "Couldn't find the requested Exe file.", "ColdClientLoader", MB_ICONERROR);
|
||||
ExitProcess(NULL);
|
||||
}
|
||||
|
||||
if (!ExeFile[0] || !CreateProcessA(ExeFile, ExeCommandLine, NULL, NULL, TRUE, CREATE_SUSPENDED, NULL, ExeRunDir, &info, &processInfo))
|
||||
{
|
||||
MessageBoxA(NULL, "Unable to load the requested EXE file.", "ColdClientLoader", MB_ICONERROR);
|
||||
ExitProcess(NULL);
|
||||
}
|
||||
HKEY Registrykey;
|
||||
// Declare some variables to be used for Steam registry.
|
||||
DWORD UserId = 0x03100004771F810D & 0xffffffff;
|
||||
DWORD ProcessID = GetCurrentProcessId();
|
||||
|
||||
if (RegOpenKeyExA(HKEY_CURRENT_USER, "Software\\Valve\\Steam\\ActiveProcess", 0, KEY_ALL_ACCESS, &Registrykey) != ERROR_SUCCESS)
|
||||
{
|
||||
if (RegCreateKeyExA(HKEY_CURRENT_USER, "Software\\Valve\\Steam\\ActiveProcess", 0, 0, REG_OPTION_NON_VOLATILE,
|
||||
KEY_ALL_ACCESS, NULL, &Registrykey, NULL) != ERROR_SUCCESS)
|
||||
{
|
||||
MessageBoxA(NULL, "Unable to patch Steam process informations on the Windows registry.", "ColdClientLoader", MB_ICONERROR);
|
||||
TerminateProcess(processInfo.hProcess, NULL);
|
||||
ExitProcess(NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
// Set values to Windows registry.
|
||||
RegSetValueExA(Registrykey, "ActiveUser", NULL, REG_DWORD, (LPBYTE)& UserId, sizeof(DWORD));
|
||||
RegSetValueExA(Registrykey, "pid", NULL, REG_DWORD, (LPBYTE)& ProcessID, sizeof(DWORD));
|
||||
|
||||
{
|
||||
// Before saving to the registry check again if the path was valid and if the file exist
|
||||
if (GetFileAttributesA(ClientPath) != INVALID_FILE_ATTRIBUTES) {
|
||||
RegSetValueExA(Registrykey, "SteamClientDll", NULL, REG_SZ, (LPBYTE)ClientPath, (DWORD)lstrlenA(ClientPath) + 1);
|
||||
}
|
||||
else {
|
||||
RegSetValueExA(Registrykey, "SteamClientDll", NULL, REG_SZ, (LPBYTE)"", (DWORD)lstrlenA(ClientPath) + 1);
|
||||
}
|
||||
if (GetFileAttributesA(Client64Path) != INVALID_FILE_ATTRIBUTES) {
|
||||
RegSetValueExA(Registrykey, "SteamClientDll64", NULL, REG_SZ, (LPBYTE)Client64Path, (DWORD)lstrlenA(Client64Path) + 1);
|
||||
}
|
||||
else {
|
||||
RegSetValueExA(Registrykey, "SteamClientDll64", NULL, REG_SZ, (LPBYTE)"", (DWORD)lstrlenA(Client64Path) + 1);
|
||||
}
|
||||
}
|
||||
RegSetValueExA(Registrykey, "Universe", NULL, REG_SZ, (LPBYTE)"Public", (DWORD)lstrlenA("Public") + 1);
|
||||
|
||||
// Close the HKEY Handle.
|
||||
RegCloseKey(Registrykey);
|
||||
|
||||
ResumeThread(processInfo.hThread);
|
||||
WaitForSingleObject(processInfo.hThread, INFINITE);
|
||||
CloseHandle(processInfo.hProcess);
|
||||
CloseHandle(processInfo.hThread);
|
||||
ExitProcess(NULL);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DWORD keyType = REG_SZ;
|
||||
CHAR OrgSteamCDir[MAX_PATH] = { 0 };
|
||||
CHAR OrgSteamCDir64[MAX_PATH] = { 0 };
|
||||
DWORD Size1 = MAX_PATH;
|
||||
DWORD Size2 = MAX_PATH;
|
||||
|
||||
// Get original values to restore later.
|
||||
RegQueryValueExA(Registrykey, "SteamClientDll", 0, &keyType, (LPBYTE)& OrgSteamCDir, &Size1);
|
||||
RegQueryValueExA(Registrykey, "SteamClientDll64", 0, &keyType, (LPBYTE)& OrgSteamCDir64, &Size2);
|
||||
|
||||
// Set values to Windows registry.
|
||||
RegSetValueExA(Registrykey, "ActiveUser", NULL, REG_DWORD, (LPBYTE)& UserId, sizeof(DWORD));
|
||||
RegSetValueExA(Registrykey, "pid", NULL, REG_DWORD, (LPBYTE)& ProcessID, sizeof(DWORD));
|
||||
|
||||
|
||||
{
|
||||
// Before saving to the registry check again if the path was valid and if the file exist
|
||||
if (GetFileAttributesA(ClientPath) != INVALID_FILE_ATTRIBUTES) {
|
||||
RegSetValueExA(Registrykey, "SteamClientDll", NULL, REG_SZ, (LPBYTE)ClientPath, (DWORD)lstrlenA(ClientPath) + 1);
|
||||
}
|
||||
else {
|
||||
RegSetValueExA(Registrykey, "SteamClientDll", NULL, REG_SZ, (LPBYTE)"", (DWORD)lstrlenA(ClientPath) + 1);
|
||||
}
|
||||
if (GetFileAttributesA(Client64Path) != INVALID_FILE_ATTRIBUTES) {
|
||||
RegSetValueExA(Registrykey, "SteamClientDll64", NULL, REG_SZ, (LPBYTE)Client64Path, (DWORD)lstrlenA(Client64Path) + 1);
|
||||
}
|
||||
else {
|
||||
RegSetValueExA(Registrykey, "SteamClientDll64", NULL, REG_SZ, (LPBYTE)"", (DWORD)lstrlenA(Client64Path) + 1);
|
||||
}
|
||||
}
|
||||
RegSetValueExA(Registrykey, "Universe", NULL, REG_SZ, (LPBYTE)"Public", (DWORD)lstrlenA("Public") + 1);
|
||||
|
||||
// Close the HKEY Handle.
|
||||
RegCloseKey(Registrykey);
|
||||
|
||||
ResumeThread(processInfo.hThread);
|
||||
WaitForSingleObject(processInfo.hThread, INFINITE);
|
||||
CloseHandle(processInfo.hProcess);
|
||||
CloseHandle(processInfo.hThread);
|
||||
|
||||
if (RegOpenKeyExA(HKEY_CURRENT_USER, "Software\\Valve\\Steam\\ActiveProcess", 0, KEY_ALL_ACCESS, &Registrykey) == ERROR_SUCCESS)
|
||||
{
|
||||
// Restore the values.
|
||||
RegSetValueExA(Registrykey, "SteamClientDll", NULL, REG_SZ, (LPBYTE)OrgSteamCDir, (DWORD)lstrlenA(OrgSteamCDir) + 1);
|
||||
RegSetValueExA(Registrykey, "SteamClientDll64", NULL, REG_SZ, (LPBYTE)OrgSteamCDir64, (DWORD)lstrlenA(OrgSteamCDir64) + 1);
|
||||
|
||||
// Close the HKEY Handle.
|
||||
RegCloseKey(Registrykey);
|
||||
}
|
||||
ExitProcess(NULL);
|
||||
}
|
||||
|
||||
|
||||
return 1;
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
#My own modified version of ColdClientLoader originally by Rat431
|
||||
[SteamClient]
|
||||
Exe=game.exe
|
||||
ExeRunDir=.
|
||||
ExeCommandLine=
|
||||
#IMPORTANT:
|
||||
AppId=
|
||||
|
||||
SteamClientDll=steamclient.dll
|
||||
SteamClient64Dll=steamclient64.dll
|
Loading…
Reference in New Issue