示例#1
0
Lex Scanner::get_lex(){
    int d, j;
    CS = H;
    do
    {
        switch( CS ){
            case H:
                if ( (c == ' ') || (c == '\n') || (c == '\r') || (c == '\t') )
                    gc();
                else if (isalpha(c) || (c == '_')){
                    clear();
                    add();
                    gc();
                    CS = IDENT;
                }
                else if (isdigit(c)){
                    d = c - '0';
                    gc();
                    CS = NUMB;
                }
                else if (c == '/'){
                    gc();
                    CS = COMS;
                }
                else if ( (c == '<') || (c == '>') || (c == '=')){
                    clear();
                    add();
                    gc();
                    CS = ALE;
                }
                else if (c == EOF)
                    return Lex(LEX_FIN,0,"EOF");
                else if (c == '!'){
                    clear();
                    add();
                    gc();
                    CS = NEQ;
                }
                else if (c == '&'){
                    clear();
                    add();
                    gc();
                    CS = AND;
                }
                else if (c == '|'){
                    clear();
                    add();
                    gc();
                    CS = OR;
                }
                else
                if (c == '"'){
                    clear();
                    gc();
                    CS = STR;
                }
                else
                    CS = DELIM;
                break;
            case IDENT:
                if (isalpha(c) || isdigit(c) || (c == '_')){
                    add();
                    gc();
                }
                else
                    if (j = look(buf,TW))
                        return Lex (words[j],j, buf);
                    else{
                        j = TID.put(buf);
                        return Lex (LEX_ID, j, buf);
                    }
                break;
            case STR:
                    if (c == '"'){
                        gc();
                        return Lex (LEX_STRING, 0, buf);
                    }
                    else if (c == '\\'){
                        gc();
                        CS = BSC;
                    }
                    else if (c == EOF)
                        throw "String must be closed!";
                    else{
                        add();
                        gc();
                    }
                    /*else
                        throw "String can't contain \n!";*/
                break;
            case BSC:
                    if (c == 'n')
                        throw "String can't contain '\\n'!";
                    else if (c == 't'){
                        char c1 = c;
                        c = '\\';
                        add();
                        c = c1;
                        add();
                        gc();
                        CS = STR;
                    }
                    else if (c == EOF)
                        throw "Strinfg must be closed!";
                    else{
                        add();
                        gc();
                        CS = STR;
                    }

                break;
            case NUMB:
                if (isdigit(c)){
                    d = c - '0' + d*10;
                    gc();
                }
                else
                    return Lex (LEX_NUM, d,"Number");
                break;
            case COMS:
                if (c == '*'){
                    gc();
                    CS = COM;
                }
                else{
                    return Lex(dlms[16], 16,"/");
                }
                break;
            case COM:
                if (c == '*'){
                    gc();
                    CS = COME;
                }
                else if ( c == EOF )
                    throw "Comment must be closed!";
                else
                    gc();
                break;
            case COME:
                if (c == '/'){
                    gc();
                    CS = H;
                }
                else if (c == EOF)
                    throw "Comment must be closed!";
                else {
                    gc();
                    CS = COM;
                }
                break;
            case ALE:
                if (c == '='){
                    add();
                    gc();
                    j = look (buf, TD);
                    return Lex (dlms[j], j, buf);
                }
                else
                {
                    j = look (buf, TD);
                    return Lex (dlms[j], j, buf);
                }
                break;
            case NEQ:
                if (c == '='){
                    add();
                    gc();
                    j = look (buf, TD);
                    return Lex(LEX_NEQ, j,"!=");
                }
                else
                    throw "Your symbol is Pyt!n. Repalce it. Oh, yes, try in next 6 years...";
                break;
            case AND:
                if (c == '&'){
                    add();
                    gc();
                    j = look (buf, TD);
                    return Lex (dlms[j], j,buf);
                }
                else
                    throw '&';
                break;
            case OR:
                if (c == '|'){
                    add();
                    gc();
                    j = look(buf, TD);
                    return Lex (dlms[j], j,buf);
                }
                else
                    throw '|';
                break;
            case DELIM:
                clear();
                add();
                if (j = look(buf, TD)){
                    gc();
                    return Lex(dlms[j], j,buf);
                }
                else
                    throw c;
                break;
        }
    }
    while(true);
};
示例#2
0
文件: lex.c 项目: tusharsoni/Inferno
int
numsym(char first)
{
    int c, isbin, isfloat, ishex;
    char *sel, *p;
    Lsym *s;

    symbol[0] = first;
    p = symbol;

    ishex = 0;
    isbin = 0;
    isfloat = 0;
    if(first == '.')
        isfloat = 1;

    if(isdigit(*p++) || isfloat) {
        for(;;) {
            c = lexc();
            if(c < 0)
                error("%d: <eof> eating symbols", line);

            if(c == '\r')
                continue;
            if(c == '\n')
                line++;
            sel = "01234567890.xb";
            if(ishex)
                sel = "01234567890abcdefABCDEF";
            else if(isbin)
                sel = "01";
            else if(isfloat)
                sel = "01234567890eE-+";

            if(strchr(sel, c) == 0) {
                unlexc(c);
                break;
            }
            if(c == '.')
                isfloat = 1;
            if(!isbin && c == 'x')
                ishex = 1;
            if(!ishex && c == 'b')
                isbin = 1;
            *p++ = c;
        }
        *p = '\0';
        if(isfloat) {
            yylval.fval = atof(symbol);
            return Tfconst;
        }

        if(isbin)
            yylval.ival = strtoul(symbol+2, 0, 2);
        else
            yylval.ival = strtoul(symbol, 0, 0);
        return Tconst;
    }

    for(;;) {
        c = lexc();
        if(c < 0)
            error("%d <eof> eating symbols", line);
        if(c == '\n')
            line++;
        if(c != '_' && c != '$' && c <= '~' && !isalnum(c)) {	/* checking against ~ lets UTF names through */
            unlexc(c);
            break;
        }
        *p++ = c;
    }

    *p = '\0';

    s = look(symbol);
    if(s == 0)
        s = enter(symbol, Tid);

    yylval.sym = s;
    return s->lexval;
}
示例#3
0
void
read_scroll()
{
    THING *obj;
    PLACE *pp;
    int y, x;
    char ch;
    int i;
    bool discardit = FALSE;
    struct room *cur_room;
    THING *orig_obj;
    static coord mp;

    obj = get_item("read", SCROLL);
    if (obj == NULL)
	return;
    if (obj->o_type != SCROLL)
    {
	if (!terse)
	    msg("there is nothing on it to read");
	else
	    msg("nothing to read");
	return;
    }
    /*
     * Calculate the effect it has on the poor guy.
     */
    if (obj == cur_weapon)
	cur_weapon = NULL;
    /*
     * Get rid of the thing
     */
    discardit = (bool)(obj->o_count == 1);
    leave_pack(obj, FALSE, FALSE);
    orig_obj = obj;

    switch (obj->o_which)
    {
	case S_CONFUSE:
	    /*
	     * Scroll of monster confusion.  Give player that power.
	     */
	    player.t_flags |= CANHUH;
	    msg("your hands begin to glow %s", pick_color("red"));
	when S_ARMOR:
	    if (cur_armor != NULL)
	    {
		cur_armor->o_arm--;
		cur_armor->o_flags &= ~ISCURSED;
		msg("your armor glows %s for a moment", pick_color("silver"));
	    }
	when S_HOLD:
	    /*
	     * Hold monster scroll.  Stop all monsters within two spaces
	     * from chasing after the hero.
	     */

	    ch = 0;
	    for (x = hero.x - 2; x <= hero.x + 2; x++)
		if (x >= 0 && x < NUMCOLS)
		    for (y = hero.y - 2; y <= hero.y + 2; y++)
			if (y >= 0 && y <= NUMLINES - 1)
			    if ((obj = moat(y, x)) != NULL && on(*obj, ISRUN))
			    {
				obj->t_flags &= ~ISRUN;
				obj->t_flags |= ISHELD;
				ch++;
			    }
	    if (ch)
	    {
		addmsg("the monster");
		if (ch > 1)
		    addmsg("s around you");
		addmsg(" freeze");
		if (ch == 1)
		    addmsg("s");
		endmsg();
		scr_info[S_HOLD].oi_know = TRUE;
	    }
	    else
		msg("you feel a strange sense of loss");
	when S_SLEEP:
	    /*
	     * Scroll which makes you fall asleep
	     */
	    scr_info[S_SLEEP].oi_know = TRUE;
	    no_command += rnd(SLEEPTIME) + 4;
	    player.t_flags &= ~ISRUN;
	    msg("you fall asleep");
	when S_CREATE:
	    /*
	     * Create a monster:
	     * First look in a circle around him, next try his room
	     * otherwise give up
	     */
	    i = 0;
	    for (y = hero.y - 1; y <= hero.y + 1; y++)
		for (x = hero.x - 1; x <= hero.x + 1; x++)
		    /*
		     * Don't put a monster in top of the player.
		     */
		    if (y == hero.y && x == hero.x)
			continue;
		    /*
		     * Or anything else nasty
		     */
		    else if (step_ok(ch = winat(y, x)))
		    {
			if (ch == SCROLL
			    && find_obj(y, x)->o_which == S_SCARE)
				continue;
			else if (rnd(++i) == 0)
			{
			    mp.y = y;
			    mp.x = x;
			}
		    }
	    if (i == 0)
		msg("you hear a faint cry of anguish in the distance");
	    else
	    {
		obj = new_item();
		new_monster(obj, randmonster(FALSE), &mp);
	    }
	when S_ID_POTION:
	case S_ID_SCROLL:
	case S_ID_WEAPON:
	case S_ID_ARMOR:
	case S_ID_R_OR_S:
	{
	    static char id_type[S_ID_R_OR_S + 1] =
		{ 0, 0, 0, 0, 0, POTION, SCROLL, WEAPON, ARMOR, R_OR_S };
	    /*
	     * Identify, let him figure something out
	     */
	    scr_info[obj->o_which].oi_know = TRUE;
	    msg("this scroll is an %s scroll", scr_info[obj->o_which].oi_name);
	    whatis(TRUE, id_type[obj->o_which]);
	}
	when S_MAP:
	    /*
	     * Scroll of magic mapping.
	     */
	    scr_info[S_MAP].oi_know = TRUE;
	    msg("oh, now this scroll has a map on it");
	    /*
	     * take all the things we want to keep hidden out of the window
	     */
	    for (y = 1; y < NUMLINES - 1; y++)
		for (x = 0; x < NUMCOLS; x++)
		{
		    pp = INDEX(y, x);
		    switch (ch = pp->p_ch)
		    {
			case DOOR:
			case STAIRS:
			    break;

			case '-':
			case '|':
			    if (!(pp->p_flags & F_REAL))
			    {
				ch = pp->p_ch = DOOR;
				pp->p_flags |= F_REAL;
			    }
			    break;

			case ' ':
			    if (pp->p_flags & F_REAL)
				goto def;
			    pp->p_flags |= F_REAL;
			    ch = pp->p_ch = PASSAGE;
			    /* FALLTHROUGH */

			case PASSAGE:
pass:
			    if (!(pp->p_flags & F_REAL))
				pp->p_ch = PASSAGE;
			    pp->p_flags |= (F_SEEN|F_REAL);
			    ch = PASSAGE;
			    break;

			case FLOOR:
			    if (pp->p_flags & F_REAL)
				ch = ' ';
			    else
			    {
				ch = TRAP;
				pp->p_ch = TRAP;
				pp->p_flags |= (F_SEEN|F_REAL);
			    }
			    break;

			default:
def:
			    if (pp->p_flags & F_PASS)
				goto pass;
			    ch = ' ';
			    break;
		    }
		    if (ch != ' ')
		    {
			if ((obj = pp->p_monst) != NULL)
			    obj->t_oldch = ch;
			if (obj == NULL || !on(player, SEEMONST))
			    mvaddch(y, x, ch);
		    }
		}
	when S_FDET:
	    /*
	     * Potion of gold detection
	     */
	    ch = FALSE;
	    wclear(hw);
	    for (obj = lvl_obj; obj != NULL; obj = next(obj))
		if (obj->o_type == FOOD)
		{
		    ch = TRUE;
		    wmove(hw, obj->o_pos.y, obj->o_pos.x);
		    waddch(hw, FOOD);
		}
	    if (ch)
	    {
		scr_info[S_FDET].oi_know = TRUE;
		show_win("Your nose tingles and you smell food.--More--");
	    }
	    else
		msg("your nose tingles");
	when S_TELEP:
	    /*
	     * Scroll of teleportation:
	     * Make player disappear and reappear
	     */
	    {
		cur_room = proom;
		teleport();
		if (cur_room != proom)
		    scr_info[S_TELEP].oi_know = TRUE;
	    }
	when S_ENCH:
	    if (cur_weapon == NULL || cur_weapon->o_type != WEAPON)
		msg("you feel a strange sense of loss");
	    else
	    {
		cur_weapon->o_flags &= ~ISCURSED;
		if (rnd(2) == 0)
		    cur_weapon->o_hplus++;
		else
		    cur_weapon->o_dplus++;
		msg("your %s glows %s for a moment",
		    weap_info[cur_weapon->o_which].oi_name, pick_color("blue"));
	    }
	when S_SCARE:
	    /*
	     * Reading it is a mistake and produces laughter at her
	     * poor boo boo.
	     */
	    msg("you hear wild laughter in the distance");
	when S_REMOVE:
	    uncurse(cur_armor);
	    uncurse(cur_weapon);
	    uncurse(cur_ring[LEFT]);
	    uncurse(cur_ring[RIGHT]);
	    msg(choose_str("you feel in touch with the Universal Onenes",
			   "you feel as if somebody is watching over you"));
	when S_AGGR:
	    /*
	     * This scroll aggravates all the monsters on the current
	     * level and sets them running towards the hero
	     */
	    aggravate();
	    msg("you hear a high pitched humming noise");
	when S_PROTECT:
	    if (cur_armor != NULL)
	    {
		cur_armor->o_flags |= ISPROT;
		msg("your armor is covered by a shimmering %s shield",
		    pick_color("gold"));
	    }
	    else
		msg("you feel a strange sense of loss");
#ifdef MASTER
	otherwise:
	    msg("what a puzzling scroll!");
	    return;
#endif
    }
    obj = orig_obj;
    look(TRUE);	/* put the result of the scroll on the screen */
    status();

    call_it(&scr_info[obj->o_which]);

    if (discardit)
	discard(obj);
}
示例#4
0
void g1_human_class::think()
{
	i4_bool process_input = i4_T;

	if (playback_think())
	{
		process_input=i4_F;
	}


	g1_player_piece_class * stank = commander();
	if ((g1_current_controller->view.get_view_mode()!=G1_ACTION_MODE &&
		 g1_current_controller->view.get_view_mode()!=G1_FOLLOW_MODE))
	{
		process_input=i4_F;
	}

	if (!process_input) //are we controlling the stank?
	{
		g1_input.deque_time(g1_input_class::LEFT);
		g1_input.deque_time(g1_input_class::RIGHT);
		g1_input.deque_time(g1_input_class::UP);
		g1_input.deque_time(g1_input_class::DOWN);
		g1_input.deque_time(g1_input_class::STRAFE_LEFT);
		g1_input.deque_time(g1_input_class::STRAFE_RIGHT);
		g1_input.deque_time(g1_input_class::STRAFE_UP);
		g1_input.deque_time(g1_input_class::STRAFE_DOWN);
		g1_input.deque_time(g1_input_class::ZOOM_IN);
		g1_input.deque_time(g1_input_class::ZOOM_OUT);
		g1_input.deque_time(g1_input_class::ZOOM_LEFT);
		g1_input.deque_time(g1_input_class::ZOOM_RIGHT);

		g1_input.deque_time(g1_input_class::ZOOM_UP);
		g1_input.deque_time(g1_input_class::ZOOM_DOWN);
//	if (g1_current_controller->view.get_view_mode()==G1_STRATEGY_MODE)
//		{
//		g1_resources.startegy_camera_dist+=(strategy_up-strategy_down)*G1_HZ/1000.0f;
//		if (g1_resources.startegy_camera_dist<=0.1f) g1_resources.startegy_camera_dist=0.1f;
//		g1_resources.startegy_camera_angle+=(strategy_out-strategy_in)*G1_HZ/1000.0f;
//		if (g1_resources.startegy_camera_angle<=0.1f) g1_resources.startegy_camera_angle=0.1f;
//		}
	}
	else
	{
		//keys are buffered in the order pressed, so do a reversed comparison
		if (memcmp(g1_input.grab_cheat_keys(),"DOG",3)==0)
		{
			g1_input.clear_cheat_keys();
			if (stank)
			{
				stank->toggle_stank_flag(g1_player_piece_class::ST_GODMODE);
			}
		}

		//This would actually belong the receive_event() function of
		//the border frame class, but it needs to be executed regardless
		//of wheter an event is outstanding.
		if (g1_border.get())
		{
			i4_float heh;
			i4_float cx=g1_border->last_mouse_x();
			i4_float lx=g1_border->prev_mouse_x();
			i4_float cy=g1_border->last_mouse_y();
			i4_float ly=g1_border->prev_mouse_y();
			if (cy<7)
			{
				heh=-0.2f;
			}
			else if (cy>(g1_border->height()-7))
			{
				heh=0.2f;
			}
			else
			{
				heh = ((cy - ly)*0.01f);
			}
			mouse_look_increment_y += heh;

			//if (mev->x<5)
			//  heh=-1.0f;
			//else if (mev->x>(width()-5))
			//  heh=1.0f;
			//else
			//if (mev->x>20&&mev->x<(width()-20))
			//    heh = (((sw32)mev->x - (sw32)mev->lx)*0.01f);
			//else
			//  heh=0;

			if (cx<20)
			{
				heh=-0.1f;
			}
			else if (cx>(g1_border->width()-20))
			{
				heh=0.1f;
			}
			else
			{
				heh = ((cx - lx)*0.01f);
			}
			mouse_look_increment_x += heh;
			g1_border->clear_mouse_move();
		}
		g1_map_piece_class * whofor=controlled();


		sw32
		left_ms=g1_input.deque_time(g1_input_class::LEFT),
		right_ms=g1_input.deque_time(g1_input_class::RIGHT),
		up_ms=g1_input.deque_time(g1_input_class::UP),
		down_ms=g1_input.deque_time(g1_input_class::DOWN),
		sleft_ms=g1_input.deque_time(g1_input_class::STRAFE_LEFT),
		sright_ms=g1_input.deque_time(g1_input_class::STRAFE_RIGHT);
		sw32 sup_ms=g1_input.deque_time(g1_input_class::STRAFE_UP);
		sw32 sdown_ms=g1_input.deque_time(g1_input_class::STRAFE_DOWN);
		sw32 zoom_in=g1_input.deque_time(g1_input_class::ZOOM_IN),
			 zoom_out=g1_input.deque_time(g1_input_class::ZOOM_OUT),
			 zoom_left=g1_input.deque_time(g1_input_class::ZOOM_LEFT),
			 zoom_right=g1_input.deque_time(g1_input_class::ZOOM_RIGHT),
			 zoom_up=g1_input.deque_time(g1_input_class::ZOOM_UP),
			 zoom_down=g1_input.deque_time(g1_input_class::ZOOM_DOWN);

		look(mouse_look_increment_x, mouse_look_increment_y,whofor);
		mouse_look_increment_y = mouse_look_increment_x = 0;
		turn( g1_resources.player_turn_speed*(left_ms-right_ms)*G1_HZ/1000.0f, whofor );
		accelerate( (up_ms-down_ms)*G1_HZ/1000.0f,whofor);
		strafe( (sright_ms-sleft_ms)*G1_HZ/1000.0f,
			   (sup_ms-sdown_ms)*G1_HZ/1000.0f,whofor);
		if (g1_current_controller->view.get_view_mode()==G1_FOLLOW_MODE)
		{
			g1_resources.follow_camera_dist+=(zoom_out-zoom_in)*G1_HZ/1000.0f;
			if (g1_resources.follow_camera_dist<=0.5f)
			{
				g1_resources.follow_camera_dist=0.5f;
			}
			g1_resources.follow_camera_height+=(zoom_up-zoom_down)*G1_HZ/1000.0f;
			g1_resources.follow_camera_rotation+=(zoom_right-zoom_left)*G1_HZ/1000.0f;
		}

		//if (sright_ms>0)
		//  sright_ms=sright_ms+1;

		if (g1_input.button_1())
		{
			fire0(whofor);
		}
		if (g1_input.button_2())
		{
			fire1(whofor);
		}
		if (g1_input.button_3())
		{
			fire2(whofor);
		}
	}


	if (g1_input.key_pressed)
	{
		continue_game();
	}

	g1_input.key_pressed=i4_F;
}
示例#5
0
static void
move(ModeInfo * mi)
{
	nosestruct *np = &noses[MI_SCREEN(mi)];

	if (!np->length) {
		register int tries = 0;

		np->dir = 0;
		if ((LRAND() & 1) && think(mi)) {
			talk(mi, False);	/* sets timeout to itself */
			return;
		}
		if (!NRAND(3) && (np->busyLoop = look(mi))) {
			np->state = MOVE;
			return;
		}
		np->busyLoop = 3 + NRAND(3);
		do {
			if (!tries)
				np->length = np->width / 100 + NRAND(90), tries = 8;
			else
				tries--;
			switch (NRAND(8)) {
				case 0:
					if (np->x - X_INCR * np->length >= 5)
						np->dir = LEFT;
					break;
				case 1:
					if (np->x + X_INCR * np->length <= np->width - np->xs - 6)
						np->dir = RIGHT;
					break;
				case 2:
					if (np->y - (Y_INCR * np->length) >= 5)
						np->dir = UP;
					break;
				case 3:
					if (np->y + Y_INCR * np->length <= np->height - np->ys - 6)
						np->dir = DOWN;
					break;
				case 4:
					if (np->x - X_INCR * np->length >= 5 &&
					  np->y - (Y_INCR * np->length) >= 5)
						np->dir = (LEFT | UP);
					break;
				case 5:
					if (np->x + X_INCR * np->length <= np->width - np->xs - 6 &&
					    np->y - Y_INCR * np->length >= 5)
						np->dir = (RIGHT | UP);
					break;
				case 6:
					if (np->x - X_INCR * np->length >= 5 &&
					    np->y + Y_INCR * np->length <= np->height - np->ys - 6)
						np->dir = (LEFT | DOWN);
					break;
				case 7:
					if (np->x + X_INCR * np->length <= np->width - np->xs - 6 &&
					    np->y + Y_INCR * np->length <= np->height - np->ys - 6)
						np->dir = (RIGHT | DOWN);
					break;
				default:
					/* No Defaults */
					break;
			}
		} while (!np->dir);
	}
	walk(mi, np->dir);
	--np->length;
	np->state = MOVE;
}
示例#6
0
static void
move (struct state *st)
{
    if (!st->move_length)
    {
	register int    tries = 0;
	st->move_dir = 0;
	if ((random() & 1) && think(st))
	{
	    talk(st, 0);		/* sets timeout to itself */
	    return;
	}
	if (!(random() % 3) && (st->interval = look(st)))
	{
	    st->next_fn = move;
	    return;
	}
	st->interval = 20 + random() % 100;
	do
	{
	    if (!tries)
		st->move_length = st->Width / 100 + random() % 90, tries = 8;
	    else
		tries--;
	    /* There maybe the case that we won't be able to exit from
	       this routine (especially when the geometry is too small)!!

	       Ensure that we can exit from this routine.
	     */
#if 1
	    if (!tries && (st->move_length <= 1)) {
	      st->move_length = 1;
	      break;
	    }
#endif
	    switch (random() % 8)
	    {
	    case 0:
		if (st->x - X_INCR * st->move_length >= 5)
		    st->move_dir = LEFT;
		break;
	    case 1:
		if (st->x + X_INCR * st->move_length <= st->Width - 70)
		    st->move_dir = RIGHT;
		break;
	    case 2:
		if (st->y - (Y_INCR * st->move_length) >= 5)
		    st->move_dir = UP, st->interval = 40;
		break;
	    case 3:
		if (st->y + Y_INCR * st->move_length <= st->Height - 70)
		    st->move_dir = DOWN, st->interval = 20;
		break;
	    case 4:
		if (st->x - X_INCR * st->move_length >= 5 && st->y - (Y_INCR * st->move_length) >= 5)
		    st->move_dir = (LEFT | UP);
		break;
	    case 5:
		if (st->x + X_INCR * st->move_length <= st->Width - 70 &&
		    st->y - Y_INCR * st->move_length >= 5)
		    st->move_dir = (RIGHT | UP);
		break;
	    case 6:
		if (st->x - X_INCR * st->move_length >= 5 &&
		    st->y + Y_INCR * st->move_length <= st->Height - 70)
		    st->move_dir = (LEFT | DOWN);
		break;
	    case 7:
		if (st->x + X_INCR * st->move_length <= st->Width - 70 &&
		    st->y + Y_INCR * st->move_length <= st->Height - 70)
		    st->move_dir = (RIGHT | DOWN);
		break;
	    default:
		/* No Defaults */
		break;
	    }
	} while (!st->move_dir);
    }
    if (st->move_dir)
      walk(st, st->move_dir);
    --st->move_length;
    st->next_fn = move;
}
示例#7
0
HRESULT InitScene()
{
	HRESULT hr;
	LPD3DXBUFFER errors = NULL;

	SetWindowText(hwnd, TITLE);

	hr = D3DXCreateEffectFromFileA(device, "../media/shaders/skinning.fx", NULL, NULL, D3DXSHADER_DEBUG, NULL, &effect, &errors);
	
	if( FAILED(hr) )
	{
		if( errors )
		{
			char* str = (char*)errors->GetBufferPointer();
			std::cout << str << "\n\n";

			errors->Release();
		}

		MYERROR("Could not create effect");
		return hr;
	}

	// load animated model
	mesh.Effect = effect;
	mesh.Method = SM_Shader;
	mesh.Path = "../media/meshes/dwarf/";
	
	if( FAILED(hr = mesh.Load(device, "../media/meshes/dwarf/dwarf.X")) )
	{
		MYERROR("Could not load dwarf");
		return hr;
	}

	// all the possible skins are contained in this file => turn off some
	mesh.SetAnimation(6);
	mesh.EnableFrame("LOD0_attachment_weapon3", false);
	mesh.EnableFrame("LOD0_attachment_weapon2", false);
	mesh.EnableFrame("LOD0_attachment_shield3", false);
	mesh.EnableFrame("LOD0_attachment_shield2", false);
	mesh.EnableFrame("LOD0_attachment_head2", false);
	mesh.EnableFrame("LOD0_attachment_head1", false);
	mesh.EnableFrame("LOD0_attachment_torso2", false);
	mesh.EnableFrame("LOD0_attachment_torso3", false);
	mesh.EnableFrame("LOD0_attachment_legs2", false);
	mesh.EnableFrame("LOD0_attachment_legs3", false);
	mesh.EnableFrame("LOD0_attachment_Lpads1", false);
	mesh.EnableFrame("LOD0_attachment_Lpads2", false);
	mesh.EnableFrame("Rshoulder", false);
	
	D3DXVECTOR3 eye(0.5f, 1.0f, -1.5f);
	D3DXVECTOR3 look(0, 0.7f, 0);
	D3DXVECTOR3 up(0, 1, 0);

	D3DXMatrixPerspectiveFovLH(&proj, D3DX_PI / 3, (float)screenwidth / (float)screenheight, 0.1f, 100);
	D3DXMatrixLookAtLH(&view, &eye, &look, &up);
	D3DXMatrixIdentity(&world);

	std::cout << "Press Space to cycle animations\n";

	return S_OK;
}
示例#8
0
文件: main.c 项目: Fluray/NxM
void
main(int argc, char *argv[])
{
	Lsym *l;
	Node *n;
	char *s;
	int pid, i;

	argv0 = argv[0];
	pid = 0;
	aout = "8.out";
	quiet = 1;

	mtype = 0;
	ARGBEGIN{
	case 'm':
		mtype = EARGF(usage());
		break;
	case 'w':
		wtflag = 1;
		break;
	case 'l':
		s = EARGF(usage());
		lm[nlm++] = s;
		break;
	case 'k':
		kernel++;
		break;
	case 'q':
		quiet = 0;
		break;
	case 'r':
		pid = 1;
		remote++;
		kernel++;
		break;
	default:
		usage();
	}ARGEND

	if(argc > 0) {
		if(remote)
			aout = argv[0];
		else
		if(isnumeric(argv[0])) {
			pid = strtol(argv[0], 0, 0);
			snprint(prog, sizeof(prog), "/proc/%d/text", pid);
			aout = prog;
			if(argc > 1)
				aout = argv[1];
			else if(kernel)
				aout = system();
		}
		else {
			if(kernel) {
				fprint(2, "acid: -k requires a pid\n");
				usage();
			}
			aout = argv[0];
		}
	} else
	if(remote)
		aout = "/mips/9ch";

	fmtinstall('x', xfmt);
	fmtinstall('L', Lfmt);
	Binit(&bioout, 1, OWRITE);
	bout = &bioout;

	kinit();
	initialising = 1;
	pushfile(0);
	loadvars();
	installbuiltin();

	if(mtype && machbyname(mtype) == 0)
		print("unknown machine %s", mtype);

	if (attachfiles(aout, pid) < 0)
		varreg();		/* use default register set on error */

	loadmodule("/sys/lib/acid/port");
	loadmoduleobjtype();

	for(i = 0; i < nlm; i++) {
		if(access(lm[i], AREAD) >= 0)
			loadmodule(lm[i]);
		else {
			s = smprint("/sys/lib/acid/%s", lm[i]);
			loadmodule(s);
			free(s);
		}
	}

	userinit();
	varsym();

	l = look("acidmap");
	if(l && l->proc) {
		n = an(ONAME, ZN, ZN);
		n->sym = l;
		n = an(OCALL, n, ZN);
		execute(n);
	}

	interactive = 1;
	initialising = 0;
	line = 1;

	notify(catcher);

	for(;;) {
		if(setjmp(err)) {
			Binit(&bioout, 1, OWRITE);
			unwind();
		}
		stacked = 0;

		Bprint(bout, "acid: ");

		if(yyparse() != 1)
			die();
		restartio();

		unwind();
	}
	/* not reached */
}
示例#9
0
void OnInit()
{
	GL_CHECK_ERRORS
	//generate the checker texture
	GLubyte data[128][128]={0};
	for(int j=0;j<128;j++) {
		for(int i=0;i<128;i++) {
			data[i][j]=(i<=64 && j<=64 || i>64 && j>64 )?255:0;
		}
	}
	//generate texture object
	glGenTextures(1, &checkerTextureID);
	glActiveTexture(GL_TEXTURE0);
	glBindTexture(GL_TEXTURE_2D, checkerTextureID);
	//set texture parameters
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);

	GL_CHECK_ERRORS

	//set maximum aniostropy setting
	GLfloat largest_supported_anisotropy;
	glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &largest_supported_anisotropy);
	glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, largest_supported_anisotropy);

	//set mipmap base and max level
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 4);

	//allocate texture object
	glTexImage2D(GL_TEXTURE_2D,0,GL_RED, 128, 128, 0, GL_RED, GL_UNSIGNED_BYTE, data);

	//generate mipmaps
	glGenerateMipmap(GL_TEXTURE_2D);

	GL_CHECK_ERRORS

	//create a textured plane object
	checker_plane = new Graphics::CTexturedPlane();

	GL_CHECK_ERRORS

	//setup camera
	//setup the camera position and look direction
	Vector3 p = Vector3(5, 5, 5);
	cam.SetPosition(p);
	Vector3 look(p);
	look.normalize();

	//rotate the camera for proper orientation
	float yaw = glm::degrees(float(atan2(look.z, look.x)+Math::M_PI));
	float pitch = glm::degrees(asin(look.y));
	rX = yaw;
	rY = pitch;
	cam.Rotate(rX,rY,0);

	std::cout << "initialization completed" << std::endl;

}
示例#10
0
文件: look.c 项目: coyizumi/cs111
int
main(int argc, char *argv[])
{
	struct stat sb;
	int ch, fd, match;
	wchar_t termchar;
	unsigned char *back, *front;
	unsigned const char *file;
	wchar_t *key;

	(void) setlocale(LC_CTYPE, "");

	file = _path_words;
	termchar = L'\0';
	while ((ch = getopt(argc, argv, "dft:")) != -1)
		switch(ch) {
		case 'd':
			dflag = 1;
			break;
		case 'f':
			fflag = 1;
			break;
		case 't':
			if (mbrtowc(&termchar, optarg, MB_LEN_MAX, NULL) !=
			    strlen(optarg))
				errx(2, "invalid termination character");
			break;
		case '?':
		default:
			usage();
		}
	argc -= optind;
	argv += optind;

	if (argc == 0)
		usage();
	if (argc == 1) 			/* But set -df by default. */
		dflag = fflag = 1;
	key = prepkey(*argv++, termchar);
	if (argc >= 2)
		file = *argv++;

	match = 1;

	do {
		if ((fd = open(file, O_RDONLY, 0)) < 0 || fstat(fd, &sb))
			err(2, "%s", file);
		if ((uintmax_t)sb.st_size > (uintmax_t)SIZE_T_MAX)
			errx(2, "%s: %s", file, strerror(EFBIG));
		if (sb.st_size == 0) {
			close(fd);
			continue;
		}
		if ((front = mmap(NULL, (size_t)sb.st_size, PROT_READ, MAP_SHARED, fd, (off_t)0)) == MAP_FAILED)
			err(2, "%s", file);
		back = front + sb.st_size;
		match *= (look(key, front, back));
		close(fd);
	} while (argc-- > 2 && (file = *argv++));

	exit(match);
}
示例#11
0
void            salle05()
{
  int           action;
  int           randmob;
  int           randmuni;
  int           randmedic;


  action = 0;
  g_map[2][0].visited = 1;
  g_map[2][0].content = 1;
  look();
  srand(time(NULL));
  randmob = rand();
  randmuni = rand();
  randmedic = rand();
  MUNI_MAP = 0;
  MEDIC_MAP = 0;

  if (randmedic%10 == 0)
    {
      MEDIC_MAP = 1;
    }
  if ((randmob%4 == 0) && (ARME_EQUIP > 0))
    {
      start_battle();
    }
  if ((randmuni%4 == 0))
    {
      MUNI_MAP = 4;
    }
  while (action == 0)
    {
      /*On propose ici le prompt au joueur*/
      action = readline();
      /*Traitement de laction :*/
      if (action == 2)
        {
	  my_putstr("\nje traverse un petit couloir etroit. Je commence a avoir sacrementpeur...\n\n");
	      g_map[2][0].content = 0;
	      SALLE = 6;
	      salle06();
	}
      if (action == 4)
        {
	  my_putstr("\nOn retourne vers le cadavre du sergent, vous etes sur de vouloir vraiment y retourner ? Moi personnelement cela ne me plait pas.");
	  g_map[2][0].content = 0;
	  SALLE = 8;
	  salle08();
	}
      if (action == 5)
        {
          prendre();
	  action = 0;
        }
      if ((action == 1) || (action == 3))
        {
	  erreur_depla();
	  action = 0;
        }
    }
}
示例#12
0
void
body(void)
{
	char *s;
	int t;

Next:
	if(pos >= epos)
		return;

	if(got("\n") || got("\r\n"))
		indent = -1;
	if(got("\n") || got("\r\n")){
		string("<br>");
		while(got("\n") || got("\r\n"))
			;
	}

	if(indent == -1){
		indent = 0;
		for(;;){
			if(got(" "))
				indent++;
			else if(got("\t")){
				indent += 8;
				indent %= 8;
			}
			else break;
		}

		if(intable && look("||", look("\n", nil)) == nil){
			string("</table>");
			intable = 0;
		}

		string("\n");
		if((indent < inlist) || (indent < inquote))
			return;

		while(indent > 0){
			if(pos >= epos)
				return;
			if(got("*") || got("#")){
				s = pos-1;
				eatspace();
				if(indent > inlist){
					if(*s == '*')
						string("<ul><li>");
					else
						string("<ol><li>");
					t = inlist;
					inlist = indent;
					body();
					inlist = t;
					if(*s == '*')
						string("</li></ul>");
					else
						string("</li></ol>");
				} else {
					string("</li><li>");
					break;
				}
			} else if(indent > inquote){
				string("<blockquote>");
				t = inquote;
				inquote = indent;
				body();
				inquote = t;
				string("</blockquote>");
			} else
				break;
		}

		if(indent == 0){
			if(got("#")){
				if((pos = look("\n", nil)) == nil)
					pos = epos;
				goto Next;
			}
			if(heading())
				goto Next;
			if(got("----")){
				while(got("-"))
					;
				string("<hr>");
				goto Next;
			}
		}
	}

	if(got("`")){
		if(s = look("`", nil)){
			escape(s);
			pos = s+1;
		} else
			string("`");
	}
	else if(got("<")){
		string("<");
		if(s = look(">", nil)){
			s++;
			output(pos, s - pos);
			pos = s;
		}
	}
	else if(got("[")){
		if(s = look("]", nil)){
			link(s);
			pos = s+1;
		} else
			string("[");
	}
	else if(tag("*", "b") ||
		tag("_", "i") ||
		tag("^", "sup") ||
		tag(",,", "sub") ||
		tag("~~", "strike")){
	}
	else if(got("{{{")){
		if(s = look("}}}", nil)){
			if(look("\n", s)){
				string("<pre>");
				escape(s);
				string("</pre>");
			} else {
				string("<tt>");
				escape(s);
				string("</tt>");
			}
			pos = s+3;
		} else
			string("{{{");
	}
	else if(got("||")){
		if(s = look("||", look("\n", nil))){
			eatspace();
			switch(intable){
			case 0:	string("<table>");
				intable++;
			case 1:	string("<tr>");
				intable++;
			}
			string("<td>");
			ebody(s);
			string("</td>");
		} else if(intable){
			string("</tr>");
			intable = 1;
		}
	}
	else if(match("http://"))
		link(nil);
	else if(match("https://"))
		link(nil);
	else if(match("ftp://"))
		link(nil);
	else{
		output(pos, 1);
		pos++;
	}
	goto Next;
}
/*
 * quaff:
 *	Quaff a potion from the pack
 */
quaff()
{
    register THING *obj, *th;
    register bool discardit = FALSE;

    obj = get_item("quaff", POTION);
    /*
     * Make certain that it is somethings that we want to drink
     */
    if (obj == NULL)
	return;
    if (obj->o_type != POTION)
    {
	if (!terse)
	    msg("yuk! Why would you want to drink that?");
	else
	    msg("that's undrinkable");
	return;
    }
    if (obj == cur_weapon)
	cur_weapon = NULL;

    /*
     * Calculate the effect it has on the poor guy.
     */
    switch (obj->o_which)
    {
	case P_CONFUSE:
	    p_know[P_CONFUSE] = TRUE;
	    if (!on(player, ISHUH))
	    {
		if (on(player, ISHUH))
		    lengthen(unconfuse, rnd(8)+HUHDURATION);
		else
		    fuse(unconfuse, 0, rnd(8)+HUHDURATION, AFTER);
		player.t_flags |= ISHUH;
		msg("wait, what's going on here. Huh? What? Who?");
	    }
	when P_POISON:
	    p_know[P_POISON] = TRUE;
	    if (!ISWEARING(R_SUSTSTR))
	    {
		chg_str(-(rnd(3)+1));
		msg("you feel very sick now");
	    }
	    else
		msg("you feel momentarily sick");
	when P_HEALING:
	    p_know[P_HEALING] = TRUE;
	    if ((pstats.s_hpt += roll(pstats.s_lvl, 4)) > max_hp)
		pstats.s_hpt = ++max_hp;
	    sight();
	    msg("you begin to feel better");
	when P_STRENGTH:
	    p_know[P_STRENGTH] = TRUE;
	    chg_str(1);
	    msg("you feel stronger, now.  What bulging muscles!");
	when P_MFIND:
	    player.t_flags |= SEEMONST;
	    fuse(turn_see, TRUE, HUHDURATION, AFTER);
	    if (mlist == NULL)
		msg("you have a strange feeling for a moment");
	    else
		p_know[P_MFIND] |= turn_see(FALSE);
	when P_TFIND:
	    /*
	     * Potion of magic detection.  Show the potions and scrolls
	     */
	    if (lvl_obj != NULL)
	    {
		register THING *tp;
		register bool show;

		show = FALSE;
		wclear(hw);
		for (tp = lvl_obj; tp != NULL; tp = next(tp))
		{
		    if (is_magic(tp))
		    {
			show = TRUE;
			mvwaddch(hw, tp->o_pos.y, tp->o_pos.x, MAGIC);
			p_know[P_TFIND] = TRUE;
		    }
		}
		for (th = mlist; th != NULL; th = next(th))
		{
		    for (tp = th->t_pack; tp != NULL; tp = next(tp))
		    {
			if (is_magic(tp))
			{
			    show = TRUE;
			    mvwaddch(hw, th->t_pos.y, th->t_pos.x, MAGIC);
			    p_know[P_TFIND] = TRUE;
			}
		    }
		}
		if (show)
		{
		    show_win(hw, 
			"You sense the presence of magic on this level.--More--");
		    break;
		}
	    }
	    msg("you have a strange feeling for a moment, then it passes");
	when P_PARALYZE:
	    p_know[P_PARALYZE] = TRUE;
	    no_command = HOLDTIME;
	    player.t_flags &= ~ISRUN;
	    msg("you can't move");
	when P_SEEINVIS:
	    if (!on(player, CANSEE))
	    {
		fuse(unsee, 0, SEEDURATION, AFTER);
		look(FALSE);
		invis_on();
	    }
	    sight();
	    msg("this potion tastes like %s juice", fruit);
	when P_RAISE:
	    p_know[P_RAISE] = TRUE;
	    msg("you suddenly feel much more skillful");
	    raise_level();
	when P_XHEAL:
	    p_know[P_XHEAL] = TRUE;
	    if ((pstats.s_hpt += roll(pstats.s_lvl, 8)) > max_hp)
	    {
		if (pstats.s_hpt > max_hp + pstats.s_lvl + 1)
		    ++max_hp;
		pstats.s_hpt = ++max_hp;
	    }
	    sight();
	    msg("you begin to feel much better");
	when P_HASTE:
	    p_know[P_HASTE] = TRUE;
	    if (add_haste(TRUE))
		msg("you feel yourself moving much faster");
	when P_RESTORE:
	    if (ISRING(LEFT, R_ADDSTR))
		add_str(&pstats.s_str, -cur_ring[LEFT]->o_ac);
	    if (ISRING(RIGHT, R_ADDSTR))
		add_str(&pstats.s_str, -cur_ring[RIGHT]->o_ac);
	    if (pstats.s_str < max_stats.s_str)
		pstats.s_str = max_stats.s_str;
	    if (ISRING(LEFT, R_ADDSTR))
		add_str(&pstats.s_str, cur_ring[LEFT]->o_ac);
	    if (ISRING(RIGHT, R_ADDSTR))
		add_str(&pstats.s_str, cur_ring[RIGHT]->o_ac);
	    msg("hey, this tastes great.  It make you feel warm all over");
	when P_BLIND:
	    p_know[P_BLIND] = TRUE;
	    if (!on(player, ISBLIND))
	    {
		player.t_flags |= ISBLIND;
		fuse(sight, 0, SEEDURATION, AFTER);
		look(FALSE);
	    }
	    msg("a cloak of darkness falls around you");
	when P_NOP:
	    msg("this potion tastes extremely dull");
	otherwise:
	    msg("what an odd tasting potion!");
	    return;
    }
    status();
    /*
     * Throw the item away
     */
    inpack--;
    if (obj->o_count > 1)
	obj->o_count--;
    else
    {
	detach(pack, obj);
        discardit = TRUE;
    }

    call_it(p_know[obj->o_which], &p_guess[obj->o_which]);

    if (discardit)
	discard(obj);
}
示例#14
0
read_scroll()
{
    register struct object *obj;
    register struct linked_list *item;
    register struct room *rp;
    register int i,j;
    register char ch, nch;
    register struct linked_list *titem;
    char buf[80];

    item = get_item("run", SCROLL);
    if (item == NULL)
	return;
    obj = (struct object *) ldata(item);
    if (obj->o_type != SCROLL)
    {
	if (!terse)
	    msg("There is no way to run it");
	else
	    msg("Nothing to run");
	return;
    }
    msg("As you run the device, it self-destructs.");
    /*
     * Calculate the effect it has on the poor guy.
     */
    if (obj == cur_weapon)
	cur_weapon = NULL;
    switch(obj->o_which)
    {
	when S_CONFUSE:
	    /*
	     * Scroll of monster confusion.  Give him that power.
	     */
	    msg("Your hands begin to glow red");
	    player.t_flags |= CANHUH;
	when S_LIGHT:
	    s_know[S_LIGHT] = TRUE;
	    if ((rp = roomin(&hero)) == NULL)
		msg("The corridor glows and then fades");
	    else
	    {
		addmsg("The room is lit");
		if (!terse)
		    addmsg(" by a shimmering blue light.");
		endmsg();
		rp->r_flags &= ~ISDARK;
		/*
		 * Light the room and put the player back up
		 */
		light(&hero);
		mvwaddch(cw, hero.y, hero.x, PLAYER);
	    }
	when S_ARMOR:
	    if (cur_armor != NULL)
	    {
		msg("Your armor glows faintly for a moment");
		cur_armor->o_ac--;
		cur_armor->o_flags &= ~ISCURSED;
	    }
	when S_HOLD:
	    /*
	     * Hold monster scroll.  Stop all monsters within two spaces
	     * from chasing after the hero.
	     */
	    {
		register int x,y;
		register struct linked_list *mon;

		for (x = hero.x-2; x <= hero.x+2; x++)
		    for (y = hero.y-2; y <= hero.y+2; y++)
			if (y > 0 && x > 0 && isupper(mvwinch(mw, y, x)))
			    if ((mon = find_mons(y, x)) != NULL)
			    {
				register struct thing *th;

				th = (struct thing *) ldata(mon);
				th->t_flags &= ~ISRUN;
				th->t_flags |= ISHELD;
			    }
	    }
	when S_SLEEP:
	    /*
	     * Scroll which makes you fall asleep
	     */
	    s_know[S_SLEEP] = TRUE;
	    msg("You fall asleep.");
	    no_command += 4 + rnd(SLEEPTIME);
	when S_CREATE:
	    /*
	     * Create a monster
	     * First look in a circle around him, next try his room
	     * otherwise give up
	     */
	    {
		register int x, y;
		register bool appear = 0;
		coord mp;

		/*
		 * Search for an open place
		 */
		for (y = hero.y; y <= hero.y+1; y++)
		    for (x = hero.x; x <= hero.x+1; x++)
		    {
			/*
			 * Don't put a monster in top of the player.
			 */
			if (y == hero.y && x == hero.x)
			    continue;
			/*
			 * Or anything else nasty
			 */
			if (step_ok(winat(y, x)))
			{
			    if (rnd(++appear) == 0)
			    {
				mp.y = y;
				mp.x = x;
			    }
			}
		    }
		if (appear)
		{
		    titem = new_item(sizeof (struct thing));
		    new_monster(titem, randmonster(FALSE), &mp);
		}
		else
		    msg("You hear a faint cry of anguish in the distance.");
	    }
	when S_IDENT:
	    /*
	     * Identify, let the rogue figure something out
	     */
	    msg("This nanodevice is an identify nanodevice");
	    s_know[S_IDENT] = TRUE;
	    whatis();
	when S_MAP:
	    /*
	     * Scroll of magic mapping.
	     */
	    s_know[S_MAP] = TRUE;
	    msg("Oh, now this nanodevice has a map on it.");
	    overwrite(stdscr, hw);
	    /*
	     * Take all the things we want to keep hidden out of the window
	     */
	    for (i = 0; i < lines(); i++)
		for (j = 0; j < cols(); j++)
		{
		    switch (nch = ch = mvwinch(hw, i, j))
		    {
			case SECRETDOOR:
			    mvaddch(i, j, nch = DOOR);
			case '-':
			case '|':
			case DOOR:
			case PASSAGE:
			case ' ':
			case STAIRS:
			    if (mvwinch(mw, i, j) != ' ')
			    {
				register struct thing *it;

				it = (struct thing *) ldata(find_mons(i, j));
				if (it->t_oldch == ' ')
				    it->t_oldch = nch;
			    }
			    break;
			default:
			    nch = ' ';
		    }
		    if (nch != ch)
			waddch(hw, nch);
		}
	    /*
	     * Copy in what he has discovered
	     */
	    overlay(cw, hw);
	    /*
	     * And set up for display
	     */
	    overwrite(hw, cw);
	when S_GFIND:
	    /*
	     * Potion of gold detection
	     */
	    {
		int gtotal = 0;

		wclear(hw);
		for (i = 0; i < MAXROOMS; i++)
		{
		    gtotal += rooms[i].r_goldval;
		    if (rooms[i].r_goldval != 0 &&
			mvwinch(stdscr, rooms[i].r_gold.y, rooms[i].r_gold.x)
			== GOLD)
			mvwaddch(hw,rooms[i].r_gold.y,rooms[i].r_gold.x,GOLD);
		}
		if (gtotal)
		{
		    s_know[S_GFIND] = TRUE;
		    show_win(hw,
			"You connect to the Net and detect credits locations.--More--");
		}
		else msg("You begin to feel a pull downward");
	    }
	when S_TELEP:
	    /*
	     * Scroll of teleportation:
	     * Make him dissapear and reappear
	     */
	    {
		int rm;
		struct room *cur_room;

		cur_room = roomin(&hero);
		rm = teleport();
		if (cur_room != &rooms[rm])
		    s_know[S_TELEP] = TRUE;
	    }
	when S_ENCH:
	    if (cur_weapon == NULL)
		msg("You feel a strange sense of loss.");
	    else
	    {
		cur_weapon->o_flags &= ~ISCURSED;
		if (rnd(100) > 50)
		    cur_weapon->o_hplus++;
		else
		    cur_weapon->o_dplus++;
		msg("Your %s glows blue for a moment.", w_names[cur_weapon->o_which]);
	    }
	when S_SCARE:
	    /*
	     * A monster will refuse to step on a scare monster scroll
	     * if it is dropped.  Thus reading it is a mistake and produces
	     * laughter at the poor rogue's boo boo.
	     */
	    msg("You hear maniacal laughter in the distance.");
	when S_REMOVE:
	    if (cur_armor != NULL)
		cur_armor->o_flags &= ~ISCURSED;
	    if (cur_weapon != NULL)
		cur_weapon->o_flags &= ~ISCURSED;
	    if (cur_ring[LEFT] != NULL)
		cur_ring[LEFT]->o_flags &= ~ISCURSED;
	    if (cur_ring[RIGHT] != NULL)
		cur_ring[RIGHT]->o_flags &= ~ISCURSED;
	    msg("You feel as if somebody is watching over you.");
	when S_AGGR:
	    /*
	     * This scroll aggravates all the monsters on the current
	     * level and sets them running towards the hero
	     */
	    aggravate();
	    msg("You hear a high pitched humming noise.");
	when S_NOP:
	    msg("This nanodevice seems to be empty.");
	when S_GENOCIDE:
	    msg("You have been granted the boon of genocide");
	    genocide();
	    s_know[S_GENOCIDE] = TRUE;
	otherwise:
	    msg("What a puzzling nanodevice!");
	    return;
    }
    look(TRUE);	/* put the result of the scroll on the screen */
    status();
    if (s_know[obj->o_which] && s_guess[obj->o_which])
    {
	cfree(s_guess[obj->o_which]);
	s_guess[obj->o_which] = NULL;
    }
    else if (!s_know[obj->o_which] && askme && s_guess[obj->o_which] == NULL)
    {
	msg(terse ? "Call it: " : "What do you want to call it? ");
	if (get_str(buf, cw) == NORM)
	{
	    s_guess[obj->o_which] = malloc((unsigned int) strlen(buf) + 1);
	    strcpy(s_guess[obj->o_which], buf);
	}
    }
    /*
     * Get rid of the thing
     */
    inpack--;
    if (obj->o_count > 1)
	obj->o_count--;
    else
    {
	detach(pack, item);
        discard(item);
    }
}
示例#15
0
文件: app.c 项目: youka2/fx
void loop(void)
{
	const float spd1=30.0f*dt();
	const float spd2=15.0f*dt();

	float r=0.0f;
	float dc=0.0f, ds=0.0f;
	float tc=0.0f, ts=0.0f;

	/*viewport(0,0,nsw,nsh);*/
	use_basic();
	send_lpview(pview);

	if(mm() || mw()!=0.0f)
	{
		if(mm())
		{
			dir+=mx()*spd1;
			if(dir<-0.0f)
			{
				dir+=360.0f;
				ndir+=360.0f;
			}
			else if(dir>360.0f)
			{
				dir-=360.0f;
				ndir-=360.0f;
			}

			tilt-=my()*spd1;
			if(tilt<0.001f) tilt=0.001f;
			else if(tilt>100.0f) tilt=100.0f;
		}

		if(mw()!=0.0f)
		{
			zoom-=mw();
			if(zoom<7.0f) zoom=7.0f;
			else if(zoom>12.0f) zoom=12.0f;
		}
	}
	if(mp(3)) zoom=10.0f;

	ndir-=(ndir-dir)*spd2;
	r=d2r(ndir);
	dc=cosf(r);
	ds=sinf(r);

	ntilt-=(ntilt-tilt)*spd2;
	r=d2r(ntilt);
	tc=cosf(r);
	ts=sinf(r);

	nzoom-=(nzoom-zoom)*spd2;

	look(view,v3(ds*ts*nzoom,dc*ts*nzoom,3.0f+(tc*nzoom)),v3(0.0f,0.0f,3.0f));
	mult(pview,proj,view);

	send_pview(pview);

	/* ----- */
	use_fb(fbos[0]);
	clear();
	/* ----- */
	use_tex(area_tex);
	/* ----- */
	draw_vbo(&area_mod);
	use_fb(0);

	blit_fb(fbos[0],fbos[1],nsw,nsh);
	/* ----- */

	use_fb(fbos[2]);
	set_drawbufs(2);
	clear();
	draw_vbo(&area_mod);
	use_fb(0);

	use_mblur();
	use_tex(texs[0]); /* ----- */
	active_tex(GL_TEXTURE1,texs[2]);
	default_tex();

	use_fb(fbos[3]);
	set_drawbufs(1);
	clear();
	quad();
	use_fb(0);

	active_tex(GL_TEXTURE1,0);
	default_tex();

	/*viewport(0,0,sw,sh);*/
	use_vig();
	use_tex(texs[3]);

	clear();
	quad();

	if(kp(SDL_SCANCODE_DELETE) || kp(SDL_SCANCODE_ESCAPE))
		quit();
}
示例#16
0
//*************************************************************************************************************
void Render(float alpha, float elapsedtime)
{
	LPDIRECT3DSURFACE9 oldtarget = NULL;

	D3DXMATRIX		vp, inv, tmp1, tmp2;
	D3DXVECTOR3		axis(0, 1, 0);
	D3DXVECTOR3		eye(0, 0, -5);
	D3DXVECTOR3		look(0, 0, 0);
	D3DXVECTOR3		up(0, 1, 0);

	D3DXVECTOR2		cangle	= cameraangle.smooth(alpha);
	D3DXVECTOR2		oangle	= objectangle.smooth(alpha);
	float			expo	= exposure.smooth(alpha);

	D3DXMatrixRotationYawPitchRoll(&world, cangle.x, cangle.y, 0);
	D3DXVec3TransformCoord(&eye, &eye, &world);

	D3DXMatrixLookAtLH(&view, &eye, &look, &up);
	D3DXMatrixMultiply(&vp, &view, &proj);
	D3DXMatrixInverse(&inv, NULL, &view);

	memcpy(&eye, inv.m[3], 3 * sizeof(float));

	if( mesh == mesh1 )
	{
		// skullocc
		D3DXMatrixScaling(&world, 0.4f, 0.4f, 0.4f);
		world._42 = -1.5f;
	}
	else if( mesh == mesh2 )
	{
		// knot
		D3DXMatrixScaling(&world, 0.8f, 0.8f, 0.8f);
	}
	else
	{
		// teapot
		D3DXMatrixScaling(&world, 1.5f, 1.5f, 1.5f);
	}

	D3DXMatrixRotationYawPitchRoll(&tmp1, oangle.x, oangle.y, 0);
	D3DXMatrixMultiply(&world, &world, &tmp1);
	D3DXMatrixInverse(&inv, NULL, &world);

	fresnel->SetVector("eyePos", (D3DXVECTOR4*)&eye);
	fresnel->SetMatrix("matWorld", &world);
	fresnel->SetMatrix("matWorldInv", &inv);
	fresnel->SetMatrix("matViewProj", &vp);

	D3DXMatrixScaling(&world, 20, 20, 20);
	skyeffect->SetMatrix("matWorld", &world);

	D3DXMatrixIdentity(&world);
	skyeffect->SetMatrix("matWorldSky", &world);
	skyeffect->SetMatrix("matViewProj", &vp);

	memcpy(tmpvert, quadvertices, 36 * sizeof(float));

	if( SUCCEEDED(device->BeginScene()) )
	{
		device->SetRenderState(D3DRS_SRGBWRITEENABLE, false);
		device->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_WRAP);
		device->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_WRAP);

		// STEP 1: render sky
		device->GetRenderTarget(0, &oldtarget);

		if( firstframe )
		{
			device->SetRenderTarget(0, aftersurfaces[0]);
			device->Clear(0, NULL, D3DCLEAR_TARGET, 0, 1.0f, 0);

			device->SetRenderTarget(0, aftersurfaces[1]);
			device->Clear(0, NULL, D3DCLEAR_TARGET, 0, 1.0f, 0);

			device->SetRenderTarget(0, avglumsurfaces[4]);
			device->Clear(0, NULL, D3DCLEAR_TARGET, 0x11111111, 1.0f, 0);

			device->SetRenderTarget(0, avglumsurfaces[5]);
			device->Clear(0, NULL, D3DCLEAR_TARGET, 0x11111111, 1.0f, 0);

			firstframe = false;
		}

		device->SetRenderTarget(0, scenesurface);
		device->Clear(0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER, 0xff6694ed, 1.0f, 0);
		device->SetRenderState(D3DRS_ZENABLE, FALSE);

		device->SetTexture(0, skytexture);

		skyeffect->Begin(NULL, 0);
		skyeffect->BeginPass(0);
		{
			skymesh->DrawSubset(0);
		}
		skyeffect->EndPass();
		skyeffect->End();
		
		device->SetRenderState(D3DRS_ZENABLE, TRUE);

		// STEP 2: render object
		device->SetTexture(0, texture);
		device->SetTexture(1, fresneltexture);
		device->SetTexture(2, skytexture);
		device->SetTexture(3, roughspecular);

		fresnel->Begin(NULL, 0);
		fresnel->BeginPass(0);
		{
			mesh->DrawSubset(0);
		}
		fresnel->EndPass();
		fresnel->End();

		device->SetVertexDeclaration(vertexdecl);

		// STEP 3: measure average luminance
		MeasureLuminance();

		// STEP 4: adapt luminance to eye
		AdaptLuminance(elapsedtime);

		// STEP 5: bright pass
		BrightPass();

		// STEP 6: downsample bright pass texture
		DownSample();

		// STEP 7: blur downsampled textures
		Blur();

		// STEP 8: ghost
		LensFlare();

		// STEP 9: star
		Star();

		// STEP 10: final combine
		hdreffect->SetTechnique("final");
		hdreffect->SetFloat("targetluminance", targetluminance);

		device->SetRenderTarget(0, oldtarget);
		device->SetTexture(0, scenetarget);			// scene
		device->SetTexture(1, blurtargets[0]);		// blur
		device->SetTexture(2, blurtargets[1]);		// star
		device->SetTexture(3, ghosttargets[0]);		// ghost
		device->SetTexture(4, afterimages[1 - afterimagetex]);

		device->SetSamplerState(0, D3DSAMP_ADDRESSU, D3DTADDRESS_WRAP);
		device->SetSamplerState(0, D3DSAMP_ADDRESSV, D3DTADDRESS_WRAP);
		device->SetRenderState(D3DRS_SRGBWRITEENABLE, true);

		oldtarget->Release();

		hdreffect->Begin(NULL, 0);
		hdreffect->BeginPass(0);
		{
			device->DrawPrimitiveUP(D3DPT_TRIANGLELIST, 2, quadvertices, sizeof(D3DXVECTOR4) + sizeof(D3DXVECTOR2));
		}
		hdreffect->EndPass();
		hdreffect->End();

		if( drawhelp )
		{
			// render text
			device->SetFVF(D3DFVF_XYZRHW|D3DFVF_TEX1);
			device->SetRenderState(D3DRS_ZENABLE, FALSE);
			device->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
			device->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
			device->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);

			device->SetTexture(0, text);
			device->DrawPrimitiveUP(D3DPT_TRIANGLELIST, 2, textvertices, 6 * sizeof(float));

			device->SetRenderState(D3DRS_ALPHABLENDENABLE, FALSE);
			device->SetRenderState(D3DRS_ZENABLE, TRUE);
		}

		// clean up
		device->SetTexture(1, NULL);
		device->SetTexture(2, NULL);
		device->SetTexture(3, NULL);
		device->SetTexture(4, NULL);
		device->SetTexture(5, NULL);

		device->EndScene();
	}

	device->Present(NULL, NULL, NULL, NULL);
}
示例#17
0
void CullingComponent::cameraVsNode(Int2 min, Int2 max, AttributePtr<Attribute_Camera> camera)
{
	if((max.x-min.x > 0) && (max.y-min.y > 0))
	{
		float fovx = atan(camera->aspectRatio*tan(camera->fieldOfView));
		float length = sqrt(camera->look.x*camera->look.x+camera->look.z*camera->look.z);
		Float2 pos(camera->ptr_spatial->ptr_position->position.x,camera->ptr_spatial->ptr_position->position.z);
		Float2 look(camera->look.x/length,camera->look.z/length);

		float l = camera->look.y; 
		float f = camera->fieldOfView;
		float viewbehind = (camera->fieldOfView/2.0f + PI/4 + abs(asin(camera->look.y))) - PI/2; 
		if(viewbehind > 0)
		{
			viewbehind = tan(viewbehind)*max(abs(camera->ptr_spatial->ptr_position->position.y - yminmax.x),abs(camera->ptr_spatial->ptr_position->position.y - yminmax.y));
			Float2 lb(look.x*viewbehind,look.y*viewbehind);
			pos = pos - lb;
		}

		
		
		Float2 p[] = {Float2(min.x-0.5f-pos.x,min.y-0.5f-pos.y),
					  Float2(min.x-0.5f-pos.x,max.y+0.5f-pos.y),
					  Float2(max.x+0.5f-pos.x,min.y-0.5f-pos.y),
					  Float2(max.x+0.5f-pos.x,max.y+0.5f-pos.y)};
		bool hit = false;
		for(unsigned int i = 0; i < 4; i++)
		{
			float angle = acos((look.x*p[i].x+look.y*p[i].y) / (look.length()*p[i].length()));
			///SMOETHING HERE
			if(angle < fovx)
			{
				hit = true;
				break;
			}
		}
		if(!hit)
		{
			if((min.x < pos.x && pos.x < max.x) && (min.y < pos.y && pos.y < max.y))
			{
				hit = true;
			}
		}

		if(hit)
		{
			if( (max.x-min.x)*(max.y-min.y) <= 1) // if less than 4 grids left then uncull
			{
				int width = max_.x-min_.x;
				for(int i = min.y; i < max.y; i++)
				{
					for(int j = min.x; j < max.x; j++)
					{
						int index = (j-min_.x) + (i-min_.y)*width;
						unsigned int size = nodes_[index].size();
						for(unsigned int k = 0; k < size; k++)
						{
							nodes_[index].at(k)->culling.setBool(camera.index(),true);
						}
					}
				}
			}
			else // otherwise subdivide
			{
				int width = (max.x - min.x)/2;
				int height = (max.y - min.y)/2;
				cameraVsNode(min,Int2(min.x+width,min.y+height),camera);
				cameraVsNode(Int2(min.x+width,min.y),Int2(max.x,min.y+height),camera);
				cameraVsNode(Int2(min.x,min.y+height),Int2(min.x+width,max.y),camera);
				cameraVsNode(Int2(min.x+width,min.y+height),max,camera);
			}
		}
	}
}
示例#18
0
void Camera::lookAt(const Vector3& target)
{
	look(target - position);
}
示例#19
0
int Java5Lex::getNextLexeme() {
  int  state           = 0;     // Current state
  int  lastAcceptState = 0;     // Most recently seen accept state
  int  prevState;               // State before lastAcceptState
  int  nextState;               // Next state
  unsigned int  lookahead;      // Lookahead character
  int  anchor;                  // Anchor mode for most recently seen accepting state

  unTerminateLexeme();
  initMore();
  markStart();

  for(;;) {
    // Check end of file. If there's an unprocessed accepting state,
    // lastAcceptState will be nonzero. In this case, ignore EOF for now so
    // that you can do the accepting action; otherwise, try to open another
    // file and return if you can't.

    for(;;) {
      if(((int)(lookahead = look(1))) != EOF) {
        assert(lookahead < 256);
        nextState = nextState(state, lookahead);
        break;
      } else if(lastAcceptState != 0) {   // still something to do
        nextState = -1;
        break;
      } else if(isWrap()) {               // another file?
        terminateLexeme();
        return 0;                         // EOI
      }
    }
    if(m_debug) {
      debugState(_T("--------"), state, lookahead);
    }

    if(nextState != -1) {
      if(advance() < 0) {                 // Buffer full
        const TCHAR *tooLongMessage = _T("Lexeme too long. Discarding extra characters.");
        error(getPos(), tooLongMessage);

        flush(true);

        if(m_debug) {
          debug(tooLongMessage);
          debugState(_T("--------"), state, look(1));
        }
      }

      if(anchor = lexAccept[nextState]) { // Is this an accept state
        prevState       = state;
        lastAcceptState = nextState;
        markEnd();                        // Mark input at current character
      }                                   // A subsequent gotoMark() returns us to this position.
      state = nextState;
    } else if(lastAcceptState == 0) {     // illegal input
      error(getPos(), _istprint(lookahead)?_T("Ignore bad input:'%c'"):_T("Ignore bad input:%#x"),lookahead);

      if(m_debug) {
        debug(_T("Ignore bad input:'%c'"), lookahead);
      }

      advance();
    } else {
      if(m_debug) {
        debugState(_T("accept--"), lastAcceptState, lookahead);
      }

      gotoMark();                         // Back up to previous accept state
      if(anchor & ANCHOR_END) {           // If end anchor is active
        pushback(1);                      // Push back the CR or LF
      }
      if(anchor & ANCHOR_START) {         // If start anchor is active
        moveStart();                      // Skip the leading newline
      }
      terminateLexeme();                  // Null-terminate the string

      switch(lastAcceptState) {
      case 1:
#line 124 "C:\\mytools2015\\ParserGen\\java\\Java5.lex"
        ;
#line 94 "C:\\mytools2015\\parsergen\\lib\\lexgencpp.par"
        break;
      case 2:
#line 87 "C:\\mytools2015\\ParserGen\\java\\Java5.lex"
        return NOT;
#line 94 "C:\\mytools2015\\parsergen\\lib\\lexgencpp.par"
        break;
      case 3:
#line 108 "C:\\mytools2015\\ParserGen\\java\\Java5.lex"
        return MOD;
#line 94 "C:\\mytools2015\\parsergen\\lib\\lexgencpp.par"
        break;
      case 4:
#line 105 "C:\\mytools2015\\ParserGen\\java\\Java5.lex"
        return AND;
#line 94 "C:\\mytools2015\\parsergen\\lib\\lexgencpp.par"
        break;
      case 5:
#line 75 "C:\\mytools2015\\ParserGen\\java\\Java5.lex"
        return LPAR;
#line 94 "C:\\mytools2015\\parsergen\\lib\\lexgencpp.par"
        break;
      case 6:
#line 76 "C:\\mytools2015\\ParserGen\\java\\Java5.lex"
        return RPAR;
#line 94 "C:\\mytools2015\\parsergen\\lib\\lexgencpp.par"
        break;
      case 7:
#line 103 "C:\\mytools2015\\ParserGen\\java\\Java5.lex"
        return STAR;
#line 94 "C:\\mytools2015\\parsergen\\lib\\lexgencpp.par"
        break;
      case 8:
#line 101 "C:\\mytools2015\\ParserGen\\java\\Java5.lex"
        return PLUS;
#line 94 "C:\\mytools2015\\parsergen\\lib\\lexgencpp.par"
        break;
      case 9:
#line 82 "C:\\mytools2015\\ParserGen\\java\\Java5.lex"
        return COMMA;
#line 94 "C:\\mytools2015\\parsergen\\lib\\lexgencpp.par"
        break;
      case 10:
#line 102 "C:\\mytools2015\\ParserGen\\java\\Java5.lex"
        return MINUS;
#line 94 "C:\\mytools2015\\parsergen\\lib\\lexgencpp.par"
        break;
      case 11:
#line 83 "C:\\mytools2015\\ParserGen\\java\\Java5.lex"
        return DOT;
#line 94 "C:\\mytools2015\\parsergen\\lib\\lexgencpp.par"
        break;
      case 12:
#line 104 "C:\\mytools2015\\ParserGen\\java\\Java5.lex"
        return DIV;
#line 94 "C:\\mytools2015\\parsergen\\lib\\lexgencpp.par"
        break;
      case 13:
      case 58:
      case 61:
      case 64:
      case 66:
#line 39 "C:\\mytools2015\\ParserGen\\java\\Java5.lex"
        return INTEGERLITERAL;
#line 94 "C:\\mytools2015\\parsergen\\lib\\lexgencpp.par"
        break;
      case 14:
#line 90 "C:\\mytools2015\\ParserGen\\java\\Java5.lex"
        return COLON;
#line 94 "C:\\mytools2015\\parsergen\\lib\\lexgencpp.par"
        break;
      case 15:
#line 81 "C:\\mytools2015\\ParserGen\\java\\Java5.lex"
        return SEMICOLON;
#line 94 "C:\\mytools2015\\parsergen\\lib\\lexgencpp.par"
        break;
      case 16:
#line 85 "C:\\mytools2015\\ParserGen\\java\\Java5.lex"
        return LT;
#line 94 "C:\\mytools2015\\parsergen\\lib\\lexgencpp.par"
        break;
      case 17:
#line 84 "C:\\mytools2015\\ParserGen\\java\\Java5.lex"
        return ASSIGN;
#line 94 "C:\\mytools2015\\parsergen\\lib\\lexgencpp.par"
        break;
      case 18:
#line 86 "C:\\mytools2015\\ParserGen\\java\\Java5.lex"
        return GT;
#line 94 "C:\\mytools2015\\parsergen\\lib\\lexgencpp.par"
        break;
      case 19:
#line 89 "C:\\mytools2015\\ParserGen\\java\\Java5.lex"
        return QUESTION;
#line 94 "C:\\mytools2015\\parsergen\\lib\\lexgencpp.par"
        break;
      case 20:
#line 92 "C:\\mytools2015\\ParserGen\\java\\Java5.lex"
        return AT;
#line 94 "C:\\mytools2015\\parsergen\\lib\\lexgencpp.par"
        break;
      case 21:
#line 48 "C:\\mytools2015\\ParserGen\\java\\Java5.lex"
        return nameOrKeyWord(getText());
#line 94 "C:\\mytools2015\\parsergen\\lib\\lexgencpp.par"
        break;
      case 22:
#line 79 "C:\\mytools2015\\ParserGen\\java\\Java5.lex"
        return LB;
#line 94 "C:\\mytools2015\\parsergen\\lib\\lexgencpp.par"
        break;
      case 23:
#line 80 "C:\\mytools2015\\ParserGen\\java\\Java5.lex"
        return RB;
#line 94 "C:\\mytools2015\\parsergen\\lib\\lexgencpp.par"
        break;
      case 24:
#line 107 "C:\\mytools2015\\ParserGen\\java\\Java5.lex"
        return XOR;
#line 94 "C:\\mytools2015\\parsergen\\lib\\lexgencpp.par"
        break;
      case 25:
#line 77 "C:\\mytools2015\\ParserGen\\java\\Java5.lex"
        return LC;
#line 94 "C:\\mytools2015\\parsergen\\lib\\lexgencpp.par"
        break;
      case 26:
#line 106 "C:\\mytools2015\\ParserGen\\java\\Java5.lex"
        return OR;
#line 94 "C:\\mytools2015\\parsergen\\lib\\lexgencpp.par"
        break;
      case 27:
#line 78 "C:\\mytools2015\\ParserGen\\java\\Java5.lex"
        return RC;
#line 94 "C:\\mytools2015\\parsergen\\lib\\lexgencpp.par"
        break;
      case 28:
#line 88 "C:\\mytools2015\\ParserGen\\java\\Java5.lex"
        return COMPLEMENT;
#line 94 "C:\\mytools2015\\parsergen\\lib\\lexgencpp.par"
        break;
      case 29:
#line 96 "C:\\mytools2015\\ParserGen\\java\\Java5.lex"
        return NEQ;
#line 94 "C:\\mytools2015\\parsergen\\lib\\lexgencpp.par"
        break;
      case 30:
#line 43 "C:\\mytools2015\\ParserGen\\java\\Java5.lex"
        return STRINGLITERAL;
#line 94 "C:\\mytools2015\\parsergen\\lib\\lexgencpp.par"
        break;
      case 31:
#line 119 "C:\\mytools2015\\ParserGen\\java\\Java5.lex"
        return MODASSIGN;
#line 94 "C:\\mytools2015\\parsergen\\lib\\lexgencpp.par"
        break;
      case 32:
#line 97 "C:\\mytools2015\\ParserGen\\java\\Java5.lex"
        return ANDAND;
#line 94 "C:\\mytools2015\\parsergen\\lib\\lexgencpp.par"
        break;
      case 33:
#line 116 "C:\\mytools2015\\ParserGen\\java\\Java5.lex"
        return ANDASSIGN;
#line 94 "C:\\mytools2015\\parsergen\\lib\\lexgencpp.par"
        break;
      case 34:
#line 114 "C:\\mytools2015\\ParserGen\\java\\Java5.lex"
        return STARASSIGN;
#line 94 "C:\\mytools2015\\parsergen\\lib\\lexgencpp.par"
        break;
      case 35:
#line 99 "C:\\mytools2015\\ParserGen\\java\\Java5.lex"
        return PLUSPLUS;
#line 94 "C:\\mytools2015\\parsergen\\lib\\lexgencpp.par"
        break;
      case 36:
#line 112 "C:\\mytools2015\\ParserGen\\java\\Java5.lex"
        return PLUSASSIGN;
#line 94 "C:\\mytools2015\\parsergen\\lib\\lexgencpp.par"
        break;
      case 37:
#line 100 "C:\\mytools2015\\ParserGen\\java\\Java5.lex"
        return MINUSMINUS;
#line 94 "C:\\mytools2015\\parsergen\\lib\\lexgencpp.par"
        break;
      case 38:
#line 113 "C:\\mytools2015\\ParserGen\\java\\Java5.lex"
        return MINUSASSIGN;
#line 94 "C:\\mytools2015\\parsergen\\lib\\lexgencpp.par"
        break;
      case 39:
      case 59:
      case 62:
#line 41 "C:\\mytools2015\\ParserGen\\java\\Java5.lex"
        return FLOATLITERAL;
#line 94 "C:\\mytools2015\\parsergen\\lib\\lexgencpp.par"
        break;
      case 40:
#line 50 "C:\\mytools2015\\ParserGen\\java\\Java5.lex"
        { int i;
        							  SourcePosition startpos = getPos();
        							  while(i = input()) {
        							    if(i < 0) {
        							      flushBuf();  /* Discard lexeme. */
        							    } else if(i == '*' && look(1) == '/') {
        							     input();
        							     break;       /* Recognized comment.*/
        							    }
        							  }
        							  if(i == 0) {
        							    error( startpos,_T("End of file in comment\n") );
                                      }
        							}
#line 94 "C:\\mytools2015\\parsergen\\lib\\lexgencpp.par"
        break;
      case 41:
#line 65 "C:\\mytools2015\\ParserGen\\java\\Java5.lex"
        { int i;
        							  while(i = input()) {
        							    if(i < 0) {
        							      flushBuf();  /* Discard lexeme. */
        							    } else if(i == '\n') {
        							      break;
        							    }
                                      }
        							}
#line 94 "C:\\mytools2015\\parsergen\\lib\\lexgencpp.par"
        break;
      case 42:
#line 115 "C:\\mytools2015\\ParserGen\\java\\Java5.lex"
        return DIVASSIGN;
#line 94 "C:\\mytools2015\\parsergen\\lib\\lexgencpp.par"
        break;
      case 43:
#line 109 "C:\\mytools2015\\ParserGen\\java\\Java5.lex"
        return SHL;
#line 94 "C:\\mytools2015\\parsergen\\lib\\lexgencpp.par"
        break;
      case 44:
#line 94 "C:\\mytools2015\\ParserGen\\java\\Java5.lex"
        return LE;
#line 94 "C:\\mytools2015\\parsergen\\lib\\lexgencpp.par"
        break;
      case 45:
#line 93 "C:\\mytools2015\\ParserGen\\java\\Java5.lex"
        return EQ;
#line 94 "C:\\mytools2015\\parsergen\\lib\\lexgencpp.par"
        break;
      case 46:
#line 95 "C:\\mytools2015\\ParserGen\\java\\Java5.lex"
        return GE;
#line 94 "C:\\mytools2015\\parsergen\\lib\\lexgencpp.par"
        break;
      case 47:
#line 110 "C:\\mytools2015\\ParserGen\\java\\Java5.lex"
        return SSHR;
#line 94 "C:\\mytools2015\\parsergen\\lib\\lexgencpp.par"
        break;
      case 48:
#line 118 "C:\\mytools2015\\ParserGen\\java\\Java5.lex"
        return XORASSIGN;
#line 94 "C:\\mytools2015\\parsergen\\lib\\lexgencpp.par"
        break;
      case 49:
#line 117 "C:\\mytools2015\\ParserGen\\java\\Java5.lex"
        return ORASSIGN;
#line 94 "C:\\mytools2015\\parsergen\\lib\\lexgencpp.par"
        break;
      case 50:
#line 98 "C:\\mytools2015\\ParserGen\\java\\Java5.lex"
        return OROR;
#line 94 "C:\\mytools2015\\parsergen\\lib\\lexgencpp.par"
        break;
      case 51:
#line 45 "C:\\mytools2015\\ParserGen\\java\\Java5.lex"
        return CHARACTERLITERAL;
#line 94 "C:\\mytools2015\\parsergen\\lib\\lexgencpp.par"
        break;
      case 52:
#line 91 "C:\\mytools2015\\ParserGen\\java\\Java5.lex"
        return ELLIPSIS;
#line 94 "C:\\mytools2015\\parsergen\\lib\\lexgencpp.par"
        break;
      case 53:
#line 120 "C:\\mytools2015\\ParserGen\\java\\Java5.lex"
        return SHLASSIGN;
#line 94 "C:\\mytools2015\\parsergen\\lib\\lexgencpp.par"
        break;
      case 54:
#line 121 "C:\\mytools2015\\ParserGen\\java\\Java5.lex"
        return SSHRASSIGN;
#line 94 "C:\\mytools2015\\parsergen\\lib\\lexgencpp.par"
        break;
      case 55:
#line 111 "C:\\mytools2015\\ParserGen\\java\\Java5.lex"
        return USHR;
#line 94 "C:\\mytools2015\\parsergen\\lib\\lexgencpp.par"
        break;
      case 56:
#line 122 "C:\\mytools2015\\ParserGen\\java\\Java5.lex"
        return USHRASSIGN;
#line 94 "C:\\mytools2015\\parsergen\\lib\\lexgencpp.par"
        break;

      default:
        throwException(_T("%s:Unknown accept state:%d, text=<%s>"), __TFUNCTION__, lastAcceptState,getText());
        break;
      }

      unTerminateLexeme();
      lastAcceptState = 0;

      if(isMore()) {
        state = prevState;                // Back up
        initMore();
      } else {
        state = 0;
        markStart();
      }
    }
  }
}
示例#20
0
void Render(float alpha, float elapsedtime)
{
	static float time = 0;
	LPDIRECT3DSURFACE9 backbuffer = 0;

	D3DXMATRIX		view, proj, viewproj;
	D3DXMATRIX		world, inv;

	D3DXVECTOR4		texelsize;
	D3DXVECTOR4		lightpos(-600, 350, 1000, 1);
	D3DXVECTOR4		refllight;
	D3DXVECTOR3		eye(0, 0, -5.0f);
	D3DXVECTOR3		look(0, 1.2f, 0);
	D3DXVECTOR3		refleye, refllook;
	D3DXVECTOR3		up(0, 1, 0);
	D3DXVECTOR2		orient	= cameraangle.smooth(alpha);

	D3DXMatrixRotationYawPitchRoll(&view, orient.x, orient.y, 0);
	D3DXVec3TransformCoord(&eye, &eye, &view);
	
	eye.y += 1.2f;

	D3DXMatrixPerspectiveFovLH(&proj, D3DX_PI / 2, (float)screenwidth / (float)screenheight, 0.1f, 30);

	time += elapsedtime;

	if( SUCCEEDED(device->BeginScene()) )
	{
		device->GetRenderTarget(0, &backbuffer);

		// STEP 1: render reflection texture
		device->SetRenderTarget(0, reflectsurf);
		device->Clear(0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER, 0xff6694ed, 1.0f, 0);

		D3DXPLANE plane(0, 1, 0, 1);

		refleye = eye - 2 * D3DXPlaneDotCoord(&plane, &eye) * (D3DXVECTOR3&)plane;
		refllook = look - 2 * D3DXPlaneDotCoord(&plane, &look) * (D3DXVECTOR3&)plane;

		refllight = lightpos - 2 * D3DXPlaneDot(&plane, &lightpos) * (D3DXVECTOR4&)plane;
		refllight.w = 1;

		D3DXMatrixLookAtLH(&view, &refleye, &refllook, &up);
		D3DXMatrixMultiply(&viewproj, &view, &proj);

		D3DXMatrixInverse(&inv, 0, &viewproj);
		D3DXMatrixTranspose(&inv, &inv);
		D3DXPlaneTransform(&plane, &plane, &inv);

		device->SetClipPlane(0, &plane.a);

		RenderScene(viewproj, refleye, refllight, true);

		// STEP 2: render scene (later used for refraction)
		D3DXMatrixLookAtLH(&view, &eye, &look, &up);
		D3DXMatrixMultiply(&viewproj, &view, &proj);

		device->SetRenderTarget(0, refractsurf);
		device->Clear(0, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER, 0xff6694ed, 1.0f, 0);

		RenderScene(viewproj, eye, lightpos, false);

		// render water surface into alpha channel for masking
		device->SetRenderState(D3DRS_COLORWRITEENABLE, D3DCOLORWRITEENABLE_ALPHA);

		D3DXMatrixTranslation(&world, 0, -1, 0);

		device->SetTransform(D3DTS_WORLD, &world);
		device->SetTransform(D3DTS_VIEW, &view);
		device->SetTransform(D3DTS_PROJECTION, &proj);

		waterplane->DrawSubset(0, DXObject::Opaque);

		device->SetRenderState(D3DRS_COLORWRITEENABLE, 0x0f);

		// STEP 3: light shafts
		quadvertices[6] = quadvertices[24] = quadvertices[30]	= (float)screenwidth - 0.5f;
		quadvertices[13] = quadvertices[19] = quadvertices[31]	= (float)screenheight - 0.5f;

		RenderLightShafts(view, proj, eye, lightpos);

		// STEP 4: gamma correct
		device->SetRenderTarget(0, sceneldrsurf);

		device->SetRenderState(D3DRS_ZENABLE, FALSE);
		device->SetVertexDeclaration(quaddecl);

		bloom->SetTechnique("gammacorrect");
		bloom->Begin(0, 0);
		bloom->BeginPass(0);
		{
			device->SetTexture(0, refraction);
			device->DrawPrimitiveUP(D3DPT_TRIANGLELIST, 2, quadvertices, 6 * sizeof(float));
		}
		bloom->EndPass();
		bloom->End();

		device->SetRenderState(D3DRS_ZENABLE, TRUE);

		// STEP 5: water surface
		device->SetRenderState(D3DRS_SRGBWRITEENABLE, TRUE);

		D3DXMatrixTranslation(&world, 0, -1, 0);
		D3DXMatrixIdentity(&inv);

		water->SetMatrix("matViewProj", &viewproj);
		water->SetMatrix("matWorld", &world);
		water->SetMatrix("matWorldInv", &inv);
		water->SetVector("eyePos", (D3DXVECTOR4*)&eye);
		water->SetVector("lightPos", &lightpos);
		water->SetVector("lightColor", &lightcolor);
		water->SetFloat("time", time);

		water->Begin(0, 0);
		water->BeginPass(0);
		{
			device->SetTexture(0, refraction);
			device->SetTexture(1, reflection);
			device->SetTexture(2, waves);

			waterplane->DrawSubset(0, DXObject::Opaque);
		}
		water->EndPass();
		water->End();

		device->SetRenderState(D3DRS_SRGBWRITEENABLE, FALSE);

		// STEP 6: downsample & blur
		quadvertices[6] = quadvertices[24] = quadvertices[30]	= (float)screenwidth * 0.5f - 0.5f;
		quadvertices[13] = quadvertices[19] = quadvertices[31]	= (float)screenheight * 0.5f - 0.5f;

		device->SetRenderTarget(0, bloomsurf1);
		device->SetRenderState(D3DRS_ZENABLE, FALSE);
		device->SetVertexDeclaration(quaddecl);

		texelsize.x = 1.0f / screenwidth;
		texelsize.y = 1.0f / screenheight;

		bloom->SetTechnique("downsample");
		bloom->SetVector("texelSize", &texelsize);

		bloom->Begin(0, 0);
		bloom->BeginPass(0);
		{
			device->SetTexture(0, sceneldr);
			device->DrawPrimitiveUP(D3DPT_TRIANGLELIST, 2, quadvertices, 6 * sizeof(float));
		}
		bloom->EndPass();
		bloom->End();

		device->SetRenderTarget(0, bloomsurf2);

		texelsize.x = 2.0f / screenwidth;
		texelsize.y = 2.0f / screenheight;

		bloom->SetTechnique("blur");
		bloom->SetVector("texelSize", &texelsize);

		bloom->Begin(0, 0);
		bloom->BeginPass(0);
		{
			device->SetTexture(0, bloomtex1);
			device->DrawPrimitiveUP(D3DPT_TRIANGLELIST, 2, quadvertices, 6 * sizeof(float));
		}
		bloom->EndPass();
		bloom->End();

		// STEP 7: add light shafts
		quadvertices[6] = quadvertices[24] = quadvertices[30]	= (float)screenwidth - 0.5f;
		quadvertices[13] = quadvertices[19] = quadvertices[31]	= (float)screenheight - 0.5f;

		device->SetRenderTarget(0, backbuffer);

		godray->SetTechnique("final");
		godray->Begin(0, 0);
		godray->BeginPass(0);
		{
			device->SetTexture(0, sceneldr);
			device->SetTexture(1, occluders);
			device->SetTexture(2, bloomtex2);

			device->DrawPrimitiveUP(D3DPT_TRIANGLELIST, 2, quadvertices, 6 * sizeof(float));
		}
		godray->EndPass();
		godray->End();

		backbuffer->Release();

		device->SetRenderState(D3DRS_ZENABLE, TRUE);
		device->EndScene();
	}

	device->Present(NULL, NULL, NULL, NULL);
}
示例#21
0
void Player::apply(int argc, const char *argv[]) {
  Game& game = Game::getGame();
  game.wait();

  if (argc>=1) {
    switch(argv[0][0]) {
    case 'l':
      if (isEmbodied()) {
	look();
	//Game::getGame().look(id,*this);
      }
      break;
    case 's':
      if (isEmbodied()) {
	char buf[1000];
	const char prefix[] = "@broadcast";
	int at = 0;
	for (int i=-1; i<argc; i++) {
	  const char *txt = NULL;
	  if (i==-1) { 
	    txt = prefix;
	  } else if (i==0) { 
	    txt = getName(); 
	  } else { 
	    txt = argv[i]; 
	  }
	  if (i>=0) {
	    if (at<sizeof(buf)-2) {
	      buf[at] = ' ';
	      at++;
	    }
	  }
	  for (int j=0; j<strlen(txt); j++)
	    if (at<sizeof(buf)-2) {
	      buf[at] = txt[j];
	      at++;
	    }
	}
	buf[at] = '\0';
	broadcast(buf);
      }
      break;


    // manage moves "go" (u,d,l,r)
    case 'g':
      if (isEmbodied()) {
	if (argc==2) {
	  switch (argv[1][0]) {
	  case 'l':
	    move(-1,0);
	    //Game::getGame().move(id,*this,-1,0);
	    break;
	  case 'r':
	    move(1,0);
	    //Game::getGame().move(id,*this,1,0);
	    break;
	  case 'u':
	    move(0,-1);
	    //Game::getGame().move(id,*this,0,-1);
	    break;
	  case 'd':
	    move(0,1);
	    //Game::getGame().move(id,*this,0,1);
	    break;
	  }
	}
      }
      break;

    // manage firing "fire" (u,d,l,r)
    case 'f':
      if (isEmbodied()) {
	if (argc==2) {
	  switch (argv[1][0]) {
	  case 'l':
	    fire(-1,0);
	    break;
	  case 'r':
	    fire(1,0);
	    break;
	  case 'u':
	    fire(0,-1);
	    break;
	  case 'd':
	    fire(0,1);
	    break;
	  }
	}
      }
      break;

    case 'c':
      send("Current server implementation ignores password");
      {
      const char *name = "anon";
      const char *key = "no-password";
      if (argc>=2) { name = argv[1]; }
      if (argc>=3) { key = argv[2]; }
      if (argc==3||1) {
	printf("LOGIN %s %s\n", name, key);
	bool ok = false;
	if (!isEmbodied()) {
	  ok = login.apply(name,key);
	}
	if (!ok) {
	  send("@error login failed");
	} else {
	  id = login.getID();
	  setName(name);
	  setEnergy(10000);
	  setLife(6000);
	  setFirerange(4);
	  send("@status login 1");
	}
      }
      }
      break;
    default:
      send("@error command not understood");
      //send("Known commands: \"look\" \"fire\" \"go left\" \"go right\" \"go up\" \"go down\"");
      break;
    }
  }

  game.post();
}
示例#22
0
文件: ppriv.c 项目: bahamas10/openzfs
int
main(int argc, char **argv)
{
	int rc = 0;
	int opt;
	struct rlimit rlim;

	(void) setlocale(LC_ALL, "");
	(void) textdomain(TEXT_DOMAIN);

	if ((command = strrchr(argv[0], '/')) != NULL)
		command++;
	else
		command = argv[0];

	while ((opt = getopt(argc, argv, "lDMNPevs:xS")) != EOF) {
		switch (opt) {
		case 'l':
			list = B_TRUE;
			break;
		case 'D':
			set = B_TRUE;
			Don = B_TRUE;
			break;
		case 'M':
			mac_aware = B_TRUE;
			break;
		case 'N':
			set = B_TRUE;
			Doff = B_TRUE;
			break;
		case 'P':
			set = B_TRUE;
			pfexec = B_TRUE;
			break;
		case 'e':
			exec = B_TRUE;
			break;
		case 'S':
			mode = PRIV_STR_SHORT;
			break;
		case 'v':
			verb = B_TRUE;
			mode = PRIV_STR_LIT;
			break;
		case 's':
			set = B_TRUE;
			if ((rc = parsespec(optarg)) != 0)
				return (rc);
			break;
		case 'x':
			set = B_TRUE;
			xpol = B_TRUE;
			break;
		default:
			usage();
			/*NOTREACHED*/
		}
	}

	argc -= optind;
	argv += optind;

	if ((argc < 1 && !list) || Doff && Don || list && (set || exec) ||
	    (mac_aware && !exec))
		usage();

	/*
	 * Make sure we'll have enough file descriptors to handle a target
	 * that has many many mappings.
	 */
	if (getrlimit(RLIMIT_NOFILE, &rlim) == 0) {
		rlim.rlim_cur = rlim.rlim_max;
		(void) setrlimit(RLIMIT_NOFILE, &rlim);
		(void) enable_extended_FILE_stdio(-1, -1);
	}

	if (exec) {
		privupdate_self();
		rc = execvp(argv[0], &argv[0]);
		(void) fprintf(stderr, "%s: %s: %s\n", command, argv[0],
		    strerror(errno));
	} else if (list) {
		rc = dumppriv(argv);
	} else {
		while (argc-- > 0)
			rc += look(*argv++);
	}

	return (rc);
}
示例#23
0
文件: answer.c 项目: PSR-hunt/hunt
/**
 * Initializes a player status.
 * @param[out] newpp The new player to initialize.
 * @param[in] enter_status The enter mode of a player.
 * [PSR]
 */
void stplayer(PLAYER *newpp, int enter_status) {
	int x, y;
	PLAYER *pp;

	nplayer++;

	for (y = 0; y < UBOUND; y++) {
		for (x = 0; x < WIDTH; x++) {
			newpp->p_maze[y][x] = maze[y][x];
		}
	}
	for (; y < DBOUND; y++) {
		for (x = 0; x < LBOUND; x++) {
			newpp->p_maze[y][x] = maze[y][x];
		}
		for (; x < RBOUND; x++) {
			newpp->p_maze[y][x] = SPACE;
		}
		for (; x < WIDTH; x++) {
			newpp->p_maze[y][x] = maze[y][x];
		}
	}
	for (; y < HEIGHT; y++) {
		for (x = 0; x < WIDTH; x++) {
			newpp->p_maze[y][x] = maze[y][x];
		}
	}

	do {
		x = rand_num(WIDTH - 1) + 1;
		y = rand_num(HEIGHT - 1) + 1;
	} while (maze[y][x] != SPACE);
	newpp->p_over = SPACE;
	newpp->p_x = x;
	newpp->p_y = y;
	newpp->p_undershot = false;

# ifdef FLY
	if (enter_status == Q_FLY) {
		newpp->p_flying = rand_num(20);
		newpp->p_flyx = 2 * rand_num(6) - 5;
		newpp->p_flyy = 2 * rand_num(6) - 5;
		newpp->p_face = FLYER;
	}
	else
# endif
	{
# ifdef FLY
		newpp->p_flying = -1;
# endif
		newpp->p_face = rand_dir();
	}
	newpp->p_damage = 0;
	newpp->p_damcap = MAXDAM;
	newpp->p_nchar = 0;
	newpp->p_ncount = 0;
	newpp->p_nexec = 0;
	newpp->p_ammo = ISHOTS;
# ifdef BOOTS
	newpp->p_nboots = 0;
# endif
	if (enter_status == Q_SCAN) {
		newpp->p_scan = SCANLEN;
		newpp->p_cloak = 0;
	} else {
		newpp->p_scan = 0;
		newpp->p_cloak = CLOAKLEN;
	}
	newpp->p_ncshot = 0;

	do {
		x = rand_num(WIDTH - 1) + 1;
		y = rand_num(HEIGHT - 1) + 1;
	} while (maze[y][x] != SPACE);
	maze[y][x] = GMINE;
# ifdef MONITOR
	for (pp = monitor; pp < end_monitor; pp++) {
		check(pp, y, x);
	}
# endif

	do {
		x = rand_num(WIDTH - 1) + 1;
		y = rand_num(HEIGHT - 1) + 1;
	} while (maze[y][x] != SPACE);
	maze[y][x] = MINE;
# ifdef MONITOR
	for (pp = monitor; pp < end_monitor; pp++) {
		check(pp, y, x);
	}
# endif

	(void) sprintf(gen_buf, "%5.2f%c%-10.10s %c", newpp->p_ident->i_score,
			stat_char(newpp), newpp->p_ident->i_name, newpp->p_ident->i_team);
	y = STAT_PLAY_ROW + 1 + (newpp - player);
	for (pp = player; pp < end_player; pp++) {
		if (pp != newpp) {
			char smallbuf[10];

			pp->p_ammo += NSHOTS;
			newpp->p_ammo += NSHOTS;
			cgoto(pp, y, STAT_NAME_COL);
			outstr(pp, gen_buf, STAT_NAME_LEN);
			(void) sprintf(smallbuf, "%3d", pp->p_ammo);
			cgoto(pp, STAT_AMMO_ROW, STAT_VALUE_COL);
			outstr(pp, smallbuf, 3);
		}
	}
# ifdef MONITOR
	for (pp = monitor; pp < end_monitor; pp++) {
		cgoto(pp, y, STAT_NAME_COL);
		outstr(pp, gen_buf, STAT_NAME_LEN);
	}
# endif

	drawmaze(newpp);
	drawplayer(newpp, true);
	look(newpp);
# ifdef	FLY
	if (enter_status == Q_FLY) {
		/* Make sure that the position you enter in will be erased */
		showexpl(newpp->p_y, newpp->p_x, FLYER);
	}
# endif
	sendcom(newpp, REFRESH);
	sendcom(newpp, READY, 0);
	(void) fflush(newpp->p_output);
}
示例#24
0
//---------------------------------------------------------------------------
inline name*insert(char*s){return look(s,1);}
示例#25
0
static int contourI(ptr_level_f func, double *x, double *y, double *z, double *zCont, int *N, int *style, int *err)
{
    int check = 1;
    char *F = NULL;
    int n1 = 0, n2 = 0, ncont = 0, i = 0, c = 0, j = 0, k = 0, n5 = 0;
    int stylec = 0;
    n1 = N[0];
    n2 = N[1];
    ncont = N[2];
    F = getFPF();
    if ( F[0] == '\0')
    {
        ChoixFormatE1(ContNumFormat, zCont, N[2]);
    }
    InitValues(x, y, z, n1, n2);
    n5 =  2 * (n1) + 2 * (n2) - 3;
    /* Allocation */
    Gcont_size = 0; /** initialize the array indices for storing contours **/
    xbd_cont = MALLOC( n5 * sizeof(int) ) ;
    ybd_cont = MALLOC( n5 * sizeof(int) ) ;
    itg_cont = MALLOC( n1 * n2 * sizeof(int) ) ;
    if ( (xbd_cont == NULL) && n5 != 0)
    {
        check = 0;
    }
    if ( (ybd_cont == NULL) && n5 != 0)
    {
        check = 0;
    }
    if ( (itg_cont == NULL) && n1 * n2 != 0)
    {
        check = 0;
    }
    if ( check == 0)
    {
        FREE( xbd_cont ) ;
        FREE( ybd_cont ) ;
        FREE( itg_cont ) ;
        Scierror(999, _("%s: No more memory.\n"), "contourI");
        return -1;
    }
    /* just a parametrization of the boundary points */
    for ( i = 0 ; i <  n2 ; i++)
    {
        ybd_cont[i] = i ;
        xbd_cont[i] = 0 ;
    }
    for ( i = 1 ; i <  n1 ; i++)
    {
        ybd_cont[n2 + i - 1] = n2 - 1 ;
        xbd_cont[n2 + i - 1] = i  ;
    }
    for ( i = n2 - 2;  i >= 0  ; i--)
    {
        ybd_cont[2 * n2 + n1 - 3 - i] = i ;
        xbd_cont[2 * n2 + n1 - 3 - i] = n1 - 1  ;
    }
    for ( i = n1 - 2 ; i >= 0 ; i--)
    {
        ybd_cont[2 * n2 + 2 * n1 - 4 - i] = 0 ;
        xbd_cont[2 * n2 + 2 * n1 - 4 - i] = i  ;
    }
    for ( c = 0 ; c < ncont ; c++)
    {
        stylec = ( style != (int *) 0) ? style[c] : c;
        /** itg-cont is a flag array to memorize checked parts of the grid **/
        for ( i = 0 ; i < n1; i++)
            for ( j = 0 ; j < n2 ; j++)
            {
                itg_cont[i + n1 * j] = 0 ;
            }
        /** all the boundary segments **/
        for ( k = 1 ; k < n5 ; k++)
        {
            int ib, jb;
            i = xbd_cont[k] ;
            j = ybd_cont[k];
            ib = xbd_cont[k - 1] ;
            jb = ybd_cont[k - 1];
            if  (not_same_sign (phi_cont(i, j) - zCont[c] ,
                                phi_cont(ib, jb) - zCont[c]))
            {
                look(func, i, j, ib, jb, 1L, zCont[c], stylec);
            }
        }
        /** inside segments **/
        for ( i = 1 ; i < n1 - 1; i++)
            for ( j = 1 ; j < n2 - 1 ; j++)
                if  (not_same_sign ( phi_cont(i, j) - zCont[c] ,
                                     phi_cont(i, j - 1) - zCont[c]))
                {
                    look(func, i, j, i, j - 1, 2L, zCont[c], stylec);
                }
    }
    FREE( xbd_cont ) ;
    FREE( ybd_cont ) ;
    FREE( itg_cont ) ;

    return 0;
}
示例#26
0
/*
 * moveshots:
 *	Move the shots already in the air, taking explosions into account
 */
void
moveshots()
{
	BULLET	*bp, *next;
	PLAYER	*pp;
	int	x, y;
	BULLET	*blist;

	rollexpl();
	if (Bullets == NULL)
		goto no_bullets;

	/*
	 * First we move through the bullet list conf_bulspd times, looking
	 * for things we may have run into.  If we do run into
	 * something, we set up the explosion and disappear, checking
	 * for damage to any player who got in the way.
	 */

	/* Move the list to a working list */
	blist = Bullets;
	Bullets = NULL;

	/* Work with bullets on the working list (blist) */
	for (bp = blist; bp != NULL; bp = next) {
		next = bp->b_next;

		x = bp->b_x;
		y = bp->b_y;

		/* Un-draw the bullet on all screens: */
		Maze[y][x] = bp->b_over;
		check(ALL_PLAYERS, y, x);

		/* Decide how to move the bullet: */
		switch (bp->b_type) {

		  /* Normal, atomic bullets: */
		  case SHOT:
		  case GRENADE:
		  case SATCHEL:
		  case BOMB:
			if (move_normal_shot(bp)) {
				/* Still there: put back on the active list */
				bp->b_next = Bullets;
				Bullets = bp;
			}
			break;

		  /* Slime bullets that explode into slime on impact: */
		  case SLIME:
			if (bp->b_expl || move_normal_shot(bp)) {
				/* Still there: put back on the active list */
				bp->b_next = Bullets;
				Bullets = bp;
			}
			break;

		  /* Drones that wander about: */
		  case DSHOT:
			if (move_drone(bp)) {
				/* Still there: put back on the active list */
				bp->b_next = Bullets;
				Bullets = bp;
			}
			break;

		  /* Other/unknown: */
		  default:
			/* Place it back on the active list: */
			bp->b_next = Bullets;
			Bullets = bp;
			break;
		}
	}

	/* Again, hang the Bullets list off `blist' and work with that: */
	blist = Bullets;
	Bullets = NULL;
	for (bp = blist; bp != NULL; bp = next) {
		next = bp->b_next;
		/* Is the bullet exploding? */
		if (!bp->b_expl) {
			/*
			 * Its still flying through the air.
			 * Put it back on the bullet list.
			 */
			save_bullet(bp);

			/* All the monitors can see the bullet: */
			for (pp = Monitor; pp < End_monitor; pp++)
				check(pp, bp->b_y, bp->b_x);

			/* All the scanning players can see the drone: */
			if (bp->b_type == DSHOT)
				for (pp = Player; pp < End_player; pp++)
					if (pp->p_scan >= 0)
						check(pp, bp->b_y, bp->b_x);
		} else {
			/* It is exploding. Check what we hit: */
			chkshot(bp, next);
			/* Release storage for the destroyed bullet: */
			free(bp);
		}
	}

	/* Re-draw all the players: (in case a bullet wiped them out) */
	for (pp = Player; pp < End_player; pp++)
		Maze[pp->p_y][pp->p_x] = pp->p_face;

no_bullets:

	/* Move flying boots through the air: */
	for (pp = Boot; pp < &Boot[NBOOTS]; pp++)
		if (pp->p_flying >= 0)
			move_flyer(pp);

	/* Move flying players through the air: */
	for (pp = Player; pp < End_player; pp++) {
		if (pp->p_flying >= 0)
			move_flyer(pp);
		/* Flush out the explosions: */
		sendcom(pp, REFRESH);
		look(pp);
	}

	/* Flush out and synchronise all the displays: */
	sendcom(ALL_PLAYERS, REFRESH);
}
示例#27
0
HRESULT InitScene()
{
	HRESULT hr;
	LPD3DXBUFFER errors = NULL;

	SetWindowText(hwnd, TITLE);

	if( FAILED(hr = D3DXLoadMeshFromXA("../media/meshes/sphere.X", D3DXMESH_MANAGED, device, NULL, NULL, NULL, NULL, &mesh)) )
	{
		MYERROR("Could not load sphere");
		return hr;
	}

	// generate tangent frame
	LPD3DXMESH newmesh = NULL;

	D3DVERTEXELEMENT9 decl[] =
	{
		{ 0, 0, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0 },
		{ 0, 12, D3DDECLTYPE_FLOAT2, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0 },
		{ 0, 20, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_NORMAL, 0 },
		{ 0, 32, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TANGENT, 0 },
		{ 0, 44, D3DDECLTYPE_FLOAT3, D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_BINORMAL, 0 },
		D3DDECL_END()
	};

	if( FAILED(hr = mesh->CloneMesh(D3DXMESH_MANAGED, decl, device, &newmesh)) )
	{
		MYERROR("Could not clone mesh");
		return hr;
	}

	mesh->Release();
	mesh = NULL;

	hr = D3DXComputeTangentFrameEx(newmesh,
		D3DDECLUSAGE_TEXCOORD, 0,
		D3DDECLUSAGE_TANGENT, 0,
		D3DDECLUSAGE_BINORMAL, 0,
		D3DDECLUSAGE_NORMAL, 0,
		0, NULL, 0.01f, 0.25f, 0.01f, &mesh, NULL);

	newmesh->Release();

	if( FAILED(hr) )
	{
		MYERROR("Could not compute tangent frame");
		return hr;
	}

	if( FAILED(hr = CreateChecker(device, 10, 10, 0xff7557a8, 0xffd8d8d8, &tex)) )
	{
		MYERROR("Could not create texture");
		return hr;
	}

	if( FAILED(hr = D3DXCreateTextureFromFileA(device, "../media/textures/brick_nh.dds", &normalmap)) )
	{
		MYERROR("Could not load normalmap");
		return hr;
	}

	hr = D3DXCreateEffectFromFileA(device, "../media/shaders/normal.fx", NULL, NULL, D3DXSHADER_DEBUG, NULL, &effect, &errors);

	if( FAILED(hr) )
	{
		if( errors )
		{
			char* str = (char*)errors->GetBufferPointer();
			std::cout << str << "\n\n";

			errors->Release();
		}

		MYERROR("Could not create effect");
		return hr;
	}

	D3DXVECTOR4 uv(3, 1, 0, 1);
	effect->SetVector("normuv", &uv);

	D3DXVECTOR3 eye(0, 0, -1.5f);
	D3DXVECTOR3 look(0, 0, 0);
	D3DXVECTOR3 up(0, 1, 0);

	D3DXMatrixPerspectiveFovLH(&proj, D3DX_PI / 3, (float)screenwidth / (float)screenheight, 0.1f, 10);
	D3DXMatrixLookAtLH(&view, &eye, &look, &up);
	D3DXMatrixIdentity(&world);

	return S_OK;
}
示例#28
0
文件: main.c 项目: JamesLinus/inferno
void
main(int argc, char *argv[])
{
	Dir *db;
	Lsym *l;
	Node *n;
	char buf[128], *s;
	int pid, i;
	char *p;
	char afile[512];

	argv0 = argv[0];
	pid = 0;
	aout = "v.out";
	quiet = 1;
	/* turn off all debugging */
	protodebug = 0;

	mtype = 0;
	ARGBEGIN{
	case 'm':
		mtype = ARGF();
		break;
	case 'w':
		wtflag = 1;
		break;
	case 'l':
		s = ARGF();
		if(s == 0)
			usage();
		lm[nlm++] = s;
		break;
	case 'd':
		p = ARGF();
		if (p == 0)
			usage();
		while (*p) {
			setdbg_opt(*p, 0); /* don't print set message */
			p++;
		}
		break;
	case 'k':
		kernel++;
		break;
	case 'q':
		quiet = 0;
		break;
	case 'r':
		pid = 1;
		remote++;
		kernel++;
		break;
	case 'R':
		pid = 1;
		rdebug++;
		s = ARGF();
		if(s == 0)
			usage();
		remfd = opentty(s, 0);
		if(remfd < 0){
			fprint(2, "acid: can't open %s: %r\n", s);
			exits("open");
		}
		break;
	default:
		usage();
	}ARGEND

	if(argc > 0) {
		if(remote || rdebug)
			aout = argv[0];
		else
		if(isnumeric(argv[0])) {
			pid = atoi(argv[0]);
			sprint(prog, "/proc/%d/text", pid);
			aout = prog;
			if(argc > 1)
				aout = argv[1];
			else if(kernel)
				aout = mysystem();
		}
		else {
			if(kernel) {
				print("-k requires a pid");
				kernel = 0;
			}
			aout = argv[0];
		}
	} else if(rdebug)
		aout = "/386/bpc";
	else if(remote)
		aout = "/mips/bcarrera";

	fmtinstall('x', xfmt);
	fmtinstall('L', Lfmt);
	fmtinstall('f', gfltconv);
	fmtinstall('F', gfltconv);
	fmtinstall('g', gfltconv);
	fmtinstall('G', gfltconv);
	fmtinstall('e', gfltconv);
	fmtinstall('E', gfltconv);
	Binit(&bioout, 1, OWRITE);
	bout = &bioout;

	kinit();
	initialising = 1;
	pushfile(0);
	loadvars();
	installbuiltin();

	if(mtype && machbyname(mtype) == 0)
		print("unknown machine %s", mtype);

	if (attachfiles(aout, pid) < 0)
		varreg();		/* use default register set on error */

	acidlib = getenv("ACIDLIB");
	if(acidlib == nil){
		p = getenv("ROOT");
		if(p == nil)
			p = "/usr/inferno";
		snprint(afile, sizeof(afile)-1, "%s/lib/acid", p);
		acidlib = strdup(afile);
	}

	snprint(afile, sizeof(afile)-1, "%s/port", acidlib);
	loadmodule(afile);
	for(i = 0; i < nlm; i++) {
		if((db = dirstat(lm[i])) != nil) {
			free(db);
			loadmodule(lm[i]);
		} else {
			sprint(buf, "%s/%s", acidlib, lm[i]);
			loadmodule(buf);
		}
	}

	userinit();
	varsym();

	l = look("acidmap");
	if(l && l->proc) {
		n = an(ONAME, ZN, ZN);
		n->sym = l;
		n = an(OCALL, n, ZN);
		execute(n);
	}

	interactive = 1;
	initialising = 0;
	line = 1;

	setup_os_notify();

	for(;;) {
		if(setjmp(err)) {
			Binit(&bioout, 1, OWRITE);
			unwind();
		}
		stacked = 0;

		Bprint(bout, "acid: ");

		if(yyparse() != 1)
			die();
		restartio();

		unwind();
	}
	/* not reached */
}
示例#29
0
int
main(int argc, char *argv[])
{
	struct stat sb;
	int ch, fd, termchar;
	char *back, *file, *front, *p;

	static const struct option longopts[] = {
		{"alternative", no_argument, NULL, 'a'},
		{"alphanum", no_argument, NULL, 'd'},
		{"ignore-case", no_argument, NULL, 'f'},
		{"terminate", required_argument, NULL, 't'},
		{"version", no_argument, NULL, 'V'},
		{"help", no_argument, NULL, 'h'},
		{NULL, 0, NULL, 0}
	};

	setlocale(LC_ALL, "");
	bindtextdomain(PACKAGE, LOCALEDIR);
	textdomain(PACKAGE);
	atexit(close_stdout);

	setlocale(LC_ALL, "");

	if ((file = getenv("WORDLIST")) && !access(file, R_OK))
		/* use the WORDLIST */;
	else
		file = _PATH_WORDS;

	termchar = '\0';
	string = NULL;		/* just for gcc */

	while ((ch = getopt_long(argc, argv, "adft:Vh", longopts, NULL)) != -1)
		switch(ch) {
		case 'a':
			file = _PATH_WORDS_ALT;
			break;
		case 'd':
			dflag = 1;
			break;
		case 'f':
			fflag = 1;
			break;
		case 't':
			termchar = *optarg;
			break;
		case 'V':
			printf(UTIL_LINUX_VERSION);
			return EXIT_SUCCESS;
		case 'h':
			usage();
		default:
			errtryhelp(EXIT_FAILURE);
		}
	argc -= optind;
	argv += optind;

	switch (argc) {
	case 2:				/* Don't set -df for user. */
		string = *argv++;
		file = *argv;
		break;
	case 1:				/* But set -df by default. */
		dflag = fflag = 1;
		string = *argv;
		break;
	default:
		warnx(_("bad usage"));
		errtryhelp(EXIT_FAILURE);
	}

	if (termchar != '\0' && (p = strchr(string, termchar)) != NULL)
		*++p = '\0';

	if ((fd = open(file, O_RDONLY, 0)) < 0 || fstat(fd, &sb))
		err(EXIT_FAILURE, "%s", file);
	front = mmap(NULL, (size_t) sb.st_size, PROT_READ,
		     MAP_SHARED, fd, (off_t) 0);
	if
#ifdef MAP_FAILED
		(front == MAP_FAILED)
#else
		((void *)(front) <= (void *)0)
#endif
			err(EXIT_FAILURE, "%s", file);
	back = front + sb.st_size;
	return look(front, back);
}
示例#30
0
void TGen::Engine::Controller::FirstPerson::update(scalar dt) {
	//std::cout << "SPEED: " << controlBody->getLinearVelocity().getMagnitude() << std::endl;
	
	TGen::Vector3 moveDelta;
	bool moveEvent = false;
	bool jump = false;
	bool initialJump = false;
	
	if (checkEvent(EventNextWeapon) && equipment)
		equipment->changeEquipmentRelative(-1);
	
	if (checkEvent(EventPreviousWeapon) && equipment)
		equipment->changeEquipmentRelative(1);
	
	static float sinceJumpPressed = 4.0f;		// TODO: fix this
	
	sinceJumpPressed += dt;
	
	if (isEventInitial(EventJump)) {
		setEventRead(EventJump);
		
		if (controlBody && controlBody->isOnFloor()) {
			airTime = jumpTime;
		
		//moveEvent = true;
	//	jump = true;
//		initialJump = true;
			sinceJumpPressed = 100.0;
			controlBody->addForce(TGen::Vector3(0.0f, jumpForce * 0.01, 0.0f));
		}
		else {
			sinceJumpPressed = 0.0;
		}
		//moveDelta += TGen::Vector3(0.0f, 1.0f, 0.0f);
	}
	else if (sinceJumpPressed < 0.1 && controlBody && controlBody->isOnFloor()) {
		controlBody->addForce(TGen::Vector3(0.0f, jumpForce * 0.01, 0.0f));
		sinceJumpPressed = 100.0;
	}
	
	/*else if (checkEvent(EventJump)) {
		
		moveEvent = true;
		jump = true;
	}
	
	if (jump)
		airTime -= dt * 1.0;
	else
		airTime -= dt * 1.3;
	*/
	//if (controlBody)
	//	std::cout << "speed: " << controlBody->getLinearVelocity().getMagnitude() << std::endl;
	
	if (checkEvent(EventForward)) {
		moveEvent = true;
		moveDelta += TGen::Vector3(0.0f, 0.0f, 1.0f);
	}
	
	if (checkEvent(EventBackward)) {
		moveEvent = true;
		moveDelta += TGen::Vector3(0.0f, 0.0f, -1.0f);
	}
	
	if (checkEvent(EventStrafeLeft)) {
		moveEvent = true;
		moveDelta += TGen::Vector3(-1.0f, 0.0f, 0.0f);
	}
	
	if (checkEvent(EventStrafeRight)) {
		moveEvent = true;
		moveDelta += TGen::Vector3(1.0f, 0.0f, 0.0f);
	}
	
	if (checkEvent(EventPrimaryFire)) {
		if (!primaryFire) {
			primaryFire = true;
			
			if (weapon)
				weapon->beginFire(0);
		}
	}
	else {
		if (primaryFire) {
			primaryFire = false;
			
			if (weapon)
				weapon->endFire(0);
		}
	}
	
	//if (moveEvent) {
		moveDelta.normalize();
		
		if (viewNode) {
			TGen::Matrix4x4 rot = TGen::Matrix4x4::RotationY(TGen::Radian(orientX)); //viewNode->getLocalOrientation();
			
			if (!usePhysics) {
				rot = TGen::Matrix4x4(viewNode->getWorldOrientation());
				
				if (checkEvent(EventJump))
					moveDelta += TGen::Vector3(0.0f, 1.0f, 0.0f);
				
				if (checkEvent(EventCrouch))
					moveDelta += TGen::Vector3(0.0f, -1.0f, 0.0f);
				
				moveDelta.z = -moveDelta.z;
				moveDelta = rot * moveDelta;
			}
			else {
				moveDelta = rot * moveDelta;
				moveDelta.y = 0.0f;
			}

			moveDelta.normalize();
			
		//	rot.invert();
			
			
			//if (jump)
			//	moveDelta.y = deltaJump;
		}
	
		//moveDelta *= dt;
	
		if (node && !usePhysics) {
			node->getSceneNode()->setPosition(node->getSceneNode()->getLocalPosition() + moveDelta * dt * deltaPlane);
		}
		else if (controlBody) {

			//std::cout << controlBody->getLinearVelocity().getMagnitude() << std::endl;
			//if (controlBody->isOnFloor())
			//	std::cout << "on floor!" << std::endl;
			//scalar dp = controlBody->getSlope();
			
			//TGen::Degree slope(TGen::Radian(acos(dp)));

			//std::cout << slope.angle << std::endl;
			//std::cout << airTime << std::endl;
			
			TGen::Vector3 up = controlBody->getGroundNormal();

			up *= TGen::Vector3::DotProduct(up, TGen::Vector3(0.0f, 1.0f, 0.0f));
			// den här kan man göra en if (<0) up = -up
			
			TGen::Vector3 look(0.0f, 0.0f, 1.0f);
			TGen::Vector3 right(1.0f, 0.0f, 0.0f);
			look = TGen::Vector3::CrossProduct(right, up);
			right = TGen::Vector3::CrossProduct(up, look);
			
			TGen::Matrix4x4 mat(right, up, look);
			
			moveDelta = mat * moveDelta;
						
			scalar slope = TGen::Vector3::DotProduct(moveDelta, TGen::Vector3(0.0f, 1.0f, 0.0f));
			
			//moveDelta *= (1.0 + TGen::Vector3::DotProduct(moveDelta, TGen::Vector3(0.0f, 1.0f, 0.0f)) * 0.8);
			//moveDelta *= 1.0 + slope;
			if (slope < 0.0f)
				slope = 0.0f;
			
			moveDelta += TGen::Vector3(0.0f, slope, 0.0f);
			moveDelta *= (1.0 + slope) * dt;
			
			
			if (controlBody->isOnFloor()) {
				controlBody->addForce(moveDelta * deltaPlane);
				controlBody->setLinearDamping(0.12);
			}
			else {
				moveDelta.y = 0.0f;
				controlBody->setLinearDamping(0.0004);
				controlBody->addForce(moveDelta * deltaPlane * airControl);				
			}
			
			//if (jump) {
			scalar force = std::max(0.0f, float(airTime));
			//std::cout << force << std::endl;
				
			//if (force > 0.0)
			//	controlBody->addForce(TGen::Vector3(0.0f, jumpForce * force, 0.0f));
			//}
			
			//scalar maxSpeed = 10000.0;
			
			//if (controlBody->getLinearVelocity().getMagnitude() < 10.0)
			//controlBody->addForce(moveDelta * maxSpeed * (10.0 - controlBody->getLinearVelocity().getMagnitude()));
			
		}
		else {
			throw TGen::RuntimeException("Controller::FirstPerson::update", "no phys body, support should be fixed later");
		}
//	}
	
	TGen::Vector3 viewDelta = checkViewDelta() * 0.002;	// TODO: sensitivity = 0.002

	orientX += viewDelta.x;
	orientY += viewDelta.y;
		
	orientY = TGen::Clamp(orientY, -TGen::HALF_PI, TGen::HALF_PI);
	
	TGen::Vector3 up(0.0f, 1.0f, 0.0f);
	TGen::Vector3 look(0.0f, 0.0f, -1.0f);
	TGen::Vector3 right(1.0f, 0.0f, 0.0f);
	
	TGen::Matrix4x4 rot = TGen::Matrix4x4::Rotation(right, TGen::Radian(orientY));
	
	look = rot * look;
	up = rot * up;
	right = TGen::Vector3::CrossProduct(look, up);
	
	rot = TGen::Matrix4x4::RotationY(TGen::Radian(orientX));
	
	look = rot * look;
	up = rot * up;
	
	right = TGen::Vector3::CrossProduct(look, up);
	
	
	TGen::Matrix4x4 rotation(right.getNormalized(), up.getNormalized(), look.getNormalized());
	
	if (viewNode)
		viewNode->setOrientation(rotation);
}