subchannel13 / Stareater

4X turn based strategy
GNU General Public License v3.0
32 stars 7 forks source link

Message queue in space combat API #117

Closed subchannel13 closed 6 years ago

subchannel13 commented 6 years ago

Previous space combat play order implementation had potential to overflow stack. Each request to AI play a unit and response to combat controller would happen on the same thread adding function calls to the stack with each exchange. Stack would be reduced to "normal" level only when human player would get his turn (or when combat would end) by accidental nature of GUI implementation.

With message queue which manages play from separate thread such issue would be averted and it opens up a room for better flow control (only one player can play at the time) and validity check (did correct player play the proper unit at proper time).