Hi.. Im fixxing source warnings but I found few of them which I cant fix
(Yeah, I know they are just warns but I want them fixxed ) I appreciate any help
char.cpp warn
Code
- char.cpp: In member function 'void CHARACTER::OpenMyShop(const char*, TShopItemTable*, BYTE, DWORD, int)':
- char.cpp:835: warning: comparison is always true due to limited range of data type
- char.cpp: In member function 'void CHARACTER::UpdateShopItems()':
- char.cpp:960: warning: comparison is always false due to limited range of data type
- char.cpp: In member function 'void CHARACTER::OpenShop(DWORD, const char*, bool)':
- char.cpp:1103: warning: comparison is always false due to limited range of data type
- char.cpp: In member function 'bool CHARACTER::ChannelChange(int)':
- char.cpp:8295: warning: 'wPort' may be used uninitialized in this function
- char.cpp:8294: warning: 'lAddr' may be used uninitialized in this function
char.cpp
Code
- if (pkItem->GetWindow() == DRAGON_SOUL_INVENTORY && pkItem->GetCell() >= 0 && pkItem->GetCell() <= 5) //<--- line 835
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("You can't sell DSS stones if it is using"));
- return;
- }
- ---------------------------------------------------------------------------------------------------------------------------------------------
- if (-1 == (shop->pos.cell = GetEmptyInventory(item_table->bSize, extended_count))) //<--- line 960
- {
- sys_err("no empty position in npc inventory");
- return;
- }
- --------------------------------------------------------------------------------------------------------------------------------------------
- if (-1 == (shop->pos.cell = GetEmptyInventory(item_table->bSize, extended_count))) //<--- line 1103
- {
- sys_err("no empty position in npc inventory");
- return;
- }
- -------------------------------------------------------------------------------------------------------------------------------------------
- #ifdef __CHANNEL_CHANGE_SYSTEM__
- bool CHARACTER::ChannelChange(int channel)
- {
- if (!IsPC() || channel == g_bChannel)
- {
- ChatPacket(CHAT_TYPE_INFO, "Znajdujesz si?na wybranym kanale.");
- if (m_pkTimedEvent)
- {
- event_cancel(&m_pkTimedEvent);
- }
- return false;
- }
- long lAddr; //<--- line 8294
- WORD wPort; //<--- line 8295
- long x = GetX();
- long y = GetY();
- long lMapIndex = GetMapIndex();
- if (GetMapIndex() != 41 && GetMapIndex() != 21 && GetMapIndex() != 1 && GetMapIndex() != 43 && GetMapIndex() != 23 && GetMapIndex() != 3 && GetMapIndex() != 61 && GetMapIndex() != 62 && GetMapIndex() != 63 && GetMapIndex() != 64 && GetMapIndex() != 65 && GetMapIndex() != 67 && GetMapIndex() != 68 && GetMapIndex() != 69 && GetMapIndex() != 70 && GetMapIndex() != 104 && GetMapIndex() != 71 && GetMapIndex() != 72 && GetMapIndex() != 73 && GetMapIndex() != 219 && GetMapIndex() != 87 && GetMapIndex() != 88 && GetMapIndex() != 89 && GetMapIndex() != 5 && GetMapIndex() != 25 && GetMapIndex() != 45 && GetMapIndex() != 210 && GetMapIndex() != 218)
- {
- ChatPacket(CHAT_TYPE_INFO, "Nie mo?sz zmieni?kana? z tej mapy.");
- return false;
- }
- char szQuery[512];
- snprintf(szQuery, sizeof(szQuery), "SELECT port, host FROM %smap_list WHERE channel = %d AND map_index = %ld", get_table_postfix(), channel, lMapIndex);
- SQLMsg *msg = DBManager::instance().DirectQuery(szQuery);
- MYSQL_RES *res = msg->Get()->pSQLResult;
- if (!res)
- {
- ChatPacket(1, "Cannot find map %d on channel %d", lMapIndex, channel);
- return false;
- }
- int rows;
- if ((rows = mysql_num_rows(res)) <= 0)
- {
- ChatPacket(1, "Cannot find map %d on channel %d", lMapIndex, channel);
- return false;
- }
- for (int i = 0; i < rows; ++i)
- {
- MYSQL_ROW row = mysql_fetch_row(res);
- int cur = 0;
- str_to_number(wPort, row[cur++]);
- str_to_number(lAddr, row[cur++]);
- }
- if (chChange_port_allow_find(wPort))
- {
- ChatPacket(CHAT_TYPE_INFO, "You can't go to the CH choosed!");
- return false;
- }
- if (g_iUserLimit > 0)
- {
- int iTotal;
- int * paiEmpireUserCount;
- int iLocal;
- DESC_MANAGER::instance().GetUserCount(iTotal, &paiEmpireUserCount, iLocal);
- if (g_iUserLimit <= iTotal)
- {
- ChatPacket(1, "Wybrany kana?%d) jest przepe?iony.", channel);
- return false;
- }
- }
- ChatPacket(CHAT_TYPE_COMMAND, "channel %d", channel);
- Stop();
- Save();
- if (GetSectree())
- {
- GetSectree()->RemoveEntity(this);
- ViewCleanup();
- EncodeRemovePacket(this);
- }
- m_lWarpMapIndex = lMapIndex;
- m_posWarp.x = x;
- m_posWarp.y = y;
- sys_log(0, "WarpSet %s %d %d current map %d target map %d port %d", GetName(), x, y, GetMapIndex(), lMapIndex, wPort);
- TPacketGCWarp p;
- p.bHeader = HEADER_GC_WARP;
- p.lX = x;
- p.lY = y;
- p.lAddr = lAddr;
- p.wPort = wPort;
- GetDesc()->Packet(&p, sizeof(TPacketGCWarp));
- return true;
- }
- #endif
char_item.cpp warn
Code
- char_item.cpp: In member function 'bool CHARACTER::UseItemEx(CItem*, TItemPos)':
- char_item.cpp:6022: warning: comparison between signed and unsigned integer expressions
- char_item.cpp: In member function 'bool CHARACTER::EquipItem(CItem*, int)':
- char_item.cpp:7243: warning: array subscript has type 'char'
char_item.cpp
Code
- case ITEM_BLEND:
- // 새로운 약초들
- #ifdef ENABLE_YMIR_AFFECT_FIX
- if ((CheckTimeUsed(item) == false)) { return false; }
- #endif
- sys_log(0, "ITEM_BLEND!!");
- if (Blend_Item_find(item->GetVnum()))
- {
- int affect_type = AFFECT_BLEND;
- if (item->GetSocket(0) >= _countof(aApplyInfo)) //<--- line 6022
- {
- sys_err("INVALID BLEND ITEM(id : %d, vnum : %d). APPLY TYPE IS %d.", item->GetID(), item->GetVnum(), item->GetSocket(0));
- return false;
- }
- int apply_type = aApplyInfo[item->GetSocket(0)].bPointType;
- int apply_value = item->GetSocket(1);
- int apply_duration = item->GetSocket(2);
- -------------------------------------------------------------------------------------------------------------------------------------------
- if (true == item->IsEquipped())
- {
- if (-1 != item->GetProto()->cLimitRealTimeFirstUseIndex)
- {
- if (0 == item->GetSocket(1))
- {
- long duration = (0 != item->GetSocket(0)) ? item->GetSocket(0) : item->GetProto()->aLimits[item->GetProto()->cLimitRealTimeFirstUseIndex].lValue; //<--- line 7243
- if (0 == duration)
- duration = 60 * 60 * 24 * 7;
- item->SetSocket(0, time(0) + duration);
- item->StartRealTimeExpireEvent();
- }
- item->SetSocket(1, item->GetSocket(1) + 1);
- }
char_skill.cpp warn
char_skill.cpp
Code
- bool CHARACTER::UseSkill(DWORD dwVnum, LPCHARACTER pkVictim, bool bUseGrandMaster)
- {
- #ifdef ENABLE_PVP_ADVANCED
- int getSkill[] = {94, 95, 96, 109, 110, 111};
- for (unsigned int j = 0; j < _countof(getSkill); j++)
- {
- if (pkVictim){
- if (getSkill[j] == dwVnum && pkVictim->IsPC() && pkVictim->GetQuestFlag(BLOCK_BUFF)) //<--- line 2453
- {
- ChatPacket(CHAT_TYPE_INFO, LC_TEXT("duel_block_victim_buff"), pkVictim->GetName());
- pkVictim = this;
- }
- }
- }
- #endif
PetSystem.cpp warn
PetSystem.cpp
Code
cmd_gm.cpp warn
Code
- cmd_gm.cpp:3360:9: warning: multi-character character constant
- cmd_gm.cpp: In function 'void do_gift_refresh(CHARACTER*, const char*, int, int)':
- cmd_gm.cpp:1244: warning: operation on 'col' may be undefined
- cmd_gm.cpp: In function 'void do_shop_refresh_items(CHARACTER*, const char*, int, int)':
- cmd_gm.cpp:1740: warning: operation on 'col' may be undefined
- cmd_gm.cpp: In function 'void do_close_shop(CHARACTER*, const char*, int, int)':
- cmd_gm.cpp:1406: warning: 'channels' may be used uninitialized in this function
cmd_gm.cpp
Code
- case 'acce': //<--- line 3360
- Acce_init();
- break;
- -------------------------------------------------------------------------------------------------------------------------------------------
- if (pRes->uiNumRows>0)
- {
- MYSQL_ROW row;
- while ((row = mysql_fetch_row(pRes->pSQLResult)) != NULL)
- {
- int col = 3;
- char attrs[256];
- char sockets[256];
- strlcpy(attrs, "", 256);
- strlcpy(sockets, "", 256);
- for (int i = 0; i<6; i++)
- sprintf(sockets, "%s%s%s", sockets, row[col++], (i<5 ? "|" : ""));
- //col--;
- for (int i = 0; i<7; i++)
- sprintf(attrs, "%s%s,%s%s", attrs, row[col++], row[col++], (i<6 ? "|" : "")); //<--- 1244
- ch->ChatPacket(CHAT_TYPE_COMMAND, "gift_item %s#%s#%s#%s#%s#%s#%s#%s", row[0], row[1], row[2], row[23], row[24], row[25], sockets, attrs);
- }
- ch->ChatPacket(CHAT_TYPE_COMMAND, "gift_info %d", pRes->uiNumRows);
- }
- -------------------------------------------------------------------------------------------------------------------------------------------
- if (pRes->uiNumRows > 0){
- MYSQL_ROW row;
- while ((row = mysql_fetch_row(pRes->pSQLResult)) != NULL)
- {
- DWORD channels; //<--- 1406
- str_to_number(channels, row[1]);
- if (channels != g_bChannel){
- ch->ChatPacket(CHAT_TYPE_INFO, LC_TEXT("Nie mozesz zamknac sklepu z tego kanalu(Sklep znajduje sie na: %d)."), channels);
- return;
- }
- }
- DeleteShop(id);
- }
entity_view.cpp warn
entity_view.cpp
Code
- void operator () (LPENTITY ent)
- {
- // 오브젝트가 아닌 것은 거리를 계산하여 거리가 멀면 추가하지 않는다.
- if (!ent->IsType(ENTITY_OBJECT))
- if (DISTANCE_APPROX(ent->GetX() - m_me->GetX(), ent->GetY() - m_me->GetY()) > dwViewRange)
- return;
- #ifdef SHOP_DISTANCE
- if (ent->IsType(ENTITY_CHARACTER) && m_me->IsType(ENTITY_CHARACTER))
- {
- LPCHARACTER chMe = (LPCHARACTER)m_me;
- LPCHARACTER chEnt = (LPCHARACTER)ent;
- DWORD ViewRange = quest::CQuestManager::instance().GetEventFlag("shop_dist");
- if (ViewRange>0 && DISTANCE_APPROX(ent->GetX() - m_me->GetX(), ent->GetY() - m_me->GetY()) > ViewRange &&
- chMe->IsPC() && chEnt->IsNPC() && (chEnt->GetRaceNum() == 30000 || chEnt->GetRaceNum() == 30001 || chEnt->GetRaceNum() == 30002 || chEnt->GetRaceNum() == 30003 || chEnt->GetRaceNum() == 30004 || chEnt->GetRaceNum() == 30005 || chEnt->GetRaceNum() == 30006 || chEnt->GetRaceNum() == 30007 || chEnt->GetRaceNum() == 30008)) // shop_type
- return;
- }
- #endif