1 /*
2  * Copyright (C) 2003 Tim Martin
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
17  */
18 
19 #ifndef POPULATION_H
20 #define POPULATION_H
21 
22 #include "player.h"
23 #include "map.h"
24 #include "game.h"
25 
26 typedef struct population_s population_t;
27 
28 #define MAXAGE 80
29 
30 #define PERSON_FLAG_HASCHILD 0x1
31 
32 typedef struct person_s {
33     short uid;
34 
35     short livex;
36     short livey;
37 
38     short workx;
39     short worky;
40 
41     short savings; /* in 100's of $ */
42     unsigned char happy;
43     unsigned char flags;
44     unsigned int edlevel:5;
45     int worklevel:3;
46 } person_t;
47 
48 typedef struct popgroup_s {
49     int size;  /* number of people in this group */
50 
51     int allocsize;
52     person_t *data;
53 } popgroup_t;
54 
55 int population_init(population_t **pop);
56 
57 int population_imigrate(population_t *pop, int);
58 int population_exigrate(population_t *pop, map_t *map, int);
59 
60 int population_age1year(population_t *pop, map_t *map);
61 int population_born(population_t *pop, int);
62 
63 int population_movehousing(population_t *pop, map_t *map);
64 int population_changejobs(population_t *pop, map_t *map);
65 void population_investment(population_t *pop, map_t *map, int, int);
66 
67 int population_paysalaries(population_t *pop, map_t *map);
68 int population_payrent(population_t *pop, map_t *map);
69 int population_patronize(population_t *pop, map_t *map);
70 void population_payupkeep(population_t *pop, map_t *map);
71 void population_revenue(population_t *pop, map_t *map);
72 void population_calculate_happiness(population_t *pop);
73 
74 popgroup_t *population_getgroup(population_t *pop, int age);
75 
76 int population_getproduction(population_t *pop);
77 int population_investment_available(population_t *pop);
78 
79 int population_property_tax(population_t *pop);
80 
81 float population_homeless_rate(population_t *pop);
82 float population_unemployment_rate(population_t *pop);
83 int population_fire_everybody(population_t *pop, int x, int y);
84 int population_evict_everybody(population_t *pop, int x, int y);
85 int population_jobs_avail(population_t *pop);
86 int population_houses_avail(population_t *pop);
87 
88 char *population_reason_string(happy_reason_t reason);
89 void population_newmonth(void);
90 extern int population_calculate_adults(population_t *pop);
91 extern int population_calculate_needhousing(population_t *pop);
92 extern void population_calculate_unemployed(population_t *pop, labor_t *labor);
93 extern void population_center(population_t *pop, int *x, int *y);
94 
95 typedef void child_iterate_func(person_t *, void *);
96 
97 extern void
98 population_foreach_child(population_t *pop, short uid,
99 			 child_iterate_func *func, void *rock);
100 
101 #endif /* POPULATION_H */
102