示例#1
0
文件: ounitb.cpp 项目: mecirt/7k2
//----------- Begin of function UnitB::process_idle----------//
//
// when a unit is idling, if it is block, process block
// if it is in formation but fnot yet reach destination, go there again
//
void UnitB::process_idle()
{
	cur_action = SPRITE_IDLE;
	if(is_blocked() && cur_order.mode != UNIT_ATTACK)
		process_blocked();
	else
	if(/*is_in_formation() && */
		is_blocked() &&
		((next_x_loc() != move_to_loc_x) || (next_y_loc() != move_to_loc_y)) &&
		can_move(move_to_loc_x, move_to_loc_y))

		move_to(move_to_loc_x, move_to_loc_y);
	
	else
		Sprite::process_idle();
}
示例#2
0
/*
 * Our main function we start of here...
 * we should make sure that we never return from here, or vectrex will
 * be surely bothered!
 */
int main(void)
{
  unsigned char anim_state;           /* our animation state counter */
  signed char pacman_x;               /* where is the pacman? */
  signed char pacman_y;
  pacman_x = 0;
  pacman_y = 0;
  anim_state = 0;
  setup();                            /* setup our program */

  while (true)                        /* never to return... */
  {
    start_one_vectrex_round();        /* start 'de round */
    intensity(MAX_BRIGHTNESS);        /* set some brightness */
    set_scale(MOVE_SCALE);            /* set scale factor */
    print_str(-128,100, "JOYTICK 1 TO MOVE PACMAN!"); /* a message! */
    move_to(pacman_x, pacman_y);      /* position pacman */
    set_scale(PACMAN_SCALE);          /* set scale factor for the sprite */
    draw_vector_list(pacman[anim_state]); /* draw the current pacman */
    anim_state++;                     /* next time the next animation */
    if (anim_state == MAX_ANIM)       /* could do a % MAXANIM, but this is */
       anim_state = 0;                /* more optimized */
    if (!read_ram(Vec_Music_Flag))    /* music finished? */
       play_song(SCRAMBLE_MUSIC);     /* if so ... restart */
    if (joystick1_x>0)                /* check the joystick and */
    {                                 /* update position */
      pacman_x++;
    }
    else if (joystick1_x<0)
    {
      pacman_x--;
    }
    if (joystick1_y>0)
    {
      pacman_y++;
    }
    else if (joystick1_y<0)
    {
      pacman_y--;
    }
    if (pacman_x>=100) pacman_x = 100;    /* make sure pacman is not */
    if (pacman_x<=-100) pacman_x = -100;  /* out of bounds */
    if (pacman_y>=100) pacman_y = 100;
    if (pacman_y<=-100) pacman_y = -100;
    joy_digital();                        /* call once per round, to insure */
  } /* while (true) */                    /* joystick information is up to date */
}
示例#3
0
NewDocumentDialog::NewDocumentDialog()
:	NWindow(
		new NDialogPanel(
			MAKEINTRESOURCE(ID_NEW_DOCUMENT_DIALOG), NRect(), "NewDialog",
			NView::FOLLOW_LEFT | NView::FOLLOW_TOP, NDialogPanel::RESIZE_TO_FIT),
		NRect(100, 100, 300, 300), "�V�K�쐬", TITLED_LOOK, MODAL_APP_FEEL,
		NOT_RESIZABLE | NOT_ZOOMABLE | NOT_MINIMIZABLE)
{
	NDialogPanel* dialog_panel = reinterpret_cast<NDialogPanel*>(panel());
	SetDlgItemText(dialog_panel->handle(), ID_WIDTH, "160");
	SetDlgItemText(dialog_panel->handle(), ID_HEIGHT, "120");

	resize_to(dialog_panel->frame().width(), dialog_panel->frame().height());
	move_to(
		(NScreen::frame().width() - frame().width()) /2,
		(NScreen::frame().height() - frame().height()) /2);
}
示例#4
0
/*
 * 显示登录界面
 */
void show_login_window()
{
	clear_win();
	move_to(0, 0);

	printf("┌────────────────────────────────────┐\n");
	printf("│           图书销售系统             │\n");
	printf("│           ────────────             │\n");
	printf("│                                    │\n");

	printf("│       ");

	color_on(INVERSE, BLACK, WHITE);
	printf("┌───────────────────┐ ");
	color_off();

	printf("       │\n");
	printf("│       ");
	
	color_on(INVERSE, BLACK, WHITE);
	printf("│ 用户名:          │ ");
	color_off();

	printf("       │\n");
	printf("│       ");
	
	color_on(INVERSE, BLACK, WHITE);
	printf("│ 密  码:          │ ");
	color_off();

	printf("       │\n");
	printf("│       ");
	
	color_on(INVERSE, BLACK, WHITE);
	printf("└───────────────────┘ ");
	color_off();

	printf("       │\n");
	printf("│                                    │\n");
	printf("│                                    │\n");
	printf("│                                    │\n");
	printf("│                                    │\n");
	printf("│  时间:               按TAB键退出   │\n");
	printf("└────────────────────────────────────┘\n");
}
示例#5
0
/**
 * Stumble in a random direction, but with some caveats.
 */
void monster::stumble( )
{
    // Only move every 3rd turn.
    if( !one_in( 3 ) ) {
        return;
    }

    std::vector<tripoint> valid_stumbles;
    const bool avoid_water = has_flag( MF_NO_BREATHE ) &&
      !has_flag( MF_SWIMS ) && !has_flag( MF_AQUATIC );
    for( int i = -1; i <= 1; i++ ) {
        for( int j = -1; j <= 1; j++ ) {
            tripoint dest( posx() + i, posy() + j, posz() );
            if( ( i || j ) && can_move_to( dest ) &&
                //Stop zombies and other non-breathing monsters wandering INTO water
                //(Unless they can swim/are aquatic)
                //But let them wander OUT of water if they are there.
                !( avoid_water &&
                   g->m.has_flag( TFLAG_SWIMMABLE, dest ) &&
                   !g->m.has_flag( TFLAG_SWIMMABLE, pos3() ) ) &&
                ( g->critter_at( dest, is_hallucination() ) == nullptr ) ) {
                valid_stumbles.push_back( dest );
            }
        }
    }

    if( g->m.has_zlevels() ) {
        tripoint below( posx(), posy(), posz() - 1 );
        tripoint above( posx(), posy(), posz() + 1 );
        if( g->m.valid_move( pos(), below, false, true ) && can_move_to( below ) ) {
            valid_stumbles.push_back( below );
        }
        // More restrictions for moving up
        if( one_in( 5 ) && has_flag( MF_FLIES ) &&
            g->m.valid_move( pos(), above, false, true ) && can_move_to( above ) ) {
            valid_stumbles.push_back( above );
        }
    }

    if( valid_stumbles.empty() ) { //nowhere to stumble?
        return;
    }

    move_to( random_entry( valid_stumbles ), false );
}
示例#6
0
文件: scrollview.cpp 项目: snori/ntk
ScrollView::ScrollView(const String& name, View* target, uint mode, uint flags, bool v, bool h, const RGBColor& color)
:	View(Rect(0, 0, 100, 100), name, mode, flags, color)
,	m_target(NULL)
,	m_v_scroll_bar(NULL)
,	m_h_scroll_bar(NULL)
{
	assert(target);

	Rect rect = target->frame();

	target->move_to(0, 0);// ‹Ù‹}”ð“ï‘[’u

	if(v)
	{
		m_v_scroll_bar = new ScrollBar(
			Rect(0, 0, ScrollBar::V_SCROLL_BAR_WIDTH, 10),
			"VScrollBar",
			NULL,
			0, 0,
			ScrollBar::VERTICAL,
			FOLLOW_RIGHT | FOLLOW_TOP_BOTTOM);
		add_child(m_v_scroll_bar);

		rect.right += m_v_scroll_bar->frame().width();
	}

	if(h)
	{
		m_h_scroll_bar = new ScrollBar(
			Rect(0, 0, 10, ScrollBar::H_SCROLL_BAR_HEIGHT),
			"HScrollBar",
			NULL,
			0, 0,
			ScrollBar::HORIZONTAL,
			FOLLOW_BOTTOM | FOLLOW_LEFT_RIGHT);
		add_child(m_h_scroll_bar);

		rect.bottom += m_h_scroll_bar->frame().height();
	}

	move_to(rect.left_top());
	resize_to(rect.width(), rect.height());

	set_target(target);
}
示例#7
0
void intercom_home(player * p, char *str)
{

  /*If they are already there.... */
  if (p->location == intercom_room)
  {
    tell_player(p, " You're already in the Intercom room!\n");
    return;
  }
  /* or if they're stuck */
  if (p->no_move)
  {
    tell_player(p, " You seem to be stuck to the ground.\n");
    return;
  }
  /* otherwise move them */
  move_to(p, "intercom.external", 0);
}
示例#8
0
//--------- Begin of function Unit::ai_escape_fire --------//
//
// Move away if the unit currently stands on a burning ground.
//
int Unit::ai_escape_fire()
{
	if(cur_action!=SPRITE_IDLE)
		return 0;

	if(mobile_type!=UNIT_LAND)
		return 0;

	Location *locPtr = world.get_loc(next_x_loc(), next_y_loc());

	if( !locPtr->fire_str() )
		return 0;

	//--------------------------------------------//

	int checkLimit = 400; // checking for 400 location
	int xShift, yShift, checkXLoc, checkYLoc;
	int curXLoc = next_x_loc();
	int curYLoc = next_y_loc();

	for(int i=2; i<checkLimit; i++)
	{
		misc.cal_move_around_a_point(i, 20, 20, xShift, yShift);

		checkXLoc = curXLoc + xShift;
		checkYLoc = curYLoc + yShift;

		if(checkXLoc<0 || checkXLoc>=MAX_WORLD_X_LOC || checkYLoc<0 || checkYLoc>=MAX_WORLD_Y_LOC)
			continue;

		if(!locPtr->can_move(mobile_type))
			continue;

		locPtr = world.get_loc(checkXLoc, checkYLoc);

		if( locPtr->fire_str()==0 )		// move to a safe place now
		{
			move_to(checkXLoc, checkYLoc);
			return 1;
		}
	}

	return 0;
}
示例#9
0
void Monster::move_towards(int target_x, int target_y)
{
  Generic_map move_map = GAME.map->get_movement_map(get_intelligence());
  Pathfinder pf(move_map);
// Simple, dumb movement - suitable for zombies at least
  Point move;
  Point to(target_x, target_y), from = get_position();
  switch (get_intelligence()) {
    case INTEL_NULL:
    case INTEL_PLANT:
// Mobile plants just drunken walk.
      move.x = rng(posx - 1, posx + 1);
      move.y = rng(posy - 1, posy + 1);
      break;

    case INTEL_ZOMBIE:
      move = pf.get_step(PATH_LINE, from, to);
      break;

    case INTEL_ANIMAL:
    case INTEL_HUMAN:
      move = pf.get_step(PATH_A_STAR, from, to);
      break;

    default:
      debugmsg("No AI movement coded for Intel_level %s",
               intel_level_name(get_intelligence()).c_str());
  }

// TODO:  Add a "Stumble" flag that occasionally randomly picks, rather than
//        picking the best available.

  if (can_move_to( GAME.map, move.x, move.y )) {
    move_to( GAME.map, move.x, move.y );
// TODO: Add a "smashes terrain" flag, and if we can't move then smash
  } else if (GAME.map->is_smashable(move.x, move.y)) {
    std::string sound = GAME.map->smash(move.x, move.y, 
                                        base_attack().roll_damage());
    GAME.make_sound(sound, move.x, move.y);
    use_ap(100);
  } else {
    pause();
  }
}
示例#10
0
void move_to_str(Move move, char *string)
{
    int from = move_from(move);
    int to = move_to(move);
    int turn = move_turn(move);
    string[0] = (from % 10) - 1 + 'a';
    string[1] = 9 - (from / 10) + '1';
    string[2] = (to % 10) - 1 + 'a';
    string[3] = 9 - (to / 10) + '1';
    switch(get_value(turn))
    {
        case QUEEN : string[4] = 'q'; break;
        case ROOK  : string[4] = 'r'; break;
        case BISHOP: string[4] = 'b'; break;
        case KNIGHT: string[4] = 'n'; break;
        default:     string[4] = '\0';
    }
    string[5] = '\0';
}
示例#11
0
文件: slider.cpp 项目: PNCG/neuron
void Slider::drag(const Event& e) {
    SliderImpl& s = *impl_;
    if (!s.aborted_ && s.dragging_) {
        if (!s.showing_old_thumb_ && s.old_thumb_ != nil) {
            s.showing_old_thumb_ = true;
            Patch* p = s.thumb_patch_;
            Canvas* c = canvas();
            c->push_transform();
            c->transformer(transformer());
            Extension ext;
            ext.clear();
            s.old_thumb_->allocate(c, p->allocation(), ext);
            c->pop_transform();
        }
        Coord x, y;
        s.get_position(this, e, x, y);
        move_to(x - s.xoffset_, y - s.yoffset_);
    }
}
示例#12
0
void start_game()
{
	// p==1 then X   p==0  then  O
	check_draw();
	move_to(getPossibleWinningPos());
	draw_board();

	if (isWinning(comp))
	{
		gotoxy(30, 20);
		SetConsoleTextAttribute(h, FOREGROUND_BLUE);
		printf("Computer wins\n");
		SetConsoleTextAttribute(h, 7); //7 - WHITE
		_getch();
		menu();
	}
	else
		player_turn();
}
示例#13
0
static void move( pos next_pos )
{
    pos monster_pos = get_monster_pos();
    next_pos.on = is_monster_shited() ? BLOCK : get_( next_pos.row, next_pos.column );
    char body = MONSTER;
    if ( is_monster_catched() ) {
        body = DEAD;
        hero_dead();
    }

    play_monstro();
    move_to( monster_pos, next_pos, body );
    if ( is_monster_shited() ) {
        play_wet();
        usleep( 1000000 );
        veiudo.shited = 0;
    }
    set_monster_pos( next_pos );
}
示例#14
0
void MsqIRel::snap_to( Mesh::VertexHandle handle,
                           Vector3D& coordinate ) const
{
  int ierr, dim;
  iBase_EntityHandle geom;
  
  ierr = geom_from_mesh( handle, geom, dim );
  if (iBase_SUCCESS != ierr) {
    process_itaps_error( ierr );
    return;
  }
  
  if (dim < 3) {  
    ierr = move_to( geom, coordinate );
    if (iBase_SUCCESS != ierr) {
      process_itaps_error( ierr );
      return;
    }
  }
}
示例#15
0
文件: ui.c 项目: saleph/bus_depot
void move_assign_dialog()
{
    int side_no;
    char first_depot[256];
    prt(MV_ASSIGNMENT);
    prt(TYPE_BUS_SIDE_NO);
    scan_to_buf();
    if (!is_number(buffer)) {
        prt(NOT_A_NUMBER);
        return;
    }
    side_no = atoi(buffer);
    prt(FROM_DEPOT);
    scan_to_buf();
    strcpy(first_depot, buffer);
    prt(TO_DEPOT);
    scan_to_buf();
    prt(CLS);
    move_to(first_depot, side_no, buffer);
}
示例#16
0
TEST(function, assignment)
{
	int a = 0;
	func::function<void ()> increment = [&a]{ ++a; };
	increment();
	ASSERT_EQ(1, a);

	increment = [increment]{ increment(); increment(); };
	increment();
	ASSERT_EQ(3, a);

	increment = [increment]{ increment(); increment(); };
	increment();
	ASSERT_EQ(7, a);

	func::function<void ()> move_to = std::move(increment);
	ASSERT_FALSE(increment);
	move_to();
	ASSERT_EQ(11, a);
}
示例#17
0
void sorting_moves(Move *movelist, int n)
{
    int sorting_values[n];
    Entry *entry = hash_get_entry();
    Move hash_move = 0;
    if(entry != NULL)
        hash_move = entry->bestmove;
    for(int i = 0; i < n; i += 1)
    {
        Move i_move = movelist[i];
        if(i_move == hash_move)
        {
            sorting_values[i] = 10000000;
        }
        else if(move_broken(i_move))
        {
            int figure = board[move_from(i_move)];
            int broken = move_broken(i_move);
            sorting_values[i] = mvv_lva[figure][broken];
        }
        else
        {
            sorting_values[i] = history[board[move_from(i_move)]][move_to(i_move)];
        }
    }
    for(int i = 1; i < n; i += 1)
    {
        int j = i;
        while(sorting_values[j] > sorting_values[j - 1] && j > 0)
        {
            int tmp = sorting_values[j];
            sorting_values[j] = sorting_values[j - 1];
            sorting_values[j - 1] = tmp;
            
            Move tmp2 = movelist[j];
            movelist[j] = movelist[j - 1];
            movelist[j - 1] = tmp2;
            j -= 1;
        }
    }
}
示例#18
0
/**
 * Function circle
 * writes a non filled circle to output file
 * Plot one circle as segments (6 to 16 depending on its radius
 * @param aCentre = center coordinates
 * @param aDiameter = diameter of the circle
 * @param aFill = plot option (NO_FILL, FILLED_SHAPE, FILLED_WITH_BG_BODYCOLOR)
 * not used here: circles are always not filled the gerber. Filled circles are flashed
 * @param aWidth = line width
 */
void GERBER_PLOTTER::circle( wxPoint aCentre, int aDiameter, FILL_T aFill, int aWidth )
{
    wxASSERT( output_file );
    wxPoint   start, end;
    double    radius = aDiameter / 2;
    const int delta  = 3600 / 32; /* increment (in 0.1 degrees) to draw circles */

    start.x = aCentre.x + wxRound( radius );
    start.y = aCentre.y;
    set_current_line_width( aWidth );
    move_to( start );

    for( int ii = delta; ii < 3600; ii += delta )
    {
        end.x = aCentre.x + (int) ( radius * cos( DEG2RAD( (double)ii / 10.0 ) ) );
        end.y = aCentre.y + (int) ( radius * sin( DEG2RAD( (double)ii / 10.0 ) ) );
        line_to( end );
    }

    finish_to( start );
}
示例#19
0
void Slider::release(const Event& e) {
    SliderImpl& s = *impl_;
    if (s.dragging_) {
        if (s.showing_old_thumb_) {
            s.showing_old_thumb_ = false;
            s.old_thumb_->redraw();
        }
        s.dragging_ = false;
        if (s.aborted_) {
            s.aborted_ = false;
            return;
        }
        move_to(e.pointer_x() - s.xoffset_, e.pointer_y() - s.yoffset_);
        redraw_thumb();
        move(e);
        apply_adjustment(&Adjustable::commit_adjustment);
    } else if (s.stepper_ != nil) {
        s.stepper_->stop_stepping();
        s.stepper_ = nil;
        move(e);
    }
}
示例#20
0
    void add_path(VertexSource& vs, unsigned path_id=0)
    {
        double x;
        double y;

        unsigned flag;
        vs.rewind(path_id);
        while(!agg::is_stop(flag = vs.vertex(&x, &y)))
        {
            if(agg::is_vertex(flag))
            {
                if(agg::is_move_to(flag)) 
                {
                    move_to(int(x), int(y));
                }
                else 
                {
                    line_to(int(x), int(y));
                }
            }
        }
    }
void TicTac_Button::print() const
{
    canvas tt_btn;
    tt_btn.open(size_x, size_y);
    if(available)
    {
        gout << move_to(0, 0) << color(0, 0, 255) << box(size_x, size_y)
             << move_to(20, 20) << color(255, 255, 255) << box(size_x-40, size_y-40);
    }
    else
    {
        gout << move_to(0, 0) << color(155, 155, 155) << box(size_x, size_y);
        if(status==0) gout << move_to(20, 20) << color(255, 255, 255) << box(size_x-40, size_y-40);
        if(status==1) gout << move_to(20, 20) << color(255, 255, 0) << box(size_x-40, size_y-40);
        if(status==2) gout << move_to(20, 20) << color(255, 0, 0) << box(size_x-40, size_y-40);
    }
}
示例#22
0
void
EditorInputCenter::put_object() {
  auto tileselect = &(Editor::current()->tileselect);
  if (tileselect->object[0] == '#') {
    if (edited_path && tileselect->object == "#node") {
      if (edited_path->is_valid() && last_node_marker) {
        add_path_node();
      }
    }
    return;
  }
  GameObjectPtr game_object;
  try {
    game_object = ObjectFactory::instance().create(tileselect->object, sector_pos, LEFT);
  } catch(const std::exception& e) {
    log_warning << "Error creating object " << tileselect->object << ": " << e.what() << std::endl;
    return;
  }
  if (game_object == NULL)
    throw std::runtime_error("Creating " + tileselect->object + " object failed.");

  auto mo = dynamic_cast<MovingObject*> (game_object.get());
  if (!mo) {
    Editor::current()->layerselect.add_layer(game_object.get());
  }

  auto wo = dynamic_cast<worldmap_editor::WorldmapObject*> (game_object.get());
  if (wo) {
    wo->move_to(wo->get_pos() / 32);
  }

  try {
    Editor::current()->currentsector->add_object(game_object);
  } catch(const std::exception& e) {
    log_warning << "Error adding object " << tileselect->object << ": " << e.what() << std::endl;
    return;
  }
}
示例#23
0
/*
 * 显示商品列表
 */
static void show_list()
{
	int i, cnt;
	list_t *list;
	line_item_t *item;

	list = &cur_sale->item_list;

	/*
	 * 遍历商品列表
	 */
	i = cur_page * ITEM_PER_PAGE;

	for (cnt = 0; i < list_len(list) &&	cnt < ITEM_PER_PAGE; i++,cnt++) {

		list_get(list, i, &item);
		move_to(2, 8+cnt);

		printf(" ");

		if (cnt == item_selected) {
			color_on(INVERSE, BLACK, WHITE);
		}

		printf("%3d%6s   %-6s%6.2lf%5.1lf%4d %6.2lf",
			cnt,
			item->code,
			item->name,
			item->price,
			item->discount,
			item->count,
			item->total);

		if (cnt == item_selected) {
			color_off();
		}
	}
}
示例#24
0
文件: Game.cpp 项目: Zereges/2048RP
void Game::process_play(const play_event& pl_event)
{
    for (const auto& oper : pl_event)
    {
        if (oper.first == play_event::operation::MOVE)
            move_to(oper.second.first.first, oper.second.first.second, oper.second.second.first, oper.second.second.second);
        else if (oper.first == play_event::operation::MERGE)
            merge_to(oper.second.first.first, oper.second.first.second, oper.second.second.first, oper.second.second.second);
    }


    auto random_block = pl_event.random_block();
    spawn_block(random_block.first, random_block.second.first, random_block.second.second);

    if (!m_won)
        if (m_won = pl_event.won())
            won();

    if (pl_event.lost())
        game_over();

    m_score += pl_event.score();
}
示例#25
0
void show_time()
{
	static int i = 0;
	char time_str[TIME_STR_LEN] = {0, };
	
	cursor_save_location();

	time_t t = time(NULL);
	struct tm *cur_time;

	cur_time = localtime(&t);
	
	sprintf(time_str, "%02d:%02d:%02d",
		cur_time->tm_hour,
		cur_time->tm_min,
		cur_time->tm_sec);

	move_to(50, 20);
	printf("%s", time_str);
	fflush(stdout);

	cursor_restore_location();
}
void main()
{
	init_captain_planet_with_our_powers_combined();
	start_movement();
	CURRENT = MID;
	
	float cycle_start_time;
	while(!black_button())
	{
		//cbc_display_clear();
		cycle_start_time = CURRENT_TIME;
		DESTINATION=calculate_destination();
		printf("Setting Dest to: %d from: %d\n",DESTINATION,CURRENT);
		move_to(CURRENT,DESTINATION);
		CURRENT = DESTINATION;
		CHARGED = dock(CURRENT);
		printf("dock returned: %d\n", CHARGED);
		update_source_order(cycle_start_time);
		printf("SOURCE_ORDER: {%d,%d,%d} @ %f\n\n",SOURCE_ORDER[0],SOURCE_ORDER[1],SOURCE_ORDER[2],		cycle_start_time);
		sleep(.1);
	}
	serializer_disconnect();
}
示例#27
0
void redraw_line(lua_State *L) {
	static int alloc_size = 0;

	// Make sure we have enough memory for the syntax
	// highlighting
	if(line_len > alloc_size) {
		alloc_size = line_len + 256;
		syntax = realloc(syntax, alloc_size);
		memset(syntax, 127, line_len);
	}

	// Get the function onto the stack...
	lua_rawgeti(L, LUA_REGISTRYINDEX, function_index);
	lua_pushstring(L, line);
	lua_pushlightuserdata(L, (void *)syntax);
	lua_call(L, 2, 1);

	// Show the line...
	save_pos();
	move_to(0, 0);
	show_line();
	putp(clr_eol);
	restore_pos();
}
示例#28
0
文件: slider.cpp 项目: PNCG/neuron
void Slider::release(const Event& e) {
    SliderImpl& s = *impl_;
    if (s.dragging_) {
        if (s.showing_old_thumb_) {
            s.showing_old_thumb_ = false;
            s.old_thumb_->redraw();
        }
        s.dragging_ = false;
        if (s.aborted_) {
            s.aborted_ = false;
            return;
        }
        Coord x, y;
        s.get_position(this, e, x, y);
        move_to(x - s.xoffset_, y - s.yoffset_);
        redraw_thumb();
        move(e);
        apply_adjustment(&Adjustable::commit_adjustment);
    } else if (s.stepper_ != nil) {
        s.stepper_->stop_stepping();
        s.stepper_ = nil;
        move(e);
    }
}
示例#29
0
void monster::friendly_move(game *g)
{
 point next;
 bool moved = false;
 if (plans.size() > 0 && (plans[0].x != g->u.posx || plans[0].y != g->u.posy) &&
     (can_move_to(g, plans[0].x, plans[0].y) ||
     (g->m.has_flag(bashable, plans[0].x, plans[0].y) && has_flag(MF_BASHES)))){
  next = plans[0];
  plans.erase(plans.begin());
  moved = true;
 } else {
  moves -= 100;
  stumble(g, moved);
 }
 if (moved) {
  int mondex = g->mon_at(next.x, next.y);
  int npcdex = g->npc_at(next.x, next.y);
  if (mondex != -1 && g->z[mondex].friendly == 0 && type->melee_dice > 0)
   hit_monster(g, mondex);
  else if (npcdex != -1 && type->melee_dice > 0)
   hit_player(g, *g->active_npc[g->npc_at(next.x, next.y)]);
  else if (mondex == -1 && npcdex == -1 && can_move_to(g, next.x, next.y))
   move_to(g, next.x, next.y);
  else if ((!can_move_to(g, next.x, next.y) || one_in(3)) &&
           g->m.has_flag(bashable, next.x, next.y) && has_flag(MF_BASHES)) {
   std::string bashsound = "NOBASH"; // If we hear "NOBASH" it's time to debug!
   int bashskill = int(type->melee_dice * type->melee_sides);
   g->m.bash(next.x, next.y, bashskill, bashsound);
   g->sound(next.x, next.y, 18, bashsound);
   moves -= 100;
  } else if (g->m.move_cost(next.x, next.y) == 0 && has_flag(MF_DESTROYS)) {
   g->m.destroy(g, next.x, next.y, true);
   moves -= 250;
  }
 }
}
示例#30
0
文件: login.c 项目: dhanks/serpent
void         enter_arena (player * p, char *dummy)
{
   int          i, match = 0;

   p->flags |= P_PROMPT;
   move_to (p, mainroom);
   command_look (p, 0);
   channel = CHAN_SYSTEM;
   tell_player (p, "\n ~o~ Welcome to serpent %s! ~o~\n", p->name);
   if (p->flags & P_RECON)
   {
      tell_player (p, "\n [ reconnection complete. ]\n");
      p->flags &= ~P_RECON;
      vlog ("connections", "%s has reconnected.\n", p->name);
      if (p->dual == 1)
	 vwriter (p, 0, p->room, "[%s %s][dualplex two]\n", p->name, p->reconmsg);
      else
	 vwriter (p, 0, p->room, "[%s %s][dualplex one]\n", p->name, p->reconmsg);
   }
   else
   {
      channel = CHAN_SYSTEM;
      vlog ("connections", "%s has connected - %s (%s:%d)\n", p->name, p->sock.host, p->sock.ip, p->sock.port);
      if (p->dual == 1)
	 vwriter (p, 0, p->room, "[%s %s][dualplex two]\n", p->name, p->conmsg);
      else
	 vwriter (p, 0, p->room, "[%s %s][dualplex one]\n", p->name, p->conmsg);
   }
   for (i = 0; root_users[i].key; i++)
      if (!strcasecmp (p->name, root_users[i].key))
      {
	 match = 1;
	 tell_player (p, " Welcome, Administrator.\n");
	 p->residency |= RESIDENT;
	 p->residency |= BASE;
	 p->residency |= PSU;
	 p->residency |= SU;
	 p->residency |= LOWER_ADMIN;
	 p->residency |= ADMIN;
	 p->residency |= HCADMIN;
	 p->residency |= CODER;
	 p->residency |= SYSOP;
	 vlog ("admin", "%s connects from %s %s:%d\n", p->name, p->sock.host, p->sock.ip,
	       p->sock.port);
      }

   if (match == 0)
   {
      if (!(p->residency & RESIDENT))
	 tell_player (p, " [ you raise to level 1. ]\n");
      p->residency |= BASE;
   }
   if (system_flags & NO_NEWBIES)
      if (p->residency & PSU)
	 writep (p, " -=> We're currently closed to newbies.\n");
   if (system_flags & TEMP_CLOSED)
      writep (p, " -=> We're temporarily closed due to repair.\n");
   channel = 0;
   p->flags |= HERE;
   p->func = 0;
   return;
}