Index: binaries/data/config/default.cfg =================================================================== --- binaries/data/config/default.cfg +++ binaries/data/config/default.cfg @@ -81,6 +81,9 @@ silhouettes = true showsky = true +; Whether or not entity variants are selected randomly +graphics.entityvariety = true + novbo = false ; Disable hardware cursors Index: binaries/data/mods/public/gui/options/options.json =================================================================== --- binaries/data/mods/public/gui/options/options.json +++ binaries/data/mods/public/gui/options/options.json @@ -198,6 +198,12 @@ }, { "type": "boolean", + "label": "Random entity appearance", + "tooltip": "Randomize the appearance of entities. Disabling gives a small performance improvement. Requires a new match.", + "config": "graphics.entityvariety" + }, + { + "type": "boolean", "label": "Particles", "tooltip": "Enable particles.", "config": "particles", Index: source/graphics/ObjectBase.h =================================================================== --- source/graphics/ObjectBase.h +++ source/graphics/ObjectBase.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2019 Wildfire Games. +/* Copyright (C) 2020 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -185,6 +185,8 @@ // so use a better one that appears to avoid those patterns using rng_t = boost::mt19937; + bool m_EntityVariety = true; + std::set CalculateRandomRemainingSelections(rng_t& rng, const std::vector >& initialSelections); std::vector< std::vector > m_VariantGroups; Index: source/graphics/ObjectBase.cpp =================================================================== --- source/graphics/ObjectBase.cpp +++ source/graphics/ObjectBase.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2019 Wildfire Games. +/* Copyright (C) 2020 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -26,6 +26,7 @@ #include "ps/XML/Xeromyces.h" #include "ps/Filesystem.h" #include "ps/CLogger.h" +#include "ps/ConfigDB.h" #include "lib/timer.h" #include "maths/MathUtil.h" @@ -34,6 +35,8 @@ CObjectBase::CObjectBase(CObjectManager& objectManager) : m_ObjectManager(objectManager) { + CFG_GET_VAL("graphics.entityvariety", m_EntityVariety); + m_Properties.m_CastShadows = false; m_Properties.m_FloatOnWater = false; } @@ -543,6 +546,14 @@ // already something to choose. Otherwise, choose randomly from the others. if (match == -1) { + // Do not choose randomly if the config asks us not to do it. + if (!m_EntityVariety) + { + remainingSelections.insert(grp->front().m_VariantName); + match = 0; + break; + } + // Sum the frequencies int totalFreq = 0; for (size_t i = 0; i < grp->size(); ++i) @@ -553,10 +564,8 @@ bool allZero = (totalFreq == 0); if (allZero) totalFreq = (int)grp->size(); - // Choose a random number in the interval [0..totalFreq) + // Choose a random number in the interval [0..totalFreq) to choose one of the variants. int randNum = boost::random::uniform_int_distribution(0, totalFreq-1)(rng); - - // and use that to choose one of the variants for (size_t i = 0; i < grp->size(); ++i) { randNum -= (allZero ? 1 : (*grp)[i].m_Frequency);