static void jack_add_ports(midi_stream_t *str) { midi_port_t *port; while (can_pass(sizeof(port), str->jack.new_ports, str->midi.new_ports) && str->jack.nports < MAX_PORTS) { jack_ringbuffer_read(str->jack.new_ports, (char*)&port, sizeof(port)); str->jack.ports[str->jack.nports++] = port; port->state = PORT_ADDED_TO_MIDI; jack_ringbuffer_write(str->midi.new_ports, (char*)&port, sizeof(port)); } }
bool path::move(int x, int y, int end_x, int end_y, int dir, int rest_movement_range, int rest_gas, bool left, bool right, const unit::ptr &u) { if(m_map->on_map(coord(x, y))) { const int move_costs = m_map->get_terrain(coord(x, y))->movement_costs(u->get_move_type()); if(move_costs != -1) { rest_movement_range -= move_costs; rest_gas -= move_costs; } else { //impassible return false; } if(rest_gas < 0 || rest_movement_range < 0) return false; if(can_pass(m_map, coord(x, y), u)) { if(x == end_x && y == end_y) { if(rest_movement_range == m_traverse->get_rest_mp(coord(x, y))) // Hält immer den kleinstmöglichen mp-Vebrauch { m_fuel_costs = u->fuel() - rest_gas; append(x, y); return true; } } //Wenn noch nicht gecheckt, oder weg mit weniger verbrauch gefunden. if(m_traverse->get_rest_mp(coord(x, y)) == -1 || m_traverse->get_rest_mp(coord(x, y)) <= rest_movement_range) { for(int i= -1; i < 2; i++) { bool done = false; //Verstehe ich selber nicht so ganz :D if(!((left == true && i == -1) || (right == true && i == 1))) { switch((dir+i)%4) { case -1: case 3: //0=north, 1=east, 2=south, 3=west done = move(x-1, y, end_x, end_y, 3, rest_movement_range, rest_gas, i==-1, i==1, u/*, current_terrain*/); break; case 0: done = move(x, y-1, end_x, end_y, 0, rest_movement_range, rest_gas, i==-1, i==1, u/*, current_terrain*/); break; case 1: done = move(x+1, y, end_x, end_y, 1, rest_movement_range, rest_gas, i==-1, i==1, u/*, current_terrain*/); break; case 2: done = move(x, y+1, end_x, end_y, 2, rest_movement_range, rest_gas, i==-1, i==1, u/*, current_terrain*/); break; } if(done) { append(x, y); return true; } } } } } // bool can:overdrive() } // bool on_map() return false; }