/*-----------------------------------------------------------------------------------*/ char server_push(const struct output_handler_t *push_handler /*CONST_VAR*/) { if(push_handler->handler_comet) { FOR_EACH_CONN(conn, { if(IS_HTTP(conn) && conn->output_handler == push_handler) { conn->protocol.http.comet_send_ack = 0; UI32(conn->protocol.http.final_outseqno) = UI32(conn->protocol.http.next_outseqno) - 1; } }) return 1;
/*-----------------------------------------------------------------------------------*/ char something_to_send(const struct http_connection *connection) { if(!connection->output_handler) return 0; if(CONST_UI8(connection->output_handler->handler_type) == type_control #ifndef DISABLE_COMET || connection->comet_send_ack == 1 #endif ) { return 1; } else { return connection->tcp_state == tcp_established && UI32(connection->next_outseqno) != UI32(connection->final_outseqno); } }
/*! \author Luxor */ void cPath::exec() { P_CHAR pc = pointers::findCharBySerial( pc_serial ); UI32 min_cost, curr_cost, heuristic, loops = 0; NODE_LIST::iterator it; while( loops < MAX_PATH_INTERNAL_LOOPS ) { if ( currNode->pos == m_finalPos ) { m_pathFound = true; break; } // Look for tiles reachable by currNode, add them to the open list addReachableNodes( currNode ); // Drop the current node in the closed list dropToClosedList( currNode ); if ( open_list.empty() ) { m_pathFound = true; break; } for ( it = open_list.begin(); it != open_list.end(); it++ ) { loops++; if ( it == open_list.begin() ) { min_cost = (*it)->cost + ( UI32( dist( (*it)->pos, m_finalPos ) ) * OBLIQUE_COST ); if ( (*it)->pos.z != m_finalPos.z ) min_cost += Z_COST * (abs( SI16((*it)->pos.z - m_finalPos.z )) / 2); nextNode = (*it); continue; } curr_cost = (*it)->cost + UI32( dist( (*it)->pos, m_finalPos ) ) * OBLIQUE_COST; if ( (*it)->pos.z != m_finalPos.z ) curr_cost += Z_COST * (abs( SI16((*it)->pos.z - m_finalPos.z) ) / 2); if ( curr_cost < min_cost ) { min_cost = curr_cost; nextNode = (*it); } } // // Heuristic and possible path improvement // heuristic = UI32( dist( currNode->parentNode->pos, nextNode->pos, false ) ); if ( heuristic == 1 ) { // The nodes are adjacent heuristic = 0; Location parent = currNode->parentNode->pos; Location next = nextNode->pos; LOGICAL bOk = false; if ( abs( SI16(parent.x - next.x) ) + abs( SI16(parent.y - next.y) ) == 1 ) heuristic = STRAIGHT_COST; else heuristic = OBLIQUE_COST; if ( heuristic < abs( SI16(nextNode->cost - currNode->parentNode->cost) ) ) bOk = true; if ( parent.z != next.z ) { next.z = parent.z; if ( isWalkable( next, WALKFLAG_ALL, pc ) == illegal_z ) // nextNode is not walkable by parentNode bOk = false; } if ( bOk ) nextNode->parentNode = currNode->parentNode; } currNode = nextNode; loops++; } m_loops += loops; if ( m_loops > MAX_PATH_TOTAL_LOOPS ) m_pathFound = true; if ( m_pathFound ) { if ( path_list.empty() ) { while( currNode->pos != m_startPos && currNode->cost != 0 && m_loops >= 0 ) { path_list.push_front( currNode->pos ); currNode = currNode->parentNode; m_loops--; } path_list.push_front( currNode->pos ); } else return; } }