-
Автор темы
- #1
Крашит сурс гидеона когда загружаешь кфг на карте
Как пофиксить ???
Дебагером кидает на load
char b_buffer[65536], i_buffer[65536], f_buffer[65536], c_buffer[65536], m_buffer[65536] = { 0 };
int b_read = GetPrivateProfileSectionA("b", b_buffer, 65536, file_path);
int i_read = GetPrivateProfileSectionA("i", i_buffer, 65536, file_path);
int f_read = GetPrivateProfileSectionA("f", f_buffer, 65536, file_path);
int c_read = GetPrivateProfileSectionA("c", c_buffer, 65536, file_path);
int m_read = GetPrivateProfileSectionA("m", m_buffer, 65536, file_path);
if ((0 < b_read) && ((65536 - 2) > b_read)) {
const char* pSubstr = b_buffer;
while ('\0' != *pSubstr) {
size_t substrLen = strlen(pSubstr);
const char* pos = strchr(pSubstr, '=');
if (NULL != pos) {
char name[256] = "";
char value[256] = "";
strncpy_s(name, _countof(name), pSubstr, pos - pSubstr);
strncpy_s(value, _countof(value), pos + 1, substrLen - (pos - pSubstr));
b[name] = atoi(value);
}
pSubstr += (substrLen + 1);
}
}
if ((0 < i_read) && ((65536 - 2) > i_read)) {
const char* pSubstr = i_buffer;
while ('\0' != *pSubstr) {
size_t substrLen = strlen(pSubstr);
const char* pos = strchr(pSubstr, '=');
if (NULL != pos) {
char name[256] = "";
char value[256] = "";
strncpy_s(name, _countof(name), pSubstr, pos - pSubstr);
strncpy_s(value, _countof(value), pos + 1, substrLen - (pos - pSubstr));
i[name] = atoi(value);
}
pSubstr += (substrLen + 1);
}
}
if ((0 < f_read) && ((65536 - 2) > f_read)) {
const char* pSubstr = f_buffer;
while ('\0' != *pSubstr) {
size_t substrLen = strlen(pSubstr);
const char* pos = strchr(pSubstr, '=');
if (NULL != pos) {
char name[256] = "";
char value[256] = "";
strncpy_s(name, _countof(name), pSubstr, pos - pSubstr);
strncpy_s(value, _countof(value), pos + 1, substrLen - (pos - pSubstr));
f[name] = atof(value);
}
pSubstr += (substrLen + 1);
}
}
if ((0 < c_read) && ((65536 - 2) > c_read)) {
const char* pSubstr = c_buffer;
while ('\0' != *pSubstr) {
size_t substrLen = strlen(pSubstr);
const char* pos = strchr(pSubstr, '=');
if (NULL != pos) {
char name[256] = "";
char value[256] = "";
strncpy_s(name, _countof(name), pSubstr, pos - pSubstr);
strncpy_s(value, _countof(value), pos + 1, substrLen - (pos - pSubstr));
auto col = string_to_color(value);
c[name][0] = col[0];
c[name][1] = col[1];
c[name][2] = col[2];
c[name][3] = col[3];
}
pSubstr += (substrLen + 1);
}
}
static auto split = [](std::string str, const char* del) -> std::vector<std::string>
{
char* pTempStr = _strdup(str.c_str());
char* pWord = strtok(pTempStr, del);
std::vector<std::string> dest;
while (pWord != NULL)
{
dest.push_back(pWord);
pWord = strtok(NULL, del);
}
free(pTempStr);
return dest;
};
if ((0 < m_read) && ((65536 - 2) > m_read)) {
const char* pSubstr = m_buffer;
while ('\0' != *pSubstr) {
size_t substrLen = strlen(pSubstr);
const char* pos = strchr(pSubstr, '=');
if (NULL != pos) {
char name[256] = "";
char value[256] = "";
strncpy_s(name, _countof(name), pSubstr, pos - pSubstr);
strncpy_s(value, _countof(value), pos + 1, substrLen - (pos - pSubstr));
std::vector<std::string> kvpa = split(value, "|");
std::unordered_map<int, bool> vl = {};
for (auto kvp : kvpa) {
if (kvp == "")
continue;
std::vector<std::string> kv = split(kvp, ":");
vl[std::stoi(kv.at(0))] = std::stoi(kv.at(1));
}
m[name] = vl;
}
pSubstr += (substrLen + 1);
}
}
this->load_keys();
Как пофиксить ???
Дебагером кидает на load
char b_buffer[65536], i_buffer[65536], f_buffer[65536], c_buffer[65536], m_buffer[65536] = { 0 };
int b_read = GetPrivateProfileSectionA("b", b_buffer, 65536, file_path);
int i_read = GetPrivateProfileSectionA("i", i_buffer, 65536, file_path);
int f_read = GetPrivateProfileSectionA("f", f_buffer, 65536, file_path);
int c_read = GetPrivateProfileSectionA("c", c_buffer, 65536, file_path);
int m_read = GetPrivateProfileSectionA("m", m_buffer, 65536, file_path);
if ((0 < b_read) && ((65536 - 2) > b_read)) {
const char* pSubstr = b_buffer;
while ('\0' != *pSubstr) {
size_t substrLen = strlen(pSubstr);
const char* pos = strchr(pSubstr, '=');
if (NULL != pos) {
char name[256] = "";
char value[256] = "";
strncpy_s(name, _countof(name), pSubstr, pos - pSubstr);
strncpy_s(value, _countof(value), pos + 1, substrLen - (pos - pSubstr));
b[name] = atoi(value);
}
pSubstr += (substrLen + 1);
}
}
if ((0 < i_read) && ((65536 - 2) > i_read)) {
const char* pSubstr = i_buffer;
while ('\0' != *pSubstr) {
size_t substrLen = strlen(pSubstr);
const char* pos = strchr(pSubstr, '=');
if (NULL != pos) {
char name[256] = "";
char value[256] = "";
strncpy_s(name, _countof(name), pSubstr, pos - pSubstr);
strncpy_s(value, _countof(value), pos + 1, substrLen - (pos - pSubstr));
i[name] = atoi(value);
}
pSubstr += (substrLen + 1);
}
}
if ((0 < f_read) && ((65536 - 2) > f_read)) {
const char* pSubstr = f_buffer;
while ('\0' != *pSubstr) {
size_t substrLen = strlen(pSubstr);
const char* pos = strchr(pSubstr, '=');
if (NULL != pos) {
char name[256] = "";
char value[256] = "";
strncpy_s(name, _countof(name), pSubstr, pos - pSubstr);
strncpy_s(value, _countof(value), pos + 1, substrLen - (pos - pSubstr));
f[name] = atof(value);
}
pSubstr += (substrLen + 1);
}
}
if ((0 < c_read) && ((65536 - 2) > c_read)) {
const char* pSubstr = c_buffer;
while ('\0' != *pSubstr) {
size_t substrLen = strlen(pSubstr);
const char* pos = strchr(pSubstr, '=');
if (NULL != pos) {
char name[256] = "";
char value[256] = "";
strncpy_s(name, _countof(name), pSubstr, pos - pSubstr);
strncpy_s(value, _countof(value), pos + 1, substrLen - (pos - pSubstr));
auto col = string_to_color(value);
c[name][0] = col[0];
c[name][1] = col[1];
c[name][2] = col[2];
c[name][3] = col[3];
}
pSubstr += (substrLen + 1);
}
}
static auto split = [](std::string str, const char* del) -> std::vector<std::string>
{
char* pTempStr = _strdup(str.c_str());
char* pWord = strtok(pTempStr, del);
std::vector<std::string> dest;
while (pWord != NULL)
{
dest.push_back(pWord);
pWord = strtok(NULL, del);
}
free(pTempStr);
return dest;
};
if ((0 < m_read) && ((65536 - 2) > m_read)) {
const char* pSubstr = m_buffer;
while ('\0' != *pSubstr) {
size_t substrLen = strlen(pSubstr);
const char* pos = strchr(pSubstr, '=');
if (NULL != pos) {
char name[256] = "";
char value[256] = "";
strncpy_s(name, _countof(name), pSubstr, pos - pSubstr);
strncpy_s(value, _countof(value), pos + 1, substrLen - (pos - pSubstr));
std::vector<std::string> kvpa = split(value, "|");
std::unordered_map<int, bool> vl = {};
for (auto kvp : kvpa) {
if (kvp == "")
continue;
std::vector<std::string> kv = split(kvp, ":");
vl[std::stoi(kv.at(0))] = std::stoi(kv.at(1));
}
m[name] = vl;
}
pSubstr += (substrLen + 1);
}
}
this->load_keys();