From 30abf893199f6dca507c578d9452af2535f7f6bd Mon Sep 17 00:00:00 2001 From: AthenaADP Date: Wed, 3 Oct 2018 16:23:58 +0800 Subject: [PATCH] Fixed searching for Taunt charms --- Armor.cpp | 5 +++-- CharmDatabase.cpp | Bin 76230 -> 82490 bytes Form1.h | 11 ++--------- Solution.cpp | 36 +++++++++++++++++++++++++++++++++--- 4 files changed, 38 insertions(+), 14 deletions(-) diff --git a/Armor.cpp b/Armor.cpp index 37a8e57..4766cf1 100644 --- a/Armor.cpp +++ b/Armor.cpp @@ -454,11 +454,12 @@ String^ Charm::GetName() return Utility::SlotString( num_slots ); else if( abilities.Count == 1 ) { - return FormatString3( CharmFormat1, L"+" + Convert::ToString( abilities[ 0 ]->amount ), abilities[ 0 ]->ability->name, Utility::SlotString( num_slots ) ); + String^ num1 = ( abilities[ 0 ]->amount > 0 ? L"+" : L"" ) + Convert::ToString( abilities[ 0 ]->amount ); + return FormatString3( CharmFormat1, num1, abilities[ 0 ]->ability->name, Utility::SlotString( num_slots ) ); } else if( abilities.Count == 2 ) { - String^ num1 = L"+" + Convert::ToString( abilities[ 0 ]->amount ); + String^ num1 = ( abilities[ 0 ]->amount > 0 ? L"+" : L"" ) + Convert::ToString( abilities[ 0 ]->amount ); String^ num2 = ( abilities[ 1 ]->amount > 0 ? L"+" : L"" ) + Convert::ToString( abilities[ 1 ]->amount ); return FormatString5( CharmFormat2, num1, abilities[ 0 ]->ability->name, num2, abilities[ 1 ]->ability->name, Utility::SlotString( num_slots ) ); } diff --git a/CharmDatabase.cpp b/CharmDatabase.cpp index 096b7dd1566d83daec5be9b5582d0644a2e1efb3..b8e300f8670abdc5193b6ba4f5bd166a7d3354ca 100644 GIT binary patch delta 2412 zcmb7FZA?^06rI6kT^9uR!jJUi<4XR|IRC(e!?&%%AIX)O@38=@V~uPT^)+k_{cB|F*ftuk zVh!wF8gHO453yf(w4R!OIF2n?hOxyNo;c(QZG>tEU*GjSS04YdkEnP`9->#}HuSubg4g?A z3-?k)y!gB?5pCaDQMFpZ{yTB-_vc~d3M+j5R&@9Mgk60(=-J|!QLHP|h_(^uci39u zdJ9Rdfi0)Q3^X@<2V9Av(GQ7w<2VuXv~LG?bJU$vwaPzRIoeKIV&7o(1lq_d34E)R z9|E^*xSW^714!*n=hZlLH(4^`4Cum_2@{}JLLa37n~%WSWM_47tvYng9tb8{h`nAYlS1~>`bfXOq4 zwu~gk)aw7ex~?&2g?SMo>}O|M)){&|~tUmhd)i%nvB<+Z^ND-_4f+7$A26WNdPEhku- z4YP~v9G`S(AMR{gn2y`1j+kg!AH-a_4Xu4axRq04y&u??GP(#;CjXw;Nfyh^j4>Z%L$o+^YxV>Z|@oQWRZh9&oRVl!0 zDj7Vdk@>GMof7fY*S9Q6i8z_hDkinOal7;-!0Q~xKSelectedIndex < 1 || sort_off ) return; + if( cmbSort->SelectedIndex < 1 || sort_off ) + return; else if( cmbSort->SelectedIndex == 1 ) final_solutions.Sort( gcnew Comparison< Solution^ >( CompareSolutionByDragonRes ) ); else if( cmbSort->SelectedIndex == 2 ) @@ -3086,14 +3087,6 @@ namespace MHGUASS final_solutions.Sort( gcnew Comparison< Solution^ >( CompareSolutionsByExtraSkills ) ); } - bool EndsWithSlots( String^% s ) - { - return s->EndsWith( L" ---" ) || - s->EndsWith( L"O--" ) || - s->EndsWith( L"OO-" ) || - s->EndsWith( L"OOO" ); - } - void contextMenuStrip1_Closing( System::Object^ sender, ToolStripDropDownClosingEventArgs^ e ) { if( preview_pane ) diff --git a/Solution.cpp b/Solution.cpp index 4412918..c0cf47a 100644 --- a/Solution.cpp +++ b/Solution.cpp @@ -101,16 +101,22 @@ bool Solution::FixBadSkill( Skill^ skill ) { if( slots_spare[ dec->slots_required + 1 ] == 0 ) { + Assert( slots_spare[ 3 ] > 0, L"Not enough slots spare" ); slots_spare[ 3 ]--; slots_spare[ 2 ]++; } else { + Assert( data->solution->slots_spare[ dec->slots_required + 1 ] > 0, L"Not enough slots spare" ); slots_spare[ dec->slots_required + 1 ]--; slots_spare[ 1 ]++; } } - else slots_spare[ dec->slots_required ]--; + else + { + Assert( slots_spare[ dec->slots_required ] > 0, L"Not enough slots spare" ); + slots_spare[ dec->slots_required ]--; + } if( AddDecoration( data->solution, dec, 1, non_body_decorations ) ) return true; @@ -742,6 +748,8 @@ void Solution::ReduceSlots() if( i <= 3 ) { //if( i > charm->num_slots ) + Assert( slots_spare[ i ] > 0, L"Not enough slots spare" ); + slots_spare[ i - charm->num_slots ]++; slots_spare[ i ]--; total_slots_spare -= charm->num_slots; @@ -891,8 +899,13 @@ void Solution::AddExtraSkills() unsigned spare[4] = { 0, slots_spare[1], slots_spare[2], slots_spare[3] }; for( unsigned size = 4; size --> 1; ) { + Assert( (int)slots_spare[ size ] >= 0, L"Negative slots spare?" ); + if( (int)slots_spare[ size ] < 0 ) + continue; + for( unsigned i = 0; i < slots_spare[size]; ++i ) { + Assert( spare[ size] > 0, L"Not enough slots spare" ); spare[size]--; unsigned s = size; while( s > 0 ) @@ -974,7 +987,10 @@ bool CalculateTaunt( CalculationData^ data ) if( data->query->taunt_decorations.Count == 0 ) return false; - const int effective_total = data->solution->torso_slots_spare * data->solution->torso_multiplier + ( data->solution->total_slots_spare - data->solution->torso_slots_spare ); + const int effective_total = + data->solution->torso_slots_spare * data->solution->torso_multiplier + + data->solution->charm_slots_spare * ( data->solution->charm_up ? 1 : 0 ) + + ( data->solution->total_slots_spare - data->solution->torso_slots_spare ); int need = have + 10; if( need > effective_total ) return false; @@ -1000,6 +1016,7 @@ bool CalculateTaunt( CalculationData^ data ) } } } + while( data->solution->torso_slots_spare > 0 && need > 0 ) { AddDecoration( data->solution, best, data->solution->torso_multiplier, data->solution->body_decorations ); @@ -1007,6 +1024,13 @@ bool CalculateTaunt( CalculationData^ data ) data->solution->torso_slots_spare--; } + while( data->solution->charm_slots_spare > 0 && need > 0 ) + { + AddDecoration( data->solution, best, data->solution->torso_multiplier, data->solution->charm_decorations ); + need -= data->solution->charm_up ? 2 : 1; + data->solution->charm_slots_spare--; + } + while( data->solution->total_slots_spare > 0 && need > 0 ) { AddDecoration( data->solution, best, 1, data->solution->non_body_decorations ); @@ -1015,16 +1039,22 @@ bool CalculateTaunt( CalculationData^ data ) { if( data->solution->slots_spare[2] == 0 ) { + Assert( data->solution->slots_spare[ 3 ] > 0, L"Not enough slots spare" ); data->solution->slots_spare[3]--; data->solution->slots_spare[2]++; } else { + Assert( data->solution->slots_spare[ 2 ] > 0, L"Not enough slots spare" ); data->solution->slots_spare[2]--; data->solution->slots_spare[1]++; } } - else data->solution->slots_spare[1]--; + else + { + Assert( data->solution->slots_spare[ 1 ] > 0, L"Not enough slots spare" ); + data->solution->slots_spare[ 1 ]--; + } } return true;