From 56c56f81e3d58f3752f69b7b9524e55691232d1a Mon Sep 17 00:00:00 2001 From: DjWarmonger Date: Sat, 28 Jan 2012 11:42:15 +0000 Subject: [PATCH] Fixed #849. Fixed buying artifacts for free. Minor tweaks. --- client/GUIClasses.cpp | 18 ++++++++++++------ config/creatures.json | 12 ++---------- lib/CObjectHandler.cpp | 5 ++--- 3 files changed, 16 insertions(+), 19 deletions(-) diff --git a/client/GUIClasses.cpp b/client/GUIClasses.cpp index 57b7e2e38..22f57507a 100644 --- a/client/GUIClasses.cpp +++ b/client/GUIClasses.cpp @@ -2883,12 +2883,18 @@ void CMarketplaceWindow::makeDeal() return; int leftIdToSend = -1; - if(mode == EMarketMode::CREATURE_RESOURCE) - leftIdToSend = hLeft->serial; - else if(mode == EMarketMode::ARTIFACT_RESOURCE) - leftIdToSend = hLeft->getArtInstance()->id; - else - leftIdToSend = hLeft->id; + switch (mode) + { + case EMarketMode::CREATURE_RESOURCE: + leftIdToSend = hLeft->serial; + break; + case EMarketMode::ARTIFACT_RESOURCE: + leftIdToSend = hLeft->getArtInstance()->id; + break; + default: + leftIdToSend = hLeft->id; + break; + } if(slider) { diff --git a/config/creatures.json b/config/creatures.json index f47b10251..20bd13d92 100644 --- a/config/creatures.json +++ b/config/creatures.json @@ -428,11 +428,7 @@ "level": 7, "name": [ "LesserTitan" ], "faction": 2, - "ability_add": [ [ "SPELL_IMMUNITY", 0, 62, 0 ], //giants are immune to mind spells (blind) - [ "SPELL_IMMUNITY", 0, 61, 0 ], //giants are immune to mind spells (forgetfulness) - [ "SPELL_IMMUNITY", 0, 60, 0 ], //giants are immune to mind spells (hypnotize) - [ "SPELL_IMMUNITY", 0, 59, 0 ], //giants are immune to mind spells (berserk) - [ "SPELL_IMMUNITY", 0, 50, 0 ] ], //giants are immune to mind spells (sorrow) + "ability_add": [ ["MIND_IMMUNITY", 0, 0, 0] ], //giants are immune to mind spells "upgrade": 41, "defname": "CLTITA.DEF" }, @@ -442,11 +438,7 @@ "level": 7, "name": [ "GreaterTitan" ], "faction": 2, - "ability_add": [ [ "SPELL_IMMUNITY", 0, 62, 0 ], //titans are immune to mind spells (blind) - [ "SPELL_IMMUNITY", 0, 61, 0 ], //titans are immune to mind spells (forgetfulness) - [ "SPELL_IMMUNITY", 0, 60, 0 ], //titans are immune to mind spells (hypnotize) - [ "SPELL_IMMUNITY", 0, 59, 0 ], //titans are immune to mind spells (berserk) - [ "SPELL_IMMUNITY", 0, 50, 0 ], //titans are immune to mind spells (sorrow) + "ability_add": [ ["MIND_IMMUNITY", 0, 0, 0], //Titans are immune to mind spells [ "HATE", 50, 83, 0 ] ], //titans hate black dragons "defname": "CGTITA.DEF", "projectile_defname": "CPRGTIX.DEF", diff --git a/lib/CObjectHandler.cpp b/lib/CObjectHandler.cpp index f4869e140..d214918f7 100644 --- a/lib/CObjectHandler.cpp +++ b/lib/CObjectHandler.cpp @@ -6816,8 +6816,7 @@ bool IMarket::getOffer(int id1, int id2, int &val1, int &val2, EMarketMode::EMar if(id1 != 6) //non-gold prices are doubled r /= 2; - assert(g >= r); //should we allow artifacts cheaper than unit of resource? - val1 = (g / r) + 0.5; + val1 = std::max(1, (int)((g / r) + 0.5)); //don't sell arts for less than 1 resource val2 = 1; } break; @@ -6831,7 +6830,7 @@ bool IMarket::getOffer(int id1, int id2, int &val1, int &val2, EMarketMode::EMar // r /= 2; val1 = 1; - val2 = (r / g) + 0.5; + val2 = std::max(1, (int)((r / g) + 0.5)); //at least one resource is given in return } break; case EMarketMode::CREATURE_EXP: