[C++]DevilTower minor bug fix

03/10/2017 22:49 MrLibya#1
Hello

It's a minor bug but it's important , when u kill the devil tower boss and get ur reward and try to upgrade ur weapon or anything if u press yes and u haee money less then the cost u will lost the reward .

so here even if u have no money u will not lost the reward

to fix it :
open input_main.cpp
Code:
add : 
#include "refine.h"
// find this
    if (!item)
    {
        ch->ClearRefineMode();
        return;
    }
// a new code block
    const TRefineTable * prt = CRefineManager::instance().GetRefineRecipe(item->GetRefineSet());
    if (!prt)
    {
        ch->ClearRefineMode();
        return;
    }  
now search for : 
if (ch->GetQuestFlag("deviltower_zone.can_refine"))
replace the whole condition with this : 
if (ch->GetQuestFlag("deviltower_zone.can_refine"))
                {
                    if (ch->GetGold() >= prt->cost)
                    {
                        ch->DoRefine(item, true);
                        ch->SetQuestFlag("deviltower_zone.can_refine", 0);
                    }
                    else
                        ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("±¹°ي؟، µ·ہج ؛خء·اد°إ³ھ µ·ہ» °،ء®؟أ¼ِ ¾ّ´آ »َب²ہش´د´ظ"));
                }
sry 4 my english :D
03/10/2017 22:59 MaxChri#2
Nice thanks for the fix. I still can remember the bug again. :o :awesome:
03/11/2017 00:53 Metin2 Team#3
well done
PHP Code:
// find this
    
if (!item)
    {
        
ch->ClearRefineMode();
        return;
    }
// a new code block
    
const TRefineTable prt CRefineManager::instance().GetRefineRecipe(item->GetRefineSet());
    if (!
prt)
    {
        
ch->ClearRefineMode();
        return;
    } 
should look like this because it might cause a crash if the proto is null.
03/11/2017 09:42 MrLibya#4
Quote:
Originally Posted by Metin2 Team View Post
well done
PHP Code:
// find this
    
if (!item)
    {
        
ch->ClearRefineMode();
        return;
    }
// a new code block
    
const TRefineTable prt CRefineManager::instance().GetRefineRecipe(item->GetRefineSet());
    if (!
prt)
    {
        
ch->ClearRefineMode();
        return;
    } 
should look like this because it might cause a crash if the proto is null.
Oh , thx i will update the topic
03/11/2017 11:27 EULOG1SON#5
Find:

Replace it with:
03/11/2017 16:51 Yiv#6
You can just check the return value of the DoRefine function:

Replace this:
Code:
if (ch->GetQuestFlag("deviltower_zone.can_refine"))
{
	ch->DoRefine(item, true);
	ch->SetQuestFlag("deviltower_zone.can_refine", 0);
}
with this:
Code:
if (ch->GetQuestFlag("deviltower_zone.can_refine"))
{
	if (ch->DoRefine(item, true))
	{
		ch->SetQuestFlag("deviltower_zone.can_refine", 0);
	}
}
I just did a real quick look but the DoRefine function returns false if the requirements to do the upgrade are not fulfilled by the player so this should be enough.

Regards