Thursday, February 27, 2014

C++ Avoid Circular Header File Dependencies

In C++, you will get compile errors when header files have a circular dependence on each other. Therefore, it is best to use forward declarations in the header files, and include the header files only in the "cpp" definition files.

However, there are 2 exceptions to this, where you will need to include another header file in the header file:

  1. When you are inheriting from another class, you will need the header class for that class in the header file
  2. When you are using a class as a stack variable rather than dynamically allocated heap variable, you will also need the header file for that class in the header file

Saturday, February 22, 2014

Article on Coordinate Unit Movement

This article provides an in-depth writeup on the various issues, solutions and options relating to multiple units moving in a coordinated way in a game: http://www.gamasutra.com/view/feature/131721/implementing_coordinated_movement.php?print=1

Issues covered include formation movement, and difficult problems such as the "stacked canyon" problem.

Friday, February 21, 2014

SSL Certificate Types

After some changes in 2007, there are now 2 classes of SSL certs:

  1. Domain Verification: only domain ownership verification based on email and/or phone and WHOIS record
  2. Extended Verification: verification of both domain ownership and business entity
DV is cheaper and most CAs issue them within hours. EV requires a few working days and costs more.

In terms of user experience if it's EV, there's a nice looking green bar in some browsers like Chrome. But there's no warning whatsoever for DV. So DV looks to be enough in most cases.

Resources:

Thursday, February 6, 2014

MongoDB Commands for Updating Values Inside Document

This page provides a good compilation: http://jonathanhui.com/mongodb-data-update

MongoDB Updating Entry in Array Within Document

This is done via the "$pop" operation but most examples out there operate on simple objects. Here's how it's done for an array that's deeper within the document.

So e.g. if we have a document like this in the "workshop" collection:


{
"_id" : ObjectId("51e216e55cf2ff1231dee123"),
"info" : {
"name" : “Workshop X”,
"city" : “Sacramento”
}
"inventory" : {
"cars" : [
{
"licensePlate" : "XXXX01",
"make" : “Toyota”
},
{
"licensePlate" : "XXXX02",
"make" : “Kia”
},
{
"licensePlate" : "XXXX03",
"make" : “Hyundai”
},
{
"licensePlate" : "XXXX04",
"make" : “Nissan”
},
{
"licensePlate" : "XXXX05",
"make" : “Honda”
}
]
}
}



We could remove the entry at the bottom of the array with the command:

db.workshop.update({"info.name":"Workshop X"} ,{$pop:{"inventory.cars" : 1}});

Note that if you use the dot notation for accessing attributes deeper into the document, you'll need to surround the expression with quotes.

More documentation on $pop here: http://docs.mongodb.org/manual/reference/operator/update/pop/#up._S_pop