Esempio n. 1
0
static int
get_command(int who, char *s)
{
  int fact;                     /* who controls us now? */
  char *order;

  if (!valid_box(who) || kind(who) == T_deadchar)
    return FALSE;

  fact = player(who);

  if (fact == 0)
    return FALSE;

  order = top_order(fact, who);

/*
 *  If we don't have any orders, then fail.
 */

  if (order == NULL)
    return FALSE;

/*
 *  Update the player's last turn field so we know if he's been
 *  playing or not.
 */

  {
    struct entity_player *p;

    p = p_player(fact);
    p->last_order_turn = sysclock.turn;
  }

  assert(strlen(order) < LEN);  /* maybe not a valid assert */

  strncpy(s, order, LEN - 1);
  s[LEN - 1] = '\0';

  pop_order(fact, who);

  return TRUE;
}
Esempio n. 2
0
void AllOrder::tic(){
	execute_order();
	if(order_stack.back()->END())pop_order();
}
Esempio n. 3
0
//--------- Begin of function Unit::pre_process ---------//
//
void Unit::pre_process()
{
	//--- if the unit's hit point drops to 0, it dies now ---//

	if( hit_points <= 0 )
	{
		set_die();
		return;
	}

	//------- process fog of war ----------//

	visit_area();

	//------ process unit_mode -------//
#ifdef DEBUG
	long startTime;
#endif

	switch( unit_mode )
	{
		case UNIT_MODE_TOWN_DEFENDER:
#ifdef DEBUG
			startTime = m.get_time();
#endif
			process_mode_town_defender();
#ifdef DEBUG
			unit_process_town_defender_profile_time += m.get_time() - startTime;
#endif
			break;

		case UNIT_MODE_CAMP_DEFENDER:
#ifdef DEBUG
			startTime = m.get_time();
#endif
			process_mode_camp_defender();
#ifdef DEBUG
			unit_process_camp_defender_profile_time += m.get_time() - startTime;
#endif
			break;

		case UNIT_MODE_REBEL:
#ifdef DEBUG
			startTime = m.get_time();
#endif
			process_mode_rebel();
#ifdef DEBUG
			unit_process_rebel_profile_time += m.get_time() - startTime;
#endif
			break;
	}

	//--- if the current order has been reset and there is a pushed order, pop the order ---//

	if( cur_order.mode==0 && has_pushed_order() )
   	pop_order();

	//-------- process unit order now -------//

	switch( cur_order.mode )
	{
		case UNIT_MOVE:		// nothing to do with move mode, as UnitB already takes care of it
#ifdef DEBUG
			startTime = m.get_time();
#endif
			execute_move();
#ifdef DEBUG
			unit_execute_move_profile_time += m.get_time() - startTime;
#endif
			break;

		case UNIT_ATTACK:
#ifdef DEBUG
			startTime = m.get_time();
#endif
			execute_attack();
#ifdef DEBUG
			unit_execute_attack_profile_time += m.get_time() - startTime;
#endif
			break;

		case UNIT_BUILD_FIRM:
#ifdef DEBUG
			startTime = m.get_time();
#endif
			execute_build_firm();
#ifdef DEBUG
			unit_execute_build_firm_profile_time += m.get_time() - startTime;
#endif
			break;

		case UNIT_SETTLE_TOWN:
#ifdef DEBUG
			startTime = m.get_time();
#endif
			execute_settle_town();
#ifdef DEBUG
			unit_execute_settle_town_profile_time += m.get_time() - startTime;
#endif
			break;

		case UNIT_ASSIGN:
#ifdef DEBUG
			startTime = m.get_time();
#endif
			execute_assign();
#ifdef DEBUG
			unit_execute_assign_profile_time += m.get_time() - startTime;
#endif
			break;

		case UNIT_GO_CAST_POWER:
#ifdef DEBUG
			startTime = m.get_time();
#endif
			execute_go_cast_power();
#ifdef DEBUG
			unit_cast_power_profile_time += m.get_time() - startTime;
#endif
			break;

		case UNIT_TRANSFORM_FORTRESS:
#ifdef DEBUG
			startTime = m.get_time();
#endif
			execute_transform_fortress();
#ifdef DEBUG
			unit_transform_fortress_profile_time += m.get_time() - startTime;
#endif
			break;
	}
}
Esempio n. 4
0
void AllOrder::clean_order(){
	while(order_stack.size()>1){
		pop_order();
	}
}