summaryrefslogtreecommitdiff
path: root/src/account-server/accounthandler.cpp
AgeCommit message (Collapse)AuthorFilesLines
2023-05-26Fixed login in case an account gets two pending tokens assignedHEADmasterThorbjørn Lindeijer1-66/+7
Not entirely sure if this is what was happening, but if a PAMSG_LOGIN_RNDTRGR was handled, a new pending account was always created and appended to mPendingAccounts. However, when handling the follow-up PAMSG_LOGIN, only the first pending account with matching username was checked, which could result in a failed login due to mismatching token. Resolved this issue by unifying the client-specific random token with the Stellar token stored on the AccountClient. This means the username value in PAMSG_LOGIN_RNDTRGR could be removed. Eventually it would also be nice to simplify this further such that the token is automatically sent to the client after connecting rather than being something that needs to be requested.
2023-05-16Allow account email to be null in the databaseThorbjørn Lindeijer1-28/+35
When using login with Stellar, the email address remains empty. This was causing issues since the email is also required to be unique, in effect only a single Stellar account could exist. Resolved this by allowing the email column to be null, since the unique requirement does not cover null values. An empty email will now be stored as null value. For non-Stellar logins, an email address is still required.
2023-05-16Added some info messages related to Stellar loginThorbjørn Lindeijer1-0/+4
Something doesn't seem to be working right...
2023-05-15Manage CharacterData using std::unique_ptrThorbjørn Lindeijer1-21/+22
Fixes many memory leaks, but also made it clear that we're very often loading all the character data only to immediately throw it away again, even when most of the time all we really need is the database ID or the name.
2023-05-15General code cleanupsThorbjørn Lindeijer1-16/+17
* Overall includes cleanup * Use std::make_pair * Make some functions const
2023-05-05Added net_stellarLoginUrl configurationThorbjørn Lindeijer1-1/+4
The client needs to know the URL to open in the browser. The bare token is still sent as well, which might allow the client to directly interact with a Stellar wallet in the future.
2023-05-05Use std::make_uniqueThorbjørn Lindeijer1-9/+4
2023-05-05Added support for logging in with StellarThorbjørn Lindeijer1-28/+158
* Added PAMSG_STELLAR_LOGIN / PAMSG_STELLAR_LOGIN_RESPONSE, which is used by the client to request a login token that can be signed using a Stellar wallet. * Added uWebSockets dependency, used to listen for a separate server that verifies signed tokens (the Stellar Bridge). When a token is verified, it is sent to manaserv-account, which then sends a APMSG_LOGIN_RESPONSE to the client matching the token. * Added RapidJSON dependency to parse the JSON WebSocket messages. * To keep everything in a single thread, uWebSockets is now driving the event loop. Processing of ENet hosts, writing stats and expired bans have been moved to uSocket timers. * C++ standard updated to C++17, as required by uWebSockets. When Stellar is used to login, the public key is used as the username. It might be better to introduce an explicit field for this, especially when we want to enable an account to feature both Stellar login as well as login with username / password.
2022-08-19Apply C++11 fixitsThorbjørn Lindeijer1-6/+6
modernize-use-auto modernize-use-nullptr modernize-use-override modernize-use-using
2022-08-19Fixed possible leak in AccountHandler::handleUnregisterMessageThorbjørn Lindeijer1-32/+35
Fixed by changing account instances to be managed by std::unique_ptr, so we don't forget to delete them somewhere, like in that function as well as during shutdown in AccountHandler.
2013-11-28Include the list of characters in the login responseThorbjørn Lindeijer1-11/+11
This makes it easier on the client to decide whether to immediately open the Create Character page or to go to the Choose Character page. Still supports client version 9 as well.
2013-10-13Changed argument to const &Thorbjørn Lindeijer1-1/+2
2013-10-06Marked getRandomString as staticThorbjørn Lindeijer1-1/+1
2013-10-01Send the character data in a single messageErik Schilling1-29/+23
2013-09-09Fixed the equipment info for charactersErik Schilling1-1/+1
It was a inventory slot not equipmentslot.
2013-09-09Send equipment data for character selectionErik Schilling1-7/+16
2013-08-26Readded level handlingErik Schilling1-1/+1
Things done: Wrote a entity:give_experience function (lua side only). Renamed characterpoints to attributepoints (no db update. Did not want to do one for a simple rename). Temponary introduced a ATTR_LEVEL constant. TODO: dehardcode this. Script binds for settings the correction and attribute points.
2013-08-26Removed skillsErik Schilling1-1/+0
This removes support for skills. The plan is to allow to implement the skills as they were implemented before via attributes. This adds a lot more flexibility to the server creators while also removing the confusion about skills and attributes. So this change does: - Remove the skillmanager with all its calls, the skill xml file, etc - Move exp giving to the script engine: --> Allows to implement the old behaviour (and more) in the scripts - Remove the exp tag from the monster definition: + Since the server itself does not require it anymore it feels wrong to require it for EVERY monster. TODO: Add a system to add properties to the monsters/items.xml which allow defining things like the exp and allows to read the value from the script engine. + Small drawback, but it should not be hard to implement this property system. - Drop the level networking and calculation. + level calculation will happen via the attribute system later but i would prefer to do this in a seperate patch since this patch already got longer than expected especially since this requires to make setting correction points and available status points scriptable. + The level would be simply set as a attribute, the int number of it will be the level, the remaining digits will be the % number till the next levelup. - NOT remove any existing skill tables in the database update scripts. + There is no way to move them into the attribute table in a unified way (there are too many different way they could have been used). So server admins have to care about moving theirs skills to attributes themselves. + Keeping the old tables does not hurt for existing databases. So removing does not give any advantage/is required anyway. The now obsolote info about the EXP transaction is not removed for updated databases either. (The update script basically only bumps the version number without doing anything else. - bump the network protocol version --> old clients won't be able to connect. - bump the database version --> serveradmins need to update their db.
2013-08-25Use std::unique_ptr for Account instance of AccountClientThorbjørn Lindeijer1-2/+2
Makes cleanup automatic and ownership somewhat better recognizable.
2013-05-02Fixed a bunch of cppcheck warningsErik Schilling1-4/+3
2013-04-27Use nullptr instead of NULL everywhereErik Schilling1-1/+1
2013-04-11Renamed Character -> CharacterData in the accountserverErik Schilling1-4/+5
2013-01-09Replaced 'unsigned int' with 'unsigned'Thorbjørn Lindeijer1-4/+4
Same thing, but shorter.
2012-04-12Fixed issues with server behind routerErik Schilling1-2/+2
Tested-by: jurkan. Reviewed-by: Bertram.
2012-03-16Fixed remaining compiler warningsThorbjørn Lindeijer1-1/+1
These were unused parameters and one return type with an ignored 'const' qualifier. Reviewed-by: Yohann Ferreira
2011-11-01Removed some superfluous new character initializationsThorbjørn Lindeijer1-13/+0
The level, character points and correction points are already initialized by the Character constructor. The ATTR_GP attribute is either not present, or obtained default value from mDefaultAttributes. In both cases it makes no sense to set it to 0. Reviewed-by: Yohann Ferreira
2011-08-10login with random hashStefan Beller1-3/+44
The account server sends out a random number, which is additionally used for hashing the password. Reviewed by Bertram
2011-03-30Fixing selection of a character if lower slots are emptyStefan Dombrowski1-1/+1
This resolves http://bugs.manasource.org/view.php?id=321 Reviewed-by: Jaxad0127, VUT
2011-03-24Rely more on the functionality in XML::DocumentThorbjørn Lindeijer1-9/+2
By default XML::Document will use the ResourceManager to resolve the file name you pass to it. There is no point in disabling that functionality only to resolve it manually. Reviewed-by: Jared Adams
2011-03-20Moved defines.h and manaserv_protocol.h into 'common'Thorbjørn Lindeijer1-1/+1
Just seems a bit more organized to me.
2011-03-20General cleanups and code style fixesThorbjørn Lindeijer1-94/+80
A bunch of variables that were continuously requested from the configuration are now members of the AccountHandler. Reviewed-by: Freeyorp
2011-03-17Micro-optimizations related to std::stringThorbjørn Lindeijer1-4/+5
* Rely on the fact that a std::string is empty by default * Use std::string::empty() rather than comparing to "" * Construct with std::string() rather than from "" Reviewed-by: Bertram
2011-03-15Moved some file-global variables into the AccountHandlerThorbjørn Lindeijer1-42/+40
Nicer as members where there is clear ownership, initialization and scope. Reviewed-by: Freeyorp
2011-03-15Introduced an AttributeValue class for convenience and readabilityThorbjørn Lindeijer1-13/+16
Easier to understand than a std::pair with its 'first' and 'second' members, and it also provides an implicit constructor so that AttributeValue is implicitly constructed from a double. Reviewed-by: Freeyorp
2011-03-14Made the "No game server for map" error message report the map IDPhilipp Sehmisch1-1/+1
(trivial patch)
2011-03-12Removed a bunch of silly documentationThorbjørn Lindeijer1-3/+0
A C++ developer should be able to recognize a constructor and a destructor by just looking at it, so let's stop writing down the obvious. :)
2011-02-11Fix the GP base and mod values for newly created characters.Yohann Ferreira1-0/+11
Reviewed-by: Freeyorp.
2011-01-11Made the servers report their protocol version.Yohann Ferreira1-3/+2
As the protocol version isn't something the maintainers should set, I removed the net_clientVersion irrelevant option, replaced by the corresponding define PROTOCOL_VERSION in the manaserv_protocol.h file. A corresponding change in the client will be made. N.B.: Now, the Enet version is also reported in the log. Reviewed-by: Jaxad.
2011-01-09Removed the superfluous point struct.Yohann Ferreira1-1/+1
It was too close from the Position class and it leads to making the server handle one or another type through the code. Still bugged me many times while making changes. Reviewed-by: Jaxad.
2011-01-03Namespaced the manaserv protocol to ease the porting of the enums.Yohann Ferreira1-0/+2
Trivial.
2010-12-29protocol.h -> manaserv_protocol.h to avoid conflicts with mysql files.Yohann Ferreira1-1/+1
Resolves: Mana-Mantis #278.
2010-12-29Made the server handle properly the characters slots.Yohann Ferreira1-37/+51
I turned the vector storing character data into a map, keeping the character's slot. Fixed a memleak along the way. Reviewed-by: Crush.
2010-12-16Deharcoded the host and port options for each servers.Yohann Ferreira1-4/+12
Changes: ============================================================ For the account server: ------------------------------------------------------------ Old -> New ------------------------------------------------------------ net_accountServerAddress, net_listenHost -> net_accountHost net_accountServerPort -> net_accountListenToClientPort net_accountServerPort +1 -> net_accountListenToGamePort For the game server: ------------------------------------------------------------ Old -> New ------------------------------------------------------------ net_gameServerAddress -> net_gameHost net_gameServerPort -> net_gameListenToClientPort For the chat server: ------------------------------------------------------------ Old -> New ------------------------------------------------------------ -> net_chatHost net_accountServerPort + 2 -> net_chatListenToClientPort Special fallback feature, as requested by Freeyorp: When the net_accountListenToClientPort (default to 9601) is set, the 3 others ports will automatically offset from it, if they're not set, following this rule: net_accountListenToGamePort = net_accountListenToClientPort + 1 net_chatListenToClientPort = net_accountListenToClientPort + 2 net_gameListenToClientPort = net_accountListenToClientPort + 3 Resolves: Mana-Mantis #216. Reviewed-by: Jaxad0127.
2010-12-08Fix many compiler warnings.Freeyorp1-1/+1
Reviewed-by: Bertram
2010-11-18Made the server return the number of slots in the login/register responses.Yohann Ferreira1-3/+14
Reviewed-by: CodyMartin.
2010-11-14Renamed .hpp files into .h for consistency.Yohann Ferreira1-18/+18
Also added an header to the autoattack.{h,cpp} files. Big but trivial fix.
2010-11-09Fixed unregistering on the server-side.Yohann Ferreira1-3/+4
When registering or logging, The client is hashing the password for sending it safely. And the server is hashing it also to store it the same way. Hence, the password ends hashed twice, which is correct because the server can't trust the client anyway. At unregister attempt, the server wasn't hashing the password before comparing it. Also while on it, I made the corresponding SQL query use the try catch method and only delete the account in memory when it's also done on the Db. Reviewed-by: thorbjorn, Freeyorp.
2010-11-03Renamed write{Byte,Short,Long} to writeInt{8,16,32}Thorbjørn Lindeijer1-83/+83
Mainly for consistency with the client, and the general consensus was that these numbered versions were clearer.
2010-10-26Send a client data URL in addition to the update hostThorbjørn Lindeijer1-0/+7
This is for developing/testing an experimental new resource manager that downloads only the files it needs on demand. Currently only used by the Mana Mobile project. Regular Mana client ignores the setting. Reviewed-by: Jared Adams
2010-09-22Centralized the servers' exit values.Yohann Ferreira1-11/+11
Also made random code format clean-ups. Resolves: Mana-Mantis #217 Reviewed-by: Jaxad0127.