TArray<FString> USkeleUtilityFunctionLibrary::GetValidResolutions() {
    int32 width, height;
    GetMonitorResolution(width, height);

    int32 widthsArray[] = {
        1280,
        1280,
        1366,
        1440,
        1600,
        1600,
        1680,
        1920,
        1920,
        2048,
        2560,
        2560,
        3840,
        4096
    };
    int32 heightsArray[] = {
        800,
        1024,
        768,
        900,
        900,
        1200,
        1050,
        1080,
        1200,
        1080,
        1440,
        1600,
        2160,
        2160
    };

    TArray<FString> resolutions;
    for (int i = 0; i < ARRAY_COUNT(widthsArray); i++) {
        if (widthsArray[i] <= width && heightsArray[i] <= height) {
            resolutions.Add(FString::FromInt(widthsArray[i]) + "x" + FString::FromInt(heightsArray[i]));
        }
    }

    return resolutions;
}
	void DrawLowerArm(MatrixStack &modelToCameraStack)
	{
		modelToCameraStack.Push();
		modelToCameraStack.Translate(posLowerArm);
		modelToCameraStack.RotateX(angLowerArm);

		modelToCameraStack.Push();
		modelToCameraStack.Translate(glm::vec3(0.0f, 0.0f, lenLowerArm / 2.0f));
		modelToCameraStack.Scale(glm::vec3(widthLowerArm / 2.0f, widthLowerArm / 2.0f, lenLowerArm / 2.0f));
		glUniformMatrix4fv(modelToCameraMatrixUnif, 1, GL_FALSE, glm::value_ptr(modelToCameraStack.Top()));
		glDrawElements(GL_TRIANGLES, ARRAY_COUNT(indexData), GL_UNSIGNED_SHORT, 0);
		modelToCameraStack.Pop();

		DrawWrist(modelToCameraStack);

		modelToCameraStack.Pop();
	}
	FVoiceCaptureWindowsVars() :
		VoiceCaptureDev(NULL),
		VoiceCaptureBuffer8(NULL),
		NextCaptureOffset(0)
	{
		FMemory::Memzero(&VoiceCaptureDevCaps, sizeof(VoiceCaptureDevCaps));

		FMemory::Memzero(&WavFormat, sizeof(WavFormat));
		FMemory::Memzero(&VoiceCaptureBufferDesc, sizeof(VoiceCaptureBufferDesc));
		FMemory::Memzero(&VoiceCaptureBufferCaps8, sizeof(VoiceCaptureBufferCaps8));
		FMemory::Memzero(&Events, ARRAY_COUNT(Events) * sizeof(HANDLE));

		for (int i = 0; i < NUM_EVENTS; i++)
		{
			Events[i] = INVALID_HANDLE_VALUE;
		}
	}
Exemple #4
0
/** Helper function to find a unit from a string (name or abbreviation) */
TOptional<EUnit> FUnitConversion::UnitFromString(const TCHAR* UnitString)
{
	if (!UnitString || *UnitString == '\0')
	{
		return TOptional<EUnit>();
	}

	for (int32 Index = 0; Index < ARRAY_COUNT(ParseCandidates); ++Index)
	{
		if (FCString::Stricmp(UnitString, ParseCandidates[Index].String) == 0)
		{
			return ParseCandidates[Index].Unit;
		}
	}

	return TOptional<EUnit>();
}
	void DrawWrist(MatrixStack &modelToCameraStack)
	{
		modelToCameraStack.Push();
		modelToCameraStack.Translate(posWrist);
		modelToCameraStack.RotateZ(angWristRoll);
		modelToCameraStack.RotateX(angWristPitch);

		modelToCameraStack.Push();
		modelToCameraStack.Scale(glm::vec3(widthWrist / 2.0f, widthWrist/ 2.0f, lenWrist / 2.0f));
		glUniformMatrix4fv(modelToCameraMatrixUnif, 1, GL_FALSE, glm::value_ptr(modelToCameraStack.Top()));
		glDrawElements(GL_TRIANGLES, ARRAY_COUNT(indexData), GL_UNSIGNED_SHORT, 0);
		modelToCameraStack.Pop();

		DrawFingers(modelToCameraStack);

		modelToCameraStack.Pop();
	}
void FIndirectLightingCache::UpdateTranslucentVolumeCache(FViewInfo& View, TMap<FIntVector, FBlockUpdateInfo>& BlocksToUpdate, TArray<FIndirectLightingCacheAllocation*>& TransitionsOverTimeToUpdate)
{
	extern int32 GUseIndirectLightingCacheInLightingVolume;

	if (View.State && GUseIndirectLightingCacheInLightingVolume)
	{
		FSceneViewState* ViewState = (FSceneViewState*)View.State;

		for (int32 CascadeIndex = 0; CascadeIndex < ARRAY_COUNT(ViewState->TranslucencyLightingCacheAllocations); CascadeIndex++)
		{
			FIndirectLightingCacheAllocation*& Allocation = ViewState->TranslucencyLightingCacheAllocations[CascadeIndex];
			const FBoxSphereBounds Bounds(FBox(View.TranslucencyLightingVolumeMin[CascadeIndex], View.TranslucencyLightingVolumeMin[CascadeIndex] + View.TranslucencyLightingVolumeSize[CascadeIndex]));

			UpdateCacheAllocation(Bounds, GTranslucencyLightingVolumeDim / 4, true, Allocation, BlocksToUpdate, TransitionsOverTimeToUpdate);
		}
	}
}
Exemple #7
0
static int
logSerialFirmwareVersion (BrailleDisplay *brl) {
  unsigned char device;

  for (device=0; device<ARRAY_COUNT(serialDeviceNames); ++device) {
    const unsigned char code = 0X46;
    unsigned char buffer[5];

    if (!writeSerialPacket(brl, code, &device, 1)) return 0;
    if (!nextSerialPacket(brl, code, buffer, sizeof(buffer), 1)) return 0;
    logMessage(LOG_INFO, "%s Firmware Version: %c.%c.%c", 
               serialDeviceNames[buffer[1]],
               buffer[2], buffer[3], buffer[4]);
  }

  return 1;
}
Exemple #8
0
void CSDL_Ext::alphaTransform(SDL_Surface *src)
{
	assert(src->format->BitsPerPixel == 8);
	SDL_Color colors[] =
	{
	    {  0,   0,  0,   0}, {  0,   0,   0,  32}, {  0,   0,   0,  64},
	    {  0,   0,  0, 128}, {  0,   0,   0, 128}
	};


	for (size_t i=0; i< ARRAY_COUNT(colors); i++ )
	{
		SDL_Color & palColor = src->format->palette->colors[i];
		palColor = colors[i];
	}
	SDL_SetColorKey(src, SDL_SRCCOLORKEY, 0);
}
Exemple #9
0
void appPrintf(const char *fmt, ...)
{
	va_list	argptr;
	va_start(argptr, fmt);
	char buf[4096];
	int len = vsnprintf(ARRAY_ARG(buf), fmt, argptr);
	va_end(argptr);
	assert(len >= 0 && len < ARRAY_COUNT(buf) - 1);

	fwrite(buf, len, 1, stdout);
	if (GLogFile) fwrite(buf, len, 1, GLogFile);

#if VSTUDIO_INTEGRATION
	if (IsDebuggerPresent())
		OutputDebugString(buf);
#endif
}
//
// Get a globally unique identifier.
//
bool FParse::Value( const TCHAR* Stream, const TCHAR* Match, struct FGuid& Guid )
{
	TCHAR Temp[256];
	if( !FParse::Value( Stream, Match, Temp, ARRAY_COUNT(Temp) ) )
		return 0;

	Guid.A = Guid.B = Guid.C = Guid.D = 0;
	if( FCString::Strlen(Temp)==32 )
	{
		TCHAR* End;
		Guid.D = FCString::Strtoi( Temp+24, &End, 16 ); Temp[24]=0;
		Guid.C = FCString::Strtoi( Temp+16, &End, 16 ); Temp[16]=0;
		Guid.B = FCString::Strtoi( Temp+8,  &End, 16 ); Temp[8 ]=0;
		Guid.A = FCString::Strtoi( Temp+0,  &End, 16 ); Temp[0 ]=0;
	}
	return 1;
}
Exemple #11
0
HMODULE GetD3DCompiler()
{
  static HMODULE ret = NULL;
  if(ret != NULL)
    return ret;

  // dlls to try in priority order
  const char *dlls[] = {
      "d3dcompiler_47.dll", "d3dcompiler_46.dll", "d3dcompiler_45.dll",
      "d3dcompiler_44.dll", "d3dcompiler_43.dll",
  };

  for(int i = 0; i < 2; i++)
  {
    for(int d = 0; d < ARRAY_COUNT(dlls); d++)
    {
      if(i == 0)
        ret = GetModuleHandleA(dlls[d]);
      else
        ret = LoadLibraryA(dlls[d]);

      if(ret != NULL)
        return ret;
    }
  }

  // all else failed, couldn't find d3dcompiler loaded,
  // and couldn't even loadlibrary any version!
  // we'll have to loadlibrary the version that ships with
  // RenderDoc.

  HMODULE hModule = NULL;
  GetModuleHandleEx(
      GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
      (LPCTSTR)&dllLocator, &hModule);
  wchar_t curFile[512] = {0};
  GetModuleFileNameW(hModule, curFile, 511);

  std::wstring path = std::wstring(curFile);
  path = dirname(path);
  std::wstring dll = path + L"/d3dcompiler_47.dll";

  ret = LoadLibraryW(dll.c_str());

  return ret;
}
void FGameplayDebuggerCategory_Navmesh::CollectData(APlayerController* OwnerPC, AActor* DebugActor)
{
#if WITH_RECAST
	ARecastNavMesh* NavData = nullptr;

	APawn* PlayerPawn = OwnerPC ? OwnerPC->GetPawnOrSpectator() : nullptr;
	APawn* DebugActorAsPawn = Cast<APawn>(DebugActor);
	APawn* DestPawn = DebugActorAsPawn ? DebugActorAsPawn : PlayerPawn;
	if (DestPawn)
	{
		UNavigationSystem* NavSys = UNavigationSystem::GetCurrent(OwnerPC->GetWorld());
		const FNavAgentProperties& NavAgentProperties = DestPawn->GetNavAgentPropertiesRef();
		NavData = Cast<ARecastNavMesh>(NavSys->GetNavDataForProps(NavAgentProperties));
	}

	if (NavData)
	{
		// add 3x3 neighborhood of target
		const FVector TargetLocation = DestPawn->GetActorLocation();

		TArray<int32> TileSet;
		int32 TileX = 0;
		int32 TileY = 0;
		const int32 DeltaX[] = { 0, 1, 1, 0, -1, -1, -1, 0, 1 };
		const int32 DeltaY[] = { 0, 0, 1, 1, 1, 0, -1, -1, -1 };

		int32 TargetTileX = 0;
		int32 TargetTileY = 0;
		NavData->GetNavMeshTileXY(TargetLocation, TargetTileX, TargetTileY);
		for (int32 Idx = 0; Idx < ARRAY_COUNT(DeltaX); Idx++)
		{
			const int32 NeiX = TargetTileX + DeltaX[Idx];
			const int32 NeiY = TargetTileY + DeltaY[Idx];
			NavData->GetNavMeshTilesAt(NeiX, NeiY, TileSet);
		}

		const int32 DetailFlags =
			(1 << static_cast<int32>(ENavMeshDetailFlags::PolyEdges)) |
			(1 << static_cast<int32>(ENavMeshDetailFlags::FilledPolys)) |
			(1 << static_cast<int32>(ENavMeshDetailFlags::NavLinks));

		NavmeshRenderData.GatherData(NavData, DetailFlags, TileSet);
	}
#endif // WITH_RECAST
}
void FOutputDeviceMacError::HandleError()
{
	// make sure we don't report errors twice
	static int32 CallCount = 0;
	int32 NewCallCount = FPlatformAtomics::InterlockedIncrement(&CallCount);
	if (NewCallCount != 1)
	{
		UE_LOG(LogMac, Error, TEXT("HandleError re-entered.") );
		return;
	}

	// Trigger the OnSystemFailure hook if it exists
	FCoreDelegates::OnHandleSystemError.Broadcast();

	try
	{
		GIsGuarded				= 0;
		GIsRunning				= 0;
		GIsCriticalError		= 1;
		GLogConsole				= NULL;
		GErrorHist[ARRAY_COUNT(GErrorHist)-1]=0;

		// Dump the error and flush the log.
		UE_LOG(LogMac, Log, TEXT("=== Critical error: ===") LINE_TERMINATOR TEXT("%s") LINE_TERMINATOR, GErrorExceptionDescription);
		UE_LOG(LogMac, Log, GErrorHist);

		GLog->Flush();

		// Unhide the mouse.
		while (!CGCursorIsVisible())
		{
			CGDisplayShowCursor(kCGDirectMainDisplay);
		}
		// Release capture and allow mouse to freely roam around.
		CGAssociateMouseAndMouseCursorPosition(true);

		FPlatformMisc::ClipboardCopy(GErrorHist);

		FPlatformMisc::SubmitErrorReport( GErrorHist, EErrorReportMode::Interactive );

		FCoreDelegates::OnShutdownAfterError.Broadcast();
	}
	catch( ... )
	{}
}
Exemple #14
0
static int
logSerialSerialNumber (BrailleDisplay *brl) {
  unsigned char device;

  for (device=0; device<ARRAY_COUNT(serialDeviceNames); ++device) {
    const unsigned char code = 0X53;
    unsigned char buffer[10];

    if (!writeSerialPacket(brl, code, &device, 1)) return 0;
    if (!nextSerialPacket(brl, code, buffer, sizeof(buffer), 1)) return 0;
    logMessage(LOG_INFO, "%s Serial Number: %02X%02X%02X%02X%02X%02X%02X%02X",
               serialDeviceNames[buffer[1]],
               buffer[2], buffer[3], buffer[4], buffer[5],
               buffer[6], buffer[7], buffer[8], buffer[9]);
  }

  return 1;
}
StreamBase & GameStatic::operator<< (StreamBase & msg, const Data & obj)
{
    msg <<
	whirlpool_lost_percent <<
	kingdom_max_heroes <<
	castle_grown_well <<
	castle_grown_wel2 <<
	castle_grown_week_of <<
	castle_grown_month_of <<
	heroes_spell_points_day <<
	gameover_lost_days <<
	spell_dd_distance <<
	spell_dd_sp <<
	spell_dd_hp;

    u8 array_size = ARRAY_COUNT(overview_distance);
    msg << array_size;
    for(u32 ii = 0; ii < array_size; ++ii)
	msg << overview_distance[ii];

    array_size = ARRAY_COUNT(kingdom_starting_resource);
    msg << array_size;
    for(u32 ii = 0; ii < array_size; ++ii)
	msg << kingdom_starting_resource[ii];

    array_size = ARRAY_COUNT(mageguild_restore_spell_points_day);
    msg << array_size;
    for(u32 ii = 0; ii < array_size; ++ii)
	msg << mageguild_restore_spell_points_day[ii];

    array_size = ARRAY_COUNT(objects_mod);
    msg << array_size;
    for(u32 ii = 0; ii < array_size; ++ii)
	msg << objects_mod[ii];

    msg << monster_upgrade_ratio << uniq;

    // skill statics
    array_size = ARRAY_COUNT(Skill::_stats);
    msg << array_size;
    for(u32 ii = 0; ii < array_size; ++ii)
        msg << Skill::_stats[ii];

    array_size = ARRAY_COUNT(Skill::_values);
    msg << array_size;
    for(u32 ii = 0; ii < array_size; ++ii)
        msg << Skill::_values[ii];

    msg << Skill::_from_witchs_hut;

    return msg;
}
void FArchiveFileWriterWindows::Serialize( void* V, INT Length )
{
	Pos += Length;
	INT Copy;
	while( Length > (Copy=ARRAY_COUNT(Buffer)-BufferCount) )
	{
		appMemcpy( Buffer+BufferCount, V, Copy );
		BufferCount += Copy;
		Length      -= Copy;
		V            = (BYTE*)V + Copy;
		Flush();
	}
	if( Length )
	{
		appMemcpy( Buffer+BufferCount, V, Length );
		BufferCount += Length;
	}
}
Exemple #17
0
wchar_t
getBaseCharacter (wchar_t character) {
#ifdef HAVE_ICU
  UChar source[] = {character};
  const unsigned int resultLength = 0X10;
  UChar resultBuffer[resultLength];
  UErrorCode error = U_ZERO_ERROR;

  unorm_normalize(source, ARRAY_COUNT(source),
                  UNORM_NFD, 0,
                  resultBuffer, resultLength,
                  &error);

  if (U_SUCCESS(error)) return resultBuffer[0];
#endif /* HAVE_ICU */

  return 0;
}
Exemple #18
0
    void DrawUpperArm(MatrixStack &modelToCameraStack)
    {
        modelToCameraStack.Push();
        modelToCameraStack.RotateX(angUpperArm);

        {
            modelToCameraStack.Push();
            modelToCameraStack.Translate(glm::vec3(0.0f, 0.0f, (sizeUpperArm / 2.0f) - 1.0f));
            modelToCameraStack.Scale(glm::vec3(1.0f, 1.0f, sizeUpperArm / 2.0f));
            glUniformMatrix4fv(modelToCameraMatrixUnif, 1, GL_FALSE, glm::value_ptr(modelToCameraStack.Top()));
            glDrawElements(GL_TRIANGLES, ARRAY_COUNT(indexData), GL_UNSIGNED_SHORT, 0);
            modelToCameraStack.Pop();
        }

        DrawLowerArm(modelToCameraStack);

        modelToCameraStack.Pop();
    }
/**
 * Filter MCPP errors.
 * @param ErrorMsg - The error message.
 * @returns true if the message is valid and has not been filtered out.
 */
static bool FilterMcppError(const FString& ErrorMsg)
{
	const TCHAR* SubstringsToFilter[] =
	{
		TEXT("with no newline, supplemented newline"),
		TEXT("Converted [CR+LF] to [LF]")
	};
	const int32 FilteredSubstringCount = ARRAY_COUNT(SubstringsToFilter);

	for (int32 SubstringIndex = 0; SubstringIndex < FilteredSubstringCount; ++SubstringIndex)
	{
		if (ErrorMsg.Contains(SubstringsToFilter[SubstringIndex]))
		{
			return false;
		}
	}
	return true;
}
void FLinuxCrashContext::CaptureStackTrace()
{
	// Only do work the first time this function is called - this is mainly a carry over from Windows where it can be called multiple times, left intact for extra safety.
	if (!bCapturedBacktrace)
	{
		const SIZE_T StackTraceSize = 65535;
		ANSICHAR* StackTrace = (ANSICHAR*) FMemory::Malloc( StackTraceSize );
		StackTrace[0] = 0;
		// Walk the stack and dump it to the allocated memory (ignore first 2 callstack lines as those are in stack walking code)
		FPlatformStackWalk::StackWalkAndDump( StackTrace, StackTraceSize, 2, this);

		FCString::Strncat( GErrorHist, ANSI_TO_TCHAR(StackTrace), ARRAY_COUNT(GErrorHist) - 1 );
		CreateExceptionInfoString(Signal, Info);

		FMemory::Free( StackTrace );
		bCapturedBacktrace = true;
	}
}
bool WrappedID3D12Device::Serialise_CreateGraphicsPipelineState(
    const D3D12_GRAPHICS_PIPELINE_STATE_DESC *pDesc, REFIID riid, void **ppPipelineState)
{
  SERIALISE_ELEMENT_PTR(D3D12_GRAPHICS_PIPELINE_STATE_DESC, Descriptor, pDesc);
  SERIALISE_ELEMENT(IID, guid, riid);
  SERIALISE_ELEMENT(ResourceId, Pipe,
                    ((WrappedID3D12PipelineState *)*ppPipelineState)->GetResourceID());

  if(m_State == READING)
  {
    ID3D12PipelineState *ret = NULL;
    HRESULT hr = m_pDevice->CreateGraphicsPipelineState(&Descriptor, guid, (void **)&ret);

    if(FAILED(hr))
    {
      RDCERR("Failed on resource serialise-creation, HRESULT: 0x%08x", hr);
    }
    else
    {
      ret = new WrappedID3D12PipelineState(ret, this);

      WrappedID3D12PipelineState *wrapped = (WrappedID3D12PipelineState *)ret;

      wrapped->graphics = new D3D12_GRAPHICS_PIPELINE_STATE_DESC(Descriptor);

      D3D12_SHADER_BYTECODE *shaders[] = {
          &wrapped->graphics->VS, &wrapped->graphics->HS, &wrapped->graphics->DS,
          &wrapped->graphics->GS, &wrapped->graphics->PS,
      };

      for(size_t i = 0; i < ARRAY_COUNT(shaders); i++)
      {
        if(shaders[i]->BytecodeLength == 0)
          shaders[i]->pShaderBytecode = NULL;
        else
          shaders[i]->pShaderBytecode = WrappedID3D12PipelineState::AddShader(*shaders[i], this);
      }

      GetResourceManager()->AddLiveResource(Pipe, ret);
    }
  }

  return true;
}
void FOutputDeviceLinuxError::HandleError()
{
	// make sure we don't report errors twice
	static int32 CallCount = 0;
	int32 NewCallCount = FPlatformAtomics::InterlockedIncrement(&CallCount);
	if (NewCallCount != 1)
	{
		UE_LOG(LogLinux, Error, TEXT("HandleError re-entered.") );
		return;
	}

	// Trigger the OnSystemFailure hook if it exists
	FCoreDelegates::OnHandleSystemError.Broadcast();

#if !PLATFORM_EXCEPTIONS_DISABLED
	try
	{
#endif // !PLATFORM_EXCEPTIONS_DISABLED
		GIsGuarded = 0;
		GIsRunning = 0;
		GIsCriticalError = 1;
		GLogConsole = NULL;
		GErrorHist[ARRAY_COUNT(GErrorHist)-1] = 0;

		// Dump the error and flush the log.
		UE_LOG(LogLinux, Log, TEXT("=== Critical error: ===") LINE_TERMINATOR TEXT("%s") LINE_TERMINATOR, GErrorExceptionDescription);
		UE_LOG(LogLinux, Log, GErrorHist);

		GLog->Flush();

		// do not copy if graphics have not been initialized or if we're on the wrong thread
		if (FApp::CanEverRender() && IsInGameThread())
		{
			FPlatformMisc::ClipboardCopy(GErrorHist);
		}

		FPlatformMisc::SubmitErrorReport(GErrorHist, EErrorReportMode::Interactive);
		FCoreDelegates::OnShutdownAfterError.Broadcast();
#if !PLATFORM_EXCEPTIONS_DISABLED
	}
	catch(...)
	{}
#endif // !PLATFORM_EXCEPTIONS_DISABLED
}
string GetReplayAppFilename()
{
  // look up the shared object's path via dladdr
  Dl_info info;
  dladdr((void *)&soLocator, &info);
  string path = info.dli_fname ? info.dli_fname : "";
  path = dirname(path);
  string replay = path + "/qrenderdoc";

  FILE *f = FileIO::fopen(replay.c_str(), "r");
  if(f)
  {
    FileIO::fclose(f);
    return replay;
  }

  // if it's not in the same directory, try in a sibling /bin
  // e.g. /foo/bar/lib/librenderdoc.so -> /foo/bar/bin/qrenderdoc
  replay = path + "/../bin/qrenderdoc";

  f = FileIO::fopen(replay.c_str(), "r");
  if(f)
  {
    FileIO::fclose(f);
    return replay;
  }

  // random guesses!
  const char *guess[] = {"/opt/renderdoc/qrenderdoc", "/opt/renderdoc/bin/qrenderdoc",
                         "/usr/local/bin/qrenderdoc", "/usr/bin/qrenderdoc"};

  for(size_t i = 0; i < ARRAY_COUNT(guess); i++)
  {
    f = FileIO::fopen(guess[i], "r");
    if(f)
    {
      FileIO::fclose(f);
      return guess[i];
    }
  }

  // out of ideas
  return "";
}
Exemple #24
0
static char *
findKeyboardDevice (const char *deviceName) {
  char *devicePath = NULL;

  const char *directoryComponents[] = {
    "/sys/devices/platform/",
    deviceName,
    "/input"
  };
  char *directoryPath = joinStrings(directoryComponents, ARRAY_COUNT(directoryComponents));

  if (directoryPath) {
    DIR *directory = opendir(directoryPath);

    if (directory) {
      const char *filePrefix = "input";
      size_t filePrefixLength = strlen(filePrefix);
      struct dirent *entry;

      while ((entry = readdir(directory))) {
        if (strncmp(entry->d_name, filePrefix, filePrefixLength) == 0) {
          int eventNumber;

          if (isInteger(&eventNumber, &entry->d_name[filePrefixLength])) {
            char path[0X80];

            snprintf(path, sizeof(path), "/dev/input/event%d", eventNumber);
            if (!(devicePath = strdup(path))) logMallocError();
            break;
          }
        }
      }

      closedir(directory);
    } else {
      logMessage(LOG_DEBUG, "keyboard directory open error: %s: %s",
                 directoryPath, strerror(errno));
    }

    free(directoryPath);
  }

  return devicePath;
}
/**
 * Give the async task a chance to marshal its data back to the game thread
 * Can only be called on the game thread by the async task manager
 */
void FOnlineAsyncEventSteamInviteAccepted::Finalize()
{
	FOnlineSessionSteamPtr SessionInt = StaticCastSharedPtr<FOnlineSessionSteam>(Subsystem->GetSessionInterface());
	if (SessionInt.IsValid() && !SessionInt->CurrentSessionSearch.IsValid())
	{
		// Create a search settings object
		TSharedRef<FOnlineSessionSearch> SearchSettings = MakeShareable(new FOnlineSessionSearch());
		SessionInt->CurrentSessionSearch = SearchSettings;
		SessionInt->CurrentSessionSearch->SearchState = EOnlineAsyncTaskState::InProgress;

		TCHAR ParsedURL[1024];
		if (!FParse::Value(*ConnectionURL, TEXT("SteamConnectIP="), ParsedURL, ARRAY_COUNT(ParsedURL)))
		{
			UE_LOG_ONLINE(Warning, TEXT("FOnlineAsyncEventSteamInviteAccepted: Failed to parse connection URL"));
			return;
		}

		// Determine the port
		int32 Port = 0;
		TCHAR* PortToken = FCString::Strchr(ParsedURL, ':');
		if (PortToken)
		{
			Port = FCString::Atoi(PortToken+1);
			PortToken[0] = '\0';
		}

		Port = (Port > 0) ? Port : Subsystem->GetGameServerGamePort();

		// Parse the address
		bool bIsValid;
		TSharedRef<FInternetAddr> IpAddr = ISocketSubsystem::Get(PLATFORM_SOCKETSUBSYSTEM)->CreateInternetAddr();
		IpAddr->SetIp(ParsedURL, bIsValid);
		if (bIsValid)
		{
			SessionInt->CurrentSessionSearch->QuerySettings.Set(FName(SEARCH_STEAM_HOSTIP), IpAddr->ToString(false), EOnlineComparisonOp::Equals);
			FOnlineAsyncTaskSteamFindServer* NewTask = new FOnlineAsyncTaskSteamFindServer(Subsystem, SearchSettings, LocalUserNum, SessionInt->OnSessionUserInviteAcceptedDelegates);
			Subsystem->QueueAsyncTask(NewTask);
		}
	}
	else
	{
		UE_LOG_ONLINE(Warning, TEXT("Invalid session or search already in progress when accepting invite.  Ignoring invite request."));
	}
}
void FArchiveFileReaderWindows::Serialize( void* V, INT Length )
{
	while( Length>0 )
	{
		INT Copy = Min( Length, BufferBase+BufferCount-Pos );
		if( Copy<=0 )
		{
			if( Length >= ARRAY_COUNT(Buffer) )
			{
				INT Count=0;
				// Read data from device via Win32 ReadFile API.
				{
					SCOPED_FILE_IO_READ_STATS( StatsHandle, Length, Pos );
					ReadFile( Handle, V, Length, (DWORD*)&Count, NULL );
				}
				if( Count!=Length )
				{
					ArIsError = 1;
					Error->Logf( TEXT("ReadFile failed: Count=%i Length=%i Error=%s for file %s"), 
						Count, Length, appGetSystemErrorMessage(), *Filename );
				}
				Pos += Length;
				BufferBase += Length;
				return;
			}
			InternalPrecache( Pos, MAXINT );
			Copy = Min( Length, BufferBase+BufferCount-Pos );
			if( Copy<=0 )
			{
				ArIsError = 1;
				Error->Logf( TEXT("ReadFile beyond EOF %i+%i/%i for file %s"), 
					Pos, Length, Size, *Filename );
			}
			if( ArIsError )
			{
				return;
			}
		}
		appMemcpy( V, Buffer+Pos-BufferBase, Copy );
		Pos       += Copy;
		Length    -= Copy;
		V          = (BYTE*)V + Copy;
	}
}
Exemple #27
0
bool ReplayOutput::PickPixel(ResourceId tex, bool customShader, uint32_t x, uint32_t y,
                             uint32_t sliceFace, uint32_t mip, uint32_t sample, PixelValue *ret)
{
  if(ret == NULL || tex == ResourceId())
    return false;

  RDCEraseEl(ret->value_f);

  bool decodeRamp = false;

  if(customShader && m_RenderData.texDisplay.CustomShader != ResourceId() &&
     m_CustomShaderResourceId != ResourceId())
  {
    tex = m_CustomShaderResourceId;
  }
  if((m_RenderData.texDisplay.overlay == eTexOverlay_QuadOverdrawDraw ||
      m_RenderData.texDisplay.overlay == eTexOverlay_QuadOverdrawPass) &&
     m_OverlayResourceId != ResourceId())
  {
    decodeRamp = true;
    tex = m_OverlayResourceId;
  }

  m_pDevice->PickPixel(m_pDevice->GetLiveID(tex), x, y, sliceFace, mip, sample, ret->value_f);

  if(decodeRamp)
  {
    for(size_t c = 0; c < ARRAY_COUNT(overdrawRamp); c++)
    {
      if(fabs(ret->value_f[0] - overdrawRamp[c].x) < 0.00005f &&
         fabs(ret->value_f[1] - overdrawRamp[c].y) < 0.00005f &&
         fabs(ret->value_f[2] - overdrawRamp[c].z) < 0.00005f)
      {
        ret->value_i[0] = (int32_t)c;
        ret->value_i[1] = 0;
        ret->value_i[2] = 0;
        ret->value_i[3] = 0;
        break;
      }
    }
  }

  return true;
}
Exemple #28
0
void PrintGameList(bool tags)
{
	const char *oldTitle = NULL;
	int pos = 0;
#define LINEFEED 80

	int Count = ARRAY_COUNT(GListOfGames) - 1;	// exclude TABLE_END marker
	bool out = false;
	for (int i = 0; i < Count; i++)
	{
		const GameInfo &info = GListOfGames[i];
		if (tags && !info.Switch) continue;
		// engine title
		const char *title = GetEngineName(info.Enum);
		if (title != oldTitle)
		{
			appPrintf("%s%s:", out ? "\n\n" : "", title);
			pos = LINEFEED;
		}
		oldTitle = title;
		out = true;
		// game info
		if (tags)
		{
			appPrintf("\n %8s  %s", info.Switch ? info.Switch : "", info.Name);
			continue;
		}
		// simple game list
		if (!(info.Enum & ~GAME_ENGINE) && info.Switch) continue;	// skip simple GAME_UEn
		const char *name = info.Name;
		int len = strlen(name);
		bool needComma = (i < Count - 1) && (GetEngineName(GListOfGames[i+1].Enum) == title);
		if (needComma) len += 2;
		if (pos >= LINEFEED - len)
		{
			appPrintf("\n  ");
			pos = 2;
		}
		appPrintf("%s%s", name, needComma ? ", " : "");
		pos += len;
	}
	appPrintf("\n");
}
Exemple #29
0
static char *
usbGetFileSystem (const char *type, const FileSystemCandidate *candidates, MountPointTester test, FileSystemVerifier verify) {
  if (candidates) {
    const FileSystemCandidate *candidate = candidates;

    while (candidate->path) {
      logMessage(LOG_DEBUG, "verifying file system path: %s: %s", type, candidate->path);

      if (candidate->verify(candidate->path)) {
        char *path = strdup(candidate->path);
        if (path) return path;
        logMallocError();
      }

      candidate += 1;
    }
  }

  if (test) {
    char *path = findMountPoint(test);
    if (path) return path;
  }

  if (verify) {
    char *directory = makeWritablePath(type);

    if (directory) {
      if (ensureDirectory(directory)) {
        if (verify(directory)) return directory;

        {
          const char *strings[] = {PACKAGE_NAME, "-", type};
          char *name = joinStrings(strings, ARRAY_COUNT(strings));
          if (makeMountPoint(directory, name, type)) return directory;
        }
      }

      free(directory);
    }
  }

  return NULL;
}
Exemple #30
0
static void
exitCharsetIconv (void *data) {
  static iconv_t *const handles[] = {
    &iconvCharToWchar,
    &iconvWcharToChar
  };

  iconv_t *const *handle = handles;
  iconv_t *const *const end = handle + ARRAY_COUNT(handles);

  while (handle < end) {
    if (**handle != CHARSET_ICONV_NULL) {
      iconv_close(**handle);
      **handle = CHARSET_ICONV_NULL;
    }

    handle += 1;
  }
}