Freeciv-3.1: /fast/freeciv/nightly/S3_1/common/workertask.c Source File

Freeciv-3.1

Loading...
Searching...
No Matches
workertask.c
Go to the documentation of this file.
1/****************************************************************************
2 Freeciv - Copyright (C) 2004 - The Freeciv Team
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
6 any later version.
7
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12****************************************************************************/
13
14#ifdef HAVE_CONFIG_H
15#include <fc_config.h>
16#endif
17
18/* utility */
19#include "log.h"
20
21/* common */
22#include "city.h"
23#include "extras.h"
24#include "unit.h"
25
26#include "workertask.h"
27
28/************************************************************************/
31 void worker_task_init(struct worker_task *ptask)
32{
33 ptask->ptile = NULL;
34 ptask->want = 0;
35}
36
37/************************************************************************/
40 bool worker_task_is_sane(struct worker_task *ptask)
41{
42 if (ptask == NULL) {
43 return FALSE;
44 }
45
46 if (ptask->ptile == NULL) {
47 return FALSE;
48 }
49
50 if (!is_real_activity(ptask->act)) {
51 return FALSE;
52 }
53
54 if (activity_requires_target(ptask->act)) {
55 if (ptask->tgt == NULL) {
56 return FALSE;
57 }
58 if (!is_extra_caused_by(ptask->tgt,
59 activity_to_extra_cause(ptask->act))
60 && !is_extra_removed_by(ptask->tgt,
61 activity_to_extra_rmcause(ptask->act))) {
62 return FALSE;
63 }
64 }
65
66 return TRUE;
67}
city.h
activity_to_extra_cause
enum extra_cause activity_to_extra_cause(enum unit_activity act)
Definition extras.c:1028
is_extra_removed_by
bool is_extra_removed_by(const struct extra_type *pextra, enum extra_rmcause rmcause)
Definition extras.c:327
activity_to_extra_rmcause
enum extra_rmcause activity_to_extra_rmcause(enum unit_activity act)
Definition extras.c:1049
extras.h
is_extra_caused_by
#define is_extra_caused_by(e, c)
Definition extras.h:196
log.h
worker_task
Definition workertask.h:21
worker_task::act
enum unit_activity act
Definition workertask.h:23
worker_task::ptile
struct tile * ptile
Definition workertask.h:22
worker_task::tgt
struct extra_type * tgt
Definition workertask.h:24
worker_task::want
int want
Definition workertask.h:25
TRUE
#define TRUE
Definition support.h:46
FALSE
#define FALSE
Definition support.h:47
is_real_activity
bool is_real_activity(enum unit_activity activity)
Definition unit.c:605
activity_requires_target
bool activity_requires_target(enum unit_activity activity)
Definition unit.c:537
unit.h
worker_task_is_sane
bool worker_task_is_sane(struct worker_task *ptask)
Definition workertask.c:40
worker_task_init
void worker_task_init(struct worker_task *ptask)
Definition workertask.c:31
workertask.h