Skip to content

Commit

Permalink
fmt pass
Browse files Browse the repository at this point in the history
  • Loading branch information
NikhilNarayana committed Sep 21, 2023
1 parent 2f817d5 commit 17db1db
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 34 deletions.
4 changes: 3 additions & 1 deletion Source/Core/Core/Slippi/SlippiMatchmaking.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,9 @@ void SlippiMatchmaking::handleMatchmaking()
{
player_info.chat_messages = m_user->GetDefaultChatMessages();
}
} else {
}
else
{
player_info.chat_messages = m_user->GetDefaultChatMessages();
}

Expand Down
57 changes: 29 additions & 28 deletions Source/Core/Core/Slippi/SlippiUser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,22 @@
// frees the underlying memory safely.
std::vector<std::string> ConvertChatMessagesFromRust(RustChatMessages* rsMessages)
{
std::vector<std::string> chatMessages;
std::vector<std::string> chatMessages;

for(int i = 0; i < rsMessages->len; i++) {
std::string message = std::string(rsMessages->data[i]);
chatMessages.push_back(message);
}
for (int i = 0; i < rsMessages->len; i++)
{
std::string message = std::string(rsMessages->data[i]);
chatMessages.push_back(message);
}

slprs_user_free_messages(rsMessages);
slprs_user_free_messages(rsMessages);

return chatMessages;
return chatMessages;
}

SlippiUser::SlippiUser(uintptr_t rs_exi_device_ptr)
{
slprs_exi_device_ptr = rs_exi_device_ptr;
slprs_exi_device_ptr = rs_exi_device_ptr;
}

SlippiUser::~SlippiUser()
Expand All @@ -32,62 +33,62 @@ SlippiUser::~SlippiUser()

bool SlippiUser::AttemptLogin()
{
return slprs_user_attempt_login(slprs_exi_device_ptr);
return slprs_user_attempt_login(slprs_exi_device_ptr);
}

void SlippiUser::OpenLogInPage()
{
slprs_user_open_login_page(slprs_exi_device_ptr);
slprs_user_open_login_page(slprs_exi_device_ptr);
}

void SlippiUser::ListenForLogIn()
{
slprs_user_listen_for_login(slprs_exi_device_ptr);
slprs_user_listen_for_login(slprs_exi_device_ptr);
}

bool SlippiUser::UpdateApp()
{
return slprs_user_update_app(slprs_exi_device_ptr);
return slprs_user_update_app(slprs_exi_device_ptr);
}

void SlippiUser::LogOut()
{
slprs_user_logout(slprs_exi_device_ptr);
slprs_user_logout(slprs_exi_device_ptr);
}

void SlippiUser::OverwriteLatestVersion(std::string version)
{
slprs_user_overwrite_latest_version(slprs_exi_device_ptr, version.c_str());
slprs_user_overwrite_latest_version(slprs_exi_device_ptr, version.c_str());
}

SlippiUser::UserInfo SlippiUser::GetUserInfo()
{
SlippiUser::UserInfo userInfo;
SlippiUser::UserInfo userInfo;

RustUserInfo* info = slprs_user_get_info(slprs_exi_device_ptr);
userInfo.uid = std::string(info->uid);
userInfo.play_key = std::string(info->play_key);
userInfo.display_name = std::string(info->display_name);
userInfo.connect_code = std::string(info->connect_code);
userInfo.latest_version = std::string(info->latest_version);
slprs_user_free_info(info);
RustUserInfo* info = slprs_user_get_info(slprs_exi_device_ptr);
userInfo.uid = std::string(info->uid);
userInfo.play_key = std::string(info->play_key);
userInfo.display_name = std::string(info->display_name);
userInfo.connect_code = std::string(info->connect_code);
userInfo.latest_version = std::string(info->latest_version);
slprs_user_free_info(info);

return userInfo;
return userInfo;
}

std::vector<std::string> SlippiUser::GetDefaultChatMessages()
{
RustChatMessages* chatMessages = slprs_user_get_default_messages(slprs_exi_device_ptr);
return ConvertChatMessagesFromRust(chatMessages);
RustChatMessages* chatMessages = slprs_user_get_default_messages(slprs_exi_device_ptr);
return ConvertChatMessagesFromRust(chatMessages);
}

std::vector<std::string> SlippiUser::GetUserChatMessages()
{
RustChatMessages* chatMessages = slprs_user_get_messages(slprs_exi_device_ptr);
return ConvertChatMessagesFromRust(chatMessages);
RustChatMessages* chatMessages = slprs_user_get_messages(slprs_exi_device_ptr);
return ConvertChatMessagesFromRust(chatMessages);
}

bool SlippiUser::IsLoggedIn()
{
return slprs_user_get_is_logged_in(slprs_exi_device_ptr);
return slprs_user_get_is_logged_in(slprs_exi_device_ptr);
}
10 changes: 5 additions & 5 deletions Source/Core/Core/Slippi/SlippiUser.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@
#include "Common/CommonTypes.h"

// This class is currently a shim for the Rust user interface. We're doing it this way
// to begin migratig things over without needing to do larger invasive changes.
// to begin migrating things over without needing to do larger invasive changes.
//
// The remaining methods on here are simply layers that direct the call over to the Rust
// side. A quirk of this is that we're using the EXI device pointer, so this class absolutely
// The remaining methods in here are simply layers that direct the call over to the Rust side.
// A quirk of this is that we're using the EXI device pointer, so this class absolutely
// cannot outlive the EXI device - but we control that and just need to do our due diligence
// when making changes.
class SlippiUser
{
public:
// This type is filled in with data from the Rust side.
// Eventually, this entire class will disappear.
// Eventually, this entire class will disappear.
struct UserInfo
{
std::string uid = "";
Expand All @@ -45,7 +45,7 @@ class SlippiUser
void OverwriteLatestVersion(std::string version);
UserInfo GetUserInfo();
std::vector<std::string> GetUserChatMessages();
std::vector<std::string> GetDefaultChatMessages();
std::vector<std::string> GetDefaultChatMessages();
bool IsLoggedIn();

protected:
Expand Down

0 comments on commit 17db1db

Please sign in to comment.