#include "mapnode_contentfeatures.h"
-#include "main.h" // For g_settings and g_texturesource
+#include "main.h" // For g_settings
#include "nodemetadata.h"
+#ifndef SERVER
+#include "tile.h"
+#endif
struct ContentFeatures g_content_features[MAX_CONTENT+1];
Must be called before accessing the table.
*/
-void init_contentfeatures()
+void init_contentfeatures(ITextureSource *tsrc)
{
#ifndef SERVER
/*
if(i == CONTENT_IGNORE || i == CONTENT_AIR)
continue;
ContentFeatures *f = &g_content_features[i];
- f->setAllTextures("unknown_block.png");
+ f->setAllTextures(tsrc, "unknown_block.png");
f->dug_item = std::string("MaterialItem2 ")+itos(i)+" 1";
}
}
#ifndef SERVER
-void ContentFeatures::setTexture(u16 i, std::string name, u8 alpha)
+void ContentFeatures::setTexture(ITextureSource *tsrc,
+ u16 i, std::string name, u8 alpha)
{
used_texturenames[name] = true;
- if(g_texturesource)
+ if(tsrc)
{
- tiles[i].texture = g_texturesource->getTexture(name);
+ tiles[i].texture = tsrc->getTexture(name);
}
if(alpha != 255)
}
if(inventory_texture == NULL)
- setInventoryTexture(name);
+ setInventoryTexture(name, tsrc);
}
-void ContentFeatures::setInventoryTexture(std::string imgname)
+void ContentFeatures::setInventoryTexture(std::string imgname,
+ ITextureSource *tsrc)
{
- if(g_texturesource == NULL)
+ if(tsrc == NULL)
return;
imgname += "^[forcesingle";
- inventory_texture = g_texturesource->getTextureRaw(imgname);
+ inventory_texture = tsrc->getTextureRaw(imgname);
}
void ContentFeatures::setInventoryTextureCube(std::string top,
- std::string left, std::string right)
+ std::string left, std::string right, ITextureSource *tsrc)
{
- if(g_texturesource == NULL)
+ if(tsrc == NULL)
return;
str_replace_char(top, '^', '&');
imgname_full += left;
imgname_full += "{";
imgname_full += right;
- inventory_texture = g_texturesource->getTextureRaw(imgname_full);
+ inventory_texture = tsrc->getTextureRaw(imgname_full);
}
#endif