Beispiel #1
0
//
// D_Init
//
// Called to initialize subsystems when loading a new set of WAD resource
// files.
//
void D_Init()
{
	// only print init messages during startup, not when changing WADs
	static bool first_time = true;

	SetLanguageIDs();

	M_ClearRandom();

	// [AM] Init rand() PRNG, needed for non-deterministic maplist shuffling.
	srand(time(NULL));

	// start the Zone memory manager
	bool use_zone = !Args.CheckParm("-nozone");
	Z_Init(use_zone);
	if (first_time)
		Printf(PRINT_HIGH, "Z_Init: Heapsize: %u megabytes\n", got_heapsize);

	// Load palette and set up colormaps
	V_InitPalette("PLAYPAL");
	R_InitColormaps();

//	if (first_time)
//		Printf(PRINT_HIGH, "Res_InitTextureManager: Init image resource management.\n");
//	Res_InitTextureManager();

	// [RH] Initialize localizable strings.
	GStrings.FreeData();
	GStrings.LoadStrings(W_GetNumForName("LANGUAGE"), STRING_TABLE_SIZE, false);
	GStrings.Compact();

	// init the renderer
	if (first_time)
		Printf(PRINT_HIGH, "R_Init: Init DOOM refresh daemon.\n");
	R_Init();

	G_SetLevelStrings();
	G_ParseMapInfo();
	G_ParseMusInfo();
	S_ParseSndInfo();

	if (first_time)
		Printf(PRINT_HIGH, "P_Init: Init Playloop state.\n");
//	P_InitEffects();
	P_Init();

	first_time = false;
}
Beispiel #2
0
//
// D_NewWadInit
//
// Client code that should be reset every time a new set of WADs are loaded
//
void D_NewWadInit()
{
	AM_Stop();

	HU_Init ();

	if (!(InitPalettes("PLAYPAL")))
		I_Error("Could not reinitialize palette");
	V_InitPalette();

	G_SetLevelStrings ();
	G_ParseMapInfo ();
	G_ParseMusInfo ();
	S_ParseSndInfo();

	M_Init();
	R_Init();
	P_InitEffects();	// [ML] Do this here so we don't have to put particle crap in server
	P_Init();

	S_Init (snd_sfxvolume, snd_musicvolume);
	ST_Init();
}
Beispiel #3
0
//
// D_Init
//
// Called to initialize subsystems when loading a new set of WAD resource
// files.
//
void D_Init()
{
	// only print init messages during startup, not when changing WADs
	static bool first_time = true;

	SetLanguageIDs();

	M_ClearRandom();

	// start the Zone memory manager
	Z_Init();

	if (!(V_InitPalettes("PLAYPAL")))
		I_Error("Could not reinitialize palette");
	V_InitPalette();

	V_InitColormaps();

	if (first_time)
		Printf(PRINT_HIGH, "R_InitTextureManager: Init image resource management.\n");
	R_InitTextureManager();

	// [RH] Initialize localizable strings.
	GStrings.LoadStrings(W_GetNumForName("LANGUAGE"), STRING_TABLE_SIZE, false);
	GStrings.Compact();

	// init the renderer
	if (first_time)
		Printf(PRINT_HIGH, "R_Init: Init DOOM refresh daemon.\n");
	R_Init();

	V_LoadFonts();

	C_InitConsoleBackground();

	HU_Init();

	G_SetLevelStrings();
	G_ParseMapInfo();
	G_ParseMusInfo();
	S_ParseSndInfo();

	// init the menu subsystem
	if (first_time)
		Printf(PRINT_HIGH, "M_Init: Init miscellaneous info.\n");
	M_Init();

	if (first_time)
		Printf(PRINT_HIGH, "P_Init: Init Playloop state.\n");
	P_InitEffects();
	P_Init();

	// init sound and music
	if (first_time)
	{
		Printf (PRINT_HIGH, "S_Init: Setting up sound.\n");
		Printf (PRINT_HIGH, "S_Init: default sfx volume is %g\n", (float)snd_sfxvolume);
		Printf (PRINT_HIGH, "S_Init: default music volume is %g\n", (float)snd_musicvolume);
	}
	S_Init(snd_sfxvolume, snd_musicvolume);

	R_InitViewBorder();

	// init the status bar
	if (first_time)
		Printf(PRINT_HIGH, "ST_Init: Init status bar.\n");
	ST_Init();

	first_time = false;
}
Beispiel #4
0
std::vector<size_t> D_DoomWadReboot(
    const std::vector<std::string> &wadnames,
    const std::vector<std::string> &patch_files,
    std::vector<std::string> needhashes
)
{
    std::vector<size_t> fails;
    size_t i;


    // already loaded these?
    if (lastWadRebootSuccess &&
            !wadhashes.empty() &&
            needhashes ==
            std::vector<std::string>(wadhashes.begin()+1, wadhashes.end()))
    {
        // fast track if files have not been changed // denis - todo - actually check the file timestamps
        Printf (PRINT_HIGH, "Currently loaded WADs match server checksum\n\n");
        return std::vector<size_t>();
    }

    // assume failure
    lastWadRebootSuccess = false;

    if (modifiedgame && (gameinfo.flags & GI_SHAREWARE))
        I_Error ("\nYou cannot switch WAD with the shareware version. Register!");

    if(gamestate == GS_LEVEL)
        G_ExitLevel(0, 0);

    AM_Stop();
    S_Stop();

    DThinker::DestroyAllThinkers();

    // Close all open WAD files
    W_Close();

    // [ML] 9/11/10: Reset custom wad level information from MAPINFO et al.
    // I have never used memset, I hope I am not invoking satan by doing this :(
    if (wadlevelinfos)
    {
        for (i = 0; i < numwadlevelinfos; i++)
            if (wadlevelinfos[i].snapshot)
            {
                delete wadlevelinfos[i].snapshot;
                wadlevelinfos[i].snapshot = NULL;
            }
        memset(wadlevelinfos,0,sizeof(wadlevelinfos));
        numwadlevelinfos = 0;
    }

    if (wadclusterinfos)
    {
        memset(wadclusterinfos,0,sizeof(wadclusterinfos));
        numwadclusterinfos = 0;
    }

    // Restart the memory manager
    Z_Init();

    gamestate_t oldgamestate = gamestate;
    gamestate = GS_STARTUP; // prevent console from trying to use nonexistant font

    wadfiles.clear();
    modifiedgame = false;

    std::string custwad;
    if(wadnames.empty() == false)
        custwad = wadnames[0];

    D_AddDefWads(custwad);

    for(i = 0; i < wadnames.size(); i++)
    {
        std::string tmp = wadnames[i];

        // strip absolute paths, as they present a security risk
        FixPathSeparator(tmp);
        size_t slash = tmp.find_last_of(PATHSEPCHAR);
        if(slash != std::string::npos)
            tmp = tmp.substr(slash + 1, tmp.length() - slash);

        // [Russell] - Generate a hash if it doesn't exist already
        if (needhashes[i].empty())
            needhashes[i] = W_MD5(tmp);

        std::string file = BaseFileSearch(tmp, ".wad", needhashes[i]);

        if(file.length())
            wadfiles.push_back(file);
        else
        {
            Printf (PRINT_HIGH, "could not find WAD: %s\n", tmp.c_str());
            fails.push_back(i);
        }
    }

    if(wadnames.size() > 1)
        modifiedgame = true;

    wadhashes = W_InitMultipleFiles (wadfiles);

    UndoDehPatch();

    // [RH] Initialize localizable strings.
    GStrings.ResetStrings ();
    GStrings.Compact ();

    D_DoDefDehackedPatch(patch_files);

    //gotconback = false;
    //C_InitConsole(DisplayWidth, DisplayHeight, true);

    HU_Init ();

    if(!(DefaultPalette = InitPalettes("PLAYPAL")))
        I_Error("Could not reinitialize palette");
    V_InitPalette();

    G_SetLevelStrings ();
    G_ParseMapInfo ();
    G_ParseMusInfo ();
    S_ParseSndInfo();

    M_Init();
    R_Init();
    P_InitEffects();	// [ML] Do this here so we don't have to put particle crap in server
    P_Init();

    S_Init (snd_sfxvolume, snd_musicvolume);
    ST_Init();

    // preserve state
    lastWadRebootSuccess = fails.empty();

    gamestate = oldgamestate; // GS_STARTUP would prevent netcode connecting properly

    return fails;
}