]> 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-2007, 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  */
33
34 #include <config.h>
35
36 #include "empthread.h"
37 #include "file.h"
38 #include "player.h"
39 #include "prototypes.h"
40 #include "server.h"
41
42 /*ARGSUSED*/
43 static void
44 check_all_markets(void *unused)
45 {
46     player->proc = empth_self();
47     player->cnum = 0;
48     player->god = 1;
49
50     check_market();
51     check_trade();
52
53     ef_flush(EF_NATION);
54     ef_flush(EF_SECTOR);
55     ef_flush(EF_PLANE);
56     ef_flush(EF_SHIP);
57     ef_flush(EF_LAND);
58     ef_flush(EF_COMM);
59     ef_flush(EF_TRADE);
60
61     player_delete(player);
62     empth_exit();
63     /*NOTREACHED*/
64 }
65
66 /*ARGSUSED*/
67 void
68 market_update(void *unused)
69 {
70     time_t now;
71     struct player *dp;
72
73     while (1) {
74         time(&now);
75 /*      logerror("Checking the world markets at %s", ctime(&now));*/
76         dp = player_new(-1);
77         if (dp) {
78             empth_create(PP_UPDATE, check_all_markets, (50 * 1024), 0,
79                          "MarketCheck", "Checks the world markets", dp);
80         } else {
81             logerror("can't create dummy player for market update");
82         }
83         now = now + 300;        /* Every 5 minutes */
84         empth_sleep(now);
85     }
86     /*NOTREACHED*/
87 }