2019-07-22 12:35:14 -07:00
|
|
|
/* Copyright (C) 2019 Wildfire Games.
|
2009-06-20 09:13:29 -07:00
|
|
|
* This file is part of 0 A.D.
|
|
|
|
|
*
|
|
|
|
|
* 0 A.D. is free software: you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation, either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* 0 A.D. is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
|
|
|
|
|
2006-04-23 16:14:18 -07:00
|
|
|
#include "precompiled.h"
|
|
|
|
|
|
|
|
|
|
#include "MessageHandler.h"
|
|
|
|
|
#include "../GameLoop.h"
|
2011-05-29 08:02:02 -07:00
|
|
|
#include "../CommandProc.h"
|
2006-04-23 16:14:18 -07:00
|
|
|
|
2006-06-09 09:44:16 -07:00
|
|
|
#include "graphics/GameView.h"
|
2011-05-29 08:02:02 -07:00
|
|
|
#include "graphics/LOSTexture.h"
|
2018-02-05 08:02:00 -08:00
|
|
|
#include "graphics/MapIO.h"
|
2006-06-09 09:44:16 -07:00
|
|
|
#include "graphics/MapWriter.h"
|
2006-04-23 16:14:18 -07:00
|
|
|
#include "graphics/Patch.h"
|
2006-06-09 09:44:16 -07:00
|
|
|
#include "graphics/Terrain.h"
|
2010-09-04 14:26:52 -07:00
|
|
|
#include "graphics/TerrainTextureEntry.h"
|
|
|
|
|
#include "graphics/TerrainTextureManager.h"
|
2012-08-07 11:49:46 -07:00
|
|
|
#include "lib/bits.h"
|
2018-02-05 08:02:00 -08:00
|
|
|
#include "lib/file/vfs/vfs_path.h"
|
|
|
|
|
#include "lib/status.h"
|
2012-08-07 11:49:46 -07:00
|
|
|
#include "maths/MathUtil.h"
|
|
|
|
|
#include "ps/CLogger.h"
|
|
|
|
|
#include "ps/Filesystem.h"
|
2006-04-23 16:14:18 -07:00
|
|
|
#include "ps/Game.h"
|
|
|
|
|
#include "ps/Loader.h"
|
2007-01-13 14:44:42 -08:00
|
|
|
#include "ps/World.h"
|
2006-06-11 00:03:59 -07:00
|
|
|
#include "renderer/Renderer.h"
|
2010-06-30 14:41:04 -07:00
|
|
|
#include "scriptinterface/ScriptInterface.h"
|
2010-01-22 12:03:14 -08:00
|
|
|
#include "simulation2/Simulation2.h"
|
|
|
|
|
#include "simulation2/components/ICmpPlayer.h"
|
|
|
|
|
#include "simulation2/components/ICmpPlayerManager.h"
|
|
|
|
|
#include "simulation2/components/ICmpPosition.h"
|
2010-09-23 05:13:13 -07:00
|
|
|
#include "simulation2/components/ICmpRangeManager.h"
|
2011-05-29 08:02:02 -07:00
|
|
|
#include "simulation2/components/ICmpTerrain.h"
|
2006-04-23 16:14:18 -07:00
|
|
|
|
2007-01-24 12:17:28 -08:00
|
|
|
namespace
|
2006-04-23 16:14:18 -07:00
|
|
|
{
|
2010-06-30 14:41:04 -07:00
|
|
|
void InitGame()
|
2007-01-24 12:17:28 -08:00
|
|
|
{
|
|
|
|
|
if (g_Game)
|
|
|
|
|
{
|
|
|
|
|
delete g_Game;
|
|
|
|
|
g_Game = NULL;
|
|
|
|
|
}
|
2006-04-23 16:14:18 -07:00
|
|
|
|
2019-08-25 04:02:55 -07:00
|
|
|
g_Game = new CGame(false);
|
2010-06-30 14:41:04 -07:00
|
|
|
|
|
|
|
|
// Default to player 1 for playtesting
|
|
|
|
|
g_Game->SetPlayerID(1);
|
2007-01-24 12:17:28 -08:00
|
|
|
}
|
2006-04-23 16:14:18 -07:00
|
|
|
|
2015-01-24 06:46:52 -08:00
|
|
|
void StartGame(JS::MutableHandleValue attrs)
|
2010-01-22 12:03:14 -08:00
|
|
|
{
|
2011-10-29 17:07:28 -07:00
|
|
|
g_Game->StartGame(attrs, "");
|
2011-04-06 19:32:16 -07:00
|
|
|
|
|
|
|
|
// TODO: Non progressive load can fail - need a decent way to handle this
|
2007-01-24 12:17:28 -08:00
|
|
|
LDR_NonprogressiveLoad();
|
2010-09-23 05:13:13 -07:00
|
|
|
|
2012-07-30 14:06:54 -07:00
|
|
|
// Disable fog-of-war - this must be done before starting the game,
|
|
|
|
|
// as visual actors cache their visibility state on first render.
|
2010-09-23 05:13:13 -07:00
|
|
|
CmpPtr<ICmpRangeManager> cmpRangeManager(*g_Game->GetSimulation2(), SYSTEM_ENTITY);
|
2012-02-07 18:46:15 -08:00
|
|
|
if (cmpRangeManager)
|
2013-12-31 13:30:48 -08:00
|
|
|
cmpRangeManager->SetLosRevealAll(-1, true);
|
2012-07-30 14:06:54 -07:00
|
|
|
|
|
|
|
|
PSRETURN ret = g_Game->ReallyStartGame();
|
|
|
|
|
ENSURE(ret == PSRETURN_OK);
|
2007-01-24 12:17:28 -08:00
|
|
|
}
|
2006-04-23 16:14:18 -07:00
|
|
|
}
|
|
|
|
|
|
2007-01-24 12:17:28 -08:00
|
|
|
namespace AtlasMessage {
|
|
|
|
|
|
2011-04-13 21:01:59 -07:00
|
|
|
QUERYHANDLER(GenerateMap)
|
2006-04-23 16:14:18 -07:00
|
|
|
{
|
2014-09-07 20:48:24 -07:00
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
InitGame();
|
2006-04-23 16:14:18 -07:00
|
|
|
|
2014-09-07 20:48:24 -07:00
|
|
|
// Random map
|
2017-11-24 22:49:58 -08:00
|
|
|
const ScriptInterface& scriptInterface = g_Game->GetSimulation2()->GetScriptInterface();
|
2014-09-07 20:48:24 -07:00
|
|
|
JSContext* cx = scriptInterface.GetContext();
|
|
|
|
|
JSAutoRequest rq(cx);
|
2016-01-22 17:02:57 -08:00
|
|
|
|
2014-09-07 20:48:24 -07:00
|
|
|
JS::RootedValue settings(cx);
|
|
|
|
|
scriptInterface.ParseJSON(*msg->settings, &settings);
|
2019-09-12 17:56:51 -07:00
|
|
|
scriptInterface.SetProperty(settings, "mapType", "random");
|
2011-04-15 21:04:06 -07:00
|
|
|
|
2014-09-07 20:48:24 -07:00
|
|
|
JS::RootedValue attrs(cx);
|
2019-09-12 17:56:51 -07:00
|
|
|
ScriptInterface::CreateObject(
|
|
|
|
|
cx,
|
2019-07-22 12:35:14 -07:00
|
|
|
&attrs,
|
2019-09-12 17:56:51 -07:00
|
|
|
"mapType", "random",
|
|
|
|
|
"script", *msg->filename,
|
2019-07-22 12:35:14 -07:00
|
|
|
"settings", settings);
|
2011-04-13 21:01:59 -07:00
|
|
|
|
2015-01-24 06:46:52 -08:00
|
|
|
StartGame(&attrs);
|
2011-04-13 21:01:59 -07:00
|
|
|
|
|
|
|
|
msg->status = 0;
|
|
|
|
|
}
|
2013-05-22 15:27:53 -07:00
|
|
|
catch (PSERROR_Game_World_MapLoadFailed&)
|
2011-04-13 21:01:59 -07:00
|
|
|
{
|
|
|
|
|
// Cancel loading
|
|
|
|
|
LDR_Cancel();
|
2006-04-23 16:14:18 -07:00
|
|
|
|
2012-01-20 16:53:34 -08:00
|
|
|
// Since map generation failed and we don't know why, use the blank map as a fallback
|
|
|
|
|
|
|
|
|
|
InitGame();
|
|
|
|
|
|
2017-11-24 22:49:58 -08:00
|
|
|
const ScriptInterface& scriptInterface = g_Game->GetSimulation2()->GetScriptInterface();
|
2014-09-07 20:48:24 -07:00
|
|
|
JSContext* cx = scriptInterface.GetContext();
|
|
|
|
|
JSAutoRequest rq(cx);
|
|
|
|
|
|
|
|
|
|
// Set up 8-element array of empty objects to satisfy init
|
|
|
|
|
JS::RootedValue playerData(cx);
|
2019-09-12 17:56:51 -07:00
|
|
|
ScriptInterface::CreateArray(cx, &playerData);
|
2019-07-22 12:35:14 -07:00
|
|
|
|
2014-09-07 20:48:24 -07:00
|
|
|
for (int i = 0; i < 8; ++i)
|
|
|
|
|
{
|
|
|
|
|
JS::RootedValue player(cx);
|
2019-09-12 17:56:51 -07:00
|
|
|
ScriptInterface::CreateObject(cx, &player);
|
2014-09-07 20:48:24 -07:00
|
|
|
scriptInterface.SetPropertyInt(playerData, i, player);
|
|
|
|
|
}
|
|
|
|
|
|
2019-07-22 12:35:14 -07:00
|
|
|
JS::RootedValue settings(cx);
|
2019-09-12 17:56:51 -07:00
|
|
|
ScriptInterface::CreateObject(
|
|
|
|
|
cx,
|
2019-07-22 12:35:14 -07:00
|
|
|
&settings,
|
2019-09-12 17:56:51 -07:00
|
|
|
"mapType", "scenario",
|
2019-07-22 12:35:14 -07:00
|
|
|
"PlayerData", playerData);
|
|
|
|
|
|
|
|
|
|
JS::RootedValue attrs(cx);
|
2019-09-12 17:56:51 -07:00
|
|
|
ScriptInterface::CreateObject(
|
|
|
|
|
cx,
|
2019-07-22 12:35:14 -07:00
|
|
|
&attrs,
|
2019-09-12 17:56:51 -07:00
|
|
|
"mapType", "scenario",
|
|
|
|
|
"map", "maps/scenarios/_default",
|
2019-07-22 12:35:14 -07:00
|
|
|
"settings", settings);
|
|
|
|
|
|
|
|
|
|
StartGame(&attrs);
|
2012-01-20 16:53:34 -08:00
|
|
|
|
2011-04-13 21:01:59 -07:00
|
|
|
msg->status = -1;
|
|
|
|
|
}
|
2006-04-23 16:14:18 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MESSAGEHANDLER(LoadMap)
|
|
|
|
|
{
|
2014-07-27 11:38:31 -07:00
|
|
|
InitGame();
|
2016-01-22 17:02:57 -08:00
|
|
|
|
2017-11-24 22:49:58 -08:00
|
|
|
const ScriptInterface& scriptInterface = g_Game->GetSimulation2()->GetScriptInterface();
|
2014-07-26 15:33:16 -07:00
|
|
|
JSContext* cx = scriptInterface.GetContext();
|
|
|
|
|
JSAutoRequest rq(cx);
|
2011-04-13 21:01:59 -07:00
|
|
|
|
|
|
|
|
// Scenario
|
|
|
|
|
CStrW map = *msg->filename;
|
|
|
|
|
CStrW mapBase = map.BeforeLast(L".pmp"); // strip the file extension, if any
|
2016-01-22 17:02:57 -08:00
|
|
|
|
2014-07-26 15:33:16 -07:00
|
|
|
JS::RootedValue attrs(cx);
|
2019-07-22 12:35:14 -07:00
|
|
|
|
2019-09-12 17:56:51 -07:00
|
|
|
ScriptInterface::CreateObject(
|
|
|
|
|
cx,
|
2019-07-22 12:35:14 -07:00
|
|
|
&attrs,
|
2019-09-12 17:56:51 -07:00
|
|
|
"mapType", "scenario",
|
|
|
|
|
"map", mapBase);
|
2011-04-13 21:01:59 -07:00
|
|
|
|
2015-01-24 06:46:52 -08:00
|
|
|
StartGame(&attrs);
|
2006-04-23 16:14:18 -07:00
|
|
|
}
|
|
|
|
|
|
2012-08-07 11:49:46 -07:00
|
|
|
MESSAGEHANDLER(ImportHeightmap)
|
|
|
|
|
{
|
2018-02-05 08:02:00 -08:00
|
|
|
std::vector<u16> heightmap_source;
|
2018-05-01 14:15:55 -07:00
|
|
|
if (LoadHeightmapImageOs(*msg->filename, heightmap_source) != INFO::OK)
|
2012-08-07 11:49:46 -07:00
|
|
|
{
|
2015-01-22 12:31:30 -08:00
|
|
|
LOGERROR("Failed to decode heightmap.");
|
2012-08-07 11:49:46 -07:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// resize terrain to heightmap size
|
2018-02-05 08:02:00 -08:00
|
|
|
// Notice that the number of tiles/pixels per side of the heightmap image is
|
|
|
|
|
// one less than the number of vertices per side of the heightmap.
|
2012-08-07 11:49:46 -07:00
|
|
|
CTerrain* terrain = g_Game->GetWorld()->GetTerrain();
|
2018-02-05 08:02:00 -08:00
|
|
|
terrain->Resize((sqrt(heightmap_source.size()) - 1) / PATCH_SIZE);
|
2016-01-22 17:02:57 -08:00
|
|
|
|
2012-08-07 11:49:46 -07:00
|
|
|
// copy heightmap data into map
|
|
|
|
|
u16* heightmap = g_Game->GetWorld()->GetTerrain()->GetHeightMap();
|
2018-02-05 08:02:00 -08:00
|
|
|
ENSURE(heightmap_source.size() == (std::size_t) SQR(g_Game->GetWorld()->GetTerrain()->GetVerticesPerSide()));
|
|
|
|
|
std::copy(heightmap_source.begin(), heightmap_source.end(), heightmap);
|
2016-01-22 17:02:57 -08:00
|
|
|
|
2012-08-07 11:49:46 -07:00
|
|
|
// update simulation
|
|
|
|
|
CmpPtr<ICmpTerrain> cmpTerrain(*g_Game->GetSimulation2(), SYSTEM_ENTITY);
|
2018-02-05 08:02:00 -08:00
|
|
|
if (cmpTerrain)
|
|
|
|
|
cmpTerrain->ReloadTerrain();
|
|
|
|
|
|
2012-08-07 11:49:46 -07:00
|
|
|
g_Game->GetView()->GetLOSTexture().MakeDirty();
|
|
|
|
|
}
|
|
|
|
|
|
2006-04-23 16:14:18 -07:00
|
|
|
MESSAGEHANDLER(SaveMap)
|
|
|
|
|
{
|
|
|
|
|
CMapWriter writer;
|
Implements skirmish maps, based on patch by sanderd17, fixes #1198. Skirmish maps are like scenarios, except the player can choose their civ during match setup. To create a skirmish map: place some skirmish entities for each player in Atlas (see templates/skirmish/* for examples), uncheck the player's civ in Atlas' player panel if desired, and save in the maps/skirmishes directory. The map will appear in match setup under the "Skirmish" match type.
Implements custom, VFS-based map load/save dialogs for Atlas (replaces
broken native file dialogs), fixes #631, #889.
Fixes map loading/saving to handle arbitrary subdirectories for better
organization.
Adds default settings to Atlas player panel, fixes #1872. Each setting
now has a checkbox to choose whether it should be saved with the map
(avoids writing lots of useless default data for each map).
Adds map preview setting to Atlas, refs #1745.
Cleans up and simplifies some duplicate code.
Fixes optional serialization performance test.
This was SVN commit r13938.
2013-10-03 19:29:16 -07:00
|
|
|
VfsPath pathname = VfsPath(*msg->filename).ChangeExtension(L".pmp");
|
2009-11-03 13:46:35 -08:00
|
|
|
writer.SaveMap(pathname,
|
2010-08-01 13:56:34 -07:00
|
|
|
g_Game->GetWorld()->GetTerrain(),
|
2006-06-21 15:37:31 -07:00
|
|
|
g_Renderer.GetWaterManager(), g_Renderer.GetSkyManager(),
|
2010-04-29 16:22:18 -07:00
|
|
|
&g_LightEnv, g_Game->GetView()->GetCamera(), g_Game->GetView()->GetCinema(),
|
2012-10-15 03:34:23 -07:00
|
|
|
&g_Renderer.GetPostprocManager(),
|
2010-04-29 16:22:18 -07:00
|
|
|
g_Game->GetSimulation2());
|
2006-04-23 16:14:18 -07:00
|
|
|
}
|
|
|
|
|
|
2011-04-13 21:01:59 -07:00
|
|
|
QUERYHANDLER(GetMapSettings)
|
|
|
|
|
{
|
|
|
|
|
msg->settings = g_Game->GetSimulation2()->GetMapSettingsString();
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-09 16:47:20 -07:00
|
|
|
BEGIN_COMMAND(SetMapSettings)
|
|
|
|
|
{
|
2011-08-22 14:45:39 -07:00
|
|
|
std::string m_OldSettings, m_NewSettings;
|
2016-01-22 17:02:57 -08:00
|
|
|
|
2011-08-22 14:45:39 -07:00
|
|
|
void SetSettings(const std::string& settings)
|
|
|
|
|
{
|
|
|
|
|
g_Game->GetSimulation2()->SetMapSettings(settings);
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-09 16:47:20 -07:00
|
|
|
void Do()
|
|
|
|
|
{
|
2011-08-22 14:45:39 -07:00
|
|
|
m_OldSettings = g_Game->GetSimulation2()->GetMapSettingsString();
|
|
|
|
|
m_NewSettings = *msg->settings;
|
2016-01-22 17:02:57 -08:00
|
|
|
|
2011-08-22 14:45:39 -07:00
|
|
|
SetSettings(m_NewSettings);
|
2011-06-09 16:47:20 -07:00
|
|
|
}
|
|
|
|
|
|
2011-08-22 14:45:39 -07:00
|
|
|
// TODO: we need some way to notify the Atlas UI when the settings are changed
|
|
|
|
|
// externally, otherwise this will have no visible effect
|
2011-06-09 16:47:20 -07:00
|
|
|
void Undo()
|
|
|
|
|
{
|
2011-08-22 14:45:39 -07:00
|
|
|
// SetSettings(m_OldSettings);
|
2011-06-09 16:47:20 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Redo()
|
|
|
|
|
{
|
2011-08-22 14:45:39 -07:00
|
|
|
// SetSettings(m_NewSettings);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MergeIntoPrevious(cSetMapSettings* prev)
|
|
|
|
|
{
|
|
|
|
|
prev->m_NewSettings = m_NewSettings;
|
2011-06-09 16:47:20 -07:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
END_COMMAND(SetMapSettings)
|
|
|
|
|
|
2011-08-22 14:45:39 -07:00
|
|
|
MESSAGEHANDLER(LoadPlayerSettings)
|
|
|
|
|
{
|
|
|
|
|
g_Game->GetSimulation2()->LoadPlayerSettings(msg->newplayers);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QUERYHANDLER(GetMapSizes)
|
|
|
|
|
{
|
|
|
|
|
msg->sizes = g_Game->GetSimulation2()->GetMapSizes();
|
|
|
|
|
}
|
|
|
|
|
|
2011-04-13 21:01:59 -07:00
|
|
|
QUERYHANDLER(GetRMSData)
|
|
|
|
|
{
|
|
|
|
|
msg->data = g_Game->GetSimulation2()->GetRMSData();
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-29 08:02:02 -07:00
|
|
|
BEGIN_COMMAND(ResizeMap)
|
|
|
|
|
{
|
2011-08-22 14:45:39 -07:00
|
|
|
int m_OldTiles, m_NewTiles;
|
|
|
|
|
|
2011-05-29 08:02:02 -07:00
|
|
|
cResizeMap()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MakeDirty()
|
|
|
|
|
{
|
|
|
|
|
CmpPtr<ICmpTerrain> cmpTerrain(*g_Game->GetSimulation2(), SYSTEM_ENTITY);
|
2012-02-07 18:46:15 -08:00
|
|
|
if (cmpTerrain)
|
2011-05-29 08:02:02 -07:00
|
|
|
cmpTerrain->ReloadTerrain();
|
|
|
|
|
|
|
|
|
|
// The LOS texture won't normally get updated when running Atlas
|
|
|
|
|
// (since there's no simulation updates), so explicitly dirty it
|
|
|
|
|
g_Game->GetView()->GetLOSTexture().MakeDirty();
|
|
|
|
|
}
|
|
|
|
|
|
2011-08-22 14:45:39 -07:00
|
|
|
void ResizeTerrain(int tiles)
|
|
|
|
|
{
|
|
|
|
|
CTerrain* terrain = g_Game->GetWorld()->GetTerrain();
|
|
|
|
|
|
|
|
|
|
terrain->Resize(tiles / PATCH_SIZE);
|
|
|
|
|
|
|
|
|
|
MakeDirty();
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-29 08:02:02 -07:00
|
|
|
void Do()
|
|
|
|
|
{
|
2011-08-22 14:45:39 -07:00
|
|
|
CmpPtr<ICmpTerrain> cmpTerrain(*g_Game->GetSimulation2(), SYSTEM_ENTITY);
|
2012-02-07 18:46:15 -08:00
|
|
|
if (!cmpTerrain)
|
2011-08-22 14:45:39 -07:00
|
|
|
{
|
|
|
|
|
m_OldTiles = m_NewTiles = 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
m_OldTiles = (int)cmpTerrain->GetTilesPerSide();
|
|
|
|
|
m_NewTiles = msg->tiles;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ResizeTerrain(m_NewTiles);
|
2011-05-29 08:02:02 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Undo()
|
|
|
|
|
{
|
2011-08-22 14:45:39 -07:00
|
|
|
ResizeTerrain(m_OldTiles);
|
2011-05-29 08:02:02 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Redo()
|
|
|
|
|
{
|
2011-08-22 14:45:39 -07:00
|
|
|
ResizeTerrain(m_NewTiles);
|
2011-05-29 08:02:02 -07:00
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
END_COMMAND(ResizeMap)
|
|
|
|
|
|
2011-10-20 16:45:27 -07:00
|
|
|
QUERYHANDLER(VFSFileExists)
|
|
|
|
|
{
|
|
|
|
|
msg->exists = VfsFileExists(*msg->path);
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-13 13:20:45 -07:00
|
|
|
QUERYHANDLER(VFSFileRealPath)
|
|
|
|
|
{
|
|
|
|
|
VfsPath pathname(*msg->path);
|
|
|
|
|
if (pathname.empty())
|
|
|
|
|
return;
|
|
|
|
|
OsPath realPathname;
|
|
|
|
|
if (g_VFS->GetRealPath(pathname, realPathname) == INFO::OK)
|
|
|
|
|
msg->realPath = realPathname.string();
|
|
|
|
|
}
|
|
|
|
|
|
Implements skirmish maps, based on patch by sanderd17, fixes #1198. Skirmish maps are like scenarios, except the player can choose their civ during match setup. To create a skirmish map: place some skirmish entities for each player in Atlas (see templates/skirmish/* for examples), uncheck the player's civ in Atlas' player panel if desired, and save in the maps/skirmishes directory. The map will appear in match setup under the "Skirmish" match type.
Implements custom, VFS-based map load/save dialogs for Atlas (replaces
broken native file dialogs), fixes #631, #889.
Fixes map loading/saving to handle arbitrary subdirectories for better
organization.
Adds default settings to Atlas player panel, fixes #1872. Each setting
now has a checkbox to choose whether it should be saved with the map
(avoids writing lots of useless default data for each map).
Adds map preview setting to Atlas, refs #1745.
Cleans up and simplifies some duplicate code.
Fixes optional serialization performance test.
This was SVN commit r13938.
2013-10-03 19:29:16 -07:00
|
|
|
static Status AddToFilenames(const VfsPath& pathname, const CFileInfo& UNUSED(fileInfo), const uintptr_t cbData)
|
|
|
|
|
{
|
|
|
|
|
std::vector<std::wstring>& filenames = *(std::vector<std::wstring>*)cbData;
|
|
|
|
|
filenames.push_back(pathname.string().c_str());
|
|
|
|
|
return INFO::OK;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
QUERYHANDLER(GetMapList)
|
|
|
|
|
{
|
2018-03-13 13:20:45 -07:00
|
|
|
#define GET_FILE_LIST(path, list) \
|
|
|
|
|
std::vector<std::wstring> list; \
|
|
|
|
|
vfs::ForEachFile(g_VFS, path, AddToFilenames, (uintptr_t)&list, L"*.xml", vfs::DIR_RECURSIVE); \
|
|
|
|
|
msg->list = list;
|
|
|
|
|
|
|
|
|
|
GET_FILE_LIST(L"maps/scenarios/", scenarioFilenames);
|
|
|
|
|
GET_FILE_LIST(L"maps/skirmishes/", skirmishFilenames);
|
|
|
|
|
GET_FILE_LIST(L"maps/tutorials/", tutorialFilenames);
|
|
|
|
|
#undef GET_FILE_LIST
|
Implements skirmish maps, based on patch by sanderd17, fixes #1198. Skirmish maps are like scenarios, except the player can choose their civ during match setup. To create a skirmish map: place some skirmish entities for each player in Atlas (see templates/skirmish/* for examples), uncheck the player's civ in Atlas' player panel if desired, and save in the maps/skirmishes directory. The map will appear in match setup under the "Skirmish" match type.
Implements custom, VFS-based map load/save dialogs for Atlas (replaces
broken native file dialogs), fixes #631, #889.
Fixes map loading/saving to handle arbitrary subdirectories for better
organization.
Adds default settings to Atlas player panel, fixes #1872. Each setting
now has a checkbox to choose whether it should be saved with the map
(avoids writing lots of useless default data for each map).
Adds map preview setting to Atlas, refs #1745.
Cleans up and simplifies some duplicate code.
Fixes optional serialization performance test.
This was SVN commit r13938.
2013-10-03 19:29:16 -07:00
|
|
|
}
|
|
|
|
|
|
2006-04-23 16:14:18 -07:00
|
|
|
}
|