diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/constants.h | 2 | ||||
-rw-r--r-- | src/irrlichtwrapper.cpp | 34 | ||||
-rw-r--r-- | src/irrlichtwrapper.h | 10 | ||||
-rw-r--r-- | src/main.cpp | 18 | ||||
-rw-r--r-- | src/map.cpp | 6 | ||||
-rw-r--r-- | src/mapblock.cpp | 4 | ||||
-rw-r--r-- | src/tile.cpp | 82 | ||||
-rw-r--r-- | src/tile.h | 5 |
8 files changed, 135 insertions, 26 deletions
diff --git a/src/constants.h b/src/constants.h index 3cb285065..f90b278d2 100644 --- a/src/constants.h +++ b/src/constants.h @@ -32,6 +32,8 @@ with this program; if not, write to the Free Software Foundation, Inc., #define DEBUGFILE "debug.txt" +#define WATER_ALPHA 160 + // Define for simulating the quirks of sending through internet. // Causes the socket class to deliberately drop random packets. // This disables unit testing of socket and connection. diff --git a/src/irrlichtwrapper.cpp b/src/irrlichtwrapper.cpp index fe4ff2771..e26cbfd15 100644 --- a/src/irrlichtwrapper.cpp +++ b/src/irrlichtwrapper.cpp @@ -175,6 +175,40 @@ video::ITexture * CrackTextureMod::make(video::ITexture *original, return newtexture; } +video::ITexture * SideGrassTextureMod::make(video::ITexture *original, + const char *newname, video::IVideoDriver* driver) +{ + // Size of the base image + core::dimension2d<u32> dim(16, 16); + // Position to copy the grass to in the base image + core::position2d<s32> pos_base(0, 0); + // Position to copy the grass from in the grass image + core::position2d<s32> pos_other(0, 0); + + video::IImage *baseimage = driver->createImage(original, pos_base, dim); + assert(baseimage); + + video::IImage *grassimage = driver->createImageFromFile(porting::getDataPath("grass_side.png").c_str()); + assert(grassimage); + + // Then copy the right part of grassimage to baseimage + + grassimage->copyToWithAlpha(baseimage, v2s32(0,0), + core::rect<s32>(pos_other, dim), + video::SColor(255,255,255,255), + NULL); + + grassimage->drop(); + + // Create texture from resulting image + + video::ITexture *newtexture = driver->addTexture(newname, baseimage); + + baseimage->drop(); + + return newtexture; +} + video::ITexture * ProgressBarTextureMod::make(video::ITexture *original, const char *newname, video::IVideoDriver* driver) { diff --git a/src/irrlichtwrapper.h b/src/irrlichtwrapper.h index ce54b70c0..97607e579 100644 --- a/src/irrlichtwrapper.h +++ b/src/irrlichtwrapper.h @@ -97,6 +97,16 @@ struct CrackTextureMod: public TextureMod u16 progression; }; +struct SideGrassTextureMod: public TextureMod +{ + SideGrassTextureMod() + { + } + + virtual video::ITexture * make(video::ITexture *original, + const char *newname, video::IVideoDriver* driver); +}; + struct ProgressBarTextureMod: public TextureMod { // value is from 0.0 to 1.0 diff --git a/src/main.cpp b/src/main.cpp index 7c5f6bf3e..092d62988 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -76,9 +76,6 @@ SUGG: Split MapBlockObject serialization to to-client and to-disk - This will allow saving ages of rats on disk but not sending
them to clients
-SUGG: Implement lighting using VoxelManipulator
- - Would it be significantly faster?
-
SUGG: MovingObject::move and Player::move are basically the same.
combine them.
@@ -168,6 +165,8 @@ TODO: Make fetching sector's blocks more efficient when rendering sectors that have very large amounts of blocks (on client)
- Is this necessary at all?
+TODO: Flowing water animation
+
Configuration:
--------------
@@ -231,8 +230,8 @@ Block object server side: - TODO: For incoming blocks, time difference is calculated and
objects are stepped according to it.
-Map generator:
---------------
+Map:
+----
NOTE: There are some lighting-related todos and fixmes in
ServerMap::emergeBlock. And there always will be. 8)
@@ -245,6 +244,8 @@ TODO: Map generator version 2 - Cliffs, arcs
- There could be a certain height (to which mountains only reach)
where some minerals are found
+ - Create a system that allows a huge amount of different "map
+ generator modules/filters"
TODO: Change AttributeList to split the area into smaller sections so
that searching won't be as heavy.
@@ -256,6 +257,10 @@ FIXME: The new pre-sunlight-propagation code messes up with initial TODO: Remove HMParams
+TODO: Flowing water to actually contain flow direction information
+
+TODO: Faster lighting using VoxelManipulator
+
Doing now:
----------
@@ -1532,8 +1537,7 @@ int main(int argc, char *argv[]) */
init_content_inventory_texture_paths();
- init_tile_texture_paths();
- tile_materials_preload(g_irrlicht);
+ init_tile_textures();
/*
GUI stuff
diff --git a/src/map.cpp b/src/map.cpp index 5655ee9ec..09fb154aa 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -1624,7 +1624,7 @@ void Map::transformLiquids(core::map<v3s16, MapBlock*> & modified_blocks) } // If n2_changed to bottom, don't flow anywhere else - if(to_bottom && flowed) + if(to_bottom && flowed && !is_source) break; }catch(InvalidPositionException &e) @@ -1770,7 +1770,7 @@ ServerMap::ServerMap(std::string savedir, HMParams hmp, MapParams mp): float randmax = 0; float randfactor = 0; - if(myrand()%4 == 0) + if(myrand()%5 == 0) { baseheight = 100; randmax = 50; @@ -2602,7 +2602,7 @@ continue_generating: (float)(myrand()%ued)+0.5 ); s16 min_d = 0; - s16 max_d = 6; + s16 max_d = 4; s16 rs = (myrand()%(max_d-min_d+1))+min_d; v3f vec = rp - orp; diff --git a/src/mapblock.cpp b/src/mapblock.cpp index f18cb2fdd..620c29fdd 100644 --- a/src/mapblock.cpp +++ b/src/mapblock.cpp @@ -268,7 +268,7 @@ void MapBlock::makeFastFace(TileSpec tile, u8 light, v3f p, if(tile.id == TILE_WATER) { - alpha = 128; + alpha = WATER_ALPHA; } video::SColor c = video::SColor(alpha,li,li,li); @@ -797,7 +797,7 @@ void MapBlock::updateMesh(u32 daynight_ratio) }catch(InvalidPositionException &e){} u8 l = decode_light(n.getLightBlend(daynight_ratio)); - video::SColor c(128,l,l,l); + video::SColor c(WATER_ALPHA,l,l,l); // Neighbor water levels (key = relative position) // Includes current node diff --git a/src/tile.cpp b/src/tile.cpp index 90de11642..79d68d4c3 100644 --- a/src/tile.cpp +++ b/src/tile.cpp @@ -25,7 +25,7 @@ with this program; if not, write to the Free Software Foundation, Inc., // A mapping from tiles to paths of textures -const char * g_tile_texture_filenames[TILES_COUNT] = +/*const char * g_tile_texture_filenames[TILES_COUNT] = { NULL, "stone.png", @@ -37,13 +37,19 @@ const char * g_tile_texture_filenames[TILES_COUNT] = "mese.png", "mud.png", "tree_top.png", - "mud_with_grass.png", + "mud.png_sidegrass", "cloud.png", "coalstone.png", "wood.png", -}; +};*/ + +/* + These can either be real paths or generated names of preloaded + textures (like "mud.png_sidegrass") +*/ +std::string g_tile_texture_paths[TILES_COUNT]; -std::string g_tile_texture_path_strings[TILES_COUNT]; +/*std::string g_tile_texture_path_strings[TILES_COUNT]; const char * g_tile_texture_paths[TILES_COUNT] = {0}; void init_tile_texture_paths() @@ -60,30 +66,86 @@ void init_tile_texture_paths() g_tile_texture_path_strings[i].c_str(); } } -} +}*/ const char * tile_texture_path_get(u32 i) { assert(i < TILES_COUNT); - return g_tile_texture_paths[i]; + //return g_tile_texture_paths[i]; + return g_tile_texture_paths[i].c_str(); } // A mapping from tiles to materials // Initialized at run-time. video::SMaterial g_tile_materials[TILES_COUNT]; -void tile_materials_preload(IrrlichtWrapper *irrlicht) +enum TileTextureModID +{ + TTMID_NONE, + TTMID_SIDEGRASS, +}; + +struct TileTextureSpec +{ + const char *filename; + enum TileTextureModID mod; +}; + +/* + Initializes g_tile_texture_paths with paths of textures, + generates generated textures and creates the tile material array. +*/ +void init_tile_textures() { + TileTextureSpec tile_texture_specs[TILES_COUNT] = + { + {NULL, TTMID_NONE}, + {"stone.png", TTMID_NONE}, + {"water.png", TTMID_NONE}, + {"grass.png", TTMID_NONE}, + {"tree.png", TTMID_NONE}, + {"leaves.png", TTMID_NONE}, + {"grass_footsteps.png", TTMID_NONE}, + {"mese.png", TTMID_NONE}, + {"mud.png", TTMID_NONE}, + {"tree_top.png", TTMID_NONE}, + {"mud.png", TTMID_SIDEGRASS}, + {"cloud.png", TTMID_NONE}, + {"coalstone.png", TTMID_NONE}, + {"wood.png", TTMID_NONE}, + }; + + for(s32 i=0; i<TILES_COUNT; i++) + { + const char *filename = tile_texture_specs[i].filename; + enum TileTextureModID mod_id = tile_texture_specs[i].mod; + + if(filename != NULL && std::string("") != filename) + { + std::string path = porting::getDataPath(filename); + std::string mod_postfix = ""; + if(mod_id == TTMID_SIDEGRASS) + { + mod_postfix = "_sidegrass"; + // Generate texture + TextureMod *mod = new SideGrassTextureMod(); + g_irrlicht->getTexture(TextureSpec(path + mod_postfix, + path, mod)); + } + g_tile_texture_paths[i] = path + mod_postfix; + } + } + for(s32 i=0; i<TILES_COUNT; i++) { const char *path = tile_texture_path_get(i); video::ITexture *t = NULL; - if(path != NULL) + if(path != NULL && std::string("") != path) { - t = irrlicht->getTexture(path); + t = g_irrlicht->getTexture(path); assert(t != NULL); } @@ -99,7 +161,7 @@ void tile_materials_preload(IrrlichtWrapper *irrlicht) g_tile_materials[i].setTexture(0, t); } - + g_tile_materials[TILE_WATER].MaterialType = video::EMT_TRANSPARENT_VERTEX_ALPHA; //g_tile_materials[TILE_WATER].MaterialType = video::EMT_TRANSPARENT_ADD_COLOR; } diff --git a/src/tile.h b/src/tile.h index b6dcb249a..5869c03ee 100644 --- a/src/tile.h +++ b/src/tile.h @@ -99,13 +99,10 @@ struct TileSpec Functions */ -void init_tile_texture_paths(); +void init_tile_textures(); const char * tile_texture_path_get(u32 i); -// Initializes g_tile_materials -void tile_materials_preload(IrrlichtWrapper *irrlicht); - video::SMaterial & tile_material_get(u32 i); #endif |