Skip to content

Commit de85bc9

Browse files
committedMay 3, 2021
fix: some code tidy about includes & irr namespaces
1 parent 48d5abd commit de85bc9

14 files changed

+59
-65
lines changed
 

‎src/client/client.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1475,7 +1475,7 @@ bool Client::updateWieldedItem()
14751475
return true;
14761476
}
14771477

1478-
irr::scene::ISceneManager* Client::getSceneManager()
1478+
scene::ISceneManager* Client::getSceneManager()
14791479
{
14801480
return m_rendering_engine->get_scene_manager();
14811481
}

‎src/client/client.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ class Client : public con::PeerHandler, public InventoryManager, public IGameDef
356356
void setCamera(Camera* camera) { m_camera = camera; }
357357

358358
Camera* getCamera () { return m_camera; }
359-
irr::scene::ISceneManager *getSceneManager();
359+
scene::ISceneManager *getSceneManager();
360360

361361
bool shouldShowMinimap() const;
362362

‎src/client/clientobject.h

+1-5
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,13 @@ class LocalPlayer;
3333
struct ItemStack;
3434
class WieldMeshSceneNode;
3535

36-
namespace irr { namespace scene {
37-
class ISceneManager;
38-
}}
39-
4036
class ClientActiveObject : public ActiveObject
4137
{
4238
public:
4339
ClientActiveObject(u16 id, Client *client, ClientEnvironment *env);
4440
virtual ~ClientActiveObject();
4541

46-
virtual void addToScene(ITextureSource *tsrc, irr::scene::ISceneManager *smgr) = 0;
42+
virtual void addToScene(ITextureSource *tsrc, scene::ISceneManager *smgr) = 0;
4743
virtual void removeFromScene(bool permanent) {}
4844

4945
virtual void updateLight(u32 day_night_ratio) {}

‎src/client/clouds.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
3030
// Menu clouds are created later
3131
class Clouds;
3232
Clouds *g_menuclouds = NULL;
33-
irr::scene::ISceneManager *g_menucloudsmgr = NULL;
33+
scene::ISceneManager *g_menucloudsmgr = NULL;
3434

3535
// Constant for now
3636
static constexpr const float cloud_size = BS * 64.0f;

‎src/client/clouds.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ class Clouds;
2929
extern Clouds *g_menuclouds;
3030

3131
// Scene manager used for menu clouds
32-
namespace irr{namespace scene{class ISceneManager;}}
33-
extern irr::scene::ISceneManager *g_menucloudsmgr;
32+
extern scene::ISceneManager *g_menucloudsmgr;
3433

3534
class Clouds : public scene::ISceneNode
3635
{

‎src/client/content_cao.cpp

+7-7
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ class TestCAO : public ClientActiveObject
188188

189189
static ClientActiveObject* create(Client *client, ClientEnvironment *env);
190190

191-
void addToScene(ITextureSource *tsrc, irr::scene::ISceneManager *smgr);
191+
void addToScene(ITextureSource *tsrc, scene::ISceneManager *smgr);
192192
void removeFromScene(bool permanent);
193193
void updateLight(u32 day_night_ratio);
194194
void updateNodePos();
@@ -219,7 +219,7 @@ ClientActiveObject* TestCAO::create(Client *client, ClientEnvironment *env)
219219
return new TestCAO(client, env);
220220
}
221221

222-
void TestCAO::addToScene(ITextureSource *tsrc, irr::scene::ISceneManager *smgr)
222+
void TestCAO::addToScene(ITextureSource *tsrc, scene::ISceneManager *smgr)
223223
{
224224
if(m_node != NULL)
225225
return;
@@ -590,7 +590,7 @@ void GenericCAO::removeFromScene(bool permanent)
590590
m_client->getMinimap()->removeMarker(&m_marker);
591591
}
592592

593-
void GenericCAO::addToScene(ITextureSource *tsrc, irr::scene::ISceneManager *smgr)
593+
void GenericCAO::addToScene(ITextureSource *tsrc, scene::ISceneManager *smgr)
594594
{
595595
m_smgr = smgr;
596596

@@ -1484,10 +1484,10 @@ void GenericCAO::updateBonePosition()
14841484
if (m_bone_position.empty() || !m_animated_meshnode)
14851485
return;
14861486

1487-
m_animated_meshnode->setJointMode(irr::scene::EJUOR_CONTROL); // To write positions to the mesh on render
1487+
m_animated_meshnode->setJointMode(scene::EJUOR_CONTROL); // To write positions to the mesh on render
14881488
for (auto &it : m_bone_position) {
14891489
std::string bone_name = it.first;
1490-
irr::scene::IBoneSceneNode* bone = m_animated_meshnode->getJointNode(bone_name.c_str());
1490+
scene::IBoneSceneNode* bone = m_animated_meshnode->getJointNode(bone_name.c_str());
14911491
if (bone) {
14921492
bone->setPosition(it.second.X);
14931493
bone->setRotation(it.second.Y);
@@ -1496,7 +1496,7 @@ void GenericCAO::updateBonePosition()
14961496

14971497
// search through bones to find mistakenly rotated bones due to bug in Irrlicht
14981498
for (u32 i = 0; i < m_animated_meshnode->getJointCount(); ++i) {
1499-
irr::scene::IBoneSceneNode *bone = m_animated_meshnode->getJointNode(i);
1499+
scene::IBoneSceneNode *bone = m_animated_meshnode->getJointNode(i);
15001500
if (!bone)
15011501
continue;
15021502

@@ -1924,7 +1924,7 @@ void GenericCAO::updateMeshCulling()
19241924
return;
19251925
}
19261926

1927-
irr::scene::ISceneNode *node = getSceneNode();
1927+
scene::ISceneNode *node = getSceneNode();
19281928
if (!node)
19291929
return;
19301930

‎src/client/content_cao.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ class GenericCAO : public ClientActiveObject
236236

237237
void removeFromScene(bool permanent);
238238

239-
void addToScene(ITextureSource *tsrc, irr::scene::ISceneManager *smgr);
239+
void addToScene(ITextureSource *tsrc, scene::ISceneManager *smgr);
240240

241241
inline void expireVisuals()
242242
{

‎src/client/content_mapblock.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ static constexpr u16 quad_indices[] = {0, 1, 2, 2, 3, 0};
6161
const std::string MapblockMeshGenerator::raillike_groupname = "connect_to_raillike";
6262

6363
MapblockMeshGenerator::MapblockMeshGenerator(MeshMakeData *input, MeshCollector *output,
64-
irr::scene::IMeshManipulator *mm):
64+
scene::IMeshManipulator *mm):
6565
data(input),
6666
collector(output),
6767
nodedef(data->m_client->ndef()),

‎src/client/content_mapblock.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ class MapblockMeshGenerator
173173

174174
public:
175175
MapblockMeshGenerator(MeshMakeData *input, MeshCollector *output,
176-
irr::scene::IMeshManipulator *mm);
176+
scene::IMeshManipulator *mm);
177177
void generate();
178178
void renderSingle(content_t node, u8 param2 = 0x00);
179179
};

‎src/client/game.cpp

+39-39
Original file line numberDiff line numberDiff line change
@@ -839,7 +839,7 @@ class Game {
839839
MapDrawControl *draw_control = nullptr;
840840
Camera *camera = nullptr;
841841
Clouds *clouds = nullptr; // Free using ->Drop()
842-
Sky *m_sky = nullptr; // Free using ->Drop()
842+
Sky *sky = nullptr; // Free using ->Drop()
843843
Hud *hud = nullptr;
844844
Minimap *mapper = nullptr;
845845

@@ -1159,8 +1159,8 @@ void Game::shutdown()
11591159
if (gui_chat_console)
11601160
gui_chat_console->drop();
11611161

1162-
if (m_sky)
1163-
m_sky->drop();
1162+
if (sky)
1163+
sky->drop();
11641164

11651165
/* cleanup menus */
11661166
while (g_menumgr.menuCount() > 0) {
@@ -1346,8 +1346,8 @@ bool Game::createClient(const GameStartData &start_data)
13461346

13471347
/* Skybox
13481348
*/
1349-
m_sky = new Sky(-1, m_rendering_engine, texture_src, shader_src);
1350-
scsf->setSky(m_sky);
1349+
sky = new Sky(-1, m_rendering_engine, texture_src, shader_src);
1350+
scsf->setSky(sky);
13511351
skybox = NULL; // This is used/set later on in the main run loop
13521352

13531353
/* Pre-calculated values
@@ -2754,51 +2754,51 @@ void Game::handleClientEvent_HudChange(ClientEvent *event, CameraOrientation *ca
27542754

27552755
void Game::handleClientEvent_SetSky(ClientEvent *event, CameraOrientation *cam)
27562756
{
2757-
m_sky->setVisible(false);
2757+
sky->setVisible(false);
27582758
// Whether clouds are visible in front of a custom skybox.
2759-
m_sky->setCloudsEnabled(event->set_sky->clouds);
2759+
sky->setCloudsEnabled(event->set_sky->clouds);
27602760

27612761
if (skybox) {
27622762
skybox->remove();
27632763
skybox = NULL;
27642764
}
27652765
// Clear the old textures out in case we switch rendering type.
2766-
m_sky->clearSkyboxTextures();
2766+
sky->clearSkyboxTextures();
27672767
// Handle according to type
27682768
if (event->set_sky->type == "regular") {
27692769
// Shows the mesh skybox
2770-
m_sky->setVisible(true);
2770+
sky->setVisible(true);
27712771
// Update mesh based skybox colours if applicable.
2772-
m_sky->setSkyColors(event->set_sky->sky_color);
2773-
m_sky->setHorizonTint(
2772+
sky->setSkyColors(event->set_sky->sky_color);
2773+
sky->setHorizonTint(
27742774
event->set_sky->fog_sun_tint,
27752775
event->set_sky->fog_moon_tint,
27762776
event->set_sky->fog_tint_type
27772777
);
27782778
} else if (event->set_sky->type == "skybox" &&
27792779
event->set_sky->textures.size() == 6) {
27802780
// Disable the dyanmic mesh skybox:
2781-
m_sky->setVisible(false);
2781+
sky->setVisible(false);
27822782
// Set fog colors:
2783-
m_sky->setFallbackBgColor(event->set_sky->bgcolor);
2783+
sky->setFallbackBgColor(event->set_sky->bgcolor);
27842784
// Set sunrise and sunset fog tinting:
2785-
m_sky->setHorizonTint(
2785+
sky->setHorizonTint(
27862786
event->set_sky->fog_sun_tint,
27872787
event->set_sky->fog_moon_tint,
27882788
event->set_sky->fog_tint_type
27892789
);
27902790
// Add textures to skybox.
27912791
for (int i = 0; i < 6; i++)
2792-
m_sky->addTextureToSkybox(event->set_sky->textures[i], i, texture_src);
2792+
sky->addTextureToSkybox(event->set_sky->textures[i], i, texture_src);
27932793
} else {
27942794
// Handle everything else as plain color.
27952795
if (event->set_sky->type != "plain")
27962796
infostream << "Unknown sky type: "
27972797
<< (event->set_sky->type) << std::endl;
2798-
m_sky->setVisible(false);
2799-
m_sky->setFallbackBgColor(event->set_sky->bgcolor);
2798+
sky->setVisible(false);
2799+
sky->setFallbackBgColor(event->set_sky->bgcolor);
28002800
// Disable directional sun/moon tinting on plain or invalid skyboxes.
2801-
m_sky->setHorizonTint(
2801+
sky->setHorizonTint(
28022802
event->set_sky->bgcolor,
28032803
event->set_sky->bgcolor,
28042804
"custom"
@@ -2810,30 +2810,30 @@ void Game::handleClientEvent_SetSky(ClientEvent *event, CameraOrientation *cam)
28102810

28112811
void Game::handleClientEvent_SetSun(ClientEvent *event, CameraOrientation *cam)
28122812
{
2813-
m_sky->setSunVisible(event->sun_params->visible);
2814-
m_sky->setSunTexture(event->sun_params->texture,
2813+
sky->setSunVisible(event->sun_params->visible);
2814+
sky->setSunTexture(event->sun_params->texture,
28152815
event->sun_params->tonemap, texture_src);
2816-
m_sky->setSunScale(event->sun_params->scale);
2817-
m_sky->setSunriseVisible(event->sun_params->sunrise_visible);
2818-
m_sky->setSunriseTexture(event->sun_params->sunrise, texture_src);
2816+
sky->setSunScale(event->sun_params->scale);
2817+
sky->setSunriseVisible(event->sun_params->sunrise_visible);
2818+
sky->setSunriseTexture(event->sun_params->sunrise, texture_src);
28192819
delete event->sun_params;
28202820
}
28212821

28222822
void Game::handleClientEvent_SetMoon(ClientEvent *event, CameraOrientation *cam)
28232823
{
2824-
m_sky->setMoonVisible(event->moon_params->visible);
2825-
m_sky->setMoonTexture(event->moon_params->texture,
2824+
sky->setMoonVisible(event->moon_params->visible);
2825+
sky->setMoonTexture(event->moon_params->texture,
28262826
event->moon_params->tonemap, texture_src);
2827-
m_sky->setMoonScale(event->moon_params->scale);
2827+
sky->setMoonScale(event->moon_params->scale);
28282828
delete event->moon_params;
28292829
}
28302830

28312831
void Game::handleClientEvent_SetStars(ClientEvent *event, CameraOrientation *cam)
28322832
{
2833-
m_sky->setStarsVisible(event->star_params->visible);
2834-
m_sky->setStarCount(event->star_params->count, false);
2835-
m_sky->setStarColor(event->star_params->starcolor);
2836-
m_sky->setStarScale(event->star_params->scale);
2833+
sky->setStarsVisible(event->star_params->visible);
2834+
sky->setStarCount(event->star_params->count, false);
2835+
sky->setStarColor(event->star_params->starcolor);
2836+
sky->setStarScale(event->star_params->scale);
28372837
delete event->star_params;
28382838
}
28392839

@@ -3710,7 +3710,7 @@ void Game::updateFrame(ProfilerGraph *graph, RunStats *stats, f32 dtime,
37103710
direct_brightness = time_brightness;
37113711
sunlight_seen = true;
37123712
} else {
3713-
float old_brightness = m_sky->getBrightness();
3713+
float old_brightness = sky->getBrightness();
37143714
direct_brightness = client->getEnv().getClientMap()
37153715
.getBackgroundBrightness(MYMIN(runData.fog_range * 1.2, 60 * BS),
37163716
daynight_ratio, (int)(old_brightness * 255.5), &sunlight_seen)
@@ -3737,15 +3737,15 @@ void Game::updateFrame(ProfilerGraph *graph, RunStats *stats, f32 dtime,
37373737

37383738
runData.time_of_day_smooth = time_of_day_smooth;
37393739

3740-
m_sky->update(time_of_day_smooth, time_brightness, direct_brightness,
3740+
sky->update(time_of_day_smooth, time_brightness, direct_brightness,
37413741
sunlight_seen, camera->getCameraMode(), player->getYaw(),
37423742
player->getPitch());
37433743

37443744
/*
37453745
Update clouds
37463746
*/
37473747
if (clouds) {
3748-
if (m_sky->getCloudsVisible()) {
3748+
if (sky->getCloudsVisible()) {
37493749
clouds->setVisible(true);
37503750
clouds->step(dtime);
37513751
// camera->getPosition is not enough for 3rd person views
@@ -3755,14 +3755,14 @@ void Game::updateFrame(ProfilerGraph *graph, RunStats *stats, f32 dtime,
37553755
camera_node_position.Y = camera_node_position.Y + camera_offset.Y * BS;
37563756
camera_node_position.Z = camera_node_position.Z + camera_offset.Z * BS;
37573757
clouds->update(camera_node_position,
3758-
m_sky->getCloudColor());
3758+
sky->getCloudColor());
37593759
if (clouds->isCameraInsideCloud() && m_cache_enable_fog) {
37603760
// if inside clouds, and fog enabled, use that as sky
37613761
// color(s)
37623762
video::SColor clouds_dark = clouds->getColor()
37633763
.getInterpolated(video::SColor(255, 0, 0, 0), 0.9);
3764-
m_sky->overrideColors(clouds_dark, clouds->getColor());
3765-
m_sky->setInClouds(true);
3764+
sky->overrideColors(clouds_dark, clouds->getColor());
3765+
sky->setInClouds(true);
37663766
runData.fog_range = std::fmin(runData.fog_range * 0.5f, 32.0f * BS);
37673767
// do not draw clouds after all
37683768
clouds->setVisible(false);
@@ -3783,7 +3783,7 @@ void Game::updateFrame(ProfilerGraph *graph, RunStats *stats, f32 dtime,
37833783

37843784
if (m_cache_enable_fog) {
37853785
driver->setFog(
3786-
m_sky->getBgColor(),
3786+
sky->getBgColor(),
37873787
video::EFT_FOG_LINEAR,
37883788
runData.fog_range * m_cache_fog_start,
37893789
runData.fog_range * 1.0,
@@ -3793,7 +3793,7 @@ void Game::updateFrame(ProfilerGraph *graph, RunStats *stats, f32 dtime,
37933793
);
37943794
} else {
37953795
driver->setFog(
3796-
m_sky->getBgColor(),
3796+
sky->getBgColor(),
37973797
video::EFT_FOG_LINEAR,
37983798
100000 * BS,
37993799
110000 * BS,
@@ -3873,7 +3873,7 @@ void Game::updateFrame(ProfilerGraph *graph, RunStats *stats, f32 dtime,
38733873
/*
38743874
Drawing begins
38753875
*/
3876-
const video::SColor &skycolor = m_sky->getSkyColor();
3876+
const video::SColor &skycolor = sky->getSkyColor();
38773877

38783878
TimeTaker tt_draw("Draw scene");
38793879
driver->beginScene(true, true, skycolor);

‎src/client/renderingengine.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ bool RenderingEngine::print_video_modes()
225225
return videomode_list != NULL;
226226
}
227227

228-
void RenderingEngine::removeMesh(const irr::scene::IMesh* mesh)
228+
void RenderingEngine::removeMesh(const scene::IMesh* mesh)
229229
{
230230
m_device->getSceneManager()->getMeshCache()->removeMesh(mesh);
231231
}

‎src/client/renderingengine.h

+1-4
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
2626
#include "irrlichttypes_extrabloated.h"
2727
#include "debug.h"
2828

29-
namespace irr { namespace scene {
30-
class IMesh;
31-
}}
3229
class ITextureSource;
3330
class Camera;
3431
class Client;
@@ -60,7 +57,7 @@ class RenderingEngine
6057
static bool print_video_modes();
6158
void cleanupMeshCache();
6259

63-
void removeMesh(const irr::scene::IMesh* mesh);
60+
void removeMesh(const scene::IMesh* mesh);
6461

6562
static v2u32 getWindowSize()
6663
{

‎src/script/common/c_content.h

+2
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ extern "C" {
3939
#include "itemgroup.h"
4040
#include "itemdef.h"
4141
#include "c_types.h"
42+
// We do a explicit path include because by default c_content.h include src/client/hud.h
43+
// prior to the src/hud.h, which is not good on server only build
4244
#include "../../hud.h"
4345

4446
namespace Json { class Value; }

‎src/unittest/test_clientactiveobjectmgr.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class TestClientActiveObject : public ClientActiveObject
2929
TestClientActiveObject() : ClientActiveObject(0, nullptr, nullptr) {}
3030
~TestClientActiveObject() = default;
3131
ActiveObjectType getType() const { return ACTIVEOBJECT_TYPE_TEST; }
32-
virtual void addToScene(ITextureSource *tsrc, irr::scene::ISceneManager *smgr) {}
32+
virtual void addToScene(ITextureSource *tsrc, scene::ISceneManager *smgr) {}
3333
};
3434

3535
class TestClientActiveObjectMgr : public TestBase

0 commit comments

Comments
 (0)
Please sign in to comment.