From: Rene S. <sa...@us...> - 2004-09-22 19:22:55
|
Update of /cvsroot/jake2/jake2/src/jake2/server In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11556/src/jake2/server Modified Files: SV_INIT.java SV.java SV_SEND.java SV_WORLD.java SV_GAME.java server_t.java server_static_t.java SV_CCMDS.java SV_ENTS.java SV_USER.java SV_MAIN.java Log Message: major refactoring in game, server and client package Index: SV_WORLD.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/server/SV_WORLD.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** SV_WORLD.java 29 Aug 2004 21:39:25 -0000 1.6 --- SV_WORLD.java 22 Sep 2004 19:22:12 -0000 1.7 *************** *** 1,682 **** /* ! Copyright (C) 1997-2001 Id Software, Inc. ! ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License ! as published by the Free Software Foundation; either version 2 ! of the License, or (at your option) any later version. ! ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of [...1182 lines suppressed...] ! clip.trace.ent = GameBase.g_edicts[0]; ! if (clip.trace.fraction == 0) ! return clip.trace; // blocked by the world ! clip.contentmask = contentmask; ! clip.start = start; ! clip.end = end; ! clip.mins = mins; ! clip.maxs = maxs; ! clip.passedict = passedict; ! Math3D.VectorCopy(mins, clip.mins2); ! Math3D.VectorCopy(maxs, clip.maxs2); ! // create the bounding box of the entire move ! SV_TraceBounds(start, clip.mins2, clip.maxs2, end, clip.boxmins, ! clip.boxmaxs); ! // clip to other solid entities ! SV_ClipMoveToEntities(clip); ! return clip.trace; ! } ! } \ No newline at end of file Index: SV_MAIN.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/server/SV_MAIN.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** SV_MAIN.java 10 Sep 2004 19:02:56 -0000 1.7 --- SV_MAIN.java 22 Sep 2004 19:22:12 -0000 1.8 *************** *** 1,31 **** /* ! Copyright (C) 1997-2001 Id Software, Inc. ! ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License ! as published by the Free Software Foundation; either version 2 ! of the License, or (at your option) any later version. ! ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of [...2031 lines suppressed...] ! SV_INIT.sv.demofile.close(); ! } catch (IOException e) { ! e.printStackTrace(); ! } ! ! SV_INIT.sv = new server_t(); ! ! Globals.server_state = SV_INIT.sv.state; ! ! if (SV_INIT.svs.demofile != null) ! try { ! SV_INIT.svs.demofile.close(); ! } catch (IOException e1) { ! e1.printStackTrace(); ! } ! ! SV_INIT.svs = new server_static_t(); ! } ! } \ No newline at end of file Index: SV_INIT.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/server/SV_INIT.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** SV_INIT.java 29 Aug 2004 21:39:25 -0000 1.8 --- SV_INIT.java 22 Sep 2004 19:22:12 -0000 1.9 *************** *** 1,27 **** /* ! Copyright (C) 1997-2001 Id Software, Inc. ! ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License ! as published by the Free Software Foundation; either version 2 ! of the License, or (at your option) any later version. ! ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of [...963 lines suppressed...] ! 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 ! } \ No newline at end of file Index: server_t.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/server/server_t.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** server_t.java 7 Jul 2004 19:59:51 -0000 1.1.1.1 --- server_t.java 22 Sep 2004 19:22:12 -0000 1.2 *************** *** 1,76 **** /* ! Copyright (C) 1997-2001 Id Software, Inc. ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License ! as published by the Free Software Foundation; either version 2 ! of the License, or (at your option) any later version. ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ! See the GNU General Public License for more details. ! You should have received a copy of the GNU General Public License ! along with this program; if not, write to the Free Software ! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ! */ ! // Created on 14.01.2004 by RST. ! // $Id$ ! package jake2.server; ! import java.io.File; ! import java.io.RandomAccessFile; ! import jake2.*; ! import jake2.client.*; ! import jake2.game.*; ! import jake2.qcommon.*; ! import jake2.render.*; ! public class server_t { ! public server_t() { ! models = new cmodel_t[Defines.MAX_MODELS]; ! for (int n = 0; n < Defines.MAX_MODELS; n++) ! models[n] = new cmodel_t(); ! ! for (int n=0; n < Defines.MAX_EDICTS; n++) ! baselines[n] = new entity_state_t(null); ! ! //for (int n=0; n < Defines.MAX_CONFIGSTRINGS; n++) ! //configstrings[n] = ""; ! } ! //server_state_t state; ! int state; // precache commands are only valid during load ! boolean attractloop; // running cinematics and demos for the local system only ! boolean loadgame; // client begins should reuse existing entity ! int time; // always sv.framenum * 100 msec ! int framenum; ! //char name[MAX_QPATH]; ! String name = ""; // map name, or cinematic name ! //struct cmodel_s *models[MAX_MODELS]; ! cmodel_t models[]; ! //char configstrings[MAX_CONFIGSTRINGS][MAX_QPATH]; ! String configstrings[] = new String[Defines.MAX_CONFIGSTRINGS]; ! entity_state_t baselines[] = new entity_state_t[Defines.MAX_EDICTS]; ! // the multicast buffer is used to send a message to a set of clients ! // it is only used to marshall data until SV_Multicast is called ! sizebuf_t multicast = new sizebuf_t(); ! byte multicast_buf[] = new byte[Defines.MAX_MSGLEN]; ! // demo server information ! RandomAccessFile demofile; ! boolean timedemo; // don't time sync ! } --- 1,72 ---- /* ! * Copyright (C) 1997-2001 Id Software, Inc. ! * ! * This program is free software; you can redistribute it and/or modify it under ! * the terms of the GNU General Public License as published by the Free Software ! * Foundation; either version 2 of the License, or (at your option) any later ! * version. ! * ! * This program is distributed in the hope that it will be useful, but WITHOUT ! * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS ! * FOR A PARTICULAR PURPOSE. ! * ! * See the GNU General Public License for more details. ! * ! * You should have received a copy of the GNU General Public License along with ! * this program; if not, write to the Free Software Foundation, Inc., 59 Temple ! * Place - Suite 330, Boston, MA 02111-1307, USA. ! * ! */ ! // Created on 14.01.2004 by RST. ! // $Id$ ! package jake2.server; ! import jake2.Defines; ! import jake2.game.cmodel_t; ! import jake2.game.entity_state_t; ! import jake2.qcommon.sizebuf_t; ! import java.io.RandomAccessFile; ! public class server_t { ! public server_t() { ! models = new cmodel_t[Defines.MAX_MODELS]; ! for (int n = 0; n < Defines.MAX_MODELS; n++) ! models[n] = new cmodel_t(); ! for (int n = 0; n < Defines.MAX_EDICTS; n++) ! baselines[n] = new entity_state_t(null); ! } ! int state; // precache commands are only valid during load ! boolean attractloop; // running cinematics and demos for the local system ! // only ! boolean loadgame; // client begins should reuse existing entity ! int time; // always sv.framenum * 100 msec ! int framenum; ! String name = ""; // map name, or cinematic name ! cmodel_t models[]; ! String configstrings[] = new String[Defines.MAX_CONFIGSTRINGS]; ! entity_state_t baselines[] = new entity_state_t[Defines.MAX_EDICTS]; ! // the multicast buffer is used to send a message to a set of clients ! // it is only used to marshall data until SV_Multicast is called ! sizebuf_t multicast = new sizebuf_t(); ! byte multicast_buf[] = new byte[Defines.MAX_MSGLEN]; ! // demo server information ! RandomAccessFile demofile; ! boolean timedemo; // don't time sync ! } \ No newline at end of file Index: SV.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/server/SV.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** SV.java 29 Aug 2004 21:39:25 -0000 1.9 --- SV.java 22 Sep 2004 19:22:12 -0000 1.10 *************** *** 6,32 **** */ /* ! Copyright (C) 1997-2001 Id Software, Inc. ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License ! as published by the Free Software Foundation; either version 2 ! of the License, or (at your option) any later version. ! This program is distributed in the hope that it will be useful, [...2301 lines suppressed...] ! } ! /* ! * ====================== SV_CloseEnough ! * ! * ====================== ! *///ok ! public static boolean SV_CloseEnough(edict_t ent, edict_t goal, float dist) { ! int i; ! for (i = 0; i < 3; i++) { ! if (goal.absmin[i] > ent.absmax[i] + dist) ! return false; ! if (goal.absmax[i] < ent.absmin[i] - dist) ! return false; ! } ! return true; ! } ! } \ No newline at end of file Index: SV_CCMDS.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/server/SV_CCMDS.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** SV_CCMDS.java 10 Sep 2004 19:02:56 -0000 1.11 --- SV_CCMDS.java 22 Sep 2004 19:22:12 -0000 1.12 *************** *** 24,39 **** package jake2.server; import jake2.Globals; ! import jake2.game.*; ! import jake2.qcommon.*; import jake2.sys.NET; import jake2.sys.Sys; import jake2.util.QuakeFile; import jake2.util.Vargs; [...1357 lines suppressed...] *************** *** 1095,1099 **** }); ! if (dedicated.value != 0) Cmd.AddCommand("say", new xcommand_t() { public void execute() { --- 1088,1092 ---- }); ! if (Globals.dedicated.value != 0) Cmd.AddCommand("say", new xcommand_t() { public void execute() { *************** *** 1136,1139 **** }); } - } --- 1129,1131 ---- Index: SV_ENTS.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/server/SV_ENTS.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** SV_ENTS.java 29 Aug 2004 21:39:25 -0000 1.4 --- SV_ENTS.java 22 Sep 2004 19:22:12 -0000 1.5 *************** *** 1,603 **** /* ! Copyright (C) 1997-2001 Id Software, Inc. ! ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License ! as published by the Free Software Foundation; either version 2 ! of the License, or (at your option) any later version. ! ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of [...1195 lines suppressed...] ! // now add the accumulated multicast information ! SZ.Write(buf, SV_INIT.svs.demo_multicast.data, ! SV_INIT.svs.demo_multicast.cursize); ! SZ.Clear(SV_INIT.svs.demo_multicast); ! // now write the entire message to the file, prefixed by the length ! len = EndianHandler.swapInt(buf.cursize); ! ! try { ! //fwrite (len, 4, 1, svs.demofile); ! SV_INIT.svs.demofile.writeInt(len); ! //fwrite (buf.data, buf.cursize, 1, svs.demofile); ! SV_INIT.svs.demofile.write(buf.data, 0, buf.cursize); ! } catch (IOException e1) { ! Com.Printf("Error writing demo file:" + e); ! } ! } ! } \ No newline at end of file Index: server_static_t.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/server/server_static_t.java,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** server_static_t.java 7 Jul 2004 19:59:51 -0000 1.1.1.1 --- server_static_t.java 22 Sep 2004 19:22:12 -0000 1.2 *************** *** 1,65 **** /* ! Copyright (C) 1997-2001 Id Software, Inc. ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License ! as published by the Free Software Foundation; either version 2 ! of the License, or (at your option) any later version. ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ! See the GNU General Public License for more details. ! You should have received a copy of the GNU General Public License ! along with this program; if not, write to the Free Software ! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ! */ ! // Created on 14.01.2004 by RST. ! // $Id$ ! package jake2.server; ! import jake2.*; ! import jake2.client.*; ! import jake2.game.*; ! import jake2.qcommon.*; ! import jake2.render.*; ! import jake2.server.*; ! import java.io.*; ! public class server_static_t { ! public server_static_t() { ! for (int n = 0; n < Defines.MAX_CHALLENGES; n++) { ! challenges[n] = new challenge_t(); ! } ! } ! boolean initialized; // sv_init has completed ! int realtime; // always increasing, no clamping, etc ! //char mapcmd[MAX_TOKEN_CHARS]; // ie: *intro.cin+base ! String mapcmd = ""; // ie: *intro.cin+base ! int spawncount; // incremented each server start ! // used to check late spawns ! client_t clients[]; // [maxclients->value]; ! int num_client_entities; // maxclients->value*UPDATE_BACKUP*MAX_PACKET_ENTITIES ! int next_client_entities; // next client_entity to use ! entity_state_t client_entities[]; // [num_client_entities] ! int last_heartbeat; ! challenge_t challenges[] = new challenge_t[Defines.MAX_CHALLENGES]; // to prevent invalid IPs from connecting ! // serverrecord values ! RandomAccessFile demofile; ! sizebuf_t demo_multicast = new sizebuf_t(); ! byte demo_multicast_buf[] = new byte[Defines.MAX_MSGLEN]; ! } --- 1,71 ---- /* ! * Copyright (C) 1997-2001 Id Software, Inc. ! * ! * This program is free software; you can redistribute it and/or modify it under ! * the terms of the GNU General Public License as published by the Free Software ! * Foundation; either version 2 of the License, or (at your option) any later ! * version. ! * ! * This program is distributed in the hope that it will be useful, but WITHOUT ! * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS ! * FOR A PARTICULAR PURPOSE. ! * ! * See the GNU General Public License for more details. ! * ! * You should have received a copy of the GNU General Public License along with ! * this program; if not, write to the Free Software Foundation, Inc., 59 Temple ! * Place - Suite 330, Boston, MA 02111-1307, USA. ! * ! */ ! // Created on 14.01.2004 by RST. ! // $Id$ ! package jake2.server; ! import jake2.Defines; ! import jake2.game.entity_state_t; ! import jake2.qcommon.sizebuf_t; ! import java.io.RandomAccessFile; ! public class server_static_t { ! public server_static_t() { ! for (int n = 0; n < Defines.MAX_CHALLENGES; n++) { ! challenges[n] = new challenge_t(); ! } ! } ! boolean initialized; // sv_init has completed ! int realtime; // always increasing, no clamping, etc ! String mapcmd = ""; // ie: *intro.cin+base ! int spawncount; // incremented each server start ! // used to check late spawns ! client_t clients[]; // [maxclients->value]; ! int num_client_entities; // maxclients->value*UPDATE_BACKUP*MAX_PACKET_ENTITIES ! int next_client_entities; // next client_entity to use ! entity_state_t client_entities[]; // [num_client_entities] ! int last_heartbeat; ! challenge_t challenges[] = new challenge_t[Defines.MAX_CHALLENGES]; // to ! // prevent ! // invalid ! // IPs ! // from ! // connecting ! // serverrecord values ! RandomAccessFile demofile; ! sizebuf_t demo_multicast = new sizebuf_t(); ! byte demo_multicast_buf[] = new byte[Defines.MAX_MSGLEN]; ! } \ No newline at end of file Index: SV_SEND.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/server/SV_SEND.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** SV_SEND.java 10 Sep 2004 19:02:56 -0000 1.5 --- SV_SEND.java 22 Sep 2004 19:22:12 -0000 1.6 *************** *** 31,36 **** import jake2.qcommon.*; import jake2.render.*; ! public class SV_SEND extends SV_MAIN { /* ============================================================================= --- 31,37 ---- import jake2.qcommon.*; import jake2.render.*; + import jake2.util.Math3D; ! public class SV_SEND { /* ============================================================================= *************** *** 41,58 **** */ ! public static byte sv_outputbuf[]= new byte[SV_OUTPUTBUF_LENGTH]; public static void SV_FlushRedirect(int sv_redirected, byte outputbuf[]) { ! if (sv_redirected == RD_PACKET) { ! String s= ("print\n" + outputbuf); ! Netchan.Netchan_OutOfBand(NS_SERVER, Netchan.net_from, s.length(), s.getBytes()); } ! else if (sv_redirected == RD_CLIENT) { ! MSG.WriteByte(SV_MAIN.sv_client.netchan.message, svc_print); ! MSG.WriteByte(SV_MAIN.sv_client.netchan.message, PRINT_HIGH); MSG.WriteString(SV_MAIN.sv_client.netchan.message, outputbuf); ! } } - /* ============================================================================= --- 42,58 ---- */ ! public static byte sv_outputbuf[] = new byte[Defines.SV_OUTPUTBUF_LENGTH]; public static void SV_FlushRedirect(int sv_redirected, byte outputbuf[]) { ! if (sv_redirected == Defines.RD_PACKET) { ! String s = ("print\n" + outputbuf); ! Netchan.Netchan_OutOfBand(Defines.NS_SERVER, Globals.net_from, s.length(), s.getBytes()); } ! else if (sv_redirected == Defines.RD_CLIENT) { ! MSG.WriteByte(SV_MAIN.sv_client.netchan.message, Defines.svc_print); ! MSG.WriteByte(SV_MAIN.sv_client.netchan.message, Defines.PRINT_HIGH); MSG.WriteString(SV_MAIN.sv_client.netchan.message, outputbuf); ! } } /* ============================================================================= *************** *** 75,83 **** return; ! MSG.WriteByte(cl.netchan.message, svc_print); MSG.WriteByte(cl.netchan.message, level); MSG.WriteString(cl.netchan.message, s); } - /* ================= --- 75,82 ---- return; ! MSG.WriteByte(cl.netchan.message, Defines.svc_print); MSG.WriteByte(cl.netchan.message, level); MSG.WriteString(cl.netchan.message, s); } /* ================= *************** *** 92,112 **** // echo to console ! if (dedicated.value != 0) { Com.Printf(s); } ! for (int i= 0; i < SV_MAIN.maxclients.value; i++) { ! cl= SV_MAIN.svs.clients[i]; if (level < cl.messagelevel) continue; ! if (cl.state != cs_spawned) continue; ! MSG.WriteByte(cl.netchan.message, svc_print); MSG.WriteByte(cl.netchan.message, level); MSG.WriteString(cl.netchan.message, s); } } - /* ================= --- 91,110 ---- // echo to console ! if (Globals.dedicated.value != 0) { Com.Printf(s); } ! for (int i = 0; i < SV_MAIN.maxclients.value; i++) { ! cl = SV_INIT.svs.clients[i]; if (level < cl.messagelevel) continue; ! if (cl.state != Defines.cs_spawned) continue; ! MSG.WriteByte(cl.netchan.message, Defines.svc_print); MSG.WriteByte(cl.netchan.message, level); MSG.WriteString(cl.netchan.message, s); } } /* ================= *************** *** 118,129 **** public static void SV_BroadcastCommand(String s) { ! if (sv.state == 0) return; ! MSG.WriteByte(sv.multicast, svc_stufftext); ! MSG.WriteString(sv.multicast, s); ! SV_Multicast(null, MULTICAST_ALL_R); } - /* ================= --- 116,126 ---- public static void SV_BroadcastCommand(String s) { ! if (SV_INIT.sv.state == 0) return; ! MSG.WriteByte(SV_INIT.sv.multicast, Defines.svc_stufftext); ! MSG.WriteString(SV_INIT.sv.multicast, s); ! SV_Multicast(null, Defines.MULTICAST_ALL_R); } /* ================= *************** *** 146,206 **** int area1, area2; ! reliable= false; ! if (to != MULTICAST_ALL_R && to != MULTICAST_ALL) { ! leafnum= CM.CM_PointLeafnum(origin); ! area1= CM.CM_LeafArea(leafnum); } else { ! leafnum= 0; // just to avoid compiler warnings ! area1= 0; } // if doing a serverrecord, store everything ! if (svs.demofile != null) ! SZ.Write(svs.demo_multicast, sv.multicast.data, sv.multicast.cursize); switch (to) { ! case MULTICAST_ALL_R : ! reliable= true; // intentional fallthrough, no break here ! case MULTICAST_ALL : ! leafnum= 0; ! mask= null; break; ! case MULTICAST_PHS_R : ! reliable= true; // intentional fallthrough ! case MULTICAST_PHS : ! leafnum= CM.CM_PointLeafnum(origin); ! cluster= CM.CM_LeafCluster(leafnum); ! mask= CM.CM_ClusterPHS(cluster); break; ! case MULTICAST_PVS_R : ! reliable= true; // intentional fallthrough ! case MULTICAST_PVS : ! leafnum= CM.CM_PointLeafnum(origin); ! cluster= CM.CM_LeafCluster(leafnum); ! mask= CM.CM_ClusterPVS(cluster); break; default : ! mask= null; ! Com.Error(ERR_FATAL, "SV_Multicast: bad to:" + to + "\n"); } // send the data to all relevent clients ! for (j= 0; j < maxclients.value; j++) { ! client= svs.clients[j]; ! if (client.state == cs_free || client.state == cs_zombie) continue; ! if (client.state != cs_spawned && !reliable) continue; if (mask != null) { ! leafnum= CM.CM_PointLeafnum(client.edict.s.origin); ! cluster= CM.CM_LeafCluster(leafnum); ! area2= CM.CM_LeafArea(leafnum); if (!CM.CM_AreasConnected(area1, area2)) continue; --- 143,203 ---- int area1, area2; ! reliable = false; ! if (to != Defines.MULTICAST_ALL_R && to != Defines.MULTICAST_ALL) { ! leafnum = CM.CM_PointLeafnum(origin); ! area1 = CM.CM_LeafArea(leafnum); } else { ! leafnum = 0; // just to avoid compiler warnings ! area1 = 0; } // if doing a serverrecord, store everything ! if (SV_INIT.svs.demofile != null) ! SZ.Write(SV_INIT.svs.demo_multicast, SV_INIT.sv.multicast.data, SV_INIT.sv.multicast.cursize); switch (to) { ! case Defines.MULTICAST_ALL_R : ! reliable = true; // intentional fallthrough, no break here ! case Defines.MULTICAST_ALL : ! leafnum = 0; ! mask = null; break; ! case Defines.MULTICAST_PHS_R : ! reliable = true; // intentional fallthrough ! case Defines.MULTICAST_PHS : ! leafnum = CM.CM_PointLeafnum(origin); ! cluster = CM.CM_LeafCluster(leafnum); ! mask = CM.CM_ClusterPHS(cluster); break; ! case Defines.MULTICAST_PVS_R : ! reliable = true; // intentional fallthrough ! case Defines.MULTICAST_PVS : ! leafnum = CM.CM_PointLeafnum(origin); ! cluster = CM.CM_LeafCluster(leafnum); ! mask = CM.CM_ClusterPVS(cluster); break; default : ! mask = null; ! Com.Error(Defines.ERR_FATAL, "SV_Multicast: bad to:" + to + "\n"); } // send the data to all relevent clients ! for (j = 0; j < SV_MAIN.maxclients.value; j++) { ! client = SV_INIT.svs.clients[j]; ! if (client.state == Defines.cs_free || client.state == Defines.cs_zombie) continue; ! if (client.state != Defines.cs_spawned && !reliable) continue; if (mask != null) { ! leafnum = CM.CM_PointLeafnum(client.edict.s.origin); ! cluster = CM.CM_LeafCluster(leafnum); ! area2 = CM.CM_LeafArea(leafnum); if (!CM.CM_AreasConnected(area1, area2)) continue; *************** *** 214,225 **** if (reliable) ! SZ.Write(client.netchan.message, sv.multicast.data, sv.multicast.cursize); else ! SZ.Write(client.datagram, sv.multicast.data, sv.multicast.cursize); } ! SZ.Clear(sv.multicast); } - /* ================== --- 211,221 ---- if (reliable) ! SZ.Write(client.netchan.message, SV_INIT.sv.multicast.data, SV_INIT.sv.multicast.cursize); else ! SZ.Write(client.datagram, SV_INIT.sv.multicast.data, SV_INIT.sv.multicast.cursize); } ! SZ.Clear(SV_INIT.sv.multicast); } /* ================== *************** *** 260,271 **** int i; int ent; ! float[] origin_v= { 0, 0, 0 }; boolean use_phs; if (volume < 0 || volume > 1.0) ! Com.Error(ERR_FATAL, "SV_StartSound: volume = " + volume); if (attenuation < 0 || attenuation > 4) ! Com.Error(ERR_FATAL, "SV_StartSound: attenuation = " + attenuation); // if (channel < 0 || channel > 15) --- 256,267 ---- int i; int ent; ! float[] origin_v = { 0, 0, 0 }; boolean use_phs; if (volume < 0 || volume > 1.0) ! Com.Error(Defines.ERR_FATAL, "SV_StartSound: volume = " + volume); if (attenuation < 0 || attenuation > 4) ! Com.Error(Defines.ERR_FATAL, "SV_StartSound: attenuation = " + attenuation); // if (channel < 0 || channel > 15) *************** *** 273,355 **** if (timeofs < 0 || timeofs > 0.255) ! Com.Error(ERR_FATAL, "SV_StartSound: timeofs = " + timeofs); ! ent= entity.index; // no PHS flag if ((channel & 8) != 0) { ! use_phs= false; channel &= 7; } else ! use_phs= true; ! sendchan= (ent << 3) | (channel & 7); ! flags= 0; if (volume != Defines.DEFAULT_SOUND_PACKET_VOLUME) ! flags |= SND_VOLUME; ! if (attenuation != DEFAULT_SOUND_PACKET_ATTENUATION) ! flags |= SND_ATTENUATION; // the client doesn't know that bmodels have weird origins // the origin can also be explicitly set ! if ((entity.svflags & SVF_NOCLIENT) != 0 || (entity.solid == SOLID_BSP) || origin != null) ! flags |= SND_POS; // always send the entity number for channel overrides ! flags |= SND_ENT; if (timeofs != 0) ! flags |= SND_OFFSET; // use the entity origin unless it is a bmodel or explicitly specified if (origin == null) { ! origin= origin_v; ! if (entity.solid == SOLID_BSP) { ! for (i= 0; i < 3; i++) ! origin_v[i]= entity.s.origin[i] + 0.5f * (entity.mins[i] + entity.maxs[i]); } else { ! VectorCopy(entity.s.origin, origin_v); } } ! MSG.WriteByte(sv.multicast, svc_sound); ! MSG.WriteByte(sv.multicast, flags); ! MSG.WriteByte(sv.multicast, soundindex); ! if ((flags & SND_VOLUME) != 0) ! MSG.WriteByte(sv.multicast, volume * 255); ! if ((flags & SND_ATTENUATION) != 0) ! MSG.WriteByte(sv.multicast, attenuation * 64); ! if ((flags & SND_OFFSET) != 0) ! MSG.WriteByte(sv.multicast, timeofs * 1000); ! if ((flags & SND_ENT) != 0) ! MSG.WriteShort(sv.multicast, sendchan); ! if ((flags & SND_POS) != 0) ! MSG.WritePos(sv.multicast, origin); // if the sound doesn't attenuate,send it to everyone // (global radio chatter, voiceovers, etc) ! if (attenuation == ATTN_NONE) ! use_phs= false; ! if ((channel & CHAN_RELIABLE) != 0) { if (use_phs) ! SV_Multicast(origin, MULTICAST_PHS_R); else ! SV_Multicast(origin, MULTICAST_ALL_R); } else { if (use_phs) ! SV_Multicast(origin, MULTICAST_PHS); else ! SV_Multicast(origin, MULTICAST_ALL); } } - /* =============================================================================== --- 269,350 ---- if (timeofs < 0 || timeofs > 0.255) ! Com.Error(Defines.ERR_FATAL, "SV_StartSound: timeofs = " + timeofs); ! ent = entity.index; // no PHS flag if ((channel & 8) != 0) { ! use_phs = false; channel &= 7; } else ! use_phs = true; ! sendchan = (ent << 3) | (channel & 7); ! flags = 0; if (volume != Defines.DEFAULT_SOUND_PACKET_VOLUME) ! flags |= Defines.SND_VOLUME; ! if (attenuation != Defines.DEFAULT_SOUND_PACKET_ATTENUATION) ! flags |= Defines.SND_ATTENUATION; // the client doesn't know that bmodels have weird origins // the origin can also be explicitly set ! if ((entity.svflags & Defines.SVF_NOCLIENT) != 0 || (entity.solid == Defines.SOLID_BSP) || origin != null) ! flags |= Defines.SND_POS; // always send the entity number for channel overrides ! flags |= Defines.SND_ENT; if (timeofs != 0) ! flags |= Defines.SND_OFFSET; // use the entity origin unless it is a bmodel or explicitly specified if (origin == null) { ! origin = origin_v; ! if (entity.solid == Defines.SOLID_BSP) { ! for (i = 0; i < 3; i++) ! origin_v[i] = entity.s.origin[i] + 0.5f * (entity.mins[i] + entity.maxs[i]); } else { ! Math3D.VectorCopy(entity.s.origin, origin_v); } } ! MSG.WriteByte(SV_INIT.sv.multicast, Defines.svc_sound); ! MSG.WriteByte(SV_INIT.sv.multicast, flags); ! MSG.WriteByte(SV_INIT.sv.multicast, soundindex); ! if ((flags & Defines.SND_VOLUME) != 0) ! MSG.WriteByte(SV_INIT.sv.multicast, volume * 255); ! if ((flags & Defines.SND_ATTENUATION) != 0) ! MSG.WriteByte(SV_INIT.sv.multicast, attenuation * 64); ! if ((flags & Defines.SND_OFFSET) != 0) ! MSG.WriteByte(SV_INIT.sv.multicast, timeofs * 1000); ! if ((flags & Defines.SND_ENT) != 0) ! MSG.WriteShort(SV_INIT.sv.multicast, sendchan); ! if ((flags & Defines.SND_POS) != 0) ! MSG.WritePos(SV_INIT.sv.multicast, origin); // if the sound doesn't attenuate,send it to everyone // (global radio chatter, voiceovers, etc) ! if (attenuation == Defines.ATTN_NONE) ! use_phs = false; ! if ((channel & Defines.CHAN_RELIABLE) != 0) { if (use_phs) ! SV_Multicast(origin, Defines.MULTICAST_PHS_R); else ! SV_Multicast(origin, Defines.MULTICAST_ALL_R); } else { if (use_phs) ! SV_Multicast(origin, Defines.MULTICAST_PHS); else ! SV_Multicast(origin, Defines.MULTICAST_ALL); } } /* =============================================================================== *************** *** 366,380 **** */ public static boolean SV_SendClientDatagram(client_t client) { ! byte msg_buf[]= new byte[MAX_MSGLEN]; ! sizebuf_t msg= new sizebuf_t(); SV_ENTS.SV_BuildClientFrame(client); SZ.Init(msg, msg_buf, msg_buf.length); ! msg.allowoverflow= true; // send over all the relevant entity_state_t // and the player_state_t ! SV_CCMDS.SV_WriteFrameToClient(client, msg); // copy the accumulated multicast datagram --- 361,375 ---- */ public static boolean SV_SendClientDatagram(client_t client) { ! byte msg_buf[] = new byte[Defines.MAX_MSGLEN]; ! sizebuf_t msg = new sizebuf_t(); SV_ENTS.SV_BuildClientFrame(client); SZ.Init(msg, msg_buf, msg_buf.length); ! msg.allowoverflow = true; // send over all the relevant entity_state_t // and the player_state_t ! SV_ENTS.SV_WriteFrameToClient(client, msg); // copy the accumulated multicast datagram *************** *** 397,405 **** // record the size for rate estimation ! client.message_size[sv.framenum % RATE_MESSAGES]= msg.cursize; return true; } - /* ================== --- 392,399 ---- // record the size for rate estimation ! client.message_size[SV_INIT.sv.framenum % Defines.RATE_MESSAGES] = msg.cursize; return true; } /* ================== *************** *** 408,423 **** */ public static void SV_DemoCompleted() { ! if (sv.demofile != null) { try { ! sv.demofile.close(); } catch (IOException e) { Com.Printf("IOError closing d9emo fiele:" + e); } ! sv.demofile= null; } ! SV_ENTS.SV_Nextserver(); } - /* ======================= --- 402,416 ---- */ public static void SV_DemoCompleted() { ! if (SV_INIT.sv.demofile != null) { try { ! SV_INIT.sv.demofile.close(); } catch (IOException e) { Com.Printf("IOError closing d9emo fiele:" + e); } ! SV_INIT.sv.demofile = null; } ! SV_USER.SV_Nextserver(); } /* ======================= *************** *** 433,442 **** // never drop over the loopback ! if (c.netchan.remote_address.type == NA_LOOPBACK) return false; ! total= 0; ! for (i= 0; i < RATE_MESSAGES; i++) { total += c.message_size[i]; } --- 426,435 ---- // never drop over the loopback ! if (c.netchan.remote_address.type == Defines.NA_LOOPBACK) return false; ! total = 0; ! for (i = 0; i < Defines.RATE_MESSAGES; i++) { total += c.message_size[i]; } *************** *** 444,448 **** if (total > c.rate) { c.surpressCount++; ! c.message_size[sv.framenum % RATE_MESSAGES]= 0; return true; } --- 437,441 ---- if (total > c.rate) { c.surpressCount++; ! c.message_size[SV_INIT.sv.framenum % Defines.RATE_MESSAGES] = 0; return true; } *************** *** 450,454 **** return false; } - /* ======================= --- 443,446 ---- *************** *** 460,477 **** client_t c; int msglen; ! byte msgbuf[]= new byte[MAX_MSGLEN]; int r; ! msglen= 0; // read the next demo message if needed ! if (sv.state == ss_demo && sv.demofile != null) { ! if (sv_paused.value != 0) ! msglen= 0; else { // get the next message //r = fread (&msglen, 4, 1, sv.demofile); try { ! msglen= EndianHandler.swapInt(sv.demofile.readInt()); } catch (Exception e) { --- 452,469 ---- client_t c; int msglen; ! byte msgbuf[] = new byte[Defines.MAX_MSGLEN]; int r; ! msglen = 0; // read the next demo message if needed ! if (SV_INIT.sv.state == Defines.ss_demo && SV_INIT.sv.demofile != null) { ! if (SV_MAIN.sv_paused.value != 0) ! msglen = 0; else { // get the next message //r = fread (&msglen, 4, 1, sv.demofile); try { ! msglen = EndianHandler.swapInt(SV_INIT.sv.demofile.readInt()); } catch (Exception e) { *************** *** 485,495 **** return; } ! if (msglen > MAX_MSGLEN) ! Com.Error(ERR_DROP, "SV_SendClientMessages: msglen > MAX_MSGLEN"); //r = fread (msgbuf, msglen, 1, sv.demofile); ! r= 0; try { ! r= sv.demofile.read(msgbuf, 0, msglen); } catch (IOException e1) { --- 477,487 ---- return; } ! if (msglen > Defines.MAX_MSGLEN) ! Com.Error(Defines.ERR_DROP, "SV_SendClientMessages: msglen > MAX_MSGLEN"); //r = fread (msgbuf, msglen, 1, sv.demofile); ! r = 0; try { ! r = SV_INIT.sv.demofile.read(msgbuf, 0, msglen); } catch (IOException e1) { *************** *** 504,509 **** // send a message to each connected client ! for (i= 0; i < maxclients.value; i++) { ! c= svs.clients[i]; if (c.state == 0) --- 496,501 ---- // send a message to each connected client ! for (i = 0; i < SV_MAIN.maxclients.value; i++) { ! c = SV_INIT.svs.clients[i]; if (c.state == 0) *************** *** 514,524 **** SZ.Clear(c.netchan.message); SZ.Clear(c.datagram); ! SV_BroadcastPrintf(PRINT_HIGH, c.name + " overflowed\n"); ! SV_DropClient(c); } ! if (sv.state == ss_cinematic || sv.state == ss_demo || sv.state == ss_pic) Netchan.Transmit(c.netchan, msglen, msgbuf); ! else if (c.state == cs_spawned) { // don't overrun bandwidth if (SV_RateDrop(c)) --- 506,518 ---- SZ.Clear(c.netchan.message); SZ.Clear(c.datagram); ! SV_BroadcastPrintf(Defines.PRINT_HIGH, c.name + " overflowed\n"); ! SV_MAIN.SV_DropClient(c); } ! if (SV_INIT.sv.state == Defines.ss_cinematic ! || SV_INIT.sv.state == Defines.ss_demo ! || SV_INIT.sv.state == Defines.ss_pic) Netchan.Transmit(c.netchan, msglen, msgbuf); ! else if (c.state == Defines.cs_spawned) { // don't overrun bandwidth if (SV_RateDrop(c)) Index: SV_USER.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/server/SV_USER.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** SV_USER.java 29 Aug 2004 21:39:25 -0000 1.5 --- SV_USER.java 22 Sep 2004 19:22:12 -0000 1.6 *************** *** 1,735 **** /* ! Copyright (C) 1997-2001 Id Software, Inc. ! ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License ! as published by the Free Software Foundation; either version 2 ! of the License, or (at your option) any later version. ! ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of [...1398 lines suppressed...] ! // copy. ! cl.lastcmd.set(newcmd); ! break; ! ! case Defines.clc_stringcmd: ! s = MSG.ReadString(Globals.net_message); ! ! // malicious users may try using too many string commands ! if (++stringCmdCount < SV_USER.MAX_STRINGCMDS) ! SV_ExecuteUserCommand(s); ! ! if (cl.state == Defines.cs_zombie) ! return; // disconnect command ! break; ! } ! } ! } ! } \ No newline at end of file Index: SV_GAME.java =================================================================== RCS file: /cvsroot/jake2/jake2/src/jake2/server/SV_GAME.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** SV_GAME.java 29 Aug 2004 21:39:25 -0000 1.7 --- SV_GAME.java 22 Sep 2004 19:22:12 -0000 1.8 *************** *** 1,318 **** /* ! Copyright (C) 1997-2001 Id Software, Inc. ! This program is free software; you can redistribute it and/or ! modify it under the terms of the GNU General Public License ! as published by the Free Software Foundation; either version 2 ! of the License, or (at your option) any later version. ! This program is distributed in the hope that it will be useful, ! but WITHOUT ANY WARRANTY; without even the implied warranty of ! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. ! See the GNU General Public License for more details. ! You should have received a copy of the GNU General Public License ! along with this program; if not, write to the Free Software ! Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ! */ ! // Created on 14.01.2004 by RST. ! // $Id$ ! package jake2.server; ! import jake2.game.*; ! import jake2.qcommon.*; ! public class SV_GAME extends SV_INIT { ! /* ! =============== ! PF_Unicast ! ! Sends the contents of the mutlicast buffer to a single client ! =============== ! */ ! public static void PF_Unicast(edict_t ent, boolean reliable) { ! int p; ! client_t client; ! if (ent == null) ! return; ! p = ent.index; ! if (p < 1 || p > SV_MAIN.maxclients.value) ! return; ! client = SV_INIT.svs.clients[p - 1]; ! if (reliable) ! SZ.Write(client.netchan.message, SV_INIT.sv.multicast.data, SV_INIT.sv.multicast.cursize); ! else ! SZ.Write(client.datagram, sv.multicast.data, sv.multicast.cursize); ! SZ.Clear(sv.multicast); ! } ! /* ! =============== ! PF_dprintf ! ! Debug print to server console ! =============== ! */ ! public static void PF_dprintf(String fmt) { ! Com.Printf(fmt); ! } ! /* ! =============== ! PF_cprintf ! ! Print to a single client ! =============== ! */ ! public static void PF_cprintf(edict_t ent, int level, String fmt) { ! int n = 0; ! if (ent != null) { ! n = ent.index; ! if (n < 1 || n > SV_MAIN.maxclients.value) ! Com.Error(ERR_DROP, "cprintf to a non-client"); ! } ! if (ent != null) ! SV_SEND.SV_ClientPrintf(svs.clients[n - 1], level, fmt); ! else ! Com.Printf(fmt); ! } ! /* ! =============== ! PF_centerprintf ! ! centerprint to a single client ! =============== ! */ ! public static void PF_centerprintf(edict_t ent, String fmt) { ! int n; ! n = ent.index; ! if (n < 1 || n > SV_MAIN.maxclients.value) ! return; // Com_Error (ERR_DROP, "centerprintf to a non-client"); ! MSG.WriteByte(sv.multicast, svc_centerprint); ! MSG.WriteString(sv.multicast, fmt); ! PF_Unicast(ent, true); ! } ! /* ! =============== ! PF_error ! ! Abort the server with a game error ! =============== ! */ ! public static void PF_error(String fmt) { ! Com.Error(ERR_DROP, "Game Error: " + fmt); ! } ! public static void PF_error(int level, String fmt) { ! Com.Error(level, fmt); ! } ! /* ! ================= ! PF_setmodel ! ! Also sets mins and maxs for inline bmodels ! ================= ! */ ! public static void PF_setmodel(edict_t ent, String name) { ! int i; ! cmodel_t mod; ! if (name == null) ! Com.Error(ERR_DROP, "PF_setmodel: NULL"); ! i = SV_ModelIndex(name); ! ent.s.modelindex = i; ! // if it is an inline model, get the size information for it ! if (name.startsWith("*")) { ! mod = CM.InlineModel(name); ! VectorCopy(mod.mins, ent.mins); ! VectorCopy(mod.maxs, ent.maxs); ! SV_WORLD.SV_LinkEdict(ent); ! } ! } ! /* ! =============== ! PF_Configstring ! ! =============== ! */ ! public static void PF_Configstring(int index, String val) { ! if (index < 0 || index >= MAX_CONFIGSTRINGS) ! Com.Error(ERR_DROP, "configstring: bad index " + index + "\n"); ! if (val == null) ! val = ""; ! // change the string in sv ! sv.configstrings[index] = val; ! if (sv.state != ss_loading) { // send the update to everyone ! SZ.Clear(sv.multicast); ! MSG.WriteChar(sv.multicast, svc_configstring); ! MSG.WriteShort(sv.multicast, index); ! MSG.WriteString(sv.multicast, val); ! SV_SEND.SV_Multicast(vec3_origin, MULTICAST_ALL_R); ! } ! } ! public static void PF_WriteChar(int c) { ! MSG.WriteChar(sv.multicast, c); ! } ! public static void PF_WriteByte(int c) { ! MSG.WriteByte(sv.multicast, c); ! } ! public static void PF_WriteShort(int c) { ! MSG.WriteShort(sv.multicast, c); ! } ! public static void PF_WriteLong(int c) { ! MSG.WriteLong(sv.multicast, c); ! } ! public static void PF_WriteFloat(float f) { ! MSG.WriteFloat(sv.multicast, f); ! } ! public static void PF_WriteString(String s) { ! MSG.WriteString(sv.multicast, s); ! } ! public static void PF_WritePos(float[] pos) { ! MSG.WritePos(sv.multicast, pos); ! } ! public static void PF_WriteDir(float[] dir) { ! MSG.WriteDir(sv.multicast, dir); ! } ! public static void PF_WriteAngle(float f) { ! MSG.WriteAngle(sv.multicast, f); ! } ! /* ! ================= ! PF_inPVS ! ! Also checks portalareas so that doors block sight ! ================= ! */ ! public static boolean PF_inPVS(float[] p1, float[] p2) { ! int leafnum; ! int cluster; ! int area1, area2; ! byte mask[]; ! leafnum = CM.CM_PointLeafnum(p1); ! cluster = CM.CM_LeafCluster(leafnum); ! area1 = CM.CM_LeafArea(leafnum); ! mask = CM.CM_ClusterPVS(cluster); ! leafnum = CM.CM_PointLeafnum(p2); ! cluster = CM.CM_LeafCluster(leafnum); ! area2 = CM.CM_LeafArea(leafnum); ! // quake2 bugfix ! if (cluster == -1) ! return false; ! if (mask != null && (0 == (mask[cluster >>> 3] & (1 << (cluster & 7))))) ! return false; ! if (!CM.CM_AreasConnected(area1, area2)) ! return false; // a door blocks sight ! return true; ! } ! /* ! ================= ! PF_inPHS ! ! Also checks portalareas so that doors block sound ! ================= ! */ ! public static boolean PF_inPHS(float[] p1, float[] p2) { ! int leafnum; ! int cluster; ! int area1, area2; ! byte mask[]; ! leafnum = CM.CM_PointLeafnum(p1); ! cluster = CM.CM_LeafCluster(leafnum); ! area1 = CM.CM_LeafArea(leafnum); ! mask = CM.CM_ClusterPHS(cluster); ! leafnum = CM.CM_PointLeafnum(p2); ! cluster = CM.CM_LeafCluster(leafnum); ! area2 = CM.CM_LeafArea(leafnum); ! // quake2 bugfix ! if (cluster == -1) ! return false; ! if (mask != null && (0 == (mask[cluster >> 3] & (1 << (cluster & 7))))) ! return false; // more than one bounce away ! if (!CM.CM_AreasConnected(area1, area2)) ! return false; // a door blocks hearing ! return true; ! } ! public static void PF_StartSound(edict_t entity, int channel, int sound_num, float volume, float attenuation, float timeofs) { ! ! if (null == entity) ! return; ! SV_SEND.SV_StartSound (null, entity, channel, sound_num, volume, attenuation, timeofs); ! ! } ! //============================================== ! /* ! =============== ! SV_ShutdownGameProgs ! ! Called when either the entire server is being killed, or ! it is changing to a different game directory. ! =============== ! */ ! public static void SV_ShutdownGameProgs() { ! Game.ShutdownGame(); ! } ! /* ! =============== ! SV_InitGameProgs ! ! Init the game subsystem for a new map ! =============== ! */ ! public static void SV_InitGameProgs() { ! // unload anything we have now ! SV_ShutdownGameProgs(); ! game_import_t gimport = new game_import_t(); ! // all functions set in game_export_t (rst) ! GameBase.GetGameApi(gimport); ! Game.InitGame(); ! } ! } --- 1,313 ---- /* ! * Copyright (C) 1997-2001 Id Software, Inc. ! * ! * This program is free software; you can redistribute it and/or modify it under ! * the terms of the GNU General Public License as published by the Free Software ! * Foundation; either version 2 of the License, or (at your option) any later ! * version. ! * ! * This program is distributed in the hope that it will be useful, but WITHOUT ! * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS ! * FOR A PARTICULAR PURPOSE. ! * ! * See the GNU General Public License for more details. ! * ! * You should have received a copy of the GNU General Public License along with ! * this program; if not, write to the Free Software Foundation, Inc., 59 Temple ! * Place - Suite 330, Boston, MA 02111-1307, USA. ! * ! */ ! // Created on 14.01.2004 by RST. ! // $Id$ ! package jake2.server; ! import jake2.Defines; ! import jake2.Globals; ! import jake2.game.*; ! import jake2.qcommon.*; ! import jake2.util.Math3D; ! public class SV_GAME { ! /* ! * =============== PF_Unicast ! * ! * Sends the contents of the mutlicast buffer to a single client ! * =============== ! */ ! public static void PF_Unicast(edict_t ent, boolean reliable) { ! int p; ! client_t client; ! if (ent == null) ! return; ! p = ent.index; ! if (p < 1 || p > SV_MAIN.maxclients.value) ! return; ! client = SV_INIT.svs.clients[p - 1]; ! if (reliable) ! SZ.Write(client.netchan.message, SV_INIT.sv.multicast.data, ! SV_INIT.sv.multicast.cursize); ! else ! SZ.Write(client.datagram, SV_INIT.sv.multicast.data, ! SV_INIT.sv.multicast.cursize); ! SZ.Clear(SV_INIT.sv.multicast); ! } + /* + * =============== PF_dprintf + * + * Debug print to server console =============== + */ + public static void PF_dprintf(String fmt) { + Com.Printf(fmt); + } ! /* ! * =============== PF_cprintf ! * ! * Print to a single client =============== ! */ ! public static void PF_cprintf(edict_t ent, int level, String fmt) { ! int n = 0; ! if (ent != null) { ! n = ent.index; ! if (n < 1 || n > SV_MAIN.maxclients.value) ! Com.Error(Defines.ERR_DROP, "cprintf to a non-client"); ! } ! if (ent != null) ! SV_SEND.SV_ClientPrintf(SV_INIT.svs.clients[n - 1], level, fmt); ! else ! Com.Printf(fmt); ! } ! /* ! * =============== PF_centerprintf ! * ! * centerprint to a single client =============== ! */ ! public static void PF_centerprintf(edict_t ent, String fmt) { ! int n; ! n = ent.index; ! if (n < 1 || n > SV_MAIN.maxclients.value) ! return; // Com_Error (ERR_DROP, "centerprintf to a non-client"); ! MSG.WriteByte(SV_INIT.sv.multicast, Defines.svc_centerprint); ! MSG.WriteString(SV_INIT.sv.multicast, fmt); ! PF_Unicast(ent, true); ! } ! /* ! * =============== PF_error ! * ! * Abort the server with a game error =============== ! */ ! public static void PF_error(String fmt) { ! Com.Error(Defines.ERR_DROP, "Game Error: " + fmt); ! } ! public static void PF_error(int level, String fmt) { ! Com.Error(level, fmt); ! } ! /* ! * ================= PF_setmodel ! * ! * Also sets mins and maxs for inline bmodels ================= ! */ ! public static void PF_setmodel(edict_t ent, String name) { ! int i; ! cmodel_t mod; ! if (name == null) ! Com.Error(Defines.ERR_DROP, "PF_setmodel: NULL"); ! i = SV_INIT.SV_ModelIndex(name); ! ent.s.modelindex = i; ! // if it is an inline model, get the size information for it ! if (name.startsWith("*")) { ! mod = CM.InlineModel(name); ! Math3D.VectorCopy(mod.mins, ent.mins); ! Math3D.VectorCopy(mod.maxs, ent.maxs); ! SV_WORLD.SV_LinkEdict(ent); ! } ! } ! /* ! * =============== PF_Configstring ! * ! * =============== ! */ ! public static void PF_Configstring(int index, String val) { ! if (index < 0 || index >= Defines.MAX_CONFIGSTRINGS) ! Com.Error(Defines.ERR_DROP, "configstring: bad index " + index ! + "\n"); ! if (val == null) ! val = ""; ! // change the string in sv ! SV_INIT.sv.configstrings[index] = val; ! if (SV_INIT.sv.state != Defines.ss_loading) { // send the update to ! // everyone ! SZ.Clear(SV_INIT.sv.multicast); ! MSG.WriteChar(SV_INIT.sv.multicast, Defines.svc_configstring); ! MSG.WriteShort(SV_INIT.sv.multicast, index); ! MSG.WriteString(SV_INIT.sv.multicast, val); ! SV_SEND.SV_Multicast(Globals.vec3_origin, Defines.MULTICAST_ALL_R); ! } ! } ! public static void PF_WriteChar(int c) { ! MSG.WriteChar(SV_INIT.sv.multicast, c); ! } ! public static void PF_WriteByte(int c) { ! MSG.WriteByte(SV_INIT.sv.multicast, c); ! } ! public static void PF_WriteShort(int c) { ! MSG.WriteShort(SV_INIT.sv.multicast, c); ! } ! public static void PF_WriteLong(int c) { ! MSG.WriteLong(SV_INIT.sv.multicast, c); ! } ! public static void PF_WriteFloat(float f) { ! MSG.WriteFloat(SV_INIT.sv.multicast, f); ! } ! public static void PF_WriteString(String s) { ! MSG.WriteString(SV_INIT.sv.multicast, s); ! } ! public static void PF_WritePos(float[] pos) { ! MSG.WritePos(SV_INIT.sv.multicast, pos); ! } ! public static void PF_WriteDir(float[] dir) { ! MSG.WriteDir(SV_INIT.sv.multicast, dir); ! } ! public static void PF_WriteAngle(float f) { ! MSG.WriteAngle(SV_INIT.sv.multicast, f); ! } ! /* ! * ================= PF_inPVS ! * ! * Also checks portalareas so that doors block sight ================= ! */ ! public static boolean PF_inPVS(float[] p1, float[] p2) { ! int leafnum; ! int cluster; ! int area1, area2; ! byte mask[]; ! leafnum = CM.CM_PointLeafnum(p1); ! cluster = CM.CM_LeafCluster(leafnum); ! area1 = CM.CM_LeafArea(leafnum); ! mask = CM.CM_ClusterPVS(cluster); ! leafnum = CM.CM_PointLeafnum(p2); ! cluster = CM.CM_LeafCluster(leafnum); ! area2 = CM.CM_LeafArea(leafnum); ! // quake2 bugfix ! if (cluster == -1) ! return false; ! if (mask != null && (0 == (mask[cluster >>> 3] & (1 << (cluster & 7))))) ! return false; ! if (!CM.CM_AreasConnected(area1, area2)) ! return false; // a door blocks sight ! return true; ! } ! /* ! * ================= PF_inPHS ! * ! * Also checks portalareas so that doors block sound ================= ! */ ! public static boolean PF_inPHS(float[] p1, float[] p2) { ! int leafnum; ! int cluster; ! int area1, area2; ! byte mask[]; ! leafnum = CM.CM_PointLeafnum(p1); ! cluster = CM.CM_LeafCluster(leafnum); ! area1 = CM.CM_LeafArea(leafnum); ! mask = CM.CM_ClusterPHS(cluster); ! leafnum = CM.CM_PointLeafnum(p2); ! cluster = CM.CM_LeafCluster(leafnum); ! area2 = CM.CM_LeafArea(leafnum); ! // quake2 bugfix ! if (cluster == -1) ! return false; ! if (mask != null && (0 == (mask[cluster >> 3] & (1 << (cluster & 7))))) ! return false; // more than one bounce away ! if (!CM.CM_AreasConnected(area1, area2)) ! return false; // a door blocks hearing ! return true; ! } ! public static void PF_StartSound(edict_t entity, int channel, ! int sound_num, float volume, float attenuation, float timeofs) { ! if (null == entity) ! return; ! SV_SEND.SV_StartSound(null, entity, channel, sound_num, volume, ! attenuation, timeofs); ! } ! //============================================== ! /* ! * =============== SV_ShutdownGameProgs ! * ! * Called when either the entire server is being killed, or it is changing ! * to a different game directory. =============== ! */ ! public static void SV_ShutdownGameProgs() { ! GameBase.ShutdownGame(); ! } ! /* ! * =============== SV_InitGameProgs ! * ! * Init the game subsystem for a new map =============== ! */ ! public static void SV_InitGameProgs() { ! // unload anything we have now ! SV_ShutdownGameProgs(); ! ! game_import_t gimport = new game_import_t(); ! ! // all functions set in game_export_t (rst) ! GameBase.GetGameApi(gimport); ! ! GameSave.InitGame(); ! } ! } \ No newline at end of file |