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"
72 #include "script/scripting_client.h"
74 #include "irrlichttypes.h"
78 class ChatBackend; /* to avoid having to include chat.h */
83 f32 max, min, avg, counter, max_sample, min_sample, max_fraction;
89 Jitter dtime_jitter, busy_time_jitter;
92 struct CameraOrientation {
93 f32 camera_yaw; // "right/left"
94 f32 camera_pitch; // "up/down"
101 struct TextDestNodeMetadata : public TextDest
103 TextDestNodeMetadata(v3s16 p, Client *client)
108 // This is deprecated I guess? -celeron55
109 void gotText(const std::wstring &text)
111 std::string ntext = wide_to_utf8(text);
112 infostream << "Submitting 'text' field of node at (" << m_p.X << ","
113 << m_p.Y << "," << m_p.Z << "): " << ntext << std::endl;
115 fields["text"] = ntext;
116 m_client->sendNodemetaFields(m_p, "", fields);
118 void gotText(const StringMap &fields)
120 m_client->sendNodemetaFields(m_p, "", fields);
127 struct TextDestPlayerInventory : public TextDest
129 TextDestPlayerInventory(Client *client)
134 TextDestPlayerInventory(Client *client, const std::string &formname)
137 m_formname = formname;
139 void gotText(const StringMap &fields)
141 m_client->sendInventoryFields(m_formname, fields);
147 struct LocalFormspecHandler : public TextDest
149 LocalFormspecHandler(const std::string &formname)
151 m_formname = formname;
154 LocalFormspecHandler(const std::string &formname, Client *client):
157 m_formname = formname;
160 void gotText(const StringMap &fields)
162 if (m_formname == "MT_PAUSE_MENU") {
163 if (fields.find("btn_sound") != fields.end()) {
164 g_gamecallback->changeVolume();
168 if (fields.find("btn_key_config") != fields.end()) {
169 g_gamecallback->keyConfig();
173 if (fields.find("btn_exit_menu") != fields.end()) {
174 g_gamecallback->disconnect();
178 if (fields.find("btn_exit_os") != fields.end()) {
179 g_gamecallback->exitToOS();
181 RenderingEngine::get_raw_device()->closeDevice();
186 if (fields.find("btn_change_password") != fields.end()) {
187 g_gamecallback->changePassword();
191 if (fields.find("quit") != fields.end()) {
195 if (fields.find("btn_continue") != fields.end()) {
200 if (m_formname == "MT_DEATH_SCREEN") {
201 assert(m_client != 0);
202 m_client->sendRespawn();
206 if (m_client && m_client->modsLoaded())
207 m_client->getScript()->on_formspec_input(m_formname, fields);
210 Client *m_client = nullptr;
213 /* Form update callback */
215 class NodeMetadataFormSource: public IFormSource
218 NodeMetadataFormSource(ClientMap *map, v3s16 p):
223 const std::string &getForm() const
225 static const std::string empty_string = "";
226 NodeMetadata *meta = m_map->getNodeMetadata(m_p);
231 return meta->getString("formspec");
234 virtual std::string resolveText(const std::string &str)
236 NodeMetadata *meta = m_map->getNodeMetadata(m_p);
241 return meta->resolveString(str);
248 class PlayerInventoryFormSource: public IFormSource
251 PlayerInventoryFormSource(Client *client):
256 const std::string &getForm() const
258 LocalPlayer *player = m_client->getEnv().getLocalPlayer();
259 return player->inventory_formspec;
265 class NodeDugEvent: public MtEvent
271 NodeDugEvent(v3s16 p, MapNode n):
275 MtEvent::Type getType() const
277 return MtEvent::NODE_DUG;
283 ISoundManager *m_sound;
284 const NodeDefManager *m_ndef;
286 bool makes_footstep_sound;
287 float m_player_step_timer;
288 float m_player_jump_timer;
290 SimpleSoundSpec m_player_step_sound;
291 SimpleSoundSpec m_player_leftpunch_sound;
292 SimpleSoundSpec m_player_rightpunch_sound;
294 SoundMaker(ISoundManager *sound, const NodeDefManager *ndef):
297 makes_footstep_sound(true),
298 m_player_step_timer(0.0f),
299 m_player_jump_timer(0.0f)
303 void playPlayerStep()
305 if (m_player_step_timer <= 0 && m_player_step_sound.exists()) {
306 m_player_step_timer = 0.03;
307 if (makes_footstep_sound)
308 m_sound->playSound(m_player_step_sound, false);
312 void playPlayerJump()
314 if (m_player_jump_timer <= 0.0f) {
315 m_player_jump_timer = 0.2f;
316 m_sound->playSound(SimpleSoundSpec("player_jump", 0.5f), false);
320 static void viewBobbingStep(MtEvent *e, void *data)
322 SoundMaker *sm = (SoundMaker *)data;
323 sm->playPlayerStep();
326 static void playerRegainGround(MtEvent *e, void *data)
328 SoundMaker *sm = (SoundMaker *)data;
329 sm->playPlayerStep();
332 static void playerJump(MtEvent *e, void *data)
334 SoundMaker *sm = (SoundMaker *)data;
335 sm->playPlayerJump();
338 static void cameraPunchLeft(MtEvent *e, void *data)
340 SoundMaker *sm = (SoundMaker *)data;
341 sm->m_sound->playSound(sm->m_player_leftpunch_sound, false);
344 static void cameraPunchRight(MtEvent *e, void *data)
346 SoundMaker *sm = (SoundMaker *)data;
347 sm->m_sound->playSound(sm->m_player_rightpunch_sound, false);
350 static void nodeDug(MtEvent *e, void *data)
352 SoundMaker *sm = (SoundMaker *)data;
353 NodeDugEvent *nde = (NodeDugEvent *)e;
354 sm->m_sound->playSound(sm->m_ndef->get(nde->n).sound_dug, false);
357 static void playerDamage(MtEvent *e, void *data)
359 SoundMaker *sm = (SoundMaker *)data;
360 sm->m_sound->playSound(SimpleSoundSpec("player_damage", 0.5), false);
363 static void playerFallingDamage(MtEvent *e, void *data)
365 SoundMaker *sm = (SoundMaker *)data;
366 sm->m_sound->playSound(SimpleSoundSpec("player_falling_damage", 0.5), false);
369 void registerReceiver(MtEventManager *mgr)
371 mgr->reg(MtEvent::VIEW_BOBBING_STEP, SoundMaker::viewBobbingStep, this);
372 mgr->reg(MtEvent::PLAYER_REGAIN_GROUND, SoundMaker::playerRegainGround, this);
373 mgr->reg(MtEvent::PLAYER_JUMP, SoundMaker::playerJump, this);
374 mgr->reg(MtEvent::CAMERA_PUNCH_LEFT, SoundMaker::cameraPunchLeft, this);
375 mgr->reg(MtEvent::CAMERA_PUNCH_RIGHT, SoundMaker::cameraPunchRight, this);
376 mgr->reg(MtEvent::NODE_DUG, SoundMaker::nodeDug, this);
377 mgr->reg(MtEvent::PLAYER_DAMAGE, SoundMaker::playerDamage, this);
378 mgr->reg(MtEvent::PLAYER_FALLING_DAMAGE, SoundMaker::playerFallingDamage, this);
381 void step(float dtime)
383 m_player_step_timer -= dtime;
384 m_player_jump_timer -= dtime;
388 // Locally stored sounds don't need to be preloaded because of this
389 class GameOnDemandSoundFetcher: public OnDemandSoundFetcher
391 std::set<std::string> m_fetched;
393 void paths_insert(std::set<std::string> &dst_paths,
394 const std::string &base,
395 const std::string &name)
397 dst_paths.insert(base + DIR_DELIM + "sounds" + DIR_DELIM + name + ".ogg");
398 dst_paths.insert(base + DIR_DELIM + "sounds" + DIR_DELIM + name + ".0.ogg");
399 dst_paths.insert(base + DIR_DELIM + "sounds" + DIR_DELIM + name + ".1.ogg");
400 dst_paths.insert(base + DIR_DELIM + "sounds" + DIR_DELIM + name + ".2.ogg");
401 dst_paths.insert(base + DIR_DELIM + "sounds" + DIR_DELIM + name + ".3.ogg");
402 dst_paths.insert(base + DIR_DELIM + "sounds" + DIR_DELIM + name + ".4.ogg");
403 dst_paths.insert(base + DIR_DELIM + "sounds" + DIR_DELIM + name + ".5.ogg");
404 dst_paths.insert(base + DIR_DELIM + "sounds" + DIR_DELIM + name + ".6.ogg");
405 dst_paths.insert(base + DIR_DELIM + "sounds" + DIR_DELIM + name + ".7.ogg");
406 dst_paths.insert(base + DIR_DELIM + "sounds" + DIR_DELIM + name + ".8.ogg");
407 dst_paths.insert(base + DIR_DELIM + "sounds" + DIR_DELIM + name + ".9.ogg");
410 void fetchSounds(const std::string &name,
411 std::set<std::string> &dst_paths,
412 std::set<std::string> &dst_datas)
414 if (m_fetched.count(name))
417 m_fetched.insert(name);
419 paths_insert(dst_paths, porting::path_share, name);
420 paths_insert(dst_paths, porting::path_user, name);
425 // before 1.8 there isn't a "integer interface", only float
426 #if (IRRLICHT_VERSION_MAJOR == 1 && IRRLICHT_VERSION_MINOR < 8)
427 typedef f32 SamplerLayer_t;
429 typedef s32 SamplerLayer_t;
433 class GameGlobalShaderConstantSetter : public IShaderConstantSetter
436 bool *m_force_fog_off;
439 CachedPixelShaderSetting<float, 4> m_sky_bg_color;
440 CachedPixelShaderSetting<float> m_fog_distance;
441 CachedVertexShaderSetting<float> m_animation_timer_vertex;
442 CachedPixelShaderSetting<float> m_animation_timer_pixel;
443 CachedPixelShaderSetting<float, 3> m_day_light;
444 CachedPixelShaderSetting<float, 4> m_star_color;
445 CachedPixelShaderSetting<float, 3> m_eye_position_pixel;
446 CachedVertexShaderSetting<float, 3> m_eye_position_vertex;
447 CachedPixelShaderSetting<float, 3> m_minimap_yaw;
448 CachedPixelShaderSetting<float, 3> m_camera_offset_pixel;
449 CachedPixelShaderSetting<float, 3> m_camera_offset_vertex;
450 CachedPixelShaderSetting<SamplerLayer_t> m_base_texture;
454 void onSettingsChange(const std::string &name)
456 if (name == "enable_fog")
457 m_fog_enabled = g_settings->getBool("enable_fog");
460 static void settingsCallback(const std::string &name, void *userdata)
462 reinterpret_cast<GameGlobalShaderConstantSetter*>(userdata)->onSettingsChange(name);
465 void setSky(Sky *sky) { m_sky = sky; }
467 GameGlobalShaderConstantSetter(Sky *sky, bool *force_fog_off,
468 f32 *fog_range, Client *client) :
470 m_force_fog_off(force_fog_off),
471 m_fog_range(fog_range),
472 m_sky_bg_color("skyBgColor"),
473 m_fog_distance("fogDistance"),
474 m_animation_timer_vertex("animationTimer"),
475 m_animation_timer_pixel("animationTimer"),
476 m_day_light("dayLight"),
477 m_star_color("starColor"),
478 m_eye_position_pixel("eyePosition"),
479 m_eye_position_vertex("eyePosition"),
480 m_minimap_yaw("yawVec"),
481 m_camera_offset_pixel("cameraOffset"),
482 m_camera_offset_vertex("cameraOffset"),
483 m_base_texture("baseTexture"),
486 g_settings->registerChangedCallback("enable_fog", settingsCallback, this);
487 m_fog_enabled = g_settings->getBool("enable_fog");
490 ~GameGlobalShaderConstantSetter()
492 g_settings->deregisterChangedCallback("enable_fog", settingsCallback, this);
495 virtual void onSetConstants(video::IMaterialRendererServices *services,
502 video::SColor bgcolor = m_sky->getBgColor();
503 video::SColorf bgcolorf(bgcolor);
504 float bgcolorfa[4] = {
510 m_sky_bg_color.set(bgcolorfa, services);
513 float fog_distance = 10000 * BS;
515 if (m_fog_enabled && !*m_force_fog_off)
516 fog_distance = *m_fog_range;
518 m_fog_distance.set(&fog_distance, services);
520 u32 daynight_ratio = (float)m_client->getEnv().getDayNightRatio();
521 video::SColorf sunlight;
522 get_sunlight_color(&sunlight, daynight_ratio);
527 m_day_light.set(dnc, services);
529 video::SColorf star_color = m_sky->getCurrentStarColor();
530 float clr[4] = {star_color.r, star_color.g, star_color.b, star_color.a};
531 m_star_color.set(clr, services);
533 u32 animation_timer = porting::getTimeMs() % 1000000;
534 float animation_timer_f = (float)animation_timer / 100000.f;
535 m_animation_timer_vertex.set(&animation_timer_f, services);
536 m_animation_timer_pixel.set(&animation_timer_f, services);
538 float eye_position_array[3];
539 v3f epos = m_client->getEnv().getLocalPlayer()->getEyePosition();
540 #if (IRRLICHT_VERSION_MAJOR == 1 && IRRLICHT_VERSION_MINOR < 8)
541 eye_position_array[0] = epos.X;
542 eye_position_array[1] = epos.Y;
543 eye_position_array[2] = epos.Z;
545 epos.getAs3Values(eye_position_array);
547 m_eye_position_pixel.set(eye_position_array, services);
548 m_eye_position_vertex.set(eye_position_array, services);
550 if (m_client->getMinimap()) {
551 float minimap_yaw_array[3];
552 v3f minimap_yaw = m_client->getMinimap()->getYawVec();
553 #if (IRRLICHT_VERSION_MAJOR == 1 && IRRLICHT_VERSION_MINOR < 8)
554 minimap_yaw_array[0] = minimap_yaw.X;
555 minimap_yaw_array[1] = minimap_yaw.Y;
556 minimap_yaw_array[2] = minimap_yaw.Z;
558 minimap_yaw.getAs3Values(minimap_yaw_array);
560 m_minimap_yaw.set(minimap_yaw_array, services);
563 float camera_offset_array[3];
564 v3f offset = intToFloat(m_client->getCamera()->getOffset(), BS);
565 #if (IRRLICHT_VERSION_MAJOR == 1 && IRRLICHT_VERSION_MINOR < 8)
566 camera_offset_array[0] = offset.X;
567 camera_offset_array[1] = offset.Y;
568 camera_offset_array[2] = offset.Z;
570 offset.getAs3Values(camera_offset_array);
572 m_camera_offset_pixel.set(camera_offset_array, services);
573 m_camera_offset_vertex.set(camera_offset_array, services);
575 SamplerLayer_t base_tex = 0;
576 m_base_texture.set(&base_tex, services);
581 class GameGlobalShaderConstantSetterFactory : public IShaderConstantSetterFactory
584 bool *m_force_fog_off;
587 std::vector<GameGlobalShaderConstantSetter *> created_nosky;
589 GameGlobalShaderConstantSetterFactory(bool *force_fog_off,
590 f32 *fog_range, Client *client) :
592 m_force_fog_off(force_fog_off),
593 m_fog_range(fog_range),
597 void setSky(Sky *sky) {
599 for (GameGlobalShaderConstantSetter *ggscs : created_nosky) {
600 ggscs->setSky(m_sky);
602 created_nosky.clear();
605 virtual IShaderConstantSetter* create()
607 GameGlobalShaderConstantSetter *scs = new GameGlobalShaderConstantSetter(
608 m_sky, m_force_fog_off, m_fog_range, m_client);
610 created_nosky.push_back(scs);
616 #define SIZE_TAG "size[11,5.5]"
618 #define SIZE_TAG "size[11,5.5,true]" // Fixed size on desktop
621 /****************************************************************************
622 ****************************************************************************/
624 const float object_hit_delay = 0.2;
627 u32 last_time, busy_time, sleep_time;
631 /* The reason the following structs are not anonymous structs within the
632 * class is that they are not used by the majority of member functions and
633 * many functions that do require objects of thse types do not modify them
634 * (so they can be passed as a const qualified parameter)
640 PointedThing pointed_old;
643 bool btn_down_for_dig;
645 bool digging_blocked;
647 bool reset_jump_timer;
648 float nodig_delay_timer;
650 float dig_time_complete;
651 float repeat_place_timer;
652 float object_hit_delay_timer;
653 float time_from_last_punch;
654 ClientActiveObject *selected_object;
658 float update_draw_list_timer;
662 v3f update_draw_list_last_cam_dir;
664 float time_of_day_smooth;
669 struct ClientEventHandler
671 void (Game::*handler)(ClientEvent *, CameraOrientation *);
679 bool startup(bool *kill,
681 const GameStartData &game_params,
682 std::string &error_message,
684 ChatBackend *chat_backend);
690 void extendedResourceCleanup();
692 // Basic initialisation
693 bool init(const std::string &map_dir, const std::string &address,
694 u16 port, const SubgameSpec &gamespec);
696 bool createSingleplayerServer(const std::string &map_dir,
697 const SubgameSpec &gamespec, u16 port);
700 bool createClient(const GameStartData &start_data);
704 bool connectToServer(const GameStartData &start_data,
705 bool *connect_ok, bool *aborted);
706 bool getServerContent(bool *aborted);
710 void updateInteractTimers(f32 dtime);
711 bool checkConnection();
712 bool handleCallbacks();
713 void processQueues();
714 void updateProfilers(const RunStats &stats, const FpsControl &draw_times, f32 dtime);
715 void updateStats(RunStats *stats, const FpsControl &draw_times, f32 dtime);
716 void updateProfilerGraphs(ProfilerGraph *graph);
719 void processUserInput(f32 dtime);
720 void processKeyInput();
721 void processItemSelection(u16 *new_playeritem);
723 void dropSelectedItem(bool single_item = false);
724 void openInventory();
725 void openEnderchest();
726 void openConsole(float scale, const wchar_t *line=NULL);
727 void toggleFreeMove();
728 void toggleFreeMoveAlt();
729 void togglePitchMove();
732 void toggleKillaura();
733 void toggleFreecam();
734 void toggleScaffold();
735 void toggleNextItem();
736 void toggleCinematic();
737 void toggleAutoforward();
739 void toggleMinimap(bool shift_pressed);
742 void toggleUpdateCamera();
743 void updatePlayerCAOVisibility();
745 void increaseViewRange();
746 void decreaseViewRange();
747 void toggleFullViewRange();
748 void checkZoomEnabled();
750 void updateCameraDirection(CameraOrientation *cam, float dtime);
751 void updateCameraOrientation(CameraOrientation *cam, float dtime);
752 void updatePlayerControl(const CameraOrientation &cam);
753 void step(f32 *dtime);
754 void processClientEvents(CameraOrientation *cam);
755 void updateCamera(u32 busy_time, f32 dtime);
756 void updateSound(f32 dtime);
757 void processPlayerInteraction(f32 dtime, bool show_hud, bool show_debug);
759 * Returns the object or node the player is pointing at.
760 * Also updates the selected thing in the Hud.
762 * @param[in] shootline the shootline, starting from
763 * the camera position. This also gives the maximal distance
765 * @param[in] liquids_pointable if false, liquids are ignored
766 * @param[in] look_for_object if false, objects are ignored
767 * @param[in] camera_offset offset of the camera
768 * @param[out] selected_object the selected object or
771 PointedThing updatePointedThing(
772 const core::line3d<f32> &shootline, bool liquids_pointable,
773 bool look_for_object, const v3s16 &camera_offset);
774 void handlePointingAtNothing(const ItemStack &playerItem);
775 void handlePointingAtNode(const PointedThing &pointed,
776 const ItemStack &selected_item, const ItemStack &hand_item, f32 dtime);
777 void handlePointingAtObject(const PointedThing &pointed, const ItemStack &playeritem,
778 const v3f &player_position, bool show_debug);
779 void handleDigging(const PointedThing &pointed, const v3s16 &nodepos,
780 const ItemStack &selected_item, const ItemStack &hand_item, f32 dtime);
781 void updateFrame(ProfilerGraph *graph, RunStats *stats, f32 dtime,
782 const CameraOrientation &cam);
785 void limitFps(FpsControl *fps_timings, f32 *dtime);
787 void showOverlayMessage(const char *msg, float dtime, int percent,
788 bool draw_clouds = true);
790 static void freecamChangedCallback(const std::string &setting_name, void *data);
791 static void settingChangedCallback(const std::string &setting_name, void *data);
792 static void updateAllMapBlocksCallback(const std::string &setting_name, void *data);
795 bool isKeyDown(GameKeyType k);
796 bool wasKeyDown(GameKeyType k);
797 bool wasKeyPressed(GameKeyType k);
798 bool wasKeyReleased(GameKeyType k);
801 void handleAndroidChatInput();
805 bool force_fog_off = false;
806 bool disable_camera_update = false;
809 void showDeathFormspec();
810 void showPauseMenu();
812 // ClientEvent handlers
813 void handleClientEvent_None(ClientEvent *event, CameraOrientation *cam);
814 void handleClientEvent_PlayerDamage(ClientEvent *event, CameraOrientation *cam);
815 void handleClientEvent_PlayerForceMove(ClientEvent *event, CameraOrientation *cam);
816 void handleClientEvent_Deathscreen(ClientEvent *event, CameraOrientation *cam);
817 void handleClientEvent_ShowFormSpec(ClientEvent *event, CameraOrientation *cam);
818 void handleClientEvent_ShowLocalFormSpec(ClientEvent *event, CameraOrientation *cam);
819 void handleClientEvent_HandleParticleEvent(ClientEvent *event,
820 CameraOrientation *cam);
821 void handleClientEvent_HudAdd(ClientEvent *event, CameraOrientation *cam);
822 void handleClientEvent_HudRemove(ClientEvent *event, CameraOrientation *cam);
823 void handleClientEvent_HudChange(ClientEvent *event, CameraOrientation *cam);
824 void handleClientEvent_SetSky(ClientEvent *event, CameraOrientation *cam);
825 void handleClientEvent_SetSun(ClientEvent *event, CameraOrientation *cam);
826 void handleClientEvent_SetMoon(ClientEvent *event, CameraOrientation *cam);
827 void handleClientEvent_SetStars(ClientEvent *event, CameraOrientation *cam);
828 void handleClientEvent_OverrideDayNigthRatio(ClientEvent *event,
829 CameraOrientation *cam);
830 void handleClientEvent_CloudParams(ClientEvent *event, CameraOrientation *cam);
832 void updateChat(f32 dtime, const v2u32 &screensize);
834 bool nodePlacement(const ItemDefinition &selected_def, const ItemStack &selected_item,
835 const v3s16 &nodepos, const v3s16 &neighbourpos, const PointedThing &pointed,
836 const NodeMetadata *meta);
837 static const ClientEventHandler clientEventHandler[CLIENTEVENT_MAX];
839 InputHandler *input = nullptr;
841 Client *client = nullptr;
842 Server *server = nullptr;
844 IWritableTextureSource *texture_src = nullptr;
845 IWritableShaderSource *shader_src = nullptr;
847 // When created, these will be filled with data received from the server
848 IWritableItemDefManager *itemdef_manager = nullptr;
849 NodeDefManager *nodedef_manager = nullptr;
851 GameOnDemandSoundFetcher soundfetcher; // useful when testing
852 ISoundManager *sound = nullptr;
853 bool sound_is_dummy = false;
854 SoundMaker *soundmaker = nullptr;
856 ChatBackend *chat_backend = nullptr;
857 LogOutputBuffer m_chat_log_buf;
859 EventManager *eventmgr = nullptr;
860 QuicktuneShortcutter *quicktune = nullptr;
861 bool registration_confirmation_shown = false;
863 std::unique_ptr<GameUI> m_game_ui;
864 GUIChatConsole *gui_chat_console = nullptr; // Free using ->Drop()
865 CheatMenu *m_cheat_menu = nullptr;
866 MapDrawControl *draw_control = nullptr;
867 Camera *camera = nullptr;
868 Clouds *clouds = nullptr; // Free using ->Drop()
869 Sky *sky = nullptr; // Free using ->Drop()
871 Minimap *mapper = nullptr;
877 This class does take ownership/responsibily for cleaning up etc of any of
878 these items (e.g. device)
880 IrrlichtDevice *device;
881 video::IVideoDriver *driver;
882 scene::ISceneManager *smgr;
884 std::string *error_message;
885 bool *reconnect_requested;
886 scene::ISceneNode *skybox;
888 bool simple_singleplayer_mode;
891 /* Pre-calculated values
893 int crack_animation_length;
895 IntervalLimiter profiler_interval;
898 * TODO: Local caching of settings is not optimal and should at some stage
899 * be updated to use a global settings object for getting thse values
900 * (as opposed to the this local caching). This can be addressed in
903 bool m_cache_doubletap_jump;
904 bool m_cache_enable_clouds;
905 bool m_cache_enable_joysticks;
906 bool m_cache_enable_particles;
907 bool m_cache_enable_fog;
908 bool m_cache_enable_noclip;
909 bool m_cache_enable_free_move;
910 f32 m_cache_mouse_sensitivity;
911 f32 m_cache_joystick_frustum_sensitivity;
912 f32 m_repeat_place_time;
913 f32 m_cache_cam_smoothing;
914 f32 m_cache_fog_start;
916 bool m_invert_mouse = false;
917 bool m_first_loop_after_window_activation = false;
918 bool m_camera_offset_changed = false;
920 bool m_does_lost_focus_pause_game = false;
922 CameraOrientation cam_view_target = { 0 };
923 CameraOrientation cam_view = { 0 };
925 int m_reset_HW_buffer_counter = 0;
927 bool m_cache_hold_aux1;
928 bool m_android_chat_open;
933 void the_game(bool *kill,
935 const GameStartData &start_data,
936 std::string &error_message,
937 ChatBackend &chat_backend,
938 bool *reconnect_requested);