Game Development Community

Question regarding copy construction of databaseResult object

by Scott Doerrfeld · in Torque Game Engine · 08/15/2007 (7:27 am) · 1 replies

I'm trying to reduce the number of database queries that take place in my application, so instead of the server querying the database on every client's request, the server is going to have a snapshot of the database that gets updated every minute. I'm storing this in a global variable from the executeevent callback. The problem occurs when two clients try to access the data at the same time, since if I use the same global, then both clients are incrementing the rows simultaneously, and it can possibly crash the server. I've tried to use the new operator and copySource to try to create a new databaseResult object but it only seems to get the first row of the original result set.

Is there a way through script to create a new databaseResult object and then have that new object be an exact copy of another databaseResult object?

#1
08/15/2007 (11:57 am)
You probably want to look at the 'processArguments' method on SimObjects. Overriding this method allows you to process arguments to the new operator. By implementing processArguments for DatabaseResult, you could make a copy constructor that would work from script.