(String mapname, String entities, String spawnpoint, GameExportsImpl gameExports)
| 916 | } |
| 917 | |
| 918 | static void SpawnEntities(String mapname, String entities, String spawnpoint, GameExportsImpl gameExports) { |
| 919 | |
| 920 | // todo: split into different functions |
| 921 | |
| 922 | gameExports.level.mapname = mapname; |
| 923 | gameExports.game.spawnpoint = spawnpoint; |
| 924 | |
| 925 | final float skill = normalizeSkillCvar(gameExports); |
| 926 | |
| 927 | // set client fields on player ents |
| 928 | for (int i = 0; i < gameExports.game.maxclients; i++) |
| 929 | gameExports.g_edicts[i + 1].setClient(gameExports.game.clients[i]); |
| 930 | |
| 931 | EntityParserKt.parseEntities(entities).forEach(map -> { |
| 932 | |
| 933 | final SubgameEntity ent; |
| 934 | if ("worldspawn".equals(map.get("classname"))) |
| 935 | ent = gameExports.g_edicts[0]; |
| 936 | else |
| 937 | ent = gameExports.G_Spawn(); |
| 938 | |
| 939 | map.forEach((key, value) -> ED_ParseField(key, value, ent, gameExports)); |
| 940 | |
| 941 | |
| 942 | // todo: add description |
| 943 | // yet another map hack |
| 944 | if ("command".equalsIgnoreCase(gameExports.level.mapname) |
| 945 | && "trigger_once".equalsIgnoreCase(ent.classname) |
| 946 | && "*27".equalsIgnoreCase(ent.model)) |
| 947 | ent.spawnflags &= ~GameDefines.SPAWNFLAG_NOT_HARD; |
| 948 | |
| 949 | boolean spawned = true; |
| 950 | if (!ent.classname.equals("worldspawn")) { |
| 951 | if (gameExports.gameCvars.deathmatch.value != 0) { |
| 952 | if ((ent.spawnflags & GameDefines.SPAWNFLAG_NOT_DEATHMATCH) != 0) { |
| 953 | spawned = false; |
| 954 | } |
| 955 | } else { |
| 956 | // fixme: similar check for SPAWNFLAG_NOT_COOP? |
| 957 | if (skill == 0 && (ent.spawnflags & GameDefines.SPAWNFLAG_NOT_EASY) != 0 |
| 958 | || skill == 1 && (ent.spawnflags & GameDefines.SPAWNFLAG_NOT_MEDIUM) != 0 |
| 959 | // SPAWNFLAG_NOT_HARD implies not hard+ also |
| 960 | || (skill == 2 || skill == 3) && (ent.spawnflags & GameDefines.SPAWNFLAG_NOT_HARD) != 0) { |
| 961 | spawned = false; |
| 962 | } |
| 963 | } |
| 964 | |
| 965 | // reset difficulty spawnflags |
| 966 | ent.spawnflags &= ~(GameDefines.SPAWNFLAG_NOT_EASY |
| 967 | | GameDefines.SPAWNFLAG_NOT_MEDIUM |
| 968 | | GameDefines.SPAWNFLAG_NOT_HARD |
| 969 | | GameDefines.SPAWNFLAG_NOT_COOP |
| 970 | | GameDefines.SPAWNFLAG_NOT_DEATHMATCH); |
| 971 | } |
| 972 | if (spawned) { |
| 973 | gameExports.gameImports.dprintf("spawning ent[" + ent.index + "], classname=" + |
| 974 | ent.classname + ", flags= " + Integer.toHexString(ent.spawnflags) + "\n"); |
| 975 | ED_CallSpawn(ent, gameExports); |
no test coverage detected