Jump to content

Dagger

Members
  • Posts

    132
  • Joined

  • Last visited

Posts posted by Dagger

  1. 12 hours ago, godarklight said:

    @Dagger I'm definitely interested in other multiplayer mods and I might be able to answer some questions if you have any - It helps that mod developers actually play the game to remain interested and I haven't touched KSP in ages :)

    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. 4 hours ago, jediminer543 said:

    My goal is to make code that doesn't need me to modify much BDA code, and definatly not re-pull and modify it, and to modify the code on a per function level. as such, all the code I need is already there, as hitmanager is version agnostic, as is the sychroniser itself. See the github for the changes currently in effect (it currently replaces explosions with the word "bang" in the console, and doesn't need to completely rebuild BDA every time).

     

    In this case, it was DMP's api changes that were a pig. but I worked them out. at 1 in the morning.

    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. 10 hours ago, Toonu said:

    Hello, I have one request. Is there any developer interested in better multiplayer for KSP named LMP? It has some new features and coding from what I heard. Developers abandoned the project before a month with the commend under this video. I'm not programmer, but I hope there is someone who is interested and can try continue that project.

    Thanks for any reply! Toonu

    Also...their github

    https://github.com/gavazquez/LunaMultiPlayer

    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, 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?

  8. 6 hours ago, Lothsahn said:

    Dagger,

     

    Would you mind if I setup a dedicated server and kept it up to date?  That would allow people to use and test the mod around the world.  I want to make sure you're OK with it before I go do it, since it is your mod.

     

    Lothsahn

    Hi! Sure feel free to do it :) It's not very stable still but the more bugs we found the better.

  9. 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

  10. 12 hours ago, Lothsahn said:

    Overall some great improvements to the mod, dagger!

     

    So I managed to compile and run the mod with a friend and I.  

     

    Few thoughts:

    1) It's definitely a developer build.  So take everything below with that in mind...

    2) Interpolation is still not good, but massively better than before

    3) We were able to undock a rocket payload (carried under fuselage) from a carrier plane and fly the rocket into space, and land the plane.  Amazing.

    4) Crashed.  A lot.  Frequently, especially when recovering ships--there appeared to be some sort of desync errors.

    5) Timewarp did not work properly.  Using it didn't warp as expected, and the sync button let me sync backwards in time.

     

    Looks like I've got some bug hunting to do.

     

     

    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

  11. 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(.......)

  12. 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 });  

  13. 1 hour ago, Diazo said:

    I can't help with the code issue, but I'm not sure detecting an engine can be done. What happens when an engine is activated, burns for a bit and then is throttle down to zero? It's still "activated" but you'd also need some way to turn the engine plume off.

    For current status of things like engines you may be stuck with the periodic updates route.

    D.

    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. 

     

  14. 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.

  15. 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...

     

     

  16. 11 hours ago, Nightmare said:

    Question: by latency of 500 ms is it that the server runs then at 2 fps or I am getting something worng here? Cause DMP as Gooddarklight said in this topic in the past runs at 5 fps as far as I can remember...

    Or I am getting it totaly wrong?

    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

  17. @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

  18. 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...

  19. 50 minutes ago, godarklight said:

    I've done the bare minimum (merged whatever rocky did, and then fixed a few compile errors for the unstable branch to 1.2), but it has had 0 testing, and KSP is now insanely crashy on linux so I cannot test it at all, so I highly recommend using forks. This might kick your dog and kill your cat, but the build is on my build server in my sig (unstable branch)

     

    I've also been working quite a lot lately, and have moved onto another game so I've not had much time for DMP. When I do get some time I'll let anyone who has forked pick my brain for a bit, but I apologize in advance for the mess that is DMPClient :P

    You shouldn't apologize, without DMP I wouldn't even know from where to start :wink: 

  20. 20 hours ago, moritz31 said:

    @EBOSHI

    thanks for the information

     

     @Dagger
    I'm study IT and have basic knowledge of c#, maybe i can help you a little bit here and there :wink:

    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

     

  21. 21 minutes ago, EBOSHI said:

    Hi Mr. developer, I'm a player playing with DMP server and client.
    Your work seems so great. but I'm sorry about me having no Modding skill at all. So I can't understand "adapt the code to DMP". Can it be done by amateur?
    There is nothing to do but I shared it on Twitter. If you need a helping ant's hand, we do our bit. 

    I hope you good luck!

    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 :)

     

×
×
  • Create New...