X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Fclient%2Fgame.h;h=0e5d0550d296b156acd1652b7bfcf205197b5a95;hb=21df26984da91143c15587f5a03c98d68c3adc4e;hp=fd93ef82d03711303f19a6cd3ed77cdacfb11471;hpb=f97763dc7020f2bb43e70520907dd569999662f8;p=dragonfireclient.git diff --git a/src/client/game.h b/src/client/game.h index fd93ef82d..0e5d0550d 100644 --- a/src/client/game.h +++ b/src/client/game.h @@ -68,6 +68,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "util/pointedthing.h" #include "util/quicktune_shortcutter.h" #include "irrlicht_changes/static_text.h" +#include "irr_ptr.h" #include "version.h" #include "script/scripting_client.h" #include "hud.h" @@ -75,7 +76,8 @@ with this program; if not, write to the Free Software Foundation, Inc., #include class InputHandler; -class ChatBackend; /* to avoid having to include chat.h */ +class ChatBackend; +class RenderingEngine; struct SubgameSpec; struct GameStartData; @@ -84,7 +86,7 @@ struct Jitter { }; struct RunStats { - u32 drawtime; + u64 drawtime; // (us) Jitter dtime_jitter, busy_time_jitter; }; @@ -188,13 +190,7 @@ struct LocalFormspecHandler : public TextDest return; } - if (fields.find("quit") != fields.end()) { - return; - } - - if (fields.find("btn_continue") != fields.end()) { - return; - } + return; } if (m_formname == "MT_DEATH_SCREEN") { @@ -422,12 +418,7 @@ class GameOnDemandSoundFetcher: public OnDemandSoundFetcher }; -// before 1.8 there isn't a "integer interface", only float -#if (IRRLICHT_VERSION_MAJOR == 1 && IRRLICHT_VERSION_MINOR < 8) -typedef f32 SamplerLayer_t; -#else typedef s32 SamplerLayer_t; -#endif class GameGlobalShaderConstantSetter : public IShaderConstantSetter @@ -448,6 +439,7 @@ class GameGlobalShaderConstantSetter : public IShaderConstantSetter CachedPixelShaderSetting m_camera_offset_pixel; CachedPixelShaderSetting m_camera_offset_vertex; CachedPixelShaderSetting m_base_texture; + CachedPixelShaderSetting m_normal_texture; Client *m_client; public: @@ -481,6 +473,7 @@ class GameGlobalShaderConstantSetter : public IShaderConstantSetter m_camera_offset_pixel("cameraOffset"), m_camera_offset_vertex("cameraOffset"), m_base_texture("baseTexture"), + m_normal_texture("normalTexture"), m_client(client) { g_settings->registerChangedCallback("enable_fog", settingsCallback, this); @@ -533,43 +526,26 @@ class GameGlobalShaderConstantSetter : public IShaderConstantSetter float eye_position_array[3]; v3f epos = m_client->getEnv().getLocalPlayer()->getEyePosition(); -#if (IRRLICHT_VERSION_MAJOR == 1 && IRRLICHT_VERSION_MINOR < 8) - eye_position_array[0] = epos.X; - eye_position_array[1] = epos.Y; - eye_position_array[2] = epos.Z; -#else epos.getAs3Values(eye_position_array); -#endif m_eye_position_pixel.set(eye_position_array, services); m_eye_position_vertex.set(eye_position_array, services); if (m_client->getMinimap()) { float minimap_yaw_array[3]; v3f minimap_yaw = m_client->getMinimap()->getYawVec(); -#if (IRRLICHT_VERSION_MAJOR == 1 && IRRLICHT_VERSION_MINOR < 8) - minimap_yaw_array[0] = minimap_yaw.X; - minimap_yaw_array[1] = minimap_yaw.Y; - minimap_yaw_array[2] = minimap_yaw.Z; -#else minimap_yaw.getAs3Values(minimap_yaw_array); -#endif m_minimap_yaw.set(minimap_yaw_array, services); } float camera_offset_array[3]; v3f offset = intToFloat(m_client->getCamera()->getOffset(), BS); -#if (IRRLICHT_VERSION_MAJOR == 1 && IRRLICHT_VERSION_MINOR < 8) - camera_offset_array[0] = offset.X; - camera_offset_array[1] = offset.Y; - camera_offset_array[2] = offset.Z; -#else offset.getAs3Values(camera_offset_array); -#endif m_camera_offset_pixel.set(camera_offset_array, services); m_camera_offset_vertex.set(camera_offset_array, services); - SamplerLayer_t base_tex = 0; + SamplerLayer_t base_tex = 0, normal_tex = 1; m_base_texture.set(&base_tex, services); + m_normal_texture.set(&normal_tex, services); } }; @@ -608,7 +584,7 @@ class GameGlobalShaderConstantSetterFactory : public IShaderConstantSetterFactor } }; -#ifdef __ANDROID__ +#ifdef HAVE_TOUCHSCREENGUI #define SIZE_TAG "size[11,5.5]" #else #define SIZE_TAG "size[11,5.5,true]" // Fixed size on desktop @@ -620,7 +596,16 @@ class GameGlobalShaderConstantSetterFactory : public IShaderConstantSetterFactor const float object_hit_delay = 0.2; struct FpsControl { - u32 last_time, busy_time, sleep_time; + FpsControl() : last_time(0), busy_time(0), sleep_time(0) {} + + void reset(); + + void limit(IrrlichtDevice *device, f32 *dtime); + + u32 getBusyMs() const { return busy_time / 1000; } + + // all values in microseconds (us) + u64 last_time, busy_time, sleep_time; }; @@ -666,6 +651,8 @@ struct ClientEventHandler void (Game::*handler)(ClientEvent *, CameraOrientation *); }; +using PausedNodesList = std::vector, float>>; + class Game { public: Game(); @@ -673,6 +660,7 @@ class Game { bool startup(bool *kill, InputHandler *input, + RenderingEngine *rendering_engine, const GameStartData &game_params, std::string &error_message, bool *reconnect, @@ -682,8 +670,6 @@ class Game { void run(); void shutdown(); - void extendedResourceCleanup(); - // Basic initialisation bool init(const std::string &map_dir, const std::string &address, u16 port, const SubgameSpec &gamespec); @@ -707,6 +693,7 @@ class Game { bool handleCallbacks(); void processQueues(); void updateProfilers(const RunStats &stats, const FpsControl &draw_times, f32 dtime); + void updateDebugState(); void updateStats(RunStats *stats, const FpsControl &draw_times, f32 dtime); void updateProfilerGraphs(ProfilerGraph *graph); @@ -729,6 +716,7 @@ class Game { void toggleScaffold(); void toggleNextItem(); void toggleCinematic(); + void toggleBlockBounds(); void toggleAutoforward(); void toggleMinimap(bool shift_pressed); @@ -747,9 +735,9 @@ class Game { void updatePlayerControl(const CameraOrientation &cam); void step(f32 *dtime); void processClientEvents(CameraOrientation *cam); - void updateCamera(u32 busy_time, f32 dtime); + void updateCamera(f32 dtime); void updateSound(f32 dtime); - void processPlayerInteraction(f32 dtime, bool show_hud, bool show_debug); + void processPlayerInteraction(f32 dtime, bool show_hud); /*! * Returns the object or node the player is pointing at. * Also updates the selected thing in the Hud. @@ -775,10 +763,9 @@ class Game { const ItemStack &selected_item, const ItemStack &hand_item, f32 dtime); void updateFrame(ProfilerGraph *graph, RunStats *stats, f32 dtime, const CameraOrientation &cam); + void updateShadows(); // Misc - void limitFps(FpsControl *fps_timings, f32 *dtime); - void showOverlayMessage(const char *msg, float dtime, int percent, bool draw_clouds = true); @@ -804,6 +791,9 @@ class Game { void showDeathFormspec(); void showPauseMenu(); + void pauseAnimation(); + void resumeAnimation(); + // ClientEvent handlers void handleClientEvent_None(ClientEvent *event, CameraOrientation *cam); void handleClientEvent_PlayerDamage(ClientEvent *event, CameraOrientation *cam); @@ -824,13 +814,15 @@ class Game { CameraOrientation *cam); void handleClientEvent_CloudParams(ClientEvent *event, CameraOrientation *cam); - void updateChat(f32 dtime, const v2u32 &screensize); + void updateChat(f32 dtime); bool nodePlacement(const ItemDefinition &selected_def, const ItemStack &selected_item, const v3s16 &nodepos, const v3s16 &neighbourpos, const PointedThing &pointed, - const NodeMetadata *meta); + const NodeMetadata *meta, bool force = false); static const ClientEventHandler clientEventHandler[CLIENTEVENT_MAX]; + f32 getSensitivityScaleFactor() const; + InputHandler *input = nullptr; Client *client = nullptr; @@ -865,6 +857,9 @@ class Game { Hud *hud = nullptr; Minimap *mapper = nullptr; + // Map server hud ids to client hud ids + std::unordered_map m_hud_server_to_client; + GameRunData runData; Flags m_flags; @@ -873,12 +868,14 @@ class Game { these items (e.g. device) */ IrrlichtDevice *device; + RenderingEngine *m_rendering_engine; video::IVideoDriver *driver; scene::ISceneManager *smgr; bool *kill; std::string *error_message; bool *reconnect_requested; scene::ISceneNode *skybox; + PausedNodesList paused_animated_nodes; bool simple_singleplayer_mode; /* End 'cache' */ @@ -914,12 +911,17 @@ class Game { bool m_does_lost_focus_pause_game = false; - CameraOrientation cam_view_target = { 0 }; - CameraOrientation cam_view = { 0 }; + CameraOrientation cam_view_target = {}; // added by dragonfireclient + CameraOrientation cam_view = {}; // added by dragonfireclient +#if IRRLICHT_VERSION_MT_REVISION < 5 int m_reset_HW_buffer_counter = 0; -#ifdef __ANDROID__ +#endif + +#ifdef HAVE_TOUCHSCREENGUI bool m_cache_hold_aux1; +#endif +#ifdef __ANDROID__ bool m_android_chat_open; #endif }; @@ -927,6 +929,7 @@ extern Game *g_game; void the_game(bool *kill, InputHandler *input, + RenderingEngine *rendering_engine, const GameStartData &start_data, std::string &error_message, ChatBackend &chat_backend,