diff --git a/sc2/BUGS b/sc2/BUGS index dee29211c..8af425c69 100644 --- a/sc2/BUGS +++ b/sc2/BUGS @@ -95,3 +95,5 @@ The bugs reported but not yet verified: - "Got a segfault too, on cvs version compiled today (2002/12/05), when activating Sun Device over the Chmmr homeworld. Worked fine on 0.1 alpha." + + - Unconfirmed report of lander cargo upgrade rendering as weapon upgrade diff --git a/sc2/ChangeLog b/sc2/ChangeLog index 8d68ca0bf..40803feea 100644 --- a/sc2/ChangeLog +++ b/sc2/ChangeLog @@ -1,4 +1,6 @@ 0.2: +- Thread library now includes condition variables +- Shofixti dialogue fixed to subtitles, by BlckKnght - Crash during loading from orbit fixed, from PhracturedBlue - Starmap issue when orbiting earth fixed, from PhracturedBlue - Oscilloscope is now implemented (OpenAL) diff --git a/sc2/src/sc2code/libs/threadlib.h b/sc2/src/sc2code/libs/threadlib.h index dd152d3c2..ea1f4e44b 100644 --- a/sc2/src/sc2code/libs/threadlib.h +++ b/sc2/src/sc2code/libs/threadlib.h @@ -83,7 +83,6 @@ extern Thread CreateThreadAux (ThreadFunction func, void *data, # define CreateThread(func, data, stackSize, name) \ CreateThreadAux ((func), (data), (stackSize)) #endif /* !defined(THREAD_NAMES) */ -extern void KillThread (Thread thread); extern void SleepThread (TimePeriod timePeriod); extern void SleepThreadUntil (TimeCount wakeTime); extern void TaskSwitch (void); @@ -106,6 +105,12 @@ extern void DestroyMutex (Mutex sem); extern int LockMutex (Mutex sem); extern void UnlockMutex (Mutex sem); +typedef void *CondVar; +extern CondVar CreateCondVar (void); +extern void DestroyCondVar (CondVar); +extern void WaitCondVar (CondVar); +extern void SignalCondVar (CondVar); +extern void BroadcastCondVar (CondVar); #endif /* _THREADLIB_H */ diff --git a/sc2/src/sc2code/libs/threads/sdl/sdlthreads.c b/sc2/src/sc2code/libs/threads/sdl/sdlthreads.c index 74ccb1f5d..e905e487f 100644 --- a/sc2/src/sc2code/libs/threads/sdl/sdlthreads.c +++ b/sc2/src/sc2code/libs/threads/sdl/sdlthreads.c @@ -66,3 +66,15 @@ SDLWrapper_TaskSwitch (void) { SDL_Delay (1); } +void +SDLWrapper_WaitCondVar (CondVar cv) { + int result; + Mutex temp = CreateMutex (); + LockMutex (temp); + result = SDL_CondWait (cv, temp); + UnlockMutex (temp); + DestroyMutex (temp); + if (result != 0) { + fprintf (stderr, "Error result from SDL_CondWait: %d\n", result); + } +} diff --git a/sc2/src/sc2code/libs/threads/sdl/sdlthreads.h b/sc2/src/sc2code/libs/threads/sdl/sdlthreads.h index d5cb5d496..d79b5813d 100644 --- a/sc2/src/sc2code/libs/threads/sdl/sdlthreads.h +++ b/sc2/src/sc2code/libs/threads/sdl/sdlthreads.h @@ -77,5 +77,18 @@ typedef SDL_mutex *NativeMutex; #define NativeUnlockMutex(mutex) \ SDL_mutexV ((mutex)) +typedef SDL_cond *NativeCondVar; +#define NativeCreateCondVar() \ + SDL_CreateCond () +#define NativeDestroyCondVar(condvar) \ + SDL_DestroyCond((condvar)) +#define NativeWaitCondVar(condvar) \ + SDLWrapper_WaitCondVar((condvar)) +#define NativeSignalCondVar(condvar) \ + SDL_CondSignal((condvar)) +#define NativeBroadcastCondVar(condvar) \ + SDL_CondBroadcast((condvar)) + + #endif /* _SDLTHREAD_H */ diff --git a/sc2/src/sc2code/libs/threads/thrcommon.c b/sc2/src/sc2code/libs/threads/thrcommon.c index 5e8b98610..b4710e072 100644 --- a/sc2/src/sc2code/libs/threads/thrcommon.c +++ b/sc2/src/sc2code/libs/threads/thrcommon.c @@ -353,4 +353,27 @@ UnlockMutex (Mutex sem) NativeUnlockMutex ((NativeMutex) sem); } +CondVar +CreateCondVar () +{ + return NativeCreateCondVar (); +} +void DestroyCondVar (CondVar cv) +{ + NativeDestroyCondVar (cv); +} +void WaitCondVar (CondVar cv) +{ + NativeWaitCondVar (cv); +} + +void SignalCondVar (CondVar cv) +{ + NativeSignalCondVar (cv); +} + +void BroadcastCondVar (CondVar cv) +{ + NativeBroadcastCondVar (cv); +}