35#include <OgreConfigFile.h>
42 , default_ground_model(nullptr)
43 , mapsize(App::GetGameContext()->GetTerrain()->getMaxTerrainSize())
68 std::map<unsigned int, String> usemap;
69 String textureFilename =
"";
71 LOG(
"Parsing landuse config: '"+filename+
"'");
76 group = ResourceGroupManager::getSingleton().findGroupContainingResource(filename);
88 cfg.loadDirect(filename);
90 cfg.loadFromResourceSystem(filename, group,
"\x09:=",
true);
92 catch (Ogre::Exception& e)
95 fmt::format(
"{}: {}",
_L(
"Error while loading landuse config"), e.getDescription()));
99 Ogre::ConfigFile::SectionIterator seci = cfg.getSectionIterator();
100 Ogre::String secName, kname, kvalue;
101 while (seci.hasMoreElements())
103 secName = seci.peekNextKey();
104 Ogre::ConfigFile::SettingsMultiMap* settings = seci.getNext();
105 Ogre::ConfigFile::SettingsMultiMap::iterator i;
106 for (i = settings->begin(); i != settings->end(); ++i)
111 if (secName ==
"general" || secName ==
"config")
114 if (kname ==
"texture")
115 textureFilename = kvalue;
116 else if (kname ==
"frictionconfig" || kname ==
"loadGroundModelsConfig")
118 else if (kname ==
"defaultuse")
121 else if (secName ==
"use-map")
123 if (kname.size() != 10)
125 LOG(
"invalid color in landuse line in " + filename);
129 unsigned int color = strtoul(kname.c_str(), &ptr, 16);
130 usemap[color] = kvalue;
150 bool bgr = colourMap->
getPixelBox().format == PF_A8B8G8R8;
166 unsigned int cols = col & 0xFF00FF00;
167 cols |= (col & 0xFF) << 16;
168 cols |= (col & 0xFF0000) >> 16;
171 String use = usemap[col];
181 catch (Ogre::Exception& oex)
183 LogFormat(
"[RoR|Physics] Landuse: failed to load texture '%s', <Ogre::Exception> message: '%s'",
184 textureFilename.c_str(), oex.getFullDescription().c_str());
186 catch (std::exception& stex)
188 LogFormat(
"[RoR|Physics] Landuse: failed to load texture '%s', <std::exception> message: '%s'",
189 textureFilename.c_str(), stex.what());
193 LogFormat(
"[RoR|Physics] Landuse: failed to load texture '%s', unknown error", textureFilename.c_str());
Central state/object manager and communications hub.
void LOG(const char *msg)
Legacy alias - formerly a macro.
Game state manager and message-queue provider.
A 2D greyscale image that is assigned to a certain region of your world to represent color levels.
static ColorMap * load(const Ogre::String &fileName, MapChannel channel=CHANNEL_COLOR)
Ogre::PixelBox getPixelBox()
Gets a pointer to the pixel data of the color map.
void setFilter(MapFilter filter)
Sets the filtering mode used for this color map.
Ogre::uint32 getColorAt(Ogre::Real x, Ogre::Real z, const Ogre::TRect< Ogre::Real > &mapBounds)
Gets the color value at the specified position.
int loadGroundModelsConfigFile(Ogre::String filename)
ground_model_t * getGroundModelByString(const Ogre::String name)
@ CONSOLE_MSGTYPE_TERRN
Parsing/spawn/simulation messages for terrain.
void putMessage(MessageArea area, MessageType type, std::string const &msg, std::string icon="")
const TerrainPtr & GetTerrain()
ground_model_t * default_ground_model
Landusemap(Ogre::String cfgfilename)
ground_model_t * getGroundModelAt(int x, int z)
int loadConfig(const Ogre::String &filename)
Collisions * GetCollisions()
@ MAPFILTER_NONE
Use no filtering - fast, but may appear blocky.
Ogre::TRect< Ogre::Real > TBounds
Define TBounds as a TRect using Real numeric units.
@ CHANNEL_COLOR
Use the image's full RGB color information.
GameContext * GetGameContext()
void LogFormat(const char *format,...)
Improved logging utility. Uses fixed 2Kb buffer.
Surface friction properties.