static void lcd_move_z() { if (encoderPosition != 0) { current_position[Z_AXIS] += float((int)encoderPosition) * move_menu_scale; if (current_position[Z_AXIS] < Z_MIN_POS) current_position[Z_AXIS] = Z_MIN_POS; if (current_position[Z_AXIS] > Z_MAX_POS) current_position[Z_AXIS] = Z_MAX_POS; encoderPosition = 0; prepare_move(); //plan_buffer_line(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS], 60, active_extruder); lcdDrawUpdate = 1; } if (lcdDrawUpdate) { lcd_implementation_drawedit(PSTR("Z"), ftostr31(current_position[Z_AXIS])); } if (LCD_CLICKED) { lcd_quick_feedback(); currentMenu = lcd_move_menu_axis; encoderPosition = 0; } }
// ------------------------------------------------------------------------ // do movement that's hidden // ------------------------------------------------------------------------ void t_army_mover::do_hidden_move() { if (m_is_visible) return; if (m_path.size() == 0) { finish_path(); return; } t_adventure_map const& map = *m_army->get_map(); t_player& player = map.get_player(); int team = player.get_team(); declare_timer( timer_1, "do_hidden_movement" ); while (!m_is_visible && !m_halted) { t_adventure_path_point& point = m_path[m_step]; m_army->move( point ); expend_movement( point.move_cost ); mark_eluded_armies(); if (m_step == m_path.size() - 1) { finish_path(); return; } trigger_event(); if (m_halted) return; m_is_visible = !m_army->hidden_by_fog_of_war( team ) && show_enemy_moves(); if (m_is_visible) break; // break here, because start_new_square will increment step. ++m_step; declare_timer( timer_2, "on_starting_new_square: hidden" ); on_starting_new_square(); } if (m_halted) return; m_army->set_action( k_adv_actor_action_walk ); m_distance = compute_overall_distance( m_path, m_step + 1 ); start_new_square(); prepare_move( 0 ); set_next_time( get_time() + get_delay() ); }
void FirmwareTest() { ECHO_EM("---------- FIRMWARE TEST --------------"); ECHO_EM("--------- by MarlinKimbra -------------"); ECHO_EV(MSG_FWTEST_01); ECHO_EV(MSG_FWTEST_02); ECHO_EV(MSG_FWTEST_YES_NO); serial_answer = ' '; while (serial_answer!='y' && serial_answer!='Y' && serial_answer!='n' && serial_answer!='N') { serial_answer = MYSERIAL.read(); } if (serial_answer=='y' || serial_answer=='Y') { ECHO_EV(MSG_FWTEST_03); ECHO_EM(" "); ECHO_EM("***** ENDSTOP X *****"); #if PIN_EXISTS(X_MIN) && (X_HOME_DIR == -1) if (!READ(X_MIN_PIN)^X_MIN_ENDSTOP_INVERTING) { ECHO_M("MIN ENDSTOP X: "); ECHO_EV(MSG_ENDSTOP_OPEN); } else { ECHO_M("X ENDSTOP "); ECHO_EM(MSG_FWTEST_ERROR); ECHO_M(MSG_FWTEST_INVERT); ECHO_M("#define X_MIN_ENDSTOP_LOGIC "); ECHO_M(MSG_FWTEST_INTO); #if MECH(CARTESIAN) ECHO_EM("Configuration_Cartesian.h"); #elif MECH(COREXY) ECHO_EM("Configuration_Core.h"); #elif MECH(COREXZ) ECHO_EM("Configuration_Core.h"); #elif MECH(DELTA) ECHO_EM("Configuration_Delta.h"); #elif MECH(SCARA) ECHO_EM("Configuration_Scara.h"); #endif return; } ECHO_V(MSG_FWTEST_PRESS); ECHO_EM("X"); ECHO_EV(MSG_FWTEST_YES); serial_answer = ' '; while (serial_answer!='y' && serial_answer!='Y' && !(READ(X_MIN_PIN)^X_MIN_ENDSTOP_INVERTING)) { serial_answer = MYSERIAL.read(); } if (READ(X_MIN_PIN)^X_MIN_ENDSTOP_INVERTING) { ECHO_M("MIN ENDSTOP X: "); ECHO_EV(MSG_ENDSTOP_HIT); } else { ECHO_M("X "); ECHO_EV(MSG_FWTEST_ENDSTOP_ERR); return; } #elif PIN_EXISTS(X_MAX) && X_HOME_DIR == 1 if (!READ(X_MAX_PIN)^X_MAX_ENDSTOP_INVERTING) { ECHO_M("MAX ENDSTOP X: "); ECHO_EV(MSG_ENDSTOP_OPEN); } else { ECHO_M("X ENDSTOP "); ECHO_EM(MSG_FWTEST_ERROR); ECHO_M(MSG_FWTEST_INVERT); ECHO_M("#define X_MAX_ENDSTOP_LOGIC "); ECHO_M(MSG_FWTEST_INTO); #if MECH(CARTESIAN) ECHO_EM("Configuration_Cartesian.h"); #elif MECH(COREXY) ECHO_EM("Configuration_Core.h"); #elif MECH(COREXZ) ECHO_EM("Configuration_Core.h"); #elif MECH(DELTA) ECHO_EM("Configuration_Delta.h"); #elif MECH(SCARA) ECHO_EM("Configuration_Scara.h"); #endif return; } ECHO_V(MSG_FWTEST_PRESS); ECHO_EM("X"); ECHO_EV(MSG_FWTEST_YES); serial_answer = ' '; while (serial_answer!='y' && serial_answer!='Y' && !(READ(X_MAX_PIN)^X_MAX_ENDSTOP_INVERTING)) { serial_answer = MYSERIAL.read(); } if (READ(X_MAX_PIN)^X_MAX_ENDSTOP_INVERTING) { ECHO_M("MAX ENDSTOP X: "); ECHO_EV(MSG_ENDSTOP_HIT); } else { ECHO_M("X "); ECHO_EV(MSG_FWTEST_ENDSTOP_ERR); return; } #elif X_HOME_DIR == -1 ECHO_M(MSG_FWTEST_ERROR); ECHO_M("!!! X_MIN_PIN "); ECHO_EM(MSG_FWTEST_NDEF); return; #elif X_HOME_DIR == 1 ECHO_M(MSG_FWTEST_ERROR); ECHO_M("!!! X_MAX_PIN "); ECHO_EM(MSG_FWTEST_NDEF); return; #endif ECHO_EM(" "); ECHO_EM("***** ENDSTOP Y *****"); #if PIN_EXISTS(Y_MIN) && Y_HOME_DIR == -1 if (!READ(Y_MIN_PIN)^Y_MIN_ENDSTOP_INVERTING) { ECHO_M("MIN ENDSTOP Y: "); ECHO_EV(MSG_ENDSTOP_OPEN); } else { ECHO_M("Y ENDSTOP "); ECHO_EM(MSG_FWTEST_ERROR); ECHO_M(MSG_FWTEST_INVERT); ECHO_M("#define Y_MIN_ENDSTOP_LOGIC "); ECHO_M(MSG_FWTEST_INTO); #if MECH(CARTESIAN) ECHO_EM("Configuration_Cartesian.h"); #elif MECH(COREXY) ECHO_EM("Configuration_Core.h"); #elif MECH(COREXZ) ECHO_EM("Configuration_Core.h"); #elif MECH(DELTA) ECHO_EM("Configuration_Delta.h"); #elif MECH(SCARA) ECHO_EM("Configuration_Scara.h"); #endif return; } ECHO_V(MSG_FWTEST_PRESS); ECHO_EM("Y"); ECHO_EV(MSG_FWTEST_YES); serial_answer = ' '; while (serial_answer!='y' && serial_answer!='Y' && !(READ(Y_MIN_PIN)^Y_MIN_ENDSTOP_INVERTING)) { serial_answer = MYSERIAL.read(); } if (READ(Y_MIN_PIN)^Y_MIN_ENDSTOP_INVERTING) { ECHO_M("MIN ENDSTOP Y: "); ECHO_EV(MSG_ENDSTOP_HIT); } else { ECHO_M("Y "); ECHO_EV(MSG_FWTEST_ENDSTOP_ERR); return; } #elif PIN_EXISTS(Y_MAX) && Y_HOME_DIR == 1 if (!READ(Y_MAX_PIN)^Y_MAX_ENDSTOP_INVERTING) { ECHO_M("MAX ENDSTOP Y: "); ECHO_EV(MSG_ENDSTOP_OPEN); } else { ECHO_M("Y ENDSTOP "); ECHO_EM(MSG_FWTEST_ERROR); ECHO_M(MSG_FWTEST_INVERT); ECHO_M("#define Y_MAX_ENDSTOP_LOGIC "); ECHO_M(MSG_FWTEST_INTO); #if MECH(CARTESIAN) ECHO_EM("Configuration_Cartesian.h"); #elif MECH(COREXY) ECHO_EM("Configuration_Core.h"); #elif MECH(COREXZ) ECHO_EM("Configuration_Core.h"); #elif MECH(DELTA) ECHO_EM("Configuration_Delta.h"); #elif MECH(SCARA) ECHO_EM("Configuration_Scara.h"); #endif return; } ECHO_V(MSG_FWTEST_PRESS); ECHO_EM("Y"); ECHO_EV(MSG_FWTEST_YES); serial_answer = ' '; while (serial_answer!='y' && serial_answer!='Y' && !(READ(Y_MAX_PIN)^Y_MAX_ENDSTOP_INVERTING)) { serial_answer = MYSERIAL.read(); } if (READ(Y_MAX_PIN)^Y_MAX_ENDSTOP_INVERTING) { ECHO_M("MAX ENDSTOP Y: "); ECHO_EV(MSG_ENDSTOP_HIT); } else { ECHO_M("Y "); ECHO_EV(MSG_FWTEST_ENDSTOP_ERR); return; } #elif Y_HOME_DIR == -1 ECHO_M(MSG_FWTEST_ERROR); ECHO_M("!!! Y_MIN_PIN "); ECHO_EM(MSG_FWTEST_NDEF); return; #elif Y_HOME_DIR == 1 ECHO_M(MSG_FWTEST_ERROR); ECHO_M("!!! Y_MAX_PIN "); ECHO_EM(MSG_FWTEST_NDEF); return; #endif ECHO_EM(" "); ECHO_EM("***** ENDSTOP Z *****"); #if PIN_EXISTS(Z_MIN) && Z_HOME_DIR == -1 if (!READ(Z_MIN_PIN)^Z_MIN_ENDSTOP_INVERTING) { ECHO_M("MIN ENDSTOP Z: "); ECHO_EV(MSG_ENDSTOP_OPEN); } else { ECHO_M("Z ENDSTOP "); ECHO_EM(MSG_FWTEST_ERROR); ECHO_M(MSG_FWTEST_INVERT); ECHO_M("#define Z_MIN_ENDSTOP_LOGIC "); ECHO_M(MSG_FWTEST_INTO); #if MECH(CARTESIAN) ECHO_EM("Configuration_Cartesian.h"); #elif MECH(COREXY) ECHO_EM("Configuration_Core.h"); #elif MECH(COREXZ) ECHO_EM("Configuration_Core.h"); #elif MECH(DELTA) ECHO_EM("Configuration_Delta.h"); #elif MECH(SCARA) ECHO_EM("Configuration_Scara.h"); #endif return; } ECHO_V(MSG_FWTEST_PRESS); ECHO_EM("Z"); ECHO_EV(MSG_FWTEST_YES); serial_answer = ' '; while (serial_answer!='y' && serial_answer!='Y' && !(READ(Z_MIN_PIN)^Z_MIN_ENDSTOP_INVERTING)) { serial_answer = MYSERIAL.read(); } if (READ(Z_MIN_PIN)^Z_MIN_ENDSTOP_INVERTING) { ECHO_M("MIN ENDSTOP Z: "); ECHO_EV(MSG_ENDSTOP_HIT); } else { ECHO_M("Z "); ECHO_EV(MSG_FWTEST_ENDSTOP_ERR); return; } #elif PIN_EXISTS(Z_MAX) && Z_HOME_DIR == 1 if (!READ(Z_MAX_PIN)^Z_MAX_ENDSTOP_INVERTING) { ECHO_M("MAX ENDSTOP Z: "); ECHO_EV(MSG_ENDSTOP_OPEN); } else { ECHO_M("Z ENDSTOP "); ECHO_EM(MSG_FWTEST_ERROR); ECHO_M(MSG_FWTEST_INVERT); ECHO_M("#define Z_MAX_ENDSTOP_LOGIC "); ECHO_M(MSG_FWTEST_INTO); #if MECH(CARTESIAN) ECHO_EM("Configuration_Cartesian.h"); #elif MECH(COREXY) ECHO_EM("Configuration_Core.h"); #elif MECH(COREXZ) ECHO_EM("Configuration_Core.h"); #elif MECH(DELTA) ECHO_EM("Configuration_Delta.h"); #elif MECH(SCARA) ECHO_EM("Configuration_Scara.h"); #endif return; } ECHO_V(MSG_FWTEST_PRESS); ECHO_EM("Z"); ECHO_EV(MSG_FWTEST_YES); serial_answer = ' '; while (serial_answer!='y' && serial_answer!='Y' && !(READ(Z_MAX_PIN)^Z_MAX_ENDSTOP_INVERTING)) { serial_answer = MYSERIAL.read(); } if (READ(Z_MAX_PIN)^Z_MAX_ENDSTOP_INVERTING) { ECHO_M("MAX ENDSTOP Z: "); ECHO_EV(MSG_ENDSTOP_HIT); } else { ECHO_M("Z "); ECHO_EV(MSG_FWTEST_ENDSTOP_ERR); return; } #elif Z_HOME_DIR == -1 ECHO_M(MSG_FWTEST_ERROR); ECHO_M("!!! Z_MIN_PIN "); ECHO_EM(MSG_FWTEST_NDEF); return; #elif Z_HOME_DIR == 1 ECHO_M(MSG_FWTEST_ERROR); ECHO_M("!!! Z_MAX_PIN "); ECHO_EM(MSG_FWTEST_NDEF); return; #endif ECHO_EM("ENDSTOP "); ECHO_M(MSG_FWTEST_OK); ECHO_EM(" "); } #if HAS(POWER_SWITCH) SET_OUTPUT(PS_ON_PIN); WRITE(PS_ON_PIN, PS_ON_AWAKE); #endif // Reset position to 0 st_synchronize(); for (int8_t i = 0; i < NUM_AXIS; i++) current_position[i] = 0; plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); ECHO_EM("***** TEST MOTOR *****"); ECHO_EV(MSG_FWTEST_ATTENTION); ECHO_EV(MSG_FWTEST_YES); serial_answer = ' '; while (serial_answer!='y' && serial_answer!='Y') { serial_answer = MYSERIAL.read(); } ECHO_EV(MSG_FWTEST_04); ECHO_EM(" "); ECHO_EM("***** MOTOR X *****"); destination[X_AXIS] = 10; prepare_move(); st_synchronize(); ECHO_EV(MSG_FWTEST_XAXIS); ECHO_EV(MSG_FWTEST_YES_NO); serial_answer = ' '; while (serial_answer!='y' && serial_answer!='Y' && serial_answer!='n' && serial_answer!='N') { serial_answer = MYSERIAL.read(); } if (serial_answer=='y' || serial_answer=='Y') { ECHO_EM("MOTOR X "); ECHO_M(MSG_FWTEST_OK); } else { ECHO_M(MSG_FWTEST_INVERT); ECHO_M("#define INVERT_X_DIR "); ECHO_M(MSG_FWTEST_INTO); #if MECH(CARTESIAN) ECHO_EM("Configuration_Cartesian.h"); #elif MECH(COREXY) ECHO_EM("Configuration_Core.h"); #elif MECH(COREXZ) ECHO_EM("Configuration_Core.h"); #elif MECH(DELTA) ECHO_EM("Configuration_Delta.h"); #elif MECH(SCARA) ECHO_EM("Configuration_Scara.h"); #endif return; } ECHO_EM(" "); ECHO_EM("***** MOTOR Y *****"); destination[Y_AXIS] = 10; prepare_move(); st_synchronize(); ECHO_EV(MSG_FWTEST_YAXIS); ECHO_EV(MSG_FWTEST_YES_NO); serial_answer = ' '; while (serial_answer!='y' && serial_answer!='Y' && serial_answer!='n' && serial_answer!='N') { serial_answer = MYSERIAL.read(); } if (serial_answer=='y' || serial_answer=='Y') { ECHO_EM("MOTOR Y "); ECHO_M(MSG_FWTEST_OK); } else { ECHO_M(MSG_FWTEST_INVERT); ECHO_M("#define INVERT_Y_DIR "); ECHO_M(MSG_FWTEST_INTO); #if MECH(CARTESIAN) ECHO_EM("Configuration_Cartesian.h"); #elif MECH(COREXY) ECHO_EM("Configuration_Core.h"); #elif MECH(COREXZ) ECHO_EM("Configuration_Core.h"); #elif MECH(DELTA) ECHO_EM("Configuration_Delta.h"); #elif MECH(SCARA) ECHO_EM("Configuration_Scara.h"); #endif return; } ECHO_EM(" "); ECHO_EM("***** MOTOR Z *****"); destination[Z_AXIS] = 10; prepare_move(); st_synchronize(); ECHO_EV(MSG_FWTEST_ZAXIS); ECHO_EV(MSG_FWTEST_YES_NO); serial_answer = ' '; while (serial_answer!='y' && serial_answer!='Y' && serial_answer!='n' && serial_answer!='N') { serial_answer = MYSERIAL.read(); } if (serial_answer=='y' || serial_answer=='Y') { ECHO_EM("MOTOR Z "); ECHO_M(MSG_FWTEST_OK); } else { ECHO_M(MSG_FWTEST_INVERT); ECHO_M("#define INVERT_Z_DIR "); ECHO_M(MSG_FWTEST_INTO); #if MECH(CARTESIAN) ECHO_EM("Configuration_Cartesian.h"); #elif MECH(COREXY) ECHO_EM("Configuration_Core.h"); #elif MECH(COREXZ) ECHO_EM("Configuration_Core.h"); #elif MECH(DELTA) ECHO_EM("Configuration_Delta.h"); #elif MECH(SCARA) ECHO_EM("Configuration_Scara.h"); #endif return; } ECHO_EM("MOTOR "); ECHO_M(MSG_FWTEST_OK); ECHO_EM(" "); ECHO_V(MSG_FWTEST_END); }
float Probe_Bed(float x_pos, float y_pos, int n) { //returns Probed Z average height float ProbeDepth[n]; float ProbeDepthAvg=0; //force bed heater off for probing int save_bed_targ = target_raw_bed; target_raw_bed = 0; WRITE(HEATER_BED_PIN,LOW); if (Z_HOME_DIR==-1) { //int probe_flag =1; float meas = 0; int fails = 0; saved_feedrate = feedrate; saved_feedmultiply = feedmultiply; feedmultiply = 100; //previous_millis_cmd = millis(); //Move to probe position if (x_pos >= 0) destination[X_AXIS]=x_pos; if (y_pos >= 0) destination[Y_AXIS]=y_pos; //destination[Z_AXIS]=current_position[Z_AXIS]; destination[Z_AXIS]=Z_HOME_RETRACT_MM; feedrate = 9000; prepare_move(); enable_endstops(true); SERIAL_ECHO("PRE-PROBE current_position[Z_AXIS]=");SERIAL_ECHOLN(current_position[Z_AXIS]); SERIAL_ECHOLN("Ready to probe..."); //Probe bed n times //*******************************************************************************************Bed Loop************************************* for(int8_t i=0; i < n ; i++) { //int z = 0; //fast probe //plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], current_position[Z_AXIS], current_position[E_AXIS]); destination[Z_AXIS] = 1.1 * Z_MAX_LENGTH * Z_HOME_DIR; feedrate = homing_feedrate[Z_AXIS]; plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder); st_synchronize(); //feedrate = 0.0; SERIAL_ECHO("current_position[Z_AXIS]=");SERIAL_ECHOLN(current_position[Z_AXIS]); if(endstop_z_hit == true) { SERIAL_ECHO("endstops_trigsteps[Z_AXIS]=");SERIAL_ECHOLN(endstops_trigsteps[Z_AXIS]); ProbeDepth[i]= endstops_trigsteps[Z_AXIS] / axis_steps_per_unit[Z_AXIS]; meas = ProbeDepth[i]; SERIAL_ECHO("ProbeDepth[");SERIAL_ECHO(i);SERIAL_ECHO("]=");SERIAL_ECHOLN(ProbeDepth[i]); //************************************************************************************************************* if (i > 0 ) //Second probe has happened so compare results { if (abs(ProbeDepth[i] - ProbeDepth[i - 1]) > .05) { //keep going until readings match to avoid sticky bed SERIAL_ECHO("Probing again: "); SERIAL_ECHO(ProbeDepth[i]); SERIAL_ECHO(" - "); SERIAL_ECHO(ProbeDepth[i - 1]);SERIAL_ECHO(" = "); SERIAL_ECHOLN(abs(ProbeDepth[i] - ProbeDepth[i - 1])); meas = ProbeDepth[i]; i--; i--; //Throw out both that don't match because we don't know which one is accurate if(fails++ > 4) break; } } }else{ SERIAL_ECHOLN("Probe not triggered."); i=n-1; } //************************************************************************************************************************************************** //fast move clear plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], meas, current_position[E_AXIS]); destination[Z_AXIS] = Z_HOME_RETRACT_MM; feedrate = fast_home_feedrate[Z_AXIS]; plan_buffer_line(destination[X_AXIS], destination[Y_AXIS], destination[Z_AXIS], destination[E_AXIS], feedrate/60, active_extruder); st_synchronize(); //check z stop isn't still triggered if ( READ(X_MIN_PIN) != X_ENDSTOPS_INVERTING ) { SERIAL_ECHOLN("Poking Stuck Bed:"); destination[Z_AXIS] = -1; prepare_move(); destination[Z_AXIS] = Z_HOME_RETRACT_MM; prepare_move(); st_synchronize(); i--; //Throw out this meaningless measurement } feedrate = 0; } //end probe loop #ifdef ENDSTOPS_ONLY_FOR_HOMING enable_endstops(false); #endif feedrate = saved_feedrate; feedmultiply = saved_feedmultiply; //previous_millis_cmd = millis(); endstops_hit_on_purpose(); } for(int8_t i=0;i<n;i++) { ProbeDepthAvg += ProbeDepth[i]; } ProbeDepthAvg /= n; SERIAL_ECHO("Probed Z="); SERIAL_ECHOLN(ProbeDepthAvg); SERIAL_ECHO("RAW current_position[Z_AXIS]=");SERIAL_ECHOLN(current_position[Z_AXIS]); plan_set_position(current_position[X_AXIS], current_position[Y_AXIS], Z_HOME_RETRACT_MM, current_position[E_AXIS]); current_position[Z_AXIS] = Z_HOME_RETRACT_MM; target_raw_bed = save_bed_targ; return ProbeDepthAvg; }
static void move_files(const char *src_pathname, const char *src_filename, const char *dest_pathname, const char *dest_filename, int movedirs) { char filepattern[MAXPATH],src_path_filename[MAXPATH],dest_path_filename[MAXPATH]; char tmp_filename[MAXFILE+MAXEXT],tmp_pathname[MAXPATH]; struct ffblk fileblock; int fileattrib, done; fileattrib=FA_RDONLY+FA_ARCH+FA_SYSTEM; if (movedirs || !ContainsWildCards(src_filename)) fileattrib +=FA_DIREC; /* Find first source file. */ strmcpy(filepattern, src_pathname, sizeof(filepattern)); strmcat(filepattern, src_filename, sizeof(filepattern)); done=findfirst(filepattern, &fileblock, fileattrib); while ((!done) && (fileblock.ff_name[0] == '.')) done = findnext(&fileblock); if (done) { char buffer[80]; #ifdef USE_KITTEN sprintf(buffer, "%s%s %s", src_pathname, src_filename, kittengets(1,0,"does not exist!")); #else sprintf(buffer, "%s%s does not exist!", src_pathname, src_filename); #endif /* error */ fprintf(stderr, " [%s]\n", buffer); } /* Check if destination directory has to be created. */ if ((!done) && !dir_exists(dest_pathname)) { strmcpy(tmp_pathname, dest_pathname, sizeof(tmp_pathname)); if (makedir(tmp_pathname) != 0) { #ifdef USE_KITTEN error(1,10,"Unable to create directory"); kittenclose(); #else error("Unable to create directory"); #endif exit(4); } /* end if. */ } /* end if. */ /* Copy files. */ while (!done) { /* Build source filename including path. */ strmcpy(src_path_filename, src_pathname, sizeof(src_path_filename)); strmcat(src_path_filename, fileblock.ff_name, sizeof(src_path_filename)); /* Build destination filename including path. */ strmcpy(dest_path_filename, dest_pathname, sizeof(dest_path_filename)); build_filename(tmp_filename, fileblock.ff_name, dest_filename); strmcat(dest_path_filename, tmp_filename, sizeof(dest_path_filename)); prepare_move(src_path_filename, dest_path_filename); do { done = findnext(&fileblock); } while ((!done) && (fileblock.ff_name[0] == '.')); } /* end while. */ } /* end move_files. */
// ------------------------------------------------------------------------ // Initialize from local or derived constructor. If use_army_path is false, // m_path must already be set up. // ------------------------------------------------------------------------ void t_army_mover::initialize( t_adventure_map_window* window, t_army* army, bool limit_move, t_adventure_path_finder const* path_finder, bool use_army_path ) { m_window = window; m_army = army; m_in_trigger = false; m_exceeded_move_limit = false; m_is_visible = false; m_movement_expended = 0; m_has_trigger = false; m_landing = false; m_limit_move = limit_move; m_original_position = army->get_position(); t_adventure_map& map = *army->get_map(); if ( use_army_path ) { t_adventure_path path = army->get_path(); int i; int move_left = army->get_movement(); bool is_boat = army->is_boat(); bool enemy_enforced_dest = false; t_creature_array const* restricting_enemy = NULL; t_adv_map_point restricted_dest; t_player* owner = army->get_owner(); bool is_computer = owner && owner->is_computer(); bool built_boat = false; bool hidden_enemy = false; // copy path until we run out of movement or encounter a trigger for (i = path.size() - 1; i >= 0; i--) { t_adventure_path_point& point = path[i]; // If the path goes into the attack radius of a hidden enemy // then truncate the path if ( path_finder != 0 && point.actual_enemy_adjacent && point.actual_enemy_distance > 0 && ( !point.visible_enemy_adjacent || point.actual_enemy_direction != point.visible_enemy_direction || point.actual_enemy_distance != point.visible_enemy_distance )) { restricting_enemy = find_enemy( map, *path_finder, point, *m_army ); if (restricting_enemy != 0) { int stealth_advantage; stealth_advantage = restricting_enemy->get_stealth_level() - m_army->get_anti_stealth_level(); if (stealth_advantage <= 0) break; if (stealth_advantage == 1 || restricting_enemy->get_owner_number() < 0) hidden_enemy = true; } } if ( path_finder && ( point.visible_restricts_movement || enemy_enforced_dest ) ) { if (enemy_enforced_dest) { if ( (point != restricted_dest) && (point != restricting_enemy->get_position()) ) break; } else { restricting_enemy = find_restrictive_enemy( map, *path_finder, point, *m_army ); if (restricting_enemy != NULL) enemy_enforced_dest = true; } restricted_dest = point + get_direction_offset( point.actual_enemy_direction ); } if (point.move_cost > move_left && limit_move) { m_actual_destination = point.last_point; m_exceeded_move_limit = true; break; } if (map.get_trigger_object( point.last_point, point.direction, army )) { m_has_trigger = true; m_trigger_point = point; } if (is_boat) { if (!map.is_ocean( point )) { m_landing = true; m_trigger_point = point; break; } } else if (is_computer && !m_has_trigger && map.is_ocean( point ) && !m_exceeded_move_limit) { t_adventure_tile const& last_tile = map[point]; t_hero* most_spell_points = NULL; if ( map.has_empty_boat( *m_army->get_owner() ) ) { int most_spell_points_count = 0; for (int i = 0; i < t_creature_array::k_size; i++) { t_hero* hero = (*m_army)[i].get_hero(); if (hero && hero->can_cast( k_spell_summon_boat )) { int cur_spell_points = hero->get_spell_points(); if ( (most_spell_points == NULL) || ( cur_spell_points > most_spell_points_count ) ) { most_spell_points = hero; most_spell_points_count = cur_spell_points; } } } } if (most_spell_points != NULL) { army->get_adventure_frame()->ai_cast_summon_boat( *m_army, *most_spell_points, point ); } else if (last_tile.ai_can_build_ship()) { t_adventure_object& object = map.get_adv_object(last_tile.ai_get_shipyard_id()); t_adv_shipyard* shipyard = dynamic_cast< t_adv_shipyard* >( &object ); t_adv_map_point boat_position; if (shipyard != NULL) built_boat = shipyard->find_new_ship_position( boat_position ); else { t_town* town = object.get_town(); if (town) { if ( !town->has( k_town_shipyard) ) { if (town->has_built()) break; town->buy_building( k_town_shipyard ); } built_boat = town->find_new_ship_position( boat_position, false ); } } if (built_boat) { t_army* boat = new t_army( army->get_creatures().get_leader().get_alignment() ); boat->set_owner( army->get_owner_number() ); boat->place( map, boat_position ); owner->spend( army->get_ai()->get_boat_cost() ); // This destination pick wouldn't have been // made unless he already had the cash. } } } if (map[point].blocks_army( *army, map, point.on_bridge, k_path_search_move_army )) break; // if the path actually enters a cell of an enemy, stop. if (point.actual_enemy_adjacent && point.actual_enemy_distance == 0) break; m_path.push_back( point ); if (m_has_trigger || built_boat || hidden_enemy) break; } } m_halted = false; m_step = -1; m_distance = compute_overall_distance( m_path, 0 ); if (m_path.size() == 0) { m_cell_distance = 0; m_crossing_point = -1; m_distance = 0; m_frames = 0; m_divisor = 1; m_delta = t_screen_point(0,0); m_offset = t_screen_point(0,0); m_distance_delta = 0; m_is_visible = !m_army->hidden_by_fog_of_war( map.get_player().get_team() ); } else { m_army->set_action( k_adv_actor_action_prewalk ); start_new_square(); prepare_move( 0 ); } set_next_time( get_time() ); }
// ------------------------------------------------------------------------ // class to move army on adventure map // ------------------------------------------------------------------------ void t_army_mover::do_movement() { int frame = m_army->get_frame(); int frame_count = m_army->get_frame_count(); t_adv_actor_action_id action = m_army->get_action(); t_uint32 current_time = get_time(); t_uint32 next_time = get_next_time() - get_delay(); t_counted_ptr<t_army_mover> ref = this; t_window_ptr adv_frame = m_window->get_frame(); // temporary reference to prevent the adventure frame // from removing itself if the game is over bool entered_new_square = false; declare_timer( timer_1, "do_movement" ); while ( m_frames > 0 && (!m_is_visible || elapsed_time( current_time, next_time ) >= 0) ) { m_offset += m_delta; m_cell_distance -= m_distance_delta; if (m_cell_distance <= m_crossing_point) { enter_new_square(); } m_army->set_frame_offset( m_offset / m_divisor ); frame++; if (action == k_adv_actor_action_walk && frame == frame_count) frame = 0; if (frame < frame_count) m_army->set_frame( frame ); m_frames--; if (m_is_visible) next_time += get_delay(); } if (m_is_visible) set_next_time( next_time ); // if m_frames is zero, we've hit the center of the cell, or we've // finished a prewalk / walk / postwalk sequence if (m_frames == 0) { if ((action == k_adv_actor_action_postwalk || m_path.size() == 0) && m_distance + m_cell_distance == 0) { finish_path(); return; } if (m_cell_distance == 0) { start_new_square(); entered_new_square = true; trigger_event(); if (m_halted) return; } else { m_cell_distance /= m_divisor; m_crossing_point /= m_divisor; } prepare_move( frame ); } if (entered_new_square) { declare_timer( timer_2, "on_starting_new_square" ); on_starting_new_square(); } }
// destination = [x,y,z,e] void nurbs_move (void) { destination[0] = x_out; destination[1] = y_out; // destination[3] = e_out; /* Extrusion Not Implemented */ prepare_move (); }