int isneighbor(dbref d1, dbref d2) { if (d1 == d2) return 1; if (Typeof(d1) != TYPE_ROOM) if (getloc(d1) == d2) return 1; if (Typeof(d2) != TYPE_ROOM) if (getloc(d2) == d1) return 1; if (Typeof(d1) != TYPE_ROOM && Typeof(d2) != TYPE_ROOM) if (getloc(d1) == getloc(d2)) return 1; return 0; }
int mesg_proximity_perms(dbref player, dbref perms, dbref obj) { if (obj == player) return 1; if (isneighbor(player, obj)) return 1; if (isneighbor(perms, obj)) return 1; if ((getloc(obj) != NOTHING) && may_read_nowizperm(OWNER(perms), getloc(obj))) return 1; if (mesg_read_perms(player, perms, obj)) return 1; return 0; }
int mesg_local_perms(dbref player, dbref perms, dbref obj, int mesgtyp) { if (getloc(obj) != NOTHING && OWNER(perms) == OWNER(getloc(obj))) return 1; if (isneighbor(perms, obj)) return 1; if (isneighbor(player, obj)) return 1; if (mesg_read_perms(player, perms, obj, mesgtyp)) return 1; return 0; }
bool can_doit(int descr, dbref player, dbref thing, const char *default_fail_msg) { dbref loc; if ((loc = getloc(player)) == NOTHING) return 0; if (OkObj(thing)) { dbref dest = Typeof(thing) == TYPE_EXIT ? (DBFETCH(thing)->sp.exit.ndest ? DBFETCH(thing)->sp.exit.dest[0] : NOTHING) : NOTHING; if (((FLAG2(player) & F2IMMOBILE) && !(FLAG2(thing) & F2IMMOBILE)) && (!OkObj(dest) || Typeof(dest) != TYPE_PROGRAM) ) { envpropqueue(descr, player, OkObj(player) ? getloc(player) : -1, thing, thing, NOTHING, "@immobile", "Immobile", 1, 1); return 0; } } if (!TMage(OWNER(player)) && Typeof(player) == TYPE_THING && (FLAGS(thing) & ZOMBIE)) { notify(player, "Sorry, but zombies can't do that."); return 0; } if (!could_doit(descr, player, thing)) { /* can't do it */ if (GETFAIL(thing)) { exec_or_notify(descr, player, thing, GETFAIL(thing), "(@Fail)"); } else if (default_fail_msg) { notify(player, default_fail_msg); } if (GETOFAIL(thing) && !Dark(player)) { parse_omessage(descr, player, loc, thing, GETOFAIL(thing), PNAME(player), "(@Ofail)"); } return 0; } else { /* can do it */ /* I moved these to the 'trigger()' function. -Akari */ /* if (GETSUCC(thing)) { exec_or_notify(descr, player, thing, GETSUCC(thing), "(@Succ)"); } if (GETOSUCC(thing) && !Dark(player)) { parse_omessage(descr, player, loc, thing, GETOSUCC(thing), NAME(player), "(@Osucc)"); } */ return 1; } }
const char * mfn_holds(MFUNARGS) { dbref obj1 = mesg_dbref_raw(descr, player, what, perms, argv[0]); dbref obj2 = player; if (argc > 1) obj2 = mesg_dbref_local(descr, player, what, perms, argv[1], mesgtyp); if (obj1 == UNKNOWN || obj1 == AMBIGUOUS || obj1 == NOTHING || obj1 == HOME) ABORT_MPI("HOLDS", "Match failed (1)."); if (obj1 == PERMDENIED) ABORT_MPI("HOLDS", "Permission Denied (1)."); if (obj2 == UNKNOWN || obj2 == AMBIGUOUS || obj2 == NOTHING || obj2 == HOME) ABORT_MPI("HOLDS", "Match failed (2)."); if (obj2 == PERMDENIED) ABORT_MPI("HOLDS", "Permission Denied (2)."); if (obj2 == getloc(obj1)) { return "1"; } else { return "0"; } }
const char * mfn_otell(MFUNARGS) { char buf2[BUFFER_LEN]; char *ptr, *ptr2; dbref obj = getloc(player); dbref eobj = player; dbref thing; if (argc > 1) obj = mesg_dbref_local(descr, player, what, perms, argv[1], mesgtyp); if (obj == UNKNOWN || obj == AMBIGUOUS || obj == NOTHING || obj == HOME) ABORT_MPI("OTELL", "Match failed."); if (obj == PERMDENIED) ABORT_MPI("OTELL", "Permission denied."); if ((mesgtyp & MPI_ISLISTENER) && (Typeof(what) != TYPE_ROOM)) ABORT_MPI("OTELL", "Permission denied."); if (argc > 2) eobj = mesg_dbref_raw(descr, player, what, perms, argv[2]); strcpyn(buf2, sizeof(buf2), argv[0]); for (ptr = buf2; *ptr; ptr = ptr2) { ptr2 = index(ptr, '\r'); if (ptr2) { *ptr2 = '\0'; } else { ptr2 = ptr + strlen(ptr); } if (((OWNER(what) == OWNER(obj) || isancestor(what, obj)) && (Typeof(what) == TYPE_ROOM || (Typeof(what) == TYPE_EXIT && Typeof(getloc(what)) == TYPE_ROOM))) || string_prefix(argv[0], NAME(player))) { strcpyn(buf, buflen, ptr); } else { snprintf(buf, BUFFER_LEN, "%.16s%s%.4078s", NAME(player), ((*argv[0] == '\'' || isspace(*argv[0])) ? "" : " "), ptr); } thing = DBFETCH(obj)->contents; while (thing != NOTHING) { if (thing != eobj) { notify_from_echo(player, thing, buf, 0); } thing = DBFETCH(thing)->next; } } return argv[0]; }
const char * mfn_force(MFUNARGS) { char *nxt, *ptr; dbref obj = mesg_dbref_raw(player, what, perms, argv[0]); if (obj == AMBIGUOUS || obj == UNKNOWN || obj == NOTHING || obj == HOME) ABORT_MPI("FORCE","Failed match. (arg1)"); if (obj == PERMDENIED) ABORT_MPI("FORCE","Permission denied. (arg1)"); if (Typeof(obj) != TYPE_THING && Typeof(obj) != TYPE_PLAYER) ABORT_MPI("FORCE","Bad object reference. (arg1)"); if (!*argv[1]) ABORT_MPI("FORCE","Null command string. (arg2)"); if (!tp_zombies && !Wizperms(perms)) ABORT_MPI("FORCE","Permission Denied."); if (!Wizperms(perms)) { const char *ptr = RNAME(obj); char objname[BUFFER_LEN], *ptr2; dbref loc = getloc(obj); if (Typeof(obj) == TYPE_THING) { if (FLAGS(obj) & DARK) ABORT_MPI("FORCE","Cannot force a dark puppet."); if ((FLAGS(OWNER(obj)) & ZOMBIE)) ABORT_MPI("FORCE","Permission denied."); if (loc != NOTHING && (FLAGS(loc) & ZOMBIE) && Typeof(loc) == TYPE_ROOM) ABORT_MPI("FORCE","Cannot force a Puppet in a no-puppets room."); for (ptr2 = objname; *ptr && !isspace(*ptr);) *(ptr2++) = *(ptr++); *ptr2 = '\0'; if (lookup_player(objname) != NOTHING) ABORT_MPI("FORCE","Cannot force a thing named after a player."); } if (!(FLAGS(obj) & XFORCIBLE)) { ABORT_MPI("FORCE","Permission denied: forced object not @set Xforcible."); } if (!test_lock_false_default(perms, obj, "@/flk")) { ABORT_MPI("FORCE","Permission denied: Object not force-locked to trigger."); } } if (God(obj)) ABORT_MPI("FORCE","Permission denied: You can't force God."); if (force_level) ABORT_MPI("FORCE","Permission denied: You can't force recursively."); strcpy(buf, argv[1]); ptr = buf; do { nxt = index(ptr, '\r'); if (nxt) *nxt++ = '\0'; force_level++; if (*ptr) process_command(obj, ptr); force_level--; ptr = nxt; } while (ptr); *buf = '\0'; return ""; }
int mesg_local_perms(dbref player, dbref perms, dbref obj) { if (OWNER(perms) == OWNER(getloc(obj))) return 1; if (isneighbor(perms, obj)) return 1; if (isneighbor(player, obj)) return 1; if (Mageperms(perms)) return 1; if (mesg_read_perms(player, perms, obj)) return 1; return 0; }
/* central output function * - print characters in uppercase mode */ virtual int_type overflow (int_type c) { if (c != EOF) { // convert lowercase to uppercase c = std::toupper(c,getloc()); // and write the character to the standard output if (putchar(c) == EOF) { return EOF; } } return c; }
const char * mfn_contents(MFUNARGS) { char buf2[50]; int list_limit = MAX_MFUN_LIST_LEN; dbref obj = mesg_dbref_local(player, what, perms, argv[0]); int typchk, ownroom; int outlen, nextlen; if (obj == AMBIGUOUS || obj == UNKNOWN || obj == NOTHING || obj == HOME) ABORT_MPI("CONTENTS","Match failed"); if (obj == PERMDENIED) ABORT_MPI("CONTENTS",NOPERM_MESG); typchk = NOTYPE; if (argc > 1) { if (!string_compare(argv[1], "Room")) { typchk = TYPE_ROOM; } else if (!string_compare(argv[1], "Exit")) { typchk = TYPE_EXIT; /* won't find any, though */ } else if (!string_compare(argv[1], "Player")) { typchk = TYPE_PLAYER; } else if (!string_compare(argv[1], "Program")) { typchk = TYPE_PROGRAM; } else if (!string_compare(argv[1], "Thing")) { typchk = TYPE_THING; } else { ABORT_MPI("CONTENTS","Type must be 'player', 'room', 'thing', 'program', or 'exit'. (2)"); } } strcpy(buf, ""); outlen = 0; ownroom = controls(perms, obj); obj = DBFETCH(obj)->contents; while (obj != NOTHING && list_limit) { if ((typchk == NOTYPE || Typeof(obj) == typchk) && (ownroom || controls(perms, obj) || !((FLAGS(obj) & DARK) || (FLAGS(getloc(obj)) & DARK) || (Typeof(obj) == TYPE_PROGRAM && !(FLAGS(obj) & LINK_OK)))) && !(Typeof(obj) == TYPE_ROOM && typchk != TYPE_ROOM)) { ref2str(obj, buf2); nextlen = strlen(buf2); if ((outlen + nextlen) >= (BUFFER_LEN - 3)) break; if (outlen) strcat((buf+(outlen++)), "\r"); strcat((buf + outlen), buf2); outlen += nextlen; list_limit--; } obj = DBFETCH(obj)->next; } return buf; }
const char * mfn_loc(MFUNARGS) { dbref obj; obj = mesg_dbref_local(descr, player, what, perms, argv[0], mesgtyp); if (obj == UNKNOWN || obj == AMBIGUOUS || obj == NOTHING || obj == HOME) ABORT_MPI("LOC", "Match failed."); if (obj == PERMDENIED) ABORT_MPI("LOC", "Permission denied."); return ref2str(getloc(obj), buf, BUFFER_LEN); }
void do_pose(int descr, dbref player, const char *message) { dbref loc; char buf[BUFFER_LEN], buf2[BUFFER_LEN]; if ((loc = getloc(player)) == NOTHING) return; tct(message, buf2); /* notify everybody */ sprintf(buf, "^SAY/POSE^%s %s", PNAME(player), buf2); anotify_except(DBFETCH(loc)->contents, NOTHING, buf, player); }
void notify_listeners(dbref who, dbref xprog, dbref obj, dbref room, const char *msg, int isprivate) { char buf[BUFFER_LEN]; dbref ref; if (obj == NOTHING) return; if (tp_listeners && (tp_listeners_obj || Typeof(obj) == TYPE_ROOM)) { listenqueue(-1, who, room, obj, obj, xprog, "_listen", msg, tp_listen_mlev, 1, 0); listenqueue(-1, who, room, obj, obj, xprog, "~listen", msg, tp_listen_mlev, 1, 1); listenqueue(-1, who, room, obj, obj, xprog, "~olisten", msg, tp_listen_mlev, 0, 1); } if (tp_zombies && Typeof(obj) == TYPE_THING && !isprivate) { if (FLAGS(obj) & VEHICLE) { if (getloc(who) == getloc(obj)) { char pbuf[BUFFER_LEN]; const char *prefix; memset(buf,0,BUFFER_LEN); /* Make sure the buffer is zeroed */ prefix = do_parse_prop(-1, who, obj, MESGPROP_OECHO, "(@Oecho)", pbuf, sizeof(pbuf), MPI_ISPRIVATE); if (!prefix || !*prefix) prefix = "Outside>"; snprintf(buf, sizeof(buf), "%s %.*s", prefix, (int)(BUFFER_LEN - 2 - strlen(prefix)), msg); ref = DBFETCH(obj)->contents; while (ref != NOTHING) { notify_filtered(who, ref, buf, isprivate); ref = DBFETCH(ref)->next; } } } } if (Typeof(obj) == TYPE_PLAYER || Typeof(obj) == TYPE_THING) notify_filtered(who, obj, msg, isprivate); }
void do_pose(dbref player, const char *message) { dbref loc; char buf[BUFFER_LEN]; if ((loc = getloc(player)) == NOTHING) return; /* notify everybody */ snprintf(buf, sizeof(buf), "%s %s", NAME(player), message); notify_except(DBFETCH(loc)->contents, NOTHING, buf, player); }
int main() { pair_t p[2], r; double course, speed, tm[2], a[2], d; int i, m, t; pi = 2. * acos(0.); for (t = 1; scanf("%d", &nbeacons) == 1;) { for (i = 0; i < nbeacons; i++) scanf(" %s %lf %lf", beacon[i].name, &beacon[i].loc.x, &beacon[i].loc.y); for (scanf("%d", &m); m-- > 0; t++) { scanf("%lf %lf %lf", &course, &speed, &tm[0]); p[0] = getloc(); scanf("%lf %lf", &a[0], &tm[1]); p[1] = getloc(); scanf("%lf", &a[1]); a[0] = (90. - course - a[0]) * pi / 180.; a[1] = (90. - course - a[1]) * pi / 180.; course = (90. - course) * pi / 180.; d = fabs(tm[1] - tm[0]) * speed; printf("Scenario %d: ", t); if (sol(&r, course, d, a, p)) printf("Position is (%.2f, %.2f)\n", r.x, r.y); else printf("Position cannot be determined\n"); } } return 0; }
const char * mfn_delay(MFUNARGS) { char *argchr, *cmdchr; int i = atoi(argv[0]); if (i < 1) i = 1; #ifdef WIZZED_DELAY if (!Mageperms(perms)) ABORT_MPI("delay",NOPERM_MESG); #endif cmdchr = get_mvar("cmd"); argchr = get_mvar("arg"); i = add_mpi_event(i, player, getloc(player), perms, argv[1], cmdchr, argchr, (mesgtyp & MPI_ISLISTENER), (!(mesgtyp & MPI_ISPRIVATE))); sprintf(buf, "%d", i); return buf; }
void do_pose(dbref player, const char *message) { dbref loc; char buf[BUFFER_LEN], buf2[BUFFER_LEN]; if ((loc = getloc(player)) == NOTHING) return; do_parse_mesg(player, player, message, "(pose)", buf, MPI_ISPRIVATE); tct(buf,buf2); /* notify everybody */ sprintf(buf, CAQUA "%s%s%.3900s", PNAME(player), isalpha(buf2[0]) ? " " : "", buf2); anotify_except(DBFETCH(loc)->contents, NOTHING, buf, player); }
void basic_format<Ch, Tr, Alloc>:: make_or_reuse_data (std::size_t nbitems) { #if !defined(BOOST_NO_STD_LOCALE) Ch fill = ( BOOST_USE_FACET(std::ctype<Ch>, getloc()) ). widen(' '); #else Ch fill = ' '; #endif if(items_.size() == 0) items_.assign( nbitems, format_item_t(fill) ); else { if(nbitems>items_.size()) items_.resize(nbitems, format_item_t(fill)); bound_.resize(0); for(std::size_t i=0; i < nbitems; ++i) items_[i].reset(fill); // strings are resized, instead of reallocated } }
void bar_pop(Widget iw_t, XEvent *event, String *params, Cardinal *num_params) { int ix1, iy1, ix2, iy2; /* Get mouse position ix1,iy1 */ getloc(event,'M',&ix1,&iy1); ix2 = ix1 + idx; iy2 = iy1 + idy; /* Bar length */ if (!(strcmp(*params,"M"))) /* Cursor moved */ { /* Copy backing store to image window & draw new bar on screen */ wirubberline(iwin,icontx,TRUE,FALSE,ix1,iy1,ix2,iy2); } else if (!(strcmp(*params,"1"))) /* Button 1 pushed */ { /* Draw permanent bar to backing store and copy to screen */ wirubberline(iwin,icontx,TRUE,TRUE,ix1,iy1,ix2,iy2); } else if (!(strcmp(*params,"2"))) /* Button 2 pushed */ { /* Erase current bar from screen */ wirubberline(iwin,icontx,FALSE,FALSE,ix1,iy1,ix2,iy2); /* Put up menu */ barmen(NULL, NULL, NULL); } else if (!(strcmp(*params,"3"))) /* Button 3 pushed */ { /* Erase current bar from screen */ wirubberline(iwin,icontx,FALSE,FALSE,ix1,iy1,ix2,iy2); /* Uninstall translations */ XtUninstallTranslations(iw_t); /* Unmanage information box */ showbutx("","","",TRUE); XtUnmanageChild(iw_barmen); } }
void do_say(int descr, dbref player, const char *message) { dbref loc; char buf[BUFFER_LEN], buf2[BUFFER_LEN]; if ((loc = getloc(player)) == NOTHING) return; tct(message, buf2); /* notify everybody */ sprintf(buf, "^SAY/POSE^You say, ^SAY/QUOTES^\"^SAY/TEXT^%s^SAY/QUOTES^\"", buf2); anotify(player, buf); sprintf(buf, "^SAY/POSE^%s says, ^SAY/QUOTES^\"^SAY/TEXT^%s^SAY/QUOTES^\"", PNAME(player), buf2); anotify_except(DBFETCH(loc)->contents, player, buf, player); }
void do_say(dbref player, const char *message) { dbref loc; char buf[BUFFER_LEN], buf2[BUFFER_LEN]; if ((loc = getloc(player)) == NOTHING) return; do_parse_mesg(player, player, message, "(say)", buf, MPI_ISPRIVATE); tct(buf,buf2); /* Notify player */ sprintf(buf, CAQUA "You say, \"" CYELLOW "%.3900s" CAQUA "\"", buf2); anotify(player, buf); /* notify everybody else */ sprintf(buf, CAQUA "%s says, \"" CYELLOW "%.3900s" CAQUA "\"", PNAME(player), buf2); anotify_except(DBFETCH(loc)->contents, player, buf, player); }
dbref mesg_dbref_raw(int descr, dbref player, dbref what, dbref perms, const char *buf) { struct match_data md; dbref obj = UNKNOWN; if (buf && *buf) { if (!string_compare(buf, "this")) { obj = what; } else if (!string_compare(buf, "me")) { obj = player; } else if (!string_compare(buf, "here")) { obj = getloc(player); } else if (!string_compare(buf, "home")) { obj = HOME; } else { init_match(descr, player, buf, NOTYPE, &md); match_absolute(&md); match_all_exits(&md); match_neighbor(&md); match_possession(&md); match_registered(&md); obj = match_result(&md); if (obj == NOTHING) { init_match_remote(descr, player, what, buf, NOTYPE, &md); match_player(&md); match_all_exits(&md); match_neighbor(&md); match_possession(&md); match_registered(&md); obj = match_result(&md); } } } if (obj < 0 || obj >= db_top || Typeof(obj) == TYPE_GARBAGE) obj = UNKNOWN; return obj; }
const char * mfn_tell(MFUNARGS) { char buf2[BUFFER_LEN]; char *ptr, *ptr2; dbref obj = player; if (argc > 1) obj = mesg_dbref_local(descr, player, what, perms, argv[1], mesgtyp); if (obj == UNKNOWN || obj == AMBIGUOUS || obj == NOTHING || obj == HOME) ABORT_MPI("TELL", "Match failed."); if (obj == PERMDENIED) ABORT_MPI("TELL", "Permission denied."); if ((mesgtyp & MPI_ISLISTENER) && (Typeof(what) != TYPE_ROOM)) ABORT_MPI("TELL", "Permission denied."); *buf = '\0'; strcpyn(buf2, sizeof(buf2), argv[0]); for (ptr = buf2; (ptr != NULL) && *ptr != '\0'; ptr = ptr2) { ptr2 = index(ptr, '\r'); if (ptr2 != NULL) { *ptr2++ = '\0'; } else { ptr2 = ptr + strlen(ptr); } if (Typeof(what) == TYPE_ROOM || OWNER(what) == obj || player == obj || (Typeof(what) == TYPE_EXIT && Typeof(getloc(what)) == TYPE_ROOM) || string_prefix(argv[0], NAME(player))) { snprintf(buf, BUFFER_LEN, "%s%.4093s", ((obj == OWNER(perms) || obj == player) ? "" : "> "), ptr); } else { snprintf(buf, BUFFER_LEN, "%s%.16s%s%.4078s", ((obj == OWNER(perms) || obj == player) ? "" : "> "), NAME(player), ((*argv[0] == '\'' || isspace(*argv[0])) ? "" : " "), ptr); } notify_from_echo(player, obj, buf, 1); } return argv[0]; }
int can_doit(int descr, dbref player, dbref thing, const char *default_fail_msg) { dbref loc; if ((loc = getloc(player)) == NOTHING) return 0; if (!Wizard(OWNER(player)) && Typeof(player) == TYPE_THING && (FLAGS(thing) & ZOMBIE)) { notify(player, "Sorry, but zombies can't do that."); return 0; } if (!could_doit(descr, player, thing)) { /* can't do it */ if (GETFAIL(thing)) { exec_or_notify_prop(descr, player, thing, MESGPROP_FAIL, "(@Fail)"); } else if (default_fail_msg) { notify(player, default_fail_msg); } if (GETOFAIL(thing) && !Dark(player)) { parse_oprop(descr, player, loc, thing, MESGPROP_OFAIL, NAME(player), "(@Ofail)"); } return 0; } else { /* can do it */ if (GETSUCC(thing)) { exec_or_notify_prop(descr, player, thing, MESGPROP_SUCC, "(@Succ)"); } if (GETOSUCC(thing) && !Dark(player)) { parse_oprop(descr, player, loc, thing, MESGPROP_OSUCC, NAME(player), "(@Osucc)"); } return 1; } }
void shader::set3f(const char * name, const vec3 & vector) { glUniform3f(getloc(name), vector.x, vector.y, vector.z); }
/* * hash_value - hash a value * * given: * type - hash type (see hash.h) * v - the value * state - the state to hash or NULL * * returns: * the new state */ HASH * hash_value(int type, void *v, HASH *state) { LISTELEM *ep; /* list element pointer */ ASSOCELEM **assochead; /* association chain head */ ASSOCELEM *aep; /* current association value */ ASSOCELEM *nextaep; /* next association value */ VALUE *value = (VALUE *)v; /* v cast to a VALUE */ VALUE *vp; /* pointer to next OBJ table value */ ZVALUE fileval; /* size, position, dev, inode of a file */ int i; /* * initialize if state is NULL */ if (state == NULL) { state = hash_init(type, NULL); } /* * process the value type */ switch (value->v_type) { case V_NULL: (state->chkpt)(state); state->bytes = TRUE; break; case V_INT: /* setup for the this value type */ (state->chkpt)(state); (state->type)(value->v_type, state); /* hash as if we have a 64 bit value */ state = hash_int(type, value->v_int, state); break; case V_NUM: /* hash this type */ state = hash_number(type, value->v_num, state); break; case V_COM: /* setup for the this value type */ (state->chkpt)(state); (state->type)(value->v_type, state); /* hash this type */ state = hash_complex(type, value->v_com, state); break; case V_ADDR: /* there is nothing to setup, simply hash what we point at */ state = hash_value(type, value->v_addr, state); break; case V_STR: /* strings have no setup */ /* hash this type */ state = hash_STR(type, value->v_str, state); break; case V_MAT: /* setup for the this value type */ (state->chkpt)(state); (state->type)(value->v_type, state); state->bytes = TRUE; /* hash all the elements of the matrix */ for (i=0; i < value->v_mat->m_size; ++i) { /* hash the next matrix value */ state = hash_value(type, value->v_mat->m_table+i, state); state->bytes = FALSE; /* as if reading words */ } break; case V_LIST: /* setup for the this value type */ (state->chkpt)(state); (state->type)(value->v_type, state); /* hash all the elements of the list */ for (i=0, ep = value->v_list->l_first; ep != NULL && i < value->v_list->l_count; ++i, ep = ep->e_next) { /* hash the next list value */ state = hash_value(type, &ep->e_value, state); state->bytes = FALSE; /* as if reading words */ } break; case V_ASSOC: /* setup for the this value type */ (state->chkpt)(state); (state->type)(value->v_type, state); state->bytes = TRUE; /* hash the association */ assochead = value->v_assoc->a_table; for (i = 0; i < value->v_assoc->a_size; i++) { nextaep = *assochead; while (nextaep) { aep = nextaep; nextaep = aep->e_next; /* hash the next association value */ state = hash_value(type, &aep->e_value, state); state->bytes = FALSE; /* as if reading words */ } assochead++; } break; case V_OBJ: /* setup for the this value type */ (state->chkpt)(state); (state->type)(value->v_type, state); state->bytes = TRUE; /* reading bytes */ /* hash the object name and then the element values */ state = hash_str(type, objtypename( value->v_obj->o_actions->oa_index), state); (state->chkpt)(state); for (i=value->v_obj->o_actions->oa_count, vp=value->v_obj->o_table; i-- > 0; vp++) { /* hash the next object value */ state = hash_value(type, vp, state); state->bytes = FALSE; /* as if reading words */ } break; case V_FILE: /* setup for the this value type */ (state->chkpt)(state); (state->type)(value->v_type, state); /* hash file length if possible */ if (getsize(value->v_file, &fileval) == 0) { state = hash_zvalue(type, fileval, state); zfree(fileval); } else { /* hash -1 for invalid length */ state = hash_long(type, (long)-1, state); } /* hash the file position if possible */ if (getloc(value->v_file, &fileval) == 0) { state = hash_zvalue(type, fileval, state); zfree(fileval); } else { /* hash -1 for invalid location */ state = hash_long(type, (long)-1, state); } /* hash the file device if possible */ if (get_device(value->v_file, &fileval) == 0) { state = hash_zvalue(type, fileval, state); zfree(fileval); } else { /* hash -1 for invalid device */ state = hash_long(type, (long)-1, state); } /* hash the file inode if possible */ if (get_inode(value->v_file, &fileval) == 0) { state = hash_zvalue(type, fileval, state); zfree(fileval); } else { /* hash -1 for invalid inode */ state = hash_long(type, (long)-1, state); } break; case V_RAND: /* setup for the this value type */ (state->chkpt)(state); (state->type)(value->v_type, state); /* hash the RAND state */ state = hash_int(type, value->v_rand->seeded, state); state = hash_int(type, value->v_rand->bits, state); (state->update)(state, (USB8 *)value->v_rand->buffer, SLEN*FULL_BITS/8); state = hash_int(type, value->v_rand->j, state); state = hash_int(type, value->v_rand->k, state); state = hash_int(type, value->v_rand->need_to_skip, state); (state->update)(state, (USB8 *)value->v_rand->slot, SCNT*FULL_BITS/8); (state->update)(state, (USB8*)value->v_rand->shuf, SHUFLEN*FULL_BITS/8); state->bytes = FALSE; /* as if reading words */ break; case V_RANDOM: /* setup for the this value type */ (state->chkpt)(state); (state->type)(value->v_type, state); /* hash the RANDOM state */ state = hash_int(type, value->v_random->seeded, state); state = hash_int(type, value->v_random->bits, state); (state->update)(state, (USB8 *)&(value->v_random->buffer), BASEB/8); state = hash_zvalue(type, value->v_random->r, state); state = hash_zvalue(type, value->v_random->n, state); state->bytes = FALSE; /* as if reading words */ break; case V_CONFIG: /* setup for the this value type */ (state->chkpt)(state); (state->type)(value->v_type, state); /* hash the CONFIG state */ state = hash_int(type, value->v_config->outmode, state); state = hash_int(type, value->v_config->outmode2, state); state = hash_long(type,(long)value->v_config->outdigits, state); state = hash_number(type, value->v_config->epsilon, state); state = hash_long(type, (long)value->v_config->epsilonprec, state); state = hash_flag(type, value->v_config->traceflags, state); state = hash_long(type, (long)value->v_config->maxprint, state); state = hash_len(type, value->v_config->mul2, state); state = hash_len(type, value->v_config->sq2, state); state = hash_len(type, value->v_config->pow2, state); state = hash_len(type, value->v_config->redc2, state); state = hash_bool(type, value->v_config->tilde_ok, state); state = hash_bool(type, value->v_config->tab_ok, state); state = hash_long(type, (long)value->v_config->quomod, state); state = hash_long(type, (long)value->v_config->quo, state); state = hash_long(type, (long)value->v_config->mod, state); state = hash_long(type, (long)value->v_config->sqrt, state); state = hash_long(type, (long)value->v_config->appr, state); state = hash_long(type, (long)value->v_config->cfappr, state); state = hash_long(type, (long)value->v_config->cfsim, state); state = hash_long(type, (long)value->v_config->outround, state); state = hash_long(type, (long)value->v_config->round, state); state = hash_bool(type, value->v_config->leadzero, state); state = hash_bool(type, value->v_config->fullzero, state); state = hash_long(type, (long)value->v_config->maxscancount, state); state = hash_str(type, value->v_config->prompt1, state); state->bytes = FALSE; /* as if just read words */ state = hash_str(type, value->v_config->prompt2, state); state->bytes = FALSE; /* as if just read words */ state = hash_int(type, value->v_config->blkmaxprint, state); state = hash_bool(type, value->v_config->blkverbose, state); state = hash_int(type, value->v_config->blkbase, state); state = hash_int(type, value->v_config->blkfmt, state); state = hash_long(type, (long)value->v_config->resource_debug, state); state = hash_long(type, (long)value->v_config->calc_debug, state); state = hash_long(type, (long)value->v_config->user_debug, state); state = hash_bool(type, value->v_config->verbose_quit, state); state = hash_int(type, value->v_config->ctrl_d, state); state = hash_str(type, value->v_config->program, state); state = hash_str(type, value->v_config->base_name, state); state = hash_bool(type, value->v_config->windows, state); state = hash_bool(type, value->v_config->cygwin, state); state = hash_bool(type, value->v_config->compile_custom, state); if (value->v_config->allow_custom != NULL && *(value->v_config->allow_custom)) { state = hash_bool(type, TRUE, state); } else { state = hash_bool(type, FALSE, state); } state = hash_str(type, value->v_config->version, state); state = hash_int(type, value->v_config->baseb, state); state = hash_bool(type, value->v_config->redecl_warn, state); state = hash_bool(type, value->v_config->dupvar_warn, state); break; case V_HASH: /* setup for the this value type */ (state->chkpt)(state); (state->type)(value->v_type, state); /* hash the HASH state */ state = hash_int(type, value->v_hash->type, state); state = hash_bool(type, value->v_hash->bytes,state); state = hash_int(type, value->v_hash->base, state); state = hash_int(type, value->v_hash->chunksize, state); state = hash_int(type, value->v_hash->unionsize, state); (state->update)(state, value->v_hash->h_union.data, state->unionsize); state->bytes = FALSE; /* as if reading words */ break; case V_BLOCK: /* there is no setup for a BLOCK */ /* hash the octets in the BLOCK */ if (value->v_block->datalen > 0) { state = hash_usb8(type, value->v_block->data, value->v_block->datalen, state); } break; case V_OCTET: /* there is no setup for an OCTET */ /* hash the OCTET */ state = hash_usb8(type, value->v_octet, 1, state); break; case V_NBLOCK: /* there is no setup for a NBLOCK */ /* hash the octets in the NBLOCK */ if (value->v_nblock->blk->datalen > 0) { state = hash_usb8(type, value->v_nblock->blk->data, value->v_nblock->blk->datalen, state); } break; default: math_error("hashing an unknown value"); /*NOTREACHED*/ } return state; }
void shader::set4f(const char * name, const vec4 & vector) { glUniform4f(getloc(name), vector.x, vector.y, vector.z, vector.w); }
int notify_html_listeners(int descr, dbref who, dbref xprog, dbref obj, dbref room, const char *msg, int isprivate) { char buf[BUFFER_LEN], *nohbuf, *noabuf, buf2[BUFFER_LEN]; dbref ref; if (obj == NOTHING) return 0; nohbuf = html_escape(msg); noabuf = tct(buf2, nohbuf); if (tp_listeners && (tp_listeners_obj || Typeof(obj) == TYPE_ROOM)) { listenqueue(descr, who, room, obj, obj, xprog, "_listen", nohbuf, tp_listen_mlev, 1, 0); listenqueue(descr, who, room, obj, obj, xprog, "_olisten", nohbuf, tp_listen_mlev, 0, 0); listenqueue(descr, who, room, obj, obj, xprog, "~listen", nohbuf, tp_listen_mlev, 1, 1); listenqueue(descr, who, room, obj, obj, xprog, "~olisten", nohbuf, tp_listen_mlev, 0, 1); listenqueue(descr, who, room, obj, obj, xprog, "@listen", nohbuf, tp_listen_mlev, 1, 1); listenqueue(descr, who, room, obj, obj, xprog, "@olisten", nohbuf, tp_listen_mlev, 0, 1); listenqueue(descr, who, room, obj, obj, xprog, "_alisten", noabuf, tp_listen_mlev, 1, 0); listenqueue(descr, who, room, obj, obj, xprog, "_aolisten", noabuf, tp_listen_mlev, 0, 0); listenqueue(descr, who, room, obj, obj, xprog, "~alisten", noabuf, tp_listen_mlev, 1, 1); listenqueue(descr, who, room, obj, obj, xprog, "~aolisten", noabuf, tp_listen_mlev, 0, 1); listenqueue(descr, who, room, obj, obj, xprog, "@alisten", noabuf, tp_listen_mlev, 1, 1); listenqueue(descr, who, room, obj, obj, xprog, "@aolisten", noabuf, tp_listen_mlev, 0, 1); /* Loop up the environment only if tp_listeners_env is set and obj * is a room. Runs once otherwise. -brevantes */ if (tp_listeners_env && (Typeof(obj) == TYPE_ROOM) ) { obj = DBFETCH(obj)->location; for (;obj != NOTHING;obj = DBFETCH(obj)->location) { listenqueue(descr, who, room, obj, obj, xprog, "_listen", nohbuf, tp_listen_mlev, 1, 0); listenqueue(descr, who, room, obj, obj, xprog, "_olisten", nohbuf, tp_listen_mlev, 0, 0); listenqueue(descr, who, room, obj, obj, xprog, "~listen", nohbuf, tp_listen_mlev, 1, 1); listenqueue(descr, who, room, obj, obj, xprog, "~olisten", nohbuf, tp_listen_mlev, 0, 1); listenqueue(descr, who, room, obj, obj, xprog, "@listen", nohbuf, tp_listen_mlev, 1, 1); listenqueue(descr, who, room, obj, obj, xprog, "@olisten", nohbuf, tp_listen_mlev, 0, 1); listenqueue(descr, who, room, obj, obj, xprog, "_alisten", noabuf, tp_listen_mlev, 1, 0); listenqueue(descr, who, room, obj, obj, xprog, "_aolisten", noabuf, tp_listen_mlev, 0, 0); listenqueue(descr, who, room, obj, obj, xprog, "~alisten", noabuf, tp_listen_mlev, 1, 1); listenqueue(descr, who, room, obj, obj, xprog, "~aolisten", noabuf, tp_listen_mlev, 0, 1); listenqueue(descr, who, room, obj, obj, xprog, "@alisten", noabuf, tp_listen_mlev, 1, 1); listenqueue(descr, who, room, obj, obj, xprog, "@aolisten", noabuf, tp_listen_mlev, 0, 1); } return 0; } } if (tp_zombies && (Typeof(obj) == TYPE_THING) && !isprivate && !(FLAGS(obj) & QUELL)) { if (FLAGS(obj) & VEHICLE) { if (getloc(who) == getloc(obj)) { char pbuf[BUFFER_LEN]; const char *prefix; prefix = GETOECHO(obj); if (prefix && *prefix) { prefix = do_parse_mesg(-1, who, obj, prefix, "(@Oecho)", pbuf, MPI_ISPRIVATE); } if (!prefix || !*prefix) prefix = "Outside>"; sprintf(buf, "%s %.*s", prefix, (int) (BUFFER_LEN - 2 - strlen(prefix)), msg); ref = DBFETCH(obj)->contents; while (ref != NOTHING) { #ifdef IGNORE_SUPPORT if (!ignorance(who, ref)) #endif /* IGNORE_SUPPORT */ notify_html_nolisten(ref, buf, isprivate); ref = DBFETCH(ref)->next; } } } } if (Typeof(obj) == TYPE_PLAYER || Typeof(obj) == TYPE_THING) { #ifdef IGNORE_SUPPORT if (ignorance(who, obj)) return 0; #endif if ( !isprivate && Typeof(obj) == TYPE_THING && FLAGS(obj) & ZOMBIE && LOCATION(obj) == LOCATION(OWNER(obj)) ) return 0; return notify_html_nolisten(obj, msg, isprivate); } else { return 0; } }
void shader::setmat4(const char * name, const mat4 & matrix) { glUniformMatrix4fv(getloc(name), 1, GL_FALSE, matrix.elements); }
void dist_pop(Widget iw_t, XEvent *event, String *params, Cardinal *num_params) { int dx, dy; /* the distance for x-y axis */ int ixi, iyi; char outstr[80]; /* print out string */ if (!(strcmp(*params, "M"))) { /* List location ---- mouse moved */ getloc(event,'m',&ix1,&iy1); if (dist_inimag) { /* find location relative to last image */ ixi = ix1 - ixul + 1; iyi = iy1 - iyul + 1; } if (ndist < 0) /* the starting point flag */ /* haven't got the starting point yet */ return; else if (dist_inimag && (ixi < 1 || ixi > nsam || iyi < 1 || iyi > nrow)) { /* cursor is outside of image, only want inside */ sprintf(outstr,"*** Outside: (%d,%d)$", ixi,iyi); spout(outstr); /* draw line */ xorline(iwin, icontxx, FALSE, ix0, iy0, ix1, iy1); } else { /* report the distance, don't save it */ dx = ix1 - ix0; dy = iy1 - iy0; distance = sqrt((float)(dx*dx + dy*dy)); sprintf(outstr,"*** Distance: %f ****$", distance); spout(outstr); xorline(iwin, icontxx, FALSE, ix0, iy0, ix1, iy1); } } else if (!(strcmp(*params, "1"))) { /* List location -------- button 1 pushed */ getloc(event,'B',&ix1,&iy1); if (dist_inimag) { /* find location relative to last image */ ixi = ix1 - ixul + 1; iyi = iy1 - iyul + 1; } if (ndist < 0) { /* set starting point for distance listing */ ndist = 0; ix0 = ix1; iy0 = iy1; return; } else if (dist_inimag && ( ixi < 1 || ixi > nsam || iyi < 1 || iyi > nrow)) { /* cursor is outside of image, only want inside */ sprintf(outstr,"*** Outside image: (%d,%d)", ixi,iyi); spout(outstr); } else { /* record the distance */ if (dist_leavit) { /* draw a permanent line along the distance */ xorline(iwin, icontxx, TRUE, ix0, iy0, ix1, iy1); xorline(iwin, icontxx, TRUE, ix0, iy0, ix1, iy1); xorline(imagsav, icontxx, TRUE, ix0, iy0, ix1, iy1); } ndist++; if (dist_docit) { /* want to save this distance for doc file */ if (ndist > MAXREG ) { /* too many distances from this starting point for doc file */ spout("*** Document key is full, maximum line # is 7"); ndist = MAXREG; } else { /* save the location for entry in doc file */ dlist[ndist] = distance; sprintf(outstr,"*** Selected: #%d: %d %f", ikey, ndist - 1, distance); spout(outstr); if (singledist) { /* only want one distance from this start */ if (dist_docit > 0) { /* save the current distance line */ dlist[0] = ikey++; dlist[2] = ix0; dlist[3] = iy0; dlist[4] = ix1; dlist[5] = iy1; fpdocpix = savdn1(docnam, datexc, &fpdocpix, dlist, 6, &opendistdoc, TRUE, TRUE); } ndist = 0; ix0 = ix1; iy0 = iy1; distance = 0; } } } } } else if (!(strcmp(*params, "2"))) { /* display the dist_menu */ /* remove current actions */ XtUninstallTranslations(iw_win); xorline(iwin, icontxx, TRUE, ix0, iy0, ix1, iy1); /* show menu */ showbutx(NULL, NULL, NULL, TRUE); distmen(NULL, NULL, NULL); } else if (!(strcmp(*params, "3"))) { /* set a new starting point */ if (ndist > 0) /* remove the current line */ xorline(iwin, icontxx, TRUE, ix0, iy0, ix1, iy1); if ( !singledist) { if (dist_docit > 0 && ndist > 0) { /* first save the current distance line */ dlist[0] = ikey; fpdocpix = savdn1(docnam, datexc, &fpdocpix, dlist, ndist+1, &opendistdoc, TRUE, TRUE); ikey++; } } ndist = -1; } }