Store level data in XML format

That’s a tough one :stuck_out_tongue_winking_eye:

Now, I have never done this myself, and it seems like a big task, but I will try to help you anyway

If you want to do it the hard way, I think this is a good place to start looking

In …\Source\Editor\UnrealEd\Private\EditorServer.cpp

bool UEditorEngine::Map_Load(const TCHAR* Str, FOutputDevice& Ar)
{
  // Line 2291 for version 4.8
  ...
  {
  //Load the map normally into a new package
  const FName WorldPackageFName = FName(*LongTempFname);	
  UWorld::WorldTypePreLoadMap.FindOrAdd(WorldPackageFName) = EWorldType::Editor;
  -> WorldPackage = LoadPackage( NULL, *LongTempFname, LoadFlags );	
  UWorld::WorldTypePreLoadMap.Remove(WorldPackageFName);
  }
  ...
}

Slightly easier to create a class that loads the map on GameMode::BeginPlay or something:

#include "Engine/Level.h"

void AFoo::LoadMap(...)
{
   // Start loading map here
}

void AFoo::SaveCurrentMap()
{
   ULevel *Level = GetWorld()->GetCurrentLevel();
   if (!Level)
        return;

	for (auto Actor : Level->Actors)
	{
		// Write XML
	}

  // Level also has other things that are worth saving i.e.
// ULevelScriptBlueprint* LevelScriptBlueprint;
}
1 Like