Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/WolfireGames/overgrowth.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'Source/Graphics/palette.cpp')
-rw-r--r--Source/Graphics/palette.cpp36
1 files changed, 16 insertions, 20 deletions
diff --git a/Source/Graphics/palette.cpp b/Source/Graphics/palette.cpp
index 44d9dd7d..8a7f8317 100644
--- a/Source/Graphics/palette.cpp
+++ b/Source/Graphics/palette.cpp
@@ -1,7 +1,7 @@
//-----------------------------------------------------------------------------
// Name: palette.cpp
// Developer: Wolfire Games LLC
-// Description:
+// Description:
// License: Read below
//-----------------------------------------------------------------------------
//
@@ -27,13 +27,12 @@
#include <tinyxml.h>
-void ReadPaletteFromRAM( OGPalette &palette, const std::vector<char> &data )
-{
- int index=0;
+void ReadPaletteFromRAM(OGPalette &palette, const std::vector<char> &data) {
+ int index = 0;
int num_colors;
memread(&num_colors, sizeof(int), 1, data, index);
palette.resize(num_colors);
- for(int i=0; i<num_colors; ++i){
+ for (int i = 0; i < num_colors; ++i) {
LabeledColor &lc = palette[i];
int str_len;
memread(&str_len, sizeof(int), 1, data, index);
@@ -44,11 +43,10 @@ void ReadPaletteFromRAM( OGPalette &palette, const std::vector<char> &data )
}
}
-void WritePaletteToRAM( const OGPalette& palette, std::vector<char> &data )
-{
+void WritePaletteToRAM(const OGPalette &palette, std::vector<char> &data) {
int num_colors = palette.size();
memwrite(&num_colors, sizeof(int), 1, data);
- for(int i=0; i<num_colors; ++i){
+ for (int i = 0; i < num_colors; ++i) {
const LabeledColor &lc = palette[i];
int str_len = lc.label.size();
memwrite(&str_len, sizeof(int), 1, data);
@@ -58,14 +56,13 @@ void WritePaletteToRAM( const OGPalette& palette, std::vector<char> &data )
}
}
-void WritePaletteToXML( const OGPalette & palette, TiXmlElement* palette_el )
-{
- for(const auto & i : palette){
- TiXmlElement* color_el = new TiXmlElement("Color");
+void WritePaletteToXML(const OGPalette &palette, TiXmlElement *palette_el) {
+ for (const auto &i : palette) {
+ TiXmlElement *color_el = new TiXmlElement("Color");
palette_el->LinkEndChild(color_el);
const std::string &label = i.label;
const vec3 &color = i.color;
- const char& channel = i.channel;
+ const char &channel = i.channel;
color_el->SetAttribute("label", label.c_str());
color_el->SetAttribute("channel", channel);
color_el->SetDoubleAttribute("red", color[0]);
@@ -74,10 +71,9 @@ void WritePaletteToXML( const OGPalette & palette, TiXmlElement* palette_el )
}
}
-void ReadPaletteFromXML( OGPalette &palette, const TiXmlElement* palette_el )
-{
- const TiXmlElement* color_el = palette_el->FirstChildElement("Color");
- while(color_el){
+void ReadPaletteFromXML(OGPalette &palette, const TiXmlElement *palette_el) {
+ const TiXmlElement *color_el = palette_el->FirstChildElement("Color");
+ while (color_el) {
LabeledColor lc;
vec3 &color = lc.color;
std::string &label = lc.label;
@@ -88,11 +84,11 @@ void ReadPaletteFromXML( OGPalette &palette, const TiXmlElement* palette_el )
int channel_int;
color_el->QueryIntAttribute("channel", &channel_int);
channel = channel_int;
- const char* c = color_el->Attribute("label");
- if(c){
+ const char *c = color_el->Attribute("label");
+ if (c) {
label = c;
}
- if(!label.empty() && channel < max_palette_elements){
+ if (!label.empty() && channel < max_palette_elements) {
palette.push_back(lc);
}
color_el = color_el->NextSiblingElement();