Jump to content


  • Posts

  • Joined

  • Last visited

Everything posted by Dagger

  1. Thanks a lot!! For the moment I'm testing LMP toguether with some collaborators, I still don't release LMP because I want it to be more stable but if I run into some issue definately I will contact you
  2. Perhaps you can have a look at this library: https://github.com/pardeike/Harmony it was created for rimworld in the beginning Changing the code that is already compiled is a hard task...
  3. It's not abandoned ;-) I'm still developing it, I had a pause in July of about 3 months but in september I took it again. In fact now the performance is much better as I recycle the network messages and implemented several multithreaded stuff, also vessels positions and docking now works fine Still there are several things to improve such as: 1- Screens are working with the old system of "OnGUI" that generate tons of garbage and must be moved to the new system 2- I'm still not happy with the network message recycling system that I implemented few days ago as there are some cases where it fails... (It's really a quite complex thing as messages are created in several threads at the same time) 3- Warp system is still not 100% done and I must go trough all the cases. 4- At the moment the vessels are transformed to protovessels in order to update their position in the server with a method called "BackupVessel". This method is bad in terms of performance and I'm finding other solutions for this... 5- Spectating other player vessels specially if they are in the ground generate issues 6- Lots of testing to be done For such reasons LMP is not public but if you have programming knowledge and want to help me just send me a PM
  4. Hi @sarbian Another option that I saw is what principia uses. Would it be more compatible with other mods? 1- It runs a function in the TimingManager.obsenceearly and sets the vessel.precalc.enabled=false 2- In another function in TimingManager.Onprecalc it calls the vessel.SetPosition. Then it sets precalc.enabled=true and calls precalc.MainPhysics
  5. I think I've found a solution... 1: Subscribe to onVesselPrecalcAssign 2: When it's triggered, assign your customVesselPrecalc (that inherits from VesselPrecalculate) class to the vessel that is being created 3: Assign that vessel to your customVesselPrecalc (supposedly this shoudn't be needed but otherwise precalc.vessel is null) 4: Do an override of MainPhysics and assign the received transform pos and rot before calling base.MainPhysics
  6. Hi. I'm trying to move NON packed vessels in a multiplayer mod that I'm making. The issue is that the vessel shakes horribly and I don't know what might be happening. I don't have a problem doing it with packed vessels but I think that the flight integrator is messing with me when the vessel is unpacked and I don't know what parts should I touch to do so. The full code: https://github.com/DaggerES/LunaMultiPlayer/blob/master/Client/Systems/VesselPositionAltSys/VesselPositionAltUpdate.cs#L153 Rotation = new Quaternion(rot[0], rot[1], rot[2], rot[3]); Position = Body.GetWorldSurfacePosition(lat, lon, alt); Vessel.checkSplashed(); Vessel.checkLanded(); Vessel.vesselTransform.rotation = Rotation; Vessel.vesselTransform.position = Position; Vessel.SetRotation(Rotation, true); Vessel.SetPosition(Position, false); Vessel.latitude = lat; Vessel.longitude = lon; Vessel.altitude = alt; foreach (var part in Vessel.parts) part.ResumeVelocity(); Hopefully someone can help me with this, I feel like I'm close to finish this multiplayer mod but the movement is very jerky and I don't know what parts should I look at.
  7. Hi sarbian, thanks a lot for your answer. I changed the code so all the other player controlled vessels are packed (by editing the vesselRanges) and it seems much better and smooth
  8. Hi, I'm doing a fork of DMP and I'm having problems when updating a vessel position. The idea is that aproximately every 30ms I receive a message with a vessel position, I store it in a buffer and I apply it on the fixedupdate to the corresponding vessel in a way that I always have 1 packet in the buffer (otherwise the vessel would stop moving until I receive the next one and the movement would jitter) Between those 30ms between packets I interpolate the vessel position with the function Lerp. but still, when flying in formation and at high speeds the vessel jitters and "jumps" in it's movement, even if it's packed or unpacked. Here is the code that I use for the vessel positioning. private void ApplySurfaceInterpolation(float interpolationValue) { //interpolationValue is a value between 0 and 1 to do the Lerp logic. //Velocity components are sent as vessel.rb_velocityD var currentVelocity = GetInterpolatedVelocity(interpolationValue, currentAcc); Vessel.latitude = Lerp(LatLonAlt[0], Target.LatLonAlt[0], interpolationValue); Vessel.longitude = Lerp(LatLonAlt[1], Target.LatLonAlt[1], interpolationValue); Vessel.altitude = Lerp(LatLonAlt[2], Target.LatLonAlt[2], interpolationValue); var worldSurfacePosition = Vessel.mainBody.GetWorldSurfacePosition(Vessel.latitude, Vessel.longitude, Vessel.altitude); var startWorldPos = new Vector3d(WorldPosition[0], WorldPosition[1], WorldPosition[2]); var targetWorldPos = new Vector3d(Target.WorldPosition[0], Target.WorldPosition[1], Target.WorldPosition[2]); var currentWorldPos = Vector3d.Lerp(startWorldPos, targetWorldPos, interpolationValue); Vessel.SetPosition(worldSurfacePosition, true); Vessel.CoMD = currentWorldPos; var startOrbitPos = new Vector3d(OrbitPosition[0], OrbitPosition[1], OrbitPosition[2]); var targetOrbitPos = new Vector3d(Target.OrbitPosition[0], Target.OrbitPosition[1], Target.OrbitPosition[2]); var currentOrbitPos = Vector3d.Lerp(startOrbitPos, targetOrbitPos, interpolationValue); Vessel.orbit.pos = currentOrbitPos; Vessel.SetWorldVelocity(currentVelocity); } Is there something I'm missing or some other vessel position variable that I must send?
  9. Hi! Sure feel free to do it It's not very stable still but the more bugs we found the better.
  10. Hi @Lothsahn Thanks for all your suggestions. I fixed the server issue and also I moved the post build events to a .bat that it's easier to modify. I agree with you that this should be taken out of this post as we are derailing DMP. I will create the post of this mod the first of november. Unfortunately I'm in Madrid so that schedule would be impossible for me. Regarding the time warp I didn't even looked at it but I will do it today. I will write in a PM some instructions on how to work with GIT
  11. Thanks a lot for the review Lothsahn!! Honestly I didn't managed to try it with a friend so your insights help a lot I'm aware about the problems of the recovering, specially it works bad when the ship has kerbals (legacy DMP code) (EDIT. It sohuld work correctly now), regarding the warp, it's still a work in progress but it will work very different than what you are used to DMP. The idea is that every time you warp yo go to your own "dimension" but you can go to other peoples dimension or to the server dimension whenever you want About the interpolation... Well yesterday I managed to find a good approach and I uploaded it but I'm stuck with extrapolation... The issue is that you always see the other player in the past (the miliseconds the messages takes to travel to the server and to your computer) so you will always see the other player plane behind his real position. DMP used a thing called "position fudge" that I also tried to implement in the code but I commented as it just make the vessels shake. https://github.com/DaggerES/LunaMultiPlayer/blob/master/Client/Systems/VesselUpdateSys/VesselUpdate.cs#L413 I'm pretty sure that if I manage to extrapolate and "advance" the other client vessels in the space to compensate those miliseconds in the past we would be able to fly in formation and so on.... Also, In case I lose interest or for whatever reason the project is abandoned I tried to make the code (specially the client part) as commented and easy to understand as possible (except the small legacy parts from DMP like flag syncing and vessel sharing) if you find some part that you don't understand let me know
  12. the code seems correct, can you try it with another binding flag like: BindingFlags.Public and filling the optional parameters? Anyway, being the method public couldn't you just cast the object "inventory" to a ModuleKISInventory type? something like: ModuleKISInventory inventory = FlightGlobals.ActiveVessel.GetComponents<ModuleKISInventory>().First(); inventory.AddItem(.......)
  13. Seems like github is down so I cannot check but from the old version of KIS that I have, the method AddItem has this signature---> AddItem(Part part, float qty = 1f, int slot = -1) Therefore, I would call it in this way as probably reflection doesn't get the default parameters: ModuleKISInventoryType.InvokeMember("AddItem", System.Reflection.BindingFlags.InvokeMethod, null, inventory, new object[] { defPart, 1f, -1 }); edit, from what i've found, you can also use "Type.Missing" so---> new object[] { defPart, Type.Missing, Type.Missing });
  14. Well if I do with the periodic update it works but right now I'm sending a packet every 50ms so every 50ms I must go to the vessel and check all the engine, clamps, decouplers etc and send if they are on or off. Then on another client, every time I receive a update I must go to that vessel and compare the status against the status that I received. That's really bad in terms of performance but anyway, KSP was not programmed with multiplayer in mind. It would be much better if I can just send a message when engines are on, off, clamps have been released (via the right click menu) or decouplers activated.
  15. Thanks @sarbian, I already tried the onPartJointBreak but it's called many times and the onStageSeparation is called after the part is separated so the part.Vessel property corresponds to the new vessel and not the old vessel that triggered it. I didn't tried with onPartUndock but it seems that in only works when undocking and not on decoupling. It would be best to have a similar event fired just before the decoupling Regarding my second question, is there any event to detect when an engine is started? Right now the client plane moves but their engines appears as they're turned off.
  16. Hi, I'm forking DMP (dark multiplayer mod) and I'm very happy with the result so far, the vessels are loaded correctly, their positions are updated smoothly etc. Still there's one issue that is giving me headaches as I can't find a solution in the API. Say for example that a client stages his rocket so now the vessel is divided in 2 (the active vessel of the client and a debris part) How can I reproduce that behaviour in the other client machine? I know I can detect the moment that the vessel is modified in the GameEvents.onVesselPartCountChanged or in the GameEvents.onVesselWasModified but what I want to achieve is to get the part ID that triggered the decoupling, send a message to the other clients and then reproduce that decoupling by calling the Part.Decouple() Method on the other clients vessels -- Right now I'm sending the started engines, stopped engines, launch clamps and decouplers that a vessel has in periodic updates and once another client detects that the represented vessel has more decouplers than it should then it triggers the needed one by using vessel.FindPartModulesImplementing<ModuleDecouple>()....Decouple() This logic works but it's not a good solution as I have to check the vessel all the time and I waste resources. Also, the OnStageSeparation event is not a good option as is triggered when any vessel stages and not only the active vessel and even if I want to use it, I will still have the same problems when clamps are released or turbofan engines are started... It would be nice to be able to detect events such as when an engine starts, clamp is released, decoupler is activated, etc...
  17. What I meant is that you see the other people 500ms "in the past" (even if you receive the position updates earlier). Most of the games use this technique (but with less than 500ms) as the UDP packets are unreliable and you can't be sure that they will arrive in a fixed interval. Therefore, you buffer the packets and reproduce them as if you are in the past and interpolate the position of the client between packet updates (otherwise you would see as if the player jumps from one position to another) People confused it with latency, that is (roughly) the time it takes a packet to travel from one computer to another but actually latency is low as all the time I have around 10+ packets in the queue to be interpolated, that's why I said that you can reduce that "interpolation time" down but then you might run out of packets in the buffer. You can get more info here: https://developer.valvesoftware.com/wiki/Source_Multiplayer_Networking http://www.gabrielgambetta.com/fpm3.html And in this video: https://www.youtube.com/watch?v=6EwaW2iz4iA
  18. @Kieran You are free the modify my code as you want and do it better than me. I chose 500ms as in MY case it was the best option (I use latency simulation), I know that many other games use 100ms or less (Counter strike for ex) so if you think you can do better, why don't you try it? EDIT: BTW, I never said that all games work with as much latency as I did. And anyway, it's still not even released so there's room for improvement
  19. Yes, in the video I didn't had the latest version but you're supposed to be interpolating from 500ms in the past. In the latest version it works better and you can reduce it to 250ms. Bear in mind that it will never be possible to reduce it more as the packets must travel to the server, then to your computer and then you must have a buffer to interpolate to so 500ms is the best option I've found. Unfortunately there are still some performance issues as the calculations are a bit complex and when the vessel gets damaged or destroyed it's not handled correctly so it will take time to release it...
  20. What Schtiebuu sent you is the DMP. Mine is still not released to the public (you have to compile it) Still, future looks good on my fork https://youtu.be/5LLrUTSJYMM
  21. Well the new repo is this one: https://github.com/DaggerES/LunaMultiPlayer/ It has less projects, but the only way I know to change the post build paths is from the project properties--> build events
  22. You shouldn't apologize, without DMP I wouldn't even know from where to start
  23. Thanks for the offer @moritz31! If you want you can compile the code with VS2015 and start digging around. If you feel confortable and understand what's going on we can speak and distribute the tasks. Code:https://github.com/DaggerES/DarkMultiPlayer Right now the fork is compatible with latest 1.2
  24. Unfortunately DMP is not easy to modify, the code has many hacks and it's quite outdated so you need to have some experience. Hopefully I will finish my fork this month
  25. Hi Guys, still a long way to go but interpolations are finished (at least for ground movement) and is much more smooth. Here you can see a small video I've done about it: https://youtu.be/_5kSkvrIsHk Perhaps someone can adapt the code to DMP and use it while I finish my fork.
  • Create New...