| 1 |
/* Emacs style mode select -*- C -*- |
| 2 |
*----------------------------------------------------------------------------- |
| 3 |
* |
| 4 |
* |
| 5 |
* PrBoom: a Doom port merged with LxDoom and LSDLDoom |
| 6 |
* based on BOOM, a modified and improved DOOM engine |
| 7 |
* Copyright (C) 1999 by |
| 8 |
* id Software, Chi Hoang, Lee Killough, Jim Flynn, Rand Phares, Ty Halderman |
| 9 |
* Copyright (C) 1999-2004 by |
| 10 |
* Jess Haas, Nicolas Kalkhof, Colin Phipps, Florian Schulze |
| 11 |
* Copyright 2005, 2006 by |
| 12 |
* Florian Schulze, Colin Phipps, Neil Stevens, Andrey Budko |
| 13 |
* |
| 14 |
* This program is free software; you can redistribute it and/or |
| 15 |
* modify it under the terms of the GNU General Public License |
| 16 |
* as published by the Free Software Foundation; either version 2 |
| 17 |
* of the License, or (at your option) any later version. |
| 18 |
* |
| 19 |
* This program is distributed in the hope that it will be useful, |
| 20 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 21 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 22 |
* GNU General Public License for more details. |
| 23 |
* |
| 24 |
* You should have received a copy of the GNU General Public License |
| 25 |
* along with this program; if not, write to the Free Software |
| 26 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA |
| 27 |
* 02111-1307, USA. |
| 28 |
* |
| 29 |
* DESCRIPTION: |
| 30 |
* DOOM main program (D_DoomMain) and game loop (D_DoomLoop), |
| 31 |
* plus functions to determine game mode (shareware, registered), |
| 32 |
* parse command line parameters, configure game parameters (turbo), |
| 33 |
* and call the startup functions. |
| 34 |
* |
| 35 |
*----------------------------------------------------------------------------- |
| 36 |
*/ |
| 37 |
|
| 38 |
#ifdef HAVE_CONFIG_H |
| 39 |
#include "config.h" |
| 40 |
#endif |
| 41 |
|
| 42 |
#include "SDL_timer.h" |
| 43 |
|
| 44 |
#ifdef _MSC_VER |
| 45 |
#include <io.h> |
| 46 |
#include <direct.h> |
| 47 |
#else |
| 48 |
#include <unistd.h> |
| 49 |
#endif |
| 50 |
#include <sys/types.h> |
| 51 |
|
| 52 |
#include "doomdef.h" |
| 53 |
#include "doomtype.h" |
| 54 |
#include "doomstat.h" |
| 55 |
#include "d_net.h" |
| 56 |
#include "dstrings.h" |
| 57 |
#include "sounds.h" |
| 58 |
#include "z_zone.h" |
| 59 |
#include "w_wad.h" |
| 60 |
#include "s_sound.h" |
| 61 |
#include "v_video.h" |
| 62 |
#include "f_finale.h" |
| 63 |
#include "f_wipe.h" |
| 64 |
#include "m_file.h" |
| 65 |
#include "m_misc.h" |
| 66 |
#include "m_menu.h" |
| 67 |
#include "i_main.h" |
| 68 |
#include "i_system.h" |
| 69 |
#include "i_sound.h" |
| 70 |
#include "i_video.h" |
| 71 |
#include "g_game.h" |
| 72 |
#include "hu_stuff.h" |
| 73 |
#include "wi_stuff.h" |
| 74 |
#include "st_stuff.h" |
| 75 |
#include "am_map.h" |
| 76 |
#include "p_setup.h" |
| 77 |
#include "r_draw.h" |
| 78 |
#include "r_main.h" |
| 79 |
#include "r_fps.h" |
| 80 |
#include "d_main.h" |
| 81 |
#include "d_deh.h" // Ty 04/08/98 - Externalizations |
| 82 |
#include "lprintf.h" // jff 08/03/98 - declaration of lprintf |
| 83 |
#include "am_map.h" |
| 84 |
#include "e6y.h" |
| 85 |
|
| 86 |
#include "dsda/args.h" |
| 87 |
#include "dsda/configuration.h" |
| 88 |
#include "dsda/demo.h" |
| 89 |
#include "dsda/exdemo.h" |
| 90 |
#include "dsda/features.h" |
| 91 |
#include "dsda/global.h" |
| 92 |
#include "dsda/save.h" |
| 93 |
#include "dsda/data_organizer.h" |
| 94 |
#include "dsda/map_format.h" |
| 95 |
#include "dsda/mapinfo.h" |
| 96 |
#include "dsda/gameinfo.h" |
| 97 |
#include "dsda/mobjinfo.h" |
| 98 |
#include "dsda/options.h" |
| 99 |
#include "dsda/pause.h" |
| 100 |
#include "dsda/playback.h" |
| 101 |
#include "dsda/preferences.h" |
| 102 |
#include "dsda/render_stats.h" |
| 103 |
#include "dsda/settings.h" |
| 104 |
#include "dsda/signal_context.h" |
| 105 |
#include "dsda/skill_info.h" |
| 106 |
#include "dsda/skip.h" |
| 107 |
#include "dsda/sndinfo.h" |
| 108 |
#include "dsda/time.h" |
| 109 |
#include "dsda/utility.h" |
| 110 |
#include "dsda/wad_stats.h" |
| 111 |
#include "dsda/zipfile.h" |
| 112 |
#include "dsda/gl/render_scale.h" |
| 113 |
|
| 114 |
#include "heretic/mn_menu.h" |
| 115 |
#include "heretic/sb_bar.h" |
| 116 |
|
| 117 |
#include "hexen/sn_sonix.h" |
| 118 |
|
| 119 |
// NSM |
| 120 |
#include "i_capture.h" |
| 121 |
|
| 122 |
#include "i_glob.h" |
| 123 |
|
| 124 |
static void D_PageDrawer(void); |
| 125 |
|
| 126 |
char* iwadlump; |
| 127 |
char* iwadver; |
| 128 |
int EpisodeStructure = false; |
| 129 |
|
| 130 |
// jff 1/24/98 add new versions of these variables to remember command line |
| 131 |
dboolean clnomonsters; // checkparm of -nomonsters |
| 132 |
dboolean clrespawnparm; // checkparm of -respawn |
| 133 |
dboolean clfastparm; // checkparm of -fast |
| 134 |
// jff 1/24/98 end definition of command line version of play mode switches |
| 135 |
|
| 136 |
dboolean nomonsters; // working -nomonsters |
| 137 |
dboolean respawnparm; // working -respawn |
| 138 |
dboolean fastparm; // working -fast |
| 139 |
|
| 140 |
dboolean pistolstart; |
| 141 |
|
| 142 |
dboolean randomclass; |
| 143 |
|
| 144 |
dboolean singletics = false; // debug flag to cancel adaptiveness |
| 145 |
|
| 146 |
//jff 1/22/98 parms for disabling music and sound |
| 147 |
dboolean nosfxparm; |
| 148 |
dboolean nomusicparm; |
| 149 |
|
| 150 |
//jff 4/18/98 |
| 151 |
extern dboolean inhelpscreens; |
| 152 |
extern dboolean BorderNeedRefresh; |
| 153 |
|
| 154 |
int startskill; |
| 155 |
int startepisode; |
| 156 |
int startmap; |
| 157 |
dboolean autostart; |
| 158 |
FILE *debugfile; |
| 159 |
|
| 160 |
dboolean advancedemo; |
| 161 |
|
| 162 |
//jff 4/19/98 list of standard IWAD names |
| 163 |
const char *const standard_iwads[]= |
| 164 |
{ |
| 165 |
"doom2f.wad", |
| 166 |
"doom2.wad", |
| 167 |
"plutonia.wad", |
| 168 |
"tnt.wad", |
| 169 |
|
| 170 |
"doom.wad", |
| 171 |
"doom1.wad", |
| 172 |
"doomu.wad", /* CPhipps - alow doomu.wad */ |
| 173 |
|
| 174 |
"freedoom2.wad", /* [email protected]: added freedoom for Fedora Extras */ |
| 175 |
"freedoom1.wad", |
| 176 |
"freedm.wad", |
| 177 |
|
| 178 |
"chex.wad", |
| 179 |
"chex3v.wad", |
| 180 |
"chex3d2.wad", |
| 181 |
|
| 182 |
"hacx.wad", |
| 183 |
"rekkrsa.wad", |
| 184 |
|
| 185 |
"bfgdoom2.wad", |
| 186 |
"bfgdoom.wad", |
| 187 |
|
| 188 |
"heretic.wad", |
| 189 |
"hexen.wad", |
| 190 |
|
| 191 |
"heretic1.wad" |
| 192 |
}; |
| 193 |
|
| 194 |
// list of episode-formatted IWAD names |
| 195 |
const char *const episode_iwads[]= |
| 196 |
{ |
| 197 |
"doom.wad", |
| 198 |
"doom1.wad", |
| 199 |
"doomu.wad", /* CPhipps - alow doomu.wad */ |
| 200 |
|
| 201 |
"freedoom1.wad", |
| 202 |
|
| 203 |
"chex.wad", |
| 204 |
"rekkrsa.wad", |
| 205 |
|
| 206 |
"heretic.wad", |
| 207 |
|
| 208 |
"heretic1.wad" |
| 209 |
}; |
| 210 |
|
| 211 |
//e6y static |
| 212 |
const int nstandard_iwads = sizeof standard_iwads/sizeof*standard_iwads; |
| 213 |
const int nepisode_iwads = sizeof episode_iwads/sizeof*episode_iwads; |
| 214 |
|
| 215 |
/* |
| 216 |
* D_PostEvent - Event handling |
| 217 |
* |
| 218 |
* Called by I/O functions when an event is received. |
| 219 |
* Try event handlers for each code area in turn. |
| 220 |
* cph - in the true spirit of the Boom source, let the |
| 221 |
* short ciruit operator madness begin! |
| 222 |
*/ |
| 223 |
|
| 224 |
void D_PostEvent(event_t *ev) |
| 225 |
{ |
| 226 |
dsda_InputTrackEvent(ev); |
| 227 |
|
| 228 |
// Allow only sensible keys during skipping |
| 229 |
if (dsda_SkipMode()) |
| 230 |
{ |
| 231 |
if (dsda_InputActivated(dsda_input_quit)) |
| 232 |
{ |
| 233 |
// Immediate exit if quit key is pressed in skip mode |
| 234 |
I_SafeExit(0); |
| 235 |
} |
| 236 |
else if ( dsda_InputActivated(dsda_input_menu_escape)) |
| 237 |
{ |
| 238 |
dsda_ExitSkipMode(); |
| 239 |
} |
| 240 |
// use key is used for seeing the current frame |
| 241 |
else if (!dsda_InputActivated(dsda_input_use) && !dsda_InputActivated(dsda_input_demo_skip)) |
| 242 |
{ |
| 243 |
return; |
| 244 |
} |
| 245 |
} |
| 246 |
|
| 247 |
if (M_Responder(ev)) |
| 248 |
dsda_InputFlushTick(); // If the menu used the event, make it invisible |
| 249 |
else |
| 250 |
G_Responder(ev); |
| 251 |
} |
| 252 |
|
| 253 |
// |
| 254 |
// D_Wipe |
| 255 |
// |
| 256 |
// CPhipps - moved the screen wipe code from D_Display to here |
| 257 |
// The screens to wipe between are already stored, this just does the timing |
| 258 |
// and screen updating |
| 259 |
|
| 260 |
static void D_Wipe(void) |
| 261 |
{ |
| 262 |
dboolean done; |
| 263 |
int wipestart; |
| 264 |
int old_game_speed = 0; |
| 265 |
|
| 266 |
//e6y |
| 267 |
if (!dsda_RenderWipeScreen() || dsda_SkipWipe()) |
| 268 |
{ |
| 269 |
if (!raven) |
| 270 |
dsda_TrackFeature(uf_wipescreen); |
| 271 |
|
| 272 |
// If there's no screen wipe, we still need to refresh the status bar |
| 273 |
SB_Start(); |
| 274 |
return; |
| 275 |
} |
| 276 |
|
| 277 |
if (dsda_GameSpeed() != 100 && dsda_WipeAtFullSpeed()) |
| 278 |
{ |
| 279 |
old_game_speed = dsda_GameSpeed(); |
| 280 |
dsda_UpdateGameSpeed(100); |
| 281 |
} |
| 282 |
|
| 283 |
wipestart = dsda_GetTick() - 1; |
| 284 |
|
| 285 |
do |
| 286 |
{ |
| 287 |
int nowtime, tics; |
| 288 |
do |
| 289 |
{ |
| 290 |
I_uSleep(5000); // CPhipps - don't thrash cpu in this loop |
| 291 |
nowtime = dsda_GetTick(); |
| 292 |
tics = nowtime - wipestart; |
| 293 |
} |
| 294 |
while (!tics); |
| 295 |
|
| 296 |
// elim - Enable render-to-texture for GL so "melt" is rendered at same resolution as the game scene |
| 297 |
if (V_IsOpenGLMode()) |
| 298 |
{ |
| 299 |
dsda_GLLetterboxClear(); |
| 300 |
dsda_GLStartMeltRenderTexture(); |
| 301 |
} |
| 302 |
|
| 303 |
wipestart = nowtime; |
| 304 |
done = wipe_ScreenWipe(tics); |
| 305 |
|
| 306 |
// elim - Render texture to screen |
| 307 |
if (V_IsOpenGLMode()) |
| 308 |
{ |
| 309 |
dsda_GLEndMeltRenderTexture(); |
| 310 |
} |
| 311 |
|
| 312 |
M_Drawer(); // menu is drawn even on top of wipes |
| 313 |
|
| 314 |
if (capturing_video && !dsda_SkipMode() && cap_wipescreen) |
| 315 |
{ |
| 316 |
I_QueueFrameCapture(); |
| 317 |
} |
| 318 |
|
| 319 |
I_FinishUpdate(); // page flip or blit buffer |
| 320 |
} |
| 321 |
while (!done); |
| 322 |
|
| 323 |
if (old_game_speed) |
| 324 |
{ |
| 325 |
dsda_UpdateGameSpeed(old_game_speed); |
| 326 |
} |
| 327 |
|
| 328 |
force_singletics_to = gametic + BACKUPTICS; |
| 329 |
} |
| 330 |
|
| 331 |
// |
| 332 |
// D_Display |
| 333 |
// draw current display, possibly wiping it from the previous |
| 334 |
// |
| 335 |
|
| 336 |
// wipegamestate can be set to -1 to force a wipe on the next draw |
| 337 |
gamestate_t wipegamestate = GS_DEMOSCREEN; |
| 338 |
extern dboolean setsizeneeded; |
| 339 |
|
| 340 |
static void D_DrawPause(void) |
| 341 |
{ |
| 342 |
if (dsda_PauseMode(PAUSE_BUILDMODE)) |
| 343 |
return; |
| 344 |
|
| 345 |
V_BeginUIDraw(); |
| 346 |
|
| 347 |
if (hexen) |
| 348 |
{ |
| 349 |
if (!netgame) |
| 350 |
{ |
| 351 |
V_DrawNamePatch(160, 5, 0, "PAUSED", CR_DEFAULT, VPT_STRETCH); |
| 352 |
} |
| 353 |
else |
| 354 |
{ |
| 355 |
V_DrawNamePatch(160, 70, 0, "PAUSED", CR_DEFAULT, VPT_STRETCH); |
| 356 |
} |
| 357 |
} |
| 358 |
else if (heretic) |
| 359 |
MN_DrawPause(); |
| 360 |
else |
| 361 |
V_DrawNamePatch((320 - V_NamePatchWidth("M_PAUSE")) / 2, 4, 0, "M_PAUSE", CR_DEFAULT, VPT_STRETCH); |
| 362 |
|
| 363 |
V_EndUIDraw(); |
| 364 |
} |
| 365 |
|
| 366 |
static dboolean must_fill_back_screen; |
| 367 |
|
| 368 |
void D_MustFillBackScreen(void) |
| 369 |
{ |
| 370 |
must_fill_back_screen = true; |
| 371 |
} |
| 372 |
|
| 373 |
void D_Display (fixed_t frac) |
| 374 |
{ |
| 375 |
static dboolean isborderstate = false; |
| 376 |
static dboolean borderwillneedredraw = false; |
| 377 |
static gamestate_t oldgamestate = GS_DEFAULT; |
| 378 |
dboolean wipe; |
| 379 |
dboolean viewactive = false, isborder = false; |
| 380 |
|
| 381 |
// e6y |
| 382 |
if (dsda_SkipMode()) |
| 383 |
{ |
| 384 |
if (HU_DrawDemoProgress(false)) |
| 385 |
I_FinishUpdate(); |
| 386 |
if (!dsda_InputActive(dsda_input_use)) |
| 387 |
return; |
| 388 |
|
| 389 |
if (V_IsOpenGLMode()) |
| 390 |
{ |
| 391 |
gld_PreprocessLevel(); |
| 392 |
} |
| 393 |
} |
| 394 |
|
| 395 |
if (!dsda_SkipMode() || !dsda_InputActive(dsda_input_use)) |
| 396 |
if (nodrawers) // for comparative timing / profiling |
| 397 |
return; |
| 398 |
|
| 399 |
if (!I_StartDisplay()) |
| 400 |
return; |
| 401 |
|
| 402 |
if (setsizeneeded) { // change the view size if needed |
| 403 |
R_ExecuteSetViewSize(); |
| 404 |
oldgamestate = GS_DEFAULT; // force background redraw |
| 405 |
} |
| 406 |
|
| 407 |
if (V_IsOpenGLMode() && !exclusive_fullscreen && !nodrawers) |
| 408 |
dsda_GLLetterboxClear(); |
| 409 |
|
| 410 |
// save the current screen if about to wipe |
| 411 |
if ((wipe = (gamestate != wipegamestate))) |
| 412 |
{ |
| 413 |
wipe_StartScreen(); |
| 414 |
R_ResetViewInterpolation(); |
| 415 |
} |
| 416 |
|
| 417 |
if (gamestate != GS_LEVEL) { // Not a level |
| 418 |
switch (oldgamestate) { |
| 419 |
case GS_DEFAULT: |
| 420 |
case GS_LEVEL: |
| 421 |
V_SetPalette(0); // cph - use default (basic) palette |
| 422 |
default: |
| 423 |
break; |
| 424 |
} |
| 425 |
|
| 426 |
V_BeginUIDraw(); |
| 427 |
switch (gamestate) { |
| 428 |
case GS_INTERMISSION: |
| 429 |
WI_Drawer(); |
| 430 |
break; |
| 431 |
case GS_FINALE: |
| 432 |
F_Drawer(); |
| 433 |
break; |
| 434 |
case GS_DEMOSCREEN: |
| 435 |
D_PageDrawer(); |
| 436 |
break; |
| 437 |
default: |
| 438 |
break; |
| 439 |
} |
| 440 |
V_EndUIDraw(); |
| 441 |
} |
| 442 |
else { // In a level |
| 443 |
dboolean redrawborderstuff; |
| 444 |
|
| 445 |
// Work out if the player view is visible, and if there is a border |
| 446 |
viewactive = automap_off && !inhelpscreens; |
| 447 |
isborder = viewactive ? R_PartialView() : (!inhelpscreens && automap_active); |
| 448 |
|
| 449 |
if (oldgamestate != GS_LEVEL || must_fill_back_screen) { |
| 450 |
must_fill_back_screen = false; |
| 451 |
R_FillBackScreen (); // draw the pattern into the back screen |
| 452 |
redrawborderstuff = isborder; |
| 453 |
} else { |
| 454 |
// CPhipps - |
| 455 |
// If there is a border, and either there was no border last time, |
| 456 |
// or the border might need refreshing, then redraw it. |
| 457 |
redrawborderstuff = isborder && (!isborderstate || borderwillneedredraw); |
| 458 |
// The border may need redrawing next time if the border surrounds the screen, |
| 459 |
// and there is a menu being displayed |
| 460 |
borderwillneedredraw = menuactive && isborder && viewactive; |
| 461 |
// e6y |
| 462 |
// I should do it because I call R_RenderPlayerView in all cases, |
| 463 |
// not only if viewactive is true |
| 464 |
borderwillneedredraw = borderwillneedredraw || automap_on; |
| 465 |
} |
| 466 |
|
| 467 |
if (redrawborderstuff || V_IsOpenGLMode()) { |
| 468 |
// elim - Update viewport and scene offsets whenever the view is changed (user hits "-" or "+") |
| 469 |
if (redrawborderstuff && V_IsOpenGLMode()) { |
| 470 |
dsda_GLSetRenderViewportParams(); |
| 471 |
} |
| 472 |
|
| 473 |
R_DrawViewBorder(); |
| 474 |
} |
| 475 |
|
| 476 |
// elim - If we go from visible status bar to invisible status bar, update affected viewport params |
| 477 |
if (!isborder && isborderstate) { |
| 478 |
dsda_GLUpdateStatusBarVisible(); |
| 479 |
} |
| 480 |
|
| 481 |
// e6y |
| 482 |
// Boom colormaps should be applied for everything in R_RenderPlayerView |
| 483 |
use_boom_cm=true; |
| 484 |
|
| 485 |
if (frac < 0) |
| 486 |
frac = I_GetTimeFrac(); |
| 487 |
|
| 488 |
R_InterpolateView(&players[displayplayer], frac); |
| 489 |
|
| 490 |
DSDA_ADD_CONTEXT(sf_player_view); |
| 491 |
R_RenderPlayerView(&players[displayplayer]); |
| 492 |
DSDA_REMOVE_CONTEXT(sf_player_view); |
| 493 |
|
| 494 |
dsda_UpdateRenderStats(); |
| 495 |
|
| 496 |
// e6y |
| 497 |
// but should NOT be applied for automap, statusbar and HUD |
| 498 |
use_boom_cm=false; |
| 499 |
frame_fixedcolormap = 0; |
| 500 |
|
| 501 |
if (automap_active) |
| 502 |
{ |
| 503 |
AM_Drawer(false); |
| 504 |
} |
| 505 |
|
| 506 |
R_RestoreInterpolations(); |
| 507 |
|
| 508 |
DSDA_ADD_CONTEXT(sf_status_bar); |
| 509 |
ST_Drawer(redrawborderstuff || BorderNeedRefresh); |
| 510 |
DSDA_REMOVE_CONTEXT(sf_status_bar); |
| 511 |
|
| 512 |
BorderNeedRefresh = false; |
| 513 |
if (V_IsSoftwareMode()) |
| 514 |
R_DrawViewBorder(); |
| 515 |
|
| 516 |
DSDA_ADD_CONTEXT(sf_hud); |
| 517 |
HU_Drawer(); |
| 518 |
DSDA_REMOVE_CONTEXT(sf_hud); |
| 519 |
} |
| 520 |
|
| 521 |
isborderstate = isborder; |
| 522 |
oldgamestate = wipegamestate = gamestate; |
| 523 |
|
| 524 |
// draw pause pic |
| 525 |
if (dsda_Paused() && (menuactive != mnact_full)) { |
| 526 |
D_DrawPause(); |
| 527 |
} |
| 528 |
|
| 529 |
V_BeginMenuDraw(); |
| 530 |
if (M_MenuIsShaded()) |
| 531 |
M_ShadedScreen(0); |
| 532 |
V_EndMenuDraw(); |
| 533 |
|
| 534 |
// menus go directly to the screen |
| 535 |
M_Drawer(); // menu is drawn even on top of everything |
| 536 |
|
| 537 |
FakeNetUpdate(); // send out any new accumulation |
| 538 |
|
| 539 |
HU_DrawDemoProgress(true); //e6y |
| 540 |
|
| 541 |
// normal update |
| 542 |
if (!wipe) |
| 543 |
I_FinishUpdate (); // page flip or blit buffer |
| 544 |
else { |
| 545 |
// wipe update |
| 546 |
wipe_EndScreen(); |
| 547 |
D_Wipe(); |
| 548 |
} |
| 549 |
|
| 550 |
// e6y |
| 551 |
// Don't thrash cpu during pausing or if the window doesnt have focus |
| 552 |
if (dsda_CameraPaused()) { |
| 553 |
I_uSleep(5000); |
| 554 |
} |
| 555 |
|
| 556 |
dsda_LimitFPS(); |
| 557 |
|
| 558 |
I_EndDisplay(); |
| 559 |
} |
| 560 |
|
| 561 |
// |
| 562 |
// D_DoomLoop() |
| 563 |
// |
| 564 |
// Not a globally visible function, |
| 565 |
// just included for source reference, |
| 566 |
// called by D_DoomMain, never exits. |
| 567 |
// Manages timing and IO, |
| 568 |
// calls all ?_Responder, ?_Ticker, and ?_Drawer, |
| 569 |
// calls I_GetTime, I_StartFrame, and I_StartTic |
| 570 |
// |
| 571 |
|
| 572 |
static void D_DoomLoop(void) |
| 573 |
{ |
| 574 |
if (dsda_IntConfig(dsda_config_startup_delay_ms) > 0) |
| 575 |
I_uSleep(dsda_IntConfig(dsda_config_startup_delay_ms) * 1000); |
| 576 |
|
| 577 |
for (;;) |
| 578 |
{ |
| 579 |
if (I_Interrupted()) |
| 580 |
I_SafeExit(0); |
| 581 |
|
| 582 |
WasRenderedInTryRunTics = false; |
| 583 |
// frame syncronous IO operations |
| 584 |
I_StartFrame (); |
| 585 |
|
| 586 |
// process one or more tics |
| 587 |
if (singletics) |
| 588 |
{ |
| 589 |
I_StartTic (); |
| 590 |
G_BuildTiccmd (&local_cmds[consoleplayer][maketic%BACKUPTICS]); |
| 591 |
if (advancedemo) |
| 592 |
D_DoAdvanceDemo (); |
| 593 |
M_Ticker (); |
| 594 |
G_Ticker (); |
| 595 |
gametic++; |
| 596 |
maketic++; |
| 597 |
} |
| 598 |
else |
| 599 |
TryRunTics (); // will run at least one tic |
| 600 |
|
| 601 |
// killough 3/16/98: change consoleplayer to displayplayer |
| 602 |
if (players[displayplayer].mo) // cph 2002/08/10 |
| 603 |
S_UpdateSounds();// move positional sounds |
| 604 |
|
| 605 |
// Update display, next frame, with current state. |
| 606 |
if (!movement_smooth || !WasRenderedInTryRunTics || gamestate != wipegamestate) |
| 607 |
{ |
| 608 |
// NSM |
| 609 |
if (capturing_video && !dsda_SkipMode()) |
| 610 |
{ |
| 611 |
dboolean first = true; |
| 612 |
int cap_step = TICRATE * FRACUNIT / cap_fps; |
| 613 |
cap_frac += cap_step; |
| 614 |
while(cap_frac <= FRACUNIT) |
| 615 |
{ |
| 616 |
isExtraDDisplay = !first; |
| 617 |
first = false; |
| 618 |
|
| 619 |
if (gamestate == wipegamestate || cap_wipescreen) |
| 620 |
{ |
| 621 |
I_QueueFrameCapture(); |
| 622 |
} |
| 623 |
|
| 624 |
D_Display(cap_frac); |
| 625 |
|
| 626 |
isExtraDDisplay = false; |
| 627 |
cap_frac += cap_step; |
| 628 |
} |
| 629 |
cap_frac -= FRACUNIT + cap_step; |
| 630 |
} |
| 631 |
else |
| 632 |
{ |
| 633 |
D_Display(-1); |
| 634 |
} |
| 635 |
} |
| 636 |
} |
| 637 |
} |
| 638 |
|
| 639 |
// |
| 640 |
// DEMO LOOP |
| 641 |
// |
| 642 |
|
| 643 |
static int demosequence; // killough 5/2/98: made static |
| 644 |
static int pagetic; |
| 645 |
static const char *pagename; // CPhipps - const |
| 646 |
dboolean bfgedition = 0; |
| 647 |
dboolean freedm = 0; |
| 648 |
|
| 649 |
// |
| 650 |
// D_PageTicker |
| 651 |
// Handles timing for warped projection |
| 652 |
// |
| 653 |
void D_PageTicker(void) |
| 654 |
{ |
| 655 |
if (--pagetic < 0) |
| 656 |
D_AdvanceDemo(); |
| 657 |
} |
| 658 |
|
| 659 |
// Check whether to skip IWAD Demos |
| 660 |
static int dsda_SkipIwadDemos(void) |
| 661 |
{ |
| 662 |
int pwaddemo = W_PWADLumpNameExists("DEMO1"); |
| 663 |
int pwadmaps = W_PWADMapExists(); |
| 664 |
|
| 665 |
if ((pwadmaps && !pwaddemo) || lumpinfo[W_CheckNumForName("DEMO1")].size == 0) |
| 666 |
return true; |
| 667 |
|
| 668 |
return false; |
| 669 |
} |
| 670 |
|
| 671 |
// |
| 672 |
// D_PageDrawer |
| 673 |
// |
| 674 |
static void D_PageDrawer(void) |
| 675 |
{ |
| 676 |
if (raven) |
| 677 |
{ |
| 678 |
V_DrawRawScreen(pagename); |
| 679 |
if (demosequence == 1) |
| 680 |
{ |
| 681 |
V_DrawNamePatch(4, 160, 0, "ADVISOR", CR_DEFAULT, VPT_STRETCH); |
| 682 |
} |
| 683 |
return; |
| 684 |
} |
| 685 |
|
| 686 |
// Allows use of PWAD HELP2 screen in demosequence |
| 687 |
if (demosequence == 4 && pwad_help2_check) |
| 688 |
pagename = "HELP2"; |
| 689 |
|
| 690 |
// proff/nicolas 09/14/98 -- now stretchs bitmaps to fullscreen! |
| 691 |
// CPhipps - updated for new patch drawing |
| 692 |
// proff - added M_DrawCredits |
| 693 |
if (pagename) |
| 694 |
{ |
| 695 |
// e6y: wide-res |
| 696 |
V_ClearBorder(); |
| 697 |
V_DrawNamePatchFS(0, 0, 0, pagename, CR_DEFAULT, VPT_STRETCH); |
| 698 |
} |
| 699 |
else if (dsda_SkipIwadDemos() && W_PWADLumpNameExists("CREDIT")) |
| 700 |
M_DrawCredits(); |
| 701 |
else |
| 702 |
M_DrawCreditsDynamic(); |
| 703 |
} |
| 704 |
|
| 705 |
// |
| 706 |
// D_AdvanceDemo |
| 707 |
// Called after each demo or intro demosequence finishes |
| 708 |
// |
| 709 |
void D_AdvanceDemo (void) |
| 710 |
{ |
| 711 |
advancedemo = true; |
| 712 |
} |
| 713 |
|
| 714 |
/* killough 11/98: functions to perform demo sequences |
| 715 |
* cphipps 10/99: constness fixes |
| 716 |
*/ |
| 717 |
|
| 718 |
static void D_SetPageName(const char *name) |
| 719 |
{ |
| 720 |
if ((bfgedition) && name && !strncmp(name,"TITLEPIC",8)) |
| 721 |
pagename = "DMENUPIC"; |
| 722 |
else |
| 723 |
pagename = name; |
| 724 |
} |
| 725 |
|
| 726 |
void D_SetPage(const char* name, int tics, int music) |
| 727 |
{ |
| 728 |
if (music) |
| 729 |
S_StartMusic(music); |
| 730 |
|
| 731 |
if (tics) |
| 732 |
pagetic = tics; |
| 733 |
|
| 734 |
D_SetPageName(name); |
| 735 |
} |
| 736 |
|
| 737 |
static void D_DrawTitle1(const char *name) |
| 738 |
{ |
| 739 |
D_SetPage(name, TICRATE * 170 / 35, mus_intro); |
| 740 |
} |
| 741 |
|
| 742 |
static void D_DrawTitle2(const char *name) |
| 743 |
{ |
| 744 |
D_SetPage(name, 0, mus_dm2ttl); |
| 745 |
} |
| 746 |
|
| 747 |
/* killough 11/98: tabulate demo sequences |
| 748 |
*/ |
| 749 |
|
| 750 |
extern const demostate_t (*demostates)[4]; |
| 751 |
|
| 752 |
const demostate_t doom_demostates[][4] = |
| 753 |
{ |
| 754 |
{ |
| 755 |
{D_DrawTitle1, "TITLEPIC"}, |
| 756 |
{D_DrawTitle1, "TITLEPIC"}, |
| 757 |
{D_DrawTitle2, "TITLEPIC"}, |
| 758 |
{D_DrawTitle1, "TITLEPIC"}, |
| 759 |
}, |
| 760 |
|
| 761 |
{ |
| 762 |
{G_DeferedPlayDemo, "demo1"}, |
| 763 |
{G_DeferedPlayDemo, "demo1"}, |
| 764 |
{G_DeferedPlayDemo, "demo1"}, |
| 765 |
{G_DeferedPlayDemo, "demo1"}, |
| 766 |
}, |
| 767 |
|
| 768 |
{ |
| 769 |
{D_SetPageName, NULL}, |
| 770 |
{D_SetPageName, NULL}, |
| 771 |
{D_SetPageName, NULL}, |
| 772 |
{D_SetPageName, NULL}, |
| 773 |
}, |
| 774 |
|
| 775 |
{ |
| 776 |
{G_DeferedPlayDemo, "demo2"}, |
| 777 |
{G_DeferedPlayDemo, "demo2"}, |
| 778 |
{G_DeferedPlayDemo, "demo2"}, |
| 779 |
{G_DeferedPlayDemo, "demo2"}, |
| 780 |
}, |
| 781 |
|
| 782 |
{ |
| 783 |
{D_SetPageName, "HELP2"}, |
| 784 |
{D_SetPageName, "HELP2"}, |
| 785 |
{D_SetPageName, "CREDIT"}, |
| 786 |
{D_DrawTitle1, "TITLEPIC"}, |
| 787 |
}, |
| 788 |
|
| 789 |
{ |
| 790 |
{G_DeferedPlayDemo, "demo3"}, |
| 791 |
{G_DeferedPlayDemo, "demo3"}, |
| 792 |
{G_DeferedPlayDemo, "demo3"}, |
| 793 |
{G_DeferedPlayDemo, "demo3"}, |
| 794 |
}, |
| 795 |
|
| 796 |
{ |
| 797 |
{NULL}, |
| 798 |
{NULL}, |
| 799 |
// e6y |
| 800 |
// Both Plutonia and TNT are commercial like Doom2, |
| 801 |
// but in difference from Doom2, they have demo4 in demo cycle. |
| 802 |
{G_DeferedPlayDemo, "demo4"}, |
| 803 |
{D_SetPageName, "CREDIT"}, |
| 804 |
}, |
| 805 |
|
| 806 |
{ |
| 807 |
{NULL}, |
| 808 |
{NULL}, |
| 809 |
{NULL}, |
| 810 |
{G_DeferedPlayDemo, "demo4"}, |
| 811 |
}, |
| 812 |
|
| 813 |
{ |
| 814 |
{NULL}, |
| 815 |
{NULL}, |
| 816 |
{NULL}, |
| 817 |
{NULL}, |
| 818 |
} |
| 819 |
}; |
| 820 |
|
| 821 |
/* |
| 822 |
* This cycles through the demo sequences. |
| 823 |
* killough 11/98: made table-driven |
| 824 |
*/ |
| 825 |
|
| 826 |
void D_DoAdvanceDemo(void) |
| 827 |
{ |
| 828 |
players[consoleplayer].playerstate = PST_LIVE; /* not reborn */ |
| 829 |
advancedemo = false; |
| 830 |
dsda_ResetPauseMode(); |
| 831 |
gameaction = ga_nothing; |
| 832 |
|
| 833 |
pagetic = TICRATE * 11; /* killough 11/98: default behavior */ |
| 834 |
gamestate = GS_DEMOSCREEN; |
| 835 |
|
| 836 |
if (netgame && !demoplayback) |
| 837 |
demosequence = 0; |
| 838 |
else if (!demostates[++demosequence][gamemode].func) |
| 839 |
demosequence = 0; |
| 840 |
|
| 841 |
// do not even attempt to play DEMO4 if it is not available |
| 842 |
if (demosequence == 6 && gamemode == commercial && !W_LumpNameExists("demo4")) |
| 843 |
demosequence = 0; |
| 844 |
|
| 845 |
if (dsda_SkipIwadDemos()) |
| 846 |
{ |
| 847 |
// Skip blank / IWAD demos in PWADs |
| 848 |
if (demostates[demosequence][gamemode].func == G_DeferedPlayDemo) |
| 849 |
demosequence++; |
| 850 |
|
| 851 |
// Limit to just TITLEPIC / CREDIT |
| 852 |
if (demosequence > (raven ? 3 : 2)) |
| 853 |
demosequence = 0; |
| 854 |
} |
| 855 |
|
| 856 |
demostates[demosequence][gamemode].func(demostates[demosequence][gamemode].name); |
| 857 |
} |
| 858 |
|
| 859 |
// |
| 860 |
// D_StartTitle |
| 861 |
// |
| 862 |
void D_StartTitle (void) |
| 863 |
{ |
| 864 |
gameaction = ga_nothing; |
| 865 |
in_game = false; |
| 866 |
demosequence = -1; |
| 867 |
D_AdvanceDemo(); |
| 868 |
} |
| 869 |
|
| 870 |
// |
| 871 |
// D_AddFile |
| 872 |
// |
| 873 |
// Rewritten by Lee Killough |
| 874 |
// |
| 875 |
// Ty 08/29/98 - add source parm to indicate where this came from |
| 876 |
// CPhipps - static, const char* parameter |
| 877 |
// - source is an enum |
| 878 |
// - modified to allocate & use new wadfiles array |
| 879 |
void D_AddFile (const char *file, wad_source_t source) |
| 880 |
{ |
| 881 |
int len; |
| 882 |
|
| 883 |
// There can only be one iwad source! |
| 884 |
if (source == source_iwad) |
| 885 |
{ |
| 886 |
int i; |
| 887 |
|
| 888 |
for (i = 0; i < numwadfiles; ++i) |
| 889 |
if (wadfiles[i].src == source_iwad) |
| 890 |
wadfiles[i].src = source_skip; |
| 891 |
} |
| 892 |
|
| 893 |
wadfiles = Z_Realloc(wadfiles, sizeof(*wadfiles)*(numwadfiles+1)); |
| 894 |
wadfiles[numwadfiles].name = |
| 895 |
AddDefaultExtension(strcpy(Z_Malloc(strlen(file)+5), file), ".wad"); |
| 896 |
wadfiles[numwadfiles].src = source; // Ty 08/29/98 |
| 897 |
wadfiles[numwadfiles].handle = 0; |
| 898 |
|
| 899 |
// No Rest For The Living |
| 900 |
len=strlen(wadfiles[numwadfiles].name); |
| 901 |
if (len>=9 && !strnicmp(wadfiles[numwadfiles].name+len-9,"nerve.wad",9)) |
| 902 |
gamemission = pack_nerve; |
| 903 |
|
| 904 |
numwadfiles++; |
| 905 |
} |
| 906 |
|
| 907 |
// killough 10/98: support -dehout filename |
| 908 |
// cph - made const, don't cache results |
| 909 |
//e6y static |
| 910 |
const char *D_dehout(void) |
| 911 |
{ |
| 912 |
dsda_arg_t* arg; |
| 913 |
|
| 914 |
arg = dsda_Arg(dsda_arg_dehout); |
| 915 |
|
| 916 |
return arg->found ? arg->value.v_string : NULL; |
| 917 |
} |
| 918 |
|
| 919 |
// |
| 920 |
// CheckIWAD |
| 921 |
// |
| 922 |
// Verify a file is indeed tagged as an IWAD |
| 923 |
// Scan its lumps for levelnames and return gamemode as indicated |
| 924 |
// Detect missing wolf levels in DOOM II |
| 925 |
// |
| 926 |
// The filename to check is passed in iwadname, the gamemode detected is |
| 927 |
// returned in gmode, hassec returns the presence of secret levels |
| 928 |
// |
| 929 |
// jff 4/19/98 Add routine to test IWAD for validity and determine |
| 930 |
// the gamemode from it. Also note if DOOM II, whether secret levels exist |
| 931 |
// CPhipps - const char* for iwadname, made static |
| 932 |
//e6y static |
| 933 |
void CheckIWAD(const char *iwadname,GameMode_t *gmode,dboolean *hassec) |
| 934 |
{ |
| 935 |
if (M_ReadAccess(iwadname)) |
| 936 |
{ |
| 937 |
int ud=0,rg=0,sw=0,cm=0,sc=0,hx=0; |
| 938 |
dboolean dmenupic = false; |
| 939 |
dboolean large_titlepic = false; |
| 940 |
dboolean freedm_lmp = false; |
| 941 |
FILE* fp; |
| 942 |
|
| 943 |
// Identify IWAD correctly |
| 944 |
if ((fp = M_OpenFile(iwadname, "rb"))) |
| 945 |
{ |
| 946 |
wadinfo_t header; |
| 947 |
|
| 948 |
// read IWAD header |
| 949 |
if (fread(&header, sizeof(header), 1, fp) == 1) |
| 950 |
{ |
| 951 |
size_t length; |
| 952 |
filelump_t *fileinfo; |
| 953 |
|
| 954 |
if (strncmp(header.identification, "IWAD", 4)) // missing IWAD tag in header |
| 955 |
{ |
| 956 |
lprintf(LO_WARN,"CheckIWAD: IWAD tag %s not present\n", iwadname); |
| 957 |
} |
| 958 |
|
| 959 |
// read IWAD directory |
| 960 |
header.numlumps = LittleLong(header.numlumps); |
| 961 |
header.infotableofs = LittleLong(header.infotableofs); |
| 962 |
length = header.numlumps; |
| 963 |
fileinfo = Z_Malloc(length*sizeof(filelump_t)); |
| 964 |
if (fseek (fp, header.infotableofs, SEEK_SET) || |
| 965 |
fread (fileinfo, sizeof(filelump_t), length, fp) != length) |
| 966 |
{ |
| 967 |
fclose(fp); |
| 968 |
I_Error("CheckIWAD: failed to read directory %s",iwadname); |
| 969 |
} |
| 970 |
|
| 971 |
// scan directory for levelname lumps |
| 972 |
while (length--) |
| 973 |
{ |
| 974 |
if (fileinfo[length].name[0] == 'E' && |
| 975 |
fileinfo[length].name[2] == 'M' && |
| 976 |
fileinfo[length].name[4] == 0) |
| 977 |
{ |
| 978 |
if (fileinfo[length].name[1] == '4') |
| 979 |
++ud; |
| 980 |
else if (fileinfo[length].name[1] == '3') |
| 981 |
++rg; |
| 982 |
else if (fileinfo[length].name[1] == '2') |
| 983 |
++rg; |
| 984 |
else if (fileinfo[length].name[1] == '1') |
| 985 |
++sw; |
| 986 |
} |
| 987 |
else if (fileinfo[length].name[0] == 'M' && |
| 988 |
fileinfo[length].name[1] == 'A' && |
| 989 |
fileinfo[length].name[2] == 'P' && |
| 990 |
fileinfo[length].name[5] == 0) |
| 991 |
{ |
| 992 |
++cm; |
| 993 |
if (fileinfo[length].name[3] == '3') |
| 994 |
if (fileinfo[length].name[4] == '1' || |
| 995 |
fileinfo[length].name[4] == '2') |
| 996 |
++sc; |
| 997 |
} |
| 998 |
|
| 999 |
if (!strncmp(fileinfo[length].name,"DMENUPIC",8)) |
| 1000 |
dmenupic = true; |
| 1001 |
if (!strncmp(fileinfo[length].name,"TITLEPIC",8) && fileinfo[length].size > 68168) |
| 1002 |
large_titlepic = true; |
| 1003 |
if (!strncmp(fileinfo[length].name,"HACX",4)) |
| 1004 |
hx++; |
| 1005 |
if (!strncmp(fileinfo[length].name,"FREEDM",6)) |
| 1006 |
freedm_lmp = true; |
| 1007 |
} |
| 1008 |
Z_Free(fileinfo); |
| 1009 |
|
| 1010 |
} |
| 1011 |
|
| 1012 |
fclose(fp); |
| 1013 |
} |
| 1014 |
else // error from open call |
| 1015 |
I_Error("CheckIWAD: Can't open IWAD %s", iwadname); |
| 1016 |
|
| 1017 |
// unity iwad has dmenupic and a large titlepic |
| 1018 |
if (dmenupic && !large_titlepic) |
| 1019 |
bfgedition++; |
| 1020 |
if (freedm_lmp) |
| 1021 |
freedm++; |
| 1022 |
|
| 1023 |
// Determine game mode from levels present |
| 1024 |
// Must be a full set for whichever mode is present |
| 1025 |
// Lack of wolf-3d levels also detected here |
| 1026 |
|
| 1027 |
*gmode = indetermined; |
| 1028 |
*hassec = false; |
| 1029 |
if (cm>=30 || (cm>=20 && hx)) |
| 1030 |
{ |
| 1031 |
*gmode = commercial; |
| 1032 |
*hassec = sc>=2; |
| 1033 |
} |
| 1034 |
else if (ud>=9) |
| 1035 |
*gmode = retail; |
| 1036 |
else if (rg>=18) |
| 1037 |
*gmode = registered; |
| 1038 |
else if (sw>=9) |
| 1039 |
*gmode = shareware; |
| 1040 |
} |
| 1041 |
else // error from access call |
| 1042 |
I_Error("CheckIWAD: IWAD %s not readable", iwadname); |
| 1043 |
} |
| 1044 |
|
| 1045 |
// |
| 1046 |
// AddIWAD |
| 1047 |
// |
| 1048 |
void AddIWAD(const char *iwad) |
| 1049 |
{ |
| 1050 |
size_t i; |
| 1051 |
|
| 1052 |
if (!(iwad && *iwad)) |
| 1053 |
return; |
| 1054 |
|
| 1055 |
//jff 9/3/98 use logical output routine |
| 1056 |
lprintf(LO_DEBUG, "IWAD found: %s\n", iwad); //jff 4/20/98 print only if found |
| 1057 |
CheckIWAD(iwad,&gamemode,&haswolflevels); |
| 1058 |
|
| 1059 |
/* jff 8/23/98 set gamemission global appropriately in all cases |
| 1060 |
* cphipps 12/1999 - no version output here, leave that to the caller |
| 1061 |
*/ |
| 1062 |
i = strlen(iwad); |
| 1063 |
|
| 1064 |
if (i >= 11 && !strnicmp(iwad + i - 11, "heretic.wad", 11)) |
| 1065 |
{ |
| 1066 |
if (!dsda_Flag(dsda_arg_heretic)) |
| 1067 |
dsda_UpdateFlag(dsda_arg_heretic, true); |
| 1068 |
} |
| 1069 |
|
| 1070 |
if (i >= 9 && !strnicmp(iwad + i - 9, "hexen.wad", 9)) |
| 1071 |
{ |
| 1072 |
if (!dsda_Flag(dsda_arg_hexen)) |
| 1073 |
dsda_UpdateFlag(dsda_arg_hexen, true); |
| 1074 |
|
| 1075 |
gamemode = commercial; |
| 1076 |
haswolflevels = false; |
| 1077 |
} |
| 1078 |
|
| 1079 |
if (i >= 12 && !strnicmp(iwad + i - 12, "heretic1.wad", 12)) |
| 1080 |
{ |
| 1081 |
if (!dsda_Flag(dsda_arg_heretic)) |
| 1082 |
dsda_UpdateFlag(dsda_arg_heretic, true); |
| 1083 |
|
| 1084 |
gamemode = shareware; |
| 1085 |
} |
| 1086 |
|
| 1087 |
switch(gamemode) |
| 1088 |
{ |
| 1089 |
case retail: |
| 1090 |
case registered: |
| 1091 |
case shareware: |
| 1092 |
gamemission = doom; |
| 1093 |
if (i>=8 && !strnicmp(iwad+i-8,"chex.wad",8)) |
| 1094 |
gamemission = tc_chex; |
| 1095 |
else if (i>=10 && !strnicmp(iwad+i-10,"chex3v.wad",10)) |
| 1096 |
gamemission = tc_chex3v; |
| 1097 |
else if (i>=11 && !strnicmp(iwad+i-11,"rekkrsa.wad",11)) |
| 1098 |
gamemission = tc_rekkr; |
| 1099 |
else if (i>=13 && !strnicmp(iwad+i-13,"freedoom1.wad",13)) |
| 1100 |
gamemission = tc_freedoom; |
| 1101 |
break; |
| 1102 |
case commercial: |
| 1103 |
gamemission = doom2; |
| 1104 |
if (i>=10 && !strnicmp(iwad+i-10,"doom2f.wad",10)) |
| 1105 |
language=french; |
| 1106 |
else if (i>=7 && !strnicmp(iwad+i-7,"tnt.wad",7)) |
| 1107 |
gamemission = pack_tnt; |
| 1108 |
else if (i>=12 && !strnicmp(iwad+i-12,"plutonia.wad",12)) |
| 1109 |
gamemission = pack_plut; |
| 1110 |
else if (i>=11 && !strnicmp(iwad+i-11,"chex3d2.wad",11)) |
| 1111 |
gamemission = tc_chex3v; |
| 1112 |
else if (i>=8 && !strnicmp(iwad+i-8,"hacx.wad",8)) |
| 1113 |
gamemission = tc_hacx; |
| 1114 |
else if ((i>=13 && !strnicmp(iwad+i-13,"freedoom2.wad",13)) |
| 1115 |
|| (i>=10 && !strnicmp(iwad+i-10,"freedm.wad",10))) |
| 1116 |
gamemission = tc_freedoom; |
| 1117 |
break; |
| 1118 |
default: |
| 1119 |
gamemission = none; |
| 1120 |
break; |
| 1121 |
} |
| 1122 |
if (gamemode == indetermined) |
| 1123 |
//jff 9/3/98 use logical output routine |
| 1124 |
lprintf(LO_WARN,"Unknown Game Version, may not work\n"); |
| 1125 |
|
| 1126 |
// Set up TC game logic |
| 1127 |
tc_game = (gamemission > pack_nerve); |
| 1128 |
|
| 1129 |
D_AddFile(iwad,source_iwad); |
| 1130 |
} |
| 1131 |
|
| 1132 |
/* |
| 1133 |
* FindIWADFIle |
| 1134 |
* |
| 1135 |
* Search for one of the standard IWADs |
| 1136 |
* CPhipps - static, proper prototype |
| 1137 |
* - 12/1999 - rewritten to use I_FindFile |
| 1138 |
*/ |
| 1139 |
static inline dboolean CheckExeSuffix(const char *suffix) |
| 1140 |
{ |
| 1141 |
extern char **dsda_argv; |
| 1142 |
|
| 1143 |
char *dash; |
| 1144 |
|
| 1145 |
if ((dash = strrchr(dsda_argv[0], '-'))) |
| 1146 |
if (!strnicmp(dash, suffix, strlen(suffix))) |
| 1147 |
return true; |
| 1148 |
|
| 1149 |
return false; |
| 1150 |
} |
| 1151 |
|
| 1152 |
static char *FindIWADFile(void) |
| 1153 |
{ |
| 1154 |
int i; |
| 1155 |
dsda_arg_t* arg; |
| 1156 |
char * iwad = NULL; |
| 1157 |
int iwadnum = EpisodeStructure ? nepisode_iwads : nstandard_iwads; |
| 1158 |
|
| 1159 |
if (CheckExeSuffix("-heretic")) |
| 1160 |
{ |
| 1161 |
if (!dsda_Flag(dsda_arg_heretic)) |
| 1162 |
dsda_UpdateFlag(dsda_arg_heretic, true); |
| 1163 |
} |
| 1164 |
else if (CheckExeSuffix("-hexen")) |
| 1165 |
{ |
| 1166 |
if (!dsda_Flag(dsda_arg_hexen)) |
| 1167 |
dsda_UpdateFlag(dsda_arg_hexen, true); |
| 1168 |
} |
| 1169 |
|
| 1170 |
arg = dsda_Arg(dsda_arg_iwad); |
| 1171 |
if (arg->found) |
| 1172 |
{ |
| 1173 |
iwad = I_FindWad(arg->value.v_string); |
| 1174 |
} |
| 1175 |
else |
| 1176 |
{ |
| 1177 |
if (dsda_Flag(dsda_arg_heretic)) |
| 1178 |
return I_FindWad("heretic.wad"); |
| 1179 |
else if (dsda_Flag(dsda_arg_hexen)) |
| 1180 |
return I_FindWad("hexen.wad"); |
| 1181 |
|
| 1182 |
if (iwadlump != NULL) |
| 1183 |
return I_FindWad(iwadlump); |
| 1184 |
|
| 1185 |
for (i=0; !iwad && i<iwadnum; i++) |
| 1186 |
iwad = EpisodeStructure ? I_FindWad(episode_iwads[i]) : I_FindWad(standard_iwads[i]); |
| 1187 |
} |
| 1188 |
return iwad; |
| 1189 |
} |
| 1190 |
|
| 1191 |
static dboolean FileMatchesIWAD(const char *name) |
| 1192 |
{ |
| 1193 |
int i; |
| 1194 |
int name_length; |
| 1195 |
|
| 1196 |
name_length = strlen(name); |
| 1197 |
for (i = 0; i < nstandard_iwads; ++i) |
| 1198 |
{ |
| 1199 |
int iwad_length; |
| 1200 |
|
| 1201 |
iwad_length = strlen(standard_iwads[i]); |
| 1202 |
if ( |
| 1203 |
name_length >= iwad_length && |
| 1204 |
!stricmp(name + name_length - iwad_length, standard_iwads[i]) |
| 1205 |
) |
| 1206 |
return true; |
| 1207 |
} |
| 1208 |
|
| 1209 |
return false; |
| 1210 |
} |
| 1211 |
|
| 1212 |
// |
| 1213 |
// DoLooseFiles |
| 1214 |
// |
| 1215 |
// Take any file names on the command line before the first switch parm |
| 1216 |
// and insert the appropriate -file, -deh or -playdemo switch in front |
| 1217 |
// of them. |
| 1218 |
// |
| 1219 |
// e6y |
| 1220 |
// Fixed crash if numbers of wads/lmps/dehs is greater than 100 |
| 1221 |
// Fixed bug when length of argname is smaller than 3 |
| 1222 |
// Refactoring of the code to avoid use the static arrays |
| 1223 |
// The logic of DoLooseFiles has been rewritten in more optimized style |
| 1224 |
// MAXARGVS has been removed. |
| 1225 |
|
| 1226 |
static void DoLooseFiles(void) |
| 1227 |
{ |
| 1228 |
extern int dsda_argc; |
| 1229 |
extern char **dsda_argv; |
| 1230 |
|
| 1231 |
int i, k; |
| 1232 |
const int loose_wad_index = 0; |
| 1233 |
|
| 1234 |
struct { |
| 1235 |
const char *ext; |
| 1236 |
dsda_arg_identifier_t arg_id; |
| 1237 |
} looses[] = { |
| 1238 |
{ ".wad", dsda_arg_file }, |
| 1239 |
{ ".zip", dsda_arg_file }, |
| 1240 |
{ ".lmp", dsda_arg_playdemo }, |
| 1241 |
{ ".deh", dsda_arg_deh }, |
| 1242 |
{ ".bex", dsda_arg_deh }, |
| 1243 |
// assume wad if no extension or length of the extention is not equal to 3 |
| 1244 |
// must be last entry |
| 1245 |
{ "", dsda_arg_file }, |
| 1246 |
{ 0 } |
| 1247 |
}; |
| 1248 |
|
| 1249 |
for (i = 1; i < dsda_argc; i++) |
| 1250 |
{ |
| 1251 |
size_t arglen, extlen; |
| 1252 |
|
| 1253 |
if (*dsda_argv[i] == '-') break; // quit at first switch |
| 1254 |
|
| 1255 |
// so now we must have a loose file. Find out what kind and store it. |
| 1256 |
arglen = strlen(dsda_argv[i]); |
| 1257 |
|
| 1258 |
for (k = 0; looses[k].ext; ++k) |
| 1259 |
{ |
| 1260 |
extlen = strlen(looses[k].ext); |
| 1261 |
if (arglen >= extlen && !stricmp(&dsda_argv[i][arglen - extlen], looses[k].ext)) |
| 1262 |
{ |
| 1263 |
// If a wad is an iwad, we don't want to send it to -file |
| 1264 |
if (k == loose_wad_index && FileMatchesIWAD(dsda_argv[i])) |
| 1265 |
{ |
| 1266 |
dsda_UpdateStringArg(dsda_arg_iwad, dsda_argv[i]); |
| 1267 |
break; |
| 1268 |
} |
| 1269 |
|
| 1270 |
dsda_AppendStringArg(looses[k].arg_id, dsda_argv[i]); |
| 1271 |
break; |
| 1272 |
} |
| 1273 |
} |
| 1274 |
} |
| 1275 |
} |
| 1276 |
|
| 1277 |
const char *port_wad_file; |
| 1278 |
|
| 1279 |
// CPhipps - misc screen stuff |
| 1280 |
int desired_screenwidth, desired_screenheight; |
| 1281 |
|
| 1282 |
// Calculate the path to the directory for autoloaded WADs/DEHs. |
| 1283 |
// Creates the directory as necessary. |
| 1284 |
|
| 1285 |
static char *autoload_path = NULL; |
| 1286 |
|
| 1287 |
static char *GetAutoloadDir(const char *iwadname, dboolean createdir) |
| 1288 |
{ |
| 1289 |
char *result; |
| 1290 |
int len; |
| 1291 |
|
| 1292 |
if (autoload_path == NULL) |
| 1293 |
{ |
| 1294 |
const char* configdir = I_ConfigDir(); |
| 1295 |
len = snprintf(NULL, 0, "%s/autoload", configdir); |
| 1296 |
autoload_path = Z_Malloc(len+1); |
| 1297 |
snprintf(autoload_path, len+1, "%s/autoload", configdir); |
| 1298 |
} |
| 1299 |
|
| 1300 |
M_MakeDir(autoload_path, false); |
| 1301 |
|
| 1302 |
len = snprintf(NULL, 0, "%s/%s", autoload_path, iwadname); |
| 1303 |
result = Z_Malloc(len+1); |
| 1304 |
snprintf(result, len+1, "%s/%s", autoload_path, iwadname); |
| 1305 |
|
| 1306 |
if (createdir) |
| 1307 |
{ |
| 1308 |
M_MakeDir(result, false); |
| 1309 |
} |
| 1310 |
|
| 1311 |
return result; |
| 1312 |
} |
| 1313 |
|
| 1314 |
const char *IWADBaseName(void) |
| 1315 |
{ |
| 1316 |
int i; |
| 1317 |
|
| 1318 |
for (i = 0; i < numwadfiles; i++) |
| 1319 |
{ |
| 1320 |
if (wadfiles[i].src == source_iwad) |
| 1321 |
break; |
| 1322 |
} |
| 1323 |
|
| 1324 |
if (i == numwadfiles) |
| 1325 |
I_Error("IWADBaseName: IWAD not found\n"); |
| 1326 |
|
| 1327 |
return dsda_BaseName(wadfiles[i].name); |
| 1328 |
} |
| 1329 |
|
| 1330 |
typedef struct { |
| 1331 |
char **list; |
| 1332 |
int count; |
| 1333 |
int allocated_count; |
| 1334 |
} deh_queue_t; |
| 1335 |
|
| 1336 |
static deh_queue_t autoload_deh_all_queue; |
| 1337 |
static deh_queue_t autoload_deh_game_queue; |
| 1338 |
static deh_queue_t autoload_deh_iwad_queue; |
| 1339 |
static deh_queue_t *autoload_deh_pwad_queue; |
| 1340 |
static int autoload_deh_pwad_count; |
| 1341 |
|
| 1342 |
static void D_QueueAutoloadDeh(deh_queue_t *queue, const char *name) |
| 1343 |
{ |
| 1344 |
int old_count; |
| 1345 |
|
| 1346 |
old_count = queue->count; |
| 1347 |
++queue->count; |
| 1348 |
|
| 1349 |
if (queue->count > queue->allocated_count) |
| 1350 |
{ |
| 1351 |
if (!queue->allocated_count) |
| 1352 |
queue->allocated_count = 4; |
| 1353 |
|
| 1354 |
while (queue->count > queue->allocated_count) |
| 1355 |
queue->allocated_count *= 2; |
| 1356 |
|
| 1357 |
queue->list = Z_Realloc(queue->list, queue->allocated_count * sizeof(*queue->list)); |
| 1358 |
memset(&queue->list[old_count], 0, (queue->allocated_count - old_count) * sizeof(*queue->list)); |
| 1359 |
} |
| 1360 |
|
| 1361 |
queue->list[queue->count - 1] = Z_Strdup(name); |
| 1362 |
} |
| 1363 |
|
| 1364 |
static void D_ProcessDehAutoloadQueue(deh_queue_t *queue) |
| 1365 |
{ |
| 1366 |
int i; |
| 1367 |
|
| 1368 |
for (i = 0; i < queue->count; ++i) |
| 1369 |
{ |
| 1370 |
ProcessDehFile(queue->list[i], D_dehout(), 0); |
| 1371 |
Z_Free(queue->list[i]); |
| 1372 |
} |
| 1373 |
|
| 1374 |
Z_Free(queue->list); |
| 1375 |
} |
| 1376 |
|
| 1377 |
// Load all WAD files from the given directory. |
| 1378 |
|
| 1379 |
static void LoadWADsAtPath(const char *path, wad_source_t source) |
| 1380 |
{ |
| 1381 |
glob_t *glob; |
| 1382 |
const char *filename; |
| 1383 |
|
| 1384 |
glob = I_StartMultiGlob(path, GLOB_FLAG_NOCASE|GLOB_FLAG_SORTED, |
| 1385 |
"*.wad", "*.lmp", NULL); |
| 1386 |
for (;;) |
| 1387 |
{ |
| 1388 |
filename = I_NextGlob(glob); |
| 1389 |
if (filename == NULL) |
| 1390 |
{ |
| 1391 |
break; |
| 1392 |
} |
| 1393 |
D_AddFile(filename, source); |
| 1394 |
} |
| 1395 |
|
| 1396 |
I_EndGlob(glob); |
| 1397 |
} |
| 1398 |
|
| 1399 |
static void LoadDehackedFilesAtPath(const char *path, dboolean defer_loading, deh_queue_t *deh_queue) |
| 1400 |
{ |
| 1401 |
const char *filename; |
| 1402 |
glob_t *glob; |
| 1403 |
|
| 1404 |
glob = I_StartMultiGlob(path, GLOB_FLAG_NOCASE|GLOB_FLAG_SORTED, |
| 1405 |
"*.deh", "*.bex", NULL); |
| 1406 |
for (;;) |
| 1407 |
{ |
| 1408 |
filename = I_NextGlob(glob); |
| 1409 |
if (filename == NULL) |
| 1410 |
{ |
| 1411 |
break; |
| 1412 |
} |
| 1413 |
|
| 1414 |
if (deh_queue) |
| 1415 |
{ |
| 1416 |
D_QueueAutoloadDeh(deh_queue, filename); |
| 1417 |
} |
| 1418 |
else if (defer_loading) |
| 1419 |
{ |
| 1420 |
dsda_AppendStringArg(dsda_arg_deh, filename); |
| 1421 |
} |
| 1422 |
else |
| 1423 |
{ |
| 1424 |
ProcessDehFile(filename, D_dehout(), 0); |
| 1425 |
} |
| 1426 |
} |
| 1427 |
|
| 1428 |
I_EndGlob(glob); |
| 1429 |
} |
| 1430 |
|
| 1431 |
static void D_AddZip(const char* zipped_file_name, wad_source_t source, deh_queue_t *deh_queue) |
| 1432 |
{ |
| 1433 |
char* full_zip_path; |
| 1434 |
const char* temporary_directory; |
| 1435 |
|
| 1436 |
full_zip_path = I_RequireZip(zipped_file_name); |
| 1437 |
temporary_directory = dsda_UnzipFile(full_zip_path); |
| 1438 |
|
| 1439 |
LoadWADsAtPath(temporary_directory, source); |
| 1440 |
if (MainLumpCache) |
| 1441 |
LoadDehackedFilesAtPath(temporary_directory, true, deh_queue); |
| 1442 |
|
| 1443 |
Z_Free(full_zip_path); |
| 1444 |
} |
| 1445 |
|
| 1446 |
static void D_AddUnzippedFile(const char* zipped_file_name, wad_source_t source, deh_queue_t *deh_queue) |
| 1447 |
{ |
| 1448 |
char* full_zip_path; |
| 1449 |
const char* temporary_directory; |
| 1450 |
|
| 1451 |
full_zip_path = I_RequireZip(zipped_file_name); |
| 1452 |
temporary_directory = dsda_ReadUnzippedFile(full_zip_path); |
| 1453 |
|
| 1454 |
LoadWADsAtPath(temporary_directory, source); |
| 1455 |
LoadDehackedFilesAtPath(temporary_directory, true, deh_queue); |
| 1456 |
|
| 1457 |
Z_Free(full_zip_path); |
| 1458 |
} |
| 1459 |
|
| 1460 |
static void LoadZIPsAtPath(const char *path, wad_source_t source, deh_queue_t *deh_queue) |
| 1461 |
{ |
| 1462 |
glob_t *glob; |
| 1463 |
const char *filename; |
| 1464 |
|
| 1465 |
glob = I_StartMultiGlob(path, GLOB_FLAG_NOCASE|GLOB_FLAG_SORTED, |
| 1466 |
"*.zip", NULL); |
| 1467 |
for (;;) |
| 1468 |
{ |
| 1469 |
filename = I_NextGlob(glob); |
| 1470 |
if (filename == NULL) |
| 1471 |
{ |
| 1472 |
break; |
| 1473 |
} |
| 1474 |
D_AddZip(filename, source, deh_queue); |
| 1475 |
} |
| 1476 |
|
| 1477 |
I_EndGlob(glob); |
| 1478 |
} |
| 1479 |
|
| 1480 |
static const char *D_AutoLoadGameBase() |
| 1481 |
{ |
| 1482 |
return hexen ? "hexen-all" : |
| 1483 |
heretic ? "heretic-all" : |
| 1484 |
(gamemission == tc_chex || |
| 1485 |
gamemission == tc_chex3v) ? "chex-all" : |
| 1486 |
(gamemission == tc_freedoom) ? "freedoom-all" : |
| 1487 |
!tc_game ? "doom-all": |
| 1488 |
NULL; |
| 1489 |
} |
| 1490 |
|
| 1491 |
#define ALL_AUTOLOAD "all-all" |
| 1492 |
|
| 1493 |
// auto-loading of .wad files. |
| 1494 |
|
| 1495 |
void D_AutoloadIWadDir() |
| 1496 |
{ |
| 1497 |
char *autoload_dir; |
| 1498 |
|
| 1499 |
// common auto-loaded files for all games |
| 1500 |
autoload_dir = GetAutoloadDir(ALL_AUTOLOAD, true); |
| 1501 |
LoadWADsAtPath(autoload_dir, source_auto_load); |
| 1502 |
LoadZIPsAtPath(autoload_dir, source_auto_load, &autoload_deh_all_queue); |
| 1503 |
Z_Free(autoload_dir); |
| 1504 |
|
| 1505 |
if (D_AutoLoadGameBase()) |
| 1506 |
{ |
| 1507 |
// common auto-loaded files for the game |
| 1508 |
autoload_dir = GetAutoloadDir(D_AutoLoadGameBase(), true); |
| 1509 |
LoadWADsAtPath(autoload_dir, source_auto_load); |
| 1510 |
LoadZIPsAtPath(autoload_dir, source_auto_load, &autoload_deh_game_queue); |
| 1511 |
Z_Free(autoload_dir); |
| 1512 |
} |
| 1513 |
|
| 1514 |
// auto-loaded files per IWAD |
| 1515 |
autoload_dir = GetAutoloadDir(IWADBaseName(), true); |
| 1516 |
LoadWADsAtPath(autoload_dir, source_auto_load); |
| 1517 |
LoadZIPsAtPath(autoload_dir, source_auto_load, &autoload_deh_iwad_queue); |
| 1518 |
Z_Free(autoload_dir); |
| 1519 |
} |
| 1520 |
|
| 1521 |
static void D_AutoloadPWadDir() |
| 1522 |
{ |
| 1523 |
int i; |
| 1524 |
|
| 1525 |
autoload_deh_pwad_count = numwadfiles; |
| 1526 |
autoload_deh_pwad_queue = Z_Calloc(autoload_deh_pwad_count, sizeof(*autoload_deh_pwad_queue)); |
| 1527 |
|
| 1528 |
for (i = 0; i < numwadfiles; ++i) |
| 1529 |
if (wadfiles[i].src == source_pwad) |
| 1530 |
{ |
| 1531 |
char *autoload_dir; |
| 1532 |
autoload_dir = GetAutoloadDir(dsda_BaseName(wadfiles[i].name), false); |
| 1533 |
LoadWADsAtPath(autoload_dir, source_auto_load); |
| 1534 |
LoadZIPsAtPath(autoload_dir, source_auto_load, &autoload_deh_pwad_queue[i]); |
| 1535 |
Z_Free(autoload_dir); |
| 1536 |
} |
| 1537 |
} |
| 1538 |
|
| 1539 |
// auto-loading of .deh files. |
| 1540 |
|
| 1541 |
static void D_AutoloadDehIWadDir() |
| 1542 |
{ |
| 1543 |
char *autoload_dir; |
| 1544 |
|
| 1545 |
// common auto-loaded files for all games |
| 1546 |
autoload_dir = GetAutoloadDir(ALL_AUTOLOAD, true); |
| 1547 |
LoadDehackedFilesAtPath(autoload_dir, false, NULL); |
| 1548 |
D_ProcessDehAutoloadQueue(&autoload_deh_all_queue); |
| 1549 |
Z_Free(autoload_dir); |
| 1550 |
|
| 1551 |
if (D_AutoLoadGameBase()) |
| 1552 |
{ |
| 1553 |
// common auto-loaded files for the game |
| 1554 |
autoload_dir = GetAutoloadDir(D_AutoLoadGameBase(), true); |
| 1555 |
LoadDehackedFilesAtPath(autoload_dir, false, NULL); |
| 1556 |
D_ProcessDehAutoloadQueue(&autoload_deh_game_queue); |
| 1557 |
Z_Free(autoload_dir); |
| 1558 |
} |
| 1559 |
|
| 1560 |
// auto-loaded files per IWAD |
| 1561 |
autoload_dir = GetAutoloadDir(IWADBaseName(), true); |
| 1562 |
LoadDehackedFilesAtPath(autoload_dir, false, NULL); |
| 1563 |
D_ProcessDehAutoloadQueue(&autoload_deh_iwad_queue); |
| 1564 |
Z_Free(autoload_dir); |
| 1565 |
} |
| 1566 |
|
| 1567 |
static void D_AutoloadDehPWadDir() |
| 1568 |
{ |
| 1569 |
int i; |
| 1570 |
for (i = 0; i < numwadfiles; ++i) |
| 1571 |
if (wadfiles[i].src == source_pwad) |
| 1572 |
{ |
| 1573 |
char *autoload_dir; |
| 1574 |
autoload_dir = GetAutoloadDir(dsda_BaseName(wadfiles[i].name), false); |
| 1575 |
LoadDehackedFilesAtPath(autoload_dir, false, NULL); |
| 1576 |
if (i < autoload_deh_pwad_count) |
| 1577 |
D_ProcessDehAutoloadQueue(&autoload_deh_pwad_queue[i]); |
| 1578 |
Z_Free(autoload_dir); |
| 1579 |
} |
| 1580 |
|
| 1581 |
Z_Free(autoload_deh_pwad_queue); |
| 1582 |
} |
| 1583 |
|
| 1584 |
int warpepisode = -1; |
| 1585 |
int warpmap = -1; |
| 1586 |
|
| 1587 |
static void HandleWarp(void) |
| 1588 |
{ |
| 1589 |
dsda_arg_t* arg; |
| 1590 |
|
| 1591 |
arg = dsda_Arg(dsda_arg_warp); |
| 1592 |
|
| 1593 |
if (arg->found) |
| 1594 |
{ |
| 1595 |
autostart = true; // Ty 08/29/98 - move outside the decision tree |
| 1596 |
|
| 1597 |
dsda_ResolveWarp(arg->value.v_int_array, arg->count, &warpepisode, &warpmap); |
| 1598 |
|
| 1599 |
if (warpmap == -1) |
| 1600 |
dsda_FirstMap(&warpepisode, &warpmap); |
| 1601 |
|
| 1602 |
startmap = warpmap; |
| 1603 |
startepisode = warpepisode; |
| 1604 |
} |
| 1605 |
} |
| 1606 |
|
| 1607 |
static void HandleClass(void) |
| 1608 |
{ |
| 1609 |
int p; |
| 1610 |
dsda_arg_t* arg; |
| 1611 |
int player_class = PCLASS_FIGHTER; |
| 1612 |
|
| 1613 |
if (!hexen) return; |
| 1614 |
|
| 1615 |
arg = dsda_Arg(dsda_arg_class); |
| 1616 |
if (arg->found) |
| 1617 |
player_class = arg->value.v_int + PCLASS_FIGHTER; |
| 1618 |
|
| 1619 |
if ( |
| 1620 |
player_class != PCLASS_FIGHTER && |
| 1621 |
player_class != PCLASS_CLERIC && |
| 1622 |
player_class != PCLASS_MAGE |
| 1623 |
) |
| 1624 |
player_class = PCLASS_FIGHTER; |
| 1625 |
|
| 1626 |
PlayerClass[0] = player_class; |
| 1627 |
for (p = 1; p < MAX_MAXPLAYERS; p++) |
| 1628 |
PlayerClass[p] = PCLASS_FIGHTER; |
| 1629 |
|
| 1630 |
randomclass = dsda_Flag(dsda_arg_randclass); |
| 1631 |
} |
| 1632 |
|
| 1633 |
static void HandlePlayback(void) |
| 1634 |
{ |
| 1635 |
const char* file; |
| 1636 |
|
| 1637 |
file = dsda_ParsePlaybackOptions(); |
| 1638 |
|
| 1639 |
if (!file) |
| 1640 |
return; |
| 1641 |
|
| 1642 |
dsda_LoadExDemo(file); |
| 1643 |
} |
| 1644 |
|
| 1645 |
const char* doomverstr = "Unknown"; |
| 1646 |
|
| 1647 |
static void EvaluateDoomVerStr(void) |
| 1648 |
{ |
| 1649 |
if (heretic) |
| 1650 |
{ |
| 1651 |
if (gamemode == retail) |
| 1652 |
doomverstr= "Heretic: Shadow of the Serpent Riders"; |
| 1653 |
else if (gamemode == shareware) |
| 1654 |
doomverstr = "Heretic Shareware"; |
| 1655 |
else |
| 1656 |
doomverstr = "Heretic"; |
| 1657 |
} |
| 1658 |
else if (hexen) |
| 1659 |
{ |
| 1660 |
doomverstr = "Hexen"; |
| 1661 |
} |
| 1662 |
else |
| 1663 |
{ |
| 1664 |
switch ( gamemode ) |
| 1665 |
{ |
| 1666 |
case retail: |
| 1667 |
switch (gamemission) |
| 1668 |
{ |
| 1669 |
case tc_chex: |
| 1670 |
doomverstr = "Chex(R) Quest"; |
| 1671 |
break; |
| 1672 |
case tc_chex3v: |
| 1673 |
doomverstr = "Chex(R) Quest 3: Vanilla Edition"; |
| 1674 |
break; |
| 1675 |
case tc_rekkr: |
| 1676 |
doomverstr = "REKKR"; |
| 1677 |
break; |
| 1678 |
case tc_freedoom: |
| 1679 |
doomverstr = "Freedoom Phase 1"; |
| 1680 |
break; |
| 1681 |
default: |
| 1682 |
doomverstr = "The Ultimate DOOM"; |
| 1683 |
break; |
| 1684 |
} |
| 1685 |
break; |
| 1686 |
case shareware: |
| 1687 |
doomverstr = "DOOM Shareware"; |
| 1688 |
break; |
| 1689 |
case registered: |
| 1690 |
doomverstr = "DOOM Registered"; |
| 1691 |
break; |
| 1692 |
case commercial: // Ty 08/27/98 - fixed gamemode vs gamemission |
| 1693 |
switch (gamemission) |
| 1694 |
{ |
| 1695 |
case pack_plut: |
| 1696 |
doomverstr = "Final DOOM - The Plutonia Experiment"; |
| 1697 |
break; |
| 1698 |
case pack_tnt: |
| 1699 |
doomverstr = "Final DOOM - TNT: Evilution"; |
| 1700 |
break; |
| 1701 |
case tc_chex3v: |
| 1702 |
doomverstr = "Chex(R) Quest 3: Modding Edition"; |
| 1703 |
break; |
| 1704 |
case tc_hacx: |
| 1705 |
doomverstr = "HACX - Twitch 'n Kill"; |
| 1706 |
break; |
| 1707 |
case tc_freedoom: |
| 1708 |
doomverstr = freedm ? "FreeDM" : "Freedoom Phase 2"; |
| 1709 |
break; |
| 1710 |
default: |
| 1711 |
doomverstr = "DOOM 2: Hell on Earth"; |
| 1712 |
break; |
| 1713 |
} |
| 1714 |
break; |
| 1715 |
default: |
| 1716 |
doomverstr = "Public DOOM"; |
| 1717 |
break; |
| 1718 |
} |
| 1719 |
} |
| 1720 |
|
| 1721 |
if (bfgedition) |
| 1722 |
{ |
| 1723 |
char *tempverstr; |
| 1724 |
const char bfgverstr[]=" (BFG Edition)"; |
| 1725 |
tempverstr = Z_Malloc(sizeof(char) * (strlen(doomverstr)+strlen(bfgverstr)+1)); |
| 1726 |
strcpy (tempverstr, doomverstr); |
| 1727 |
strcat (tempverstr, bfgverstr); |
| 1728 |
doomverstr = Z_Strdup (tempverstr); |
| 1729 |
Z_Free (tempverstr); |
| 1730 |
} |
| 1731 |
|
| 1732 |
/* cphipps - the main display. This shows the copyright and game type */ |
| 1733 |
lprintf(LO_INFO, |
| 1734 |
"%s is released under the GNU General Public license v2.0.\n" |
| 1735 |
"You are welcome to redistribute it under certain conditions.\n" |
| 1736 |
"It comes with ABSOLUTELY NO WARRANTY. See the file COPYING for details.\n\n", |
| 1737 |
PROJECT_NAME); |
| 1738 |
|
| 1739 |
lprintf(LO_INFO, "Playing: %s\n", doomverstr); |
| 1740 |
} |
| 1741 |
|
| 1742 |
static void dsda_Loadfiles(void) |
| 1743 |
{ |
| 1744 |
dsda_arg_t *arg; |
| 1745 |
|
| 1746 |
if ((arg = dsda_Arg(dsda_arg_file))->found) |
| 1747 |
{ |
| 1748 |
int file_i; |
| 1749 |
// the parms after p are wadfile/lump names, |
| 1750 |
// until end of parms or another - preceded parm |
| 1751 |
modifiedgame = true; // homebrew levels |
| 1752 |
|
| 1753 |
for (file_i = 0; file_i < arg->count; ++file_i) |
| 1754 |
{ |
| 1755 |
const char* file_name; |
| 1756 |
char *file = NULL; |
| 1757 |
|
| 1758 |
file_name = arg->value.v_string_array[file_i]; |
| 1759 |
|
| 1760 |
if (!dsda_FileExtension(file_name)) |
| 1761 |
{ |
| 1762 |
const char *extensions[] = { ".wad", ".lmp", ".zip", ".deh", ".bex", NULL }; |
| 1763 |
|
| 1764 |
file = I_RequireAnyFile(file_name, extensions); |
| 1765 |
file_name = file; |
| 1766 |
} |
| 1767 |
|
| 1768 |
if (dsda_HasFileExt(file_name, ".deh") || dsda_HasFileExt(file_name, ".bex")) |
| 1769 |
{ |
| 1770 |
if (MainLumpCache) |
| 1771 |
dsda_AppendStringArg(dsda_arg_deh, file_name); |
| 1772 |
} |
| 1773 |
else if (dsda_HasFileExt(file_name, ".zip")) |
| 1774 |
{ |
| 1775 |
if (dsda_Arg(dsda_arg_iwad)->found) |
| 1776 |
D_AddZip(file_name, source_pwad, NULL); |
| 1777 |
else |
| 1778 |
MainLumpCache ? D_AddUnzippedFile(file_name, source_pwad, NULL) : D_AddZip(file_name, source_pwad, NULL); |
| 1779 |
} |
| 1780 |
else if (dsda_HasFileExt(file_name, ".wad") || dsda_HasFileExt(file_name, ".lmp")) |
| 1781 |
{ |
| 1782 |
if (!file) |
| 1783 |
file = I_RequireWad(file_name); |
| 1784 |
|
| 1785 |
D_AddFile(file, source_pwad); |
| 1786 |
} |
| 1787 |
else |
| 1788 |
{ |
| 1789 |
I_Error("File type \"%s\" is not supported", dsda_FileExtension(file_name)); |
| 1790 |
} |
| 1791 |
|
| 1792 |
Z_Free(file); |
| 1793 |
} |
| 1794 |
} |
| 1795 |
} |
| 1796 |
|
| 1797 |
// |
| 1798 |
// DetectEpisodeStructure |
| 1799 |
// |
| 1800 |
// If GAMEINFO is not present but Doom 1 maps are found, autoload episode IWAD. |
| 1801 |
// |
| 1802 |
|
| 1803 |
static void dsda_DetectEpisodeStructure(void) |
| 1804 |
{ |
| 1805 |
int i, ii; |
| 1806 |
char lump[5]; |
| 1807 |
char *iwad; |
| 1808 |
|
| 1809 |
for (i=0;i<10;i++) |
| 1810 |
{ |
| 1811 |
for (ii=0;ii<10;ii++) |
| 1812 |
{ |
| 1813 |
snprintf(lump, sizeof(lump), "E%dM%d", i, ii); |
| 1814 |
if (W_LumpNameExists(lump)) |
| 1815 |
{ |
| 1816 |
EpisodeStructure = true; |
| 1817 |
iwadver = Z_Strdup(lump); |
| 1818 |
iwad = FindIWADFile(); |
| 1819 |
|
| 1820 |
if (iwad) |
| 1821 |
iwadlump = Z_Strdup(iwad); |
| 1822 |
|
| 1823 |
return; |
| 1824 |
} |
| 1825 |
} |
| 1826 |
} |
| 1827 |
} |
| 1828 |
|
| 1829 |
// |
| 1830 |
// IdentifyVersion |
| 1831 |
// |
| 1832 |
// Set the location of the defaults file and the savegame root |
| 1833 |
// Locate and validate an IWAD file |
| 1834 |
// Determine gamemode from the IWAD |
| 1835 |
// |
| 1836 |
// supports IWADs with custom names. Also allows the -iwad parameter to |
| 1837 |
// specify which iwad is being searched for if several exist in one dir. |
| 1838 |
// The -iwad parm may specify: |
| 1839 |
// |
| 1840 |
// 1) a specific pathname, which must exist (.wad optional) |
| 1841 |
// 2) or a directory, which must contain a standard IWAD, |
| 1842 |
// 3) or a filename, which must be found in one of the standard places: |
| 1843 |
// a) current dir, |
| 1844 |
// b) exe dir |
| 1845 |
// c) $DOOMWADDIR |
| 1846 |
// d) or $HOME |
| 1847 |
// |
| 1848 |
// jff 4/19/98 rewritten to use a more advanced search algorithm |
| 1849 |
|
| 1850 |
static void IdentifyVersion (void) |
| 1851 |
{ |
| 1852 |
char *iwad = NULL; |
| 1853 |
|
| 1854 |
// why is this here? |
| 1855 |
dsda_InitDataDir(); |
| 1856 |
dsda_InitSaveDir(); |
| 1857 |
|
| 1858 |
if (!dsda_Arg(dsda_arg_iwad)->found) |
| 1859 |
{ |
| 1860 |
dsda_Loadfiles(); // Load files for GAMEINFO lump |
| 1861 |
if (!dsda_Flag(dsda_arg_noautoload)) D_AutoloadPWadDir(); // Load autoload PWAD files for GAMEINFO lump |
| 1862 |
W_Init(); // Quick cache to search for GAMEINFO lump |
| 1863 |
|
| 1864 |
// Parse GAMEINFO lump |
| 1865 |
dsda_LoadGameInfo(); |
| 1866 |
|
| 1867 |
// Autodetect Doom 1 maps |
| 1868 |
if (iwadlump == NULL) |
| 1869 |
dsda_DetectEpisodeStructure(); |
| 1870 |
|
| 1871 |
// Reset lump cache |
| 1872 |
dsda_ResetInitLumpCache(); |
| 1873 |
|
| 1874 |
// If IWAD found, check if it exists |
| 1875 |
if (iwadlump != NULL) |
| 1876 |
{ |
| 1877 |
iwad = FindIWADFile(); |
| 1878 |
|
| 1879 |
// Clear data if IWAD not found |
| 1880 |
if (!(iwad && *iwad)) |
| 1881 |
{ |
| 1882 |
Z_Free(iwadlump); |
| 1883 |
Z_Free(iwadver); |
| 1884 |
iwadlump = NULL; |
| 1885 |
iwadver = NULL; |
| 1886 |
} |
| 1887 |
} |
| 1888 |
} |
| 1889 |
|
| 1890 |
// If GAMEINFO / Episode IWAD not found, |
| 1891 |
// locate IWAD the traditional way |
| 1892 |
if (iwadlump == NULL) |
| 1893 |
{ |
| 1894 |
EpisodeStructure = false; |
| 1895 |
iwad = FindIWADFile(); |
| 1896 |
} |
| 1897 |
|
| 1898 |
// It is now ok to load dehacked / unzip files |
| 1899 |
MainLumpCache = true; |
| 1900 |
|
| 1901 |
if (iwad && *iwad) |
| 1902 |
{ |
| 1903 |
AddIWAD(iwad); |
| 1904 |
Z_Free(iwad); |
| 1905 |
} |
| 1906 |
else |
| 1907 |
{ |
| 1908 |
I_Error("IdentifyVersion: IWAD not found\n\n" |
| 1909 |
"Make sure your IWADs are in a folder that dsda-doom searches on\n" |
| 1910 |
"For example: %s", I_ConfigDir()); |
| 1911 |
} |
| 1912 |
} |
| 1913 |
|
| 1914 |
// |
| 1915 |
// D_DoomMainSetup |
| 1916 |
// |
| 1917 |
// CPhipps - the old contents of D_DoomMain, but moved out of the main |
| 1918 |
// line of execution so its stack space can be freed |
| 1919 |
|
| 1920 |
static void D_DoomMainSetup(void) |
| 1921 |
{ |
| 1922 |
int p; |
| 1923 |
dsda_arg_t *arg; |
| 1924 |
dboolean autoload; |
| 1925 |
|
| 1926 |
setbuf(stdout,NULL); |
| 1927 |
|
| 1928 |
if (dsda_Flag(dsda_arg_help)) |
| 1929 |
{ |
| 1930 |
dsda_PrintArgHelp(); |
| 1931 |
I_SafeExit(0); |
| 1932 |
} |
| 1933 |
|
| 1934 |
// CPhipps - autoloading of wads |
| 1935 |
autoload = !dsda_Flag(dsda_arg_noautoload); |
| 1936 |
|
| 1937 |
DoLooseFiles(); // Ty 08/29/98 - handle "loose" files on command line |
| 1938 |
|
| 1939 |
IdentifyVersion(); // Get IWAD |
| 1940 |
|
| 1941 |
dsda_InitGlobal(); |
| 1942 |
|
| 1943 |
// e6y: DEH files preloaded in wrong order |
| 1944 |
// http://sourceforge.net/tracker/index.php?func=detail&aid=1418158&group_id=148658&atid=772943 |
| 1945 |
// The dachaked stuff has been moved below an autoload |
| 1946 |
|
| 1947 |
// jff 1/24/98 set both working and command line value of play parms |
| 1948 |
nomonsters = clnomonsters = dsda_Flag(dsda_arg_nomonsters); |
| 1949 |
respawnparm = clrespawnparm = dsda_Flag(dsda_arg_respawn); |
| 1950 |
fastparm = clfastparm = dsda_Flag(dsda_arg_fast); |
| 1951 |
// jff 1/24/98 end of set to both working and command line value |
| 1952 |
|
| 1953 |
if (dsda_Flag(dsda_arg_altdeath)) |
| 1954 |
deathmatch = 2; |
| 1955 |
else if (dsda_Flag(dsda_arg_deathmatch)) |
| 1956 |
deathmatch = 1; |
| 1957 |
|
| 1958 |
modifiedgame = false; |
| 1959 |
|
| 1960 |
// get skill / episode / map from parms |
| 1961 |
|
| 1962 |
startskill = dsda_IntConfig(dsda_config_default_skill) - 1; |
| 1963 |
startepisode = 1; |
| 1964 |
startmap = 1; |
| 1965 |
autostart = false; |
| 1966 |
|
| 1967 |
arg = dsda_Arg(dsda_arg_skill); |
| 1968 |
if (arg->found) |
| 1969 |
{ |
| 1970 |
startskill = arg->value.v_int - 1; |
| 1971 |
autostart = true; |
| 1972 |
} |
| 1973 |
|
| 1974 |
arg = dsda_Arg(dsda_arg_episode); |
| 1975 |
if (arg->found) |
| 1976 |
{ |
| 1977 |
startepisode = arg->value.v_int; |
| 1978 |
startmap = 1; |
| 1979 |
autostart = true; |
| 1980 |
} |
| 1981 |
|
| 1982 |
HandleClass(); |
| 1983 |
|
| 1984 |
arg = dsda_Arg(dsda_arg_timer); |
| 1985 |
if (arg->found && deathmatch) |
| 1986 |
{ |
| 1987 |
int time = arg->value.v_int; |
| 1988 |
//jff 9/3/98 use logical output routine |
| 1989 |
lprintf(LO_INFO,"Levels will end after %d minute%s.\n", time, time>1 ? "s" : ""); |
| 1990 |
} |
| 1991 |
|
| 1992 |
//jff 1/22/98 add command line parms to disable sound and music |
| 1993 |
{ |
| 1994 |
int nosound = dsda_Flag(dsda_arg_nosound); |
| 1995 |
nomusicparm = nosound || dsda_Flag(dsda_arg_nomusic); |
| 1996 |
nosfxparm = nosound || dsda_Flag(dsda_arg_nosfx); |
| 1997 |
} |
| 1998 |
//jff end of sound/music command line parms |
| 1999 |
|
| 2000 |
// killough 3/2/98: allow -nodraw generally |
| 2001 |
nodrawers = dsda_Flag(dsda_arg_nodraw); |
| 2002 |
|
| 2003 |
// init subsystems |
| 2004 |
|
| 2005 |
G_ReloadDefaults(); // killough 3/4/98: set defaults just loaded. |
| 2006 |
// jff 3/24/98 this sets startskill if it was -1 |
| 2007 |
|
| 2008 |
// proff 04/05/2000: for GL-specific switches |
| 2009 |
gld_InitCommandLine(); |
| 2010 |
|
| 2011 |
//jff 9/3/98 use logical output routine |
| 2012 |
lprintf(LO_DEBUG, "V_Init: allocate screens.\n"); |
| 2013 |
V_Init(); |
| 2014 |
|
| 2015 |
//e6y: Calculate the screen resolution and init all buffers |
| 2016 |
I_InitScreenResolution(); |
| 2017 |
|
| 2018 |
//e6y: some stuff from command-line should be initialised before ProcessDehFile() |
| 2019 |
e6y_InitCommandLine(); |
| 2020 |
|
| 2021 |
D_AddFile(port_wad_file, source_auto_load); |
| 2022 |
|
| 2023 |
HandlePlayback(); // must come before autoload: may detect iwad in footer |
| 2024 |
|
| 2025 |
EvaluateDoomVerStr(); // must come after HandlePlayback (may change iwad) |
| 2026 |
|
| 2027 |
// add wad files from autoload directory before wads from -file parameter |
| 2028 |
if (autoload) |
| 2029 |
D_AutoloadIWadDir(); |
| 2030 |
|
| 2031 |
// add any files specified on the command line with -file wadfile |
| 2032 |
// to the wad list |
| 2033 |
|
| 2034 |
dsda_Loadfiles(); |
| 2035 |
|
| 2036 |
// add wad files from autoload PWAD directories |
| 2037 |
if (autoload) |
| 2038 |
D_AutoloadPWadDir(); |
| 2039 |
|
| 2040 |
D_InitFakeNetGame(); |
| 2041 |
|
| 2042 |
//jff 9/3/98 use logical output routine |
| 2043 |
lprintf(LO_DEBUG, "W_Init: Init WADfiles.\n"); |
| 2044 |
W_Init(); // CPhipps - handling of wadfiles init changed |
| 2045 |
|
| 2046 |
if (hexen) |
| 2047 |
{ |
| 2048 |
if (!W_LumpNameExists("MAP05")) |
| 2049 |
{ |
| 2050 |
I_Error("The Hexen IWAD shareware is not supported."); |
| 2051 |
gamemode = shareware; |
| 2052 |
g_maxplayers = 4; |
| 2053 |
} |
| 2054 |
else if (!W_LumpNameExists("CLUS1MSG")) |
| 2055 |
{ |
| 2056 |
I_Error("The Hexen v1.0 IWAD is not supported."); |
| 2057 |
} |
| 2058 |
} |
| 2059 |
|
| 2060 |
lprintf(LO_DEBUG, "G_ReloadDefaults: Checking OPTIONS.\n"); |
| 2061 |
dsda_ParseOptionsLump(); |
| 2062 |
|
| 2063 |
if (iwadlump != NULL) |
| 2064 |
{ |
| 2065 |
lprintf(LO_INFO, "Detected %s lump: %s\n", iwadver ? iwadver : "GAMEINFO", iwadlump); |
| 2066 |
Z_Free(iwadlump); |
| 2067 |
|
| 2068 |
if (iwadver) |
| 2069 |
Z_Free(iwadver); |
| 2070 |
} |
| 2071 |
|
| 2072 |
G_ReloadDefaults(); |
| 2073 |
|
| 2074 |
// e6y |
| 2075 |
// option to disable automatic loading of dehacked-in-wad lump |
| 2076 |
if (!dsda_Flag(dsda_arg_nodeh)) |
| 2077 |
{ |
| 2078 |
// MBF-style DeHackEd in wad support: load all lumps, not just the last one |
| 2079 |
for (p = -1; (p = W_ListNumFromName("DEHACKED", p)) >= 0; ) |
| 2080 |
// Split loading DEHACKED lumps into IWAD/autoload and PWADs/others |
| 2081 |
if (lumpinfo[p].source == source_iwad |
| 2082 |
|| lumpinfo[p].source == source_pre |
| 2083 |
|| lumpinfo[p].source == source_auto_load) |
| 2084 |
ProcessDehFile(NULL, D_dehout(), p); // cph - add dehacked-in-a-wad support |
| 2085 |
|
| 2086 |
if (bfgedition) |
| 2087 |
{ |
| 2088 |
int lump = W_CheckNumForName2("BFGBEX", ns_prboom); |
| 2089 |
if (lump != LUMP_NOT_FOUND) |
| 2090 |
{ |
| 2091 |
ProcessDehFile(NULL, D_dehout(), lump); |
| 2092 |
} |
| 2093 |
} |
| 2094 |
if (gamemission == pack_nerve) |
| 2095 |
{ |
| 2096 |
int lump = W_CheckNumForName2("NERVEBEX", ns_prboom); |
| 2097 |
if (lump != LUMP_NOT_FOUND) |
| 2098 |
{ |
| 2099 |
ProcessDehFile(NULL, D_dehout(), lump); |
| 2100 |
} |
| 2101 |
} |
| 2102 |
if (gamemission == tc_chex) |
| 2103 |
{ |
| 2104 |
int lump = W_CheckNumForName2("CHEXDEH", ns_prboom); |
| 2105 |
if (lump != LUMP_NOT_FOUND) |
| 2106 |
{ |
| 2107 |
ProcessDehFile(NULL, D_dehout(), lump); |
| 2108 |
} |
| 2109 |
} |
| 2110 |
} |
| 2111 |
|
| 2112 |
// process deh files from autoload directory before deh in wads from -file parameter |
| 2113 |
if (autoload) |
| 2114 |
D_AutoloadDehIWadDir(); |
| 2115 |
|
| 2116 |
if (!dsda_Flag(dsda_arg_nodeh)) |
| 2117 |
for (p = -1; (p = W_ListNumFromName("DEHACKED", p)) >= 0; ) |
| 2118 |
if (!(lumpinfo[p].source == source_iwad |
| 2119 |
|| lumpinfo[p].source == source_pre |
| 2120 |
|| lumpinfo[p].source == source_auto_load)) |
| 2121 |
ProcessDehFile(NULL, D_dehout(), p); |
| 2122 |
|
| 2123 |
// process .deh files from PWADs autoload directories |
| 2124 |
if (autoload) |
| 2125 |
D_AutoloadDehPWadDir(); |
| 2126 |
|
| 2127 |
// Load command line dehacked patches after WAD dehacked patches |
| 2128 |
|
| 2129 |
// e6y: DEH files preloaded in wrong order |
| 2130 |
// http://sourceforge.net/tracker/index.php?func=detail&aid=1418158&group_id=148658&atid=772943 |
| 2131 |
|
| 2132 |
// ty 03/09/98 do dehacked stuff |
| 2133 |
// Using -deh in BOOM, others use -dehacked. |
| 2134 |
// Ty 03/18/98 also allow .bex extension. .bex overrides if both exist. |
| 2135 |
|
| 2136 |
arg = dsda_Arg(dsda_arg_deh); |
| 2137 |
if (arg->found) |
| 2138 |
{ |
| 2139 |
int i; |
| 2140 |
|
| 2141 |
// e6y |
| 2142 |
// reorganization of the code for looking for bex/deh patches |
| 2143 |
// in all standard dirs (%DOOMWADDIR%, etc) |
| 2144 |
for (i = 0; i < arg->count; ++i) |
| 2145 |
{ |
| 2146 |
char *file = NULL; |
| 2147 |
|
| 2148 |
file = I_RequireDeh(arg->value.v_string_array[i]); |
| 2149 |
|
| 2150 |
// during the beta we have debug output to dehout.txt |
| 2151 |
ProcessDehFile(file,D_dehout(),0); |
| 2152 |
Z_Free(file); |
| 2153 |
} |
| 2154 |
} |
| 2155 |
|
| 2156 |
PostProcessDeh(); |
| 2157 |
dsda_AppendZDoomMobjInfo(); |
| 2158 |
dsda_ApplyDefaultMapFormat(); |
| 2159 |
|
| 2160 |
lprintf(LO_DEBUG, "dsda_InitWadStats: Setting up wad stats.\n"); |
| 2161 |
dsda_InitWadStats(); |
| 2162 |
|
| 2163 |
lprintf(LO_INFO, "\n"); // Separator after file loading |
| 2164 |
|
| 2165 |
V_InitColorTranslation(); //jff 4/24/98 load color translation lumps |
| 2166 |
|
| 2167 |
//jff 9/3/98 use logical output routine |
| 2168 |
lprintf(LO_DEBUG, "M_Init: Init miscellaneous info.\n"); |
| 2169 |
M_Init(); |
| 2170 |
|
| 2171 |
dsda_LoadSndInfo(); |
| 2172 |
|
| 2173 |
if (map_format.sndseq) |
| 2174 |
{ |
| 2175 |
SN_InitSequenceScript(); |
| 2176 |
} |
| 2177 |
|
| 2178 |
//jff 9/3/98 use logical output routine |
| 2179 |
lprintf(LO_DEBUG, "R_Init: Init DOOM refresh daemon - "); |
| 2180 |
R_Init(); |
| 2181 |
|
| 2182 |
dsda_LoadWadPreferences(); |
| 2183 |
dsda_LoadMapInfo(); |
| 2184 |
dsda_InitSkills(); |
| 2185 |
dsda_InitGameModifiers(); // Set game modifiers based off args / persistent cfgs |
| 2186 |
|
| 2187 |
//jff 9/3/98 use logical output routine |
| 2188 |
lprintf(LO_DEBUG, "\nP_Init: Init Playloop state.\n"); |
| 2189 |
P_Init(); |
| 2190 |
|
| 2191 |
// Must be after P_Init |
| 2192 |
HandleWarp(); |
| 2193 |
|
| 2194 |
// Must be after HandleWarp |
| 2195 |
dsda_HandleSkip(); |
| 2196 |
|
| 2197 |
//jff 9/3/98 use logical output routine |
| 2198 |
lprintf(LO_DEBUG, "I_Init: Setting up machine state.\n"); |
| 2199 |
I_Init(); |
| 2200 |
|
| 2201 |
//jff 9/3/98 use logical output routine |
| 2202 |
lprintf(LO_DEBUG, "S_Init: Setting up sound.\n"); |
| 2203 |
S_Init(); |
| 2204 |
|
| 2205 |
//jff 9/3/98 use logical output routine |
| 2206 |
lprintf(LO_DEBUG, "dsda_InitFont: Loading the hud fonts.\n"); |
| 2207 |
dsda_InitFont(); |
| 2208 |
|
| 2209 |
if (!(dsda_Flag(dsda_arg_nodraw) && dsda_Flag(dsda_arg_nosound))) |
| 2210 |
I_InitGraphics(); |
| 2211 |
|
| 2212 |
// NSM |
| 2213 |
arg = dsda_Arg(dsda_arg_viddump); |
| 2214 |
if (arg->found) |
| 2215 |
{ |
| 2216 |
I_CapturePrep(arg->value.v_string); |
| 2217 |
} |
| 2218 |
|
| 2219 |
//jff 9/3/98 use logical output routine |
| 2220 |
lprintf(LO_DEBUG, "ST_Init: Init status bar.\n"); |
| 2221 |
ST_Init(); |
| 2222 |
|
| 2223 |
// start the appropriate game based on parms |
| 2224 |
|
| 2225 |
arg = dsda_Arg(dsda_arg_record); |
| 2226 |
if (arg->found) |
| 2227 |
{ |
| 2228 |
autostart = true; |
| 2229 |
dsda_SetDemoBaseName(arg->value.v_string); |
| 2230 |
dsda_InitDemoRecording(); |
| 2231 |
} |
| 2232 |
|
| 2233 |
dsda_ExecutePlaybackOptions(); |
| 2234 |
|
| 2235 |
if (!userdemo) |
| 2236 |
{ |
| 2237 |
if (autostart || netgame) |
| 2238 |
{ |
| 2239 |
G_InitNew(startskill, startepisode, startmap, true); |
| 2240 |
if (demorecording) |
| 2241 |
G_BeginRecording(); |
| 2242 |
} |
| 2243 |
else |
| 2244 |
D_StartTitle(); // start up intro loop |
| 2245 |
} |
| 2246 |
|
| 2247 |
// do not try to interpolate during timedemo |
| 2248 |
M_ChangeUncappedFrameRate(); |
| 2249 |
|
| 2250 |
lprintf(LO_DEBUG, "\n"); // Separator after setup |
| 2251 |
} |
| 2252 |
|
| 2253 |
// |
| 2254 |
// D_DoomMain |
| 2255 |
// |
| 2256 |
|
| 2257 |
void D_DoomMain(void) |
| 2258 |
{ |
| 2259 |
D_DoomMainSetup(); // CPhipps - setup out of main execution stack |
| 2260 |
|
| 2261 |
D_DoomLoop (); // never returns |
| 2262 |
} |