]> git.pond.sub.org Git - empserver/blob - src/server/marketup.c
Import of Empire 4.2.12
[empserver] / src / server / marketup.c
1 /*
2  *  Empire - A multi-player, client/server Internet based war game.
3  *  Copyright (C) 1986-2000, 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 the "LEGAL", "LICENSE", "CREDITS" and "README" files for all the
23  *  related information and legal notices. It is expected that any future
24  *  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 "options.h"
35 #include "misc.h"
36 #include "player.h"
37 #include "keyword.h"
38 #include "empthread.h"
39 #include "file.h"
40 #include <stdio.h>
41 #include "prototypes.h"
42
43 /*ARGSUSED*/
44 void
45 check_all_markets(argv)
46 void *argv;
47 {
48     player->proc = empth_self();
49     player->cnum = 0;
50     player->god = 1;
51
52     check_market();
53     check_trade();
54
55     ef_flush(EF_NATION);
56     ef_flush(EF_SECTOR);
57     ef_flush(EF_PLANE);
58     ef_flush(EF_SHIP);
59     ef_flush(EF_LAND);
60     ef_flush(EF_COMM);
61     ef_flush(EF_TRADE);
62
63     player_delete(player);
64     empth_exit();
65     /*NOTREACHED*/
66 }
67
68 /*ARGSUSED*/
69 void
70 market_update(argv)
71 void    *argv;
72 {
73     time_t    now;
74     struct player *dp;
75     
76     while (1) {
77         time(&now);
78 /*      logerror("Checking the world markets at %s", ctime(&now));*/
79         dp = player_new(0, 0);
80         empth_create(PP_UPDATE, check_all_markets, (50*1024), 0,
81                   "MarketCheck", "Checks the world markets", dp);
82         now = now + 300; /* Every 5 minutes */
83         empth_sleep(now);
84     }
85     /*NOTREACHED*/
86 }
87