potential timing issues with command processing?

    This site uses cookies. By continuing to browse this site, you are agreeing to our Cookie Policy.

    • potential timing issues with command processing?

      Should commands (translated from user input or from AI) sent to the game logic, be executed immediately? I.e user requests fire weapon, weapon is fired and damage to enemies is applied immediately? Or should it be queued, then processed later?

      I was thinking about possible timing issues that could arise. E.g if an AI requests "move actor 5" but actor 5 was already destroyed earlier by the user. How would I sequence commands being generated from the user and AI, and the processing of these commands to prevent this sort of thing from happening?

      If it was sequenced like this: send user commands to logic, send AI commands to logic, logic processes commands, this could happen, but then the AI and user are acting on the same information (the previous game state).
    • Queuing should be fine. The sequence doesn't really matter; if the actor is destroyed between queuing the event and processing it, you simply discard the event. You don't want to send a raw pointer to the actor along with the event, you want to send either a weak reference or the actor ID. That way, you can test to see if the actor is still alive.

      If you do run into issues, it wouldn't be a big deal to send the event synchronously, but I don't think it's a problem.