Download

Trying to add a new TConstIterator in the world .h file, no luck?

I have been trying to add a new Iterator but get this error when trying to add it.


1>C:\Program Files\Epic Games\UE_4.25\Engine\Source\Runtime\Engine\Classes\Engine/World.h(368): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int

What seems to be causing this is when i add to the header of the World.h file. These are the lines here. Even if i comment them out it still gives that error, until i completely remove them, before it will compile with no errors



class ANavigationObjectBase

typedef TArray<TWeakObjectPtr<ANavigationObjectBase> >::TConstIterator FConstNavigationObjectIterator;


Here is all the code i am putting in. I am after getting all my player starts so i can scan them on login to get my spectator spawns to choose one to spawn at.
//goes in world.h file



class ANavigationObjectBase

typedef TArray<TWeakObjectPtr<ANavigationObjectBase> >::TConstIterator FConstNavigationObjectIterator;

/** Add a physics volume to the list of those in the world. DefaultPhysicsVolume is not tracked. Used internally by APhysicsVolume. */
void AddSpectatorStart(ANavigationObjectBase* S_Start);

/** Removes a physics volume from the list of those in the world. */
void RemoveSpectatorStart(ANavigationObjectBase* S_Start);

/** Get an iterator for all PhysicsVolumes in the world that are not a DefaultPhysicsVolume. */
FConstNavigationObjectIterator GetNavigationObjectIterator() const;

/** Get the count of all PhysicsVolumes in the world that are not a DefaultPhysicsVolume. */
int32 GetNavigationObjectCount() const;

/** List of all Spectator Starts in the world.*/
TArray<TWeakObjectPtr<ANavigationObjectBase> > NavigationObjectList;

FORCEINLINE_DEBUGGABLE FConstNavigationObjectIterator UWorld::GetNavigationObjectIterator() const
{
    auto Result = NavigationObjectList.CreateConstIterator();
    return (const FConstNavigationObjectIterator&)Result;
}

FORCEINLINE_DEBUGGABLE int32 UWorld::GetNavigationObjectCount() const
{
    return NavigationObjectList.Num();
}


//goes in world.cpp file



#include "Engine/NavigationObjectBase.h"

void UWorld::AddSpectatorStart(ANavigationObjectBase* S_Start)
{
     if (S_Start)
     {
        NavigationObjectList.Add(S_Start);
     }
}

void UWorld::RemoveSpectatorStart(ANavigationObjectBase* S_Start)
{
      NavigationObjectList.RemoveSwap(S_Start);

      // Also remove null entries that may accumulate as items become invalidated
      NavigationObjectList.RemoveSwap(nullptr);
}


Any help or ideas would be great, thanks for reading.



error C4430: missing type specifier - int assumed.


That means the compiler doesn’t know what the object is. Likely you’re missing an include of some sort.

I basically copied the volume code and made it to go to the NavagationOjbectBase class. I tried the using player start class, same error, tried using the spectator start class i made, same error.
I see the volumes come from the actor as does the NavagationOjbectBase class. This one got me stumped at the moment. I’m over looking something but not sure what.

The compiler does not know what this is?
class ANavigationObjectBase

All you have to do is add that or this, class APlayerStart
and it will give you that error. wth is up with this?

So your saying it does not know what a defined class is?

I think we have a bug here, you can not add in a class file to add more code from.

In terms of general advice, this really isn’t something you should be modifying UWorld for. Any kind of engine change comes with significant maintenance cost in the first place - let alone making modifications to a file as common as world.h.

Why can’t you keep this iterator and/or an array of registered ANavigationObjectBase objects in some other class? Your compile times will be obscene if you keep modifying engine files for game-specific code, maybe even becoming unmaintainable when it comes to engine upgrades.

I understand what you are saying, but maybe i want to just take off with my project and add what i want and not upgrade it anymore on the engine side. If that were the case. You can not do that for the fact that you cant edit somethings that should be very editable.

Thanks for the input.