void user_move (void) { int i, sec, sec_start; piece_type_t n; piece_info_t *obj, *next_obj; int prod; /* * First we loop through objects to update the user's view * of the world and perform any other necessary processing. * We would like to have the world view up to date before * asking the user any questions. This means that we should * also scan through all cities before possibly asking the * user what to produce in each city. */ for (n = FIRST_OBJECT; n < NUM_OBJECTS; n++) for (obj = user_obj[n]; obj != NULL; obj = obj->piece_link.next) { obj->moved = 0; /* nothing moved yet */ scan (user_map, obj->loc); /* refresh user's view of world */ } /* produce new hardware */ for (i = 0; i < NUM_CITY; i++) if (city[i].owner == USER) { scan (user_map, city[i].loc); prod = city[i].prod; if (prod == NOPIECE) { /* need production? */ set_prod (&(city[i])); /* ask user what to produce */ } else if (city[i].work++ >= (long)piece_attr[prod].build_time) { info("City at %d has completed %s.", city[i].loc, piece_attr[prod].article); produce (&city[i]); /* produce should set object.moved to 0 */ } } /* move all satellites */ for (obj = user_obj[SATELLITE]; obj != NULL; obj = next_obj) { next_obj = obj->piece_link.next; move_sat (obj); } sec_start = cur_sector (); /* get currently displayed sector */ if (sec_start == -1) sec_start = 0; /* loop through sectors, moving every piece in the sector */ for (i = sec_start; i < sec_start + NUM_SECTORS; i++) { sec = i % NUM_SECTORS; sector_change (); /* allow screen to be redrawn */ for (n = FIRST_OBJECT; n < NUM_OBJECTS; n++) /* loop through obj lists */ for (obj = user_obj[move_order[n]]; obj != NULL; obj = next_obj) { /* loop through objs in list */ next_obj = obj->piece_link.next; if (!obj->moved) /* object not moved yet? */ if (loc_sector (obj->loc) == sec) /* object in sector? */ piece_move (obj); /* yup; move the object */ } if (cur_sector() == sec) { /* is sector displayed? */ print_sector_u (sec); /* make screen up-to-date */ } } if (save_movie) save_movie_screen (); }
bool map_menu_event_run(int cmd) { d3ang rot_ang; switch (cmd) { // file menu case map_menu_item_FileSave: file_save_map(); return(TRUE); case map_menu_item_FileQuit: if (file_close_map()) { os_application_quit(); } return(TRUE); // edit menu case map_menu_item_EditUndo: map_undo_pull(); return(TRUE); case map_menu_item_EditDelete: piece_delete(); return(TRUE); case map_menu_item_EditDuplicate: piece_duplicate(); return(TRUE); case map_menu_item_EditSelectMore: piece_select_more(); return(TRUE); // view menu case map_menu_item_ViewFront: view_face_front(); main_wind_draw(); break; case map_menu_item_ViewLeft: view_face_left(); main_wind_draw(); break; case map_menu_item_ViewRight: view_face_right(); main_wind_draw(); break; case map_menu_item_ViewBack: view_face_back(); main_wind_draw(); break; case map_menu_item_ViewTop: view_face_top(); main_wind_draw(); break; case map_menu_item_ViewBottom: view_face_bottom(); main_wind_draw(); break; case map_menu_item_ViewPerspective: view_perspective_ortho(FALSE); main_wind_menu_update(); main_wind_draw(); return(TRUE); case map_menu_item_ViewOrtho: view_perspective_ortho(TRUE); main_wind_menu_update(); main_wind_draw(); return(TRUE); case map_menu_item_ViewUVLayer1: view_set_uv_layer(uv_layer_normal); main_wind_menu_update(); main_wind_draw(); return(TRUE); case map_menu_item_ViewUVLayer2: view_set_uv_layer(uv_layer_light_map); main_wind_menu_update(); main_wind_draw(); return(TRUE); case map_menu_item_ViewGotoSelect: map_view_goto_select(); main_wind_draw(); return(TRUE); case map_menu_item_ViewGotoMapCenter: map_view_goto_map_center(view_get_current_view()); main_wind_draw(); return(TRUE); case map_menu_item_ViewClip: view_flip_clip(); main_wind_menu_update(); main_wind_draw(); return(TRUE); case map_menu_item_ViewShowHideLiquids: select_remove_type(item_map_liquid); state.map.show_liquid=!state.map.show_liquid; main_wind_menu_update(); main_wind_draw(); break; case map_menu_item_ViewShowHideSpots: select_remove_type(item_map_spot); select_remove_type(item_map_scenery); state.map.show_object=!state.map.show_object; main_wind_menu_update(); main_wind_draw(); break; case map_menu_item_ViewShowHideLights: select_remove_type(item_map_light); select_remove_type(item_map_sound); select_remove_type(item_map_particle); state.map.show_lightsoundparticle=!state.map.show_lightsoundparticle; main_wind_menu_update(); main_wind_draw(); break; case map_menu_item_ViewShowHideNodes: select_remove_type(item_map_node); state.map.show_node=!state.map.show_node; main_wind_menu_update(); main_wind_draw(); break; case map_menu_item_ViewShowHideMovements: state.map.show_movements=!state.map.show_movements; main_wind_menu_update(); main_wind_draw(); break; case map_menu_item_ViewSplitHorizontal: view_split_horizontal(); main_wind_menu_update(); main_wind_draw(); break; case map_menu_item_ViewSplitVertical: view_split_vertical(); main_wind_menu_update(); main_wind_draw(); break; case map_menu_item_ViewRemoveSplit: view_split_remove(); main_wind_menu_update(); main_wind_draw(); break; // map menu case map_menu_item_MapRaiseY: map_mesh_move_all(0,-2000,0); main_wind_draw(); return(TRUE); case map_menu_item_MapLowerY: map_mesh_move_all(0,2000,0); main_wind_draw(); return(TRUE); case map_menu_item_MapCenter: map_mesh_center_all(); main_wind_draw(); return(TRUE); case map_menu_item_MapResetUV: map_mesh_reset_uv_all(); main_wind_draw(); return(TRUE); case map_menu_item_MapResetNormals: os_set_wait_cursor(); map_recalc_normals(&map,FALSE); os_set_arrow_cursor(); main_wind_draw(); return(TRUE); case map_menu_item_MapSortMeshPolys: os_set_wait_cursor(); map_mesh_sort_polys(&map); os_set_arrow_cursor(); main_wind_draw(); return(TRUE); case map_menu_item_ClearLightMaps: light_maps_clear(); view_set_uv_layer(uv_layer_normal); main_wind_menu_update(); main_wind_draw(); return(TRUE); case map_menu_item_BuildLightMaps: if (light_maps_create()) { view_set_uv_layer(uv_layer_light_map); main_wind_menu_update(); main_wind_draw(); } return(TRUE); case map_menu_item_BuildLiquidReflectionMaps: liquid_reflection_maps_create(); return(TRUE); case map_menu_item_AutoGenerateTextures: view_map_auto_generate_textures(); return(TRUE); case map_menu_item_AutoGenerateMap: view_map_auto_generate_start(); return(TRUE); case map_menu_item_Run: launch_engine(); return(TRUE); // mesh menu case map_menu_item_MeshCombine: piece_combine_mesh(); main_wind_draw(); return(TRUE); case map_menu_item_MeshSplit: piece_split_mesh(); main_wind_draw(); return(TRUE); case map_menu_item_MeshTesselate: piece_tesselate(TRUE); return(TRUE); case map_menu_item_MeshDistort: piece_distort(); return(TRUE); case map_menu_item_MeshResize: piece_resize(); return(TRUE); case map_menu_item_MeshForceGrid: piece_force_grid(); return(TRUE); case map_menu_item_MeshFlipX: piece_flip(TRUE,FALSE,TRUE); return(TRUE); case map_menu_item_MeshFlipY: piece_flip(FALSE,TRUE,FALSE); return(TRUE); case map_menu_item_MeshFlipZ: piece_flip(FALSE,FALSE,TRUE); return(TRUE); case map_menu_item_MeshRotateX: rot_ang.x=90.0f; rot_ang.y=rot_ang.z=0.0f; piece_rotate(&rot_ang); return(TRUE); case map_menu_item_MeshRotateY: rot_ang.y=90.0f; rot_ang.x=rot_ang.z=0.0f; piece_rotate(&rot_ang); return(TRUE); case map_menu_item_MeshRotateZ: rot_ang.z=90.0f; rot_ang.x=rot_ang.y=0.0f; piece_rotate(&rot_ang); return(TRUE); case map_menu_item_MeshFreeRotate: piece_free_rotate(); return(TRUE); case map_menu_item_MeshRaiseY: piece_move(0,-100,0); main_wind_draw(); return(TRUE); case map_menu_item_MeshLowerY: piece_move(0,100,0); main_wind_draw(); return(TRUE); case map_menu_item_MeshSelectAllPoly: piece_mesh_select_all_poly(); main_wind_draw(); return(TRUE); case map_menu_item_MeshResetUV: piece_reset_uvs(FALSE); main_wind_draw(); return(TRUE); case map_menu_item_MeshWholeUV: piece_whole_uvs(FALSE); main_wind_draw(); return(TRUE); case map_menu_item_MeshSingleUV: piece_single_uvs(FALSE); main_wind_draw(); return(TRUE); case map_menu_item_MeshCreateNormals: piece_mesh_recalc_normals(FALSE); main_wind_draw(); return(TRUE); case map_menu_item_MeshInvertNormals: piece_mesh_invert_normals(FALSE); main_wind_draw(); return(TRUE); case map_menu_item_MeshSetNormalsOut: piece_mesh_set_normals_in_out(TRUE); main_wind_draw(); return(TRUE); case map_menu_item_MeshSetNormalsIn: piece_mesh_set_normals_in_out(FALSE); main_wind_draw(); return(TRUE); // polygon menu case map_menu_item_PolygonHole: piece_poly_hole(); return(TRUE); case map_menu_item_PolyTesselate: piece_tesselate(FALSE); return(TRUE); case map_menu_item_PolygonRotateUV: piece_rotate_uvs(); main_wind_draw(); return(TRUE); case map_menu_item_PolygonFlipU: piece_flip_uvs(TRUE,FALSE); main_wind_draw(); return(TRUE); case map_menu_item_PolygonFlipV: piece_flip_uvs(FALSE,TRUE); main_wind_draw(); return(TRUE); case map_menu_item_PolygonRecalcNormal: piece_mesh_recalc_normals(TRUE); main_wind_draw(); return(TRUE); case map_menu_item_PolygonInvertNormal: piece_mesh_invert_normals(TRUE); main_wind_draw(); return(TRUE); case map_menu_item_PolygonResetUV: piece_reset_uvs(TRUE); main_wind_draw(); return(TRUE); case map_menu_item_PolygonWholeUV: piece_whole_uvs(TRUE); main_wind_draw(); return(TRUE); case map_menu_item_PolygonSingleUV: piece_single_uvs(TRUE); main_wind_draw(); return(TRUE); } return(FALSE); }