当前位置: 首页>>代码示例>>C++>>正文


C++ NetworkMessage::AddU8方法代码示例

本文整理汇总了C++中NetworkMessage::AddU8方法的典型用法代码示例。如果您正苦于以下问题:C++ NetworkMessage::AddU8方法的具体用法?C++ NetworkMessage::AddU8怎么用?C++ NetworkMessage::AddU8使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在NetworkMessage的用法示例。


在下文中一共展示了NetworkMessage::AddU8方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ONThreadSafe

bool Protocol79::CharlistLogin(const char *username, const char *password) {
    NetworkMessage nm;

    ONThreadSafe(threadsafe);

    connectiontype = CHARLIST;

    nm.AddU8(0x01); // protocol id
    nm.AddU16(0x02); // client OS
    nm.AddU16(protocolversion);

    nm.AddU32(fingerprints[FINGERPRINT_TIBIADAT]); // tibia.dat
    nm.AddU32(fingerprints[FINGERPRINT_TIBIASPR]); // tibia.spr
    nm.AddU32(fingerprints[FINGERPRINT_TIBIAPIC]); // tibia.pic

    nm.RSABegin();


    // encryption keys
    for (int i = 0 ; i < 4 ; i++) {
        nm.AddU32(key[i]);
    }

    // account number and password
    nm.AddU32(atol((this->username = username).c_str()));
    nm.AddString(this->password = password);


    nm.RSAEncrypt();


    if (!nm.Dump(s)) {
        this->errormsg = "Could not write to socket.\nPossible it's a premature disconnect.\n\nCheck you typed in the correct protocol!";
        ONThreadUnsafe(threadsafe);
        return false;
    }

    nm.Clean();
    if (!nm.FillFromSocket(s)) {
        this->errormsg = "Could not read from socket.\nPossibly it's a premature disconnect.\n\nCheck you typed in the correct protocol!";
        ONThreadUnsafe(threadsafe);
        return false;
    }
	printf("Okies, lets decrypt\n");
//    this->Close();

    nm.XTEADecrypt(key);
	printf("Ok, decoded\n");
    logonsuccessful = true;
    while ((signed int)(nm.GetSize())>0 && ParsePacket(&nm));
    if ((signed int)(nm.GetSize())>0) printf("++++++++++++++++++++DIDNT EMPTY UP THE NETWORKMESSAGE!++++++++++++++++++\n");

    ONThreadUnsafe(threadsafe);
    return logonsuccessful;
}
开发者ID:ivucica,项目名称:theoutcast,代码行数:55,代码来源:protocol79.cpp

示例2: while

bool Protocol77::GameworldLogin () {
    // this is valid for 7.7!
    // 7.72 has a bit different order of stuff! check out old outcast's sources
    NetworkMessage nm;

    connectiontype = GAMEWORLD;

    nm.AddU8(0x0A); // protocol id


    nm.RSABegin();

    // encryption keys
    for (int i = 0 ; i < 4 ; i++) {
        nm.AddU32(key[i]);
    }


    // in 7.72 onwards move this BEFORE the keys and BEFORE the encryption
    nm.AddU16(0x02); // client OS
    nm.AddU16(protocolversion);


    // are we a gamemaster
    nm.AddChar(0);

    // account number and password
    nm.AddU32(atol(this->username.c_str())); // this does NOT exist before 7.4
    nm.AddString(this->charlist[this->charlistselected]->charactername);
    nm.AddString(this->password);



    nm.RSAEncrypt();

    // FIXME inside dump, we should check whether or not socket is still open
    // or after dump, at least
    nm.Dump(s);

    nm.Clean();
    nm.FillFromSocket(s );

    nm.XTEADecrypt(key);

    logonsuccessful = true;
    while ((signed int)(nm.GetSize())>0 && ParsePacket(&nm));
    if ((signed int)(nm.GetSize())!=0) printf("++++++++++++++++++++DIDNT EMPTY UP THE NETWORKMESSAGE!++++++++++++++++++\n");

    if (logonsuccessful) active = true;

    return logonsuccessful;
}
开发者ID:ivucica,项目名称:theoutcast,代码行数:52,代码来源:protocol77.cpp

示例3: ONThreadSafe

bool ProtocolME0::GameworldLogin () {
    NetworkMessage nm;

    ONThreadSafe(threadsafe);
    connectiontype = GAMEWORLD;

    //nm.AddU8(0x14);
    //nm.AddString(this->charlist[this->charlistselected]->charactername);
    //spcount ++;
    if (!strcmp(this->charlist[this->charlistselected]->charactername, "Character Manager")) {
        nm.AddU8(0x0C); // charmgr...
        nm.AddU8(0x01); // ...enter

        FILE *f = fopen((std::string("save/") + this->username + ".ous").c_str(), "r");
        ASSERTFRIENDLY(f, "It appears that savefile has mysteriously disappeared. Exiting");
        fclose(f);

    }
    else {
        nm.AddU8(0x0A); // player's creature id shall be 1
        nm.AddU32(1);

        nm.AddU8(0x32); // report bugs?
        nm.AddU8(0);
        nm.AddU8(0);

        nm.AddU8(0x64); // player teleport
        nm.AddU16(30);
        nm.AddU16(30);
        nm.AddU8(7);
        int tilesremaining = 18*14*7;
        for (int i = 0; i < 18; i ++)
            for (int j = 0; j < 14; j++) {
                printf("%d\n", tilesremaining);
                nm.AddU16(102);
                if (i == 8 && j == 6) {
                    nm.AddU16(0x0061);
                    nm.AddU32(0); // remove with this id
                    nm.AddU32(1); // creatureid -- player is 1
                    nm.AddString("Newbie");
                    nm.AddU8(25); // health
                    nm.AddU8(0); //dir
                    nm.AddU16(128); // lookid
                    nm.AddU8(50);
                    nm.AddU8(60);
                    nm.AddU8(70);
                    nm.AddU8(80);
                    nm.AddU8(0); // addons

                    nm.AddU8(0); // lightlevel
                    nm.AddU8(0); // lightcolor
                    nm.AddU16(500); // speed
                    nm.AddU8(0); // skull
                    nm.AddU8(0); // shield




                }
                tilesremaining--;
                nm.AddU16(0xFF00);
            }
        while(tilesremaining) {

            nm.AddU8(tilesremaining > 255 ? 255 : tilesremaining);
            tilesremaining -= tilesremaining > 255 ? 255 : tilesremaining;
            printf("%d\n", tilesremaining);
            nm.AddU8(0xFF);
        }
    }


    ((GM_MainMenu*)game)->DestroyCharlist();





    // by default logon is a success
    logonsuccessful = true;

    packetparsing:
    while ((signed int)(nm.GetSize())>0 && ParsePacket(&nm));
    if ((signed int)(nm.GetSize())>0) printf("++++++++++++++++++++DIDNT EMPTY UP THE NETWORKMESSAGE!++++++++++++++++++\n");

    ONThreadUnsafe(threadsafe);
    return logonsuccessful;

}
开发者ID:ivucica,项目名称:theoutcast,代码行数:89,代码来源:protocolme0.cpp

示例4: SetProtocolStatus

bool Protocol79::GameworldLogin () {
    // this is valid for 7.9!
    // 7.7 has a bit different order of stuff! check out old outcast's sources
    NetworkMessage nm;

    SetProtocolStatus("Preparing to transfer logon data...");
    connectiontype = GAMEWORLD;

    nm.AddU8(0x0A); // protocol id

    // in 7.72 onwards move this BEFORE the keys and BEFORE the encryption
    nm.AddU16(0x02); // client OS
    nm.AddU16(protocolversion);

    SetProtocolStatus("RSA encryption...");
    nm.RSABegin();

    //key[3] = 92;
    // encryption keys
    for (int i = 0 ; i < 4 ; i++) {
        nm.AddU32(key[i]);
        //printf("KEY %d - %d\n", i, key[i]);
    }


    // are we a gamemaster
    nm.AddChar(0);

    // account number and password
    nm.AddU32(atol(this->username.c_str())); // this does NOT exist before 7.4
    nm.AddString(this->charlist[this->charlistselected]->charactername);
    nm.AddString(this->password);



    nm.RSAEncrypt();

    SetProtocolStatus("Transmitting logon data...");

    if (!nm.Dump(s)) {
        this->errormsg = "Could not write to socket.\nPossible it's a premature disconnect.\n\nCheck you typed in the correct protocol!";
        return false;
    }


//    SetStance(DEFENSIVE, STAND);

    SetProtocolStatus("Waiting for response...");
    //nm.Clean();
    NetworkMessage nm2;
    //nm.FillFromSocket(s);
    if (!nm2.FillFromSocket(s )) {
        this->errormsg = "Could not read from socket.\nPossibly it's a premature disconnect.\n\nCheck you typed in the correct protocol!";
        return false;
    }
    nm2.XTEADecrypt(key);
    logonsuccessful = true;
    while ((signed int)(nm2.GetSize())>0 && ParsePacket(&nm2));
    if ((signed int)(nm2.GetSize())!=0) printf("++++++++++++++++++++DIDNT EMPTY UP THE NETWORKMESSAGE!++++++++++++++++++\n");

    if (logonsuccessful) active = true;

    return logonsuccessful;
}
开发者ID:ivucica,项目名称:theoutcast,代码行数:64,代码来源:protocol79.cpp


注:本文中的NetworkMessage::AddU8方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。