Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!

1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


Member Since 28 Feb 2011
Online Last Active Today, 03:59 PM

#5232888 Does My Connection Influence Other Teammates's Connections?

Posted by Bacterius on 04 June 2015 - 10:11 PM

It's a common misconception that so-called "high pingers" are ruining everyone else's connection. The server, if it is properly written, does not care if a player has 1000ms latency while another has 20ms latency, its internal authoritative game state is independent of the player's respective latencies, so if there's a player with a high ping in the game it should not affect other people's connection quality.


What is true however is that it can be frustrating to play against someone with a vastly higher (or, correspondingly, lower) ping than you, because (if he has a higher ping) he doesn't update his position/velocity information with the server very often, which causes the network interpolation algorithm to be very inaccurate, making the guy rubberband all over the place and generally being hard to hit, or (if he has a lower ping) your actions are so delayed compared to his that by the time your "shoot in this direction" action has reached the server, the guy has already moved and shot you back (but it doesn't look that way on your screen as the server hasn't had time to send you the information yet).


TL;DR: it can be problematic to play against someone with a very different ping from yours, but unless the game is really badly implemented, the mere existence of a high-ping player somewhere on the server does not cause everyone else's ping to suffer

#5232504 Sacrificing time: Elegance vs crude coding

Posted by Bacterius on 02 June 2015 - 07:17 PM

I don't really understand the image processing problem, but anyway I don't see what egoism or evil has to do with it. Perhaps it would have been wise to give up after a few days of work after realizing it would be too difficult to implement the correct algorithm, and just use the less optimal, less flexible approach to save time. Managing your priorities is part of a programmer's work.


That said I find that when I am stuck on a low-level problem like this and making no progress for days, it helps to step back a bit; in my experience you tend to tunnel-vision on your specific problem after a while, and that's not good because it prevents you from approaching the problem from a different angle that might lead to a simpler solution.

#5231836 In 2d, it's an Arc, but what is the shape called in 3d?

Posted by Bacterius on 30 May 2015 - 07:35 AM

To summarize, if you want the arc (the portion of the CIRCLE that is "in between" the two angles, as a 1D curve) then the equivalent is spherical cap (as a 2D surface), if you want the sector/"piece of a pie" (the portion of the DISK that is "in between" the two angles, as a 2D area) then the equivalent is a spherical sector (as a 3D volume).

#5231379 Infinite Fractal

Posted by Bacterius on 27 May 2015 - 07:11 PM

The obvious fix is to switch to higher precision at some zoom level, but that can be much slower and less well supported by graphics cards. To zoom infinitely deep would require arbitrary precision arithmetic, which is very slow to implement in any reasonable way on graphics cards (all those "super-deep" zooms you see on Youtube are made with CPU's and are not rendered in realtime). You could settle for some "nice" precision like, say, 256-bit arithmetic, and optimize the add/multiply operations on the graphics cards, you'll eventually reach a limit but it should still be realtime at that precision and you'll be able to zoom much further in.


There's also some advanced techniques to get more out of 32-bit floating-point precision, utilizing things like perturbation theory, but that can be tricky to implement (worth looking into). But at the end of the day if you truly want infinite precision you pretty much need to resign yourself to the fact that the further you zoom in, the more precision you need, and the slower it's going to be, so CPU's + offline rendering are king for really deep zooms.

#5231185 Is it advisable to use a scoped_ptr in CreateFrame? (D3DX9)

Posted by Bacterius on 27 May 2015 - 12:24 AM

There's a built-in contradiction in your post: you say you want the pointer to be scoped to the CreateFrame function (meaning it will be freed upon leaving the function) but you also want to return it for use outside of the function (meaning it can't be freed upon leaving the function). Which is it? And I think just returning a pointer like that does suggest that you have a structural problem with your memory ownership model. Who (meaning which program module/component) owns this pointer, who eventually frees it, and why does CreateFrame have to allocate it, if it's just doing some minor initialization work? You need to think about these things, just trying out every smart pointer variety until it works doesn't work very well smile.png

#5230944 SSE denormals

Posted by Bacterius on 25 May 2015 - 06:38 PM

A little off-topic but



demoralized numbers




#5230748 What's the deal with setting multiple viewports on the rasterizer?

Posted by Bacterius on 24 May 2015 - 06:14 PM

The SV_ViewportArrayIndex semantic allows you to select which viewport from this array to use on the fly, instead of constantly switching viewports in the API, note that the viewport bounds you choose must eventually find their way onto the graphics card for the rasterizer to use, so passing a new viewport is just like any other state change. Apparently it's a semantic applied to the geometry shader output, but I would imagine you can apply it to the vertex shader output if you have no geometry shader (I may be wrong on this).

#5230675 [SharpDX] Loading texture from file

Posted by Bacterius on 24 May 2015 - 08:07 AM

All these texture classes (Direct3D9.Texture, Direct3D11.Texture{1,2,3}D, etc) also have FromFile() static methods that you can use, along with FromMemory() and FromStream(). For instance http://sharpdx.org/documentation/api/m-sharpdx-direct3d11-resource-fromfile--1-1. Have you tried these?

#5230246 Circle Circle intersection help

Posted by Bacterius on 21 May 2015 - 07:13 AM

Vector2 p2 = new Vector2((float)(c1.p.X + (a * (c2.p.X - c1.p.X)) / d), (float)(c1.p.Y + (a * c2.p.Y - c1.p.Y) / d));

That line looks suspect. If you write it properly it actually reads:

Vector2 p2 = new Vector2((float)(c1.p.X + (a * (c2.p.X - c1.p.X)) / d),
                         (float)(c1.p.Y + (a * c2.p.Y - c1.p.Y) / d));

It seems like you're missing a pair of brackets, and that it should actually be:

Vector2 p2 = new Vector2((float)(c1.p.X + (a * (c2.p.X - c1.p.X)) / d),
                         (float)(c1.p.Y + (a * (c2.p.Y - c1.p.Y)) / d));

Remember, the compiler isn't human and isn't going to correct your mistakes (though a clever static analyzer might pick this up). Get into the habit of always trying to write and format your code to decrease the likelihood of such typographical errors.


Note: in this case that also means using vector types to write code that logically represents vector operations, which would have avoided this error. In other words, why does your Vector2 type not have operators that you can use to write "p2 = c1.p + a * (c2.p - c1.p) / d" instead of doing it component-wise here?

#5230199 WTF inconsistent line ending ?

Posted by Bacterius on 21 May 2015 - 12:21 AM

That just means that file ended up with non-windows line endings (such as LF instead of CRLF) for some reason. Possible reasons include:


- you copied some code from the internet that had different line endings into your Cell.cpp file

- you worked on the Cell.cpp file in an editor (or OS) that uses different line endings by default

- the file's line endings were modified by an automated command such as dos2unix

- your hard drive is failing


If the contents of the file are otherwise unchanged you can just normalize them and you're good to go, line endings are just a convention and modern tools are okay at dealing with them...

#5230145 Too clever...?

Posted by Bacterius on 20 May 2015 - 05:49 PM

That seems pretty standard to me, it isn't an optimization it's just the straightforward way to bounds-check a range, the readability does not really go down in my opinion. That said I would personally put the "lastIndexExclusive < firstIndexInclusive" check first since the validity of the other two checks does depend on that condition being true, and also should those indices really be signed ints?

#5230139 Massive Python Example Script

Posted by Bacterius on 20 May 2015 - 05:10 PM

Why would someone new to Python skim a tutorial, and what could he hope to learn by skimming? Also, I feel there are enough tutorials online about basic Python syntax for beginners, how about doing something a little more useful such as how to create runnable Python scripts, creating and managing modules, usage of setup.py/pypi to distribute scripts and programs, etc... you know, the kinds of things that people still have to read through (mostly) technical documentation to figure out. In my opinion this is where clear, well-written tutorials and good code snippets are most urgently needed, everyone and their dog has already written Python intro tutorials and there are some really good ones out there.

#5229501 Running Debug and Release Code Simultaneously

Posted by Bacterius on 17 May 2015 - 04:15 PM

I believe you can set the optimization settings of specific files in the Visual Studio properties, so you can turn all optimizations on in one file and leave them off in the others. If that's not granular enough you can use the #pragma optimize (https://msdn.microsoft.com/en-us/library/chh3fb0k.aspx) option but that's kinda yucky.

#5229499 NitroNet - New, High-Level Networking Library

Posted by Bacterius on 17 May 2015 - 03:29 PM

Im sorry, I dont understand how exactly it would defeat the checksum protection by allowing them to modify the bytes. The checksum will always try to be received regardless of whether or not someone modifies the bytes.

CRC32 is not a cryptographic checksum. It's very easy to modify the bytes in such a way that the modified bytes have the same checksum as the original (for instance https://github.com/theonlypwner/crc32) and it's even easier if one can modify the checksum itself since it's being sent over the wire as well. That's because CRC32 is a cyclic redundancy check, intended as protection against accidental errors such as line noise. It's useless against an opponent (a "hacker"). That's only one vulnerability.

No offense, but I would say it's not very responsible of you towards your users to advertise encryption features if you yourself don't understand what makes a network protocol (in)secure...

#5229496 NitroNet - New, High-Level Networking Library

Posted by Bacterius on 17 May 2015 - 03:12 PM

I designed the IEncryptor interface with the idea in mind that the developer could design any encryption method they would like and implement it using this interface. I did not add any encryption libraries on top, like gnutls, but they certainly could be added. The functionality is there and it works. Im not sure what you mean when you're saying that it is a broken functionality. The IEncryptor interface will pass the bytes of each packet to you before a packet is sent so that you can do whatever you would like to the bytes. What I imagined was that people would use this interface, take the bytes, and use other encryption libraries on top of NitroNet. I left it open for the developer.

Yes, that is my point. That is not sufficient functionality, for an adversary could modify the bytes of the stream on the fly (defeating any checksum "protection" you might have in place) and you would be unable to detect the modification. Actually, you could in principle detect it inside the decrypt() method, but there is no way to report to the program that the bytes have been modified (just throwing an exception is not sufficient, who knows what might be catching it and what kind of side channel attacks can occur when doing this). Basically, encryption is hard, you can't just slap an encrypt() and a decrypt() method and expect it to be "secure". And if you wanted to leave the encryption portion open to developers, then the IEncryptor is not really a feature, since you have to implement it yourself... (which people are really bad at, hence the need for standard presets). Unless you are happy with half-assed security, of course.

In short, I would just drop that feature completely and let the user implement the encryption layer directly on top of the networking library (along with, say, compression, as needed). Since the user needs to implement that layer himself anyway, there is no benefit to using your restrictive and frankly dangerous IEncryptor interface instead of just directly layering it on top of the read() and write() methods of the UDP/TCP classes.