This Trac instance is not used for development anymore!

We migrated our development workflow to git and Gitea.
To test the future redirection, replace trac by ariadne in the page URL.

Changeset 9901 for ps


Ignore:
Timestamp:
07/24/11 05:28:18 (13 years ago)
Author:
ben
Message:

Adds GetCivData to map generator API (to replace the hardcoded starting entities in rmgen).
Adds some starting entities to unfinished civs.

Location:
ps/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • ps/trunk/binaries/data/mods/public/civs/cart.json

    r9429 r9901  
    8181    "StartEntities":
    8282    [
     83        {
     84            "Template": "structures/cart_civil_centre"
     85        },
     86        {
     87            "Template": "units/cart_support_female_citizen",
     88            "Count": 4
     89        },
     90        {
     91            "Template": "units/cart_infantry_spearman_b",
     92            "Count": 4
     93        },
     94        {
     95            "Template": "units/cart_cavalry_swordsman_b"
     96        }
    8397    ],
    8498    "SelectableInGameSetup": false
  • ps/trunk/binaries/data/mods/public/civs/pers.json

    r9429 r9901  
    8787    "StartEntities":
    8888    [
     89        {
     90            "Template": "structures/pers_civil_centre"
     91        }
    8992    ],
    9093    "SelectableInGameSetup": false
  • ps/trunk/binaries/data/mods/public/civs/rome.json

    r9429 r9901  
    9292    "StartEntities":
    9393    [
     94        {
     95            "Template": "structures/rome_civil_centre"
     96        }
    9497    ],
    9598    "SelectableInGameSetup": false
  • ps/trunk/source/graphics/MapGenerator.cpp

    r9550 r9901  
    9292    m_ScriptInterface->RegisterFunction<void, int, CMapGeneratorWorker::SetProgress>("SetProgress");
    9393    m_ScriptInterface->RegisterFunction<void, CMapGeneratorWorker::MaybeGC>("MaybeGC");
     94    m_ScriptInterface->RegisterFunction<std::vector<std::string>, CMapGeneratorWorker::GetCivData>("GetCivData");
    9495
    9596    // Parse settings
     
    173174}
    174175
     176std::vector<std::string> CMapGeneratorWorker::GetCivData(void* UNUSED(cbdata))
     177{
     178    VfsPath path(L"civs/");
     179    VfsPaths pathnames;
     180
     181    std::vector<std::string> data;
     182
     183    // Load all JSON files in civs directory
     184    Status ret = vfs::GetPathnames(g_VFS, path, L"*.json", pathnames);
     185    if (ret == INFO::OK)
     186    {
     187        for (VfsPaths::iterator it = pathnames.begin(); it != pathnames.end(); ++it)
     188        {
     189            // Load JSON file
     190            CVFSFile file;
     191            PSRETURN ret = file.Load(g_VFS, *it);
     192            if (ret != PSRETURN_OK)
     193            {
     194                LOGERROR(L"CMapGeneratorWorker::GetCivData: Failed to load file '%ls': %hs", path.string().c_str(), GetErrorString(ret));
     195            }
     196            else
     197            {
     198                data.push_back(std::string(file.GetBuffer(), file.GetBuffer() + file.GetBufferSize()));
     199            }
     200        }
     201    }
     202    else
     203    {
     204        // Some error reading directory
     205        wchar_t error[200];
     206        LOGERROR(L"CMapGeneratorWorker::GetCivData: Error reading directory '%ls': %ls", path.string().c_str(), StatusDescription(ret, error, ARRAY_SIZE(error)));
     207    }
     208
     209    return data;
     210
     211}
     212
    175213bool CMapGeneratorWorker::LoadScripts(const std::wstring& libraryName)
    176214{
  • ps/trunk/source/graphics/MapGenerator.h

    r9523 r9901  
    124124    static void SetProgress(void* cbdata, int progress);
    125125    static void MaybeGC(void* cbdata);
     126    static std::vector<std::string> GetCivData(void* cbdata);
    126127
    127128    std::set<std::wstring> m_LoadedLibraries;
Note: See TracChangeset for help on using the changeset viewer.