AFFEND static void hashtable_expand(arc *c, value hash) { unsigned int hv, index, i, j, nhashbits; value oldtbl, newtbl, e; nhashbits = HASH_BITS(hash) + 1; newtbl = arc_mkvector(c, HASHSIZE(nhashbits)); ((struct cell *)newtbl)->_type = T_TABLEVEC; for (i=0; i<HASHSIZE(nhashbits); i++) XVINDEX(newtbl, i) = CUNBOUND; oldtbl = HASH_TABLE(hash); /* Search for active keys and move them into the new table */ for (i=0; i<VECLEN(oldtbl); i++) { e = VINDEX(oldtbl, i); if (EMPTYP(e)) continue; /* remove the old link now that we have a copy */ SVINDEX(oldtbl, i, CUNBOUND); /* insert the old key into the new table */ hv = (unsigned int)FIX2INT(BHASHVAL(e)); index = hv & HASHMASK(nhashbits); for (j=0; !EMPTYP(VINDEX(newtbl, index)); j++) index = (index + PROBE(j)) & HASHMASK(nhashbits); BTABLE(e) = newtbl; XVINDEX(newtbl, index) = e; SBINDEX(e, index); /* change index */ SVINDEX(oldtbl, i, CUNBOUND); } SET_HASHBITS(hash, nhashbits); SET_LLIMIT(hash, (HASHSIZE(nhashbits)*MAX_LOAD_FACTOR) / 100); HASH_TABLE(hash) = newtbl; }
static void tablevec_sweeper(arc *c, value v) { int i; /* Clear the BTABLE links for any active buckets within this tablevec before fully sweeping it away. */ for (i=0; i<VECLEN(v); i++) { if (EMPTYP(VINDEX(v, i))) continue; BTABLE(VINDEX(v, i)) = CNIL; } }
int arc_hash_length(arc *c, value hash) { int count, i; value e, tbl; count = 0; tbl = HASH_TABLE(hash); for (i=0; i<VECLEN(tbl); i++) { e = VINDEX(tbl, i); if (EMPTYP(e)) continue; count++; } return(count); }
void tank_drawHUD(entity_t *pt, warf_t *wf, wardraw_t *wd, const double irot[16], void (*gdraw)(void)){ tank2_t *p = (tank2_t*)pt; base_drawHUD_target(pt, wf, wd, gdraw); base_drawHUD_map(pt, wf, wd, irot, gdraw); base_drawHUD(pt, wf, wd, gdraw); if(wf->pl->control != pt){ } else{ GLint vp[4]; int w, h, m; double left, bottom; /* int tkills, tdeaths, ekills, edeaths;*/ /* entity_t *pt2;*/ double v; glGetIntegerv(GL_VIEWPORT, vp); w = vp[2], h = vp[3]; m = w < h ? h : w; left = -(double)w / m; bottom = -(double)h / m; v = VECLEN(pt->velo); glPushMatrix(); glLoadIdentity(); glRasterPos3d(left + 20. / m, bottom + 60. / m, -1); gldprintf("%lg m/s", v * 1e3); glRasterPos3d(left + 20. / m, bottom + 80. / m, -1); gldprintf("%lg km/h", v * 1e3 * 3600. / 1000.); glRasterPos3d(-left - 500. / m, bottom + 60. / m, -1); gldprintf("%c 120mm Main Gun x %d", pt->weapon == 0 ? '>' : ' ', p->ammo[0]); glRasterPos3d(-left - 500. / m, bottom + 40. / m, -1); gldprintf("%c 7.62mm Type 74 x %d", pt->weapon == 1 ? '>' : ' ', p->ammo[1]); glRasterPos3d(-left - 500. / m, bottom + 20. / m, -1); gldprintf("%c 12.7mm M2 Browning x %d", pt->weapon == 2 ? '>' : ' ', p->ammo[2]); glRasterPos3d(-left - 500. / m, bottom + 0. / m, -1); gldprintf("%c 120mm Shotgun x %d", pt->weapon == 3 ? '>' : ' ', p->ammo[0]); glPopMatrix(); } }
static AFFDEF(hash_isocmp) { AARG(v1, v2, vh1, vh2); AVAR(iso2, tbl, e, v2val, i); value vhh1, vhh2; /* not required after calls */ AFBEGIN; if ((vhh1 = __arc_visit(c, AV(v1), AV(vh1))) != CNIL) { /* If we find a visited object, see if v2 is also visited in vh2. If not, they are not the same. */ vhh2 = __arc_visit(c, AV(v2), AV(vh2)); /* We see if the same value was produced on visiting. */ ARETURN((vhh2 == vhh1) ? CTRUE : CNIL); } /* Get value assigned by __arc_visit to v1. */ vhh1 = __arc_visit(c, AV(v1), AV(vh1)); /* If we somehow already visited v2 when v1 was not visited in the same way, they cannot be the same. */ if (__arc_visit2(c, AV(v2), AV(vh2), vhh1) != CNIL) ARETURN(CNIL); /* Two hash tables must have identical numbers of entries to be isomorphic */ if (HASH_NENTRIES(AV(v1)) != HASH_NENTRIES(AV(v2))) ARETURN(CNIL); WV(tbl, HASH_TABLE(AV(v1))); WV(iso2, arc_mkaff(c, arc_iso2, CNIL)); for (WV(i, INT2FIX(0)); FIX2INT(AV(i))<VECLEN(AV(tbl)); WV(i, INT2FIX(FIX2INT(AV(i)) + 1))) { WV(e, VINDEX(AV(tbl), FIX2INT(AV(i)))); if (EMPTYP(AV(e))) continue; WV(v2val, arc_hash_lookup(c, AV(v2), BKEY(AV(e)))); AFCALL(AV(iso2), BVALUE(AV(e)), AV(v2val), AV(vh1), AV(vh2)); if (NIL_P(AFCRV)) ARETURN(CNIL); } ARETURN(CTRUE); AFEND; }