rem: ClearSemaphore (&GraphicsSem);
add: ClearSemaphore (GraphicsSem);
context: DoTransaction (RESPONSE_REF R){	if (PLAYER_SAID (R, sell_maidens))	{		SET_GAME_STATE (MAIDENS_ON_SHIP, 0);	}	else if (PLAYER_SAID (R, sell_fragments))	{		BYTE num_frags;		if (GET_GAME_STATE (EGG_CASE0_ON_SHIP))		{			SET_GAME_STATE (EGG_CASE0_ON_SHIP, 0);		}		else if (GET_GAME_STATE (EGG_CASE1_ON_SHIP))		{			SET_GAME_STATE (EGG_CASE1_ON_SHIP, 0);		}		else if (GET_GAME_STATE (EGG_CASE2_ON_SHIP))		{			SET_GAME_STATE (EGG_CASE2_ON_SHIP, 0);		}		num_frags = GET_GAME_STATE (FRAGMENTS_BOUGHT) + 1;		SET_GAME_STATE (FRAGMENTS_BOUGHT, num_frags);	}	else if (PLAYER_SAID (R, sell_caster))	{		SET_GAME_STATE (BURV_BROADCASTERS_ON_SHIP, 0);	}	else if (PLAYER_SAID (R, sell_spawner))	{		SET_GAME_STATE (PORTAL_SPAWNER_ON_SHIP, 0);	}	if (!GET_GAME_STATE (ROSY_SPHERE)			&& GET_GAME_STATE (ROSY_SPHERE_ON_SHIP))	{		SET_GAME_STATE (ROSY_SPHERE, 1);	}	else	{		BYTE trade_gas;		BYTE ship_slots, ships_to_trade;		trade_gas = 0;		ships_to_trade = 0;		ship_slots = ActivateStarShip (DRUUGE_SHIP, FEASIBILITY_STUDY);		if (PLAYER_SAID (R, sell_maidens))		{			NPCPhrase (BOUGHT_MAIDENS);			ships_to_trade = 6;		}		else if (PLAYER_SAID (R, sell_fragments))		{			NPCPhrase (BOUGHT_FRAGMENTS);			ships_to_trade = 1;		}		else if (PLAYER_SAID (R, sell_caster))		{			NPCPhrase (BOUGHT_CASTER);			ships_to_trade = 0;			trade_gas = 1;		}		else if (PLAYER_SAID (R, sell_spawner))		{			NPCPhrase (BOUGHT_SPAWNER);			ships_to_trade = 3;			trade_gas = 1;		}		NPCPhrase (YOU_GET);		if (ships_to_trade)		{			ActivateStarShip (DRUUGE_SHIP, ships_to_trade);			if (ship_slots >= ships_to_trade)				NPCPhrase (DEAL_FOR_STATED_SHIPS);			else if (ship_slots == 0)				NPCPhrase (DEAL_FOR_NO_SHIPS);			else				NPCPhrase (DEAL_FOR_LESS_SHIPS);			if (trade_gas)				NPCPhrase (YOU_ALSO_GET);		}		if (trade_gas)		{			BYTE slot;			COUNT f;			DWORD capacity;			capacity = FUEL_RESERVE;			slot = NUM_MODULE_SLOTS - 1;			do			{				if (GLOBAL_SIS (ModuleSlots[slot]) == FUEL_TANK						|| GLOBAL_SIS (ModuleSlots[slot]) == HIGHEFF_FUELSYS)				{					COUNT volume;					volume = GLOBAL_SIS (ModuleSlots[slot]) == FUEL_TANK							? FUEL_TANK_CAPACITY : HEFUEL_TANK_CAPACITY;					capacity += volume;				}			} while (slot--);			capacity -= GLOBAL_SIS (FuelOnBoard);			f = (COUNT)((capacity + (FUEL_TANK_SCALE >> 1)) / FUEL_TANK_SCALE);			SetSemaphore (&GraphicsSem);			while (capacity > 0x3FFFL)			{				DeltaSISGauges (0, 0x3FFF, 0);				capacity -= 0x3FFF;			}			DeltaSISGauges (0, (SIZE)capacity, 0);			ClearSemaphore (&GraphicsSem);			NPCPhrase (FUEL0);			NPCPhrase (-(int)f);			NPCPhrase (FUEL1);			if (f >= 250)				NPCPhrase (HIDEOUS_DEAL);			else if (f >= 100)				NPCPhrase (BAD_DEAL);			else if (f >= 50)				NPCPhrase (FAIR_DEAL);			else if (f >= 10)				NPCPhrase (GOOD_DEAL);			else				NPCPhrase (FINE_DEAL);		}	}}