예제 #1
0
// -----------------------------------------------------------------------------
static void EventHandler(char *pszMsg, void *pUser)
{
	CONNINST *pInst = (CONNINST*)pUser;
	unsigned int uiLen = strlen (pszMsg);
	static BOOL bFirstLogin = TRUE;

	if (pInst->hProxy->pCfg->bVerbose && pInst->hProxy->pCfg->fpLog)
	{
		fprintf (pInst->hProxy->pCfg->fpLog, "%03d> %s\n", pInst->hSock, pszMsg);
		fflush (pInst->hProxy->pCfg->fpLog);
	}
	if (bFirstLogin && strncmp (pszMsg, "CONNSTATUS", 10) == 0 &&
		strcmp(pszMsg+11, "CONNECTING"))
	{
		pInst->iConnectionStat = (strcmp(pszMsg+11, "ONLINE")==0);
		UnlockMutex (pInst->connected);
		bFirstLogin = FALSE;
	}
	LockMutex(pInst->sendmutex);
	if (!(SendPacket (pInst, &uiLen, sizeof(uiLen)) && SendPacket (pInst, pszMsg, uiLen)))
	{
		//Dispatcher_Stop(pInst);
		//FreeConnection (pInst);
	}
	UnlockMutex(pInst->sendmutex);
}
예제 #2
0
void
PlanetOrbitMenu (void)
{
	MENU_STATE MenuState;
	InputFrameCallback *oldCallback;

	memset (&MenuState, 0, sizeof MenuState);

	DrawMenuStateStrings (PM_SCAN, SCAN);
	LockMutex (GraphicsLock);
	SetFlashRect (SFR_MENU_3DO);
	UnlockMutex (GraphicsLock);

	MenuState.CurState = SCAN;
	SetMenuSounds (MENU_SOUND_ARROWS, MENU_SOUND_SELECT);
	oldCallback = SetInputCallback (on_input_frame);

	MenuState.InputFunc = DoPlanetOrbit;
	DoInput (&MenuState, TRUE);

	SetInputCallback (oldCallback);

	LockMutex (GraphicsLock);
	SetFlashRect (NULL);
	UnlockMutex (GraphicsLock);
	DrawMenuStateStrings (PM_STARMAP, -NAVIGATION);
}
예제 #3
0
void
TFB_DrawImage_SetMipmap (TFB_Image *img, TFB_Image *mmimg, int hotx, int hoty)
{
	bool imgpal;
	bool mmpal;

	if (!img || !mmimg)
		return;

	LockMutex (img->mutex);
	LockMutex (mmimg->mutex);
	
	// Either both images must be using the same colormap, or mipmap image
	// must not be paletted. This restriction is due to the current
	// implementation of fill-stamp, which replaces the palette with
	// fill color.
	imgpal = TFB_DrawCanvas_IsPaletted (img->NormalImg);
	mmpal = TFB_DrawCanvas_IsPaletted (mmimg->NormalImg);
	if (!mmpal || (mmpal && imgpal &&
			img->colormap_index == mmimg->colormap_index))
	{
		img->MipmapImg = mmimg->NormalImg;
		img->MipmapHs.x = hotx;
		img->MipmapHs.y = hoty;
	}
	else
	{
		img->MipmapImg = NULL;
	}

	UnlockMutex (mmimg->mutex);
	UnlockMutex (img->mutex);
}
예제 #4
0
void
TFB_DrawImage_CopyRect (TFB_Image *source, const RECT *srcRect,
		TFB_Image *target, POINT dstPt)
{
	LockMutex (source->mutex);
	LockMutex (target->mutex);
	TFB_DrawCanvas_CopyRect (source->NormalImg, srcRect,
			target->NormalImg, dstPt);
	target->dirty = TRUE;
	UnlockMutex (target->mutex);
	UnlockMutex (source->mutex);
}
예제 #5
0
void arith_frame_blit (FRAME srcFrame, const RECT *rsrc, FRAME dstFrame,
		const RECT *rdst, int num, int denom)
{
	TFB_Image *srcImg, *dstImg;
	SDL_Surface *src, *dst;
	SDL_Rect srcRect, dstRect, *srp = NULL, *drp = NULL;
	srcImg = srcFrame->image;
	dstImg = dstFrame->image;
	LockMutex (srcImg->mutex);
	LockMutex (dstImg->mutex);
	src = (SDL_Surface *)srcImg->NormalImg;
	dst = (SDL_Surface *)dstImg->NormalImg;
	if (rdst)
	{
		dstRect.x = rdst->corner.x;
		dstRect.y = rdst->corner.y;
		dstRect.w = rdst->extent.width;
		dstRect.h = rdst->extent.height;
		drp = &dstRect;
	}
	if (rsrc)
	{
		srcRect.x = rsrc->corner.x;
		srcRect.y = rsrc->corner.y;
		srcRect.w = rsrc->extent.width;
		srcRect.h = rsrc->extent.height;
		srp = &srcRect;
	}
	else if (srcFrame->HotSpot.x || srcFrame->HotSpot.y)
	{
		if (rdst)
		{
			dstRect.x -= srcFrame->HotSpot.x;
			dstRect.y -= srcFrame->HotSpot.y;
		}
		else
		{
			dstRect.x = -srcFrame->HotSpot.x;
			dstRect.y = -srcFrame->HotSpot.y;
			dstRect.w = GetFrameWidth (srcFrame);
			dstRect.h = GetFrameHeight (srcFrame);
			drp = &dstRect;
		}

	}
	TFB_BlitSurface (src, srp, dst, drp, num, denom);
	UnlockMutex (srcImg->mutex);
	UnlockMutex (dstImg->mutex);
}
예제 #6
0
BOOLEAN
DoSaveTeam (MELEE_STATE *pMS)
{
	STAMP MsgStamp;
	char file[NAME_MAX];
	uio_Stream *stream;
	CONTEXT OldContext;
	bool saveOk = false;

	snprintf (file, sizeof file, "%s.mle",
			MeleeSetup_getTeamName (pMS->meleeSetup, pMS->side));

	LockMutex (GraphicsLock);
	OldContext = SetContext (ScreenContext);
	ConfirmSaveLoad (&MsgStamp);
			// Show the "Saving . . ." message.
	UnlockMutex (GraphicsLock);

	stream = uio_fopen (meleeDir, file, "wb");
	if (stream != NULL)
	{
		saveOk = (MeleeTeam_serialize (&pMS->meleeSetup->teams[pMS->side],
				stream) == 0);
		uio_fclose (stream);

		if (!saveOk)
			uio_unlink (meleeDir, file);
	}

	pMS->load.top = 0;
	pMS->load.cur = 0;

	// Undo the screen damage done by the "Saving . . ." message.
	LockMutex (GraphicsLock);
	DrawStamp (&MsgStamp);
	DestroyDrawable (ReleaseDrawable (MsgStamp.frame));
	SetContext (OldContext);
	UnlockMutex (GraphicsLock);

	if (!saveOk)
		SaveProblem ();

	// Update the team list; a previously existing team may have been
	// deleted when save failed.
	LoadTeamList (pMS);
	SelectTeamByFileName (pMS, file);
	
	return (stream != 0);
}
예제 #7
0
BOOLEAN
TFB_DrawImage_Intersect (TFB_Image *img1, POINT img1org,
		TFB_Image *img2, POINT img2org, const RECT *interRect)
{
	BOOLEAN ret;

	LockMutex (img1->mutex);
	LockMutex (img2->mutex);
	ret = TFB_DrawCanvas_Intersect (img1->NormalImg, img1org,
			img2->NormalImg, img2org, interRect);
	UnlockMutex (img2->mutex);
	UnlockMutex (img1->mutex);

	return ret;
}
예제 #8
0
파일: music.c 프로젝트: Serosis/UQM-MegaMod
BOOLEAN
_ReleaseMusicData (void *data)
{
	TFB_SoundSample **pmus = data;
	TFB_SoundSample *sample;

	if (pmus == NULL)
		return (FALSE);

	sample = *pmus;
	assert (sample != 0);
	if (sample->decoder)
	{
		TFB_SoundDecoder *decoder = sample->decoder;
		LockMutex (soundSource[MUSIC_SOURCE].stream_mutex);
		if (soundSource[MUSIC_SOURCE].sample == sample)
		{	// Currently playing this sample! Not good.
			StopStream (MUSIC_SOURCE);
		}
		UnlockMutex (soundSource[MUSIC_SOURCE].stream_mutex);

		sample->decoder = NULL;
		SoundDecoder_Free (decoder);
	}
	TFB_DestroySoundSample (sample);
	FreeMusicData (data);

	return (TRUE);
}
예제 #9
0
파일: cmap.c 프로젝트: jurchik/project6014
static void
FlushFadeXForms (void)
{
	LockMutex (XFormControl.Lock);
	finishPendingFade ();
	UnlockMutex (XFormControl.Lock);
}
예제 #10
0
파일: cmap.c 프로젝트: jurchik/project6014
int
GetFadeAmount (void)
{
	int newAmount;

	LockMutex (XFormControl.Lock);

	if (fadeInterval)
	{	// have a pending fade
		TimeCount Now = GetTimeCounter ();
		sint32 elapsed;
		
		elapsed = Now - fadeStartTime;
		if (elapsed > fadeInterval)
			elapsed = fadeInterval;

		newAmount = fadeAmount + (long)fadeDelta * elapsed / fadeInterval;

		if (elapsed >= fadeInterval)
		{	// fade is over
			fadeAmount = newAmount;
			fadeInterval = 0;
		}
	}
	else
	{	// no fade pending, return the current
		newAmount = fadeAmount;
	}

	UnlockMutex (XFormControl.Lock);

	return newAmount;
}
예제 #11
0
파일: cmap.c 프로젝트: jurchik/project6014
void
TFB_ReturnColorMap (TFB_ColorMap *map)
{
	LockMutex (maplock);
	release_colormap (map);
	UnlockMutex (maplock);
}
예제 #12
0
static void
DrawRestartMenu (BYTE OldState, BYTE NewState, FRAME f)
{
	RECT r;
	TEXT t;
	UNICODE buf[64];

	LockMutex (GraphicsLock);
	SetContext (ScreenContext);
	r.corner.x = r.corner.y = r.extent.width = r.extent.height = 0;
	SetContextClipRect (&r);
	r.corner.x = 0;
	r.corner.y = 0;
	r.extent.width = SCREEN_WIDTH;
	r.extent.height = SCREEN_HEIGHT;
	SetFlashRect (&r, SetAbsFrameIndex (f, NewState + 1));

	// Put version number in the corner
	SetContextFont (TinyFont);
	t.pStr = buf;
	t.baseline.x = SCREEN_WIDTH - 3;
	t.baseline.y = SCREEN_HEIGHT - 2;
	t.align = ALIGN_RIGHT;
	t.CharCount = (COUNT)~0;
	sprintf (buf, "v%d.%d.%d%s", UQM_MAJOR_VERSION, UQM_MINOR_VERSION,
			UQM_PATCH_VERSION, UQM_EXTRA_VERSION);
	SetContextForeGroundColor (WHITE_COLOR);
	font_DrawText (&t);

	UnlockMutex (GraphicsLock);
	(void) OldState;  /* Satisfying compiler (unused parameter) */
}
예제 #13
0
void
AlienTalkSegue (COUNT wait_track)
{
	// this skips any talk segues that follow an aborted one
	if ((GLOBAL (CurrentActivity) & CHECK_ABORT) || TalkingFinished)
		return;

	if (!pCurInputState->Initialized)
	{
		InitSpeechGraphics ();
		LockMutex (GraphicsLock);
		SetColorMap (GetColorMapAddress (CommData.AlienColorMap));
		SetContext (AnimContext);
		DrawAlienFrame (NULL, 0, TRUE);
		UpdateSpeechGraphics ();
		CommIntroTransition ();
		UnlockMutex (GraphicsLock);
		
		pCurInputState->Initialized = TRUE;

		PlayMusic (CommData.AlienSong, TRUE, 1);
		SetMusicVolume (BACKGROUND_VOL);

		InitCommAnimations ();

		LastActivity &= ~CHECK_LOAD;
	}
	
	TalkingFinished = TalkSegue (wait_track);
	if (TalkingFinished)
		FadeMusic (FOREGROUND_VOL, ONE_SECOND);
}
예제 #14
0
static COUNT
DeltaCredit (SIZE delta_credit)
{
	COUNT Credit;

	Credit = MAKE_WORD (
			GET_GAME_STATE (MELNORME_CREDIT0),
			GET_GAME_STATE (MELNORME_CREDIT1)
			);
	if ((int)delta_credit >= 0 || ((int)(-delta_credit) <= (int)(Credit)))
	{
		Credit += delta_credit;
		SET_GAME_STATE (MELNORME_CREDIT0, LOBYTE (Credit));
		SET_GAME_STATE (MELNORME_CREDIT1, HIBYTE (Credit));
		LockMutex (GraphicsLock);
		DrawStatusMessage ((UNICODE *)~0);
		UnlockMutex (GraphicsLock);
	}
	else
	{
		NPCPhrase (NEED_MORE_CREDIT0);
		NPCPhrase (delta_credit + (int)Credit);
		NPCPhrase (NEED_MORE_CREDIT1);
	}
	
	return (Credit);
}
예제 #15
0
static void
post_melnorme_enc (void)
{
	LockMutex (GraphicsLock);
	DrawStatusMessage (0);
	UnlockMutex (GraphicsLock);
}
예제 #16
0
void 
TFB_DrawImage_Delete (TFB_Image *image)
{
	if (image == 0)
	{
		log_add (log_Warning, "INTERNAL ERROR: Tried to delete a null image!");
		/* Should we die here? */
		return;
	}
	LockMutex (image->mutex);

	TFB_DrawCanvas_Delete (image->NormalImg);
			
	if (image->ScaledImg)
	{
		TFB_DrawCanvas_Delete (image->ScaledImg);
		image->ScaledImg = 0;
	}

	if (image->FilledImg)
	{
		TFB_DrawCanvas_Delete (image->FilledImg);
		image->FilledImg = 0;
	}

	UnlockMutex (image->mutex);
	DestroyMutex (image->mutex);
			
	HFree (image);
}
예제 #17
0
static void Imo2sproxy_Exit(IMO2SPROXY *hInst)
{
	IMO2SPROXY_INST *hProxy = (IMO2SPROXY_INST*)hInst;
	CONNINST *pInst;

	if (hProxy->pCfg->bVerbose && hProxy->pCfg->fpLog)
		fprintf (hProxy->pCfg->fpLog, "W32SkypeEmu:Exit()\n");

	if (hProxy->hWndDispatch) DestroyWindow (hProxy->hWndDispatch);
	if (hProxy->dwThreadID) PostThreadMessage (hProxy->dwThreadID, WM_QUIT, 0, 0);
	LockMutex(hProxy->loopmutex);

	// Kill 'em all!
	if (hProxy->hClients)
	{
		while (pInst=List_Pop(hProxy->hClients))
		{
			FreeConnection(pInst);
			free (pInst);
		}
		List_Exit (hProxy->hClients);
	}

	UnregisterClass ("Imo2SProxyDispatchWindow", GetModuleHandle(NULL));

	UnlockMutex(hProxy->loopmutex);
	ExitMutex(hProxy->loopmutex);

	free (hProxy);
}
예제 #18
0
static void
GiveRadios (RESPONSE_REF R)
{
	if (PLAYER_SAID (R, we_will_transfer_now))
	{
		SET_GAME_STATE (RADIOACTIVES_PROVIDED, 1);

		NPCPhrase (FUEL_UP0);
		NPCPhrase (FUEL_UP1);		
		AlienTalkSegue (1);

		LockMutex (GraphicsLock);
		//CommData.AlienAmbientArray[2].AnimFlags |= ANIM_DISABLED; // JMS
		UnlockMutex (GraphicsLock);

		XFormColorMap (GetColorMapAddress (
				SetAbsColorMapIndex (CommData.AlienColorMap, 0)
				), ONE_SECOND / 2);

		AlienTalkSegue ((COUNT)~0);

		RevealSelf (0);
	}
	else
	{
		if (PLAYER_SAID (R, what_will_you_give_us))
			NPCPhrase (MESSAGE_GARBLED_1);
		else if (PLAYER_SAID (R, before_radios_we_need_info))
			NPCPhrase (MESSAGE_GARBLED_2);

		Response (we_will_transfer_now, GiveRadios);
		Response (what_will_you_give_us, GiveRadios);
		Response (before_radios_we_need_info, GiveRadios);
	}
}
예제 #19
0
파일: cmap.c 프로젝트: Serosis/UQM-MegaMod
static void
FlushFadeXForms (void)
{
	LockMutex (fadeLock);
	finishPendingFade ();
	UnlockMutex (fadeLock);
}
예제 #20
0
static void
on_input_frame (void)
{
	LockMutex (GraphicsLock);
	RotatePlanetSphere (TRUE);
	UnlockMutex (GraphicsLock);
}
예제 #21
0
static void
RosterCleanup (MENU_STATE *pMS)
{
	if (pMS->flash_task)
	{
		UnlockMutex (GraphicsLock);
		ConcludeTask (pMS->flash_task);
		LockMutex (GraphicsLock);
		pMS->flash_task = 0;
	}

	if (pMS->CurFrame)
	{
		STAMP s;
		SHIP_FRAGMENT *StarShipPtr;

		SetContext (StatusContext);
		s.origin = pMS->first_item;
		StarShipPtr = LockShipFrag (&GLOBAL (built_ship_q),
				(HSHIPFRAG)pMS->CurFrame);
		s.frame = StarShipPtr->icons;
		UnlockShipFrag (&GLOBAL (built_ship_q), (HSHIPFRAG)pMS->CurFrame);
		if (!(pMS->CurState & SHIP_TOGGLE))
			DrawStamp (&s);
		else
		{
			SetContextForeGroundColor (WHITE_COLOR);
			DrawFilledStamp (&s);
		}
	}
}
예제 #22
0
static void
DrawDevices (DEVICES_STATE *devState, COUNT OldDevice, COUNT NewDevice)
{
	LockMutex (GraphicsLock);
	BatchGraphics ();

	SetContext (StatusContext);

	if (OldDevice > NUM_DEVICES)
	{	// Asked for the initial display or refresh
		DrawDevicesDisplay (devState);

		// do not draw unselected again this time
		OldDevice = NewDevice;
	}

	if (OldDevice != NewDevice)
	{	// unselect the previous element
		DrawDevice (devState->list[OldDevice], OldDevice - devState->topIndex,
				false);
	}

	if (NewDevice < NUM_DEVICES)
	{	// select the new element
		DrawDevice (devState->list[NewDevice], NewDevice - devState->topIndex,
				true);
	}

	UnbatchGraphics ();
	UnlockMutex (GraphicsLock);
}
예제 #23
0
void
StopTrack (void)
{
    LockMutex (soundSource[SPEECH_SOURCE].stream_mutex);
    StopStream (SPEECH_SOURCE);
    track_count = 0;
    tracks_length = 0;
    cur_chunk = NULL;
    cur_sub_chunk = NULL;
    UnlockMutex (soundSource[SPEECH_SOURCE].stream_mutex);

    if (chunks_head)
    {
        chunks_tail = NULL;
        destroy_SoundChunk_list (chunks_head);
        chunks_head = NULL;
        last_sub = NULL;
    }
    if (sound_sample)
    {
        // We delete the decoders ourselves
        sound_sample->decoder = NULL;
        TFB_DestroySoundSample (sound_sample);
        sound_sample = NULL;
    }
}
예제 #24
0
void
TFB_DrawImage_Rect (RECT *rect, int r, int g, int b, TFB_Image *image)
{
	LockMutex (image->mutex);
	TFB_DrawCanvas_Rect (rect, r, g, b, image->NormalImg);
	image->dirty = TRUE;
	UnlockMutex (image->mutex);
}
예제 #25
0
// Initialise the surface graphics, and start the planet music.
// Called from the GenerateFunctions.generateOribital() function
// (when orbit is entered; either from IP, or from loading a saved game)
// and when "starmap" is selected from orbit and then cancelled;
// also after in-orbit comm and after defeating planet guards in combat.
// SurfDefFrame contains surface definition images when a planet comes
// with its own bitmap (currently only for Earth)
void
LoadPlanet (FRAME SurfDefFrame)
{
	bool WaitMode = !(LastActivity & CHECK_LOAD);
	PLANET_DESC *pPlanetDesc;

#ifdef DEBUG
	if (disableInteractivity)
		return;
#endif

	assert (pSolarSysState->InOrbit && !pSolarSysState->TopoFrame);

	CreatePlanetContext ();

	if (WaitMode)
	{
		LockMutex (GraphicsLock);
		DrawOrbitalDisplay (DRAW_ORBITAL_WAIT);
		UnlockMutex (GraphicsLock);
	}

	StopMusic ();

	pPlanetDesc = pSolarSysState->pOrbitalDesc;
	GeneratePlanetSurface (pPlanetDesc, SurfDefFrame);
	SetPlanetMusic (pPlanetDesc->data_index & ~PLANET_SHIELDED);
	GeneratePlanetSide ();

	if (!PLRPlaying ((MUSIC_REF)~0))
		PlayMusic (LanderMusic, TRUE, 1);

	if (WaitMode)
	{
		ZoomInPlanetSphere ();
		LockMutex (GraphicsLock);
		DrawOrbitalDisplay (DRAW_ORBITAL_UPDATE);
		UnlockMutex (GraphicsLock);
	}
	else
	{
		LockMutex (GraphicsLock);
		DrawOrbitalDisplay (DRAW_ORBITAL_FULL);
		UnlockMutex (GraphicsLock);
	}
}
예제 #26
0
파일: mutex.c 프로젝트: koder77/NanoVM
void var_unlock (struct varlist *varlist, S4 index)
{
	#if OS_AROS
		UnlockMutex (varlist[index].mutex);
	#else
		pthread_mutex_unlock (&varlist[index].mutex);
	#endif
}
예제 #27
0
파일: uqmlog.c 프로젝트: ex/urquan-masters
static void
unlockQueue (void)
{
	if (!qlock)
		return;

	UnlockMutex (qmutex);
}
예제 #28
0
static void
runCommAnimFrame (void)
{
	LockMutex (GraphicsLock);
	UpdateCommGraphics ();
	UnlockMutex (GraphicsLock);
	SleepThread (COMM_ANIM_RATE);
}
예제 #29
0
static void regain_lockstep()
{
// This looks jolly ugly to me - I need to talk to others who are more
// experienced in concurrency to see if I can improve it.
    if (term->sync_even)
    {   UnlockMutex(term->mutex1);
        LockMutex(term->mutex3);
        UnlockMutex(term->mutex2);
        LockMutex(term->mutex4);
    }
    else
    {   UnlockMutex(term->mutex3);
        LockMutex(term->mutex1);
        UnlockMutex(term->mutex4);
        LockMutex(term->mutex2);
    }
}
예제 #30
0
void
TFB_DrawImage_Rect (RECT *rect, Color color, DrawMode mode, TFB_Image *target)
{
	LockMutex (target->mutex);
	TFB_DrawCanvas_Rect (rect, color, mode, target->NormalImg);
	target->dirty = TRUE;
	UnlockMutex (target->mutex);
}