public static void Initialize(int port) { _socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); bool bound = false; while (!bound) { try { _socket.Bind(new IPEndPoint(IPAddress.Any, port)); bound = true; } catch (SocketException e) { if (e.SocketErrorCode == SocketError.AddressAlreadyInUse) { port++; } else { throw e; } } } Log.Write(LogLevel.Info, "Listening on port {0}", port); _socket.Blocking = false; _receiveQueue = new List <NetPacket>(); _sendQueue = new List <NetPacket>(); net_forceLatency = ConVar.Register("net_forceLatency", 0, "Force network packets to be sent/arrive with latency.", ConVarFlags.None); }
public static void Initialize(GraphicsDevice device) { _pointEffect = EffectManager.Load("PointLight", device); _dirAmbEffect = EffectManager.Load("Ambient", device); _halfPixel = new Vector2(0.5f / (float)device.PresentationParameters.BackBufferWidth, 0.5f / (float)device.PresentationParameters.BackBufferHeight); r_sunIntensity = ConVar.Register("r_sunIntensity", 1.6f, "Sun intensity, duh.", ConVarFlags.Archived); }
public static void Initialize() { MainCamera = new PerspectiveCamera(MathHelper.ToRadians(30.0f), 1280f / 720f, 1.0f, 50.0f); MainCamera.Position = new Vector3(72.0f, -190.0f, 12.0f); FOV = ConVar.Register("FOV", 30.0f, "The field of view in degrees", ConVarFlags.Cheat); // TODO: dynamically obtain aspect ratio/FOV //ProjectionMatrix = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(30f), 1280f / 720f, 1.0f, 50.0f); }
public static void Initialize(GraphicsDevice device) { // register convar r_hdr_enable = ConVar.Register("r_hdr_enable", true, "Enable high dynamic range rendering.", ConVarFlags.Archived); // create render targets int width = device.PresentationParameters.BackBufferWidth; int height = device.PresentationParameters.BackBufferHeight; _colorRT = new RenderTarget2D(device, width, height, false, SurfaceFormat.Color, DepthFormat.Depth16); _depthRT = new RenderTarget2D(device, width, height, false, SurfaceFormat.Single, DepthFormat.Depth16); _normalRT = new RenderTarget2D(device, width, height, false, SurfaceFormat.Color, DepthFormat.Depth16); _lightRT = new RenderTarget2D(device, width, height, false, (r_hdr_enable.GetValue <bool>()) ? SurfaceFormat.Rgba1010102 : SurfaceFormat.Color, DepthFormat.Depth16); if (r_hdr_enable.GetValue <bool>()) { _hdrRT = new RenderTarget2D(device, width, height, false, SurfaceFormat.Rgba1010102, DepthFormat.None); _hdrBloomRT = new RenderTarget2D(device, width, height, false, SurfaceFormat.Rgba1010102, DepthFormat.None); int sampleEntries = 1; int startSize = Math.Min(width / 16, height / 16); int size = 16; for (size = 16; size < startSize; size *= 4) { sampleEntries++; } _lightDownsampleRTs = new RenderTarget2D[sampleEntries]; size /= 4; for (int i = 0; i < sampleEntries; i++) { _lightDownsampleRTs[i] = new RenderTarget2D(device, size, size, false, SurfaceFormat.Single, DepthFormat.None); size /= 4; } _avgLightRT = new RenderTarget2D(device, 1, 1, false, SurfaceFormat.Single, DepthFormat.None); } // load shaders _baseEffect = EffectManager.Load("BaseDraw", device); _compositeEffect = EffectManager.Load("ScreenComposite", device); _bloomEffect = EffectManager.Load("Bloom", device); _lightnessEffect = EffectManager.Load("Lightness", device); // light renderer LightRenderer.Initialize(device); // shadow renderer ShadowRenderer.Initialize(device); }
public static void Initialize() { cl_maxpackets = ConVar.Register("cl_maxpackets", 33, "", ConVarFlags.Archived); // FIXME: interpolation only works at server frame time cl_snapDelay = ConVar.Register("cl_snapDelay", 50, "Amount of time to delay the rendering by", ConVarFlags.Archived); _serverChannel = new NetChannel(NetChannelType.ClientToServer, NetAddress.Loopback); //_entities = new Entity[4096]; InitializeConnection(); State = ClientState.Idle; }
/// <summary> /// Global server initialization code /// </summary> public static void Initialize() { // temp stuff to keep in sync with client using Game.Time //_serverTime = Game.Time; ConVar.Register("sv_gravity", 0.5f, "Gravitational value", ConVarFlags.None); _clients = new ServerClient[24]; _rng = new Random(); // testing stuff: add local client //_clients[0] = new ServerClient(); //_clients[0].Channel = new NetChannel(NetChannelType.ServerToClient, NetAddress.Loopback); //_clients[0].Name = "me"; }
public static void Initialize(GraphicsDevice device) { _shadowEffect = EffectManager.Load("Shadow", device); _shadowMap = new RenderTarget2D(device, 2048, 2048, false, SurfaceFormat.Single, DepthFormat.Depth16); _shadowOcclusion = new RenderTarget2D(device, device.PresentationParameters.BackBufferWidth, device.PresentationParameters.BackBufferHeight, false, SurfaceFormat.Color, DepthFormat.None); _disabledShadowOcclusion = new RenderTarget2D(device, 1, 1, false, SurfaceFormat.Color, DepthFormat.None); shadowOcclusionTechniques[0] = _shadowEffect.Techniques["CreateShadowTerm2x2PCF"]; /*shadowOcclusionTechniques[1] = _shadowEffect.Techniques["CreateShadowTerm3x3PCF"]; * shadowOcclusionTechniques[2] = _shadowEffect.Techniques["CreateShadowTerm5x5PCF"]; * shadowOcclusionTechniques[3] = _shadowEffect.Techniques["CreateShadowTerm7x7PCF"];*/ _frustumCornersVS = new Vector3[8]; _frustumCornersWS = new Vector3[8]; _frustumCornersLS = new Vector3[8]; _farFrustumCornersVS = new Vector3[4]; sm_enable = ConVar.Register("sm_enable", true, "Enable shadow mapping", ConVarFlags.Archived); sm_filterType = ConVar.Register("sm_filterType", 0, "Defines the filtering algorithm to use for shadow mapping", ConVarFlags.Archived); }
public static void Initialize() { ConVar.Register("cheats", false, "Enable cheats", ConVarFlags.None); }
public static void Initialize() { // set the current culture to the invariant culture Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; // initialize the logging service Log.Initialize(LogLevel.All); Log.AddListener(new ConsoleLogListener()); Log.AddListener(new GameLogListener()); Log.AddListener(new FileLogListener("GBHGame.log", false)); Log.Write(LogLevel.Info, "GBH2 v0 initializing"); Log.Write(LogLevel.Critical, "jeremych is an egghead and a nabsalad"); ConVar.Initialize(); FileSystem.Initialize(); Win32System.Initialize(); MapGeometry.Initialize(); //StyleManager.Load("Styles/bil.sty"); //MapManager.Load("Maps/MP1-comp.gmp"); Camera.Initialize(); NetManager.Initialize(29960); Client.Initialize(); Server.Initialize(); GameWindow.Initialize(); com_maxFPS = ConVar.Register("com_maxFPS", 0, "Maximum framerate for the game loop.", ConVarFlags.Archived); timescale = ConVar.Register("timescale", 1.0f, "Scale time by this amount", ConVarFlags.Cheat); sv_running = ConVar.Register("sv_running", true, "Is the server running?", ConVarFlags.ReadOnly); cl_running = ConVar.Register("cl_running", false, "Is the client running?", ConVarFlags.ReadOnly); sv_paused = ConVar.Register("sv_paused", false, "Is the server paused?", ConVarFlags.ReadOnly); cl_paused = ConVar.Register("cl_paused", false, "Is the client paused?", ConVarFlags.ReadOnly); net_showpackets = ConVar.Register("net_showpackets", false, "Show network packets.", ConVarFlags.None); mapname = ConVar.Register("mapname", "", "Current mapname", ConVarFlags.ReadOnly); nickname = ConVar.Register("nickname", Environment.GetEnvironmentVariable("username"), "Your nickname", ConVarFlags.Archived); Renderer.Initialize(); MaterialManager.ReadMaterialFile("base.material"); MaterialManager.ReadMaterialFile("Styles/bil.material"); ConsoleRenderer.Initialize(); //StyleManager.CreateTextures(Renderer.Device); MapRenderer.Initialize(Renderer.Device); DeferredRenderer.Initialize(Renderer.Device); Renderer2D.Initialize(Renderer.Device); // jeez, people these days just need to get a *proper* nickname if (ConVar.GetValue <string>("nicknamee") == Environment.GetEnvironmentVariable("username")) { Log.Write(LogLevel.Info, "It looks it's your first time running GBH2. Please type 'nickname <WANTED NICKNAME>' to set your nickname."); } var path = Directory.GetCurrentDirectory() + "\\config.ini"; IniFile ini = new IniFile(path); var value = ini.IniReadValue("CONFIG", "nickname"); if (value != null) { ConVar.SetValue <string>("nicknamee", value); } }