• 【C++】指针引发的bug


    如果你要从配置里面取一个属性,需要修改这个属性,注意不要把配置的属性修改掉了。取的是配置的指针属性,需要弄个临时属性来修改计算。

    	int nLuckValue = WingsAngelCfg.m_Config.nWing[nLevel].nLuck;
    	double percentage = (double)nLuckPoint/nLuckValue;
    	nCount = WingsAngelCfg.m_Config.nWing[nLevel].nCount;
    	if(nCount == 0)
    		return calc;
    	GAMEATTR* tmpValueProp = WingsAngelCfg.m_Config.nWing[nLevel].PropList;
    	if(tmpValueProp == NULL)
    		return calc;
    	for (int i = 0; i < nCount; i++)
    	{
    		//if(tmpValueProp[i].reserve[0] == 0)
    		{
    			GAMEATTR Prop;
    			INT_PTR nValue = tmpValueProp[i].value.nValue * percentage;
    			if(nValue <1)
    			{
    				nValue = 1;
    			}
    			Prop.type = tmpValueProp->type;
    			Prop.value.nValue = nValue;	
    			calc << Prop;
    		}
    	}


     

  • 相关阅读:
    4.23上机练习
    4.17java作业
    4.16java作业
    leetcode 189
    leetcode 172
    leetcode 171
    leetcode 169
    win10内网外网智能访问
    leetcode 168
    leetcode 165
  • 原文地址:https://www.cnblogs.com/byfei/p/14104259.html
Copyright © 2020-2023  润新知