summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortron <tron@openttd.org>2005-09-23 06:34:06 +0000
committertron <tron@openttd.org>2005-09-23 06:34:06 +0000
commitafcb9f0d602d6f26393efcdc638e64ecbb4b753b (patch)
tree08abed3b34006ce90e787907ae8fff76b59652c4
parenteeeeecb03011d7d7d88fba79a74608f73b961386 (diff)
downloadopenttd-afcb9f0d602d6f26393efcdc638e64ecbb4b753b.tar.xz
(svn r2972) Fix the speed of the AI
-rw-r--r--ai/ai.c24
1 files changed, 3 insertions, 21 deletions
diff --git a/ai/ai.c b/ai/ai.c
index 3fcd94cff..6779528e2 100644
--- a/ai/ai.c
+++ b/ai/ai.c
@@ -149,27 +149,9 @@ void AI_RunGameLoop(void)
_ai.tick++;
/* Make sure the AI follows the difficulty rule.. */
- switch (_opt.diff.competitor_speed) {
- case 0: // Very slow
- if (!(_ai.tick & 8)) return;
- break;
-
- case 1: // Slow
- if (!(_ai.tick & 4)) return;
- break;
-
- case 2: // Medium
- if (!(_ai.tick & 2)) return;
- break;
-
- case 3: // Fast
- if (!(_ai.tick & 1)) return;
- break;
-
- case 4: // Very fast
- default:
- break;
- }
+ assert(_opt.diff.competitor_speed <= 4);
+ if ((_ai.tick & ((1 << (4 - _opt.diff.competitor_speed)) - 1)) != 0)
+ return;
/* Check for AI-client (so joining a network with an AI) */
if (_ai.network_client) {