Fix css style order when using external css files
[ryzomcore.git] / ryzom / client / src / far_tp.h
bloba4c8f77b4ace37a23b6fe94b19e736d15ef5077f
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/>.
17 #ifndef FAR_TP_H
18 #define FAR_TP_H
20 #include "nel/misc/co_task.h"
21 #include <list>
22 #include <string>
23 #include "game_share/security_check.h"
26 class CLoginStateMachine : private NLMISC::CCoTask
29 public:
30 enum TState
32 /// initial state
33 st_start,
34 /// display login screen and options
35 st_login,
36 /// auto login using cmd lien parameters (used with patch reboot)
37 st_auto_login,
38 /// display the shard list
39 st_shard_list,
40 /// lauch the configurator and close ryzom
41 st_start_config,
42 /// run the scan data thread
43 st_scan_data,
44 /// display the eula and wait for validation
45 st_display_eula,
46 /// check the data to determine need for patch
47 st_check_patch,
48 /// display the list of optional patch category for patching
49 st_display_cat,
50 /// run the patch process and display progress
51 st_patch,
52 /// terminate the client and quit
53 st_close_client,
54 /// display the reboot screen and wait validation
55 st_reboot_screen,
56 /// restart the client with login bypass params
57 st_restart_client,
58 /// connect to the FS (start the 'in game' mode)
59 st_connect,
60 /// show the outgame browser
61 st_browser_screen,
62 /// ingame state
63 st_ingame,
64 /// leave the current shard (the exit action progress, Far TP part 1.1; Server Hop part 1-2)
65 st_leave_shard,
66 /// let the main loop finish the current frame and leave it (Far TP part 1.2)
67 st_enter_far_tp_main_loop,
68 /// disconnect from the FS (Far TP part 2)
69 st_disconnect,
70 /// connect to a new FS (Far TP & Server Hop part 3.1)
71 st_reconnect_fs,
72 /// after reconnecting, bypass character selection ui & select the same character (Far TP & Server Hop part 3.2)
73 st_reconnect_select_char,
74 /// after reconnecting and receiving ready, send ready (Far TP part 3.3)
75 st_reconnect_ready,
76 /// between global menu exit and sending ready (Server Hop part 3.3)
77 st_exit_global_menu,
78 /// error while reconnecting
79 st_reconnect_error,
80 /// Rate a ring session. should pop a web windows pointing the rate session page
81 st_rate_session,
82 /// create account
83 st_create_account,
84 /// try to login with alternate login system
85 st_alt_login,
86 /// pseudo state to leave the state machine
87 st_end,
88 ///
89 st_unknown
92 /// For displaying
93 static const std::string& toString(TState state);
95 enum TEvent
97 /// the client click the 'quit' button
98 ev_quit,
99 /// the client is connecting without authentication (dev mode)
100 ev_skip_all_login,
101 /// the init is done
102 ev_init_done,
103 /// the client push the 'config' button
104 ev_game_conf,
105 /// the client push the 'scan data' button
106 ev_data_scan,
107 /// the client push the 'scan data' button
108 ev_close_data_scan,
109 /// the login is validated and cookie is received
110 ev_login_ok,
111 /// the login check as failed
112 ev_bad_login,
113 /// the client has selected a shard
114 ev_shard_selected,
115 /// the patch checker says we need to ev_patch_needed
116 ev_patch_needed,
117 /// the patch check says we are clean, no patch needed
118 ev_no_patch,
119 /// the user validate the category screen, patch can begin
120 ev_run_patch,
121 /// the client validate the patch result
122 ev_close_patch,
123 /// Client accept the eula screen
124 ev_accept_eula,
125 /// Client decline the eula screen
126 ev_decline_eula,
127 /// the client valide the reboot message box
128 ev_reboot,
129 /// the ingame session terminates (CONNECTION:SERVER_QUIT_OK msg)
130 ev_ingame_return,
131 /// the far tp main loop is entered
132 ev_far_tp_main_loop_entered,
133 /// the lua script (from web usually) starts the client connection to a shard
134 ev_connect,
135 /// the connection fail for some reason
136 ev_conn_failed,
137 /// the connection was dropped by the server
138 ev_conn_dropped,
139 /// the client enters the game main loop
140 ev_enter_game,
141 // a self reconnetion is complete, get back to outgame menu
142 ev_self_reconnected,
143 /// characters received (CONNECTION:USER_CHARS msg)
144 ev_chars_received,
145 /// characters received but empty (CONNECTION:NO_USER_CHAR msg)
146 ev_no_user_char,
147 /// ready received (CONNECTION:READY msg)
148 ev_ready_received,
149 /// reselect character (CONNECTION:RECO
150 // ev_reselect_char,
151 /// reconnect ok received (CONNECTION:SERVER_RECONNECT_OK msg)
152 ev_reconnect_ok_received,
153 /// global menu exited
154 ev_global_menu_exited,
155 /// The client click the 'relog' button
156 ev_relog,
157 /// the client push the 'create account' button
158 ev_create_account,
159 /// the client push the 'create account' button
160 ev_close_create_account,
161 /// the client want to use alternate login system
162 ev_login_not_alt,
164 ev_unknown
167 /// For displaying
168 static const std::string& toString(TEvent event);
171 private:
172 TState _CurrentState;
173 std::list<TEvent> _NextEvents;
174 public:
176 // Create the state machine with the wanted start.
177 // Note that, because it is a co-task, restarting the state machine after it has finished
178 // require to delete then recreate this object
179 CLoginStateMachine() :
180 _CurrentState(st_start)
185 TState getCurrentState()
187 return _CurrentState;
190 void pushEvent(TEvent eventId);
192 TEvent waitEvent();
195 private:
197 void run();
200 extern CLoginStateMachine LoginSM;
202 void initLoginScreen();
203 void initShardDisplay();
204 void initDataScan();
205 bool initCreateAccount();
206 void initEula();
207 void initPatchCheck();
208 void initCatDisplay();
209 void initAutoLogin();
210 void initAltLogin();
211 void initPatch();
212 //void initWebBrowser();
213 void initReboot();
215 void ConnectToShard();
217 void waitForUserCharReceived();
222 class CFarTP
224 public:
226 // See definition of _URLTable for url binding
227 enum TJoinMode
229 LaunchEditor,
230 JoinSession,
231 JoinMainland,
232 NbJoinModes
235 CFarTP() : _Reason(NULL), _SessionIdToJoinFast(0), _InGameMode(false), _PreviousR2EdEnabled(false), _ReselectingChar(false), _IsServerHopEmbedded(false), _HookedForEditor(false), _DSSDown(false) /*, _SelfReconnecting(false)*/ {}
237 // Get the address of a front-end service via http, then begin Far TP
238 bool requestFarTPToSession(TSessionId sessionId, uint8 charSlot, CFarTP::TJoinMode joinMode, bool bailOutIfSessionVanished);
240 // Ask the EGS to pop the top position if applicable
241 void requestReturnToPreviousSession(TSessionId rejectedSessionId=TSessionId(0));
243 // Store the result of a JoinSession request for the next disconnection request
244 void setJoinSessionResult(TSessionId sessionId, const CSecurityCode& securityCode);
246 // Tell to ignore the next Far TP request, it will be replaced by a Far TP to the edition session (allows to shortcut anim-mainland-edition by anim-edition)
247 void hookNextFarTPForEditor();
249 /// Begin a Character Reselect sequence
250 void requestReconnection();
252 // These states can overlap
253 bool isIngame() const { return _InGameMode; }
254 bool isFarTPInProgress() const;
255 bool isServerHopInProgress() const;
256 bool isLeavingEGS() const { return (LoginSM.getCurrentState() == CLoginStateMachine::st_leave_shard); }
257 bool isLeavingShard() const; // from begin of Far TP to disconnection
258 bool isJoiningShard() const; // from reconnection to game entering
259 bool isReselectingChar() const { return _ReselectingChar; }
260 bool isServerHopEmbedded() const { return _IsServerHopEmbedded; }
261 bool isFastDisconnectGranted() const { return _SessionIdToJoinFast != 0; }
263 // Far TP from the main loop
264 void farTPmainLoop();
265 void writeSecurityCodeForDisconnection(NLMISC::IStream& msgout);
266 void onServerQuitOk();
267 void onServerQuitAbort();
268 void disconnectFromPreviousShard();
269 void connectToNewShard();
270 bool reselectCharacter();
271 void selectCharAndEnter();
272 void sendReady();
273 void onFailure();
274 void onDssDown(bool forceReturn=false);
276 void setIngame() { _InGameMode = true; }
277 void setOutgame() { _InGameMode = false; }
278 void setMainLoopEntered() { setIngame(); _ReselectingChar = false; }
279 void beginEmbeddedServerHop() { _IsServerHopEmbedded = true; setOutgame(); _ReselectingChar = false; }
280 void endEmbeddedServerHop() { _IsServerHopEmbedded = false; setIngame(); _ReselectingChar = true; }
282 void setURLBase(const std::string& urlBase) { _URLBase = urlBase; }
284 private:
286 // called back from session browser after a far tp request
287 void joinSessionResult(uint32 userId, TSessionId sessionId, uint32 result, const std::string &shardAddr, const std::string &participantStatus);
290 std::string *_Reason;
292 static const char *_URLTable[NbJoinModes];
294 std::string _URLBase;
296 TSessionId _SessionIdToJoinFast; // if non 0, fast disconnection allowed to session
297 CSecurityCode _SecurityCodeForDisconnection;
299 bool _InGameMode; // formerly known as EnterWorld
300 bool _PreviousR2EdEnabled;
301 bool _ReselectingChar;
302 bool _IsServerHopEmbedded; // allows to embed a server hop inside a char reselect (e.g. click on Launch Editor of PLAY with a character on a remote shard)
303 bool _HookedForEditor; // allows to Far TP to editor instead of following the next Far TP request
304 bool _DSSDown; // remembers a DSSDown event if occurs during a FarTP
305 // bool _SelfReconnecting; // allows to disconnect after character selection and reconnect until the player can choose another character
309 extern CFarTP FarTP;
311 #endif // FAR_TP_H