Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
MapGenerator.h
Go to the documentation of this file.
1/* Copyright (C) 2023 Wildfire Games.
2 * This file is part of 0 A.D.
3 *
4 * 0 A.D. is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * 0 A.D. is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef INCLUDED_MAPGENERATOR
19#define INCLUDED_MAPGENERATOR
20
24
25#include <atomic>
26#include <string>
27
28/**
29 * Generate the map. This does take a long time.
30 *
31 * @param progress Destination to write the function progress to. You must not
32 * write to it while `RunMapGenerationScript` is running.
33 * @param script The VFS path for the script, e.g. "maps/random/latium.js".
34 * @param settings JSON string containing settings for the map generator.
35 * @param flags With thous flags the engine functions get registered
36 * `g_MapSettings` also respects this flags.
37 * @return If there is an error `nullptr` is returned. Otherwise random map
38 * data, according to this format:
39 * https://trac.wildfiregames.com/wiki/Random_Map_Generator_Internals#Dataformat
40 */
41Script::StructuredClone RunMapGenerationScript(std::atomic<int>& progress,
42 ScriptInterface& scriptInterface, const VfsPath& script, const std::string& settings,
43 const u16 flags = JSPROP_ENUMERATE | JSPROP_READONLY | JSPROP_PERMANENT);
44
45#endif //INCLUDED_MAPGENERATOR
Script::StructuredClone RunMapGenerationScript(std::atomic< int > &progress, ScriptInterface &scriptInterface, const VfsPath &script, const std::string &settings, const u16 flags=JSPROP_ENUMERATE|JSPROP_READONLY|JSPROP_PERMANENT)
Generate the map.
Definition: MapGenerator.cpp:379
Definition: path.h:80
Abstraction around a SpiderMonkey JS::Realm.
Definition: ScriptInterface.h:72
std::shared_ptr< JSStructuredCloneData > StructuredClone
Structured clones are a way to serialize 'simple' JS::Values into a buffer that can safely be passed ...
Definition: StructuredClone.h:36
uint16_t u16
Definition: types.h:38