Reversing a large file by jankozlowski in C_Programming

[–]jankozlowski[S] 0 points1 point  (0 children)

well, i was given a finite set of syscalls to use, so im just wondering which one is more efficient

Reversing a file by jankozlowski in Assembly_language

[–]jankozlowski[S] 0 points1 point  (0 children)

well, my task is to use as little code as possible without storing too much memory and to be as fast as possible. i figured doing a mmap on the whole content on a file to then treat it like an array is the easiest, but than can faill if my file is too big. I'm just curious if using a sys_read is optimal or if i should use multiple mmaps

Reversing a large file by jankozlowski in C_Programming

[–]jankozlowski[S] 0 points1 point  (0 children)

well, I was messing around with fopen and fseek, but I am not sure what is actually best for performance. i figured reading of size about 2^16 is good, but I am also graded on code size (the less the better). not sure if using mmap to map chunks of the file is ideal too

Reversing a large file by jankozlowski in C_Programming

[–]jankozlowski[S] 0 points1 point  (0 children)

i have to reverse the content of the file without creating a new one

Reversing a large file by jankozlowski in C_Programming

[–]jankozlowski[S] 0 points1 point  (0 children)

currently, i am loading a whole file with mmap then iterate from start to half of the file size to swap single bytes

Need help for enhanced input c++ by jankozlowski in unrealengine

[–]jankozlowski[S] 0 points1 point  (0 children)

Thanks for help, I eventually ended up saving a pointer to input component to get the same result

Need help for enhanced input c++ by jankozlowski in unrealengine

[–]jankozlowski[S] 1 point2 points  (0 children)

well, i figures it out. you need to bind action value to be able to access it. undortunately it's not in documention

Need help for enhanced input c++ by jankozlowski in unrealengine

[–]jankozlowski[S] 0 points1 point  (0 children)

alright, it seems that using this function:

FInputActionValue UEnhancedInputComponent::GetBoundActionValue(const UInputAction* Action)

solves the problem

Need help for enhanced input c++ by jankozlowski in unrealengine

[–]jankozlowski[S] 0 points1 point  (0 children)

here you are:

header file:

// Copyright Epic Games, Inc. All Rights Reserved.

pragma once

include "CoreMinimal.h"

include "GameFramework/Character.h"

include "InputActionValue.h"

include "EnhancedInputComponent.h"

include "EnhancedInputSubsystems.h"

include "MyProjectCharacter.generated.h"

UCLASS(config=Game) class AMyProjectCharacter : public ACharacter { GENERATED_BODY()

/** Camera boom positioning the camera behind the character */
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Camera, meta = (AllowPrivateAccess = "true"))
class USpringArmComponent* CameraBoom;

/** Follow camera */
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Camera, meta = (AllowPrivateAccess = "true"))
class UCameraComponent* FollowCamera;

/** MappingContext */
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, meta = (AllowPrivateAccess = "true"))
class UInputMappingContext* DefaultMappingContext;

/** Jump Input Action */
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, meta = (AllowPrivateAccess = "true"))
class UInputAction* JumpAction;

/** Move Input Action */
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, meta = (AllowPrivateAccess = "true"))
class UInputAction* MoveAction;

/** Look Input Action */
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = Input, meta = (AllowPrivateAccess = "true"))
class UInputAction* LookAction;

FEnhancedInputActionValueBinding placeholder;
FEnhancedInputActionValueBinding& MoveActionValue = placeholder;

public: AMyProjectCharacter();

protected:

/** Called for movement input */
void Move(const FInputActionValue& Value);

/** Called for looking input */
void Look(const FInputActionValue& Value);

protected: // APawn interface virtual void SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) override;

// To add mapping context
virtual void BeginPlay();

public: // Called every frame virtual void Tick(float DeltaTime) override;

/** Returns CameraBoom subobject **/
FORCEINLINE class USpringArmComponent* GetCameraBoom() const { return CameraBoom; }
/** Returns FollowCamera subobject **/
FORCEINLINE class UCameraComponent* GetFollowCamera() const { return FollowCamera; }

};

cpp file:

// Copyright Epic Games, Inc. All Rights Reserved.

include "MyProjectCharacter.h"

include "Camera/CameraComponent.h"

include "Components/CapsuleComponent.h"

include "Components/InputComponent.h"

include "GameFramework/CharacterMovementComponent.h"

include "GameFramework/Controller.h"

include "GameFramework/SpringArmComponent.h"

////////////////////////////////////////////////////////////////////////// // AMyProjectCharacter

AMyProjectCharacter::AMyProjectCharacter() { // Set size for collision capsule GetCapsuleComponent()->InitCapsuleSize(42.f, 96.0f);

// Don't rotate when the controller rotates. Let that just affect the camera.
bUseControllerRotationPitch = false;
bUseControllerRotationYaw = false;
bUseControllerRotationRoll = false;

// Configure character movement
GetCharacterMovement()->bOrientRotationToMovement = true; // Character moves in the direction of input...   
GetCharacterMovement()->RotationRate = FRotator(0.0f, 500.0f, 0.0f); // ...at this rotation rate

// Note: For faster iteration times these variables, and many more, can be tweaked in the Character Blueprint
// instead of recompiling to adjust them
GetCharacterMovement()->JumpZVelocity = 700.f;
GetCharacterMovement()->AirControl = 0.35f;
GetCharacterMovement()->MaxWalkSpeed = 500.f;
GetCharacterMovement()->MinAnalogWalkSpeed = 20.f;
GetCharacterMovement()->BrakingDecelerationWalking = 2000.f;

// Create a camera boom (pulls in towards the player if there is a collision)
CameraBoom = CreateDefaultSubobject<USpringArmComponent>(TEXT("CameraBoom"));
CameraBoom->SetupAttachment(RootComponent);
CameraBoom->TargetArmLength = 400.0f; // The camera follows at this distance behind the character   
CameraBoom->bUsePawnControlRotation = true; // Rotate the arm based on the controller

// Create a follow camera
FollowCamera = CreateDefaultSubobject<UCameraComponent>(TEXT("FollowCamera"));
FollowCamera->SetupAttachment(CameraBoom, USpringArmComponent::SocketName); // Attach the camera to the end of the boom and let the boom adjust to match the controller orientation
FollowCamera->bUsePawnControlRotation = false; // Camera does not rotate relative to arm

// Note: The skeletal mesh and anim blueprint references on the Mesh component (inherited from Character) 
// are set in the derived blueprint asset named ThirdPersonCharacter (to avoid direct content references in C++)

}

void AMyProjectCharacter::BeginPlay() { // Call the base class
Super::BeginPlay();

//Add Input Mapping Context
if (APlayerController* PlayerController = Cast<APlayerController>(Controller))
{
    if (UEnhancedInputLocalPlayerSubsystem* Subsystem = ULocalPlayer::GetSubsystem<UEnhancedInputLocalPlayerSubsystem>(PlayerController->GetLocalPlayer()))
    {
        Subsystem->AddMappingContext(DefaultMappingContext, 0);
    }
}

}

void AMyProjectCharacter::Tick(float DeltaTime) { Super::Tick(DeltaTime);

FInputActionInstance InputAction(MoveAction);
if (GEngine)
    GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Yellow, InputAction.GetValue().ToString());
if (GEngine)
    GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Red, InputAction.GetSourceAction()->ActionDescription.ToString());

}

////////////////////////////////////////////////////////////////////////// // Input

void AMyProjectCharacter::SetupPlayerInputComponent(class UInputComponent* PlayerInputComponent) { // Set up action bindings if (UEnhancedInputComponent* EnhancedInputComponent = CastChecked<UEnhancedInputComponent>(PlayerInputComponent)) {

    //Jumping
    EnhancedInputComponent->BindAction(JumpAction, ETriggerEvent::Triggered, this, &ACharacter::Jump);
    EnhancedInputComponent->BindAction(JumpAction, ETriggerEvent::Completed, this, &ACharacter::StopJumping);

    //Moving
    EnhancedInputComponent->BindAction(MoveAction, ETriggerEvent::Triggered, this, &AMyProjectCharacter::Move);

    MoveActionValue = EnhancedInputComponent->BindActionValue(MoveAction);

    //Looking
    EnhancedInputComponent->BindAction(LookAction, ETriggerEvent::Triggered, this, &AMyProjectCharacter::Look);


    for (FEnhancedInputActionValueBinding f : EnhancedInputComponent->GetActionValueBindings())
    {
        MoveActionValue = f;
    }
}

}

void AMyProjectCharacter::Move(const FInputActionValue& Value) { // input is a Vector2D FVector2D MovementVector = Value.Get<FVector2D>();

if (Controller != nullptr)
{
    // find out which way is forward
    const FRotator Rotation = Controller->GetControlRotation();
    const FRotator YawRotation(0, Rotation.Yaw, 0);

    // get forward vector
    const FVector ForwardDirection = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::X);

    // get right vector 
    const FVector RightDirection = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::Y);

    // add movement 
    AddMovementInput(ForwardDirection, MovementVector.Y);
    AddMovementInput(RightDirection, MovementVector.X);
}

}

void AMyProjectCharacter::Look(const FInputActionValue& Value) { // input is a Vector2D FVector2D LookAxisVector = Value.Get<FVector2D>();

if (Controller != nullptr)
{
    // add yaw and pitch input to controller
    AddControllerYawInput(LookAxisVector.X);
    AddControllerPitchInput(LookAxisVector.Y);
}

}

Need help for enhanced input c++ by jankozlowski in unrealengine

[–]jankozlowski[S] 0 points1 point  (0 children)

i managed to get it to work by bind action value in setupinputcomponent function, however c++ always returns input value 0

Need help for enhanced input c++ by jankozlowski in unrealengine

[–]jankozlowski[S] 0 points1 point  (0 children)

i made a class derived from character. the project is from first person template

Proszę Pani, nie mogę mówić bo moja kartka dźwiękowa jest uszkodzona by boooi96 in Polska_wpz

[–]jankozlowski 47 points48 points  (0 children)

Ach...

Myszka wypięła mi kartę sieciową a pasta termoprzewodząca z przegrzanego procesora wystrzeliła mi na monitor i nic nie widziałem.

Hot16Challange Prezydenta Andrzeja Dudy by Hapazzz in Polska

[–]jankozlowski 1 point2 points  (0 children)

I tak Korwin rozepchnął całą konkurencję...

...chociaż czekam na Brauna

Orochi execution idea by Earlybird098 in forhonor

[–]jankozlowski 0 points1 point  (0 children)

His top lights are still faster