Changeset 507
- Timestamp:
- Apr 19, 2011, 7:13:51 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
abuse/trunk/src/game.cpp
r501 r507 2395 2395 start_argv = argv; 2396 2396 2397 for(int i = 0; i < argc; i++) 2398 { 2399 if(!strcmp(argv[i], "-cprint")) 2400 { 2397 for (int i = 0; i < argc; i++) 2398 { 2399 if (!strcmp(argv[i], "-cprint")) 2401 2400 external_print = 1; 2402 } 2403 } 2404 2405 #if(defined(__APPLE__) && !defined(__MACH__)) 2401 } 2402 2403 #if (defined(__APPLE__) && !defined(__MACH__)) 2406 2404 unsigned char km[16]; 2407 2405 … … 2409 2407 xres = 320; yres = 200; 2410 2408 GetKeys((uint32_t*)&km); 2411 if ((km[ 0x3a >>3] >> (0x3a & 7)) &1 != 0)2409 if ((km[ 0x3a >>3] >> (0x3a & 7)) &1 != 0) 2412 2410 { 2413 2411 dev|=EDIT_MODE; … … 2417 2415 fprintf(stderr, "Edit Mode..."); 2418 2416 } 2419 if ((km[ 0x3b >>3] >> (0x3b & 7)) &1 != 0)2417 if ((km[ 0x3b >>3] >> (0x3b & 7)) &1 != 0) 2420 2418 { 2421 2419 PixMult = 1; … … 2427 2425 fprintf(stderr, "Double Pixel..."); 2428 2426 } 2429 if ((km[ 0x38 >>3] >> (0x38 & 7)) &1 != 0)2427 if ((km[ 0x38 >>3] >> (0x38 & 7)) &1 != 0) 2430 2428 { 2431 2429 xres *= 2; yres *= 2; … … 2434 2432 fprintf(stderr, "\n"); 2435 2433 2436 if (tcpip.installed())2434 if (tcpip.installed()) 2437 2435 fprintf(stderr, "Using %s\n", tcpip.name()); 2438 2436 #endif … … 2449 2447 2450 2448 stat_man = new text_status_manager(); 2451 if(!get_option("-no_timer")) 2452 { 2449 if (!get_option("-no_timer")) 2453 2450 timer_init(); 2454 }2455 2451 2456 2452 // look to see if we are supposed to fetch the data elsewhere 2457 if(getenv("ABUSE_PATH")) 2458 { 2453 if (getenv("ABUSE_PATH")) 2459 2454 set_filename_prefix(getenv("ABUSE_PATH")); 2460 }2461 2455 2462 2456 // look to see if we are supposed to save the data elsewhere 2463 if(getenv("ABUSE_SAVE_PATH")) 2464 { 2457 if (getenv("ABUSE_SAVE_PATH")) 2465 2458 set_save_filename_prefix(getenv("ABUSE_SAVE_PATH")); 2466 }2467 2459 2468 2460 jrand_init(); 2469 jrand(); 2461 jrand(); // so compiler doesn't complain 2470 2462 2471 2463 set_spec_main_file("abuse.spe"); 2472 2473 2464 check_for_lisp(argc, argv); 2474 2465 2475 2466 do 2476 2467 { 2477 if(main_net_cfg) 2478 { 2479 if(!main_net_cfg->notify_reset()) 2480 { 2481 if(!get_option("-no_timer")) 2482 timer_uninit(); 2483 sound_uninit(); 2484 exit(0); 2485 } 2468 if (main_net_cfg && !main_net_cfg->notify_reset()) 2469 { 2470 if (!get_option("-no_timer")) 2471 timer_uninit(); 2472 sound_uninit(); 2473 exit(0); 2486 2474 } 2487 2475 … … 2496 2484 dev_cont->load_stuff(); 2497 2485 2498 g->get_input(); // prime the net 2499 2500 int xx; 2501 for(xx = 1; xx < argc; xx++) 2502 { 2503 if(!strcmp(argv[xx], "-server")) 2486 g->get_input(); // prime the net 2487 2488 for (int i = 1; i + 1 < argc; i++) 2489 { 2490 if (!strcmp(argv[i], "-server")) 2504 2491 { 2505 xx++; 2506 if(!become_server(argv[xx])) 2492 if (!become_server(argv[i + 1])) 2507 2493 { 2508 2494 dprintf("unable to become a server\n"); 2509 2495 exit(0); 2510 2496 } 2511 xx = argc + 1;2497 break; 2512 2498 } 2513 2499 } 2514 2500 2515 if(main_net_cfg) 2516 { 2501 if (main_net_cfg) 2517 2502 wait_min_players(); 2518 }2519 2503 2520 2504 net_send(1); 2521 if (net_start())2522 { 2523 g->step(); // process all the objects in the2505 if (net_start()) 2506 { 2507 g->step(); // process all the objects in the world 2524 2508 g->calc_speed(); 2525 g->update_screen(); // redraw the screen with any changes 2526 } 2527 2528 while(!g->done()) 2529 { 2530 music_check(); 2531 2532 if(req_end) 2533 { 2534 delete current_level; 2535 current_level = NULL; 2509 g->update_screen(); // redraw the screen with any changes 2510 } 2511 2512 while (!g->done()) 2513 { 2514 music_check(); 2515 2516 if (req_end) 2517 { 2518 delete current_level; current_level = NULL; 2536 2519 2537 2520 show_end(); … … 2539 2522 the_game->set_state(MENU_STATE); 2540 2523 req_end = 0; 2541 } 2542 2543 if(demo_man.current_state()==demo_manager::NORMAL) 2544 { 2524 } 2525 2526 if (demo_man.current_state() == demo_manager::NORMAL) 2545 2527 net_receive(); 2546 } 2547 2548 if(req_name[0]) // see if a request for a level load was made during the last tick 2549 { 2550 g->load_level(req_name); 2551 req_name[0]=0; 2552 g->draw(g->state == SCENE_STATE); 2553 } 2554 2555 // if(demo_man.current_state()!=demo_manager::PLAYING) 2556 g->get_input(); 2557 2558 if(demo_man.current_state()==demo_manager::NORMAL) 2559 net_send(); 2560 else demo_man.do_inputs(); 2561 2562 service_net_request(); 2563 2564 g->step(); // process all the objects in the 2565 2566 server_check(); 2567 2568 g->calc_speed(); 2569 if(!req_name[0]) // see if a request for a level load was made during the last tick 2570 g->update_screen(); // redraw the screen with any changes 2571 2572 2573 } 2574 2575 net_uninit(); 2576 2577 if(net_crcs) 2578 { 2579 net_crcs->clean_up(); 2580 delete net_crcs; 2581 net_crcs = NULL; 2582 } 2583 2584 delete chat; 2585 2586 milli_wait(500); 2587 2588 if(small_render) { delete small_render; small_render = NULL; } 2589 2590 if(current_song) 2591 { current_song->stop(); 2592 delete current_song; 2593 current_song = NULL; 2594 } 2595 2596 2597 cache.empty(); 2598 2599 2600 if(dev_console) 2601 { 2602 delete dev_console; 2603 dev_console = NULL; 2604 } 2605 2606 if(dev_menu) 2607 { 2608 delete dev_menu; 2609 dev_menu = NULL; 2610 } 2611 2612 if(g) 2613 { 2614 delete g; 2615 g = NULL; 2616 } 2617 2618 if(old_pal) delete old_pal; old_pal = NULL; 2619 compiled_uninit(); 2620 delete_all_lights(); 2621 free(white_light_initial); 2622 2623 for(int i = 0; i < TTINTS; i++) free(tints[i]); 2624 2625 2626 dev_cleanup(); 2627 if(dev_cont) 2628 { 2629 delete dev_cont; 2630 dev_cont = NULL; 2631 } 2528 2529 // see if a request for a level load was made during the last tick 2530 if (req_name[0]) 2531 { 2532 g->load_level(req_name); 2533 req_name[0] = 0; 2534 g->draw(g->state == SCENE_STATE); 2535 } 2536 2537 //if (demo_man.current_state() != demo_manager::PLAYING) 2538 g->get_input(); 2539 2540 if (demo_man.current_state() == demo_manager::NORMAL) 2541 net_send(); 2542 else 2543 demo_man.do_inputs(); 2544 2545 service_net_request(); 2546 2547 // process all the objects in the world 2548 g->step(); 2549 server_check(); 2550 g->calc_speed(); 2551 2552 // see if a request for a level load was made during the last tick 2553 if (!req_name[0]) 2554 g->update_screen(); // redraw the screen with any changes 2555 } 2556 2557 net_uninit(); 2558 2559 if (net_crcs) 2560 net_crcs->clean_up(); 2561 delete net_crcs; net_crcs = NULL; 2562 2563 delete chat; 2564 2565 milli_wait(500); 2566 2567 delete small_render; small_render = NULL; 2568 2569 if (current_song) 2570 current_song->stop(); 2571 delete current_song; current_song = NULL; 2572 2573 cache.empty(); 2574 2575 delete dev_console; dev_console = NULL; 2576 delete dev_menu; dev_menu = NULL; 2577 delete g; g = NULL; 2578 delete old_pal; old_pal = NULL; 2579 2580 compiled_uninit(); 2581 delete_all_lights(); 2582 free(white_light_initial); 2583 2584 for (int i = 0; i < TTINTS; i++) 2585 free(tints[i]); 2586 2587 dev_cleanup(); 2588 delete dev_cont; dev_cont = NULL; 2589 delete stat_man; stat_man = new text_status_manager(); 2590 2591 if (!(main_net_cfg && main_net_cfg->restart_state())) 2592 { 2593 LSymbol *end_msg = LSymbol::FindOrCreate("end_msg"); 2594 if (DEFINEDP(end_msg->GetValue())) 2595 printf("%s\n", lstring_value(end_msg->GetValue())); 2596 } 2597 2598 lisp_uninit(); 2599 2600 base->packet.packet_reset(); 2601 } 2602 while (main_net_cfg && main_net_cfg->restart_state()); 2603 2632 2604 delete stat_man; 2633 stat_man = new text_status_manager(); 2634 2635 if(!(main_net_cfg && main_net_cfg->restart_state())) 2636 { 2637 LSymbol *end_msg = LSymbol::FindOrCreate("end_msg"); 2638 if(DEFINEDP(end_msg->GetValue())) 2639 printf("%s\n", lstring_value(end_msg->GetValue())); 2640 } 2641 2642 lisp_uninit(); 2643 2644 base->packet.packet_reset(); 2645 } while(main_net_cfg && main_net_cfg->restart_state()); 2646 2647 delete stat_man; 2648 2649 if(main_net_cfg) 2650 { 2651 delete main_net_cfg; 2652 main_net_cfg = NULL; 2653 } 2605 delete main_net_cfg; main_net_cfg = NULL; 2606 2654 2607 set_filename_prefix(NULL); // dealloc this mem if there was any 2655 2608 set_save_filename_prefix(NULL); 2656 2609 2657 if(!get_option("-no_timer")) 2658 { 2610 if (!get_option("-no_timer")) 2659 2611 timer_uninit(); 2660 }2661 2612 2662 2613 l_user_stack.clean_up(); … … 2666 2617 sound_uninit(); 2667 2618 2668 exit(0);2669 2670 2619 return 0; 2671 2620 }
Note: See TracChangeset
for help on using the changeset viewer.