Brandon's Blog

1/27/2005

(No Title)

Another proof of concept:

Python doesn’t like pointers too much, so how do you identify a Player, Room, Item, or whatever within Python and make the C++ API able to modify the correct object?  Well, here’s an idea that seems to work:

Memory addresses (void*, castable to any class or data type pointer) are of type long int.  Since we’re not in quantum here, only one object can occupy a certain memory address.  So, cast all pointers to classes as long integers and send them via the Python API to the script.  The API functions will accept long’s (not like Python checks types anyway) as arguments to in-script manipulation functions like GiveItem() or something.  When the C++ API receives these longs as arguments, it casts them back to class pointers and dereferences them.

This seems to work.  I like that it seems to work.

Food for thought…