public static void SV_UserinfoChanged(client_t cl) { String val; Int32 i; PlayerClient.ClientUserinfoChanged(cl.edict, cl.userinfo); cl.name = Info.Info_ValueForKey(cl.userinfo, "name"); val = Info.Info_ValueForKey(cl.userinfo, "rate"); if (val.Length > 0) { i = Lib.Atoi(val); cl.rate = i; if (cl.rate < 100) { cl.rate = 100; } if (cl.rate > 15000) { cl.rate = 15000; } } else { cl.rate = 5000; } val = Info.Info_ValueForKey(cl.userinfo, "msg"); if (val.Length > 0) { cl.messagelevel = Lib.Atoi(val); } }
public static bool StringToAdr(string s, netadr_t a) { if (s.EqualsIgnoreCase("localhost") || s.EqualsIgnoreCase("loopback")) { a.Set(net_local_adr); return(true); } try { String[] address = s.Split(":"); a.ip = IPAddress.Parse(address[0]); a.type = Defines.NA_IP; if (address.Length == 2) { a.port = Lib.Atoi(address[1]); } return(true); } catch (Exception e) { Com.Println(e.Message); return(false); } }
public static void SVC_Info( ) { String string_renamed; Int32 i, count; Int32 version; if (SV_MAIN.maxclients.value == 1) { return; } version = Lib.Atoi(Cmd.Argv(1)); if (version != Defines.PROTOCOL_VERSION) { string_renamed = SV_MAIN.hostname.string_renamed + ": wrong version\\n"; } else { count = 0; for (i = 0; i < SV_MAIN.maxclients.value; i++) { if (SV_INIT.svs.clients[i].state >= Defines.cs_connected) { count++; } } string_renamed = SV_MAIN.hostname.string_renamed + " " + SV_INIT.sv.name + " " + count + "/" + ( Int32 )SV_MAIN.maxclients.value + "\\n"; } Netchan.OutOfBandPrint(Defines.NS_SERVER, Globals.net_from, "info\\n" + string_renamed); }
static Boolean StringToFilter(String s, GameSVCmds.ipfilter_t f) { Byte[] b = new Byte[] { 0, 0, 0, 0 }; Byte[] m = new Byte[] { 0, 0, 0, 0 }; try { StringTokenizer tk = new StringTokenizer(s, ". "); for (var n = 0; n < 4; n++) { tk.MoveNext(); b[n] = ( Byte )Lib.Atoi(tk.Current); if (b[n] != 0) { m[n] = 0; ///-1; } } f.mask = ByteBuffer.Wrap(m).GetInt32(); f.compare = ByteBuffer.Wrap(b).GetInt32(); } catch (Exception e) { GameBase.gi.Cprintf(null, Defines.PRINT_HIGH, "Bad filter address: " + s + "\\n"); return(false); } return(true); }
public static void SV_Nextserver_f( ) { if (Lib.Atoi(Cmd.Argv(1)) != SV_INIT.svs.spawncount) { Com.DPrintf("Nextserver() from wrong level, from " + SV_MAIN.sv_client.name + "\\n"); return; } Com.DPrintf("Nextserver() from " + SV_MAIN.sv_client.name + "\\n"); SV_Nextserver(); }
public static void SV_BeginDownload_f( ) { String name; var offset = 0; name = Cmd.Argv(1); if (Cmd.Argc() > 2) { offset = Lib.Atoi(Cmd.Argv(2)); } if (name.IndexOf("..") != -1 || SV_MAIN.allow_download.value == 0 || name[0] == '.' || name[0] == '/' || (name.StartsWith("players/") && 0 == SV_MAIN.allow_download_players.value) || (name.StartsWith("models/") && 0 == SV_MAIN.allow_download_models.value) || (name.StartsWith("sound/") && 0 == SV_MAIN.allow_download_sounds.value) || (name.StartsWith("maps/") && 0 == SV_MAIN.allow_download_maps.value) || name.IndexOf('/') == -1) { MSG.WriteByte(SV_MAIN.sv_client.netchan.message, Defines.svc_download); MSG.WriteShort(SV_MAIN.sv_client.netchan.message, -1); MSG.WriteByte(SV_MAIN.sv_client.netchan.message, 0); return; } if (SV_MAIN.sv_client.download != null) { FS.FreeFile(SV_MAIN.sv_client.download); } SV_MAIN.sv_client.download = FS.LoadFile(name); if (SV_MAIN.sv_client.download == null) { return; } SV_MAIN.sv_client.downloadsize = SV_MAIN.sv_client.download.Length; SV_MAIN.sv_client.downloadcount = offset; if (offset > SV_MAIN.sv_client.downloadsize) { SV_MAIN.sv_client.downloadcount = SV_MAIN.sv_client.downloadsize; } if (SV_MAIN.sv_client.download == null || (name.StartsWith("maps/") && FS.file_from_pak != 0)) { Com.DPrintf("Couldn't download " + name + " to " + SV_MAIN.sv_client.name + "\\n"); if (SV_MAIN.sv_client.download != null) { FS.FreeFile(SV_MAIN.sv_client.download); SV_MAIN.sv_client.download = null; } MSG.WriteByte(SV_MAIN.sv_client.netchan.message, Defines.svc_download); MSG.WriteShort(SV_MAIN.sv_client.netchan.message, -1); MSG.WriteByte(SV_MAIN.sv_client.netchan.message, 0); return; } SV_NextDownload_f(); Com.DPrintf("Downloading " + name + " to " + SV_MAIN.sv_client.name + "\\n"); }
public static void SP_trigger_gravity(edict_t self) { if (GameBase.st.gravity == null) { GameBase.gi.Dprintf("trigger_gravity without gravity set at " + Lib.Vtos(self.s.origin) + "\\n"); GameUtil.G_FreeEdict(self); return; } InitTrigger(self); self.gravity = Lib.Atoi(GameBase.st.gravity); self.touch = trigger_gravity_touch; }
static void KeyUp(kbutton_t b) { int k; string c; int uptime; c = Cmd.Argv(1); if (c.Length > 0) { k = Lib.Atoi(c); } else { b.down[0] = b.down[1] = 0; b.state = 4; return; } if (b.down[0] == k) { b.down[0] = 0; } else if (b.down[1] == k) { b.down[1] = 0; } else { return; } if (b.down[0] != 0 || b.down[1] != 0) { return; } if ((b.state & 1) == 0) { return; } c = Cmd.Argv(2); uptime = Lib.Atoi(c); if (uptime != 0) { b.msec += uptime - b.downtime; } else { b.msec += 10; } b.state &= ~1; b.state |= 4; }
public static void SV_Begin_f( ) { Com.DPrintf("Begin() from " + SV_MAIN.sv_client.name + "\\n"); if (Lib.Atoi(Cmd.Argv(1)) != SV_INIT.svs.spawncount) { Com.Printf("SV_Begin_f from different level\\n"); SV_New_f(); return; } SV_MAIN.sv_client.state = Defines.cs_spawned; PlayerClient.ClientBegin(SV_USER.sv_player); Cbuf.InsertFromDefer(); }
public static Boolean SV_SetPlayer( ) { client_t cl; Int32 i; Int32 idnum; String s; if (Cmd.Argc() < 2) { return(false); } s = Cmd.Argv(1); if (s[0] >= '0' && s[0] <= '9') { idnum = Lib.Atoi(Cmd.Argv(1)); if (idnum < 0 || idnum >= SV_MAIN.maxclients.value) { Com.Printf("Bad client slot: " + idnum + "\\n"); return(false); } SV_MAIN.sv_client = SV_INIT.svs.clients[idnum]; SV_USER.sv_player = SV_MAIN.sv_client.edict; if (0 == SV_MAIN.sv_client.state) { Com.Printf("Client " + idnum + " is not active\\n"); return(false); } return(true); } for (i = 0; i < SV_MAIN.maxclients.value; i++) { cl = SV_INIT.svs.clients[i]; if (0 == cl.state) { continue; } if (0 == Lib.Strcmp(cl.name, s)) { SV_MAIN.sv_client = cl; SV_USER.sv_player = SV_MAIN.sv_client.edict; return(true); } } Com.Printf("Userid " + s + " is not on the server\\n"); return(false); }
public static void Wave_f(edict_t ent) { Int32 i; i = Lib.Atoi(Cmd.Argv(1)); if ((ent.client.ps.pmove.pm_flags & pmove_t.PMF_DUCKED) != 0) { return; } if (ent.client.anim_priority > Defines.ANIM_WAVE) { return; } ent.client.anim_priority = Defines.ANIM_WAVE; switch (i) { case 0: SV_GAME.PF_cprintfhigh(ent, "flipoff\\n"); ent.s.frame = M_Player.FRAME_flip01 - 1; ent.client.anim_end = M_Player.FRAME_flip12; break; case 1: SV_GAME.PF_cprintfhigh(ent, "salute\\n"); ent.s.frame = M_Player.FRAME_salute01 - 1; ent.client.anim_end = M_Player.FRAME_salute11; break; case 2: SV_GAME.PF_cprintfhigh(ent, "taunt\\n"); ent.s.frame = M_Player.FRAME_taunt01 - 1; ent.client.anim_end = M_Player.FRAME_taunt17; break; case 3: SV_GAME.PF_cprintfhigh(ent, "wave\\n"); ent.s.frame = M_Player.FRAME_wave01 - 1; ent.client.anim_end = M_Player.FRAME_wave11; break; case 4: default: SV_GAME.PF_cprintfhigh(ent, "point\\n"); ent.s.frame = M_Player.FRAME_point01 - 1; ent.client.anim_end = M_Player.FRAME_point12; break; } }
public static void SV_Baselines_f( ) { Int32 start; entity_state_t nullstate; entity_state_t base_renamed; Com.DPrintf("Baselines() from " + SV_MAIN.sv_client.name + "\\n"); if (SV_MAIN.sv_client.state != Defines.cs_connected) { Com.Printf("baselines not valid -- already spawned\\n"); return; } if (Lib.Atoi(Cmd.Argv(1)) != SV_INIT.svs.spawncount) { Com.Printf("SV_Baselines_f from different level\\n"); SV_New_f(); return; } start = Lib.Atoi(Cmd.Argv(2)); nullstate = new entity_state_t(null); while (SV_MAIN.sv_client.netchan.message.cursize < Defines.MAX_MSGLEN / 2 && start < Defines.MAX_EDICTS) { base_renamed = SV_INIT.sv.baselines[start]; if (base_renamed.modelindex != 0 || base_renamed.sound != 0 || base_renamed.effects != 0) { MSG.WriteByte(SV_MAIN.sv_client.netchan.message, Defines.svc_spawnbaseline); MSG.WriteDeltaEntity(nullstate, base_renamed, SV_MAIN.sv_client.netchan.message, true, true); } start++; } if (start == Defines.MAX_EDICTS) { MSG.WriteByte(SV_MAIN.sv_client.netchan.message, Defines.svc_stufftext); MSG.WriteString(SV_MAIN.sv_client.netchan.message, "precache " + SV_INIT.svs.spawncount + "\\n"); } else { MSG.WriteByte(SV_MAIN.sv_client.netchan.message, Defines.svc_stufftext); MSG.WriteString(SV_MAIN.sv_client.netchan.message, "cmd baselines " + SV_INIT.svs.spawncount + " " + start + "\\n"); } }
static void KeyDown(kbutton_t b) { int k; string c; c = Cmd.Argv(1); if (c.Length > 0) { k = Lib.Atoi(c); } else { k = -1; } if (k == b.down[0] || k == b.down[1]) { return; } if (b.down[0] == 0) { b.down[0] = k; } else if (b.down[1] == 0) { b.down[1] = k; } else { Com.Printf("Three keys down for a button!\\n"); return; } if ((b.state & 1) != 0) { return; } c = Cmd.Argv(2); b.downtime = Lib.Atoi(c); if (b.downtime == 0) { b.downtime = Globals.sys_frame_time - 100; } b.state |= 3; }
public static void SV_Configstrings_f( ) { Int32 start; Com.DPrintf("Configstrings() from " + SV_MAIN.sv_client.name + "\\n"); if (SV_MAIN.sv_client.state != Defines.cs_connected) { Com.Printf("configstrings not valid -- already spawned\\n"); return; } if (Lib.Atoi(Cmd.Argv(1)) != SV_INIT.svs.spawncount) { Com.Printf("SV_Configstrings_f from different level\\n"); SV_New_f(); return; } start = Lib.Atoi(Cmd.Argv(2)); while (SV_MAIN.sv_client.netchan.message.cursize < Defines.MAX_MSGLEN / 2 && start < Defines.MAX_CONFIGSTRINGS) { if (SV_INIT.sv.configstrings[start] != null && SV_INIT.sv.configstrings[start].Length != 0) { MSG.WriteByte(SV_MAIN.sv_client.netchan.message, Defines.svc_configstring); MSG.WriteShort(SV_MAIN.sv_client.netchan.message, start); MSG.WriteString(SV_MAIN.sv_client.netchan.message, SV_INIT.sv.configstrings[start]); } start++; } if (start == Defines.MAX_CONFIGSTRINGS) { MSG.WriteByte(SV_MAIN.sv_client.netchan.message, Defines.svc_stufftext); MSG.WriteString(SV_MAIN.sv_client.netchan.message, "cmd baselines " + SV_INIT.svs.spawncount + " 0\\n"); } else { MSG.WriteByte(SV_MAIN.sv_client.netchan.message, Defines.svc_stufftext); MSG.WriteString(SV_MAIN.sv_client.netchan.message, "cmd configstrings " + SV_INIT.svs.spawncount + " " + start + "\\n"); } }
public static void SVC_DirectConnect( ) { String userinfo; netadr_t adr; Int32 i; client_t cl; Int32 version; Int32 qport; adr = Globals.net_from; Com.DPrintf("SVC_DirectConnect ()\\n"); version = Lib.Atoi(Cmd.Argv(1)); if (version != Defines.PROTOCOL_VERSION) { Netchan.OutOfBandPrint(Defines.NS_SERVER, adr, "print\\nServer is version " + Globals.VERSION + "\\n"); Com.DPrintf(" rejected connect from version " + version + "\\n"); return; } qport = Lib.Atoi(Cmd.Argv(2)); var challenge = Lib.Atoi(Cmd.Argv(3)); userinfo = Cmd.Argv(4); userinfo = Info.Info_SetValueForKey(userinfo, "ip", NET.AdrToString(Globals.net_from)); if (SV_INIT.sv.attractloop) { if (!NET.IsLocalAddress(adr)) { Com.Printf("Remote connect in attract loop. Ignored.\\n"); Netchan.OutOfBandPrint(Defines.NS_SERVER, adr, "print\\nConnection refused.\\n"); return; } } if (!NET.IsLocalAddress(adr)) { for (i = 0; i < Defines.MAX_CHALLENGES; i++) { if (NET.CompareBaseAdr(Globals.net_from, SV_INIT.svs.challenges[i].adr)) { if (challenge == SV_INIT.svs.challenges[i].challenge) { break; } Netchan.OutOfBandPrint(Defines.NS_SERVER, adr, "print\\nBad challenge.\\n"); return; } } if (i == Defines.MAX_CHALLENGES) { Netchan.OutOfBandPrint(Defines.NS_SERVER, adr, "print\\nNo challenge for address.\\n"); return; } } for (i = 0; i < SV_MAIN.maxclients.value; i++) { cl = SV_INIT.svs.clients[i]; if (cl.state == Defines.cs_free) { continue; } if (NET.CompareBaseAdr(adr, cl.netchan.remote_address) && (cl.netchan.qport == qport || adr.port == cl.netchan.remote_address.port)) { if (!NET.IsLocalAddress(adr) && (SV_INIT.svs.realtime - cl.lastconnect) < (( Int32 )SV_MAIN.sv_reconnect_limit.value * 1000)) { Com.DPrintf(NET.AdrToString(adr) + ":reconnect rejected : too soon\\n"); return; } Com.Printf(NET.AdrToString(adr) + ":reconnect\\n"); Gotnewcl(i, challenge, userinfo, adr, qport); return; } } var index = -1; for (i = 0; i < SV_MAIN.maxclients.value; i++) { cl = SV_INIT.svs.clients[i]; if (cl.state == Defines.cs_free) { index = i; break; } } if (index == -1) { Netchan.OutOfBandPrint(Defines.NS_SERVER, adr, "print\\nServer is full.\\n"); Com.DPrintf("Rejected a connection.\\n"); return; } Gotnewcl(index, challenge, userinfo, adr, qport); }
public virtual Boolean SetField(String key, String value) { if (key.Equals("classname")) { classname = GameSpawn.ED_NewString(value); return(true); } if (key.Equals("model")) { model = GameSpawn.ED_NewString(value); return(true); } if (key.Equals("spawnflags")) { spawnflags = Lib.Atoi(value); return(true); } if (key.Equals("speed")) { speed = Lib.Atof(value); return(true); } if (key.Equals("accel")) { accel = Lib.Atof(value); return(true); } if (key.Equals("decel")) { decel = Lib.Atof(value); return(true); } if (key.Equals("target")) { target = GameSpawn.ED_NewString(value); return(true); } if (key.Equals("targetname")) { targetname = GameSpawn.ED_NewString(value); return(true); } if (key.Equals("pathtarget")) { pathtarget = GameSpawn.ED_NewString(value); return(true); } if (key.Equals("deathtarget")) { deathtarget = GameSpawn.ED_NewString(value); return(true); } if (key.Equals("killtarget")) { killtarget = GameSpawn.ED_NewString(value); return(true); } if (key.Equals("combattarget")) { combattarget = GameSpawn.ED_NewString(value); return(true); } if (key.Equals("message")) { message = GameSpawn.ED_NewString(value); return(true); } if (key.Equals("team")) { team = GameSpawn.ED_NewString(value); Com.Dprintln("Monster Team:" + team); return(true); } if (key.Equals("wait")) { wait = Lib.Atof(value); return(true); } if (key.Equals("delay")) { delay = Lib.Atof(value); return(true); } if (key.Equals("random")) { random = Lib.Atof(value); return(true); } if (key.Equals("move_origin")) { move_origin = Lib.Atov(value); return(true); } if (key.Equals("move_angles")) { move_angles = Lib.Atov(value); return(true); } if (key.Equals("style")) { style = Lib.Atoi(value); return(true); } if (key.Equals("count")) { count = Lib.Atoi(value); return(true); } if (key.Equals("health")) { health = Lib.Atoi(value); return(true); } if (key.Equals("sounds")) { sounds = Lib.Atoi(value); return(true); } if (key.Equals("light")) { return(true); } if (key.Equals("dmg")) { dmg = Lib.Atoi(value); return(true); } if (key.Equals("mass")) { mass = Lib.Atoi(value); return(true); } if (key.Equals("volume")) { volume = Lib.Atof(value); return(true); } if (key.Equals("attenuation")) { attenuation = Lib.Atof(value); return(true); } if (key.Equals("map")) { map = GameSpawn.ED_NewString(value); return(true); } if (key.Equals("origin")) { s.origin = Lib.Atov(value); return(true); } if (key.Equals("angles")) { s.angles = Lib.Atov(value); return(true); } if (key.Equals("angle")) { s.angles = new Single[] { 0, Lib.Atof(value), 0 }; return(true); } if (key.Equals("item")) { GameBase.gi.Error("ent.set(\\\"item\\\") called."); return(true); } return(false); }
public virtual bool Set(string key, string value) { if (key.Equals("lip")) { lip = Lib.Atoi(value); return(true); } if (key.Equals("distance")) { distance = Lib.Atoi(value); return(true); } if (key.Equals("height")) { height = Lib.Atoi(value); return(true); } if (key.Equals("noise")) { noise = GameSpawn.ED_NewString(value); return(true); } if (key.Equals("pausetime")) { pausetime = Lib.Atof(value); return(true); } if (key.Equals("item")) { item = GameSpawn.ED_NewString(value); return(true); } if (key.Equals("gravity")) { gravity = GameSpawn.ED_NewString(value); return(true); } if (key.Equals("sky")) { sky = GameSpawn.ED_NewString(value); return(true); } if (key.Equals("skyrotate")) { skyrotate = Lib.Atof(value); return(true); } if (key.Equals("skyaxis")) { skyaxis = Lib.Atov(value); return(true); } if (key.Equals("minyaw")) { minyaw = Lib.Atof(value); return(true); } if (key.Equals("maxyaw")) { maxyaw = Lib.Atof(value); return(true); } if (key.Equals("minpitch")) { minpitch = Lib.Atof(value); return(true); } if (key.Equals("maxpitch")) { maxpitch = Lib.Atof(value); return(true); } if (key.Equals("nextmap")) { nextmap = GameSpawn.ED_NewString(value); return(true); } return(false); }
public static void Give_f(edict_t ent) { String name; gitem_t it; Int32 index; Int32 i; Boolean give_all; edict_t it_ent; if (GameBase.deathmatch.value != 0 && GameBase.sv_cheats.value == 0) { SV_GAME.PF_cprintfhigh(ent, "You must run the server with '+set cheats 1' to enable this command.\\n"); return; } name = Cmd.Args(); if (0 == Lib.Q_stricmp(name, "all")) { give_all = true; } else { give_all = false; } if (give_all || 0 == Lib.Q_stricmp(Cmd.Argv(1), "health")) { if (Cmd.Argc() == 3) { ent.health = Lib.Atoi(Cmd.Argv(2)); } else { ent.health = ent.max_health; } if (!give_all) { return; } } if (give_all || 0 == Lib.Q_stricmp(name, "weapons")) { for (i = 1; i < GameBase.game.num_items; i++) { it = GameItemList.itemlist[i]; if (null == it.pickup) { continue; } if (0 == (it.flags & Defines.IT_WEAPON)) { continue; } ent.client.pers.inventory[i] += 1; } if (!give_all) { return; } } if (give_all || 0 == Lib.Q_stricmp(name, "ammo")) { for (i = 1; i < GameBase.game.num_items; i++) { it = GameItemList.itemlist[i]; if (null == it.pickup) { continue; } if (0 == (it.flags & Defines.IT_AMMO)) { continue; } GameItems.Add_Ammo(ent, it, 1000); } if (!give_all) { return; } } if (give_all || Lib.Q_stricmp(name, "armor") == 0) { gitem_armor_t info; it = GameItems.FindItem("Jacket Armor"); ent.client.pers.inventory[GameItems.ITEM_INDEX(it)] = 0; it = GameItems.FindItem("Combat Armor"); ent.client.pers.inventory[GameItems.ITEM_INDEX(it)] = 0; it = GameItems.FindItem("Body Armor"); info = ( gitem_armor_t )it.info; ent.client.pers.inventory[GameItems.ITEM_INDEX(it)] = info.max_count; if (!give_all) { return; } } if (give_all || Lib.Q_stricmp(name, "Power Shield") == 0) { it = GameItems.FindItem("Power Shield"); it_ent = GameUtil.G_Spawn(); it_ent.classname = it.classname; GameItems.SpawnItem(it_ent, it); GameItems.Touch_Item(it_ent, ent, GameBase.dummyplane, null); if (it_ent.inuse) { GameUtil.G_FreeEdict(it_ent); } if (!give_all) { return; } } if (give_all) { for (i = 1; i < GameBase.game.num_items; i++) { it = GameItemList.itemlist[i]; if (it.pickup != null) { continue; } if ((it.flags & (Defines.IT_ARMOR | Defines.IT_WEAPON | Defines.IT_AMMO)) != 0) { continue; } ent.client.pers.inventory[i] = 1; } return; } it = GameItems.FindItem(name); if (it == null) { name = Cmd.Argv(1); it = GameItems.FindItem(name); if (it == null) { SV_GAME.PF_cprintf(ent, Defines.PRINT_HIGH, "unknown item\\n"); return; } } if (it.pickup == null) { SV_GAME.PF_cprintf(ent, Defines.PRINT_HIGH, "non-pickup item\\n"); return; } index = GameItems.ITEM_INDEX(it); if ((it.flags & Defines.IT_AMMO) != 0) { if (Cmd.Argc() == 3) { ent.client.pers.inventory[index] = Lib.Atoi(Cmd.Argv(2)); } else { ent.client.pers.inventory[index] += it.quantity; } } else { it_ent = GameUtil.G_Spawn(); it_ent.classname = it.classname; GameItems.SpawnItem(it_ent, it); GameItems.Touch_Item(it_ent, ent, GameBase.dummyplane, null); if (it_ent.inuse) { GameUtil.G_FreeEdict(it_ent); } } }
static void IN_Impulse() { in_impulse = Lib.Atoi(Cmd.Argv(1)); }