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; }
void update_handler( void ) { static int pulse_area; static int pulse_mobile; static int pulse_violence; static int pulse_point; static int pulse_room; struct timeval start; gettimeofday( &start, NULL ); event_update( ); delete_list( extracted ); if( --pulse_area <= 0 ) { pulse_area = number_range( PULSE_AREA/2, 3*PULSE_AREA/2 ); area_update( ); } if( --pulse_mobile <= 0 ) { pulse_mobile = PULSE_MOBILE; action_update( ); auction_update( ); regen_update( ); time_update( ); } if( --pulse_point <= 0 ) { pulse_point = number_range( PULSE_TICK/2, 3*PULSE_TICK/2 ); char_update( ); obj_update( ); } if( --pulse_room <= 0 ) { pulse_room = number_range( PULSE_ROOM/2, 3*PULSE_ROOM/2 ); room_update( ); w3_who( ); } if( --pulse_violence <= 0 ) { pulse_violence = PULSE_VIOLENCE; update_queue( ); } pulse_time[ TIME_UPDATE ] = stop_clock( start ); }
/* * Big mama top level function. */ void boot_db( void ) { /* * Init some data space stuff. */ { if ( ( string_space = calloc( 1, MAX_STRING ) ) == NULL ) { bug( "Boot_db: can't alloc %d string space.", MAX_STRING ); exit( 1 ); } top_string = string_space; fBootDb = TRUE; } /* * Init random number generator. */ { init_mm( ); } /* * Set time and weather. */ { long lhour, lday, lmonth; lhour = (current_time - 650336715) / (PULSE_TICK / PULSE_PER_SECOND); time_info.hour = lhour % 24; lday = lhour / 24; time_info.day = lday % 35; lmonth = lday / 35; time_info.month = lmonth % 17; time_info.year = lmonth / 17; if ( time_info.hour < 5 ) weather_info.sunlight = SUN_DARK; else if ( time_info.hour < 6 ) weather_info.sunlight = SUN_RISE; else if ( time_info.hour < 19 ) weather_info.sunlight = SUN_LIGHT; else if ( time_info.hour < 20 ) weather_info.sunlight = SUN_SET; else weather_info.sunlight = SUN_DARK; weather_info.change = 0; weather_info.mmhg = 960; if ( time_info.month >= 7 && time_info.month <=12 ) weather_info.mmhg += number_range( 1, 50 ); else weather_info.mmhg += number_range( 1, 80 ); if ( weather_info.mmhg <= 980 ) weather_info.sky = SKY_LIGHTNING; else if ( weather_info.mmhg <= 1000 ) weather_info.sky = SKY_RAINING; else if ( weather_info.mmhg <= 1020 ) weather_info.sky = SKY_CLOUDY; else weather_info.sky = SKY_CLOUDLESS; } /* * Assign gsn's for skills which have them. */ { int sn; for ( sn = 0; sn < MAX_SKILL; sn++ ) { if ( skill_table[sn].pgsn != NULL ) *skill_table[sn].pgsn = sn; } } /* * Read in all the area files. */ { FILE *fpList; if ( ( fpList = fopen( AREA_LIST, "r" ) ) == NULL ) { perror( AREA_LIST ); exit( 1 ); } for ( ; ; ) { strcpy( strArea, fread_word( fpList ) ); if ( strArea[0] == '$' ) break; if ( strArea[0] == '-' ) { fpArea = stdin; } else { if ( ( fpArea = fopen( strArea, "r" ) ) == NULL ) { perror( strArea ); exit( 1 ); } } for ( ; ; ) { char *word; if ( fread_letter( fpArea ) != '#' ) { bug( "Boot_db: # not found.", 0 ); exit( 1 ); } word = fread_word( fpArea ); if ( word[0] == '$' ) break; else if ( !str_cmp( word, "AREA" ) ) load_area (fpArea); else if ( !str_cmp( word, "HELPS" ) ) load_helps (fpArea); else if ( !str_cmp( word, "MOBILES" ) ) load_mobiles (fpArea); else if ( !str_cmp( word, "OBJECTS" ) ) load_objects (fpArea); else if ( !str_cmp( word, "RESETS" ) ) load_resets (fpArea); else if ( !str_cmp( word, "ROOMS" ) ) load_rooms (fpArea); else if ( !str_cmp( word, "SHOPS" ) ) load_shops (fpArea); else if ( !str_cmp( word, "SPECIALS" ) ) load_specials(fpArea); else { bug( "Boot_db: bad section name.", 0 ); exit( 1 ); } } if ( fpArea != stdin ) fclose( fpArea ); fpArea = NULL; } fclose( fpList ); } /* * Fix up exits. * Declare db booting over. * Reset all areas once. * Load up the notes file. */ { fix_exits( ); fBootDb = FALSE; area_update( ); load_notes( ); } return; }