As before, the control modules are where we focus our game-specific energies. In the root control folder is the control main module. The rest of the code modules are divided between the client and server branches. The data branch is where our art and other data definition resources reside.
Type in the following code and save it as the control main module at C:\Emaga5\control\main.cs. In order to save on space, there are fewer source code comments than in the last chapter.
//----------------------------------------------------------- // control/main.cs // Copyright (c) 2003 by Kenneth C. Finney. //----------------------------------------------------------- Exec("./client/presets.cs"); Exec("./server/presets.cs"); package control { function OnStart() { Parent::OnStart(); Echo("\n++++++++++++ Initializing control module ++++++++++++"); Exec("./client/initialize.cs"); Exec("./server/initialize.cs"); InitializeServer(); // Prepare the server-specific aspects InitializeClient(); // Prepare the client-specific aspects } function OnExit() { Parent::onExit(); } }; // Client package ActivatePackage(control); // Tell TGE to make the client package active
Right off the bat, we can see some new additions. The two Exec statements at the beginning load two files that contain presets. These are script variable assignment statements. We make these assignments here to specify standard or default settings. Some of the variables in those files pertain to graphics settings, others specify input modes, and things like that.
Next we have the control package, which has a few minor changes in its OnStart() function. This is where we load the two new initialization modules and then call the initialization functions for the server and then the client.