footsteps are back

This commit is contained in:
darkrose 2013-12-31 19:54:56 +10:00
parent 9aa0ec1b30
commit 2625efbb22
6 changed files with 71 additions and 5 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 771 B

After

Width:  |  Height:  |  Size: 902 B

View File

@ -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

View File

@ -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");

View File

@ -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

View File

@ -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

View File

@ -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<Player*>::Iterator i = m_players.begin();
i != m_players.end(); i++)
{
for (core::list<Player*>::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)
{
}
}
}
/*