Skip to content

Commit 8fb4270

Browse files
committed
Bug fix in material_value.c
An if is moved to its "right" place. A couple of redundant checks are eliminated.
1 parent e4ceb9b commit 8fb4270

File tree

2 files changed

+30
-26
lines changed

2 files changed

+30
-26
lines changed

src/Firenzina.vcxproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@
138138
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
139139
<CheckUndimensionedArrays>false</CheckUndimensionedArrays>
140140
<DisableIntelLangExtensions>false</DisableIntelLangExtensions>
141-
<OptimizeForWindowsApplication>false</OptimizeForWindowsApplication>
141+
<OptimizeForWindowsApplication>true</OptimizeForWindowsApplication>
142142
<StructMemberAlignment>Default</StructMemberAlignment>
143143
<DisableSpecificWarnings>
144144
</DisableSpecificWarnings>

src/material_value.c

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ static int WhiteWeight(int wP, int wN, int wB, int wBL, int wBD, int wR, int wQ,
267267
else if (bPhase == 4)
268268
wWeight = 1;
269269
}
270-
if (wR == 1)
270+
else if (wR == 1)
271271
{
272272
if (bPhase == 3)
273273
{
@@ -302,16 +302,17 @@ static int WhiteWeight(int wP, int wN, int wB, int wBL, int wBD, int wR, int wQ,
302302
if (wQ)
303303
{
304304
if (bPhase == 4)
305-
wWeight = 2;
306-
else if (bPhase == 5)
307-
wWeight = 1;
308-
if (bPhase == 4 && bR == 2)
309-
{
310-
if (wN)
311-
wWeight = 3;
312-
if (wB)
313-
wWeight = 7;
314-
}
305+
{
306+
if (bR == 2)
307+
{
308+
if (wN)
309+
wWeight = 3;
310+
if (wB)
311+
wWeight = 7;
312+
}
313+
else
314+
wWeight = 2;
315+
}
315316
else if (bPhase == 5)
316317
wWeight = 1;
317318
}
@@ -484,9 +485,10 @@ static int WhiteWeight(int wP, int wN, int wB, int wBL, int wBD, int wR, int wQ,
484485
wWeight = 7;
485486
}
486487
}
488+
if (wQ == 1 && wPhase == 4 && bPhase >= 2 && bP >= 1) // Added on 3/29/2013, recommended by Jose Maria Velasco
489+
wWeight = 5;
487490
}
488-
if (wQ == 1 && wPhase == 4 && bPhase >= 2 && bP >= 1) // Added on 3/29/2013, recommended by Jose Maria Velasco
489-
wWeight = 5;
491+
490492
return wWeight;
491493
}
492494
static int BlackWeight(int wP, int wN, int wB, int wBL, int wBD, int wR, int wQ, int bP, int bN, int bB, int bBL,
@@ -648,16 +650,17 @@ static int BlackWeight(int wP, int wN, int wB, int wBL, int wBD, int wR, int wQ,
648650
if (bQ)
649651
{
650652
if (wPhase == 4)
651-
bWeight = 2;
652-
else if (wPhase == 5)
653-
bWeight = 1;
654-
if (wPhase == 4 && wR == 2)
655-
{
656-
if (bN)
657-
bWeight = 3;
658-
if (bB)
659-
bWeight = 7;
660-
}
653+
{
654+
if (wR == 2)
655+
{
656+
if (bN)
657+
bWeight = 3;
658+
if (bB)
659+
bWeight = 7;
660+
}
661+
else
662+
bWeight = 2;
663+
}
661664
else if (wPhase == 5)
662665
bWeight = 1;
663666
}
@@ -830,9 +833,10 @@ static int BlackWeight(int wP, int wN, int wB, int wBL, int wBD, int wR, int wQ,
830833
bWeight = 7;
831834
}
832835
}
836+
if (bQ == 1 && bPhase == 4 && wPhase >= 2 && wP >= 1) // Added on 3/29/2013, recommended by Jose Maria Velasco
837+
bWeight = 5;
833838
}
834-
if (bQ == 1 && bPhase == 4 && wPhase >= 2 && wP >= 1) // Added on 3/29/2013, recommended by Jose Maria Velasco
835-
bWeight = 5;
839+
836840
return bWeight;
837841
}
838842

0 commit comments

Comments
 (0)