Fix issue #1275 - wielded index greater than inv size.
authorRealBadAngel <maciej.kasatkin@o2.pl>
Tue, 17 Jun 2014 11:03:24 +0000 (13:03 +0200)
committerRealBadAngel <maciej.kasatkin@o2.pl>
Tue, 17 Jun 2014 12:17:53 +0000 (14:17 +0200)
src/game.cpp

index 609ca1a1ae2b48f0e8eccde9261fedbeafd6b0ad..c2ee7f311116a15b32bc3e0a9b08d246de756bf2 100644 (file)
@@ -2581,10 +2581,8 @@ void the_game(bool &kill, bool random_input, InputHandler *input,
                ItemStack playeritem;
                {
                        InventoryList *mlist = local_inventory.getList("main");
-                       if(mlist != NULL)
-                       {
+                       if((mlist != NULL) && (client.getPlayerItem() < mlist->getSize()))
                                playeritem = mlist->getItem(client.getPlayerItem());
-                       }
                }
                const ItemDefinition &playeritem_def =
                                playeritem.getDefinition(itemdef);
@@ -3332,7 +3330,7 @@ void the_game(bool &kill, bool random_input, InputHandler *input,
                        // Update wielded tool
                        InventoryList *mlist = local_inventory.getList("main");
                        ItemStack item;
-                       if(mlist != NULL)
+                       if((mlist != NULL) && (client.getPlayerItem() < mlist->getSize()))
                                item = mlist->getItem(client.getPlayerItem());
                        camera.wield(item, client.getPlayerItem());
                }