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:

    parse_command_line(argc, argv, general_options);
    parse_command_line(argc, argv, variant_options);
    parse_command_line(argc, argv, player_options);
    parse_command_line(argc, argv, leftover_options);

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.