/>\r
<Tool\r
Name="VCLinkerTool"\r
+ AdditionalDependencies="wsock32.lib"\r
AdditionalLibraryDirectories=""..\irrlicht\irrlicht-1.7.1\lib\Win32-visualstudio";..\zlib125dll\dll32"\r
IgnoreAllDefaultLibraries="false"\r
GenerateDebugInformation="true"\r
/>\r
<Tool\r
Name="VCLinkerTool"\r
+ AdditionalDependencies="wsock32.lib"\r
AdditionalLibraryDirectories=""..\irrlicht\irrlicht-1.7.1\lib\Win32-visualstudio";..\zlib125dll\dll32"\r
IgnoreDefaultLibraryNames="libcmtd.dll"\r
GenerateDebugInformation="false"\r
if(WIN32)
# Windows
- if(MSVC)
+ if(MSVC) # MSVC Specifics
# Surpress some useless warnings
add_definitions ( /D "_CRT_SECURE_NO_DEPRECATE" /W1 )
+ else() # Probably MinGW = GCC
+ set(PLATFORM_LIBS ws2_32.lib)
endif()
# Zlib stuff
set(ZLIB_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/../../zlib/zlib-1.2.5"
#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
- #include <eh.h>
+ #ifdef _MSC_VER
+ #include <eh.h>
+ #endif
#else
#endif
#ifndef SERVER
video::ITexture * getImage()
{
- //TODO
- //return g_irrlicht->getTexture(content_features(m_content).inventory_texture);
+ return content_features(m_content).inventory_texture;
return NULL;
}
#endif
#ifndef SERVER
video::ITexture * getImage()
{
+ if(g_texturesource == NULL)
+ return NULL;
+
std::string name;
if(m_subname == "Stick")
// Get such a texture
//return g_irrlicht->getTexture(name);
- //TODO
- return NULL;
+ return g_texturesource->getTextureRaw(name);
}
#endif
std::string getText()
#ifndef SERVER
video::ITexture * getImage()
{
+ if(g_texturesource == NULL)
+ return NULL;
+
std::string basename;
if(m_toolname == "WPick")
basename = "tool_wpick.png";
float value_f = (float)toolprogress / (float)maxprogress;
std::ostringstream os;
- os<<"[progressbar"<<value_f;
+ os<<basename<<"^[progressbar"<<value_f;
+
+ return g_texturesource->getTextureRaw(os.str());
/*TextureSpec spec;
spec.addTid(g_irrlicht->getTextureId(basename));
spec.addTid(g_irrlicht->getTextureId(os.str()));
return g_irrlicht->getTexture(spec);*/
- //TODO
- return NULL;
-
- /*// Make texture name for the new texture with a progress bar
- float value_f = (float)toolprogress / (float)maxprogress;
- std::ostringstream os;
- os<<basename<<"[[mod:progressbar"<<value_f;
- return g_irrlicht->getTexture(os.str());*/
-
- /*// Make texture name for the new texture with a progress bar
- std::ostringstream os;
- os<<basename<<"-toolprogress-"<<toolprogress;
- std::string finalname = os.str();
-
- float value_f = (float)toolprogress / (float)maxprogress;
-
- // Get such a texture
- TextureMod *mod = new ProgressBarTextureMod(value_f);
- return g_irrlicht->getTexture(TextureSpec(finalname, basename, mod));*/
}
#endif
std::string getText()
# maybe done\r
* not done\r
\r
-=== Stuff being done\r
+=== Immediate stuff\r
* Combine meshes to bigger ones in ClientMap and set them EHM_STATIC\r
\r
+=== Making it more portable\r
+* MinGW: Switch away from swprintf; mingw has a bad version of it.\r
+ Use snprintf + narrow_to_wide or (w)ostringstream\r
+* Some MSVC: std::sto* are defined without a namespace and collide\r
+ with the ones in utility.h\r
+\r
=== Stuff to do before release\r
* Save the new mapgen stuff\r
- map/meta.txt, which should contain only plain text, something like this:\r
#endif\r
\r
#ifdef _MSC_VER\r
-#pragma comment(lib, "Irrlicht.lib")\r
-//#pragma comment(lib, "jthread.lib")\r
-#pragma comment(lib, "zlibwapi.lib")\r
-#pragma comment(lib, "Shell32.lib")\r
-// This would get rid of the console window\r
-//#pragma comment(linker, "/subsystem:windows /ENTRY:mainCRTStartup")\r
+ #pragma comment(lib, "Irrlicht.lib")\r
+ //#pragma comment(lib, "jthread.lib")\r
+ #pragma comment(lib, "zlibwapi.lib")\r
+ #pragma comment(lib, "Shell32.lib")\r
+ // This would get rid of the console window\r
+ //#pragma comment(linker, "/subsystem:windows /ENTRY:mainCRTStartup")\r
#endif\r
\r
#include <iostream>\r
These are needed for unit tests at least.\r
*/\r
\r
- IIrrlichtWrapper irrlicht_dummy;\r
-\r
- init_mapnode(&irrlicht_dummy);\r
+ // Initial call with g_texturesource not set.\r
+ init_mapnode();\r
\r
/*\r
Run unit tests\r
*/\r
\r
init_content_inventory_texture_paths();\r
- init_mapnode(g_irrlicht);\r
+ init_mapnode(); // Second call with g_texturesource set\r
init_mineral(g_irrlicht);\r
\r
/*\r
Get texture id, translate it to name, append stuff to
name, get texture id
*/
+
// Get original texture name
u32 orig_id = spec.texture.id;
std::string orig_name = g_texturesource->getTextureName(orig_id);
+
// Create new texture name
std::ostringstream os;
os<<orig_name<<"^[crack"<<mod.param;
- //os<<orig_name<<"^[progressbar0.5";
- //os<<"mese.png";
+
// Get new texture
u32 new_id = g_texturesource->getTextureId(os.str());
- dstream<<"MapBlock::getNodeTile(): Switching from "
+ /*dstream<<"MapBlock::getNodeTile(): Switching from "
<<orig_name<<" to "<<os.str()<<" ("
- <<orig_id<<" to "<<new_id<<")"<<std::endl;
+ <<orig_id<<" to "<<new_id<<")"<<std::endl;*/
spec.texture = g_texturesource->getTexture(new_id);
}
//material.MaterialType = video::EMT_TRANSPARENT_ALPHA_CHANNEL;
material.MaterialType
= video::EMT_TRANSPARENT_ALPHA_CHANNEL_REF;
- //TODO
- /*if(dir == v3s16(0,-1,0))
+
+ if(dir == v3s16(0,-1,0))
material.setTexture(0,
- g_irrlicht->getTexture("torch_on_floor.png"));
+ g_texturesource->getTextureRaw("torch_on_floor.png"));
else if(dir == v3s16(0,1,0))
material.setTexture(0,
- g_irrlicht->getTexture("torch_on_ceiling.png"));
+ g_texturesource->getTextureRaw("torch_on_ceiling.png"));
// For backwards compatibility
else if(dir == v3s16(0,0,0))
material.setTexture(0,
- g_irrlicht->getTexture("torch_on_floor.png"));
+ g_texturesource->getTextureRaw("torch_on_floor.png"));
else
material.setTexture(0,
- g_irrlicht->getTexture("torch.png"));*/
+ g_texturesource->getTextureRaw("torch.png"));
u16 indices[] = {0,1,2,2,3,0};
// Add to mesh collector
tiles[i].alpha = alpha;
tiles[i].material_type = MATERIAL_ALPHA_VERTEX;
}
+
+ if(inventory_texture == NULL)
+ setInventoryTexture(name);
+}
+
+void ContentFeatures::setInventoryTexture(std::string imgname)
+{
+ if(g_texturesource == NULL)
+ return;
+
+ imgname += "^[forcesingle";
+
+ inventory_texture = g_texturesource->getTextureRaw(imgname);
+}
+
+void ContentFeatures::setInventoryTextureCube(std::string top,
+ std::string left, std::string right)
+{
+ if(g_texturesource == NULL)
+ return;
+
+ str_replace_char(top, '^', '&');
+ str_replace_char(left, '^', '&');
+ str_replace_char(right, '^', '&');
+
+ std::string imgname_full;
+ imgname_full += "[inventorycube{";
+ imgname_full += top;
+ imgname_full += "{";
+ imgname_full += left;
+ imgname_full += "{";
+ imgname_full += right;
+ inventory_texture = g_texturesource->getTextureRaw(imgname_full);
}
struct ContentFeatures g_content_features[256];
return g_content_features[i];
}
-void init_mapnode(IIrrlichtWrapper *irrlicht)
+/*
+ See mapnode.h for description.
+*/
+void init_mapnode()
{
+ if(g_texturesource == NULL)
+ {
+ dstream<<"INFO: Initial run of init_mapnode with "
+ "g_texturesource=NULL. If this segfaults, "
+ "there is a bug with something not checking for "
+ "the NULL value."<<std::endl;
+ }
+ else
+ {
+ dstream<<"INFO: Full run of init_mapnode with "
+ "g_texturesource!=NULL"<<std::endl;
+ }
+
// Read some settings
bool new_style_water = g_settings.getBool("new_style_water");
bool new_style_leaves = g_settings.getBool("new_style_leaves");
i = CONTENT_STONE;
f = &g_content_features[i];
f->setAllTextures("stone.png");
+ f->setInventoryTextureCube("stone.png", "stone.png", "stone.png");
f->param_type = CPT_MINERAL;
f->is_ground_content = true;
f->setAllTextures("mud.png^grass_side.png");
f->setTexture(0, "grass.png");
f->setTexture(1, "mud.png");
- //f->setInventoryTexture(irrlicht->getTextureId("grass.png"));
f->param_type = CPT_MINERAL;
f->is_ground_content = true;
i = CONTENT_GRASS_FOOTSTEPS;
f = &g_content_features[i];
- //f->setInventoryTexture(irrlicht->getTextureId("grass_footsteps.png"));
f->setAllTextures("mud.png^grass_side.png");
f->setTexture(0, "grass_footsteps.png");
f->setTexture(1, "mud.png");
f->setAllTextures("tree.png");
f->setTexture(0, "tree_top.png");
f->setTexture(1, "tree_top.png");
- //f->setInventoryTexture(irrlicht->getTextureId("tree_top.png"));
f->param_type = CPT_MINERAL;
f->is_ground_content = true;
i = CONTENT_COALSTONE;
f = &g_content_features[i];
//f->translate_to = new MapNode(CONTENT_STONE, MINERAL_COAL);
- /*f->setAllTextures(TextureSpec(irrlicht->getTextureId("coal.png"),
- irrlicht->getTextureId("mineral_coal.png")));*/
f->setAllTextures("stone.png^mineral_coal.png");
f->is_ground_content = true;
i = CONTENT_WOOD;
f = &g_content_features[i];
- //f->setAllTextures(irrlicht->getTextureId("wood.png"));
f->setAllTextures("wood.png");
f->is_ground_content = true;
i = CONTENT_MESE;
f = &g_content_features[i];
- //f->setAllTextures(irrlicht->getTextureId("mese.png"));
f->setAllTextures("mese.png");
f->is_ground_content = true;
i = CONTENT_CLOUD;
f = &g_content_features[i];
- //f->setAllTextures(irrlicht->getTextureId("cloud.png"));
f->setAllTextures("cloud.png");
f->is_ground_content = true;
i = CONTENT_WATER;
f = &g_content_features[i];
- //f->setInventoryTexture(irrlicht->getTextureId("water.png"));
+ f->setInventoryTextureCube("water.png", "water.png", "water.png");
f->param_type = CPT_LIGHT;
f->light_propagates = true;
f->solidness = 0; // Drawn separately, makes no faces
i = CONTENT_WATERSOURCE;
f = &g_content_features[i];
- //f->setInventoryTexture(irrlicht->getTextureId("water.png"));
+ f->setInventoryTexture("water.png");
if(new_style_water)
{
f->solidness = 0; // drawn separately, makes no faces
i = CONTENT_TORCH;
f = &g_content_features[i];
+ f->setInventoryTexture("torch_on_floor.png");
f->param_type = CPT_LIGHT;
f->light_propagates = true;
f->solidness = 0; // drawn separately, makes no faces
Initializes all kind of stuff in here.
Many things depend on this.
- irrlicht: Used for getting texture ids.
+ This accesses g_texturesource; if it is non-NULL, textures are set.
+
+ Client first calls this with g_texturesource=NULL to run some
+ unit tests and stuff, then it runs this again with g_texturesource
+ defined to get the textures.
+
+ Server only calls this once with g_texturesource=NULL.
*/
-void init_mapnode(IIrrlichtWrapper *irrlicht);
+void init_mapnode();
// Initializes g_content_inventory_texture_paths
void init_content_inventory_texture_paths();
//std::string inventory_image_path;
//TextureSpec inventory_texture;
//u32 inventory_texture_id;
+ video::ITexture *inventory_texture;
bool is_ground_content; //TODO: Remove, use walkable instead
bool light_propagates;
{
translate_to = NULL;
param_type = CPT_NONE;
+ inventory_texture = NULL;
is_ground_content = false;
light_propagates = false;
sunlight_propagates = false;
}
}
- /*void setInventoryTexture(const TextureSpec &spec)
- {
- inventory_texture = spec;
- }*/
-
- /*void setInventoryImage(std::string imgname)
- {
- inventory_image_path = porting::getDataPath(imgname.c_str());
- }*/
+ void setInventoryTexture(std::string imgname);
+
+ void setInventoryTextureCube(std::string top,
+ std::string left, std::string right);
};
/*
setStoneLikeDiggingProperties(CONTENT_STONE, 1.0);
g_material_properties[CONTENT_GRASS].setDiggingProperties("",
- DiggingProperties(true, 0.5, 0));
+ DiggingProperties(true, 0.4, 0));
g_material_properties[CONTENT_TORCH].setDiggingProperties("",
DiggingProperties(true, 0.0, 0));
DiggingProperties(true, 1.5, 0));
g_material_properties[CONTENT_LEAVES].setDiggingProperties("",
- DiggingProperties(true, 0.5, 0));
+ DiggingProperties(true, 0.35, 0));
g_material_properties[CONTENT_GRASS_FOOTSTEPS].setDiggingProperties("",
DiggingProperties(true, 0.5, 0));
setStoneLikeDiggingProperties(CONTENT_MESE, 0.5);
g_material_properties[CONTENT_MUD].setDiggingProperties("",
- DiggingProperties(true, 0.5, 0));
+ DiggingProperties(true, 0.4, 0));
setStoneLikeDiggingProperties(CONTENT_COALSTONE, 1.5);
#include "debug.h"
#include "constants.h"
-#ifdef _WIN32
+#ifdef _MSC_VER
#define SWPRINTF_CHARSTRING L"%S"
#else
#define SWPRINTF_CHARSTRING L"%s"
#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN
+ // Without this some of the network functions are not found on mingw
+ #ifndef _WIN32_WINNT
+ #define _WIN32_WINNT 0x0501
+ #endif
#include <windows.h>
#include <winsock2.h>
#include <ws2tcpip.h>
- #pragma comment(lib, "wsock32.lib")
+ #ifdef _MSC_VER
+ #pragma comment(lib, "wsock32.lib")
+ #endif
typedef SOCKET socket_t;
typedef int socklen_t;
#else
dstream<<"INFO: getTextureIdDirect(): generating special "
<<"modification \""<<part_of_name<<"\""
<<std::endl;
+
+ /*
+ This is the simplest of all; it just adds stuff to the
+ name so that a separate texture is created.
- if(part_of_name.substr(0,6) == "[crack")
+ It is used to make textures for stuff that doesn't want
+ to implement getting the texture from a bigger texture
+ atlas.
+ */
+ if(part_of_name == "[forcesingle")
+ {
+ }
+ /*
+ [crackN
+ Adds a cracking texture
+ */
+ else if(part_of_name.substr(0,6) == "[crack")
{
if(baseimg == NULL)
{
crackimage->drop();
}
}
+ /*
+ [combine:WxH:X,Y=filename:X,Y=filename2
+ Creates a bigger texture from an amount of smaller ones
+ */
else if(part_of_name.substr(0,8) == "[combine")
{
- // "[combine:16x128:0,0=stone.png:0,16=grass.png"
Strfnd sf(part_of_name);
sf.next(":");
u32 w0 = stoi(sf.next("x"));
}
}
}
+ /*
+ [progressbarN
+ Adds a progress bar, 0.0 <= N <= 1.0
+ */
else if(part_of_name.substr(0,12) == "[progressbar")
{
if(baseimg == NULL)
float value = stof(part_of_name.substr(12));
make_progressbar(value, baseimg);
}
- // "[noalpha:filename.png"
- // Use an image without it's alpha channel
+ /*
+ "[noalpha:filename.png"
+ Use an image without it's alpha channel.
+ Used for the leaves texture when in old leaves mode, so
+ that the transparent parts don't look completely black
+ when simple alpha channel is used for rendering.
+ */
else if(part_of_name.substr(0,8) == "[noalpha")
{
if(baseimg != NULL)
image->drop();
}
}
+ /*
+ [inventorycube{topimage{leftimage{rightimage
+ In every subimage, replace ^ with &.
+ Create an "inventory cube".
+ NOTE: This should be used only on its own.
+ Example (a grass block (not actually used in game):
+ "[inventorycube{grass.png{mud.png&grass_side.png{mud.png&grass_side.png"
+ */
+ else if(part_of_name.substr(0,14) == "[inventorycube")
+ {
+ if(baseimg != NULL)
+ {
+ dstream<<"WARNING: getTextureIdDirect(): baseimg!=NULL "
+ <<"for part_of_name="<<part_of_name
+ <<", cancelling."<<std::endl;
+ return false;
+ }
+
+ // This is just a placeholder
+
+ str_replace_char(part_of_name, '&', '^');
+ Strfnd sf(part_of_name);
+ sf.next("{");
+ std::string imagename_top = sf.next("{");
+ std::string imagename_left = sf.next("{");
+ std::string imagename_right = sf.next("{");
+
+ baseimg = generate_image_from_scratch(
+ imagename_top, driver);
+
+ //TODO
+#if 0
+ if(driver->queryFeature(video::EVDF_RENDER_TO_TARGET) == false)
+ {
+ dstream<<"WARNING: getTextureIdDirect(): EVDF_RENDER_TO_TARGET"
+ " not supported"<<std::endl;
+ return false;
+ }
+
+ u32 w0 = 16;
+ u32 h0 = 16;
+ dstream<<"INFO: inventorycube w="<<w0<<" h="<<h0<<std::endl;
+ core::dimension2d<u32> dim(w0,h0);
+
+ //baseimg = driver->createImage(video::ECF_A8R8G8B8, dim);
+
+ video::IImage *img_top = generate_image_from_scratch(
+ imagename_top, driver);
+ video::IImage *img_left = generate_image_from_scratch(
+ imagename_left, driver);
+ video::IImage *img_right = generate_image_from_scratch(
+ imagename_right, driver);
+
+ // Render target texture
+ video::ITexture *rtt = NULL;
+ std::string rtt_name = part_of_name + "_RTT";
+
+ rtt = driver->addRenderTargetTexture(dim, rtt_name.c_str());
+ assert(rtt);
+
+
+
+ img_top->drop();
+ img_left->drop();
+ img_right->drop();
+
+ //TODO
+ assert(0);
+#endif
+ }
else
{
dstream<<"WARNING: getTextureIdDirect(): Invalid "
{
return getTexture(getTextureId(name));
}
+
+ // Gets a separate texture
+ video::ITexture* getTextureRaw(const std::string &name)
+ {
+ AtlasPointer ap = getTexture(name);
+ return ap.atlas;
+ }
private:
/*
return o.str();
}
+inline void str_replace(std::string & str, std::string const & pattern,
+ std::string const & replacement)
+{
+ std::string::size_type start = str.find(pattern, 0);
+ while(start != str.npos)
+ {
+ str.replace(start, pattern.size(), replacement);
+ start = str.find(pattern, start+replacement.size());
+ }
+}
+
+inline void str_replace_char(std::string & str, char from, char to)
+{
+ for(unsigned int i=0; i<str.size(); i++)
+ {
+ if(str[i] == from)
+ str[i] = to;
+ }
+}
+
/*
A base class for simple background thread implementation
*/