diff --git a/doc/lua_api.txt b/doc/lua_api.txt index 1cd6a134e..43c719a43 100644 --- a/doc/lua_api.txt +++ b/doc/lua_api.txt @@ -478,8 +478,10 @@ Note: Future revisions to the HUD API may be incompatible; the HUD API is still - image Displays an image on the HUD. - - scale: The scale of the image, with 1 being the original texture size. - Only the X coordinate scale is used. + - scale: The scale of the image, with 1 being the original texture size. + Only the X coordinate scale is used (positive values) + Negative values represent that percentage of the screen it + should take; e.g. x=-100 means 100% (width) - text: The name of the texture that is displayed. - alignment: The alignment of the image. - offset: offset in pixels from position. diff --git a/src/hud.cpp b/src/hud.cpp index a0086b2f7..183f94e49 100644 --- a/src/hud.cpp +++ b/src/hud.cpp @@ -234,13 +234,16 @@ void Hud::drawLuaElements() { const video::SColor color(255, 255, 255, 255); const video::SColor colors[] = {color, color, color, color}; core::dimension2di imgsize(texture->getOriginalSize()); - core::rect rect(0, 0, imgsize.Width * e->scale.X, - imgsize.Height * e->scale.X); - rect += pos; - v2s32 offset((e->align.X - 1.0) * ((imgsize.Width * e->scale.X) / 2), - (e->align.Y - 1.0) * ((imgsize.Height * e->scale.X) / 2)); - rect += offset; - rect += v2s32(e->offset.X, e->offset.Y); + v2s32 dstsize(imgsize.Width * e->scale.X, + imgsize.Height * e->scale.Y); + if (e->scale.X < 0) + dstsize.X = screensize.X * (e->scale.X * -0.01); + if (e->scale.Y < 0) + dstsize.Y = screensize.Y * (e->scale.Y * -0.01); + v2s32 offset((e->align.X - 1.0) * dstsize.X / 2, + (e->align.Y - 1.0) * dstsize.Y / 2); + core::rect rect(0, 0, dstsize.X, dstsize.Y); + rect += pos + offset + v2s32(e->offset.X, e->offset.Y); driver->draw2DImage(texture, rect, core::rect(core::position2d(0,0), imgsize), NULL, colors, true); diff --git a/src/map.cpp b/src/map.cpp index 55b758055..e8115d39b 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -3935,8 +3935,10 @@ s16 ServerMap::updateBlockHeat(ServerEnvironment *env, v3s16 p, MapBlock *block) f32 heat = m_emerge->biomedef->calcBlockHeat(p, m_seed, env->getTimeOfDayF(), gametime * env->getTimeOfDaySpeed()); - block->heat = heat; - block->weather_update_time = gametime; + if(block) { + block->heat = heat; + block->weather_update_time = gametime; + } return heat; } @@ -3954,8 +3956,10 @@ s16 ServerMap::updateBlockHumidity(ServerEnvironment *env, v3s16 p, MapBlock *bl f32 humidity = m_emerge->biomedef->calcBlockHumidity(p, m_seed, env->getTimeOfDayF(), gametime * env->getTimeOfDaySpeed()); - block->humidity = humidity; - block->weather_update_time = gametime; + if(block) { + block->humidity = humidity; + block->weather_update_time = gametime; + } return humidity; }