mirror of
https://gitea.wildfiregames.com/0ad/0ad.git
synced 2026-06-21 01:29:50 +00:00
Put the CMapGeneratorWorker completely inside the task
The return-slot provided by the `Future` is used for synchronisation. Refs: #5874 Comments By: @Stan, @vladislavbelov, @wraitii Differential Revision: https://code.wildfiregames.com/D5001 This was SVN commit r27944.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/* Copyright (C) 2021 Wildfire Games.
|
||||
/* Copyright (C) 2023 Wildfire Games.
|
||||
* This file is part of 0 A.D.
|
||||
*
|
||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||
@@ -19,6 +19,8 @@
|
||||
#include "ps/Filesystem.h"
|
||||
#include "simulation2/system/ComponentTest.h"
|
||||
|
||||
#include <atomic>
|
||||
|
||||
class TestMapGenerator : public CxxTest::TestSuite
|
||||
{
|
||||
public:
|
||||
@@ -52,9 +54,16 @@ public:
|
||||
ScriptInterface scriptInterface("Engine", "MapGenerator", g_ScriptContext);
|
||||
ScriptTestSetup(scriptInterface);
|
||||
|
||||
CMapGeneratorWorker worker(&scriptInterface);
|
||||
worker.InitScriptInterface(0);
|
||||
scriptInterface.LoadGlobalScriptFile(path);
|
||||
// It's never read in the test so it doesn't matter to what value it's initialized. For
|
||||
// good practice it's initialized to 1.
|
||||
std::atomic<int> progress{1};
|
||||
|
||||
const Script::StructuredClone result{RunMapGenerationScript(progress, scriptInterface,
|
||||
path, "{\"Seed\": 0}", JSPROP_ENUMERATE | JSPROP_PERMANENT)};
|
||||
|
||||
// The test scripts don't call `ExportMap` so `RunMapGenerationScript` allways returns
|
||||
// `nullptr`.
|
||||
TS_ASSERT_EQUALS(result, nullptr);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user