]> git.pond.sub.org Git - empserver/blob - src/server/marketup.c
Update copyright notice
[empserver] / src / server / marketup.c
1 /*
2  *  Empire - A multi-player, client/server Internet based war game.
3  *  Copyright (C) 1986-2010, Dave Pare, Jeff Bailey, Thomas Ruschak,
4  *                           Ken Stevens, Steve McClure
5  *
6  *  This program is free software; you can redistribute it and/or modify
7  *  it under the terms of the GNU General Public License as published by
8  *  the Free Software Foundation; either version 2 of the License, or
9  *  (at your option) any later version.
10  *
11  *  This program is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *  GNU General Public License for more details.
15  *
16  *  You should have received a copy of the GNU General Public License
17  *  along with this program; if not, write to the Free Software
18  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19  *
20  *  ---
21  *
22  *  See files README, COPYING and CREDITS in the root of the source
23  *  tree for related information and legal notices.  It is expected
24  *  that future projects/authors will amend these files as needed.
25  *
26  *  ---
27  *
28  *  marketup.c: Market updater thread
29  *
30  *  Known contributors to this file:
31  *     Steve McClure, 1996
32  *     Markus Armbruster, 2007
33  */
34
35 #include <config.h>
36
37 #include "empthread.h"
38 #include "file.h"
39 #include "optlist.h"
40 #include "player.h"
41 #include "prototypes.h"
42 #include "server.h"
43
44 /*ARGSUSED*/
45 static void
46 market_update(void *unused)
47 {
48     time_t now;
49
50     player->proc = empth_self();
51     player->cnum = 0;
52     player->god = 1;
53
54     for (;;) {
55         time(&now);
56         check_market();
57         check_trade();
58         now += 300;             /* Every 5 minutes */
59         empth_sleep(now);
60     }
61     /*NOTREACHED*/
62 }
63
64 void
65 market_init(void)
66 {
67     struct player *dp;
68
69     if (!opt_MARKET)
70         return;
71     dp = player_new(-1);
72     if (!dp)
73         exit_nomem();
74     if (!empth_create(market_update, 50 * 1024, 0, "MarketUpdate", dp))
75         exit_nomem();
76 }