There's always a try catch.

I added some try catch statements to a few places. One reason for this is to prevent people from causing exceptions on purpose to produce undesirable results.

Each poll of the server is not in a try catch that way if a user sends a packet that somehow causes an exception no other users will be effected. I still plan to add validation to the manager classes but it is impossible for me to think of every single exploit before anyone else thinks of it. So I plan to monitor the exceptions once I have a server up and make fixes based on the exceptions.

After all I can't have one rouge user bringing down the server and causing everyone to get disconnected.

I also added a try catch to the execute command callback. I'm doing some tricky parsing stuff and any failure on the user's part to correctly form a command could cause an exception. So rather than have the game just die I'm spitting out a console message and give the user an invalid/unknown command message.

I don't want invalid user input to crash the game under any circumstances. If there is a hardware problem of some kind that makes sense to allow as crash because continuing to run may cause harm to the user's system for character data.

I have also been looking into the performance cost of exceptions in c++. I have always heard & read that exceptions are expensive. And some of my research agrees. However I have also found some articles/posts that say it is very inexpensive and should be used where ever needed.

What I'm thinking though is that most of the libraries I'm using throw exceptions so I have no choice but to add exception handling. I think I will avoid throwing exceptions in my code as much as possible but I will add exception handling where ever it seems appropriate.

Also I will try to keep exception handling out of the main loop as much as possible.

http://www.gamedev.net/reference/articles/article953.asp
http://bytes.com/groups/cpp/590545-whats-cost-try-block
http://www.crazyontap.com/topic.php?TopicId=34384
https://developer.mozilla.org/en/C___Portability_Guide

Comments

Popular posts from this blog

VK9 - Milestone8 Completed

VK9 - Milestone13 Completed

VK9 - Milestone16 Completed