Пример #1
0
void raw_tcp_connection::user_on_tcp_connection_read()
{
	// We may receive multiple packets in the same TCP chunk. If one of them is
	// a DTLS Close Alert this would be closed (close() called) so we cannot call
	// our listeners anymore.
	if (is_closing())
		return;

	m_listener->on_data_recv(this, m_buffer, m_buffer_data_len);

	m_buffer_data_len = 0;
}
Пример #2
0
/**
 * @brief Starts closing the door and plays the corresponding animations.
 *
 * Nothing is done if the door is already in the process of being closed.
 */
void Door::close() {

  if (is_closed() || is_closing()) {
    // The door is already closed or being closed: nothing to do.
    return;
  }

  set_closing();

  if (is_saved()) {
    get_savegame().set_boolean(savegame_variable, false);
  }
}
Пример #3
0
/**
 * @brief Enables or disables the dynamic tiles related to this door.
 *
 * The dynamic tiles impacted by this function are the ones whose prefix is the door's name
 * followed by "_closed" or "_open", depending on the door state.
 */
void Door::update_dynamic_tiles() {

  std::list<MapEntity*> tiles = get_entities().get_entities_with_prefix(DYNAMIC_TILE, get_name() + "_closed");
  std::list<MapEntity*>::iterator it;
  for (it = tiles.begin(); it != tiles.end(); it++) {
    DynamicTile* tile = static_cast<DynamicTile*>(*it);
    tile->set_enabled(is_closed() || is_opening());
  }

  tiles = get_entities().get_entities_with_prefix(DYNAMIC_TILE, get_name() + "_open");
  for (it = tiles.begin(); it != tiles.end(); it++) {
    DynamicTile* tile = static_cast<DynamicTile*>(*it);
    tile->set_enabled(is_open() || is_closing());
  }
}
Пример #4
0
/* https://stackoverflow.com/a/2718114/6049386 , MIT, Feb 2018 */
static const char *match(const char *str)
{
   if (*str == '\0' || is_closing(*str))
      return str;

   if (is_opening(*str)) {
      const char *closer = match(str + 1);

      if (is_matching(*str, *closer))
         return match(closer + 1);

      return str;
   }

   return match(++str);
}