Merge branch 'fixes' into main/rendor-staging
[ryzomcore.git] / ryzom / common / src / game_share / action_login.h
blobc55fc8d76ee1d7ecaad8184c814f277d17c558ff
1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Affero General Public License as
6 // published by the Free Software Foundation, either version 3 of the
7 // License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Affero General Public License for more details.
14 // You should have received a copy of the GNU Affero General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
19 #ifndef NL_ACTION_LOGIN_H
20 #define NL_ACTION_LOGIN_H
22 #include "nel/misc/types_nl.h"
24 #include "nel/net/login_cookie.h"
26 #include "action.h"
29 namespace CLFECOMMON {
31 /**
32 * This action means the entity Id has left the game.
33 * Note: No more data or processing than in CAction.
34 * \author Olivier Cado
35 * \author Nevrax France
36 * \date 2001
38 class CActionLogin: public CAction
40 public:
42 /** This function creates initializes its fields using the buffer.
43 * \param buffer pointer to the buffer where the data are
44 * \size size of the buffer
46 virtual void unpack (NLMISC::CBitMemStream &message)
48 uint32 ua, uk, ui;
49 message.serial (ua);
50 message.serial (uk);
51 message.serial (ui);
52 Cookie.set (ua, uk, ui);
55 /** Returns the size of this action when it will be send to the UDP connection:
56 * the size is IN BITS, not in bytes (the actual size is this one plus the header size)
58 virtual uint32 size () { return 3*32; }
60 static CAction *create () { return new CActionLogin(); }
62 void setCookie (NLNET::CLoginCookie &lc)
64 Cookie = lc;
67 const NLNET::CLoginCookie &getCookie () const { return Cookie; }
69 protected:
71 NLNET::CLoginCookie Cookie;
73 /** This function transform the internal field and transform them into a buffer for the UDP connection.
74 * \param buffer pointer to the buffer where the data will be written
75 * \size size of the buffer
77 virtual void pack (NLMISC::CBitMemStream &message)
79 uint32 ua, uk, ui;
80 if (Cookie.isValid ())
82 ua = Cookie.getUserAddr ();
83 uk = Cookie.getUserKey ();
84 ui = Cookie.getUserId ();
86 // if not valid, serialize dummy things
87 message.serial (ua);
88 message.serial (uk);
89 message.serial (ui);
92 virtual void reset()
94 Cookie.clear ();
97 friend class CActionFactory;
103 #endif // NL_ACTION_LOGIN_H
105 /* End of action_login.h */