Exemple #1
0
bool send_monitor_update(const client_list *cClientTable, monitor_list *mMonitorTable,
monitor_event eEvent, const data_list *dData)
{
	if (!cClientTable || !mMonitorTable) return false;

	monitor_send_list sending_list;

	if (!get_event_current_clients(mMonitorTable->events, *cClientTable, eEvent, sending_list))
	return true;

	command_transmit monitor_command;
	if (!monitor_command.set_command(new proto_monitor_data(eEvent, dData)))
	return false;

	if (!monitor_command.command_ready()) return false;

	for (unsigned int I = 0; I < sending_list.size(); I++)
	{
	monitor_command.target_entity = sending_list[I]->client_name;
	monitor_command.orig_entity   = entity_name();

	if (monitor_command.command_sendable())
	send_protected_output(sending_list[I]->attached_client, &monitor_command);
	}

	return true;
}
Exemple #2
0
bool send_exit_update(const client_list *cClientTable, monitor_list *mMonitorTable,
entity_handle cClient, text_info nName)
{
	if (!cClientTable || !mMonitorTable) return false;

	exit_send_list sending_list;

	if (!get_exit_current_clients(mMonitorTable->exits, *cClientTable, cClient, nName, sending_list))
	return true;

	command_transmit monitor_command;


	for (unsigned int I = 0; I < sending_list.size(); I++)
	{
	if ( !monitor_command.set_command(new proto_resource_exit(sending_list[I].value().c_str())) ||
	     !monitor_command.command_ready() )
	continue;

	monitor_command.target_entity = sending_list[I].key()->client_name;
	monitor_command.orig_entity   = entity_name();

	if (monitor_command.command_sendable() &&
	  send_protected_output(sending_list[I].key()->attached_client, &monitor_command))
    log_server_client_exit_sent(sending_list[I].key()->process_id,
      sending_list[I].key()->logging_name(), sending_list[I].value().c_str());
	}

	return true;
}
Exemple #3
0
CubitStatus RefEdge::get_center_radius( CubitVector& center, double& radius )
{
   Curve* curve_ptr = get_curve_ptr();

   if( curve_ptr != NULL )
   {

      if( curve_ptr->geometry_type() != ARC_CURVE_TYPE &&
          curve_ptr->geometry_type() != ELLIPSE_CURVE_TYPE )
         return CUBIT_FAILURE;

      if( curve_ptr->get_center_radius( center, radius ) == CUBIT_FAILURE )
         return CUBIT_FAILURE;
   }
   else 
   {
      PRINT_WARNING("In RefEdge::get_center_radius\n"
                    "         %s (curve %d) is not associated with a valid\n"
                    "         underlying geoemtric Curve\n",
                    entity_name().c_str(), id()) ;
      return CUBIT_FAILURE ;
   }
   
   return CUBIT_SUCCESS;
}
Exemple #4
0
CubitStatus RefEdge::get_point_direction( CubitVector& origin, CubitVector& direction )
{
   Curve* curve_ptr = get_curve_ptr();

   if( curve_ptr != NULL )
   {

      if( curve_ptr->geometry_type() != STRAIGHT_CURVE_TYPE ) 
         return CUBIT_FAILURE;

      if( curve_ptr->get_point_direction( origin, direction ) == CUBIT_FAILURE )
      {
         origin = start_coordinates();
         direction = end_coordinates() - origin;
         direction.normalize();
      }
   }
   else 
   {
      PRINT_WARNING("In RefEdge::get_point_direction\n"
                    "         %s (curve %d) is not associated with a valid\n"
                    "         underlying geometric Curve\n",
                    entity_name().c_str(), id()) ;
      return CUBIT_FAILURE ;
   }
   
   if (curve_ptr->bridge_sense() == CUBIT_REVERSED)
     direction = -direction;
   
   return CUBIT_SUCCESS;

}
Exemple #5
0
CubitBoolean RefEdge::is_tolerant()
{
   Curve* curve_ptr = get_curve_ptr();
   if (curve_ptr == NULL) {
      PRINT_WARNING("\tWARNING: Null underlying curve for %s, (%s %d)\n",
         entity_name().c_str(), class_name(), id());
      return CUBIT_FALSE;
   }

   return curve_ptr->is_tolerant();
}
Exemple #6
0
CJsonNode g_GenericStatToJson(CNetServer server,
        ENetScheduleStatTopic topic, bool verbose)
{
    string stat_cmd(s_StatTopics[topic].command);
    CTempString prefix(s_StatTopics[topic].record_prefix);
    CTempString entity_name(s_StatTopics[topic].entity_name);

    if (verbose)
        stat_cmd.append(" VERBOSE");

    CNetServerMultilineCmdOutput output(server.ExecWithRetry(stat_cmd, true));

    CJsonNode entities(CJsonNode::NewArrayNode());
    CJsonNode entity_info;
    CJsonNode array_value;

    string line;

    while (output.ReadLine(line)) {
        if (NStr::StartsWith(line, prefix)) {
            if (entity_info)
                entities.Append(entity_info);
            entity_info = CJsonNode::NewObjectNode();
            entity_info.SetString(entity_name, UnquoteIfQuoted(
                    CTempString(line.data() + prefix.length(),
                    line.length() - prefix.length())));
        } else if (entity_info && NStr::StartsWith(line, "  ")) {
            if (NStr::StartsWith(line, "    ") && array_value) {
                array_value.AppendString(UnquoteIfQuoted(
                        NStr::TruncateSpaces(line, NStr::eTrunc_Begin)));
            } else {
                if (array_value)
                    array_value = NULL;
                CTempString key, value;
                NStr::SplitInTwo(line, ":", key, value);
                NormalizeStatKeyName(key);
                string key_norm(key);
                value = NStr::TruncateSpaces_Unsafe(value, NStr::eTrunc_Begin);
                if (value.empty())
                    entity_info.SetByKey(key_norm, array_value =
                            CJsonNode::NewArrayNode());
                else
                    entity_info.SetByKey(key_norm, CJsonNode::GuessType(value));
            }
        }
    }
    if (entity_info)
        entities.Append(entity_info);

    return entities;
}
Exemple #7
0
static void collision_detection_coins() {
  
  /* We simply check if the player intersects with the coins */
  
  character* main_char = entity_get("main_char");
  
  vec2 top_left = vec2_add(main_char->position, vec2_new(-TILE_SIZE, -TILE_SIZE));
  vec2 bottom_right = vec2_add(main_char->position, vec2_new(TILE_SIZE, TILE_SIZE));
  
  /* Again we collect pointers to all the coin type entities */
  int num_coins = 0;
  coin* coins[COIN_COUNT];
  entities_get(coins, &num_coins, coin); 
  
  for(int i = 0; i < num_coins; i++) {
    /* Check if they are within the main char bounding box */
    if ((coins[i]->position.x > top_left.x) &&
        (coins[i]->position.x < bottom_right.x) &&
        (coins[i]->position.y > top_left.y) && 
        (coins[i]->position.y < bottom_right.y)) {
      
      /* Remove them from the entity manager and delete */
      char* coin_name = entity_name(coins[i]);
      entity_delete(coin_name);
      
      /* Play a nice twinkle sound */
      audio_sound_play(asset_get_as(P("./sounds/coin.wav"), sound), 0);
      
      /* Add some score! */
      level_score += 10;
      
      /* Update the ui text */
      ui_button* score = ui_elem_get("score");
      sprintf(score->label->string, "Score %06i", level_score);
      ui_text_draw(score->label);
    }
  }
  
  
  ui_button* victory = ui_elem_get("victory");
  
  /* if all the coins are gone and the victory rectangle isn't disaplayed then show it */
  if ((entity_type_count(coin) == 0) && (!victory->active)) {
    ui_button* victory = ui_elem_get("victory");
    ui_button* new_game = ui_elem_get("new_game");
    victory->active = true;
    new_game->active = true;
  }
  
}
Exemple #8
0
int RefEdge::validate()
{
    //- This function determines whether the entity is valid.
    //- Several types of checks can be done, 
  int error = 0;
  
    // Perform general RefEntity checks (measure > 0)
  error += RefEntity::validate();
  
    // Pass through to curve and add in its validation
  Curve *curve = get_curve_ptr();
  
    // check curve ptr
  if (curve != NULL) {
      // Check underlying curve
    DLIList <TopologyEntity*> bad_entities;
    error += curve->validate(entity_name(),bad_entities);
  } else {
    PRINT_WARNING("\tWARNING: Null underlying curve for %s, (%s %d)\n",
                  entity_name().c_str(), class_name(), id());
    error++;
  }
  return error;
}
text_info get_client_name()
{ return entity_name(); }