From 8becb9cbbdbeb4a3a9c6e2274c71ac6d04514a89 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 17 May 2016 01:20:57 +0300 Subject: Fix /hat command output if no hat equipped. --- src/actions/chat.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/actions/chat.cpp b/src/actions/chat.cpp index f8cb0731d..5a328b3b5 100644 --- a/src/actions/chat.cpp +++ b/src/actions/chat.cpp @@ -607,10 +607,18 @@ impHandler(hat) const int sprite = localPlayer->getSpriteID( charServerHandler->hatSprite()); - const ItemInfo &info = ItemDB::get(sprite); - // TRANSLATORS: equipped hat chat message - const std::string str = strprintf(_("equipped hat %s."), - info.getName().c_str()); + std::string str; + if (sprite == 0) + { + str = strprintf(_("no hat equipped.")); + } + else + { + const ItemInfo &info = ItemDB::get(sprite); + // TRANSLATORS: equipped hat chat message + str = strprintf(_("equipped hat %s."), + info.getName().c_str()); + } outString(event.tab, str, str); return true; } -- cgit v1.2.3-60-g2f50