Showing with 49 additions and 27 deletions.
  1. +2 −0 minetest.conf.example
  2. +10 −5 src/client.cpp
  3. +4 −2 src/clientmap.h
  4. +1 −0 src/defaultsettings.cpp
  5. +23 −12 src/game.cpp
  6. +1 −1 src/mapblock_mesh.cpp
  7. +6 −6 src/nodedef.cpp
  8. +2 −1 src/tile.cpp
2 changes: 2 additions & 0 deletions minetest.conf.example
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@
#address =
# Enable random user input, for testing
#random_input = false
# Disable death screen, respawn automaticaly
#respawn_auto = false
# Timeout for client to remove unused map data from memory
#client_unload_unused_data_timeout = 600
# Whether to fog out the end of the visible area
Expand Down
15 changes: 10 additions & 5 deletions src/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2894,24 +2894,28 @@ void Client::afterContentReceived(IrrlichtDevice *device, gui::IGUIFont* font)
// ought to have
m_media_name_sha1_map.clear();

bool no_output = device->getVideoDriver()->getDriverType() == video::EDT_NULL;
// Rebuild inherited images and recreate textures
infostream<<"- Rebuilding images and textures"<<std::endl;
m_tsrc->rebuildImagesAndTextures();
if (!no_output)
m_tsrc->rebuildImagesAndTextures();

// Rebuild shaders
infostream<<"- Rebuilding shaders"<<std::endl;
m_shsrc->rebuildShaders();
if (!no_output)
m_shsrc->rebuildShaders();

// Update node aliases
infostream<<"- Updating node aliases"<<std::endl;
m_nodedef->updateAliases(m_itemdef);

// Update node textures
infostream<<"- Updating node textures"<<std::endl;
m_nodedef->updateTextures(m_tsrc);
if (!no_output)
m_nodedef->updateTextures(m_tsrc);

// Preload item textures and meshes if configured to
if(g_settings->getBool("preload_item_visuals"))
if(!no_output && g_settings->getBool("preload_item_visuals"))
{
verbosestream<<"Updating item textures and meshes"<<std::endl;
wchar_t* text = wgettext("Item textures...");
Expand All @@ -2935,7 +2939,8 @@ void Client::afterContentReceived(IrrlichtDevice *device, gui::IGUIFont* font)

// Start mesh update thread after setting up content definitions
infostream<<"- Starting mesh update thread"<<std::endl;
m_mesh_update_thread.Start();
if (!no_output)
m_mesh_update_thread.Start();

infostream<<"Client::afterContentReceived() done"<<std::endl;
}
Expand Down
6 changes: 4 additions & 2 deletions src/clientmap.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,10 @@ class ClientMap : public Map, public scene::ISceneNode
virtual void render()
{
video::IVideoDriver* driver = SceneManager->getVideoDriver();
driver->setTransform(video::ETS_WORLD, AbsoluteTransformation);
renderMap(driver, SceneManager->getSceneNodeRenderPass());
if (driver->getDriverType() != video::EDT_NULL) {
driver->setTransform(video::ETS_WORLD, AbsoluteTransformation);
renderMap(driver, SceneManager->getSceneNodeRenderPass());
}
}

virtual const core::aabbox3d<f32>& getBoundingBox() const
Expand Down
1 change: 1 addition & 0 deletions src/defaultsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ void set_default_settings(Settings *settings)
settings->setDefault("vsync", "false");
settings->setDefault("address", "");
settings->setDefault("random_input", "false");
settings->setDefault("respawn_auto", "false");
settings->setDefault("client_unload_unused_data_timeout", "600");
settings->setDefault("enable_fog", "true");
settings->setDefault("fov", "72");
Expand Down
35 changes: 23 additions & 12 deletions src/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1318,7 +1318,8 @@ void the_game(
{
video::ITexture *t = tsrc->getTexture("crack_anylength.png");
v2u32 size = t->getOriginalSize();
crack_animation_length = size.Y / size.X;
if (size.X)
crack_animation_length = size.Y / size.X;
}

/*
Expand Down Expand Up @@ -1458,6 +1459,7 @@ void the_game(
gamedef, player, &local_inventory);

bool use_weather = g_settings->getBool("weather");
bool no_output = device->getVideoDriver()->getDriverType() == video::EDT_NULL;

for(;;)
{
Expand Down Expand Up @@ -1613,15 +1615,17 @@ void the_game(
}

/* Process TextureSource's queue */
tsrc->processQueue();
if (!no_output)
tsrc->processQueue();

/* Process ItemDefManager's queue */
itemdef->processQueue(gamedef);

/*
Process ShaderSource's queue
*/
shsrc->processQueue();
if (!no_output)
shsrc->processQueue();

/*
Random calculations
Expand Down Expand Up @@ -2228,15 +2232,19 @@ void the_game(
camera_point_target.X = event.deathscreen.camera_point_target_x;
camera_point_target.Y = event.deathscreen.camera_point_target_y;
camera_point_target.Z = event.deathscreen.camera_point_target_z;*/

if (g_settings->getBool("respawn_auto")) {
client.sendRespawn();
} else {
MainRespawnInitiator *respawner =
new MainRespawnInitiator(
&respawn_menu_active, &client);
GUIDeathScreen *menu =
new GUIDeathScreen(guienv, guiroot, -1,
new GUIDeathScreen(guienv, guiroot, -1,
&g_menumgr, respawner);
menu->drop();
}

chat_backend.addMessage(L"", L"You died.");

/* Handle visualization */

Expand Down Expand Up @@ -2926,8 +2934,10 @@ void the_game(
Update particles
*/

allparticles_step(dtime, client.getEnv());
allparticlespawners_step(dtime, client.getEnv());
if (!no_output) {
allparticles_step(dtime, client.getEnv());
allparticlespawners_step(dtime, client.getEnv());
}

/*
Fog
Expand Down Expand Up @@ -3154,7 +3164,7 @@ void the_game(

TimeTaker tt_draw("mainloop: draw");

{
if (!no_output) {
TimeTaker timer("beginScene");
//driver->beginScene(false, true, bgcolor);
//driver->beginScene(true, true, bgcolor);
Expand All @@ -3165,7 +3175,7 @@ void the_game(
//timer3.stop();

//infostream<<"smgr->drawAll()"<<std::endl;
{
if (!no_output) {
TimeTaker timer("smgr");
smgr->drawAll();

Expand Down Expand Up @@ -3282,7 +3292,7 @@ void the_game(
/*
Post effects
*/
{
if (!no_output) {
client.getEnv().getClientMap().renderPostFx();
}

Expand Down Expand Up @@ -3348,12 +3358,13 @@ void the_game(
Draw gui
*/
// 0-1ms
guienv->drawAll();
if (!no_output)
guienv->drawAll();

/*
End scene
*/
{
if (!no_output) {
TimeTaker timer("endScene");
driver->endScene();
endscenetime = timer.stop(true);
Expand Down
2 changes: 1 addition & 1 deletion src/mapblock_mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1349,7 +1349,7 @@ bool MapBlockMesh::animate(bool faraway, float time, int crack, u32 daynight_rat
// Figure out current frame
int frameoffset = m_animation_frame_offsets[i->first];
int frame = (int)(time * 1000 / tile.animation_frame_length_ms
+ frameoffset) % tile.animation_frame_count;
+ frameoffset) % (tile.animation_frame_count ? tile.animation_frame_count : 1);
// If frame doesn't change, skip
if(frame == m_animation_frames[i->first])
continue;
Expand Down
12 changes: 6 additions & 6 deletions src/nodedef.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -712,9 +712,9 @@ class CNodeDefManager: public IWritableNodeDefManager
// aspect ratio
v2u32 size = f->tiles[j].texture->getOriginalSize();
int frame_height = (float)size.X /
(float)tiledef[j].animation.aspect_w *
(float)tiledef[j].animation.aspect_h;
int frame_count = size.Y / frame_height;
(tiledef[j].animation.aspect_w ? (float)tiledef[j].animation.aspect_w : 1) *
(tiledef[j].animation.aspect_h ? (float)tiledef[j].animation.aspect_h : 1);
int frame_count = size.Y / (frame_height ? frame_height : size.Y ? size.Y : 1);
int frame_length_ms = 1000.0 *
tiledef[j].animation.length / frame_count;
f->tiles[j].animation_frame_count = frame_count;
Expand Down Expand Up @@ -754,9 +754,9 @@ class CNodeDefManager: public IWritableNodeDefManager
// aspect ratio
v2u32 size = f->special_tiles[j].texture->getOriginalSize();
int frame_height = (float)size.X /
(float)f->tiledef_special[j].animation.aspect_w *
(float)f->tiledef_special[j].animation.aspect_h;
int frame_count = size.Y / frame_height;
(f->tiledef_special[j].animation.aspect_w ? (float)f->tiledef_special[j].animation.aspect_w : 1) *
(f->tiledef_special[j].animation.aspect_h ? (float)f->tiledef_special[j].animation.aspect_h : 1);
int frame_count = size.Y / (frame_height ? frame_height : size.Y ? size.Y : 1);
int frame_length_ms = 1000.0 *
f->tiledef_special[j].animation.length / frame_count;
f->special_tiles[j].animation_frame_count = frame_count;
Expand Down
3 changes: 2 additions & 1 deletion src/tile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1415,7 +1415,8 @@ bool TextureSource::generateImage(std::string part_of_name, video::IImage *& bas
}

v2u32 frame_size = baseimg->getDimension();
frame_size.Y /= frame_count;
if (frame_count)
frame_size.Y /= frame_count;

video::IImage *img = driver->createImage(video::ECF_A8R8G8B8,
frame_size);
Expand Down