private string GetAvatarString(VMAvatar ava) { int prefixNum = 3; if (ava.IsPet) { prefixNum = 5; } else if (ava.PersistID < 65536) { prefixNum = 4; } else { var permissionsLevel = ((VMTSOAvatarState)ava.TSOState).Permissions; switch (permissionsLevel) { case VMTSOAvatarPermissions.Visitor: prefixNum = 3; break; case VMTSOAvatarPermissions.Roommate: case VMTSOAvatarPermissions.BuildBuyRoommate: prefixNum = 2; break; case VMTSOAvatarPermissions.Admin: case VMTSOAvatarPermissions.Owner: prefixNum = 1; break; } } return(GameFacade.Strings.GetString("217", prefixNum.ToString()) + ava.ToString()); }
public override bool Execute(VM vm, VMAvatar avatar) { if (Message.Length == 0) { return(false); } if (Message.Length > 200) { Message = Message.Substring(0, 200); } if (avatar == null) { return(false); } if (Message[0] == '/' && Message.Length > 1) { var spaceIndex = Message.IndexOf(' '); if (spaceIndex == -1) { spaceIndex = Message.Length; } if ((FromNet && avatar.AvatarState.Permissions < VMTSOAvatarPermissions.Admin) || !(vm.Driver is VMServerDriver)) { return(false); } //commands are only run from the server sim right now var cmd = Message.Substring(1, spaceIndex - 1); var args = Message.Substring(Math.Min(Message.Length, spaceIndex + 1), Math.Max(0, Message.Length - (spaceIndex + 1))); var server = (VMServerDriver)vm.Driver; VMEntity sim; switch (cmd.ToLowerInvariant()) { case "ban": server.BanUser(vm, args); break; case "banip": server.BanIP(args); vm.SignalChatEvent(new VMChatEvent(null, VMChatEventType.Generic, "Added " + args + " to the IP ban list.")); break; case "unban": server.SandboxBans.Remove(args.ToLowerInvariant().Trim(' ')); vm.SignalChatEvent(new VMChatEvent(null, VMChatEventType.Generic, "Removed " + args + " from the IP ban list.")); break; case "banlist": string result = ""; foreach (var ban in server.SandboxBans.List()) { result += ban + "\r\n"; } vm.SignalChatEvent(new VMChatEvent(null, VMChatEventType.Generic, "==== BANNED IPS: ==== \r\n" + result)); break; case "builder": sim = vm.Entities.Where(x => x is VMAvatar && x.ToString().ToLowerInvariant().Trim(' ') == args.ToLowerInvariant().Trim(' ')).FirstOrDefault(); if (sim != null) { vm.ForwardCommand(new VMChangePermissionsCmd() { TargetUID = sim.PersistID, Level = VMTSOAvatarPermissions.BuildBuyRoommate, Verified = true }); vm.SignalChatEvent(new VMChatEvent(null, VMChatEventType.Generic, "Made " + sim.Name + " a build-roommate.")); } break; case "admin": sim = vm.Entities.Where(x => x is VMAvatar && x.ToString().ToLowerInvariant().Trim(' ') == args.ToLowerInvariant().Trim(' ')).FirstOrDefault(); if (sim != null) { vm.ForwardCommand(new VMChangePermissionsCmd() { TargetUID = sim.PersistID, Level = VMTSOAvatarPermissions.Admin, Verified = true }); vm.SignalChatEvent(new VMChatEvent(null, VMChatEventType.Generic, "Made " + sim.Name + " an admin.")); } break; case "roomie": sim = vm.Entities.Where(x => x is VMAvatar && x.ToString().ToLowerInvariant().Trim(' ') == args.ToLowerInvariant().Trim(' ')).FirstOrDefault(); if (sim != null) { vm.ForwardCommand(new VMChangePermissionsCmd() { TargetUID = sim.PersistID, Level = VMTSOAvatarPermissions.Roommate, Verified = true }); vm.SignalChatEvent(new VMChatEvent(null, VMChatEventType.Generic, "Made " + sim.Name + " a roommate.")); } break; case "visitor": sim = vm.Entities.Where(x => x is VMAvatar && x.ToString().ToLowerInvariant().Trim(' ') == args.ToLowerInvariant().Trim(' ')).FirstOrDefault(); if (sim != null) { vm.ForwardCommand(new VMChangePermissionsCmd() { TargetUID = sim.PersistID, Level = VMTSOAvatarPermissions.Visitor, Verified = true }); vm.SignalChatEvent(new VMChatEvent(null, VMChatEventType.Generic, "Made " + sim.Name + " a visitor.")); } break; case "close": if (FromNet) { return(false); } vm.CloseNet(VMCloseNetReason.ServerShutdown); break; case "qtrday": var count = int.Parse(args); for (int i = 0; i < count; i++) { vm.ProcessQTRDay(); } vm.SignalChatEvent(new VMChatEvent(null, VMChatEventType.Generic, "Ran " + count + " quarter days.")); break; case "setjob": var jobsplit = args.Split(' '); if (jobsplit.Length < 2) { return(true); } var jobid = short.Parse(jobsplit[0]); var jobgrade = short.Parse(jobsplit[1]); avatar.SetPersonData(SimAntics.Model.VMPersonDataVariable.OnlineJobID, jobid); avatar.SetPersonData(SimAntics.Model.VMPersonDataVariable.OnlineJobGrade, jobgrade); vm.SignalChatEvent(new VMChatEvent(null, VMChatEventType.Generic, "Set " + avatar.ToString() + " job grade/type to " + jobgrade + "/" + jobid + ".")); break; case "trace": //enables desync tracing vm.UseSchedule = false; vm.Trace = new Engine.Debug.VMSyncTrace(); break; case "reload": //enables desync tracing var servD = vm.Driver as VMServerDriver; vm.SignalChatEvent(new VMChatEvent(null, VMChatEventType.Debug, "Manually requested self resync.")); if (servD != null) { servD.SelfResync = true; } break; case "time": var timesplit = args.Split(' '); if (timesplit.Length < 2) { return(true); } vm.Context.Clock.Hours = int.Parse(timesplit[0]); vm.Context.Clock.Minutes = int.Parse(timesplit[1]); vm.Context.Clock.MinuteFractions = 0; break; } return(true); } else { vm.SignalChatEvent(new VMChatEvent(avatar, VMChatEventType.Message, (byte)(ChannelID & 0x7f), avatar.Name, Message)); if ((ChannelID & 0x80) == 0) { avatar.Message = Message; } return(true); } }
private string GetAvatarString(VMAvatar ava) { return(ava.ToString()); }
private string GetAvatarString(VMAvatar ava) { int prefixNum = 3; string prefixSrc = "217"; if (ava.IsPet) { prefixNum = 5; } else if (ava.PersistID == 0) { prefixNum = 4; } else { var permissionsLevel = ((VMTSOAvatarState)ava.TSOState).Permissions; if (vm.TSOState.CommunityLot) { switch (permissionsLevel) { case VMTSOAvatarPermissions.Visitor: prefixNum = 3; break; case VMTSOAvatarPermissions.Roommate: prefixSrc = "f114"; prefixNum = 11; break; case VMTSOAvatarPermissions.BuildBuyRoommate: prefixSrc = "f114"; prefixNum = 10; break; case VMTSOAvatarPermissions.Admin: prefixSrc = "f114"; prefixNum = 17; break; case VMTSOAvatarPermissions.Owner: prefixNum = 1; break; } } else { switch (permissionsLevel) { case VMTSOAvatarPermissions.Visitor: prefixNum = 3; break; case VMTSOAvatarPermissions.Roommate: case VMTSOAvatarPermissions.BuildBuyRoommate: prefixNum = 2; break; case VMTSOAvatarPermissions.Admin: prefixSrc = "f114"; prefixNum = 17; break; case VMTSOAvatarPermissions.Owner: prefixNum = 1; break; } } } var result = GameFacade.Strings.GetString(prefixSrc, prefixNum.ToString()) + ava.ToString(); if (MayorIcon != null) { result += GameFacade.Strings.GetString("f114", "8"); } return(result); }
public override bool Execute(VM vm, VMAvatar avatar) { if (Message.Length == 0) { return(false); } if (Message.Length > 200) { Message = Message.Substring(0, 200); } if (avatar == null) { return(false); } if (Message[0] == '/' && Message.Length > 1) { var spaceIndex = Message.IndexOf(' '); if (spaceIndex == -1) { spaceIndex = Message.Length; } if ((FromNet && avatar.AvatarState.Permissions < VMTSOAvatarPermissions.Admin) || !(vm.Driver is VMServerDriver)) { return(false); } //commands are only run from the server sim right now var cmd = Message.Substring(1, spaceIndex - 1); var args = Message.Substring(Math.Min(Message.Length, spaceIndex + 1), Math.Max(0, Message.Length - (spaceIndex + 1))); var server = (VMServerDriver)vm.Driver; VMEntity sim; switch (cmd.ToLowerInvariant()) { case "ban": server.BanUser(vm, args); break; case "banip": server.BanIP(args); vm.SignalChatEvent(new VMChatEvent(null, VMChatEventType.Generic, "Added " + args + " to the IP ban list.")); break; case "unban": server.SandboxBans.Remove(args.ToLowerInvariant().Trim(' ')); vm.SignalChatEvent(new VMChatEvent(null, VMChatEventType.Generic, "Removed " + args + " from the IP ban list.")); break; case "banlist": string result = ""; foreach (var ban in server.SandboxBans.List()) { result += ban + "\r\n"; } vm.SignalChatEvent(new VMChatEvent(null, VMChatEventType.Generic, "==== BANNED IPS: ==== \r\n" + result)); break; case "builder": sim = vm.Entities.Where(x => x is VMAvatar && x.ToString().ToLowerInvariant().Trim(' ') == args.ToLowerInvariant().Trim(' ')).FirstOrDefault(); if (sim != null) { vm.ForwardCommand(new VMChangePermissionsCmd() { TargetUID = sim.PersistID, Level = VMTSOAvatarPermissions.BuildBuyRoommate, Verified = true }); vm.SignalChatEvent(new VMChatEvent(null, VMChatEventType.Generic, "Made " + sim.Name + " a build-roommate.")); } break; case "admin": sim = vm.Entities.Where(x => x is VMAvatar && x.ToString().ToLowerInvariant().Trim(' ') == args.ToLowerInvariant().Trim(' ')).FirstOrDefault(); if (sim != null) { vm.ForwardCommand(new VMChangePermissionsCmd() { TargetUID = sim.PersistID, Level = VMTSOAvatarPermissions.Admin, Verified = true }); vm.SignalChatEvent(new VMChatEvent(null, VMChatEventType.Generic, "Made " + sim.Name + " an admin.")); } break; case "roomie": sim = vm.Entities.Where(x => x is VMAvatar && x.ToString().ToLowerInvariant().Trim(' ') == args.ToLowerInvariant().Trim(' ')).FirstOrDefault(); if (sim != null) { vm.ForwardCommand(new VMChangePermissionsCmd() { TargetUID = sim.PersistID, Level = VMTSOAvatarPermissions.Roommate, Verified = true }); vm.SignalChatEvent(new VMChatEvent(null, VMChatEventType.Generic, "Made " + sim.Name + " a roommate.")); } break; case "visitor": sim = vm.Entities.Where(x => x is VMAvatar && x.ToString().ToLowerInvariant().Trim(' ') == args.ToLowerInvariant().Trim(' ')).FirstOrDefault(); if (sim != null) { vm.ForwardCommand(new VMChangePermissionsCmd() { TargetUID = sim.PersistID, Level = VMTSOAvatarPermissions.Visitor, Verified = true }); vm.SignalChatEvent(new VMChatEvent(null, VMChatEventType.Generic, "Made " + sim.Name + " a visitor.")); } break; case "close": if (FromNet) { return(false); } vm.CloseNet(VMCloseNetReason.ServerShutdown); break; case "qtrday": var count = int.Parse(args); for (int i = 0; i < count; i++) { vm.ProcessQTRDay(); } vm.SignalChatEvent(new VMChatEvent(null, VMChatEventType.Generic, "Ran " + count + " quarter days.")); break; case "setjob": var jobsplit = args.Split(' '); if (jobsplit.Length < 2) { return(true); } var jobid = short.Parse(jobsplit[0]); var jobgrade = short.Parse(jobsplit[1]); avatar.SetPersonData(SimAntics.Model.VMPersonDataVariable.OnlineJobID, jobid); avatar.SetPersonData(SimAntics.Model.VMPersonDataVariable.OnlineJobGrade, jobgrade); vm.SignalChatEvent(new VMChatEvent(null, VMChatEventType.Generic, "Set " + avatar.ToString() + " job grade/type to " + jobgrade + "/" + jobid + ".")); break; case "trace": //enables desync tracing vm.UseSchedule = false; vm.Trace = new Engine.Debug.VMSyncTrace(); break; case "reload": //enables desync tracing var servD = vm.Driver as VMServerDriver; vm.SignalChatEvent(new VMChatEvent(null, VMChatEventType.Debug, "Manually requested self resync.")); if (servD != null) { servD.SelfResync = true; } break; case "time": var timesplit = args.Split(' '); if (timesplit.Length < 2) { return(true); } vm.Context.Clock.Hours = int.Parse(timesplit[0]); vm.Context.Clock.Minutes = int.Parse(timesplit[1]); vm.Context.Clock.MinuteFractions = 0; break; case "tuning": var tuningsplit = args.Split(' '); if (tuningsplit.Length < 4) { return(true); } vm.Tuning.AddTuning(new Common.Model.DynTuningEntry() { tuning_type = tuningsplit[0], tuning_table = int.Parse(tuningsplit[1]), tuning_index = int.Parse(tuningsplit[2]), value = float.Parse(tuningsplit[3]), }); vm.ForwardCommand(new VMNetTuningCmd() { Tuning = vm.Tuning }); break; case "fixall": var fixCount = 0; foreach (var ent in vm.Entities) { if (ent is VMGameObject && ent == ent.MultitileGroup.BaseObject) { var state = (VMTSOObjectState)ent.TSOState; if (state.Broken) { foreach (var objr in ent.MultitileGroup.Objects) { ((VMGameObject)objr).DisableParticle(256); } fixCount++; } state.QtrDaysSinceLastRepair = 0; state.Wear = 0; } } vm.SignalChatEvent(new VMChatEvent(null, VMChatEventType.Generic, "Fixed " + fixCount + " objects.")); break; case "testcollision": vm.SignalChatEvent(new VMChatEvent(null, VMChatEventType.Debug, $"Scanning collision for lot { vm.TSOState.Name }.")); try { var collisionValidator = new CollisionTestUtils(); collisionValidator.VerifyAllCollision(vm); vm.SignalChatEvent(new VMChatEvent(null, VMChatEventType.Debug, "No issue detected with collision.")); } catch (Exception e) { vm.SignalChatEvent(new VMChatEvent(null, VMChatEventType.Debug, e.Message)); } break; } return(true); } else { vm.SignalChatEvent(new VMChatEvent(avatar, VMChatEventType.Message, (byte)(ChannelID & 0x7f), avatar.Name, Message)); if ((ChannelID & 0x80) == 0) { avatar.Message = Message; } UpdateTalkingHeadSeek(vm, avatar); return(true); } }