void update_handler( void ) { static int pulse_area; static int pulse_mobile; static int pulse_violence; static int pulse_point; static int pulse_music; if ( --pulse_area <= 0 ) { pulse_area = PULSE_AREA; /* number_range( PULSE_AREA / 2, 3 * PULSE_AREA / 2 ); */ area_update ( ); } if ( --pulse_music <= 0 ) { pulse_music = PULSE_MUSIC; song_update(); } if ( --pulse_mobile <= 0 ) { pulse_mobile = PULSE_MOBILE; mobile_update ( ); } if ( --pulse_violence <= 0 ) { pulse_violence = PULSE_VIOLENCE; violence_update ( ); } if ( --pulse_point <= 0 ) { wiznet("TICK!",NULL,NULL,WIZ_TICKS,0,0); pulse_point = PULSE_TICK; /* number_range( PULSE_TICK / 2, 3 * PULSE_TICK / 2 ); */ weather_update ( ); char_update ( ); obj_update ( ); } aggr_update( ); tail_chain( ); return; }
static void tick_handler(struct tm *tick_time, TimeUnits units_changed) { time_update(tick_time); date_update(tick_time); weather_update(tick_time); }
int start_rendering() { static int done = 0; static void * network_thread_data[2] = { NULL, NULL }; static Uint32 last_frame_and_command_update = 0; SDL_Thread *network_thread; queue_t *message_queue; #ifndef WINDOWS SDL_EventState(SDL_SYSWMEVENT,SDL_ENABLE); #endif queue_initialise(&message_queue); network_thread_data[0] = message_queue; network_thread_data[1] = &done; network_thread = SDL_CreateThread(get_message_from_server, network_thread_data); /* Loop until done. */ while( !done ) { SDL_Event event; // handle SDL events in_main_event_loop = 1; while( SDL_PollEvent( &event ) ) { done = HandleEvent(&event); } in_main_event_loop = 0; //advance the clock cur_time = SDL_GetTicks(); //check for network data if(!queue_isempty(message_queue)) { message_t *message; while((message = queue_pop(message_queue)) != NULL) { process_message_from_server(message->data, message->length); free(message->data); free(message); } } #ifdef OLC olc_process(); #endif //OLC my_tcp_flush(my_socket); // make sure the tcp output buffer is set if (have_a_map && cur_time > last_frame_and_command_update + 60) { LOCK_ACTORS_LISTS(); next_command(); UNLOCK_ACTORS_LISTS(); move_to_next_frame(); last_frame_and_command_update = cur_time; } while (cur_time > next_second_time && real_game_second < 59) { real_game_second += 1; new_second(); next_second_time += 1000; } #ifdef NEW_SOUND weather_sound_control(); #endif //NEW_SOUND if(!limit_fps || (cur_time-last_time && 1000/(cur_time-last_time) <= limit_fps)) { weather_update(); animate_actors(); //draw everything draw_scene(); last_time=cur_time; } else { SDL_Delay(1);//give up timeslice for anyone else } #ifdef TIMER_CHECK //Check the timers to make sure that they are all still alive... check_timers(); #endif //cache handling if(cache_system)cache_system_maint(); //see if we need to exit if(exit_now) { done = 1; break; } } if(!done) { done = 1; } LOG_INFO("Client closed"); SDL_WaitThread(network_thread,&done); queue_destroy(message_queue); if(pm_log.ppl)free_pm_log(); //save all local data save_local_data(NULL, 0); #ifdef PAWN cleanup_pawn (); #endif #ifdef NEW_SOUND destroy_sound(); // Cleans up physical elements of the sound system and the streams thread clear_sound_data(); // Cleans up the config data #endif // NEW_SOUND ec_destroy_all_effects(); if (have_a_map) { destroy_map(); free_buffers(); } unload_questlog(); save_item_lists(); free_emotes(); free_actor_defs(); free_books(); free_vars(); cleanup_rules(); save_exploration_map(); cleanup_counters(); cleanup_chan_names(); cleanup_hud(); SDL_RemoveTimer(draw_scene_timer); SDL_RemoveTimer(misc_timer); end_particles (); free_bbox_tree(main_bbox_tree); main_bbox_tree = NULL; free_astro_buffer(); free_translations(); free_skybox(); /* Destroy our GL context, etc. */ SDL_QuitSubSystem(SDL_INIT_AUDIO); SDL_QuitSubSystem(SDL_INIT_TIMER); /*#ifdef WINDOWS // attempt to restart if requested if(restart_required > 0){ LOG_INFO("Restarting %s", win_command_line); SDL_CreateThread(system, win_command_line); } #endif //WINDOWS */ #ifdef NEW_SOUND final_sound_exit(); #endif #ifdef CUSTOM_UPDATE stopp_custom_update(); #endif /* CUSTOM_UPDATE */ clear_zip_archives(); destroy_tcp_out_mutex(); if (use_frame_buffer) free_reflection_framebuffer(); printf("doing SDL_Quit\n"); fflush(stderr); SDL_Quit( ); printf("done SDL_Quit\n"); fflush(stderr); cleanup_mem(); xmlCleanupParser(); FreeXML(); exit_logging(); return(0); }