Skip to content

Commit ccdd886

Browse files
committedMay 3, 2021
refacto: Hud: make driver, client, player, inventory, tsrc private & drop unused guienv
also fix c_content.h, on client it includes the src/client/hud.h instead of src/hud.h, which leads to wrong file dependency on the lua stack
1 parent a47a002 commit ccdd886

File tree

4 files changed

+12
-14
lines changed

4 files changed

+12
-14
lines changed
 

‎src/client/game.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1389,7 +1389,7 @@ bool Game::createClient(const GameStartData &start_data)
13891389
player->hurt_tilt_timer = 0;
13901390
player->hurt_tilt_strength = 0;
13911391

1392-
hud = new Hud(guienv, client, player, &player->inventory);
1392+
hud = new Hud(client, player, &player->inventory);
13931393

13941394
mapper = client->getMinimap();
13951395

‎src/client/hud.cpp

+3-4
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,10 @@ with this program; if not, write to the Free Software Foundation, Inc.,
4545
#define OBJECT_CROSSHAIR_LINE_SIZE 8
4646
#define CROSSHAIR_LINE_SIZE 10
4747

48-
Hud::Hud(gui::IGUIEnvironment *guienv, Client *client, LocalPlayer *player,
48+
Hud::Hud(Client *client, LocalPlayer *player,
4949
Inventory *inventory)
5050
{
5151
driver = RenderingEngine::get_video_driver();
52-
this->guienv = guienv;
5352
this->client = client;
5453
this->player = player;
5554
this->inventory = inventory;
@@ -315,7 +314,7 @@ bool Hud::calculateScreenPos(const v3s16 &camera_offset, HudElement *e, v2s32 *p
315314
{
316315
v3f w_pos = e->world_pos * BS;
317316
scene::ICameraSceneNode* camera =
318-
RenderingEngine::get_scene_manager()->getActiveCamera();
317+
client->getSceneManager()->getActiveCamera();
319318
w_pos -= intToFloat(camera_offset, BS);
320319
core::matrix4 trans = camera->getProjectionMatrix();
321320
trans *= camera->getViewMatrix();
@@ -475,7 +474,7 @@ void Hud::drawLuaElements(const v3s16 &camera_offset)
475474

476475
// Angle according to camera view
477476
v3f fore(0.f, 0.f, 1.f);
478-
scene::ICameraSceneNode *cam = RenderingEngine::get_scene_manager()->getActiveCamera();
477+
scene::ICameraSceneNode *cam = client->getSceneManager()->getActiveCamera();
479478
cam->getAbsoluteTransformation().rotateVect(fore);
480479
int angle = - fore.getHorizontalAngle().Y;
481480

‎src/client/hud.h

+7-8
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,6 @@ struct ItemStack;
3535
class Hud
3636
{
3737
public:
38-
video::IVideoDriver *driver;
39-
gui::IGUIEnvironment *guienv;
40-
Client *client;
41-
LocalPlayer *player;
42-
Inventory *inventory;
43-
ITextureSource *tsrc;
44-
4538
video::SColor crosshair_argb;
4639
video::SColor selectionbox_argb;
4740

@@ -54,7 +47,7 @@ class Hud
5447

5548
bool pointing_at_object = false;
5649

57-
Hud(gui::IGUIEnvironment *guienv, Client *client, LocalPlayer *player,
50+
Hud(Client *client, LocalPlayer *player,
5851
Inventory *inventory);
5952
~Hud();
6053

@@ -105,6 +98,12 @@ class Hud
10598
void drawCompassRotate(HudElement *e, video::ITexture *texture,
10699
const core::rect<s32> &rect, int way);
107100

101+
Client *client = nullptr;
102+
video::IVideoDriver *driver = nullptr;
103+
LocalPlayer *player = nullptr;
104+
Inventory *inventory = nullptr;
105+
ITextureSource *tsrc = nullptr;
106+
108107
float m_hud_scaling; // cached minetest setting
109108
float m_scale_factor;
110109
v3s16 m_camera_offset;

‎src/script/common/c_content.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ extern "C" {
3939
#include "itemgroup.h"
4040
#include "itemdef.h"
4141
#include "c_types.h"
42-
#include "hud.h"
42+
#include "../../hud.h"
4343

4444
namespace Json { class Value; }
4545

0 commit comments

Comments
 (0)
Please sign in to comment.