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),
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, 3> m_eye_position_pixel;
445 CachedVertexShaderSetting<float, 3> m_eye_position_vertex;
446 CachedPixelShaderSetting<float, 3> m_minimap_yaw;
447 CachedPixelShaderSetting<float, 3> m_camera_offset_pixel;
448 CachedPixelShaderSetting<float, 3> m_camera_offset_vertex;
449 CachedPixelShaderSetting<SamplerLayer_t> m_base_texture;
450 CachedPixelShaderSetting<SamplerLayer_t> m_normal_texture;
451 CachedPixelShaderSetting<SamplerLayer_t> m_texture_flags;
455 void onSettingsChange(const std::string &name)
457 if (name == "enable_fog")
458 m_fog_enabled = g_settings->getBool("enable_fog");
461 static void settingsCallback(const std::string &name, void *userdata)
463 reinterpret_cast<GameGlobalShaderConstantSetter*>(userdata)->onSettingsChange(name);
466 void setSky(Sky *sky) { m_sky = sky; }
468 GameGlobalShaderConstantSetter(Sky *sky, bool *force_fog_off,
469 f32 *fog_range, Client *client) :
471 m_force_fog_off(force_fog_off),
472 m_fog_range(fog_range),
473 m_sky_bg_color("skyBgColor"),
474 m_fog_distance("fogDistance"),
475 m_animation_timer_vertex("animationTimer"),
476 m_animation_timer_pixel("animationTimer"),
477 m_day_light("dayLight"),
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"),
484 m_normal_texture("normalTexture"),
485 m_texture_flags("textureFlags"),
488 g_settings->registerChangedCallback("enable_fog", settingsCallback, this);
489 m_fog_enabled = g_settings->getBool("enable_fog");
492 ~GameGlobalShaderConstantSetter()
494 g_settings->deregisterChangedCallback("enable_fog", settingsCallback, this);
497 virtual void onSetConstants(video::IMaterialRendererServices *services,
504 video::SColor bgcolor = m_sky->getBgColor();
505 video::SColorf bgcolorf(bgcolor);
506 float bgcolorfa[4] = {
512 m_sky_bg_color.set(bgcolorfa, services);
515 float fog_distance = 10000 * BS;
517 if (m_fog_enabled && !*m_force_fog_off)
518 fog_distance = *m_fog_range;
520 m_fog_distance.set(&fog_distance, services);
522 u32 daynight_ratio = (float)m_client->getEnv().getDayNightRatio();
523 video::SColorf sunlight;
524 get_sunlight_color(&sunlight, daynight_ratio);
529 m_day_light.set(dnc, services);
531 u32 animation_timer = porting::getTimeMs() % 1000000;
532 float animation_timer_f = (float)animation_timer / 100000.f;
533 m_animation_timer_vertex.set(&animation_timer_f, services);
534 m_animation_timer_pixel.set(&animation_timer_f, services);
536 float eye_position_array[3];
537 v3f epos = m_client->getEnv().getLocalPlayer()->getEyePosition();
538 #if (IRRLICHT_VERSION_MAJOR == 1 && IRRLICHT_VERSION_MINOR < 8)
539 eye_position_array[0] = epos.X;
540 eye_position_array[1] = epos.Y;
541 eye_position_array[2] = epos.Z;
543 epos.getAs3Values(eye_position_array);
545 m_eye_position_pixel.set(eye_position_array, services);
546 m_eye_position_vertex.set(eye_position_array, services);
548 if (m_client->getMinimap()) {
549 float minimap_yaw_array[3];
550 v3f minimap_yaw = m_client->getMinimap()->getYawVec();
551 #if (IRRLICHT_VERSION_MAJOR == 1 && IRRLICHT_VERSION_MINOR < 8)
552 minimap_yaw_array[0] = minimap_yaw.X;
553 minimap_yaw_array[1] = minimap_yaw.Y;
554 minimap_yaw_array[2] = minimap_yaw.Z;
556 minimap_yaw.getAs3Values(minimap_yaw_array);
558 m_minimap_yaw.set(minimap_yaw_array, services);
561 float camera_offset_array[3];
562 v3f offset = intToFloat(m_client->getCamera()->getOffset(), BS);
563 #if (IRRLICHT_VERSION_MAJOR == 1 && IRRLICHT_VERSION_MINOR < 8)
564 camera_offset_array[0] = offset.X;
565 camera_offset_array[1] = offset.Y;
566 camera_offset_array[2] = offset.Z;
568 offset.getAs3Values(camera_offset_array);
570 m_camera_offset_pixel.set(camera_offset_array, services);
571 m_camera_offset_vertex.set(camera_offset_array, services);
573 SamplerLayer_t base_tex = 0,
576 m_base_texture.set(&base_tex, services);
577 m_normal_texture.set(&normal_tex, services);
578 m_texture_flags.set(&flags_tex, services);
583 class GameGlobalShaderConstantSetterFactory : public IShaderConstantSetterFactory
586 bool *m_force_fog_off;
589 std::vector<GameGlobalShaderConstantSetter *> created_nosky;
591 GameGlobalShaderConstantSetterFactory(bool *force_fog_off,
592 f32 *fog_range, Client *client) :
594 m_force_fog_off(force_fog_off),
595 m_fog_range(fog_range),
599 void setSky(Sky *sky) {
601 for (GameGlobalShaderConstantSetter *ggscs : created_nosky) {
602 ggscs->setSky(m_sky);
604 created_nosky.clear();
607 virtual IShaderConstantSetter* create()
609 GameGlobalShaderConstantSetter *scs = new GameGlobalShaderConstantSetter(
610 m_sky, m_force_fog_off, m_fog_range, m_client);
612 created_nosky.push_back(scs);
618 #define SIZE_TAG "size[11,5.5]"
620 #define SIZE_TAG "size[11,5.5,true]" // Fixed size on desktop
623 /****************************************************************************
625 ****************************************************************************/
627 const float object_hit_delay = 0.2;
630 u32 last_time, busy_time, sleep_time;
634 /* The reason the following structs are not anonymous structs within the
635 * class is that they are not used by the majority of member functions and
636 * many functions that do require objects of thse types do not modify them
637 * (so they can be passed as a const qualified parameter)
643 PointedThing pointed_old;
647 bool digging_blocked;
649 bool reset_jump_timer;
650 float nodig_delay_timer;
652 float dig_time_complete;
653 float repeat_rightclick_timer;
654 float object_hit_delay_timer;
655 float time_from_last_punch;
656 ClientActiveObject *selected_object;
660 float update_draw_list_timer;
664 v3f update_draw_list_last_cam_dir;
666 float time_of_day_smooth;
671 struct ClientEventHandler
673 void (Game::*handler)(ClientEvent *, CameraOrientation *);
681 bool startup(bool *kill,
683 const GameStartData &game_params,
684 std::string &error_message,
686 ChatBackend *chat_backend);
692 void extendedResourceCleanup();
694 // Basic initialisation
695 bool init(const std::string &map_dir, const std::string &address,
696 u16 port, const SubgameSpec &gamespec);
698 bool createSingleplayerServer(const std::string &map_dir,
699 const SubgameSpec &gamespec, u16 port);
702 bool createClient(const GameStartData &start_data);
706 bool connectToServer(const GameStartData &start_data,
707 bool *connect_ok, bool *aborted);
708 bool getServerContent(bool *aborted);
712 void updateInteractTimers(f32 dtime);
713 bool checkConnection();
714 bool handleCallbacks();
715 void processQueues();
716 void updateProfilers(const RunStats &stats, const FpsControl &draw_times, f32 dtime);
717 void updateStats(RunStats *stats, const FpsControl &draw_times, f32 dtime);
718 void updateProfilerGraphs(ProfilerGraph *graph);
721 void processUserInput(f32 dtime);
722 void processKeyInput();
723 void processItemSelection(u16 *new_playeritem);
725 void dropSelectedItem(bool single_item = false);
726 void openInventory();
727 void openSpecialInventory();
728 void openConsole(float scale, const wchar_t *line=NULL);
729 void toggleFreeMove();
730 void toggleFreeMoveAlt();
731 void togglePitchMove();
735 void toggleFullbright();
736 void toggleKillaura();
737 void toggleFreecam();
738 void toggleCinematic();
739 void toggleAutoforward();
741 void toggleMinimap(bool shift_pressed);
744 void toggleUpdateCamera();
745 void updatePlayerCAOVisibility();
747 void increaseViewRange();
748 void decreaseViewRange();
749 void toggleFullViewRange();
750 void checkZoomEnabled();
752 void updateCameraDirection(CameraOrientation *cam, float dtime);
753 void updateCameraOrientation(CameraOrientation *cam, float dtime);
754 void updatePlayerControl(const CameraOrientation &cam);
755 void step(f32 *dtime);
756 void processClientEvents(CameraOrientation *cam);
757 void updateCamera(u32 busy_time, f32 dtime);
758 void updateSound(f32 dtime);
759 void processPlayerInteraction(f32 dtime, bool show_hud, bool show_debug);
761 * Returns the object or node the player is pointing at.
762 * Also updates the selected thing in the Hud.
764 * @param[in] shootline the shootline, starting from
765 * the camera position. This also gives the maximal distance
767 * @param[in] liquids_pointable if false, liquids are ignored
768 * @param[in] look_for_object if false, objects are ignored
769 * @param[in] camera_offset offset of the camera
770 * @param[out] selected_object the selected object or
773 PointedThing updatePointedThing(
774 const core::line3d<f32> &shootline, bool liquids_pointable,
775 bool look_for_object, const v3s16 &camera_offset);
776 void handleKillaura(v3f origin, f32 max_d);
777 void handlePointingAtNothing(const ItemStack &playerItem);
778 void handlePointingAtNode(const PointedThing &pointed,
779 const ItemStack &selected_item, const ItemStack &hand_item, f32 dtime);
780 void handlePointingAtObject(const PointedThing &pointed, const ItemStack &playeritem,
781 const v3f &player_position, bool show_debug);
782 void handleDigging(const PointedThing &pointed, const v3s16 &nodepos,
783 const ItemStack &selected_item, const ItemStack &hand_item, f32 dtime);
784 void updateFrame(ProfilerGraph *graph, RunStats *stats, f32 dtime,
785 const CameraOrientation &cam);
788 void limitFps(FpsControl *fps_timings, f32 *dtime);
790 void showOverlayMessage(const char *msg, float dtime, int percent,
791 bool draw_clouds = true);
793 static void freecamChangedCallback(const std::string &setting_name, void *data);
794 static void settingChangedCallback(const std::string &setting_name, void *data);
797 inline bool isKeyDown(GameKeyType k)
799 return input->isKeyDown(k);
801 inline bool wasKeyDown(GameKeyType k)
803 return input->wasKeyDown(k);
807 void handleAndroidChatInput();
811 bool force_fog_off = false;
812 bool disable_camera_update = false;
815 void showDeathFormspec();
816 void showPauseMenu();
818 // ClientEvent handlers
819 void handleClientEvent_None(ClientEvent *event, CameraOrientation *cam);
820 void handleClientEvent_PlayerDamage(ClientEvent *event, CameraOrientation *cam);
821 void handleClientEvent_PlayerForceMove(ClientEvent *event, CameraOrientation *cam);
822 void handleClientEvent_Deathscreen(ClientEvent *event, CameraOrientation *cam);
823 void handleClientEvent_ShowFormSpec(ClientEvent *event, CameraOrientation *cam);
824 void handleClientEvent_ShowLocalFormSpec(ClientEvent *event, CameraOrientation *cam);
825 void handleClientEvent_HandleParticleEvent(ClientEvent *event,
826 CameraOrientation *cam);
827 void handleClientEvent_HudAdd(ClientEvent *event, CameraOrientation *cam);
828 void handleClientEvent_HudRemove(ClientEvent *event, CameraOrientation *cam);
829 void handleClientEvent_HudChange(ClientEvent *event, CameraOrientation *cam);
830 void handleClientEvent_SetSky(ClientEvent *event, CameraOrientation *cam);
831 void handleClientEvent_SetSun(ClientEvent *event, CameraOrientation *cam);
832 void handleClientEvent_SetMoon(ClientEvent *event, CameraOrientation *cam);
833 void handleClientEvent_SetStars(ClientEvent *event, CameraOrientation *cam);
834 void handleClientEvent_OverrideDayNigthRatio(ClientEvent *event,
835 CameraOrientation *cam);
836 void handleClientEvent_CloudParams(ClientEvent *event, CameraOrientation *cam);
838 void updateChat(f32 dtime, const v2u32 &screensize);
840 bool nodePlacement(const ItemDefinition &selected_def, const ItemStack &selected_item,
841 const v3s16 &nodepos, const v3s16 &neighbourpos, const PointedThing &pointed,
842 const NodeMetadata *meta);
843 static const ClientEventHandler clientEventHandler[CLIENTEVENT_MAX];
845 InputHandler *input = nullptr;
847 Client *client = nullptr;
848 Server *server = nullptr;
850 IWritableTextureSource *texture_src = nullptr;
851 IWritableShaderSource *shader_src = nullptr;
853 // When created, these will be filled with data received from the server
854 IWritableItemDefManager *itemdef_manager = nullptr;
855 NodeDefManager *nodedef_manager = nullptr;
857 GameOnDemandSoundFetcher soundfetcher; // useful when testing
858 ISoundManager *sound = nullptr;
859 bool sound_is_dummy = false;
860 SoundMaker *soundmaker = nullptr;
862 ChatBackend *chat_backend = nullptr;
863 LogOutputBuffer m_chat_log_buf;
865 EventManager *eventmgr = nullptr;
866 QuicktuneShortcutter *quicktune = nullptr;
867 bool registration_confirmation_shown = false;
869 std::unique_ptr<GameUI> m_game_ui;
870 GUIChatConsole *gui_chat_console = nullptr; // Free using ->Drop()
871 CheatMenu *m_cheat_menu = nullptr;
872 MapDrawControl *draw_control = nullptr;
873 Camera *camera = nullptr;
874 Clouds *clouds = nullptr; // Free using ->Drop()
875 Sky *sky = nullptr; // Free using ->Drop()
877 Minimap *mapper = nullptr;
883 This class does take ownership/responsibily for cleaning up etc of any of
884 these items (e.g. device)
886 IrrlichtDevice *device;
887 video::IVideoDriver *driver;
888 scene::ISceneManager *smgr;
890 std::string *error_message;
891 bool *reconnect_requested;
892 scene::ISceneNode *skybox;
895 bool simple_singleplayer_mode;
898 /* Pre-calculated values
900 int crack_animation_length;
902 IntervalLimiter profiler_interval;
905 * TODO: Local caching of settings is not optimal and should at some stage
906 * be updated to use a global settings object for getting thse values
907 * (as opposed to the this local caching). This can be addressed in
910 bool m_cache_doubletap_jump;
911 bool m_cache_enable_clouds;
912 bool m_cache_enable_joysticks;
913 bool m_cache_enable_particles;
914 bool m_cache_enable_fog;
915 bool m_cache_enable_noclip;
916 bool m_cache_enable_free_move;
917 f32 m_cache_mouse_sensitivity;
918 f32 m_cache_joystick_frustum_sensitivity;
919 f32 m_repeat_right_click_time;
920 f32 m_cache_cam_smoothing;
921 f32 m_cache_fog_start;
923 bool m_invert_mouse = false;
924 bool m_first_loop_after_window_activation = false;
925 bool m_camera_offset_changed = false;
927 bool m_does_lost_focus_pause_game = false;
930 bool m_cache_hold_aux1;
931 bool m_android_chat_open;
936 void the_game(bool *kill,
938 const GameStartData &start_data,
939 std::string &error_message,
940 ChatBackend &chat_backend,
941 bool *reconnect_requested);