struct hostent *hostp;
lp = (struct player *)malloc(sizeof(struct player));
+ if (!lp)
+ return NULL;
memset(lp, 0, sizeof(struct player));
if (sin) {
- /* update uses dummy player */
- /* so does the market updater */
+ /* real player, not dummy created by update and market update */
+ lp->iop = io_open(s,
+ IO_READ | IO_WRITE | IO_NBLOCK,
+ IO_BUFSIZE, 0, 0);
+ if (!lp->iop) {
+ free(lp);
+ return NULL;
+ }
emp_insque(&lp->queue, &Players);
strcpy(lp->hostaddr, inet_ntoa(sin->sin_addr));
#ifdef RESOLVE_IPADDRESS
lp->cnum = 255;
lp->curid = -1;
time(&lp->curup);
- lp->iop = io_open(s, IO_READ | IO_WRITE | IO_NBLOCK,
- IO_BUFSIZE, 0, 0);
}
return lp;
}
continue;
}
np = player_new(ns, &sin);
+ if (!np) {
+ logerror("can't create player for fd %d", ns);
+ close(ns);
+ continue;
+ }
/* XXX may not be big enough */
stacksize = 100000
/* budget */ + max(WORLD_X * WORLD_Y / 2 * sizeof(int) * 7,
time(&now);
/* logerror("Checking the world markets at %s", ctime(&now));*/
dp = player_new(0, 0);
- empth_create(PP_UPDATE, check_all_markets, (50 * 1024), 0,
- "MarketCheck", "Checks the world markets", dp);
+ 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);
}
* in the land so it can finish before it yields.
*/
dp = player_new(0, 0);
+ if (!dp) {
+ logerror("can't create dummy player for update");
+ continue;
+ }
stacksize = 100000 +
/* finish_sects */ WORLD_X * WORLD_Y * (2 * sizeof(double) +
sizeof(s_char *));