Game Development Community

Adding support of 64-bit integer to Torque

by Koh Hwee Miin · in Torque 3D Professional · 07/15/2010 (7:37 am) · 4 replies

I'm working with Torque3D 1.0.1, and I discover that Torque does not support 64-bit integer, but my game need to keep track of a lot of data in 64-bit integer and performs a lot of arithmetic operations on them. After searching through the forum I conclude that there are 2 ways to do it:

1. Use String in script, then add Console functions to convert String to _int64 when performing arithmetic operations and then convert the result to String again. This should be the easier way but I'm worrying about performance overhead caused by the conversion.

2. Added U64/S64 type to Torque, but this seem like going to be a lot of work, as far as I know the modifications will involve the console, the script engine, the journal module. I'm new to Torque so this look like a risky move to me, I wonder if anyone ever tried to did it successfully? If so, hope you won't mind to share the experience?

Thanks.

#1
08/02/2010 (4:26 pm)

64bit integer types (U64, S64) are already defined in the engine and can be used where needed. Or are you talking about adding 64bit arithmetic to TorqueScript?
#2
08/03/2010 (3:00 am)
Yes, I'm referring to 64-bit arithmetic to TorqueScript, including passing/return 64-bit integer between console functions and scripts.
#3
08/03/2010 (3:21 am)

Then 1 is the easier way. Adding 64bit ints to TorqueScript's VM is a bit more work except you switch the 32bit ints completely to 64bits. Very straightforward but not a good thing for a 32bit executable.

1 is pretty trivial. Add a TypeS64 to consoleTypes akin to TypeS32. To work with the type, add a couple of functions to do arithmetic, etc.

Since all data is passed as strings in TS, both approaches end up converting to and from strings, though. The integer and floating-point support itself in the TS VM is more an optimization.
#4
08/03/2010 (6:15 am)
Thanks Rene, I'll give it a try.