void mkgold(long num, int x, int y) { struct gold *gold; long amount = (num ? num : 1 + (rnd(dlevel+2) * rnd(30))); if((gold = g_at(x,y))) gold->amount += amount; else { gold = newgold(); gold->ngold = fgold; gold->gx = x; gold->gy = y; gold->amount = amount; fgold = gold; /* do sth with display? */ } }
void getlev(int fd, int pid, xchar lev) { struct gold *gold; struct trap *trap; #ifndef NOWORM struct wseg *wtmp; #endif /* NOWORM */ int tmp; long omoves; int hpid; xchar dlvl; /* First some sanity checks */ mread(fd, &hpid, sizeof(hpid)); mread(fd, &dlvl, sizeof(dlvl)); if ((pid && pid != hpid) || (lev && dlvl != lev)) { pline("Strange, this map is not as I remember it."); pline("Somebody is trying some trickery here ..."); pline("This game is void ..."); done("tricked"); } fgold = 0; ftrap = 0; mread(fd, levl, sizeof(levl)); mread(fd, &omoves, sizeof(omoves)); mread(fd, &xupstair, sizeof(xupstair)); mread(fd, &yupstair, sizeof(yupstair)); mread(fd, &xdnstair, sizeof(xdnstair)); mread(fd, &ydnstair, sizeof(ydnstair)); fmon = restmonchn(fd); /* regenerate animals while on another level */ { long tmoves = (moves > omoves) ? moves - omoves : 0; struct monst *mtmp, *mtmp2; for (mtmp = fmon; mtmp; mtmp = mtmp2) { long newhp; /* tmoves may be very large */ mtmp2 = mtmp->nmon; if (strchr(genocided, mtmp->data->mlet)) { mondead(mtmp); continue; } if (mtmp->mtame && tmoves > 250) { mtmp->mtame = 0; mtmp->mpeaceful = 0; } newhp = mtmp->mhp + (strchr(MREGEN, mtmp->data->mlet) ? tmoves : tmoves / 20); if (newhp > mtmp->mhpmax) mtmp->mhp = mtmp->mhpmax; else mtmp->mhp = newhp; } } setgd(); gold = newgold(); mread(fd, gold, sizeof(struct gold)); while (gold->gx) { gold->ngold = fgold; fgold = gold; gold = newgold(); mread(fd, gold, sizeof(struct gold)); } free(gold); trap = newtrap(); mread(fd, trap, sizeof(struct trap)); while (trap->tx) { trap->ntrap = ftrap; ftrap = trap; trap = newtrap(); mread(fd, trap, sizeof(struct trap)); } free(trap); fobj = restobjchn(fd); billobjs = restobjchn(fd); rest_engravings(fd); #ifndef QUEST mread(fd, rooms, sizeof(rooms)); mread(fd, doors, sizeof(doors)); #endif /* QUEST */ #ifndef NOWORM mread(fd, wsegs, sizeof(wsegs)); for (tmp = 1; tmp < 32; tmp++) if (wsegs[tmp]) { wheads[tmp] = wsegs[tmp] = wtmp = newseg(); while (1) { mread(fd, wtmp, sizeof(struct wseg)); if (!wtmp->nseg) break; wheads[tmp]->nseg = wtmp = newseg(); wheads[tmp] = wtmp; } } mread(fd, wgrowtime, sizeof(wgrowtime)); #endif /* NOWORM */ }