GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — UZDoom/src/g_level.cpp at trunk · UZDoom/UZDoom Expand file tree/ Copy pathg_level.cppMore file actions 2633 lines (2279 loc) · 67.7 KB / Copy pathg_level.cppFile metadata and controls2633 lines (2279 loc) · 67.7 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 /* ** g_level.cpp ** ** controls movement between levels ** **--------------------------------------------------------------------------- ** ** Copyright 1998-2016 Marisa Heit ** Copyright 2006-2016 Christoph Oelckers ** Copyright 2017-2025 GZDoom Maintainers and Contributors ** Copyright 2025-2026 UZDoom Maintainers and Contributors ** ** SPDX-License-Identifier: GPL-3.0-or-later ** **--------------------------------------------------------------------------- ** ** Code written prior to 2026 is also licensed under: ** ** SPDX-License-Identifier: BSD-3-Clause ** **--------------------------------------------------------------------------- ** */ #include <assert.h> #include "d_main.h" #include "g_level.h" #include "g_game.h" #include "s_sound.h" #include "d_event.h" #include "m_random.h" #include "engineerrors.h" #include "doomstat.h" #include "wi_stuff.h" #include "filesystem.h" #include "am_map.h" #include "c_dispatch.h" #include "i_interface.h" #include "p_setup.h" #include "p_local.h" #include "r_sky.h" #include "c_console.h" #include "intermission/intermission.h" #include "v_video.h" #include "st_stuff.h" #include "hu_stuff.h" #include "p_saveg.h" #include "p_acs.h" #include "d_protocol.h" #include "v_text.h" #include "s_sndseq.h" #include "b_bot.h" #include "sbar.h" #include "a_lightning.h" #include "version.h" #include "sbarinfo.h" #include "p_lnspec.h" #include "cmdlib.h" #include "d_net.h" #include "d_netinf.h" #include "doommenu.h" #include "a_sharedglobal.h" #include "r_utility.h" #include "p_spec.h" #include "serializer_doom.h" #include "vm.h" #include "events.h" #include "i_music.h" #include "a_dynlight.h" #include "p_conversation.h" #include "p_effect.h" #include "stringtable.h" #include "c_buttons.h" #include "screenjob.h" #include "types.h" #include "gstrings.h" #include "gi.h" #include "g_hub.h" #include "g_levellocals.h" #include "actorinlines.h" #include "i_time.h" #include "p_maputl.h" #include "s_music.h" #include "fragglescript/t_script.h" #include "texturemanager.h" void STAT_StartNewGame(const char *lev); void STAT_ChangeLevel(const char *newl, FLevelLocals *Level); FString STAT_EpisodeName(); EXTERN_CVAR(Bool, save_formatted) EXTERN_CVAR (Float, sv_gravity) EXTERN_CVAR (Float, sv_aircontrol) EXTERN_CVAR (Int, disableautosave) EXTERN_CVAR (String, playerclass) extern uint8_t globalfreeze, globalchangefreeze; int startpos = 0; // [RH] Support for multiple starts per level int laststartpos = 0; #define SNAP_ID MAKE_ID('s','n','A','p') #define DSNP_ID MAKE_ID('d','s','N','p') #define VIST_ID MAKE_ID('v','i','S','t') #define ACSD_ID MAKE_ID('a','c','S','d') #define RCLS_ID MAKE_ID('r','c','L','s') #define PCLS_ID MAKE_ID('p','c','L','s') void G_VerifySkill(); void I_UpdateWindowTitle(); CUSTOM_CVAR(Bool, gl_brightfog, false, CVAR_ARCHIVE | CVAR_NOINITCALL) { for (auto Level : AllLevels()) { if (Level->info == nullptr || Level->info->brightfog == -1) Level->brightfog = self; } } CUSTOM_CVAR(Bool, gl_lightadditivesurfaces, false, CVAR_ARCHIVE | CVAR_NOINITCALL) { for (auto Level : AllLevels()) { if (Level->info == nullptr || Level->info->lightadditivesurfaces == -1) Level->lightadditivesurfaces = self; } } CUSTOM_CVAR(Bool, gl_notexturefill, false, CVAR_NOINITCALL) { for (auto Level : AllLevels()) { if (Level->info == nullptr || Level->info->notexturefill == -1) Level->notexturefill = self; } } CUSTOM_CVAR(Int, gl_maplightmode, -1, CVAR_NOINITCALL | CVAR_CHEAT) // this is just for testing. -1 means 'inactive' { if (self > 4 || self < -1) self = -1; } CUSTOM_CVARD(Int, gl_lightmode, 1, CVAR_ARCHIVE, "Select lighting mode. 2 is vanilla accurate, 1 is accurate to the ZDoom software renderer and 0 is a less demanding non-shader implementation") { if (self < 0 || self > 2) self = 1; } ELightMode getRealLightmode(FLevelLocals* Level, bool for3d) { // The rules are: // 1) if the map sets a proper light mode, it is taken unconditionally. if (Level->info->lightmode != ELightMode::NotSet) return Level->info->lightmode; // 2) if the user sets gl_maplightmode, this is being used. if (gl_maplightmode != -1) return (ELightMode)*gl_maplightmode; // 3) if not for 3D use lightmode Doom. This is for the automap where the software light modes do not work if (!for3d) return ELightMode::Doom; // otherwise use lightmode Doom or software lighting based on user preferences. if (gl_lightmode == 1) return ELightMode::ZDoomSoftware; else if (gl_lightmode == 2) return ELightMode::DoomSoftware; return ELightMode::Doom; } CVAR(Int, sv_alwaystally, 0, CVAR_SERVERINFO) static FRandom pr_classchoice ("RandomPlayerClassChoice"); extern level_info_t TheDefaultLevelInfo; extern bool timingdemo; // Start time for timing demos int starttime; extern FString BackupSaveName; bool savegamerestore; int finishstate = FINISH_NoHub; extern float mousex, mousey; extern bool sendpause, sendsave, sendturn180, SendLand; void *statcopy; // for statistics driver FLevelLocals level; // info about current level FLevelLocals *primaryLevel = &level; // level for which to display the user interface. FLevelLocals *currentVMLevel = &level; // level which currently ticks. Used as global input to the VM and some functions called by it. static PType* maprecordtype; //============================================================================= // // // //============================================================================= void Local_Job_Init() { maprecordtype = NewPointer(NewStruct("MapRecord", nullptr, true)); } //============================================================================= // // // //============================================================================= static void CallCreateMapFunction(const char* qname, DObject* runner, level_info_t* map) { auto func = LookupFunction(qname); if (func->Proto->ArgumentTypes.Size() == 1) return CallCreateFunction(qname, runner); // accept functions without map parameter as well here. if (func->Proto->ArgumentTypes.Size() != 2) I_Error("Bad map-cutscene function %s. Must receive precisely two arguments.", qname); if (func->Proto->ArgumentTypes[0] != cutscene.runnerclasstype && func->Proto->ArgumentTypes[1] != maprecordtype) I_Error("Bad cutscene function %s. Must receive ScreenJobRunner and LevelInfo reference.", qname); VMValue val[2] = { runner, map }; VMCall(func, val, 2, nullptr, 0); } //============================================================================= // // // //============================================================================= bool CreateCutscene(CutsceneDef* cs, DObject* runner, level_info_t* map) { if (cs->function.CompareNoCase("none") == 0) return true; // play nothing but return as being validated if (cs->function.IsNotEmpty()) { CallCreateMapFunction(cs->function.GetChars(), runner, map); return true; } else if (cs->video.IsNotEmpty()) { AddGenericVideo(runner, cs->video, cs->GetSound(), cs->framespersec); return true; } return false; } //========================================================================== // // G_InitNew // Can be called by the startup code or the menu task, // consoleplayer, playeringame[] should be set. // //========================================================================== static FString d_mapname; static int d_skill=-1; void G_DeferedInitNew (const char *mapname, int newskill) { d_mapname = mapname; d_skill = newskill; CheckWarpTransMap (d_mapname, true); gameaction = ga_newgame2; } void G_DeferedInitNew (FNewGameStartup *gs) { if (gs->hasPlayerClass) playerclass = gs->PlayerClass.GetChars(); d_mapname = AllEpisodes[gs->Episode].mEpisodeMap; d_skill = gs->Skill; CheckWarpTransMap (d_mapname, true); gameaction = ga_newgame2; finishstate = FINISH_NoHub; if (AllEpisodes[gs->Episode].mIntro.isdefined()) { cutscene.runner = CreateRunner(false); GC::WriteBarrier(cutscene.runner); if (!CreateCutscene(&AllEpisodes[gs->Episode].mIntro, cutscene.runner, nullptr)) { return; } cutscene.completion = [](bool) { gameaction = ga_newgame2; }; if (!ScreenJobValidate()) { DeleteScreenJob(); cutscene.completion = nullptr; return; } gameaction = ga_intermission; } } //========================================================================== // // //========================================================================== CCMD (map) { if (netgame) { Printf ("Use " TEXTCOLOR_BOLD "changemap" TEXTCOLOR_NORMAL " instead. " TEXTCOLOR_BOLD "Map" TEXTCOLOR_NORMAL " is for single-player only.\n"); return; } if (argv.argc() > 1) { const char *mapname = argv[1]; if (!strcmp(mapname, "*")) mapname = primaryLevel->MapName.GetChars(); try { if (!P_CheckMapData(mapname)) { Printf ("No map %s\n", mapname); } else { if (argv.argc() > 2 && stricmp(argv[2], "coop") == 0) { deathmatch = false; multiplayernext = true; } else if (argv.argc() > 2 && stricmp(argv[2], "dm") == 0) { deathmatch = true; multiplayernext = true; } G_DeferedInitNew (mapname); } } catch(CRecoverableError &error) { if (error.GetMessage()) Printf("%s", error.GetMessage()); } } else { Printf ("Usage: map <map name> [coop|dm]\n"); } } //========================================================================== // // //========================================================================== UNSAFE_CCMD(recordmap) { if (netgame) { Printf("You cannot record a new game while in a netgame.\n"); return; } if (argv.argc() > 2) { const char *mapname = argv[2]; if (!strcmp(mapname, "*")) mapname = primaryLevel->MapName.GetChars(); try { if (!P_CheckMapData(mapname)) { Printf("No map %s\n", mapname); } else { if (argv.argc() > 3 && stricmp(argv[3], "coop") == 0) { deathmatch = false; multiplayernext = true; } else if (argv.argc() > 3 && stricmp(argv[3], "dm") == 0) { deathmatch = true; multiplayernext = true; } G_DeferedInitNew(mapname); gameaction = ga_recordgame; newdemoname = argv[1]; newdemomap = mapname; } } catch (CRecoverableError &error) { if (error.GetMessage()) Printf("%s", error.GetMessage()); } } else { Printf("Usage: recordmap <filename> <map name> [coop|dm]\n"); } } //========================================================================== // // //========================================================================== UNSAFE_CCMD (open) { if (netgame) { Printf ("You cannot use open in multiplayer games.\n"); return; } if (argv.argc() > 1) { d_mapname = "file:"; d_mapname += argv[1]; if (!P_CheckMapData(d_mapname.GetChars())) { Printf ("No map %s\n", d_mapname.GetChars()); } else { if (argv.argc() > 2 && stricmp(argv[2], "coop") == 0) { deathmatch = false; multiplayernext = true; } else if (argv.argc() > 2 && stricmp(argv[2], "dm") == 0) { deathmatch = true; multiplayernext = true; } gameaction = ga_newgame2; d_skill = -1; } } else { Printf ("Usage: open <map file> [coop|dm]\n"); } } //========================================================================== // // //========================================================================== void G_NewInit () { unsigned int i; // Destory all old player refrences that may still exist TThinkerIterator<AActor> it(primaryLevel, NAME_PlayerPawn, STAT_TRAVELLING, false); AActor *pawn, *next; next = it.Next(); while ((pawn = next) != NULL) { next = it.Next(); pawn->flags |= MF_NOSECTOR | MF_NOBLOCKMAP; pawn->Destroy(); } if (primaryLevel->FraggleScriptThinker) primaryLevel->FraggleScriptThinker->Destroy(); primaryLevel->FraggleScriptThinker = nullptr; // Destroy thinkers that may remain after change level failure // Usually, the list contains just a sentinel when such error occurred primaryLevel->Thinkers.DestroyThinkersInList(STAT_TRAVELLING); primaryLevel->ClientSideThinkers.DestroyThinkersInList(STAT_TRAVELLING); G_ClearSnapshots (); netgame = false; multiplayer = multiplayernext; multiplayernext = false; if (demoplayback) { C_RestoreCVars (); demoplayback = false; D_SetupUserInfo (); } for (i = 0; i < MAXPLAYERS; ++i) { player_t *p = &players[i]; userinfo_t saved_ui; saved_ui.TransferFrom(p->userinfo); const int chasecam = p->cheats & CF_CHASECAM; const bool settings_controller = p->settings_controller; p->~player_t(); ::new(p) player_t; p->settings_controller = settings_controller; p->cheats |= chasecam; p->playerstate = PST_DEAD; p->userinfo.TransferFrom(saved_ui); playeringame[i] = false; } BackupSaveName = ""; consoleplayer = 0; NextSkill = -1; } //========================================================================== // // //========================================================================== void G_DoNewGame (void) { G_NewInit (); playeringame[consoleplayer] = 1; if (d_skill != -1) { gameskill = d_skill; } G_InitNew (d_mapname.GetChars(), false); gameaction = ga_nothing; } //========================================================================== // // Initializes player classes in case they are random. // This gets called at the start of a new game, and the classes // chosen here are used for the remainder of a single-player // or coop game. These are ignored for deathmatch. // //========================================================================== static void InitPlayerClasses () { if (!savegamerestore) { for (unsigned int i = 0; i < MAXPLAYERS; ++i) { SinglePlayerClass[i] = players[i].userinfo.GetPlayerClassNum(); if (SinglePlayerClass[i] < 0 || !playeringame[i]) { SinglePlayerClass[i] = (pr_classchoice()) % PlayerClasses.Size (); } players[i].cls = NULL; players[i].CurrentPlayerClass = SinglePlayerClass[i]; } } } // Account for additional players joining from a save file. static void UpdatePlayerClass(int i) { if (!savegamerestore || !playeringame[i]) return; SinglePlayerClass[i] = players[i].userinfo.GetPlayerClassNum(); if (SinglePlayerClass[i] < 0) SinglePlayerClass[i] = (pr_classchoice()) % PlayerClasses.Size(); players[i].cls = nullptr; players[i].CurrentPlayerClass = SinglePlayerClass[i]; } //========================================================================== // // //========================================================================== void G_InitNew (const char *mapname, bool bTitleLevel) { bool wantFast; unsigned int i; // did we have any level before? if (primaryLevel->info != nullptr) staticEventManager.WorldUnloaded(FString()); // [MK] don't pass the new map, as it's not a level transition UnlatchCVars (); if (!savegamerestore) { G_ClearHubInfo(); G_ClearSnapshots (); P_RemoveDefereds (); // [RH] Mark all levels as not visited for (unsigned int i = 0; i < wadlevelinfos.Size(); i++) wadlevelinfos[i].flags = wadlevelinfos[i].flags & ~LEVEL_VISITED; auto redirectmap = FindLevelInfo(mapname); if (redirectmap->RedirectCVAR != NAME_None) redirectmap = redirectmap->CheckLevelRedirect(); if (redirectmap && redirectmap->MapName.IsNotEmpty()) mapname = redirectmap->MapName.GetChars(); } G_VerifySkill(); UnlatchCVars (); globalfreeze = globalchangefreeze = 0; for (auto Level : AllLevels()) { Level->Thinkers.DestroyThinkersInList(STAT_STATIC); Level->ClientSideThinkers.DestroyThinkersInList(STAT_STATIC); } if (paused) { paused = 0; S_ResumeSound (false); } ST_CreateStatusBar(bTitleLevel); setsizeneeded = true; // [RH] If this map doesn't exist, bomb out if (!P_CheckMapData(mapname)) { I_Error ("Could not find map %s\n", mapname); } wantFast = !!G_SkillProperty(SKILLP_FastMonsters); GameSpeed = wantFast ? SPEED_Fast : SPEED_Normal; if (!savegamerestore) { if (!netgame && !demorecording && !demoplayback) { // [RH] Change the random seed for each new single player game // [ED850] The demo already sets the RNG. rngseed = use_staticrng ? staticrngseed : (rngseed + 1); } FRandom::StaticClearRandom (); P_ClearACSVars(true); primaryLevel->time = 0; primaryLevel->maptime = 0; primaryLevel->totaltime = 0; primaryLevel->spawnindex = 0; if (!multiplayer || !deathmatch) { InitPlayerClasses (); } // force players to be initialized upon first level load for (i = 0; i < MAXPLAYERS; i++) players[i].playerstate = PST_ENTER; // [BC] STAT_StartNewGame(mapname); GameUUID = GenerateUUID(); } usergame = !bTitleLevel; // will be set false if a demo paused = 0; demoplayback = false; automapactive = false; viewactive = true; //Added by MC: Initialize bots. if (!deathmatch) { primaryLevel->BotInfo.Init (); } if (bTitleLevel) { gamestate = GS_TITLELEVEL; } else if (gamestate != GS_STARTUP) { gamestate = GS_LEVEL; } if (!savegamerestore) startpos = laststartpos = 0; G_DoLoadLevel (mapname, startpos, false, !savegamerestore); if (!savegamerestore && (gameinfo.gametype == GAME_Strife || (SBarInfoScript[SCRIPT_CUSTOM] != nullptr && SBarInfoScript[SCRIPT_CUSTOM]->GetGameType() == GAME_Strife))) { // Set the initial quest log text for Strife. for (i = 0; i < MAXPLAYERS; ++i) { if (playeringame[i]) players[i].SetLogText("$TXT_FINDHELP"); } } } // // G_DoCompleted // static FString nextlevel; extern int NoWipe; // [RH] Don't wipe when travelling in hubs static int changeflags; static bool unloading; //========================================================================== // // [RH] The position parameter to these next three functions should // match the first parameter of the single player start spots // that should appear in the next map. // //========================================================================== EXTERN_CVAR(Bool, sv_singleplayerrespawn) bool FLevelLocals::ShouldDoIntermission(cluster_info_t* nextcluster, cluster_info_t* thiscluster) { // this is here to remove some code duplication if ((sv_alwaystally == 2) || (deathmatch)) return true; if (sv_alwaystally == 3) return false; if ((sv_alwaystally == 0) && (flags & LEVEL_NOINTERMISSION)) return false; bool withinSameCluster = (nextcluster == thiscluster); bool clusterIsHub = (thiscluster->flags & CLUSTER_HUB); bool hubNoIntermission = !(thiscluster->flags & CLUSTER_ALLOWINTERMISSION); if (withinSameCluster && clusterIsHub && hubNoIntermission) return false; return true; } void FLevelLocals::ChangeLevel(const char *levelname, int position, int inflags, int nextSkill) { if (!isPrimaryLevel()) return; // only the primary level may exit. FString nextlevel; level_info_t *nextinfo = nullptr; if (unloading) { Printf (TEXTCOLOR_RED "Unloading scripts cannot exit the level again.\n"); return; } if (gameaction == ga_completed && !(i_compatflags2 & COMPATF2_MULTIEXIT)) // do not exit multiple times. { return; } if (levelname == NULL || *levelname == 0) { // end the game levelname = NULL; if (!NextMap.Compare("enDSeQ",6)) { nextlevel = NextMap; // If there is already an end sequence please leave it alone! } else { nextlevel.Format("enDSeQ%04x", gameinfo.DefaultEndSequence.GetIndex()); } } else if (strncmp(levelname, "enDSeQ", 6) != 0) { FString reallevelname = levelname; CheckWarpTransMap(reallevelname, true); nextinfo = FindLevelInfo (reallevelname.GetChars(), false); if (nextinfo != NULL) { level_info_t *nextredir = nextinfo->CheckLevelRedirect(); if (nextredir != NULL) { nextinfo = nextredir; } nextlevel = nextinfo->MapName; } else { nextlevel = levelname; } } else { nextlevel = levelname; } if (nextSkill != -1) NextSkill = (unsigned)nextSkill < AllSkills.Size() ? nextSkill : -1; if (inflags & CHANGELEVEL_NOINTERMISSION) { flags |= LEVEL_NOINTERMISSION; } cluster_info_t *thiscluster = FindClusterInfo (cluster); cluster_info_t *nextcluster = nextinfo? FindClusterInfo (nextinfo->cluster) : NULL; startpos = position; SetMusicVolume(1.0); if (nextinfo != NULL) { if (thiscluster != nextcluster || (thiscluster && !(thiscluster->flags & CLUSTER_HUB))) { const bool doReset = dmflags3 & DF3_PISTOL_START; if (doReset || (nextinfo->flags2 & LEVEL2_RESETINVENTORY)) { inflags |= CHANGELEVEL_RESETINVENTORY; } if (doReset || (nextinfo->flags2 & LEVEL2_RESETHEALTH)) { inflags |= CHANGELEVEL_RESETHEALTH; } } } changeflags = inflags; BotInfo.End(); //Added by MC: // [RH] Give scripts a chance to do something unloading = true; Behaviors.StartTypedScripts (SCRIPT_Unloading, NULL, false, 0, true); // [ZZ] safe world unload for (auto Level : AllLevels()) { // Todo: This must be exolicitly sandboxed! Level->localEventManager->WorldUnloaded(nextlevel); } // [ZZ] unsafe world unload (changemap != map) staticEventManager.WorldUnloaded(nextlevel); unloading = false; STAT_ChangeLevel(nextlevel.GetChars(), this); if (thiscluster && (thiscluster->flags & CLUSTER_HUB)) { if (!ShouldDoIntermission(nextcluster, thiscluster)) NoWipe = 35; D_DrawIcon = "TELEICON"; } for(unsigned int i = 0; i < MAXPLAYERS; i++) { if (PlayerInGame(i)) { player_t *player = Players[i]; // Un-crouch all players here. player->Uncrouch(); // If this is co-op, respawn any dead players now so they can // keep their inventory on the next map. if ((multiplayer || flags2 & LEVEL2_ALLOWRESPAWN || sv_singleplayerrespawn || !!G_SkillProperty(SKILLP_PlayerRespawn)) && !deathmatch && player->playerstate == PST_DEAD) { // Copied from the end of P_DeathThink [[ player->cls = NULL; // Force a new class if the player is using a random class player->playerstate = PST_REBORN; if (player->mo->special1 > 2) { player->mo->special1 = 0; } // ]] DoReborn(i, true); } } } // Set global transition state. gameaction = ga_completed; ::nextlevel = nextlevel; } DEFINE_ACTION_FUNCTION(FLevelLocals, ChangeLevel) { PARAM_SELF_STRUCT_PROLOGUE(FLevelLocals); PARAM_STRING(levelname); PARAM_INT(position); PARAM_INT(inflags); PARAM_INT(nextSkill); self->ChangeLevel(levelname.GetChars(), position, inflags, nextSkill); return 0; } //========================================================================== // // //========================================================================== const char *FLevelLocals::GetSecretExitMap() { const char *nextmap = NextMap.GetChars(); if (NextSecretMap.Len() > 0) { if (NextSecretMap.Compare("enDSeQ", 6) == 0 || P_CheckMapData(NextSecretMap.GetChars())) { nextmap = NextSecretMap.GetChars(); } } return nextmap; } //========================================================================== // // //========================================================================== void FLevelLocals::ExitLevel (int position, bool keepFacing) { flags3 |= LEVEL3_EXITNORMALUSED; ChangeLevel(NextMap.GetChars(), position, keepFacing ? CHANGELEVEL_KEEPFACING : 0); } static void LevelLocals_ExitLevel(FLevelLocals *self, int position, bool keepFacing) { self->ExitLevel(position, keepFacing); } DEFINE_ACTION_FUNCTION_NATIVE(FLevelLocals, ExitLevel, LevelLocals_ExitLevel) { PARAM_SELF_STRUCT_PROLOGUE(FLevelLocals); PARAM_INT(position); PARAM_INT(keepFacing); self->ExitLevel(position, keepFacing); return 0; } void FLevelLocals::SecretExitLevel (int position) { flags3 |= LEVEL3_EXITSECRETUSED; ChangeLevel(GetSecretExitMap(), position, 0); } static void LevelLocals_SecretExitLevel(FLevelLocals *self, int position) { self->SecretExitLevel(position); } DEFINE_ACTION_FUNCTION_NATIVE(FLevelLocals, SecretExitLevel, LevelLocals_SecretExitLevel) { PARAM_SELF_STRUCT_PROLOGUE(FLevelLocals); PARAM_INT(position); self->SecretExitLevel(position); return 0; } //========================================================================== // // //========================================================================== static wbstartstruct_t staticWmInfo; DIntermissionController* FLevelLocals::CreateIntermission() { DIntermissionController* controller = nullptr; cluster_info_t *nextcluster; cluster_info_t *thiscluster; if (flags & LEVEL_CHANGEMAPCHEAT) return nullptr; thiscluster = FindClusterInfo (cluster); bool endgame = strncmp (nextlevel.GetChars(), "enDSeQ", 6) == 0; if (endgame) { FName endsequence = ENamedName(strtoll(nextlevel.GetChars()+6, NULL, 16)); // Strife needs a special case here to choose between good and sad ending. Bad is handled elsewhere. if (endsequence == NAME_Inter_Strife) { if (Players[0]->mo->FindInventory (NAME_QuestItem25) || Players[0]->mo->FindInventory (NAME_QuestItem28)) { endsequence = NAME_Inter_Strife_Good; } else { endsequence = NAME_Inter_Strife_Sad; } } auto ext = info->ExitMapTexts.CheckKey(flags3 & LEVEL3_EXITSECRETUSED ? NAME_Secret : NAME_Normal); if (ext != nullptr && (ext->mDefined & FExitText::DEF_TEXT)) { controller = F_StartFinale(ext->mDefined & FExitText::DEF_MUSIC ? ext->mMusic.GetChars() : gameinfo.finaleMusic.GetChars(), ext->mDefined & FExitText::DEF_MUSIC ? ext->mOrder : gameinfo.finaleOrder, -1, 0, ext->mDefined & FExitText::DEF_BACKDROP ? ext->mBackdrop.GetChars() : gameinfo.FinaleFlat.GetChars(), ext->mText.GetChars(), false, ext->mDefined & FExitText::DEF_PIC, ext->mDefined & FExitText::DEF_LOOKUP, true, endsequence); } else if (!(info->flags2 & LEVEL2_NOCLUSTERTEXT)) { controller = F_StartFinale(thiscluster->MessageMusic.GetChars(), thiscluster->musicorder, thiscluster->cdtrack, thiscluster->cdid, thiscluster->FinaleFlat.GetChars(), thiscluster->ExitText.GetChars(), thiscluster->flags & CLUSTER_EXITTEXTINLUMP, thiscluster->flags & CLUSTER_FINALEPIC, thiscluster->flags & CLUSTER_LOOKUPEXITTEXT, true, endsequence); } } else if (!deathmatch) { FExitText *ext = nullptr; if (flags3 & LEVEL3_EXITSECRETUSED) ext = info->ExitMapTexts.CheckKey(NAME_Secret); else if (flags3 & LEVEL3_EXITNORMALUSED) ext = info->ExitMapTexts.CheckKey(NAME_Normal); if (ext == nullptr) ext = info->ExitMapTexts.CheckKey(nextlevel); |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |