EAPI int ecore_shutdown(void) { int (*_ecore_shutdown)(void) = dlsym(RTLD_NEXT, "ecore_shutdown"); if (_hook_setting) { if (vr_list && _hook_setting->recording) write_events(_hook_setting->file_name, vr_list); tsuite_evas_hook_reset(); free(_hook_setting); _hook_setting = NULL; } if (ts.td) free(ts.td); evas_list = eina_list_free(evas_list); memset(&ts, 0, sizeof(Tsuite_Data)); return _ecore_shutdown(); }
int main(void) { int nout, nin; mcfioC_Init(); nout = write_events(); nin = read_events(); printf(" %d events written and %d events read back\n",nout,nin); return 0; }
// ----------------------------------------------------------- // town data // ----------------------------------------------------------- bool t_abstract_town::write( std::streambuf& stream ) const { get_towndwelling_count(); // trigger assert if too many t_owned_adv_object::write( stream ); put_bitset( stream, m_buildings ); put_bitset( stream, m_enabled_buildings ); t_creature_array::write( stream ); write_string16( stream, m_name ); put<bool>( stream, m_named_by_map ); put<t_town_type>( stream, m_type ); write_events( stream ); put< t_uint8 >( stream, m_ai_importance ); return true; }
void ScreenManager::display() { show_software_cursor(globals::software_cursor); Uint32 last_ticks = SDL_GetTicks(); float previous_frame_time; std::vector<Input::Event> events; while (!screens.empty()) { events.clear(); Uint32 dt; // Get time and update Input::Events if (playback_input) { // Get Time read(std::cin, previous_frame_time); // Update InputManager so that SDL_QUIT and stuff can be // handled, even if the basic events are taken from record input_manager.update(previous_frame_time); input_controller->clear_events(); read_events(std::cin, events); //Ceu SDL_DT dt = previous_frame_time*1000; int dt_us = 1000*dt; ceu_sys_go(&CEUapp, CEU_IN__WCLOCK, &dt_us); ceu_sys_go(&CEUapp, CEU_IN_SDL_DT, &dt); } else { // Get Time Uint32 ticks = SDL_GetTicks(); previous_frame_time = float(ticks - last_ticks)/1000.0f; dt = ticks - last_ticks; last_ticks = ticks; // Update InputManager and get Events input_manager.update(previous_frame_time); input_controller->poll_events(events); //Ceu SDL_DT int dt_us = 1000*dt; ceu_sys_go(&CEUapp, CEU_IN__WCLOCK, &dt_us); ceu_sys_go(&CEUapp, CEU_IN_SDL_DT, &dt); } if (record_input) { write(std::cerr, previous_frame_time); write_events(std::cerr, events); } if (globals::software_cursor) cursor.update(previous_frame_time); // previous frame took more than one second if (previous_frame_time > 1.0) { ///if (globals::developer_mode) log_warn("ScreenManager: previous frame took longer than 1 second (%1% sec.), ignoring and doing frameskip", previous_frame_time); } else { update(previous_frame_time, events); // cap the framerate at the desired value // figure out how long this frame took float current_frame_time = float(SDL_GetTicks() - last_ticks) / 1000.0f; // idly delay if this frame didn't last long enough to // achieve <desired_fps> frames per second if (current_frame_time < 1.0f / globals::desired_fps) { Uint32 sleep_time = static_cast<Uint32>(1000 *((1.0f / globals::desired_fps) - current_frame_time)); SDL_Delay(sleep_time); } } } }
/** * Write a M2/BC file from its corresponding structure * @param bc_m2_file The file to write data. * @param ptr A pointer to a M2/BC structure. */ int write_model(FILE *bc_m2_file, BCM2 *ptr) { //Header fwrite(&ptr->header, sizeof(ModelHeader), 1, bc_m2_file); align(bc_m2_file); //Filename ptr->header.nameOfs = getPos(bc_m2_file); fwrite(ptr->filename, sizeof(char), ptr->header.nameLength, bc_m2_file); align(bc_m2_file); //Global Sequences if (ptr->header.nGlobalSequences > 0) { ptr->header.ofsGlobalSequences = getPos(bc_m2_file); fwrite(ptr->globalsequences, sizeof(int), ptr->header.nGlobalSequences, bc_m2_file); align(bc_m2_file); } //Animations if (ptr->header.nAnimations > 0) { ptr->header.ofsAnimations = getPos(bc_m2_file); fwrite(ptr->animations, sizeof(ModelAnimation), ptr->header.nAnimations, bc_m2_file); align(bc_m2_file); } //Bones write_bones(bc_m2_file, ptr); //Animlookup if (ptr->header.nAnimationLookup > 0) { ptr->header.ofsAnimationLookup = getPos(bc_m2_file); fwrite(ptr->AnimLookup, sizeof(int16), ptr->header.nAnimationLookup, bc_m2_file); align(bc_m2_file); } //PlayAnimlookup if (ptr->header.nPlayableAnimationLookup > 0) { ptr->header.ofsPlayableAnimationLookup = getPos(bc_m2_file); fwrite(ptr->PlayAnimLookup, sizeof(PlayAnimRecord), ptr->header.nPlayableAnimationLookup, bc_m2_file); align(bc_m2_file); } //Keybonelookup if (ptr->header.nKeyBoneLookup > 0) { ptr->header.ofsKeyBoneLookup = getPos(bc_m2_file); fwrite(ptr->keybonelookup, sizeof(short), ptr->header.nKeyBoneLookup, bc_m2_file); align(bc_m2_file); } //Vertices if (ptr->header.nVertices > 0) { ptr->header.ofsVertices = getPos(bc_m2_file); fwrite(ptr->vertices, sizeof(ModelVertex), ptr->header.nVertices, bc_m2_file); align(bc_m2_file); } //Views write_views(bc_m2_file, ptr); //Transparency write_transparency(bc_m2_file, ptr); //Colors write_colors(bc_m2_file, ptr); //Textures if (ptr->header.nTextures > 0) { ptr->header.ofsTextures = getPos(bc_m2_file); fwrite(ptr->textures_def, sizeof(ModelTextureDef), ptr->header.nTextures, bc_m2_file); align(bc_m2_file); int i; for (i = 0; i < ptr->header.nTextures; i++) { if (ptr->textures_def[i].type == 0) { ptr->textures_def[i].nameOfs = getPos(bc_m2_file); fwrite(ptr->texture_names[i], sizeof(char), ptr->textures_def[i].nameLen, bc_m2_file); align(bc_m2_file); } } fseek(bc_m2_file, ptr->header.ofsTextures, SEEK_SET); fwrite(ptr->textures_def, sizeof(ModelTextureDef), ptr->header.nTextures, bc_m2_file); fseek(bc_m2_file, 0, SEEK_END); } //RenderFlags if (ptr->header.nRenderFlags > 0) { ptr->header.ofsRenderFlags = getPos(bc_m2_file); fwrite(ptr->renderflags, sizeof(int), ptr->header.nRenderFlags, bc_m2_file); align(bc_m2_file); } //TexReplace if (ptr->header.nTexReplace > 0) { ptr->header.ofsTexReplace = getPos(bc_m2_file); fwrite(ptr->TexReplace, sizeof(short), ptr->header.nTexReplace, bc_m2_file); align(bc_m2_file); } //BoneLookupTable if (ptr->header.nBoneLookupTable > 0) { ptr->header.ofsBoneLookupTable = getPos(bc_m2_file); fwrite(ptr->BoneLookupTable, sizeof(int16), ptr->header.nBoneLookupTable, bc_m2_file); align(bc_m2_file); } //Lookups if (ptr->header.nTexLookup > 0) { ptr->header.ofsTexLookup = getPos(bc_m2_file); fwrite(ptr->TexLookupTable, sizeof(short), ptr->header.nTexLookup, bc_m2_file); align(bc_m2_file); } if (ptr->header.nTexUnitLookup > 0) { ptr->header.ofsTexUnitLookup = getPos(bc_m2_file); fwrite(ptr->TexUnit, sizeof(short), ptr->header.nTexUnitLookup, bc_m2_file); align(bc_m2_file); } if (ptr->header.nTransparencyLookup > 0) { ptr->header.ofsTransparencyLookup = getPos(bc_m2_file); fwrite(ptr->TransparencyLookup, sizeof(short), ptr->header.nTransparencyLookup, bc_m2_file); align(bc_m2_file); } if (ptr->header.nTexAnimLookup > 0) { ptr->header.ofsTexAnimLookup = getPos(bc_m2_file); fwrite(ptr->TexAnimLookup, sizeof(short), ptr->header.nTexAnimLookup, bc_m2_file); align(bc_m2_file); } //Attachments write_attachments(bc_m2_file, ptr); if (ptr->header.nAttachLookup > 0) { ptr->header.ofsAttachLookup = getPos(bc_m2_file); fwrite(ptr->AttachLookup, sizeof(int16), ptr->header.nAttachLookup, bc_m2_file); align(bc_m2_file); } //Events write_events(bc_m2_file, ptr); //Cameras write_cameras(bc_m2_file, ptr); if (ptr->header.nCameraLookup > 0) { ptr->header.ofsCameraLookup = getPos(bc_m2_file); fwrite(ptr->CameraLookup, sizeof(int16), ptr->header.nCameraLookup, bc_m2_file); align(bc_m2_file); } //Rewrite the header with updated offsets fseek(bc_m2_file, 0, SEEK_SET); fwrite(&ptr->header, sizeof(ModelHeader), 1, bc_m2_file); return 0; }