Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
KroArtem committed Mar 15, 2014
2 parents ccd6019 + de82005 commit a3a851b
Show file tree
Hide file tree
Showing 12 changed files with 280 additions and 295 deletions.
7 changes: 5 additions & 2 deletions src/graphics/stkmeshscenenode.cpp
Expand Up @@ -132,8 +132,11 @@ void STKMeshSceneNode::drawGlow(const GLMesh &mesh)
computeMVP(ModelViewProjectionMatrix);
MeshShader::ColorizeShader::setUniforms(ModelViewProjectionMatrix, cb->getRed(), cb->getGreen(), cb->getBlue());

glBindVertexArray(mesh.vao_glow_pass);
glDrawElements(ptype, count, itype, 0);
if (mesh.vao_glow_pass != 0)
{
glBindVertexArray(mesh.vao_glow_pass);
glDrawElements(ptype, count, itype, 0);
}
}

void STKMeshSceneNode::drawDisplace(const GLMesh &mesh)
Expand Down
207 changes: 6 additions & 201 deletions src/online/current_user.cpp
Expand Up @@ -30,10 +30,10 @@
#include "online/profile_manager.hpp"
#include "online/servers_manager.hpp"
#include "states_screens/login_screen.hpp"
#include "states_screens/online_profile_friends.hpp"
#include "states_screens/dialogs/change_password_dialog.hpp"
#include "states_screens/dialogs/user_info_dialog.hpp"
#include "states_screens/dialogs/notification_dialog.hpp"
#include "states_screens/online_profile_friends.hpp"
#include "utils/log.hpp"
#include "utils/translation.hpp"

Expand Down Expand Up @@ -88,39 +88,6 @@ namespace Online
m_profile = NULL;
} // CurrentUser

// ------------------------------------------------------------------------
const XMLRequest * CurrentUser::requestRecovery(const core::stringw &username,
const core::stringw &email)
{
assert(m_state == US_SIGNED_OUT || m_state == US_GUEST);
XMLRequest * request = new XMLRequest();
request->setServerURL("client-user.php");
request->addParameter("action", "recovery");
request->addParameter("username", username);
request->addParameter("email", email);
request->queue();
return request;
} // requestRecovery

// ------------------------------------------------------------------------
const XMLRequest * CurrentUser::requestSignUp(const core::stringw &username,
const core::stringw &password,
const core::stringw &password_confirm,
const core::stringw &email)
{
assert(m_state == US_SIGNED_OUT || m_state == US_GUEST);
XMLRequest * request = new XMLRequest();
request->setServerURL("client-user.php");
request->addParameter("action", "register");
request->addParameter("username", username);
request->addParameter("password", password);
request->addParameter("password_confirm", password_confirm);
request->addParameter("email", email);
request->addParameter("terms", "on");
request->queue();
return request;
} // requestSignUp

// ------------------------------------------------------------------------
/** Request a login using the saved credentials of the user.
*/
Expand Down Expand Up @@ -266,34 +233,6 @@ namespace Online
UserConfigParams::m_saved_session = false;
} // signOut

// ------------------------------------------------------------------------
const CurrentUser::ServerCreationRequest*
CurrentUser::requestServerCreation(const core::stringw &name,
int max_players)
{
assert(m_state == US_SIGNED_IN);
ServerCreationRequest * request = new ServerCreationRequest();
request->setServerURL("client-user.php");
request->addParameter("action", "create_server");
request->addParameter("token", getToken());
request->addParameter("userid", getID());
request->addParameter("name", name);
request->addParameter("max_players", max_players);
request->queue();
return request;
} // requestServerCreation

// ------------------------------------------------------------------------
void CurrentUser::ServerCreationRequest::callback()
{
if(isSuccess())
{
Server * server = new Server(*getXMLData()->getNode("server"));
ServersManager::get()->addServer(server);
m_created_server_id = server->getServerId();
}
} // ServerCreationRequest::callback

// ------------------------------------------------------------------------
CurrentUser::ServerJoinRequest*
CurrentUser::requestServerJoin(uint32_t server_id,
Expand Down Expand Up @@ -397,138 +336,6 @@ namespace Online
} // requestUserSearch

// ------------------------------------------------------------------------
/** A request to the server, to invite a user to be friends.
* \param friend_id The id of the user which has to be friended.
*/
void CurrentUser::requestFriendRequest(const uint32_t friend_id) const
{
assert(m_state == US_SIGNED_IN);
CurrentUser::FriendRequest * request = new CurrentUser::FriendRequest();
request->setServerURL("client-user.php");
request->addParameter("action", "friend-request");
request->addParameter("token", getToken());
request->addParameter("userid", getID());
request->addParameter("friendid", friend_id);
request->queue();
} // requestFriendRequest

// ------------------------------------------------------------------------
/** Callback for the request to send a friend invitation. Shows a
* confirmation message and takes care of updating all the cached
* information.
*/
void CurrentUser::FriendRequest::callback()
{
uint32_t id(0);
getXMLData()->get("friendid", &id);
core::stringw info_text("");
if(isSuccess())
{
CurrentUser::get()->getProfile()->addFriend(id);
OnlineProfile::RelationInfo *info =
new OnlineProfile::RelationInfo(_("Today"), false, true, false);
ProfileManager::get()->getProfileByID(id)->setRelationInfo(info);
OnlineProfileFriends::getInstance()->refreshFriendsList();
info_text = _("Friend request send!");
}
else
info_text = getInfo();
UserInfoDialog *dialog = new UserInfoDialog(id, info_text,
!isSuccess(), true);
GUIEngine::DialogQueue::get()->pushDialog(dialog, true);
} // FriendRequest::callback

// ------------------------------------------------------------------------
/** A request to the server, to accept a friend request.
* \param friend_id The id of the user of which the request has to be
* accepted.
*/
void CurrentUser::requestAcceptFriend(const uint32_t friend_id) const
{
assert(m_state == US_SIGNED_IN);
CurrentUser::AcceptFriendRequest * request =
new CurrentUser::AcceptFriendRequest();
request->setServerURL("client-user.php");
request->addParameter("action", "accept-friend-request");
request->addParameter("token", getToken());
request->addParameter("userid", getID());
request->addParameter("friendid", friend_id);
request->queue();
} // requestAcceptFriend

// ------------------------------------------------------------------------
/** Callback for the request to accept a friend invitation. Shows a
* confirmation message and takes care of updating all the cached
* information.
*/
void CurrentUser::AcceptFriendRequest::callback()
{
uint32_t id(0);
getXMLData()->get("friendid", &id);
core::stringw info_text("");
if(isSuccess())
{
OnlineProfile * profile = ProfileManager::get()->getProfileByID(id);
profile->setFriend();
OnlineProfile::RelationInfo *info =
new OnlineProfile::RelationInfo(_("Today"), false, false, true);
profile->setRelationInfo(info);
OnlineProfileFriends::getInstance()->refreshFriendsList();
info_text = _("Friend request accepted!");
}
else
info_text = getInfo();
GUIEngine::DialogQueue::get()->pushDialog(
new UserInfoDialog(id, info_text,!isSuccess(), true), true);
} // AcceptFriendRequest::callback

// ------------------------------------------------------------------------
/** A request to the server, to decline a friend request.
* \param friend_id The id of the user of which the request has to be
* declined.
*/
void CurrentUser::requestDeclineFriend(const uint32_t friend_id) const
{
assert(m_state == US_SIGNED_IN);
CurrentUser::DeclineFriendRequest * request =
new CurrentUser::DeclineFriendRequest();
request->setServerURL("client-user.php");
request->addParameter("action", "decline-friend-request");
request->addParameter("token", getToken());
request->addParameter("userid", getID());
request->addParameter("friendid", friend_id);
request->queue();
} // requestDeclineFriend

// ------------------------------------------------------------------------
/** Callback for the request to decline a friend invitation. Shows a
* confirmation message and takes care of updating all the cached
* information.
*/
void CurrentUser::DeclineFriendRequest::callback()
{
uint32_t id(0);
getXMLData()->get("friendid", &id);
core::stringw info_text("");
if(isSuccess())
{
CurrentUser::get()->getProfile()->removeFriend(id);
ProfileManager::get()->moveToCache(id);
ProfileManager::get()->getProfileByID(id)->deleteRelationalInfo();
OnlineProfileFriends::getInstance()->refreshFriendsList();
info_text = _("Friend request declined!");
}
else
info_text = getInfo();
GUIEngine::DialogQueue::get()->pushDialog(
new UserInfoDialog(id, info_text,!isSuccess(), true), true);
} // DeclineFriendRequest::callback

// ------------------------------------------------------------------------
/** A request to the server, to cancel a pending friend request.
* \param friend_id The id of the user of which the request has to be
* canceled.
*/
void CurrentUser::requestCancelFriend(const uint32_t friend_id) const
{
assert(m_state == US_SIGNED_IN);
Expand Down Expand Up @@ -575,7 +382,7 @@ namespace Online
{
assert(m_state == US_SIGNED_IN);
CurrentUser::RemoveFriendRequest * request =
new CurrentUser::RemoveFriendRequest();
new CurrentUser::RemoveFriendRequest(friend_id);
request->setServerURL("client-user.php");
request->addParameter("action", "remove-friend");
request->addParameter("token", getToken());
Expand All @@ -590,20 +397,18 @@ namespace Online
*/
void CurrentUser::RemoveFriendRequest::callback()
{
uint32_t id(0);
getXMLData()->get("friendid", &id);
core::stringw info_text("");
if(isSuccess())
{
CurrentUser::get()->getProfile()->removeFriend(id);
ProfileManager::get()->moveToCache(id);
ProfileManager::get()->getProfileByID(id)->deleteRelationalInfo();
CurrentUser::get()->getProfile()->removeFriend(m_id);
ProfileManager::get()->moveToCache(m_id);
ProfileManager::get()->getProfileByID(m_id)->deleteRelationalInfo();
OnlineProfileFriends::getInstance()->refreshFriendsList();
info_text = _("Friend removed!");
}
else
info_text = getInfo();
UserInfoDialog *info = new UserInfoDialog(id, info_text,!isSuccess(),
UserInfoDialog *info = new UserInfoDialog(m_id, info_text,!isSuccess(),
true);
GUIEngine::DialogQueue::get()->pushDialog(info, true);

Expand Down
52 changes: 4 additions & 48 deletions src/online/current_user.hpp
Expand Up @@ -72,19 +72,6 @@ namespace Online
SignOutRequest() : XMLRequest(true,/*priority*/10) {}
}; // SignOutRequest

// ----------------------------------------------------------------
class ServerCreationRequest : public XMLRequest {
virtual void callback ();
uint32_t m_created_server_id;
public:
ServerCreationRequest() : XMLRequest() {}
const uint32_t getCreatedServerID() const
{
assert(isDone());
return m_created_server_id;
} // getCreatedServerID
}; // ServerCreationRequest

// ----------------------------------------------------------------

class ServerJoinRequest : public XMLRequest {
Expand All @@ -100,32 +87,13 @@ namespace Online
SetAddonVoteRequest() : XMLRequest() {}
}; // SetAddonVoteRequest

// ----------------------------------------------------------------
class FriendRequest : public XMLRequest {
virtual void callback ();
public:
FriendRequest() : XMLRequest(true) {}
}; // FriendRequest

// ----------------------------------------------------------------
class AcceptFriendRequest : public XMLRequest {
virtual void callback ();
public:
AcceptFriendRequest() : XMLRequest(true) {}
}; // AcceptFriendRequest

// ----------------------------------------------------------------
class DeclineFriendRequest : public XMLRequest {
virtual void callback ();
public:
DeclineFriendRequest() : XMLRequest(true) {}
}; // DeclineFriendRequest

// ----------------------------------------------------------------
class RemoveFriendRequest : public XMLRequest {
unsigned int m_id;
virtual void callback ();
public:
RemoveFriendRequest() : XMLRequest(true) {}
RemoveFriendRequest(unsigned int id)
: XMLRequest(true), m_id(id) {}
}; // RemoveFriendRequest

// ----------------------------------------------------------------
Expand Down Expand Up @@ -168,32 +136,20 @@ namespace Online
/**Singleton */
static CurrentUser * get();
static void deallocate();
static void setUserDetails(HTTPRequest *html);
static void setUserDetails(HTTPRequest *request);

void requestSavedSession();
SignInRequest * requestSignIn( const irr::core::stringw &username,
const irr::core::stringw &password,
bool save_session,
bool request_now = true);
void requestSignOut();
const ServerCreationRequest * requestServerCreation(const irr::core::stringw &name, int max_players);
ServerJoinRequest * requestServerJoin(uint32_t server_id, bool request_now = true);


/** Register */
const XMLRequest * requestSignUp( const irr::core::stringw &username,
const irr::core::stringw &password,
const irr::core::stringw &password_ver,
const irr::core::stringw &email);

const XMLRequest * requestRecovery(const irr::core::stringw &username,
const irr::core::stringw &email);

const XMLRequest * requestGetAddonVote(const std::string & addon_id) const;
const SetAddonVoteRequest * requestSetAddonVote(const std::string & addon_id, float rating) const;
void requestFriendRequest(const uint32_t friend_id) const;
void requestAcceptFriend(const uint32_t friend_id) const;
void requestDeclineFriend(const uint32_t friend_id) const;
void requestRemoveFriend(const uint32_t friend_id) const;
void requestCancelFriend(const uint32_t friend_id) const;
void requestPasswordChange( const irr::core::stringw &current_password,
Expand Down
23 changes: 20 additions & 3 deletions src/states_screens/create_server_screen.cpp
Expand Up @@ -136,15 +136,32 @@ void CreateServerScreen::serverCreationRequest()
}
else
{
//m_options_widget->setDeactivated();
m_server_creation_request = Online::CurrentUser::get()->requestServerCreation(name, max_players);

m_server_creation_request = new ServerCreationRequest();
CurrentUser::setUserDetails(m_server_creation_request);
m_server_creation_request->addParameter("action", "create_server");
m_server_creation_request->addParameter("name", name);
m_server_creation_request->addParameter("max_players", max_players);
m_server_creation_request->queue();

return;
}
sfx_manager->quickSound("anvil");
}
// --------------------------------------------------------------------
void CreateServerScreen::ServerCreationRequest::callback()
{
if (isSuccess())
{
Server *server = new Server(*getXMLData()->getNode("server"));
ServersManager::get()->addServer(server);
m_created_server_id = server->getServerId();
} // isSuccess
} // callback

// ----------------------------------------------------------------------------
void CreateServerScreen::eventCallback(Widget* widget, const std::string& name, const int playerID)
void CreateServerScreen::eventCallback(Widget* widget, const std::string& name,
const int playerID)
{
if (name == m_options_widget->m_properties[PROP_ID])
{
Expand Down

0 comments on commit a3a851b

Please sign in to comment.