⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sv_init.java

📁 Jake2是一个Java 3D游戏引擎.
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
            sv.models[1] = CM.CM_LoadMap(                    sv.configstrings[Defines.CS_MODELS + 1], false, iw);        }        checksum = iw[0];        sv.configstrings[Defines.CS_MAPCHECKSUM] = "" + checksum;        // clear physics interaction links                SV_WORLD.SV_ClearWorld();        for (i = 1; i < CM.CM_NumInlineModels(); i++) {            sv.configstrings[Defines.CS_MODELS + 1 + i] = "*" + i;                        // copy references            sv.models[i + 1] = CM.InlineModel(sv.configstrings[Defines.CS_MODELS + 1 + i]);        }             // spawn the rest of the entities on the map        // precache and static commands can be issued during        // map initialization        sv.state = Defines.ss_loading;        Globals.server_state = sv.state;        // load and spawn all other entities        GameSpawn.SpawnEntities(sv.name, CM.CM_EntityString(), spawnpoint);        // run two frames to allow everything to settle        GameBase.G_RunFrame();        GameBase.G_RunFrame();        // all precaches are complete        sv.state = serverstate;        Globals.server_state = sv.state;        // create a baseline for more efficient communications        SV_CreateBaseline();        // check for a savegame        SV_CheckForSavegame();        // set serverinfo variable        Cvar.FullSet("mapname", sv.name, Defines.CVAR_SERVERINFO                | Defines.CVAR_NOSET);    }    /**     * SV_InitGame.     *      * A brand new game has been started.     */    public static void SV_InitGame() {        int i;        edict_t ent;        //char idmaster[32];        String idmaster;        if (svs.initialized) {            // cause any connected clients to reconnect            SV_MAIN.SV_Shutdown("Server restarted\n", true);        } else {            // make sure the client is down            CL.Drop();            SCR.BeginLoadingPlaque();        }        // get any latched variable changes (maxclients, etc)        Cvar.GetLatchedVars();        svs.initialized = true;        if (Cvar.VariableValue("coop") != 0                && Cvar.VariableValue("deathmatch") != 0) {            Com.Printf("Deathmatch and Coop both set, disabling Coop\n");            Cvar.FullSet("coop", "0", Defines.CVAR_SERVERINFO                    | Defines.CVAR_LATCH);        }        // dedicated servers are can't be single player and are usually DM        // so unless they explicity set coop, force it to deathmatch        if (Globals.dedicated.value != 0) {            if (0 == Cvar.VariableValue("coop"))                Cvar.FullSet("deathmatch", "1", Defines.CVAR_SERVERINFO                        | Defines.CVAR_LATCH);        }        // init clients        if (Cvar.VariableValue("deathmatch") != 0) {            if (SV_MAIN.maxclients.value <= 1)                Cvar.FullSet("maxclients", "8", Defines.CVAR_SERVERINFO                        | Defines.CVAR_LATCH);            else if (SV_MAIN.maxclients.value > Defines.MAX_CLIENTS)                Cvar.FullSet("maxclients", "" + Defines.MAX_CLIENTS,                        Defines.CVAR_SERVERINFO | Defines.CVAR_LATCH);        } else if (Cvar.VariableValue("coop") != 0) {            if (SV_MAIN.maxclients.value <= 1 || SV_MAIN.maxclients.value > 4)                Cvar.FullSet("maxclients", "4", Defines.CVAR_SERVERINFO                        | Defines.CVAR_LATCH);        } else // non-deathmatch, non-coop is one player        {            Cvar.FullSet("maxclients", "1", Defines.CVAR_SERVERINFO                    | Defines.CVAR_LATCH);        }        svs.spawncount = Lib.rand();                svs.clients = new client_t[(int) SV_MAIN.maxclients.value];        for (int n = 0; n < svs.clients.length; n++) {            svs.clients[n] = new client_t();            svs.clients[n].serverindex = n;        }        svs.num_client_entities = ((int) SV_MAIN.maxclients.value)                * Defines.UPDATE_BACKUP * 64; //ok.        svs.client_entities = new entity_state_t[svs.num_client_entities];        for (int n = 0; n < svs.client_entities.length; n++)            svs.client_entities[n] = new entity_state_t(null);        // init network stuff        NET.Config((SV_MAIN.maxclients.value > 1));        // heartbeats will always be sent to the id master        svs.last_heartbeat = -99999; // send immediately        idmaster = "192.246.40.37:" + Defines.PORT_MASTER;        NET.StringToAdr(idmaster, SV_MAIN.master_adr[0]);        // init game        SV_GAME.SV_InitGameProgs();        for (i = 0; i < SV_MAIN.maxclients.value; i++) {            ent = GameBase.g_edicts[i + 1];            svs.clients[i].edict = ent;            svs.clients[i].lastcmd = new usercmd_t();        }    }    private static String firstmap = "";        /**     * SV_Map     *      * the full syntax is:     *      * map [*] <map>$ <startspot>+ <nextserver>     *      * command from the console or progs. Map can also be a.cin, .pcx, or .dm2 file.     *      * Nextserver is used to allow a cinematic to play, then proceed to     * another level:     *      * map tram.cin+jail_e3     */    public static void SV_Map(boolean attractloop, String levelstring, boolean loadgame) {        int l;        String level, ch, spawnpoint;        sv.loadgame = loadgame;        sv.attractloop = attractloop;        if (sv.state == Defines.ss_dead && !sv.loadgame)            SV_InitGame(); // the game is just starting        level = levelstring; // bis hier her ok.        // if there is a + in the map, set nextserver to the remainder        int c = level.indexOf('+');        if (c != -1) {            Cvar.Set("nextserver", "gamemap \"" + level.substring(c + 1) + "\"");            level = level.substring(0, c);        } else {            Cvar.Set("nextserver", "");        }                // rst: base1 works for full, damo1 works for demo, so we need to store first map.        if (firstmap.length() == 0)        {                	if (!levelstring.endsWith(".cin") && !levelstring.endsWith(".pcx") && !levelstring.endsWith(".dm2"))        	{        		int pos = levelstring.indexOf('+');        		firstmap = levelstring.substring(pos + 1);        	}        }        // ZOID: special hack for end game screen in coop mode        if (Cvar.VariableValue("coop") != 0 && level.equals("victory.pcx"))            Cvar.Set("nextserver", "gamemap \"*" + firstmap + "\"");        // if there is a $, use the remainder as a spawnpoint        int pos = level.indexOf('$');        if (pos != -1) {            spawnpoint = level.substring(pos + 1);            level = level.substring(0, pos);        } else            spawnpoint = "";        // skip the end-of-unit flag * if necessary        if (level.charAt(0) == '*')            level = level.substring(1);        l = level.length();        if (l > 4 && level.endsWith(".cin")) {            SCR.BeginLoadingPlaque(); // for local system            SV_SEND.SV_BroadcastCommand("changing\n");            SV_SpawnServer(level, spawnpoint, Defines.ss_cinematic,                    attractloop, loadgame);        } else if (l > 4 && level.endsWith(".dm2")) {            SCR.BeginLoadingPlaque(); // for local system            SV_SEND.SV_BroadcastCommand("changing\n");            SV_SpawnServer(level, spawnpoint, Defines.ss_demo, attractloop,                    loadgame);        } else if (l > 4 && level.endsWith(".pcx")) {            SCR.BeginLoadingPlaque(); // for local system            SV_SEND.SV_BroadcastCommand("changing\n");            SV_SpawnServer(level, spawnpoint, Defines.ss_pic, attractloop,                    loadgame);        } else {            SCR.BeginLoadingPlaque(); // for local system            SV_SEND.SV_BroadcastCommand("changing\n");            SV_SEND.SV_SendClientMessages();            SV_SpawnServer(level, spawnpoint, Defines.ss_game, attractloop,                    loadgame);            Cbuf.CopyToDefer();        }        SV_SEND.SV_BroadcastCommand("reconnect\n");    }    public static server_static_t svs = new server_static_t(); // persistant                                                               // server info    public static server_t sv = new server_t(); // local server}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -