From b0c0439b391f4ccdc63a8b2ce0c58060731a6bae Mon Sep 17 00:00:00 2001 From: kaetemi Date: Sun, 7 Sep 2014 08:53:10 +0200 Subject: [PATCH] Change ClientApplication to DomainId in permission table --- .../game_share/generate_module_interface.xslt | 6 +- .../nel_database_mapping.cpp | 77 ++-- .../nel_database_mapping.h | 57 +-- .../nel_database_mapping.xml | 6 +- .../src/shard_unifier_service/readme.txt | 2 + .../ring_session_manager.cpp | 362 +++++++++--------- .../oldmodule/ryzommanage.module | 4 +- code/web/private_php/ams/autoload/sync.php | 32 +- code/web/private_php/ams/autoload/users.php | 6 +- code/web/private_php/setup/sql/nel_00002.sql | 5 + code/web/public_php/login/r2_login.php | 54 +-- code/web/public_php/setup/database.php | 4 + code/web/public_php/setup/install.php | 7 + code/web/public_php/setup/upgrade.php | 7 + 14 files changed, 286 insertions(+), 343 deletions(-) create mode 100644 code/ryzom/server/src/shard_unifier_service/readme.txt create mode 100644 code/web/private_php/setup/sql/nel_00002.sql diff --git a/code/ryzom/common/src/game_share/generate_module_interface.xslt b/code/ryzom/common/src/game_share/generate_module_interface.xslt index 425e699a4..ee87f6ae4 100644 --- a/code/ryzom/common/src/game_share/generate_module_interface.xslt +++ b/code/ryzom/common/src/game_share/generate_module_interface.xslt @@ -28,9 +28,7 @@ #ifndef #define #include "nel/misc/types_nl.h" -#ifdef NL_COMP_VC8 - #include <memory> -#endif +#include <memory> #include "nel/misc/hierarchical_timer.h" #include "nel/misc/string_conversion.h" #include "nel/net/message.h" @@ -45,7 +43,7 @@ #include "nel/misc/string_common.h" -#include "game_share/mysql_wrapper.h" +#include "server_share/mysql_wrapper.h" #include "game_share/synchronised_message.h" diff --git a/code/ryzom/server/src/shard_unifier_service/nel_database_mapping.cpp b/code/ryzom/server/src/shard_unifier_service/nel_database_mapping.cpp index 25cf56504..9e81798dc 100644 --- a/code/ryzom/server/src/shard_unifier_service/nel_database_mapping.cpp +++ b/code/ryzom/server/src/shard_unifier_service/nel_database_mapping.cpp @@ -1,18 +1,3 @@ -// Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program 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 Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . ///////////////////////////////////////////////////////////////// // WARNING : this is a generated file, don't change it ! @@ -99,7 +84,7 @@ namespace RSMGR { nlwarning("ERROR : someone try to delete this object, but there are still ptr on it !"); CNelUserPtr *ptr = _PtrList; - do + do { nlwarning(" Pointer created from '%s', line %u", ptr->_FileName, ptr->_LineNum); ptr = _PtrList->getNextPtr(); @@ -107,7 +92,7 @@ namespace RSMGR nlstop; } // remove object from cache map - if (_UserId != NOPE::INVALID_OBJECT_ID + if (_UserId != NOPE::INVALID_OBJECT_ID && _ObjectState != NOPE::os_removed && _ObjectState != NOPE::os_transient) { @@ -318,7 +303,7 @@ namespace RSMGR } else if (cmd == NOPE::cc_instance_count) { - return (uint32)_ObjectCache.size(); + return _ObjectCache.size(); } // default return value @@ -336,7 +321,7 @@ namespace RSMGR TReleasedObject::iterator first(_ReleasedObject.begin()), last(_ReleasedObject.end()); for (; first != last; ++first) { - nbReleased += (uint32)first->second.size(); + nbReleased += first->second.size(); } nlinfo(" There are %u object instances in cache not referenced (waiting deletion or re-use))", nbReleased); @@ -424,7 +409,7 @@ namespace RSMGR if(_ObjectState == NOPE::os_released && state == NOPE::os_removed) { // a release object gets removed (e.g. by remove by id) - + // delete the object delete this; @@ -578,7 +563,7 @@ namespace RSMGR { nlwarning("ERROR : someone try to delete this object, but there are still ptr on it !"); CNelPermissionPtr *ptr = _PtrList; - do + do { nlwarning(" Pointer created from '%s', line %u", ptr->_FileName, ptr->_LineNum); ptr = _PtrList->getNextPtr(); @@ -586,16 +571,16 @@ namespace RSMGR nlstop; } // remove object from cache map - if (_Prim != NOPE::INVALID_OBJECT_ID + if (_PermissionId != NOPE::INVALID_OBJECT_ID && _ObjectState != NOPE::os_removed && _ObjectState != NOPE::os_transient) { - nldebug("NOPE: clearing CNelPermission @%p from cache with id %u", this, static_cast(_Prim)); - nlverify(_ObjectCache.erase(_Prim) == 1); + nldebug("NOPE: clearing CNelPermission @%p from cache with id %u", this, static_cast(_PermissionId)); + nlverify(_ObjectCache.erase(_PermissionId) == 1); } else if (_ObjectState != NOPE::os_transient) { - nlassert(_ObjectCache.find(_Prim) == _ObjectCache.end()); + nlassert(_ObjectCache.find(_PermissionId) == _ObjectCache.end()); } if (_ObjectState == NOPE::os_released) { @@ -626,18 +611,18 @@ namespace RSMGR { nlassert(getPersistentState() == NOPE::os_transient); - nlassert(_Prim != 0); + nlassert(_PermissionId != 0); std::string qs; qs = "INSERT INTO permission ("; - qs += "prim, UId, ClientApplication, ShardId, AccessPrivilege"; + qs += "PermissionId, UId, DomainId, ShardId, AccessPrivilege"; qs += ") VALUES ("; - qs += "'"+MSW::escapeString(NLMISC::toString(_Prim), connection)+"'"; + qs += "'"+MSW::escapeString(NLMISC::toString(_PermissionId), connection)+"'"; qs += ", "; qs += "'"+MSW::escapeString(NLMISC::toString(_UserId), connection)+"'"; qs += ", "; - qs += "'"+MSW::escapeString(NLMISC::toString(_DomainName), connection)+"'"; + qs += "'"+MSW::escapeString(NLMISC::toString(_DomainId), connection)+"'"; qs += ", "; qs += "'"+MSW::escapeString(NLMISC::toString(_ShardId), connection)+"'"; qs += ", "; @@ -670,17 +655,17 @@ namespace RSMGR std::string qs; qs = "UPDATE permission SET "; - qs += "prim = '"+MSW::escapeString(NLMISC::toString(_Prim), connection)+"'"; + qs += "PermissionId = '"+MSW::escapeString(NLMISC::toString(_PermissionId), connection)+"'"; qs += ", "; qs += "UId = '"+MSW::escapeString(NLMISC::toString(_UserId), connection)+"'"; qs += ", "; - qs += "ClientApplication = '"+MSW::escapeString(NLMISC::toString(_DomainName), connection)+"'"; + qs += "DomainId = '"+MSW::escapeString(NLMISC::toString(_DomainId), connection)+"'"; qs += ", "; qs += "ShardId = '"+MSW::escapeString(NLMISC::toString(_ShardId), connection)+"'"; qs += ", "; qs += "AccessPrivilege = '"+MSW::escapeString(NLMISC::toString(_AccessPriv), connection)+"'"; - qs += " WHERE prim = '"+NLMISC::toString(_Prim)+"'"; + qs += " WHERE PermissionId = '"+NLMISC::toString(_PermissionId)+"'"; if (connection.query(qs)) @@ -702,7 +687,7 @@ namespace RSMGR std::string qs; qs = "DELETE FROM permission "; - qs += " WHERE prim = '"+NLMISC::toString(_Prim)+"'"; + qs += " WHERE PermissionId = '"+NLMISC::toString(_PermissionId)+"'"; if (connection.query(qs)) @@ -736,7 +721,7 @@ namespace RSMGR std::string qs; qs = "DELETE FROM permission "; - qs += " WHERE prim = '"+NLMISC::toString(id)+"'"; + qs += " WHERE PermissionId = '"+NLMISC::toString(id)+"'"; if (connection.query(qs)) @@ -796,7 +781,7 @@ namespace RSMGR } else if (cmd == NOPE::cc_instance_count) { - return (uint32)_ObjectCache.size(); + return _ObjectCache.size(); } // default return value @@ -814,7 +799,7 @@ namespace RSMGR TReleasedObject::iterator first(_ReleasedObject.begin()), last(_ReleasedObject.end()); for (; first != last; ++first) { - nbReleased += (uint32)first->second.size(); + nbReleased += first->second.size(); } nlinfo(" There are %u object instances in cache not referenced (waiting deletion or re-use))", nbReleased); @@ -902,7 +887,7 @@ namespace RSMGR if(_ObjectState == NOPE::os_released && state == NOPE::os_removed) { // a release object gets removed (e.g. by remove by id) - + // delete the object delete this; @@ -912,12 +897,12 @@ namespace RSMGR if (_ObjectState == NOPE::os_transient && state != NOPE::os_transient) { - nldebug("NOPE: inserting CNelPermission @%p in cache with id %u", this, static_cast(_Prim)); - nlverify(_ObjectCache.insert(std::make_pair(_Prim, this)).second); + nldebug("NOPE: inserting CNelPermission @%p in cache with id %u", this, static_cast(_PermissionId)); + nlverify(_ObjectCache.insert(std::make_pair(_PermissionId, this)).second); } if (_ObjectState != NOPE::os_transient) - nlassert(_ObjectCache.find(_Prim) != _ObjectCache.end()); + nlassert(_ObjectCache.find(_PermissionId) != _ObjectCache.end()); _ObjectState = state; @@ -928,8 +913,8 @@ namespace RSMGR } else if (state == NOPE::os_removed) { - nldebug("NOPE: erasing CNelPermission @%p in cache with id %u", this, static_cast(_Prim)); - nlverify(_ObjectCache.erase(_Prim) == 1); + nldebug("NOPE: erasing CNelPermission @%p in cache with id %u", this, static_cast(_PermissionId)); + nlverify(_ObjectCache.erase(_PermissionId) == 1); } } @@ -945,11 +930,11 @@ namespace RSMGR std::string qs; qs = "SELECT "; - qs += "prim, UId, ClientApplication, ShardId, AccessPrivilege"; + qs += "PermissionId, UId, DomainId, ShardId, AccessPrivilege"; qs += " FROM permission"; - qs += " WHERE prim = '"+NLMISC::toString(id)+"'"; + qs += " WHERE PermissionId = '"+NLMISC::toString(id)+"'"; CNelPermissionPtr ret; if (!connection.query(qs)) { @@ -965,9 +950,9 @@ namespace RSMGR // ok, we have an object result->fetchRow(); - result->getField(0, ret->_Prim); + result->getField(0, ret->_PermissionId); result->getField(1, ret->_UserId); - result->getField(2, ret->_DomainName); + result->getField(2, ret->_DomainId); result->getField(3, ret->_ShardId); result->getField(4, ret->_AccessPriv); diff --git a/code/ryzom/server/src/shard_unifier_service/nel_database_mapping.h b/code/ryzom/server/src/shard_unifier_service/nel_database_mapping.h index 7ddd3de74..50ef8e823 100644 --- a/code/ryzom/server/src/shard_unifier_service/nel_database_mapping.h +++ b/code/ryzom/server/src/shard_unifier_service/nel_database_mapping.h @@ -1,18 +1,3 @@ -// Ryzom - MMORPG Framework -// Copyright (C) 2010 Winch Gate Property Limited -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as -// published by the Free Software Foundation, either version 3 of the -// License, or (at your option) any later version. -// -// This program 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 Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . ///////////////////////////////////////////////////////////////// // WARNING : this is a generated file, don't change it ! @@ -107,7 +92,7 @@ namespace RSMGR _PrevPtr(NULL) { _Ptr = objectPtr; - + linkPtr(); } @@ -247,7 +232,7 @@ namespace RSMGR _PrevPtr(NULL) { _Ptr = objectPtr; - + linkPtr(); } @@ -556,7 +541,7 @@ namespace RSMGR time_t _ReleaseDate; /// The linked list of pointer on this object - CNelUserPtr *_PtrList; + CNelUserPtr *_PtrList; // Try to load the specified object from the memory cache, return NULL if the object is not in the cache static CNelUser *loadFromCache(uint32 objectId, bool unrelease); @@ -583,7 +568,7 @@ namespace RSMGR } public: - + /** Return the object identifier (witch is unique) * You can only call this method on a persistent instance. * (because transient instance can have invalid id) @@ -632,11 +617,11 @@ namespace RSMGR { protected: // - uint32 _Prim; + uint32 _PermissionId; // uint32 _UserId; // - std::string _DomainName; + uint32 _DomainId; // uint32 _ShardId; // @@ -662,25 +647,21 @@ namespace RSMGR } // - const std::string &getDomainName() const + uint32 getDomainId() const { - return _DomainName; + return _DomainId; } - - - void setDomainName(const std::string &value) + void setDomainId(uint32 value) { - if (_DomainName != value) + if (_DomainId != value) { if (getPersistentState() != NOPE::os_transient) setPersistentState(NOPE::os_dirty); + _DomainId = value; - _DomainName = value; - - } } @@ -729,9 +710,9 @@ namespace RSMGR bool operator == (const CNelPermission &other) const { - return _Prim == other._Prim + return _PermissionId == other._PermissionId && _UserId == other._UserId - && _DomainName == other._DomainName + && _DomainId == other._DomainId && _ShardId == other._ShardId && _AccessPriv == other._AccessPriv; } @@ -742,7 +723,7 @@ namespace RSMGR CNelPermission() : _PtrList(NULL), _ObjectState(NOPE::os_transient), - _Prim(NOPE::INVALID_OBJECT_ID) + _PermissionId(NOPE::INVALID_OBJECT_ID) { // register the cache for this class (if not already done) @@ -825,7 +806,7 @@ namespace RSMGR time_t _ReleaseDate; /// The linked list of pointer on this object - CNelPermissionPtr *_PtrList; + CNelPermissionPtr *_PtrList; // Try to load the specified object from the memory cache, return NULL if the object is not in the cache static CNelPermission *loadFromCache(uint32 objectId, bool unrelease); @@ -852,7 +833,7 @@ namespace RSMGR } public: - + /** Return the object identifier (witch is unique) * You can only call this method on a persistent instance. * (because transient instance can have invalid id) @@ -860,7 +841,7 @@ namespace RSMGR uint32 getObjectId() const { - return _Prim; + return _PermissionId; } /** Set the object unique ID. @@ -874,8 +855,8 @@ namespace RSMGR // can only be set when in transient state nlassert(getPersistentState() == NOPE::os_transient); // can only be set once - nlassert(_Prim == NOPE::INVALID_OBJECT_ID); - _Prim = objectId; + nlassert(_PermissionId == NOPE::INVALID_OBJECT_ID); + _PermissionId = objectId; } /** Return the current persistent state of the object.*/ diff --git a/code/ryzom/server/src/shard_unifier_service/nel_database_mapping.xml b/code/ryzom/server/src/shard_unifier_service/nel_database_mapping.xml index 02642eb11..cd85c2fd5 100644 --- a/code/ryzom/server/src/shard_unifier_service/nel_database_mapping.xml +++ b/code/ryzom/server/src/shard_unifier_service/nel_database_mapping.xml @@ -17,16 +17,16 @@ - + - + - + diff --git a/code/ryzom/server/src/shard_unifier_service/readme.txt b/code/ryzom/server/src/shard_unifier_service/readme.txt new file mode 100644 index 000000000..6d45d7556 --- /dev/null +++ b/code/ryzom/server/src/shard_unifier_service/readme.txt @@ -0,0 +1,2 @@ +xsltproc -o nel_database_mapping.cpp --stringparam output cpp --stringparam filename nel_database_mapping ../../../common/src/game_share/generate_module_interface.xslt nel_database_mapping.xml +xsltproc -o nel_database_mapping.h --stringparam output header --stringparam filename nel_database_mapping ../../../common/src/game_share/generate_module_interface.xslt nel_database_mapping.xml diff --git a/code/ryzom/server/src/shard_unifier_service/ring_session_manager.cpp b/code/ryzom/server/src/shard_unifier_service/ring_session_manager.cpp index 8d6c2a91f..a2dc72b1c 100644 --- a/code/ryzom/server/src/shard_unifier_service/ring_session_manager.cpp +++ b/code/ryzom/server/src/shard_unifier_service/ring_session_manager.cpp @@ -58,7 +58,7 @@ CVariable PrivilegeForSessionAccess("su", "PrivilegeForSessionAccess", " namespace RSMGR { - class CRingSessionManager : + class CRingSessionManager : public CEmptyModuleServiceBehav > >, public CRingSessionManagerSkel, public CRingSessionManagerWebItf, @@ -74,10 +74,10 @@ namespace RSMGR // mysql nel database connection MSW::CConnection _NelDb; - + struct TSessionServerInfo { - /// Shard id + /// Shard id TShardId ShardId; /// Total number of player in the sessions hosted by this server uint32 NbTotalPlayingChars; @@ -97,7 +97,7 @@ namespace RSMGR TSessionServers _SessionServers; typedef map TSessionServersIdx; - // index of sessionId to session server + // index of sessionId to session server TSessionServersIdx _SessionIndex; struct TWelcomeServiceInfo @@ -147,7 +147,7 @@ namespace RSMGR }; typedef map TTemporaryShardAssocs; - /** A table of session owner and the ring shard on witch they are + /** A table of session owner and the ring shard on witch they are * currently stuck. This allow the RSM to assign edit and anim session * of a character to the same DSS to use the DSS session ID masquerading * that allow reuse of the same session for editing and animating without @@ -184,7 +184,7 @@ namespace RSMGR struct TPendingJoinSession { /// The user ID - uint32 UserId; + uint32 UserId; /// the session id TSessionId SessionId; /// The web connection @@ -206,7 +206,7 @@ namespace RSMGR /// Pointer to character sync speaker ICharacterSync *_CharSync; public: - CRingSessionManager() + CRingSessionManager() : _DontUsePerm(false), _CharSync(NULL) { @@ -284,7 +284,7 @@ namespace RSMGR nlwarning("Missing 'web' param in module init string"); return false; } - + const TParsedCommandLine *portParam = web->getParam("port"); if (portParam == NULL) { @@ -399,7 +399,7 @@ namespace RSMGR { nldebug("RSM : receive module down for session server '%s'", proxy->getModuleName().c_str()); - // lock any sessions that belong to this module (because we don't now if + // lock any sessions that belong to this module (because we don't now if // the session server if just unreachable or really dead) TSessionServerInfo &ssi = it->second; { @@ -433,7 +433,7 @@ namespace RSMGR else ++it; } - + } { @@ -457,7 +457,7 @@ namespace RSMGR } } } - + } // remove session info @@ -625,11 +625,11 @@ namespace RSMGR // query << " WHERE shard.domain_id = domain.domain_id"; // query << " AND domain_name = '" << DomainName << "'"; // query << " AND ShardId = " << shardId; -// +// // BOMB_IF(!_NelDb.query(query), "registerWS : Failed to request into the NeL database", return CNelShardPtr()); // auto_ptr result = auto_ptr(_NelDb.storeResult()); // BOMB_IF(result.get() == NULL, "registerWS : Failed to retrieve request result", return CNelShardPtr()); -// +// // if (result->getNumRows() == 0) // { // return CNelShardPtr(); @@ -639,7 +639,7 @@ namespace RSMGR // // load the data // uint32 prim; // result->getField(0, prim); -// +// // return CNelShard::load(_NelDb, prim, __FILE__, __LINE__); // } @@ -648,8 +648,8 @@ namespace RSMGR userAccessPriv.clear(); CSString query; query << "SELECT AccessPrivilege FROM permission"; - query << " WHERE UId = " << userId << " AND permission.ClientApplication = '"<getModuleName().c_str()); if (_SessionServers.find(sender) != _SessionServers.end()) @@ -696,13 +696,13 @@ namespace RSMGR for (uint i=0; i(rsi.getSessionId()), + nlwarning("registerDSS : can't load the session %u hosted by '%s, closing it", + static_cast(rsi.getSessionId()), sender->getModuleName().c_str()); CRingSessionManagerClientProxy smc(sender); @@ -718,7 +718,7 @@ namespace RSMGR if (session->getState() != TSessionState::ss_open && session->getState() != TSessionState::ss_locked) { nlwarning("registerDSS : The session %u open hosted by '%s' is '%s', asking DSS to close it", - static_cast(rsi.getSessionId()), + static_cast(rsi.getSessionId()), sender->getModuleName().c_str(), session->getState().toString().c_str()); @@ -790,7 +790,7 @@ restartLoop: _TemporaryLockedSession.erase(sessionId); sessionToClose.pop_front(); } - + } _SessionServers[sender] = ssi; @@ -829,7 +829,7 @@ restartLoop: invokeResult(from, (it3->CharId) >> 4, 5, "Session server failure"); return; } - + TSessionServerInfo &ssi = it->second; TSessionServerInfo::THostedSessions::iterator it2(ssi.HostedSessions.find(sessionInfo.getSessionId())); @@ -875,7 +875,7 @@ restartLoop: _PendingSessions.erase(it3); } - + // that all } @@ -898,7 +898,7 @@ restartLoop: sender->getModuleName().c_str()); return; } - + TSessionServerInfo &ssi = it->second; TSessionServerInfo::THostedSessions::iterator it2(ssi.HostedSessions.find(sessionId)); @@ -1049,7 +1049,7 @@ restartLoop: sessionLog->setScenarioPointScored(0); sessionLog->setTimeTaken(0); sessionLog->setGuildName(""); - + sessionLog->create(_RingDb); } @@ -1095,12 +1095,12 @@ restartLoop: // provides a bunch of data about the session life. // The DSS report the end of an animation session and // provides a bunch of data about the session life. - virtual void scenarioEnded(NLNET::IModuleProxy *sender, - TSessionId sessionId, - const R2::TRunningScenarioInfo &scenarioInfo, - uint32 rrpScored, - uint32 scenarioPointScored, - uint32 timeTaken, + virtual void scenarioEnded(NLNET::IModuleProxy *sender, + TSessionId sessionId, + const R2::TRunningScenarioInfo &scenarioInfo, + uint32 rrpScored, + uint32 scenarioPointScored, + uint32 timeTaken, const std::vector < uint32 > &participants) { H_AUTO(SessionManager_scenarioEnded); @@ -1171,7 +1171,7 @@ restartLoop: // build the participants string for (uint i=0; isetObjectId(shardId); - // new WS are always inserted in restricted mode + // new WS are always inserted in restricted mode wsInfo.ShardInfo->setWSOnline(false); wsInfo.ShardInfo->setRequiredState(TAccessLevel::ds_restricted); wsInfo.ShardInfo->setMOTD("Shard up, access restricted"); @@ -1286,7 +1286,7 @@ restartLoop: if (isOnline && wsInfo.ShardInfo->getRequiredState() != TAccessLevel::ds_close) { - // the WS is online, check the previous known state of the + // the WS is online, check the previous known state of the // WS and put it in restricted if it was previously close. if (!wsInfo.ShardInfo->getWSOnline()) { @@ -1322,8 +1322,8 @@ restartLoop: { TWelcomeServiceInfo &wsi = itw->second; - if (isOnline - && wsi.ShardInfo->getRequiredState() != TAccessLevel::ds_close + if (isOnline + && wsi.ShardInfo->getRequiredState() != TAccessLevel::ds_close && !wsi.ShardInfo->getWSOnline()) { // unclose this shard @@ -1388,7 +1388,7 @@ restartLoop: // retrieve the session participant character->loadSessionParticipants(_RingDb, __FILE__, __LINE__); TSessionPartStatus status; - + // vector::iterator first(character->getSessionParticipants().begin()), last(character->getSessionParticipants().end()); // for (; first != last; ++first) uint i; @@ -1479,7 +1479,7 @@ restartLoop: joinSessionResult(pjs.From, pjs.UserId, pjs.SessionId, 8, string("Welcome refused entry in shard with error : '")+errorMsg+"'", TSessionPartStatus::invalid_val); } -endOfWelcomeUserResult: +endOfWelcomeUserResult: if (ok) { // update the 'ring_user' table to signal which session we're entering and with which character @@ -1494,7 +1494,7 @@ endOfWelcomeUserResult: return; } } - + nlwarning("welcomeUserResult : received a result for unexpected userId %u from WS '%s'", userId, sender->getModuleName().c_str()); @@ -1559,37 +1559,37 @@ endOfWelcomeUserResult: } } - virtual void on_setSessionStartParams(NLNET::TSockId from, + virtual void on_setSessionStartParams(NLNET::TSockId from, uint32 charId, TSessionId sessionId, const std::string &initialIslandLocation, const std::string &initialEntryPointLocation, const std::string &initialSeason) { CSessionPtr session = CSession::load(_RingDb, sessionId.asInt(), __FILE__, __LINE__); if (session == NULL) { return; } if (session->getSessionType() == TSessionType::st_mainland) { return;} - + TSessionServersIdx::iterator it(_SessionIndex.find(sessionId)); if (it == _SessionIndex.end()) { return; } CRingSessionManagerClientProxy ss(it->second); ss.setSessionStartParams(this, charId, sessionId, initialIslandLocation, initialEntryPointLocation, initialSeason); - + } - virtual void on_scheduleSession(NLNET::TSockId from, - uint32 charId, - const TSessionType &sessionType, - const std::string &sessionTitle, - const std::string &sessionDesc, - const TSessionLevel &sessionLevel, -// const TAccessType &accessType, - const TRuleType &ruleType, - const TEstimatedDuration &estimatedDuration, - uint32 subscriptionSlot, + virtual void on_scheduleSession(NLNET::TSockId from, + uint32 charId, + const TSessionType &sessionType, + const std::string &sessionTitle, + const std::string &sessionDesc, + const TSessionLevel &sessionLevel, +// const TAccessType &accessType, + const TRuleType &ruleType, + const TEstimatedDuration &estimatedDuration, + uint32 subscriptionSlot, const TAnimMode &animMode, - const TRaceFilter &raceFilter, - const TReligionFilter &religionFilter, - const TGuildFilter &guildFilter, + const TRaceFilter &raceFilter, + const TReligionFilter &religionFilter, + const TGuildFilter &guildFilter, const TShardFilter &shardFilter, const TLevelFilter &levelFilter, const std::string &language, @@ -1636,7 +1636,7 @@ endOfWelcomeUserResult: CCharacterPtr character = CCharacter::load(_RingDb, charId, __FILE__, __LINE__); if (character == NULL) { - // failed !, invalid character + // failed !, invalid character scheduleSessionResult(from, charId, TSessionId(0), 3, "Invalid character"); return; } @@ -1646,13 +1646,13 @@ endOfWelcomeUserResult: { CNelUserPtr nelUser = CNelUser::load(_NelDb, userId, __FILE__, __LINE__); BOMB_IF(nelUser == NULL, "Failed to load nel user "<getExtendedPrivilege().find(":TRIAL:") != string::npos) { // this account is free trial, no anim session allowed - scheduleSessionResult(from, charId, TSessionId(0), 9, "Forbidden for free trial"); + scheduleSessionResult(from, charId, TSessionId(0), 9, "Forbidden for free trial"); return; } */ @@ -1704,7 +1704,7 @@ endOfWelcomeUserResult: // store the session session->create(_RingDb); - + // ok, return the result to web scheduleSessionResult(from, charId, TSessionId(session->getObjectId()), 0, ""); } @@ -1730,7 +1730,7 @@ endOfWelcomeUserResult: } // ok, return the result to web - sessionInfoResult(from, charId, TSessionId(session->getObjectId()), + sessionInfoResult(from, charId, TSessionId(session->getObjectId()), session->getRaceFilter(), session->getReligionFilter(), session->getGuildFilter(), session->getShardFilter(), session->getLevelFilter(), session->getSubscriptionClosed(), (session->getAccessType()==TAccessType::at_public), session->getLang(), session->getOrientation(), session->getDescription()); @@ -1743,21 +1743,21 @@ endOfWelcomeUserResult: // 3 : char don't own the session // 4 : session is closed, no update allowed // 5 : invalid parameter - virtual void on_updateSessionInfo(NLNET::TSockId from, - uint32 charId, - TSessionId sessionId, - const std::string &sessionTitle, - uint32 plannedDate, - const std::string &sessionDesc, - const TSessionLevel &sessionLevel, -// const TAccessType &accessType, - const TEstimatedDuration &estimatedDuration, - uint32 subscriptionSlot, - const TRaceFilter &raceFilter, - const TReligionFilter &religionFilter, - const TGuildFilter &guildFilter, - const TShardFilter &shardFilter, - const TLevelFilter &levelFilter, + virtual void on_updateSessionInfo(NLNET::TSockId from, + uint32 charId, + TSessionId sessionId, + const std::string &sessionTitle, + uint32 plannedDate, + const std::string &sessionDesc, + const TSessionLevel &sessionLevel, +// const TAccessType &accessType, + const TEstimatedDuration &estimatedDuration, + uint32 subscriptionSlot, + const TRaceFilter &raceFilter, + const TReligionFilter &religionFilter, + const TGuildFilter &guildFilter, + const TShardFilter &shardFilter, + const TLevelFilter &levelFilter, bool subscriptionClosed, bool autoInvite, const std::string &language, @@ -1833,7 +1833,7 @@ endOfWelcomeUserResult: invokeResult(from, charId>>4, 0, ""); } - + // Cancel a planned session // Return 'invokeResult' : 0 : ok, session canceled // 1 : unknown char @@ -1867,14 +1867,14 @@ endOfWelcomeUserResult: return; } - if (session->getState() != TSessionState::ss_planned + if (session->getState() != TSessionState::ss_planned && session->getState() != TSessionState::ss_locked) { // not planned invokeResult(from, charId>>4, 4, "Session not in planned state"); return; } - + // remove the session from database session->remove(_RingDb); @@ -1928,7 +1928,7 @@ endOfWelcomeUserResult: // look for the best server TSessionServers::iterator best(_SessionServers.end()); - + // check if the user has a open edit session, if so, lauch the session on the same shard if (session->getSessionType() == TSessionType::st_anim) @@ -1944,7 +1944,7 @@ endOfWelcomeUserResult: TSessionServersIdx::iterator it(_SessionIndex.find(s->getObjectId())); if (it != _SessionIndex.end()) best = _SessionServers.find(it->second); - + break; } } @@ -2134,7 +2134,7 @@ endOfWelcomeUserResult: if (session->getState() != TSessionState::ss_closed && session->getState() != TSessionState::ss_planned) - { + { // ask the session server to close this session TSessionServersIdx::iterator it(_SessionIndex.find(sessionId)); if (it != _SessionIndex.end()) @@ -2142,7 +2142,7 @@ endOfWelcomeUserResult: TModuleProxyPtr proxy = it->second; CRingSessionManagerClientProxy ss(proxy); - + ss.closeSession(this, sessionId); // ok, we have closed the session @@ -2162,7 +2162,7 @@ endOfWelcomeUserResult: // use the first server in the list TModuleProxyPtr proxy = _SessionServers.begin()->first; CRingSessionManagerClientProxy ss(proxy); - + ss.stopHibernation(this, TSessionId(sessionId), charId); } @@ -2171,7 +2171,7 @@ endOfWelcomeUserResult: } // Close a running session - // Return 'invokeResult' : 0 : ok, + // Return 'invokeResult' : 0 : ok, // 1 : not ok //:TODO: change the name to Cloase or hibernate previous sessions virtual void on_hibernateEditSession(NLNET::TSockId from, uint32 charId) @@ -2186,12 +2186,12 @@ endOfWelcomeUserResult: CCharacterPtr character = CCharacter::load(_RingDb, charId, __FILE__, __LINE__); if (character == NULL) { - invokeResult(from, charId>>4, 1, "Character not found"); + invokeResult(from, charId>>4, 1, "Character not found"); return; } // Hiberning edit sessions { - + CSString query; query << "SELECT session_id FROM sessions"; query << " WHERE owner = "<getNumRows() != 0) { - + if (result->getNumRows() > 1) { @@ -2214,13 +2214,13 @@ endOfWelcomeUserResult: uint32 sessionNum; result->getField(0, sessionNum); TSessionId sessionId(sessionNum); - + CSessionPtr session = CSession::load(_RingDb, sessionId.asInt(), __FILE__, __LINE__); if (session != NULL) { if (session->getState() != TSessionState::ss_closed && session->getState() != TSessionState::ss_planned) - { + { // ask the session server to close this session TSessionServersIdx::iterator it(_SessionIndex.find(sessionId)); if (it != _SessionIndex.end()) @@ -2228,7 +2228,7 @@ endOfWelcomeUserResult: TModuleProxyPtr proxy = it->second; CRingSessionManagerClientProxy ss(proxy); - + ss.hibernateSession(this, sessionId); } } @@ -2238,7 +2238,7 @@ endOfWelcomeUserResult: // Close anim sessions { - + CSString query; query << "SELECT session_id FROM sessions"; query << " WHERE owner = "<getNumRows()); } - + unsigned int firstSession = 0; unsigned int lastSession = result->getNumRows(); for (;firstSession != lastSession; ++firstSession) - { + { result->fetchRow(); - // get the session id - + // get the session id + uint32 sessionNum; result->getField(0, sessionNum); TSessionId sessionId(sessionNum); - + CSessionPtr session = CSession::load(_RingDb, sessionId.asInt(), __FILE__, __LINE__); if (session != NULL) { - - if ( session->getState() != TSessionState::ss_closed && session->getState() != TSessionState::ss_planned) - { + + if ( session->getState() != TSessionState::ss_closed && session->getState() != TSessionState::ss_planned) + { // ask the session server to close this session TSessionServersIdx::iterator it(_SessionIndex.find(sessionId)); if (it == _SessionIndex.end()) @@ -2335,8 +2335,8 @@ endOfWelcomeUserResult: uint i; for (i=0; igetKnownUsers().size(); ++i) { - const CKnownUserPtr &ku = ru->getKnownUsers()[i]; - if (ku->getTargetCharacter() == friendCharId + const CKnownUserPtr &ku = ru->getKnownUsers()[i]; + if (ku->getTargetCharacter() == friendCharId && (ku->getRelation() == TKnownUserRelation::rt_friend || ku->getRelation() == TKnownUserRelation::rt_banned)) break; } @@ -2411,7 +2411,7 @@ endOfWelcomeUserResult: uint i; for (i=0; igetKnownUsers().size(); ++i) { - const CKnownUserPtr &ku = ru->getKnownUsers()[i]; + const CKnownUserPtr &ku = ru->getKnownUsers()[i]; if (ku->getTargetCharacter() == friendCharId && ku->getRelation() == TKnownUserRelation::rt_friend) break; } @@ -2468,7 +2468,7 @@ endOfWelcomeUserResult: uint i; for (i=0; igetKnownUsers().size(); ++i) { - const CKnownUserPtr &ku = ru->getKnownUsers()[i]; + const CKnownUserPtr &ku = ru->getKnownUsers()[i]; if (ku->getTargetCharacter() == bannedCharId && ku->getRelation() == TKnownUserRelation::rt_banned) break; } @@ -2487,14 +2487,14 @@ endOfWelcomeUserResult: } else { - // the character is already banned + // the character is already banned } vector removeList; // remove any friend or DM friend record for (i=0; igetKnownUsers().size(); ++i) { - const CKnownUserPtr &ku = ru->getKnownUsers()[i]; + const CKnownUserPtr &ku = ru->getKnownUsers()[i]; if (ku->getTargetCharacter() == bannedCharId && ku->getRelation() != TKnownUserRelation::rt_banned) removeList.push_back(ku); } @@ -2545,7 +2545,7 @@ endOfWelcomeUserResult: uint i; for (i=0; igetKnownUsers().size(); ++i) { - const CKnownUserPtr &ku = ru->getKnownUsers()[i]; + const CKnownUserPtr &ku = ru->getKnownUsers()[i]; if (ku->getTargetCharacter() == bannedCharId && ku->getRelation() == TKnownUserRelation::rt_banned) break; } @@ -2562,7 +2562,7 @@ endOfWelcomeUserResult: // invokeResult(from, userId, 3, "character not flagged as banned"); // return; // } - + // ok, remove the know user record ku->remove(_RingDb); @@ -2606,8 +2606,8 @@ endOfWelcomeUserResult: uint i; for (i=0; igetKnownUsers().size(); ++i) { - const CKnownUserPtr &ku = ru->getKnownUsers()[i]; - if (ku->getTargetCharacter() == friendDMCharId + const CKnownUserPtr &ku = ru->getKnownUsers()[i]; + if (ku->getTargetCharacter() == friendDMCharId && (ku->getRelation() == TKnownUserRelation::rt_friend_dm || ku->getRelation() == TKnownUserRelation::rt_banned)) break; } @@ -2681,7 +2681,7 @@ endOfWelcomeUserResult: uint i; for (i=0; igetKnownUsers().size(); ++i) { - const CKnownUserPtr &ku = ru->getKnownUsers()[i]; + const CKnownUserPtr &ku = ru->getKnownUsers()[i]; if (ku->getTargetCharacter() == friendDMCharId && ku->getRelation() == TKnownUserRelation::rt_friend_dm) break; } @@ -2698,7 +2698,7 @@ endOfWelcomeUserResult: // invokeResult(from, userId, 3, "character not flagged as friend"); // return; // } - + // ok, remove the know user record ku->remove(_RingDb); @@ -2715,9 +2715,9 @@ endOfWelcomeUserResult: // 5 : invalid param virtual void on_setKnownCharacterComments(NLNET::TSockId from, uint32 userId, uint32 charId, const std::string &relation, const std::string &comments) { - nldebug("RSM : setKnownCharacterComments set comment '%s' on char %u knowns as '%s' of user %u", + nldebug("RSM : setKnownCharacterComments set comment '%s' on char %u knowns as '%s' of user %u", comments.c_str(), - charId, + charId, relation.c_str(), userId); @@ -2739,7 +2739,7 @@ endOfWelcomeUserResult: bool foundARelation = false; for (uint i=0; igetKnownUsers().size(); ++i) { - CKnownUserPtr &ku = ru->getKnownUsersByIndex(i); + CKnownUserPtr &ku = ru->getKnownUsersByIndex(i); if (ku->getTargetCharacter() == charId && ku->getRelation() == rel) { // we found the relation, update the comment @@ -2772,7 +2772,7 @@ endOfWelcomeUserResult: // A user invite a character to help or play in his session // charRole is from enum TSessionPartStatus // invokeReturn : 0 : ok, character invited - // 1 : char not found + // 1 : char not found // 2 : session not found // 3 : invited char not found // 4 : char not own the session @@ -2842,17 +2842,17 @@ endOfWelcomeUserResult: invokeResult(from, ownerCharId>>4, 13, "scenario not started, can't validate invitation now"); return; } - + CScenarioPtr scenario = CScenario::load(_RingDb, sessionLog->getScenarioId(), __FILE__, __LINE__); BOMB_IF(invitedNelUser == NULL, "Failed to load scenario for id "<getScenarioId()<<" for session "<>4, 8, "Can not load scenario associated with session log"); return); - - if (invitedNelUser->getExtendedPrivilege().find(":TRIAL:") != string::npos + + if (invitedNelUser->getExtendedPrivilege().find(":TRIAL:") != string::npos && !scenario->getAllowFreeTrial()) { // free trial are not allowed in this scenario invokeResult(from, ownerCharId>>4, 14, "free trial character are not allowed in user scenario"); return; - + } // check that the character is not already participating @@ -2877,18 +2877,18 @@ endOfWelcomeUserResult: invokeResult(from, ownerCharId>>4, 4, "Animator can't invite other animator (only session owner can)"); return; } - else if (session->getOwnerId() != ownerCharId) + else if (session->getOwnerId() != ownerCharId) { // the character that request the invitation is not the session owner, // check that he is animator in the session/ BOMB_IF(!ownerChar->loadSessionParticipants(_RingDb, __FILE__, __LINE__), "Failed to load participation for host character "<>4, 8, "Failed to load participation for host character"); return); - + uint i=0; for (; igetSessionParticipants().size(); ++i) { CSessionParticipantPtr sp = ownerChar->getSessionParticipantsByIndex(i); - + if (sp->getSessionId() == sessionId.asInt()) { // we found it @@ -2899,12 +2899,12 @@ endOfWelcomeUserResult: invokeResult(from, ownerCharId>>4, 11, "Invitation requester char is not animator in the session"); return; } - + // ok, stop the loop break; } } - + if (i == ownerChar->getSessionParticipants().size()) { // no participation found ! @@ -3059,7 +3059,7 @@ endOfWelcomeUserResult: { const CKnownUserPtr &ku = ru->getKnownUsersByIndex(i); - if (ku->getRelation() == TKnownUserRelation::rt_banned + if (ku->getRelation() == TKnownUserRelation::rt_banned && ku->getTargetUser() == character->getUserId()) { // this character is banned ! @@ -3170,7 +3170,7 @@ endOfWelcomeUserResult: { BOMB_IF (!loadUserAccessPrivileges(userId, userAccessPriv), "RSM:on_joinSession : failed to load privileges for user "<getOwnerId() != charId + if (session->getOwnerId() != charId && nelUser->getExtendedPrivilege().find(":TRIAL:") != string::npos) { // check that the scenario launched allow free trials players @@ -3277,7 +3277,7 @@ endOfWelcomeUserResult: sessionPart->setCharId(charId); sessionPart->setSessionId(session->getObjectId()); sessionPart->setStatus(TSessionPartStatus::sps_play_invited); - + // store the participation sessionPart->create(_RingDb); } @@ -3344,7 +3344,7 @@ endOfWelcomeUserResult: // warn the session server that an editor come in enterAs = WS::TUserRole::ur_editor; ss.addCharacterInSession(this, sessionId, charId, enterAs, charac->getRingAccess(), charac->getNewcomer()); - + // update the participant status sessionPart->setStatus(TSessionPartStatus::sps_editing); @@ -3352,8 +3352,8 @@ endOfWelcomeUserResult: else if ( sessionPart->getStatus() == TSessionPartStatus::sps_anim_invited || sessionPart->getStatus() == TSessionPartStatus::sps_animating) { - // warn the session server that an animator come in - enterAs = WS::TUserRole::ur_animator; + // warn the session server that an animator come in + enterAs = WS::TUserRole::ur_animator; ss.addCharacterInSession(this, sessionId, charId, enterAs, charac->getRingAccess(), charac->getNewcomer()); // update the participant status sessionPart->setStatus(TSessionPartStatus::sps_animating); @@ -3406,7 +3406,7 @@ endOfWelcomeUserResult: if (wspSwitch == NULL) { // can't find a welcome service for this shard - + // try to read a shard status in the database CShardPtr shard = CShard::load(_RingDb, sessionId.asInt(), __FILE__, __LINE__); if (shard != NULL) @@ -3455,13 +3455,13 @@ endOfWelcomeUserResult: _PendingJoins.push_back(pjs); // reserve an entry place on the welcome service of the shard and wait for the response - wsp.welcomeUser(this, - charId, - nelUser->getLoginName(), - cookie, - nelUser->getPrivilege(), - nelUser->getExtendedPrivilege(), - enterAs, + wsp.welcomeUser(this, + charId, + nelUser->getLoginName(), + cookie, + nelUser->getPrivilege(), + nelUser->getExtendedPrivilege(), + enterAs, instanceId); // the rest of the code is done in 'welcomeUserResult' returned by the WS. @@ -3566,7 +3566,7 @@ endOfWelcomeUserResult: uint32 sessionNum; result->getField(0, sessionNum); TSessionId sessionId(sessionNum); - + // 2 : check that the character is invited in his session BOMB_IF(!character->loadSessionParticipants(_RingDb, __FILE__, __LINE__), "on_joinEditSession : failed to load session participants for char "<>4, TSessionId(0), 3, "Error loading partipation", TSessionPartStatus::invalid_val); return); uint i; @@ -3612,7 +3612,7 @@ endOfWelcomeUserResult: // ok, now call the normal join session _joinSessionCommon(from, charId, sessionId, clientApplication, true); } - + // Request to have the list of accessible shards with their attributes. virtual void on_getShards(NLNET::TSockId from, uint32 charId) { @@ -3645,7 +3645,7 @@ endOfWelcomeUserResult: } } } - + } getShardsResult(from, charId>>4, result); } @@ -3673,11 +3673,11 @@ endOfWelcomeUserResult: if (!hasSessionAccessPrivilege(userId)) { STOP("RSM : on_kickCharacter : char "<>4, 5, "Owner char don't own the session"); + invokeResult(from, ownerCharId>>4, 5, "Owner char don't own the session"); return; } } - + // load the participants BOMB_IF(!session->loadSessionParticipants(_RingDb, __FILE__, __LINE__), "RSM : on_kickCharacter : failed to load session participants for session "<>4, 4, "Failed to load session participants"); return); @@ -3733,7 +3733,7 @@ endOfWelcomeUserResult: if (!hasSessionAccessPrivilege(userId)) { STOP("RSM : on_unkickCharacter : char "<>4, 5, "Owner char don't own the session"); + invokeResult(from, ownerCharId>>4, 5, "Owner char don't own the session"); return; } } @@ -3775,7 +3775,7 @@ endOfWelcomeUserResult: // 5 : char don't own the session virtual void on_inviteGuild(NLNET::TSockId from, uint32 charId, TSessionId sessionId, uint32 guildId) { - nldebug("RSM : onInviteGuild char %u invite guild %u in session %u", + nldebug("RSM : onInviteGuild char %u invite guild %u in session %u", charId, guildId, sessionId.asInt()); @@ -3830,10 +3830,10 @@ endOfWelcomeUserResult: invite->setGuildId(guildId); invite->setSessionId(sessionId.asInt()); - + // store the new invite invite->create(_RingDb); - + // result ok invokeResult(from, charId>>4, 0, ""); } @@ -3847,7 +3847,7 @@ endOfWelcomeUserResult: // 5 : char don't own the session virtual void on_removeInvitedGuild(NLNET::TSockId from, uint32 charId, TSessionId sessionId, uint32 guildId) { - nldebug("RSM : removeInvitedGuild char %u revoke invitattion for guild %u in session %u", + nldebug("RSM : removeInvitedGuild char %u revoke invitattion for guild %u in session %u", charId, guildId, sessionId.asInt()); @@ -3919,13 +3919,13 @@ endOfWelcomeUserResult: // 2 : user not owner of session // 3 : user not found // 4 : session not found -// virtual void on_setScenarioInfo(NLNET::TSockId from, -// uint32 userId, -// TSessionId sessionId, -// const std::string &title, -// const std::string &journal, -// const std::string &credits, -// uint32 numPlayer, +// virtual void on_setScenarioInfo(NLNET::TSockId from, +// uint32 userId, +// TSessionId sessionId, +// const std::string &title, +// const std::string &journal, +// const std::string &credits, +// uint32 numPlayer, // const std::string &playType) virtual void on_setScenarioInfo(NLNET::TSockId from, uint32 charId, TSessionId sessionId, const std::string &title, uint32 numPlayer, const std::string &playType) { @@ -3955,7 +3955,7 @@ endOfWelcomeUserResult: // invokeResult(from, charId>>4, 2, "Character don't own the session"); // return; // } -// +// // // load the scenario desc // CScenarioDescPtr scenario = CScenarioDesc::load(_RingDb, sessionId.asInt(), __FILE__, __LINE__); // if (scenario == NULL) @@ -3968,7 +3968,7 @@ endOfWelcomeUserResult: // scenario->setTitle(title); // //oups, data do not matchs // nlstop; -// +// invokeResult(from, charId>>4, 100, "Deprecatted"); }; @@ -3982,10 +3982,10 @@ endOfWelcomeUserResult: // 5 : user participation not found // 6 : character not found // 7 : invalid params - virtual void on_addJournalEntry(NLNET::TSockId from, - uint32 charId, - TSessionId sessionId, - const std::string &entryType, + virtual void on_addJournalEntry(NLNET::TSockId from, + uint32 charId, + TSessionId sessionId, + const std::string &entryType, const std::string &text) { nldebug("RSM : addJournalEntry char %u add an entry in journal of session %u", charId, sessionId.asInt()); @@ -4075,11 +4075,11 @@ endOfWelcomeUserResult: // 6 : session not found // 7 : scenario not found // 8 : internal error - virtual void on_setPlayerRating(NLNET::TSockId from, uint32 charId, TSessionId sessionId, - uint32 rateFun, - uint32 rateDifficulty, - uint32 rateAccessibility, - uint32 rateOriginality, + virtual void on_setPlayerRating(NLNET::TSockId from, uint32 charId, TSessionId sessionId, + uint32 rateFun, + uint32 rateDifficulty, + uint32 rateAccessibility, + uint32 rateOriginality, uint32 rateDirection) { nldebug("Web set player rating from char %u to session %u as %u,%u,%u,%u, %u", @@ -4106,14 +4106,14 @@ endOfWelcomeUserResult: if (sp->getKicked() == true) { - invokeResult(from, charId>>4, 5, "Char is banned from the session"); + invokeResult(from, charId>>4, 5, "Char is banned from the session"); return; } break; } } - BOMB_IF(i == character->getSessionParticipants().size(), + BOMB_IF(i == character->getSessionParticipants().size(), "No participation found for char "<>4, 3, "No participation found in session"); return); // retrieve the scenario data @@ -4216,7 +4216,7 @@ endOfWelcomeUserResult: } - + NLMISC_COMMAND_HANDLER_TABLE_EXTEND_BEGIN(CRingSessionManager, CModuleBase) NLMISC_COMMAND_HANDLER_ADD(CRingSessionManager, dump, "dump the session manager internal state", "no param"); NLMISC_COMMAND_HANDLER_ADD(CRingSessionManager, forceSessionCleanup, "force a database synchronisation with current running session", "no param"); @@ -4245,7 +4245,7 @@ endOfWelcomeUserResult: log.displayNL("failed to load session %u", sessionId); return true; } - + // load the participants if (!session->loadSessionParticipants(_RingDb, __FILE__, __LINE__)) { @@ -4355,19 +4355,19 @@ endOfWelcomeUserResult: if (args.size() > 2) { shard->setMOTD(args[2]); - log.displayNL("Shard %u set required state to '%s' with message '%s'", + log.displayNL("Shard %u set required state to '%s' with message '%s'", shardId, al.toString().c_str(), args[2].c_str()); } else { - log.displayNL("Shard %u set required state to '%s'", + log.displayNL("Shard %u set required state to '%s'", shardId, al.toString().c_str()); shard->setMOTD(""); } - + // update WSState if possible @@ -4376,7 +4376,7 @@ endOfWelcomeUserResult: return true; } - + NLMISC_CLASS_COMMAND_DECL(forceSessionCleanup) { if (!_RingDb.query(string("SELECT session_id FROM sessions WHERE state = ")+toString(uint32(TSessionState::ss_open)))) @@ -4437,8 +4437,8 @@ endOfWelcomeUserResult: log.displayNL(" + Welcome service '%s' for shard %u", wsInfo.WSModuleProxy->getModuleName().c_str(), shardId); if (wsInfo.FixedSessionId.asInt() != 0) log.displayNL(" Mainland sessionId: %u", wsInfo.FixedSessionId.asInt()); - log.displayNL(" Access State = '%s', online = %s, message = '%s'", - wsInfo.ShardInfo->getRequiredState().toString().c_str(), + log.displayNL(" Access State = '%s', online = %s, message = '%s'", + wsInfo.ShardInfo->getRequiredState().toString().c_str(), wsInfo.ShardInfo->getWSOnline() ? "true" : "false", wsInfo.ShardInfo->getMOTD().c_str()); log.displayNL(" %u online players", wsInfo.NbOnlinePlayers); @@ -4455,7 +4455,7 @@ endOfWelcomeUserResult: { IModuleProxy *server = first->first; TSessionServerInfo &ssi = first->second; - + log.displayNL(" + Session server '%s' :", server->getModuleName().c_str()); log.displayNL(" Shard ID = %u", ssi.ShardId); log.displayNL(" Total player = %u", ssi.NbTotalPlayingChars); @@ -4479,9 +4479,9 @@ endOfWelcomeUserResult: return true; } - - }; + + }; NLNET_REGISTER_MODULE_FACTORY(CRingSessionManager, RingSessionManagerClassName); diff --git a/code/ryzom/tools/server/ryzom_ams/drupal_module/oldmodule/ryzommanage.module b/code/ryzom/tools/server/ryzom_ams/drupal_module/oldmodule/ryzommanage.module index e5e184556..f09b06a37 100644 --- a/code/ryzom/tools/server/ryzom_ams/drupal_module/oldmodule/ryzommanage.module +++ b/code/ryzom/tools/server/ryzom_ams/drupal_module/oldmodule/ryzommanage.module @@ -659,12 +659,12 @@ function createPermissions($values) { $sth = $dbh->prepare("SELECT UId FROM user WHERE Login='" . $values[0] . "';"); $sth->execute(); $result = $sth->fetchAll(); - foreach ($result as $UId) { + /*foreach ($result as $UId) { $statement = $dbh->prepare("INSERT INTO permission (UId, ClientApplication, AccessPrivilege) VALUES ('" . $UId['UId'] . "', 'r2', 'OPEN');"); $statement->execute($values); $statement = $dbh->prepare("INSERT INTO permission (UId, ClientApplication, AccessPrivilege) VALUES ('" . $UId['UId'] . "', 'ryzom_open', 'OPEN');"); $statement->execute($values); - } + }*///FIXME: GARBAGE } catch (PDOException $e) { watchdog('ryzommanage', $e->getMessage(), NULL, WATCHDOG_ERROR); diff --git a/code/web/private_php/ams/autoload/sync.php b/code/web/private_php/ams/autoload/sync.php index a3bf6fdb2..f989e3e59 100644 --- a/code/web/private_php/ams/autoload/sync.php +++ b/code/web/private_php/ams/autoload/sync.php @@ -6,12 +6,12 @@ * @author Daan Janssens, mentored by Matthew Lagoe */ class Sync{ - + const OS_UNKNOWN = 1; const OS_WIN = 2; const OS_LINUX = 3; const OS_OSX = 4; - + /** * performs the actions listed in the querycache. * All entries in the querycache will be read and performed depending on their type. @@ -19,13 +19,13 @@ class Sync{ * These changes are: createPermissions, createUser, change_pass, change_mail */ static public function syncdata ($display = false) { - + if (function_exists('pcntl_fork')) { $pid = pcntl_fork(); } global $AMS_TMPDIR; $pidfile = $AMS_TMPDIR.'/ams_cron_pid'; - + if(isset($pid) and function_exists('pcntl_fork') ) { // We're the main process. } else { @@ -43,9 +43,9 @@ class Sync{ try { $dbl = new DBLayer("lib"); $statement = $dbl->executeWithoutParams("SELECT * FROM ams_querycache"); - $rows = $statement->fetchAll(); + $rows = $statement->fetchAll(); foreach ($rows as $record) { - + $db = new DBLayer($record['db']); switch($record['type']) { case 'createPermissions': @@ -54,32 +54,32 @@ class Sync{ //make connection with and put into shard db & delete from the lib $sth=$db->selectWithParameter("UId", "user", $values, "Login= :username" ); $result = $sth->fetchAll(); - foreach ($result as $UId) { + /*foreach ($result as $UId) { $ins_values = array('UId' => $UId['UId']); $ins_values['ClientApplication'] = "r2"; $ins_values['AccessPrivilege'] = "OPEN"; $db->insert("permission", $ins_values); $ins_values['ClientApplication'] = 'ryzom_open'; $db->insert("permission",$ins_values); - } + }*/ // FIXME: GARBAGE break; case 'change_pass': $decode = json_decode($record['query']); $values = array('Password' => $decode[1]); //make connection with and put into shard db & delete from the lib - $db->update("user", $values, "Login = '$decode[0]'"); + $db->update("user", $values, "Login = '$decode[0]'"); break; case 'change_mail': $decode = json_decode($record['query']); $values = array('Email' => $decode[1]); //make connection with and put into shard db & delete from the lib - $db->update("user", $values, "Login = '$decode[0]'"); + $db->update("user", $values, "Login = '$decode[0]'"); break; - case 'createUser': + case 'createUser': $decode = json_decode($record['query']); $values = array('Login' => $decode[0], 'Password' => $decode[1], 'Email' => $decode[2] ); //make connection with and put into shard db & delete from the lib - $db->insert("user", $values); + $db->insert("user", $values); break; } $dbl->delete("ams_querycache", array('SID' => $record['SID']), "SID=:SID"); @@ -99,11 +99,11 @@ class Sync{ } } - + public static function check_pid($pid){ - + $OS = Sync::getOS(); - + if ($OS == 2) { $processes = explode( "\n", shell_exec( "tasklist.exe" )); foreach( $processes as $process ) @@ -117,7 +117,7 @@ class Sync{ } } else { return file_exists( "/proc/$pid" ); - } + } } static public function getOS() { switch (true) { diff --git a/code/web/private_php/ams/autoload/users.php b/code/web/private_php/ams/autoload/users.php index 1754a4f05..cde30cf63 100644 --- a/code/web/private_php/ams/autoload/users.php +++ b/code/web/private_php/ams/autoload/users.php @@ -25,7 +25,7 @@ class Users{ $cpass = ""; $email = ""; } - + if ( helpers :: check_if_game_client() or isset($FORCE_INGAME) ) { if ( isset( $_POST["TaC"] )) { $tac="success"; @@ -336,12 +336,12 @@ class Users{ $dbs = new DBLayer("shard"); $sth = $dbs->selectWithParameter("UId", "user", $values, "Login= :username"); $result = $sth->fetchAll(); - foreach ($result as $UId) { + /*foreach ($result as $UId) { $ins_values = array('UId' => $UId['UId'], 'clientApplication' => 'r2', 'AccessPrivilege' => 'OPEN'); $dbs->insert("permission", $ins_values); $ins_values['clientApplication'] = 'ryzom_open'; $dbs->insert("permission", $ins_values); - } + }*/ // FIXME: GARBAGE } catch (PDOException $e) { //oh noooz, the shard is offline! Put it in query queue at ams_lib db! diff --git a/code/web/private_php/setup/sql/nel_00002.sql b/code/web/private_php/setup/sql/nel_00002.sql new file mode 100644 index 000000000..74a59d980 --- /dev/null +++ b/code/web/private_php/setup/sql/nel_00002.sql @@ -0,0 +1,5 @@ +ALTER TABLE `permission` CHANGE `ClientApplication` `ClientApplication` CHAR( 64 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ; +ALTER TABLE `permission` DROP `prim` ; +ALTER TABLE `permission` ADD `PermissionId` INT NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST ; +ALTER TABLE `permission` ADD `DomainId` INT NOT NULL DEFAULT '-1' AFTER `UId` ; +ALTER TABLE `permission` DROP `ClientApplication` ; diff --git a/code/web/public_php/login/r2_login.php b/code/web/public_php/login/r2_login.php index 8e97aafae..a1bccc13a 100644 --- a/code/web/public_php/login/r2_login.php +++ b/code/web/public_php/login/r2_login.php @@ -176,7 +176,6 @@ // if we need to create missing ring info if ($AutoCreateRingInfo) { - ////////////// Temporary code alpha 0 only ///////////////////////////////////// // check if the ring user exist, and create it if not $ringDb = mysqli_connect($DBHost, $RingDBUserName, $RingDBPassword) or die(errorMsgBlock(3004, 'Ring', $DBHost, $RingDBUserName)); mysqli_select_db ($ringDb, $domainInfo['ring_db_name']) or die(errorMsgBlock(3005, 'Ring', $domainInfo['ring_db_name'], $DBHost, $RingDBUserName)); @@ -190,17 +189,6 @@ $query = "INSERT INTO ring_users SET user_id = '$id', user_name = '$login', user_type='ut_pioneer'"; $result = mysqli_query ($ringDb, $query) or die(errorMsgBlock(3006, $query, 'Ring', $domainInfo['ring_db_name'], $DBHost, $RingDBUserName, mysqli_error($ringDb))); } - -// // check that there is a character record (deprecated) -// $query = "SELECT user_id FROM characters where user_id = '".$id."'"; -// $result = mysqli_query ($ringDb, $query) or die("Query ".$query." failed"); -// if (mysqli_num_rows($result) == 0) -// { -// // no characters record, build a default one -// $charId = ($id * 16); -// $query = "INSERT INTO characters SET char_id='".$charId."', char_name='".$_GET["login"]."_default', user_id = '".$id."'"; -// $result = mysqli_query ($ringDb, $query) or die("Query ".$query." failed"); -// } } // // check domain status @@ -324,7 +312,7 @@ $extended = $row["ExtendedPrivilege"]; // add the default permission - $query = "INSERT INTO permission (UId, ClientApplication, AccessPrivilege) VALUES ('$id', 'r2', '$accessPriv')"; + $query = "INSERT INTO permission (UId, DomainId, AccessPrivilege) VALUES ('$id', '$domainId', '$accessPriv')"; $result = mysqli_query ($link, $query) or die (errorMsgBlock(3006, $query, 'main', $DBName, $DBHost, $DBUserName, mysqli_error($link))); $res = false; @@ -338,40 +326,6 @@ else { $reason = errorMsg(2001, $login, 'checkUserValidity'); - // Check if this is not an unconfirmed account - /* - $query = "SELECT GamePassword, Email, Language FROM signup_data WHERE login='$login'"; - $result = mysqli_query($link, $query) or die (errorMsgBlock(3006, $query, 'main', $DBName, $DBHost, $DBUserName, mysqli_error($link))); - - if (mysqli_num_rows($result) == 0) - { - $reason = errorMsg(2001, $login, 'checkUserValidity'); - $res = false; - } - else - { - // Check password to avoid revealing email address to third-party - $passwordMatchedRow = false; - while ($row = mysqli_fetch_assoc($result)) - { - $salt = substr($row['GamePassword'],0,2); - if (($cp && $row['GamePassword'] == $password) || (!$cp && $row['GamePassword'] == crypt($password, $salt))) - { - $passwordMatchedRow = $row; - break; - } - } - if ($passwordMatchedRow !== false) - { - if ($lang == 'unknown') - setMsgLanguage($passwordMatchedRow['Language']); - $reason = errorMsg(2002, $passwordMatchedRow['Email']); - } - else - $reason = errorMsg(2004, 'db signup_data'); - $res = false; - } - */ } } else @@ -385,14 +339,14 @@ // check if the user can use this application $clientApplication = mysqli_real_escape_string($link, $clientApplication); - $query = "SELECT * FROM permission WHERE UId='".$row["UId"]."' AND ClientApplication='$clientApplication'"; + $query = "SELECT * FROM permission WHERE UId='".$row["UId"]."' AND DomainId='$domainId'"; $result = mysqli_query ($link, $query) or die (errorMsgBlock(3006, $query, 'main', $DBName, $DBHost, $DBUserName, mysqli_error($link))); if (mysqli_num_rows ($result) == 0) { if ($AcceptUnknownUser) { // add default permission - $query = "INSERT INTO permission (UId, ClientApplication, ShardId, AccessPrivilege) VALUES ('".$row["UId"]."', '$clientApplication', -1, '$domainStatus')"; + $query = "INSERT INTO permission (UId, DomainId, ShardId, AccessPrivilege) VALUES ('".$row["UId"]."', '$domainId', -1, '$domainStatus')"; $result = mysqli_query ($link, $query) or die (errorMsgBlock(3006, $query, 'main', $DBName, $DBHost, $DBUserName, mysqli_error($link))); $reason = errorMsg(3010); @@ -416,7 +370,7 @@ if ($AcceptUnknownUser) { // set an additionnal privilege for this player - $query = "UPDATE permission set AccessPrivilege='".$permission['AccessPrivilege'].",$accessPriv' WHERE prim=".$permission['prim']; + $query = "UPDATE permission set AccessPrivilege='".$permission['AccessPrivilege'].",$accessPriv' WHERE PermissionId=".$permission['PermissionId']; $result = mysqli_query ($link, $query) or die (errorMsgBlock(3006, $query, 'main', $DBName, $DBHost, $DBUserName, mysqli_error($link))); $reason = errorMsg(3012, $accessPriv); diff --git a/code/web/public_php/setup/database.php b/code/web/public_php/setup/database.php index 564e74039..37e5ce50b 100644 --- a/code/web/public_php/setup/database.php +++ b/code/web/public_php/setup/database.php @@ -57,6 +57,10 @@ function upgrade_service_databases($continue_r) { $continue = update_database_structure($continue, $con, "nel_00001.sql"); $continue = set_db_version($continue, "shard", 1); } + if ($continue && get_db_version("shard") < 2) { + $continue = update_database_structure($continue, $con, "nel_00002.sql"); + $continue = set_db_version($continue, "shard", 2); + } disconnect_database($con, "shard"); $con = null; diff --git a/code/web/public_php/setup/install.php b/code/web/public_php/setup/install.php index cc9972f8d..7eb3a7925 100644 --- a/code/web/public_php/setup/install.php +++ b/code/web/public_php/setup/install.php @@ -34,6 +34,13 @@ include('header.php'); $continue = false; } + if ($continue) { + if (!extension_loaded('mcrypt')) { + printalert("danger", "The mcrypt extension is missing. Please check your PHP configuration"); + $continue = false; + } + } + // Validate basics if ($continue) { if (file_exists($_POST["privatePhpDirectory"])) { diff --git a/code/web/public_php/setup/upgrade.php b/code/web/public_php/setup/upgrade.php index b29c04e2c..cc157a997 100644 --- a/code/web/public_php/setup/upgrade.php +++ b/code/web/public_php/setup/upgrade.php @@ -28,6 +28,13 @@ if (!isset($NEL_SETUP_VERSION_CONFIGURED)) { require_once('database.php'); + if ($continue) { + if (!extension_loaded('mcrypt')) { + printalert("danger", "The mcrypt extension is missing. Please check your PHP configuration"); + $continue = false; + } + } + if (file_exists("role_support")) { $continue = upgrade_support_databases($continue); }