void moove_right(t_env *env) { if (!check_map((int)(env->posx + env->planex * env->movespeed), (int)(env->posy))) env->posx += env->planex * env->movespeed; else ft_putstr("\a"); if (!check_map((int)(env->posx), (int)(env->posy + env->planey * env->movespeed))) env->posy += env->planey * env->movespeed; else ft_putstr("\a"); }
void moove_backwards(t_env *env) { if (!check_map((int)(env->posx - env->dirx * env->movespeed), (int)env->posy)) env->posx -= env->dirx * env->movespeed; else ft_putstr("\a"); if (!check_map((int)env->posx, (int)(env->posy - env->diry * env->movespeed))) env->posy -= env->diry * env->movespeed; else ft_putstr("\a"); }
void moove_left(t_env *env) { if (!check_map((int)(env->posx - env->planex * env->movespeed), (int)(env->posy))) env->posx -= env->planex * env->movespeed; else ft_putstr("\a"); if (!check_map((int)(env->posx), (int)(env->posy - env->planey * env->movespeed))) env->posy -= env->planey * env->movespeed; else ft_putstr("\a"); }
void moove_forward(t_env *env) { if (!check_map((int)(env->posx + env->dirx * env->movespeed), (int)env->posy)) env->posx += env->dirx * env->movespeed; else ft_putstr("\a"); if (!check_map((int)env->posx, (int)(env->posy + env->diry * env->movespeed))) env->posy += env->diry * env->movespeed; else ft_putstr("\a"); }
int main(int argc, char ** argv) { struct map maps[NUM_MAPS] = {}, maps_compare[NUM_MAPS] = {}; int i, j, k; test_init(argc, argv); k = 0; for (i = 0; i < NUM_MPROTS; i++) for (j = 0; j < NUM_MFLAGS; j++) init_map(maps + k++, i, j); for (i = 0; i < NUM_MAPS; i++) if (make_map(maps + i)) goto err; test_daemon(); test_waitsig(); for (i = 0; i < NUM_MAPS; i++) if ((maps[i].prot_real=check_map(maps + i))<0) goto err; k=0; for (i = 0; i < NUM_MPROTS; i++) for (j = 0; j < NUM_MFLAGS; j++) init_map(maps_compare + k++, i, j); for (i = 0; i < NUM_MAPS; i++) if (make_map(maps_compare+ i)) goto err; for (i = 0; i < NUM_MAPS; i++) if ((maps_compare[i].prot_real=check_map(maps_compare + i))<0) goto err; for (i = 0; i< NUM_MAPS; i++) if (!check_prot(maps[i].prot_real, maps_compare[i].prot_real)){ fail("protection on %i (flag=%d prot=%d) maps has changed (prot=%d(expected %d))", i, maps[i].flag, maps[i].prot, maps[i].prot_real, maps_compare[i].prot_real); goto err; } pass(); for (i = 0; i < NUM_MAPS; i++) { destroy_map(maps + i); destroy_map(maps_compare + i); } return 0; err: return 1; }
/*! \brief Delete existing feature (topological level required) Note: Topology must be built at level >= GV_BUILD_BASE A warning is printed on error. \param Map pointer to Map_info structure \param line feature id \return 0 on success \return -1 on error */ int Vect_delete_line(struct Map_info *Map, int line) { int ret; G_debug(3, "Vect_delete_line(): name = %s, line = %d", Map->name, line); if (!check_map(Map)) return -1; if (line < 1 || line > Map->plus.n_lines) { G_warning(_("Attempt to access feature with invalid id (%d)"), line); return -1; } if (!(Map->plus.update_cidx)) { Map->plus.cidx_up_to_date = FALSE; /* category index will be outdated */ } ret = (*Vect_delete_line_array[Map->format][Map->level]) (Map, line); if (ret == -1) G_warning(_("Unable to delete feature %d from vector map <%s>"), line, Vect_get_name(Map)); return ret; }
/*{{{ log_line -- log lines*/ void log_line(BITMAP *dst, int x0, int y0, int x1, int y1, int op) { check_map(dst); if (do_save) { SEND_LINE(dst->id, x0, y0, x1, y1, op); } }
void Fl_Image::system_convert() { Fl_Renderer::system_init(); Fl_PixelFormat *format = Fl_Renderer::system_format(); if( fl_format_equal((&m_fmt), format) ) { return; } m_fmt.invalidate_map(); // Check to make sure the blit mapping is valid check_map(format); Fl_Size s(m_width, m_height); uint8 *system_fmt = Fl_Renderer::system_convert(&m_fmt, &s, m_data); if(m_data_alloc) free(m_data); m_data = system_fmt; m_data_alloc = true; m_fmt.copy(format); if(format->palette) { m_fmt.map_this(format); } m_pitch = Fl_Renderer::calc_pitch(bytespp(), m_width); invalidate(); }
/*! \brief Restore previously deleted feature (topological level required) Note: Topology must be built at level >= GV_BUILD_BASE A warning is printed on error. \param Map pointer to Map_info structure \param line feature id to be restored \param offset feature offset \return 0 on success \return -1 on error */ int Vect_restore_line(struct Map_info *Map, int line, off_t offset) { int ret; G_debug(3, "Vect_restore_line(): name = %s, line = %d", Map->name, line); if (!check_map(Map)) return -1; if (line < 1 || line > Map->plus.n_lines) { G_warning(_("Attempt to access feature with invalid id (%d)"), line); return -1; } if (!(Map->plus.update_cidx)) { Map->plus.cidx_up_to_date = 0; } ret = (*Vect_restore_line_array[Map->format][Map->level]) (Map, line, offset); if (ret == -1) G_warning(_("Unable to restore feature %d in vector map <%s>"), line, Vect_get_name(Map)); return ret; }
/*{{{ log_point -- log points*/ void log_point(BITMAP *dst, int x, int y, int op) { check_map(dst); if (do_save) { SEND_PNT(dst->id, x, y, op); } }
/*! \brief Rewrites existing feature (topological level required) Note: Topology must be built at level >= GV_BUILD_BASE A warning is printed on error. The number of points or cats or type may change. If necessary, the old feature is deleted and new is written. \param Map pointer to Map_info structure \param line feature id \param type feature type (GV_POINT, GV_LINE, ...) \param points feature geometry \param cats feature categories \return new feature offset \return -1 on error */ off_t Vect_rewrite_line(struct Map_info *Map, int line, int type, const struct line_pnts *points, const struct line_cats *cats) { off_t ret, offset; if (!check_map(Map)) return -1; if (line < 1 || line > Map->plus.n_lines) { G_warning(_("Attempt to access feature with invalid id (%d)"), line); return -1; } if (!(Map->plus.update_cidx)) { Map->plus.cidx_up_to_date = FALSE; /* category index will be outdated */ } offset = Map->plus.Line[line]->offset; G_debug(3, "Vect_rewrite_line(): name = %s, line = %d, offset = %lu", Map->name, line, offset); ret = (*Vect_rewrite_line_array[Map->format][Map->level]) (Map, line, type, offset, points, cats); if (ret == -1) G_warning(_("Unable to rewrite feature %d in vector map <%s>"), line, Vect_get_name(Map)); return ret; }
/*{{{ log_blit -- do the logging for bitmaps*/ void log_blit(BITMAP *dst_map, int xd, int yd, int w, int h, int op, BITMAP *src_map, int xs, int ys) { check_map(dst_map); check_map(src_map); /* log xaction iff turned on */ if (do_save) { if (src_map) { src_map->primary->type &= ~_DIRTY; SEND_SRC(dst_map->id, xd, yd, w, h, op, src_map->id, xs, ys); } else { SEND_DST(dst_map->id, xd, yd, w, h, op); } dst_map->primary->type &= ~_DIRTY; } }
int save_all_map(void) { int x,y,z; char info[160]; char *txt; if ((z=check_map(&x,&y))!=0) { WINDOW *w; unselect_map(); if ((w=find_window(tool_bar))!=NULL) close_window(w); tool_sel=30; create_map_win(-1); open_sector_win(); jdi_na_sektor(x); } sprintf(info,"Chyba %02d na pozici %d:%d",-z,x,y); switch (z) { case -1:msg_box(info,'\01',"Chyb� definice st�ny!","OK",NULL);break; case -2:msg_box(info,'\01',"Chodba vede do neexistuj�c�ho sektoru!","OK",NULL);break; case -3:msg_box(info,'\01',"Schody jsou �patn� spojen� se sousedn�m� sektory!","OK",NULL);break; case -4:msg_box(info,'\01',"Ud�lost v neexistuj�c�m sektoru!","OK",NULL);break; } if (!backup) { create_backup(filename); create_backup(SHOP_NAME); create_backup(ITEMS_DAT); create_backup(MOB_FILE); create_backup(MOB_SOUND); backup=1; } if (save_map(filename)) { sprintf(info,"Nedok��u ulo�it soubor %s.",filename); msg_box("Chyba I/O",'\01',info,"!Panika!",NULL); } else txt=pripona(filename,TXT); save_items(); if (_access(txt,0)!=0) { FILE *f; f=fopen(txt,"w"); if (f) { fputs("-1\n",f); fclose(f); } } if (!mglob.local_monsters) { save_mobs(); save_sound_map(); } save_all_shops(); validate_sound_map(); return z; }
int main(int argc, char **argv) { setup(); iterate(); check_map(); if (!failed) printf("Inode scan tested OK!\n"); return failed; }
/*! \brief Set vector points style \param params parameters \return 1 on success \return 0 on failure */ int vpoints_set_attrb(const struct GParams *params) { int i, layer, have_colors, with_z; int *site_list, nsites; int marker, color, width; float size; char *marker_str, *color_column, *size_column, *width_column, *marker_column; struct Colors colors; site_list = GP_get_site_list(&nsites); for (i = 0; i < nsites; i++) { check_map(params, i, FALSE, &layer, &with_z); color = Nviz_color_from_str(params->vpoint_color->answers[i]); color_column = params->vpoint_color_column->answers ? params->vpoint_color_column->answers[i] : NULL; size = atof(params->vpoint_size->answers[i]); size_column = params->vpoint_size_column->answers ? params->vpoint_size_column->answers[i] : NULL; width = atoi(params->vpoint_width->answers[i]); width_column = params->vpoint_width_column->answers ? params->vpoint_width_column->answers[i] : NULL; marker_str = params->vpoint_marker->answers[i]; marker_column = params->vpoint_marker_column->answers ? params->vpoint_marker_column->answers[i] : NULL; marker = GP_str_to_marker(marker_str); if (with_z) { if (strcmp(params->vpoint_mode->answers[i], "surface") == 0) GP_set_zmode(site_list[i], FALSE); else GP_set_zmode(site_list[i], TRUE); } if (GP_set_style(site_list[i], color, width, size, marker) < 0) return 0; /* check for vector color table */ have_colors = Vect_read_colors(params->vpoints->answers[i], "", &colors); if (have_colors || color_column || width_column || size_column || marker_column) { if (GP_set_style_thematic(site_list[i], layer, color_column, width_column, size_column, marker_column, have_colors ? &colors : NULL) < 0) return 0; } } return 1; }
// del key/value A2_API inline void a2_delmap(struct a2_state* state){ int top = a2_top(state)-1; struct a2_obj* k = a2_getcstack(state->env_p, top); struct a2_obj* map = a2_getcstack(state->env_p, top-1); check_map(map); check_key(k); a2_map_del(a2_gcobj2map(obj_vX(map, obj)), k); a2_pop(state, 1); }
void gimme_env(t_file *data_file, char *file) { int fd; if ((fd = open(file, O_RDONLY)) == -1) { ft_putstr("OPEN MAP FAIL test.\n"); exit(0); } data_file->nbr_lines = gimme_nbr_lines(file); gimme_map(fd, data_file); check_map(data_file); close(fd); }
// get map A2_API inline void a2_getmap(struct a2_state* state){ int top = a2_top(state)-1; struct a2_obj* k = a2_getcstack(state->env_p, top); struct a2_obj* map = a2_getcstack(state->env_p, top-1); struct a2_obj* v = NULL; check_map(map); check_key(k); v = a2_map_query(a2_gcobj2map(obj_vX(map, obj)), k); if(v==NULL) obj_setX(map, A2_TNIL, point, NULL); else *map = *v; }
/*! \brief Set vector lines mode \param params parameters \return 1 on success \return 0 on failure */ int vlines_set_attrb(const struct GParams *params) { int i, layer, color, width, flat, height; int *vect_list, nvects; int have_colors; char *color_column, *width_column; struct Colors colors; vect_list = GV_get_vect_list(&nvects); for (i = 0; i < nvects; i++) { check_map(params, i, TRUE, &layer, NULL); color = Nviz_color_from_str(params->vline_color->answers[i]); color_column = params->vline_color_column->answers ? params->vline_color_column->answers[i] : NULL; width = atoi(params->vline_width->answers[i]); width_column = params->vline_width_column->answers ? params->vline_width_column->answers[i] : NULL; if (strcmp(params->vline_mode->answers[i], "flat") == 0) flat = 1; else flat = 0; /* style (mode -- use memory by default) */ if (GV_set_style(vect_list[i], TRUE, color, width, flat) < 0) return 0; /* check for vector color table */ have_colors = Vect_read_colors(params->vlines->answers[i], "", &colors); if (have_colors || color_column || width_column) if (GV_set_style_thematic(vect_list[i], layer, color_column, width_column, have_colors ? &colors : NULL) < 0) return 0; /* height */ height = atoi(params->vline_height->answers[i]); if (height > 0) GV_set_trans(vect_list[i], 0.0, 0.0, height); } return 1; }
int main(int ac, char** av) { SDL_Surface *screen; SDL_Surface *life_back; char **map; char *life; int i; int size_line; int size_column; if (ac == 2) { map = loadMap(av[1]); size_line = check_map(map, &size_column); life = constr_life(size_line, life); x_SDL_Init(SDL_INIT_VIDEO); screen = SDL_SetVideoMode(size_line*SIZE_IMAGE , size_column*SIZE_IMAGE + SIZE_IMAGE, 32, SDL_RESIZABLE | SDL_DOUBLEBUF); SDL_WM_SetCaption("Epikong", "KONG"); loadAllImages(map, screen); life_back = SDL_CreateRGBSurface(SDL_HWSURFACE, SIZE_IMAGE, SIZE_IMAGE, 32, 0, 0, 0, 0); loadImagelife(screen, life, 0); /* 3 vies */ loadImagelife(screen, life, 1); loadImagelife(screen, life, 1); loadImagelife(screen, life, 1); x_SDL_Flip(screen); x_SDL_Flip(life_back); waitImage(); i = -1; while (map[++i] != NULL) free(map[i]); free(map); SDL_Quit(); } else { printf("Format : %s filemap\n", av[0]); exitError("[ERROR] : Bad parameters\n"); } return (EXIT_SUCCESS); }
void map_test(int fd) { char *std_in; std_in = take_stdin(fd); if (!ft_strcmp(std_in, "error")) map_error(); else { if (check_map(std_in)) map_error(); else dyna_sol(std_in); if (std_in) free(std_in); } }
int exec_map(char *path) { int result; SDL_Surface *screen; t_map *map; map = check_map(get_map(path)); if (!map) return (EXIT_FAILURE); if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) < 0) err_SDL("Can't init SDL", 1); screen = creat_win(map); if (!screen) err_SDL("screen load fail", 1); result = exec_fct(screen, map); SDL_FreeSurface(screen); SDL_Quit(); return (result); }
static void check_map_and_post() { if(fst == NULL) { return; } if(check_map(&fst->map)) { fst->retx = 0; #ifdef SOS_SIM /* * We update module version here */ // TODO: figure out the right place... //set_version_to_sim(fst->map.mod_id, fst->map.version); #endif DEBUG_PID(KER_FETCHER_PID, "Request Done!!!\n"); ker_timer_stop(KER_FETCHER_PID, FETCHER_REQUEST_TID); send_fetcher_done(); } }
void get_map(t_board *board, char *filename) { int fd; void *file_map; off_t r_lseek; fd = openfile(filename); r_lseek = lseek(fd, 0, SEEK_END); if (r_lseek == -1) { PRINT_ERROR; exit(EXIT_FAILURE); } file_map = mmap(NULL,r_lseek, PROT_READ, MAP_SHARED, fd, 0); if (file_map == (void *)-1) { PRINT_ERROR; exit(EXIT_FAILURE); } board->map = (char *)file_map; check_map(board); }
void start(int argc, char **argv, t_option option) { t_map map; t_stack *stack; char *p; p = argv[argc - 1]; if (check_map(p) && check_exit(p) && check_player(p)) { init_map(&map, argv, argc, option); if (map.width != 0) { stack = s_solve(&map, NULL, NULL); if (stack_empty(stack) && option.c == 1) { map.option.c = 0; stack = s_solve(&map, NULL, NULL); } result(map, stack, option); destruct(map); stack_clean(stack); } } else my_putstr("La carte n'est pas valide\n"); }
void loadFile(t_image* img, char *filemap) { t_removable remove; img->map = loadMap(filemap); check_map(img); if (img->sizeX != SCREEN_X || img->sizeY != SCREEN_Y) { fprintf(stderr, "[ERROR] : The map have to have dimension of %d by %d\n", SCREEN_X, SCREEN_Y); exitError(""); } loadAllImages(img); x_SDL_Flip(img->screen); remove.monster = catch_monster(img->map); remove.item = catch_item(img->map, &remove); put_elem(&remove, img); x_SDL_Flip(img->screen); key(&remove, *img); x_SDL_Flip(img->screen); waitImage(); freeMap(img->map); }
void hart_init() { int i; char filename[256], filename2[256]; const char *tmp; const char *path; tmp = extract_option1("initial-conditions-path","ics",NULL); if(tmp != NULL) { path = tmp; } else { path = output_directory; } /* // No more options are allowed. */ if(num_options > 0) { cart_error("Unrecognized option: %s",options[0]); } #ifdef PARTICLES sprintf( filename, "%s/PMcrd.DAT", path ); sprintf( filename2, "%s/PMcrs0.DAT", path ); restart_load_balance_cart( NULL, filename, filename2 ); read_cart_particles( filename, filename2, NULL, NULL, 0, NULL ); cart_debug("read in particles"); #endif #ifdef HYDRO sprintf( filename, "%s/tr_ic.dat", path ); read_hart_gas_ic(filename); cart_debug("read in gas"); #endif /* HYDRO */ units_init(); units_update( min_level ); cart_debug("tl[min_level] = %f", tl[min_level] ); cart_debug(" a[min_level] = %f", auni[min_level] ); #ifdef HYDRO hydro_magic( min_level ); hydro_eos( min_level ); #endif /* HYDRO */ #ifdef PARTICLES build_mesh(); #ifdef STARFORM for ( i = 0; i < nDim; i++ ) { star_formation_volume_min[i] = refinement_volume_min[i]; star_formation_volume_max[i] = refinement_volume_max[i]; } #endif /* STARFORM */ #else for ( i = 0; i < nDim; i++ ) { refinement_volume_min[i] = 0; refinement_volume_max[i] = (double)num_grid; } #endif /* PARTICLES */ #ifdef HYDRO_TRACERS set_hydro_tracers_to_particles(); #endif /* HYDRO_TRACERS */ if ( !buffer_enabled ) { cart_debug("building cell buffer"); build_cell_buffer(); repair_neighbors(); } #ifdef DEBUG check_map(); #endif /* DEBUG */ }
static inline void send_fragment() { uint16_t frag_id; uint8_t i, j; uint8_t mask = 1; uint8_t ret; fetcher_fragment_t *out_pkt; fetcher_cam_t *cam; if ( send_state.map == NULL ) { ker_timer_stop(KER_FETCHER_PID, FETCHER_TRANSMIT_TID); return; } cam = (fetcher_cam_t *) ker_shm_get( KER_FETCHER_PID, send_state.map->key); if ( cam == NULL ) { // file got deleted. give up! free_send_state_map(); return; } if ( send_state.frag != NULL) { //! timer fires faster than data reading. Highly unlikely... //! but we still handle it. return; } //! search map and find one fragment to send for(i = 0; i < send_state.map->bitmap_size; i++) { //! for each byte if(send_state.map->bitmap[i] != 0) { break; } } if(i == send_state.map->bitmap_size) { /* * Did not find any block... */ free_send_state_map(); return; } //sos_assert(i < send_state.map->bitmap_size); frag_id = i * 8; mask = 1; for(j = 0; j < 8; j++, mask = mask << 1) { if(mask & (send_state.map->bitmap[i])) { send_state.map->bitmap[i] &= ~(mask); break; } } //sos_assert(j < 8); frag_id += j; print_bitmap(send_state.map); out_pkt = (fetcher_fragment_t*)ker_malloc(sizeof(fetcher_fragment_t), KER_FETCHER_PID); if(out_pkt == NULL){ DEBUG_PID(KER_FETCHER_PID,"malloc fetcher_fragment_t failed\n"); goto send_fragment_postproc; } out_pkt->frag_id = ehtons(frag_id); out_pkt->key = ehtons(send_state.map->key); ret = ker_codemem_read(cam->cm, KER_FETCHER_PID, out_pkt->fragment, FETCHER_FRAGMENT_SIZE, frag_id * (code_addr_t)FETCHER_FRAGMENT_SIZE); if(ret == SOS_SPLIT) { send_state.frag = out_pkt; } else if(ret != SOS_OK){ DEBUG_PID(KER_FETCHER_PID, "codemem_read failed\n"); ker_free(out_pkt); goto send_fragment_postproc; } //DEBUG("out_pkt has addr %x\n", (int)out_pkt); DEBUG_PID(KER_FETCHER_PID, "send_fragment: frag_id = %d to %d\n", frag_id, send_state.dest); ret = post_auto(KER_FETCHER_PID, KER_FETCHER_PID, MSG_FETCHER_FRAGMENT, sizeof(fetcher_fragment_t), out_pkt, SOS_MSG_RELEASE | SOS_MSG_RELIABLE, send_state.dest); if( ret == SOS_OK ) { send_state.num_msg_in_queue++; } send_fragment_postproc: if(check_map(send_state.map)) { //! no more fragment to send free_send_state_map(); } }
void init_run() { int i, j, k; int index; double a_th; int ipart; int icell; double qi, qj, qk; double xcons, vcons; double dx, dvx; double pw; double a_vel; double qfact; int num_level_cells; int *level_cells; cosmology_set(OmegaM,OmM0); cosmology_set(OmegaB,OmB0); cosmology_set(OmegaL,OmL0); cosmology_set(h,h0); cosmology_set(DeltaDC,dDC); box_size = Lbox0; units_set_art(cosmology->OmegaM,cosmology->h,box_size); units_init(); build_cell_buffer(); repair_neighbors(); auni[min_level] = auni_init; tl[min_level] = tcode_from_auni( auni_init ); for ( i = min_level; i <= max_level; i++ ) { tl[i] = tl[min_level]; } abox[min_level] = auni_init; for(i=min_level+1; i<=max_level; i++) { tl[i] = tl[min_level]; auni[i] = auni[min_level]; abox[i] = abox[min_level]; } units_update(min_level); cart_debug("tl[min_level] = %f", tl[min_level] ); cart_debug("au[min_level] = %f", auni[min_level] ); cart_debug("ab[min_level] = %f", abox[min_level] ); cart_debug("DC mode = %f", cosmology->DeltaDC ); cosmology_set_fixed(); rhogas0 = cosmology->OmegaB/cosmology->OmegaM; cart_debug("rhogas0 = %e", rhogas0 ); Tinit = TinitK/units->temperature; ak = 2.0*M_PI / lambda; dgrowth = growth(abox[min_level]); ddgrowthdt = dgrowthdt(abox[min_level]); ampl = 1.0 / ( growth(a_cross) * ak ); cart_debug("Tinit,TinitK = %e %e", Tinit,TinitK ); #ifdef HYDRO for ( i = min_level; i <= max_level; i++ ) { cart_debug("generating initial conditions on level %u", i ); select_level( i, CELL_TYPE_LOCAL, &num_level_cells, &level_cells ); for ( j = 0; j < num_level_cells; j++ ) { // cart_debug("%d %d",level_cells[j],num_cells); initial_conditions( level_cells[j], i ); } cart_free( level_cells ); } for ( i = min_level; i <= max_level; i++ ) { update_buffer_level( i, all_hydro_vars, num_hydro_vars ); } #endif /* HYDRO */ cart_debug("choose timestep and set velocity on the half step"); dtl[min_level] = 0.0; set_timestepping_scheme(); dtl[min_level]=.125; cart_debug("=======================%e",dtl[min_level]); dtl_old[min_level] = dtl[min_level]; tl_old[min_level] = tl[min_level]-dtl[min_level]; abox_old[min_level] = abox_from_tcode(tl_old[min_level]); dtl_old[min_level] = dtl[min_level]; for ( i = min_level+1; i <= max_level; i++ ) { tl_old[i] = tl[i]-dtl[i]; abox_old[i] = abox_from_tcode(tl_old[i]); dtl_old[i] = dtl[i]; } #ifdef GRAVITY #ifdef HYDRO for ( i = min_level; i <= max_level; i++ ) { cart_debug("generating gravity on level %u", i ); // cart_assert(dtl[i]==0); select_level( i, CELL_TYPE_LOCAL, &num_level_cells, &level_cells ); for ( j = 0; j < num_level_cells; j++ ) { initial_gravity( level_cells[j], i ); } cart_free( level_cells ); } for ( i = min_level; i <= max_level; i++ ) { update_buffer_level( i, all_hydro_vars, num_hydro_vars ); } #endif /* GRAVITY */ #endif /* HYDRO */ #ifdef PARTICLES qfact = (double)num_grid / (double)num_grid; pw = (1.0-rhogas0)*qfact*qfact*qfact; cart_debug("particle weight = %e", pw ); xcons = dgrowth*ampl; a_vel = abox_from_tcode( tl[min_level] - 0.5*dtl[min_level] ); vcons = ampl * dgrowthdt( a_vel); ipart = 0; for ( i = 0; i < num_grid; i++ ) { qi = qfact*((double)i + 0.5); dx = xcons * sin( ak * qi ); dvx = vcons * sin( ak * qi ); for ( j = 0; j < num_grid; j++ ) { qj = qfact*((double)j + 0.5); for ( k = 0; k < num_grid; k++ ) { qk = qfact*((double)k + 0.5); particle_x[ipart][0] = qi + dx; particle_x[ipart][1] = qj; particle_x[ipart][2] = qk; if ( particle_x[ipart][0] >= (double)num_grid ) { particle_x[ipart][0] -= num_grid; } if ( particle_x[ipart][1] >= (double)num_grid ) { particle_x[ipart][1] -= num_grid; } if ( particle_x[ipart][2] >= (double)num_grid ) { particle_x[ipart][2] -= num_grid; } icell = cell_find_position( particle_x[ipart] ); if ( icell != -1 && cell_is_local(icell) ) { particle_v[ipart][0] = dvx; particle_v[ipart][1] = 0.0; particle_v[ipart][2] = 0.0; particle_id[ipart] = (particleid_t)num_grid*(num_grid*i + j) + k; particle_mass[ipart] = pw; cart_assert( qi == particle_q_init( particle_id[ipart] ) ); particle_t[ipart] = tl[min_level]; particle_dt[ipart] = dtl[min_level]; ipart++; } } } } cart_debug("created %u particles", ipart ); num_local_particles = ipart; num_particles_total = (particleid_t)num_grid*(particleid_t)num_grid*(particleid_t)num_grid; num_particle_species = 1; particle_species_mass[0] = pw; particle_species_num[0] = num_particles_total; particle_species_indices[0] = 0; particle_species_indices[1] = num_particles_total; build_particle_list(); /* assign_density( min_level, min_level ); */ //for refinement /* modify( min_level, 0 ); */ assign_density( min_level, min_level ); //for refinement modify( min_level, 0 ); if ( local_proc_id == MASTER_NODE ) { particles = fopen("dumps/particle_rms.dat", "w"); fclose(particles); } #endif check_map(); cart_debug("done with initialization"); }
/* This function takes the character string in ch->pnote and * creates rooms laid out in the appropriate configuration. */ void map_to_rooms( CHAR_DATA * ch, MAP_INDEX_DATA * m_index ) { struct map_stuff map[49][78]; /* size of edit buffer */ const char *newmap; int row, col, i, n, x, y, tvnum, proto_vnum = 0, leftmost, rightmost; int newx, newy; const char *l; char c; ROOM_INDEX_DATA *newrm; MAP_INDEX_DATA *map_index = NULL, *tmp; EXIT_DATA *xit; /* these are for exits */ bool getroomnext = FALSE; if( !ch->pnote ) { bug( "%s: ch->pnote==NULL!", __FUNCTION__ ); return; } /* * Make sure format is right */ newmap = check_map( ch->pnote->text ); STRFREE( ch->pnote->text ); ch->pnote->text = STRALLOC( newmap ); n = 0; row = col = 0; leftmost = rightmost = 0; /* * Check to make sure map_index exists. * If not, then make a new one. */ if( !m_index ) { /* * Make a new vnum */ for( i = ch->pcdata->area->low_r_vnum; i <= ch->pcdata->area->hi_r_vnum; i++ ) { if( ( tmp = get_map_index( i ) ) == NULL ) { map_index = make_new_map_index( i ); break; } } } else map_index = m_index; /* * */ if( !map_index ) { send_to_char( "Couldn't find or make a map_index for you!\r\n", ch ); bug( "%s", "map_to_rooms: Couldn't find or make a map_index\r\n" ); /* * do something. return failed or somesuch */ return; } for( x = 0; x < 49; x++ ) { for( y = 0; y < 78; y++ ) { map[x][y].vnum = 0; map[x][y].proto_vnum = 0; map[x][y].exits = 0; map[x][y].index = 0; } } l = ch->pnote->text; do { c = l[0]; switch ( c ) { case '\n': break; case '\r': col = 0; row++; break; } if( c != ' ' && c != '-' && c != '|' && c != '=' && c != '\\' && c != '/' && c != '^' && c != ':' && c != '[' && c != ']' && c != '^' && !getroomnext ) { l++; continue; } if( getroomnext ) { n++; /* * Actual room info */ map[row][col].vnum = add_new_room_to_map( ch, c ); map_index->map_of_vnums[row][col] = map[row][col].vnum; map[row][col].proto_vnum = proto_vnum; getroomnext = FALSE; } else { map_index->map_of_vnums[row][col] = 0; map[row][col].vnum = 0; map[row][col].exits = 0; } map[row][col].code = c; /* * Handle rooms */ if( c == '[' ) getroomnext = TRUE; col++; l++; } while( c != '\0' ); for( y = 0; y < ( row + 1 ); y++ ) { /* rows */ for( x = 0; x < 78; x++ ) { /* cols (78, i think) */ if( map[y][x].vnum == 0 ) continue; newrm = get_room_index( map[y][x].vnum ); /* * Continue if no newrm */ if( !newrm ) continue; /* * Check up */ if( y > 1 ) { newx = x; newy = y; newy--; while( newy >= 0 && ( map[newy][x].code == '^' ) ) newy--; /* * dont link it to itself */ if( map[y][x].vnum == map[newy][x].vnum ) break; if( ( tvnum = map[newy][x].vnum ) != 0 ) { xit = make_exit( newrm, get_room_index( tvnum ), DIR_UP ); xit->keyword = STRALLOC( "" ); xit->description = STRALLOC( "" ); xit->key = -1; xit->exit_info = 0; } } /* * Check down */ if( y < 48 ) { newx = x; newy = y; newy++; while( newy <= 48 && ( map[newy][x].code == '^' ) ) newy++; /* * dont link it to itself */ if( map[y][x].vnum == map[newy][x].vnum ) break; if( ( tvnum = map[newy][x].vnum ) != 0 ) { xit = make_exit( newrm, get_room_index( tvnum ), DIR_DOWN ); xit->keyword = STRALLOC( "" ); xit->description = STRALLOC( "" ); xit->key = -1; xit->exit_info = 0; } } /* * Check north */ if( y > 1 ) { newx = x; newy = y; newy--; while( newy >= 0 && ( map[newy][x].code == '|' || map[newy][x].code == ':' || map[newy][x].code == '=' ) ) newy--; /* * dont link it to itself */ if( map[y][x].vnum == map[newy][x].vnum ) break; if( ( tvnum = map[newy][x].vnum ) != 0 ) { xit = make_exit( newrm, get_room_index( tvnum ), DIR_NORTH ); xit->keyword = STRALLOC( "" ); xit->description = STRALLOC( "" ); xit->key = -1; if( map[newy + 1][x].code == ':' || map[newy + 1][x].code == '=' ) { SET_BIT( xit->exit_info, EX_ISDOOR ); SET_BIT( xit->exit_info, EX_CLOSED ); } else xit->exit_info = 0; } } /* * Check south */ if( y < 48 ) { newx = x; newy = y; newy++; while( newy <= 48 && ( map[newy][x].code == '|' || map[newy][x].code == ':' || map[newy][x].code == '=' ) ) newy++; /* * dont link it to itself */ if( map[y][x].vnum == map[newy][x].vnum ) break; if( ( tvnum = map[newy][x].vnum ) != 0 ) { xit = make_exit( newrm, get_room_index( tvnum ), DIR_SOUTH ); xit->keyword = STRALLOC( "" ); xit->description = STRALLOC( "" ); xit->key = -1; if( map[newy - 1][x].code == ':' || map[newy - 1][x].code == '=' ) { SET_BIT( xit->exit_info, EX_ISDOOR ); SET_BIT( xit->exit_info, EX_CLOSED ); } else xit->exit_info = 0; } } /* * Check east */ if( x < 79 ) { newx = x; newy = y; newx++; while( newx <= 79 && ( map[y][newx].code == '-' || map[y][newx].code == ':' || map[y][newx].code == '=' || map[y][newx].code == '[' || map[y][newx].code == ']' ) ) newx++; /* * dont link it to itself */ if( map[y][x].vnum == map[y][newx].vnum ) break; if( ( tvnum = map[y][newx].vnum ) != 0 ) { xit = make_exit( newrm, get_room_index( tvnum ), DIR_EAST ); xit->keyword = STRALLOC( "" ); xit->description = STRALLOC( "" ); xit->key = -1; if( map[y][newx - 2].code == ':' || map[y][newx - 2].code == '=' ) { SET_BIT( xit->exit_info, EX_ISDOOR ); SET_BIT( xit->exit_info, EX_CLOSED ); } else xit->exit_info = 0; } } /* * Check west */ if( x > 1 ) { newx = x; newy = y; newx--; while( newx >= 0 && ( map[y][newx].code == '-' || map[y][newx].code == ':' || map[y][newx].code == '=' || map[y][newx].code == '[' || map[y][newx].code == ']' ) ) newx--; /* * dont link it to itself */ if( map[y][x].vnum == map[y][newx].vnum ) break; if( ( tvnum = map[y][newx].vnum ) != 0 ) { xit = make_exit( newrm, get_room_index( tvnum ), DIR_WEST ); xit->keyword = STRALLOC( "" ); xit->description = STRALLOC( "" ); xit->key = -1; if( map[y][newx + 2].code == ':' || map[y][newx + 2].code == '=' ) { SET_BIT( xit->exit_info, EX_ISDOOR ); SET_BIT( xit->exit_info, EX_CLOSED ); } else xit->exit_info = 0; } } /* * Check southeast */ if( y < 48 && x < 79 ) { newx = x; newy = y; newx += 2; newy++; while( newx <= 79 && newy <= 48 && ( map[newy][newx].code == '\\' || map[newy][newx].code == ':' || map[newy][newx].code == '=' ) ) { newx++; newy++; } if( map[newy][newx].code == '[' ) newx++; /* * dont link it to itself */ if( map[y][x].vnum == map[newy][newx].vnum ) break; if( ( tvnum = map[newy][newx].vnum ) != 0 ) { xit = make_exit( newrm, get_room_index( tvnum ), DIR_SOUTHEAST ); xit->keyword = STRALLOC( "" ); xit->description = STRALLOC( "" ); xit->key = -1; xit->exit_info = 0; } } /* * Check northeast */ if( y > 1 && x < 79 ) { newx = x; newy = y; newx += 2; newy--; while( newx >= 0 && newy <= 48 && ( map[newy][newx].code == '/' || map[newy][newx].code == ':' || map[newy][newx].code == '=' ) ) { newx++; newy--; } if( map[newy][newx].code == '[' ) newx++; /* * dont link it to itself */ if( map[y][x].vnum == map[newy][newx].vnum ) break; if( ( tvnum = map[newy][newx].vnum ) != 0 ) { xit = make_exit( newrm, get_room_index( tvnum ), DIR_NORTHEAST ); xit->keyword = STRALLOC( "" ); xit->description = STRALLOC( "" ); xit->key = -1; xit->exit_info = 0; } } /* * Check northwest */ if( y > 1 && x > 1 ) { newx = x; newy = y; newx -= 2; newy--; while( newx >= 0 && newy >= 0 && ( map[newy][newx].code == '\\' || map[newy][newx].code == ':' || map[newy][newx].code == '=' ) ) { newx--; newy--; } if( map[newy][newx].code == ']' ) newx--; /* * dont link it to itself */ if( map[y][x].vnum == map[newy][newx].vnum ) break; if( ( tvnum = map[newy][newx].vnum ) != 0 ) { xit = make_exit( newrm, get_room_index( tvnum ), DIR_NORTHWEST ); xit->keyword = STRALLOC( "" ); xit->description = STRALLOC( "" ); xit->key = -1; xit->exit_info = 0; } } /* * Check southwest */ if( y < 48 && x > 1 ) { newx = x; newy = y; newx -= 2; newy++; while( newx >= 0 && newy <= 48 && ( map[newy][newx].code == '/' || map[newy][newx].code == ':' || map[newy][newx].code == '=' ) ) { newx--; newy++; } if( map[newy][newx].code == ']' ) newx--; /* * dont link it to itself */ if( map[y][x].vnum == map[newy][newx].vnum ) break; if( ( tvnum = map[newy][newx].vnum ) != 0 ) { xit = make_exit( newrm, get_room_index( tvnum ), DIR_SOUTHWEST ); xit->keyword = STRALLOC( "" ); xit->description = STRALLOC( "" ); xit->key = -1; xit->exit_info = 0; } } } } }