3 Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
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.
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.
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.
24 #include "client/renderingengine.h"
27 #include "client/clientevent.h"
28 //#include "client/gameui.h"
29 #include "client/inputhandler.h"
30 #include "client/sound.h"
31 #include "client/tile.h" // For TextureSource
32 #include "client/keys.h"
33 #include "client/joystick_controller.h"
34 #include "clientmap.h"
37 #include "content_cao.h"
38 #include "client/event_manager.h"
39 #include "fontengine.h"
44 #include "gui/cheatMenu.h"
45 #include "gui/guiChatConsole.h"
46 #include "gui/guiConfirmRegistration.h"
47 #include "gui/guiFormSpecMenu.h"
48 #include "gui/guiKeyChangeMenu.h"
49 #include "gui/guiPasswordChange.h"
50 #include "gui/guiVolumeChange.h"
51 #include "gui/mainmenumanager.h"
52 #include "gui/profilergraph.h"
55 #include "nodedef.h" // Needed for determining pointing to nodes
56 #include "nodemetadata.h"
57 #include "particles.h"
65 #include "translation.h"
66 #include "util/basic_macros.h"
67 #include "util/directiontables.h"
68 #include "util/pointedthing.h"
69 #include "util/quicktune_shortcutter.h"
70 #include "irrlicht_changes/static_text.h"
73 #include "script/scripting_client.h"
75 #include "irrlichttypes.h"
80 class RenderingEngine;
85 f32 max, min, avg, counter, max_sample, min_sample, max_fraction;
91 Jitter dtime_jitter, busy_time_jitter;
94 struct CameraOrientation {
95 f32 camera_yaw; // "right/left"
96 f32 camera_pitch; // "up/down"
103 struct TextDestNodeMetadata : public TextDest
105 TextDestNodeMetadata(v3s16 p, Client *client)
110 // This is deprecated I guess? -celeron55
111 void gotText(const std::wstring &text)
113 std::string ntext = wide_to_utf8(text);
114 infostream << "Submitting 'text' field of node at (" << m_p.X << ","
115 << m_p.Y << "," << m_p.Z << "): " << ntext << std::endl;
117 fields["text"] = ntext;
118 m_client->sendNodemetaFields(m_p, "", fields);
120 void gotText(const StringMap &fields)
122 m_client->sendNodemetaFields(m_p, "", fields);
129 struct TextDestPlayerInventory : public TextDest
131 TextDestPlayerInventory(Client *client)
136 TextDestPlayerInventory(Client *client, const std::string &formname)
139 m_formname = formname;
141 void gotText(const StringMap &fields)
143 m_client->sendInventoryFields(m_formname, fields);
149 struct LocalFormspecHandler : public TextDest
151 LocalFormspecHandler(const std::string &formname)
153 m_formname = formname;
156 LocalFormspecHandler(const std::string &formname, Client *client):
159 m_formname = formname;
162 void gotText(const StringMap &fields)
164 if (m_formname == "MT_PAUSE_MENU") {
165 if (fields.find("btn_sound") != fields.end()) {
166 g_gamecallback->changeVolume();
170 if (fields.find("btn_key_config") != fields.end()) {
171 g_gamecallback->keyConfig();
175 if (fields.find("btn_exit_menu") != fields.end()) {
176 g_gamecallback->disconnect();
180 if (fields.find("btn_exit_os") != fields.end()) {
181 g_gamecallback->exitToOS();
183 RenderingEngine::get_raw_device()->closeDevice();
188 if (fields.find("btn_change_password") != fields.end()) {
189 g_gamecallback->changePassword();
196 if (m_formname == "MT_DEATH_SCREEN") {
197 assert(m_client != 0);
198 m_client->sendRespawn();
202 if (m_client->modsLoaded())
203 m_client->getScript()->on_formspec_input(m_formname, fields);
206 Client *m_client = nullptr;
209 /* Form update callback */
211 class NodeMetadataFormSource: public IFormSource
214 NodeMetadataFormSource(ClientMap *map, v3s16 p):
219 const std::string &getForm() const
221 static const std::string empty_string = "";
222 NodeMetadata *meta = m_map->getNodeMetadata(m_p);
227 return meta->getString("formspec");
230 virtual std::string resolveText(const std::string &str)
232 NodeMetadata *meta = m_map->getNodeMetadata(m_p);
237 return meta->resolveString(str);
244 class PlayerInventoryFormSource: public IFormSource
247 PlayerInventoryFormSource(Client *client):
252 const std::string &getForm() const
254 LocalPlayer *player = m_client->getEnv().getLocalPlayer();
255 return player->inventory_formspec;
261 class NodeDugEvent: public MtEvent
267 NodeDugEvent(v3s16 p, MapNode n):
271 MtEvent::Type getType() const
273 return MtEvent::NODE_DUG;
279 ISoundManager *m_sound;
280 const NodeDefManager *m_ndef;
282 bool makes_footstep_sound;
283 float m_player_step_timer;
284 float m_player_jump_timer;
286 SimpleSoundSpec m_player_step_sound;
287 SimpleSoundSpec m_player_leftpunch_sound;
288 SimpleSoundSpec m_player_rightpunch_sound;
290 SoundMaker(ISoundManager *sound, const NodeDefManager *ndef):
293 makes_footstep_sound(true),
294 m_player_step_timer(0.0f),
295 m_player_jump_timer(0.0f)
299 void playPlayerStep()
301 if (m_player_step_timer <= 0 && m_player_step_sound.exists()) {
302 m_player_step_timer = 0.03;
303 if (makes_footstep_sound)
304 m_sound->playSound(m_player_step_sound, false);
308 void playPlayerJump()
310 if (m_player_jump_timer <= 0.0f) {
311 m_player_jump_timer = 0.2f;
312 m_sound->playSound(SimpleSoundSpec("player_jump", 0.5f), false);
316 static void viewBobbingStep(MtEvent *e, void *data)
318 SoundMaker *sm = (SoundMaker *)data;
319 sm->playPlayerStep();
322 static void playerRegainGround(MtEvent *e, void *data)
324 SoundMaker *sm = (SoundMaker *)data;
325 sm->playPlayerStep();
328 static void playerJump(MtEvent *e, void *data)
330 SoundMaker *sm = (SoundMaker *)data;
331 sm->playPlayerJump();
334 static void cameraPunchLeft(MtEvent *e, void *data)
336 SoundMaker *sm = (SoundMaker *)data;
337 sm->m_sound->playSound(sm->m_player_leftpunch_sound, false);
340 static void cameraPunchRight(MtEvent *e, void *data)
342 SoundMaker *sm = (SoundMaker *)data;
343 sm->m_sound->playSound(sm->m_player_rightpunch_sound, false);
346 static void nodeDug(MtEvent *e, void *data)
348 SoundMaker *sm = (SoundMaker *)data;
349 NodeDugEvent *nde = (NodeDugEvent *)e;
350 sm->m_sound->playSound(sm->m_ndef->get(nde->n).sound_dug, false);
353 static void playerDamage(MtEvent *e, void *data)
355 SoundMaker *sm = (SoundMaker *)data;
356 sm->m_sound->playSound(SimpleSoundSpec("player_damage", 0.5), false);
359 static void playerFallingDamage(MtEvent *e, void *data)
361 SoundMaker *sm = (SoundMaker *)data;
362 sm->m_sound->playSound(SimpleSoundSpec("player_falling_damage", 0.5), false);
365 void registerReceiver(MtEventManager *mgr)
367 mgr->reg(MtEvent::VIEW_BOBBING_STEP, SoundMaker::viewBobbingStep, this);
368 mgr->reg(MtEvent::PLAYER_REGAIN_GROUND, SoundMaker::playerRegainGround, this);
369 mgr->reg(MtEvent::PLAYER_JUMP, SoundMaker::playerJump, this);
370 mgr->reg(MtEvent::CAMERA_PUNCH_LEFT, SoundMaker::cameraPunchLeft, this);
371 mgr->reg(MtEvent::CAMERA_PUNCH_RIGHT, SoundMaker::cameraPunchRight, this);
372 mgr->reg(MtEvent::NODE_DUG, SoundMaker::nodeDug, this);
373 mgr->reg(MtEvent::PLAYER_DAMAGE, SoundMaker::playerDamage, this);
374 mgr->reg(MtEvent::PLAYER_FALLING_DAMAGE, SoundMaker::playerFallingDamage, this);
377 void step(float dtime)
379 m_player_step_timer -= dtime;
380 m_player_jump_timer -= dtime;
384 // Locally stored sounds don't need to be preloaded because of this
385 class GameOnDemandSoundFetcher: public OnDemandSoundFetcher
387 std::set<std::string> m_fetched;
389 void paths_insert(std::set<std::string> &dst_paths,
390 const std::string &base,
391 const std::string &name)
393 dst_paths.insert(base + DIR_DELIM + "sounds" + DIR_DELIM + name + ".ogg");
394 dst_paths.insert(base + DIR_DELIM + "sounds" + DIR_DELIM + name + ".0.ogg");
395 dst_paths.insert(base + DIR_DELIM + "sounds" + DIR_DELIM + name + ".1.ogg");
396 dst_paths.insert(base + DIR_DELIM + "sounds" + DIR_DELIM + name + ".2.ogg");
397 dst_paths.insert(base + DIR_DELIM + "sounds" + DIR_DELIM + name + ".3.ogg");
398 dst_paths.insert(base + DIR_DELIM + "sounds" + DIR_DELIM + name + ".4.ogg");
399 dst_paths.insert(base + DIR_DELIM + "sounds" + DIR_DELIM + name + ".5.ogg");
400 dst_paths.insert(base + DIR_DELIM + "sounds" + DIR_DELIM + name + ".6.ogg");
401 dst_paths.insert(base + DIR_DELIM + "sounds" + DIR_DELIM + name + ".7.ogg");
402 dst_paths.insert(base + DIR_DELIM + "sounds" + DIR_DELIM + name + ".8.ogg");
403 dst_paths.insert(base + DIR_DELIM + "sounds" + DIR_DELIM + name + ".9.ogg");
406 void fetchSounds(const std::string &name,
407 std::set<std::string> &dst_paths,
408 std::set<std::string> &dst_datas)
410 if (m_fetched.count(name))
413 m_fetched.insert(name);
415 paths_insert(dst_paths, porting::path_share, name);
416 paths_insert(dst_paths, porting::path_user, name);
421 typedef s32 SamplerLayer_t;
424 class GameGlobalShaderConstantSetter : public IShaderConstantSetter
427 bool *m_force_fog_off;
430 CachedPixelShaderSetting<float, 4> m_sky_bg_color;
431 CachedPixelShaderSetting<float> m_fog_distance;
432 CachedVertexShaderSetting<float> m_animation_timer_vertex;
433 CachedPixelShaderSetting<float> m_animation_timer_pixel;
434 CachedPixelShaderSetting<float, 3> m_day_light;
435 CachedPixelShaderSetting<float, 4> m_star_color;
436 CachedPixelShaderSetting<float, 3> m_eye_position_pixel;
437 CachedVertexShaderSetting<float, 3> m_eye_position_vertex;
438 CachedPixelShaderSetting<float, 3> m_minimap_yaw;
439 CachedPixelShaderSetting<float, 3> m_camera_offset_pixel;
440 CachedPixelShaderSetting<float, 3> m_camera_offset_vertex;
441 CachedPixelShaderSetting<SamplerLayer_t> m_base_texture;
442 CachedPixelShaderSetting<SamplerLayer_t> m_normal_texture;
446 void onSettingsChange(const std::string &name)
448 if (name == "enable_fog")
449 m_fog_enabled = g_settings->getBool("enable_fog");
452 static void settingsCallback(const std::string &name, void *userdata)
454 reinterpret_cast<GameGlobalShaderConstantSetter*>(userdata)->onSettingsChange(name);
457 void setSky(Sky *sky) { m_sky = sky; }
459 GameGlobalShaderConstantSetter(Sky *sky, bool *force_fog_off,
460 f32 *fog_range, Client *client) :
462 m_force_fog_off(force_fog_off),
463 m_fog_range(fog_range),
464 m_sky_bg_color("skyBgColor"),
465 m_fog_distance("fogDistance"),
466 m_animation_timer_vertex("animationTimer"),
467 m_animation_timer_pixel("animationTimer"),
468 m_day_light("dayLight"),
469 m_star_color("starColor"),
470 m_eye_position_pixel("eyePosition"),
471 m_eye_position_vertex("eyePosition"),
472 m_minimap_yaw("yawVec"),
473 m_camera_offset_pixel("cameraOffset"),
474 m_camera_offset_vertex("cameraOffset"),
475 m_base_texture("baseTexture"),
476 m_normal_texture("normalTexture"),
479 g_settings->registerChangedCallback("enable_fog", settingsCallback, this);
480 m_fog_enabled = g_settings->getBool("enable_fog");
483 ~GameGlobalShaderConstantSetter()
485 g_settings->deregisterChangedCallback("enable_fog", settingsCallback, this);
488 void onSetConstants(video::IMaterialRendererServices *services) override
491 video::SColor bgcolor = m_sky->getBgColor();
492 video::SColorf bgcolorf(bgcolor);
493 float bgcolorfa[4] = {
499 m_sky_bg_color.set(bgcolorfa, services);
502 float fog_distance = 10000 * BS;
504 if (m_fog_enabled && !*m_force_fog_off)
505 fog_distance = *m_fog_range;
507 m_fog_distance.set(&fog_distance, services);
509 u32 daynight_ratio = (float)m_client->getEnv().getDayNightRatio();
510 video::SColorf sunlight;
511 get_sunlight_color(&sunlight, daynight_ratio);
516 m_day_light.set(dnc, services);
518 video::SColorf star_color = m_sky->getCurrentStarColor();
519 float clr[4] = {star_color.r, star_color.g, star_color.b, star_color.a};
520 m_star_color.set(clr, services);
522 u32 animation_timer = porting::getTimeMs() % 1000000;
523 float animation_timer_f = (float)animation_timer / 100000.f;
524 m_animation_timer_vertex.set(&animation_timer_f, services);
525 m_animation_timer_pixel.set(&animation_timer_f, services);
527 float eye_position_array[3];
528 v3f epos = m_client->getEnv().getLocalPlayer()->getEyePosition();
529 epos.getAs3Values(eye_position_array);
530 m_eye_position_pixel.set(eye_position_array, services);
531 m_eye_position_vertex.set(eye_position_array, services);
533 if (m_client->getMinimap()) {
534 float minimap_yaw_array[3];
535 v3f minimap_yaw = m_client->getMinimap()->getYawVec();
536 minimap_yaw.getAs3Values(minimap_yaw_array);
537 m_minimap_yaw.set(minimap_yaw_array, services);
540 float camera_offset_array[3];
541 v3f offset = intToFloat(m_client->getCamera()->getOffset(), BS);
542 offset.getAs3Values(camera_offset_array);
543 m_camera_offset_pixel.set(camera_offset_array, services);
544 m_camera_offset_vertex.set(camera_offset_array, services);
546 SamplerLayer_t base_tex = 0, normal_tex = 1;
547 m_base_texture.set(&base_tex, services);
548 m_normal_texture.set(&normal_tex, services);
553 class GameGlobalShaderConstantSetterFactory : public IShaderConstantSetterFactory
556 bool *m_force_fog_off;
559 std::vector<GameGlobalShaderConstantSetter *> created_nosky;
561 GameGlobalShaderConstantSetterFactory(bool *force_fog_off,
562 f32 *fog_range, Client *client) :
564 m_force_fog_off(force_fog_off),
565 m_fog_range(fog_range),
569 void setSky(Sky *sky) {
571 for (GameGlobalShaderConstantSetter *ggscs : created_nosky) {
572 ggscs->setSky(m_sky);
574 created_nosky.clear();
577 virtual IShaderConstantSetter* create()
579 auto *scs = new GameGlobalShaderConstantSetter(
580 m_sky, m_force_fog_off, m_fog_range, m_client);
582 created_nosky.push_back(scs);
588 #define SIZE_TAG "size[11,5.5]"
590 #define SIZE_TAG "size[11,5.5,true]" // Fixed size on desktop
593 /****************************************************************************
594 ****************************************************************************/
596 const float object_hit_delay = 0.2;
599 u32 last_time, busy_time, sleep_time;
603 /* The reason the following structs are not anonymous structs within the
604 * class is that they are not used by the majority of member functions and
605 * many functions that do require objects of thse types do not modify them
606 * (so they can be passed as a const qualified parameter)
612 PointedThing pointed_old;
615 bool btn_down_for_dig;
617 bool digging_blocked;
618 bool reset_jump_timer;
619 float nodig_delay_timer;
621 float dig_time_complete;
622 float repeat_place_timer;
623 float object_hit_delay_timer;
624 float time_from_last_punch;
625 ClientActiveObject *selected_object;
629 float update_draw_list_timer;
633 v3f update_draw_list_last_cam_dir;
635 float time_of_day_smooth;
640 struct ClientEventHandler
642 void (Game::*handler)(ClientEvent *, CameraOrientation *);
645 using PausedNodesList = std::vector<std::pair<irr_ptr<scene::IAnimatedMeshSceneNode>, float>>;
652 bool startup(bool *kill,
654 RenderingEngine *rendering_engine,
655 const GameStartData &game_params,
656 std::string &error_message,
658 ChatBackend *chat_backend);
664 // Basic initialisation
665 bool init(const std::string &map_dir, const std::string &address,
666 u16 port, const SubgameSpec &gamespec);
668 bool createSingleplayerServer(const std::string &map_dir,
669 const SubgameSpec &gamespec, u16 port);
672 bool createClient(const GameStartData &start_data);
676 bool connectToServer(const GameStartData &start_data,
677 bool *connect_ok, bool *aborted);
678 bool getServerContent(bool *aborted);
682 void updateInteractTimers(f32 dtime);
683 bool checkConnection();
684 bool handleCallbacks();
685 void processQueues();
686 void updateProfilers(const RunStats &stats, const FpsControl &draw_times, f32 dtime);
687 void updateDebugState();
688 void updateStats(RunStats *stats, const FpsControl &draw_times, f32 dtime);
689 void updateProfilerGraphs(ProfilerGraph *graph);
692 void processUserInput(f32 dtime);
693 void processKeyInput();
694 void processItemSelection(u16 *new_playeritem);
696 void dropSelectedItem(bool single_item = false);
697 void openInventory();
698 void openEnderchest();
699 void openConsole(float scale, const wchar_t *line=NULL);
700 void toggleFreeMove();
701 void toggleFreeMoveAlt();
702 void togglePitchMove();
705 void toggleKillaura();
706 void toggleFreecam();
707 void toggleScaffold();
708 void toggleNextItem();
709 void toggleCinematic();
710 void toggleBlockBounds();
711 void toggleAutoforward();
713 void toggleMinimap(bool shift_pressed);
716 void toggleUpdateCamera();
717 void updatePlayerCAOVisibility();
719 void increaseViewRange();
720 void decreaseViewRange();
721 void toggleFullViewRange();
722 void checkZoomEnabled();
724 void updateCameraDirection(CameraOrientation *cam, float dtime);
725 void updateCameraOrientation(CameraOrientation *cam, float dtime);
726 void updatePlayerControl(const CameraOrientation &cam);
727 void step(f32 *dtime);
728 void processClientEvents(CameraOrientation *cam);
729 void updateCamera(u32 busy_time, f32 dtime);
730 void updateSound(f32 dtime);
731 void processPlayerInteraction(f32 dtime, bool show_hud, bool show_debug);
733 * Returns the object or node the player is pointing at.
734 * Also updates the selected thing in the Hud.
736 * @param[in] shootline the shootline, starting from
737 * the camera position. This also gives the maximal distance
739 * @param[in] liquids_pointable if false, liquids are ignored
740 * @param[in] look_for_object if false, objects are ignored
741 * @param[in] camera_offset offset of the camera
742 * @param[out] selected_object the selected object or
745 PointedThing updatePointedThing(
746 const core::line3d<f32> &shootline, bool liquids_pointable,
747 bool look_for_object, const v3s16 &camera_offset);
748 void handlePointingAtNothing(const ItemStack &playerItem);
749 void handlePointingAtNode(const PointedThing &pointed,
750 const ItemStack &selected_item, const ItemStack &hand_item, f32 dtime);
751 void handlePointingAtObject(const PointedThing &pointed, const ItemStack &playeritem,
752 const v3f &player_position, bool show_debug);
753 void handleDigging(const PointedThing &pointed, const v3s16 &nodepos,
754 const ItemStack &selected_item, const ItemStack &hand_item, f32 dtime);
755 void updateFrame(ProfilerGraph *graph, RunStats *stats, f32 dtime,
756 const CameraOrientation &cam);
757 void updateShadows();
760 void limitFps(FpsControl *fps_timings, f32 *dtime);
762 void showOverlayMessage(const char *msg, float dtime, int percent,
763 bool draw_clouds = true);
765 static void freecamChangedCallback(const std::string &setting_name, void *data);
766 static void settingChangedCallback(const std::string &setting_name, void *data);
767 static void updateAllMapBlocksCallback(const std::string &setting_name, void *data);
770 bool isKeyDown(GameKeyType k);
771 bool wasKeyDown(GameKeyType k);
772 bool wasKeyPressed(GameKeyType k);
773 bool wasKeyReleased(GameKeyType k);
776 void handleAndroidChatInput();
780 bool force_fog_off = false;
781 bool disable_camera_update = false;
784 void showDeathFormspec();
785 void showPauseMenu();
787 void pauseAnimation();
788 void resumeAnimation();
790 // ClientEvent handlers
791 void handleClientEvent_None(ClientEvent *event, CameraOrientation *cam);
792 void handleClientEvent_PlayerDamage(ClientEvent *event, CameraOrientation *cam);
793 void handleClientEvent_PlayerForceMove(ClientEvent *event, CameraOrientation *cam);
794 void handleClientEvent_Deathscreen(ClientEvent *event, CameraOrientation *cam);
795 void handleClientEvent_ShowFormSpec(ClientEvent *event, CameraOrientation *cam);
796 void handleClientEvent_ShowLocalFormSpec(ClientEvent *event, CameraOrientation *cam);
797 void handleClientEvent_HandleParticleEvent(ClientEvent *event,
798 CameraOrientation *cam);
799 void handleClientEvent_HudAdd(ClientEvent *event, CameraOrientation *cam);
800 void handleClientEvent_HudRemove(ClientEvent *event, CameraOrientation *cam);
801 void handleClientEvent_HudChange(ClientEvent *event, CameraOrientation *cam);
802 void handleClientEvent_SetSky(ClientEvent *event, CameraOrientation *cam);
803 void handleClientEvent_SetSun(ClientEvent *event, CameraOrientation *cam);
804 void handleClientEvent_SetMoon(ClientEvent *event, CameraOrientation *cam);
805 void handleClientEvent_SetStars(ClientEvent *event, CameraOrientation *cam);
806 void handleClientEvent_OverrideDayNigthRatio(ClientEvent *event,
807 CameraOrientation *cam);
808 void handleClientEvent_CloudParams(ClientEvent *event, CameraOrientation *cam);
810 void updateChat(f32 dtime, const v2u32 &screensize);
812 bool nodePlacement(const ItemDefinition &selected_def, const ItemStack &selected_item,
813 const v3s16 &nodepos, const v3s16 &neighbourpos, const PointedThing &pointed,
814 const NodeMetadata *meta, bool force = false);
815 static const ClientEventHandler clientEventHandler[CLIENTEVENT_MAX];
817 f32 getSensitivityScaleFactor() const;
819 InputHandler *input = nullptr;
821 Client *client = nullptr;
822 Server *server = nullptr;
824 IWritableTextureSource *texture_src = nullptr;
825 IWritableShaderSource *shader_src = nullptr;
827 // When created, these will be filled with data received from the server
828 IWritableItemDefManager *itemdef_manager = nullptr;
829 NodeDefManager *nodedef_manager = nullptr;
831 GameOnDemandSoundFetcher soundfetcher; // useful when testing
832 ISoundManager *sound = nullptr;
833 bool sound_is_dummy = false;
834 SoundMaker *soundmaker = nullptr;
836 ChatBackend *chat_backend = nullptr;
837 LogOutputBuffer m_chat_log_buf;
839 EventManager *eventmgr = nullptr;
840 QuicktuneShortcutter *quicktune = nullptr;
841 bool registration_confirmation_shown = false;
843 std::unique_ptr<GameUI> m_game_ui;
844 GUIChatConsole *gui_chat_console = nullptr; // Free using ->Drop()
845 CheatMenu *m_cheat_menu = nullptr;
846 MapDrawControl *draw_control = nullptr;
847 Camera *camera = nullptr;
848 Clouds *clouds = nullptr; // Free using ->Drop()
849 Sky *sky = nullptr; // Free using ->Drop()
851 Minimap *mapper = nullptr;
853 // Map server hud ids to client hud ids
854 std::unordered_map<u32, u32> m_hud_server_to_client;
860 This class does take ownership/responsibily for cleaning up etc of any of
861 these items (e.g. device)
863 IrrlichtDevice *device;
864 RenderingEngine *m_rendering_engine;
865 video::IVideoDriver *driver;
866 scene::ISceneManager *smgr;
868 std::string *error_message;
869 bool *reconnect_requested;
870 scene::ISceneNode *skybox;
871 PausedNodesList paused_animated_nodes;
873 bool simple_singleplayer_mode;
876 /* Pre-calculated values
878 int crack_animation_length;
880 IntervalLimiter profiler_interval;
883 * TODO: Local caching of settings is not optimal and should at some stage
884 * be updated to use a global settings object for getting thse values
885 * (as opposed to the this local caching). This can be addressed in
888 bool m_cache_doubletap_jump;
889 bool m_cache_enable_clouds;
890 bool m_cache_enable_joysticks;
891 bool m_cache_enable_particles;
892 bool m_cache_enable_fog;
893 bool m_cache_enable_noclip;
894 bool m_cache_enable_free_move;
895 f32 m_cache_mouse_sensitivity;
896 f32 m_cache_joystick_frustum_sensitivity;
897 f32 m_repeat_place_time;
898 f32 m_cache_cam_smoothing;
899 f32 m_cache_fog_start;
901 bool m_invert_mouse = false;
902 bool m_first_loop_after_window_activation = false;
903 bool m_camera_offset_changed = false;
905 bool m_does_lost_focus_pause_game = false;
907 CameraOrientation cam_view_target = { 0 };
908 CameraOrientation cam_view = { 0 };
910 int m_reset_HW_buffer_counter = 0;
912 bool m_cache_hold_aux1;
913 bool m_android_chat_open;
918 void the_game(bool *kill,
920 RenderingEngine *rendering_engine,
921 const GameStartData &start_data,
922 std::string &error_message,
923 ChatBackend &chat_backend,
924 bool *reconnect_requested);