Changeset View
Changeset View
Standalone View
Standalone View
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 All 13 Lines | |||||
#include "graphics/CinemaManager.h" | #include "graphics/CinemaManager.h" | ||||
#include "graphics/Entity.h" | #include "graphics/Entity.h" | ||||
#include "graphics/GameView.h" | #include "graphics/GameView.h" | ||||
#include "graphics/MapGenerator.h" | #include "graphics/MapGenerator.h" | ||||
#include "graphics/Patch.h" | #include "graphics/Patch.h" | ||||
#include "graphics/Terrain.h" | #include "graphics/Terrain.h" | ||||
#include "graphics/TerrainTextureEntry.h" | #include "graphics/TerrainTextureEntry.h" | ||||
#include "graphics/TerrainTextureManager.h" | #include "graphics/TerrainTextureManager.h" | ||||
#include "graphics/Unit.h" | |||||
Silier: jenkins does not like this include
```
../../../source/graphics/MapReader.cpp:31:27: fatal… | |||||
#include "lib/timer.h" | #include "lib/timer.h" | ||||
#include "lib/external_libraries/libsdl.h" | #include "lib/external_libraries/libsdl.h" | ||||
#include "maths/MathUtil.h" | #include "maths/MathUtil.h" | ||||
#include "ps/CLogger.h" | #include "ps/CLogger.h" | ||||
#include "ps/Loader.h" | #include "ps/Loader.h" | ||||
#include "ps/LoaderThunks.h" | #include "ps/LoaderThunks.h" | ||||
#include "ps/World.h" | #include "ps/World.h" | ||||
#include "ps/XML/Xeromyces.h" | #include "ps/XML/Xeromyces.h" | ||||
▲ Show 20 Lines • Show All 377 Lines • ▼ Show 20 Lines | private: | ||||
int el_template, el_player; | int el_template, el_player; | ||||
int el_position, el_orientation, el_obstruction; | int el_position, el_orientation, el_obstruction; | ||||
int el_actor; | int el_actor; | ||||
int at_x, at_y, at_z; | int at_x, at_y, at_z; | ||||
int at_group, at_group2; | int at_group, at_group2; | ||||
int at_angle; | int at_angle; | ||||
int at_uid; | int at_uid; | ||||
int at_seed; | int at_seed; | ||||
int el_variation; | |||||
int el_variations; | |||||
XMBElementList nodes; // children of root | XMBElementList nodes; // children of root | ||||
// loop counters | // loop counters | ||||
size_t node_idx; | size_t node_idx; | ||||
size_t entity_idx; | size_t entity_idx; | ||||
// # entities+nonentities processed and total (for progress calc) | // # entities+nonentities processed and total (for progress calc) | ||||
Show All 35 Lines | #define AT(x) at_##x = xmb_file.GetAttributeID(#x) | ||||
EL(orientation); | EL(orientation); | ||||
EL(obstruction); | EL(obstruction); | ||||
EL(actor); | EL(actor); | ||||
AT(x); AT(y); AT(z); | AT(x); AT(y); AT(z); | ||||
AT(group); AT(group2); | AT(group); AT(group2); | ||||
AT(angle); | AT(angle); | ||||
AT(uid); | AT(uid); | ||||
AT(seed); | AT(seed); | ||||
EL(variations); | |||||
EL(variation); | |||||
#undef AT | #undef AT | ||||
#undef EL | #undef EL | ||||
XMBElement root = xmb_file.GetRoot(); | XMBElement root = xmb_file.GetRoot(); | ||||
ENSURE(xmb_file.GetElementString(root.GetNodeName()) == "Scenario"); | ENSURE(xmb_file.GetElementString(root.GetNodeName()) == "Scenario"); | ||||
nodes = root.GetChildNodes(); | nodes = root.GetChildNodes(); | ||||
// find out total number of entities+nonentities | // find out total number of entities+nonentities | ||||
▲ Show 20 Lines • Show All 460 Lines • ▼ Show 20 Lines | while (entity_idx < entities.size()) | ||||
ENSURE(!uid.empty()); | ENSURE(!uid.empty()); | ||||
int EntityUid = uid.ToInt(); | int EntityUid = uid.ToInt(); | ||||
CStrW TemplateName; | CStrW TemplateName; | ||||
int PlayerID = 0; | int PlayerID = 0; | ||||
CFixedVector3D Position; | CFixedVector3D Position; | ||||
CFixedVector3D Orientation; | CFixedVector3D Orientation; | ||||
long Seed = -1; | long Seed = -1; | ||||
std::set<CStr> actorSelections; | |||||
// Obstruction control groups. | // Obstruction control groups. | ||||
entity_id_t ControlGroup = INVALID_ENTITY; | entity_id_t ControlGroup = INVALID_ENTITY; | ||||
entity_id_t ControlGroup2 = INVALID_ENTITY; | entity_id_t ControlGroup2 = INVALID_ENTITY; | ||||
XERO_ITER_EL(entity, setting) | XERO_ITER_EL(entity, setting) | ||||
{ | { | ||||
int element_name = setting.GetNodeName(); | int element_name = setting.GetNodeName(); | ||||
Show All 39 Lines | XERO_ITER_EL(entity, setting) | ||||
{ | { | ||||
XMBAttributeList attrs = setting.GetAttributes(); | XMBAttributeList attrs = setting.GetAttributes(); | ||||
CStr seedStr = attrs.GetNamedItem(at_seed); | CStr seedStr = attrs.GetNamedItem(at_seed); | ||||
if (!seedStr.empty()) | if (!seedStr.empty()) | ||||
{ | { | ||||
Seed = seedStr.ToLong(); | Seed = seedStr.ToLong(); | ||||
ENSURE(Seed >= 0); | ENSURE(Seed >= 0); | ||||
} | } | ||||
XMBElementList childActors = setting.GetChildNodes(); | |||||
if (childActors.size() > 1) | |||||
elexisUnsubmitted Not Done Inline Actionsit warns about > 1, perhaps it should also warn about 0? elexis: it warns about > 1, perhaps it should also warn about 0? | |||||
trompetin17AuthorUnsubmitted Done Inline Actionscould be, but if we have 0 children that means they didn't choose any variant and this could be acceptable trompetin17: could be, but if we have 0 children that means they didn't choose any variant and this could be… | |||||
LOGERROR("Failed to load variations from actor(more than one child) template '%s'", utf8_from_wstring(TemplateName)); | |||||
else if (childActors.size() == 1) | |||||
{ | |||||
XMBElement variations = childActors[0]; | |||||
Done Inline ActionsI believe same here about { } Silier: I believe same here about { } | |||||
Done Inline ActionsI suspect it complains about childActors[0] being out of bounds elexis: I suspect it complains about `childActors[0]` being out of bounds | |||||
ENSURE(variations.GetNodeName() == el_variations); | |||||
XERO_ITER_EL(variations, variation) | |||||
{ | |||||
ENSURE(variation.GetNodeName() == el_variation); | |||||
actorSelections.insert(variation.GetText()); | |||||
} | |||||
} | |||||
} | } | ||||
else | else | ||||
debug_warn(L"Invalid map XML data"); | debug_warn(L"Invalid map XML data"); | ||||
} | } | ||||
entity_id_t ent = sim.AddEntity(TemplateName, EntityUid); | entity_id_t ent = sim.AddEntity(TemplateName, EntityUid); | ||||
entity_id_t player = cmpPlayerManager->GetPlayerByID(PlayerID); | entity_id_t player = cmpPlayerManager->GetPlayerByID(PlayerID); | ||||
if (ent == INVALID_ENTITY || player == INVALID_ENTITY) | if (ent == INVALID_ENTITY || player == INVALID_ENTITY) | ||||
Show All 25 Lines | else | ||||
cmpObstruction->ResolveFoundationCollisions(); | cmpObstruction->ResolveFoundationCollisions(); | ||||
} | } | ||||
CmpPtr<ICmpVisual> cmpVisual(sim, ent); | CmpPtr<ICmpVisual> cmpVisual(sim, ent); | ||||
if (cmpVisual) | if (cmpVisual) | ||||
{ | { | ||||
if (Seed != -1) | if (Seed != -1) | ||||
cmpVisual->SetActorSeed((u32)Seed); | cmpVisual->SetActorSeed((u32)Seed); | ||||
// TODO: variation/selection strings | |||||
if (!actorSelections.empty()) | |||||
{ | |||||
CUnit* unit = cmpVisual->GetUnit(); | |||||
if (unit) | |||||
unit->SetActorSelections(actorSelections); | |||||
Done Inline Actionsthis { } can go away Silier: this { } can go away | |||||
} | |||||
} | } | ||||
if (PlayerID == m_MapReader.m_PlayerID && (boost::algorithm::ends_with(TemplateName, L"civil_centre") || m_MapReader.m_StartingCameraTarget == INVALID_ENTITY)) | if (PlayerID == m_MapReader.m_PlayerID && (boost::algorithm::ends_with(TemplateName, L"civil_centre") || m_MapReader.m_StartingCameraTarget == INVALID_ENTITY)) | ||||
{ | { | ||||
// Focus on civil centre or first entity owned by player | // Focus on civil centre or first entity owned by player | ||||
m_MapReader.m_StartingCameraTarget = ent; | m_MapReader.m_StartingCameraTarget = ent; | ||||
} | } | ||||
} | } | ||||
▲ Show 20 Lines • Show All 504 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
jenkins does not like this include