diff --git a/data/textures/grass_footsteps.png b/data/textures/grass_footsteps.png index 8349033..3977e8f 100644 Binary files a/data/textures/grass_footsteps.png and b/data/textures/grass_footsteps.png differ diff --git a/minetest.conf.example b/minetest.conf.example index 4964b57..0d2b0d9 100644 --- a/minetest.conf.example +++ b/minetest.conf.example @@ -151,6 +151,8 @@ #enable_lavabuckets = false # allow players to craft tnt #enable_tnt = false +# add footprints when players walk on grass +#enable_footprints = true # Profiler data print interval. #0 = disable. #profiler_print_interval = 0 diff --git a/src/content_mapnode.cpp b/src/content_mapnode.cpp index b2ef7f8..fb2d081 100644 --- a/src/content_mapnode.cpp +++ b/src/content_mapnode.cpp @@ -1078,6 +1078,17 @@ void content_mapnode_init() f->dug_item = std::string("MaterialItem2 ")+itos(CONTENT_MUD)+" 1"; setDirtLikeDiggingProperties(f->digging_properties, 1.0); + i = CONTENT_GRASS_FOOTSTEPS; + f = &content_features(i); + f->description = std::string("Grass"); + f->setAllTextures("mud.png^grass_side.png"); + f->setTexture(0, "grass_footsteps.png"); + f->setTexture(1, "mud.png"); + f->draw_type = CDT_CUBELIKE; + f->is_ground_content = true; + f->dug_item = std::string("MaterialItem2 ")+itos(CONTENT_MUD)+" 1"; + setDirtLikeDiggingProperties(f->digging_properties, 1.0); + i = CONTENT_MUDSNOW; f = &content_features(i); f->description = std::string("Muddy Snow"); diff --git a/src/content_mapnode.h b/src/content_mapnode.h index 0468e2a..4484df7 100644 --- a/src/content_mapnode.h +++ b/src/content_mapnode.h @@ -179,7 +179,8 @@ MapNode mapnode_translate_to_internal(MapNode n_from, u8 version); #define CONTENT_STEAM 0x8CE #define CONTENT_INCINERATOR 0x8CF #define CONTENT_ASH 0x8D0 -// FREE 8D1-8FF +#define CONTENT_GRASS_FOOTSTEPS 0x8D1 +// FREE 8D2-8FF // glass pane #define CONTENT_GLASS_PANE 0x900 #define CONTENT_GLASS_PANE_BLUE 0x901 diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp index 2a0f397..0c0c16c 100644 --- a/src/defaultsettings.cpp +++ b/src/defaultsettings.cpp @@ -100,6 +100,7 @@ void set_default_settings(Settings *settings) settings->setDefault("default_password", ""); settings->setDefault("default_privs", "build, shout"); settings->setDefault("borderstone_radius","5"); + settings->setDefault("enable_footprints","true"); // only enable http on the server for now // adventurous players can enable it on the client diff --git a/src/environment.cpp b/src/environment.cpp index 750cf75..e3a9ec6 100644 --- a/src/environment.cpp +++ b/src/environment.cpp @@ -764,6 +764,9 @@ void ServerEnvironment::step(float dtime) //TimeTaker timer("ServerEnv step"); + // Get some settings + bool footprints = g_settings->getBool("enable_footprints"); + /* Increment game time */ @@ -779,19 +782,32 @@ void ServerEnvironment::step(float dtime) */ { ScopeProfiler sp(g_profiler, "SEnv: handle players avg", SPT_AVG); - for(core::list::Iterator i = m_players.begin(); - i != m_players.end(); i++) - { + for (core::list::Iterator i = m_players.begin(); i != m_players.end(); i++) { Player *player = *i; // Ignore disconnected players - if(player->peer_id == 0) + if (player->peer_id == 0) continue; v3f playerpos = player->getPosition(); // Move player->move(dtime, *m_map, 100*BS); + + /* + Add footsteps to grass + */ + if (footprints) { + // Get node that is at BS/4 under player + v3s16 bottompos = floatToInt(playerpos + v3f(0,-BS/4,0), BS); + try{ + MapNode n = m_map->getNode(bottompos); + if (n.getContent() == CONTENT_GRASS) { + n.setContent(CONTENT_GRASS_FOOTSTEPS); + m_map->setNode(bottompos, n); + } + }catch (InvalidPositionException &e) {} + } } } @@ -964,6 +980,12 @@ void ServerEnvironment::step(float dtime) v3s16 p = p0 + block->getPosRelative(); MapNode n = block->getNodeNoEx(p0); + if (n.getContent() == CONTENT_GRASS_FOOTSTEPS) { + if (myrand()%5 == 0) { + n.setContent(CONTENT_GRASS); + m_map->addNodeWithEvent(p, n); + } + } /* Test something: Convert mud under proper lighting to grass @@ -2990,6 +3012,7 @@ void ClientEnvironment::step(float dtime) // Get some settings bool free_move = g_settings->getBool("free_move"); + bool footprints = g_settings->getBool("enable_footprints"); // Get local player LocalPlayer *lplayer = getLocalPlayer(); @@ -3197,6 +3220,34 @@ void ClientEnvironment::step(float dtime) } catch(InvalidPositionException &e) {} player->updateLight(light); + + /* + Add footsteps to grass + */ + if(footprints) + { + // Get node that is at BS/4 under player + v3s16 bottompos = floatToInt(playerpos + v3f(0,-BS/4,0), BS); + try{ + MapNode n = m_map->getNode(bottompos); + if(n.getContent() == CONTENT_GRASS) + { + n.setContent(CONTENT_GRASS_FOOTSTEPS); + m_map->setNode(bottompos, n); + // Update mesh on client + if(m_map->mapType() == MAPTYPE_CLIENT) + { + v3s16 p_blocks = getNodeBlockPos(bottompos); + MapBlock *b = m_map->getBlockNoCreate(p_blocks); + //b->updateMesh(getDayNightRatio()); + b->setMeshExpired(true); + } + } + } + catch(InvalidPositionException &e) + { + } + } } /*