C ++ STRUCT不存储值

时间:2012-11-19 11:45:06

标签: c++ visual-c++

我有问题,我做了基本结构

struct TRADEBOT_ITEM
{
    BYTE Slot;
    BYTE Cat;
    BYTE Id;
    BYTE LVL;
};
struct TRADEBOT_BUFFS
{
    short BUFFID;
    short Duration;
};

struct TRADEBOT_INVENTORY
{
    short itemId;
    BYTE level;
    BYTE opt;
    BYTE opt2;
    BYTE opt3;
    BYTE NewOption;
    BYTE Socket[5];
    int Expiration;

};
struct TRADEBOT_REQ
{
    short itemId;
    BYTE level;
    BYTE opt;
    BYTE opt2;
    BYTE opt3;
    BYTE NewOption;
    BYTE Socket[5];
};
struct TRADEBOT_MIX
{
    TRADEBOT_INVENTORY m_Inventory[64];
    TRADEBOT_REQ    m_Req[64];
    int ReqCnt;
};
struct TRADEBOT_DATA
{
    BYTE ID;
    BYTE Class;
    BYTE SPAWN;
    BYTE map;
    BYTE X;
    BYTE Y;
    BYTE Dir;
    BYTE Vip;
    WORD Strength;
    WORD Dexterity;
    WORD Vitality;
    WORD Energy;
    WORD Leadership;
    int ZEN;
    char Name[10];
    TRADEBOT_ITEM m_Item[9];
    TRADEBOT_BUFFS m_Buffs[5];
    TRADEBOT_MIX m_Mix[142];
};

后来用作

std::map<int, TRADEBOT_DATA> m_BotData;

然后我尝试从文件中读取信息并在结构中保存fil的信息

            this->m_BotData[ID].m_Mix[ID].m_Req[cntr].itemId = ITEMGET(cat,idx);


            Token = GetToken();
            this->m_BotData[ID].m_Mix[ID].m_Req[cntr].level = TokenNumber;

            Token = GetToken();
            this->m_BotData[ID].m_Mix[ID].m_Req[cntr].opt = TokenNumber;

            Token = GetToken();
            this->m_BotData[ID].m_Mix[ID].m_Req[cntr].opt2 = TokenNumber;

            Token = GetToken();
            this->m_BotData[ID].m_Mix[ID].m_Req[cntr].opt3 = TokenNumber;

            Token = GetToken();
            this->m_BotData[ID].m_Mix[ID].m_Req[cntr].NewOption = TokenNumber;

            Token = GetToken();
            this->m_BotData[ID].m_Mix[ID].m_Req[cntr].Socket[0] = TokenNumber;

            Token = GetToken();
            this->m_BotData[ID].m_Mix[ID].m_Req[cntr].Socket[1] = TokenNumber;

            Token = GetToken();
            this->m_BotData[ID].m_Mix[ID].m_Req[cntr].Socket[2] = TokenNumber;

            Token = GetToken();
            this->m_BotData[ID].m_Mix[ID].m_Req[cntr].Socket[3] = TokenNumber;

            Token = GetToken();
            this->m_BotData[ID].m_Mix[ID].m_Req[cntr].Socket[4] = TokenNumber;

            this->m_BotData[ID].m_Mix[ID].ReqCnt++;
            cntr++;

并且结构保持空白,没有信息写入它。我不明白为什么。

如果我将值TRADEBOT_MIX m_Mix[142];更改为TRADEBOT_MIX m_Mix[143];应用程序崩溃,也不知道原因。任何想法都将不胜感激。

我正在使用Visual Studio 2010

0 个答案:

没有答案