a0781ef377342d2c7d611916bac3d3e7d0c30fa6
[oweals/minetest.git] / src / client / clientlauncher.cpp
1 /*
2 Minetest
3 Copyright (C) 2010-2013 celeron55, Perttu Ahola <celeron55@gmail.com>
4
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation; either version 2.1 of the License, or
8 (at your option) any later version.
9
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 GNU Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
20 #include "mainmenumanager.h"
21 #include "debug.h"
22 #include "clouds.h"
23 #include "server.h"
24 #include "filesys.h"
25 #include "guiMainMenu.h"
26 #include "game.h"
27 #include "chat.h"
28 #include "gettext.h"
29 #include "profiler.h"
30 #include "log.h"
31 #include "serverlist.h"
32 #include "guiEngine.h"
33 #include "player.h"
34 #include "fontengine.h"
35 #include "joystick_controller.h"
36 #include "clientlauncher.h"
37 #include "version.h"
38
39 /* mainmenumanager.h
40  */
41 gui::IGUIEnvironment *guienv = NULL;
42 gui::IGUIStaticText *guiroot = NULL;
43 MainMenuManager g_menumgr;
44
45 bool noMenuActive()
46 {
47         return g_menumgr.menuCount() == 0;
48 }
49
50 // Passed to menus to allow disconnecting and exiting
51 MainGameCallback *g_gamecallback = NULL;
52
53
54 // Instance of the time getter
55 static TimeGetter *g_timegetter = NULL;
56
57 u32 getTimeMs()
58 {
59         if (g_timegetter == NULL)
60                 return 0;
61         return g_timegetter->getTime(PRECISION_MILLI);
62 }
63
64 u32 getTime(TimePrecision prec) {
65         if (g_timegetter == NULL)
66                 return 0;
67         return g_timegetter->getTime(prec);
68 }
69
70 ClientLauncher::~ClientLauncher()
71 {
72         if (receiver)
73                 delete receiver;
74
75         if (input)
76                 delete input;
77
78         if (g_fontengine)
79                 delete g_fontengine;
80
81         if (device)
82                 device->drop();
83 }
84
85
86 bool ClientLauncher::run(GameParams &game_params, const Settings &cmd_args)
87 {
88         init_args(game_params, cmd_args);
89
90         // List video modes if requested
91         if (list_video_modes)
92                 return print_video_modes();
93
94         if (!init_engine()) {
95                 errorstream << "Could not initialize game engine." << std::endl;
96                 return false;
97         }
98
99         // Create time getter
100         g_timegetter = new IrrlichtTimeGetter(device);
101
102         // Speed tests (done after irrlicht is loaded to get timer)
103         if (cmd_args.getFlag("speedtests")) {
104                 dstream << "Running speed tests" << std::endl;
105                 speed_tests();
106                 return true;
107         }
108
109         video::IVideoDriver *video_driver = device->getVideoDriver();
110         if (video_driver == NULL) {
111                 errorstream << "Could not initialize video driver." << std::endl;
112                 return false;
113         }
114
115         porting::setXorgClassHint(video_driver->getExposedVideoData(), PROJECT_NAME_C);
116
117         /*
118                 This changes the minimum allowed number of vertices in a VBO.
119                 Default is 500.
120         */
121         //driver->setMinHardwareBufferVertexCount(50);
122
123         // Create game callback for menus
124         g_gamecallback = new MainGameCallback(device);
125
126         device->setResizable(true);
127
128         if (random_input)
129                 input = new RandomInputHandler();
130         else
131                 input = new RealInputHandler(device, receiver);
132
133         smgr = device->getSceneManager();
134         smgr->getParameters()->setAttribute(scene::ALLOW_ZWRITE_ON_TRANSPARENT, true);
135
136         guienv = device->getGUIEnvironment();
137         skin = guienv->getSkin();
138         skin->setColor(gui::EGDC_BUTTON_TEXT, video::SColor(255, 255, 255, 255));
139         skin->setColor(gui::EGDC_3D_LIGHT, video::SColor(0, 0, 0, 0));
140         skin->setColor(gui::EGDC_3D_HIGH_LIGHT, video::SColor(255, 30, 30, 30));
141         skin->setColor(gui::EGDC_3D_SHADOW, video::SColor(255, 0, 0, 0));
142         skin->setColor(gui::EGDC_HIGH_LIGHT, video::SColor(255, 70, 120, 50));
143         skin->setColor(gui::EGDC_HIGH_LIGHT_TEXT, video::SColor(255, 255, 255, 255));
144
145         g_fontengine = new FontEngine(g_settings, guienv);
146         FATAL_ERROR_IF(g_fontengine == NULL, "Font engine creation failed.");
147
148 #if (IRRLICHT_VERSION_MAJOR >= 1 && IRRLICHT_VERSION_MINOR >= 8) || IRRLICHT_VERSION_MAJOR >= 2
149         // Irrlicht 1.8 input colours
150         skin->setColor(gui::EGDC_EDITABLE, video::SColor(255, 128, 128, 128));
151         skin->setColor(gui::EGDC_FOCUSED_EDITABLE, video::SColor(255, 96, 134, 49));
152 #endif
153
154         // Create the menu clouds
155         if (!g_menucloudsmgr)
156                 g_menucloudsmgr = smgr->createNewSceneManager();
157         if (!g_menuclouds)
158                 g_menuclouds = new Clouds(g_menucloudsmgr->getRootSceneNode(),
159                                 g_menucloudsmgr, -1, rand(), 100);
160         g_menuclouds->update(v2f(0, 0), video::SColor(255, 200, 200, 255));
161         scene::ICameraSceneNode* camera;
162         camera = g_menucloudsmgr->addCameraSceneNode(0,
163                                 v3f(0, 0, 0), v3f(0, 60, 100));
164         camera->setFarValue(10000);
165
166         /*
167                 GUI stuff
168         */
169
170         ChatBackend chat_backend;
171
172         // If an error occurs, this is set to something by menu().
173         // It is then displayed before the menu shows on the next call to menu()
174         std::string error_message;
175         bool reconnect_requested = false;
176
177         bool first_loop = true;
178
179         /*
180                 Menu-game loop
181         */
182         bool retval = true;
183         bool *kill = porting::signal_handler_killstatus();
184
185         while (device->run() && !*kill && !g_gamecallback->shutdown_requested)
186         {
187                 // Set the window caption
188                 const wchar_t *text = wgettext("Main Menu");
189                 device->setWindowCaption((utf8_to_wide(PROJECT_NAME_C) +
190                         L" " + utf8_to_wide(g_version_hash) +
191                         L" [" + text + L"]").c_str());
192                 delete[] text;
193
194                 try {   // This is used for catching disconnects
195
196                         guienv->clear();
197
198                         /*
199                                 We need some kind of a root node to be able to add
200                                 custom gui elements directly on the screen.
201                                 Otherwise they won't be automatically drawn.
202                         */
203                         guiroot = guienv->addStaticText(L"", core::rect<s32>(0, 0, 10000, 10000));
204
205                         bool game_has_run = launch_game(error_message, reconnect_requested,
206                                 game_params, cmd_args);
207
208                         // Reset the reconnect_requested flag
209                         reconnect_requested = false;
210
211                         // If skip_main_menu, we only want to startup once
212                         if (skip_main_menu && !first_loop)
213                                 break;
214
215                         first_loop = false;
216
217                         if (!game_has_run) {
218                                 if (skip_main_menu)
219                                         break;
220                                 else
221                                         continue;
222                         }
223
224                         // Break out of menu-game loop to shut down cleanly
225                         if (!device->run() || *kill) {
226                                 if (g_settings_path != "")
227                                         g_settings->updateConfigFile(g_settings_path.c_str());
228                                 break;
229                         }
230
231                         if (current_playername.length() > PLAYERNAME_SIZE-1) {
232                                 error_message = gettext("Player name too long.");
233                                 playername = current_playername.substr(0, PLAYERNAME_SIZE-1);
234                                 g_settings->set("name", playername);
235                                 continue;
236                         }
237
238                         device->getVideoDriver()->setTextureCreationFlag(
239                                         video::ETCF_CREATE_MIP_MAPS, g_settings->getBool("mip_map"));
240
241 #ifdef HAVE_TOUCHSCREENGUI
242                         receiver->m_touchscreengui = new TouchScreenGUI(device, receiver);
243                         g_touchscreengui = receiver->m_touchscreengui;
244 #endif
245
246                         the_game(
247                                 kill,
248                                 random_input,
249                                 input,
250                                 device,
251                                 worldspec.path,
252                                 current_playername,
253                                 current_password,
254                                 current_address,
255                                 current_port,
256                                 error_message,
257                                 chat_backend,
258                                 &reconnect_requested,
259                                 gamespec,
260                                 simple_singleplayer_mode
261                         );
262                         smgr->clear();
263
264 #ifdef HAVE_TOUCHSCREENGUI
265                         delete g_touchscreengui;
266                         g_touchscreengui = NULL;
267                         receiver->m_touchscreengui = NULL;
268 #endif
269
270                 } //try
271                 catch (con::PeerNotFoundException &e) {
272                         error_message = gettext("Connection error (timed out?)");
273                         errorstream << error_message << std::endl;
274                 }
275
276 #ifdef NDEBUG
277                 catch (std::exception &e) {
278                         std::string error_message = "Some exception: \"";
279                         error_message += e.what();
280                         error_message += "\"";
281                         errorstream << error_message << std::endl;
282                 }
283 #endif
284
285                 // If no main menu, show error and exit
286                 if (skip_main_menu) {
287                         if (!error_message.empty()) {
288                                 verbosestream << "error_message = "
289                                               << error_message << std::endl;
290                                 retval = false;
291                         }
292                         break;
293                 }
294         } // Menu-game loop
295
296         g_menuclouds->drop();
297         g_menucloudsmgr->drop();
298
299         return retval;
300 }
301
302 void ClientLauncher::init_args(GameParams &game_params, const Settings &cmd_args)
303 {
304
305         skip_main_menu = cmd_args.getFlag("go");
306
307         // FIXME: This is confusing (but correct)
308
309         /* If world_path is set then override it unless skipping the main menu using
310          * the --go command line param. Else, give preference to the address
311          * supplied on the command line
312          */
313         address = g_settings->get("address");
314         if (game_params.world_path != "" && !skip_main_menu)
315                 address = "";
316         else if (cmd_args.exists("address"))
317                 address = cmd_args.get("address");
318
319         playername = g_settings->get("name");
320         if (cmd_args.exists("name"))
321                 playername = cmd_args.get("name");
322
323         list_video_modes = cmd_args.getFlag("videomodes");
324
325         use_freetype = g_settings->getBool("freetype");
326
327         random_input = g_settings->getBool("random_input")
328                         || cmd_args.getFlag("random-input");
329 }
330
331 bool ClientLauncher::init_engine()
332 {
333         receiver = new MyEventReceiver();
334         create_engine_device();
335         return device != NULL;
336 }
337
338 bool ClientLauncher::launch_game(std::string &error_message,
339                 bool reconnect_requested, GameParams &game_params,
340                 const Settings &cmd_args)
341 {
342         // Initialize menu data
343         MainMenuData menudata;
344         menudata.address                         = address;
345         menudata.name                            = playername;
346         menudata.password                        = password;
347         menudata.port                            = itos(game_params.socket_port);
348         menudata.script_data.errormessage        = error_message;
349         menudata.script_data.reconnect_requested = reconnect_requested;
350
351         error_message.clear();
352
353         if (cmd_args.exists("password"))
354                 menudata.password = cmd_args.get("password");
355
356         menudata.enable_public = g_settings->getBool("server_announce");
357
358         // If a world was commanded, append and select it
359         if (game_params.world_path != "") {
360                 worldspec.gameid = getWorldGameId(game_params.world_path, true);
361                 worldspec.name = _("[--world parameter]");
362
363                 if (worldspec.gameid == "") {   // Create new
364                         worldspec.gameid = g_settings->get("default_game");
365                         worldspec.name += " [new]";
366                 }
367                 worldspec.path = game_params.world_path;
368         }
369
370         /* Show the GUI menu
371          */
372         if (!skip_main_menu) {
373                 main_menu(&menudata);
374
375                 // Skip further loading if there was an exit signal.
376                 if (*porting::signal_handler_killstatus())
377                         return false;
378
379                 address = menudata.address;
380                 int newport = stoi(menudata.port);
381                 if (newport != 0)
382                         game_params.socket_port = newport;
383
384                 simple_singleplayer_mode = menudata.simple_singleplayer_mode;
385
386                 std::vector<WorldSpec> worldspecs = getAvailableWorlds();
387
388                 if (menudata.selected_world >= 0
389                                 && menudata.selected_world < (int)worldspecs.size()) {
390                         g_settings->set("selected_world_path",
391                                         worldspecs[menudata.selected_world].path);
392                         worldspec = worldspecs[menudata.selected_world];
393                 }
394         }
395
396         if (!menudata.script_data.errormessage.empty()) {
397                 /* The calling function will pass this back into this function upon the
398                  * next iteration (if any) causing it to be displayed by the GUI
399                  */
400                 error_message = menudata.script_data.errormessage;
401                 return false;
402         }
403
404         if (menudata.name == "")
405                 menudata.name = std::string("Guest") + itos(myrand_range(1000, 9999));
406         else
407                 playername = menudata.name;
408
409         password = menudata.password;
410
411         g_settings->set("name", playername);
412
413         current_playername = playername;
414         current_password   = password;
415         current_address    = address;
416         current_port       = game_params.socket_port;
417
418         // If using simple singleplayer mode, override
419         if (simple_singleplayer_mode) {
420                 assert(skip_main_menu == false);
421                 current_playername = "singleplayer";
422                 current_password = "";
423                 current_address = "";
424                 current_port = myrand_range(49152, 65535);
425         } else if (address != "") {
426                 ServerListSpec server;
427                 server["name"] = menudata.servername;
428                 server["address"] = menudata.address;
429                 server["port"] = menudata.port;
430                 server["description"] = menudata.serverdescription;
431                 ServerList::insert(server);
432         }
433
434         infostream << "Selected world: " << worldspec.name
435                    << " [" << worldspec.path << "]" << std::endl;
436
437         if (current_address == "") { // If local game
438                 if (worldspec.path == "") {
439                         error_message = gettext("No world selected and no address "
440                                         "provided. Nothing to do.");
441                         errorstream << error_message << std::endl;
442                         return false;
443                 }
444
445                 if (!fs::PathExists(worldspec.path)) {
446                         error_message = gettext("Provided world path doesn't exist: ")
447                                         + worldspec.path;
448                         errorstream << error_message << std::endl;
449                         return false;
450                 }
451
452                 // Load gamespec for required game
453                 gamespec = findWorldSubgame(worldspec.path);
454                 if (!gamespec.isValid() && !game_params.game_spec.isValid()) {
455                         error_message = gettext("Could not find or load game \"")
456                                         + worldspec.gameid + "\"";
457                         errorstream << error_message << std::endl;
458                         return false;
459                 }
460
461                 if (porting::signal_handler_killstatus())
462                         return true;
463
464                 if (game_params.game_spec.isValid() &&
465                                 game_params.game_spec.id != worldspec.gameid) {
466                         warningstream << "Overriding gamespec from \""
467                                     << worldspec.gameid << "\" to \""
468                                     << game_params.game_spec.id << "\"" << std::endl;
469                         gamespec = game_params.game_spec;
470                 }
471
472                 if (!gamespec.isValid()) {
473                         error_message = gettext("Invalid gamespec.");
474                         error_message += " (world.gameid=" + worldspec.gameid + ")";
475                         errorstream << error_message << std::endl;
476                         return false;
477                 }
478         }
479
480         return true;
481 }
482
483 void ClientLauncher::main_menu(MainMenuData *menudata)
484 {
485         bool *kill = porting::signal_handler_killstatus();
486         video::IVideoDriver *driver = device->getVideoDriver();
487
488         infostream << "Waiting for other menus" << std::endl;
489         while (device->run() && *kill == false) {
490                 if (noMenuActive())
491                         break;
492                 driver->beginScene(true, true, video::SColor(255, 128, 128, 128));
493                 guienv->drawAll();
494                 driver->endScene();
495                 // On some computers framerate doesn't seem to be automatically limited
496                 sleep_ms(25);
497         }
498         infostream << "Waited for other menus" << std::endl;
499
500         // Cursor can be non-visible when coming from the game
501 #ifndef ANDROID
502         device->getCursorControl()->setVisible(true);
503 #endif
504
505         /* show main menu */
506         GUIEngine mymenu(device, &input->joystick, guiroot,
507                 &g_menumgr, smgr, menudata, *kill);
508
509         smgr->clear();  /* leave scene manager in a clean state */
510 }
511
512 bool ClientLauncher::create_engine_device()
513 {
514         // Resolution selection
515         bool fullscreen = g_settings->getBool("fullscreen");
516         u16 screenW = g_settings->getU16("screenW");
517         u16 screenH = g_settings->getU16("screenH");
518
519         // bpp, fsaa, vsync
520         bool vsync = g_settings->getBool("vsync");
521         u16 bits = g_settings->getU16("fullscreen_bpp");
522         u16 fsaa = g_settings->getU16("fsaa");
523
524         // stereo buffer required for pageflip stereo
525         bool stereo_buffer = g_settings->get("3d_mode") == "pageflip";
526
527         // Determine driver
528         video::E_DRIVER_TYPE driverType = video::EDT_OPENGL;
529         std::string driverstring = g_settings->get("video_driver");
530         std::vector<video::E_DRIVER_TYPE> drivers
531                 = porting::getSupportedVideoDrivers();
532         u32 i;
533         for (i = 0; i != drivers.size(); i++) {
534                 if (!strcasecmp(driverstring.c_str(),
535                         porting::getVideoDriverName(drivers[i]))) {
536                         driverType = drivers[i];
537                         break;
538                 }
539         }
540         if (i == drivers.size()) {
541                 errorstream << "Invalid video_driver specified; "
542                         "defaulting to opengl" << std::endl;
543         }
544
545         SIrrlichtCreationParameters params = SIrrlichtCreationParameters();
546         params.DriverType    = driverType;
547         params.WindowSize    = core::dimension2d<u32>(screenW, screenH);
548         params.Bits          = bits;
549         params.AntiAlias     = fsaa;
550         params.Fullscreen    = fullscreen;
551         params.Stencilbuffer = false;
552         params.Stereobuffer  = stereo_buffer;
553         params.Vsync         = vsync;
554         params.EventReceiver = receiver;
555         params.HighPrecisionFPU = g_settings->getBool("high_precision_fpu");
556         params.ZBufferBits   = 24;
557 #ifdef __ANDROID__
558         params.PrivateData = porting::app_global;
559         params.OGLES2ShaderPath = std::string(porting::path_user + DIR_DELIM +
560                         "media" + DIR_DELIM + "Shaders" + DIR_DELIM).c_str();
561 #endif
562
563         device = createDeviceEx(params);
564
565         if (device) {
566                 if (g_settings->getBool("enable_joysticks")) {
567                         irr::core::array<irr::SJoystickInfo> infos;
568                         std::vector<irr::SJoystickInfo> joystick_infos;
569                         // Make sure this is called maximum once per
570                         // irrlicht device, otherwise it will give you
571                         // multiple events for the same joystick.
572                         if (device->activateJoysticks(infos)) {
573                                 infostream << "Joystick support enabled" << std::endl;
574                                 joystick_infos.reserve(infos.size());
575                                 for (u32 i = 0; i < infos.size(); i++) {
576                                         joystick_infos.push_back(infos[i]);
577                                 }
578                         } else {
579                                 errorstream << "Could not activate joystick support." << std::endl;
580                         }
581                 }
582                 porting::initIrrlicht(device);
583         }
584
585         return device != NULL;
586 }
587
588 void ClientLauncher::speed_tests()
589 {
590         // volatile to avoid some potential compiler optimisations
591         volatile static s16 temp16;
592         volatile static f32 tempf;
593         static v3f tempv3f1;
594         static v3f tempv3f2;
595         static std::string tempstring;
596         static std::string tempstring2;
597
598         tempv3f1 = v3f();
599         tempv3f2 = v3f();
600         tempstring = std::string();
601         tempstring2 = std::string();
602
603         {
604                 infostream << "The following test should take around 20ms." << std::endl;
605                 TimeTaker timer("Testing std::string speed");
606                 const u32 jj = 10000;
607                 for (u32 j = 0; j < jj; j++) {
608                         tempstring = "";
609                         tempstring2 = "";
610                         const u32 ii = 10;
611                         for (u32 i = 0; i < ii; i++) {
612                                 tempstring2 += "asd";
613                         }
614                         for (u32 i = 0; i < ii+1; i++) {
615                                 tempstring += "asd";
616                                 if (tempstring == tempstring2)
617                                         break;
618                         }
619                 }
620         }
621
622         infostream << "All of the following tests should take around 100ms each."
623                    << std::endl;
624
625         {
626                 TimeTaker timer("Testing floating-point conversion speed");
627                 tempf = 0.001;
628                 for (u32 i = 0; i < 4000000; i++) {
629                         temp16 += tempf;
630                         tempf += 0.001;
631                 }
632         }
633
634         {
635                 TimeTaker timer("Testing floating-point vector speed");
636
637                 tempv3f1 = v3f(1, 2, 3);
638                 tempv3f2 = v3f(4, 5, 6);
639                 for (u32 i = 0; i < 10000000; i++) {
640                         tempf += tempv3f1.dotProduct(tempv3f2);
641                         tempv3f2 += v3f(7, 8, 9);
642                 }
643         }
644
645         {
646                 TimeTaker timer("Testing std::map speed");
647
648                 std::map<v2s16, f32> map1;
649                 tempf = -324;
650                 const s16 ii = 300;
651                 for (s16 y = 0; y < ii; y++) {
652                         for (s16 x = 0; x < ii; x++) {
653                                 map1[v2s16(x, y)] =  tempf;
654                                 tempf += 1;
655                         }
656                 }
657                 for (s16 y = ii - 1; y >= 0; y--) {
658                         for (s16 x = 0; x < ii; x++) {
659                                 tempf = map1[v2s16(x, y)];
660                         }
661                 }
662         }
663
664         {
665                 infostream << "Around 5000/ms should do well here." << std::endl;
666                 TimeTaker timer("Testing mutex speed");
667
668                 Mutex m;
669                 u32 n = 0;
670                 u32 i = 0;
671                 do {
672                         n += 10000;
673                         for (; i < n; i++) {
674                                 m.lock();
675                                 m.unlock();
676                         }
677                 }
678                 // Do at least 10ms
679                 while(timer.getTimerTime() < 10);
680
681                 u32 dtime = timer.stop();
682                 u32 per_ms = n / dtime;
683                 infostream << "Done. " << dtime << "ms, " << per_ms << "/ms" << std::endl;
684         }
685 }
686
687 bool ClientLauncher::print_video_modes()
688 {
689         IrrlichtDevice *nulldevice;
690
691         bool vsync = g_settings->getBool("vsync");
692         u16 fsaa = g_settings->getU16("fsaa");
693         MyEventReceiver* receiver = new MyEventReceiver();
694
695         SIrrlichtCreationParameters params = SIrrlichtCreationParameters();
696         params.DriverType    = video::EDT_NULL;
697         params.WindowSize    = core::dimension2d<u32>(640, 480);
698         params.Bits          = 24;
699         params.AntiAlias     = fsaa;
700         params.Fullscreen    = false;
701         params.Stencilbuffer = false;
702         params.Vsync         = vsync;
703         params.EventReceiver = receiver;
704         params.HighPrecisionFPU = g_settings->getBool("high_precision_fpu");
705
706         nulldevice = createDeviceEx(params);
707
708         if (nulldevice == NULL) {
709                 delete receiver;
710                 return false;
711         }
712
713         std::cout << _("Available video modes (WxHxD):") << std::endl;
714
715         video::IVideoModeList *videomode_list = nulldevice->getVideoModeList();
716
717         if (videomode_list != NULL) {
718                 s32 videomode_count = videomode_list->getVideoModeCount();
719                 core::dimension2d<u32> videomode_res;
720                 s32 videomode_depth;
721                 for (s32 i = 0; i < videomode_count; ++i) {
722                         videomode_res = videomode_list->getVideoModeResolution(i);
723                         videomode_depth = videomode_list->getVideoModeDepth(i);
724                         std::cout << videomode_res.Width << "x" << videomode_res.Height
725                                 << "x" << videomode_depth << std::endl;
726                 }
727
728                 std::cout << _("Active video mode (WxHxD):") << std::endl;
729                 videomode_res = videomode_list->getDesktopResolution();
730                 videomode_depth = videomode_list->getDesktopDepth();
731                 std::cout << videomode_res.Width << "x" << videomode_res.Height
732                         << "x" << videomode_depth << std::endl;
733
734         }
735
736         nulldevice->drop();
737         delete receiver;
738
739         return videomode_list != NULL;
740 }