mirror of
				https://github.com/luanti-org/luanti.git
				synced 2025-11-04 01:05:48 +01:00 
			
		
		
		
	Clean nodefeat and content_mapnode a bit
This commit is contained in:
		@@ -427,7 +427,8 @@ void content_mapnode_init(IWritableNodeDefManager *nodemgr)
 | 
			
		||||
	i = CONTENT_WATER;
 | 
			
		||||
	f = nodemgr->getModifiable(i);
 | 
			
		||||
	f->drawtype = NDT_FLOWINGLIQUID;
 | 
			
		||||
	f->setAllTextures("water.png", WATER_ALPHA);
 | 
			
		||||
	f->setAllTextures("water.png");
 | 
			
		||||
	f->alpha = WATER_ALPHA;
 | 
			
		||||
	f->setInventoryTextureCube("water.png", "water.png", "water.png");
 | 
			
		||||
	f->param_type = CPT_LIGHT;
 | 
			
		||||
	f->light_propagates = true;
 | 
			
		||||
@@ -440,17 +441,14 @@ void content_mapnode_init(IWritableNodeDefManager *nodemgr)
 | 
			
		||||
	f->liquid_alternative_source = CONTENT_WATERSOURCE;
 | 
			
		||||
	f->liquid_viscosity = WATER_VISC;
 | 
			
		||||
	f->post_effect_color = video::SColor(64, 100, 100, 200);
 | 
			
		||||
	// Flowing water material
 | 
			
		||||
	f->mspec_special[0].tname = "water.png";
 | 
			
		||||
	f->mspec_special[0].backface_culling = false;
 | 
			
		||||
	f->mspec_special[1].tname = "water.png";
 | 
			
		||||
	f->mspec_special[1].backface_culling = true;
 | 
			
		||||
	f->setSpecialMaterial(0, MaterialSpec("water.png", false));
 | 
			
		||||
	f->setSpecialMaterial(1, MaterialSpec("water.png", true));
 | 
			
		||||
 | 
			
		||||
	i = CONTENT_WATERSOURCE;
 | 
			
		||||
	f = nodemgr->getModifiable(i);
 | 
			
		||||
	f->drawtype = NDT_LIQUID;
 | 
			
		||||
	f->setAllTextures("water.png", WATER_ALPHA);
 | 
			
		||||
	//f->setInventoryTexture("water.png");
 | 
			
		||||
	f->setAllTextures("water.png");
 | 
			
		||||
	f->alpha = WATER_ALPHA;
 | 
			
		||||
	f->setInventoryTextureCube("water.png", "water.png", "water.png");
 | 
			
		||||
	f->param_type = CPT_LIGHT;
 | 
			
		||||
	f->light_propagates = true;
 | 
			
		||||
@@ -465,8 +463,7 @@ void content_mapnode_init(IWritableNodeDefManager *nodemgr)
 | 
			
		||||
	f->liquid_viscosity = WATER_VISC;
 | 
			
		||||
	f->post_effect_color = video::SColor(64, 100, 100, 200);
 | 
			
		||||
	// New-style water source material (mostly unused)
 | 
			
		||||
	f->mspec_special[0].tname = "water.png";
 | 
			
		||||
	f->mspec_special[0].backface_culling = false;
 | 
			
		||||
	f->setSpecialMaterial(0, MaterialSpec("water.png", false));
 | 
			
		||||
	
 | 
			
		||||
	i = CONTENT_LAVA;
 | 
			
		||||
	f = nodemgr->getModifiable(i);
 | 
			
		||||
@@ -486,11 +483,8 @@ void content_mapnode_init(IWritableNodeDefManager *nodemgr)
 | 
			
		||||
	f->liquid_viscosity = LAVA_VISC;
 | 
			
		||||
	f->damage_per_second = 4*2;
 | 
			
		||||
	f->post_effect_color = video::SColor(192, 255, 64, 0);
 | 
			
		||||
	// Flowing lava material
 | 
			
		||||
	f->mspec_special[0].tname = "lava.png";
 | 
			
		||||
	f->mspec_special[0].backface_culling = false;
 | 
			
		||||
	f->mspec_special[1].tname = "lava.png";
 | 
			
		||||
	f->mspec_special[1].backface_culling = true;
 | 
			
		||||
	f->setSpecialMaterial(0, MaterialSpec("lava.png", false));
 | 
			
		||||
	f->setSpecialMaterial(1, MaterialSpec("lava.png", true));
 | 
			
		||||
	
 | 
			
		||||
	i = CONTENT_LAVASOURCE;
 | 
			
		||||
	f = nodemgr->getModifiable(i);
 | 
			
		||||
@@ -512,8 +506,7 @@ void content_mapnode_init(IWritableNodeDefManager *nodemgr)
 | 
			
		||||
	f->damage_per_second = 4*2;
 | 
			
		||||
	f->post_effect_color = video::SColor(192, 255, 64, 0);
 | 
			
		||||
	// New-style lava source material (mostly unused)
 | 
			
		||||
	f->mspec_special[0].tname = "lava.png";
 | 
			
		||||
	f->mspec_special[0].backface_culling = false;
 | 
			
		||||
	f->setSpecialMaterial(0, MaterialSpec("lava.png", false));
 | 
			
		||||
	
 | 
			
		||||
	i = CONTENT_TORCH;
 | 
			
		||||
	f = nodemgr->getModifiable(i);
 | 
			
		||||
 
 | 
			
		||||
@@ -27,7 +27,11 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 | 
			
		||||
#include "log.h"
 | 
			
		||||
#include "settings.h"
 | 
			
		||||
 | 
			
		||||
void NodeBox::serialize(std::ostream &os)
 | 
			
		||||
/*
 | 
			
		||||
	NodeBox
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
void NodeBox::serialize(std::ostream &os) const
 | 
			
		||||
{
 | 
			
		||||
	writeU8(os, 0); // version
 | 
			
		||||
	writeU8(os, type);
 | 
			
		||||
@@ -57,7 +61,11 @@ void NodeBox::deSerialize(std::istream &is)
 | 
			
		||||
	wall_side.MaxEdge = readV3F1000(is);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void MaterialSpec::serialize(std::ostream &os)
 | 
			
		||||
/*
 | 
			
		||||
	MaterialSpec
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
void MaterialSpec::serialize(std::ostream &os) const
 | 
			
		||||
{
 | 
			
		||||
	os<<serializeString(tname);
 | 
			
		||||
	writeU8(os, backface_culling);
 | 
			
		||||
@@ -69,6 +77,10 @@ void MaterialSpec::deSerialize(std::istream &is)
 | 
			
		||||
	backface_culling = readU8(is);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
	ContentFeatures
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
ContentFeatures::ContentFeatures()
 | 
			
		||||
{
 | 
			
		||||
	reset();
 | 
			
		||||
@@ -248,6 +260,20 @@ void ContentFeatures::setTexture(u16 i, std::string name)
 | 
			
		||||
		tname_inventory = name;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void ContentFeatures::setAllTextures(std::string name)
 | 
			
		||||
{
 | 
			
		||||
	for(u16 i=0; i<6; i++)
 | 
			
		||||
		setTexture(i, name);
 | 
			
		||||
	// Force inventory texture too
 | 
			
		||||
	setInventoryTexture(name);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void ContentFeatures::setSpecialMaterial(u16 i, const MaterialSpec &mspec)
 | 
			
		||||
{
 | 
			
		||||
	assert(i < CF_SPECIAL_COUNT);
 | 
			
		||||
	mspec_special[i] = mspec;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void ContentFeatures::setInventoryTexture(std::string imgname)
 | 
			
		||||
{
 | 
			
		||||
	tname_inventory = imgname + "^[forcesingle";
 | 
			
		||||
@@ -270,6 +296,10 @@ void ContentFeatures::setInventoryTextureCube(std::string top,
 | 
			
		||||
	tname_inventory = imgname_full;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
	CNodeDefManager
 | 
			
		||||
*/
 | 
			
		||||
 | 
			
		||||
class CNodeDefManager: public IWritableNodeDefManager
 | 
			
		||||
{
 | 
			
		||||
public:
 | 
			
		||||
 
 | 
			
		||||
@@ -98,7 +98,7 @@ struct NodeBox
 | 
			
		||||
		wall_side(-BS/2, -BS/2, -BS/2, -BS/2+BS/16., BS/2, BS/2)
 | 
			
		||||
	{}
 | 
			
		||||
 | 
			
		||||
	void serialize(std::ostream &os);
 | 
			
		||||
	void serialize(std::ostream &os) const;
 | 
			
		||||
	void deSerialize(std::istream &is);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
@@ -115,7 +115,7 @@ struct MaterialSpec
 | 
			
		||||
		backface_culling(backface_culling_)
 | 
			
		||||
	{}
 | 
			
		||||
 | 
			
		||||
	void serialize(std::ostream &os);
 | 
			
		||||
	void serialize(std::ostream &os) const;
 | 
			
		||||
	void deSerialize(std::istream &is);
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
@@ -156,9 +156,8 @@ struct ContentFeatures
 | 
			
		||||
	bool backface_culling;
 | 
			
		||||
#endif
 | 
			
		||||
	
 | 
			
		||||
	// List of all block textures that have been used (value is dummy)
 | 
			
		||||
	// Used for texture atlas making.
 | 
			
		||||
	// Exists on server too for cleaner code in content_mapnode.cpp.
 | 
			
		||||
	// List of textures that are used and are wanted to be included in
 | 
			
		||||
	// the texture atlas
 | 
			
		||||
	std::set<std::string> used_texturenames;
 | 
			
		||||
	
 | 
			
		||||
	// True if this actually contains non-default data
 | 
			
		||||
@@ -173,7 +172,7 @@ struct ContentFeatures
 | 
			
		||||
	float visual_scale; // Misc. scale parameter
 | 
			
		||||
	std::string tname_tiles[6];
 | 
			
		||||
	std::string tname_inventory;
 | 
			
		||||
	MaterialSpec mspec_special[CF_SPECIAL_COUNT];
 | 
			
		||||
	MaterialSpec mspec_special[CF_SPECIAL_COUNT]; // Use setter methods
 | 
			
		||||
	u8 alpha;
 | 
			
		||||
 | 
			
		||||
	// Post effect color, drawn when the camera is inside the node.
 | 
			
		||||
@@ -240,24 +239,19 @@ struct ContentFeatures
 | 
			
		||||
	void deSerialize(std::istream &is, IGameDef *gamedef);
 | 
			
		||||
 | 
			
		||||
	/*
 | 
			
		||||
		Quickhands for simple materials
 | 
			
		||||
		Texture setters.
 | 
			
		||||
		
 | 
			
		||||
	*/
 | 
			
		||||
	
 | 
			
		||||
	// Texture setters. They also add stuff to used_texturenames.
 | 
			
		||||
	void setTexture(u16 i, std::string name);
 | 
			
		||||
 | 
			
		||||
	void setAllTextures(std::string name, u8 alpha_=255)
 | 
			
		||||
	{
 | 
			
		||||
		for(u16 i=0; i<6; i++)
 | 
			
		||||
			setTexture(i, name);
 | 
			
		||||
		alpha = alpha_;
 | 
			
		||||
		// Force inventory texture too
 | 
			
		||||
		setInventoryTexture(name);
 | 
			
		||||
	}
 | 
			
		||||
	void setAllTextures(std::string name);
 | 
			
		||||
	void setSpecialMaterial(u16 i, const MaterialSpec &mspec);
 | 
			
		||||
 | 
			
		||||
	void setInventoryTexture(std::string imgname);
 | 
			
		||||
	void setInventoryTextureCube(std::string top,
 | 
			
		||||
			std::string left, std::string right);
 | 
			
		||||
 | 
			
		||||
	
 | 
			
		||||
	/*
 | 
			
		||||
		Some handy methods
 | 
			
		||||
	*/
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user