Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/source/graphics/MapReader.cpp
/* Copyright (C) 2017 Wildfire Games. | /* Copyright (C) 2019 Wildfire Games. | ||||
* This file is part of 0 A.D. | * This file is part of 0 A.D. | ||||
* | * | ||||
* 0 A.D. is free software: you can redistribute it and/or modify | * 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 | * it under the terms of the GNU General Public License as published by | ||||
* the Free Software Foundation, either version 2 of the License, or | * the Free Software Foundation, either version 2 of the License, or | ||||
* (at your option) any later version. | * (at your option) any later version. | ||||
* | * | ||||
* 0 A.D. is distributed in the hope that it will be useful, | * 0 A.D. is distributed in the hope that it will be useful, | ||||
▲ Show 20 Lines • Show All 87 Lines • ▼ Show 20 Lines | void CMapReader::LoadMap(const VfsPath& pathname, JSRuntime* rt, JS::HandleValue settings, CTerrain *pTerrain_, | ||||
{ | { | ||||
// [25ms] | // [25ms] | ||||
unpacker.Read(pathname, "PSMP"); | unpacker.Read(pathname, "PSMP"); | ||||
file_format_version = unpacker.GetVersion(); | file_format_version = unpacker.GetVersion(); | ||||
} | } | ||||
// check oldest supported version | // check oldest supported version | ||||
if (file_format_version < FILE_READ_VERSION) | if (file_format_version < FILE_READ_VERSION) | ||||
throw PSERROR_File_InvalidVersion(); | throw PSERROR_Game_World_MapLoadFailed("Could not load terrain file - too old version!"); | ||||
// delete all existing entities | // delete all existing entities | ||||
if (pSimulation2) | if (pSimulation2) | ||||
pSimulation2->ResetState(); | pSimulation2->ResetState(); | ||||
// reset post effects | // reset post effects | ||||
if (pPostproc) | if (pPostproc) | ||||
pPostproc->SetPostEffect(L"default"); | pPostproc->SetPostEffect(L"default"); | ||||
▲ Show 20 Lines • Show All 332 Lines • ▼ Show 20 Lines | |||||
void CXMLReader::Init(const VfsPath& xml_filename) | void CXMLReader::Init(const VfsPath& xml_filename) | ||||
{ | { | ||||
// must only assign once, so do it here | // must only assign once, so do it here | ||||
node_idx = entity_idx = 0; | node_idx = entity_idx = 0; | ||||
if (xmb_file.Load(g_VFS, xml_filename, "scenario") != PSRETURN_OK) | if (xmb_file.Load(g_VFS, xml_filename, "scenario") != PSRETURN_OK) | ||||
throw PSERROR_File_ReadFailed(); | throw PSERROR_Game_World_MapLoadFailed("Could not read map XML file!"); | ||||
// define the elements and attributes that are frequently used in the XML file, | // define the elements and attributes that are frequently used in the XML file, | ||||
// so we don't need to do lots of string construction and comparison when | // so we don't need to do lots of string construction and comparison when | ||||
// reading the data. | // reading the data. | ||||
// (Needs to be synchronised with the list in CXMLReader - ugh) | // (Needs to be synchronised with the list in CXMLReader - ugh) | ||||
#define EL(x) el_##x = xmb_file.GetElementID(#x) | #define EL(x) el_##x = xmb_file.GetElementID(#x) | ||||
#define AT(x) at_##x = xmb_file.GetAttributeID(#x) | #define AT(x) at_##x = xmb_file.GetAttributeID(#x) | ||||
EL(entity); | EL(entity); | ||||
▲ Show 20 Lines • Show All 1,097 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator