08-28-2016, 09:04 PM
(This post was last modified: 08-28-2016, 09:05 PM by NightmareX1337.)
(08-28-2016, 08:22 PM)MangaD Wrote: Done cpp version including the changes of 2.01. Only tested a bit but seems to work well. However, the ping command does not work well in both versions as it gives a much lower value than the OS ping command. The following piece of code can't be right:
Code://LF2 has a inner clock, and it delays its respond if the request was sent quicker that its FPS ratio.
//So I subtract this ratio from the total ping result.
//Apparently LF2 waits 2 frames before it responds.
//I don't sure why. I will check it again when I have some time.
players[i].TotalWaitAmount -= PING_LF2_WAIT_BETWEEN_FRAMES * 2;
if (players[i].TotalWaitAmount < 0) players[i].TotalWaitAmount = 0;
So, zort just gave a great idea. How about using the system ping command instead of using LF2 to check it? In c++ I'd do it like:
Code:system("ping some_ip");
Well... I don't know what's the rationale behind converting it to C++ but...
Anyways, calling ping command is a horrible idea because
1- it's a blocking operation
2- unnecessarily expensive since you're creating a new process
3- it's unnecessarily inefficient and stupid trying to capture and parse standard output of ping command
I would suggest using async methods of Ping class. I don't know how much it's applicable to your C++ code base though.
Ultimately, my constant dissatisfaction with the way things are becomes the driving force behind everything I do.
![[Image: sigline.png]](http://www.lf-empire.de/forum/images/unrealblack/english/sigline.png)
LF2 IDE - Advanced visual data changer featuring instant data loader
LF2 Sprite Sheet Generator - Template based sprite sheet generator based on Gad's method
![[Image: sigline.png]](http://www.lf-empire.de/forum/images/unrealblack/english/sigline.png)
There is no perfect language, but C++ is the worst.
![[Image: sigline.png]](http://www.lf-empire.de/forum/images/unrealblack/english/sigline.png)
LF2 IDE - Advanced visual data changer featuring instant data loader
LF2 Sprite Sheet Generator - Template based sprite sheet generator based on Gad's method
![[Image: sigline.png]](http://www.lf-empire.de/forum/images/unrealblack/english/sigline.png)
There is no perfect language, but C++ is the worst.