Jump to content


Photo

Network connection reliability problem


  • Please log in to reply
1 reply to this topic

#1 Creator

Creator

    The cat

  • Hosted
  • 3,632 posts
  • Location:Moscow, Russia
  • Projects:Contra

Posted 27 May 2017 - 11:44 AM

Hello. I'm glad that the mod lives even without my help. Recently I received a letter from one guy about Contra. He told me that the mod is not reliable and disconnection happens often. This is why I need to explain you how the game works and why disconnection happens.

 

The game uses peer-to-peer connection. It means that each player has both client and server running on his computer. The game is played synchronously. Lets think about it. All computers have all units in their memory. They move units synchronously by their own. All movement must be absolutely idential everywhere. Data transferred by network is not coordinates of all units. It is commands only. If units do something not synchronously on different comuters - mismatch problem will appear. This is why framerate is fixed - it is 30 FPS. Fast computers must do everything exactly like slow ones. Which factors can make units to move and act different way on different computers? Here are they:

1. Data loss in network. This can be solved by using VPN. You can use VPN over LAN too (Google it if you don't know how).

2. Not deterministic calculations. Floating point numbers are calculated different way on different hardware. Solution must be in the engine already. So, we should not care about it.

3. Undefined variables.

 

This 3rd oprion is the most problematic. Because here mod makers can make errors. Each time when you have a link to something which does not exist - it is undefined link. Each computer will put random number there and it is the reason why we will see a mismatch. So, entire code must be checked. This is what can help:

- If a module has a link to something which does not exist - mismatch or crash will happen.

- If a module has a number of variables but you set only some of them and skip another ones - missmatch will happen.

 

I already made INI checker and uploaded it long ago. Here it is http://contra.cncgui...Eng/checker.php It helps to find links to non-existing things.

 

But undefined variables is a problem. You need to check all code and add all variables to all modules. The game usually sets zeroes to all module variables which are not defined in the code explictly. But there can be possible bug in the engine which does not set something to zero. But we don't know which parameter of which module is not defined by default. This is why setting all variables for all modules can be a solution. It is extremely hard to do manually. This is why a programm which makes everything automatically is needed.


Edited by Creator, 27 May 2017 - 11:47 AM.


#2 predator_bg

predator_bg

    The predator

  • Hosted
  • 2,435 posts
  • Location:Bulgaria
  • Projects:Contra

Posted 27 May 2017 - 06:12 PM

Creator, what a miracle it is too see you at the Contra forums! While you were absent, I got familiar with INI coding and World Builder scripting. Fixed many bugs and spent a good amount of time on Challenge mode. INI Checker was very helpful at times. Current test build is very stable.

 

Both mismatch and crash can be caused by coding errors. I personally discovered and fixed some. I hope the following info will be useful to any modders out there reading this:

 

Fixed mismatches so far:

- Calling powers (such as Comanche Drop) on water or "bad" terrain. It was caused by the "DiesOnBadLand = No" code line. I simply used the Spy Drone approach to code reinforcement powers.

- Stealth general's Panic power. I suspect that "DiesOnBadLand = No" was responsible here too.

- Seraph's weapons. Not exactly sure, but I think it was because he had PreferredAgainst tied to a weapon that can't normally fire on the "preferred" KINDOF.

 

Fixed crashes so far:

- The game used to crash after selecting and then switching a Strategy Center Battle Plan once. The reason was that some super units use additional weapons (OverlordContain addons). Since super units have the DRONE KINDOF, their addon objects must have it too. When they didn't, the game ignored super units but considered their addons eligible for Battle Plan bonuses, so it crashed.

- Other crashes caused by units linking to non existing upgrades (problems with Beta releases).


Edited by predator_bg, 27 May 2017 - 06:18 PM.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users