VSCODE error- May be related to UE4.25 update

Hello,

I seems to have hit a bug that will not allow the Isograms and such (they’re not doing anything in UE) added after updating the newest UE4.25 to function. However, the irony here is, I’m only using 4.22 for BullCow.

I have added the coding below for both cpp and header file, as well as a screenshot of what I think might be the problem, but I don’t see a way to fix it.

Hopefully, I’m posting the code correctly…

BullCowCartridge.cpp

// Fill out your copyright notice in the Description page of Project Settings.
#include "BullCowCartridge.h"
#include "HiddenWordList.h"
//#include "Math/UnrealMathUtility.h"

void UBullCowCartridge::BeginPlay() // When the game starts
{
    Super::BeginPlay();

    Isograms = GetValidWords(Words);
    
    SetUpGame(); //Setting Up Game
}

void UBullCowCartridge::OnInput(const FString& PlayerInput) // When the player hits enter
{
    // If game is over, clear screen and prompt play again.
    if (bGameOver)
    {
        ClearScreen();
        SetUpGame();
    }
    // Else - Check player's guess
    // Check User Input
    else
    {
    // Process to deterimate if player answered correctly or not
        ProcessGuess(PlayerInput);
    }
}

void UBullCowCartridge::SetUpGame()
{
    // Welcoming the Player and explaining the rules
    PrintLine(TEXT("I want to play a game.")); // Text() = string literals for Unreal

    // Hidden words and amount of lives declared here
    HiddenWord = Isograms[FMath::RandRange(0, Isograms.Num() -1)]; // (Declared function in BullCowCartidge.h as FString) Set the HiddenWord
    Lives = HiddenWord.Len() * 2; // (Also Declared in BullCowCartridge.h, but as int32) Set Lives
    bGameOver = false;

    PrintLine(TEXT("You have %i attempts\nto answer correctly."), Lives);
    PrintLine(TEXT("If you fail all \nattempts, you will die."));
    PrintLine(TEXT("Guess the %i letter word\nand press enter."), HiddenWord.Len()); // Magic Number %i

    //PrintLine(TEXT("The HiddenWord is: %s."), *HiddenWord); // Debug Line
}

void UBullCowCartridge::EndGame()
{
    bGameOver = true;
    PrintLine(TEXT("\nPress enter to gamble your lives again."));
}

void UBullCowCartridge::ProcessGuess(const FString& Guess)
{
    // If player guessed correctly.
    if (Guess == HiddenWord)
    {
        ClearScreen();
        PrintLine(TEXT("You have not died. Disappointing..."));
        EndGame();
        return;
    }
 
// Prompt to Guess Again
// Check Right Number of Characters
// Check if Lives > 0
    if (Guess.Len() != HiddenWord.Len())
    {
    // Player guesses incorrectly and is told amount of letters required
    // %i = HiddenWord
        PrintLine(TEXT("The word is %i characters long."), HiddenWord.Len());
        PrintLine(TEXT("Please do try again.\nI enjoy watching you fail.\nYou have %i chances left."), --Lives);
        return;
    }

    // Check If Isogram
    if (!IsIsogram(Guess))
    {
        /* code */
        PrintLine(TEXT("Repeating letters are disallowed."));
        return;
    }

// Remove Life
// Show Remaining Lives Left
// Also, if incorrect, Prompt Guess Again
    // if player guess is incorrect, subtract one life/chance.
    // %i = Lives
    PrintLine(TEXT("Please do try again.\nI enjoy watching you fail.\nYou have %i chances left."), --Lives);

    if (Lives <= 0)
    {
    // if player used up all lives, he or she loses
    // If no lives left, Show Gameover and HiddenWord Missed
        ClearScreen();
        PrintLine(TEXT("You have died. I wanted to say that\nwas unexpected, but then I would be lying."));
        PrintLine(TEXT("\nThe word was: %s"), *HiddenWord);
        EndGame();
        return;
    }
// Show the player skulls and spiders
    int32 Skull, Spider;
    GetSkullSpider(Guess, Skull, Spider);
}

bool UBullCowCartridge::IsIsogram(const FString& Word) const
{
    for (int32 Index = 0; Index < Word.Len(); Index++)
    {
        for (int32 Comparison = Index + 1; Comparison < Word.Len(); Comparison++)
        {
            if (Word[Index] == Word[Comparison])
            {
                return false;
            }
        }
    }
    
    return true;
   
    //int32 Index = 0;
    //int32 Comparison = Index + 1;

    //for (int32 Index = 0, Comparison = Index + 1; Comparison < Word.Len(); Comparison++)
    //{
    //    if (Word[Index] == Word[Comparison])
    //    {
    //        return false;
    //    }
    //    
    //}
}

TArray<FString> UBullCowCartridge::GetValidWords(const TArray<FString>& WordList) const
{
    TArray<FString> ValidWords;
    
    for (FString Word : WordList) // Allows observation of the first word till the last word in HiddenWordList.h
    {
        if (Word.Len() >= 4 && Word.Len() <= 8) // Modified the obervation to show seven instead of ten
        {
            if(IsIsogram(Word))
            {
                ValidWords.Emplace(Word);
            }
        }    
    }
    return ValidWords;
}

void UBullCowCartridge::GetSkullSpider(const FString& Guess, int32& SkullCount, int32& SpiderCount) const
{
    SkullCount = 0;
    SpiderCount = 0;

    // for every index Guess = index Hidden, SkullCount ++
    // if \= bull, then maybe = spider. If so, SpiderCount++
    for (int32 GuessIndex = 0; GuessIndex < Guess.Len(); GuessIndex++)
    {
        if (Guess[GuessIndex] == HiddenWord[GuessIndex])
        {
            SkullCount ++;
            continue;
        }
        for (int32 HiddenIndex = 0; HiddenIndex < HiddenWord.Len(); HiddenIndex++)
        {
            if (Guess[GuessIndex] == HiddenWord[HiddenIndex])
            {
                SpiderCount ++;
            }
        }
    }
}

BullCowCartridge.h

// Fill out your copyright notice in the Description page of Project Settings.

#pragma once

#include "CoreMinimal.h"
#include "Console/Cartridge.h"
#include "BullCowCartridge.generated.h"

UCLASS(ClassGroup=(Custom), meta=(BlueprintSpawnableComponent))
class BULLCOWGAME_API UBullCowCartridge : public UCartridge
{
	GENERATED_BODY()

	public:
	virtual void BeginPlay() override;
	virtual void OnInput(const FString& Input) override;
	void SetUpGame();
	void EndGame();
	void ProcessGuess(const FString& Guess);
	bool IsIsogram(const FString& Word) const;
	TArray<FString> GetValidWords(const TArray<FString>& WordList) const;
	void GetSkullSpider(const FString& Guess, int32& SkullCount, int32& SpiderCount) const;

	// Your declarations go below!
	private:
	FString HiddenWord;
	int32 Lives;
	bool bGameOver;
	TArray<FString> Isograms;
};

Below, it states the error for c_cpp_properties.json is:

{
“resource”: “/d:/Programming/CowsNBulls/BullCowGame-starter-kit/.vscode/c_cpp_properties.json”,
“owner”: “generated_diagnostic_collection_name#0”,
“code”: “768”,
“severity”: 4,
“message”: “Unable to load schema from ‘cpptools-schema:///c_cpp_properties.schema.json’: Request vscode/content failed with message: cannot open cpptools-schema:/c_cpp_properties.schema.json. Detail: resource is not available.”,
“startLineNumber”: 1,
“startColumn”: 1,
“endLineNumber”: 1,
“endColumn”: 2
}

Any help is appreciated.

Thanks,

Jason

Have you attempted to refresh the vscode project from within the Unreal Editor?
Also try uninstalling and reinstalling the C/C++ extension in VSCode to see if that fixes the issue

No luck.

Just to clarify, you meant clicking the compile button when you mentioned refreshing, right?

If you meant something else, please let me know what.

Thanks.

They meant in VS Code, go to the extensions tab, uninstall the C/C++ extension, reload, install it again.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms