void init_weapon(struct object *weap, int type) { struct init_weps *iwp; iwp = &init_dam[type]; strcpy(weap->o_damage,iwp->iw_dam); strcpy(weap->o_hurldmg,iwp->iw_hrl); weap->o_launch = iwp->iw_launch; weap->o_flags = iwp->iw_flags; if (weap->o_flags & ISMANY) { weap->o_count = rnd(8) + 8; weap->o_group = newgrp(); } else weap->o_count = 1; }
/* * init_weapon: * Set up the initial goodies for a weapon */ void init_weapon(struct object *weap, int type) { register struct init_weps *iwp ; iwp = &weaps[type] ; strcpy(weap->o_damage,iwp->w_dam); strcpy(weap->o_hurldmg,iwp->w_hrl) ; weap->o_launch = iwp->w_launch ; weap->o_flags = iwp->w_flags ; weap->o_weight = iwp->w_wght; if (weap->o_flags & ISMANY) { weap->o_count = rnd(8) + 8 ; weap->o_group = newgrp() ; } else { weap->o_count = 1 ; } }
Prog* newprog(Prog *p, Modlink *m) { Heap *h; Prog *n, **ph; Osenv *on, *op; static int pidnum; if(p != nil){ if(p->group != nil) p->flags |= p->group->flags & Pkilled; if(p->kill != nil) error(p->kill); if(p->flags & Pkilled) error(""); } n = malloc(sizeof(Prog)+sizeof(Osenv)); if(n == 0){ if(p == nil) panic("no memory"); else error(exNomem); } n->pid = ++pidnum; if(n->pid <= 0) panic("no pids"); n->group = nil; if(isched.tail != nil) { n->prev = isched.tail; isched.tail->next = n; } else { isched.head = n; n->prev = nil; } isched.tail = n; ph = pidlook(n->pid); if(*ph != nil) panic("dup pid"); n->pidlink = nil; *ph = n; n->osenv = (Osenv*)((uchar*)n + sizeof(Prog)); n->xec = xec; n->quanta = PQUANTA; n->flags = 0; n->exval = H; h = D2H(m); h->ref++; Setmark(h); n->R.M = m; n->R.MP = m->MP; if(m->MP != H) Setmark(D2H(m->MP)); addrun(n); if(p == nil){ newgrp(n); return n; } addgrp(n, p); n->flags = p->flags; if(p->flags & Prestrict) n->flags |= Prestricted; memmove(n->osenv, p->osenv, sizeof(Osenv)); op = p->osenv; on = n->osenv; on->waitq = op->childq; on->childq = nil; on->debug = nil; incref(on->pgrp); incref(on->fgrp); if(on->egrp != nil) incref(on->egrp); if(on->sigs != nil) incref(on->sigs); on->user = nil; kstrdup(&on->user, op->user); on->errstr = on->errbuf0; on->syserrstr = on->errbuf1; return n; }