OpenKore source code documentation

# Initialization & main loop

## High-level description of what Kore does

When you start Kore, it first loads configuration and table files. Then it connects to the Ragnarok Online server. It will now process all data received from the server, and calculate what to do (walking, attacking monsters, etc.), in an infinite loop (until the user tells Kore to quit).

## Initialization

openkore.pl is the main source file. The following image describes what happens when openkore.pl is run:

After this, Kore will enter the main loop.

## Main loop

Every loop in the main loop lasts very shortly (exception: when it's calculating a route it can take a while). In each loop, the following things are performed:

1. #### Re-initialize X-Kore if necessary

   TODO: document how X-Kore works.

2. #### Parse command input

   If there is keyboard input available, then Kore will read the keyboard input and process the data.
   - The Interface module is the module that checks whether there is keyboard input.
   - The main loop retrieves the keyboard input data, and passes that data to the Commands module, where it is processed.

3. #### Process and handle data from RO server

   TODO

4. #### Process AI

   The AI ("Artificial Intelligence") function calculates what actions to perform, when, and in what way. See also the page that describes the AI in detail.

5. #### Handle connection states

   The function `Network::checkConnection()` handles connection issues. See the Network module for more information. Do not confuse this step with step 3, which handles network data, not network connection issues.

6. #### Misc other stuff