本文整理汇总了C++中BEGINPACKET函数的典型用法代码示例。如果您正苦于以下问题:C++ BEGINPACKET函数的具体用法?C++ BEGINPACKET怎么用?C++ BEGINPACKET使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了BEGINPACKET函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}
示例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 );
}
示例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;
}
示例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;
}
示例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;
}
示例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 );
}