/// <summary> /// Send a FLPACKET_SERVER_ACTIVATEOBJECT command to the player to /// activate or deactivate an animation or effect on an object. /// </summary> /// <param name="objid">The object id</param> /// <param name="activate">Activate or deactivate the animation/effect</param> /// <param name="index"> /// The index of the animation starting from 0. Most /// objects only have a single animation to trigger /// </param> // fixme: this should be a notify public void SendActivateObject(DockingObject obj, bool activate, uint index) { byte[] omsg = { 0x0A, 0x02 }; FLMsgType.AddUInt32(ref omsg, obj.Solar.Objid); FLMsgType.AddUInt8(ref omsg, (activate ? 1u : 0u)); FLMsgType.AddUInt32(ref omsg, index); // fixme: send activate only if any player is close to this solar. foreach (Player.Player player in Players.Values) { player.SendMsgToClient(omsg); } }
/// <summary> /// Load a single system /// </summary> /// <param name="path"></param> /// <param name="system"></param> /// <param name="log"></param> private static void LoadSystem(string path, StarSystem system, ILogController log) { try { var ini = new FLDataFile(path, true); foreach (FLDataFile.Section sec in ini.Sections) { string sectionName = sec.SectionName.ToLowerInvariant(); if (sectionName == "zone") { var zone = new Zone { shape = null, nickname = sec.GetSetting("nickname").Str(0) }; zone.zoneid = FLUtility.CreateID(zone.nickname); Vector position = sec.GetSetting("pos").Vector(); var orientation = new Matrix(); double[] size = null; string shape = sec.GetSetting("shape").Str(0).ToLowerInvariant(); foreach (FLDataFile.Setting set in sec.Settings) { string settingName = set.SettingName.ToLowerInvariant(); switch (settingName) { case "rotation": orientation = Matrix.EulerDegToMatrix(set.Vector()); break; case "size": size = new double[set.NumValues()]; for (int a = 0; a < size.Length; a++) { size[a] = set.Float(a); } break; case "damage": zone.damage = set.Float(0); break; case "interference": zone.interference = set.Float(0); break; case "encounter": break; case "faction": break; case "density": zone.density = set.Float(0); break; } } if (size != null) { if (shape == "sphere" && size.Length == 1) { zone.shape = new Sphere(position, orientation, size[0]); } else if (shape == "cylinder" && size.Length == 2) { zone.shape = new Cylinder(position, orientation, size[0], size[1]); } else if (shape == "ellipsoid" && size.Length == 3) { zone.shape = new Ellipsoid(position, orientation, new Vector(size[0], size[1], size[2])); } else if (shape == "box" && size.Length == 3) { zone.shape = new Box(position, orientation, new Vector(size[0], size[1], size[2])); } else if (shape == "ring" && size.Length == 3) { zone.shape = new Ring(position, orientation, size[0], size[1], size[2]); } } system.Zones.Add(zone); } else if (sectionName == "object") { var solar = new Object.Solar.Solar(system, sec.GetSetting("nickname").Str(0)); if (sec.SettingExists("pos")) { solar.Position = sec.GetSetting("pos").Vector(); } if (sec.SettingExists("rotate")) { Vector euler = sec.GetSetting("rotate").Vector(); solar.Orientation = Matrix.EulerDegToMatrix(euler); } if (sec.SettingExists("base")) { // When a ship undocks, it undocks from the solar specified by baseid. // uint baseid = FLUtility.CreateID(sec.GetSetting("base").Str(0)); // FIXME: check base exists // solar.base_data = bases[baseid]; // bases[baseid].solar = solar; } if (sec.SettingExists("archetype")) { uint archetypeid = FLUtility.CreateID(sec.GetSetting("archetype").Str(0)); solar.Arch = ArchetypeDB.Find(archetypeid); solar.GetLoadout(); // FIXME: check archetype exists } if (sec.SettingExists("dock_with")) { uint baseid = FLUtility.CreateID(sec.GetSetting("dock_with").Str(0)); solar.BaseData = Bases[baseid]; } if (sec.SettingExists("goto")) { solar.DestinationObjid = FLUtility.CreateID(sec.GetSetting("goto").Str(1)); solar.DestinationSystemid = FLUtility.CreateID(sec.GetSetting("goto").Str(0)); } if (sec.SettingExists("prev_ring")) { solar.PrevRing = FLUtility.CreateID(sec.GetSetting("prev_ring").Str(0)); } if (sec.SettingExists("next_ring")) { solar.NextRing = FLUtility.CreateID(sec.GetSetting("next_ring").Str(0)); } if (sec.SettingExists("reputation")) { Faction faction = FindFaction(sec.GetSetting("reputation").Str(0)); if (faction == null) { log.AddLog(LogType.ERROR, "error: not valid faction={0}", sec.GetSetting("reputation").Str(0)); } else { solar.Faction = faction; } } // Rebuild the docking points from the archetype // to the solar position and rotation. foreach (DockingPoint dockingPoint in solar.Arch.DockingPoints) { var dockingObj = new DockingObject { Type = dockingPoint.Type, Solar = solar, Index = (uint)solar.Arch.DockingPoints.IndexOf(dockingPoint), DockingRadius = dockingPoint.DockingRadius, Position = solar.Orientation * dockingPoint.Position }; // rotate the hardpoint by the base orientation and then dockingObj.Position += solar.Position; // the ship launch rotation is the base rotation rotated by the hardpoint rotation dockingObj.Rotation = dockingPoint.Rotation * solar.Orientation; if (solar.BaseData != null) { solar.BaseData.LaunchObjs.Add(dockingObj); } solar.DockingObjs.Add(dockingObj); } // Store the solar. system.Solars[solar.Objid] = solar; Solars[solar.Objid] = solar; if (solar.Arch.Type == Archetype.ObjectType.JUMP_GATE || solar.Arch.Type == Archetype.ObjectType.JUMP_HOLE) { system.Gates.Add(solar); } } } } catch (Exception e) { log.AddLog(LogType.ERROR, "error: '" + e.Message + "' when parsing '" + path); if (e.InnerException != null) { log.AddLog(LogType.ERROR, "error: '" + e.InnerException.Message + "' when parsing '" + path); } } }
public static void SendServerRequestReturned(Player player, Old.Object.Ship.Ship ship, DockingObject dockingObj) { player.Log.AddLog(LogType.FL_MSG, "tx FLPACKET_SERVER_REQUEST_RETURNED"); byte[] omsg = { 0x44, 0x02 }; FLMsgType.AddUInt32(ref omsg, ship.Objid); if (dockingObj != null) { if (dockingObj.Type == DockingPoint.DockingSphere.TRADELANE_RING) { FLMsgType.AddUInt8(ref omsg, 2); // type? 0 is used for docking, 1 for something? else } else { FLMsgType.AddUInt8(ref omsg, 0); // type? 0 is used for docking, 1 for something? else } FLMsgType.AddUInt8(ref omsg, 4); // 4 = dock, 3 = wait, 5 = denied? FLMsgType.AddUInt8(ref omsg, dockingObj.Index); // docking point } else { FLMsgType.AddUInt8(ref omsg, 0); // type? 0 is used for docking, 1 for something? else FLMsgType.AddUInt8(ref omsg, 0); // Response: 5 is dock, 0 is denied target hostile, 2 is denied too big (hostile takes priority), 3 is queue, 4 is proceed after queue; 0, 1 don't actually give a message, 2 gives a generic "denied" message FLMsgType.AddUInt8(ref omsg, 255); // docking point } player.SendMsgToClient(omsg); }