(SubgameEntity targ, GameExportsImpl gameExports)
| 82 | } |
| 83 | |
| 84 | public static void BeginIntermission(SubgameEntity targ, GameExportsImpl gameExports) { |
| 85 | |
| 86 | if (gameExports.level.intermissiontime != 0) |
| 87 | return; // already activated |
| 88 | |
| 89 | gameExports.game.autosaved = false; |
| 90 | |
| 91 | // respawn any dead clients |
| 92 | for (int i = 0; i < gameExports.game.maxclients; i++) { |
| 93 | SubgameEntity client = gameExports.g_edicts[1 + i]; |
| 94 | if (!client.inuse) |
| 95 | continue; |
| 96 | if (client.health <= 0) |
| 97 | PlayerClient.respawn(client, gameExports); |
| 98 | } |
| 99 | |
| 100 | gameExports.level.intermissiontime = gameExports.level.time; |
| 101 | gameExports.level.changemap = targ.map; |
| 102 | |
| 103 | // if we exit current unit in coop (only in coop because in single player all keys should have been already used) |
| 104 | if (gameExports.level.changemap.contains("*")) { |
| 105 | if (gameExports.gameCvars.coop.value != 0) { |
| 106 | for (int i = 0; i < gameExports.game.maxclients; i++) { |
| 107 | final SubgameEntity client = gameExports.g_edicts[1 + i]; |
| 108 | if (!client.inuse) |
| 109 | continue; |
| 110 | // strip players of all keys between units |
| 111 | gameExports.items.stream() |
| 112 | .filter(it -> (it.flags & GameDefines.IT_KEY) != 0) |
| 113 | .forEach(it -> client.getClient().pers.inventory[it.index] = 0); |
| 114 | } |
| 115 | } |
| 116 | } else { |
| 117 | if (0 == gameExports.gameCvars.deathmatch.value) { |
| 118 | // go immediately to the next level |
| 119 | gameExports.level.exitintermission = true; |
| 120 | return; |
| 121 | } |
| 122 | } |
| 123 | |
| 124 | gameExports.level.exitintermission = false; |
| 125 | |
| 126 | // find an intermission spot |
| 127 | edict_t ent = GameBase.G_FindEdict(null, GameBase.findByClassName, |
| 128 | "info_player_intermission", gameExports); |
| 129 | if (ent == null) { // the map creator forgot to put in an intermission |
| 130 | // point... |
| 131 | ent = GameBase.G_FindEdict(null, GameBase.findByClassName, |
| 132 | "info_player_start", gameExports); |
| 133 | if (ent == null) |
| 134 | ent = GameBase.G_FindEdict(null, GameBase.findByClassName, |
| 135 | "info_player_deathmatch", gameExports); |
| 136 | } else { // chose one of four spots |
| 137 | int i = Lib.rand() & 3; |
| 138 | EdictIterator es = null; |
| 139 | |
| 140 | while (i-- > 0) { |
| 141 | es = GameBase.G_Find(es, GameBase.findByClassName, |
no test coverage detected