// Copyright 2013-2021 the openage authors. See copying.md for legal info.

// Warning: this file is a dummy file and was auto-generated by the v0.4.1 converter;
// its purpose is to keep the deprecated gamestate compilable and intact;
// these files keep only the minimum functionality and should not be changed;
// For details, see buildsystem/codegen.cmake and openage/codegen.


#include <cstdio>
#include <vector>
#include "error/error.h"
#include "player_color_dummy.h"
#include "util/strings.h"


namespace openage {
namespace gamedata {

constexpr size_t player_color::member_count;
int player_color::fill(const std::string &line) {
    std::vector<std::string> buf = openage::util::split_escape(
        line, ',', player_color::member_count
    );

    if (buf.size() != player_color::member_count) {
        throw openage::error::Error(
            ERR
            << "Tokenizing player_color led to "
            << buf.size()
            << " columns (expected "
            << player_color::member_count
            << ")!"
        );
    }

    if (sscanf(buf[0].c_str(), "%d", &this->id) != 1) { return 0; }
    if (sscanf(buf[1].c_str(), "%d", &this->player_color_base) != 1) { return 1; }
    if (sscanf(buf[2].c_str(), "%d", &this->outline_color) != 1) { return 2; }
    if (sscanf(buf[3].c_str(), "%d", &this->unit_selection_color1) != 1) { return 3; }
    if (sscanf(buf[4].c_str(), "%d", &this->unit_selection_color2) != 1) { return 4; }
    if (sscanf(buf[5].c_str(), "%d", &this->minimap_color1) != 1) { return 5; }
    if (sscanf(buf[6].c_str(), "%d", &this->minimap_color2) != 1) { return 6; }
    if (sscanf(buf[7].c_str(), "%d", &this->minimap_color3) != 1) { return 7; }
    if (sscanf(buf[8].c_str(), "%d", &this->statistics_text_color) != 1) { return 8; }

    return -1;
}

bool player_color::recurse(const openage::util::CSVCollection & /*storage*/, const std::string & /*basedir*/) {
    return true;
}

} // gamedata
} // openage
