We are looking to rent a dedicated server pretty soon to host Zero Gear game servers as well as other services. We are hoping to get some suggestions from people for good (and cheap!) servers.
Here is what we are basically looking for:
1. We need full access. We have multiple software servers to run on the machine and need to be able to customize things to our liking.
2. Windows OS is required for the time being.
3. Hopefully around $100 a month but we are able to go a bit over if it is worth it.
4. It needs to have enough bandwidth and speed to host a few game servers. I don't have exact numbers for this yet but think a few TF2 or CS:S servers.
5. We want this first server to be in the L.A. or Bay Area in California.
If you have a suggestion, please leave a comment or better yet, reply to this forum post.
Now, on to the code!
Exposing the privates of a class to other classes explicitly
I have been told that title sounds dirty. I don't understand why.
This post will only be of interest to programmers who use C++ (and maybe programmers in general). No artsy fartsy stuff going on here.
Say I am designing a NetworkManager class. This class has a SendPacket() function that I don't want to expose to the public. However, I do want some classes, like my GameObject class, to have access to SendPacket().
The obvious solution is this:
class NetworkManager
{
public:
...
private:
friend class GameObject;
void SendPacket(int packet);
void ManageConnections(void);
etc...
};
This works but has a few problems. First of all, we don't want GameObject to have access to ManageConnections(). Also, we later discover that the ChatManager class needs access to SendPacket as well. The lesson: friendship is hard.
The solution I use is to create an accessor class which is friend to NetworkManager and only exposes the SendPacket function. Then any other class can use this accessor to send a packet.
The best part about this is that I can be very explicit about which parts of NetworkManager I expose.
Code is the best explanation:
class NetworkManager
{
private:
friend class SendPacketAccessor;
void SendPacket(int packet)
{
//Success!
}
};
class SendPacketAccessor
{
public:
void SendPacket(NetworkManager & netManager, int packet)
{
//We have access to SendPacket()!
netManager.SendPacket(packet);
}
};
class GameObject
{
public:
void Update(NetworkManager & netManager)
{
//We have access to SendPacket() though the accessor
accessor.SendPacket(netManager, 1);
}
private:
//Our key to SendPacket()
SendPacketAccessor accessor;
};
class ChatManager
{
public:
void Update(NetworkManager & netManager)
{
accessor.SendPacket(netManager, 2)
}
private:
SendPacketAccessor accessor;
};
void main(void)
{
NetworkManager netManager;
GameObject obj1;
ChatManager chat;
obj1.Update(netManager);
chat.Update(netManager);
}
If other parts of NetworkManager needed to be exposed, those parts should have special accessors just like SendPacket() does.