Fuse market update and market check thread:
(check_all_markets): No longer a thread entry point. Remove the parameter. Remove *player setup. Don't terminate the thread when done. (market_update): Call check_all_markets() instead of running it in its own thread. Set up *player for it. (market_init): Create the fused update thread instead of the update wait thread.
This commit is contained in:
parent
f41e44fb74
commit
c9a041bd72
1 changed files with 14 additions and 22 deletions
|
@ -40,14 +40,9 @@
|
||||||
#include "prototypes.h"
|
#include "prototypes.h"
|
||||||
#include "server.h"
|
#include "server.h"
|
||||||
|
|
||||||
/*ARGSUSED*/
|
|
||||||
static void
|
static void
|
||||||
check_all_markets(void *unused)
|
check_all_markets(void)
|
||||||
{
|
{
|
||||||
player->proc = empth_self();
|
|
||||||
player->cnum = 0;
|
|
||||||
player->god = 1;
|
|
||||||
|
|
||||||
check_market();
|
check_market();
|
||||||
check_trade();
|
check_trade();
|
||||||
|
|
||||||
|
@ -58,10 +53,6 @@ check_all_markets(void *unused)
|
||||||
ef_flush(EF_LAND);
|
ef_flush(EF_LAND);
|
||||||
ef_flush(EF_COMM);
|
ef_flush(EF_COMM);
|
||||||
ef_flush(EF_TRADE);
|
ef_flush(EF_TRADE);
|
||||||
|
|
||||||
player_delete(player);
|
|
||||||
empth_exit();
|
|
||||||
/*NOTREACHED*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*ARGSUSED*/
|
/*ARGSUSED*/
|
||||||
|
@ -69,19 +60,15 @@ static void
|
||||||
market_update(void *unused)
|
market_update(void *unused)
|
||||||
{
|
{
|
||||||
time_t now;
|
time_t now;
|
||||||
struct player *dp;
|
|
||||||
|
player->proc = empth_self();
|
||||||
|
player->cnum = 0;
|
||||||
|
player->god = 1;
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
time(&now);
|
time(&now);
|
||||||
/* logerror("Checking the world markets at %s", ctime(&now));*/
|
check_all_markets();
|
||||||
dp = player_new(-1);
|
now += 300; /* Every 5 minutes */
|
||||||
if (dp) {
|
|
||||||
empth_create(PP_UPDATE, check_all_markets, (50 * 1024), 0,
|
|
||||||
"MarketCheck", "Checks the world markets", dp);
|
|
||||||
} else {
|
|
||||||
logerror("can't create dummy player for market update");
|
|
||||||
}
|
|
||||||
now = now + 300; /* Every 5 minutes */
|
|
||||||
empth_sleep(now);
|
empth_sleep(now);
|
||||||
}
|
}
|
||||||
/*NOTREACHED*/
|
/*NOTREACHED*/
|
||||||
|
@ -90,9 +77,14 @@ market_update(void *unused)
|
||||||
void
|
void
|
||||||
market_init(void)
|
market_init(void)
|
||||||
{
|
{
|
||||||
|
struct player *dp;
|
||||||
|
|
||||||
if (!opt_MARKET)
|
if (!opt_MARKET)
|
||||||
return;
|
return;
|
||||||
if (!empth_create(PP_TIMESTAMP, market_update, 50 * 1024, 0,
|
dp = player_new(-1);
|
||||||
"MarketUpdate", "Updates the market", NULL))
|
if (!dp)
|
||||||
|
exit_nomem();
|
||||||
|
if (!empth_create(PP_UPDATE, market_update, 50 * 1024, 0,
|
||||||
|
"MarketUpdate", "Updates the market", dp))
|
||||||
exit_nomem();
|
exit_nomem();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue