Merge branch 'master' into issue_#5
commit
0a9b950d2e
|
@ -93,7 +93,8 @@ struct Steam_Call_Result {
|
|||
Steam_Call_Result(SteamAPICall_t a, int icb, void *r, unsigned int s, double r_in, bool run_cc_cb) {
|
||||
api_call = a;
|
||||
result.resize(s);
|
||||
memcpy(&(result[0]), r, s);
|
||||
if (s > 0 && r != NULL)
|
||||
memcpy(&(result[0]), r, s);
|
||||
created = std::chrono::high_resolution_clock::now();
|
||||
run_in = r_in;
|
||||
run_call_completed_cb = run_cc_cb;
|
||||
|
|
|
@ -192,6 +192,8 @@ static std::vector<struct File_Data> get_filenames(std::string strPath)
|
|||
|
||||
static std::vector<struct File_Data> get_filenames_recursive(std::string base_path)
|
||||
{
|
||||
if (base_path.back() == *PATH_SEPARATOR)
|
||||
base_path.pop_back();
|
||||
std::vector<struct File_Data> output;
|
||||
std::string strPath = base_path;
|
||||
strPath = strPath.append("\\*");
|
||||
|
@ -211,11 +213,11 @@ static std::vector<struct File_Data> get_filenames_recursive(std::string base_pa
|
|||
std::string dir_name = ffd.cFileName;
|
||||
|
||||
std::string path = base_path;
|
||||
path += "\\";
|
||||
path += PATH_SEPARATOR;
|
||||
path += dir_name;
|
||||
|
||||
std::vector<struct File_Data> lower = get_filenames_recursive(path);
|
||||
std::transform(lower.begin(), lower.end(), std::back_inserter(output), [dir_name](File_Data f) {f.name = dir_name + "\\" + f.name; return f;});
|
||||
std::transform(lower.begin(), lower.end(), std::back_inserter(output), [&dir_name](File_Data f) {f.name = dir_name + "\\" + f.name; return f;});
|
||||
} else {
|
||||
File_Data f;
|
||||
f.name = ffd.cFileName;
|
||||
|
@ -354,7 +356,7 @@ static std::vector<struct File_Data> get_filenames_recursive(std::string base_pa
|
|||
path += dir_name;
|
||||
|
||||
std::vector<struct File_Data> lower = get_filenames_recursive(path);
|
||||
std::transform(lower.begin(), lower.end(), std::back_inserter(output), [dir_name](File_Data f) {f.name = dir_name + "/" + f.name; return f;});
|
||||
std::transform(lower.begin(), lower.end(), std::back_inserter(output), [&dir_name](File_Data f) {f.name = dir_name + "/" + f.name; return f;});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -584,7 +586,19 @@ bool Local_Storage::file_exists(std::string folder, std::string file)
|
|||
|
||||
std::string full_path = save_directory + appid + folder + file;
|
||||
struct stat buffer;
|
||||
return (stat (full_path.c_str(), &buffer) == 0);
|
||||
|
||||
if (stat(full_path.c_str(), &buffer) != 0)
|
||||
return false;
|
||||
|
||||
#if defined(STEAM_WIN32)
|
||||
if ( buffer.st_mode & _S_IFDIR)
|
||||
return false;
|
||||
#else
|
||||
if (S_ISDIR(buffer.st_mode))
|
||||
return false;
|
||||
#endif
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
unsigned int Local_Storage::file_size(std::string folder, std::string file)
|
||||
|
|
|
@ -176,10 +176,14 @@ message Auth_Ticket {
|
|||
message Friend_Messages {
|
||||
enum Types {
|
||||
LOBBY_INVITE = 0;
|
||||
GAME_INVITE = 1;
|
||||
}
|
||||
|
||||
Types type = 1;
|
||||
uint64 lobby_id = 2;
|
||||
oneof invite_data {
|
||||
uint64 lobby_id = 2;
|
||||
bytes connect_str = 3;
|
||||
}
|
||||
}
|
||||
|
||||
message Common_Message {
|
||||
|
|
|
@ -379,7 +379,10 @@ unsigned int receive_buffer_amount(sock_t sock)
|
|||
|
||||
static void send_tcp_pending(struct TCP_Socket &socket)
|
||||
{
|
||||
int len = send(socket.sock, &(socket.send_buffer[0]), socket.send_buffer.size(), MSG_NOSIGNAL);
|
||||
size_t buf_size = socket.send_buffer.size();
|
||||
if (buf_size == 0) return;
|
||||
|
||||
int len = send(socket.sock, &(socket.send_buffer[0]), buf_size, MSG_NOSIGNAL);
|
||||
if (len <= 0) return;
|
||||
|
||||
socket.send_buffer.erase(socket.send_buffer.begin(), socket.send_buffer.begin() + len);
|
||||
|
|
|
@ -545,6 +545,7 @@ void SetPlayedWith( CSteamID steamIDUserPlayedWith )
|
|||
void ActivateGameOverlayInviteDialog( CSteamID steamIDLobby )
|
||||
{
|
||||
PRINT_DEBUG("Steam_Friends::ActivateGameOverlayInviteDialog\n");
|
||||
// TODO: Here open the overlay
|
||||
}
|
||||
|
||||
// gets the small (32x32) avatar of the current user, which is a handle to be used in IClientUtils::GetImageRGBA(), or 0 if none set
|
||||
|
@ -775,8 +776,18 @@ void RequestFriendRichPresence( CSteamID steamIDFriend )
|
|||
bool InviteUserToGame( CSteamID steamIDFriend, const char *pchConnectString )
|
||||
{
|
||||
PRINT_DEBUG("Steam_Friends::InviteUserToGame\n");
|
||||
//TODO
|
||||
return true;
|
||||
std::lock_guard<std::recursive_mutex> lock(global_mutex);
|
||||
Friend *f = find_friend(steamIDFriend);
|
||||
if (!f) return false;
|
||||
|
||||
Common_Message msg;
|
||||
Friend_Messages *friend_messages = new Friend_Messages();
|
||||
friend_messages->set_type(Friend_Messages::GAME_INVITE);
|
||||
friend_messages->set_connect_str(pchConnectString);
|
||||
msg.set_allocated_friend_messages(friend_messages);
|
||||
msg.set_source_id(settings->get_local_steam_id().ConvertToUint64());
|
||||
msg.set_dest_id(steamIDFriend.ConvertToUint64());
|
||||
return network->sendTo(&msg, true);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1021,6 +1032,16 @@ void Callback(Common_Message *msg)
|
|||
data.m_steamIDFriend = CSteamID((uint64)msg->source_id());
|
||||
callbacks->addCBResult(data.k_iCallback, &data, sizeof(data));
|
||||
}
|
||||
|
||||
if (msg->friend_messages().type() == Friend_Messages::GAME_INVITE) {
|
||||
PRINT_DEBUG("Steam_Friends Got Game Invite\n");
|
||||
//TODO: I'm pretty sure that the user should accept the invite before this is posted but we do like above
|
||||
std::string const& connect_str = msg->friend_messages().connect_str();
|
||||
GameRichPresenceJoinRequested_t data = {};
|
||||
data.m_steamIDFriend = CSteamID((uint64)msg->source_id());
|
||||
strncpy(data.m_rgchConnect, connect_str.c_str(), k_cchMaxRichPresenceValueLength - 1);
|
||||
callbacks->addCBResult(data.k_iCallback, &data, sizeof(data));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue