• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ BEGINPACKET函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中BEGINPACKET函数的典型用法代码示例。如果您正苦于以下问题:C++ BEGINPACKET函数的具体用法?C++ BEGINPACKET怎么用?C++ BEGINPACKET使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: GetClanByID

// Send Clan information
bool CCharServer::SendClanInfo (CCharClient* thisclient)
{
    if( thisclient->clanid > 0 )
    {
        CClans *thisclan = GetClanByID(thisclient->clanid);
        if(thisclan!=NULL)
        {
            BEGINPACKET( pak, 0x7e0);
            ADDBYTE    ( pak, 0x33);//0x33 you have invited to clan
            ADDWORD    ( pak, thisclan->id);// clan id
            ADDBYTE    ( pak, 0x00);//
            ADDBYTE    ( pak, 0x00);
            ADDWORD    ( pak, thisclan->back);//Clan Background
            ADDWORD    ( pak, thisclan->logo);//Clan logo
            ADDBYTE    ( pak, thisclan->grade);//Clan grade
            ADDBYTE    ( pak, thisclient->clan_rank);// Clan rank (0 = red rokie / 6 = master)
            ADDDWORD    ( pak, thisclan->cp);//Clan Points
            ADDDWORD   ( pak, 0x00000064);
            ADDDWORD   ( pak, 0x00000000); //Clan found
            ADDDWORD   ( pak, 0x00000000);
            ADDBYTE    ( pak, 0x01);
            for(int i=34;i<156;i++)
                ADDBYTE ( pak, 0x00);
            ADDWORD    ( pak, 0x0000);
            ADDBYTE    ( pak, 0x00);
            ADDSTRING  ( pak, thisclan->name);//Clan Name            
            ADDBYTE    ( pak, 0x00);            
            ADDSTRING  ( pak, thisclan->slogan);//Clan slogan
            ADDBYTE    ( pak, 0x00);
            ADDSTRING  ( pak, thisclan->news);//Clan news
            ADDBYTE    ( pak, 0x00);
            thisclient->SendPacket(&pak);	
            
            //Put the player online in clan
            for(UINT i=0;i<thisclan->ClanMembers.size();i++)
        	{		
                CClanMembers*	ClanMember = thisclan->ClanMembers.at( i );;
                CCharClient* otherclient = GetClientByID( ClanMember->id );
                if(otherclient!=NULL)
                    ChangeClanStatus (thisclient, otherclient, thisclient->channel);//send channel here
        	}                      
        }
    }     
    return true;
}
开发者ID:L3nn0x,项目名称:osirosenew,代码行数:46,代码来源:clan.cpp


示例2: BEGINPACKET

bool CMap::DeleteDrop( CDrop* drop )
{
    BEGINPACKET( pak, 0x794 );
	ADDWORD    ( pak, drop->clientid );
	GServer->SendToVisible( &pak, drop );
    GServer->ClearClientID( drop->clientid );
    for(UINT j=0;j<DropsList.size();j++)
    {
        if(drop==DropsList.at(j))
        {
            DropsList.erase( DropsList.begin()+j );
            delete drop;
            return true;
        }
    }
    delete drop;
    return false;
}
开发者ID:karlseven,项目名称:ROED,代码行数:18,代码来源:worldmap.cpp


示例3: BEGINPACKET

// Send Server encryption
bool CLoginServer::pakEncryptionRequest( CLoginClient* thisclient, CPacket* P )
{
	BEGINPACKET( pak, 0x7ff );
	ADDWORD    ( pak, 0xaf02 );
	ADDWORD    ( pak, 0xbd46 );
	ADDWORD    ( pak, 0x0009 );
	ADDWORD    ( pak, 0x0012 );
	ADDBYTE    ( pak, 0x0000 );
	ADDDWORD   ( pak, 0xcdcdcdcd );
	ADDDWORD   ( pak, 0xcdcdcdcd );
	ADDDWORD   ( pak, 0xcdcdcdcd );
	ADDDWORD   ( pak, 0xcdcdcdcd );
	ADDWORD    ( pak, 0xcdcd );
	ADDBYTE    ( pak, 0xd3 );
	thisclient->SendPacket( &pak );
	Log(MSG_DEBUG, "Sent a 0x7ff packet to client");
    return true;
}
开发者ID:boermansjo,项目名称:KTRose_Server,代码行数:19,代码来源:loginpackets.cpp


示例4: BEGINPACKET

// Change player status in clan ((channel) = online/ 0xff = offline)
bool CCharServer::ChangeClanStatus (CCharClient* thisclient, CCharClient* otherclient, int channel)
{
     if (thisclient->charid !=otherclient->charid)
     {
        BEGINPACKET( pak, 0x7e0 );
        ADDBYTE    ( pak, 0x73 );//Change player status
        ADDBYTE    ( pak, 0x00 );
        ADDBYTE    ( pak, channel );//CANAL
        ADDWORD    ( pak, 0x0000 );
        ADDWORD    ( pak, 0x0000 );
        ADDWORD    ( pak, thisclient->level );
        ADDWORD    ( pak, thisclient->job );
        ADDSTRING  ( pak, thisclient->charname );
        ADDBYTE    ( pak, 0x00 );
        otherclient->SendPacket(&pak);
     }
     return true;
}
开发者ID:L3nn0x,项目名称:osirosenew,代码行数:19,代码来源:clan.cpp


示例5: BEGINPACKET

// do buff skill
bool CCharacter::BuffSkill( CCharacter* Target, CSkills* skill )
{
    Position->destiny = Position->current;
    //if(Battle->castTime == 0)
    //{
        BEGINPACKET( pak, 0x7bb );
        ADDWORD    ( pak, clientid );
        GServer->SendToVisible( &pak, (CCharacter*)this );
    //    Battle->castTime = clock();
    //    return true;
    //}
    //else
    //{
    //    clock_t etime = clock() - Battle->castTime;
    //    if(etime < SKILL_DELAY)
    //        return true;
    //}
    //Battle->castTime = 0;
    //Log(MSG_DEBUG,"applied buff skill %i",skill->id);
    UseBuffSkill( Target, skill );
    Stats->MP -= (skill->mp - (skill->mp * Stats->MPReduction / 100));
    if(Stats->MP < 0) Stats->MP = 0;
    GServer->DoSkillScript( this, skill ); //summons a monster. Why do we do this for all skills?
    if(!IsMonster())
    {
        ClearBattle( Battle ); // clear battle for players when they use buff skills
        //Battle->bufftarget = 0;
        //Battle->skilltarget = 0;
        //Battle->skillid = 0;
        //Battle->atktype = NORMAL_ATTACK;
    }
    else //Monsters need to be reset to normal attack and clear skill attacks.
    {
        //Battle->atktarget = Battle->target;
        //Battle->bufftarget = 0;
        //Battle->skilltarget = 0;
        //Battle->skillid = 0;
        //Battle->atktype = NORMAL_ATTACK;
        //StartAction(Target, NORMAL_ATTACK);
    }
    Battle->lastAtkTime = clock( );
    Battle->iscasting = 1;
    return true;
}
开发者ID:osROSE,项目名称:osprose,代码行数:45,代码来源:battle.cpp


示例6: GETDWORD

// Do player identification
bool CCharServer::pakDoIdentify( CCharClient* thisclient, CPacket* P )
{
	if (thisclient->isLoggedIn) return false;	
	MYSQL_RES *result;
	MYSQL_ROW row;
	thisclient->userid = GETDWORD((*P), 0x00);
	memcpy( thisclient->password, &P->Buffer[4], 32 );
	result = DB->QStore("SELECT username,lastsvr,accesslevel,platinum FROM accounts WHERE id=%i AND password='%s'", thisclient->userid, thisclient->password);
	if(result==NULL) return false;
	if (mysql_num_rows( result ) != 1) 
    {
		Log( MSG_HACK, "Someone tried to connect to char server with an invalid account" );
		DB->QFree( );
		return false;
	}
    else
    {
		row = mysql_fetch_row(result);
		strncpy(thisclient->username, row[0],16);
		thisclient->channel = atoi(row[1]);
		thisclient->accesslevel = atoi(row[2]);
		thisclient->platinum = atoi(row[3]);
		DB->QFree( );
	}

	Log( MSG_INFO,"User '%s'(#%i) logged in", thisclient->username, thisclient->userid );

	BEGINPACKET( pak, 0x070c );
	ADDBYTE    ( pak, 0 );
	ADDDWORD   ( pak, 0x87654321);
	ADDDWORD   ( pak, 0x00000000 );
	thisclient->SendPacket( &pak );
	result = DB->QStore( "SELECT online FROM accounts WHERE username='%s'", thisclient->username );
    if(result==NULL) return false;	
    row = mysql_fetch_row(result);
    bool online = atoi(row[0]);
    DB->QFree( );    
    if(online)
        return false;
    if(!DB->QExecute( "UPDATE accounts SET online=1 WHERE username='%s'", thisclient->username ))
        return false;
	thisclient->isLoggedIn = true;
    return true;
}
开发者ID:osROSE,项目名称:osrose,代码行数:45,代码来源:charpackets.cpp


示例7: AddMonster

// convert a npc to other [not working]
CMonster* CMap::ConverToMonster( CNPC* npc, UINT newmontype )
{
    CMonster* monster = AddMonster( newmontype, npc->pos, 0, NULL, NULL, 0, true );
    if(monster==NULL) // invalid montype
        return NULL;
    GServer->ClearClientID( monster->clientid );
    monster->clientid = npc->clientid;
    for(UINT i=0;i<NPCList.size();i++)
    {
        if(NPCList.at(i)==npc)
            NPCList.erase( NPCList.begin()+i );
    }
    delete npc;
    BEGINPACKET( pak, 0x774 );
    ADDWORD    ( pak, npc->clientid );
    ADDWORD    ( pak, newmontype );
    GServer->SendToVisible( &pak, monster );
    return monster;
}
开发者ID:karlseven,项目名称:ROED,代码行数:20,代码来源:mapfunctions.cpp


示例8: ClearBattle

// Move a mob (random place)
void CMonster::Move( )
{
    Position->destiny  = GServer->RandInCircle( Position->source, 10 );
//    Position->lastMoveTime = clock();
    ClearBattle( Battle );
    BEGINPACKET( pak, 0x797 );
	ADDWORD    ( pak, clientid );
	ADDWORD    ( pak, 0x0000 );//???
	ADDWORD    ( pak, Stats->Move_Speed ); //speed
	ADDFLOAT   ( pak, Position->destiny.x*100 );
	ADDFLOAT   ( pak, Position->destiny.y*100 );
	ADDWORD    ( pak, 0xcdcd );
	//ADDBYTE    ( pak, 0x01 );
	ADDBYTE	   ( pak, thisnpc->stance );    //AIP
	GServer->SendToVisible(&pak, this);

    if(Position->Map==8)
        Log(MSG_INFO,"Move (%.2f;%.2f) to (%.2f;%.2f)",Position->current.x,Position->current.y,Position->destiny.x,Position->destiny.y);
}
开发者ID:TheDgtl,项目名称:osrose,代码行数:20,代码来源:Monster.cpp


示例9: BEGINPACKET

// Move a mob (specified point)
void CMonster::MoveTo( fPoint nPos, bool randcircle )
{
    if(randcircle) Position->destiny  = GServer->RandInCircle( nPos, 5 );
    else Position->destiny  = nPos;
//    Position->lastMoveTime = clock();
    BEGINPACKET( pak, 0x797 );
	ADDWORD    ( pak, clientid );
	ADDWORD    ( pak, 0x0000 ); // ???
	ADDWORD    ( pak, Stats->Move_Speed );
	ADDFLOAT   ( pak, Position->destiny.x*100 );
	ADDFLOAT   ( pak, Position->destiny.y*100 );
	ADDWORD    ( pak, 0xcdcd );
	//ADDBYTE    ( pak, 0x01 );
	ADDBYTE    ( pak, thisnpc->stance); //AIP
	GServer->SendToVisible(&pak, this );

    if(Position->Map==8)
        Log(MSG_INFO,"MoveTo (%.2f;%.2f) to (%.2f;%.2f)",Position->current.x,Position->current.y,Position->destiny.x,Position->destiny.y);
}
开发者ID:TheDgtl,项目名称:osrose,代码行数:20,代码来源:Monster.cpp


示例10: GETDWORD

// Send server IP
bool CLoginServer::pakGetIP( CLoginClient* thisclient, CPacket* P )
{
	if (!thisclient->isLoggedIn) return false;
	;
	MYSQL_ROW row;
	DWORD servernum = GETDWORD( (*P), 0 );
	BYTE channelnum = GETBYTE( (*P), 4 );

	BEGINPACKET( pak, 0x70a );

	if(!DB->QExecute( "UPDATE accounts SET lastsvr=%i,lastip='%s',lasttime=UNIX_TIMESTAMP( NOW() ) WHERE id=%i", channelnum, inet_ntoa( thisclient->clientinfo.sin_addr ), thisclient->userid))
	   return false;
	MYSQL_RES *result = DB->QStore( "SELECT host,port,lanip,lansubmask FROM channels WHERE id=%i and type=1", servernum );
    if(result==NULL) return false;
	if(mysql_num_rows(result)!=1)
	{
        Log(MSG_WARNING, "Player selected a invalid channel or channel offline" );
        DB->QFree( );
        return true;
    }

	row = mysql_fetch_row(result);
	ADDBYTE( pak, 0 );
	ADDDWORD( pak, thisclient->userid );
	ADDDWORD( pak, 0x87654321 );

	if(strcmp(thisclient->ClientSubNet, row[3])==0)//Lan
	{
        ADDSTRING( pak, row[2] );
    } else if(strcmp( thisclient->ClientSubNet ,"127.0.0")==0) { //localhost
        ADDSTRING( pak, "127.0.0.1" );
    } else {  // Other
        ADDSTRING( pak, row[0] );
    }

	ADDBYTE( pak, 0 );
	ADDWORD( pak, atoi(row[1]) );
	DB->QFree( );
	thisclient->SendPacket ( &pak );
    return true;
}
开发者ID:randybatiquin,项目名称:freerose,代码行数:42,代码来源:loginpackets.cpp


示例11: BEGINPACKET

void CPlayer::UpdateInventory( unsigned int slot1, unsigned int slot2 )
{

    if(slot1 == 0xffff && slot2 == 0xffff) return;              //neither slot is valid
    BEGINPACKET( pak, 0x718 );
    if(slot1 != 0xffff && slot2 != 0xffff) {ADDBYTE( pak, 2 );} //both slots are valid
    else {ADDBYTE( pak, 1 );}                                   //one of the slots is valid
    if(slot1 != 0xffff)
    {
        ADDBYTE    ( pak, slot1);
        ADDWORD    ( pak, GServer->BuildItemHead( items[slot1] ) );
        ADDDWORD   ( pak, GServer->BuildItemData( items[slot1] ) );
    }
    if(slot2 != 0xffff)
    {
        ADDBYTE    ( pak, slot2 );
        ADDWORD    ( pak, GServer->BuildItemHead( items[slot2] ) );
        ADDDWORD   ( pak, GServer->BuildItemData( items[slot2] ) );
    }
    client->SendPacket( &pak );
    
}
开发者ID:osROSE,项目名称:osprose,代码行数:22,代码来源:playerfunctions.cpp


示例12: BEGINPACKET

// convert a monster to other
CMonster* CMap::ConverToMonster( CMonster* monster, UINT newmontype, bool heal )
{
    CNPCData* thisnpc = GServer->GetNPCDataByID( newmontype );
    if(thisnpc==NULL)// invalid type
        return NULL;
    monster->montype = newmontype;
    monster->thisnpc = thisnpc;
    monster->SetStats( );
    if(heal)
        monster->Stats->HP = monster->GetMaxHP();
    if(monster->owner==0)
    {
        monster->MonsterDrop->mobdrop = GServer->GetDropData( monster->thisnpc->dropid );
        monster->MonsterDrop->mapdrop = GServer->GetDropData( id );
    }
    BEGINPACKET( pak, 0x774 );
    ADDWORD    ( pak, monster->clientid );
    ADDWORD    ( pak, newmontype );
    GServer->SendToVisible( &pak, monster );
    monster->OnSpawn( false );
    return monster;
}
开发者ID:RavenX8,项目名称:osirose,代码行数:23,代码来源:mapfunctions.cpp


示例13: BEGINPACKET

// NPC Announce to the server
bool CWorldServer::NPCAnnounce( char* msg, char* npc, int mapid)
{
    //LMA: We only announce in the NPC's map
    //Log(MSG_INFO,"%s announces: %s",npc,msg);
    BEGINPACKET( pak, 0x702 );
    ADDSTRING( pak, npc );
	ADDSTRING( pak, "> " );
	ADDSTRING( pak, msg);
	ADDBYTE( pak, 0x00);

	if(mapid!=0)
	{
	    SendToMap  ( &pak, mapid );
	}
	else
	{
	    SendToAll( &pak );
	}


	return true;
}
开发者ID:TheDgtl,项目名称:osrose,代码行数:23,代码来源:ServerFunctions.cpp


示例14: clock

// HP/MP Regeneration Function
bool CPlayer::Regeneration()
{
    if (Stats->MaxHP == Stats->HP && Stats->MaxMP == Stats->MP)
    {
       lastRegenTime = 0;
       return true;
    }

    bool is_first_regen = false;
    if (lastRegenTime == 0)
    {
       is_first_regen = true;
    }

    clock_t etime = clock() - lastRegenTime;
    if( etime >= 8 * CLOCKS_PER_SEC && Stats->HP > 0 )
    {
        //Log(MSG_INFO,"Regeneration function. Character %i HP on entry %i", clientid, Stats->HP);
        unsigned int hpamount = GetHPRegenAmount( );
        unsigned int mpamount = GetMPRegenAmount( );
        Stats->HP += hpamount;
        Stats->MP += mpamount;
        if( Stats->HP > Stats->MaxHP)
            Stats->HP = Stats->MaxHP;
        if( Stats->MP > Stats->MaxMP )
            Stats->MP = Stats->MaxMP;
        BEGINPACKET( pak, 0x7ec );
	    ADDWORD( pak, Stats->HP);
	    ADDWORD( pak, Stats->MP );
	    client->SendPacket( &pak );

        if (Stats->MaxHP == Stats->HP && Stats->MaxMP == Stats->MP)
           lastRegenTime = 0;
        else
            lastRegenTime = clock();
        //Log(MSG_INFO,"Regeneration function. Character %i HP on exit %i clock time %i", clientid, Stats->HP, lastRegenTime);
    }
    return true;
}
开发者ID:osROSE,项目名称:osprose,代码行数:40,代码来源:playerfunctions.cpp


示例15: BEGINPACKET

void CPlayer::UpdateInventory( unsigned int slot1, unsigned int slot2 )
{

    if(slot1==0xffff && slot2==0xffff) return;
    BEGINPACKET( pak, 0x718 );
    if(slot2!=0xffff && slot2!=0xffff) {ADDBYTE( pak, 2 );}
    else {ADDBYTE( pak, 1 );}
    if(slot1!=0xffff)
    {
        ADDBYTE    ( pak, slot1);
        ADDWORD   ( pak, GServer->BuildItemHead( items[slot1] ) );
        ADDDWORD   ( pak, GServer->BuildItemData( items[slot1] ) );
    }
    if(slot2!=0xffff)
    {
        ADDBYTE    ( pak, slot2 );
        ADDWORD   ( pak, GServer->BuildItemHead( items[slot2] ) );
        ADDDWORD   ( pak, GServer->BuildItemData( items[slot2] ) );
    }
    client->SendPacket( &pak );

}
开发者ID:L3nn0x,项目名称:osirosenew,代码行数:22,代码来源:playerfunctions.cpp


示例16: BEGINPACKET

// Delete a monster
bool CMap::DeleteMonster( CMonster* monster, bool clearobject, UINT i )
{
    if(monster==NULL) return false;
    GServer->ClearClientID( monster->clientid );
    if(monster->Position->respawn!=0)
    {
        CSpawnArea* thisspawn = GServer->GetSpawnArea( monster->Position->respawn, monster->Position->Map );
        if(thisspawn!=NULL)
            thisspawn->amon--;
    }
    if(clearobject)
    {
        BEGINPACKET( pak, 0x799 );
        ADDWORD    ( pak, monster->clientid );
        ADDWORD    ( pak, monster->clientid );
        ADDDWORD   ( pak, monster->Stats->HP );
        ADDDWORD   ( pak, 16 );
        GServer->SendToVisible( &pak, monster );
    }
    if(i!=0)
    {
        MonsterList.erase( MonsterList.begin()+i );
        delete monster;
        return true;
    }
    for(UINT i=0; i<MonsterList.size(); i++)
    {
        CMonster* othermon = MonsterList.at(i);
        if(othermon==monster)
        {
            MonsterList.erase( MonsterList.begin()+i );
            delete monster;
            return true;
        }
    }
    delete monster;
    return false;
}
开发者ID:osROSE,项目名称:osrose,代码行数:39,代码来源:worldmap.cpp


示例17: BEGINPACKET

// convert a monster to other
CMonster* CMap::ConverToMonster( CMonster* monster, UINT newmontype, bool heal )
{
    CNPCData* thisnpc = GServer->GetNPCDataByID( newmontype );
    if(thisnpc == NULL)// invalid type
        return NULL;
    int spawnid = monster->Status->spawnid;
    monster->montype = newmontype;
    monster->thisnpc = thisnpc;
    monster->SetStats( );
    if(heal)
        monster->Stats->HP = monster->Stats->MaxHP;
    if(monster->owner == 0)
    {
        monster->MonsterDrop->mobdrop = GServer->GetDropData( monster->thisnpc->dropid );
        monster->MonsterDrop->mapdrop = GServer->GetDropData( id );
    }
    BEGINPACKET( pak, 0x774 );
    ADDWORD    ( pak, monster->clientid );
    ADDWORD    ( pak, newmontype );
    GServer->SendToVisible( &pak, monster );
    monster->OnSpawn( false );
    monster->Status->spawnid = spawnid; //make sure the monster retains the original spawnid. Don't see why it should be lost though.
    return monster;
}
开发者ID:karlseven,项目名称:ROED,代码行数:25,代码来源:mapfunctions.cpp


示例18: Log

// Return to char select 
bool CCharServer::pakWSCharSelect ( CCharClient* thisclient, CPacket* P )
{
	if(!thisclient->isLoggedIn) return false;    
	Log( MSG_INFO, "World server requested char select" );

	DWORD userid = GETDWORD( (*P), 0 );
	CCharClient* otherclient = GetClientByUserID( userid );
	if(otherclient==NULL)
	{
        Log(MSG_WARNING, "Invalid userid: %i", userid );
	    return true;
    }
	BEGINPACKET( pak, 0x71c );
	ADDBYTE    ( pak, 0x00 );
	otherclient->SendPacket( &pak ); 
    Log( MSG_INFO, "Client returning to char select" );
    RESETPACKET( pak, 0x505 );
    ADDDWORD( pak, thisclient->userid );
    cryptPacket( (char*)&pak, NULL );
    CChanels* thischannel = GetChannelByID( thisclient->channel );
    if(thischannel!=NULL)
        send( thischannel->sock, (char*)&pak, pak.Size, 0 );  	            
	return true;
}
开发者ID:osROSE,项目名称:osrose,代码行数:25,代码来源:charpackets.cpp


示例19: clock


//.........这里部分代码省略.........
    */

    //End debug.

    //Load our Server Info
    LoadQuestSTB();

    //hidden
    // LoadDropsData( );
    // new drops routine load
    LoadPYDropsData( );
    LoadSkillBookDropsData( );
    // end of new drops data

    //LoadChestData( ); //LMA: loaded now by STB in LoadBreakChestBlueList.
    // PY custom events start
    LoadCustomTeleGate( );
    LoadCustomEvents( );
    // PY custom events end
    LoadNPCData( );
    LoadQuestItemData( );
    LoadTeleGateData( );
    LoadRespawnData( );
    LoadMobGroups( );
    LoadMobGroupsSpecial( );    //LMA: Special spawns (Halloween for example).
    LoadNPCs( );
    LoadNPCsSpecial( );  //Special NPC load
    LoadMonsters( );
    LoadUpgrade( );
    LoadLTB();  //LMA: Loading LTB for AIP.
    LoadQuestData( );
    LoadAipData();  //LMA: loading AIP.
    CleanConnectedList( );

    Log(MSG_INFO, "Database Loaded                      " );
    pthread_create( &WorldThread[WORLD_THREAD], &at, WorldProcess, NULL);
    pthread_create( &WorldThread[VISUALITY_THREAD], &at, VisibilityProcess, NULL);
    pthread_create( &MapThread[0], &at, MapProcess, NULL);
    Log (MSG_INFO, "osRose Revision %s", Config.osRoseVer );
    Log( MSG_INFO, "Process Loaded. WorldDelay %i | MapDelay %i | VisualDelay %i",Config.WorldDelay,Config.MapDelay,Config.VisualDelay);
    DB->QExecute( "DELETE FROM channels WHERE id=%u and type=%i", Config.ServerID, Config.ServerType );
    if(!DB->QExecute("INSERT INTO channels (id,type,name,host,port,lanip,lansubmask,connected,maxconnections,owner) VALUES (%i,%i,'%s','%s',%u,'%s','%s',0,%i,%i)",
            Config.ServerID, Config.ServerType, Config.ServerName, Config.WorldIP, Config.WorldPort, Config.LanIP, Config.LanSubnet, Config.MaxConnections, Config.ParentID))
    {
        Log(MSG_WARNING, "Error accessing to database, the other server will not connect to WorldServer" );
    }


	MYSQL_ROW row;
    bool pflag = false;
    //Get IP and Port from Charserver
    MYSQL_RES *result = DB->QStore( "SELECT host,port,lanip FROM channels WHERE id=%u and type=1", Config.ParentID );
    if(result==NULL) return false;
	if (mysql_num_rows( result ) == 1)
	{
    	row = mysql_fetch_row( result );
    	switch(Config.Connection)
    	{
            case 0://wanip
               	Config.CharIP = row[0];
            break;
            case 1://lanip
               	Config.CharIP = row[2];
            break;
            default://localhost
               	Config.CharIP = "127.0.0.1";
            break;
        }
    	Config.CharPort =  atoi(row[1]);
        pflag = true;
    }
    DB->QFree( );
    if(pflag)
    {
        Log(  MSG_INFO, "Initialized Charserver connection" );
    	// Connect To LoginServer
    	csock = socket( AF_INET, SOCK_STREAM, 0 );
    	if (csock == INVALID_SOCKET)
        {
            Log( MSG_WARNING, "Could not access login server" );
        }
    	struct sockaddr_in ain;
    	ain.sin_family		= AF_INET;
       	ain.sin_addr.s_addr	= inet_addr( Config.CharIP );
    	ain.sin_port = htons( Config.CharPort );
    	if ( connect( csock, (SOCKADDR*) &ain, sizeof(ain) ) == SOCKET_ERROR )
    		Log( MSG_WARNING, "Could not access charserver" );
    	BEGINPACKET( pak, 0x500 );
        ADDDWORD   ( pak, Config.CharPass );
        ADDDWORD   ( pak, Config.ServerID );
        ADDWORD    ( pak, Config.WorldPort );
    	cryptPacket( (char*)&pak, NULL );
    	send( csock, (char*)&pak, pak.Size, 0 );
    }

	float loadtime = (float)( clock() - timer ) / CLOCKS_PER_SEC;
	Log(  MSG_INFO, "Server took %.4f seconds to load", loadtime );

	return true;
}
开发者ID:TheDgtl,项目名称:osrose,代码行数:101,代码来源:worldserver.cpp


示例20: BEGINPACKET

// This cleans up our clients mess :P
void CWorldServer::OnClientDisconnect( CClientSocket* thisclient )
{
    if(thisclient->player==NULL) return;
	CPlayer* player = (CPlayer*)thisclient->player;
	if(!player->Session->isLoggedIn) return;
    if(!player->Saved)
    {
    	player->savedata();
        player->Session->isLoggedIn = false;
        //send packet to change messenger status (offline)
    	BEGINPACKET( pak, 0x7e1 );
    	ADDBYTE    ( pak, 0xfa );
    	ADDWORD    ( pak, player->CharInfo->charid );
    	ADDBYTE    ( pak, 0x00 );
    	cryptPacket( (char*)&pak, NULL );
    	send( csock, (char*)&pak, pak.Size, 0 );
    }
    if ( player->Fairy )
    {
        FairyList.at(player->FairyListIndex)->assigned = false;
        FairyList.at(player->FairyListIndex)->LastTime = clock();
        FairyList.at(player->FairyListIndex)->ListIndex = 0;
        FairyList.at(player->FairyListIndex)->WaitTime = Config.FairyWait * (rand()% GetFairyRange(1)+ GetFairyRange(0));
        player->Fairy = false;
        player->FairyListIndex = 0;
        DoFairyStuff(player, 0);
        // recalculate FairyMax
        Config.FairyMax = (int)ceil((float)ClientList.size() / 50.0); //(1 fairy more every 50 player)
    }
    if(player->Party->party!=NULL)
    {
        CParty* party = player->Party->party;
        BEGINPACKET( pak, 0x7d2 );
        ADDWORD    ( pak, 0xff00 );
        ADDDWORD   ( pak, player->CharInfo->charid );
        bool pflag = false;
        party->RemovePlayer( player );
        if(party->Members.size()>1)
        {
            for(UINT i=0;i<party->Members.size();i++)
            {
                CPlayer* othermember = party->Members.at(i);
                if(!pflag)
                {
                    ADDDWORD( pak, othermember->CharInfo->charid );
                    if(player->Party->IsMaster)
                        othermember->Party->IsMaster = true;
                    pflag = true;
                }
                othermember->client->SendPacket( &pak );
            }
        }
        else
        {
            for(UINT i=0;i<party->Members.size();i++)
            {
                CPlayer* othermember = party->Members.at(i);
                BEGINPACKET( pak, 0x7d1 );
                ADDBYTE    ( pak, 0x05 );
                ADDWORD    ( pak, 0x0000 );
                ADDWORD    ( pak, 0x0000 );
                othermember->client->SendPacket( &pak );
                othermember->Party->party = NULL;
                othermember->Party->IsMaster = true;
            }
            RemoveParty( party );
            delete party;
            party = NULL;
        }
    }
    DB->QExecute("UPDATE accounts SET online=false where id=%u", player->Session->userid );
}
开发者ID:TheDgtl,项目名称:osrose,代码行数:73,代码来源:worldserver.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ BEGIN_BATCH_NO_AUTOSTATE函数代码示例发布时间:2022-05-30
下一篇:
C++ BEFS_SB函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap