/* * do the actual motion on the screen done by an object traveling * across the room */ void do_motion(struct object *obj, int ydelta, int xdelta, struct thing *tp) { /* * Come fly with us ... */ obj->o_pos = tp->t_pos ; for ( ; ;) { register int ch ; /* * Erase the old one */ if (!ce(obj->o_pos, tp->t_pos) && cansee(unc(obj->o_pos)) && mvwinch(cw, obj->o_pos.y, obj->o_pos.x) != ' ') { mvwaddch(cw, obj->o_pos.y, obj->o_pos.x, show(obj->o_pos.y, obj->o_pos.x)) ; } /* * Get the new position */ obj->o_pos.y += ydelta ; obj->o_pos.x += xdelta ; if (shoot_ok(ch = winat(obj->o_pos.y, obj->o_pos.x)) && ch != DOOR && !ce(obj->o_pos, hero)) { /* * It hasn't hit anything yet, so display it * If it alright. */ if (cansee(unc(obj->o_pos)) && mvwinch(cw, obj->o_pos.y, obj->o_pos.x) != ' ') { mvwaddch(cw, obj->o_pos.y, obj->o_pos.x, obj->o_type) ; draw(cw) ; } continue ; } /* don't want objects to end up in wall, or fall through * so back it up. */ if (ch == '|' || ch == '-' || ch == SECRETDOOR || ch == ' ') { obj->o_pos.y -= ydelta ; obj->o_pos.x -= xdelta ; } break ; } }
NonLinearLSQ::NLVector NonLinearLSQ::getUncertainty(const gsl_matrix *covar) const { NLVector unc(covar->size1); for (size_t i = 0 ; i < covar->size1 ; i++ ) { unc[i] = sqrt(gsl_matrix_get(covar, i, i)); } return (unc); }
void do_motion(THING *obj, int ydelta, int xdelta) { int ch; /* * Come fly with us ... */ obj->o_pos = hero; for (;;) { /* * Erase the old one */ if (!ce(obj->o_pos, hero) && cansee(unc(obj->o_pos)) && !terse) { ch = chat(obj->o_pos.y, obj->o_pos.x); if (ch == FLOOR && !show_floor()) ch = ' '; mvaddch(obj->o_pos.y, obj->o_pos.x, ch); } /* * Get the new position */ obj->o_pos.y += ydelta; obj->o_pos.x += xdelta; if (step_ok(ch = winat(obj->o_pos.y, obj->o_pos.x)) && ch != DOOR) { /* * It hasn't hit anything yet, so display it * If it alright. */ if (cansee(unc(obj->o_pos)) && !terse) { mvaddch(obj->o_pos.y, obj->o_pos.x, obj->o_type); refresh(); } continue; } break; } }
/* * do the actual motion on the screen done by an object traveling * across the room */ void do_motion(struct object *obj, int ydelta, int xdelta) { /* * Come fly with us ... */ obj->o_pos = hero; for (;;) { int ch; /* * Erase the old one */ if (!ce(obj->o_pos, hero) && cansee(unc(obj->o_pos)) && CMVWINCH(cw, obj->o_pos.y, obj->o_pos.x) != ' ') mvwaddrawch(cw, obj->o_pos.y, obj->o_pos.x, show(obj->o_pos.y, obj->o_pos.x)); /* * Get the new position */ obj->o_pos.y += ydelta; obj->o_pos.x += xdelta; if (step_ok(ch = winat(obj->o_pos.y, obj->o_pos.x)) && ch != DOOR) { /* * It hasn't hit anything yet, so display it * If it alright. */ if (cansee(unc(obj->o_pos)) && CMVWINCH(cw, obj->o_pos.y, obj->o_pos.x) != ' ') { mvwaddrawch(cw, obj->o_pos.y, obj->o_pos.x, obj->o_type); draw(cw); } continue; } break; } }
void Smb4KCustomOptions::setShare(Smb4KShare *share) { Q_ASSERT(share); switch (d->type) { case UnknownNetworkItem: { d->url = share->url(); d->workgroup = share->workgroupName(); d->type = Share; d->smbPort = 139; #if defined(Q_OS_LINUX) d->fileSystemPort = share->port() != -1 ? share->port() : 445; #endif d->user = share->user(); d->group = share->group(); d->ip.setAddress(share->hostIP()); break; } case Host: { if (QString::compare(unc(), share->hostUNC(), Qt::CaseInsensitive) == 0) { d->url = share->url(); d->type = Share; #if defined(Q_OS_LINUX) d->fileSystemPort = share->port() != -1 ? share->port() : d->fileSystemPort; #endif d->user = share->user(); d->group = share->group(); d->ip.setAddress(share->hostIP()); } else { // Do nothing } break; } default: { break; } } }
void missile(int ydelta, int xdelta) { struct object *obj; struct linked_list *item, *nitem; /* * Get which thing we are hurling */ if ((item = get_item("throw", WEAPON)) == NULL) return; obj = (struct object *) ldata(item); if (!dropcheck(obj) || is_current(obj)) return; /* * Get rid of the thing. If it is a non-multiple item object, or * if it is the last thing, just drop it. Otherwise, create a new * item with a count of one. */ if (obj->o_count < 2) { detach(pack, item); inpack--; } else { obj->o_count--; if (obj->o_group == 0) inpack--; nitem = (struct linked_list *) new_item(sizeof *obj); obj = (struct object *) ldata(nitem); *obj = *((struct object *) ldata(item)); obj->o_count = 1; item = nitem; } do_motion(obj, ydelta, xdelta); /* * AHA! Here it has hit something. If it is a wall or a door, * or if it misses (combat) the mosnter, put it on the floor */ if (!ismons(CMVWINCH(mw, obj->o_pos.y, obj->o_pos.x)) || !hit_monster(unc(obj->o_pos), obj)) fall(item, TRUE); mvwaddrawch(cw, hero.y, hero.x, PLAYER); }
void missile(int ydelta, int xdelta) { THING *obj; /* * Get which thing we are hurling */ if ((obj = get_item("throw", WEAPON)) == NULL) return; if (!dropcheck(obj) || is_current(obj)) return; obj = leave_pack(obj, TRUE, FALSE); do_motion(obj, ydelta, xdelta); /* * AHA! Here it has hit something. If it is a wall or a door, * or if it misses (combat) the monster, put it on the floor */ if (moat(obj->o_pos.y, obj->o_pos.x) == NULL || !hit_monster(unc(obj->o_pos), obj)) fall(obj, TRUE); }
/* * roomin: * Find what room some coordinates are in. NULL means they aren't * in any room. */ struct room * roomin(const coord *cp) { struct room *rp; int *fp; fp = &flat(cp->y, cp->x); if (*fp & F_PASS) return &passages[*fp & F_PNUM]; for (rp = rooms; rp < &rooms[MAXROOMS]; rp++) if (cp->x <= rp->r_pos.x + rp->r_max.x && rp->r_pos.x <= cp->x && cp->y <= rp->r_pos.y + rp->r_max.y && rp->r_pos.y <= cp->y) return rp; msg("in some bizarre place (%d, %d)", unc(*cp)); #ifdef MASTER abort(); return NULL; #else return NULL; #endif }
int do_chase(struct thing *th) { struct room *rer, *ree; /* room of chaser, room of chasee */ int mindist = 32767, i, dist; int stoprun = FALSE; /* TRUE means we are there */ int sch; coord this; /* Temporary destination for chaser */ rer = roomin(&th->t_pos); /* Find room of chaser */ ree = roomin(th->t_dest); /* Find room of chasee */ /* * We don't count doors as inside rooms for this routine */ if (CMVWINCH(stdscr, th->t_pos.y, th->t_pos.x) == DOOR) rer = NULL; this = *th->t_dest; /* * If the object of our desire is in a different room, * than we are and we ar not in a corridor, run to the * door nearest to our goal. */ if (rer != NULL && rer != ree) for (i = 0; i < rer->r_nexits; i++) /* loop through doors */ { dist = DISTANCE(th->t_dest->y, th->t_dest->x, rer->r_exit[i].y, rer->r_exit[i].x); if (dist < mindist) /* minimize distance */ { this = rer->r_exit[i]; mindist = dist; } } /* * this now contains what we want to run to this time * so we run to it. If we hit it we either want to fight it * or stop running */ if (!chase(th, &this)) { if (ce(this, hero)) { return( attack(th) ); } else if (th->t_type != 'F') stoprun = TRUE; } else if (th->t_type == 'F') return(0); mvwaddrawch(cw, th->t_pos.y, th->t_pos.x, th->t_oldch); sch = CMVWINCH(cw, ch_ret.y, ch_ret.x); if (rer != NULL && (rer->r_flags & ISDARK) && sch == FLOOR && DISTANCE(ch_ret.y, ch_ret.x, th->t_pos.y, th->t_pos.x) < 3 && off(player, ISBLIND)) th->t_oldch = ' '; else th->t_oldch = sch; if (cansee(unc(ch_ret)) && !on(*th, ISINVIS)) mvwaddrawch(cw, ch_ret.y, ch_ret.x, th->t_type); mvwaddrawch(mw, th->t_pos.y, th->t_pos.x, ' '); mvwaddrawch(mw, ch_ret.y, ch_ret.x, th->t_type); th->t_pos = ch_ret; /* * And stop running if need be */ if (stoprun && ce(th->t_pos, *(th->t_dest))) th->t_flags &= ~ISRUN; return(0); }
bool Smb4KCustomOptions::equals(Smb4KCustomOptions *options, bool fullCheck) const { // Type if (d->type != options->type()) { return false; } else { // Do nothing } // Profile if (QString::compare(d->profile, options->profile()) != 0) { return false; } else { // Do nothing } // Workgroup if (QString::compare(d->workgroup, options->workgroupName(), Qt::CaseInsensitive) != 0) { return false; } else { // Do nothing } // UNC if (QString::compare(unc(), options->unc(), Qt::CaseInsensitive) != 0) { return false; } else { // Do nothing } // Full check if (fullCheck) { // IP address if (QString::compare(d->ip.toString(), options->ip()) != 0) { return false; } else { // Do nothing } // Remounting if (d->remount != options->remount()) { return false; } else { // Do nothing } // SMB port if (d->smbPort != options->smbPort()) { return false; } else { // Do nothing } #if defined(Q_OS_LINUX) // File system port (used for mounting) if (d->fileSystemPort != options->fileSystemPort()) { return false; } else { // Do nothing } // Security mode if (d->securityMode != options->securityMode()) { return false; } else { // Do nothing } // Write access if (d->writeAccess != options->writeAccess()) { return false; } else { // Do nothing } #endif // Kerberos if (d->kerberos != options->useKerberos()) { return false; } else { // Do nothing } // UID if (d->user.userId() != options->user().userId()) { return false; } else { // Do nothing } // GID if (d->group.groupId() != options->group().groupId()) { return false; } else { // Do nothing } // MAC address if (QString::compare(d->mac, options->macAddress()) != 0) { return false; } else { // Do nothing } // Send WOL packages before first scan if (d->wol_first_scan != options->wolSendBeforeNetworkScan()) { return false; } else { // Do nothing } // Send WOL packages before mount if (d->wol_mount != options->wolSendBeforeMount()) { return false; } else { // Do nothing } } else { // Do nothing } return true; }
/* * missile: * Fire a missile in a given direction */ void missile(int ydelta, int xdelta, struct linked_list *item, struct thing *tp) { register struct object *obj ; register struct linked_list *nitem ; /* * Get which thing we are hurling */ if (item == NULL) { return ; } obj = (struct object *) ldata(item) ; if (!dropcheck(obj) || is_current(obj)) { return ; } /* * Get rid of the thing. If it is a non-multiple item object, or * if it is the last thing, just drop it. Otherwise, create a new * item with a count of one. */ if (obj->o_count < 2) { detach(tp->t_pack, item) ; if (tp->t_pack == pack) { inpack-- ; freeletter(item); } } else { obj->o_count-- ; nitem = (struct linked_list *) new_item(sizeof *obj) ; obj = (struct object *) ldata(nitem) ; *obj = *((struct object *) ldata(item)) ; obj->o_count = 1 ; item = nitem ; } if (obj->o_type == ARTIFACT) has_artifact &= ~(1 << obj->o_which); if (obj->o_type == SCROLL && obj->o_which == S_SCARE) { if (obj->o_flags & ISBLESSED) obj->o_flags &= ~ISBLESSED; else obj->o_flags |= ISCURSED; } updpack (FALSE); do_motion(obj, ydelta, xdelta, tp) ; /* * AHA! Here it has hit something. If it is a wall or a door, * or if it misses (combat) the monster, put it on the floor */ if (!hit_monster(unc(obj->o_pos), obj, tp)) { if (obj->o_type == WEAPON && obj->o_which == GRENADE) { register struct room *rp; static coord fpos; msg("BOOOM!"); aggravate(); rp = roomin(&obj->o_pos); if (ntraps + 1 < MAXTRAPS + MAXTRAPS && fallpos(&obj->o_pos, &fpos, TRUE)) { mvaddch(fpos.y, fpos.x, TRAPDOOR); traps[ntraps].tr_type = TRAPDOOR; traps[ntraps].tr_flags = ISFOUND; traps[ntraps].tr_show = TRAPDOOR; traps[ntraps].tr_pos.y = fpos.y; traps[ntraps++].tr_pos.x = fpos.x; light(&hero); } discard(item); } else if (obj->o_flags & ISLOST) { if (obj->o_type == WEAPON) addmsg("The %s", weaps[obj->o_which].w_name); else addmsg(inv_name(obj, TRUE)); msg(" vanishes in a puff of greasy smoke."); discard(item); } else { if (fall(item, TRUE)) if (obj->o_flags & CANRETURN) msg("You have %s.", inv_name(obj, TRUE)); } } else if (obj->o_flags & ISOWNED) { add_pack(item, TRUE); msg("You have %s.", inv_name(obj, TRUE)); } mvwaddch(cw, hero.y, hero.x, PLAYER) ; }
/* * do_chase: * Make one thing chase another. */ void do_chase(struct thing *th, int flee) { register struct room *rer, *ree, /* room of chaser, room of chasee */ *old_room, /* old room of monster */ *new_room; /* new room of monster */ register int mindist = MAXINT, maxdist = MININT, dist = MININT, i, last_door = -1; /* Door we just came from */ register int stoprun = FALSE, /* TRUE means we are there */ rundoor; /* TRUE means run to a door */ int mdead = 0; register int sch; coord this; /* Temporary destination for chaser */ /* Make sure the monster can move */ if (th->t_no_move != 0) { th->t_no_move--; return; } rer = roomin(&th->t_pos); /* Find room of chaser */ ree = roomin(th->t_dest); /* Find room of chasee */ /* * We don't count doors as inside rooms for this routine */ if (mvwinch(stdscr, th->t_pos.y, th->t_pos.x) == DOOR) rer = NULL; this = *th->t_dest; /* * If we are not in a corridor and not a Xorn, then if we are running * after the player, we run to a door if he is not in the same room. * If we are fleeing, we run to a door if he IS in the same room. * Note: We don't bother with doors in mazes. */ if (levtype != MAZELEV && rer != NULL && off(*th, CANINWALL)) { if (flee) rundoor = (rer == ree); else rundoor = (rer != ree); } else rundoor = FALSE; if (rundoor) { coord exit; /* A particular door */ int exity, exitx; /* Door's coordinates */ if (th->t_doorgoal != -1) { /* Do we already have the goal? */ this = rer->r_exit[th->t_doorgoal]; dist = 0; /* Indicate that we have our door */ } else for (i = 0; i < rer->r_nexits; i++) { /* Loop through doors */ exit = rer->r_exit[i]; exity = exit.y; exitx = exit.x; /* Avoid secret doors */ if (mvwinch(stdscr, exity, exitx) == DOOR) { /* Were we just on this door? */ if (ce(exit, th->t_oldpos)) last_door = i; else { dist = DISTANCE(th->t_dest->y, th->t_dest->x, exity, exitx); /* If fleeing, we want to maximize distance from door to * what we flee, and minimize distance from door to us. */ if (flee) dist -= DISTANCE(th->t_pos.y, th->t_pos.x, exity, exitx); /* Maximize distance if fleeing, otherwise minimize it */ if ((flee && (dist > maxdist)) || (!flee && (dist < mindist))) { th->t_doorgoal = i; /* Use this door */ this = exit; mindist = maxdist = dist; } } } } /* Could we not find a door? */ if (dist == MININT) { /* If we were on a door, go ahead and use it */ if (last_door != -1) { th->t_doorgoal = last_door; this = th->t_oldpos; dist = 0; /* Indicate that we found a door */ } } /* Indicate that we do not want to flee from the door */ if (dist != MININT) flee = FALSE; } else th->t_doorgoal = -1; /* Not going to any door */ /* * this now contains what we want to run to this time * so we run to it. If we hit it we either want to fight it * or stop running */ if (!chase(th, &this, flee, &mdead)) { if (ce(ch_ret, hero)) { /* merchants try to sell something */ if (on(*th, CANSELL)) sell(th); else if (on(*th, ISCHARMED)) {} /* future enhancements */ else if (on(*th, ISFRIENDLY)) {} else attack(th, NULL, FALSE); return; } else if (on(*th, NOMOVE)) stoprun = TRUE; } if (on(*th, ISDEAD)) return; /* Did monster get itself killed? */ if (on(*th, NOMOVE)) return; /* If we have a scavenger, it can pick something up */ if (on(*th, ISSCAVENGE)) { register struct linked_list *item; if ((item = find_obj(ch_ret.y, ch_ret.x)) != NULL) { register int floor = (roomin(&ch_ret) == NULL) ? PASSAGE : FLOOR; detach(lvl_obj, item); mvaddch(ch_ret.y, ch_ret.x, floor); mvwaddch(cw, ch_ret.y, ch_ret.x, floor); attach(th->t_pack, item); } } mvwaddch(cw, th->t_pos.y, th->t_pos.x, th->t_oldch); sch = CCHAR( mvwinch(cw, ch_ret.y, ch_ret.x) ); /* Get old and new room of monster */ old_room=roomin(&th->t_pos); new_room=roomin(&ch_ret); /* If the monster can illuminate rooms, check for a change */ if (on(*th, HASFIRE)) { /* Is monster entering a room? */ if (old_room != new_room && new_room != NULL) { new_room->r_flags |= HASFIRE; new_room->r_fires++; if (cansee(ch_ret.y, ch_ret.x) && new_room->r_fires == 1) light(&hero); } /* Is monster leaving a room? */ if (old_room != new_room && old_room != NULL) { if (--(old_room->r_fires) <= 0) { old_room->r_flags &= ~HASFIRE; if (cansee(th->t_pos.y, th->t_pos.x)) light(&th->t_pos); } } } /* If monster is entering player's room and player can see it, * stop the player's running. */ if (new_room != old_room && new_room != NULL && new_room == ree && cansee(unc(ch_ret)) && (off(*th, ISINVIS) || (off(*th, ISSHADOW) || rnd(10) == 0) || on(player, CANSEE)) && off(*th, CANSURPRISE)) running = FALSE; if (rer != NULL && (rer->r_flags & ISDARK) && !(rer->r_flags & HASFIRE) && sch == FLOOR && DISTANCE(ch_ret.y, ch_ret.x, th->t_pos.y, th->t_pos.x) < see_dist && off(player, ISBLIND)) th->t_oldch = ' '; else th->t_oldch = sch; if (cansee(unc(ch_ret)) && off(*th, ISINWALL) && ((off(*th, ISINVIS) && (off(*th, ISSHADOW) || rnd(100) < 10)) || on(player, CANSEE)) && off(*th, CANSURPRISE)) mvwaddch(cw, ch_ret.y, ch_ret.x, th->t_type); mvwaddch(mw, th->t_pos.y, th->t_pos.x, ' '); mvwaddch(mw, ch_ret.y, ch_ret.x, th->t_type); /* Record monster's last position (if new one is different) */ if (!ce(ch_ret, th->t_pos)) th->t_oldpos = th->t_pos; th->t_pos = ch_ret; /* Mark the monster's new position */ /* If the monster is on a trap, trap it */ sch = CCHAR( mvinch(ch_ret.y, ch_ret.x) ); if (isatrap(sch)) { debug("Monster trapped by %c.", sch); if (cansee(ch_ret.y, ch_ret.x)) th->t_oldch = sch; be_trapped(th, &ch_ret); } /* * And stop running if need be */ if (stoprun && ce(th->t_pos, *(th->t_dest))) turn_off(*th, ISRUN); }