Don't crash if some textures are missing

This commit is contained in:
Deve 2018-07-08 23:00:16 +02:00
parent 8a25edf2cc
commit 8885119974
4 changed files with 47 additions and 37 deletions

View File

@ -540,7 +540,8 @@ void RaceGUI::drawGlobalMiniMap()
lower_y -(int)(draw_at.getY()-marker_half_size));
// Highlight the player icons with some backgorund image.
if (kart->getController()->isLocalPlayerController())
if (kart->getController()->isLocalPlayerController() &&
m_icons_frame != NULL)
{
video::SColor colors[4];
for (unsigned int i=0;i<4;i++)

View File

@ -73,13 +73,13 @@ RaceGUIBase::RaceGUIBase()
m_music_icon = irr_driver->getTexture("notes.png");
if (!m_music_icon)
{
Log::fatal("RaceGuiBase", "Can't find 'notes.png' texture, aborting.");
Log::error("RaceGuiBase", "Can't find 'notes.png' texture, aborting.");
}
m_plunger_face = irr_driver->getTexture("plungerface.png");
if (!m_plunger_face)
{
Log::fatal("RaceGuiBase",
Log::error("RaceGuiBase",
"Can't find 'plungerface.png' texture, aborting.");
}
@ -87,7 +87,7 @@ RaceGUIBase::RaceGUIBase()
m_icons_frame = irr_driver->getTexture("icons-frame.png");
if (!m_icons_frame)
{
Log::fatal("RaceGuiBase",
Log::error("RaceGuiBase",
"Can't find 'icons-frame.png' texture, aborting.");
}
@ -590,6 +590,8 @@ void RaceGUIBase::drawGlobalMusicDescription()
true /* vcenter */);
// Draw music icon
if (m_music_icon != NULL)
{
int iconSizeX = (int)(ICON_SIZE*resize + x_pulse*resize*resize);
int iconSizeY = (int)(ICON_SIZE*resize + y_pulse*resize*resize);
@ -601,6 +603,7 @@ void RaceGUIBase::drawGlobalMusicDescription()
m_music_icon->getSize());
draw2DImage(m_music_icon, dest, source, NULL, NULL, true);
}
#endif
} // drawGlobalMusicDescription
@ -870,7 +873,8 @@ void RaceGUIBase::drawGlobalPlayerIcons(int bottom_margin)
const core::rect<s32> pos(x, y, x+w, y+w);
//to bring to light the player's icon: add a background
if (kart->getController()->isLocalPlayerController())
if (kart->getController()->isLocalPlayerController() &&
m_icons_frame != NULL)
{
video::SColor colors[4];
for (unsigned int i=0;i<4;i++)
@ -1066,6 +1070,8 @@ void RaceGUIBase::drawPlungerInFace(const Camera *camera, float dt)
m_plunger_offset.Y += (int)(m_plunger_speed.Y * dt);
}
if (m_plunger_face != NULL)
{
const int plunger_size = (int)(0.6f * screen_width);
int offset_y = viewport.UpperLeftCorner.Y + viewport.getHeight()/2
- plunger_size/2 - m_plunger_offset.Y;
@ -1084,6 +1090,7 @@ void RaceGUIBase::drawPlungerInFace(const Camera *camera, float dt)
&viewport /* clip */,
NULL /* color */,
true /* alpha */ );
}
#endif // !SERVER_ONLY
} // drawPlungerInFace

View File

@ -127,6 +127,9 @@ private:
/** Musical notes icon (for music description and credits) */
video::ITexture* m_music_icon;
/** Texture for the 'plunger in the face' texture. */
video::ITexture* m_plunger_face;
/** Translated strings 'ready', 'set', 'go'. */
core::stringw m_string_ready, m_string_set, m_string_go, m_string_goal;
@ -146,8 +149,6 @@ private:
protected:
/** Texture for the 'plunger in the face' texture. */
video::ITexture* m_plunger_face;
/** State of the plunger: From the 'init' states the plunger switches
* between two slow moving states ('shakily moving') till the end of

View File

@ -477,7 +477,8 @@ void RaceGUIOverworld::drawGlobalMiniMap()
lower_y -(int)(draw_at.getY()-marker_half_size));
// Highlight the player icons with some backgorund image.
if (kart->getController()->isLocalPlayerController())
if (kart->getController()->isLocalPlayerController() &&
m_icons_frame != NULL)
{
video::SColor colors[4];
for (unsigned int i=0;i<4;i++)