t_obj *initobj(t_scene *scene, t_parse *p, int type) { t_obj *obj; t_vector3f v; if (!(obj = (t_obj *)ft_memalloc(sizeof(t_obj)))) return (NULL); obj->rot = new_quaternion4vf(new_vector3f(1, 0, 0), p->rot_x); v = new_vector3f(0, 1, 0); obj->rot = mul4q(obj->rot, new_quaternion4vf(v, p->rot_y)); v = new_vector3f(0, 0, 1); obj->rot = mul4q(obj->rot, new_quaternion4vf(v, p->rot_z)); obj->pos = new_vector3f(p->pos_x, p->pos_y, p->pos_z); obj->color = new_vector3f(p->red, p->green, p->blue); obj->diameter = p->diameter; obj->intens = p->intens; obj->diffuse = p->diffuse; obj->specular = p->specular; obj->type = type; obj->refrac = p->refrac; obj->reflec = p->reflec; obj->cam = NULL; if (type >= 0) add_obj(scene, obj); else if (type == PROJ) add_proj(scene, obj); return (obj); }
void duplicate_obj(t_obj *obj) { t_obj *obj_crea; obj_crea = new_obj(OBJ_SPHERE); ft_memcpy(obj_crea, obj, sizeof(t_obj)); add_obj(env->e_scene.scene, obj crea); e->frame.scene_refresh = clock(); }
// add an object to a directory, allocate an object //void add_obj(struct Object_dec *dir, struct Object_dec *object) Address_dec * create_obj(struct Object_dec *dir, U32 type) { struct Object_dec *object; struct Object_dec *sub_obj; // for accessing any sub objects struct Task_dec *task; // Allocate an object in memory object = malloc(sizeof(struct Object_dec)); // allocate an appropriately sized block of memory for sub // structure switch (type) { case OTYPE_OBJ: #ifdef DEBUG dprint("Event: creating object at 0x%x\n",object->St); #endif object->St = malloc(sizeof(struct Object_dec)); object->Type = type; break; case OTYPE_DIR: // should really only accept subdir case OTYPE_SUBDIR: object->Type = OTYPE_SUBDIR; object->St = malloc(sizeof(struct Object_dec)); sub_obj = (struct Object_dec *)object->St; sub_obj->Next = sub_obj; sub_obj->Previous = sub_obj; sub_obj->Parent = object; sub_obj->Type = OTYPE_DIR; sub_obj->St = NULL; #ifdef DEBUG dprint("Event: creating directory at 0x%x\n",object->St); #endif break; case OTYPE_TASK: object->Type = type; object->St = malloc(sizeof(struct Task_dec)); task = (struct Task_dec *)object->St; task->Obj = object; #ifdef DEBUG dprint("Event: creating task at 0x%x\n",object->St); #endif break; default: #ifdef DEBUG dprint("Event: Object type not recognized\n"); #endif object->St = NULL; break; } add_obj(dir,object); return object->St; }
static void loadShader(const char* vs_path , const char* fs_path) { // Need to delete the previous shader program glDeleteProgram(program); program = setup_shader(readfile(vs_path).c_str(), readfile(fs_path).c_str()); int sun = add_obj(program, "sun.obj","sun.bmp"); glEnable(GL_DEPTH_TEST); glCullFace(GL_BACK); }
void init_obj(void) { // Set up the base dir ring Base_dir.Next = &Base_dir; Base_dir.Previous = &Base_dir; Base_dir.Parent = &Base_dir; // Initialize the root directory Base_dir.Type = OTYPE_DIR; Base_dir.St = NULL; // Set up the basic directory structure dir_Tasks = (struct Object_dec *)create_obj(&Base_dir,OTYPE_SUBDIR); dir_Devices = (struct Object_dec *)create_obj(&Base_dir,OTYPE_SUBDIR); // Add the kernel task to the Tasks directory add_obj(dir_Tasks,&Base_obj); }
void fill_obj(int fd, t_overview *over) { t_obj *obj; char *trim; char *str; obj = (t_obj*)malloc(sizeof(t_obj)); obj->next = NULL; obj->specular = 0; while (get_next_line(fd, &str)) { trim = ft_strtrim(str); if (object_to_fill(trim, obj) == FALSE) break ; } if (obj->specular) obj->specular = 1.0f - obj->diffuse; over->l = add_obj(over->l, obj); }
void fall(struct thing *tp, struct linked_list *item, int pr, int player_owned) { struct object *obj; struct room *rp; coord fpos; obj = OBJPTR(item); rp = roomin(tp->t_pos); if (player_owned && obj->o_flags & CANRETURN) { add_pack(item, NOMESSAGE); msg("You have %s.", inv_name(obj, LOWERCASE)); return; } else if (fallpos(obj->o_pos, &fpos)) { if (obj->o_flags & CANBURN && obj->o_type == WEAPON && obj->o_which == MOLOTOV && ntraps + 1 < 2 * MAXTRAPS) { mvaddch(fpos.y, fpos.x, FIRETRAP); traps[ntraps].tr_type = FIRETRAP; traps[ntraps].tr_flags = ISFOUND; traps[ntraps].tr_show = FIRETRAP; traps[ntraps].tr_pos = fpos; ntraps++; if (rp != NULL) rp->r_flags &= ~ISDARK; } else { obj->o_pos = fpos; add_obj(item, fpos.y, fpos.x); } if (rp != NULL && (!(rp->r_flags & ISDARK) || (rp->r_flags & HASFIRE))) { light(&hero); mvwaddch(cw, hero.y, hero.x, PLAYER); } return; } /* get here only if there isn't a place to put it */ if (pr) { if (cansee(obj->o_pos.y, obj->o_pos.x)) { if (obj->o_type == WEAPON) addmsg("The %s", weaps[obj->o_which].w_name); else addmsg(inv_name(obj, LOWERCASE)); msg(" vanishes as it hits the ground."); } } discard(item); }
void death(int monst) { char **dp = (char **) rip, *killer; struct tm *lt; time_t date; char buf[80]; int c; if (is_wearing(R_RESURRECT) || rnd(wizard ? 3 : 67) == 0) { int die = TRUE; if (resurrect-- == 0) msg("You've run out of lives."); else if (!save_resurrect(ring_value(R_RESURRECT))) msg("Your attempt to return from the grave fails."); else { struct linked_list *item; struct linked_list *next_item; struct object *obj; int rm, flags; coord pos; die = FALSE; msg("You feel a sudden warmth and then nothingness."); teleport(); if (ring_value(R_RESURRECT) > 1 && rnd(10)) { pstats.s_hpt = 2 * pstats.s_const; pstats.s_const = max(pstats.s_const - 1, 3); } else { for (item = pack; item != NULL; item = next_item) { obj = OBJPTR(item); if (obj->o_flags & ISOWNED || obj->o_flags & ISPROT) { next_item = next(item); continue; } flags = obj->o_flags; obj->o_flags &= ~ISCURSED; dropcheck(obj); obj->o_flags = flags; next_item = next(item); rem_pack(obj); if (obj->o_type == ARTIFACT) has_artifact &= ~(1 << obj->o_which); do { rm = rnd_room(); rnd_pos(&rooms[rm], &pos); } while(winat(pos.y, pos.x) != FLOOR); obj->o_pos = pos; add_obj(item, obj->o_pos.y, obj->o_pos.x); } pstats.s_hpt = pstats.s_const; pstats.s_const = max(pstats.s_const - roll(2, 2), 3); } chg_str(roll(1, 4), TRUE, FALSE); pstats.s_lvl = max(pstats.s_lvl, 1); no_command += 2 + rnd(4); if (on(player, ISHUH)) lengthen_fuse(FUSE_UNCONFUSE, rnd(8) + HUHDURATION); else light_fuse(FUSE_UNCONFUSE, 0, rnd(8) + HUHDURATION, AFTER); turn_on(player, ISHUH); light(&hero); } if (die) { wmove(cw, mpos, 0); waddstr(cw, morestr); wrefresh(cw); wait_for(' '); } else return; } time(&date); lt = localtime(&date); clear(); wclear(cw); move(8, 0); while (*dp) printw("%s\n", *dp++); mvaddstr(14, 28 - ((int)(strlen(whoami) + 1) / 2), whoami); sprintf(buf, "%d+%ld Points", pstats.s_lvl, pstats.s_exp); mvaddstr(15, 28 - ((int)(strlen(buf) + 1) / 2), buf); killer = killname(monst,buf); mvaddstr(17, 28 - ((int)(strlen(killer) + 1) / 2), killer); mvaddstr(18, 28, (sprintf(prbuf, "%2d", lt->tm_year), prbuf)); move(LINES - 1, 0); mvaddstr(LINES - 1, 0, retstr); while ((c = readcharw(stdscr)) != '\n' && c != '\r') continue; idenpack(); wrefresh(cw); refresh(); score(pstats.s_exp, pstats.s_lvl, KILLED, monst); byebye(); }
int main(int argc, char *argv[]) { GLFWwindow* window; glfwSetErrorCallback(error_callback); if (!glfwInit()) exit(EXIT_FAILURE); // OpenGL 3.3, Mac OS X is reported to have some problem. However I don't have Mac to test glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); // For Mac OS X glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); window = glfwCreateWindow(1280, 960, "Mesh Smoothing Demo", NULL, NULL); if (!window) { glfwTerminate(); return EXIT_FAILURE; } glfwMakeContextCurrent(window); // This line MUST put below glfwMakeContextCurrent glewExperimental = GL_TRUE; glewInit(); // Enable vsync glfwSwapInterval(1); // Setup input callback glfwSetKeyCallback(window, key_callback); glfwSetMouseButtonCallback(window, mouse_callback); setup_gui_texture(); setup_gui_render_obj(); filenames[0] = "smoothing"; filenames[1] = "/ori/"; filenames[2] = "/lap/"; filenames[3] = "/tau/"; // load shader program shaders[0] = setup_shader(readfile("shaders/vs.txt").c_str(), readfile("shaders/fs.txt").c_str()); gui_shader = setup_shader(readfile("shaders/guivs.txt").c_str(), readfile("shaders/guifs.txt").c_str()); shaders[1] = setup_shader(readfile("shaders/nvs.txt").c_str(), readfile("shaders/nfs.txt").c_str()); shaders[2] = setup_shader(readfile("shaders/fvs.txt").c_str(), readfile("shaders/ffs.txt").c_str()); printf("we have:%d, %d, %d\n", shaders[0], shaders[1], shaders[2]); program1 = shaders[0]; show_obj = add_obj("smoothing/ori/bunny.obj"); glm::vec3 light_pos(0.0f, 0.0f, 0.0f); camera_location = glm::vec4(0.0f, 0.0f, 2.0f, 1.0f); up_direction = glm::vec4(0.0f, 1.0f, 0.0f, 1.0f); glEnable(GL_DEPTH_TEST); glCullFace(GL_BACK); glm::vec3 camera_location_xyz = glm::vec3(camera_location.x, camera_location.y, camera_location.z); glm::vec3 up_direction_xyz = glm::vec3(up_direction.x, up_direction.y, up_direction.z); setUniformMat4(shaders[0], "p", glm::perspective(glm::radians(45.0f), 640.0f/480, 0.1f, 100.f) *glm::mat4(1.0f)); setUniformMat4(shaders[0], "v", glm::lookAt(camera_location_xyz, glm::vec3(0.0f), glm::vec3(0, 1, 0))*glm::mat4(1.0f)); setUniformMat4(shaders[1], "p", glm::perspective(glm::radians(45.0f), 640.0f/480, 0.1f, 100.f) *glm::mat4(1.0f)); setUniformMat4(shaders[1], "v", glm::lookAt(camera_location_xyz, glm::vec3(0.0f), glm::vec3(0, 1, 0))*glm::mat4(1.0f)); setUniformMat4(shaders[2], "p", glm::perspective(glm::radians(45.0f), 640.0f/480, 0.1f, 100.f) *glm::mat4(1.0f)); setUniformMat4(shaders[2], "v", glm::lookAt(camera_location_xyz, glm::vec3(0.0f), glm::vec3(0, 1, 0))*glm::mat4(1.0f)); glm::mat4 rot; glm::mat4 rev; float last, start; last = start = glfwGetTime(); float fps = 0; while (!glfwWindowShouldClose(window)) { rotate(); zoom(); camera_location_xyz = glm::vec3(camera_location.x, camera_location.y, camera_location.z); up_direction_xyz = glm::vec3(up_direction.x, up_direction.y, up_direction.z); setUniformMat4(shaders[0], "v", glm::lookAt(camera_location_xyz, glm::vec3(0.0f), up_direction_xyz)*glm::mat4(1.0f)); setUniformMat4(shaders[1], "v", glm::lookAt(camera_location_xyz, glm::vec3(0.0f), up_direction_xyz)*glm::mat4(1.0f)); setUniformMat4(shaders[2], "v", glm::lookAt(camera_location_xyz, glm::vec3(0.0f), up_direction_xyz)*glm::mat4(1.0f)); render(); glfwSwapBuffers(window); glfwPollEvents(); fps++; if(glfwGetTime() - last > 1.0) { std::cout<<(double)fps/(glfwGetTime()-last)<<std::endl; fps = 0; last = glfwGetTime(); } } releaseObjects(); glfwDestroyWindow(window); glfwTerminate(); return EXIT_SUCCESS; }
static void mouse_callback(GLFWwindow* window, int click_button, int action, int mods) { button b; double xpos, ypos; int buttonID; glfwGetCursorPos(window, &xpos, &ypos); ypos = 960 - ypos; if(click_button==GLFW_MOUSE_BUTTON_1) { if(action==GLFW_PRESS) mouse_state = GLFW_PRESS; else if(action==GLFW_RELEASE && mouse_state==GLFW_PRESS) { mouse_state = GLFW_RELEASE; buttonID = gui.check_button(xpos/1.6, ypos/1.6); printf("at %f %f\n", xpos, ypos); if(buttonID!=-1) { b = gui.buttons[buttonID]; printf("at %f, %f, click %d button, its state is %d!\n", xpos, ypos, buttonID, b.state); //check if the button action dosen't need to change shader if(buttonID < 13 || buttonID > 15) { std::string s = filenames[0]; if(buttonID<3) { objects.clear(); indicesCount.clear(); s.append(filenames[1]); switch(buttonID) { case 0: s += "bunny.obj"; show_obj = add_obj(s.c_str()); now_mesh = 0; break; case 1: s += "body.obj"; show_obj = add_obj(s.c_str()); now_mesh = 1; break; case 2: s += "trex.obj"; show_obj = add_obj(s.c_str()); now_mesh = 2; break; } gui.clear_button_state(); } else if(buttonID < 13) { objects.clear(); indicesCount.clear(); switch(now_algor) { case 16: s += filenames[2]; break; case 17: s += filenames[3]; break; } switch(now_mesh) { case 0: s += "bunny"; break; case 1: s += "body"; break; case 2: s += "trex"; break; } switch(buttonID) { case 3: s += "10"; break; case 4: s += "20"; break; case 5: s += "40"; break; case 6: s += "80"; break; case 7: s += "100"; break; case 8: s += "200"; break; case 9: s += "400"; break; case 10: s += "800"; break; case 11: s += "1000"; break; case 12: s += "10000"; break; } now_times = buttonID; s += ".obj"; printf("%s\n", s.c_str()); show_obj = add_obj(s.c_str()); } else { gui.clear_button_state(3); now_algor = buttonID; } } else { //change shader if(buttonID==13 && gui.buttons[13].state==0) program1 = shaders[0]; else if(buttonID==14 && gui.buttons[14].state==0) program1 = shaders[1]; else if(buttonID==15 && gui.buttons[15].state==0) program1 = shaders[2]; printf("now program: %d\n", program1); } gui.clear_button_state(buttonID); gui.buttons[buttonID].state = 1; } } } }
int main(int argc, char *argv[]) { GLFWwindow* window; glfwSetErrorCallback(error_callback); if (!glfwInit()) exit(EXIT_FAILURE); // OpenGL 3.3, Mac OS X is reported to have some problem. However I don't have Mac to test glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); //set hint to glfwCreateWindow, (target, hintValue) glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); //hint--> window not resizable, explicit use core-profile, opengl version 3.3 // For Mac OS X glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); window = glfwCreateWindow(800, 600, "Simple Example", NULL, NULL); if (!window) { glfwTerminate(); return EXIT_FAILURE; } glfwMakeContextCurrent(window); //set current window as main window to focus // This line MUST put below glfwMakeContextCurrent glewExperimental = GL_TRUE; //tell glew to use more modern technique for managing OpenGL functionality glewInit(); // Enable vsync glfwSwapInterval(1); glProvokingVertex(GL_FIRST_VERTEX_CONVENTION); // Setup input callback glfwSetKeyCallback(window, key_callback); //set key event handler // load shader program program = setup_shader(readfile("flat_vs.txt").c_str(), readfile("flat_fs.txt").c_str()); program1 = setup_shader(readfile("gourand_vs.txt").c_str(), readfile("gourand_fs.txt").c_str()); program2 = setup_shader(readfile("phong_vs.txt").c_str(), readfile("phong_fs.txt").c_str()); program3 = setup_shader(readfile("blin_vs.txt").c_str(), readfile("blin_fs.txt").c_str()); int sun = add_obj(program, "sun.obj","sun.bmp"); int sun1 = add_obj(program1, "sun.obj", "sun.bmp"); int sun2 = add_obj(program2, "sun.obj", "sun.bmp"); int sun3 = add_obj(program3, "sun.obj", "sun.bmp"); glEnable(GL_DEPTH_TEST); // prevent faces rendering to the front while they're behind other faces. glCullFace(GL_BACK); // discard back-facing trangle // Enable blend mode for billboard //glEnable(GL_BLEND); //glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); //-----------------------------------------------------------setting view point----------------------------------// set_vp(program); set_vp(program1); set_vp(program2); set_vp(program3); //-----------------------------------------------------------end of setting--------------------------------------// //------------------------------------------------------setting viewing position---------------------------------// set_viewPosition(program); set_viewPosition(program1); set_viewPosition(program2); set_viewPosition(program3); //------------------------------------------------------end of setting-------------------------------------------// float last, start; last = start = glfwGetTime(); int fps=0; while (!glfwWindowShouldClose(window)) {//program will keep draw here until you close the window float delta = glfwGetTime() - start; render(); glfwSwapBuffers(window); //swap the color buffer and show it as output to the screen. glfwPollEvents(); //check if there is any event being triggered fps++; if(glfwGetTime() - last > 1.0) { std::cout<<(double)fps/(glfwGetTime()-last)<<std::endl; fps = 0; last = glfwGetTime(); } } releaseObjects(); glfwDestroyWindow(window); glfwTerminate(); return EXIT_SUCCESS; }
do_rooms() { int i; struct room *rp; struct linked_list *item; struct thing *tp; int left_out; coord top; coord bsze; coord mp; /* * bsze is the maximum room size */ bsze.x = COLS / 3; bsze.y = (LINES - 2) / 3; /* * Clear things for a new level */ for (rp = rooms; rp < &rooms[MAXROOMS]; rp++) rp->r_nexits = rp->r_flags = rp->r_fires = 0; /* * Put the gone rooms, if any, on the level */ left_out = rnd(4); for (i = 0; i < left_out; i++) rooms[rnd_room()].r_flags |= ISGONE; /* * dig and populate all the rooms on the level */ for (i = 0, rp = rooms; i < MAXROOMS; rp++, i++) { bool has_gold = FALSE; /* * Find upper left corner of box that this room goes in */ top.x = (i % 3) * bsze.x; top.y = i / 3 * bsze.y + 1; if (rp->r_flags & ISGONE) { /* * Place a gone room. Make certain that there is a * blank line for passage drawing. */ do { rp->r_pos.x = top.x + rnd(bsze.x - 2) + 1; rp->r_pos.y = top.y + rnd(bsze.y - 2) + 1; rp->r_max.x = -COLS; rp->r_max.x = -LINES; } while (rp->r_pos.y < 1 || rp->r_pos.y > LINES - 3); continue; } if (rnd(80) < level - 15) rp->r_flags |= ISDARK; /* * Find a place and size for a random room */ do { rp->r_max.x = rnd(bsze.x - 4) + 4; rp->r_max.y = rnd(bsze.y - 4) + 4; rp->r_pos.x = top.x + rnd(bsze.x - rp->r_max.x); rp->r_pos.y = top.y + rnd(bsze.y - rp->r_max.y); } while (rp->r_pos.y == 0); /* Draw the room */ draw_room(rp); /* * Put the gold in */ if (rnd(100) < 50 && (!has_artifact || level >= max_level)) { struct linked_list *item; struct object *cur; coord tp; has_gold = TRUE; /* This room has gold in it */ item = spec_item(GOLD, NULL, NULL, NULL); cur = OBJPTR(item); /* Put it somewhere */ rnd_pos(rp, &tp); cur->o_pos = tp; /* Put the gold into the level list of items */ add_obj(item, tp.y, tp.x); if (roomin(&tp) != rp) { endwin(); abort(); } } /* * Put the monster in */ if (rnd(100) < (has_gold ? 80 : 40)) { short which; int i, count; item = new_item(sizeof *tp); tp = THINGPTR(item); do { rnd_pos(rp, &mp); } while (mvwinch(stdscr, mp.y, mp.x) != FLOOR); which = randmonster(NOWANDER, NOGRAB); new_monster(item, which, &mp, NOMAXSTATS); /* * See if we want to give it a treasure to carry * around. */ if (rnd(100) < monsters[tp->t_index].m_carry) attach(tp->t_pack, new_thing()); /* * If it has a fire, mark it */ if (on(*tp, HASFIRE)) { rp->r_flags |= HASFIRE; rp->r_fires++; } /* * If it carries gold, give it some */ if (on(*tp, CARRYGOLD)) { struct object *cur; item = spec_item(GOLD, NULL, NULL, NULL); cur = OBJPTR(item); cur->o_count = GOLDCALC + GOLDCALC + GOLDCALC; cur->o_pos = tp->t_pos; attach(tp->t_pack, item); } i = rnd(7); if (on(*tp, ISSWARM) && i < 5) count = roll(2, 4); else if (on(*tp, ISFLOCK) && i < 5) count = roll(1, 4); else count = 0; for (i = 1; i <= count; i++) { coord *mpos; if ((mpos = place_mons(mp.y, mp.x)) != NULL) { struct linked_list *nitem; nitem = new_item(sizeof(struct thing)); new_monster(nitem, which, mpos, NOMAXSTATS); /* * If the monster is on a trap, trap * it */ if (isatrap(mvinch(mpos->y, mpos->x))) be_trapped(THINGPTR(nitem), mp); if (on(*tp, ISFRIENDLY)) turn_on(*(THINGPTR(nitem)), ISFRIENDLY); else turn_off(*(THINGPTR(nitem)), ISFRIENDLY); } } if (count > 0) { int boost = rnd(3) + 1; if (on(*tp, LOWCAST) || on(*tp, MEDCAST) || on(*tp, HIGHCAST)) turn_on(*tp, CANCAST); tp->t_stats.s_hpt += 3 * boost; tp->t_stats.s_arm -= 2 * boost; tp->t_stats.s_lvl += 2 * boost; tp->t_stats.s_str += 2 * boost; tp->t_stats.s_intel += 2 * boost; tp->t_stats.s_exp += 4 * boost * monsters[which].m_add_exp; } } } }
/*------------------------------------------------------------------------- * Function: find_objs_cb * * Purpose: Callback to find objects, committed types and store them in tables * * Return: Success: SUCCEED * * Failure: FAIL * * Programmer: Ruey-Hsia Li * * Modifications: * *------------------------------------------------------------------------- */ static herr_t find_objs_cb(const char *name, const H5O_info_t *oinfo, const char *already_seen, void *op_data) { find_objs_t *info = (find_objs_t*)op_data; herr_t ret_value = 0; switch(oinfo->type) { case H5O_TYPE_GROUP: if(NULL == already_seen) add_obj(info->group_table, oinfo->addr, name, TRUE); break; case H5O_TYPE_DATASET: if(NULL == already_seen) { hid_t dset; /* Add the dataset to the list of objects */ add_obj(info->dset_table, oinfo->addr, name, TRUE); /* Check for a dataset that uses a named datatype */ if((dset = H5Dopen2(info->fid, name, H5P_DEFAULT)) >= 0) { hid_t type = H5Dget_type(dset); if(H5Tcommitted(type) > 0) { H5O_info_t type_oinfo; H5Oget_info(type, &type_oinfo); if(search_obj(info->type_table, type_oinfo.addr) == NULL) add_obj(info->type_table, type_oinfo.addr, name, FALSE); } /* end if */ H5Tclose(type); H5Dclose(dset); } /* end if */ else ret_value = FAIL; } /* end if */ break; case H5O_TYPE_NAMED_DATATYPE: if(NULL == already_seen) { obj_t *found_obj; if((found_obj = search_obj(info->type_table, oinfo->addr)) == NULL) add_obj(info->type_table, oinfo->addr, name, TRUE); else { /* Use latest version of name */ HDfree(found_obj->objname); found_obj->objname = HDstrdup(name); /* Mark named datatype as having valid name */ found_obj->recorded = TRUE; } /* end else */ } /* end if */ break; default: break; } /* end switch */ return ret_value; }