Ticket #118: variations.diff

File variations.diff, 3.0 KB (added by trompetin17, 9 years ago)
  • source/graphics/MapReader.cpp

    diff --git a/source/graphics/MapReader.cpp b/source/graphics/MapReader.cpp
    index ed57c2c..19acace 100644
    a b  
    1919
    2020#include "MapReader.h"
    2121
     22#include "boost/algorithm/string/split.hpp"
     23#include "boost/algorithm/string/classification.hpp"
    2224#include "graphics/Camera.h"
    2325#include "graphics/CinemaTrack.h"
    2426#include "graphics/Entity.h"
     
    2830#include "graphics/Terrain.h"
    2931#include "graphics/TerrainTextureEntry.h"
    3032#include "graphics/TerrainTextureManager.h"
     33#include "graphics/Unit.h"
    3134#include "lib/timer.h"
    3235#include "lib/external_libraries/libsdl.h"
    3336#include "maths/MathUtil.h"
    private:  
    433436    int el_template, el_player;
    434437    int el_position, el_orientation, el_obstruction;
    435438    int el_actor;
     439    int el_actorSelections;
    436440    int at_x, at_y, at_z;
    437441    int at_group, at_group2;
    438442    int at_id;
    void CXMLReader::Init(const VfsPath& xml_filename)  
    485489    EL(orientation);
    486490    EL(obstruction);
    487491    EL(actor);
     492    EL(actorSelections);
    488493    AT(x); AT(y); AT(z);
    489494    AT(group); AT(group2);
    490495    AT(angle);
    int CXMLReader::ReadEntities(XMBElement parent, double end_time)  
    986991        CFixedVector3D Position;
    987992        CFixedVector3D Orientation;
    988993        long Seed = -1;
     994        std::set<CStr8> actorSelections;
    989995
    990996        // Obstruction control groups.
    991997        entity_id_t ControlGroup = INVALID_ENTITY;
    int CXMLReader::ReadEntities(XMBElement parent, double end_time)  
    10421048                    ENSURE(Seed >= 0);
    10431049                }
    10441050            }
     1051            else if (element_name == el_actorSelections)
     1052            {
     1053                CStr8 cdata = setting.GetText();
     1054                boost::algorithm::split(actorSelections, cdata, boost::is_any_of("|"));
     1055            }
    10451056            else
    10461057                debug_warn(L"Invalid map XML data");
    10471058        }
    int CXMLReader::ReadEntities(XMBElement parent, double end_time)  
    10831094                if (Seed != -1)
    10841095                    cmpVisual->SetActorSeed((u32)Seed);
    10851096                // TODO: variation/selection strings
     1097                CUnit* unit = cmpVisual->GetUnit();
     1098                if (unit)
     1099                    unit->SetActorSelections(actorSelections);
    10861100            }
    10871101
    10881102            if (PlayerID == m_MapReader.m_PlayerID && (boost::algorithm::ends_with(TemplateName, L"civil_centre") || m_MapReader.m_StartingCameraTarget == INVALID_ENTITY))
  • source/graphics/MapWriter.cpp

    diff --git a/source/graphics/MapWriter.cpp b/source/graphics/MapWriter.cpp
    index 9d59ac0..03b97a9 100644
    a b  
    2727#include "Terrain.h"
    2828#include "TerrainTextureEntry.h"
    2929#include "TerrainTextureManager.h"
     30#include "Unit.h"
    3031
     32
     33#include "boost/algorithm/string/join.hpp"
    3134#include "maths/MathUtil.h"
    3235#include "maths/NUSpline.h"
    3336#include "ps/CLogger.h"
    void CMapWriter::WriteXML(const VfsPath& filename,  
    392395                        XML_Element("Actor");
    393396                        XML_Attribute("seed", seed);
    394397                    }
    395                     // TODO: variation/selection strings
     398                   
     399                    CUnit* unit = cmpVisual->GetUnit();
     400                    if (unit)
     401                    {
     402                        CStr actorSelections = boost::algorithm::join(unit->GetActorSelections(), "|");
     403                       
     404                        XML_Element("ActorSelections");
     405                        XML_CDATA(actorSelections.c_str());
     406                    }
    396407                }
    397408            }
    398409        }