Go to the first, previous, next, last section, table of contents.

Main Program

The interface provides main() for Xconq; this allows maximum flexibility in adapting to different environments. In a sense, the kernel is a large library that the interface calls to do game-related operations.

There is a standard set of calls that need to be made during initialization. The set changes from time to time, so the following extract from `skelconq' should not be taken as definitive:

    init_library_path(NULL);
    clear_game_modules();
    init_data_structures();
    parse_command_line(argc, argv, general_options);
    load_all_modules();
    check_game_validity();
    parse_command_line(argc, argv, variant_options);
    set_variants_from_options();
    parse_command_line(argc, argv, player_options);
    set_players_from_options();
    parse_command_line(argc, argv, leftover_options);
    make_trial_assignments();
    calculate_globals();
    run_synth_methods();
    final_init();
    assign_players_to_sides();
    init_displays();
    init_signal_handlers();
    run_game(0);

Note that this sequence is only straight-through for a simple command line option program; if you have one or more game setup dialogs, then you choose which to call based on how the players have progressed through the dialogs. The decision points more-or-less correspond to the different parse_command_line calls in the example. You may also need to interleave some interface-specific calls; for instance, if you want to display side emblems in a player/side selection dialog, then you will need to arrange for the emblem images to be loaded and displayable, rather than doing it as part of opening displays.

Once a game is underway, the interface is basically self-contained, needing only to call run_game periodically to keep the game moving along. run_game takes one argument which can be -1, 0, or 1. If 1, then one unit gets to do one action, then the routine returns. If 0, the calculations are gone through, but no units can act. If -1, then all possible units will move before run_game returns. This last case is not recommended for interactive programs, since moving all units in a large game may take a very long time; several minutes sometimes, and run_game may not necessarily call back to the interface very often.


Go to the first, previous, next, last section, table of contents.