Rinor 59 Report post Posted February 28, 2022 (edited) Hi, i went through gameserver logs on my test server (playing with CO src/files), i noticed something at util_db.txt file: [02-28 18:42:35]SQL Error State:42S22, Native Error Code: CF, ODBC Error: [Microsoft][ODBC SQL Server Driver][SQL Server]Invalid column name 'con'. [02-28 18:42:35][STMT:0x3238720][SQLERR]: [select cha_id, con from map_mask where id=2790] So i first checked database and the column name was con I tried to add con attribute ingame to check if it updates on database and it did I went through source code to check database if the column was con and it was Still it throws this error while other stuff as agi,sta etc.. are fine. Could anyone give me any clue on this? thanks Edited February 28, 2022 by Rinor Quote Share this post Link to post Share on other sites
V3ct0r 2,117 Report post Posted March 1, 2022 Hello @Rinor, Based on the text of the error, we are talking about the map_mask table, not character. Quote Some useful links / Полезные ссылки Tips for making a topic in 'Questions & Help' / Рекомендации по созданию тем в разделе "Помощь" Server Advertising Section Rules / Правила раздела "Реклама серверов" Available e-mail domains for registration / Допустимые e-mail домены для регистрации User groups / Группы пользователей User ranks / Звания пользователей "Broken" pictures on the forum / "Битые" изображения на форуме Beware of scammers! / Осторожно, мошенники! My developments / Мои разработки Mods for client and server / Моды для клиента и сервера PKOdev.NET website for Tales of Pirates Server / PKOdev.NET веб-обвязка для сервера Пиратии I do not provide any help in private messages and outside the forum. Use 'Questions & Help' section please. Thank you for understanding! Я не оказываю какую-либо помощь в личных сообщениях и вне форума. Пожалуйста, используйте раздел "Пиратия: Помощь". Благодарю за понимание! Share this post Link to post Share on other sites
Rinor 59 Report post Posted March 2, 2022 On 3/1/2022 at 6:17 AM, V3ct0r said: Hello @Rinor, Based on the text of the error, we are talking about the map_mask table, not character. Hi @V3ct0r, map_mask table has only this kind of column'shttps://imgur.com/a/ZGGc6YQ It has same columns on a clean DB aswell, i can't find any con column related inside source code which asks for this column con inside map_mask, do you have any idea of this issue? Quote Share this post Link to post Share on other sites
V3ct0r 2,117 Report post Posted March 2, 2022 @Rinor Look for SQL-query in the GameServer source code: select cha_id, con from map_mask where id=2790 Something like: select cha_id, con from %s where id=%d or select cha_id, con from Probably field con should be content1 ... content5. Quote Some useful links / Полезные ссылки Tips for making a topic in 'Questions & Help' / Рекомендации по созданию тем в разделе "Помощь" Server Advertising Section Rules / Правила раздела "Реклама серверов" Available e-mail domains for registration / Допустимые e-mail домены для регистрации User groups / Группы пользователей User ranks / Звания пользователей "Broken" pictures on the forum / "Битые" изображения на форуме Beware of scammers! / Осторожно, мошенники! My developments / Мои разработки Mods for client and server / Моды для клиента и сервера PKOdev.NET website for Tales of Pirates Server / PKOdev.NET веб-обвязка для сервера Пиратии I do not provide any help in private messages and outside the forum. Use 'Questions & Help' section please. Thank you for understanding! Я не оказываю какую-либо помощь в личных сообщениях и вне форума. Пожалуйста, используйте раздел "Пиратия: Помощь". Благодарю за понимание! Share this post Link to post Share on other sites
Rinor 59 Report post Posted March 2, 2022 28 minutes ago, V3ct0r said: @Rinor Look for SQL-query in the GameServer source code: select cha_id, con from map_mask where id=2790 Something like: select cha_id, con from %s where id=%d or select cha_id, con from Probably field con should be content1 ... content5. It is content1...content5 already by default inside source codes of gameserver _snprintf_s(g_sql, sizeof(g_sql), _TRUNCATE, "select \ id, cha_id, content1, content2, content3, content4, content5 \ from %s \ (nolock) where 1=2", \ _get_table()); Quote Share this post Link to post Share on other sites
mkhzaleh 131 Report post Posted March 2, 2022 (edited) 7 hours ago, V3ct0r said: Probably field con should be content1 ... content5. he seems refactoring / copying _sprintf without reading how it works so buffer limited to < 3 > so mostly his issue inside CTableMapMask::GetColNameByMapName which is char* szColBase = "content"; so as he post i can see he use sprintf like this: _snprintf_s(szColName, sizeof(szColName), _TRUNCATE, "%s%d", szColBase, chIndex); which suppose to be _snprintf_s(szColName, lColNameLen, _TRUNCATE, "%s%d", szColBase, chIndex); still can use (long)strlen(szColBase) but as it above will works just fine! Edited March 2, 2022 by mkhzaleh Quote Share this post Link to post Share on other sites
Rinor 59 Report post Posted March 2, 2022 8 hours ago, Rinor said: _snprintf_s(g_sql, sizeof(g_sql), _TRUNCATE, "select \ id, cha_id, content1, content2, content3, content4, content5 \ from %s \ (nolock) where 1=2", \ _get_table()); So sprintf cant be used like this but as you saying below?: 1 hour ago, mkhzaleh said: which suppose to be _snprintf_s(szColName, lColNameLen, _TRUNCATE, "%s%d", szColBase, chIndex); Quote Share this post Link to post Share on other sites
V3ct0r 2,117 Report post Posted March 3, 2022 19 hours ago, Rinor said: It is content1...content5 already by default inside source codes of gameserver _snprintf_s(g_sql, sizeof(g_sql), _TRUNCATE, "select \ id, cha_id, content1, content2, content3, content4, content5 \ from %s \ (nolock) where 1=2", \ _get_table()); Are you sure that this is the SQL query that is being called by your code? The _snprintf_s() function in the second parameter accepts the size of a buffer specified in the first parameter. The buffer must be larger than the resulting string after formatting, otherwise the string will be truncated to the size of the buffer. Quote Some useful links / Полезные ссылки Tips for making a topic in 'Questions & Help' / Рекомендации по созданию тем в разделе "Помощь" Server Advertising Section Rules / Правила раздела "Реклама серверов" Available e-mail domains for registration / Допустимые e-mail домены для регистрации User groups / Группы пользователей User ranks / Звания пользователей "Broken" pictures on the forum / "Битые" изображения на форуме Beware of scammers! / Осторожно, мошенники! My developments / Мои разработки Mods for client and server / Моды для клиента и сервера PKOdev.NET website for Tales of Pirates Server / PKOdev.NET веб-обвязка для сервера Пиратии I do not provide any help in private messages and outside the forum. Use 'Questions & Help' section please. Thank you for understanding! Я не оказываю какую-либо помощь в личных сообщениях и вне форума. Пожалуйста, используйте раздел "Пиратия: Помощь". Благодарю за понимание! Share this post Link to post Share on other sites
Rinor 59 Report post Posted March 3, 2022 6 hours ago, V3ct0r said: Are you sure that this is the SQL query that is being called by your code? Hm, based on the error that i get it throws error about column “con” inside the map_mask table, while theres no such column, there is just content1…content5 and the only code inside source code about this are the one i sent above, the one that mkhzaleh sent could be the fix maybe? I haven’t tested it yet. You have any other clue? Theres no other map_mask code inside source that is related to content1…content5 expect “content” only which is this one: char* szColBase = "content"; like mkhzaleh sent above. Quote Share this post Link to post Share on other sites
V3ct0r 2,117 Report post Posted March 4, 2022 @Rinor, do you can show the contents of CTableMapMask::GetColNameByMapName and CTableMapMask::ReadData methods? Quote Some useful links / Полезные ссылки Tips for making a topic in 'Questions & Help' / Рекомендации по созданию тем в разделе "Помощь" Server Advertising Section Rules / Правила раздела "Реклама серверов" Available e-mail domains for registration / Допустимые e-mail домены для регистрации User groups / Группы пользователей User ranks / Звания пользователей "Broken" pictures on the forum / "Битые" изображения на форуме Beware of scammers! / Осторожно, мошенники! My developments / Мои разработки Mods for client and server / Моды для клиента и сервера PKOdev.NET website for Tales of Pirates Server / PKOdev.NET веб-обвязка для сервера Пиратии I do not provide any help in private messages and outside the forum. Use 'Questions & Help' section please. Thank you for understanding! Я не оказываю какую-либо помощь в личных сообщениях и вне форума. Пожалуйста, используйте раздел "Пиратия: Помощь". Благодарю за понимание! Share this post Link to post Share on other sites
Rinor 59 Report post Posted March 5, 2022 On 3/4/2022 at 7:15 AM, V3ct0r said: @Rinor, do you can show the contents of CTableMapMask::GetColNameByMapName and CTableMapMask::ReadData methods? bool CTableMapMask::GetColNameByMapName(const char *szMapName, char *szColName, long lColNameLen) { if (!szMapName || !szColName) return false; char *szColBase = "content"; if ((long)strlen(szColBase) + 1 >= lColNameLen) return false; char chIndex = 0; if (!strcmp(szMapName, "garner")) chIndex = 1; else if (!strcmp(szMapName, "magicsea")) chIndex = 2; else if (!strcmp(szMapName, "darkblue")) chIndex = 3; else if (!strcmp(szMapName, "winterland")) // Add by lark.li 20080812 chIndex = 4; //else if (!strcmp(szMapName, "eastgoaf")) // chIndex = 4; //else if (!strcmp(szMapName, "lonetower")) // chIndex = 5; else return false; _snprintf_s(szColName, sizeof(szColName), _TRUNCATE, "%s%d", szColBase, chIndex); return true; } bool CTableMapMask::ReadData(CPlayer *pCPly) { if(!pCPly || !pCPly->IsValid()) { //LG("enter_map", "读地图掩码数据库错误,角色不存在.\n"); LG("enter_map", "Load map hideID database error,character is inexistence.\n"); return false; } if (pCPly->GetMapMaskDBID() == 0) { long lDBID; if (!Create(lDBID, pCPly->GetDBChaId())) return false; pCPly->SetMapMaskDBID(lDBID); } char szMaskColName[30]; if (!GetColNameByMapName(pCPly->GetMaskMapName(), szMaskColName, 30)) { //LG("enter_map", "选择地图掩码数据错误.\n"); LG("enter_map", "choice map hideID data error.\n"); return false; } int nIndex = 0; char param[80]; _snprintf_s(param, sizeof(param), _TRUNCATE, "cha_id, %s", szMaskColName); char filter[80]; _snprintf_s(filter, sizeof(filter), _TRUNCATE, "id=%d", pCPly->GetMapMaskDBID()); int r = _get_row3(g_buf, g_cnCol, param, filter); int r1 = get_affected_rows(); if (DBOK(r) && r1 > 0) { DWORD dwChaId = Str2Int(g_buf[nIndex++]); if (dwChaId != pCPly->GetDBChaId()) { //LG("enter_map", "读地图掩码数据库错误,角色不匹配.\n"); LG("enter_map", "Load map hideID database error,character is not matching.\n"); return false; } pCPly->SetMapMaskBase64(g_buf[nIndex++].c_str()); //if (strcmp(g_buf[nIndex-1].c_str(), "0")) // LG("大地图长度", "地图 %s,长度 %u.\n", pCPly->GetMaskMapName(), strlen(g_buf[nIndex-1].c_str())); } else { //LG("enter_map", "读地图掩码数据库错误,_get_row()返回值:%d.%u\n", r); LG("enter_map", "Load map hideID database error,_get_row() return value:%d.%u\n", r); return false; } //LG("enter_map", "读大地图数据成功.\n"); LG("enter_map", "Load big map data succeed.\n"); return true; } Quote Share this post Link to post Share on other sites
mkhzaleh 131 Report post Posted March 5, 2022 its just as i explained above ,bad refactor , Quote Share this post Link to post Share on other sites
Rinor 59 Report post Posted March 5, 2022 43 minutes ago, mkhzaleh said: its just as i explained above ,bad refactor , Its used like that in top-recode so whats the difference? Still bad refactor? Lol Quote Share this post Link to post Share on other sites
V3ct0r 2,117 Report post Posted March 6, 2022 @Rinor Replace it: _snprintf_s(szColName, sizeof(szColName), _TRUNCATE, "%s%d", szColBase, chIndex); with: _snprintf_s(szColName, lColNameLen, _TRUNCATE, "%s%d", szColBase, chIndex); sizeof(szColName) is wrong. It will give 4 bytes (the size of pointer for char data type), but not the size of outter buffer szColName. As the result you see con (3 symbols + null terminator). 1 Quote Some useful links / Полезные ссылки Tips for making a topic in 'Questions & Help' / Рекомендации по созданию тем в разделе "Помощь" Server Advertising Section Rules / Правила раздела "Реклама серверов" Available e-mail domains for registration / Допустимые e-mail домены для регистрации User groups / Группы пользователей User ranks / Звания пользователей "Broken" pictures on the forum / "Битые" изображения на форуме Beware of scammers! / Осторожно, мошенники! My developments / Мои разработки Mods for client and server / Моды для клиента и сервера PKOdev.NET website for Tales of Pirates Server / PKOdev.NET веб-обвязка для сервера Пиратии I do not provide any help in private messages and outside the forum. Use 'Questions & Help' section please. Thank you for understanding! Я не оказываю какую-либо помощь в личных сообщениях и вне форума. Пожалуйста, используйте раздел "Пиратия: Помощь". Благодарю за понимание! Share this post Link to post Share on other sites