Waring 4804

Hello i have littel problem: I don have big experience for C++. Can some one help me ?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
unsigned short	CBGServerMap::AddCharacter(CCharacter* lpCharacter)
{
	if (NULL == lpCharacter)
	{
		return PktBase::SERVER_ERROR;
	}

	if (m_MapInfo.m_cMaxCharNumOfNation <= m_MapInfo.m_cCurrentCharNum[ lpCharacter->GetRace() ])
	{
		return PktBGServerMoveZone::FAIL_FULL_MAP;
	}
// waring start
	if (m_MapInfo.m_cCurrentCharNum[ lpCharacter->GetRace() ] >= 10)
	{
	waring 	if ( (lpCharacter->GetRace() == CClass::HUMAN && m_MapInfo.m_cCurrentCharNum[CClass::HUMAN] >= m_MapInfo.m_cCurrentCharNum[CClass::AKHAN] >= m_MapInfo.m_cCurrentCharNum[CClass::PIRATE] * 1.5) ||
	waring		(lpCharacter->GetRace() == CClass::PIRATE && m_MapInfo.m_cCurrentCharNum[CClass::PIRATE] >= m_MapInfo.m_cCurrentCharNum[CClass::AKHAN] >= m_MapInfo.m_cCurrentCharNum[CClass::HUMAN]* 1.5) ||
	waring	 (lpCharacter->GetRace() == CClass::AKHAN && m_MapInfo.m_cCurrentCharNum[CClass::AKHAN] >= m_MapInfo.m_cCurrentCharNum[CClass::HUMAN] >= m_MapInfo.m_cCurrentCharNum[CClass::PIRATE]* 1.5) )
		{
			return PktBGServerMoveZone::FAIL_FIX_RATE;
		}
	}
//waring end
	++m_MapInfo.m_cCurrentCharNum[ lpCharacter->GetRace() ];
	m_CharacterList.push_back(lpCharacter);

	// µé¾î¿ÔÀ»¶§ ³²Àº °æ±â½Ã°£À» ÀúÀåÇØµÐ´Ù. (³²Àº °æ±â½Ã°£¿¡ µû¸¥ Â÷µî Á¡¼ö¸¦ ÁÖ±âÀ§Çؼ­...)
	MapInfo::PersonalInfo personalInfo(m_MapInfo.m_cRemainPlayMin);
	m_MapInfo.m_PersonalInfoMap.insert( make_pair(lpCharacter->GetCID(), personalInfo) );

	// ·Î±× ³²±â±â
	char szNation[8];
	if (lpCharacter->GetRace() == CClass::HUMAN) 
	{
		strcpy(szNation, "HUMAN");

		strcpy(szNation, "AKHAN");
	}
	else 
	{
		strcpy(szNation, "PIRATE");
	}

	DETLOG5(g_Log, "Battle Server Log :: (Channel : %d, %s) - CID : 0x%08x ij¸¯ÅÍ(%s, %s)°¡ Player ·Î µé¾î¿Ô½À´Ï´Ù.", 
		(m_wMapIndex & ~VirtualArea::BGSERVERMAP), GetMapTypeName(), 
		lpCharacter->GetCID(), lpCharacter->GetCharacterName(), szNation);

	return PktBase::NO_SERVER_ERR;
}


I get waring and for that i not sure that code work or no:
warning C4804: '>=' : unsafe use of type 'bool' in operation
Best regards
Peter

I hope now is better ty for say that code stuff :)
Last edited on
Um... we don't know what line that's on, so we can't help you much.

Yes, as long as you don't get any errors your code will compile fine, and it may run fine depending on whether or not the programmer knew what he/she was doing.


Honestly, I didn't even look at the code. :|

-Albatross
Last edited on
Please use code tags next time. It makes it much easier to read your code.

The problem is that when you write something like a >= b >= c
that is the same as (a >= b) >= c.

a >= b evaluates to boolean value (true or false), so you are actually comparing c with a boolean value which doesn't make much sense. It will compile though because false is treated as 0 and true as 1.

The way to write it is a >= b && b >= c.
Last edited on
Topic archived. No new replies allowed.