From 95fc9b3bffb9d2df1178070a57879493ea894f22 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Thu, 1 Jun 2023 03:27:20 +0300 Subject: [PATCH 15/15] Fix erroneously failing worker task sanity check It was not accepting targetless, i.e., terrain converting, irrigate or mine activities. In S3_0 those still exist. Reported by alain_bkr See osdn #47542 Signed-off-by: Marko Lindqvist --- common/workertask.c | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/common/workertask.c b/common/workertask.c index ebad1394af..0f772b5395 100644 --- a/common/workertask.c +++ b/common/workertask.c @@ -34,9 +34,9 @@ void worker_task_init(struct worker_task *ptask) ptask->want = 0; } -/************************************************************************//** - Returns TRUE iff the specified worker_task is sane. -****************************************************************************/ +/************************************************************************* + Returns TRUE iff the specified task is sane. +*************************************************************************/ bool worker_task_is_sane(struct worker_task *ptask) { if (ptask == NULL) { @@ -52,14 +52,22 @@ bool worker_task_is_sane(struct worker_task *ptask) } if (activity_requires_target(ptask->act)) { - if (ptask->tgt == NULL) { - return FALSE; - } - if (!is_extra_caused_by(ptask->tgt, - activity_to_extra_cause(ptask->act)) - && !is_extra_removed_by(ptask->tgt, - activity_to_extra_rmcause(ptask->act))) { - return FALSE; + if (ptask->tgt != NULL) { + if (!is_extra_caused_by(ptask->tgt, + activity_to_extra_cause(ptask->act)) + && !is_extra_removed_by(ptask->tgt, + activity_to_extra_rmcause(ptask->act))) { + return FALSE; + } + } else { + struct terrain *pterrain = tile_terrain(ptask->ptile); + + if ((ptask->act != ACTIVITY_IRRIGATE + || pterrain->irrigation_result == pterrain) + && (ptask->act != ACTIVITY_MINE + && pterrain->mining_result == pterrain)) { + return FALSE; + } } } -- 2.39.2