This function initializes the different subsystems of the game engine. The setjmp/longjmp mechanism of the original was replaced with exceptions. @param argsMain the original unmodified command line arguments @return
(String[] argsMain)
| 142 | * @return |
| 143 | */ |
| 144 | public static JakeServer Init(String[] argsMain) { |
| 145 | JakeServer result = null; |
| 146 | try { |
| 147 | |
| 148 | // prepare enough of the subsystems to handle |
| 149 | // cvar and command buffer management |
| 150 | List<String> args = Arrays.asList(argsMain); |
| 151 | |
| 152 | Cmd.Init(); |
| 153 | Cvar.getInstance().Init(); |
| 154 | |
| 155 | Key.Init(); |
| 156 | |
| 157 | // we need to add the early commands twice, because |
| 158 | // a basedir or cddir needs to be set before execing |
| 159 | // config files, but we want other parms to override |
| 160 | // the settings of the config files |
| 161 | Cbuf.AddEarlySetCommands(args, false); |
| 162 | Cbuf.Execute(); |
| 163 | |
| 164 | |
| 165 | FS.InitFilesystem(); |
| 166 | |
| 167 | Cbuf.reconfigure(args, false); |
| 168 | |
| 169 | FS.setCDDir(); // use cddir from config.cfg |
| 170 | |
| 171 | Cbuf.reconfigure(args, true); // reload default.cfg and config.cfg |
| 172 | |
| 173 | Globals.host_speeds= Cvar.getInstance().Get("host_speeds", "0", 0); |
| 174 | Globals.developer= Cvar.getInstance().Get("developer", "0", Defines.CVAR_ARCHIVE); |
| 175 | Globals.timescale= Cvar.getInstance().Get("timescale", "0", 0); |
| 176 | Globals.fixedtime= Cvar.getInstance().Get("fixedtime", "0", 0); |
| 177 | Globals.showtrace= Cvar.getInstance().Get("showtrace", "0", 0); |
| 178 | Globals.dedicated= Cvar.getInstance().Get("dedicated", "0", Defines.CVAR_NOSET); |
| 179 | String version = Globals.VERSION + " " + CPUSTRING + " " + BUILDSTRING; |
| 180 | Cvar.getInstance().Get("version", version, Defines.CVAR_SERVERINFO | Defines.CVAR_NOSET); |
| 181 | |
| 182 | Netchan.Netchan_Init(); //ok |
| 183 | |
| 184 | result = new SV_MAIN(); //SV_MAIN.SV_Init(); //ok |
| 185 | |
| 186 | CL.Init(); |
| 187 | |
| 188 | // add + commands from command line |
| 189 | if (Cbuf.AddLateCommands(args)) { |
| 190 | // if the user didn't give any commands, run default action |
| 191 | if (Globals.dedicated.value == 0) |
| 192 | Cbuf.AddText("d1\n"); |
| 193 | else |
| 194 | Cbuf.AddText("dedicated_start\n"); |
| 195 | |
| 196 | Cbuf.Execute(); |
| 197 | } else { |
| 198 | // the user asked for something explicit |
| 199 | // so drop the loading plaque |
| 200 | SCR.EndLoadingPlaque(); |
| 201 | } |