From 13c7b2b3376c36e77425550244ff5f33b923449f Mon Sep 17 00:00:00 2001 From: Darkvater Date: Wed, 1 Jun 2005 23:08:33 +0000 Subject: (svn r2391) - Feature: saving games happen in a seperate thread so you no longer will have to wait such a long time (especially handy on bigger maps and multiplayer games). The mouse also changes into the 'ZZZ' state :P. The thread on windows is currently given a little-bit-less-than-normal priority so it should not interfere that much with the gameplay; it will take a bit longer though. Upon the exit of the game any pending saves are waited upon. - Fix: fixed GetSavegameFormat() so that it takes the best compressor (highest), or a forced one added with the parameter - Open issues: 1. Don't attempt to load a game while saving is in progress, it will kick you back to the intro-screen with only the vast ocean to look at. 2. The server is disabled from threaded-saving, but might be enabled in the future. 3. Current implementation only allows 1 additional running thread. 4. Stupid global variables.....grrr Big thanks for TrueLight and the amazing memorypool :D --- unix.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'unix.c') diff --git a/unix.c b/unix.c index b4c353878..0f98008bb 100644 --- a/unix.c +++ b/unix.c @@ -11,6 +11,7 @@ #include #include #include +#include #if (defined(_POSIX_VERSION) && _POSIX_VERSION >= 200112L) || defined(__GLIBC__) #define HAS_STATVFS @@ -554,3 +555,18 @@ bool InsertTextBufferClipboard(Textbuf *tb) { return false; } + +static pthread_t thread1 = 0; +bool CreateOTTDThread(void *func, void *param) +{ + return (pthread_create(&thread1, NULL, func, param) == 0) ? true : false; +} + +void CloseOTTDThread(void) {return;} + +void JoinOTTDThread(void) +{ + if (thread1 == 0) return; + + pthread_join(thread1, NULL); +} -- cgit v1.2.3-54-g00ecf