summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFranklin Wei <frankhwei536@gmail.com>2015-08-14 22:11:06 -0400
committerSolomon Peachy <pizza@shaftnet.org>2024-05-26 11:51:30 -0400
commite72bae7c3ff538769ec01ed2c38ebd236b319edf (patch)
tree53ae481a18161966a9c3c049c3d924786fe410b7
parent4e54443dc95ef6fb0560b84389728a00f05ccac8 (diff)
downloadrockbox-e72bae7c3f.tar.gz
rockbox-e72bae7c3f.zip
[Superdom] Bugfix
Prevents the plugin from locking up on the highest difficulty level Change-Id: I07ab77e825935948b2d15ca6d36ad24b2716ac1b
-rw-r--r--apps/plugins/superdom.c33
1 files changed, 14 insertions, 19 deletions
diff --git a/apps/plugins/superdom.c b/apps/plugins/superdom.c
index 79a6d1a8f2..efa6f4a22a 100644
--- a/apps/plugins/superdom.c
+++ b/apps/plugins/superdom.c
@@ -1941,37 +1941,32 @@ static void computer_allocate(void)
}
}
}
- if(superdom_settings.compdiff>=AI_BUILD_INDS_FARMS_LEVEL && compres.cash>=PRICE_FACTORY)
+ if(superdom_settings.compdiff>=AI_BUILD_INDS_FARMS_LEVEL && compres.cash>=PRICE_FACTORY+100)
{
- while(compres.cash>=PRICE_FACTORY)
+ int i = 0;
+ do
{
if(compres.farms<compres.inds)
{
- while(compres.farms<compres.inds && compres.cash>=PRICE_FARM)
+ i = rb->rand()%BOARD_SIZE + 1;
+ j = rb->rand()%BOARD_SIZE + 1;
+ if(board[i][j].colour == COLOUR_DARK && !board[i][j].farm)
{
- i = rb->rand()%BOARD_SIZE + 1;
- j = rb->rand()%BOARD_SIZE + 1;
- if(board[i][j].colour == COLOUR_DARK && !board[i][j].farm)
- {
- buy_resources(COLOUR_DARK, 3, i, j, 0);
- break;
- }
+ buy_resources(COLOUR_DARK, 3, i, j, 0);
+ break;
}
}
else
{
- while(compres.inds<compres.farms && compres.cash>=PRICE_FACTORY)
+ i = rb->rand()%BOARD_SIZE + 1;
+ j = rb->rand()%BOARD_SIZE + 1;
+ if(board[i][j].colour == COLOUR_DARK && !board[i][j].ind)
{
- i = rb->rand()%BOARD_SIZE + 1;
- j = rb->rand()%BOARD_SIZE + 1;
- if(board[i][j].colour == COLOUR_DARK && !board[i][j].ind)
- {
- buy_resources(COLOUR_DARK, 4, i, j, 0);
- break;
- }
+ buy_resources(COLOUR_DARK, 4, i, j, 0);
+ break;
}
}
- }
+ } while(compres.cash>=PRICE_FACTORY + 100 && i++ < 3);
}
/* AI will buy nukes first if possible */
if(compres.cash > PRICE_NUKE + PRICE_TANK && superdom_settings.compdiff>=AI_BUILD_NUKES_LEVEL)