Game Development Reference
In-Depth Information
StrongProcessPtr is managed by the smart pointer class, ensuring that the pro-
cess object will remain in memory as long as there is a valid reference to it. The
moment the last reference is cleared or reassigned, the process memory is finally
freed. That ' s why the ProcessManager has a list of StrongProcessPtr ' s instead
of a list of Process pointers.
A Seriously Nasty Bug on Ultima VIII
One of the trickiest bugs I ever had to find had to do with a special kind of
process in Ultima VIII. Ultima VIII processes could attach their OnUpdate()
calls to a real-time interrupt, which was pretty cool. Animations and other
events could happen smoothly without worrying about the exact CPU speed
of the machine. The process table was getting corrupted somehow, and no
one was sure how to find it as the bug occurred completely randomly
or so
we thought. After tons of QA time and late nights, we eventually found that
jumping from map to map made the problem happen relatively frequently. We
were able to track the bug down to the code that removed processes from the
main process list. It turned out that the real-time processes were accessing the
process list at the same moment that the list was being changed. Thank
goodness, we weren
'
t on multiple processors; we never would have found it.
Here is the definition of the ProcessManager class:
class ProcessManager
{
typedef std::list<StrongProcessPtr> ProcessList;
ProcessList m_processList;
public:
// construction
˜
ProcessManager(void);
// interface
unsigned int UpdateProcesses(unsigned long deltaMs);
WeakProcessPtr AttachProcess(StrongProcessPtr pProcess);
void AbortAllProcesses(bool immediate);
// accessors
unsigned int GetProcessCount(void) const { return m_processList.size(); }
private:
void ClearAllProcesses(void); // should only be called by the destructor
};
 
Search WWH ::




Custom Search