Create pymod function for translating void pointers to players

Issue #1 wontfix
d1st0rt created an issue

In <<changeset c69aa5c4ded7>> support was added to Pymod for passing void pointers around as PyCObjects. There is currently no way to extract any relevant data from a PyCObject on the Python side as it is just a wrapper object. Pymod should be updated to include a function that can be called from Python such as asss.void_to_player(obj) that will return a Python player object if the PyCObject that was passed is indeed a player.

Comments (5)

  1. d1st0rt reporter

    This is going to be really dangerous unless I add something similar to MODMAN_MAGIC to the top of the player structure. Can anybody think of things that would break if I did that?

  2. grelminar repo owner

    That doesn't sound right. If something is a player, it should be marked as a player and not a void, and then it'll be converted automatically. voids should only be used when there is no appropriate python representation. How did you end up with a PyCObject holding a Player* ?

  3. d1st0rt reporter

    I was actually thinking ahead to something I wanted to do down the road in a fork of the hosted game core to essentially get rid of the "hosted" requirement. How I envisioned it in C was that it would change from things like int StartGame(Arena *a, Player *host) to int StartGame(Arena *a, int how, void *clos) and the how parameter would dictate what was contained in the pointer. After some thought I think it is probably a better idea to use a custom union type like Target and have it converted automatically to whatever it should be in Python modules.

  4. Log in to comment