From 495aa7bec51ced509e500ddd7250a122336f5c19 Mon Sep 17 00:00:00 2001 From: leper Date: Sun, 21 Jun 2015 20:22:34 +0000 Subject: [PATCH] Expose TemplateExists() to RM scripts. This was SVN commit r16804. --- source/graphics/MapGenerator.cpp | 7 +++++++ source/graphics/MapGenerator.h | 3 ++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/source/graphics/MapGenerator.cpp b/source/graphics/MapGenerator.cpp index 4e61cd784e..fe03db68dc 100644 --- a/source/graphics/MapGenerator.cpp +++ b/source/graphics/MapGenerator.cpp @@ -104,6 +104,7 @@ bool CMapGeneratorWorker::Run() m_ScriptInterface->RegisterFunction("MaybeGC"); m_ScriptInterface->RegisterFunction, CMapGeneratorWorker::GetCivData>("GetCivData"); m_ScriptInterface->RegisterFunction("GetTemplate"); + m_ScriptInterface->RegisterFunction("TemplateExists"); m_ScriptInterface->RegisterFunction, std::string, bool, CMapGeneratorWorker::FindTemplates>("FindTemplates"); m_ScriptInterface->RegisterFunction, std::string, bool, CMapGeneratorWorker::FindActorTemplates>("FindActorTemplates"); @@ -230,6 +231,12 @@ CParamNode CMapGeneratorWorker::GetTemplate(ScriptInterface::CxPrivate* pCxPriva return templateRoot; } +bool CMapGeneratorWorker::TemplateExists(ScriptInterface::CxPrivate* pCxPrivate, std::string templateName) +{ + CMapGeneratorWorker* self = static_cast(pCxPrivate->pCBData); + return self->m_TemplateLoader.TemplateExists(templateName); +} + std::vector CMapGeneratorWorker::FindTemplates(ScriptInterface::CxPrivate* pCxPrivate, std::string path, bool includeSubdirectories) { CMapGeneratorWorker* self = static_cast(pCxPrivate->pCBData); diff --git a/source/graphics/MapGenerator.h b/source/graphics/MapGenerator.h index 60eb979462..a3f9d5cd10 100644 --- a/source/graphics/MapGenerator.h +++ b/source/graphics/MapGenerator.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2014 Wildfire Games. +/* Copyright (C) 2015 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -127,6 +127,7 @@ private: static void MaybeGC(ScriptInterface::CxPrivate* pCxPrivate); static std::vector GetCivData(ScriptInterface::CxPrivate* pCxPrivate); static CParamNode GetTemplate(ScriptInterface::CxPrivate* pCxPrivate, std::string templateName); + static bool TemplateExists(ScriptInterface::CxPrivate* pCxPrivate, std::string templateName); static std::vector FindTemplates(ScriptInterface::CxPrivate* pCxPrivate, std::string path, bool includeSubdirectories); static std::vector FindActorTemplates(ScriptInterface::CxPrivate* pCxPrivate, std::string path, bool includeSubdirectories);