Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[no sq] Misc fixes #15661

Merged
merged 4 commits into from
Jan 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions doc/lua_api.md
Original file line number Diff line number Diff line change
Expand Up @@ -5044,7 +5044,7 @@ inside the VoxelManip.
can use `core.emerge_area` to make sure that the area you want to
read/write is already generated.

* Other mods, or the core itself, could possibly modify the area of the map
* Other mods, or the engine itself, could possibly modify the area of the map
currently loaded into a VoxelManip object. With the exception of Mapgen
VoxelManips (see above section), the internal buffers are not updated. For
this reason, it is strongly encouraged to complete the usage of a particular
Expand All @@ -5059,9 +5059,11 @@ inside the VoxelManip.
Methods
-------

* `read_from_map(p1, p2)`: Loads a chunk of map into the VoxelManip object
* `read_from_map(p1, p2)`: Loads a chunk of map into the VoxelManip object
containing the region formed by `p1` and `p2`.
* returns actual emerged `pmin`, actual emerged `pmax`
* Note that calling this multiple times will *add* to the area loaded in the
VoxelManip, and not reset it.
* `write_to_map([light])`: Writes the data loaded from the `VoxelManip` back to
the map.
* **important**: data must be set using `VoxelManip:set_data()` before
Expand Down Expand Up @@ -5120,8 +5122,8 @@ Methods
generated mapchunk above are propagated down into the mapchunk, defaults
to `true` if left out.
* `update_liquids()`: Update liquid flow
* `was_modified()`: Returns `true` if the data in the voxel manipulator has been modified
since it was last read from the map. This means you have to call `get_data` again.
* `was_modified()`: Returns `true` if the data in the VoxelManip has been modified
since it was last read from the map. This means you have to call `get_data()` again.
This only applies to a `VoxelManip` object from `core.get_mapgen_object`,
where the engine will keep the map and the VM in sync automatically.
* Note: this doesn't do what you think it does and is subject to removal. Don't use it!
Expand Down
65 changes: 31 additions & 34 deletions irr/include/SMaterial.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class ITexture;

//! Flag for MaterialTypeParam (in combination with EMT_ONETEXTURE_BLEND) or for BlendFactor
//! BlendFunc = source * sourceFactor + dest * destFactor
enum E_BLEND_FACTOR
enum E_BLEND_FACTOR : u8
{
EBF_ZERO = 0, //!< src & dest (0, 0, 0, 0)
EBF_ONE, //!< src & dest (1, 1, 1, 1)
Expand All @@ -36,7 +36,7 @@ enum E_BLEND_FACTOR
};

//! Values defining the blend operation
enum E_BLEND_OPERATION
enum E_BLEND_OPERATION : u8
{
EBO_NONE = 0, //!< No blending happens
EBO_ADD, //!< Default blending adds the color values
Expand All @@ -51,15 +51,15 @@ enum E_BLEND_OPERATION
};

//! MaterialTypeParam: e.g. DirectX: D3DTOP_MODULATE, D3DTOP_MODULATE2X, D3DTOP_MODULATE4X
enum E_MODULATE_FUNC
enum E_MODULATE_FUNC : u8
{
EMFN_MODULATE_1X = 1,
EMFN_MODULATE_2X = 2,
EMFN_MODULATE_4X = 4
};

//! Comparison function, e.g. for depth buffer test
enum E_COMPARISON_FUNC
enum E_COMPARISON_FUNC : u8
{
//! Depth test disabled (disable also write to depth buffer)
ECFN_DISABLED = 0,
Expand All @@ -82,7 +82,7 @@ enum E_COMPARISON_FUNC
};

//! Enum values for enabling/disabling color planes for rendering
enum E_COLOR_PLANE
enum E_COLOR_PLANE : u8
{
//! No color enabled
ECP_NONE = 0,
Expand All @@ -103,7 +103,7 @@ enum E_COLOR_PLANE
//! Source of the alpha value to take
/** This is currently only supported in EMT_ONETEXTURE_BLEND. You can use an
or'ed combination of values. Alpha values are modulated (multiplied). */
enum E_ALPHA_SOURCE
enum E_ALPHA_SOURCE : u8
{
//! Use no alpha, somewhat redundant with other settings
EAS_NONE = 0,
Expand Down Expand Up @@ -181,7 +181,7 @@ Some drivers don't support a per-material setting of the anti-aliasing
modes. In those cases, FSAA/multisampling is defined by the device mode
chosen upon creation via irr::SIrrCreationParameters.
*/
enum E_ANTI_ALIASING_MODE
enum E_ANTI_ALIASING_MODE : u8
{
//! Use to turn off anti-aliasing for this material
EAAM_OFF = 0,
Expand All @@ -202,7 +202,7 @@ const c8 *const PolygonOffsetDirectionNames[] = {
};

//! For SMaterial.ZWriteEnable
enum E_ZWRITE
enum E_ZWRITE : u8
{
//! zwrite always disabled for this material
EZW_OFF = 0,
Expand Down Expand Up @@ -240,10 +240,10 @@ class SMaterial
//! Default constructor. Creates a solid material
SMaterial() :
MaterialType(EMT_SOLID), ColorParam(0, 0, 0, 0),
MaterialTypeParam(0.0f), Thickness(1.0f), ZBuffer(ECFN_LESSEQUAL),
AntiAliasing(EAAM_SIMPLE), ColorMask(ECP_ALL),
BlendOperation(EBO_NONE), BlendFactor(0.0f), PolygonOffsetDepthBias(0.f),
PolygonOffsetSlopeScale(0.f), Wireframe(false), PointCloud(false),
MaterialTypeParam(0.0f), Thickness(1.0f), BlendFactor(0.0f),
PolygonOffsetDepthBias(0.f), PolygonOffsetSlopeScale(0.f),
ZBuffer(ECFN_LESSEQUAL), AntiAliasing(EAAM_SIMPLE), ColorMask(ECP_ALL),
BlendOperation(EBO_NONE), Wireframe(false), PointCloud(false),
ZWriteEnable(EZW_AUTO),
BackfaceCulling(true), FrontfaceCulling(false), FogEnable(false),
UseMipMaps(true)
Expand All @@ -268,28 +268,6 @@ class SMaterial
//! Thickness of non-3dimensional elements such as lines and points.
f32 Thickness;

//! Is the ZBuffer enabled? Default: ECFN_LESSEQUAL
/** If you want to disable depth test for this material
just set this parameter to ECFN_DISABLED.
Values are from E_COMPARISON_FUNC. */
u8 ZBuffer;

//! Sets the antialiasing mode
/** Values are chosen from E_ANTI_ALIASING_MODE. Default is
EAAM_SIMPLE, i.e. simple multi-sample anti-aliasing. */
u8 AntiAliasing;

//! Defines the enabled color planes
/** Values are defined as or'ed values of the E_COLOR_PLANE enum.
Only enabled color planes will be rendered to the current render
target. Typical use is to disable all colors when rendering only to
depth or stencil buffer, or using Red and Green for Stereo rendering. */
u8 ColorMask : 4;

//! Store the blend operation of choice
/** Values to be chosen from E_BLEND_OPERATION. */
E_BLEND_OPERATION BlendOperation : 4;

//! Store the blend factors
/** textureBlendFunc/textureBlendFuncSeparate functions should be used to write
properly blending factors to this parameter.
Expand All @@ -316,6 +294,25 @@ class SMaterial
and -1.f to pull them towards the camera. */
f32 PolygonOffsetSlopeScale;

//! Is the ZBuffer enabled? Default: ECFN_LESSEQUAL
/** If you want to disable depth test for this material
just set this parameter to ECFN_DISABLED. */
E_COMPARISON_FUNC ZBuffer : 4;

//! Sets the antialiasing mode
/** Default is EAAM_SIMPLE, i.e. simple multi-sample anti-aliasing. */
E_ANTI_ALIASING_MODE AntiAliasing : 4;

//! Defines the enabled color planes
/** Values are defined as or'ed values of the E_COLOR_PLANE enum.
Only enabled color planes will be rendered to the current render
target. Typical use is to disable all colors when rendering only to
depth or stencil buffer, or using Red and Green for Stereo rendering. */
E_COLOR_PLANE ColorMask : 4;

//! Store the blend operation of choice
E_BLEND_OPERATION BlendOperation : 4;

//! Draw as wireframe or filled triangles? Default: false
bool Wireframe : 1;

Expand Down
4 changes: 2 additions & 2 deletions irr/include/SMaterialLayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ static const char *const aTextureClampNames[] = {
//! Texture minification filter.
/** Used when scaling textures down. See the documentation on OpenGL's
`GL_TEXTURE_MIN_FILTER` for more information. */
enum E_TEXTURE_MIN_FILTER
enum E_TEXTURE_MIN_FILTER : u8
{
//! Aka nearest-neighbor.
ETMINF_NEAREST_MIPMAP_NEAREST = 0,
Expand All @@ -61,7 +61,7 @@ enum E_TEXTURE_MIN_FILTER
/** Used when scaling textures up. See the documentation on OpenGL's
`GL_TEXTURE_MAG_FILTER` for more information.
Note that mipmaps are only used for minification, not for magnification. */
enum E_TEXTURE_MAG_FILTER
enum E_TEXTURE_MAG_FILTER : u8
{
//! Aka nearest-neighbor.
ETMAGF_NEAREST = 0,
Expand Down
2 changes: 1 addition & 1 deletion irr/src/CAnimatedMeshSceneNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ void CAnimatedMeshSceneNode::render()
// for debug purposes only:
if (DebugDataVisible && PassCount == 1) {
video::SMaterial debug_mat;
debug_mat.AntiAliasing = 0;
debug_mat.AntiAliasing = video::EAAM_OFF;
driver->setMaterial(debug_mat);
// show normals
if (DebugDataVisible & scene::EDS_NORMALS) {
Expand Down
2 changes: 1 addition & 1 deletion irr/src/CMeshSceneNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ void CMeshSceneNode::render()
// for debug purposes only:
if (DebugDataVisible && PassCount == 1) {
video::SMaterial m;
m.AntiAliasing = 0;
m.AntiAliasing = video::EAAM_OFF;
m.ZBuffer = video::ECFN_DISABLED;
driver->setMaterial(m);

Expand Down
2 changes: 1 addition & 1 deletion irr/src/CNullDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1311,7 +1311,7 @@ void CNullDriver::runOcclusionQuery(scene::ISceneNode *node, bool visible)
OcclusionQueries[index].Run = 0;
if (!visible) {
SMaterial mat;
mat.AntiAliasing = 0;
mat.AntiAliasing = video::EAAM_OFF;
mat.ColorMask = ECP_NONE;
mat.ZWriteEnable = EZW_OFF;
setMaterial(mat);
Expand Down
2 changes: 1 addition & 1 deletion src/client/render/anaglyph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ void SetColorMaskStep::run(PipelineContext &context)
{
video::SOverrideMaterial &mat = context.device->getVideoDriver()->getOverrideMaterial();
mat.reset();
mat.Material.ColorMask = color_mask;
mat.Material.ColorMask = static_cast<video::E_COLOR_PLANE>(color_mask);
mat.EnableProps = video::EMP_COLOR_MASK;
mat.EnablePasses = scene::ESNRP_SKY_BOX | scene::ESNRP_SOLID |
scene::ESNRP_TRANSPARENT | scene::ESNRP_TRANSPARENT_EFFECT;
Expand Down
2 changes: 1 addition & 1 deletion src/client/render/secondstage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ PostProcessingStep::PostProcessingStep(u32 _shader_id, const std::vector<u8> &_t
void PostProcessingStep::configureMaterial()
{
material.UseMipMaps = false;
material.ZBuffer = true;
material.ZBuffer = video::ECFN_LESSEQUAL;
material.ZWriteEnable = video::EZW_ON;
for (u32 k = 0; k < texture_map.size(); ++k) {
material.TextureLayers[k].AnisotropicFilter = 0;
Expand Down
2 changes: 1 addition & 1 deletion src/client/sky.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ static video::SMaterial baseMaterial()
video::SMaterial mat;
mat.ZBuffer = video::ECFN_DISABLED;
mat.ZWriteEnable = video::EZW_OFF;
mat.AntiAliasing = 0;
mat.AntiAliasing = video::EAAM_OFF;
mat.TextureLayers[0].TextureWrapU = video::ETC_CLAMP_TO_EDGE;
mat.TextureLayers[0].TextureWrapV = video::ETC_CLAMP_TO_EDGE;
mat.BackfaceCulling = false;
Expand Down
7 changes: 5 additions & 2 deletions src/content/mod_configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ void ModConfiguration::addMods(const std::vector<ModSpec> &new_mods)
}

// Add new mods
for (int want_from_modpack = 1; want_from_modpack >= 0; --want_from_modpack) {
for (bool want_from_modpack : {true, false}) {
// First iteration:
// Add all the mods that come from modpacks
// Second iteration:
Expand All @@ -56,9 +56,12 @@ void ModConfiguration::addMods(const std::vector<ModSpec> &new_mods)
std::set<std::string> seen_this_iteration;

for (const ModSpec &mod : new_mods) {
if (mod.part_of_modpack != (bool)want_from_modpack)
if (mod.part_of_modpack != want_from_modpack)
continue;

// unrelated to this code, but we want to assert it somewhere
assert(fs::IsPathAbsolute(mod.path));

if (existing_mods.count(mod.name) == 0) {
// GOOD CASE: completely new mod.
m_unsatisfied_mods.push_back(mod);
Expand Down
3 changes: 2 additions & 1 deletion src/content/mods.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,14 +167,15 @@ std::map<std::string, ModSpec> getModsInPath(

mod_path.clear();
mod_path.append(path).append(DIR_DELIM).append(modname);
mod_path = fs::AbsolutePath(mod_path);

mod_virtual_path.clear();
// Intentionally uses / to keep paths same on different platforms
mod_virtual_path.append(virtual_path).append("/").append(modname);

ModSpec spec(modname, mod_path, part_of_modpack, mod_virtual_path);
parseModContents(spec);
result.insert(std::make_pair(modname, spec));
result[modname] = std::move(spec);
}
return result;
}
Expand Down
2 changes: 1 addition & 1 deletion src/content/mods.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ struct ModSpec
{
std::string name;
std::string author;
std::string path;
std::string path; // absolute path on disk
std::string desc;
int release = 0;

Expand Down
17 changes: 5 additions & 12 deletions src/map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -752,17 +752,12 @@ MMVManip::MMVManip(Map *map):
assert(map);
}

void MMVManip::initialEmerge(v3s16 blockpos_min, v3s16 blockpos_max,
bool load_if_inexistent)
void MMVManip::initialEmerge(v3s16 p_min, v3s16 p_max, bool load_if_inexistent)
{
TimeTaker timer1("initialEmerge", &emerge_time);

assert(m_map);

// Units of these are MapBlocks
v3s16 p_min = blockpos_min;
v3s16 p_max = blockpos_max;

VoxelArea block_area_nodes
(p_min*MAP_BLOCKSIZE, (p_max+1)*MAP_BLOCKSIZE-v3s16(1,1,1));

Expand All @@ -775,6 +770,7 @@ void MMVManip::initialEmerge(v3s16 blockpos_min, v3s16 blockpos_max,
infostream<<std::endl;
}

const bool all_new = m_area.hasEmptyExtent() || block_area_nodes.contains(m_area);
addArea(block_area_nodes);

for(s32 z=p_min.Z; z<=p_max.Z; z++)
Expand Down Expand Up @@ -812,16 +808,12 @@ void MMVManip::initialEmerge(v3s16 blockpos_min, v3s16 blockpos_max,
setFlags(a, VOXELFLAG_NO_DATA);
}
}
/*else if (block->getNode(0, 0, 0).getContent() == CONTENT_IGNORE)
{
// Mark that block was loaded as blank
flags |= VMANIP_BLOCK_CONTAINS_CIGNORE;
}*/

m_loaded_blocks[p] = flags;
}

m_is_dirty = false;
if (all_new)
m_is_dirty = false;
}

void MMVManip::blitBackAll(std::map<v3s16, MapBlock*> *modified_blocks,
Expand All @@ -834,6 +826,7 @@ void MMVManip::blitBackAll(std::map<v3s16, MapBlock*> *modified_blocks,
/*
Copy data of all blocks
*/
assert(!m_loaded_blocks.empty());
for (auto &loaded_block : m_loaded_blocks) {
v3s16 p = loaded_block.first;
MapBlock *block = m_map->getBlockNoCreateNoEx(p);
Expand Down
7 changes: 4 additions & 3 deletions src/map.h
Original file line number Diff line number Diff line change
Expand Up @@ -298,9 +298,6 @@ class Map /*: public NodeContainer*/
u32 needed_count);
};

#define VMANIP_BLOCK_DATA_INEXIST 1
#define VMANIP_BLOCK_CONTAINS_CIGNORE 2

class MMVManip : public VoxelManipulator
{
public:
Expand Down Expand Up @@ -344,4 +341,8 @@ class MMVManip : public VoxelManipulator
value = flags describing the block
*/
std::map<v3s16, u8> m_loaded_blocks;

enum : u8 {
VMANIP_BLOCK_DATA_INEXIST = 1 << 0,
};
};
13 changes: 13 additions & 0 deletions src/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,11 @@ void Server::AsyncRunStep(float dtime, bool initial_step)
ZoneScoped;
auto framemarker = FrameMarker("Server::AsyncRunStep()-frame").started();

if (!m_async_fatal_error.get().empty()) {
infostream << "Refusing server step in error state" << std::endl;
return;
}

{
// Send blocks to clients
SendBlocks(dtime);
Expand Down Expand Up @@ -3854,6 +3859,14 @@ std::string Server::getBuiltinLuaPath()
return porting::path_share + DIR_DELIM + "builtin";
}

void Server::setAsyncFatalError(const std::string &error)
{
m_async_fatal_error.set(error);
// make sure server steps stop happening immediately
if (m_thread)
m_thread->stop();
}

// Not thread-safe.
void Server::addShutdownError(const ModError &e)
{
Expand Down
Loading
Loading