Exemplo n.º 1
0
void M_StartGame(int choice)
{
	skill.Set ((float)choice+1);

	G_DeferedInitNew (CalcMapName (epi+1, 1));
	M_ClearMenus ();
}
Exemplo n.º 2
0
// Determine the "next map" and change to it.
void G_ChangeMap() {
	unnatural_level_progression = false;

	size_t next_index;
	if (!Maplist::instance().get_next_index(next_index)) {
		// We don't have a maplist, so grab the next 'natural' map lump.
		std::string next = G_NextMap();
		G_DeferedInitNew((char *)next.c_str());
	} else {
		maplist_entry_t maplist_entry;
		Maplist::instance().get_map_by_index(next_index, maplist_entry);

		G_LoadWad(JoinStrings(maplist_entry.wads, " "), maplist_entry.map);

		// Set the new map as the current map
		Maplist::instance().set_index(next_index);
	}

	// run script at the end of each map
	// [ML] 8/22/2010: There are examples in the wiki that outright don't work
	// when onlcvars (addcommandstring's second param) is true.  Is there a
	// reason why the mapscripts ahve to be safe mode?
	if(strlen(sv_endmapscript.cstring()))
		AddCommandString(sv_endmapscript.cstring()/*, true*/);
}
Exemplo n.º 3
0
boolean Cht_WarpFunc(player_t *plyr, char *buf)
{
    int     epsd, map;

    if(gamemode == commercial)
    {
        epsd = 1;
        map = (buf[0] - '0') * 10 + buf[1] - '0';
    }
    else
    {
        epsd = buf[0] - '0';
        map = buf[1] - '0';
    }

    // Catch invalid maps.
    if(!G_ValidateMap(&epsd, &map))
        return false;

    // So be it.
    P_SetMessage(plyr, STSTR_CLEV, false);
    G_DeferedInitNew(gameskill, epsd, map);

    // Clear the menu if open
    Hu_MenuCommand(MCMD_CLOSE);
    briefDisabled = true;
    return true;
}
Exemplo n.º 4
0
void M_VerifyNightmare(int ch)
{
    if (ch != 'y')
		return;
		
    G_DeferedInitNew((skill_t)nightmare,epi+1,1);
    M_ClearMenus ();
}
Exemplo n.º 5
0
void M_VerifyNightmare(int ch)
{
	if (ch != KEY_ENTER)
		return;

	G_DeferedInitNew((skill_t)nightmare,::g->epi+1, 1);
	M_ClearMenus ();
}
Exemplo n.º 6
0
void M_StartGame(int choice)
{
	sv_skill.Set ((float)(choice+1));
	sv_gametype = GM_COOP;

	G_DeferedInitNew (CalcMapName (epi+1, 1));
	M_ClearMenus ();
}
Exemplo n.º 7
0
int G_GotoNextLevel(void)
{
  static byte doom2_next[32] = {
    2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
    12, 13, 14, 15, 31, 17, 18, 19, 20, 21,
    22, 23, 24, 25, 26, 27, 28, 29, 30, 1,
    32, 16
  };
  static byte doom_next[4][9] = {
    {12, 13, 19, 15, 16, 17, 18, 21, 14},
    {22, 23, 24, 25, 29, 27, 28, 31, 26},
    {32, 33, 34, 35, 36, 39, 38, 41, 37},
    {42, 49, 44, 45, 46, 47, 48, 11, 43}
  };

  int changed = false;

  // secret level
  doom2_next[14] = (haswolflevels ? 31 : 16);
  
  // shareware doom has only episode 1
  doom_next[0][7] = (gamemode == shareware ? 11 : 21);
  
  doom_next[2][7] = ((gamemode == registered) ||
    // the fourth episode for pre-ultimate complevels is not allowed.
    (compatibility_level < ultdoom_compatibility) ?
    11 : 41);
  
  if ((gamestate == GS_LEVEL) &&
      !deathmatch && !netgame &&
      !demorecording && !demoplayback &&
      !menuactive)
  {
    //doom2_next and doom_next are 0 biased, unlike gameepisode and gamemap
    int epsd = gameepisode - 1;
    int map = gamemap - 1;

    if (gamemode == commercial)
    {
      epsd = 1;
      map = doom2_next[BETWEEN(0, 31, map)];
    }
    else
    {
      int next = doom_next[BETWEEN(0, 3, epsd)][BETWEEN(0, 9, map)];
      epsd = next / 10;
      map = next % 10;
    }

    G_DeferedInitNew(gameskill, epsd, map);
    changed = true;
  }

  return changed;
}
Exemplo n.º 8
0
// Restart the current map.
void G_RestartMap() {
	// Restart the current map.
	G_DeferedInitNew(level.mapname);

	// run script at the end of each map
	// [ML] 8/22/2010: There are examples in the wiki that outright don't work
	// when onlcvars (addcommandstring's second param) is true.  Is there a
	// reason why the mapscripts ahve to be safe mode?
	if(strlen(sv_endmapscript.cstring()))
		AddCommandString(sv_endmapscript.cstring()/*, true*/);
}
Exemplo n.º 9
0
void M_ChooseSkill(int choice)
{
    /*if (choice == nightmare)
    {
		M_StartMessage(NIGHTMARE,(void *)M_VerifyNightmare,true);
		return;
    }
	*/
    G_DeferedInitNew((skill_t)choice,epi+1,1);
    M_ClearMenus ();
}
Exemplo n.º 10
0
int G_ReloadLevel(void)
{
  int result = false;

  if ((gamestate == GS_LEVEL) &&
      !deathmatch && !netgame &&
      !demorecording && !demoplayback &&
      !menuactive)
  {
    G_DeferedInitNew(gameskill, gameepisode, gamemap);
    result = true;
  }

  return result;
}
Exemplo n.º 11
0
void M_StartGame(int choice)
{
	sv_skill.Set ((float)(choice+1));
	sv_gametype = GM_COOP;

    if (gamemode == commercial_bfg)     // Funky external loading madness fun time (DOOM 2 BFG)
    {
        std::string str = "nerve.wad";

        if (epi)
        {
            // Load No Rest for The Living Externally
            epi = 0;
            G_LoadWad(str);
        }
        else
        {
            // Check for nerve.wad, if it's loaded re-load with just iwad (DOOM 2 BFG)
            for (unsigned int i = 2; i < wadfiles.size(); i++)
            {
                if (StdStringCompare(str, M_ExtractFileName(wadfiles[i]), true) == 0)
                {
                    G_LoadWad(wadfiles[1]);
                }
            }

            G_DeferedInitNew (CalcMapName (epi+1, 1));
        }
    }
    else
    {
        G_DeferedInitNew (CalcMapName (epi+1, 1));
    }

    M_ClearMenus ();
}
Exemplo n.º 12
0
void M_ChooseSkill(int choice)
{
	/*
	if (choice == nightmare)
	{
		M_StartMessage(NIGHTMARE,M_VerifyNightmare,true);
		return;
	}
	*/
	if ( ::g->gamemode != commercial ) {
		static int startLevel = 1;
		G_DeferedInitNew((skill_t)choice,::g->epi+1, startLevel);
		M_ClearMenus ();
	} else {
		DoomLib::SetCurrentExpansion( DoomLib::idealExpansion );
		DoomLib::skipToNew = true;
		DoomLib::chosenSkill = choice;
		DoomLib::chosenEpisode = ::g->epi+1;
	}
}
Exemplo n.º 13
0
// Respond to keyboard input events,
//  intercept cheats.
boolean
ST_Responder (event_t* ev)
{
  int		i;
    
  // Filter automap on/off.
  if (ev->type == ev_keyup
      && ((ev->data1 & 0xffff0000) == AM_MSGHEADER))
  {
    switch(ev->data1)
    {
      case AM_MSGENTERED:
	st_gamestate = AutomapState;
	st_firsttime = true;
	break;
	
      case AM_MSGEXITED:
	//	fprintf(stderr, "AM exited\n");
	st_gamestate = FirstPersonState;
	break;
    }
  }

  // if a user keypress...
  else if (ev->type == ev_keydown)
  {
    if (!netgame)
    {
      // b. - enabled for more debug fun.
      // if (gameskill != sk_nightmare) {
      
      // 'dqd' cheat for toggleable god mode
      if (cht_CheckCheat(&cheat_god, ev->data1))
      {
	plyr->cheats ^= CF_GODMODE;
	if (plyr->cheats & CF_GODMODE)
	{
	  if (plyr->mo)
	    plyr->mo->health = 100;
	  
	  plyr->health = 100;
	  plyr->message = STSTR_DQDON;
	}
	else 
	  plyr->message = STSTR_DQDOFF;
      }
      // 'fa' cheat for killer f*****g arsenal
      else if (cht_CheckCheat(&cheat_ammonokey, ev->data1))
      {
	plyr->armorpoints = 200;
	plyr->armortype = 2;
	
	for (i=0;i<NUMWEAPONS;i++)
	  plyr->weaponowned[i] = true;
	
	for (i=0;i<NUMAMMO;i++)
	  plyr->ammo[i] = plyr->maxammo[i];
	
	plyr->message = STSTR_FAADDED;
      }
      // 'kfa' cheat for key full ammo
      else if (cht_CheckCheat(&cheat_ammo, ev->data1))
      {
	plyr->armorpoints = 200;
	plyr->armortype = 2;
	
	for (i=0;i<NUMWEAPONS;i++)
	  plyr->weaponowned[i] = true;
	
	for (i=0;i<NUMAMMO;i++)
	  plyr->ammo[i] = plyr->maxammo[i];
	
	for (i=0;i<NUMCARDS;i++)
	  plyr->cards[i] = true;
	
	plyr->message = STSTR_KFAADDED;
      }
      // 'mus' cheat for changing music
      else if (cht_CheckCheat(&cheat_mus, ev->data1))
      {
	
	char	buf[3];
	int		musnum;
	
	plyr->message = STSTR_MUS;
	cht_GetParam(&cheat_mus, buf);
	
	if (gamemode == commercial)
	{
	  musnum = mus_runnin + (buf[0]-'0')*10 + buf[1]-'0' - 1;
	  
	  if (((buf[0]-'0')*10 + buf[1]-'0') > 35)
	    plyr->message = STSTR_NOMUS;
	  else
	    S_ChangeMusic(musnum, 1);
	}
	else
	{
	  musnum = mus_e1m1 + (buf[0]-'1')*9 + (buf[1]-'1');
	  
	  if (((buf[0]-'1')*9 + buf[1]-'1') > 31)
	    plyr->message = STSTR_NOMUS;
	  else
	    S_ChangeMusic(musnum, 1);
	}
      }
      // Simplified, accepting both "noclip" and "idspispopd".
      // no clipping mode cheat
      else if ( cht_CheckCheat(&cheat_noclip, ev->data1) 
		|| cht_CheckCheat(&cheat_commercial_noclip,ev->data1) )
      {	
	plyr->cheats ^= CF_NOCLIP;
	
	if (plyr->cheats & CF_NOCLIP)
	  plyr->message = STSTR_NCON;
	else
	  plyr->message = STSTR_NCOFF;
      }
      // 'behold?' power-up cheats
      for (i=0;i<6;i++)
      {
	if (cht_CheckCheat(&cheat_powerup[i], ev->data1))
	{
	  if (!plyr->powers[i])
	    P_GivePower( plyr, i);
	  else if (i!=pw_strength)
	    plyr->powers[i] = 1;
	  else
	    plyr->powers[i] = 0;
	  
	  plyr->message = STSTR_BEHOLDX;
	}
      }
      
      // 'behold' power-up menu
      if (cht_CheckCheat(&cheat_powerup[6], ev->data1))
      {
	plyr->message = STSTR_BEHOLD;
      }
      // 'choppers' invulnerability & chainsaw
      else if (cht_CheckCheat(&cheat_choppers, ev->data1))
      {
	plyr->weaponowned[wp_chainsaw] = true;
	plyr->powers[pw_invulnerability] = true;
	plyr->message = STSTR_CHOPPERS;
      }
      // 'mypos' for player position
      else if (cht_CheckCheat(&cheat_mypos, ev->data1))
      {
	static char	buf[ST_MSGWIDTH];
	sprintf(buf, "ang=0x%x;x,y=(0x%x,0x%x)",
		players[consoleplayer].mo->angle,
		players[consoleplayer].mo->x,
		players[consoleplayer].mo->y);
	plyr->message = buf;
      }
    }
    
    // 'clev' change-level cheat
    if (cht_CheckCheat(&cheat_clev, ev->data1))
    {
      char		buf[3];
      int		epsd;
      int		map;
      
      cht_GetParam(&cheat_clev, buf);
      
      if (gamemode == commercial)
      {
	epsd = 0;
	map = (buf[0] - '0')*10 + buf[1] - '0';
      }
      else
      {
	epsd = buf[0] - '0';
	map = buf[1] - '0';
      }

      // Catch invalid maps.
      if (epsd < 1)
	return false;

      if (map < 1)
	return false;
      
      // Ohmygod - this is not going to work.
      if ((gamemode == retail)
	  && ((epsd > 4) || (map > 9)))
	return false;

      if ((gamemode == registered)
	  && ((epsd > 3) || (map > 9)))
	return false;

      if ((gamemode == shareware)
	  && ((epsd > 1) || (map > 9)))
	return false;

      if ((gamemode == commercial)
	&& (( epsd > 1) || (map > 34)))
	return false;

      // So be it.
      plyr->message = STSTR_CLEV;
      G_DeferedInitNew(gameskill, epsd, map);
    }    
  }
  return false;
}
Exemplo n.º 14
0
/**
 * Post Engine Initialization routine.
 * All game-specific actions that should take place at this time go here.
 */
void G_PostInit(void)
{
    int                 p;
    char                file[256];
    char                mapStr[6];

    // Common post init routine
    G_CommonPostInit();

    // Initialize ammo info.
    P_InitAmmoInfo();

    // Initialize weapon info.
    P_InitWeaponInfo();

    // Print a game mode banner with rulers.
    Con_FPrintf(CBLF_RULER | CBLF_WHITE | CBLF_CENTER,
                gamemode ==
                retail ? "The Ultimate DOOM Startup\n" : gamemode ==
                shareware ? "DOOM Shareware Startup\n" : gamemode ==
                registered ? "DOOM Registered Startup\n" : gamemode ==
                commercial ? (gamemission ==
                              GM_PLUT ?
                              "Final DOOM: The Plutonia Experiment\n" :
                              gamemission ==
                              GM_TNT ? "Final DOOM: TNT: Evilution\n" :
                              "DOOM 2: Hell on Earth\n") : "Public DOOM\n");
    Con_FPrintf(CBLF_RULER, "");

    // Game parameters.
    monsterinfight = GetDefInt("AI|Infight", 0);

    // get skill / episode / map from parms
    gameskill = startskill = SM_NOITEMS;
    startepisode = 1;
    startmap = 1;
    autostart = false;

    // Game mode specific settings
    // Plutonia and TNT automatically turn on the full sky.
    if(gamemode == commercial &&
       (gamemission == GM_PLUT || gamemission == GM_TNT))
    {
        Con_SetInteger("rend-sky-full", 1, true);
    }

    // Command line options
    nomonsters = ArgCheck("-nomonsters");
    respawnparm = ArgCheck("-respawn");
    fastparm = ArgCheck("-fast");
    devparm = ArgCheck("-devparm");

    if(ArgCheck("-altdeath"))
        cfg.netDeathmatch = 2;
    else if(ArgCheck("-deathmatch"))
        cfg.netDeathmatch = 1;

    p = ArgCheck("-skill");
    if(p && p < myargc - 1)
    {
        startskill = Argv(p + 1)[0] - '1';
        autostart = true;
    }

    p = ArgCheck("-episode");
    if(p && p < myargc - 1)
    {
        startepisode = Argv(p + 1)[0] - '0';
        startmap = 1;
        autostart = true;
    }

    p = ArgCheck("-timer");
    if(p && p < myargc - 1 && deathmatch)
    {
        int     time;

        time = atoi(Argv(p + 1));
        Con_Message("Levels will end after %d minute", time);
        if(time > 1)
            Con_Message("s");
        Con_Message(".\n");
    }

    p = ArgCheck("-warp");
    if(p && p < myargc - 1)
    {
        if(gamemode == commercial)
        {
            startmap = atoi(Argv(p + 1));
            autostart = true;
        }
        else if(p < myargc - 2)
        {
            startepisode = Argv(p + 1)[0] - '0';
            startmap = Argv(p + 2)[0] - '0';
            autostart = true;
        }
    }

    // turbo option
    p = ArgCheck("-turbo");
    turboMul = 1.0f;
    if(p)
    {
        int     scale = 200;

        turboparm = true;
        if(p < myargc - 1)
            scale = atoi(Argv(p + 1));
        if(scale < 10)
            scale = 10;
        if(scale > 400)
            scale = 400;

        Con_Message("turbo scale: %i%%\n", scale);
        turboMul = scale / 100.f;
    }

    // Are we autostarting?
    if(autostart)
    {
        if(gamemode == commercial)
            Con_Message("Warp to Map %d, Skill %d\n", startmap, startskill + 1);
        else
            Con_Message("Warp to Episode %d, Map %d, Skill %d\n", startepisode,
                        startmap, startskill + 1);
    }

    // Load a saved game?
    p = ArgCheck("-loadgame");
    if(p && p < myargc - 1)
    {
        SV_GetSaveGameFileName(Argv(p + 1)[0] - '0', file);
        G_LoadGame(file);
    }

    // Check valid episode and map
    if((autostart || IS_NETGAME))
    {
        if(gamemode == commercial)
            sprintf(mapStr,"MAP%2.2d", startmap);
        else
            sprintf(mapStr,"E%d%d",startepisode, startmap);

        if(!W_CheckNumForName(mapStr))
        {
            startepisode = 1;
            startmap = 1;
        }
    }

    // Print a string showing the state of the game parameters
    Con_Message("Game state parameters:%s%s%s%s%s\n",
                 nomonsters? " nomonsters" : "",
                 respawnparm? " respawn" : "",
                 fastparm? " fast" : "",
                 turboparm? " turbo" : "",
                 (cfg.netDeathmatch ==1)? " deathmatch" :
                    (cfg.netDeathmatch ==2)? " altdeath" : "");

    if(G_GetGameAction() != GA_LOADGAME)
    {
        if(autostart || IS_NETGAME)
        {
            G_DeferedInitNew(startskill, startepisode, startmap);
        }
        else
        {
            G_StartTitle();     // start up intro loop
        }
    }
}
Exemplo n.º 15
0
void M_SetMenu(FName menu, int param)
{
    // some menus need some special treatment
    switch (menu)
    {
    case NAME_Episodemenu:
        // sent from the player class menu
        GameStartupInfo.Skill = -1;
        GameStartupInfo.Episode = -1;
        GameStartupInfo.PlayerClass =
            param == -1000? NULL :
            param == -1? "Random" : GetPrintableDisplayName(PlayerClasses[param].Type).GetChars();
        break;

    case NAME_Skillmenu:
        // sent from the episode menu

        if ((gameinfo.flags & GI_SHAREWARE) && param > 0)
        {
            // Only Doom and Heretic have multi-episode shareware versions.
            M_StartMessage(GStrings("SWSTRING"), 1);
            return;
        }

        GameStartupInfo.Episode = param;
        M_StartupSkillMenu(&GameStartupInfo);	// needs player class name from class menu (later)
        break;

    case NAME_StartgameConfirm:
    {
        // sent from the skill menu for a skill that needs to be confirmed
        GameStartupInfo.Skill = param;

        const char *msg = AllSkills[param].MustConfirmText;
        if (*msg==0) msg = GStrings("NIGHTMARE");
        M_StartMessage (msg, 0, NAME_StartgameConfirmed);
        return;
    }

    case NAME_Startgame:
        // sent either from skill menu or confirmation screen. Skill gets only set if sent from skill menu
        // Now we can finally start the game. Ugh...
        GameStartupInfo.Skill = param;
    case NAME_StartgameConfirmed:

        G_DeferedInitNew (&GameStartupInfo);
        if (gamestate == GS_FULLCONSOLE)
        {
            gamestate = GS_HIDECONSOLE;
            gameaction = ga_newgame;
        }
        M_ClearMenus ();
        return;

    case NAME_Savegamemenu:
        if (!usergame || (players[consoleplayer].health <= 0 && !multiplayer) || gamestate != GS_LEVEL)
        {
            // cannot save outside the game.
            M_StartMessage (GStrings("SAVEDEAD"), 1);
            return;
        }
    }

    // End of special checks

    FMenuDescriptor **desc = MenuDescriptors.CheckKey(menu);
    if (desc != NULL)
    {
        if ((*desc)->mNetgameMessage.IsNotEmpty() && netgame && !demoplayback)
        {
            M_StartMessage((*desc)->mNetgameMessage, 1);
            return;
        }

        if ((*desc)->mType == MDESC_ListMenu)
        {
            FListMenuDescriptor *ld = static_cast<FListMenuDescriptor*>(*desc);
            if (ld->mAutoselect >= 0 && ld->mAutoselect < (int)ld->mItems.Size())
            {
                // recursively activate the autoselected item without ever creating this menu.
                ld->mItems[ld->mAutoselect]->Activate();
            }
            else
            {
                const PClass *cls = ld->mClass == NULL? RUNTIME_CLASS(DListMenu) : ld->mClass;

                DListMenu *newmenu = (DListMenu *)cls->CreateNew();
                newmenu->Init(DMenu::CurrentMenu, ld);
                M_ActivateMenu(newmenu);
            }
        }
        else if ((*desc)->mType == MDESC_OptionsMenu)
        {
            FOptionMenuDescriptor *ld = static_cast<FOptionMenuDescriptor*>(*desc);
            const PClass *cls = ld->mClass == NULL? RUNTIME_CLASS(DOptionMenu) : ld->mClass;

            DOptionMenu *newmenu = (DOptionMenu *)cls->CreateNew();
            newmenu->Init(DMenu::CurrentMenu, ld);
            M_ActivateMenu(newmenu);
        }
        return;
    }
    else
    {
        const PClass *menuclass = PClass::FindClass(menu);
        if (menuclass != NULL)
        {
            if (menuclass->IsDescendantOf(RUNTIME_CLASS(DMenu)))
            {
                DMenu *newmenu = (DMenu*)menuclass->CreateNew();
                newmenu->mParentMenu = DMenu::CurrentMenu;
                M_ActivateMenu(newmenu);
                return;
            }
        }
    }
    Printf("Attempting to open menu of unknown type '%s'\n", menu.GetChars());
    M_ClearMenus();
}
Exemplo n.º 16
0
static boolean SCSkill(int option)
{
    G_DeferedInitNew(option, MenuEpisode, 1);
    MN_DeactivateMenu();
    return true;
}
Exemplo n.º 17
0
//
// G_LoadWad
//
// Determines if the vectors of wad & patch filenames differs from the currently
// loaded ones and calls D_DoomWadReboot if so.
//
bool G_LoadWad(	const std::vector<std::string> &newwadfiles,
				const std::vector<std::string> &newpatchfiles,
				const std::vector<std::string> &newwadhashes,
				const std::vector<std::string> &newpatchhashes,
				const std::string &mapname)
{
	bool AddedIWAD = false;
	bool Reboot = false;
	size_t i, j;

	// Did we pass an IWAD?
	if (!newwadfiles.empty() && W_IsIWAD(newwadfiles[0]))
		AddedIWAD = true;

	// Check our environment, if the same WADs are used, ignore this command.

	// Did we switch IWAD files?
	if (AddedIWAD && !wadfiles.empty())
	{
		if (StdStringCompare(M_ExtractFileName(newwadfiles[0]), M_ExtractFileName(wadfiles[1]), true) != 0)
			Reboot = true;
	}

	// Do the sizes of the WAD lists not match up?
	if (!Reboot)
	{
		if (wadfiles.size() - 2 != newwadfiles.size() - (AddedIWAD ? 1 : 0))
			Reboot = true;
	}

	// Do our WAD lists match up exactly?
	if (!Reboot)
	{
		for (i = 2, j = (AddedIWAD ? 1 : 0); i < wadfiles.size() && j < newwadfiles.size(); i++, j++)
		{
			if (StdStringCompare(M_ExtractFileName(newwadfiles[j]), M_ExtractFileName(wadfiles[i]), true) != 0)
			{
				Reboot = true;
				break;
			}
		}
	}

	// Do the sizes of the patch lists not match up?
	if (!Reboot)
	{
		if (patchfiles.size() != newpatchfiles.size())
			Reboot = true;
	}

	// Do our patchfile lists match up exactly?
	if (!Reboot)
	{
		for (i = 0, j = 0; i < patchfiles.size() && j < newpatchfiles.size(); i++, j++)
		{
			if (StdStringCompare(M_ExtractFileName(newpatchfiles[j]), M_ExtractFileName(patchfiles[i]), true) != 0)
			{
				Reboot = true;
				break;
			}
		}
	}

	if (Reboot)
	{
		D_DoomWadReboot(newwadfiles, newpatchfiles, newwadhashes, newpatchhashes);
		if (!missingfiles.empty())
			return false;
	}

	unnatural_level_progression = true;
	if (mapname.length())
		G_DeferedInitNew((char *)mapname.c_str());
	else
		G_DeferedInitNew(startmap);

	return true;
}
Exemplo n.º 18
0
// Respond to keyboard input events,
//  intercept cheats.
boolean
ST_Responder (event_t* ev)
{
  int		i;
    
  // Filter automap on/off.
  if (ev->type == ev_keyup
      && ((ev->data1 & 0xffff0000) == AM_MSGHEADER))
  {
    switch(ev->data1)
    {
      case AM_MSGENTERED:
	st_gamestate = AutomapState;
	st_firsttime = true;
	break;
	
      case AM_MSGEXITED:
	//	fprintf(stderr, "AM exited\n");
	st_gamestate = FirstPersonState;
	break;
    }
  }

  // if a user keypress...
  else if (ev->type == ev_keydown)
  {
    if (!netgame && gameskill != sk_nightmare)
    {
      // 'dqd' cheat for toggleable god mode
      if (cht_CheckCheat(&cheat_god, ev->data2))
      {
	plyr->cheats ^= CF_GODMODE;
	if (plyr->cheats & CF_GODMODE)
	{
	  if (plyr->mo)
	    plyr->mo->health = 100;
	  
	  plyr->health = deh_god_mode_health;
	  plyr->message = DEH_String(STSTR_DQDON);
	}
	else 
	  plyr->message = DEH_String(STSTR_DQDOFF);
      }
      // 'fa' cheat for killer f*****g arsenal
      else if (cht_CheckCheat(&cheat_ammonokey, ev->data2))
      {
	plyr->armorpoints = deh_idfa_armor;
	plyr->armortype = deh_idfa_armor_class;
	
	for (i=0;i<NUMWEAPONS;i++)
	  plyr->weaponowned[i] = true;
	
	for (i=0;i<NUMAMMO;i++)
	  plyr->ammo[i] = plyr->maxammo[i];
	
	plyr->message = DEH_String(STSTR_FAADDED);
      }
      // 'kfa' cheat for key full ammo
      else if (cht_CheckCheat(&cheat_ammo, ev->data2))
      {
	plyr->armorpoints = deh_idkfa_armor;
	plyr->armortype = deh_idkfa_armor_class;
	
	for (i=0;i<NUMWEAPONS;i++)
	  plyr->weaponowned[i] = true;
	
	for (i=0;i<NUMAMMO;i++)
	  plyr->ammo[i] = plyr->maxammo[i];
	
	for (i=0;i<NUMCARDS;i++)
	  plyr->cards[i] = true;
	
	plyr->message = DEH_String(STSTR_KFAADDED);
      }
      // 'mus' cheat for changing music
      else if (cht_CheckCheat(&cheat_mus, ev->data2))
      {
	
	char	buf[3];
	int		musnum;
	
	plyr->message = DEH_String(STSTR_MUS);
	cht_GetParam(&cheat_mus, buf);

        // Note: The original v1.9 had a bug that tried to play back
        // the Doom II music regardless of gamemode.  This was fixed
        // in the Ultimate Doom executable so that it would work for
        // the Doom 1 music as well.

	if (gamemode == commercial || gameversion < exe_ultimate)
	{
	  musnum = mus_runnin + (buf[0]-'0')*10 + buf[1]-'0' - 1;
	  
	  if (((buf[0]-'0')*10 + buf[1]-'0') > 35
       && gameversion >= exe_doom_1_8)
	    plyr->message = DEH_String(STSTR_NOMUS);
	  else
	    S_ChangeMusic(musnum, 1);
	}
	else
	{
	  musnum = mus_e1m1 + (buf[0]-'1')*9 + (buf[1]-'1');
	  
	  if (((buf[0]-'1')*9 + buf[1]-'1') > 31)
	    plyr->message = DEH_String(STSTR_NOMUS);
	  else
	    S_ChangeMusic(musnum, 1);
	}
      }
      else if ( (logical_gamemission == doom 
                 && cht_CheckCheat(&cheat_noclip, ev->data2))
             || (logical_gamemission != doom 
                 && cht_CheckCheat(&cheat_commercial_noclip,ev->data2)))
      {	
        // Noclip cheat.
        // For Doom 1, use the idspipsopd cheat; for all others, use
        // idclip

	plyr->cheats ^= CF_NOCLIP;
	
	if (plyr->cheats & CF_NOCLIP)
	  plyr->message = DEH_String(STSTR_NCON);
	else
	  plyr->message = DEH_String(STSTR_NCOFF);
      }
      // 'behold?' power-up cheats
      for (i=0;i<6;i++)
      {
	if (cht_CheckCheat(&cheat_powerup[i], ev->data2))
	{
	  if (!plyr->powers[i])
	    P_GivePower( plyr, i);
	  else if (i!=pw_strength)
	    plyr->powers[i] = 1;
	  else
	    plyr->powers[i] = 0;
	  
	  plyr->message = DEH_String(STSTR_BEHOLDX);
	}
      }
      
      // 'behold' power-up menu
      if (cht_CheckCheat(&cheat_powerup[6], ev->data2))
      {
	plyr->message = DEH_String(STSTR_BEHOLD);
      }
      // 'choppers' invulnerability & chainsaw
      else if (cht_CheckCheat(&cheat_choppers, ev->data2))
      {
	plyr->weaponowned[wp_chainsaw] = true;
	plyr->powers[pw_invulnerability] = true;
	plyr->message = DEH_String(STSTR_CHOPPERS);
      }
      // 'mypos' for player position
      else if (cht_CheckCheat(&cheat_mypos, ev->data2))
      {
        static char buf[ST_MSGWIDTH];
        M_snprintf(buf, sizeof(buf), "ang=0x%x;x,y=(0x%x,0x%x)",
                   players[consoleplayer].mo->angle,
                   players[consoleplayer].mo->x,
                   players[consoleplayer].mo->y);
        plyr->message = buf;
      }
    }
    
    // 'clev' change-level cheat
    if (!netgame && cht_CheckCheat(&cheat_clev, ev->data2))
    {
      char		buf[3];
      int		epsd;
      int		map;
      
      cht_GetParam(&cheat_clev, buf);
      
      if (gamemode == commercial)
      {
	epsd = 1;
	map = (buf[0] - '0')*10 + buf[1] - '0';
      }
      else
      {
	epsd = buf[0] - '0';
	map = buf[1] - '0';
      }

      // Chex.exe always warps to episode 1.

      if (gameversion == exe_chex)
      {
        epsd = 1;
      }

      // Catch invalid maps.
      if (epsd < 1)
	return false;

      if (map < 1)
	return false;

      // Ohmygod - this is not going to work.
      if ((gamemode == retail)
	  && ((epsd > 4) || (map > 9)))
	return false;

      if ((gamemode == registered)
	  && ((epsd > 3) || (map > 9)))
	return false;

      if ((gamemode == shareware)
	  && ((epsd > 1) || (map > 9)))
	return false;

      // The source release has this check as map > 34. However, Vanilla
      // Doom allows IDCLEV up to MAP40 even though it normally crashes.
      if ((gamemode == commercial)
	&& (( epsd > 1) || (map > 40)))
	return false;

      // So be it.
      plyr->message = DEH_String(STSTR_CLEV);
      G_DeferedInitNew(gameskill, epsd, map);
    }
  }
  return false;
}
Exemplo n.º 19
0
// Respond to keyboard input events,
//  intercept cheats.
boolean
ST_Responder (event_t* ev)
{
  int		i;
    
  // Filter automap on/off.
  if (ev->type == ev_keyup
      && ((ev->data1 & 0xffff0000) == AM_MSGHEADER))
  {
    switch(ev->data1)
    {
      case AM_MSGENTERED:
	st_gamestate = AutomapState;
	st_firsttime = true;
	break;
	
      case AM_MSGEXITED:
	//	fprintf(stderr, "AM exited\n");
	st_gamestate = FirstPersonState;
	break;
    }
  }

  // if a user keypress...
  else if (ev->type == ev_keydown)
  {
    if (!netgame && gameskill != sk_nightmare)
    {
      // 'dqd' cheat for toggleable god mode
      if (cht_CheckCheat(&cheat_god, ev->data2))
      {
	plyr->cheats ^= CF_GODMODE;
	if (plyr->cheats & CF_GODMODE)
	{
	  if (plyr->mo)
	    plyr->mo->health = 100;
	  
	  plyr->health = deh_god_mode_health;
	  plyr->message = DEH_String(STSTR_DQDON);
	}
	else 
	  plyr->message = DEH_String(STSTR_DQDOFF);
      }
      // 'fa' cheat for killer f*****g arsenal
      else if (cht_CheckCheat(&cheat_ammonokey, ev->data2))
      {
	plyr->armorpoints = deh_idfa_armor;
	plyr->armortype = deh_idfa_armor_class;
	
	// [crispy] give backpack
	if (!plyr->backpack)
	{
	    for (i=0 ; i<NUMAMMO ; i++)
		plyr->maxammo[i] *= 2;
	    plyr->backpack = true;
	}

	for (i=0;i<NUMWEAPONS;i++)
	  plyr->weaponowned[i] = true;
	
	for (i=0;i<NUMAMMO;i++)
	  plyr->ammo[i] = plyr->maxammo[i];
	
	plyr->message = DEH_String(STSTR_FAADDED);
      }
      // 'kfa' cheat for key full ammo
      else if (cht_CheckCheat(&cheat_ammo, ev->data2))
      {
	plyr->armorpoints = deh_idkfa_armor;
	plyr->armortype = deh_idkfa_armor_class;
	
	// [crispy] give backpack
	if (!plyr->backpack)
	{
	    for (i=0 ; i<NUMAMMO ; i++)
		plyr->maxammo[i] *= 2;
	    plyr->backpack = true;
	}

	for (i=0;i<NUMWEAPONS;i++)
	  plyr->weaponowned[i] = true;
	
	for (i=0;i<NUMAMMO;i++)
	  plyr->ammo[i] = plyr->maxammo[i];
	
	for (i=0;i<NUMCARDS;i++)
	  plyr->cards[i] = true;
	
	plyr->message = DEH_String(STSTR_KFAADDED);
      }
      // [crispy] implement Boom's "tntem" cheat
      else if (cht_CheckCheat(&cheat_massacre, ev->data2))
      {
	static char msg[32];
	int killcount = ST_cheat_massacre();

	M_snprintf(msg, sizeof(msg), "\x1b%c%d \x1b%cMonster%s Killed",
	           '0' + CR_GOLD,
	           killcount, '0' + CR_RED, (killcount == 1) ? "" : "s");
	plyr->message = msg;
      }
      // [crispy] implement Crispy Doom's "spechits" cheat
      else if (cht_CheckCheat(&cheat_spechits, ev->data2))
      {
	static char msg[32];
	int triggeredlines = ST_cheat_spechits();

	M_snprintf(msg, sizeof(msg), "\x1b%c%d \x1b%cSpecial Line%s Triggered",
	           '0' + CR_GOLD,
	           triggeredlines, '0' + CR_RED, (triggeredlines == 1) ? "" : "s");
	plyr->message = msg;
      }
      // [crispy] implement Boom's "tnthom" cheat
      else if (cht_CheckCheat(&cheat_hom, ev->data2))
      {
	static char msg[32];

	crispy_flashinghom = !crispy_flashinghom;

	M_snprintf(msg, sizeof(msg), "HOM Detection \x1b%c%s",
	           '0' + CR_GREEN,
	           (crispy_flashinghom) ? "ON" : "OFF");
	plyr->message = msg;
      }
      // 'mus' cheat for changing music
      else if (cht_CheckCheat(&cheat_mus, ev->data2))
      {
	
	char	buf[3];
	int		musnum;
	
	plyr->message = DEH_String(STSTR_MUS);
	cht_GetParam(&cheat_mus, buf);

        // Note: The original v1.9 had a bug that tried to play back
        // the Doom II music regardless of gamemode.  This was fixed
        // in the Ultimate Doom executable so that it would work for
        // the Doom 1 music as well.

	if (gamemode == commercial || gameversion < exe_ultimate)
	{
	  musnum = mus_runnin + (buf[0]-'0')*10 + buf[1]-'0' - 1;
	  
	  // [crispy] prevent crash with IDMUS00
	  if (((buf[0]-'0')*10 + buf[1]-'0') > 35 || musnum < mus_runnin)
	    plyr->message = DEH_String(STSTR_NOMUS);
	  else
	    S_ChangeMusic(musnum, 1);
	}
	else
	{
	  musnum = mus_e1m1 + (buf[0]-'1')*9 + (buf[1]-'1');
	  
	  // [crispy] prevent crash with IDMUS0x or IDMUSx0
	  if (((buf[0]-'1')*9 + buf[1]-'1') > 31 || buf[0] < '1' || buf[1] < '1')
	    plyr->message = DEH_String(STSTR_NOMUS);
	  else
	    S_ChangeMusic(musnum, 1);
	}
      }
      // [crispy] allow both idspispopd and idclip cheats in all gamemissions
      else if ( ( /* logical_gamemission == doom
                 && */ cht_CheckCheat(&cheat_noclip, ev->data2))
             || ( /* logical_gamemission != doom
                 && */ cht_CheckCheat(&cheat_commercial_noclip,ev->data2)))
      {	
        // Noclip cheat.
        // For Doom 1, use the idspipsopd cheat; for all others, use
        // idclip

	plyr->cheats ^= CF_NOCLIP;
	
	if (plyr->cheats & CF_NOCLIP)
	  plyr->message = DEH_String(STSTR_NCON);
	else
	  plyr->message = DEH_String(STSTR_NCOFF);
      }
      // [crispy] implement PrBoom+'s "notarget" cheat
      else if (cht_CheckCheat(&cheat_notarget, ev->data2))
      {
	static char msg[32];

	plyr->cheats ^= CF_NOTARGET;

	M_snprintf(msg, sizeof(msg), "Notarget Mode \x1b%c%s",
	           '0' + CR_GREEN,
	           (plyr->cheats & CF_NOTARGET) ? "ON" : "OFF");
	plyr->message = msg;
      }
      // 'behold?' power-up cheats
      for (i=0;i<6;i++)
      {
	if (cht_CheckCheat(&cheat_powerup[i], ev->data2))
	{
	  if (!plyr->powers[i])
	    P_GivePower( plyr, i);
	  else if (i!=pw_strength)
	    plyr->powers[i] = 1;
	  else
	    plyr->powers[i] = 0;
	  
	  plyr->message = DEH_String(STSTR_BEHOLDX);
	}
      }
      
      // 'behold' power-up menu
      if (cht_CheckCheat(&cheat_powerup[6], ev->data2))
      {
	plyr->message = DEH_String(STSTR_BEHOLD);
      }
      // [crispy] implement Boom's "tntweap?" weapon cheats
      else if (cht_CheckCheat(&cheat_weapon, ev->data2))
      {
	char		buf[2];
	int		w;
	static char	msg[32];

	cht_GetParam(&cheat_weapon, buf);
	w = *buf - '1';

	if (w < 0 || w >= NUMWEAPONS)
	    return false;

	if (w == wp_supershotgun && !crispy_havessg)
	    return false;

	if ((w == wp_bfg || w == wp_plasma) && gamemode == shareware)
	    return false;

	// make '1' apply beserker strength toggle
	if (w == wp_fist)
	{
	    if (!plyr->powers[pw_strength])
		P_GivePower(plyr, pw_strength);
	    else
		plyr->powers[pw_strength] = 0;
	    M_snprintf(msg, sizeof(msg), DEH_String(STSTR_BEHOLDX));
	}
	else
	{
	    if ((plyr->weaponowned[w] = !plyr->weaponowned[w]))
		M_snprintf(msg, sizeof(msg), "Weapon \x1b%c%d\x1b%c Added",
		           '0' + CR_GOLD,
		           w + 1, '0' + CR_RED);
	    else
	    {
		M_snprintf(msg, sizeof(msg), "Weapon \x1b%c%d\x1b%c Removed",
		           '0' + CR_GOLD,
		           w + 1, '0' + CR_RED);

		// [crispy] removed current weapon, select another one
		if (w == plyr->readyweapon)
		{
		    extern boolean P_CheckAmmo (player_t* player);

		    P_CheckAmmo(plyr);
		}
	    }
	}
	plyr->message = msg;
      }
      // 'choppers' invulnerability & chainsaw
      else if (cht_CheckCheat(&cheat_choppers, ev->data2))
      {
	plyr->weaponowned[wp_chainsaw] = true;
	plyr->powers[pw_invulnerability] = true;
	plyr->message = DEH_String(STSTR_CHOPPERS);
      }
      // 'mypos' for player position
      else if (cht_CheckCheat(&cheat_mypos, ev->data2))
      {
        // [crispy] show (human readable) map coordinates
        // in the upper right corner (like automap stats)
/*
        static char buf[ST_MSGWIDTH];
        M_snprintf(buf, sizeof(buf), "ang=0x%x;x,y=(0x%x,0x%x)",
                   players[consoleplayer].mo->angle,
                   players[consoleplayer].mo->x,
                   players[consoleplayer].mo->y);
        plyr->message = buf;
*/
        p2fromp(plyr)->mapcoords ^= 1;
      }
    }
    
    // 'clev' change-level cheat
    if (!netgame && cht_CheckCheat(&cheat_clev, ev->data2))
    {
      char		buf[3];
      int		epsd;
      int		map;
      
      cht_GetParam(&cheat_clev, buf);
      
      if (gamemission == pack_nerve)
      {
	epsd = 2;
	map = (buf[0] - '0')*10 + buf[1] - '0';
      }
      else
      if (gamemode == commercial)
      {
	epsd = 1;
	map = (buf[0] - '0')*10 + buf[1] - '0';
      }
      else
      {
	epsd = buf[0] - '0';
	map = buf[1] - '0';
      }

      // Chex.exe always warps to episode 1.

      if (gameversion == exe_chex)
      {
        epsd = 1;
      }

      // Catch invalid maps.
      if (epsd == 0) // [crispy] allow IDCLEV0x to work in Doom 1
	epsd = gameepisode;
      else
      if (epsd < 1)
	return false;

      if ((map == 0) && (buf[0] - '0' == 0)) // [crispy] IDCLEV00 restarts current map
	map = gamemap;
      else
      if (map < 1)
	return false;

      // Ohmygod - this is not going to work.
      if ((gamemode == retail)
	  && ((epsd > 4) || (map > 9)))
	return false;

      if ((gamemode == registered)
	  && ((epsd > 3) || (map > 9)))
	return false;

      if ((gamemode == shareware)
	  && ((epsd > 1) || (map > 9)))
	return false;

      // The source release has this check as map > 34. However, Vanilla
      // Doom allows IDCLEV up to MAP40 even though it normally crashes.
      if ((gamemode == commercial && gamemission != pack_nerve)
	&& (( epsd > 1) || (map > 40)))
	return false;

      if ((gamemission == pack_nerve)
	&& (( epsd > 2) || (map > 9)))
	return false;

      // So be it.
      plyr->message = DEH_String(STSTR_CLEV);
      G_DeferedInitNew(gameskill, epsd, map);

      // [crispy] eat key press, i.e. don't change weapon upon level change
      return true;
    }
  }
  return false;
}