Recent Posts

Pages: [1] 2 3 ... 10
1
Outpost 2 Update / Re: Updates for Outpost 2 1.3.8
« Last post by Arklon on December 11, 2018, 08:51:00 PM »
Then I sent the package to someone else and attempted multiplayer. Without touching router configurations or Hamachi or anything else, we were both able to create and see each others' game using TCP/IP. For NetFix, he could see and join my game but I could not see his created game. This was consistent with earlier tests. Not sure why the discrepancy exists. I can send the routers involved if anyone wants the data. Considering I had never been able to play Outpost 2 without Hamachi before this, it seems to be in a much better place.
Issues like that are fairly common with OP2. In fact, I've seen a pattern of behavior like that among lots of older games in particular with the same people, and what they all seem to have in common is they use DirectPlay, which makes me really suspicious. I wonder if there's any good way to look into that.
2
Outpost 2 Update / Re: Updates for Outpost 2 1.3.8
« Last post by Vagabond on December 11, 2018, 08:21:36 PM »
Hooman,

Just finished uploading to the SVN repository and testing.

To test, I put Outpost 2 in the directory: C://Users/.../Outpost 2 Test. This way the directory had spaces in it. I then loaded cm1 using the console mod loader and saw that the colors had been updated. This proved the console mod loader was working with spaces in the directory. No annoying popups occured either.

Then I sent the package to someone else and attempted multiplayer. Without touching router configurations or Hamachi or anything else, we were both able to create and see each others' game using TCP/IP. For NetFix, he could see and join my game but I could not see his created game. This was consistent with earlier tests. Not sure why the discrepancy exists. I can send the routers involved if anyone wants the data. Considering I had never been able to play Outpost 2 without Hamachi before this, it seems to be in a much better place.

If you don't mind, it would be good to proof-read the change log and the publishing instructions I just wrote. Also, please test on Linux using Wine to make sure I didn't break any of the compatibility there I cannot test. Besides that unless someone else wants to test, I would like to see it published.

Thanks,
Brett
3
Computers & Programming General / Re: Spaceship Operator
« Last post by Hooman on December 11, 2018, 03:09:42 AM »
It's a lot like how strcmp works. You implement the one operator, the spaceship operator, which is effectively 3-valued:
  • a < b  : (a <=> b) < 0
  • a == b  : (a <=> b) == 0
  • a > b  : (a <=> b) > 0

Then, using that single value, from a single operator call, you can determine (compiler generated):
  • a == b  : (a <=> b) == 0
  • a != b  : (a <=> b) != 0
  • a < b  : (a <=> b) < 0
  • a > b  : (a <=> b) > 0
  • a <= b  : (a <=> b) <= 0
  • a >= b  : (a <=> b) >= 0

So effectively you get all 6 comparison operators, but only have to implement one.



Previously they had std::rel_ops. Given two operators operator==, and operator<, it would implement the other 4 for you. The problem with std::rel_ops is it didn't play nicely with ADT (Argument-Dependent Lookup), so sometimes those operators weren't found. Additionally, it added extra template operators to the global namespace, so all structs would end up getting the extra comparison operators, whether you wanted them or not.

The implementation of std::rel_ops might use the following equivalences:
  • a != b  : !(a == b)
  • a > b  : (b < a)
  • a <= b  : !(a > b)
  • a >= b  : !(a < b)

Note: The above also only require one operator call.

A naive implementation might call two possibly expensive operators:
  • a <= b  : (a < b) || (a == b)
You want to avoid that.



Another benefit of the <=> operator, is that it can distinguish between the various relational strengths, and only provide overloads that are appropriate. That's a whole other topic, but here are the orderings:
  • strong ordering
  • weak ordering
  • partial ordering
  • strong equality
  • weak equality




Edit: In regards to a "point" (2D, 3D, etc.), there may be no natural way to do inequality comparisons. Hence the different orderings above, which may exclude auto generation of some comparison operators. In particular, if the return type of the spaceship operator is of the last 2 types, the compiler knows not to generate inequality comparisons.
4
Computers & Programming General / Re: Spaceship Operator
« Last post by Vagabond on December 10, 2018, 09:04:31 PM »
But that doesn't tell you which point is actually greater than the other point? The spaceship operator needs some help to understand what greater than or less than means for a point class right?
5
Computers & Programming General / Re: Spaceship Operator
« Last post by leeor_net on December 10, 2018, 08:39:54 PM »
Probably by doing one operator in terms of the other.

E.g., in many implementations of operator> and operator<, the code looks something like this:

Code: [Select]
bool Class::operator>(c)
{
    /* some comparison of members here */
    return true;
}

Class::operator<(c)
{
    return this > c;
}
6
Computers & Programming General / Re: Spaceship Operator
« Last post by Vagabond on December 10, 2018, 07:33:03 PM »
How does it know when one point is greater than or less than another point without some more code to tell the compiler?

-Brett
7
Feedback/Suggestions/Problems / Re: SVN Certificate Issue
« Last post by Vagabond on December 10, 2018, 07:30:57 PM »
Just committed changes to the SVN server and it worked. Good news!
8
Computers & Programming General / Re: Spaceship Operator
« Last post by leeor_net on December 10, 2018, 06:48:37 PM »
This is exciting. Having to hand write those freaking operators sucks.
9
Computers & Programming General / Spaceship Operator
« Last post by Hooman on December 10, 2018, 02:39:38 PM »
Ohh, the Spaceship operator <=> is coming to C++20.

This allows you to define a single three-way comparison operator <=>, and the compiler can auto generate all other comparison operators from it: ==, !=, <, >, <=, >=

Example (from cppreference.com):
Code: cpp [Select]

class Point {
 int x;
 int y;
public:
 auto operator<=>(const Point&) const = default;
 /* ... non-comparison functions ... */
};

/* compiler generates all six relational operators */
Point pt1, pt2;
if (pt1 == pt2) { /*...*/ } /* ok */
std::set<Point> s; /* ok */
s.insert(pt1); /* ok */
if (pt1 <= pt2) { /*...*/ } /* ok, makes only a single call to <=>  */


References:
cppreference.com - Default Comparisons
cppreference.com - Comparison Operators - Three Way Comparison
Library Support for the Spaceship (Comparison) Operator


EDIT (leeor_net): Fix code syntax highlighting.
10
Feedback/Suggestions/Problems / Re: SVN Certificate Issue
« Last post by Hooman on December 09, 2018, 10:17:52 AM »
The SVN server is running again.

I've updated my backup copy. I'll look into a way to automating the backup so it stays up to date.
Pages: [1] 2 3 ... 10