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 096b7dd..b8e300f 100644 Binary files a/CharmDatabase.cpp and b/CharmDatabase.cpp differ diff --git a/Form1.h b/Form1.h index a2b59ed..0e3e7e6 100644 --- a/Form1.h +++ b/Form1.h @@ -3059,7 +3059,8 @@ namespace MHGUASS System::Void SortResults() { - if( cmbSort->SelectedIndex < 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;