Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
proller committed Oct 17, 2024
1 parent 56d9c82 commit 2aeef60
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 8 deletions.
3 changes: 2 additions & 1 deletion src/client/fm_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ void Client::handleCommand_FreeminerInit(NetworkPacket *pkt)
<< "' not valid; falling back to "
<< Mapgen::getMapgenName(FARMESH_DEFAULT_MAPGEN) << std::endl;
mgtype = FARMESH_DEFAULT_MAPGEN;
far_container.use_weather = false;
}

MakeEmerge(settings, mgtype);
Expand Down Expand Up @@ -230,7 +231,7 @@ void Client::handleCommand_BlockDataFm(NetworkPacket *pkt)
block->humidity = h;

if (m_localdb && !is_simple_singleplayer_game) {
if (const auto db = GetFarDatabase({}, far_dbases, m_world_path, step); db) {
if (const auto db = GetFarDatabase({}, far_dbases, m_world_path, step); db) {
ServerMap::saveBlock(block.get(), db);

if (!step) {
Expand Down
2 changes: 1 addition & 1 deletion src/client/fm_far_container.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ const MapNode &FarContainer::getNodeRefUnsafe(const v3pos_t &pos)
block_cache = block;
}

if (const auto &v = m_mg->visible_content(pos); v.getContent()) {
if (const auto &v = m_mg->visible_content(pos, use_weather); v.getContent()) {
return v;
}

Expand Down
2 changes: 1 addition & 1 deletion src/client/fm_far_container.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class FarContainer : public NodeContainer

public:
Mapgen *m_mg{};

bool use_weather {true};
FarContainer(Client *client);
const MapNode &getNodeRefUnsafe(const v3pos_t &p) override;
};
1 change: 1 addition & 0 deletions src/client/fm_farmesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ FarMesh::FarMesh(Client *client, Server *server, MapDrawControl *control) :
settings.set("mg_name", Mapgen::getMapgenName(mgtype));
m_client->MakeEmerge(settings, mgtype);
emerge_use = m_client->m_emerge.get();
m_client->far_container.use_weather = false;
}

if (emerge_use) {
Expand Down
4 changes: 3 additions & 1 deletion src/mapgen/mapgen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1229,12 +1229,14 @@ bool Mapgen::visible(const v3pos_t &p)
return getGroundLevelAtPoint({p.X, p.Z}) >= p.Y;
}

const MapNode &Mapgen::visible_content(const v3pos_t &p)
const MapNode &Mapgen::visible_content(const v3pos_t &p, bool use_weather)
{
const auto v = visible(p);
const auto vw = visible_water_level(p);
if (!v && !vw)
return visible_transparent;
if (!use_weather)
return visible_surface_green;
const auto heat = m_emerge->biomemgr->calcBlockHeat(p, seed,
env ? env->getTimeOfDay() * env->m_time_of_day_speed : 0,
env ? env->getGameTime() : 0, !!env && env->m_use_weather);
Expand Down
2 changes: 1 addition & 1 deletion src/mapgen/mapgen.h
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ class Mapgen {

virtual bool visible(const v3pos_t &p);
virtual bool visible_water_level(const v3pos_t &p);
virtual const MapNode &visible_content(const v3pos_t &p);
virtual const MapNode &visible_content(const v3pos_t &p, bool use_weather);
virtual bool surface_2d() { return true; };

// getSpawnLevelAtPoint() is a function within each mapgen that returns a
Expand Down
8 changes: 6 additions & 2 deletions src/mapgen/mapgen_earth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,12 +218,16 @@ bool MapgenEarth::visible(const v3pos_t &p)
return p.Y < get_height(p.X, p.Z);
}

const MapNode &MapgenEarth::visible_content(const v3pos_t &p)
const MapNode &MapgenEarth::visible_content(const v3pos_t &p, bool use_weather)
{
const auto v = visible(p);
const auto vw = visible_water_level(p);
if (!v && !vw)
if (!v && !vw) {
return visible_transparent;
}
if (!use_weather) {
return visible_surface_green;
}
auto heat = 10;
heat += p.Y / -100; // upper=colder, lower=hotter, 3c per 1000

Expand Down
2 changes: 1 addition & 1 deletion src/mapgen/mapgen_earth.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class MapgenEarth : public MapgenV7

MapNode layers_get(float value, float max);
bool visible(const v3pos_t &p) override;
const MapNode &visible_content(const v3pos_t &p) override;
const MapNode &visible_content(const v3pos_t &p, bool use_weather) override;

hgts hgt_reader;

Expand Down

0 comments on commit 2aeef60

Please sign in to comment.