Jump to content

  • Log In with Google      Sign In   
  • Create Account

Madhed

Member Since 13 Jun 2001
Offline Last Active May 02 2016 02:22 PM

#5269459 How Is This Pixel Art So Detailed?

Posted by Madhed on 05 January 2016 - 12:24 PM

Like Lorenzo said, it's not particularly detailed.

 

If you want to see truly detailed pixel art, search for Metal Slug or anything done by Paul Robertson.




#5268907 Fun Challenge: Implement Polymorphic Callback

Posted by Madhed on 02 January 2016 - 07:30 PM

I made this when I realized C++ is lacking in that department

 

[...]

 

Its just a pointer to a function and a pointer to an object (which is null if its free function). Ive only done primitive testing on it so it might be breaking some rule somewhere, but maybe you get ideas.

 

You are relying on vendor specific behaviour. :)

Calling conventions are up to the compiler and platform. So calling the member function as a free function with an implicit this argument might fail.

 

But as long as it works...

It's the same trick that the FastDelegate library uses. Only it has compile switches for a dozen compilers or so. :D




#5268709 Fun Challenge: Implement Polymorphic Callback

Posted by Madhed on 01 January 2016 - 08:44 AM

class IDelegate {
public:
    virtual void invoke() = 0;
};

template<class T>
class Delegate : public IDelegate {
    T* instance;
    void (T::*method)();

public:
    Delegate(T* inst, void (T::*met)()) : instance(inst), method(met) {
    }

    void invoke() {
        (instance->*method)();
    }
};

// ---------------------

class Callable {
public:
    void foo() {
        std::cout << "foo called\n";
    }
};

Callable instance = new Callable();
IDelegate del = new Delegate<Callable>(instance, &Callable::foo);
del->invoke();

 
 
This uses a virtual call but is type safe.

EDIT: There is also the FastDelegate library by Don Clugston which uses some (apparently widely supported) hacks to achieve the same without virtual function calls. I don't know if the library is still recommended as it was implemented 10 years ago... I only know that the Spotify client on windows has it listed on its credits screen. smile.png


#5268187 How Does One Create A Walk Cycle?

Posted by Madhed on 28 December 2015 - 05:31 AM

Use some reference frames and put them behind your character while drawing.

When you have done that a few times it will beome very easy to do it without any reference.




#5260221 The Big List of Good Design Practices

Posted by Madhed on 02 November 2015 - 05:44 PM

Document every issue, as minor as it may seem. Lots of bugs can be forgotten because "I don't have time for that now, will look at it later"




#5259979 Armour penetration and firearms

Posted by Madhed on 01 November 2015 - 07:22 AM

You could subtract a fixed amount from the DPS when armored and limit the damage to be between 0 and 100.

 

Base DPS:

 

Pistol: 100 DMG

Rifle: 150 DMG

Sniper: 200 DMG

 

Without armor:

 

Pistol: 100 DMG

Rifle: 100 DMG

Sniper: 100DMG

 

With armor that subtracts 100DMG:

 

Pistol: 0 DMG

Rifle: 50 DMG

Sniper: 100 DMG




#5257813 combating udp flood attacks

Posted by Madhed on 18 October 2015 - 02:56 PM

Thanks guys, really great responses.

What about a single person that tries to disturb your service from a typical home line? Would such an event even register if you have enough bandwidth and your server isn't written in a completely dumb way, like forwarding malicious packets deep inside your game before they are discarded?




#5257807 combating udp flood attacks

Posted by Madhed on 18 October 2015 - 02:12 PM

Interesting, I have heard of iptables in a typical web setup before but somehow didn't make the connetion to it being used on a game server. Need to jot down.

But basically this means it's only worthwhile to prepare for these kinds of attacks if you have a large production running and can afford the costs.




#5257796 combating udp flood attacks

Posted by Madhed on 18 October 2015 - 12:11 PM

This is a theoretical question that I have wondered about, so I have no actual code to show here.

 

Say I have a game server that is accepting client packets at a publicly known port. What is a common method to handle a client trying to DOS the server by flooding it with udp packets?

 

1. There is a portable way to block communication with a specific IP at the operating system level. I don't know if this atually exists, but it would probably be the most effective solution.

 

2. Close the known socket and reopen it on another port. While this prevents the rogue packets from reaching the appliation, the operating system still has to handle the packets before it can decide to drop them.

I guess this is cheaper than to drop them at the application level, but it still puts some strain on the system.

Also, the server still has to announce the new port eventually and the attack could continue there.

 

Did someone here deal with this before?




#5257134 Class / array question

Posted by Madhed on 13 October 2015 - 05:34 PM

You can iterate a std::vector like a normal array using the subscript operator (square brackets)

mObject->vertices[0] // returns the first vertex

Vector is a weird name for that container, especially if you are coming from a math/graphics background.

std::vector is just a dynamic array that you can resize and it manages the memory for you.

You can call vertices.size() to get the number of vertices, vertices.push_back(vertex) to append a new vertex and more cool stuff.

 

I'd suggest you go through a beginner's tutorial for the stl container classes as they are a fundamental building block of modern c++.




#5257127 Class / array question

Posted by Madhed on 13 October 2015 - 05:06 PM

Ah!

 

You are trying to initialize a vector of VertexPos with a list of XMFLOAT3's which is not going to work.

 

So either you need to make it std::vector<XMFLOAT3> or put another pair of parentheses around the initializer elements like so:

mObject->vertices =
{
	{XMFLOAT3(0,0,0)}, {XMFLOAT3(0,0,0)}, {XMFLOAT3(0,0,0)}
};



#5257121 Class / array question

Posted by Madhed on 13 October 2015 - 04:50 PM

Weird, I just tried with VS.net 2015 community edition and it works. Can you post the code of the VertexPos class and the way you initialize the list?




#5257115 Class / array question

Posted by Madhed on 13 October 2015 - 04:20 PM

you can use a std::vector.

 

If your compiler supports c++11 you can even use the array initializer syntax like in your example.

#include <vector>

class Object
{
public:
	Object(){}
	~Object(){}

	std::vector<VertexPos> vertices;
private:
};

mObject->vertices = { ... }



#5256878 Variable size strucs

Posted by Madhed on 12 October 2015 - 10:33 AM


Yes indeed. But then, how do you define the "material" object ? This material object will need to have thoses fields anyway with the arrays

 

Well, the main idea is that not every draw item will have a unique combination of shaders and textures, etc. By moving the shared data into a material you will save memory in your main draw queue, it's basically the flyweight pattern.

 

Also you will want to sort your render queue by some criteria which will probably include a material id. Since the number of materials will hopefully be much less than the actual number of draw calls you could use some "heavier" data structures like vectors for the varying length parameters like textures and constants.




#5254146 MySQL statement error

Posted by Madhed on 26 September 2015 - 09:37 AM

No. NULL is very different from 0. NULL basically means the value of this field is not known, whereas 0 is a known numerical value.




PARTNERS