[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: Network game

Hi Jens,

Jens Granseuer wrote:

Henk, if you've got ideas on how to properly do this without threads I'm all ears.

Well, what could we do:

1. Let the game in the normal event loop but have a flag telling that we are waiting for the network player to send us data and only allow things like map scrolling. But this would also need to have kind of timer events which allow us to poll on a regular base for network data. Also it probably doesn't fit in the current program flow? Plus, we would need to disable a lot of things, as the player which waits isn't allow to change stuff on the map during wait.

2. (what I would prefer) Poll in regular intervall for Network data and for events and only process scroll events and redraw the map window in the background and then redraw the network window (with the abort button) in front of it. This could be a loop in Game::StartTurn. You use already a function to poll for network data in Network:Read. Just call it inside the loop, check for events and then sleep for 100 ms or such. When scroll events occur scroll the map window in the background, when network data arrives, break and process it. You might open the network-abort window very small in the upper left corner, would make it easier to study the map during the wait.

This should work in every port, at least it even works with Palm OS, which has a very basic API :-)

Regards Henk

  Henk Jonas
  Palm OS ® certified developer

  metaview@xxxxxx                                   www.metaviewsoft.de